annotate src/filter.h @ 128:8897b7e3b108 noffle

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