Ignore the testclient binary
[idzebra-moved-to-github.git] / index / zebrash.c
index f88ce45..efa8b2d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebrash.c,v 1.17 2003-07-04 14:00:22 heikki Exp $
+/* $Id: zebrash.c,v 1.20 2003-07-07 14:56:04 heikki Exp $
    Copyright (C) 2002,2003
    Index Data Aps
 
@@ -133,6 +133,16 @@ int cmd_echo( char *args[], WRBUF outbuff)
  
 int cmd_quit( char *args[], WRBUF outbuff)
 {
+    if (zs)
+    {
+        onecommand("zebra_close",outbuff,"");
+        zs=0;
+    }
+    if (zh)
+    {
+        onecommand("zebra_stop",outbuff,"");
+        zh=0;
+    }
     wrbuf_puts(outbuff, "bye");
     return -99; /* special stop signal */
 }
@@ -407,14 +417,14 @@ static int cmd_show( char *args[], WRBUF outbuff)
     int nrecs=defargint(args[2],1);
     char *setname=defarg(args[3],DEFAULTRESULTSET);
     int rc=0;
+    ZebraRetrievalRecord *recs;
     ODR odr;
     Z_RecordComposition *pcomp=0;
     int i;
     oid_value format;
 
     odr=odr_createmem(ODR_ENCODE);
-    ZebraRetrievalRecord *recs=
-              odr_malloc(odr,sizeof(ZebraRetrievalRecord)*nrecs);
+    recs= odr_malloc(odr,sizeof(ZebraRetrievalRecord)*nrecs);
     rc =z_RecordComposition(odr, &pcomp, 0,"recordComposition");
     format=oid_getvalbyname ("xml"); /*FIXME - let the user specify*/
     for (i=0;i<nrecs;i++)
@@ -422,7 +432,6 @@ static int cmd_show( char *args[], WRBUF outbuff)
 
     rc = zebra_records_retrieve (zh, odr, setname,
             pcomp, format, nrecs,recs);
-    printf("rc=%d\n",rc);
     if (0==rc)
     {
         for (i=0;i<nrecs;i++)
@@ -438,6 +447,7 @@ static int cmd_show( char *args[], WRBUF outbuff)
         }
         nextrecno=start+nrecs+1;
     }
+    odr_destroy(odr);
     return rc;
 }
 /**************************************)
@@ -736,6 +746,7 @@ void shell()
            Zerrors(outbuff);
            printf("%s\n", wrbuf_buf(outbuff));
     } /* while */
+    wrbuf_free(outbuff,1);
 } /* shell() */