YAZ  5.34.0
srwutil.c
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12 
13 #include <stdlib.h>
14 #include <assert.h>
15 #include <yaz/srw.h>
16 #include <yaz/matchstr.h>
17 #include <yaz/base64.h>
18 #include <yaz/yaz-iconv.h>
19 #include "sru-p.h"
20 
21 #define MAX_SRU_PARAMETERS 30
22 
24  const char *n, const char *v)
25 {
26  if (n && v && *v != '\0')
27  {
28  while (*l)
29  l = &(*l)->next;
30  *l = (Z_SRW_extra_arg *) odr_malloc(odr, sizeof(**l));
31  (*l)->name = odr_strdup(odr, n);
32  (*l)->value = odr_strdup(odr, v);
33  (*l)->next = 0;
34  l = &(*l)->next;
35  }
36  return l;
37 }
38 
40  const char *n, Odr_int *v)
41 {
42  if (v)
43  {
44  char str[32];
45  sprintf(str, ODR_INT_PRINTF, *v);
46  l = append_extra_arg(odr, l, n, str);
47  }
48  return l;
49 }
50 
51 static char *yaz_decode_sru_dbpath_odr(ODR n, const char *uri, size_t len)
52 {
53  return odr_strdupn(n, uri, len);
54 }
55 
56 void yaz_encode_sru_dbpath_buf(char *dst, const char *db)
57 {
58  assert(db);
59  *dst = '/';
60  strcpy(dst+1, db);
61 }
62 
63 char *yaz_encode_sru_dbpath_odr(ODR out, const char *db)
64 {
65  char *dst = odr_malloc(out, 3 * strlen(db) + 2);
67  return dst;
68 }
69 
70 #if YAZ_HAVE_XML2
71 const char *yaz_element_attribute_value_get(xmlNodePtr ptr,
72  const char *node_name,
73  const char *attribute_name)
74 {
75  struct _xmlAttr *attr;
76  if (strcmp((const char*) ptr->name, node_name))
77  return 0;
78  for (attr = ptr->properties; attr; attr = attr->next)
79  if (attr->children && attr->children->type == XML_TEXT_NODE)
80  {
81  if (!strcmp((const char *) attr->name, attribute_name))
82  return (const char *) attr->children->content;
83  }
84  return 0;
85 }
86 #endif
87 
89 {
90  const char *content_type = z_HTTP_header_lookup(hres->headers,
91  "Content-Type");
92  if (content_type)
93  {
94  if (!yaz_strcmp_del("text/xml", content_type, "; "))
95  return 1;
96  if (!yaz_strcmp_del("application/xml", content_type, "; "))
97  return 1;
98  if (!yaz_strcmp_del("application/sru+xml", content_type, "; "))
99  return 1;
100  }
101  return 0;
102 }
103 
109  char *username, char *password, ODR decode)
110 {
111  const char *basic = z_HTTP_header_lookup(hreq->headers, "Authorization");
112 
113  if (username)
114  sr->username = username;
115  if (password)
116  sr->password = password;
117 
118  if (basic)
119  {
120  int len;
121  char out[256];
122  char ubuf[256] = "", pbuf[256] = "", *p;
123  if (strncmp(basic, "Basic ", 6))
124  return;
125  basic += 6;
126  len = strlen(basic);
127  if (!len || len > 256)
128  return;
129  yaz_base64decode(basic, out);
130  /* Format of out should be username:password at this point */
131  strcpy(ubuf, out);
132  if ((p = strchr(ubuf, ':')))
133  {
134  *(p++) = '\0';
135  if (*p)
136  strcpy(pbuf, p);
137  }
138  if (*ubuf)
139  sr->username = odr_strdup(decode, ubuf);
140  if (*pbuf)
141  sr->password = odr_strdup(decode, pbuf);
142  }
143 }
144 
146  const char *uri, const char *message,
147  const char *details)
148 {
149  d->uri = odr_strdup(o, uri);
150  if (message)
151  d->message = odr_strdup(o, message);
152  else
153  d->message = 0;
154  if (details)
155  d->details = odr_strdup(o, details);
156  else
157  d->details = 0;
158 }
159 
161  int code, const char *details)
162 {
163  char uri[40];
164 
165  sprintf(uri, "info:srw/diagnostic/1/%d", code);
166  yaz_mk_srw_diagnostic(o, d, uri, 0, details);
167 }
168 
170  int *num, const char *uri,
171  const char *message, const char *details)
172 {
173  Z_SRW_diagnostic *d_new;
174  d_new = (Z_SRW_diagnostic *) odr_malloc(o, (*num + 1)* sizeof(**d));
175  if (*num)
176  memcpy(d_new, *d, *num *sizeof(**d));
177  *d = d_new;
178 
179  yaz_mk_srw_diagnostic(o, *d + *num, uri, message, details);
180  (*num)++;
181 }
182 
184  int *num, int code, const char *addinfo)
185 {
186  char uri[40];
187 
188  sprintf(uri, "info:srw/diagnostic/1/%d", code);
189  yaz_add_srw_diagnostic_uri(o, d, num, uri, 0, addinfo);
190 }
191 
192 
194  int *num, int code, const char *addinfo)
195 {
196  char uri[40];
197 
198  sprintf(uri, "info:srw/diagnostic/12/%d", code);
199  yaz_add_srw_diagnostic_uri(o, d, num, uri, 0, addinfo);
200 }
201 
202 
203 void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos,
204  int code, const char *details)
205 {
206  const char *message = yaz_diag_srw_str(code);
207  int len = 200;
208  if (message)
209  len += strlen(message);
210  if (details)
211  len += strlen(details);
212 
213  record->recordData_buf = (char *) odr_malloc(o, len);
214 
215  sprintf(record->recordData_buf, "<diagnostic "
216  "xmlns=\"http://www.loc.gov/zing/srw/diagnostic/\">\n"
217  " <uri>info:srw/diagnostic/1/%d</uri>\n", code);
218  if (details)
219  sprintf(record->recordData_buf + strlen(record->recordData_buf),
220  " <details>%s</details>\n", details);
221  if (message)
222  sprintf(record->recordData_buf + strlen(record->recordData_buf),
223  " <message>%s</message>\n", message);
224  sprintf(record->recordData_buf + strlen(record->recordData_buf),
225  "</diagnostic>\n");
226  record->recordData_len = strlen(record->recordData_buf);
227  record->recordPosition = odr_intdup(o, pos);
228  record->recordSchema = "info:srw/schema/1/diagnostics-v1.1";
229 }
230 
231 static void grab_charset(ODR o, const char *content_type, char **charset)
232 {
233  if (charset)
234  {
235  const char *charset_p = 0;
236  if (content_type && (charset_p = strstr(content_type, "; charset=")))
237  {
238  int j = 0, i = 0;
239  int sep = 0;
240  charset_p += 10; /* skip ; charset= */
241  if (charset_p[i] == '"' || charset_p[i] == '\'')
242  sep = charset_p[i++];
243  *charset = odr_strdup(o, charset_p);
244  while (charset_p[i] && charset_p[i] != sep)
245  {
246  if (!sep && strchr("; \n\r", charset_p[i]))
247  break;
248  if (charset_p[i] == '\\' && charset_p[i+1])
249  i++;
250  (*charset)[j++] = charset_p[i++];
251  }
252  (*charset)[j] = '\0';
253  }
254  }
255 }
256 
258  Z_SOAP **soap_package, ODR decode, char **charset)
259 {
260  if (!strcmp(hreq->method, "POST"))
261  {
262  const char *content_type = z_HTTP_header_lookup(hreq->headers,
263  "Content-Type");
264  if (content_type &&
265  (!yaz_strcmp_del("text/xml", content_type, "; ") ||
266  !yaz_strcmp_del("application/soap+xml", content_type, "; ") ||
267  !yaz_strcmp_del("text/plain", content_type, "; ")))
268  {
269  char *db = "Default";
270  const char *p0 = hreq->path, *p1;
271  int ret = -1;
272 
273  static Z_SOAP_Handler soap_handlers[5] = {
274 #if YAZ_HAVE_XML2
279 #endif
280  {0, 0, 0}
281  };
282 
283  if (*p0 == '/')
284  p0++;
285  p1 = strchr(p0, '?');
286  if (!p1)
287  p1 = p0 + strlen(p0);
288  if (p1 != p0)
289  db = yaz_decode_sru_dbpath_odr(decode, p0, p1 - p0);
290 
291  ret = z_soap_codec(decode, soap_package,
292  &hreq->content_buf, &hreq->content_len,
293  soap_handlers);
294  if (ret == 0 && (*soap_package)->which == Z_SOAP_generic)
295  {
296  *srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
297  yaz_srw_decodeauth(*srw_pdu, hreq, 0, 0, decode);
298 
299  /* last entry in handlers - SRU 2.0 - is turned into
300  offset 0.. due to other pieces relying on it */
301  if ((*soap_package)->u.generic->no == 3)
302  (*soap_package)->u.generic->no = 0;
303  if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
304  (*srw_pdu)->u.request->database == 0)
305  (*srw_pdu)->u.request->database = db;
306 
307  if ((*srw_pdu)->which == Z_SRW_explain_request &&
308  (*srw_pdu)->u.explain_request->database == 0)
309  (*srw_pdu)->u.explain_request->database = db;
310 
311  if ((*srw_pdu)->which == Z_SRW_scan_request &&
312  (*srw_pdu)->u.scan_request->database == 0)
313  (*srw_pdu)->u.scan_request->database = db;
314 
315  if ((*srw_pdu)->which == Z_SRW_update_request &&
316  (*srw_pdu)->u.update_request->database == 0)
317  (*srw_pdu)->u.update_request->database = db;
318 
319  return 0;
320  }
321  return 1;
322  }
323  }
324  return 2;
325 }
326 
327 #if YAZ_HAVE_XML2
328 static int yaz_sru_decode_integer(ODR odr, const char *pname,
329  const char *valstr, Odr_int **valp,
330  Z_SRW_diagnostic **diag, int *num_diag,
331  int min_value)
332 {
333  int ival;
334  if (!valstr)
335  return 0;
336  if (sscanf(valstr, "%d", &ival) != 1)
337  {
338  yaz_add_srw_diagnostic(odr, diag, num_diag,
340  return 0;
341  }
342  if (min_value >= 0 && ival < min_value)
343  {
344  yaz_add_srw_diagnostic(odr, diag, num_diag,
346  return 0;
347  }
348  *valp = odr_intdup(odr, ival);
349  return 1;
350 }
351 #endif
352 
357  Z_SOAP **soap_package, ODR decode, char **charset,
358  Z_SRW_diagnostic **diag, int *num_diag)
359 {
360 #if YAZ_HAVE_XML2
361  static Z_SOAP_Handler soap_handlers[2] = {
363  {0, 0, 0}
364  };
365 #endif
366  const char *content_type = z_HTTP_header_lookup(hreq->headers,
367  "Content-Type");
368 
369  /*
370  SRU GET: ignore content type.
371  SRU POST: we support "application/x-www-form-urlencoded";
372  not "multipart/form-data" .
373  */
374  if (!strcmp(hreq->method, "GET")
375  ||
376  (!strcmp(hreq->method, "POST") && content_type &&
377  !yaz_strcmp_del("application/x-www-form-urlencoded",
378  content_type, "; ")))
379  {
380  char *db = "Default";
381  const char *p0 = hreq->path, *p1;
382 #if YAZ_HAVE_XML2
383  const char *operation = 0;
384  char *version = 0;
385  char *query = 0;
386  char *queryType = "cql";
387  char *username = 0;
388  char *password = 0;
389  char *sortKeys = 0;
390  char *stylesheet = 0;
391  char *scanClause = 0;
392  char *recordXPath = 0;
393  char *recordSchema = 0;
394  char *recordXMLEscaping = 0;
395  char *recordPacking = 0;
396  char *maximumRecords = 0;
397  char *startRecord = 0;
398  char *maximumTerms = 0;
399  char *responsePosition = 0;
400  const char *facetLimit = 0;
401  const char *facetStart = 0;
402  const char *facetSort = 0;
403  Z_SRW_extra_arg *extra_args = 0;
404 #endif
405  char **uri_name;
406  char **uri_val;
407 
408  grab_charset(decode, content_type, charset);
409  if (charset && *charset == 0 && !strcmp(hreq->method, "GET"))
410  *charset = "UTF-8";
411 
412  if (*p0 == '/')
413  p0++;
414  p1 = strchr(p0, '?');
415  if (!p1)
416  p1 = p0 + strlen(p0);
417  if (p1 != p0)
418  db = yaz_decode_sru_dbpath_odr(decode, p0, p1 - p0);
419  if (!strcmp(hreq->method, "POST") && hreq->content_buf)
420  p1 = hreq->content_buf;
421  yaz_uri_to_array(p1, decode, &uri_name, &uri_val);
422 #if YAZ_HAVE_XML2
423  if (uri_name)
424  {
425  int i;
426  for (i = 0; uri_name[i]; i++)
427  {
428  char *n = uri_name[i];
429  char *v = uri_val[i];
430  if (!strcmp(n, "query"))
431  query = v;
432  else if (!strcmp(n, "x-pquery"))
433  {
434  query = v;
435  queryType = "pqf";
436  }
437  else if (!strcmp(n, "queryType"))
438  queryType = v;
439  else if (!strcmp(n, "x-username"))
440  username = v;
441  else if (!strcmp(n, "x-password"))
442  password = v;
443  else if (!strcmp(n, "operation"))
444  operation = v;
445  else if (!strcmp(n, "stylesheet"))
446  stylesheet = v;
447  else if (!strcmp(n, "sortKeys"))
448  sortKeys = v;
449  else if (!strcmp(n, "recordXPath"))
450  recordXPath = v;
451  else if (!strcmp(n, "recordSchema"))
452  recordSchema = v;
453  else if (!strcmp(n, "recordPacking"))
454  recordPacking = v;
455  else if (!strcmp(n, "recordXMLEscaping"))
456  recordXMLEscaping = v;
457  else if (!strcmp(n, "version"))
458  version = v;
459  else if (!strcmp(n, "scanClause"))
460  scanClause = v;
461  else if (!strcmp(n, "x-pScanClause"))
462  {
463  scanClause = v;
464  queryType = "pqf";
465  }
466  else if (!strcmp(n, "maximumRecords"))
467  maximumRecords = v;
468  else if (!strcmp(n, "startRecord"))
469  startRecord = v;
470  else if (!strcmp(n, "maximumTerms"))
471  maximumTerms = v;
472  else if (!strcmp(n, "responsePosition"))
473  responsePosition = v;
474  else if (!strcmp(n, "facetLimit"))
475  facetLimit = v;
476  else if (!strcmp(n, "facetStart"))
477  facetStart = v;
478  else if (!strcmp(n, "facetSort"))
479  facetSort = v;
480  else if (!strcmp(n, "extraRequestData"))
481  ; /* ignoring extraRequestData */
482  else if (n[0] == 'x' && n[1] == '-')
483  {
484  append_extra_arg(decode, &extra_args, n, v);
485  }
486  else
487  {
488  if (*num_diag < 10)
489  yaz_add_srw_diagnostic(decode, diag, num_diag,
491  }
492  }
493  }
494  if (!operation)
495  {
496  if (query)
497  operation = "searchRetrieve";
498  else if (scanClause)
499  operation = "scan";
500  else
501  operation = "explain";
502  }
503  version = yaz_negotiate_sru_version(version);
504 
505  if (!version)
506  { /* negotiation failed. */
507  yaz_add_srw_diagnostic(decode, diag, num_diag,
508  YAZ_SRW_UNSUPP_VERSION, "2.0");
509  version = "2.0";
510  }
511  if (!operation)
512  {
513  if (uri_name)
515  decode, diag, num_diag,
517  operation = "explain";
518  }
519  if (strcmp(version, "2.0"))
520  {
521  if (recordXMLEscaping)
522  {
523  yaz_add_srw_diagnostic(decode, diag, num_diag,
525  "recordXMLEscaping");
526 
527  }
528  recordXMLEscaping = recordPacking;
529  recordPacking = "packed";
530  }
531  if (!recordXMLEscaping)
532  recordXMLEscaping = "xml";
533  if (!strcmp(operation, "searchRetrieve"))
534  {
536 
537  sr->srw_version = version;
538  sr->extra_args = extra_args;
539  *srw_pdu = sr;
540  yaz_srw_decodeauth(sr, hreq, username, password, decode);
541 
542  sr->u.request->queryType = queryType;
543  sr->u.request->query = query;
544 
545  if (!query)
547  decode, diag, num_diag,
549 
550  if (sortKeys)
551  {
553  sr->u.request->sort.sortKeys = sortKeys;
554  }
555  sr->u.request->recordXPath = recordXPath;
556  sr->u.request->recordSchema = recordSchema;
557  sr->u.request->recordPacking = recordXMLEscaping;
558  sr->u.request->packing = recordPacking;
559  sr->u.request->stylesheet = stylesheet;
560  yaz_sru_facet_request(decode , &sr->u.request->facetList,
561  &facetLimit, &facetStart, &facetSort);
562 
563  yaz_sru_decode_integer(decode, "maximumRecords", maximumRecords,
564  &sr->u.request->maximumRecords,
565  diag, num_diag, 0);
566 
567  yaz_sru_decode_integer(decode, "startRecord", startRecord,
568  &sr->u.request->startRecord,
569  diag, num_diag, 1);
570 
571  sr->u.request->database = db;
572 
573  (*soap_package) = (Z_SOAP *)
574  odr_malloc(decode, sizeof(**soap_package));
575  (*soap_package)->which = Z_SOAP_generic;
576 
577  (*soap_package)->u.generic = (Z_SOAP_Generic *)
578  odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
579 
580  (*soap_package)->u.generic->p = sr;
581  (*soap_package)->u.generic->ns = soap_handlers[0].ns;
582  (*soap_package)->u.generic->no = 0;
583 
584  (*soap_package)->ns = "SRU";
585 
586  return 0;
587  }
588  else if (!strcmp(operation, "explain"))
589  {
590  /* Transfer SRU explain parameters to common struct */
591  /* http://www.loc.gov/standards/sru/explain/ */
592  /* http://zeerex.z3950.org/overview/ */
594 
595  sr->srw_version = version;
596  sr->extra_args = extra_args;
597  yaz_srw_decodeauth(sr, hreq, username, password, decode);
598  *srw_pdu = sr;
599  sr->u.explain_request->recordPacking = recordXMLEscaping;
600  sr->u.explain_request->packing = recordPacking;
601  sr->u.explain_request->database = db;
602 
603  sr->u.explain_request->stylesheet = stylesheet;
604 
605  (*soap_package) = (Z_SOAP *)
606  odr_malloc(decode, sizeof(**soap_package));
607  (*soap_package)->which = Z_SOAP_generic;
608 
609  (*soap_package)->u.generic = (Z_SOAP_Generic *)
610  odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
611 
612  (*soap_package)->u.generic->p = sr;
613  (*soap_package)->u.generic->ns = soap_handlers[0].ns;
614  (*soap_package)->u.generic->no = 0;
615 
616  (*soap_package)->ns = "SRU";
617 
618  return 0;
619  }
620  else if (!strcmp(operation, "scan"))
621  {
622  /* Transfer SRU scan parameters to common struct */
623  /* http://www.loc.gov/standards/sru/companionSpecs/scan.html */
625 
626  sr->srw_version = version;
627  sr->extra_args = extra_args;
628  *srw_pdu = sr;
629  yaz_srw_decodeauth(sr, hreq, username, password, decode);
630 
631  sr->u.scan_request->queryType = queryType;
632  sr->u.scan_request->scanClause = scanClause;
633 
634  if (!scanClause)
636  decode, diag, num_diag,
638  sr->u.scan_request->database = db;
639 
640  yaz_sru_decode_integer(decode, "maximumTerms",
641  maximumTerms,
643  diag, num_diag, 0);
644 
645  yaz_sru_decode_integer(decode, "responsePosition",
646  responsePosition,
648  diag, num_diag, 0);
649 
650  sr->u.scan_request->stylesheet = stylesheet;
651 
652  (*soap_package) = (Z_SOAP *)
653  odr_malloc(decode, sizeof(**soap_package));
654  (*soap_package)->which = Z_SOAP_generic;
655 
656  (*soap_package)->u.generic = (Z_SOAP_Generic *)
657  odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
658 
659  (*soap_package)->u.generic->p = sr;
660  (*soap_package)->u.generic->ns = soap_handlers[0].ns;
661  (*soap_package)->u.generic->no = 0;
662 
663  (*soap_package)->ns = "SRU";
664 
665  return 0;
666  }
667  else
668  {
669  /* unsupported operation ... */
670  /* Act as if we received a explain request and throw diagnostic. */
671 
673 
674  sr->srw_version = version;
675  *srw_pdu = sr;
676  sr->u.explain_request->recordPacking = recordPacking;
677  sr->u.explain_request->database = db;
678 
679  sr->u.explain_request->stylesheet = stylesheet;
680 
681  (*soap_package) = (Z_SOAP *)
682  odr_malloc(decode, sizeof(**soap_package));
683  (*soap_package)->which = Z_SOAP_generic;
684 
685  (*soap_package)->u.generic = (Z_SOAP_Generic *)
686  odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
687 
688  (*soap_package)->u.generic->p = sr;
689  (*soap_package)->u.generic->ns = soap_handlers[0].ns;
690  (*soap_package)->u.generic->no = 0;
691 
692  (*soap_package)->ns = "SRU";
693 
694  yaz_add_srw_diagnostic(decode, diag, num_diag,
695  YAZ_SRW_UNSUPP_OPERATION, operation);
696  return 0;
697  }
698 #else
699  return 1;
700 #endif
701  }
702  return 2;
703 }
704 
706 {
708  odr_malloc(o, sizeof(*res));
709 
710  res->extraRecordData_buf = 0;
711  res->extraRecordData_len = 0;
712  res->recordIdentifier = 0;
713  return res;
714 }
715 
716 
718 {
719  Z_SRW_record *res = (Z_SRW_record *) odr_malloc(o, n * sizeof(*res));
720  int i;
721 
722  for (i = 0; i<n; i++)
723  {
724  res[i].recordSchema = 0;
726  res[i].recordData_buf = 0;
727  res[i].recordData_len = 0;
728  res[i].recordPosition = 0;
729  }
730  return res;
731 }
732 
734 {
735  return yaz_srw_get_records(o, 1);
736 }
737 
738 static Z_SRW_PDU *yaz_srw_get_core_ver(ODR o, const char *version)
739 {
740  Z_SRW_PDU *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(*p));
741  p->srw_version = odr_strdup(o, version);
742  p->username = 0;
743  p->password = 0;
744  p->extra_args = 0;
745  p->extraResponseData_buf = 0;
746  p->extraResponseData_len = 0;
747  return p;
748 }
749 
751 {
752  return yaz_srw_get_core_ver(o, "2.0");
753 }
754 
755 Z_SRW_PDU *yaz_srw_get(ODR o, int which)
756 {
757  return yaz_srw_get_pdu(o, which, "2.0");
758 }
759 
760 /* http://docs.oasis-open.org/search-ws/searchRetrieve/v1.0/os/schemas/sruResponse.xsd */
762 {
763  int version2 = !req->srw_version || strcmp(req->srw_version, "2.") > 0;
764  Z_SRW_PDU *res = yaz_srw_get_pdu(o, which, req->srw_version);
765  Z_SRW_extra_arg **l = &res->extra_args, *ea;
766  l = append_extra_arg(o, l, "version", req->srw_version);
767  if (req->which == Z_SRW_searchRetrieve_request &&
769  {
770  if (req->u.request->queryType &&
771  strcmp(req->u.request->queryType, "cql"))
772  l = append_extra_arg(o, l, "queryType", req->u.request->queryType);
773  l = append_extra_arg(o, l, "query", req->u.request->query);
774  l = append_extra_arg_int(o, l, "startRecord",
775  req->u.request->startRecord);
776  l = append_extra_arg_int(o, l, "maximumRecords",
777  req->u.request->maximumRecords);
778  if (version2)
779  {
780  l = append_extra_arg(o, l, "recordXMLEscaping",
781  req->u.request->recordPacking);
782  l = append_extra_arg(o, l, "recordPacking",
783  req->u.request->packing);
784  }
785  else
786  l = append_extra_arg(o, l, "recordPacking",
787  req->u.request->recordPacking);
788  l = append_extra_arg(o, l, "recordSchema",
789  req->u.request->recordSchema);
791  l = append_extra_arg(o, l, "sortKeys",
792  req->u.request->sort.sortKeys);
793  l = append_extra_arg(o, l, "stylesheet", req->u.request->stylesheet);
794  }
795  if (req->which == Z_SRW_explain_request &&
796  which == Z_SRW_explain_response)
797  {
798  if (version2)
799  {
800  l = append_extra_arg(o, l, "recordXMLEscaping",
802  l = append_extra_arg(o, l, "recordPacking",
803  req->u.explain_request->packing);
804  }
805  else
806  l = append_extra_arg(o, l, "recordPacking",
808  l = append_extra_arg(o, l, "stylesheet",
810  }
811  for (ea = req->extra_args; ea; ea = ea->next)
812  l = append_extra_arg(o, l, ea->name, ea->value);
813  return res;
814 }
815 
816 Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version)
817 {
818  Z_SRW_PDU *sr = yaz_srw_get_core_ver(o, version);
819 
820  sr->which = which;
821  switch (which)
822  {
825  odr_malloc(o, sizeof(*sr->u.request));
826  sr->u.request->queryType = "cql";
827  sr->u.request->query = 0;
829  sr->u.request->sort.none = 0;
830  sr->u.request->startRecord = 0;
831  sr->u.request->maximumRecords = 0;
832  sr->u.request->recordSchema = 0;
833  sr->u.request->recordPacking = 0;
834  sr->u.request->packing = 0;
835  sr->u.request->recordXPath = 0;
836  sr->u.request->database = 0;
837  sr->u.request->resultSetTTL = 0;
838  sr->u.request->stylesheet = 0;
839  sr->u.request->facetList = 0;
840  break;
843  odr_malloc(o, sizeof(*sr->u.response));
844  sr->u.response->numberOfRecords = 0;
846  sr->u.response->resultSetId = 0;
847  sr->u.response->resultSetIdleTime = 0;
848  sr->u.response->records = 0;
849  sr->u.response->num_records = 0;
850  sr->u.response->diagnostics = 0;
851  sr->u.response->num_diagnostics = 0;
852  sr->u.response->nextRecordPosition = 0;
853  sr->u.response->extra_records = 0;
854  sr->u.response->facetList = 0;
855  sr->u.response->suggestions = 0;
856  break;
859  odr_malloc(o, sizeof(*sr->u.explain_request));
861  sr->u.explain_request->packing = 0;
862  sr->u.explain_request->database = 0;
863  sr->u.explain_request->stylesheet = 0;
864  break;
867  odr_malloc(o, sizeof(*sr->u.explain_response));
874  sr->u.explain_response->diagnostics = 0;
877  break;
878  case Z_SRW_scan_request:
880  odr_malloc(o, sizeof(*sr->u.scan_request));
881  sr->u.scan_request->database = 0;
882  sr->u.scan_request->stylesheet = 0;
883  sr->u.scan_request->maximumTerms = 0;
885  sr->u.scan_request->queryType = "cql";
886  sr->u.scan_request->scanClause = 0;
887  break;
888  case Z_SRW_scan_response:
890  odr_malloc(o, sizeof(*sr->u.scan_response));
891  sr->u.scan_response->terms = 0;
892  sr->u.scan_response->num_terms = 0;
893  sr->u.scan_response->diagnostics = 0;
895  break;
898  odr_malloc(o, sizeof(*sr->u.update_request));
899  sr->u.update_request->database = 0;
900  sr->u.update_request->stylesheet = 0;
901  sr->u.update_request->record = 0;
902  sr->u.update_request->recordId = 0;
905  sr->u.update_request->extra_record = 0;
908  sr->u.request->database = 0;
909  break;
912  odr_malloc(o, sizeof(*sr->u.update_response));
914  sr->u.update_response->recordId = 0;
917  sr->u.update_response->record = 0;
918  sr->u.update_response->extra_record = 0;
921  sr->u.update_response->diagnostics = 0;
923  }
924  return sr;
925 }
926 
927 void yaz_add_name_value_int(ODR o, char **name, char **value, int *i,
928  char *a_name, Odr_int *val)
929 {
930  if (val)
931  {
932  name[*i] = a_name;
933  value[*i] = (char *) odr_malloc(o, 40);
934  sprintf(value[*i], ODR_INT_PRINTF, *val);
935  (*i)++;
936  }
937 }
938 
939 void yaz_add_name_value_str(ODR o, char **name, char **value, int *i,
940  char *a_name, char *val)
941 {
942  if (val)
943  {
944  name[*i] = a_name;
945  value[*i] = val;
946  (*i)++;
947  }
948 }
949 
950 static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode,
951  char **name, char **value, int max_names)
952 {
953  int version2 = strcmp(srw_pdu->srw_version, "2.") > 0;
954  int i = 0;
955  char *queryType;
956  yaz_add_name_value_str(encode, name, value, &i, "version",
957  srw_pdu->srw_version);
958  name[i] = "operation";
959  switch (srw_pdu->which)
960  {
962  value[i++] = "searchRetrieve";
963  queryType = srw_pdu->u.request->queryType;
964  if (version2)
965  {
966  if (queryType && strcmp(queryType, "cql"))
967  yaz_add_name_value_str(encode, name, value, &i, "queryType",
968  queryType);
969  yaz_add_name_value_str(encode, name, value, &i, "query",
970  srw_pdu->u.request->query);
971  }
972  else
973  {
974  if (!strcmp(queryType, "cql"))
975  {
976  yaz_add_name_value_str(encode, name, value, &i, "query",
977  srw_pdu->u.request->query);
978  }
979  else if (!strcmp(queryType, "pqf"))
980  {
981  yaz_add_name_value_str(encode, name, value, &i, "x-pquery",
982  srw_pdu->u.request->query);
983  }
984  else if (!strcmp(queryType, "xcql"))
985  {
986  yaz_add_name_value_str(encode, name, value, &i, "x-cql",
987  srw_pdu->u.request->query);
988  }
989  }
990  switch (srw_pdu->u.request->sort_type)
991  {
993  break;
995  yaz_add_name_value_str(encode, name, value, &i, "sortKeys",
996  srw_pdu->u.request->sort.sortKeys);
997  break;
998  }
999  yaz_add_name_value_int(encode, name, value, &i, "startRecord",
1000  srw_pdu->u.request->startRecord);
1001  yaz_add_name_value_int(encode, name, value, &i, "maximumRecords",
1002  srw_pdu->u.request->maximumRecords);
1003  yaz_add_name_value_str(encode, name, value, &i, "recordSchema",
1004  srw_pdu->u.request->recordSchema);
1005  if (version2)
1006  {
1007  yaz_add_name_value_str(encode, name, value, &i, "recordXMLEscaping",
1008  srw_pdu->u.request->recordPacking);
1009  yaz_add_name_value_str(encode, name, value, &i, "recordPacking",
1010  srw_pdu->u.request->packing);
1011  }
1012  else
1013  yaz_add_name_value_str(encode, name, value, &i, "recordPacking",
1014  srw_pdu->u.request->recordPacking);
1015  yaz_add_name_value_str(encode, name, value, &i, "recordXPath",
1016  srw_pdu->u.request->recordXPath);
1017  yaz_add_name_value_str(encode, name, value, &i, "stylesheet",
1018  srw_pdu->u.request->stylesheet);
1019  yaz_add_name_value_int(encode, name, value, &i, "resultSetTTL",
1020  srw_pdu->u.request->resultSetTTL);
1021  {
1022  const char *facetLimit = 0;
1023  const char *facetStart = 0;
1024  const char *facetSort = 0;
1025  yaz_sru_facet_request(encode, &srw_pdu->u.request->facetList,
1026  &facetLimit, &facetStart, &facetSort);
1027  yaz_add_name_value_str(encode, name, value, &i, "facetLimit",
1028  (char *) facetLimit);
1029  yaz_add_name_value_str(encode, name, value, &i, "facetStart",
1030  (char *) facetStart);
1031  yaz_add_name_value_str(encode, name, value, &i, "facetSort",
1032  (char *) facetSort);
1033  }
1034  break;
1035  case Z_SRW_explain_request:
1036  value[i++] = "explain";
1037 
1038  if (version2)
1039  {
1040  yaz_add_name_value_str(encode, name, value, &i, "recordXMLEscaping",
1041  srw_pdu->u.explain_request->recordPacking);
1042  yaz_add_name_value_str(encode, name, value, &i, "recordPacking",
1043  srw_pdu->u.explain_request->packing);
1044  }
1045  else
1046  yaz_add_name_value_str(encode, name, value, &i, "recordPacking",
1047  srw_pdu->u.explain_request->recordPacking);
1048  yaz_add_name_value_str(encode, name, value, &i, "stylesheet",
1049  srw_pdu->u.explain_request->stylesheet);
1050  break;
1051  case Z_SRW_scan_request:
1052  value[i++] = "scan";
1053  queryType = srw_pdu->u.scan_request->queryType;
1054  if (version2)
1055  {
1056  if (queryType && strcmp(queryType, "cql"))
1057  yaz_add_name_value_str(encode, name, value, &i, "queryType",
1058  queryType);
1059  yaz_add_name_value_str(encode, name, value, &i, "scanClause",
1060  srw_pdu->u.scan_request->scanClause);
1061  }
1062  else
1063  {
1064  if (!queryType || !strcmp(queryType, "cql"))
1065  yaz_add_name_value_str(encode, name, value, &i, "scanClause",
1066  srw_pdu->u.scan_request->scanClause);
1067  else if (!strcmp(queryType, "pqf"))
1068  yaz_add_name_value_str(encode, name, value, &i, "x-pScanClause",
1069  srw_pdu->u.scan_request->scanClause);
1070  else if (!strcmp(queryType, "xcql"))
1071  yaz_add_name_value_str(encode, name, value, &i,
1072  "x-cqlScanClause",
1073  srw_pdu->u.scan_request->scanClause);
1074  }
1075  yaz_add_name_value_int(encode, name, value, &i, "responsePosition",
1076  srw_pdu->u.scan_request->responsePosition);
1077  yaz_add_name_value_int(encode, name, value, &i, "maximumTerms",
1078  srw_pdu->u.scan_request->maximumTerms);
1079  yaz_add_name_value_str(encode, name, value, &i, "stylesheet",
1080  srw_pdu->u.scan_request->stylesheet);
1081  break;
1082  case Z_SRW_update_request:
1083  value[i++] = "update";
1084  break;
1085  default:
1086  return -1;
1087  }
1088  if (srw_pdu->extra_args)
1089  {
1090  Z_SRW_extra_arg *ea = srw_pdu->extra_args;
1091  for (; ea && i < max_names-1; ea = ea->next)
1092  {
1093  name[i] = ea->name;
1094  value[i] = ea->value;
1095  i++;
1096  }
1097  }
1098  name[i++] = 0;
1099 
1100  return 0;
1101 }
1102 
1104  ODR encode, const char *charset)
1105 {
1106  char *name[MAX_SRU_PARAMETERS], *value[MAX_SRU_PARAMETERS]; /* definite upper limit for SRU params */
1107  char *uri_args;
1108  char *path;
1109  char *cp;
1110 
1111  z_HTTP_header_add_basic_auth(encode, &hreq->headers,
1112  srw_pdu->username, srw_pdu->password);
1113  if (yaz_get_sru_parms(srw_pdu, encode, name, value, MAX_SRU_PARAMETERS))
1114  return -1;
1115  yaz_array_to_uri(&uri_args, encode, name, value);
1116 
1117  hreq->method = "GET";
1118 
1119  cp = strchr(hreq->path, '#');
1120  if (cp)
1121  *cp = '\0';
1122 
1123  path = (char *)
1124  odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 4);
1125 
1126  sprintf(path, "%s%c%s", hreq->path, strchr(hreq->path, '?') ? '&' : '?',
1127  uri_args);
1128  hreq->path = path;
1129 
1130  z_HTTP_header_add_content_type(encode, &hreq->headers,
1131  "text/xml", charset);
1132  return 0;
1133 }
1134 
1136  ODR encode, const char *charset)
1137 {
1138  char *name[MAX_SRU_PARAMETERS], *value[MAX_SRU_PARAMETERS]; /* definite upper limit for SRU params */
1139  char *uri_args;
1140 
1141  z_HTTP_header_add_basic_auth(encode, &hreq->headers,
1142  srw_pdu->username, srw_pdu->password);
1143  if (yaz_get_sru_parms(srw_pdu, encode, name, value, MAX_SRU_PARAMETERS))
1144  return -1;
1145 
1146  yaz_array_to_uri(&uri_args, encode, name, value);
1147 
1148  hreq->method = "POST";
1149 
1150  hreq->content_buf = uri_args;
1151  hreq->content_len = strlen(uri_args);
1152 
1153  z_HTTP_header_add_content_type(encode, &hreq->headers,
1154  "application/x-www-form-urlencoded",
1155  charset);
1156  return 0;
1157 }
1158 
1160  ODR odr, const char *charset)
1161 {
1162  Z_SOAP_Handler handlers[3] = {
1163 #if YAZ_HAVE_XML2
1166 #endif
1167  {0, 0, 0}
1168  };
1169  Z_SOAP *p = (Z_SOAP*) odr_malloc(odr, sizeof(*p));
1170 
1172  srw_pdu->username, srw_pdu->password);
1174  &hreq->headers,
1175  "text/xml", 0 /* no charset in MIME */);
1176 
1177  z_HTTP_header_add(odr, &hreq->headers,
1178  "SOAPAction", "\"\"");
1179  p->which = Z_SOAP_generic;
1180  p->u.generic = (Z_SOAP_Generic *) odr_malloc(odr, sizeof(*p->u.generic));
1181  p->u.generic->no = 0;
1182  p->u.generic->ns = 0;
1183  p->u.generic->p = srw_pdu;
1184  p->ns = "http://schemas.xmlsoap.org/soap/envelope/";
1185 
1186 #if YAZ_HAVE_XML2
1187  if (srw_pdu->which == Z_SRW_update_request ||
1188  srw_pdu->which == Z_SRW_update_response)
1189  p->u.generic->no = 1; /* second handler */
1190 #endif
1191  return z_soap_codec_enc(odr, &p,
1192  &hreq->content_buf,
1193  &hreq->content_len, handlers,
1194  charset);
1195 }
1196 
1198 {
1199  Z_SRW_recordVersion *ver
1200  = (Z_SRW_recordVersion *) odr_malloc(odr,num * sizeof(*ver));
1201  int i;
1202  for (i = 0; i < num; ++i)
1203  {
1204  ver[i].versionType = 0;
1205  ver[i].versionValue = 0;
1206  }
1207  return ver;
1208 }
1209 
1210 const char *yaz_srw_pack_to_str(int pack)
1211 {
1212  switch(pack)
1213  {
1215  return "string";
1217  return "xml";
1219  return "url";
1220  }
1221  return 0;
1222 }
1223 
1224 int yaz_srw_str_to_pack(const char *str)
1225 {
1226  if (!yaz_matchstr(str, "string"))
1228  if (!yaz_matchstr(str, "xml"))
1229  return Z_SRW_recordPacking_XML;
1230  if (!yaz_matchstr(str, "url"))
1231  return Z_SRW_recordPacking_URL;
1232  return -1;
1233 }
1234 
1235 void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args)
1236 {
1237  if (extra_args)
1238  {
1239  char **name;
1240  char **val;
1241  Z_SRW_extra_arg **ea = &sr->extra_args;
1242  yaz_uri_to_array(extra_args, odr, &name, &val);
1243 
1244  while (*name)
1245  {
1246  ea = append_extra_arg(odr, ea, *name, *val);
1247  val++;
1248  name++;
1249  }
1250  }
1251 }
1252 
1253 
1254 /*
1255  * Local variables:
1256  * c-basic-offset: 4
1257  * c-file-style: "Stroustrup"
1258  * indent-tabs-mode: nil
1259  * End:
1260  * vim: shiftwidth=4 tabstop=8 expandtab
1261  */
1262 
int yaz_base64decode(const char *in, char *out)
decodes Base64 string
Definition: base64.c:82
Header for Base64 utilities.
const char * yaz_diag_srw_str(int code)
Definition: diagsrw.c:110
#define YAZ_SRW_UNSUPP_VERSION
Definition: diagsrw.h:14
#define YAZ_SRW_UNSUPP_PARAMETER_VALUE
Definition: diagsrw.h:15
#define YAZ_SRW_UNSUPP_OPERATION
Definition: diagsrw.h:13
#define YAZ_SRW_UNSUPP_PARAMETER
Definition: diagsrw.h:17
#define YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED
Definition: diagsrw.h:16
const char * z_HTTP_header_lookup(const Z_HTTP_Header *hp, const char *n)
Definition: http.c:233
void z_HTTP_header_add_basic_auth(ODR o, Z_HTTP_Header **hp, const char *username, const char *password)
Definition: http.c:168
void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n, const char *v)
Definition: http.c:189
void z_HTTP_header_add_content_type(ODR o, Z_HTTP_Header **hp, const char *content_type, const char *charset)
Definition: http.c:147
char * name
Definition: initopt.c:18
int yaz_strcmp_del(const char *a, const char *b, const char *b_del)
match a and b with some delimitor for b
Definition: matchstr.c:72
int yaz_matchstr(const char *s1, const char *s2)
match strings - independent of case and '-'
Definition: matchstr.c:42
Header for YAZ iconv interface.
#define ODR_INT_PRINTF
Definition: odr.h:49
nmem_int_t Odr_int
Definition: odr.h:47
char * odr_strdupn(ODR o, const char *str, size_t n)
Definition: odr_mem.c:46
char * odr_strdup(ODR o, const char *str)
Definition: odr_mem.c:36
Odr_int * odr_intdup(ODR o, Odr_int v)
Definition: odr_mem.c:51
void * odr_malloc(ODR o, size_t size)
Definition: odr_mem.c:31
int z_soap_codec(ODR o, Z_SOAP **pp, char **content_buf, int *content_len, Z_SOAP_Handler *handlers)
Definition: soap.c:340
int z_soap_codec_enc(ODR o, Z_SOAP **pp, char **content_buf, int *content_len, Z_SOAP_Handler *handlers, const char *encoding)
Definition: soap.c:331
int(* Z_SOAP_fun)(ODR o, void *ptr, void **handler_data, void *client_data, const char *ns)
Definition: soap.h:65
#define Z_SOAP_generic
Definition: soap.h:53
SRU private header.
void yaz_sru_facet_request(ODR, Z_FacetList **facetList, const char **limit, const char **start, const char **sort)
Definition: sru_facet.c:60
char * yaz_negotiate_sru_version(char *input_ver)
Definition: srw.c:26
int yaz_ucp_codec(ODR o, void *vptr, Z_SRW_PDU **handler_data, void *client_data, const char *ns_ucp_str)
Definition: srw.c:1144
int yaz_srw_codec(ODR o, void *vptr, Z_SRW_PDU **handler_data, void *client_data, const char *ns)
Definition: srw.c:575
Header for SRW/SRU.
#define YAZ_XMLNS_SRU_v2_mask
Definition: srw.h:332
#define Z_SRW_recordPacking_XML
Definition: srw.h:55
#define Z_SRW_searchRetrieve_response
Definition: srw.h:192
#define Z_SRW_explain_request
Definition: srw.h:193
#define Z_SRW_update_request
Definition: srw.h:197
#define Z_SRW_scan_request
Definition: srw.h:195
#define YAZ_XMLNS_SRU_v1_1
Definition: srw.h:328
#define Z_SRW_sort_type_none
Definition: srw.h:74
#define Z_SRW_recordPacking_string
Definition: srw.h:54
#define Z_SRW_recordPacking_URL
Definition: srw.h:56
#define Z_SRW_update_response
Definition: srw.h:198
#define Z_SRW_sort_type_sort
Definition: srw.h:75
#define Z_SRW_explain_response
Definition: srw.h:194
#define YAZ_XMLNS_SRU_v1_0
Definition: srw.h:327
#define Z_SRW_scan_response
Definition: srw.h:196
#define Z_SRW_searchRetrieve_request
Definition: srw.h:191
#define YAZ_XMLNS_UPDATE_v0_9
Definition: srw.h:331
int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset, Z_SRW_diagnostic **diag, int *num_diag)
Definition: srwutil.c:356
void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args)
Definition: srwutil.c:1235
char * yaz_encode_sru_dbpath_odr(ODR out, const char *db)
encode SRU database for HTTP path
Definition: srwutil.c:63
static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode, char **name, char **value, int max_names)
Definition: srwutil.c:950
static int yaz_sru_decode_integer(ODR odr, const char *pname, const char *valstr, Odr_int **valp, Z_SRW_diagnostic **diag, int *num_diag, int min_value)
Definition: srwutil.c:328
int yaz_srw_check_content_type(Z_HTTP_Response *hres)
Definition: srwutil.c:88
void yaz_encode_sru_dbpath_buf(char *dst, const char *db)
encode SRU database for HTTP path
Definition: srwutil.c:56
Z_SRW_PDU * yaz_srw_get_pdu_e(ODR o, int which, Z_SRW_PDU *req)
Definition: srwutil.c:761
static Z_SRW_PDU * yaz_srw_get_core_ver(ODR o, const char *version)
Definition: srwutil.c:738
static Z_SRW_extra_arg ** append_extra_arg_int(ODR odr, Z_SRW_extra_arg **l, const char *n, Odr_int *v)
Definition: srwutil.c:39
void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo)
Definition: srwutil.c:193
int yaz_srw_str_to_pack(const char *str)
Definition: srwutil.c:1224
Z_SRW_extra_record * yaz_srw_get_extra_record(ODR o)
Definition: srwutil.c:705
void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d, int *num, const char *uri, const char *message, const char *details)
Definition: srwutil.c:169
void yaz_add_name_value_int(ODR o, char **name, char **value, int *i, char *a_name, Odr_int *val)
Definition: srwutil.c:927
int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset)
Definition: srwutil.c:1103
void yaz_mk_sru_surrogate(ODR o, Z_SRW_record *record, int pos, int code, const char *details)
Definition: srwutil.c:203
#define MAX_SRU_PARAMETERS
Definition: srwutil.c:21
int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset)
Definition: srwutil.c:257
Z_SRW_PDU * yaz_srw_get_pdu(ODR o, int which, const char *version)
Definition: srwutil.c:816
Z_SRW_record * yaz_srw_get_records(ODR o, int n)
Definition: srwutil.c:717
int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR encode, const char *charset)
Definition: srwutil.c:1135
static void grab_charset(ODR o, const char *content_type, char **charset)
Definition: srwutil.c:231
const char * yaz_element_attribute_value_get(xmlNodePtr ptr, const char *node_name, const char *attribute_name)
Definition: srwutil.c:71
const char * yaz_srw_pack_to_str(int pack)
Definition: srwutil.c:1210
void yaz_add_name_value_str(ODR o, char **name, char **value, int *i, char *a_name, char *val)
Definition: srwutil.c:939
Z_SRW_PDU * yaz_srw_get_core_v_2_0(ODR o)
Definition: srwutil.c:750
void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d, const char *uri, const char *message, const char *details)
Definition: srwutil.c:145
static void yaz_srw_decodeauth(Z_SRW_PDU *sr, Z_HTTP_Request *hreq, char *username, char *password, ODR decode)
Definition: srwutil.c:108
Z_SRW_recordVersion * yaz_srw_get_record_versions(ODR odr, int num)
Definition: srwutil.c:1197
int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, ODR odr, const char *charset)
Definition: srwutil.c:1159
void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, int code, const char *details)
Definition: srwutil.c:160
static Z_SRW_extra_arg ** append_extra_arg(ODR odr, Z_SRW_extra_arg **l, const char *n, const char *v)
Definition: srwutil.c:23
static char * yaz_decode_sru_dbpath_odr(ODR n, const char *uri, size_t len)
Definition: srwutil.c:51
Z_SRW_PDU * yaz_srw_get(ODR o, int which)
Definition: srwutil.c:755
void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d, int *num, int code, const char *addinfo)
Definition: srwutil.c:183
Z_SRW_record * yaz_srw_get_record(ODR o)
Definition: srwutil.c:733
Z_HTTP_Header * headers
Definition: zgdu.h:52
char * content_buf
Definition: zgdu.h:53
char * path
Definition: zgdu.h:51
char * method
Definition: zgdu.h:49
int content_len
Definition: zgdu.h:54
Z_HTTP_Header * headers
Definition: zgdu.h:60
int no
Definition: soap.h:47
void * p
Definition: soap.h:49
char * ns
Definition: soap.h:48
char * ns
Definition: soap.h:68
Definition: soap.h:55
int which
Definition: soap.h:56
const char * ns
Definition: soap.h:62
Z_SOAP_Generic * generic
Definition: soap.h:59
union Z_SOAP::@28 u
Definition: srw.h:200
Z_SRW_explainRequest * explain_request
Definition: srw.h:205
Z_SRW_updateRequest * update_request
Definition: srw.h:209
Z_SRW_updateResponse * update_response
Definition: srw.h:210
union Z_SRW_PDU::@30 u
char * srw_version
Definition: srw.h:212
Z_SRW_scanRequest * scan_request
Definition: srw.h:207
Z_SRW_searchRetrieveResponse * response
Definition: srw.h:204
Z_SRW_extra_arg * extra_args
Definition: srw.h:219
Z_SRW_scanResponse * scan_response
Definition: srw.h:208
Z_SRW_explainResponse * explain_response
Definition: srw.h:206
Z_SRW_searchRetrieveRequest * request
Definition: srw.h:203
char * password
Definition: srw.h:214
int which
Definition: srw.h:201
char * extraResponseData_buf
Definition: srw.h:221
int extraResponseData_len
Definition: srw.h:222
char * username
Definition: srw.h:213
char * message
Definition: srw.h:66
char * details
Definition: srw.h:65
char * uri
Definition: srw.h:64
char * packing
Definition: srw.h:117
char * database
Definition: srw.h:118
char * stylesheet
Definition: srw.h:119
char * recordPacking
Definition: srw.h:116
Z_SRW_diagnostic * diagnostics
Definition: srw.h:124
Z_SRW_record record
Definition: srw.h:123
Z_SRW_extra_record * extra_record
Definition: srw.h:126
char * value
Definition: srw.h:174
Z_SRW_extra_arg * next
Definition: srw.h:175
char * name
Definition: srw.h:173
int extraRecordData_len
Definition: srw.h:46
char * extraRecordData_buf
Definition: srw.h:45
char * recordIdentifier
Definition: srw.h:47
char * versionValue
Definition: srw.h:155
char * versionType
Definition: srw.h:154
char * recordData_buf
Definition: srw.h:58
int recordPacking
Definition: srw.h:53
char * recordSchema
Definition: srw.h:51
int recordData_len
Definition: srw.h:59
Odr_int * recordPosition
Definition: srw.h:60
Odr_int * responsePosition
Definition: srw.h:132
Odr_int * maximumTerms
Definition: srw.h:133
char * queryType
Definition: srw.h:130
char * scanClause
Definition: srw.h:131
char * stylesheet
Definition: srw.h:134
char * database
Definition: srw.h:135
Z_SRW_diagnostic * diagnostics
Definition: srw.h:148
Z_SRW_scanTerm * terms
Definition: srw.h:146
int num_diagnostics
Definition: srw.h:149
Odr_int * resultSetTTL
Definition: srw.h:93
Z_FacetList * facetList
Definition: srw.h:94
Odr_int * maximumRecords
Definition: srw.h:84
Odr_int * startRecord
Definition: srw.h:83
union Z_SRW_searchRetrieveRequest::@29 sort
Z_SRW_record * records
Definition: srw.h:103
Odr_int * numberOfRecords
Definition: srw.h:98
Z_SRW_diagnostic * diagnostics
Definition: srw.h:106
char * resultCountPrecision
Definition: srw.h:99
Odr_int * nextRecordPosition
Definition: srw.h:108
Odr_int * resultSetIdleTime
Definition: srw.h:101
Z_SRW_extra_record ** extra_records
Definition: srw.h:110
Z_FacetList * facetList
Definition: srw.h:111
char * database
Definition: srw.h:159
int extraRequestData_len
Definition: srw.h:167
char * stylesheet
Definition: srw.h:168
char * recordId
Definition: srw.h:161
Z_SRW_extra_record * extra_record
Definition: srw.h:165
Z_SRW_recordVersion * recordVersions
Definition: srw.h:162
int num_recordVersions
Definition: srw.h:163
Z_SRW_record * record
Definition: srw.h:164
char * extraRequestData_buf
Definition: srw.h:166
char * operationStatus
Definition: srw.h:179
int num_diagnostics
Definition: srw.h:188
char * recordId
Definition: srw.h:180
Z_SRW_diagnostic * diagnostics
Definition: srw.h:187
Z_SRW_record * record
Definition: srw.h:183
int extraResponseData_len
Definition: srw.h:186
int num_recordVersions
Definition: srw.h:182
Z_SRW_recordVersion * recordVersions
Definition: srw.h:181
char * extraResponseData_buf
Definition: srw.h:185
Z_SRW_extra_record * extra_record
Definition: srw.h:184
Definition: odr.h:125
int yaz_uri_to_array(const char *path, ODR o, char ***name, char ***val)
Definition: uri.c:121
void yaz_array_to_uri(char **path, ODR o, char **name, char **value)
Definition: uri.c:98
Header for YAZ iconv interface.