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