X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fapitest.c;h=c9eac7f48d8687a8538f50ab748dde1d08e477da;hb=ba572d8e1de44023f355c09c4250328aba0e9a47;hp=57c2f746df798deac7671aed0993844c5e676781;hpb=e5b0bb88921b593c89dd6ae9077c6566bc8a6a91;p=idzebra-moved-to-github.git diff --git a/index/apitest.c b/index/apitest.c index 57c2f74..c9eac7f 100644 --- a/index/apitest.c +++ b/index/apitest.c @@ -1,8 +1,14 @@ +/* + * Copyright (C) 1995-2000, Index Data + * All rights reserved. + * + * $Header: /home/cvsroot/idis/index/Attic/apitest.c,v 1.10 2000-09-06 08:59:36 adam Exp $ + */ #include -#include -#include +#include +#include #include "zebraapi.h" /* Small routine to display GRS-1 record variants ... */ @@ -100,7 +106,10 @@ int main (int argc, char **argv) various functions */ ODR odr_input, odr_output; - /* zh is our Zebra Handle - describes the server as a whole */ + /* zs is our Zebra Service - decribes whole server */ + ZebraService zs; + + /* zh is our Zebra Handle - describes database session */ ZebraHandle zh; /* the database we specify in our example */ @@ -109,22 +118,24 @@ int main (int argc, char **argv) nmem_init (); + yaz_log_init_file("apitest.log"); + odr_input = odr_createmem (ODR_DECODE); odr_output = odr_createmem (ODR_ENCODE); - /* open Zebra */ - zh = zebra_open ("zebra.cfg"); + zs = zebra_start ("zebra.cfg"); + if (!zs) + { + printf ("zebra_start failed; missing zebra.cfg?\n"); + exit (1); + } + /* open Zebra */ + zh = zebra_open (zs); if (!zh) { - printf ("Couldn't init zebra\n"); + printf ("zebras_open failed\n"); exit (1); } - - /* This call controls the logging facility in YAZ/Zebra */ -#if 0 - log_init(LOG_ALL, "", "out.log"); -#endif - /* Each argument to main will be a query */ for (argno = 1; argno < argc; argno++) { @@ -145,9 +156,27 @@ int main (int argc, char **argv) odr_reset (odr_input); continue; } + else + { + char out_str[100]; + int r; +#if 1 + r = zebra_string_norm (zh, 'w', + argv[argno], strlen(argv[argno]), + out_str, sizeof(out_str)); + if (r >= 0) + { + printf ("norm: '%s'\n", out_str); + } + else + { + printf ("norm fail: %d\n", r); + } +#endif + } /* result set name will be called 1,2, etc */ - sprintf (setname, "%d", i); + sprintf (setname, "%d", argno); /* fire up the search */ zebra_search_rpn (zh, odr_input, odr_output, query, 1, &base, setname); @@ -184,7 +213,7 @@ int main (int argc, char **argv) for (i = 0; i