Mercurial > noffle
annotate src/filter.h @ 205:a47b47cc1e9d noffle
[svn] *** empty log message ***
| author | mirkol |
|---|---|
| date | Sun, 11 Nov 2001 04:22:42 +0000 |
| parents | a4e9a20e50e5 |
| children | 21200ce10e68 |
| rev | line source |
|---|---|
| 128 | 1 /* |
| 2 filter.h | |
| 3 | |
| 4 Article filtering. | |
| 5 | |
|
194
a4e9a20e50e5
[svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents:
128
diff
changeset
|
6 $Id: filter.h 313 2001-10-30 12:42:13Z bears $ |
| 128 | 7 */ |
| 8 | |
| 9 #ifndef FILTER_H | |
| 10 #define FILTER_H | |
| 11 | |
| 12 #include <sys/types.h> | |
| 13 #include <regex.h> | |
| 14 #include "fetchlist.h" | |
| 15 #include "over.h" | |
| 16 | |
| 17 /* The possible actions in a filter. */ | |
| 18 typedef enum { | |
| 19 FILTER_FULL, | |
| 20 FILTER_XOVER, | |
| 21 FILTER_THREAD, | |
|
194
a4e9a20e50e5
[svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents:
128
diff
changeset
|
22 FILTER_DISCARD, |
|
a4e9a20e50e5
[svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents:
128
diff
changeset
|
23 FILTER_DEFAULT |
| 128 | 24 } FilterAction; |
| 25 | |
| 26 /* Representation of a rule. */ | |
| 27 typedef enum { | |
| 28 RULE_NEWSGROUP, /* Wildmat data */ | |
| 29 RULE_SUBJECT, /* Regex data */ | |
| 30 RULE_FROM, | |
| 31 RULE_MSGID, | |
| 32 RULE_BYTES_LT, RULE_BYTES_EQ, RULE_BYTES_GT, /* Number data */ | |
| 33 RULE_LINES_LT, RULE_LINES_EQ, RULE_LINES_GT, | |
| 34 RULE_NOREFS_LT, RULE_NOREFS_EQ, RULE_NOREFS_GT, | |
| 35 RULE_XPOSTS_LT, RULE_XPOSTS_EQ, RULE_XPOSTS_GT | |
| 36 } FilterRuleType; | |
| 37 | |
| 38 typedef union { | |
| 39 regex_t regex; | |
| 40 unsigned long amount; | |
| 41 char *grp; | |
| 42 } FilterRuleData; | |
| 43 | |
| 44 typedef struct { | |
| 45 FilterRuleType type; | |
| 46 FilterRuleData data; | |
| 47 } FilterRule; | |
| 48 | |
| 49 /* A single filter is a collection of rules with an action. */ | |
| 50 typedef struct { | |
| 51 int nRules; | |
| 52 int maxRules; | |
| 53 FilterRule *rules; | |
| 54 FilterAction action; | |
| 55 } Filter; | |
| 56 | |
| 57 /* Add a filter to the list of filters. */ | |
| 58 void | |
| 59 Flt_addFilter( const Filter *f ); | |
| 60 | |
| 61 /* | |
| 62 * Run the rules over the supplied overview. If a specific rule fires, | |
| 63 * returns its action. If no rule fires, return the default read mode. | |
| 64 */ | |
| 65 FilterAction | |
| 66 Flt_checkFilters( const char *thisGrp, const char *newsgroups, | |
| 67 const Over *ov, FetchMode mode ); | |
| 68 | |
| 69 /* | |
| 70 * Build and access a filter | |
| 71 */ | |
| 72 Filter * | |
| 73 new_Filter( void ); | |
| 74 | |
| 75 void | |
| 76 del_Filter( Filter *f ); | |
| 77 | |
| 78 FilterAction | |
| 79 Flt_action( const Filter *f ); | |
| 80 | |
| 81 int | |
| 82 Flt_nRules( const Filter *f ); | |
| 83 | |
| 84 Bool | |
| 85 Flt_getNewsgroups( void ); | |
| 86 | |
| 87 FilterRule | |
| 88 Flt_rule( const Filter *f, int ruleNo ); | |
| 89 | |
| 90 void | |
| 91 Flt_setAction( Filter *f, FilterAction action ); | |
| 92 | |
| 93 void | |
| 94 Flt_addRule( Filter *f, FilterRule rule ); | |
| 95 | |
| 96 #endif /* FILTER_H */ |
