annotate src/filter.c @ 278:a0497ffac49b noffle

[svn] I'm not very good at automake. Redo with automake2.13.
author bears
date Sun, 10 Nov 2002 18:49:41 +0000
parents 0340b9c17edc
children 5eece4dfd945
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.c
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.c 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 #if HAVE_CONFIG_H
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
10 #include <config.h>
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
11 #endif
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
12
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
13 #include <ctype.h>
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
14 #include "common.h"
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
15 #include "configfile.h"
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
16 #include "itemlist.h"
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
17 #include "log.h"
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
18 #include "wildmat.h"
212
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
19 #include "group.h"
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
20 #include "util.h"
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
21 #include "filter.h"
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
22
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
23 struct
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
24 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
25 int nFilters;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
26 int maxFilters;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
27 const Filter **filters;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
28 Bool needGroups;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
29 } filter = { 0, 0, NULL, FALSE };
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
30
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
31 static unsigned long
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
32 countGroups( const char *grps )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
33 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
34 unsigned long res;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
35
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
36 res = 1;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
37 while ( *grps != '\0' )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
38 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
39 if ( *grps == ',' )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
40 res++;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
41 grps++;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
42 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
43
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
44 return res;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
45 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
46 static unsigned long
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
47 countRefs( const char *refs )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
48 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
49 unsigned long res;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
50 Bool inRef;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
51
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
52 res = 0;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
53 inRef = FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
54
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
55 while ( *refs != '\0' )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
56 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
57 if ( inRef )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
58 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
59 if ( *refs == '>' )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
60 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
61 inRef = FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
62 res++;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
63 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
64 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
65 else if ( *refs == '<' )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
66 inRef = TRUE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
67 refs++;
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 return res;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
71 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
72
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
73 /* Check a single rule to see if it passes. */
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
74 static Bool
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
75 checkRule( const char *thisGrp, const char *newsgroups,
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
76 const Over *ov, const FilterRule *r )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
77 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
78 unsigned long ul;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
79 ItemList *grps;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
80 const char *p;
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
81 time_t articletime;
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
82
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
83 switch( r->type )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
84 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
85 case RULE_NEWSGROUP:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
86 if ( Wld_match( thisGrp, r->data.grp ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
87 return TRUE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
88 if ( newsgroups != NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
89 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
90 grps = new_Itl( newsgroups, " ,\t" );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
91 for ( p = Itl_first( grps ); p != NULL; p = Itl_next( grps ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
92 if ( Wld_match( p, r->data.grp ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
93 return TRUE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
94 del_Itl( grps );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
95 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
96 return FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
97
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
98 case RULE_SUBJECT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
99 return ( regexec( &r->data.regex, Ov_subj( ov ), 0, NULL, 0 ) == 0 );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
100
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
101 case RULE_REFERENCE: /* kill thread by Msg-Id in References: */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
102 return ( regexec( &r->data.regex, Ov_ref( ov ), 0, NULL, 0 ) == 0 );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
103
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
104 case RULE_FROM:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
105 return ( regexec( &r->data.regex, Ov_from( ov ), 0, NULL, 0 ) == 0 );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
106
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
107 case RULE_BYTES_LT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
108 return ( Ov_bytes( ov ) < r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
109
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
110 case RULE_BYTES_EQ:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
111 return ( Ov_bytes( ov ) == r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
112
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
113 case RULE_BYTES_GT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
114 return ( Ov_bytes( ov ) > r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
115
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
116 case RULE_LINES_LT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
117 return ( Ov_lines( ov ) < r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
118
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
119 case RULE_LINES_EQ:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
120 return ( Ov_lines( ov ) == r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
121
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
122 case RULE_LINES_GT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
123 return ( Ov_lines( ov ) > r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
124
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
125 case RULE_MSGID:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
126 return ( regexec( &r->data.regex, Ov_msgId( ov ), 0, NULL, 0 ) == 0 );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
127
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
128 case RULE_DATE_LT:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
129 /* Utl_parseNewsDate() is quite picky. I'm not entirely happy
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
130 about this, but I won't implement a relaxed date parser. */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
131 articletime = Utl_parseNewsDate( Ov_date( ov ) );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
132 if ( articletime == (time_t) -1 )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
133 return FALSE;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
134 return ( articletime < r->data.reftime.calctime );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
135
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
136 case RULE_DATE_EQ:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
137 articletime = Utl_parseNewsDate( Ov_date( ov ) );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
138 if ( ( articletime == (time_t) -1)
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
139 && ( r->data.reftime.vartime == INVALID ))
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
140 return TRUE;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
141 if ( ( articletime == (time_t) -1)
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
142 != ( r->data.reftime.vartime == INVALID ))
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
143 return FALSE;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
144 return ( ( articletime <= r->data.reftime.calctime
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
145 + RULE_DATE_EQ_PRECISION )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
146 && ( articletime >= r->data.reftime.calctime
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
147 - RULE_DATE_EQ_PRECISION ) );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
148
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
149 case RULE_DATE_GT:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
150 articletime = Utl_parseNewsDate( Ov_date( ov ) );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
151 if ( articletime == (time_t) -1 )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
152 return FALSE;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
153 return ( articletime > r->data.reftime.calctime );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
154
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
155 case RULE_NOREFS_LT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
156 ul = countRefs( Ov_ref( ov ) );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
157 return ( ul < r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
158
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
159 case RULE_NOREFS_EQ:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
160 ul = countRefs( Ov_ref( ov ) );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
161 return ( ul == r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
162
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
163 case RULE_NOREFS_GT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
164 ul = countRefs( Ov_ref( ov ) );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
165 return ( ul > r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
166
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
167 case RULE_XPOSTS_LT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
168 if ( newsgroups == NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
169 return FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
170 ul = countGroups( newsgroups );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
171 return ( ul < r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
172
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
173 case RULE_XPOSTS_EQ:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
174 if ( newsgroups == NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
175 return FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
176 ul = countGroups( newsgroups );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
177 return ( ul == r->data.amount );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
178
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
179 case RULE_XPOSTS_GT:
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
180 if ( newsgroups == NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
181 return FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
182 ul = countGroups( newsgroups );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
183 return ( ul > r->data.amount );
212
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
184
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
185 case RULE_POST_STATUS:
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
186 if ( Grp_postAllow( thisGrp ) == r->data.postAllow )
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
187 return TRUE;
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
188 return FALSE;
21200ce10e68 [svn] filter post-status=mod|yes|no.
mirkol
parents: 197
diff changeset
189
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
190 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
191
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
192 ASSERT( FALSE ); /* Shouldn't get here */
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 128
diff changeset
193 return 0; /* Keep compiler quiet */
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
194 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
195
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
196 /* Check a single filter to see if it fires. */
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
197 static Bool
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
198 checkFilter( const char *thisGrp, const char *newsgroups,
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
199 const Over *ov, const Filter *f )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
200 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
201 int i;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
202
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
203 for ( i = 0; i < f->nRules; i++ )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
204 if ( ! checkRule( thisGrp, newsgroups, ov, &f->rules[i] ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
205 return FALSE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
206
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
207 return TRUE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
208 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
209
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
210 /* Add a filter to the list of filters. */
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
211 void
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
212 Flt_addFilter( const Filter *f )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
213 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
214 ASSERT( f != NULL );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
215
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
216 if ( ( filter.nFilters + 1 ) > filter.maxFilters )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
217 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
218 filter.filters =
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
219 ( const Filter ** ) realloc( filter.filters,
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
220 ( filter.maxFilters + 5 )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
221 * sizeof( Filter * ) );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
222 if ( filter.filters == NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
223 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
224 Log_err( "Could not realloc filter list" );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
225 exit( EXIT_FAILURE );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
226 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
227 filter.maxFilters += 5;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
228 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
229 filter.filters[ filter.nFilters++ ] = f;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
230 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
231
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
232
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
233 /*
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
234 * Called by Fetch_init().
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
235 * Must be called before
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
236 * Fetch_getNewGrps(), Client_getNewgrps(), client.c:processGrps()
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
237 * because processGrps() sets the stampfile needed by lastupdate.
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
238 */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
239 void
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
240 Flt_init( const char * server )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
241 {
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
242 int index1, index2;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
243 time_t now, lastupdate;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
244 FilterRule * thisRule ;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
245 Str filename;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
246
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
247 time ( &now );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
248 lastupdate = (time_t) 0; /* defaults to start of epoch */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
250 snprintf( filename, MAXCHAR, "%s/lastupdate.%s",
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
251 Cfg_spoolDir(), server );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
252 if ( !Utl_getStamp( &lastupdate , filename ) )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
253 /* There's no stamp file if server has never been queried.
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
254 *
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
255 */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
256 Log_dbg( LOG_DBG_FILTER,
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
257 "Filter unable to get stamp file %s . Please query server.", filename );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
258
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
259 /* traverse all rules of all filters */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
260
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
261 for ( index1 = 0; index1 < filter.nFilters; index1++ )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
262 {
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
263 for ( index2 = 0; index2 < filter.filters[ index1 ] -> nRules; index2++ )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
264 {
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
265 thisRule = & ( filter.filters[ index1 ] -> rules[ index2 ] );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
266 switch ( thisRule -> type )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
267 {
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
268 /* evaluate variable date specs */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
269 case RULE_DATE_LT:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
270 case RULE_DATE_EQ:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
271 case RULE_DATE_GT:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
272 thisRule -> data.reftime.calctime =
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
273 thisRule ->data.reftime.timeoffset;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
274 switch ( thisRule ->data.reftime.vartime )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
275 {
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
276 case NOW:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
277 thisRule -> data.reftime.calctime += now;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
278 break;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
279 case LASTUPDATE:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
280 thisRule -> data.reftime.calctime += lastupdate;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
281 break;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
282 default:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
283 break;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
284 } /* end switch( ... vartime) */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
285
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
286 /* Silently fix absolute dates before the epoch.
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
287 * This is not the place to mock about strange dates.
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
288 */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
289 if ( thisRule -> data.reftime.calctime < (time_t) 0 )
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
290 thisRule -> data.reftime.calctime = (time_t) 0 ;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
291
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
292 /* Log_dbg( LOG_DBG_FILTER, "%d: %dl = %dl + %d",
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
293 * thisRule -> type,
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
294 * (long) thisRule -> data.reftime.calctime,
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
295 * (long) thisRule ->data.reftime.timeoffset,
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
296 * (int) ( thisRule ->data.reftime.vartime == NOW ?
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
297 * now :
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
298 * ( thisRule ->data.reftime.vartime == LASTUPDATE ?
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
299 * lastupdate : thisRule ->data.reftime.vartime ) ) );
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
300 */ break;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
301 default:
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
302 break;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
303 } /* end switch( ... -> type) */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
304 } /* end for() */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
305 } /* end for() */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
306 return ;
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
307 }
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 212
diff changeset
308
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
309 /*
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
310 * Run the rules over the supplied overview. If a specific rule fires,
194
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
311 * returns its action. If no rule fires, or a rule specifying the default
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
312 * action fires, return the default read mode.
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
313 */
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
314 FilterAction
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
315 Flt_checkFilters( const char *thisGrp, const char *newsgroups,
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
316 const Over *ov, FetchMode mode )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
317 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
318 int i;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
319
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
320 for ( i = 0; i < filter.nFilters; i++ )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
321 if ( checkFilter( thisGrp, newsgroups, ov, filter.filters[ i ] ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
322 {
194
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
323 FilterAction action = filter.filters[ i ]->action;
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
324
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 128
diff changeset
325 Log_dbg( LOG_DBG_FILTER,
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 128
diff changeset
326 "Filter %d fired on message %s",
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 128
diff changeset
327 i, Ov_msgId( ov ) );
194
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
328 if ( action == FILTER_DEFAULT )
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
329 break;
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
330 else
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
331 return action;
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
332 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
333
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
334 switch( mode )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
335 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
336 case FULL: return FILTER_FULL;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
337 case THREAD: return FILTER_THREAD;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
338 case OVER: return FILTER_XOVER;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
339 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
340
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
341 ASSERT( FALSE ); /* Shouldn't get here */
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 128
diff changeset
342 return FILTER_FULL; /* Keep compiler quiet */
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
343 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
344
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
345 Filter *
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
346 new_Filter( void )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
347 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
348 Filter *f;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
349
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
350 if ( ! ( f = ( Filter * ) malloc( sizeof( Filter ) ) ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
351 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
352 Log_err( "Cannot allocate Filter" );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
353 exit( EXIT_FAILURE );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
354 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
355 f->nRules = 0;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
356 f->maxRules = 0;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
357 f->rules = NULL;
194
a4e9a20e50e5 [svn] * docs/noffle.conf.5,src/configfile.c,src/filter.h,src/filter.c:
bears
parents: 185
diff changeset
358 f->action = FILTER_DEFAULT;
128
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
359 return f;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
360 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
361
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
362 void
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
363 del_Filter( Filter *f )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
364 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
365 if ( f == NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
366 return;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
367
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
368 if ( f->rules != NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
369 free( f->rules );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
370 free( f );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
371 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
372
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
373 FilterAction
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
374 Flt_action( const Filter *f )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
375 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
376 return f->action;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
377 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
378
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
379 int
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
380 Flt_nRules( const Filter *f )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
381 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
382 return f->nRules;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
383 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
384
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
385 /*
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
386 * Do we have a rule requiring us to fetch the Newsgroups: headers of
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
387 * articles?
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
388 */
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
389 Bool
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
390 Flt_getNewsgroups( void )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
391 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
392 return filter.needGroups;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
393 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
394
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
395 FilterRule
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
396 Flt_rule( const Filter *f, int ruleNo )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
397 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
398 ASSERT( ruleNo < f->nRules );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
399 return f->rules[ ruleNo ];
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
400 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
401
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
402 void
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
403 Flt_setAction( Filter *f, FilterAction action )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
404 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
405 f->action = action;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
406 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
407
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
408 void
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
409 Flt_addRule( Filter *f, FilterRule rule )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
410 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
411 /* Does the rule require Newsgroups: headers to be fetched? */
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
412 if ( rule.type == RULE_NEWSGROUP ||
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
413 ( rule.type >= RULE_XPOSTS_LT && rule.type <= RULE_XPOSTS_GT ) )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
414 filter.needGroups = TRUE;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
415
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
416 if ( f->nRules + 1 > f->maxRules )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
417 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
418 f->rules =
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
419 ( FilterRule * ) realloc( f->rules,
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
420 ( f->maxRules + 5 )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
421 * sizeof( FilterRule ) );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
422
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
423 if ( f->rules == NULL )
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
424 {
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
425 Log_err( "Could not realloc rule list" );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
426 exit( EXIT_FAILURE );
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
427 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
428 f->maxRules += 5;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
429 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
430 f->rules[ f->nRules++ ] = rule;
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
431 }
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
432
8897b7e3b108 [svn] Add article filtering
bears
parents:
diff changeset
433