Doxygen comment.
[yaz-moved-to-github.git] / src / zoom-c.c
index 7dc2b21..f6184f9 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-c.c,v 1.83 2006-08-15 13:31:07 adam Exp $
+ * $Id: zoom-c.c,v 1.86 2006-08-24 12:51:49 adam Exp $
  */
 /**
  * \file zoom-c.c
@@ -371,6 +371,8 @@ ZOOM_API(void)
     yaz_log(log_api, "%p ZOOM_connection_connect host=%s portnum=%d",
             c, host, portnum);
 
+    set_ZOOM_error(c, ZOOM_ERROR_NONE, 0);
+
     if (c->cs)
     {
         yaz_log(log_details, "%p ZOOM_connection_connect reconnect ok", c);
@@ -472,8 +474,6 @@ ZOOM_API(void)
     c->async = ZOOM_options_get_bool(c->options, "async", 0);
     yaz_log(log_details, "%p ZOOM_connection_connect async=%d", c, c->async);
  
-    set_ZOOM_error(c, ZOOM_ERROR_NONE, 0);
-
     task = ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
 
     if (!c->async)
@@ -1187,23 +1187,28 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c)
     ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_1);
     ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2);
     ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3);
-
+    
     /* Index Data's Z39.50 Implementor Id is 81 */
-    ireq->implementationId = odr_prepend(c->odr_out,
-                                         ZOOM_options_get(c->options, "implementationId"),
-                                         odr_prepend(c->odr_out, "81", ireq->implementationId));
-
-    ireq->implementationName = odr_prepend(c->odr_out,
-                                           ZOOM_options_get(c->options, "implementationName"),
-                                           odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
-
-    version = odr_strdup(c->odr_out, "$Revision: 1.83 $");
+    ireq->implementationId =
+        odr_prepend(c->odr_out,
+                    ZOOM_options_get(c->options, "implementationId"),
+                    odr_prepend(c->odr_out, "81", ireq->implementationId));
+    
+    ireq->implementationName = 
+        odr_prepend(c->odr_out,
+                    ZOOM_options_get(c->options, "implementationName"),
+                    odr_prepend(c->odr_out, "ZOOM-C",
+                                ireq->implementationName));
+    
+    version = odr_strdup(c->odr_out, "$Revision: 1.86 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
-    ireq->implementationVersion = odr_prepend(c->odr_out,
-                                              ZOOM_options_get(c->options, "implementationVersion"),
-                                              odr_prepend(c->odr_out, &version[11], ireq->implementationVersion));
-
+    ireq->implementationVersion = 
+        odr_prepend(c->odr_out,
+                    ZOOM_options_get(c->options, "implementationVersion"),
+                    odr_prepend(c->odr_out, &version[11],
+                                ireq->implementationVersion));
+    
     *ireq->maximumRecordSize =
         ZOOM_options_get_int(c->options, "maximumRecordSize", 1024*1024);
     *ireq->preferredMessageSize =
@@ -1313,7 +1318,7 @@ static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
     int *start, *count;
     ZOOM_resultset resultset = 0;
     Z_SRW_PDU *sr = 0;
-    const char *recordPacking = 0;
+    const char *option_val = 0;
 
     if (c->error)                  /* don't continue on error */
         return zoom_complete;
@@ -1381,12 +1386,14 @@ static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
     sr->u.request->maximumRecords = odr_intdup(
         c->odr_out, resultset->step>0 ? resultset->step : *count);
     sr->u.request->recordSchema = resultset->schema;
-
-    recordPacking = ZOOM_resultset_option_get(resultset, "recordPacking");
-
-    if (recordPacking)
-        sr->u.request->recordPacking = odr_strdup(c->odr_out, recordPacking);
     
+    option_val = ZOOM_resultset_option_get(resultset, "recordPacking");
+    if (option_val)
+        sr->u.request->recordPacking = odr_strdup(c->odr_out, option_val);
+
+    option_val = ZOOM_resultset_option_get(resultset, "extraArgs");
+    if (option_val)
+        sr->extra_args = odr_strdup(c->odr_out, option_val);
     return send_srw(c, sr);
 }
 #else
@@ -2503,15 +2510,9 @@ ZOOM_API(ZOOM_scanset)
 ZOOM_API(ZOOM_scanset)
     ZOOM_connection_scan1(ZOOM_connection c, ZOOM_query q)
 {
-    ZOOM_scanset scan = (ZOOM_scanset) xmalloc(sizeof(*scan));
     char *start;
     char *freeme = 0;
-
-    scan->connection = c;
-    scan->odr = odr_createmem(ODR_DECODE);
-    scan->options = ZOOM_options_create_with_parent(c->options);
-    scan->refcount = 1;
-    scan->scan_response = 0;
+    ZOOM_scanset scan = 0;
 
     /*
      * We need to check the query-type, so we can recognise CQL and
@@ -2520,22 +2521,35 @@ ZOOM_API(ZOOM_scanset)
      * inspection of the ZOOM_query_prefix() and ZOOM_query_cql()
      * functions shows how the structure is set up in each case.
      */
-    if (q->z_query->which == Z_Query_type_1) {
+    if (!q->z_query)
+        return 0;
+    else if (q->z_query->which == Z_Query_type_1) 
+    {
         yaz_log(log_api, "%p ZOOM_connection_scan1 q=%p PQF '%s'",
                 c, q, q->query_string);
         start = q->query_string;
-    } else if (q->z_query->which == Z_Query_type_104) {
+    } 
+    else if (q->z_query->which == Z_Query_type_104)
+    {
         yaz_log(log_api, "%p ZOOM_connection_scan1 q=%p CQL '%s'",
                 c, q, q->query_string);
         start = freeme = cql2pqf(c, q->query_string);
         if (start == 0)
             return 0;
-    } else {
+    } 
+    else
+    {
         yaz_log(YLOG_FATAL, "%p ZOOM_connection_scan1 q=%p unknown type '%s'",
                 c, q, q->query_string);
         abort();
     }
 
+    scan = (ZOOM_scanset) xmalloc(sizeof(*scan));
+    scan->connection = c;
+    scan->odr = odr_createmem(ODR_DECODE);
+    scan->options = ZOOM_options_create_with_parent(c->options);
+    scan->refcount = 1;
+    scan->scan_response = 0;
     scan->termListAndStartPoint =
         p_query_scan(scan->odr, PROTO_Z3950, &scan->attributeSet, start);
     xfree(freeme);