Mercurial > dnsbl
comparison src/context.cpp @ 72:e6a2d0be7c5e
start coding on new config syntax
author | carl |
---|---|
date | Sun, 10 Jul 2005 13:28:33 -0700 |
parents | dd21c8e13074 |
children | 2b369f7db7bf |
comparison
equal
deleted
inserted
replaced
71:dd21c8e13074 | 72:e6a2d0be7c5e |
---|---|
1 #include "context.h" | 1 /* |
2 | |
3 Copyright (c) 2004 Carl Byington - 510 Software Group, released under | |
4 the GPL version 2 or any later version at your choice available at | |
5 http://www.fsf.org/licenses/gpl.txt | |
6 | |
7 */ | |
8 | |
9 #include "includes.h" | |
2 | 10 |
3 static char* context_version="$Id:"; | 11 static char* context_version="$Id:"; |
4 | 12 |
5 char *token_black; | 13 char *token_black; |
6 char *token_content; | 14 char *token_content; |
80 if (i != env_to.end()) { | 88 if (i != env_to.end()) { |
81 con = (*i).second; | 89 con = (*i).second; |
82 return con->find_from_context(from); | 90 return con->find_from_context(from); |
83 } | 91 } |
84 } | 92 } |
85 if (default_context) { | 93 return default_context->find_from_context(from); |
86 return default_context->find_from_context(from); | |
87 } | |
88 return NULL; | |
89 } | 94 } |
90 | 95 |
91 | 96 |
92 void CONFIG::dump() { | 97 void CONFIG::dump() { |
93 if (default_context) default_context->dump(); | 98 if (default_context) default_context->dump(); |
196 if (parent) return parent->find_dnsbl(name); | 201 if (parent) return parent->find_dnsbl(name); |
197 return NULL; | 202 return NULL; |
198 } | 203 } |
199 | 204 |
200 | 205 |
206 bool CONTEXT::acceptable_content(recorder &memory, char *&msg) { | |
207 if (memory.excessive_bad_tags(tag_limit)) { | |
208 msg = tag_limit_message; | |
209 return false; | |
210 } | |
211 if (!host_random && memory.excessive_hosts(host_limit)) { | |
212 msg = host_limit_message; | |
213 return false; | |
214 } | |
215 } | |
216 | |
217 | |
201 void CONTEXT::dump(int level) { | 218 void CONTEXT::dump(int level) { |
202 const int maxlen = 1000; | 219 const int maxlen = 1000; |
203 char indent[maxlen]; | 220 char indent[maxlen]; |
204 int i = min(maxlen-1, level*4); | 221 int i = min(maxlen-1, level*4); |
205 memset(indent, ' ', i); | 222 memset(indent, ' ', i); |
685 else { | 702 else { |
686 tok.token_error(token_context, have); | 703 tok.token_error(token_context, have); |
687 return false; | 704 return false; |
688 } | 705 } |
689 } | 706 } |
690 return true; | 707 return (dc.default_context) ? true : false; |
691 } | 708 } |
692 | 709 |
693 | 710 |
694 //////////////////////////////////////////////// | 711 //////////////////////////////////////////////// |
695 // init the tokens | 712 // init the tokens |