Updated to use zebrautl.h instead of alexutil.h.
[idzebra-moved-to-github.git] / util / res-test.c
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: res-test.c,v $
7  * Revision 1.6  1996-10-29 13:48:16  adam
8  * Updated to use zebrautl.h instead of alexutil.h.
9  *
10  * Revision 1.5  1995/09/04 12:34:05  adam
11  * Various cleanup. YAZ util used instead.
12  *
13  * Revision 1.4  1994/10/04  17:47:11  adam
14  * Function options now returns arg with error option.
15  *
16  * Revision 1.3  1994/08/18  11:02:27  adam
17  * Implementation of res_write.
18  *
19  * Revision 1.2  1994/08/18  10:02:01  adam
20  * Module alexpath moved from res.c to alexpath.c. Minor changes in res-test.c
21  *
22  * Revision 1.1  1994/08/18  09:43:51  adam
23  * Development of resource manager. Only missing is res_write.
24  *
25  */
26
27 #include <stdio.h>
28
29 #include <zebrautl.h>
30
31 static void res_print (const char *name, const char *value)
32 {
33     logf (LOG_LOG, "%s=%s", name, value);
34 }
35
36 int main(int argc, char **argv)
37 {
38     char *arg;
39     char *resfile = NULL;
40     char *prefix = NULL;
41     int ret;
42     char *prog = *argv;
43     Res res;
44     int write_flag = 0;
45
46     log_init (LOG_DEFAULT_LEVEL, prog, NULL);
47     while ((ret = options ("wp:v", argv, argc, &arg)) != -2)
48         if (ret == 0)
49             resfile = arg;
50         else if (ret == 'v')
51             log_init (LOG_ALL, prog, NULL);
52         else if (ret == 'p')
53             prefix = arg;
54         else if (ret == 'w')
55             write_flag = 1;
56         else
57         {
58             logf (LOG_FATAL, "Unknown option '-%s'", arg);
59             exit (1);
60         }
61     if (!resfile)
62     {
63         logf (LOG_FATAL, "No resource file given.");
64         exit (1);
65     }
66     res = res_open (resfile);
67     res_trav (res, prefix, res_print);
68     if (write_flag)
69         res_write (res);
70     res_close (res);
71     return 0;
72 }