bb074ac81d94dc7d423d031be6e774a6f24f05ca
[idzebra-moved-to-github.git] / util / res-test.c
1 /* $Id: res-test.c,v 1.12 2006-08-14 10:40:34 adam Exp $
2    Copyright (C) 1995-2006
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23
24
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  * indent-tabs-mode: nil
75  * End:
76  * vim: shiftwidth=4 tabstop=8 expandtab
77  */
78