1 #ifndef _CONFIG_PARSER_H_ 2 #define _CONFIG_PARSER_H_ 3 #include "first.h" 4 5 #include "base_decls.h" 6 #include "plugin_config.h" 7 #include "array.h" 8 #include "buffer.h" 9 10 /* $HTTP["host"] == "incremental.home.kneschke.de" { ... } 11 * for print: comp_key op string 12 * for compare: comp cond string/regex 13 */ 14 15 #ifdef HAVE_PCRE2_H 16 struct pcre2_real_match_data_8; /* declaration */ 17 #elif defined(HAVE_PCRE_H) 18 struct pcre_extra; /* declaration */ 19 #endif 20 21 typedef struct data_config data_config; 22 23 typedef struct data_config_list { 24 data_config **data; 25 uint32_t used; 26 uint32_t size; 27 } data_config_list; 28 29 struct data_config { 30 DATA_UNSET; 31 int context_ndx; /* more or less like an id */ 32 comp_key_t comp; 33 config_cond_t cond; 34 35 /* nested */ 36 data_config *parent; 37 /* for chaining only */ 38 data_config *prev; 39 data_config *next; 40 41 buffer string; 42 #ifdef HAVE_PCRE2_H 43 void *code; 44 struct pcre2_real_match_data_8 *match_data; 45 #elif defined(HAVE_PCRE_H) 46 void *regex; 47 struct pcre_extra *regex_study; 48 int ovec_nelts; 49 #endif 50 int capture_idx; 51 int ext; 52 buffer comp_tag; 53 const char *comp_key; 54 55 data_config_list children; 56 array *value; 57 }; 58 59 __attribute_cold__ 60 __attribute_returns_nonnull__ 61 data_config *data_config_init(void); 62 63 __attribute_cold__ 64 int data_config_pcre_compile(data_config *dc, int pcre_jit, log_error_st *errh); 65 /*struct cond_cache_t;*/ /* declaration */ /*(moved to plugin_config.h)*/ 66 /*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/ 67 68 typedef struct { 69 server *srv; 70 int ok; 71 array *all_configs; 72 data_config_list configs_stack; /* to parse nested block */ 73 data_config *current; /* current started with { */ 74 buffer *basedir; 75 } config_t; 76 77 __attribute_cold__ 78 void *configparserAlloc(void *(*mallocProc)(size_t)); 79 80 __attribute_cold__ 81 void configparserFree(void *p, void (*freeProc)(void*)); 82 83 __attribute_cold__ 84 void configparser(void *yyp, int yymajor, buffer *yyminor, config_t *ctx); 85 86 __attribute_cold__ 87 int config_parse_file(server *srv, config_t *context, const char *fn); 88 89 __attribute_cold__ 90 int config_parse_cmd(server *srv, config_t *context, const char *cmd); 91 92 __attribute_cold__ 93 int config_remoteip_normalize(buffer *b, buffer *tb); 94 95 #endif 96