Fix uninit variable (hits_limit)
[idzebra-moved-to-github.git] / util / res-test.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 1994-2011 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20
21
22 #if HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 #include <stdio.h>
26
27 #include <zebrautl.h>
28
29 static void res_print (const char *name, const char *value)
30 {
31     yaz_log (YLOG_LOG, "%s=%s", name, value);
32 }
33
34 int main(int argc, char **argv)
35 {
36     char *arg;
37     char *resfile = NULL;
38     char *prefix = NULL;
39     int ret;
40     char *prog = *argv;
41     Res res;
42     int write_flag = 0;
43
44     log_init (YLOG_DEFAULT_LEVEL, prog, NULL);
45     while ((ret = options ("wp:v", argv, argc, &arg)) != -2)
46         if (ret == 0)
47             resfile = arg;
48         else if (ret == 'v')
49             log_init (YLOG_ALL, prog, NULL);
50         else if (ret == 'p')
51             prefix = arg;
52         else if (ret == 'w')
53             write_flag = 1;
54         else
55         {
56             yaz_log (YLOG_FATAL, "Unknown option '-%s'", arg);
57             exit (1);
58         }
59     if (!resfile)
60     {
61         yaz_log (YLOG_FATAL, "No resource file given.");
62         exit (1);
63     }
64     res = res_open (resfile);
65     res_trav (res, prefix, res_print);
66     if (write_flag)
67         res_write (res);
68     res_close (res);
69     return 0;
70 }
71 /*
72  * Local variables:
73  * c-basic-offset: 4
74  * c-file-style: "Stroustrup"
75  * indent-tabs-mode: nil
76  * End:
77  * vim: shiftwidth=4 tabstop=8 expandtab
78  */
79