2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: srwutil.c,v 1.38 2006-04-20 00:01:01 adam Exp $
9 * \brief Implements SRW/SRU utilities.
14 #include <yaz/yaz-iconv.h>
16 static int hex_digit (int ch)
18 if (ch >= '0' && ch <= '9')
20 else if (ch >= 'a' && ch <= 'f')
22 else if (ch >= 'A' && ch <= 'F')
27 void encode_uri_char(char *dst, char ch)
31 else if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
32 (ch >= '0' && ch <= '9'))
40 sprintf(dst+1, "%02X", (unsigned char ) ch);
44 void yaz_array_to_uri(char **path, ODR o, char **name, char **value)
46 size_t i, szp = 0, sz = 0;
47 for(i = 0; name[i]; i++)
48 sz += strlen(name[i]) + 3 + strlen(value[i]) * 3;
49 *path = odr_malloc(o, sz);
51 for(i = 0; name[i]; i++)
56 ilen = strlen(name[i]);
57 memcpy(*path+szp, name[i], ilen);
60 for (j = 0; value[i][j]; j++)
64 encode_uri_char(vstr, value[i][j]);
66 memcpy(*path+szp, vstr, vlen);
73 int yaz_uri_array(const char *path, ODR o, char ***name, char ***val)
83 while ((cp = strchr(cp, '&')))
88 *name = odr_malloc(o, no * sizeof(char*));
89 *val = odr_malloc(o, no * sizeof(char*));
91 for (no = 0; *path; no++)
93 const char *p1 = strchr(path, '=');
99 (*name)[no] = odr_malloc(o, (p1-path)+1);
100 memcpy((*name)[no], path, p1-path);
101 (*name)[no][p1-path] = '\0';
104 p1 = strchr(path, '&');
106 p1 = strlen(path) + path;
107 (*val)[no] = ret = odr_malloc(o, p1 - path + 1);
108 while (*path && *path != '&')
115 else if (*path == '%' && path[1] && path[2])
117 ret[i++] = hex_digit (path[1])*16 + hex_digit (path[2]);
133 char *yaz_uri_val(const char *path, const char *name, ODR o)
135 size_t nlen = strlen(name);
139 while (path && *path)
141 const char *p1 = strchr(path, '=');
144 if ((size_t)(p1 - path) == nlen && !memcmp(path, name, nlen))
150 p1 = strchr(path, '&');
152 p1 = strlen(path) + path;
153 ret = (char *) odr_malloc(o, p1 - path + 1);
154 while (*path && *path != '&')
161 else if (*path == '%' && path[1] && path[2])
163 ret[i++] = hex_digit (path[1])*16 + hex_digit (path[2]);
172 path = strchr(p1, '&');
179 void yaz_uri_val_int(const char *path, const char *name, ODR o, int **intp)
181 const char *v = yaz_uri_val(path, name, o);
183 *intp = odr_intdup(o, atoi(v));
186 void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
187 const char *uri, const char *message,
190 d->uri = odr_strdup(o, uri);
192 d->message = odr_strdup(o, message);
196 d->details = odr_strdup(o, details);
201 void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
202 int code, const char *details)
206 sprintf(uri, "info:srw/diagnostic/1/%d", code);
207 yaz_mk_srw_diagnostic(o, d, uri, 0, details);
210 void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
211 int *num, const char *uri,
212 const char *message, const char *details)
214 Z_SRW_diagnostic *d_new;
215 d_new = (Z_SRW_diagnostic *) odr_malloc (o, (*num + 1)* sizeof(**d));
217 memcpy (d_new, *d, *num *sizeof(**d));
220 yaz_mk_srw_diagnostic(o, *d + *num, uri, message, details);
224 void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
225 int *num, int code, const char *addinfo)
229 sprintf(uri, "info:srw/diagnostic/1/%d", code);
230 yaz_add_srw_diagnostic_uri(o, d, num, uri, 0, addinfo);
233 int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
234 Z_SOAP **soap_package, ODR decode, char **charset)
236 if (!strcmp(hreq->method, "POST"))
238 const char *content_type = z_HTTP_header_lookup(hreq->headers,
241 (!yaz_strcmp_del("text/xml", content_type, "; ") ||
242 !yaz_strcmp_del("application/soap+xml", content_type, "; ") ||
243 !yaz_strcmp_del("text/plain", content_type, "; ")))
245 char *db = "Default";
246 const char *p0 = hreq->path, *p1;
248 const char *charset_p = 0;
250 static Z_SOAP_Handler soap_handlers[4] = {
252 {"http://www.loc.gov/zing/srw/", 0,
253 (Z_SOAP_fun) yaz_srw_codec},
254 {"http://www.loc.gov/zing/srw/v1.0/", 0,
255 (Z_SOAP_fun) yaz_srw_codec},
256 {"http://www.loc.gov/zing/srw/update/", 0,
257 (Z_SOAP_fun) yaz_ucp_codec},
264 p1 = strchr(p0, '?');
266 p1 = p0 + strlen(p0);
269 db = (char*) odr_malloc(decode, p1 - p0 + 1);
270 memcpy (db, p0, p1 - p0);
274 if (charset && (charset_p = strstr(content_type, "; charset=")))
278 while (i < 20 && charset_p[i] &&
279 !strchr("; \n\r", charset_p[i]))
281 *charset = (char*) odr_malloc(decode, i+1);
282 memcpy(*charset, charset_p, i);
283 (*charset)[i] = '\0';
285 ret = z_soap_codec(decode, soap_package,
286 &hreq->content_buf, &hreq->content_len,
288 if (ret == 0 && (*soap_package)->which == Z_SOAP_generic)
290 *srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
292 if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
293 (*srw_pdu)->u.request->database == 0)
294 (*srw_pdu)->u.request->database = db;
296 if ((*srw_pdu)->which == Z_SRW_explain_request &&
297 (*srw_pdu)->u.explain_request->database == 0)
298 (*srw_pdu)->u.explain_request->database = db;
300 if ((*srw_pdu)->which == Z_SRW_scan_request &&
301 (*srw_pdu)->u.scan_request->database == 0)
302 (*srw_pdu)->u.scan_request->database = db;
304 if ((*srw_pdu)->which == Z_SRW_update_request &&
305 (*srw_pdu)->u.update_request->database == 0)
306 (*srw_pdu)->u.update_request->database = db;
317 http://www.loc.gov/z3950/agency/zing/srw/service.html
319 int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
320 Z_SOAP **soap_package, ODR decode, char **charset,
321 Z_SRW_diagnostic **diag, int *num_diag)
324 static Z_SOAP_Handler soap_handlers[2] = {
325 {"http://www.loc.gov/zing/srw/", 0,
326 (Z_SOAP_fun) yaz_srw_codec},
330 const char *content_type = z_HTTP_header_lookup(hreq->headers,
333 SRU GET: allow any content type.
334 SRU POST: we support "application/x-www-form-urlencoded";
335 not "multipart/form-data" .
337 if (!strcmp(hreq->method, "GET")
339 (!strcmp(hreq->method, "POST")
341 !yaz_strcmp_del("application/x-www-form-urlencoded",
346 char *db = "Default";
347 const char *p0 = hreq->path, *p1;
349 const char *operation = 0;
354 char *stylesheet = 0;
355 char *scanClause = 0;
356 char *pScanClause = 0;
357 char *recordXPath = 0;
358 char *recordSchema = 0;
359 char *recordPacking = "xml"; /* xml packing is default for SRU */
360 char *maximumRecords = 0;
361 char *startRecord = 0;
362 char *maximumTerms = 0;
363 char *responsePosition = 0;
364 char *extraRequestData = 0;
373 p1 = strchr(p0, '?');
375 p1 = p0 + strlen(p0);
378 db = (char*) odr_malloc(decode, p1 - p0 + 1);
379 memcpy (db, p0, p1 - p0);
382 if (!strcmp(hreq->method, "POST"))
383 p1 = hreq->content_buf;
384 yaz_uri_array(p1, decode, &uri_name, &uri_val);
389 for (i = 0; uri_name[i]; i++)
391 char *n = uri_name[i];
392 char *v = uri_val[i];
393 if (!strcmp(n, "query"))
395 else if (!strcmp(n, "x-pquery"))
397 else if (!strcmp(n, "operation"))
399 else if (!strcmp(n, "stylesheet"))
401 else if (!strcmp(n, "sortKeys"))
403 else if (!strcmp(n, "recordXPath"))
405 else if (!strcmp(n, "recordSchema"))
407 else if (!strcmp(n, "recordPacking"))
409 else if (!strcmp(n, "version"))
411 else if (!strcmp(n, "scanClause"))
413 else if (!strcmp(n, "x-pScanClause"))
415 else if (!strcmp(n, "maximumRecords"))
417 else if (!strcmp(n, "startRecord"))
419 else if (!strcmp(n, "maximumTerms"))
421 else if (!strcmp(n, "responsePosition"))
422 responsePosition = v;
423 else if (!strcmp(n, "extraRequestData"))
424 extraRequestData = v;
426 yaz_add_srw_diagnostic(decode, diag, num_diag, 8, n);
432 yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "version");
435 if (strcmp(version, "1.1"))
436 yaz_add_srw_diagnostic(decode, diag, num_diag, 5, "1.1");
440 yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "operation");
441 operation = "explain";
443 if (!strcmp(operation, "searchRetrieve"))
445 Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_searchRetrieve_request);
447 sr->srw_version = version;
451 sr->u.request->query_type = Z_SRW_query_type_cql;
452 sr->u.request->query.cql = query;
456 sr->u.request->query_type = Z_SRW_query_type_pqf;
457 sr->u.request->query.pqf = pQuery;
460 yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "query");
464 sr->u.request->sort_type = Z_SRW_sort_type_sort;
465 sr->u.request->sort.sortKeys = sortKeys;
467 sr->u.request->recordXPath = recordXPath;
468 sr->u.request->recordSchema = recordSchema;
469 sr->u.request->recordPacking = recordPacking;
470 sr->u.request->stylesheet = stylesheet;
473 sr->u.request->maximumRecords =
474 odr_intdup(decode, atoi(maximumRecords));
476 sr->u.request->startRecord =
477 odr_intdup(decode, atoi(startRecord));
479 sr->u.request->database = db;
481 (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
482 (*soap_package)->which = Z_SOAP_generic;
484 (*soap_package)->u.generic =
485 odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
487 (*soap_package)->u.generic->p = sr;
488 (*soap_package)->u.generic->ns = soap_handlers[0].ns;
489 (*soap_package)->u.generic->no = 0;
491 (*soap_package)->ns = "SRU";
495 else if (!strcmp(operation, "explain"))
497 /* Transfer SRU explain parameters to common struct */
498 /* http://www.loc.gov/z3950/agency/zing/srw/explain.html */
499 Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_explain_request);
501 sr->srw_version = version;
503 sr->u.explain_request->recordPacking = recordPacking;
504 sr->u.explain_request->database = db;
506 sr->u.explain_request->stylesheet = stylesheet;
508 (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
509 (*soap_package)->which = Z_SOAP_generic;
511 (*soap_package)->u.generic =
512 odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
514 (*soap_package)->u.generic->p = sr;
515 (*soap_package)->u.generic->ns = soap_handlers[0].ns;
516 (*soap_package)->u.generic->no = 0;
518 (*soap_package)->ns = "SRU";
522 else if (!strcmp(operation, "scan"))
524 /* Transfer SRU scan parameters to common struct */
525 /* http://www.loc.gov/z3950/agency/zing/srw/scan.html */
526 Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_scan_request);
528 sr->srw_version = version;
533 sr->u.scan_request->query_type = Z_SRW_query_type_cql;
534 sr->u.scan_request->scanClause.cql = scanClause;
536 else if (pScanClause)
538 sr->u.scan_request->query_type = Z_SRW_query_type_pqf;
539 sr->u.scan_request->scanClause.pqf = pScanClause;
542 yaz_add_srw_diagnostic(decode, diag, num_diag, 7,
544 sr->u.scan_request->database = db;
547 sr->u.scan_request->maximumTerms =
548 odr_intdup(decode, atoi(maximumTerms));
549 if (responsePosition)
550 sr->u.scan_request->responsePosition =
551 odr_intdup(decode, atoi(responsePosition));
553 sr->u.scan_request->stylesheet = stylesheet;
555 (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
556 (*soap_package)->which = Z_SOAP_generic;
558 (*soap_package)->u.generic =
559 odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
561 (*soap_package)->u.generic->p = sr;
562 (*soap_package)->u.generic->ns = soap_handlers[0].ns;
563 (*soap_package)->u.generic->no = 0;
565 (*soap_package)->ns = "SRU";
571 /* unsupported operation ... */
572 /* Act as if we received a explain request and throw diagnostic. */
574 Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_explain_request);
576 sr->srw_version = version;
578 sr->u.explain_request->recordPacking = recordPacking;
579 sr->u.explain_request->database = db;
581 sr->u.explain_request->stylesheet = stylesheet;
583 (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
584 (*soap_package)->which = Z_SOAP_generic;
586 (*soap_package)->u.generic =
587 odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
589 (*soap_package)->u.generic->p = sr;
590 (*soap_package)->u.generic->ns = soap_handlers[0].ns;
591 (*soap_package)->u.generic->no = 0;
593 (*soap_package)->ns = "SRU";
595 yaz_add_srw_diagnostic(decode, diag, num_diag, 4, operation);
604 Z_SRW_extra_record *yaz_srw_get_extra_record(ODR o)
606 Z_SRW_extra_record *res = (Z_SRW_extra_record *)
607 odr_malloc(o, sizeof(*res));
609 res->recordReviewCode = 0;
610 res->recordReviewNote = 0;
612 res->nonDupRecordId = 0;
613 res->recordLockStatus = 0;
614 res->recordOldVersion = 0;
618 Z_SRW_PDU *yaz_srw_get(ODR o, int which)
620 Z_SRW_PDU *sr = (Z_SRW_PDU *) odr_malloc(o, sizeof(*o));
622 sr->srw_version = odr_strdup(o, "1.1");
626 case Z_SRW_searchRetrieve_request:
627 sr->u.request = (Z_SRW_searchRetrieveRequest *)
628 odr_malloc(o, sizeof(*sr->u.request));
629 sr->u.request->query_type = Z_SRW_query_type_cql;
630 sr->u.request->query.cql = 0;
631 sr->u.request->sort_type = Z_SRW_sort_type_none;
632 sr->u.request->sort.none = 0;
633 sr->u.request->startRecord = 0;
634 sr->u.request->maximumRecords = 0;
635 sr->u.request->recordSchema = 0;
636 sr->u.request->recordPacking = 0;
637 sr->u.request->recordXPath = 0;
638 sr->u.request->database = 0;
639 sr->u.request->resultSetTTL = 0;
640 sr->u.request->stylesheet = 0;
642 case Z_SRW_searchRetrieve_response:
643 sr->u.response = (Z_SRW_searchRetrieveResponse *)
644 odr_malloc(o, sizeof(*sr->u.response));
645 sr->u.response->numberOfRecords = 0;
646 sr->u.response->resultSetId = 0;
647 sr->u.response->resultSetIdleTime = 0;
648 sr->u.response->records = 0;
649 sr->u.response->num_records = 0;
650 sr->u.response->diagnostics = 0;
651 sr->u.response->num_diagnostics = 0;
652 sr->u.response->nextRecordPosition = 0;
653 sr->u.response->extra_records = 0;
655 case Z_SRW_explain_request:
656 sr->u.explain_request = (Z_SRW_explainRequest *)
657 odr_malloc(o, sizeof(*sr->u.explain_request));
658 sr->u.explain_request->recordPacking = 0;
659 sr->u.explain_request->database = 0;
660 sr->u.explain_request->stylesheet = 0;
662 case Z_SRW_explain_response:
663 sr->u.explain_response = (Z_SRW_explainResponse *)
664 odr_malloc(o, sizeof(*sr->u.explain_response));
665 sr->u.explain_response->record.recordData_buf = 0;
666 sr->u.explain_response->record.recordData_len = 0;
667 sr->u.explain_response->record.recordSchema = 0;
668 sr->u.explain_response->record.recordPosition = 0;
669 sr->u.explain_response->record.recordPacking =
670 Z_SRW_recordPacking_string;
671 sr->u.explain_response->diagnostics = 0;
672 sr->u.explain_response->num_diagnostics = 0;
673 sr->u.explain_response->extra_record = 0;
675 case Z_SRW_scan_request:
676 sr->u.scan_request = (Z_SRW_scanRequest *)
677 odr_malloc(o, sizeof(*sr->u.scan_request));
678 sr->u.scan_request->database = 0;
679 sr->u.scan_request->stylesheet = 0;
680 sr->u.scan_request->maximumTerms = 0;
681 sr->u.scan_request->responsePosition = 0;
682 sr->u.scan_request->query_type = Z_SRW_query_type_cql;
683 sr->u.scan_request->scanClause.cql = 0;
685 case Z_SRW_scan_response:
686 sr->u.scan_response = (Z_SRW_scanResponse *)
687 odr_malloc(o, sizeof(*sr->u.scan_response));
688 sr->u.scan_response->terms = 0;
689 sr->u.scan_response->num_terms = 0;
690 sr->u.scan_response->diagnostics = 0;
691 sr->u.scan_response->num_diagnostics = 0;
693 case Z_SRW_update_request:
694 sr->u.update_request = (Z_SRW_updateRequest *)
695 odr_malloc(o, sizeof(*sr->u.update_request));
696 sr->u.update_request->database = 0;
697 sr->u.update_request->stylesheet = 0;
698 sr->u.update_request->record.recordSchema = 0;
699 sr->u.update_request->record.recordPacking = Z_SRW_recordPacking_XML;
700 sr->u.update_request->recordId = 0;
701 sr->u.update_request->recordVersion = 0;
702 sr->u.update_request->recordOldVersion = 0;
703 sr->u.update_request->record.recordData_buf = 0;
704 sr->u.update_request->record.recordData_len = 0;
705 sr->u.update_request->extra_record = 0;
706 sr->u.update_request->extraRequestData = 0;
707 sr->u.request->database = 0;
709 case Z_SRW_update_response:
710 sr->u.update_response = (Z_SRW_updateResponse *)
711 odr_malloc(o, sizeof(*sr->u.update_response));
712 sr->u.update_response->operationStatus = 0;
713 sr->u.update_response->recordId = 0;
714 sr->u.update_response->recordVersion = 0;
715 sr->u.update_response->recordChecksum = 0;
716 sr->u.update_response->record.recordData_buf = 0;
717 sr->u.update_response->record.recordData_len = 0;
718 sr->u.update_response->record.recordSchema = 0;
719 sr->u.update_response->record.recordPacking =
720 Z_SRW_recordPacking_XML;
721 sr->u.update_response->extra_record = 0;
722 sr->u.update_response->extraResponseData = 0;
723 sr->u.update_response->diagnostics = 0;
724 sr->u.update_response->num_diagnostics = 0;
730 static int srw_bib1_map[] = {
740 108, 10, /* Malformed query : Syntax error */
770 100, 1, /* bad map */
818 205, 1, /* bad map */
819 206, 1, /* bad map */
821 208, 1, /* bad map */
832 218, 1, /* bad map */
833 219, 1, /* bad map */
834 220, 1, /* bad map */
835 221, 1, /* bad map */
837 223, 1, /* bad map */
838 224, 1, /* bad map */
839 225, 1, /* bad map */
840 226, 1, /* bad map */
842 228, 1, /* bad map */
847 233, 1, /* bad map */
848 234, 1, /* bad map */
854 240, 1, /* bad map */
855 241, 1, /* bad map */
857 243, 1, /* bad map */
862 1001, 1, /* bad map */
863 1002, 1, /* bad map */
864 1003, 1, /* bad map */
865 1004, 1, /* bad map */
866 1005, 1, /* bad map */
867 1006, 1, /* bad map */
899 int yaz_diag_bib1_to_srw (int code)
901 const int *p = srw_bib1_map;
911 int yaz_diag_srw_to_bib1(int code)
913 const int *p = srw_bib1_map;
923 static void add_val_int(ODR o, char **name, char **value, int *i,
924 char *a_name, int *val)
929 value[*i] = odr_malloc(o, 30);
930 sprintf(value[*i], "%d", *val);
935 static void add_val_str(ODR o, char **name, char **value, int *i,
936 char *a_name, char *val)
946 static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode,
947 char **name, char **value)
950 add_val_str(encode, name, value, &i, "version", srw_pdu->srw_version);
951 name[i] = "operation";
952 switch(srw_pdu->which)
954 case Z_SRW_searchRetrieve_request:
955 value[i++] = "searchRetrieve";
956 switch(srw_pdu->u.request->query_type)
958 case Z_SRW_query_type_cql:
959 add_val_str(encode, name, value, &i, "query",
960 srw_pdu->u.request->query.cql);
962 case Z_SRW_query_type_pqf:
963 add_val_str(encode, name, value, &i, "x-pquery",
964 srw_pdu->u.request->query.pqf);
966 case Z_SRW_query_type_xcql:
967 add_val_str(encode, name, value, &i, "x-cql",
968 srw_pdu->u.request->query.xcql);
971 switch(srw_pdu->u.request->sort_type)
973 case Z_SRW_sort_type_none:
975 case Z_SRW_sort_type_sort:
976 add_val_str(encode, name, value, &i, "sortKeys",
977 srw_pdu->u.request->sort.sortKeys);
980 add_val_int(encode, name, value, &i, "startRecord",
981 srw_pdu->u.request->startRecord);
982 add_val_int(encode, name, value, &i, "maximumRecords",
983 srw_pdu->u.request->maximumRecords);
984 add_val_str(encode, name, value, &i, "recordSchema",
985 srw_pdu->u.request->recordSchema);
986 add_val_str(encode, name, value, &i, "recordPacking",
987 srw_pdu->u.request->recordPacking);
988 add_val_str(encode, name, value, &i, "recordXPath",
989 srw_pdu->u.request->recordXPath);
990 add_val_str(encode, name, value, &i, "stylesheet",
991 srw_pdu->u.request->stylesheet);
992 add_val_int(encode, name, value, &i, "resultSetTTL",
993 srw_pdu->u.request->resultSetTTL);
995 case Z_SRW_explain_request:
996 value[i++] = "explain";
997 add_val_str(encode, name, value, &i, "stylesheet",
998 srw_pdu->u.explain_request->stylesheet);
1000 case Z_SRW_scan_request:
1001 value[i++] = "scan";
1003 switch(srw_pdu->u.scan_request->query_type)
1005 case Z_SRW_query_type_cql:
1006 add_val_str(encode, name, value, &i, "scanClause",
1007 srw_pdu->u.scan_request->scanClause.cql);
1009 case Z_SRW_query_type_pqf:
1010 add_val_str(encode, name, value, &i, "x-pScanClause",
1011 srw_pdu->u.scan_request->scanClause.pqf);
1013 case Z_SRW_query_type_xcql:
1014 add_val_str(encode, name, value, &i, "x-cqlScanClause",
1015 srw_pdu->u.scan_request->scanClause.xcql);
1018 add_val_int(encode, name, value, &i, "responsePosition",
1019 srw_pdu->u.scan_request->responsePosition);
1020 add_val_int(encode, name, value, &i, "maximumTerms",
1021 srw_pdu->u.scan_request->maximumTerms);
1022 add_val_str(encode, name, value, &i, "stylesheet",
1023 srw_pdu->u.scan_request->stylesheet);
1025 case Z_SRW_update_request:
1026 value[i++] = "update";
1035 int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
1036 ODR encode, char *charset)
1038 char *name[30], *value[30]; /* definite upper limit for SRU params */
1042 if (yaz_get_sru_parms(srw_pdu, encode, name, value))
1044 yaz_array_to_uri(&uri_args, encode, name, value);
1046 hreq->method = "GET";
1048 path = odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 3);
1049 sprintf(path, "%s?%s", hreq->path, uri_args);
1052 z_HTTP_header_add_content_type(encode, &hreq->headers,
1053 "text/xml", charset);
1057 int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
1058 ODR encode, char *charset)
1060 char *name[30], *value[30]; /* definite upper limit for SRU params */
1063 if (yaz_get_sru_parms(srw_pdu, encode, name, value))
1066 yaz_array_to_uri(&uri_args, encode, name, value);
1068 hreq->method = "POST";
1070 hreq->content_buf = uri_args;
1071 hreq->content_len = strlen(uri_args);
1073 z_HTTP_header_add_content_type(encode, &hreq->headers,
1074 "application/x-www-form-urlencoded",
1082 * indent-tabs-mode: nil
1084 * vim: shiftwidth=4 tabstop=8 expandtab