From 073195289eb9b73d6793fa283e5a7dca7a24fba8 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 9 Jan 2004 18:10:31 +0000 Subject: [PATCH] Picky SRU decode. yaz_srw_get supports scan --- include/yaz/srw.h | 10 ++- src/seshigh.c | 52 ++++++++--- src/srw.c | 109 +++++++++++------------ src/srwutil.c | 250 +++++++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 328 insertions(+), 93 deletions(-) diff --git a/include/yaz/srw.h b/include/yaz/srw.h index 26f9819..f937730 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -2,7 +2,7 @@ * Copyright (c) 2002-2004, Index Data. * See the file LICENSE for details. * - * $Id: srw.h,v 1.13 2004-01-07 21:02:42 adam Exp $ + * $Id: srw.h,v 1.14 2004-01-09 18:10:31 adam Exp $ */ #ifndef YAZ_SRW_H @@ -142,7 +142,13 @@ YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name, YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset); YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, - Z_SOAP **soap_package, ODR decode, char **charset); + Z_SOAP **soap_package, ODR decode, + char **charset, + Z_SRW_diagnostic **, int *num_diagnostic); + +void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d, + int *num, int code, const char *addinfo); + YAZ_END_CDECL #endif diff --git a/src/seshigh.c b/src/seshigh.c index 8cd5d39..08f5c32 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.15 2004-01-07 21:02:42 adam Exp $ + * $Id: seshigh.c,v 1.16 2004-01-09 18:10:31 adam Exp $ */ /* @@ -564,12 +564,8 @@ static void srw_bend_search(association *assoc, request *req, { srw_error = 3; /* assume Authentication error */ - srw_res->num_diagnostics = 1; - srw_res->diagnostics = (Z_SRW_diagnostic *) - odr_malloc(assoc->encode, sizeof(*srw_res->diagnostics)); - srw_res->diagnostics[0].code = - odr_intdup(assoc->encode, srw_error); - srw_res->diagnostics[0].details = 0; + yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics, + &srw_res->num_diagnostics, 1, 0); return; } } @@ -787,10 +783,13 @@ static void process_http_request(association *assoc, request *req) Z_HTTP_Response *hres; int keepalive = 1; char *stylesheet = 0; + Z_SRW_diagnostic *diagnostic = 0; + int num_diagnostic = 0; r = yaz_srw_decode(hreq, &sr, &soap_package, assoc->decode, &charset); if (r == 2) /* not taken */ - r = yaz_sru_decode(hreq, &sr, &soap_package, assoc->decode, &charset); + r = yaz_sru_decode(hreq, &sr, &soap_package, assoc->decode, &charset, + &diagnostic, &num_diagnostic); if (r == 0) /* decode SRW/SRU OK .. */ { int http_code = 200; @@ -800,8 +799,16 @@ static void process_http_request(association *assoc, request *req) yaz_srw_get(assoc->encode, Z_SRW_searchRetrieve_response); stylesheet = sr->u.request->stylesheet; - srw_bend_search(assoc, req, sr->u.request, res->u.response, - &http_code); + if (num_diagnostic) + { + res->u.response->diagnostics = diagnostic; + res->u.response->num_diagnostics = num_diagnostic; + } + else + { + srw_bend_search(assoc, req, sr->u.request, res->u.response, + &http_code); + } if (http_code == 200) soap_package->u.generic->p = res; } @@ -809,11 +816,32 @@ static void process_http_request(association *assoc, request *req) { Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_explain_response); stylesheet = sr->u.explain_request->stylesheet; - srw_bend_explain(assoc, req, sr->u.explain_request, + if (num_diagnostic) + { + res->u.explain_response->diagnostics = diagnostic; + res->u.explain_response->num_diagnostics = num_diagnostic; + } + srw_bend_explain(assoc, req, sr->u.explain_request, res->u.explain_response, &http_code); if (http_code == 200) soap_package->u.generic->p = res; } + else if (sr->which == Z_SRW_scan_request) + { + Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_scan_response); + stylesheet = sr->u.scan_request->stylesheet; + if (num_diagnostic) + { + res->u.scan_response->diagnostics = diagnostic; + res->u.scan_response->num_diagnostics = num_diagnostic; + } + yaz_add_srw_diagnostic(o, + &res->u.scan_response->diagnostics, + &res->u.scan_response->num_diagnostics, + 4, "scan"); + if (http_code == 200) + soap_package->u.generic->p = res; + } else { http_code = 500; @@ -1274,7 +1302,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->init->implementation_name, odr_prepend(assoc->encode, "GFS", resp->implementationName)); - version = odr_strdup(assoc->encode, "$Revision: 1.15 $"); + version = odr_strdup(assoc->encode, "$Revision: 1.16 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; resp->implementationVersion = odr_prepend(assoc->encode, diff --git a/src/srw.c b/src/srw.c index cf22d06..375df80 100644 --- a/src/srw.c +++ b/src/srw.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2004, Index Data. * See the file LICENSE for details. * - * $Id: srw.c,v 1.15 2004-01-07 20:36:44 adam Exp $ + * $Id: srw.c,v 1.16 2004-01-09 18:10:32 adam Exp $ */ #include @@ -433,7 +433,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, for (; ptr; ptr = ptr->next) { - if (match_xsd_string(ptr, "query", o, + if (match_xsd_string(ptr, "version", o, + &(*p)->srw_version)) + ; + else if (match_xsd_string(ptr, "query", o, &req->query.cql)) req->query_type = Z_SRW_query_type_cql; else if (match_xsd_string(ptr, "pQuery", o, @@ -442,36 +445,33 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, else if (match_xsd_string(ptr, "xQuery", o, &req->query.xcql)) req->query_type = Z_SRW_query_type_xcql; - else if (match_xsd_string(ptr, "sortKeys", o, - &req->sort.sortKeys)) - req->sort_type = Z_SRW_sort_type_sort; - else if (match_xsd_string(ptr, "recordSchema", o, - &req->recordSchema)) + else if (match_xsd_integer(ptr, "startRecord", o, + &req->startRecord)) + ; + else if (match_xsd_integer(ptr, "maximumRecords", o, + &req->maximumRecords)) ; else if (match_xsd_string(ptr, "recordPacking", o, &req->recordPacking)) ; + else if (match_xsd_string(ptr, "recordSchema", o, + &req->recordSchema)) + ; else if (match_xsd_string(ptr, "recordXPath", o, &req->recordXPath)) ; - else if (match_xsd_integer(ptr, "startRecord", o, - &req->startRecord)) - ; - else if (match_xsd_integer(ptr, "maximumRecords", o, - &req->maximumRecords)) + else if (match_xsd_string(ptr, "resultSetTTL", o, + &req->database)) ; + else if (match_xsd_string(ptr, "sortKeys", o, + &req->sort.sortKeys)) + req->sort_type = Z_SRW_sort_type_sort; else if (match_xsd_string(ptr, "stylesheet", o, &req->stylesheet)) ; else if (match_xsd_string(ptr, "database", o, &req->database)) ; - else if (match_xsd_string(ptr, "resultSetTTL", o, - &req->database)) - ; - else if (match_xsd_string(ptr, "version", o, - &(*p)->srw_version)) - ; /* missing is xQuery, xSortKeys .. */ } } @@ -494,7 +494,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, for (; ptr; ptr = ptr->next) { - if (match_xsd_integer(ptr, "numberOfRecords", o, + if (match_xsd_string(ptr, "version", o, + &(*p)->srw_version)) + ; + else if (match_xsd_integer(ptr, "numberOfRecords", o, &res->numberOfRecords)) ; else if (match_xsd_string(ptr, "resultSetId", o, @@ -507,16 +510,13 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, yaz_srw_records(o, ptr, &res->records, &res->num_records, client_data, ns); + else if (match_xsd_integer(ptr, "nextRecordPosition", o, + &res->nextRecordPosition)) + ; else if (match_element(ptr, "diagnostics")) yaz_srw_diagnostics(o, ptr, &res->diagnostics, &res->num_diagnostics, client_data, ns); - else if (match_xsd_integer(ptr, "nextRecordPosition", o, - &res->nextRecordPosition)) - ; - else if (match_xsd_string(ptr, "version", o, - &(*p)->srw_version)) - ; } } else if (!strcmp(method->name, "explainRequest")) @@ -531,18 +531,18 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, req->stylesheet = 0; for (; ptr; ptr = ptr->next) { - if (match_xsd_string(ptr, "database", o, - &req->database)) - ; + if (match_xsd_string(ptr, "version", o, + &(*p)->srw_version)) + ; else if (match_xsd_string(ptr, "stylesheet", o, &req->stylesheet)) ; else if (match_xsd_string(ptr, "recordPacking", o, &req->recordPacking)) ; - else if (match_xsd_string(ptr, "version", o, - &(*p)->srw_version)) - ; + else if (match_xsd_string(ptr, "database", o, + &req->database)) + ; } } else if (!strcmp(method->name, "explainResponse")) @@ -557,11 +557,11 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, for (; ptr; ptr = ptr->next) { - if (match_element(ptr, "record")) - yaz_srw_record(o, ptr, &res->record, client_data, ns); - else if (match_xsd_string(ptr, "version", o, - &(*p)->srw_version)) + if (match_xsd_string(ptr, "version", o, + &(*p)->srw_version)) ; + else if (match_element(ptr, "record")) + yaz_srw_record(o, ptr, &res->record, client_data, ns); else if (match_element(ptr, "diagnostics")) yaz_srw_diagnostics(o, ptr, &res->diagnostics, &res->num_diagnostics, @@ -590,18 +590,18 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, else if (match_xsd_string(ptr, "scanClause", o, &req->scanClause)) ; - else if (match_xsd_string(ptr, "database", o, - &req->database)) - ; - else if (match_xsd_string(ptr, "stylesheet", o, - &req->stylesheet)) - ; else if (match_xsd_integer(ptr, "responsePosition", o, &req->responsePosition)) ; else if (match_xsd_integer(ptr, "maximumTerms", o, &req->maximumTerms)) ; + else if (match_xsd_string(ptr, "stylesheet", o, + &req->stylesheet)) + ; + else if (match_xsd_string(ptr, "database", o, + &req->database)) + ; } } else if (!strcmp(method->name, "scanResponse")) @@ -618,7 +618,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, for (; ptr; ptr = ptr->next) { - if (match_element(ptr, "terms")) + if (match_xsd_string(ptr, "version", o, + &(*p)->srw_version)) + ; + else if (match_element(ptr, "terms")) yaz_srw_terms(o, ptr, &res->terms, &res->num_terms, client_data, ns); @@ -626,9 +629,6 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, yaz_srw_diagnostics(o, ptr, &res->diagnostics, &res->num_diagnostics, client_data, ns); - else if (match_xsd_string(ptr, "version", o, - &(*p)->srw_version)) - ; } } else @@ -664,6 +664,12 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, add_xsd_string(ptr, "pQuery", req->query.pqf); break; } + add_xsd_integer(ptr, "startRecord", req->startRecord); + add_xsd_integer(ptr, "maximumRecords", req->maximumRecords); + add_xsd_string(ptr, "recordPacking", req->recordPacking); + add_xsd_string(ptr, "recordSchema", req->recordSchema); + add_xsd_string(ptr, "recordXPath", req->recordXPath); + add_xsd_integer(ptr, "resultSetTTL", req->resultSetTTL); switch(req->sort_type) { case Z_SRW_sort_type_none: @@ -675,14 +681,8 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, add_xsd_string(ptr, "xSortKeys", req->sort.xSortKeys); break; } - add_xsd_integer(ptr, "startRecord", req->startRecord); - add_xsd_integer(ptr, "maximumRecords", req->maximumRecords); - add_xsd_string(ptr, "recordSchema", req->recordSchema); - add_xsd_string(ptr, "recordPacking", req->recordPacking); - add_xsd_string(ptr, "recordXPath", req->recordXPath); - add_xsd_string(ptr, "database", req->database); - add_xsd_integer(ptr, "resultSetTTL", req->resultSetTTL); add_xsd_string(ptr, "stylesheet", req->stylesheet); + add_xsd_string(ptr, "database", req->database); } else if ((*p)->which == Z_SRW_searchRetrieve_response) { @@ -703,13 +703,14 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, yaz_srw_records(o, rptr, &res->records, &res->num_records, client_data, ns); } + add_xsd_integer(ptr, "nextRecordPosition", + res->nextRecordPosition); if (res->num_diagnostics) { xmlNodePtr rptr = xmlNewChild(ptr, 0, "diagnostics", 0); yaz_srw_diagnostics(o, rptr, &res->diagnostics, &res->num_diagnostics, client_data, ns); } - add_xsd_integer(ptr, "nextRecordPosition", res->nextRecordPosition); } else if ((*p)->which == Z_SRW_explain_request) { @@ -721,6 +722,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, add_xsd_string(ptr, "version", (*p)->srw_version); add_xsd_string(ptr, "recordPacking", req->recordPacking); add_xsd_string(ptr, "stylesheet", req->stylesheet); + add_xsd_string(ptr, "database", req->database); } else if ((*p)->which == Z_SRW_explain_response) { @@ -754,6 +756,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, add_xsd_integer(ptr, "responsePosition", req->responsePosition); add_xsd_integer(ptr, "maximumTerms", req->maximumTerms); add_xsd_string(ptr, "stylesheet", req->stylesheet); + add_xsd_string(ptr, "database", req->database); } else if ((*p)->which == Z_SRW_scan_response) { diff --git a/src/srwutil.c b/src/srwutil.c index d284727..226b43a 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2004, Index Data. * See the file LICENSE for details. * - * $Id: srwutil.c,v 1.7 2004-01-07 22:27:41 adam Exp $ + * $Id: srwutil.c,v 1.8 2004-01-09 18:10:32 adam Exp $ */ #include @@ -19,6 +19,65 @@ static int hex_digit (int ch) return 0; } +int yaz_uri_array(const char *path, ODR o, char ***name, char ***val) +{ + int no = 2; + const char *cp; + *name = 0; + if (*path != '?') + return no; + path++; + cp = path; + while ((cp = strchr(cp, '&'))) + { + cp++; + no++; + } + *name = odr_malloc(o, no * sizeof(char**)); + *val = odr_malloc(o, no * sizeof(char**)); + + for (no = 0; *path; no++) + { + const char *p1 = strchr(path, '='); + size_t i = 0; + char *ret; + if (!p1) + break; + + (*name)[no] = odr_malloc(o, (p1-path)+1); + memcpy((*name)[no], path, p1-path); + (*name)[no][p1-path] = '\0'; + + path = p1 + 1; + p1 = strchr(path, '&'); + if (!p1) + p1 = strlen(path) + path; + (*val)[no] = ret = odr_malloc(o, p1 - path + 1); + while (*path && *path != '&') + { + if (*path == '+') + { + ret[i++] = ' '; + path++; + } + else if (*path == '%' && path[1] && path[2]) + { + ret[i++] = hex_digit (path[1])*16 + hex_digit (path[2]); + path = path + 3; + } + else + ret[i++] = *path++; + } + ret[i] = '\0'; + + if (*path) + path++; + } + (*name)[no] = 0; + (*val)[no] = 0; + return no; +} + char *yaz_uri_val(const char *path, const char *name, ODR o) { size_t nlen = strlen(name); @@ -72,6 +131,22 @@ void yaz_uri_val_int(const char *path, const char *name, ODR o, int **intp) *intp = odr_intdup(o, atoi(v)); } +void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d, + int *num, int code, const char *addinfo) +{ + Z_SRW_diagnostic *d_new; + d_new = (Z_SRW_diagnostic *) odr_malloc (o, (*num + 1)* sizeof(**d)); + if (*num) + memcpy (d_new, *d, *num *sizeof(**d)); + *d = d_new; + (*d + *num)->code = odr_intdup(o, code); + if (addinfo) + (*d + *num)->details = odr_strdup(o, addinfo); + else + (*d + *num)->details = 0; + (*num)++; +} + int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, Z_SOAP **soap_package, ODR decode, char **charset) { @@ -147,7 +222,8 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, } int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, - Z_SOAP **soap_package, ODR decode, char **charset) + Z_SOAP **soap_package, ODR decode, char **charset, + Z_SRW_diagnostic **diag, int *num_diag) { #if HAVE_XML2 static Z_SOAP_Handler soap_handlers[2] = { @@ -161,10 +237,20 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, char *db = "Default"; const char *p0 = hreq->path, *p1; const char *operation = 0; + char *version = 0; char *query = 0; char *pQuery = 0; + char *sortKeys = 0; char *stylesheet = 0; - + char *scanClause = 0; + char *recordXPath = 0; + char *recordSchema = 0; + char *recordPacking = "xml"; + char *maximumRecords = 0; + char *startRecord = 0; + char **uri_name; + char **uri_val; + if (charset) *charset = 0; if (*p0 == '/') @@ -178,46 +264,87 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, memcpy (db, p0, p1 - p0); db[p1 - p0] = '\0'; } + yaz_uri_array(p1, decode, &uri_name, &uri_val); #if HAVE_XML2 - query = yaz_uri_val(p1, "query", decode); - pQuery = yaz_uri_val(p1, "pQuery", decode); - operation = yaz_uri_val(p1, "operation", decode); - stylesheet = yaz_uri_val(p1, "stylesheet", decode); + if (uri_name) + { + int i; + for (i = 0; uri_name[i]; i++) + { + char *n = uri_name[i]; + char *v = uri_val[i]; + if (!strcmp(n, "query")) + query = v; + else if (!strcmp(n, "x-pquery")) + pQuery = v; + else if (!strcmp(n, "operation")) + operation = v; + else if (!strcmp(n, "stylesheet")) + stylesheet = v; + else if (!strcmp(n, "sortKeys")) + sortKeys = v; + else if (!strcmp(n, "recordXPath")) + recordXPath = v; + else if (!strcmp(n, "recordSchema")) + recordSchema = v; + else if (!strcmp(n, "recordPacking")) + recordPacking = v; + else if (!strcmp(n, "version")) + version = v; + else if (!strcmp(n, "scanClause")) + scanClause = v; + else if (!strcmp(n, "maximumRecords")) + maximumRecords = v; + else if (!strcmp(n, "startRecord")) + startRecord = v; + else + yaz_add_srw_diagnostic(decode, diag, num_diag, 9, n); + } + } + if (!version) + yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "version"); + else if (version && strcmp(version, "1.1")) + yaz_add_srw_diagnostic(decode, diag, num_diag, 5, "1.1"); if (!operation) + { + yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "operation"); operation = "explain"; - if ((operation && !strcmp(operation, "searchRetrieve")) - || pQuery || query) + } + if (!strcmp(operation, "searchRetrieve")) { Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_searchRetrieve_request); - char *sortKeys = yaz_uri_val(p1, "sortKeys", decode); - + + sr->srw_version = version; *srw_pdu = sr; if (query) { sr->u.request->query_type = Z_SRW_query_type_cql; sr->u.request->query.cql = query; } - if (pQuery) + else if (pQuery) { sr->u.request->query_type = Z_SRW_query_type_pqf; sr->u.request->query.pqf = pQuery; } + else + yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "query"); + if (sortKeys) { sr->u.request->sort_type = Z_SRW_sort_type_sort; sr->u.request->sort.sortKeys = sortKeys; } - sr->u.request->recordXPath = yaz_uri_val(p1, "recordXPath", decode); - sr->u.request->recordSchema = yaz_uri_val(p1, "recordSchema", decode); - sr->u.request->recordPacking = yaz_uri_val(p1, "recordPacking", decode); + sr->u.request->recordXPath = recordXPath; + sr->u.request->recordSchema = recordSchema; + sr->u.request->recordPacking = recordPacking; sr->u.request->stylesheet = stylesheet; - if (!sr->u.request->recordPacking) - sr->u.request->recordPacking = "xml"; - yaz_uri_val_int(p1, "maximumRecords", decode, - &sr->u.request->maximumRecords); - yaz_uri_val_int(p1, "startRecord", decode, - &sr->u.request->startRecord); + if (maximumRecords) + sr->u.request->maximumRecords = + odr_intdup(decode, atoi(maximumRecords)); + if (startRecord) + sr->u.request->startRecord = + odr_intdup(decode, atoi(startRecord)); sr->u.request->database = db; @@ -235,15 +362,13 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, return 0; } - else if (p1 && !strcmp(operation, "explain")) + else if (!strcmp(operation, "explain")) { Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_explain_request); + sr->srw_version = version; *srw_pdu = sr; - sr->u.explain_request->recordPacking = - yaz_uri_val(p1, "recordPacking", decode); - if (!sr->u.explain_request->recordPacking) - sr->u.explain_request->recordPacking = "xml"; + sr->u.explain_request->recordPacking = recordPacking; sr->u.explain_request->database = db; sr->u.explain_request->stylesheet = stylesheet; @@ -262,6 +387,62 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, return 0; } + else if (!strcmp(operation, "scan")) + { + Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_scan_request); + + if (!scanClause) + yaz_add_srw_diagnostic(decode, diag, num_diag, 7, + "scanClause"); + sr->srw_version = version; + *srw_pdu = sr; + sr->u.scan_request->scanClause = scanClause; + sr->u.scan_request->database = db; + sr->u.scan_request->stylesheet = stylesheet; + + (*soap_package) = odr_malloc(decode, sizeof(**soap_package)); + (*soap_package)->which = Z_SOAP_generic; + + (*soap_package)->u.generic = + odr_malloc(decode, sizeof(*(*soap_package)->u.generic)); + + (*soap_package)->u.generic->p = sr; + (*soap_package)->u.generic->ns = soap_handlers[0].ns; + (*soap_package)->u.generic->no = 0; + + (*soap_package)->ns = "SRU"; + + return 0; + } + else + { + /* unsupported operation ... */ + /* Act as if we received a explain request and throw diagnostic. */ + + Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_explain_request); + + sr->srw_version = version; + *srw_pdu = sr; + sr->u.explain_request->recordPacking = recordPacking; + sr->u.explain_request->database = db; + + sr->u.explain_request->stylesheet = stylesheet; + + (*soap_package) = odr_malloc(decode, sizeof(**soap_package)); + (*soap_package)->which = Z_SOAP_generic; + + (*soap_package)->u.generic = + odr_malloc(decode, sizeof(*(*soap_package)->u.generic)); + + (*soap_package)->u.generic->p = sr; + (*soap_package)->u.generic->ns = soap_handlers[0].ns; + (*soap_package)->u.generic->no = 0; + + (*soap_package)->ns = "SRU"; + + yaz_add_srw_diagnostic(decode, diag, num_diag, 4, operation); + return 0; + } #endif return 1; } @@ -322,6 +503,23 @@ Z_SRW_PDU *yaz_srw_get(ODR o, int which) Z_SRW_recordPacking_string; sr->u.explain_response->diagnostics = 0; sr->u.explain_response->num_diagnostics = 0; + break; + case Z_SRW_scan_request: + sr->u.scan_request = (Z_SRW_scanRequest *) + odr_malloc(o, sizeof(*sr->u.scan_request)); + sr->u.scan_request->database = 0; + sr->u.scan_request->stylesheet = 0; + sr->u.scan_request->maximumTerms = 0; + sr->u.scan_request->responsePosition = 0; + sr->u.scan_request->scanClause = 0; + break; + case Z_SRW_scan_response: + sr->u.scan_response = (Z_SRW_scanResponse *) + odr_malloc(o, sizeof(*sr->u.scan_response)); + sr->u.scan_response->terms = 0; + sr->u.scan_response->num_terms = 0; + sr->u.scan_response->diagnostics = 0; + sr->u.scan_response->num_diagnostics = 0; } return sr; } -- 1.7.10.4