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