* 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
} 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;
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);
* 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 $
*/
/*
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,
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;
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)
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);
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);
* 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 <stdio.h>
}
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;
}
* 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 <yaz/srw.h>
}
-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;
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;
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))
;
}
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;
}
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);
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;
* 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 <yaz/srw.h>
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;
* 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.
*/
}
#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},
{
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;
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
{
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