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