1 /*
2 * This file is part of the zlog Library.
3 *
4 * Copyright (C) 2011 by Hardy Simpson <HardySimpson1984@gmail.com>
5 *
6 * Licensed under the LGPL v2.1, see the file COPYING in base directory.
7 */
8
9 #include "fmacros.h"
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <string.h>
15
16 #include <unistd.h>
17
18 #include "zlog.h"
19 #include "version.h"
20
21
main(int argc,char * argv[])22 int main(int argc, char *argv[])
23 {
24 int rc = 0;
25 int op;
26 int quiet = 0;
27 static const char *help =
28 "useage: zlog-chk-conf [conf files]...\n"
29 "\t-q,\tsuppress non-error message\n"
30 "\t-h,\tshow help message\n"
31 "zlog version: " ZLOG_VERSION "\n";
32
33 while((op = getopt(argc, argv, "qhv")) > 0) {
34 if (op == 'h') {
35 fputs(help, stdout);
36 return 0;
37 } else if (op == 'q') {
38 quiet = 1;
39 }
40 }
41
42 argc -= optind;
43 argv += optind;
44
45 if (argc == 0) {
46 fputs(help, stdout);
47 return -1;
48 }
49
50 setenv("ZLOG_PROFILE_ERROR", "/dev/stderr", 1);
51 setenv("ZLOG_CHECK_FORMAT_RULE", "1", 1);
52
53 while (argc > 0) {
54 rc = zlog_init(*argv);
55 if (rc) {
56 printf("\n---[%s] syntax error, see error message above\n",
57 *argv);
58 exit(2);
59 } else {
60 zlog_fini();
61 if (!quiet) {
62 printf("--[%s] syntax right\n", *argv);
63 }
64 }
65 argc--;
66 argv++;
67 }
68
69 exit(0);
70 }
71