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