summaryrefslogtreecommitdiffstats
path: root/utility/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'utility/config.c')
-rw-r--r--utility/config.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/utility/config.c b/utility/config.c
index 847d474..d3a6ca5 100644
--- a/utility/config.c
+++ b/utility/config.c
@@ -3,6 +3,7 @@
3#include "apr_file_io.h" 3#include "apr_file_io.h"
4#include "apr_strings.h" 4#include "apr_strings.h"
5#include "apr_hash.h" 5#include "apr_hash.h"
6#include "apr_uri.h"
6 7
7#include "shell.h" 8#include "shell.h"
8#include "config.h" 9#include "config.h"
@@ -65,18 +66,6 @@ static apr_status_t config_set_loglevel(config_t *cfg, config_opt_t *opt,
65 return APR_SUCCESS; 66 return APR_SUCCESS;
66} 67}
67 68
68static apr_status_t config_set_dbconnect(config_t *cfg, config_opt_t *opt,
69 int argc, const char **argv)
70{
71 return APR_SUCCESS;
72}
73
74static apr_status_t config_set_dbparam(config_t *cfg, config_opt_t *opt,
75 int argc, const char **argv)
76{
77 return APR_SUCCESS;
78}
79
80static apr_status_t config_set_inputfile(config_t *cfg, config_opt_t *opt, 69static apr_status_t config_set_inputfile(config_t *cfg, config_opt_t *opt,
81 int argc, const char **argv) 70 int argc, const char **argv)
82{ 71{
@@ -123,12 +112,12 @@ static apr_status_t config_set_output_field(config_t *cfg, config_opt_t *opt,
123 config_output_field_t *field; 112 config_output_field_t *field;
124 char *type, *size, *temp; 113 char *type, *size, *temp;
125 114
126 if (argc < 4) 115 if (argc < 5)
127 return APR_EINVAL; 116 return APR_EINVAL;
128 field = (config_output_field_t *)apr_array_push(cfg->output_fields); 117 field = (config_output_field_t *)apr_array_push(cfg->output_fields);
129 field->field = apr_pstrdup(cfg->pool, argv[1]); 118 field->field = apr_pstrdup(cfg->pool, argv[1]);
130 field->source = apr_pstrdup(cfg->pool, argv[3]); 119 field->source = apr_pstrdup(cfg->pool, argv[4]);
131 120 field->def = apr_pstrdup(cfg->pool, argv[3]);
132 type = size = apr_pstrdup(cfg->pool, argv[2]); 121 type = size = apr_pstrdup(cfg->pool, argv[2]);
133 while (*size!='\0' && *size!='(') 122 while (*size!='\0' && *size!='(')
134 size++; 123 size++;
@@ -156,13 +145,13 @@ static apr_status_t config_set_output_field(config_t *cfg, config_opt_t *opt,
156 } 145 }
157 146
158 // Has a function 147 // Has a function
159 if (argc > 4) { 148 if (argc > 5) {
160 int i; 149 int i;
161 field->fname = apr_pstrdup(cfg->pool, argv[4]); 150 field->fname = apr_pstrdup(cfg->pool, argv[5]);
162 field->func = parser_get_func(field->fname); 151 field->func = parser_get_func(field->fname);
163 field->args = apr_pcalloc(cfg->pool, sizeof(char *) * (argc-4+1)); 152 field->args = apr_pcalloc(cfg->pool, sizeof(char *) * (argc-5+1));
164 for (i=5; i<=argc; i++) { 153 for (i=6; i<=argc; i++) {
165 field->args[i-5] = apr_pstrdup(cfg->pool, argv[i]); 154 field->args[i-6] = apr_pstrdup(cfg->pool, argv[i]);
166 } 155 }
167 } 156 }
168 157
@@ -208,6 +197,9 @@ void config_dump(config_t *cfg)
208 197
209 printf("InputDir: %s\n", cfg->input_dir); 198 printf("InputDir: %s\n", cfg->input_dir);
210 199
200 printf("DB Driver: %s\n", cfg->dbdriver);
201 printf("DB Params: %s\n", cfg->dbparams);
202
211 printf("Table: %s\n", cfg->table); 203 printf("Table: %s\n", cfg->table);
212 printf("Transactions: %d\n", cfg->transactions); 204 printf("Transactions: %d\n", cfg->transactions);
213 printf("MachineID: %s\n", cfg->machineid); 205 printf("MachineID: %s\n", cfg->machineid);
@@ -231,7 +223,9 @@ void config_dump(config_t *cfg)
231 printf("Output Fields:\n"); 223 printf("Output Fields:\n");
232 fields = (config_output_field_t *)cfg->output_fields->elts; 224 fields = (config_output_field_t *)cfg->output_fields->elts;
233 for (i=0; i<cfg->output_fields->nelts; i++) { 225 for (i=0; i<cfg->output_fields->nelts; i++) {
234 printf(">> %s %s(%d): %s", fields[i].field, logsql_field_datatyeName(fields[i].datatype), fields[i].size, fields[i].source); 226 printf(">> %s %s(%d) DEFAULT '%s': %s", fields[i].field,
227 logsql_field_datatyeName(fields[i].datatype),
228 fields[i].size, fields[i].def, fields[i].source);
235 if (fields[i].func) { 229 if (fields[i].func) {
236 printf(" :: %s(", fields[i].fname); 230 printf(" :: %s(", fields[i].fname);
237 if (fields[i].args) { 231 if (fields[i].args) {
@@ -280,11 +274,10 @@ void config_init(apr_pool_t *p)
280 config_add_option(p, "InputFile", "Parse only this file", 274 config_add_option(p, "InputFile", "Parse only this file",
281 config_set_inputfile, NULL); 275 config_set_inputfile, NULL);
282 276
283 config_add_option(p, "DBConnect", 277 config_add_option(p, "DBDDriver", "DBD Driver to use",
284 "DB Connection information type://user:pass@hostname/database", 278 config_set_string, (void *)APR_OFFSETOF(config_t, dbdriver));
285 config_set_dbconnect, NULL); 279 config_add_option(p, "DBDParams", "DBD Connection Parameters",
286 config_add_option(p, "DBParam", "DB Connection Parameter", 280 config_set_string, (void *)APR_OFFSETOF(config_t, dbparams));
287 config_set_dbparam, NULL);
288 config_add_option(p, "Table", "Table to import the log to", 281 config_add_option(p, "Table", "Table to import the log to",
289 config_set_string, (void *)APR_OFFSETOF(config_t, table)); 282 config_set_string, (void *)APR_OFFSETOF(config_t, table));
290 config_add_option(p, "UseTransactions", "Enable Transactions?", 283 config_add_option(p, "UseTransactions", "Enable Transactions?",
@@ -330,7 +323,6 @@ config_t *config_create(apr_pool_t *p)
330 cfg->summary = 1; 323 cfg->summary = 1;
331 cfg->transactions = 1; 324 cfg->transactions = 1;
332 cfg->input_files = apr_array_make(cfg->pool, 10, sizeof(char *)); 325 cfg->input_files = apr_array_make(cfg->pool, 10, sizeof(char *));
333 cfg->dbconfig = apr_table_make(cfg->pool, 5);
334 cfg->log_formats = apr_hash_make(cfg->pool); 326 cfg->log_formats = apr_hash_make(cfg->pool);
335 cfg->output_fields = apr_array_make(cfg->pool, 10, 327 cfg->output_fields = apr_array_make(cfg->pool, 10,
336 sizeof(config_output_field_t)); 328 sizeof(config_output_field_t));