From 64ef77f3378cbd213bf2f9cc775e5e81a77303f2 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 9 Mar 2006 17:13:43 +0000 Subject: [PATCH] Support for SRU and SRW. Mostly this is provided by the YAZ GFS, but changes are needed to allow for the case where there is no RPN query (due to absent on invalid element in GFS configuration) so that CQL is passed through natively; and also to fake up an {REQ_FORM} and {REP_FORM} parameters set to the "text/xml" OID when this information is not specified by the GFS. --- SimpleServer.xs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/SimpleServer.xs b/SimpleServer.xs index 862ef21..c945f50 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -1,5 +1,5 @@ /* - * $Id: SimpleServer.xs,v 1.36 2006-01-30 21:29:41 adam Exp $ + * $Id: SimpleServer.xs,v 1.37 2006-03-09 17:13:43 mike Exp $ * ---------------------------------------------------------------------- * * Copyright (c) 2000-2004, Index Data. @@ -615,6 +615,7 @@ int bend_search(void *handle, bend_search_rr *rr) SV *point; Zfront_handle *zhandle = (Zfront_handle *)handle; CV* handler_cv = 0; + SV *rpnSV; dSP; ENTER; @@ -641,15 +642,23 @@ int bend_search(void *handle, bend_search_rr *rr) hv_store(href, "DATABASES", 9, newRV( (SV*) aref), 0); hv_store(href, "HANDLE", 6, zhandle->handle, 0); hv_store(href, "PID", 3, newSViv(getpid()), 0); - hv_store(href, "RPN", 3, zquery2perl(rr->query), 0); + if ((rpnSV = zquery2perl(rr->query)) != 0) { + hv_store(href, "RPN", 3, rpnSV, 0); + } query = zquery2pquery(rr->query); if (query) { hv_store(href, "QUERY", 5, newSVpv((char *)query->buf, query->pos), 0); } + else if (rr->query->which == Z_Query_type_104 && + rr->query->u.type_104->which == Z_External_CQL) { + hv_store(href, "CQL", 3, + newSVpv(rr->query->u.type_104->u.cql, 0), 0); + } else { rr->errcode = 108; + return 0; } PUSHMARK(sp); @@ -683,7 +692,8 @@ int bend_search(void *handle, bend_search_rr *rr) zhandle->handle = point; sv_free( (SV*) aref); sv_free( (SV*) href); - wrbuf_free(query, 1); + if (query) + wrbuf_free(query, 1); PUTBACK; FREETMPS; LEAVE; @@ -790,7 +800,13 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) href = newHV(); hv_store(href, "SETNAME", 7, newSVpv(rr->setname, 0), 0); temp = hv_store(href, "OFFSET", 6, newSViv(rr->number), 0); - oid_dotted = oid2dotted(rr->request_format_raw); + if (rr->request_format_raw != 0) { + oid_dotted = oid2dotted(rr->request_format_raw); + } else { + /* Probably an SRU request: assume XML is required */ + oid_dotted = wrbuf_alloc(); + wrbuf_puts(oid_dotted, "1.2.840.10003.5.109.10"); + } hv_store(href, "REQ_FORM", 8, newSVpv((char *)oid_dotted->buf, oid_dotted->pos), 0); hv_store(href, "REP_FORM", 8, newSVpv((char *)oid_dotted->buf, oid_dotted->pos), 0); hv_store(href, "BASENAME", 8, newSVpv("", 0), 0); @@ -818,7 +834,11 @@ int bend_fetch(void *handle, bend_fetch_rr *rr) } else { - rr->errcode = 26; + /* This is where we end up in the case of + * SRU. Since record composition ("element + * sets") are meaningless in SRU anyway, we + * just skip this. + */ } } -- 1.7.10.4