Move headers zebraapi.h->idzebra/api.h, zebraver.h->idzebra/version.h,
[idzebra-moved-to-github.git] / test / api / t3.c
index 771b95c..be6188e 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: t3.c,v 1.1 2003-05-19 21:37:38 adam Exp $
-   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: t3.c,v 1.9 2004-08-25 09:23:39 adam Exp $
+   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
 This file is part of the Zebra server.
@@ -20,10 +20,19 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
-
+#include <yaz/log.h>
 #include <yaz/pquery.h>
-#include <zebraapi.h>
+#include <idzebra/api.h>
 
+/* read zebra.cfg from env var srcdir if it exists; otherwise current dir */
+static ZebraService start_service()
+{
+    char cfg[256];
+    char *srcdir = getenv("srcdir");
+    sprintf(cfg, "%.200s%szebra.cfg", srcdir ? srcdir : "", srcdir ? "/" : "");
+    return zebra_start(cfg);
+}
+       
 int main(int argc, char **argv)
 {
     int i;
@@ -33,14 +42,18 @@ int main(int argc, char **argv)
         "<gils>\n"
         "  <title>My title</title>\n"
         "</gils>\n";
+
+    yaz_log_init_file("t3.log");
+
     nmem_init ();
     
-    zs = zebra_start("t2.cfg");
+    zs = start_service();
     zh = zebra_open (zs);
     zebra_select_database(zh, "Default");
+    zebra_init(zh);
 
     zebra_begin_trans (zh, 1);
-    zebra_record_insert (zh, myrec, strlen(myrec));
+    zebra_add_record (zh, myrec, strlen(myrec));
     zebra_end_trans (zh);
 
     for (i = 0; i<4; i++)
@@ -61,7 +74,7 @@ int main(int argc, char **argv)
         zebra_begin_trans (zh, 0);
         
         sprintf(setname, "s%d", i+1);
-        zebra_search_rpn (zh, odr_input, odr_output, query, setname, &hits);
+        zebra_search_RPN (zh, odr_input, query, setname, &hits);
 
         zebra_end_trans (zh);
         zebra_end_trans (zh);