* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.135 2007-06-21 09:00:53 adam Exp $
+ * $Id: zoom-c.c,v 1.140 2007-08-15 17:53:11 mike Exp $
*/
/**
* \file zoom-c.c
#include <yaz/ccl.h>
#include <yaz/query-charset.h>
#include <yaz/copy_types.h>
+#include <yaz/snprintf.h>
static int log_api = 0;
static int log_details = 0;
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.135 $");
+ 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 =
{
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;
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");
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)
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;
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;
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;
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 ?
{
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 : "<unknown>");
+ yaz_snprintf(msg, sizeof(msg),
+ "ODR code %d:%d element=%s offset=%d",
+ err, x, element ? element : "<unknown>",
+ 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)
if (c->cs->io_pending & CS_WANT_READ)
mask += ZOOM_SELECT_READ;
ZOOM_connection_set_mask(c, mask);
+ event = ZOOM_Event_create(ZOOM_EVENT_NONE);
+ ZOOM_connection_put_event(c, event);
}
else if (ret == 0)
{