annotate src/context.cpp @ 71:dd21c8e13074

start coding on new config syntax
author carl
date Sat, 09 Jul 2005 19:24:41 -0700
parents
children e6a2d0be7c5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
1 #include "context.h"
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
3 static char* context_version="$Id:";
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
5 char *token_black;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
6 char *token_content;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
7 char *token_context;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
8 char *token_dccfrom;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
9 char *token_dccto;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
10 char *token_default;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
11 char *token_dnsbl;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
12 char *token_dnsbll;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
13 char *token_envfrom;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
14 char *token_envto;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
15 char *token_filter;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
16 char *token_host_limit;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
17 char *token_html_limit;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
18 char *token_html_tags;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
19 char *token_ignore;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
20 char *token_include;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
21 char *token_inherit;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
22 char *token_lbrace;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
23 char *token_many;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
24 char *token_off;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
25 char *token_ok;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
26 char *token_ok2;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
27 char *token_on;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
28 char *token_rbrace;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
29 char *token_semi;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
30 char *token_soft;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
31 char *token_tld;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
32 char *token_unknown;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
33 char *token_white;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
34
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
35 string_set all_strings; // owns all the strings, only modified by the config loader thread
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
36
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
37 DNSBL::DNSBL(char *n, char *s, char *m) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
38 name = n;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
39 suffix = s;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
40 message = m;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
41 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
42
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
43
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
44 CONFIG::CONFIG() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
45 reference_count = 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
46 generation = 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
47 load_time = 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
48 default_context = NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
49 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
50
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
51
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
52 CONFIG::~CONFIG() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
53 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
54 CONTEXT *c = *i;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
55 delete c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
56 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
57 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
58
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
59
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
60 void CONFIG::add_context(CONTEXTP con) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
61 contexts.push_back(con);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
62 if (!default_context && !con->get_parent()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
63 // first global context
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
64 default_context = con;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
65 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
66 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
67
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
68
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
69 CONTEXTP CONFIG::find_context(char *to, char *from) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
70 CONTEXTP con = NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
71 context_map::iterator i = env_to.find(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
72 if (i != env_to.end()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
73 con = (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
74 return con->find_from_context(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
75 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
76 char *x = strchr(to, '@');
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
77 if (x) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
78 x++;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
79 i = env_to.find(x);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
80 if (i != env_to.end()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
81 con = (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
82 return con->find_from_context(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
83 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
84 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
85 if (default_context) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
86 return default_context->find_from_context(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
87 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
88 return NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
89 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
90
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
91
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
92 void CONFIG::dump() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
93 if (default_context) default_context->dump();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
94 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
95 CONTEXTP c = *i;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
96 CONTEXTP p = c->get_parent();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
97 if (!p && (c != default_context)) c->dump();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
98 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
99 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
100
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
101
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
102 CONTEXT::CONTEXT(CONTEXTP parent_, char *name_) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
103 parent = parent_;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
104 name = name_;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
105 env_from_default = (parent) ? token_inherit : token_unknown;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
106 content_filtering = (parent) ? parent->content_filtering : false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
107 content_suffix = NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
108 content_message = NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
109 host_limit = 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
110 host_limit_message = NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
111 host_random = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
112 tag_limit = 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
113 tag_limit_message = NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
114 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
115
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
116
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
117 CONTEXT::~CONTEXT() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
118 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
119 DNSBLP d = (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
120 // delete the underlying DNSBL objects.
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
121 delete d;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
122 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
123 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
124
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
125
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
126 char *CONTEXT::get_full_name(char *buffer, int size) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
127 if (!parent) return name;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
128 const int maxlen = 1000;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
129 char buf[maxlen];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
130 snprintf(buffer, size, "%s.%s", parent->get_full_name(buf, maxlen), name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
131 return buffer;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
132 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
133
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
134
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
135 bool CONTEXT::cover_env_to(char *to) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
136 const int maxlen = 1000;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
137 char buffer[maxlen];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
138 char *x = strchr(to, '@');
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
139 if (x) x++;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
140 else x = to;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
141 string_set::iterator i = env_to.find(x);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
142 if (i != env_to.end()) return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
143 return (parent) ? parent->cover_env_to(to) : false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
144 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
145
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
146
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
147 char *CONTEXT::find_from(char *from) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
148 // do we have a white/black/unknown for this full from value?
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
149 string_map::iterator i = env_from.find(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
150 if (i != env_from.end()) return (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
151 // do we have a white/black/unknown for the source domain name?
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
152 char *x = strchr(from, '@');
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
153 if (x) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
154 x++;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
155 i = env_from.find(x);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
156 if (i != env_from.end()) return (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
157 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
158 if ((env_from_default == token_inherit) && parent) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
159 return parent->find_from(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
160 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
161 return env_from_default;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
162 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
163
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
164
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
165 CONTEXTP CONTEXT::find_from_context(char *from) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
166 // do we have a special child context for this full from value?
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
167 context_map::iterator j = env_from_context.find(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
168 if (j != env_from_context.end()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
169 CONTEXTP con = (*j).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
170 return con->find_from_context(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
171 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
172 char *x = strchr(from, '@');
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
173 if (x) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
174 x++;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
175 // do we have a special context for the source domain name?
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
176 j = env_from_context.find(x);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
177 if (j != env_from_context.end()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
178 CONTEXTP con = (*j).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
179 return con->find_from_context(from);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
180 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
181 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
182 return this;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
183 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
184
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
185
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
186 CONTEXTP CONTEXT::find_from_context_name(char *name) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
187 context_map::iterator i = children.find(name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
188 if (i != children.end()) return (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
189 return NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
190 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
191
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
192
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
193 DNSBLP CONTEXT::find_dnsbl(char *name) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
194 dnsblp_map::iterator i = dnsbl_names.find(name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
195 if (i != dnsbl_names.end()) return (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
196 if (parent) return parent->find_dnsbl(name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
197 return NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
198 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
199
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
200
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
201 void CONTEXT::dump(int level) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
202 const int maxlen = 1000;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
203 char indent[maxlen];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
204 int i = min(maxlen-1, level*4);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
205 memset(indent, ' ', i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
206 indent[i] = '\0';
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
207 printf("%s context %s { \n", indent, name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
208
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
209 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
210 char *n = (*i).first;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
211 DNSBL &d = *(*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
212 printf("%s dnsbl %s %s \"%s\"; \n", indent, n, d.suffix, d.message);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
213 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
214
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
215 if (!dnsbl_list.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
216 printf("%s dnsbl_list", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
217 for (dnsblp_list::iterator i=dnsbl_list.begin(); i!=dnsbl_list.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
218 DNSBL &d = *(*i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
219 printf(" %s", d.name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
220 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
221 printf("; \n");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
222 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
223
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
224 if (content_filtering) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
225 printf("%s content on { \n", indent, env_from_default);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
226 if (content_suffix) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
227 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
228 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
229 if (!content_host_ignore.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
230 printf("%s ignore { \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
231 for (string_set::iterator i=content_host_ignore.begin(); i!=content_host_ignore.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
232 printf("%s %s; \n", indent, *i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
233 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
234 printf("%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
235 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
236 if (!content_tlds.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
237 printf("%s tld { \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
238 printf("%s ", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
239 for (string_set::iterator i=content_tlds.begin(); i!=content_tlds.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
240 printf("%s; ", *i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
241 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
242 printf("\n%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
243 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
244 if (!html_tags.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
245 printf("%s html_tags { \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
246 printf("%s ", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
247 for (string_set::iterator i=html_tags.begin(); i!=html_tags.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
248 printf("%s; ", *i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
249 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
250 printf("\n%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
251 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
252 if (host_limit_message) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
253 printf("%s host_limit on %d \"%s\"; \n", indent, host_limit, host_limit_message);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
254 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
255 else if (host_random) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
256 printf("%s host_limit soft %d; \n", indent, host_limit);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
257 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
258 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
259 printf("%s host_limit off; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
260 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
261 if (tag_limit_message) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
262 printf("%s tag_limit on %d \"%s\"; \n", indent, tag_limit, tag_limit_message);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
263 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
264 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
265 printf("%s tag_limit off; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
266 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
267 printf("%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
268 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
269 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
270 printf("%s content off {}; \n", indent, env_from_default);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
271 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
272
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
273 printf("%s env_to { \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
274 for (string_set::iterator i=env_to.begin(); i!=env_to.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
275 printf("%s %s; \n", indent, *i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
276 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
277 printf("%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
278
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
279 for (context_map::iterator i=children.begin(); i!=children.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
280 CONTEXTP c = (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
281 c->dump(level+1);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
282 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
283
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
284 printf("%s env_from %s { \n", indent, env_from_default);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
285 if (!env_from.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
286 printf("%s // white/black/unknown \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
287 for (string_map::iterator i=env_from.begin(); i!=env_from.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
288 char *f = (*i).first;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
289 char *t = (*i).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
290 printf("%s %s \t %s; \n", indent, f, t);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
291 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
292 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
293 if (!env_from_context.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
294 printf("%s // child contexts \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
295 for (context_map::iterator j=env_from_context.begin(); j!=env_from_context.end(); j++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
296 char *f = (*j).first;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
297 CONTEXTP t = (*j).second;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
298 printf("%s %s \t %s; \n", indent, f, t->name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
299 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
300 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
301 printf("%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
302
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
303 printf("%s }; \n", indent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
304 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
305
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
306
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
307 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
308 // helper to discard the strings held by a string_set
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
309 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
310 static void discard(string_set &s) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
311 for (string_set::iterator i=s.begin(); i!=s.end(); i++) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
312 free(*i);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
313 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
314 s.clear();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
315 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
316
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
317
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
318 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
319 // helper to register a string in a string set
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
320 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
321 char* register_string(string_set &s, char *name) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
322 string_set::iterator i = s.find(name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
323 if (i != s.end()) return *i;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
324 char *x = strdup(name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
325 s.insert(x);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
326 return x;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
327 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
328
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
329
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
330 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
331 // register a global string
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
332 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
333 char* register_string(char *name) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
334 return register_string(all_strings, name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
335 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
336
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
337
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
338 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
339 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
340 bool tsa(TOKEN &tok, char *token);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
341 bool tsa(TOKEN &tok, char *token) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
342 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
343 if (have == token) return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
344 tok.token_error(token, have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
345 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
346 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
347
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
348
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
349 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
350 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
351 bool parse_dnsbl(TOKEN &tok, CONFIG &dc, CONTEXT &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
352 bool parse_dnsbl(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
353 char *name = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
354 char *suf = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
355 char *msg = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
356 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
357 DNSBLP dns = new DNSBL(name, suf, msg);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
358 me.add_dnsbl(name, dns);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
359 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
360 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
361
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
362
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
363 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
364 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
365 bool parse_dnsbll(TOKEN &tok, CONFIG &dc, CONTEXT &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
366 bool parse_dnsbll(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
367 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
368 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
369 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
370 if (have == token_semi) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
371 DNSBLP dns = me.find_dnsbl(have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
372 if (dns) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
373 me.add_dnsbl(dns);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
374 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
375 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
376 tok.token_error("dnsbl name", have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
377 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
378 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
379 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
380 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
381 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
382
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
383
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
384 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
385 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
386 bool parse_content(TOKEN &tok, CONFIG &dc, CONTEXT &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
387 bool parse_content(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
388 char *setting = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
389 if (setting == token_on) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
390 me.set_content_filtering(true);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
391 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
392 else if (setting == token_off) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
393 me.set_content_filtering(false);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
394 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
395 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
396 tok.token_error("on/off", setting);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
397 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
398 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
399 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
400 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
401 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
402 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
403 if (have == token_filter) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
404 me.set_content_suffix(tok.next());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
405 me.set_content_message(tok.next());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
406 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
407 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
408 else if (have == token_ignore) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
409 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
410 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
411 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
412 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
413 if (have == token_rbrace) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
414 break; // done
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
415 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
416 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
417 me.add_ignore(have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
418 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
419 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
420 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
421 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
422 else if (have == token_tld) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
423 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
424 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
425 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
426 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
427 if (have == token_rbrace) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
428 break; // done
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
429 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
430 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
431 me.add_tld(have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
432 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
433 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
434 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
435 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
436 else if (have == token_html_limit) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
437 have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
438 if (have == token_on) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
439 me.set_tag_limit(tok.nextint());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
440 me.set_tag_message(tok.next());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
441 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
442 else if (have == token_off) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
443 me.set_tag_limit(0);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
444 me.set_tag_message(NULL);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
445 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
446 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
447 tok.token_error("on/off", have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
448 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
449 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
450 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
451 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
452 else if (have == token_html_tags) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
453 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
454 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
455 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
456 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
457 if (have == token_rbrace) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
458 break; // done
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
459 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
460 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
461 me.add_tag(have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
462 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
463 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
464 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
465 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
466 else if (have == token_host_limit) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
467 have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
468 if (have == token_on) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
469 me.set_host_limit(tok.nextint());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
470 me.set_host_message(tok.next());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
471 me.set_host_random(false);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
472 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
473 else if (have == token_off) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
474 me.set_host_limit(0);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
475 me.set_host_message(NULL);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
476 me.set_host_random(false);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
477 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
478 else if (have == token_soft) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
479 me.set_host_limit(tok.nextint());
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
480 me.set_host_message(NULL);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
481 me.set_host_random(true);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
482 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
483 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
484 tok.token_error("on/off/soft", have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
485 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
486 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
487 if (!tsa(tok, token_semi)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
488 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
489 else if (have == token_rbrace) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
490 break; // done
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
491 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
492 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
493 tok.token_error("content keyword", have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
494 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
495 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
496 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
497 return tsa(tok, token_semi);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
498 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
499
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
500
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
501 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
502 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
503 bool parse_envto(TOKEN &tok, CONFIG &dc, CONTEXT &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
504 bool parse_envto(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
505 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
506 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
507 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
508 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
509 if (have == token_rbrace) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
510 if (have == token_semi) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
511 // optional separators
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
512 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
513 else if (have == token_dccto) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
514 char *flavor = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
515 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
516 bool keeping = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
517 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
518 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
519 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
520 if (have == token_rbrace) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
521 if (have == flavor) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
522 keeping = true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
523 continue;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
524 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
525 else if ((have == token_ok) || (have == token_ok2) || (have == token_many)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
526 keeping = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
527 continue;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
528 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
529 if (have == token_envto) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
530 have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
531 if (keeping) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
532 if (me.allow_env_to(have)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
533 me.add_to(have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
534 dc.add_to(have, &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
535 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
536 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
537 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
538 tok.skipeol();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
539 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
540 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
541 else if (me.allow_env_to(have)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
542 me.add_to(have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
543 dc.add_to(have, &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
544 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
545 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
546 tok.token_error("valid env_to address or domain name", have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
547 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
548 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
549 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
550 return tsa(tok, token_semi);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
551 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
552
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
553
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
554 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
555 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
556 bool parse_envfrom(TOKEN &tok, CONFIG &dc, CONTEXT &me);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
557 bool parse_envfrom(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
558 char *st = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
559 if ((st == token_black) || (st == token_white) || (st == token_unknown)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
560 me.set_from_default(st);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
561 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
562 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
563 tok.push(st);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
564 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
565 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
566 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
567 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
568 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
569 if (have == token_rbrace) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
570 if (have == token_semi) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
571 // optional separators
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
572 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
573 else if (have == token_dccfrom) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
574 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
575 bool keeping = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
576 bool many = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
577 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
578 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
579 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
580 if (have == token_rbrace) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
581 if (have == token_ok) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
582 keeping = true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
583 many = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
584 continue;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
585 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
586 else if (have == token_many) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
587 keeping = true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
588 many = true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
589 continue;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
590 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
591 else if (have == token_ok2) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
592 keeping = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
593 continue;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
594 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
595 if (have == token_envfrom) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
596 have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
597 if (keeping) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
598 me.add_from(have, (many) ? token_black : token_white);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
599 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
600 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
601 tok.skipeol();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
602 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
603 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
604 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
605 // may be a valid email address or domain name
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
606 char *st = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
607 if ((st == token_black) || (st == token_white) || (st == token_unknown)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
608 me.add_from(have, st);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
609 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
610 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
611 CONTEXTP con = me.find_from_context_name(st);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
612 if (con) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
613 me.add_from_context(have, con);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
614 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
615 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
616 tok.token_error("white/black/unknown or child context name", st);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
617 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
618 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
619 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
620 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
621 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
622 return tsa(tok, token_semi);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
623 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
624
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
625
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
626 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
627 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
628 bool parse_context(TOKEN &tok, CONFIG &dc, CONTEXTP parent);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
629 bool parse_context(TOKEN &tok, CONFIG &dc, CONTEXTP parent) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
630 char *name = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
631 if (!tsa(tok, token_lbrace)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
632 CONTEXTP con = new CONTEXT(parent, name);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
633
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
634 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
635 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
636 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
637 if (have == token_rbrace) break; // done
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
638 if (have == token_dnsbl) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
639 if (!parse_dnsbl(tok, dc, *con)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
640 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
641 else if (have == token_dnsbll) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
642 if (!parse_dnsbll(tok, dc, *con)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
643 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
644 else if (have == token_content) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
645 if (!parse_content(tok, dc, *con)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
646 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
647 else if (have == token_envto) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
648 if (!parse_envto(tok, dc, *con)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
649 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
650 else if (have == token_envfrom) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
651 if (!parse_envfrom(tok, dc, *con)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
652 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
653 else if (have == token_context) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
654 if (!parse_context(tok, dc, con)) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
655 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
656 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
657 tok.token_error("context keyword", have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
658 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
659 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
660 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
661
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
662 if (!tsa(tok, token_semi)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
663 delete con;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
664 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
665 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
666 dc.add_context(con);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
667 if (parent) parent->add_context(con);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
668 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
669 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
670
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
671
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
672 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
673 // parse a config file
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
674 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
675 bool load_conf(CONFIG &dc, char *fn) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
676 TOKEN tok(fn, &dc.config_files);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
677 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
678 char *have = tok.next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
679 if (!have) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
680 if (have == token_context) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
681 if (!parse_context(tok, dc, NULL)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
682 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
683 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
684 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
685 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
686 tok.token_error(token_context, have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
687 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
688 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
689 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
690 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
691 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
692
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
693
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
694 ////////////////////////////////////////////////
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
695 // init the tokens
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
696 //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
697 void token_init() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
698 token_black = register_string("black");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
699 token_content = register_string("content");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
700 token_context = register_string("context");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
701 token_dccfrom = register_string("dcc_from");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
702 token_dccto = register_string("dcc_to");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
703 token_default = register_string("default");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
704 token_dnsbl = register_string("dnsbl");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
705 token_dnsbll = register_string("dnsbl_list");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
706 token_envfrom = register_string("env_from");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
707 token_envto = register_string("env_to");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
708 token_filter = register_string("filter");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
709 token_host_limit = register_string("host_limit");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
710 token_html_limit = register_string("html_limit");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
711 token_html_tags = register_string("html_tags");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
712 token_ignore = register_string("ignore");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
713 token_include = register_string("include");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
714 token_inherit = register_string("inherit");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
715 token_lbrace = register_string("{");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
716 token_many = register_string("many");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
717 token_off = register_string("off");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
718 token_ok = register_string("ok");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
719 token_ok2 = register_string("ok2");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
720 token_on = register_string("on");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
721 token_rbrace = register_string("}");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
722 token_semi = register_string(";");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
723 token_soft = register_string("soft");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
724 token_tld = register_string("tld");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
725 token_unknown = register_string("unknown");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
726 token_white = register_string("white");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
727 }