summaryrefslogtreecommitdiffstatsabout
path: root/utility/config.h
diff options
context:
space:
mode:
authorEdward Rudd <urkle@outoforder.cc>2008-10-01 03:57:58 (GMT)
committer Edward Rudd <urkle@outoforder.cc>2008-10-01 03:57:58 (GMT)
commitcc75ebf7e8560a69a6847f0260cce4772fff440a (patch)
tree0af45d26c6781995f1d643e599fe36be481d9ee5 /utility/config.h
parentba30ceeb705e9b4d40ce0d98f6a4e047d47ce919 (diff)
Initial revision of command line importer.
Diffstat (limited to 'utility/config.h')
-rw-r--r--utility/config.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/utility/config.h b/utility/config.h
new file mode 100644
index 0000000..e1827fe
--- /dev/null
+++ b/utility/config.h
@@ -0,0 +1,104 @@
1#ifndef CONFIG_H_
2#define CONFIG_H_
3
4#include "apr_tables.h"
5#include "apr_hash.h"
6#include "apr_file_io.h"
7
8typedef enum {
9 LOGLEVEL_QUIET = 0,
10 LOGLEVEL_ERROR = 1,
11 LOGLEVEL_WARN = 2,
12 LOGLEVEL_DEBUG = 3,
13} loglevel_e;
14
15typedef struct {
16 /** the structures pool (to ease function arguments) */
17 apr_pool_t *pool;
18
19 /** error log file */
20 const char *errorlog;
21 /** log level */
22 loglevel_e loglevel;
23 /** error_log */
24 apr_file_t *errorlog_fp;
25
26 /** input directory of log files */
27 const char *input_dir;
28 /** list of files to scan */
29 apr_array_header_t *input_files;
30
31 /** db connection configuration */
32 apr_table_t *dbconfig;
33 /** Logging table */
34 const char *table;
35 /** Use transactons */
36 int transactions;
37 /** Machine ID */
38 const char *machineid;
39
40 /** Log file formats */
41 apr_hash_t *log_formats;
42 /** format to use to parse files */
43 const char *logformat;
44
45 /** output fields */
46 apr_array_header_t *output_fields;
47
48 /** filter configuration */
49 apr_array_header_t *filters;
50
51 /** Dry Run */
52 int dryrun;
53
54 /* Show the summary */
55 int summary;
56} config_t;
57
58typedef struct {
59 const char *name;
60 apr_array_header_t *fields;
61} config_logformat_t;
62
63typedef struct {
64 const char *name;
65 const char *datatype;
66} config_logformat_field_t;
67
68typedef struct config_opt_t config_opt_t;
69typedef apr_status_t (*config_func_t)(config_t *cfg, config_opt_t *opt,
70 int argc, const char **argv);
71
72struct config_opt_t {
73 const char *name;
74 const char *help;
75 config_func_t func;
76 void *data;
77};
78
79#define CHECK_YESNO(c) ((!strcasecmp(c,"on") || !strcasecmp(c,"yes")) ? 1 : 0)
80
81/**
82 * Initialize the config parser
83 */
84void config_init(apr_pool_t *p);
85
86/**
87 * Dump the configuration to stdout
88 */
89void config_dump(config_t *cfg);
90
91/**
92 * Creates the default configuration
93 */
94config_t *config_create(apr_pool_t *p);
95
96/**
97 * Read in a configuration file
98 */
99apr_status_t config_read(config_t *cfg, const char *filename,
100 apr_table_t *merge);
101
102void config_generate(const char *filename);
103
104#endif /*CONFIG_H_*/