IDZEBRA 2.2.8
res-test.c
Go to the documentation of this file.
1/* This file is part of the Zebra server.
2 Copyright (C) Index Data
3
4Zebra is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 2, or (at your option) any later
7version.
8
9Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18*/
19
20
21
22#if HAVE_CONFIG_H
23#include <config.h>
24#endif
25#include <stdio.h>
26
27#include <zebrautl.h>
28
29static void res_print (const char *name, const char *value)
30{
31 yaz_log (YLOG_LOG, "%s=%s", name, value);
32}
33
34int 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 * c-file-style: "Stroustrup"
75 * indent-tabs-mode: nil
76 * End:
77 * vim: shiftwidth=4 tabstop=8 expandtab
78 */
79
static char * prog
Definition agrep.c:49
static void res_print(const char *name, const char *value)
Definition res-test.c:29
int main(int argc, char **argv)
Definition res-test.c:34
void res_close(Res r)
Definition res.c:261
Res res_open(Res res_def, Res over_res)
Definition res.c:234
int res_trav(Res r, const char *prefix, void *p, void(*f)(void *p, const char *name, const char *value))
Definition res.c:357