* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: srw.h,v 1.34 2007-05-23 11:54:47 adam Exp $ */
+/* $Id: srw.h,v 1.35 2007-08-23 14:23:23 adam Exp $ */
/**
* \file srw.h
Z_SRW_PDU **handler_data,
void *client_data, const char *ns);
YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o);
+YAZ_EXPORT Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version);
YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
YAZ_EXPORT Z_SRW_recordVersion *yaz_srw_get_record_versions(ODR o, int num);
YAZ_EXPORT Z_SRW_extra_record *yaz_srw_get_extra_record(ODR o);
YAZ_EXPORT int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
ODR odr, const char *charset);
+YAZ_EXPORT char *yaz_negotiate_sru_version(char *input_ver);
+
#define YAZ_XMLNS_SRU_v1_0 "http://www.loc.gov/zing/srw/v1.0/"
#define YAZ_XMLNS_SRU_v1_1 "http://www.loc.gov/zing/srw/"
#define YAZ_XMLNS_DIAG_v1_1 "http://www.loc.gov/zing/srw/diagnostic/"
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.126 2007-08-22 08:11:28 adam Exp $
+ * $Id: seshigh.c,v 1.127 2007-08-23 14:23:23 adam Exp $
*/
/**
* \file seshigh.c
if (sr->which == Z_SRW_searchRetrieve_request)
{
Z_SRW_PDU *res =
- yaz_srw_get(assoc->encode, Z_SRW_searchRetrieve_response);
-
+ yaz_srw_get_pdu(assoc->encode, Z_SRW_searchRetrieve_response,
+ sr->srw_version);
stylesheet = sr->u.request->stylesheet;
if (num_diagnostic)
{
}
else if (sr->which == Z_SRW_explain_request)
{
- Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_explain_response);
+ Z_SRW_PDU *res = yaz_srw_get_pdu(o, Z_SRW_explain_response,
+ sr->srw_version);
stylesheet = sr->u.explain_request->stylesheet;
if (num_diagnostic)
{
}
else if (sr->which == Z_SRW_scan_request)
{
- Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_scan_response);
+ Z_SRW_PDU *res = yaz_srw_get_pdu(o, Z_SRW_scan_response,
+ sr->srw_version);
stylesheet = sr->u.scan_request->stylesheet;
if (num_diagnostic)
{
}
else if (sr->which == Z_SRW_update_request)
{
- Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_update_response);
+ Z_SRW_PDU *res = yaz_srw_get_pdu(o, Z_SRW_update_response,
+ sr->srw_version);
yaz_log(YLOG_DEBUG, "handling SRW UpdateRequest");
if (num_diagnostic)
{
assoc->init->implementation_name,
odr_prepend(assoc->encode, "GFS", resp->implementationName));
- version = odr_strdup(assoc->encode, "$Revision: 1.126 $");
+ version = odr_strdup(assoc->encode, "$Revision: 1.127 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
resp->implementationVersion = odr_prepend(assoc->encode,
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.56 2007-05-23 13:11:11 adam Exp $
+ * $Id: srw.c,v 1.57 2007-08-23 14:23:23 adam Exp $
*/
/**
* \file srw.c
return 1;
}
+char *yaz_negotiate_sru_version(char *input_ver)
+{
+ if (!input_ver)
+ input_ver = "1.1";
+
+ if (!strcmp(input_ver, "1.1"))
+ return "1.1";
+ return "1.2"; /* our latest supported version */
+}
+
static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec,
Z_SRW_extra_record **extra,
void *client_data, const char *ns)
{
Z_SRW_PDU **p = handler_data;
xmlNodePtr method = pptr->children;
+ char *neg_version;
while (method && method->type == XML_TEXT_NODE)
method = method->next;
*p = 0;
return -1;
}
+ neg_version = yaz_negotiate_sru_version((*p)->srw_version);
+ if (neg_version)
+ (*p)->srw_version = neg_version;
}
else if (o->direction == ODR_ENCODE)
{
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: srwutil.c,v 1.59 2007-05-24 10:18:36 adam Exp $
+ * $Id: srwutil.c,v 1.60 2007-08-23 14:23:23 adam Exp $
*/
/**
* \file srwutil.c
YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "version");
version = "1.1";
}
- if (strcmp(version, "1.1"))
+
+ version = yaz_negotiate_sru_version(version);
+
+ if (!version)
+ { /* negotiation failed. */
yaz_add_srw_diagnostic(decode, diag, num_diag,
- YAZ_SRW_UNSUPP_VERSION, "1.1");
+ YAZ_SRW_UNSUPP_VERSION, "1.2");
+ version = "1.2";
+ }
+
if (!operation)
{
if (uri_name)
return yaz_srw_get_records(o, 1);
}
-Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o)
+static Z_SRW_PDU *yaz_srw_get_core_ver(ODR o, const char *version)
{
Z_SRW_PDU *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(*p));
- p->srw_version = odr_strdup(o, "1.1");
+ p->srw_version = odr_strdup(o, version);
p->username = 0;
p->password = 0;
p->extra_args = 0;
return p;
}
+Z_SRW_PDU *yaz_srw_get_core_v_1_1(ODR o)
+{
+ return yaz_srw_et_core_ver(o, "1.1");
+}
+
Z_SRW_PDU *yaz_srw_get(ODR o, int which)
{
- Z_SRW_PDU *sr = yaz_srw_get_core_v_1_1(o);
+ return yaz_srw_get_pdu(o, which, "1.2");
+}
+
+Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version)
+{
+ Z_SRW_PDU *sr = yaz_srw_get_core_ver(o, version);
+
sr->which = which;
switch(which)
{
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.142 2007-08-23 12:24:38 adam Exp $
+ * $Id: zoom-c.c,v 1.143 2007-08-23 14:23:23 adam Exp $
*/
/**
* \file zoom-c.c
c->m_queue_front = 0;
c->m_queue_back = 0;
+
+ c->sru_version = xstrdup("1.1");
return c;
}
val = ZOOM_options_get(c->options, "sru");
c->sru_mode = get_sru_mode_from_string(val);
+ xfree(c->sru_version);
+ val = ZOOM_options_get(c->options, "sru_version");
+ c->sru_version = xstrdup(val ? val : "1.1");
+
ZOOM_options_set(c->options, "host", c->host_port);
xfree(c->cookie_out);
xfree(c->user);
xfree(c->group);
xfree(c->password);
+ xfree(c->sru_version);
xfree(c);
}
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.142 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.143 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion =
}
assert(resultset->query);
- sr = yaz_srw_get(c->odr_out, Z_SRW_searchRetrieve_request);
+ sr = yaz_srw_get_pdu(c->odr_out, Z_SRW_searchRetrieve_request,
+ c->sru_version);
if (resultset->query->z_query->which == Z_Query_type_104
&& resultset->query->z_query->u.type_104->which == Z_External_CQL)
assert (c->tasks->which == ZOOM_TASK_SCAN);
scan = c->tasks->u.scan.scan;
- sr = yaz_srw_get(c->odr_out, Z_SRW_scan_request);
+ sr = yaz_srw_get_pdu(c->odr_out, Z_SRW_scan_request, c->sru_version);
/* SRU scan can only carry CQL and PQF */
if (scan->query->z_query->which == Z_Query_type_104)
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-p.h,v 1.21 2007-08-16 10:09:36 adam Exp $
+ * $Id: zoom-p.h,v 1.22 2007-08-23 14:23:23 adam Exp $
*/
/**
* \file zoom-p.h
char *cookie_out;
char *cookie_in;
char *client_IP;
+ char *sru_version;
char *user;
char *group;