From 0ddd719a72469f732a881c93d4c804e9aca787fe Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Wed, 22 Oct 2008 12:40:58 +0000 Subject: 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) --- (limited to 'utility/config.h') diff --git a/utility/config.h b/utility/config.h index e1827fe..67f8ea5 100644 --- a/utility/config.h +++ b/utility/config.h @@ -5,6 +5,8 @@ #include "apr_hash.h" #include "apr_file_io.h" +#include "ap_pcre.h" + typedef enum { LOGLEVEL_QUIET = 0, LOGLEVEL_ERROR = 1, @@ -12,7 +14,8 @@ typedef enum { LOGLEVEL_DEBUG = 3, } loglevel_e; -typedef struct { +typedef struct config_t config_t; +struct config_t { /** the structures pool (to ease function arguments) */ apr_pool_t *pool; @@ -46,29 +49,33 @@ typedef struct { apr_array_header_t *output_fields; /** filter configuration */ - apr_array_header_t *filters; + apr_array_header_t *linefilters; + apr_array_header_t *prefilters; + apr_array_header_t *postfilters; /** Dry Run */ int dryrun; /* Show the summary */ int summary; -} config_t; +}; + -typedef struct { +typedef struct config_logformat_t config_logformat_t; +struct config_logformat_t { const char *name; apr_array_header_t *fields; -} config_logformat_t; +}; -typedef struct { +typedef struct config_logformat_field_t config_logformat_field_t; +struct config_logformat_field_t { const char *name; const char *datatype; -} config_logformat_field_t; +}; typedef struct config_opt_t config_opt_t; typedef apr_status_t (*config_func_t)(config_t *cfg, config_opt_t *opt, int argc, const char **argv); - struct config_opt_t { const char *name; const char *help; @@ -76,6 +83,40 @@ struct config_opt_t { void *data; }; +typedef struct config_filter_t config_filter_t; +struct config_filter_t { + const char *field; + const char *filter; + int negative; + ap_regex_t *regex; +}; + +typedef enum { + LOGSQL_DATATYPE_INT = 0, + LOGSQL_DATATYPE_SMALLINT, + LOGSQL_DATATYPE_VARCHAR, + LOGSQL_DATATYPE_CHAR, + LOGSQL_DATATYPE_BIGINT +} logsql_field_datatype; +#define logsql_field_datatyeName(x) \ + (x == LOGSQL_DATATYPE_INT ? "INT" \ + : (x == LOGSQL_DATATYPE_SMALLINT ? "SMALLINT" \ + : (x == LOGSQL_DATATYPE_VARCHAR ? "VARCHAR" \ + : (x == LOGSQL_DATATYPE_CHAR ? "CHAR" \ + : (x == LOGSQL_DATATYPE_BIGINT ? "BIGINT" : "ERR"))))) + +typedef struct config_output_field_t config_output_field_t; + +struct config_output_field_t { + const char *field; + logsql_field_datatype datatype; + apr_size_t size; + const char *source; + const char *fname; + void *func; + const char **args; +}; + #define CHECK_YESNO(c) ((!strcasecmp(c,"on") || !strcasecmp(c,"yes")) ? 1 : 0) /** @@ -99,6 +140,4 @@ config_t *config_create(apr_pool_t *p); apr_status_t config_read(config_t *cfg, const char *filename, apr_table_t *merge); -void config_generate(const char *filename); - #endif /*CONFIG_H_*/ -- cgit v0.9.2