diff options
author | Edward Rudd <urkle@outoforder.cc> | 2008-10-30 23:03:13 (GMT) |
---|---|---|
committer | Edward Rudd <urkle@outoforder.cc> | 2008-10-30 23:03:13 (GMT) |
commit | e940dd14426c5a725fda70a154fd2bf4bb91ba44 (patch) | |
tree | cfdb73628640839e4a02106032f693c6dbb9b352 /utility/config.c | |
parent | 4c46bfeaa5ec5c6a87c29ece56891e070d3faee1 (diff) |
add ability to skip N number of bad lines before throwing an error.
Will log the bad lines to a log file so they can be preserved
Diffstat (limited to 'utility/config.c')
-rw-r--r-- | utility/config.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/utility/config.c b/utility/config.c index 064a5e2..6d3f61e 100644 --- a/utility/config.c +++ b/utility/config.c | |||
@@ -24,6 +24,17 @@ static apr_status_t config_set_string(config_t *cfg, config_opt_t *opt, | |||
24 | return APR_SUCCESS; | 24 | return APR_SUCCESS; |
25 | } | 25 | } |
26 | 26 | ||
27 | static apr_status_t config_set_int(config_t *cfg, config_opt_t *opt, int argc, | ||
28 | const char **argv) | ||
29 | { | ||
30 | int offset = (int)(long)opt->data; | ||
31 | int *data = (int *)((void *)cfg + offset); | ||
32 | if (argc != 2) | ||
33 | return APR_EINVAL; | ||
34 | *data = apr_atoi64(argv[1]); | ||
35 | return APR_SUCCESS; | ||
36 | } | ||
37 | |||
27 | static apr_status_t config_set_flag(config_t *cfg, config_opt_t *opt, int argc, | 38 | static apr_status_t config_set_flag(config_t *cfg, config_opt_t *opt, int argc, |
28 | const char **argv) | 39 | const char **argv) |
29 | { | 40 | { |
@@ -197,6 +208,9 @@ void config_dump(config_t *cfg) | |||
197 | printf("ErrorLog: %s\n", cfg->errorlog); | 208 | printf("ErrorLog: %s\n", cfg->errorlog); |
198 | printf("LogLevel: %d\n", cfg->loglevel); | 209 | printf("LogLevel: %d\n", cfg->loglevel); |
199 | 210 | ||
211 | printf("BadLineFile: %s\n", cfg->badlinefile); | ||
212 | printf("BadLineMax: %d\n", cfg->badlinemax); | ||
213 | |||
200 | printf("InputDir: %s\n", cfg->input_dir); | 214 | printf("InputDir: %s\n", cfg->input_dir); |
201 | 215 | ||
202 | printf("DB Driver: %s\n", cfg->dbdriver); | 216 | printf("DB Driver: %s\n", cfg->dbdriver); |
@@ -291,6 +305,13 @@ void config_init(apr_pool_t *p) | |||
291 | "Set Log Level (error, warn, debug, quiet)", config_set_loglevel, | 305 | "Set Log Level (error, warn, debug, quiet)", config_set_loglevel, |
292 | NULL); | 306 | NULL); |
293 | 307 | ||
308 | config_add_option(p, "BadLineFile", "File to log bad log lines", config_set_string, | ||
309 | (void *)APR_OFFSETOF(config_t, badlinefile)); | ||
310 | config_add_option(p, "BadLineMax", | ||
311 | "Max number of bad lines before aborting", config_set_int, | ||
312 | (void *)APR_OFFSETOF(config_t, badlinemax)); | ||
313 | |||
314 | |||
294 | config_add_option(p, "InputDirectory", "Directory to scan for log files", | 315 | config_add_option(p, "InputDirectory", "Directory to scan for log files", |
295 | config_set_string, (void *)APR_OFFSETOF(config_t, input_dir)); | 316 | config_set_string, (void *)APR_OFFSETOF(config_t, input_dir)); |
296 | config_add_option(p, "InputFile", "Parse only this file", | 317 | config_add_option(p, "InputFile", "Parse only this file", |