Fix bug with missing initialization of member in init_diagnostics.
[yaz-moved-to-github.git] / ztest / ztest.c
index 2574a8c..7ea27de 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2003, Index Data.
+ * Copyright (c) 1995-2004, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: ztest.c,v 1.58 2003-09-02 12:12:13 adam Exp $
+ * $Id: ztest.c,v 1.63 2004-03-29 15:09:14 adam Exp $
  */
 
 /*
@@ -34,6 +34,15 @@ int ztest_search (void *handle, bend_search_rr *rr)
         rr->errcode = 23;
         return 0;
     }
+#if NMEM_DEBUG
+    /* if database is stop, stop this process.. For debugging only. */
+    if (!yaz_matchstr (rr->basenames[0], "stop"))
+    {
+       nmem_print_list_l(LOG_LOG);
+        exit(0);
+    }
+#endif
+    /* Throw Database unavailable if other than Default */
     if (yaz_matchstr (rr->basenames[0], "Default"))
     {
         rr->errcode = 109;
@@ -428,7 +437,7 @@ int ztest_present (void *handle, bend_present_rr *rr)
 int ztest_fetch(void *handle, bend_fetch_rr *r)
 {
     char *cp;
-    r->errstring = 0;
+
     r->last_in_set = 0;
     r->basename = "Default";
     r->output_format = r->request_format;  
@@ -602,12 +611,15 @@ int ztest_scan(void *handle, bend_scan_rr *q)
 
 static int ztest_explain(void *handle, bend_explain_rr *rr)
 {
-    rr->explain_buf = "<explain>\n"
-        "\t<serverInfo>\n"
-        "\t\t<host>localhost</host>\n"
-        "\t\t<port>210</port>\n"
-        "\t</serverInfo>\n"
-        "</explain>\n";
+    if (rr->database && !strcmp(rr->database, "Default"))
+    {
+       rr->explain_buf = "<explain>\n"
+           "\t<serverInfo>\n"
+           "\t\t<host>localhost</host>\n"
+           "\t\t<port>210</port>\n"
+           "\t</serverInfo>\n"
+           "</explain>\n";
+    }
     return 0;
 }
 
@@ -629,6 +641,7 @@ bend_initresult *bend_init(bend_initrequest *q)
     q->bend_fetch = ztest_fetch;
     q->bend_scan = ztest_scan;
     q->bend_explain = ztest_explain;
+
     return r;
 }