Put local variables footer in all c, h files.
[idzebra-moved-to-github.git] / dict / dicttest.c
index 85cce13..dbebc8d 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id: dicttest.c,v 1.28 2004-01-22 11:27:20 adam Exp $
-   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
-   Index Data Aps
+/* $Id: dicttest.c,v 1.36 2006-05-10 08:13:18 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
 
 This file is part of the Zebra server.
 
@@ -20,15 +20,15 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 */
 
-
-
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
 
-#include <dict.h>
-#include <zebrautl.h>
+#include <idzebra/dict.h>
+#include <idzebra/util.h>
+#include <idzebra/res.h>
+#include <yaz/yaz-util.h>
 
 char *prog;
 static Dict dict;
@@ -103,7 +103,7 @@ int main (int argc, char **argv)
                 name = arg;
             else
             {
-                logf (LOG_FATAL, "too many files specified\n");
+                yaz_log (YLOG_FATAL, "too many files specified\n");
                 exit (1);
             }
         }
@@ -151,31 +151,33 @@ int main (int argc, char **argv)
         }
         else
         {
-            logf (LOG_FATAL, "Unknown option '-%s'", arg);
+            yaz_log (YLOG_FATAL, "Unknown option '-%s'", arg);
             exit (1);
         }
     }
     if (!config || !name)
     {
-        logf (LOG_FATAL, "no config and/or dictionary specified");
+        yaz_log (YLOG_FATAL, "no config and/or dictionary specified");
         exit (1);
     }
-    my_resource = res_open (config, 0, 0);
+    my_resource = res_open(0, 0);
     if (!my_resource)
     {
-        logf (LOG_FATAL, "cannot open resource `%s'", config);
+        yaz_log (YLOG_FATAL, "cannot open resource `%s'", config);
         exit (1);
     }
+    res_read_file(my_resource, config);
+
     bfs = bfs_create (res_get(my_resource, "register"), 0);
     if (!bfs)
     {
-        logf (LOG_FATAL, "bfs_create fail");
+        yaz_log (YLOG_FATAL, "bfs_create fail");
         exit (1);
     }
-    dict = dict_open (bfs, name, cache, rw, 0);
+    dict = dict_open (bfs, name, cache, rw, 0, 4096);
     if (!dict)
     {
-        logf (LOG_FATAL, "dict_open fail of `%s'", name);
+        yaz_log (YLOG_FATAL, "dict_open fail of `%s'", name);
         exit (1);
     }
     if (inputfile)
@@ -188,7 +190,7 @@ int main (int argc, char **argv)
 
         if (!(ipf = fopen(inputfile, "r")))
         {
-            logf (LOG_FATAL|LOG_ERRNO, "cannot open %s", inputfile);
+            yaz_log (YLOG_FATAL|YLOG_ERRNO, "cannot open %s", inputfile);
             exit (1);
         }
         
@@ -227,11 +229,11 @@ int main (int argc, char **argv)
                             case 1:
                                 no_of_change++;
                                 if (unique)
-                                    logf (LOG_LOG, "%s change\n", ipf_ptr);
+                                    yaz_log (YLOG_LOG, "%s change\n", ipf_ptr);
                                 break;
                             case 2:
                                 if (unique)
-                                    logf (LOG_LOG, "%s duplicate\n", ipf_ptr);
+                                    yaz_log (YLOG_LOG, "%s duplicate\n", ipf_ptr);
                                 no_of_same++;
                                 break;
                             }
@@ -270,36 +272,36 @@ int main (int argc, char **argv)
     }
     if (rw && delete_term)
     {
-       logf (LOG_LOG, "dict_delete_subtree %s", delete_term);
+       yaz_log (YLOG_LOG, "dict_delete_subtree %s", delete_term);
        dict_delete_subtree (dict, delete_term, 0, 0);
     }
     if (grep_pattern)
     {
         if (range < 0)
             range = 0;
-        logf (LOG_LOG, "Grepping '%s'", grep_pattern);
+        yaz_log (YLOG_LOG, "Grepping '%s'", grep_pattern);
         dict_lookup_grep (dict, grep_pattern, range, NULL, &max_pos,
                           srange, grep_handler);
     }
     if (rw)
     {
-        logf (LOG_LOG, "Iterations.... %d", no_of_iterations);            
+        yaz_log (YLOG_LOG, "Iterations.... %d", no_of_iterations);            
         if (do_delete)
         {
-            logf (LOG_LOG, "No of deleted. %d", no_of_deleted);
-            logf (LOG_LOG, "No not found.. %d", no_not_found);
+            yaz_log (YLOG_LOG, "No of deleted. %d", no_of_deleted);
+            yaz_log (YLOG_LOG, "No not found.. %d", no_not_found);
         }
         else
         {
-            logf (LOG_LOG, "No of new..... %d", no_of_new);
-            logf (LOG_LOG, "No of change.. %d", no_of_change);
+            yaz_log (YLOG_LOG, "No of new..... %d", no_of_new);
+            yaz_log (YLOG_LOG, "No of change.. %d", no_of_change);
         }
     }
     else
     {
-        logf (LOG_LOG, "Lookups....... %d", no_of_iterations);
-        logf (LOG_LOG, "No of hits.... %d", no_of_hits);
-        logf (LOG_LOG, "No of misses.. %d", no_of_misses);
+        yaz_log (YLOG_LOG, "Lookups....... %d", no_of_iterations);
+        yaz_log (YLOG_LOG, "No of hits.... %d", no_of_hits);
+        yaz_log (YLOG_LOG, "No of misses.. %d", no_of_misses);
     }
     if (scan_the_thing)
     {
@@ -307,7 +309,7 @@ int main (int argc, char **argv)
         
        int before = 1000000;
        int after = 1000000;
-       logf (LOG_LOG, "dict_scan");
+       yaz_log (YLOG_LOG, "dict_scan");
        term_dict[0] = 1;
        term_dict[1] = 0;
        dict_scan (dict, term_dict, &before, &after, 0, scan_handler);
@@ -317,3 +319,11 @@ int main (int argc, char **argv)
     res_close (my_resource);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+