Mercurial > noffle
annotate src/filter.h @ 194:a4e9a20e50e5 noffle
[svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
Contrary to the documentation, the action of a filter if not specified
was 'full'. Add a new 'default' action which makes the action that of the
group's subscription mode. Make this the default action, and allow
'default' to be specified explicitly as the action in the filter
definition. Adapted from patch submitted by Mirko Liss. Thanks, Mirko.
* docs/noffle.conf.5: Correct small typo.
author | bears |
---|---|
date | Tue, 30 Oct 2001 12:42:13 +0000 |
parents | 8897b7e3b108 |
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 */ |