X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-c.c;h=3ada8d1ca85c65b858cbf73f527fcf28fc0da9b2;hb=fadf07ca8b5d84ed21b83e63bfec438666e11587;hp=ea23a86af56f9a695807e9c8b163d126210b3f9e;hpb=a5a9ecf542c87afaa06315bcb389686bedae07b3;p=yaz-moved-to-github.git diff --git a/src/zoom-c.c b/src/zoom-c.c index ea23a86..3ada8d1 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.136 2007-06-25 18:34:09 adam Exp $ + * $Id: zoom-c.c,v 1.140 2007-08-15 17:53:11 mike Exp $ */ /** * \file zoom-c.c @@ -28,6 +28,7 @@ #include #include #include +#include static int log_api = 0; static int log_details = 0; @@ -1341,7 +1342,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.136 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.140 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -2690,6 +2691,19 @@ ZOOM_API(ZOOM_scanset) { yaz_log(log_api, "%p ZOOM_connection_scan1 q=%p CQL '%s'", c, q, q->query_string); + /* + * ### This is wrong: if ZOOM_query_cql2rpn() was used, then + * the query already been translated to PQF, so we'd be in the + * previous branch. We only get here if the client submitted + * CQL to be interepreted by the server using + * ZOOM_query_cql(), in which case we should send it as-is. + * We can't do that in Z39.50 as the ScanRequest APDU has no + * slot in which to place the CQL, but we could and should do + * it for SRU connections. At present, we can't do that + * because there is no slot in the ZOOM_scanset structure to + * save the CQL so that it can be sent when the ZOOM_TASK_SCAN + * fires. + */ start = freeme = cql2pqf(c, q->query_string); if (start == 0) return 0; @@ -3124,6 +3138,7 @@ static Z_APDU *create_update_package(ZOOM_package p) const char *recordIdNumber = ZOOM_options_get(p->options, "recordIdNumber"); const char *record_buf = ZOOM_options_get(p->options, "record"); const char *syntax_str = ZOOM_options_get(p->options, "syntax"); + const char *version = ZOOM_options_get(p->options, "updateVersion"); const char *correlationInfo_note = ZOOM_options_get(p->options, "correlationInfo.note"); @@ -3131,7 +3146,10 @@ static Z_APDU *create_update_package(ZOOM_package p) ZOOM_options_get(p->options, "correlationInfo.id"); int action_no = -1; Odr_oid *syntax_oid = 0; + const Odr_oid *package_oid = yaz_oid_extserv_database_update; + if (!version) + version = "3"; if (!syntax_str) syntax_str = "xml"; if (!record_buf) @@ -3152,8 +3170,27 @@ static Z_APDU *create_update_package(ZOOM_package p) if (num_db > 0) first_db = db[0]; - if (!action) - action = "specialUpdate"; + switch(*version) + { + case '1': + package_oid = yaz_oid_extserv_database_update_first_version; + /* old update does not support specialUpdate */ + if (!action) + action = "recordInsert"; + break; + case '2': + if (!action) + action = "specialUpdate"; + package_oid = yaz_oid_extserv_database_update_second_version; + break; + case '3': + if (!action) + action = "specialUpdate"; + package_oid = yaz_oid_extserv_database_update; + break; + default: + return 0; + } if (!strcmp(action, "recordInsert")) action_no = Z_IUOriginPartToKeep_recordInsert; @@ -3168,7 +3205,7 @@ static Z_APDU *create_update_package(ZOOM_package p) else return 0; - apdu = create_es_package(p, yaz_oid_extserv_database_update); + apdu = create_es_package(p, package_oid); if (apdu) { Z_IUOriginPartToKeep *toKeep; @@ -3179,10 +3216,8 @@ static Z_APDU *create_update_package(ZOOM_package p) ZOOM_options_get(p->options, "elementSetName"); apdu->u.extendedServicesRequest->taskSpecificParameters = r; - - r->direct_reference = odr_oiddup(p->odr_out, - yaz_oid_extserv_database_update); + r->direct_reference = odr_oiddup(p->odr_out, package_oid); r->descriptor = 0; r->which = Z_External_update; r->indirect_reference = 0; @@ -3535,7 +3570,7 @@ static void recv_apdu(ZOOM_connection c, Z_APDU *apdu) switch(apdu->which) { case Z_APDU_initResponse: - yaz_log(log_api, "%p recv_apd: Received Init response", c); + yaz_log(log_api, "%p recv_apdu: Received Init response", c); initrs = apdu->u.initResponse; ZOOM_connection_option_set(c, "serverImplementationId", initrs->implementationId ? @@ -3853,11 +3888,19 @@ static int do_read(ZOOM_connection c) { int x; int err = odr_geterrorx(c->odr_in, &x); - char msg[60]; + char msg[100]; const char *element = odr_getelement(c->odr_in); - sprintf(msg, "ODR code %d:%d element=%-20s", - err, x, element ? element : ""); + yaz_snprintf(msg, sizeof(msg), + "ODR code %d:%d element=%s offset=%d", + err, x, element ? element : "", + odr_offset(c->odr_in)); set_ZOOM_error(c, ZOOM_ERROR_DECODE, msg); + if (log_api) + { + FILE *ber_file = yaz_log_file(); + if (ber_file) + odr_dumpBER(ber_file, c->buf_in, r); + } do_close(c); } else if (gdu->which == Z_GDU_Z3950)