../../index/zebrasrv -S -c zebra1.cfg -l srv.log tcp:@:9901 &
sleep 1
-echo " cheking that it runs... "
+echo " checking that it runs... "
test -f zebrasrv.pid || exit 1
PID=`cat zebrasrv.pid`
ps -p $PID >/dev/null || exit 1
ps -p $PID >/dev/null || exit 1
echo " connecting again, with a delay..."
-../testclient localhost:9901 utah 5 > log &
+../testclient -d 5 localhost:9901 utah > log &
sleep 1 # let the client connect
echo " killing it..."
/*
- * $Id: testclient.c,v 1.2 2002-10-23 13:25:00 heikki Exp $
+ * $Id: testclient.c,v 1.3 2002-10-23 13:41:15 adam Exp $
*
* Synchronous single-target client doing search (but no yet retrieval)
*/
#include <stdlib.h>
#include <stdio.h>
#include <yaz/xmalloc.h>
+#include <yaz/options.h>
#include <yaz/zoom.h>
+char *prog = "testclient";
+
int main(int argc, char **argv)
{
ZOOM_connection z;
ZOOM_resultset r;
int error;
const char *errmsg, *addinfo;
- int sec;
+ char *query = 0;
+ char *target = 0;
+ char *arg;
+ int delay_sec = 0;
+ int ret;
+
+ while ((ret = options("d:", argv, argc, &arg)) != -2)
+ {
+ switch (ret)
+ {
+ case 0:
+ if (!target)
+ target = xstrdup(arg);
+ else if (!query)
+ query = xstrdup(arg);
+ break;
+ case 'd':
+ delay_sec = atoi(arg);
+ break;
+ default:
+ printf ("%s: unknown option %s\n", prog, arg);
+ printf ("usage:\n%s [options] target query \n", prog);
+ printf (" eg. bagel.indexdata.dk/gils computer\n");
+ exit (1);
+ }
+ }
- if ( (argc != 3) && (argc !=4) )
+ if (!target || !target)
{
- fprintf (stderr, "usage:\n%s target query [delay]\n", *argv);
- fprintf (stderr, " eg. bagel.indexdata.dk/gils computer\n");
- exit (1);
+ printf ("%s: missing target/query\n", prog);
+ printf ("usage:\n%s [options] target query \n", prog);
+ printf (" eg. bagel.indexdata.dk/gils computer\n");
+ exit (3);
}
- z = ZOOM_connection_new (argv[1], 0);
+ z = ZOOM_connection_new (target, 0);
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
{
- fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
+ printf ("Error: %s (%d) %s\n", errmsg, error, addinfo);
exit (2);
}
- r = ZOOM_connection_search_pqf (z, argv[2]);
+ r = ZOOM_connection_search_pqf (z, query);
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
else
printf ("Result count: %d\n", ZOOM_resultset_size(r));
- if (argc==4)
- {
- sec=atoi(argv[3]);
- if (sec <= 0)
- sec=3;
- sleep(sec);
- }
+
+ if (delay_sec > 0)
+ sleep(delay_sec);
ZOOM_resultset_destroy (r);
ZOOM_connection_destroy (z);
exit (0);