forked from HardySimpson/zlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzlog-chk-conf.c
83 lines (71 loc) · 1.85 KB
/
zlog-chk-conf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* This file is part of the zlog Library.
*
* Copyright (C) 2011 by Hardy Simpson <[email protected]>
*
* The zlog Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The zlog Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the zlog Library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fmacros.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include "zlog.h"
int main(int argc, char *argv[])
{
int rc = 0;
int op;
int quiet = 0;
static const char *help =
"Useage: zlog-chk-conf [conf files]...\n"
"\t-q,\tsuppress non-error message\n"
"\t-h,\tshow help message\n"
"\t-v,\tshow zlog library's git version\n";
while((op = getopt(argc, argv, "qhv")) > 0) {
if (op == 'h') {
puts(help);
return 0;
} else if (op == 'v') {
printf("zlog git version[%s]\n", zlog_git_sha1);
return 0;
} else if (op == 'q') {
quiet = 1;
}
}
argc -= optind;
argv += optind;
if (argc == 0) {
puts(help);
return -1;
}
setenv("ZLOG_PROFILE_ERROR", "/dev/stderr", 1);
setenv("ZLOG_CHECK_FORMAT_RULE", "1", 1);
while (argc > 0) {
rc = zlog_init(*argv);
if (rc) {
printf("\n---[%s] syntax error, see error message above\n",
*argv);
exit(2);
} else {
zlog_fini();
if (!quiet) {
printf("--[%s] syntax right\n", *argv);
}
}
argc--;
argv++;
}
exit(0);
}