annotate src/filter.h @ 327:a9d3ea0478c1 noffle

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