Allow empty ODR (NMEM=0) for odr_oiddup and odr_getoidbystr.
[yaz-moved-to-github.git] / client / client.c
index 0b0e8fe..daee888 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.216 2003-12-20 00:51:19 adam Exp $
+ * $Id: client.c,v 1.219 2003-12-31 00:14:00 adam Exp $
  */
 
 #include <stdio.h>
@@ -1197,8 +1197,12 @@ static int send_srw(Z_SRW_PDU *sr)
         char *buf_out;
         int len_out;
         int r;
-       if (apdu_file && !z_GDU(print, &gdu, 0, 0))
-            printf ("Failed to print outgoing APDU\n");
+       if (apdu_file)
+       {
+           if (!z_GDU(print, &gdu, 0, 0))
+               printf ("Failed to print outgoing APDU\n");
+           odr_reset(print);
+       }
         buf_out = odr_getbuf(out, &len_out, 0);
         
         /* we don't odr_reset(out), since we may need the buffer again */
@@ -2140,7 +2144,7 @@ static int cmd_explain(const char *arg)
 #if HAVE_XML2
     if (!conn)
        cmd_open(0);
-    if (1)
+    if (conn)
     {
        Z_SRW_PDU *sr = 0;
        
@@ -2151,9 +2155,8 @@ static int cmd_explain(const char *arg)
        send_srw(sr);
        return 2;
     }
-#else
-    return 0;
 #endif
+    return 0;
 }
     
 static int cmd_find(const char *arg)
@@ -2168,6 +2171,8 @@ static int cmd_find(const char *arg)
 #if HAVE_XML2
         if (!conn)
             cmd_open(0);
+       if (!conn)
+           return 0;
         if (!send_SRW_searchRequest(arg))
             return 0;
 #else
@@ -2434,6 +2439,8 @@ static int cmd_show(const char *arg)
 #if HAVE_XML2
         if (!conn)
             cmd_open(0);
+       if (!conn)
+           return 0;
         if (!send_SRW_presentRequest(arg))
             return 0;
 #else
@@ -3443,7 +3450,10 @@ void wait_and_handle_response()
             odr_dumpBER(f, netbuffer, res);
             fprintf(f, "---------\n");
             if (apdu_file)
+           {
                 z_GDU(print, &gdu, 0, 0);
+               odr_reset(print);
+           }
             if (conn && cs_more(conn))
                 continue;
            break;