3 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
4 * Copyright (c) 2001-2014 by Hiroyuki Yamamoto & The Claws Mail Team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <glib/gi18n.h>
27 #include "filtering.h"
29 #include "matcher_parser.h"
30 #include "matcher_parser_lex.h"
31 #include "colorlabel.h"
32 #include "folder_item_prefs.h"
34 static gint
error = 0;
35 static gint bool_op
= 0;
36 static gint match_type
= 0;
37 static gchar
*header
= NULL
;
39 static MatcherProp
*prop
;
41 static GSList
*matchers_list
= NULL
;
43 static gboolean enabled
= TRUE
;
44 static gchar
*name
= NULL
;
45 static gint account_id
= 0;
46 static MatcherList
*cond
;
47 static GSList
*action_list
= NULL
;
48 static FilteringAction
*action
= NULL
;
49 static gboolean matcher_is_fast
= TRUE
;
50 static gboolean disable_warnings
= FALSE
;
52 static FilteringProp
*filtering
;
54 static GSList
**prefs_filtering
= NULL
;
55 static int enable_compatibility
= 0;
60 MATCHER_PARSE_ENABLED
,
62 MATCHER_PARSE_ACCOUNT
,
63 MATCHER_PARSE_CONDITION
,
64 MATCHER_PARSE_FILTERING_ACTION
,
67 static int matcher_parse_op
= MATCHER_PARSE_FILE
;
70 /* ******************************************************************** */
71 /* redeclarations to avoid warnings */
72 void matcher_parserrestart
(FILE *input_file
);
73 void matcher_parser_init
(void);
74 void matcher_parser_switch_to_buffer
(void * new_buffer
);
75 void matcher_parser_delete_buffer
(void * b
);
76 void matcher_parserpop_buffer_state
(void);
77 int matcher_parserlex
(void);
79 void matcher_parser_disable_warnings
(const gboolean disable
)
81 disable_warnings
= disable
;
84 void matcher_parser_start_parsing
(FILE *f
)
86 matcher_parserlineno
= 1;
87 matcher_parserrestart
(f
);
89 matcher_parserparse
();
93 void * matcher_parser_scan_string
(const char * str
);
95 FilteringProp
*matcher_parser_get_filtering
(gchar
*str
)
100 /* little hack to allow passing rules with no names */
101 if
(!strncmp
(str
, "rulename ", 9))
102 tmp_str
= g_strdup
(str
);
104 tmp_str
= g_strconcat
("rulename \"\" ", str
, NULL
);
106 /* bad coding to enable the sub-grammar matching
108 matcher_parserlineno
= 1;
109 matcher_parse_op
= MATCHER_PARSE_NO_EOL
;
110 matcher_parserrestart
(NULL
);
111 matcher_parserpop_buffer_state
();
112 matcher_parser_init
();
113 bufstate
= matcher_parser_scan_string
((const char *) tmp_str
);
114 matcher_parser_switch_to_buffer
(bufstate
);
115 if
(matcher_parserparse
() != 0)
117 matcher_parse_op
= MATCHER_PARSE_FILE
;
118 matcher_parser_delete_buffer
(bufstate
);
123 static gboolean check_quote_symetry
(gchar
*str
)
129 return TRUE
; /* heh, that's symetric */
132 for
(walk
= str
; *walk
; walk
++) {
134 if
(walk
== str
/* first char */
135 ||
*(walk
- 1) != '\\') /* not escaped */
142 MatcherList
*matcher_parser_get_name
(gchar
*str
)
146 if
(!check_quote_symetry
(str
)) {
151 /* bad coding to enable the sub-grammar matching
153 matcher_parserlineno
= 1;
154 matcher_parse_op
= MATCHER_PARSE_NAME
;
155 matcher_parserrestart
(NULL
);
156 matcher_parserpop_buffer_state
();
157 matcher_parser_init
();
158 bufstate
= matcher_parser_scan_string
(str
);
159 matcher_parserparse
();
160 matcher_parse_op
= MATCHER_PARSE_FILE
;
161 matcher_parser_delete_buffer
(bufstate
);
165 MatcherList
*matcher_parser_get_enabled
(gchar
*str
)
169 if
(!check_quote_symetry
(str
)) {
174 /* bad coding to enable the sub-grammar matching
176 matcher_parserlineno
= 1;
177 matcher_parse_op
= MATCHER_PARSE_ENABLED
;
178 matcher_parserrestart
(NULL
);
179 matcher_parserpop_buffer_state
();
180 matcher_parser_init
();
181 bufstate
= matcher_parser_scan_string
(str
);
182 matcher_parserparse
();
183 matcher_parse_op
= MATCHER_PARSE_FILE
;
184 matcher_parser_delete_buffer
(bufstate
);
188 MatcherList
*matcher_parser_get_account
(gchar
*str
)
192 if
(!check_quote_symetry
(str
)) {
197 /* bad coding to enable the sub-grammar matching
199 matcher_parserlineno
= 1;
200 matcher_parse_op
= MATCHER_PARSE_ACCOUNT
;
201 matcher_parserrestart
(NULL
);
202 matcher_parserpop_buffer_state
();
203 matcher_parser_init
();
204 bufstate
= matcher_parser_scan_string
(str
);
205 matcher_parserparse
();
206 matcher_parse_op
= MATCHER_PARSE_FILE
;
207 matcher_parser_delete_buffer
(bufstate
);
211 MatcherList
*matcher_parser_get_cond
(gchar
*str
, gboolean
*is_fast
)
215 if
(!check_quote_symetry
(str
)) {
220 matcher_is_fast
= TRUE
;
221 /* bad coding to enable the sub-grammar matching
223 matcher_parserlineno
= 1;
224 matcher_parse_op
= MATCHER_PARSE_CONDITION
;
225 matcher_parserrestart
(NULL
);
226 matcher_parserpop_buffer_state
();
227 matcher_parser_init
();
228 bufstate
= matcher_parser_scan_string
(str
);
229 matcher_parserparse
();
230 matcher_parse_op
= MATCHER_PARSE_FILE
;
231 matcher_parser_delete_buffer
(bufstate
);
233 *is_fast
= matcher_is_fast
;
237 GSList
*matcher_parser_get_action_list
(gchar
*str
)
241 if
(!check_quote_symetry
(str
)) {
246 /* bad coding to enable the sub-grammar matching
248 matcher_parserlineno
= 1;
249 matcher_parse_op
= MATCHER_PARSE_FILTERING_ACTION
;
250 matcher_parserrestart
(NULL
);
251 matcher_parserpop_buffer_state
();
252 matcher_parser_init
();
253 bufstate
= matcher_parser_scan_string
(str
);
254 matcher_parserparse
();
255 matcher_parse_op
= MATCHER_PARSE_FILE
;
256 matcher_parser_delete_buffer
(bufstate
);
260 MatcherProp
*matcher_parser_get_prop
(gchar
*str
)
265 matcher_parserlineno
= 1;
266 list
= matcher_parser_get_cond
(str
, NULL
);
270 if
(list
->matchers
== NULL
)
273 if
(list
->matchers
->next
!= NULL
)
276 prop
= list
->matchers
->data
;
278 g_slist_free
(list
->matchers
);
284 void matcher_parsererror
(char *str
)
289 for
(l
= matchers_list
; l
!= NULL
; l
= g_slist_next
(l
)) {
290 matcherprop_free
((MatcherProp
*)
294 g_slist_free
(matchers_list
);
295 matchers_list
= NULL
;
298 if
(!disable_warnings
)
299 g_warning
("filtering parsing: %i: %s",
300 matcher_parserlineno
, str
);
304 int matcher_parserwrap
(void)
314 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
315 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
316 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
317 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
318 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
319 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
320 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
321 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
322 %token MATCHER_AGE_GREATER_HOURS MATCHER_AGE_LOWER_HOURS
323 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
324 %token MATCHER_MESSAGEID MATCHER_NOT_MESSAGEID
325 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
326 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
327 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
328 %token MATCHER_HEADERS_CONT MATCHER_NOT_HEADERS_CONT
329 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
330 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
331 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
332 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
333 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
334 %token MATCHER_LOCK MATCHER_UNLOCK
335 %token MATCHER_EXECUTE
336 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
337 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
338 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
339 %token MATCHER_OR MATCHER_AND
340 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
341 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
342 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
343 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
344 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
345 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
346 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
347 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
348 %token MATCHER_ADD_TO_ADDRESSBOOK
349 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
350 %token MATCHER_SPAM MATCHER_NOT_SPAM
351 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
352 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
353 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
354 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
358 %token MATCHER_ENABLED MATCHER_DISABLED
359 %token MATCHER_RULENAME
360 %token MATCHER_ACCOUNT
361 %token
<str
> MATCHER_STRING
362 %token
<str
> MATCHER_SECTION
363 %token
<str
> MATCHER_INTEGER
369 if
(matcher_parse_op
== MATCHER_PARSE_FILE
) {
370 prefs_filtering
= &pre_global_processing
;
384 { action_list
= NULL
; }
391 section_notification:
392 MATCHER_SECTION MATCHER_EOL
395 FolderItem
*item
= NULL
;
397 if
(matcher_parse_op
== MATCHER_PARSE_FILE
) {
398 enable_compatibility
= 0;
399 if
(!strcmp
(folder
, "global")) {
400 /* backward compatibility */
401 enable_compatibility
= 1;
403 else if
(!strcmp
(folder
, "preglobal")) {
404 prefs_filtering
= &pre_global_processing
;
406 else if
(!strcmp
(folder
, "postglobal")) {
407 prefs_filtering
= &post_global_processing
;
409 else if
(!strcmp
(folder
, "filtering")) {
410 prefs_filtering
= &filtering_rules
;
413 item
= folder_find_item_from_identifier
(folder
);
415 prefs_filtering
= &item
->prefs
->processing
;
417 prefs_filtering
= NULL
;
425 enabled name account condition filtering MATCHER_EOL
426 | enabled name account condition filtering
427 | enabled name condition filtering MATCHER_EOL
428 | enabled name condition filtering
429 | name condition filtering MATCHER_EOL
430 | name condition filtering
432 if
(matcher_parse_op
== MATCHER_PARSE_NO_EOL
)
435 matcher_parsererror
("parse error [no eol]");
441 if
(matcher_parse_op
== MATCHER_PARSE_ENABLED
)
444 matcher_parsererror
("parse error [enabled]");
450 if
(matcher_parse_op
== MATCHER_PARSE_ACCOUNT
)
453 matcher_parsererror
("parse error [account]");
459 if
(matcher_parse_op
== MATCHER_PARSE_NAME
)
462 matcher_parsererror
("parse error [name]");
468 if
(matcher_parse_op
== MATCHER_PARSE_CONDITION
)
471 matcher_parsererror
("parse error [condition]");
475 | filtering_action_list
477 if
(matcher_parse_op
== MATCHER_PARSE_FILTERING_ACTION
)
480 matcher_parsererror
("parse error [filtering action]");
499 MATCHER_RULENAME MATCHER_STRING
506 MATCHER_ACCOUNT MATCHER_INTEGER
508 account_id
= strtol
($2, NULL
, 10);
513 filtering_action_list
515 filtering
= filteringprop_new
(enabled
, name
, account_id
, cond
, action_list
);
520 if
(enable_compatibility
) {
521 prefs_filtering
= &filtering_rules
;
522 if
(action_list
!= NULL
) {
523 FilteringAction
* first_action
;
525 first_action
= action_list
->data
;
527 if
(first_action
->type
== MATCHACTION_CHANGE_SCORE
)
528 prefs_filtering
= &pre_global_processing
;
535 if
((matcher_parse_op
== MATCHER_PARSE_FILE
) &&
536 (prefs_filtering
!= NULL
)) {
537 *prefs_filtering
= g_slist_append
(*prefs_filtering
,
544 filtering_action_list:
545 filtering_action_b filtering_action_list
552 action_list
= g_slist_append
(action_list
, action
);
560 match_type
= MATCHTYPE_MATCHCASE
;
564 match_type
= MATCHTYPE_MATCH
;
568 match_type
= MATCHTYPE_REGEXPCASE
;
572 match_type
= MATCHTYPE_REGEXP
;
579 cond
= matcherlist_new
(matchers_list
, (bool_op
== MATCHERBOOL_AND
));
580 matchers_list
= NULL
;
585 condition_list bool_op one_condition
587 matchers_list
= g_slist_append
(matchers_list
, prop
);
591 matchers_list
= NULL
;
592 matchers_list
= g_slist_append
(matchers_list
, prop
);
599 bool_op
= MATCHERBOOL_AND
;
603 bool_op
= MATCHERBOOL_OR
;
612 criteria
= MATCHCRITERIA_ALL
;
613 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
619 criteria
= MATCHCRITERIA_UNREAD
;
620 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
626 criteria
= MATCHCRITERIA_NOT_UNREAD
;
627 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
633 criteria
= MATCHCRITERIA_NEW
;
634 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
640 criteria
= MATCHCRITERIA_NOT_NEW
;
641 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
647 criteria
= MATCHCRITERIA_MARKED
;
648 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
654 criteria
= MATCHCRITERIA_NOT_MARKED
;
655 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
661 criteria
= MATCHCRITERIA_DELETED
;
662 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
664 | MATCHER_NOT_DELETED
668 criteria
= MATCHCRITERIA_NOT_DELETED
;
669 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
675 criteria
= MATCHCRITERIA_REPLIED
;
676 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
678 | MATCHER_NOT_REPLIED
682 criteria
= MATCHCRITERIA_NOT_REPLIED
;
683 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
689 criteria
= MATCHCRITERIA_FORWARDED
;
690 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
692 | MATCHER_NOT_FORWARDED
696 criteria
= MATCHCRITERIA_NOT_FORWARDED
;
697 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
703 criteria
= MATCHCRITERIA_LOCKED
;
704 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
710 criteria
= MATCHCRITERIA_NOT_LOCKED
;
711 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
717 criteria
= MATCHCRITERIA_SPAM
;
718 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
724 criteria
= MATCHCRITERIA_NOT_SPAM
;
725 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
727 | MATCHER_HAS_ATTACHMENT
731 criteria
= MATCHCRITERIA_HAS_ATTACHMENT
;
732 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
734 | MATCHER_HAS_NO_ATTACHMENT
738 criteria
= MATCHCRITERIA_HAS_NO_ATTACHMENT
;
739 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
745 criteria
= MATCHCRITERIA_SIGNED
;
746 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
752 criteria
= MATCHCRITERIA_NOT_SIGNED
;
753 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
759 criteria
= MATCHCRITERIA_PARTIAL
;
760 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
762 | MATCHER_NOT_PARTIAL
766 criteria
= MATCHCRITERIA_NOT_PARTIAL
;
767 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
769 | MATCHER_COLORLABEL MATCHER_INTEGER
774 criteria
= MATCHCRITERIA_COLORLABEL
;
775 value
= strtol
($2, NULL
, 10);
776 if
(value
< 0) value
= 0;
777 else if
(value
> COLORLABELS
) value
= COLORLABELS
;
778 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
780 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
785 criteria
= MATCHCRITERIA_NOT_COLORLABEL
;
786 value
= strtol
($2, NULL
, 0);
787 if
(value
< 0) value
= 0;
788 else if
(value
> COLORLABELS
) value
= COLORLABELS
;
789 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
791 | MATCHER_IGNORE_THREAD
795 criteria
= MATCHCRITERIA_IGNORE_THREAD
;
796 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
798 | MATCHER_NOT_IGNORE_THREAD
802 criteria
= MATCHCRITERIA_NOT_IGNORE_THREAD
;
803 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
805 | MATCHER_WATCH_THREAD
809 criteria
= MATCHCRITERIA_WATCH_THREAD
;
810 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
812 | MATCHER_NOT_WATCH_THREAD
816 criteria
= MATCHCRITERIA_NOT_WATCH_THREAD
;
817 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
819 | MATCHER_SUBJECT match_type MATCHER_STRING
824 criteria
= MATCHCRITERIA_SUBJECT
;
826 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
828 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
833 criteria
= MATCHCRITERIA_NOT_SUBJECT
;
835 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
837 | MATCHER_FROM match_type MATCHER_STRING
842 criteria
= MATCHCRITERIA_FROM
;
844 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
846 | MATCHER_NOT_FROM match_type MATCHER_STRING
851 criteria
= MATCHCRITERIA_NOT_FROM
;
853 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
855 | MATCHER_TO match_type MATCHER_STRING
860 criteria
= MATCHCRITERIA_TO
;
862 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
864 | MATCHER_NOT_TO match_type MATCHER_STRING
869 criteria
= MATCHCRITERIA_NOT_TO
;
871 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
873 | MATCHER_CC match_type MATCHER_STRING
878 criteria
= MATCHCRITERIA_CC
;
880 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
882 | MATCHER_NOT_CC match_type MATCHER_STRING
887 criteria
= MATCHCRITERIA_NOT_CC
;
889 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
891 | MATCHER_TO_OR_CC match_type MATCHER_STRING
896 criteria
= MATCHCRITERIA_TO_OR_CC
;
898 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
900 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
905 criteria
= MATCHCRITERIA_NOT_TO_AND_NOT_CC
;
907 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
909 | MATCHER_TAG match_type MATCHER_STRING
914 criteria
= MATCHCRITERIA_TAG
;
916 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
918 | MATCHER_NOT_TAG match_type MATCHER_STRING
923 criteria
= MATCHCRITERIA_NOT_TAG
;
925 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
931 criteria
= MATCHCRITERIA_TAGGED
;
932 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
938 criteria
= MATCHCRITERIA_NOT_TAGGED
;
939 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
941 | MATCHER_AGE_GREATER MATCHER_INTEGER
946 criteria
= MATCHCRITERIA_AGE_GREATER
;
947 value
= strtol
($2, NULL
, 0);
948 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
950 | MATCHER_AGE_LOWER MATCHER_INTEGER
955 criteria
= MATCHCRITERIA_AGE_LOWER
;
956 value
= strtol
($2, NULL
, 0);
957 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
959 | MATCHER_AGE_GREATER_HOURS MATCHER_INTEGER
964 criteria
= MATCHCRITERIA_AGE_GREATER_HOURS
;
965 value
= strtol
($2, NULL
, 0);
966 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
968 | MATCHER_AGE_LOWER_HOURS MATCHER_INTEGER
973 criteria
= MATCHCRITERIA_AGE_LOWER_HOURS
;
974 value
= strtol
($2, NULL
, 0);
975 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
977 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
982 criteria
= MATCHCRITERIA_NEWSGROUPS
;
984 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
986 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
991 criteria
= MATCHCRITERIA_NOT_NEWSGROUPS
;
993 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
995 | MATCHER_MESSAGEID match_type MATCHER_STRING
1000 criteria
= MATCHCRITERIA_MESSAGEID
;
1002 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1004 | MATCHER_NOT_MESSAGEID match_type MATCHER_STRING
1009 criteria
= MATCHCRITERIA_NOT_MESSAGEID
;
1011 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1013 | MATCHER_INREPLYTO match_type MATCHER_STRING
1018 criteria
= MATCHCRITERIA_INREPLYTO
;
1020 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1022 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
1027 criteria
= MATCHCRITERIA_NOT_INREPLYTO
;
1029 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1031 | MATCHER_REFERENCES match_type MATCHER_STRING
1036 criteria
= MATCHCRITERIA_REFERENCES
;
1038 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1040 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
1045 criteria
= MATCHCRITERIA_NOT_REFERENCES
;
1047 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1049 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1054 criteria
= MATCHCRITERIA_SCORE_GREATER
;
1055 value
= strtol
($2, NULL
, 0);
1056 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1058 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1063 criteria
= MATCHCRITERIA_SCORE_LOWER
;
1064 value
= strtol
($2, NULL
, 0);
1065 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1067 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1072 criteria
= MATCHCRITERIA_SCORE_EQUAL
;
1073 value
= strtol
($2, NULL
, 0);
1074 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1076 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1080 criteria
= MATCHCRITERIA_SIZE_GREATER
;
1081 value
= strtol
($2, NULL
, 0);
1082 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1084 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1088 criteria
= MATCHCRITERIA_SIZE_SMALLER
;
1089 value
= strtol
($2, NULL
, 0);
1090 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1092 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1096 criteria
= MATCHCRITERIA_SIZE_EQUAL
;
1097 value
= strtol
($2, NULL
, 0);
1098 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1100 | MATCHER_HEADER MATCHER_STRING
1102 header
= g_strdup
($2);
1103 } match_type MATCHER_STRING
1107 matcher_is_fast
= FALSE
;
1108 criteria
= MATCHCRITERIA_HEADER
;
1110 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1113 | MATCHER_NOT_HEADER MATCHER_STRING
1115 header
= g_strdup
($2);
1116 } match_type MATCHER_STRING
1120 matcher_is_fast
= FALSE
;
1121 criteria
= MATCHCRITERIA_NOT_HEADER
;
1123 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1126 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1130 matcher_is_fast
= FALSE
;
1131 criteria
= MATCHCRITERIA_HEADERS_PART
;
1133 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1135 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1139 matcher_is_fast
= FALSE
;
1140 criteria
= MATCHCRITERIA_NOT_HEADERS_PART
;
1142 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1144 | MATCHER_HEADERS_CONT match_type MATCHER_STRING
1148 matcher_is_fast
= FALSE
;
1149 criteria
= MATCHCRITERIA_HEADERS_CONT
;
1151 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1153 | MATCHER_NOT_HEADERS_CONT match_type MATCHER_STRING
1157 matcher_is_fast
= FALSE
;
1158 criteria
= MATCHCRITERIA_NOT_HEADERS_CONT
;
1160 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1162 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1164 header
= g_strdup
($2);
1165 } MATCHER_IN MATCHER_STRING
1170 criteria
= MATCHCRITERIA_FOUND_IN_ADDRESSBOOK
;
1172 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1175 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1177 header
= g_strdup
($2);
1178 } MATCHER_IN MATCHER_STRING
1183 criteria
= MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK
;
1185 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1188 | MATCHER_MESSAGE match_type MATCHER_STRING
1192 matcher_is_fast
= FALSE
;
1193 criteria
= MATCHCRITERIA_MESSAGE
;
1195 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1197 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1201 matcher_is_fast
= FALSE
;
1202 criteria
= MATCHCRITERIA_NOT_MESSAGE
;
1204 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1206 | MATCHER_BODY_PART match_type MATCHER_STRING
1210 matcher_is_fast
= FALSE
;
1211 criteria
= MATCHCRITERIA_BODY_PART
;
1213 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1215 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1219 matcher_is_fast
= FALSE
;
1220 criteria
= MATCHCRITERIA_NOT_BODY_PART
;
1222 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1224 | MATCHER_TEST MATCHER_STRING
1228 matcher_is_fast
= FALSE
;
1229 criteria
= MATCHCRITERIA_TEST
;
1231 prop
= matcherprop_new
(criteria
, NULL
, MATCHTYPE_MATCH
, expr
, 0);
1233 | MATCHER_NOT_TEST MATCHER_STRING
1237 matcher_is_fast
= FALSE
;
1238 criteria
= MATCHCRITERIA_NOT_TEST
;
1240 prop
= matcherprop_new
(criteria
, NULL
, MATCHTYPE_MATCH
, expr
, 0);
1245 MATCHER_EXECUTE MATCHER_STRING
1248 gint action_type
= 0;
1250 action_type
= MATCHACTION_EXECUTE
;
1252 action
= filteringaction_new
(action_type
, 0, cmd
, 0, 0, NULL
);
1254 | MATCHER_MOVE MATCHER_STRING
1256 gchar
*destination
= NULL
;
1257 gint action_type
= 0;
1259 action_type
= MATCHACTION_MOVE
;
1261 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1263 | MATCHER_SET_TAG MATCHER_STRING
1265 gchar
*destination
= NULL
;
1266 gint action_type
= 0;
1268 action_type
= MATCHACTION_SET_TAG
;
1270 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1272 | MATCHER_UNSET_TAG MATCHER_STRING
1274 gchar
*destination
= NULL
;
1275 gint action_type
= 0;
1277 action_type
= MATCHACTION_UNSET_TAG
;
1279 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1281 | MATCHER_CLEAR_TAGS
1283 gint action_type
= 0;
1285 action_type
= MATCHACTION_CLEAR_TAGS
;
1286 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1288 | MATCHER_COPY MATCHER_STRING
1290 gchar
*destination
= NULL
;
1291 gint action_type
= 0;
1293 action_type
= MATCHACTION_COPY
;
1295 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1299 gint action_type
= 0;
1301 action_type
= MATCHACTION_DELETE
;
1302 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1306 gint action_type
= 0;
1308 action_type
= MATCHACTION_MARK
;
1309 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1313 gint action_type
= 0;
1315 action_type
= MATCHACTION_UNMARK
;
1316 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1320 gint action_type
= 0;
1322 action_type
= MATCHACTION_LOCK
;
1323 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1327 gint action_type
= 0;
1329 action_type
= MATCHACTION_UNLOCK
;
1330 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1332 | MATCHER_MARK_AS_READ
1334 gint action_type
= 0;
1336 action_type
= MATCHACTION_MARK_AS_READ
;
1337 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1339 | MATCHER_MARK_AS_UNREAD
1341 gint action_type
= 0;
1343 action_type
= MATCHACTION_MARK_AS_UNREAD
;
1344 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1346 | MATCHER_MARK_AS_SPAM
1348 gint action_type
= 0;
1350 action_type
= MATCHACTION_MARK_AS_SPAM
;
1351 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1353 | MATCHER_MARK_AS_HAM
1355 gint action_type
= 0;
1357 action_type
= MATCHACTION_MARK_AS_HAM
;
1358 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1360 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1362 gchar
*destination
= NULL
;
1363 gint action_type
= 0;
1364 gint account_id
= 0;
1366 action_type
= MATCHACTION_FORWARD
;
1367 account_id
= strtol
($2, NULL
, 10);
1369 action
= filteringaction_new
(action_type
,
1370 account_id
, destination
, 0, 0, NULL
);
1372 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1374 gchar
*destination
= NULL
;
1375 gint action_type
= 0;
1376 gint account_id
= 0;
1378 action_type
= MATCHACTION_FORWARD_AS_ATTACHMENT
;
1379 account_id
= strtol
($2, NULL
, 10);
1381 action
= filteringaction_new
(action_type
,
1382 account_id
, destination
, 0, 0, NULL
);
1384 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1386 gchar
*destination
= NULL
;
1387 gint action_type
= 0;
1388 gint account_id
= 0;
1390 action_type
= MATCHACTION_REDIRECT
;
1391 account_id
= strtol
($2, NULL
, 10);
1393 action
= filteringaction_new
(action_type
,
1394 account_id
, destination
, 0, 0, NULL
);
1396 | MATCHER_COLOR MATCHER_INTEGER
1398 gint action_type
= 0;
1401 action_type
= MATCHACTION_COLOR
;
1402 color
= strtol
($2, NULL
, 10);
1403 action
= filteringaction_new
(action_type
, 0, NULL
, color
, 0, NULL
);
1405 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1409 score
= strtol
($2, NULL
, 10);
1410 action
= filteringaction_new
(MATCHACTION_CHANGE_SCORE
, 0,
1411 NULL
, 0, score
, NULL
);
1413 /* backward compatibility */
1414 | MATCHER_SCORE MATCHER_INTEGER
1418 score
= strtol
($2, NULL
, 10);
1419 action
= filteringaction_new
(MATCHACTION_CHANGE_SCORE
, 0,
1420 NULL
, 0, score
, NULL
);
1422 | MATCHER_SET_SCORE MATCHER_INTEGER
1426 score
= strtol
($2, NULL
, 10);
1427 action
= filteringaction_new
(MATCHACTION_SET_SCORE
, 0,
1428 NULL
, 0, score
, NULL
);
1432 action
= filteringaction_new
(MATCHACTION_HIDE
, 0, NULL
, 0, 0, NULL
);
1436 action
= filteringaction_new
(MATCHACTION_IGNORE
, 0, NULL
, 0, 0, NULL
);
1440 action
= filteringaction_new
(MATCHACTION_WATCH
, 0, NULL
, 0, 0, NULL
);
1442 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1444 header
= g_strdup
($2);
1447 gchar
*addressbook
= NULL
;
1448 gint action_type
= 0;
1450 action_type
= MATCHACTION_ADD_TO_ADDRESSBOOK
;
1452 action
= filteringaction_new
(action_type
, 0, addressbook
, 0, 0, header
);
1457 action
= filteringaction_new
(MATCHACTION_STOP
, 0, NULL
, 0, 0, NULL
);