xref: /lighttpd1.4/src/configfile.h (revision 2e0edb85)
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_PCRE2_H
17 struct pcre2_real_match_data_8; /* declaration */
18 #elif defined(HAVE_PCRE_H)
19 struct pcre_extra;      /* declaration */
20 #endif
21 
22 typedef struct data_config data_config;
23 DEFINE_TYPED_VECTOR_NO_RELEASE(config_weak, data_config*);
24 
25 struct data_config {
26 	DATA_UNSET;
27 	int context_ndx; /* more or less like an id */
28 	comp_key_t comp;
29 	config_cond_t cond;
30 
31 	/* nested */
32 	data_config *parent;
33 	/* for chaining only */
34 	data_config *prev;
35 	data_config *next;
36 
37 	buffer string;
38   #ifdef HAVE_PCRE2_H
39 	void *code;
40 	struct pcre2_real_match_data_8 *match_data;
41   #elif defined(HAVE_PCRE_H)
42 	void *regex;
43 	struct pcre_extra *regex_study;
44 	int ovec_nelts;
45   #endif
46 	int capture_idx;
47 	int ext;
48 	buffer comp_tag;
49 	const char *comp_key;
50 
51 	vector_config_weak children;
52 	array *value;
53 };
54 
55 __attribute_cold__
56 __attribute_returns_nonnull__
57 data_config *data_config_init(void);
58 
59 __attribute_cold__
60 int data_config_pcre_compile(data_config *dc, int pcre_jit, log_error_st *errh);
61 /*struct cond_cache_t;*/    /* declaration */ /*(moved to plugin_config.h)*/
62 /*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/
63 
64 typedef struct {
65 	server *srv;
66 	int     ok;
67 	array  *all_configs;
68 	vector_config_weak configs_stack; /* to parse nested block */
69 	data_config *current; /* current started with { */
70 	buffer *basedir;
71 } config_t;
72 
73 __attribute_cold__
74 void *configparserAlloc(void *(*mallocProc)(size_t));
75 
76 __attribute_cold__
77 void configparserFree(void *p, void (*freeProc)(void*));
78 
79 __attribute_cold__
80 void configparser(void *yyp, int yymajor, buffer *yyminor, config_t *ctx);
81 
82 __attribute_cold__
83 int config_parse_file(server *srv, config_t *context, const char *fn);
84 
85 __attribute_cold__
86 int config_parse_cmd(server *srv, config_t *context, const char *cmd);
87 
88 __attribute_cold__
89 int config_remoteip_normalize(buffer *b, buffer *tb);
90 
91 #endif
92