Mercurial > dnsbl
comparison src/context.h @ 73:2b369f7db7bf
start coding on new config syntax
author | carl |
---|---|
date | Sun, 10 Jul 2005 13:28:33 -0700 |
parents | dd21c8e13074 |
children | b7449114ebb0 |
comparison
equal
deleted
inserted
replaced
72:e6a2d0be7c5e | 73:2b369f7db7bf |
---|---|
1 #ifndef context_include | |
2 #define context_include | |
3 | |
1 #include "tokenizer.h" | 4 #include "tokenizer.h" |
2 #include <map> | 5 #include <map> |
3 | 6 |
4 | 7 |
5 enum status {oksofar, // not rejected yet | 8 enum status {oksofar, // not rejected yet |
9 reject_tag, // too many bad html tags | 12 reject_tag, // too many bad html tags |
10 reject_host}; // too many hosts/urls in body | 13 reject_host}; // too many hosts/urls in body |
11 | 14 |
12 class DNSBL; | 15 class DNSBL; |
13 class CONTEXT; | 16 class CONTEXT; |
17 class recorder; | |
14 | 18 |
15 typedef map<char *, char *, ltstr> string_map; | 19 typedef map<char *, char *, ltstr> string_map; |
16 typedef set<int> int_set; | 20 typedef set<int> int_set; |
17 typedef list<char *> string_list; | 21 typedef list<char *> string_list; |
18 typedef DNSBL * DNSBLP; | 22 typedef DNSBL * DNSBLP; |
84 | 88 |
85 void add_dnsbl(char *name, DNSBLP dns) {dnsbl_names[name] = dns;}; | 89 void add_dnsbl(char *name, DNSBLP dns) {dnsbl_names[name] = dns;}; |
86 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);}; | 90 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);}; |
87 DNSBLP find_dnsbl(char *name); | 91 DNSBLP find_dnsbl(char *name); |
88 | 92 |
93 int get_host_limit() {return host_limit;}; | |
94 bool get_host_random() {return host_random;}; | |
95 char* get_content_suffix() {return content_suffix;}; | |
96 char* get_content_message() {return content_message;}; | |
97 string_set& get_content_host_ignore() {return content_host_ignore;}; | |
98 string_set& get_content_tlds() {return content_tlds;}; | |
99 string_set& get_html_tags() {return html_tags;}; | |
100 dnsblp_list& get_dnsbl_list() {return dnsbl_list;}; | |
101 bool get_content_filtering() {return content_filtering;}; | |
102 | |
103 bool acceptable_content(recorder &memory); | |
104 bool ignore_host(char *host); | |
105 | |
89 void dump(int level = 0); | 106 void dump(int level = 0); |
90 }; | 107 }; |
91 | 108 |
92 | 109 |
93 struct CONFIG { | 110 struct CONFIG { |
98 time_t load_time; | 115 time_t load_time; |
99 string_set config_files; | 116 string_set config_files; |
100 context_list contexts; // owns all the contexts, not just top level contexts | 117 context_list contexts; // owns all the contexts, not just top level contexts |
101 context_map env_to; // map recipient to a filtering context | 118 context_map env_to; // map recipient to a filtering context |
102 CONTEXTP default_context;// for env_to values that don't have their own specific filtering context | 119 CONTEXTP default_context;// for env_to values that don't have their own specific filtering context |
120 // the default context is also used for some of the content filtering values | |
103 | 121 |
104 CONFIG(); | 122 CONFIG(); |
105 ~CONFIG(); | 123 ~CONFIG(); |
106 void add_context(CONTEXTP con); | 124 void add_context(CONTEXTP con); |
107 void add_to(char *to, CONTEXTP con) {env_to[to] = con;}; | 125 void add_to(char *to, CONTEXTP con) {env_to[to] = con;}; |
108 CONTEXTP find_context(char *to, char *from); | 126 CONTEXTP find_context(char *to, char *from); |
127 | |
128 char* get_content_suffix() {return default_context->get_content_suffix() ;}; | |
129 char* get_content_message() {return default_context->get_content_message() ;}; | |
130 string_set& get_content_host_ignore() {return default_context->get_content_host_ignore() ;}; | |
131 string_set& get_content_tlds() {return default_context->get_content_tlds() ;}; | |
132 string_set& get_html_tags() {return default_context->get_html_tags() ;}; | |
133 | |
109 void dump(); | 134 void dump(); |
110 }; | 135 }; |
111 | 136 |
112 extern char *token_black; | 137 extern char *token_black; |
113 extern char *token_content; | 138 extern char *token_content; |
145 char* register_string(string_set &s, char *name); | 170 char* register_string(string_set &s, char *name); |
146 char* register_string(char *name); | 171 char* register_string(char *name); |
147 CONFIG *parse_config(char *fn); | 172 CONFIG *parse_config(char *fn); |
148 bool load_conf(CONFIG &dc, char *fn); | 173 bool load_conf(CONFIG &dc, char *fn); |
149 void token_init(); | 174 void token_init(); |
175 | |
176 #endif |