Mercurial > noffle
annotate src/filter.h @ 435:aae1f2906cea noffle
[svn] updated init script output
author | godisch |
---|---|
date | Tue, 24 Jun 2003 10:28:18 +0100 |
parents | 0340b9c17edc |
children |
rev | line source |
---|---|
128 | 1 /* |
2 filter.h | |
3 | |
4 Article filtering. | |
5 | |
249 | 6 $Id: filter.h 381 2002-05-14 14:25:45Z mirkol $ |
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 */ | |
249 | 30 RULE_REFERENCE, |
128 | 31 RULE_FROM, |
32 RULE_MSGID, | |
33 RULE_BYTES_LT, RULE_BYTES_EQ, RULE_BYTES_GT, /* Number data */ | |
34 RULE_LINES_LT, RULE_LINES_EQ, RULE_LINES_GT, | |
35 RULE_NOREFS_LT, RULE_NOREFS_EQ, RULE_NOREFS_GT, | |
212 | 36 RULE_XPOSTS_LT, RULE_XPOSTS_EQ, RULE_XPOSTS_GT, |
249 | 37 RULE_DATE_LT, RULE_DATE_EQ, RULE_DATE_GT, |
212 | 38 RULE_POST_STATUS /* 'y','n','m' */ |
128 | 39 } FilterRuleType; |
40 | |
249 | 41 /* Data for Date: header parsing. */ |
42 | |
43 #define RULE_DATE_EQ_PRECISION ((time_t) (24*60*60)) /* +/- 24 hours precision */ | |
44 | |
45 typedef enum { | |
46 NOW, /* beginning of fetch */ | |
47 LASTUPDATE, /* of last fetch */ | |
48 INVALID, /* invalid dates, only RULE_DATE_EQ */ | |
49 FIXED /* fixed time */ | |
50 } FilterRuleDateEnumType; | |
51 | |
52 typedef struct { | |
53 time_t calctime; /* calctime = vartime + timeoffset */ | |
54 time_t timeoffset; | |
55 FilterRuleDateEnumType vartime; | |
56 } FilterRuleDateType; | |
57 | |
58 | |
128 | 59 typedef union { |
60 regex_t regex; | |
61 unsigned long amount; | |
62 char *grp; | |
212 | 63 char postAllow; /* 'y','n','m' */ |
249 | 64 FilterRuleDateType reftime; |
128 | 65 } FilterRuleData; |
66 | |
67 typedef struct { | |
68 FilterRuleType type; | |
69 FilterRuleData data; | |
70 } FilterRule; | |
71 | |
72 /* A single filter is a collection of rules with an action. */ | |
73 typedef struct { | |
74 int nRules; | |
75 int maxRules; | |
76 FilterRule *rules; | |
77 FilterAction action; | |
78 } Filter; | |
79 | |
80 /* Add a filter to the list of filters. */ | |
81 void | |
82 Flt_addFilter( const Filter *f ); | |
83 | |
249 | 84 |
85 /* | |
86 * Called by client.c once before processing a batch of overviews | |
87 * with Flt_checkFilters(). | |
88 */ | |
89 void | |
90 Flt_init( const char *filename ); | |
91 | |
128 | 92 /* |
93 * Run the rules over the supplied overview. If a specific rule fires, | |
94 * returns its action. If no rule fires, return the default read mode. | |
95 */ | |
96 FilterAction | |
97 Flt_checkFilters( const char *thisGrp, const char *newsgroups, | |
98 const Over *ov, FetchMode mode ); | |
99 | |
100 /* | |
101 * Build and access a filter | |
102 */ | |
103 Filter * | |
104 new_Filter( void ); | |
105 | |
106 void | |
107 del_Filter( Filter *f ); | |
108 | |
109 FilterAction | |
110 Flt_action( const Filter *f ); | |
111 | |
112 int | |
113 Flt_nRules( const Filter *f ); | |
114 | |
115 Bool | |
116 Flt_getNewsgroups( void ); | |
117 | |
118 FilterRule | |
119 Flt_rule( const Filter *f, int ruleNo ); | |
120 | |
121 void | |
122 Flt_setAction( Filter *f, FilterAction action ); | |
123 | |
124 void | |
125 Flt_addRule( Filter *f, FilterRule rule ); | |
126 | |
127 #endif /* FILTER_H */ |