From: Adam Dickmeiss Date: Sun, 23 Feb 2003 14:26:57 +0000 (+0000) Subject: Renamed Z_SRW_searchRetrieve to Z_SRW_PDU X-Git-Tag: YAZ.2.0~8 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=5f9dfb9266ab741d41a636249a39a254e4fb7211;p=yaz-moved-to-github.git Renamed Z_SRW_searchRetrieve to Z_SRW_PDU --- diff --git a/include/yaz/srw.h b/include/yaz/srw.h index 18cc743..5cbeab0 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: srw.h,v 1.4 2003-02-19 15:22:11 adam Exp $ + * $Id: srw.h,v 1.5 2003-02-23 14:26:57 adam Exp $ */ #ifndef YAZ_SRW_H @@ -23,11 +23,26 @@ typedef struct { } Z_SRW_diagnostic; typedef struct { - char *query; - char *pQuery; - void *xQuery; - char *sortKeys; - void *xSortKeys; + +#define Z_SRW_query_type_cql 1 +#define Z_SRW_query_type_xcql 2 +#define Z_SRW_query_type_pqf 3 + int query_type; + union { + char *cql; + char *xcql; + char *pqf; + } query; + +#define Z_SRW_sort_type_none 1 +#define Z_SRW_sort_type_sort 2 +#define Z_SRW_sort_type_xSort 3 + int sort_type; + union { + char *none; + char *sortKeys; + char *xSortKeys; + } sort; int *startRecord; int *maximumRecords; char *recordSchema; @@ -57,12 +72,12 @@ typedef struct { Z_SRW_searchRetrieveRequest *request; Z_SRW_searchRetrieveResponse *response; } u; -} Z_SRW_searchRetrieve; +} Z_SRW_PDU; YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr, - Z_SRW_searchRetrieve **handler_data, + Z_SRW_PDU **handler_data, void *client_data, const char *ns); -YAZ_EXPORT Z_SRW_searchRetrieve *yaz_srw_get(ODR o, int which); +YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which); YAZ_EXPORT const char *yaz_diag_srw_str (int code); diff --git a/server/seshigh.c b/server/seshigh.c index 4427a88..bb27754 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.145 2003-02-21 12:08:59 adam Exp $ + * $Id: seshigh.c,v 1.146 2003-02-23 14:26:57 adam Exp $ */ /* @@ -541,7 +541,7 @@ static void srw_bend_search(association *assoc, request *req, rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query)); - if (srw_req->query) + if (srw_req->query_type == Z_SRW_query_type_cql) { ext = (Z_External *) odr_malloc(assoc->decode, sizeof(*ext)); ext->direct_reference = odr_getoidbystr(assoc->decode, @@ -549,21 +549,20 @@ static void srw_bend_search(association *assoc, request *req, ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_CQL; - ext->u.cql = srw_req->query; + ext->u.cql = srw_req->query.cql; rr.query->which = Z_Query_type_104; rr.query->u.type_104 = ext; } - else if (srw_req->pQuery) + else if (srw_req->query_type == Z_SRW_query_type_pqf) { Z_RPNQuery *RPNquery; YAZ_PQF_Parser pqf_parser; pqf_parser = yaz_pqf_create (); - yaz_log(LOG_LOG, "PQF: %s", srw_req->pQuery); - - RPNquery = yaz_pqf_parse (pqf_parser, assoc->decode, srw_req->pQuery); + RPNquery = yaz_pqf_parse (pqf_parser, assoc->decode, + srw_req->query.pqf); if (!RPNquery) { const char *pqf_msg; @@ -583,7 +582,7 @@ static void srw_bend_search(association *assoc, request *req, else srw_error = 11; - if (srw_req->sortKeys || srw_req->xSortKeys) + if (srw_req->sort_type != Z_SRW_sort_type_none) srw_error = 80; if (srw_error) @@ -791,11 +790,11 @@ static void process_http_request(association *assoc, request *req) soap_package->u.generic->no == 0) { /* SRW package */ - Z_SRW_searchRetrieve *sr = soap_package->u.generic->p; + Z_SRW_PDU *sr = soap_package->u.generic->p; if (sr->which == Z_SRW_searchRetrieve_request) { - Z_SRW_searchRetrieve *res = + Z_SRW_PDU *res = yaz_srw_get(assoc->encode, Z_SRW_searchRetrieve_response); @@ -875,7 +874,7 @@ static void process_http_request(association *assoc, request *req) if (alive && isdigit(*alive)) t = atoi(alive); else - t = 30; + t = 15; if (t < 0 || t > 3600) t = 3600; iochan_settimeout(assoc->client_chan,t); diff --git a/server/statserv.c b/server/statserv.c index be221e2..199c6f4 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -6,7 +6,7 @@ * NT threaded server code by * Chas Woodfield, Fretwell Downing Informatics. * - * $Id: statserv.c,v 1.95 2003-02-20 15:15:04 adam Exp $ + * $Id: statserv.c,v 1.96 2003-02-23 14:26:58 adam Exp $ */ #include @@ -657,7 +657,8 @@ static int add_listener(char *where, int what) } if (cs_bind(l, ap, CS_SERVER) < 0) { - yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", where); + yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", + where, errno); cs_close (l); return -1; } diff --git a/zutil/srw.c b/zutil/srw.c index bde6bc5..4a66bbd 100644 --- a/zutil/srw.c +++ b/zutil/srw.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: srw.c,v 1.6 2003-02-19 15:22:11 adam Exp $ + * $Id: srw.c,v 1.7 2003-02-23 14:26:58 adam Exp $ */ #include @@ -221,7 +221,7 @@ static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs, } -int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data, +int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, void *client_data, const char *ns) { xmlNodePtr pptr = vptr; @@ -236,18 +236,17 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data, return -1; if (method && !strcmp(method->name, "searchRetrieveRequest")) { - Z_SRW_searchRetrieve **p = handler_data; + Z_SRW_PDU **p = handler_data; xmlNodePtr ptr = method->children; Z_SRW_searchRetrieveRequest *req; *p = odr_malloc(o, sizeof(**p)); (*p)->which = Z_SRW_searchRetrieve_request; req = (*p)->u.request = odr_malloc(o, sizeof(*req)); - req->query = 0; - req->pQuery = 0; - req->xQuery = 0; - req->sortKeys = 0; - req->xSortKeys = 0; + req->query_type = Z_SRW_query_type_cql; + req->query.cql = 0; + req->sort_type = Z_SRW_sort_type_none; + req->sort.none = 0; req->startRecord = 0; req->maximumRecords = 0; req->recordSchema = 0; @@ -257,14 +256,17 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data, for (; ptr; ptr = ptr->next) { if (match_xsd_string(ptr, "query", o, - &req->query)) - ; + &req->query.cql)) + req->query_type = Z_SRW_query_type_cql; else if (match_xsd_string(ptr, "pQuery", o, - &req->pQuery)) - ; + &req->query.pqf)) + req->query_type = Z_SRW_query_type_pqf; + 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->sortKeys)) - ; + &req->sort.sortKeys)) + req->sort_type = Z_SRW_sort_type_sort; else if (match_xsd_string(ptr, "recordSchema", o, &req->recordSchema)) ; @@ -285,7 +287,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data, } else if (method && !strcmp(method->name, "searchRetrieveResponse")) { - Z_SRW_searchRetrieve **p = handler_data; + Z_SRW_PDU **p = handler_data; xmlNodePtr ptr = method->children; Z_SRW_searchRetrieveResponse *res; @@ -333,17 +335,36 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data, } else if (o->direction == ODR_ENCODE) { - Z_SRW_searchRetrieve **p = handler_data; + Z_SRW_PDU **p = handler_data; if ((*p)->which == Z_SRW_searchRetrieve_request) { Z_SRW_searchRetrieveRequest *req = (*p)->u.request; xmlNsPtr ns_srw = xmlNewNs(pptr, ns, "zs"); xmlNodePtr ptr = xmlNewChild(pptr, ns_srw, "searchRetrieveRequest", 0); - - add_xsd_string(ptr, "query", req->query); - add_xsd_string(ptr, "pQuery", req->pQuery); - add_xsd_string(ptr, "sortKeys", req->sortKeys); + switch(req->query_type) + { + case Z_SRW_query_type_cql: + add_xsd_string(ptr, "query", req->query.cql); + break; + case Z_SRW_query_type_xcql: + add_xsd_string(ptr, "xQuery", req->query.xcql); + break; + case Z_SRW_query_type_pqf: + add_xsd_string(ptr, "pQuery", req->query.pqf); + break; + } + switch(req->sort_type) + { + case Z_SRW_sort_type_none: + break; + case Z_SRW_sort_type_sort: + add_xsd_string(ptr, "sortKeys", req->sort.sortKeys); + break; + case Z_SRW_sort_type_xSort: + 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); @@ -381,19 +402,18 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data, return 0; } -Z_SRW_searchRetrieve *yaz_srw_get(ODR o, int which) +Z_SRW_PDU *yaz_srw_get(ODR o, int which) { - Z_SRW_searchRetrieve *sr = odr_malloc(o, sizeof(*o)); + Z_SRW_PDU *sr = odr_malloc(o, sizeof(*o)); sr->which = which; switch(which) { case Z_SRW_searchRetrieve_request: sr->u.request = odr_malloc(o, sizeof(*sr->u.request)); - sr->u.request->query = 0; - sr->u.request->xQuery = 0; - sr->u.request->pQuery = 0; - sr->u.request->sortKeys = 0; - sr->u.request->xSortKeys = 0; + sr->u.request->query_type = Z_SRW_query_type_cql; + sr->u.request->query.cql = 0; + sr->u.request->sort_type = Z_SRW_sort_type_none; + sr->u.request->sort.none = 0; sr->u.request->startRecord = 0; sr->u.request->maximumRecords = 0; sr->u.request->recordSchema = 0; diff --git a/zutil/srwtst.c b/zutil/srwtst.c index d31dca2..984b460 100644 --- a/zutil/srwtst.c +++ b/zutil/srwtst.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: srwtst.c,v 1.3 2003-02-17 22:35:48 adam Exp $ + * $Id: srwtst.c,v 1.4 2003-02-23 14:26:58 adam Exp $ */ #include @@ -49,7 +49,7 @@ int main(int argc, char **argv) if (soap_package->which == Z_SOAP_generic && soap_package->u.generic->no == 0) { - Z_SRW_searchRetrieve *sr = soap_package->u.generic->p; + Z_SRW_PDU *sr = soap_package->u.generic->p; if (sr->which == Z_SRW_searchRetrieve_request) { Z_SRW_searchRetrieveRequest *req = sr->u.request; diff --git a/zutil/zoom-c.c b/zutil/zoom-c.c index 48a2472..82c7c3e 100644 --- a/zutil/zoom-c.c +++ b/zutil/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (c) 2000-2003, Index Data * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.27 2003-02-21 12:08:59 adam Exp $ + * $Id: zoom-c.c,v 1.28 2003-02-23 14:26:58 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -979,7 +979,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) } #if HAVE_XML2 -static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr) +static zoom_ret send_srw (ZOOM_connection c, Z_SRW_PDU *sr) { Z_SOAP_Handler h[2] = { {"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec}, @@ -1026,7 +1026,7 @@ static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) { int i; ZOOM_resultset resultset = 0; - Z_SRW_searchRetrieve *sr = 0; + Z_SRW_PDU *sr = 0; if (c->error) /* don't continue on error */ return zoom_complete; @@ -1066,12 +1066,15 @@ static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) if (resultset->query->z_query->which == Z_Query_type_104 && resultset->query->z_query->u.type_104->which == Z_External_CQL) { - sr->u.request->query = resultset->query->z_query->u.type_104->u.cql; + + sr->u.request->query_type = Z_SRW_query_type_cql; + sr->u.request->query.cql =resultset->query->z_query->u.type_104->u.cql; } else if (resultset->query->z_query->which == Z_Query_type_1 && resultset->query->z_query->u.type_1) { - sr->u.request->pQuery = resultset->query->query_string; + sr->u.request->query_type = Z_SRW_query_type_pqf; + sr->u.request->query.pqf = resultset->query->query_string; } else { @@ -2488,7 +2491,7 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) if (!ret && soap_package->which == Z_SOAP_generic && soap_package->u.generic->no == 0) { - Z_SRW_searchRetrieve *sr = soap_package->u.generic->p; + Z_SRW_PDU *sr = soap_package->u.generic->p; if (sr->which == Z_SRW_searchRetrieve_response) handle_srw_response(c, sr->u.response); else