2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: srwutil.c,v 1.37 2006-03-22 13:03:59 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;
692 case Z_SRW_update_request:
693 sr->u.update_request = (Z_SRW_updateRequest *)
694 odr_malloc(o, sizeof(*sr->u.update_request));
695 sr->u.update_request->database = 0;
696 sr->u.update_request->stylesheet = 0;
697 sr->u.update_request->record.recordSchema = 0;
698 sr->u.update_request->record.recordPacking = Z_SRW_recordPacking_XML;
699 sr->u.update_request->recordId = 0;
700 sr->u.update_request->recordVersion = 0;
701 sr->u.update_request->recordOldVersion = 0;
702 sr->u.update_request->record.recordData_buf = 0;
703 sr->u.update_request->record.recordData_len = 0;
704 sr->u.update_request->extra_record = 0;
705 sr->u.update_request->extraRequestData = 0;
706 sr->u.request->database = 0;
708 case Z_SRW_update_response:
709 sr->u.update_response = (Z_SRW_updateResponse *)
710 odr_malloc(o, sizeof(*sr->u.update_response));
711 sr->u.update_response->operationStatus = 0;
712 sr->u.update_response->recordId = 0;
713 sr->u.update_response->recordVersion = 0;
714 sr->u.update_response->recordChecksum = 0;
715 sr->u.update_response->record.recordData_buf = 0;
716 sr->u.update_response->record.recordData_len = 0;
717 sr->u.update_response->record.recordSchema = 0;
718 sr->u.update_response->record.recordPacking =
719 Z_SRW_recordPacking_XML;
720 sr->u.update_response->extra_record = 0;
721 sr->u.update_response->extraResponseData = 0;
722 sr->u.update_response->diagnostics = 0;
723 sr->u.update_response->num_diagnostics = 0;
729 static int srw_bib1_map[] = {
739 108, 10, /* Malformed query : Syntax error */
769 100, 1, /* bad map */
817 205, 1, /* bad map */
818 206, 1, /* bad map */
820 208, 1, /* bad map */
831 218, 1, /* bad map */
832 219, 1, /* bad map */
833 220, 1, /* bad map */
834 221, 1, /* bad map */
836 223, 1, /* bad map */
837 224, 1, /* bad map */
838 225, 1, /* bad map */
839 226, 1, /* bad map */
841 228, 1, /* bad map */
846 233, 1, /* bad map */
847 234, 1, /* bad map */
853 240, 1, /* bad map */
854 241, 1, /* bad map */
856 243, 1, /* bad map */
861 1001, 1, /* bad map */
862 1002, 1, /* bad map */
863 1003, 1, /* bad map */
864 1004, 1, /* bad map */
865 1005, 1, /* bad map */
866 1006, 1, /* bad map */
898 int yaz_diag_bib1_to_srw (int code)
900 const int *p = srw_bib1_map;
910 int yaz_diag_srw_to_bib1(int code)
912 const int *p = srw_bib1_map;
922 static void add_val_int(ODR o, char **name, char **value, int *i,
923 char *a_name, int *val)
928 value[*i] = odr_malloc(o, 30);
929 sprintf(value[*i], "%d", *val);
934 static void add_val_str(ODR o, char **name, char **value, int *i,
935 char *a_name, char *val)
945 static int yaz_get_sru_parms(const Z_SRW_PDU *srw_pdu, ODR encode,
946 char **name, char **value)
949 add_val_str(encode, name, value, &i, "version", srw_pdu->srw_version);
950 name[i] = "operation";
951 switch(srw_pdu->which)
953 case Z_SRW_searchRetrieve_request:
954 value[i++] = "searchRetrieve";
955 switch(srw_pdu->u.request->query_type)
957 case Z_SRW_query_type_cql:
958 add_val_str(encode, name, value, &i, "query",
959 srw_pdu->u.request->query.cql);
961 case Z_SRW_query_type_pqf:
962 add_val_str(encode, name, value, &i, "x-pquery",
963 srw_pdu->u.request->query.pqf);
965 case Z_SRW_query_type_xcql:
966 add_val_str(encode, name, value, &i, "x-cql",
967 srw_pdu->u.request->query.xcql);
970 switch(srw_pdu->u.request->sort_type)
972 case Z_SRW_sort_type_none:
974 case Z_SRW_sort_type_sort:
975 add_val_str(encode, name, value, &i, "sortKeys",
976 srw_pdu->u.request->sort.sortKeys);
979 add_val_int(encode, name, value, &i, "startRecord",
980 srw_pdu->u.request->startRecord);
981 add_val_int(encode, name, value, &i, "maximumRecords",
982 srw_pdu->u.request->maximumRecords);
983 add_val_str(encode, name, value, &i, "recordSchema",
984 srw_pdu->u.request->recordSchema);
985 add_val_str(encode, name, value, &i, "recordPacking",
986 srw_pdu->u.request->recordPacking);
987 add_val_str(encode, name, value, &i, "recordXPath",
988 srw_pdu->u.request->recordXPath);
989 add_val_str(encode, name, value, &i, "stylesheet",
990 srw_pdu->u.request->stylesheet);
991 add_val_int(encode, name, value, &i, "resultSetTTL",
992 srw_pdu->u.request->resultSetTTL);
994 case Z_SRW_explain_request:
995 value[i++] = "explain";
996 add_val_str(encode, name, value, &i, "stylesheet",
997 srw_pdu->u.explain_request->stylesheet);
999 case Z_SRW_scan_request:
1000 value[i++] = "scan";
1002 switch(srw_pdu->u.scan_request->query_type)
1004 case Z_SRW_query_type_cql:
1005 add_val_str(encode, name, value, &i, "scanClause",
1006 srw_pdu->u.scan_request->scanClause.cql);
1008 case Z_SRW_query_type_pqf:
1009 add_val_str(encode, name, value, &i, "x-pScanClause",
1010 srw_pdu->u.scan_request->scanClause.pqf);
1012 case Z_SRW_query_type_xcql:
1013 add_val_str(encode, name, value, &i, "x-cqlScanClause",
1014 srw_pdu->u.scan_request->scanClause.xcql);
1017 add_val_int(encode, name, value, &i, "responsePosition",
1018 srw_pdu->u.scan_request->responsePosition);
1019 add_val_int(encode, name, value, &i, "maximumTerms",
1020 srw_pdu->u.scan_request->maximumTerms);
1021 add_val_str(encode, name, value, &i, "stylesheet",
1022 srw_pdu->u.scan_request->stylesheet);
1024 case Z_SRW_update_request:
1025 value[i++] = "update";
1034 int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
1035 ODR encode, char *charset)
1037 char *name[30], *value[30]; /* definite upper limit for SRU params */
1041 if (yaz_get_sru_parms(srw_pdu, encode, name, value))
1043 yaz_array_to_uri(&uri_args, encode, name, value);
1045 hreq->method = "GET";
1047 path = odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 3);
1048 sprintf(path, "%s?%s", hreq->path, uri_args);
1051 z_HTTP_header_add_content_type(encode, &hreq->headers,
1052 "text/xml", charset);
1056 int yaz_sru_post_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
1057 ODR encode, char *charset)
1059 char *name[30], *value[30]; /* definite upper limit for SRU params */
1062 if (yaz_get_sru_parms(srw_pdu, encode, name, value))
1065 yaz_array_to_uri(&uri_args, encode, name, value);
1067 hreq->method = "POST";
1069 hreq->content_buf = uri_args;
1070 hreq->content_len = strlen(uri_args);
1072 z_HTTP_header_add_content_type(encode, &hreq->headers,
1073 "application/x-www-form-urlencoded",
1081 * indent-tabs-mode: nil
1083 * vim: shiftwidth=4 tabstop=8 expandtab