xref: /lighttpd1.4/src/configfile.h (revision 70b1af06)
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 	buffer *comp_tag;
41 	buffer *comp_key;
42 	const char *op;
43 
44 	vector_config_weak children;
45 	array *value;
46 };
47 
48 __attribute_cold__
49 data_config *data_config_init(void);
50 
51 __attribute_cold__
52 int data_config_pcre_compile(data_config *dc);
53 /*struct cond_cache_t;*/    /* declaration */ /*(moved to plugin_config.h)*/
54 /*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/
55 
56 typedef struct {
57 	server *srv;
58 	int     ok;
59 	array  *all_configs;
60 	vector_config_weak configs_stack; /* to parse nested block */
61 	data_config *current; /* current started with { */
62 	buffer *basedir;
63 } config_t;
64 
65 __attribute_cold__
66 void *configparserAlloc(void *(*mallocProc)(size_t));
67 
68 __attribute_cold__
69 void configparserFree(void *p, void (*freeProc)(void*));
70 
71 __attribute_cold__
72 void configparser(void *yyp, int yymajor, buffer *yyminor, config_t *ctx);
73 
74 __attribute_cold__
75 int config_parse_file(server *srv, config_t *context, const char *fn);
76 
77 __attribute_cold__
78 int config_parse_cmd(server *srv, config_t *context, const char *cmd);
79 
80 #endif
81