Mercurial > noffle
comparison src/filter.h @ 128:8897b7e3b108 noffle
[svn] Add article filtering
| author | bears |
|---|---|
| date | Wed, 09 Aug 2000 22:19:17 +0100 |
| parents | |
| children | a4e9a20e50e5 |
comparison
equal
deleted
inserted
replaced
| 127:3c71e28c8eef | 128:8897b7e3b108 |
|---|---|
| 1 /* | |
| 2 filter.h | |
| 3 | |
| 4 Article filtering. | |
| 5 | |
| 6 $Id: filter.h 189 2000-08-09 21:19:17Z bears $ | |
| 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, | |
| 22 FILTER_DISCARD | |
| 23 } FilterAction; | |
| 24 | |
| 25 /* Representation of a rule. */ | |
| 26 typedef enum { | |
| 27 RULE_NEWSGROUP, /* Wildmat data */ | |
| 28 RULE_SUBJECT, /* Regex data */ | |
| 29 RULE_FROM, | |
| 30 RULE_MSGID, | |
| 31 RULE_BYTES_LT, RULE_BYTES_EQ, RULE_BYTES_GT, /* Number data */ | |
| 32 RULE_LINES_LT, RULE_LINES_EQ, RULE_LINES_GT, | |
| 33 RULE_NOREFS_LT, RULE_NOREFS_EQ, RULE_NOREFS_GT, | |
| 34 RULE_XPOSTS_LT, RULE_XPOSTS_EQ, RULE_XPOSTS_GT | |
| 35 } FilterRuleType; | |
| 36 | |
| 37 typedef union { | |
| 38 regex_t regex; | |
| 39 unsigned long amount; | |
| 40 char *grp; | |
| 41 } FilterRuleData; | |
| 42 | |
| 43 typedef struct { | |
| 44 FilterRuleType type; | |
| 45 FilterRuleData data; | |
| 46 } FilterRule; | |
| 47 | |
| 48 /* A single filter is a collection of rules with an action. */ | |
| 49 typedef struct { | |
| 50 int nRules; | |
| 51 int maxRules; | |
| 52 FilterRule *rules; | |
| 53 FilterAction action; | |
| 54 } Filter; | |
| 55 | |
| 56 /* Add a filter to the list of filters. */ | |
| 57 void | |
| 58 Flt_addFilter( const Filter *f ); | |
| 59 | |
| 60 /* | |
| 61 * Run the rules over the supplied overview. If a specific rule fires, | |
| 62 * returns its action. If no rule fires, return the default read mode. | |
| 63 */ | |
| 64 FilterAction | |
| 65 Flt_checkFilters( const char *thisGrp, const char *newsgroups, | |
| 66 const Over *ov, FetchMode mode ); | |
| 67 | |
| 68 /* | |
| 69 * Build and access a filter | |
| 70 */ | |
| 71 Filter * | |
| 72 new_Filter( void ); | |
| 73 | |
| 74 void | |
| 75 del_Filter( Filter *f ); | |
| 76 | |
| 77 FilterAction | |
| 78 Flt_action( const Filter *f ); | |
| 79 | |
| 80 int | |
| 81 Flt_nRules( const Filter *f ); | |
| 82 | |
| 83 Bool | |
| 84 Flt_getNewsgroups( void ); | |
| 85 | |
| 86 FilterRule | |
| 87 Flt_rule( const Filter *f, int ruleNo ); | |
| 88 | |
| 89 void | |
| 90 Flt_setAction( Filter *f, FilterAction action ); | |
| 91 | |
| 92 void | |
| 93 Flt_addRule( Filter *f, FilterRule rule ); | |
| 94 | |
| 95 #endif /* FILTER_H */ |
