Comment
[yaz-moved-to-github.git] / src / zoom-c.c
index 7131b41..e5fbd38 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-c.c,v 1.58 2005-12-20 22:24:05 mike Exp $
+ * $Id: zoom-c.c,v 1.61 2005-12-21 08:35:36 mike Exp $
  */
 /**
  * \file zoom-c.c
@@ -167,7 +167,13 @@ static void set_ZOOM_error (ZOOM_connection c, int error,
 
 static void clear_error (ZOOM_connection c)
 {
-
+    /*
+     * If an error is tied to an operation then it's ok to clear: for
+     * example, a diagnostic returned from a search is cleared by a
+     * subsequent search.  However, problems such as Connection Lost
+     * or Init Refused are not cleared, because they are not
+     * recoverable: doing another search doesn't help.
+     */
     switch (c->error)
     {
     case ZOOM_ERROR_CONNECT:
@@ -1098,7 +1104,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c)
         ZOOM_options_get(c->options, "implementationName"),
         odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
 
-    version = odr_strdup(c->odr_out, "$Revision: 1.58 $");
+    version = odr_strdup(c->odr_out, "$Revision: 1.61 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     ireq->implementationVersion = odr_prepend(c->odr_out,
@@ -4020,7 +4026,6 @@ static char *cql2pqf(ZOOM_connection c, const char *cql)
     char pqfbuf[512];
 
     parser = cql_parser_create();
-    printf("*** got CQL parser %p\n", parser);
     if ((error = cql_parser_string(parser, cql)) != 0) {
         cql_parser_destroy(parser);
         set_ZOOM_error(c, ZOOM_ERROR_CQL_PARSE, cql);
@@ -4028,24 +4033,19 @@ static char *cql2pqf(ZOOM_connection c, const char *cql)
     }
 
     node = cql_parser_result(parser);
-    printf("*** got CQL node %p\n", node);
-    cql_parser_destroy(parser);
-    printf("*** destroyed parser\n");
+    /* ### Do not call cql_parser_destroy() yet: it destroys `node'! */
 
     cqlfile = ZOOM_connection_option_get(c, "cqlfile");
-    printf("*** cqlfile is %p\n", cqlfile);
     if (cqlfile == 0) {
-        printf("*** cqlfile is null\n");
+        cql_parser_destroy(parser);
         cql_node_destroy(node);
-        printf("*** destroyed node\n");
         set_ZOOM_error(c, ZOOM_ERROR_CQL_TRANSFORM, "no CQL transform file");
-        printf("*** set ZOOM_error\n");
         return 0;
     }
-    printf("*** got CQL file %s\n", cqlfile);
 
     if ((trans = cql_transform_open_fname(cqlfile)) == 0) {
         char buf[512];        
+        cql_parser_destroy(parser);
         cql_node_destroy(node);
         sprintf(buf, "can't open CQL transform file '%.200s': %.200s",
                 cqlfile, strerror(errno));
@@ -4054,6 +4054,7 @@ static char *cql2pqf(ZOOM_connection c, const char *cql)
     }
 
     error = cql_transform_buf(trans, node, pqfbuf, sizeof pqfbuf);
+    cql_parser_destroy(parser);
     cql_node_destroy(node);
     if (error != 0) {
         char buf[512];