#include <NewsgroupFilter.h>
Public Member Functions | |
| NewsgroupFilter () | |
| NewsgroupFilter (const NewsgroupFilter &filter) | |
| NewsgroupFilter (const char *rulelist) | |
| NewsgroupFilter & | operator= (const NewsgroupFilter &filter) |
| NewsgroupFilter & | operator= (const char *rulelist) |
| NewsgroupFilter & | operator= (const string &rulelist) |
| int | operator== (const char *rulelist) |
| void | setWildmat (const char *pWildmat) |
| const string & | getRulelist (void) |
| int | matches (const char *newsgroup) const |
| NewsgroupFilter & | operator|= (const NewsgroupFilter &filter2) |
| NewsgroupFilter & | operator &= (const NewsgroupFilter &filter2) |
Private Member Functions | |
| void | add_rule_to_rulelist (string &rulelist, const char *rule) |
| RuleIterator | begin () const |
| RuleIterator | end () const |
Private Attributes | |
| string | rulelist |
| const char * | c_rulelist |
| string | Wildmat |
| int | WildmatSearch |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const NewsgroupFilter &f) |
Definition at line 19 of file NewsgroupFilter.h.
|
|
Definition at line 119 of file NewsgroupFilter.h. References c_rulelist, rulelist, and WildmatSearch.
00119 :WildmatSearch(0) { 00120 c_rulelist = rulelist.c_str(); 00121 } |
|
|
Construct a newsgroup filter based on a list of rules. E.g., at.*,!at.top.secret.*
Definition at line 128 of file NewsgroupFilter.h. References c_rulelist, rulelist, and WildmatSearch.
00129 : rulelist(filter.rulelist), WildmatSearch(0) { 00130 this->c_rulelist = this->rulelist.c_str(); 00131 } |
|
|
Construct a newsgroup filter based on a list of rules. E.g., at.*,!at.top.secret.*
Definition at line 140 of file NewsgroupFilter.h. References c_rulelist, and WildmatSearch.
00141 :rulelist(rulelist), WildmatSearch(0) { 00142 this->c_rulelist = this->rulelist.c_str(); 00143 } |
|
||||||||||||
|
Add a rule to a list of rules if the rule is not already contained in the list of rules.
Definition at line 94 of file NewsgroupFilter.h. Referenced by operator &=(), and operator|=().
00094 {
00095 const char *p = rulelist.c_str(), *q;
00096
00097 do {
00098 q = rule;
00099 while (*p == *q) {
00100 ++p;
00101 ++q;
00102 }
00103 if (*q == '\0' && (*p == '\0' || *p == ',')) {
00104 // current rule already contained in rulelist
00105 return;
00106 }
00107 while (*p && *p++ != ',');
00108 } while (*p);
00109
00110 rulelist += rule;
00111 rulelist += ',';
00112 }
|
|
|
Definition at line 114 of file NewsgroupFilter.h. References c_rulelist. Referenced by operator &=(), and operator|=().
00114 {
00115 return RuleIterator(c_rulelist, RuleIterator::iter_begin);
00116 } RuleIterator end() const {
|
|
|
Definition at line 116 of file NewsgroupFilter.h. Referenced by operator &=(), and operator|=().
00116 {
00117 return RuleIterator(c_rulelist, RuleIterator::iter_end);
00118 } public:
|
|
|
returning the current rulelist
Definition at line 188 of file NewsgroupFilter.h. References rulelist. Referenced by check_auth_file(), check_auth_unix(), and AccessEntry::printParameters().
00188 {
00189 return rulelist;
00190 }
|
|
|
Check whether a given newsgroup is matched/rejected by this filter. The result is based on the longest rule matching the newsgroup. Wildmat Search Extend by Herbert Straub.
Definition at line 203 of file NewsgroupFilter.h. References c_rulelist, Wildmat, wildmat(), and WildmatSearch. Referenced by ns_group(), ns_listgroup(), operator &=(), active_filter_group_time< Format >::operator()(), active_filter_group< Format >::operator()(), CheckOR::operator()(), CheckAND::operator()(), and operator|=().
00203 {
00204 char c;
00205 int j, clen, bmlen = 0, bmrej = 0;
00206 int rejrule = 0;
00207
00208 j = 0;
00209 do {
00210 clen = 0;
00211 if (c_rulelist[j] == '!') {
00212 j++;
00213 rejrule = 1;
00214 } else {
00215 rejrule = 0;
00216 }
00217 while ((c = c_rulelist[j]) && c == newsgroup[clen]) {
00218 clen++;
00219 j++;
00220 }
00221
00222 switch (c) {
00223 case ',':
00224 case '\0':
00225 if (newsgroup[clen] != '\0'
00226 && !isspace(newsgroup[clen])) {
00227 clen = -2;
00228 }
00229 clen++;
00230 break;
00231 case '*':
00232 clen++;
00233 break;
00234 default:
00235 clen = -1;
00236 break;
00237 }
00238
00239 if (clen > bmlen) {
00240 bmlen = clen;
00241 bmrej = rejrule;
00242 }
00243
00244 while (c && c != ',') {
00245 j++;
00246 c = c_rulelist[j];
00247 }
00248 j++;
00249 } while (c);
00250
00251 if (bmrej) {
00252 return -bmlen;
00253 } else if (!WildmatSearch) {
00254 return bmlen;
00255 } else {
00256 return (wildmat(newsgroup, Wildmat.c_str())? (1)
00257 : (0));
00258 }
00259 //return bmrej?-bmlen:bmlen;
00260 }
|
|
|
new filter matches all groups matched by current filter and by filter2.
Definition at line 319 of file NewsgroupFilter.h. References add_rule_to_rulelist(), begin(), c_rulelist, end(), matches(), and rulelist.
00319 {
00320 string new_rulelist;
00321 RuleIterator begin, end;
00322 const char *grp;
00323
00324 begin = this->begin();
00325 end = this->end();
00326 while (begin != end) {
00327 // copy all reject rules
00328 // copy accept rules not rejected by filter2
00329 if ((grp = *begin)[0] == '!'
00330 || filter2.matches(grp) > 0) {
00331 add_rule_to_rulelist(new_rulelist, grp);
00332 }
00333 ++begin;
00334 }
00335
00336 begin = filter2.begin();
00337 end = filter2.end();
00338 while (begin != end) {
00339 // do not add positive/negative rules already rejected
00340 if ((grp = *begin)[0] != '!') {
00341 if (matches(grp) > 0) {
00342 add_rule_to_rulelist(new_rulelist,
00343 grp);
00344 }
00345 } else if (matches(grp + 1) > 0) {
00346 add_rule_to_rulelist(new_rulelist, grp);
00347 }
00348 ++begin;
00349 }
00350
00351 long l;
00352 if ((l = new_rulelist.length()) > 0) {
00353 new_rulelist.replace(l - 1, l, "");
00354 }
00355 rulelist = new_rulelist;
00356 c_rulelist = rulelist.c_str();
00357 return *this;
00358 }
|
|
|
Definition at line 161 of file NewsgroupFilter.h. References c_rulelist.
00161 {
00162 this->rulelist = rulelist;
00163 this->c_rulelist = this->rulelist.c_str();
00164 return *this;
00165 }
|
|
|
Definition at line 155 of file NewsgroupFilter.h. References c_rulelist.
00155 {
00156 this->rulelist = rulelist;
00157 this->c_rulelist = this->rulelist.c_str();
00158 return *this;
00159 }
|
|
|
Definition at line 145 of file NewsgroupFilter.h. References c_rulelist, rulelist, Wildmat, and WildmatSearch.
00145 {
00146 this->rulelist = filter.rulelist;
00147 this->c_rulelist = rulelist.c_str();
00148 this->WildmatSearch = filter.WildmatSearch;
00149 if (this->WildmatSearch) {
00150 this->Wildmat = filter.Wildmat;
00151 }
00152 return *this;
00153 }
|
|
|
Definition at line 167 of file NewsgroupFilter.h.
00167 {
00168 return this->rulelist == rulelist;
00169 }
|
|
|
new filter matches all groups matched by current filter or by filter2.
Definition at line 270 of file NewsgroupFilter.h. References add_rule_to_rulelist(), begin(), c_rulelist, end(), matches(), and rulelist.
00270 {
00271 string new_rulelist;
00272 RuleIterator begin, end;
00273 const char *grp;
00274
00275 begin = this->begin();
00276 end = this->end();
00277 while (begin != end) {
00278 // copy all accept rules
00279 // copy reject rules also rejected by filter2
00280 if ((grp = *begin)[0] != '!'
00281 || filter2.matches(grp + 1) <= 0) {
00282 add_rule_to_rulelist(new_rulelist, grp);
00283 }
00284 ++begin;
00285 }
00286
00287 begin = filter2.begin();
00288 end = filter2.end();
00289 while (begin != end) {
00290 // do not copy accept/reject rules of filter2 accepted by this filter
00291 if ((grp = *begin)[0] != '!') {
00292 if (matches(grp) <= 0) {
00293 add_rule_to_rulelist(new_rulelist,
00294 grp);
00295 }
00296 } else if (matches(grp + 1) <= 0) {
00297 add_rule_to_rulelist(new_rulelist, grp);
00298 }
00299 ++begin;
00300 }
00301
00302 long l;
00303 if ((l = new_rulelist.length()) > 0) {
00304 new_rulelist.replace(l - 1, l, "");
00305 }
00306 rulelist = new_rulelist;
00307 c_rulelist = rulelist.c_str();
00308 return *this;
00309 }
|
|
|
Set Wildmat Pattern. Using the wildmat routine from Rich Salz INN Project.
Definition at line 178 of file NewsgroupFilter.h. References Wildmat, and WildmatSearch. Referenced by ns_list().
00178 {
00179 Wildmat = pWildmat;
00180 WildmatSearch = 1;
00181 }
|
|
||||||||||||
|
Definition at line 360 of file NewsgroupFilter.h.
00361 {
00362 os << f.rulelist;
00363 return os;
00364 }
|
|
|
Definition at line 22 of file NewsgroupFilter.h. Referenced by begin(), matches(), NewsgroupFilter(), operator &=(), operator=(), and operator|=(). |
|
|
Definition at line 21 of file NewsgroupFilter.h. Referenced by getRulelist(), NewsgroupFilter(), operator &=(), operator=(), and operator|=(). |
|
|
Definition at line 23 of file NewsgroupFilter.h. Referenced by matches(), operator=(), and setWildmat(). |
|
|
Definition at line 24 of file NewsgroupFilter.h. Referenced by matches(), NewsgroupFilter(), operator=(), and setWildmat(). |
1.3.6-20040222