COmment.
[yaz-moved-to-github.git] / src / zoom-c.c
index 6f6e1ad..3ada8d1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-c.c,v 1.138 2007-06-29 08:05:07 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 <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;
@@ -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.138 $");
+    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;
@@ -3874,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 : "<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)