diff options
author | Edward Rudd <urkle@outoforder.cc> | 2008-10-22 12:40:58 (GMT) |
---|---|---|
committer | Edward Rudd <urkle@outoforder.cc> | 2008-10-22 12:40:58 (GMT) |
commit | 0ddd719a72469f732a881c93d4c804e9aca787fe (patch) | |
tree | e05821ff5a6ad0f00d63f23090ce4f2ec19bef75 /utility/shell.c | |
parent | cc75ebf7e8560a69a6847f0260cce4772fff440a (diff) |
added more config options
included PCRE wrapper from httpd
more complete log parser code.
fixed NASTY bug with setting values in the hash tables (Need to DUP the strings before setting the keys)
Diffstat (limited to 'utility/shell.c')
-rw-r--r-- | utility/shell.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/utility/shell.c b/utility/shell.c index 07d9da1..eaa7098 100644 --- a/utility/shell.c +++ b/utility/shell.c | |||
@@ -54,7 +54,7 @@ void show_help(const char *prog, const apr_getopt_option_t *opts, FILE *output) | |||
54 | 54 | ||
55 | int main(int argc, const char *const argv[]) | 55 | int main(int argc, const char *const argv[]) |
56 | { | 56 | { |
57 | apr_pool_t *pool; | 57 | apr_pool_t *pool, *ptemp; |
58 | apr_getopt_t *opts; | 58 | apr_getopt_t *opts; |
59 | int opt; | 59 | int opt; |
60 | const char *opt_arg; | 60 | const char *opt_arg; |
@@ -69,12 +69,13 @@ int main(int argc, const char *const argv[]) | |||
69 | fprintf(stderr, "Failed to create memory pool!\n"); | 69 | fprintf(stderr, "Failed to create memory pool!\n"); |
70 | exit(1); | 70 | exit(1); |
71 | } | 71 | } |
72 | apr_pool_create(&ptemp, NULL); | ||
72 | 73 | ||
73 | /** Iterate over command line arguments | 74 | /** Iterate over command line arguments |
74 | * shoving args in a apr_table for processing later*/ | 75 | * shoving args in a apr_table for processing later*/ |
75 | args = apr_table_make(pool, 5); | 76 | args = apr_table_make(ptemp, 5); |
76 | apr_table_setn(args, "config", "mod_log_sql.conf"); | 77 | apr_table_setn(args, "config", "mod_log_sql.conf"); |
77 | apr_getopt_init(&opts, pool, argc, argv); | 78 | apr_getopt_init(&opts, ptemp, argc, argv); |
78 | while ((rv = apr_getopt_long(opts, _opt_config, &opt, &opt_arg)) == APR_SUCCESS) { | 79 | while ((rv = apr_getopt_long(opts, _opt_config, &opt, &opt_arg)) == APR_SUCCESS) { |
79 | switch (opt) { | 80 | switch (opt) { |
80 | case 'c': | 81 | case 'c': |
@@ -122,17 +123,21 @@ int main(int argc, const char *const argv[]) | |||
122 | } | 123 | } |
123 | 124 | ||
124 | // Process configuration file | 125 | // Process configuration file |
126 | parser_init(pool); | ||
125 | config_init(pool); | 127 | config_init(pool); |
126 | base = config_create(pool); | 128 | base = config_create(pool); |
127 | rv = config_read(base, apr_table_get(args,"Config"), args); | 129 | rv = config_read(base, apr_table_get(args,"Config"), args); |
130 | apr_pool_destroy(ptemp); | ||
131 | |||
128 | if (APR_STATUS_IS_ENOENT(rv)) { | 132 | if (APR_STATUS_IS_ENOENT(rv)) { |
129 | fprintf(stderr,"Could not load configuration file: %s\n",apr_table_get(args,"config")); | 133 | fprintf(stderr,"Could not load configuration file: %s\n",apr_table_get(args,"config")); |
130 | } else if (rv) { | 134 | } else if (rv) { |
131 | exit(1); | 135 | exit(1); |
132 | } | 136 | } |
133 | config_dump(base); | 137 | config_dump(base); |
134 | // Apply overrides from command line | 138 | |
135 | find_log_files(base); | 139 | // Find files and parse |
140 | parser_find_logs(base); | ||
136 | if (!apr_is_empty_array(base->input_files)) { | 141 | if (!apr_is_empty_array(base->input_files)) { |
137 | char **filelist; | 142 | char **filelist; |
138 | int f, l; | 143 | int f, l; |