diff options
Diffstat (limited to 'utility/config.c')
-rw-r--r-- | utility/config.c | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/utility/config.c b/utility/config.c index fca2f77..28bb5cd 100644 --- a/utility/config.c +++ b/utility/config.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "config.h" | 9 | #include "config.h" |
10 | #include "util.h" | 10 | #include "util.h" |
11 | #include "logparse.h" | 11 | #include "logparse.h" |
12 | #include "autoconfig.h" | ||
12 | 13 | ||
13 | apr_hash_t *g_config_opts; | 14 | apr_hash_t *g_config_opts; |
14 | 15 | ||
@@ -148,9 +149,19 @@ static apr_status_t config_set_filter(config_t *cfg, config_opt_t *opt, | |||
148 | { | 149 | { |
149 | int argn = 1; | 150 | int argn = 1; |
150 | config_filter_t *filter; | 151 | config_filter_t *filter; |
151 | filter = apr_pcalloc(cfg->pool, sizeof(config_filter_t)); | 152 | switch (opt->name[1]) { |
153 | case 'i': //line | ||
154 | filter = apr_array_push(cfg->linefilters); | ||
155 | break; | ||
156 | case 'r': //pre | ||
157 | filter = apr_array_push(cfg->prefilters); | ||
158 | break; | ||
159 | case 'o': //post | ||
160 | filter = apr_array_push(cfg->postfilters); | ||
161 | break; | ||
162 | } | ||
152 | 163 | ||
153 | if (opt->name[0]!='L') { // Pre or post 2-3 args | 164 | if (opt->name[0]=='P') { // Pre or post 2-3 args |
154 | if (argc == 1) | 165 | if (argc == 1) |
155 | return APR_EINVAL; | 166 | return APR_EINVAL; |
156 | filter->field = apr_pstrdup(cfg->pool, argv[1]); | 167 | filter->field = apr_pstrdup(cfg->pool, argv[1]); |
@@ -158,16 +169,20 @@ static apr_status_t config_set_filter(config_t *cfg, config_opt_t *opt, | |||
158 | } // Otherwise Line based only 1-2 args (no field) | 169 | } // Otherwise Line based only 1-2 args (no field) |
159 | if (argc <= argn) | 170 | if (argc <= argn) |
160 | return APR_EINVAL; | 171 | return APR_EINVAL; |
161 | if (argv[argn][0] == '+') | 172 | if (*argv[argn] == '+') |
162 | argn++; | 173 | argn++; |
163 | if (argv[argn][0] == '-') { | 174 | if (*argv[argn] == '-') { |
164 | filter->negative = 1; | 175 | filter->negative = 1; |
165 | argn++; | 176 | argn++; |
166 | } | 177 | } |
178 | if (filter->negative && argc == argn) { | ||
179 | // if no filter for negative.. that's ok.. Assume ALL | ||
180 | return APR_SUCCESS; | ||
181 | } | ||
167 | if (argc <= argn) | 182 | if (argc <= argn) |
168 | return APR_EINVAL; | 183 | return APR_EINVAL; |
169 | filter->filter = apr_pstrdup(cfg->pool, argv[argn]); | 184 | filter->filter = apr_pstrdup(cfg->pool, argv[argn]); |
170 | filter->regex = ap_pregcomp(cfg->pool, filter->filter, AP_REG_ICASE); | 185 | filter->regex = ap_pregcomp(cfg->pool, filter->filter, AP_REG_EXTENDED|AP_REG_ICASE); |
171 | return APR_SUCCESS; | 186 | return APR_SUCCESS; |
172 | } | 187 | } |
173 | 188 | ||
@@ -176,6 +191,7 @@ void config_dump(config_t *cfg) | |||
176 | apr_hash_index_t *hi; | 191 | apr_hash_index_t *hi; |
177 | int i; | 192 | int i; |
178 | config_output_field_t *fields; | 193 | config_output_field_t *fields; |
194 | config_filter_t *filters; | ||
179 | 195 | ||
180 | printf("ErrorLog: %s\n", cfg->errorlog); | 196 | printf("ErrorLog: %s\n", cfg->errorlog); |
181 | printf("LogLevel: %d\n", cfg->loglevel); | 197 | printf("LogLevel: %d\n", cfg->loglevel); |
@@ -224,6 +240,26 @@ void config_dump(config_t *cfg) | |||
224 | } | 240 | } |
225 | printf("\n"); | 241 | printf("\n"); |
226 | } | 242 | } |
243 | printf("Filters:\n>> Line:\n"); | ||
244 | filters = cfg->linefilters->elts; | ||
245 | for (i=0; i<cfg->linefilters->nelts; i++) { | ||
246 | printf(">>>> %c \"%s\" (%pp)\n",filters[i].negative ? '-':'+', | ||
247 | filters[i].filter, filters[i].regex); | ||
248 | } | ||
249 | printf(">> Pre:\n"); | ||
250 | filters = cfg->prefilters->elts; | ||
251 | for (i=0; i<cfg->prefilters->nelts; i++) { | ||
252 | printf(">>>> %s %c \"%s\" (%pp)\n", | ||
253 | filters[i].field, filters[i].negative ? '-':'+', | ||
254 | filters[i].filter, filters[i].regex); | ||
255 | } | ||
256 | printf(">> Post:\n"); | ||
257 | filters = cfg->postfilters->elts; | ||
258 | for (i=0; i<cfg->postfilters->nelts; i++) { | ||
259 | printf(">>>> %s %c \"%s\" (%pp)\n", | ||
260 | filters[i].field, filters[i].negative ? '-':'+', | ||
261 | filters[i].filter, filters[i].regex); | ||
262 | } | ||
227 | 263 | ||
228 | printf("DryRun: %d\n", cfg->dryrun); | 264 | printf("DryRun: %d\n", cfg->dryrun); |
229 | printf("Summary: %d\n", cfg->summary); | 265 | printf("Summary: %d\n", cfg->summary); |
@@ -309,10 +345,13 @@ config_t *config_create(apr_pool_t *p) | |||
309 | cfg->loglevel = LOGLEVEL_ERROR; | 345 | cfg->loglevel = LOGLEVEL_ERROR; |
310 | cfg->summary = 1; | 346 | cfg->summary = 1; |
311 | cfg->transactions = 1; | 347 | cfg->transactions = 1; |
312 | cfg->input_files = apr_array_make(cfg->pool, 10, sizeof(char *)); | 348 | cfg->input_files = apr_array_make(cfg->pool, 2, sizeof(char *)); |
313 | cfg->log_formats = apr_hash_make(cfg->pool); | 349 | cfg->log_formats = apr_hash_make(cfg->pool); |
314 | cfg->output_fields = apr_array_make(cfg->pool, 10, | 350 | cfg->output_fields = apr_array_make(cfg->pool, 10, |
315 | sizeof(config_output_field_t)); | 351 | sizeof(config_output_field_t)); |
352 | cfg->linefilters = apr_array_make(cfg->pool, 2, sizeof(config_filter_t)); | ||
353 | cfg->prefilters = apr_array_make(cfg->pool, 2, sizeof(config_filter_t)); | ||
354 | cfg->postfilters = apr_array_make(cfg->pool, 2, sizeof(config_filter_t)); | ||
316 | return cfg; | 355 | return cfg; |
317 | } | 356 | } |
318 | 357 | ||
@@ -335,6 +374,12 @@ apr_status_t config_check(config_t *cfg) | |||
335 | logging_log(cfg, LOGLEVEL_NOISE, "CONFIG: No Input Log Formats Defined"); | 374 | logging_log(cfg, LOGLEVEL_NOISE, "CONFIG: No Input Log Formats Defined"); |
336 | ret = APR_EINVAL; | 375 | ret = APR_EINVAL; |
337 | } | 376 | } |
377 | #if !defined(HAVE_APR_DBD_TRANSACTION_MODE_GET) | ||
378 | if (cfg->transactions) { | ||
379 | logging_log(cfg, LOGLEVEL_NOISE, "CONFIG: Disabling Transaction Support. Requires apr-util 1.3.0 or higher"); | ||
380 | cfg->transactions = 0; | ||
381 | } | ||
382 | #endif | ||
338 | return ret; | 383 | return ret; |
339 | } | 384 | } |
340 | 385 | ||