#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 Herbert Straub
Definition at line 189 of file NewsgroupFilter.h. References rulelist. Referenced by check_auth_file(), check_auth_unix(), and AccessEntry::printParameters().
00189 {
00190 return rulelist;
00191 }
|
|
|
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 204 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|=().
00204 {
00205 char c;
00206 int j, clen, bmlen = 0, bmrej = 0;
00207 int rejrule = 0;
00208
00209 j = 0;
00210 do {
00211 clen = 0;
00212 if (c_rulelist[j] == '!') {
00213 j++;
00214 rejrule = 1;
00215 } else {
00216 rejrule = 0;
00217 }
00218 while ((c = c_rulelist[j]) && c == newsgroup[clen]) {
00219 clen++;
00220 j++;
00221 }
00222
00223 switch (c) {
00224 case ',':
00225 case '\0':
00226 if (newsgroup[clen] != '\0'
00227 && !isspace(newsgroup[clen])) {
00228 clen = -2;
00229 }
00230 clen++;
00231 break;
00232 case '*':
00233 clen++;
00234 break;
00235 default:
00236 clen = -1;
00237 break;
00238 }
00239
00240 if (clen > bmlen) {
00241 bmlen = clen;
00242 bmrej = rejrule;
00243 }
00244
00245 while (c && c != ',') {
00246 j++;
00247 c = c_rulelist[j];
00248 }
00249 j++;
00250 } while (c);
00251
00252 if (bmrej) {
00253 return -bmlen;
00254 } else if (!WildmatSearch) {
00255 return bmlen;
00256 } else {
00257 return (wildmat(newsgroup, Wildmat.c_str())? (1)
00258 : (0));
00259 }
00260 //return bmrej?-bmlen:bmlen;
00261 }
|
|
|
new filter matches all groups matched by current filter and by filter2.
Definition at line 320 of file NewsgroupFilter.h. References add_rule_to_rulelist(), begin(), c_rulelist, end(), matches(), and rulelist.
00320 {
00321 string new_rulelist;
00322 RuleIterator begin, end;
00323 const char *grp;
00324
00325 begin = this->begin();
00326 end = this->end();
00327 while (begin != end) {
00328 // copy all reject rules
00329 // copy accept rules not rejected by filter2
00330 if ((grp = *begin)[0] == '!'
00331 || filter2.matches(grp) > 0) {
00332 add_rule_to_rulelist(new_rulelist, grp);
00333 }
00334 ++begin;
00335 }
00336
00337 begin = filter2.begin();
00338 end = filter2.end();
00339 while (begin != end) {
00340 // do not add positive/negative rules already rejected
00341 if ((grp = *begin)[0] != '!') {
00342 if (matches(grp) > 0) {
00343 add_rule_to_rulelist(new_rulelist,
00344 grp);
00345 }
00346 } else if (matches(grp + 1) > 0) {
00347 add_rule_to_rulelist(new_rulelist, grp);
00348 }
00349 ++begin;
00350 }
00351
00352 long l;
00353 if ((l = new_rulelist.length()) > 0) {
00354 new_rulelist.replace(l - 1, l, "");
00355 }
00356 rulelist = new_rulelist;
00357 c_rulelist = rulelist.c_str();
00358 return *this;
00359 }
|
|
|
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 271 of file NewsgroupFilter.h. References add_rule_to_rulelist(), begin(), c_rulelist, end(), matches(), and rulelist.
00271 {
00272 string new_rulelist;
00273 RuleIterator begin, end;
00274 const char *grp;
00275
00276 begin = this->begin();
00277 end = this->end();
00278 while (begin != end) {
00279 // copy all accept rules
00280 // copy reject rules also rejected by filter2
00281 if ((grp = *begin)[0] != '!'
00282 || filter2.matches(grp + 1) <= 0) {
00283 add_rule_to_rulelist(new_rulelist, grp);
00284 }
00285 ++begin;
00286 }
00287
00288 begin = filter2.begin();
00289 end = filter2.end();
00290 while (begin != end) {
00291 // do not copy accept/reject rules of filter2 accepted by this filter
00292 if ((grp = *begin)[0] != '!') {
00293 if (matches(grp) <= 0) {
00294 add_rule_to_rulelist(new_rulelist,
00295 grp);
00296 }
00297 } else if (matches(grp + 1) <= 0) {
00298 add_rule_to_rulelist(new_rulelist, grp);
00299 }
00300 ++begin;
00301 }
00302
00303 long l;
00304 if ((l = new_rulelist.length()) > 0) {
00305 new_rulelist.replace(l - 1, l, "");
00306 }
00307 rulelist = new_rulelist;
00308 c_rulelist = rulelist.c_str();
00309 return *this;
00310 }
|
|
|
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 361 of file NewsgroupFilter.h.
00362 {
00363 os << f.rulelist;
00364 return os;
00365 }
|
|
|
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