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 #include "vector.h" 10 11 /* $HTTP["host"] == "incremental.home.kneschke.de" { ... } 12 * for print: comp_key op string 13 * for compare: comp cond string/regex 14 */ 15 16 #ifdef HAVE_PCRE_H 17 struct pcre_extra; /* declaration */ 18 #endif 19 20 typedef struct data_config data_config; 21 DEFINE_TYPED_VECTOR_NO_RELEASE(config_weak, data_config*); 22 23 struct data_config { 24 DATA_UNSET; 25 int context_ndx; /* more or less like an id */ 26 comp_key_t comp; 27 config_cond_t cond; 28 29 /* nested */ 30 data_config *parent; 31 /* for chaining only */ 32 data_config *prev; 33 data_config *next; 34 35 buffer string; 36 #ifdef HAVE_PCRE_H 37 void *regex; 38 struct pcre_extra *regex_study; 39 #endif 40 int ext; 41 buffer comp_tag; 42 const char *comp_key; 43 44 vector_config_weak children; 45 array *value; 46 }; 47 48 __attribute_cold__ 49 __attribute_returns_nonnull__ 50 data_config *data_config_init(void); 51 52 __attribute_cold__ 53 int data_config_pcre_compile(data_config *dc, int pcre_jit, log_error_st *errh); 54 /*struct cond_cache_t;*/ /* declaration */ /*(moved to plugin_config.h)*/ 55 /*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/ 56 57 typedef struct { 58 server *srv; 59 int ok; 60 array *all_configs; 61 vector_config_weak configs_stack; /* to parse nested block */ 62 data_config *current; /* current started with { */ 63 buffer *basedir; 64 } config_t; 65 66 __attribute_cold__ 67 void *configparserAlloc(void *(*mallocProc)(size_t)); 68 69 __attribute_cold__ 70 void configparserFree(void *p, void (*freeProc)(void*)); 71 72 __attribute_cold__ 73 void configparser(void *yyp, int yymajor, buffer *yyminor, config_t *ctx); 74 75 __attribute_cold__ 76 int config_parse_file(server *srv, config_t *context, const char *fn); 77 78 __attribute_cold__ 79 int config_parse_cmd(server *srv, config_t *context, const char *cmd); 80 81 #endif 82