3 * Claws Mail -- 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"
28 #include "procheader.h"
30 #include "matcher_parser.h"
31 #include "matcher_parser_lex.h"
32 #include "colorlabel.h"
33 #include "folder_item_prefs.h"
35 static gint
error = 0;
36 static gint bool_op
= 0;
37 static gint match_type
= 0;
38 static gchar
*header
= NULL
;
40 static MatcherProp
*prop
;
42 static GSList
*matchers_list
= NULL
;
44 static gboolean enabled
= TRUE
;
45 static gchar
*name
= NULL
;
46 static gint account_id
= 0;
47 static MatcherList
*cond
;
48 static GSList
*action_list
= NULL
;
49 static FilteringAction
*action
= NULL
;
50 static gboolean matcher_is_fast
= TRUE
;
51 static gboolean disable_warnings
= FALSE
;
53 static FilteringProp
*filtering
;
54 static gboolean filtering_ptr_externally_managed
= FALSE
;
56 static GSList
**prefs_filtering
= NULL
;
57 static int enable_compatibility
= 0;
62 MATCHER_PARSE_ENABLED
,
64 MATCHER_PARSE_ACCOUNT
,
65 MATCHER_PARSE_CONDITION
,
66 MATCHER_PARSE_FILTERING_ACTION
,
69 static int matcher_parse_op
= MATCHER_PARSE_FILE
;
72 /* ******************************************************************** */
73 /* redeclarations to avoid warnings */
74 void matcher_parserrestart
(FILE *input_file
);
75 void matcher_parser_init
(void);
76 void matcher_parser_switch_to_buffer
(void * new_buffer
);
77 void matcher_parser_delete_buffer
(void * b
);
78 void matcher_parserpop_buffer_state
(void);
79 int matcher_parserlex
(void);
81 void matcher_parser_disable_warnings
(const gboolean disable
)
83 disable_warnings
= disable
;
86 void matcher_parser_start_parsing
(FILE *f
)
88 matcher_parserlineno
= 1;
89 matcher_parserrestart
(f
);
91 matcher_parserparse
();
95 void * matcher_parser_scan_string
(const char * str
);
97 FilteringProp
*matcher_parser_get_filtering
(gchar
*str
)
100 void *tmp_str
= NULL
;
102 /* little hack to allow passing rules with no names */
103 if
(!strncmp
(str
, "rulename ", 9))
104 tmp_str
= g_strdup
(str
);
106 tmp_str
= g_strconcat
("rulename \"\" ", str
, NULL
);
108 /* bad coding to enable the sub-grammar matching
110 matcher_parserlineno
= 1;
111 matcher_parse_op
= MATCHER_PARSE_NO_EOL
;
112 matcher_parserrestart
(NULL
);
113 matcher_parserpop_buffer_state
();
114 matcher_parser_init
();
115 bufstate
= matcher_parser_scan_string
((const char *) tmp_str
);
116 matcher_parser_switch_to_buffer
(bufstate
);
117 /* Indicate that we will be using the global "filtering" pointer,
118 * so that yyparse does not free it in "filtering_action_list"
120 filtering_ptr_externally_managed
= TRUE
;
121 if
(matcher_parserparse
() != 0)
123 matcher_parse_op
= MATCHER_PARSE_FILE
;
124 matcher_parser_delete_buffer
(bufstate
);
126 filtering_ptr_externally_managed
= FALSE
; /* Return to normal. */
130 static gboolean check_quote_symetry
(gchar
*str
)
136 return TRUE
; /* heh, that's symetric */
139 for
(walk
= str
; *walk
; walk
++) {
141 if
(walk
== str
/* first char */
142 ||
*(walk
- 1) != '\\') /* not escaped */
149 MatcherList
*matcher_parser_get_name
(gchar
*str
)
153 if
(!check_quote_symetry
(str
)) {
158 /* bad coding to enable the sub-grammar matching
160 matcher_parserlineno
= 1;
161 matcher_parse_op
= MATCHER_PARSE_NAME
;
162 matcher_parserrestart
(NULL
);
163 matcher_parserpop_buffer_state
();
164 matcher_parser_init
();
165 bufstate
= matcher_parser_scan_string
(str
);
166 matcher_parserparse
();
167 matcher_parse_op
= MATCHER_PARSE_FILE
;
168 matcher_parser_delete_buffer
(bufstate
);
172 MatcherList
*matcher_parser_get_enabled
(gchar
*str
)
176 if
(!check_quote_symetry
(str
)) {
181 /* bad coding to enable the sub-grammar matching
183 matcher_parserlineno
= 1;
184 matcher_parse_op
= MATCHER_PARSE_ENABLED
;
185 matcher_parserrestart
(NULL
);
186 matcher_parserpop_buffer_state
();
187 matcher_parser_init
();
188 bufstate
= matcher_parser_scan_string
(str
);
189 matcher_parserparse
();
190 matcher_parse_op
= MATCHER_PARSE_FILE
;
191 matcher_parser_delete_buffer
(bufstate
);
195 MatcherList
*matcher_parser_get_account
(gchar
*str
)
199 if
(!check_quote_symetry
(str
)) {
204 /* bad coding to enable the sub-grammar matching
206 matcher_parserlineno
= 1;
207 matcher_parse_op
= MATCHER_PARSE_ACCOUNT
;
208 matcher_parserrestart
(NULL
);
209 matcher_parserpop_buffer_state
();
210 matcher_parser_init
();
211 bufstate
= matcher_parser_scan_string
(str
);
212 matcher_parserparse
();
213 matcher_parse_op
= MATCHER_PARSE_FILE
;
214 matcher_parser_delete_buffer
(bufstate
);
218 MatcherList
*matcher_parser_get_cond
(gchar
*str
, gboolean
*is_fast
)
222 if
(!check_quote_symetry
(str
)) {
227 matcher_is_fast
= TRUE
;
228 /* bad coding to enable the sub-grammar matching
230 matcher_parserlineno
= 1;
231 matcher_parse_op
= MATCHER_PARSE_CONDITION
;
232 matcher_parserrestart
(NULL
);
233 matcher_parserpop_buffer_state
();
234 matcher_parser_init
();
235 bufstate
= matcher_parser_scan_string
(str
);
236 matcher_parserparse
();
237 matcher_parse_op
= MATCHER_PARSE_FILE
;
238 matcher_parser_delete_buffer
(bufstate
);
240 *is_fast
= matcher_is_fast
;
244 GSList
*matcher_parser_get_action_list
(gchar
*str
)
248 if
(!check_quote_symetry
(str
)) {
253 /* bad coding to enable the sub-grammar matching
255 matcher_parserlineno
= 1;
256 matcher_parse_op
= MATCHER_PARSE_FILTERING_ACTION
;
257 matcher_parserrestart
(NULL
);
258 matcher_parserpop_buffer_state
();
259 matcher_parser_init
();
260 bufstate
= matcher_parser_scan_string
(str
);
261 matcher_parserparse
();
262 matcher_parse_op
= MATCHER_PARSE_FILE
;
263 matcher_parser_delete_buffer
(bufstate
);
267 MatcherProp
*matcher_parser_get_prop
(gchar
*str
)
272 matcher_parserlineno
= 1;
273 list
= matcher_parser_get_cond
(str
, NULL
);
277 if
(list
->matchers
== NULL
)
280 if
(list
->matchers
->next
!= NULL
)
283 prop
= list
->matchers
->data
;
285 g_slist_free
(list
->matchers
);
291 void matcher_parsererror
(char *str
)
296 for
(l
= matchers_list
; l
!= NULL
; l
= g_slist_next
(l
)) {
297 matcherprop_free
((MatcherProp
*)
301 g_slist_free
(matchers_list
);
302 matchers_list
= NULL
;
305 if
(!disable_warnings
)
306 g_warning
("filtering parsing: %i: %s",
307 matcher_parserlineno
, str
);
311 int matcher_parserwrap
(void)
321 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
322 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
323 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
324 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
325 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
326 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
327 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
328 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
329 %token MATCHER_AGE_GREATER_HOURS MATCHER_AGE_LOWER_HOURS
330 %token MATCHER_DATE_AFTER MATCHER_DATE_BEFORE
331 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
332 %token MATCHER_MESSAGEID MATCHER_NOT_MESSAGEID
333 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
334 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
335 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
336 %token MATCHER_HEADERS_CONT MATCHER_NOT_HEADERS_CONT
337 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
338 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
339 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
340 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
341 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
342 %token MATCHER_LOCK MATCHER_UNLOCK
343 %token MATCHER_EXECUTE
344 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
345 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
346 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
347 %token MATCHER_OR MATCHER_AND
348 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
349 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
350 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
351 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
352 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
353 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
354 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
355 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
356 %token MATCHER_ADD_TO_ADDRESSBOOK
357 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
358 %token MATCHER_SPAM MATCHER_NOT_SPAM
359 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
360 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
361 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
362 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
366 %token MATCHER_ENABLED MATCHER_DISABLED
367 %token MATCHER_RULENAME
368 %token MATCHER_ACCOUNT
369 %token
<str
> MATCHER_STRING
370 %token
<str
> MATCHER_SECTION
371 %token
<str
> MATCHER_INTEGER
377 if
(matcher_parse_op
== MATCHER_PARSE_FILE
) {
378 prefs_filtering
= &pre_global_processing
;
392 { action_list
= NULL
; }
399 section_notification:
400 MATCHER_SECTION MATCHER_EOL
403 FolderItem
*item
= NULL
;
405 if
(matcher_parse_op
== MATCHER_PARSE_FILE
) {
406 enable_compatibility
= 0;
407 if
(!strcmp
(folder
, "global")) {
408 /* backward compatibility */
409 enable_compatibility
= 1;
411 else if
(!strcmp
(folder
, "preglobal")) {
412 prefs_filtering
= &pre_global_processing
;
414 else if
(!strcmp
(folder
, "postglobal")) {
415 prefs_filtering
= &post_global_processing
;
417 else if
(!strcmp
(folder
, "filtering")) {
418 prefs_filtering
= &filtering_rules
;
421 item
= folder_find_item_from_identifier
(folder
);
423 prefs_filtering
= &item
->prefs
->processing
;
425 prefs_filtering
= NULL
;
433 enabled name account condition filtering MATCHER_EOL
434 | enabled name account condition filtering
435 | enabled name condition filtering MATCHER_EOL
436 | enabled name condition filtering
437 | name condition filtering MATCHER_EOL
438 | name condition filtering
440 if
(matcher_parse_op
== MATCHER_PARSE_NO_EOL
)
443 matcher_parsererror
("parse error [no eol]");
449 if
(matcher_parse_op
== MATCHER_PARSE_ENABLED
)
452 matcher_parsererror
("parse error [enabled]");
458 if
(matcher_parse_op
== MATCHER_PARSE_ACCOUNT
)
461 matcher_parsererror
("parse error [account]");
467 if
(matcher_parse_op
== MATCHER_PARSE_NAME
)
470 matcher_parsererror
("parse error [name]");
476 if
(matcher_parse_op
== MATCHER_PARSE_CONDITION
)
479 matcher_parsererror
("parse error [condition]");
483 | filtering_action_list
485 if
(matcher_parse_op
== MATCHER_PARSE_FILTERING_ACTION
)
488 matcher_parsererror
("parse error [filtering action]");
507 MATCHER_RULENAME MATCHER_STRING
514 MATCHER_ACCOUNT MATCHER_INTEGER
516 account_id
= strtol
($2, NULL
, 10);
521 filtering_action_list
523 filtering
= filteringprop_new
(enabled
, name
, account_id
, cond
, action_list
);
528 if
(enable_compatibility
) {
529 prefs_filtering
= &filtering_rules
;
530 if
(action_list
!= NULL
) {
531 FilteringAction
* first_action
;
533 first_action
= action_list
->data
;
535 if
(first_action
->type
== MATCHACTION_CHANGE_SCORE
)
536 prefs_filtering
= &pre_global_processing
;
543 if
((matcher_parse_op
== MATCHER_PARSE_FILE
) &&
544 (prefs_filtering
!= NULL
)) {
545 *prefs_filtering
= g_slist_append
(*prefs_filtering
,
548 } else if
(!filtering_ptr_externally_managed
) {
549 /* If filtering_ptr_externally_managed was TRUE, it
550 * would mean that some function higher in the stack is
551 * interested in the data "filtering" is pointing at, so
552 * we would not free it. That function has to free it itself.
553 * At the time of writing this, the only function that
554 * does this is matcher_parser_get_filtering(). */
555 filteringprop_free
(filtering
);
561 filtering_action_list:
562 filtering_action_b filtering_action_list
569 action_list
= g_slist_append
(action_list
, action
);
577 match_type
= MATCHTYPE_MATCHCASE
;
581 match_type
= MATCHTYPE_MATCH
;
585 match_type
= MATCHTYPE_REGEXPCASE
;
589 match_type
= MATCHTYPE_REGEXP
;
596 cond
= matcherlist_new
(matchers_list
, (bool_op
== MATCHERBOOL_AND
));
597 matchers_list
= NULL
;
602 condition_list bool_op one_condition
604 matchers_list
= g_slist_append
(matchers_list
, prop
);
608 matchers_list
= NULL
;
609 matchers_list
= g_slist_append
(matchers_list
, prop
);
616 bool_op
= MATCHERBOOL_AND
;
620 bool_op
= MATCHERBOOL_OR
;
629 criteria
= MATCHCRITERIA_ALL
;
630 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
636 criteria
= MATCHCRITERIA_UNREAD
;
637 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
643 criteria
= MATCHCRITERIA_NOT_UNREAD
;
644 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
650 criteria
= MATCHCRITERIA_NEW
;
651 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
657 criteria
= MATCHCRITERIA_NOT_NEW
;
658 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
664 criteria
= MATCHCRITERIA_MARKED
;
665 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
671 criteria
= MATCHCRITERIA_NOT_MARKED
;
672 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
678 criteria
= MATCHCRITERIA_DELETED
;
679 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
681 | MATCHER_NOT_DELETED
685 criteria
= MATCHCRITERIA_NOT_DELETED
;
686 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
692 criteria
= MATCHCRITERIA_REPLIED
;
693 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
695 | MATCHER_NOT_REPLIED
699 criteria
= MATCHCRITERIA_NOT_REPLIED
;
700 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
706 criteria
= MATCHCRITERIA_FORWARDED
;
707 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
709 | MATCHER_NOT_FORWARDED
713 criteria
= MATCHCRITERIA_NOT_FORWARDED
;
714 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
720 criteria
= MATCHCRITERIA_LOCKED
;
721 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
727 criteria
= MATCHCRITERIA_NOT_LOCKED
;
728 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
734 criteria
= MATCHCRITERIA_SPAM
;
735 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
741 criteria
= MATCHCRITERIA_NOT_SPAM
;
742 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
744 | MATCHER_HAS_ATTACHMENT
748 criteria
= MATCHCRITERIA_HAS_ATTACHMENT
;
749 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
751 | MATCHER_HAS_NO_ATTACHMENT
755 criteria
= MATCHCRITERIA_HAS_NO_ATTACHMENT
;
756 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
762 criteria
= MATCHCRITERIA_SIGNED
;
763 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
769 criteria
= MATCHCRITERIA_NOT_SIGNED
;
770 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
776 criteria
= MATCHCRITERIA_PARTIAL
;
777 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
779 | MATCHER_NOT_PARTIAL
783 criteria
= MATCHCRITERIA_NOT_PARTIAL
;
784 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
786 | MATCHER_COLORLABEL MATCHER_INTEGER
791 criteria
= MATCHCRITERIA_COLORLABEL
;
792 value
= strtol
($2, NULL
, 10);
793 if
(value
< 0) value
= 0;
794 else if
(value
> COLORLABELS
) value
= COLORLABELS
;
795 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
797 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
802 criteria
= MATCHCRITERIA_NOT_COLORLABEL
;
803 value
= strtol
($2, NULL
, 0);
804 if
(value
< 0) value
= 0;
805 else if
(value
> COLORLABELS
) value
= COLORLABELS
;
806 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
808 | MATCHER_IGNORE_THREAD
812 criteria
= MATCHCRITERIA_IGNORE_THREAD
;
813 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
815 | MATCHER_NOT_IGNORE_THREAD
819 criteria
= MATCHCRITERIA_NOT_IGNORE_THREAD
;
820 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
822 | MATCHER_WATCH_THREAD
826 criteria
= MATCHCRITERIA_WATCH_THREAD
;
827 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
829 | MATCHER_NOT_WATCH_THREAD
833 criteria
= MATCHCRITERIA_NOT_WATCH_THREAD
;
834 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
836 | MATCHER_SUBJECT match_type MATCHER_STRING
841 criteria
= MATCHCRITERIA_SUBJECT
;
843 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
845 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
850 criteria
= MATCHCRITERIA_NOT_SUBJECT
;
852 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
854 | MATCHER_FROM match_type MATCHER_STRING
859 criteria
= MATCHCRITERIA_FROM
;
861 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
863 | MATCHER_NOT_FROM match_type MATCHER_STRING
868 criteria
= MATCHCRITERIA_NOT_FROM
;
870 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
872 | MATCHER_TO match_type MATCHER_STRING
877 criteria
= MATCHCRITERIA_TO
;
879 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
881 | MATCHER_NOT_TO match_type MATCHER_STRING
886 criteria
= MATCHCRITERIA_NOT_TO
;
888 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
890 | MATCHER_CC match_type MATCHER_STRING
895 criteria
= MATCHCRITERIA_CC
;
897 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
899 | MATCHER_NOT_CC match_type MATCHER_STRING
904 criteria
= MATCHCRITERIA_NOT_CC
;
906 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
908 | MATCHER_TO_OR_CC match_type MATCHER_STRING
913 criteria
= MATCHCRITERIA_TO_OR_CC
;
915 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
917 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
922 criteria
= MATCHCRITERIA_NOT_TO_AND_NOT_CC
;
924 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
926 | MATCHER_TAG match_type MATCHER_STRING
931 criteria
= MATCHCRITERIA_TAG
;
933 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
935 | MATCHER_NOT_TAG match_type MATCHER_STRING
940 criteria
= MATCHCRITERIA_NOT_TAG
;
942 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
948 criteria
= MATCHCRITERIA_TAGGED
;
949 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
955 criteria
= MATCHCRITERIA_NOT_TAGGED
;
956 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, 0);
958 | MATCHER_AGE_GREATER MATCHER_INTEGER
963 criteria
= MATCHCRITERIA_AGE_GREATER
;
964 value
= strtol
($2, NULL
, 0);
965 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
967 | MATCHER_AGE_LOWER MATCHER_INTEGER
972 criteria
= MATCHCRITERIA_AGE_LOWER
;
973 value
= strtol
($2, NULL
, 0);
974 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
976 | MATCHER_AGE_GREATER_HOURS MATCHER_INTEGER
981 criteria
= MATCHCRITERIA_AGE_GREATER_HOURS
;
982 value
= strtol
($2, NULL
, 0);
983 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
985 | MATCHER_AGE_LOWER_HOURS MATCHER_INTEGER
990 criteria
= MATCHCRITERIA_AGE_LOWER_HOURS
;
991 value
= strtol
($2, NULL
, 0);
992 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
994 | MATCHER_DATE_AFTER MATCHER_STRING
1000 criteria
= MATCHCRITERIA_DATE_AFTER
;
1002 value
= procheader_date_parse
(NULL
, expr
, 0);
1003 prop
= matcherprop_new
(criteria
, NULL
, 0, expr
, value
);
1005 | MATCHER_DATE_BEFORE MATCHER_STRING
1011 criteria
= MATCHCRITERIA_DATE_BEFORE
;
1013 value
= procheader_date_parse
(NULL
, expr
, 0);
1014 prop
= matcherprop_new
(criteria
, NULL
, 0, expr
, value
);
1016 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
1021 criteria
= MATCHCRITERIA_NEWSGROUPS
;
1023 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1025 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
1030 criteria
= MATCHCRITERIA_NOT_NEWSGROUPS
;
1032 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1034 | MATCHER_MESSAGEID match_type MATCHER_STRING
1039 criteria
= MATCHCRITERIA_MESSAGEID
;
1041 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1043 | MATCHER_NOT_MESSAGEID match_type MATCHER_STRING
1048 criteria
= MATCHCRITERIA_NOT_MESSAGEID
;
1050 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1052 | MATCHER_INREPLYTO match_type MATCHER_STRING
1057 criteria
= MATCHCRITERIA_INREPLYTO
;
1059 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1061 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
1066 criteria
= MATCHCRITERIA_NOT_INREPLYTO
;
1068 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1070 | MATCHER_REFERENCES match_type MATCHER_STRING
1075 criteria
= MATCHCRITERIA_REFERENCES
;
1077 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1079 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
1084 criteria
= MATCHCRITERIA_NOT_REFERENCES
;
1086 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1088 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1093 criteria
= MATCHCRITERIA_SCORE_GREATER
;
1094 value
= strtol
($2, NULL
, 0);
1095 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1097 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1102 criteria
= MATCHCRITERIA_SCORE_LOWER
;
1103 value
= strtol
($2, NULL
, 0);
1104 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1106 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1111 criteria
= MATCHCRITERIA_SCORE_EQUAL
;
1112 value
= strtol
($2, NULL
, 0);
1113 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1115 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1119 criteria
= MATCHCRITERIA_SIZE_GREATER
;
1120 value
= strtol
($2, NULL
, 0);
1121 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1123 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1127 criteria
= MATCHCRITERIA_SIZE_SMALLER
;
1128 value
= strtol
($2, NULL
, 0);
1129 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1131 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1135 criteria
= MATCHCRITERIA_SIZE_EQUAL
;
1136 value
= strtol
($2, NULL
, 0);
1137 prop
= matcherprop_new
(criteria
, NULL
, 0, NULL
, value
);
1139 | MATCHER_HEADER MATCHER_STRING
1141 header
= g_strdup
($2);
1142 } match_type MATCHER_STRING
1146 matcher_is_fast
= FALSE
;
1147 criteria
= MATCHCRITERIA_HEADER
;
1149 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1152 | MATCHER_NOT_HEADER MATCHER_STRING
1154 header
= g_strdup
($2);
1155 } match_type MATCHER_STRING
1159 matcher_is_fast
= FALSE
;
1160 criteria
= MATCHCRITERIA_NOT_HEADER
;
1162 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1165 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1169 matcher_is_fast
= FALSE
;
1170 criteria
= MATCHCRITERIA_HEADERS_PART
;
1172 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1174 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1178 matcher_is_fast
= FALSE
;
1179 criteria
= MATCHCRITERIA_NOT_HEADERS_PART
;
1181 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1183 | MATCHER_HEADERS_CONT match_type MATCHER_STRING
1187 matcher_is_fast
= FALSE
;
1188 criteria
= MATCHCRITERIA_HEADERS_CONT
;
1190 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1192 | MATCHER_NOT_HEADERS_CONT match_type MATCHER_STRING
1196 matcher_is_fast
= FALSE
;
1197 criteria
= MATCHCRITERIA_NOT_HEADERS_CONT
;
1199 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1201 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1203 header
= g_strdup
($2);
1204 } MATCHER_IN MATCHER_STRING
1209 criteria
= MATCHCRITERIA_FOUND_IN_ADDRESSBOOK
;
1211 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1214 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1216 header
= g_strdup
($2);
1217 } MATCHER_IN MATCHER_STRING
1222 criteria
= MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK
;
1224 prop
= matcherprop_new
(criteria
, header
, match_type
, expr
, 0);
1227 | MATCHER_MESSAGE match_type MATCHER_STRING
1231 matcher_is_fast
= FALSE
;
1232 criteria
= MATCHCRITERIA_MESSAGE
;
1234 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1236 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1240 matcher_is_fast
= FALSE
;
1241 criteria
= MATCHCRITERIA_NOT_MESSAGE
;
1243 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1245 | MATCHER_BODY_PART match_type MATCHER_STRING
1249 matcher_is_fast
= FALSE
;
1250 criteria
= MATCHCRITERIA_BODY_PART
;
1252 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1254 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1258 matcher_is_fast
= FALSE
;
1259 criteria
= MATCHCRITERIA_NOT_BODY_PART
;
1261 prop
= matcherprop_new
(criteria
, NULL
, match_type
, expr
, 0);
1263 | MATCHER_TEST MATCHER_STRING
1267 matcher_is_fast
= FALSE
;
1268 criteria
= MATCHCRITERIA_TEST
;
1270 prop
= matcherprop_new
(criteria
, NULL
, MATCHTYPE_MATCH
, expr
, 0);
1272 | MATCHER_NOT_TEST MATCHER_STRING
1276 matcher_is_fast
= FALSE
;
1277 criteria
= MATCHCRITERIA_NOT_TEST
;
1279 prop
= matcherprop_new
(criteria
, NULL
, MATCHTYPE_MATCH
, expr
, 0);
1284 MATCHER_EXECUTE MATCHER_STRING
1287 gint action_type
= 0;
1289 action_type
= MATCHACTION_EXECUTE
;
1291 action
= filteringaction_new
(action_type
, 0, cmd
, 0, 0, NULL
);
1293 | MATCHER_MOVE MATCHER_STRING
1295 gchar
*destination
= NULL
;
1296 gint action_type
= 0;
1298 action_type
= MATCHACTION_MOVE
;
1300 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1302 | MATCHER_SET_TAG MATCHER_STRING
1304 gchar
*destination
= NULL
;
1305 gint action_type
= 0;
1307 action_type
= MATCHACTION_SET_TAG
;
1309 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1311 | MATCHER_UNSET_TAG MATCHER_STRING
1313 gchar
*destination
= NULL
;
1314 gint action_type
= 0;
1316 action_type
= MATCHACTION_UNSET_TAG
;
1318 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1320 | MATCHER_CLEAR_TAGS
1322 gint action_type
= 0;
1324 action_type
= MATCHACTION_CLEAR_TAGS
;
1325 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1327 | MATCHER_COPY MATCHER_STRING
1329 gchar
*destination
= NULL
;
1330 gint action_type
= 0;
1332 action_type
= MATCHACTION_COPY
;
1334 action
= filteringaction_new
(action_type
, 0, destination
, 0, 0, NULL
);
1338 gint action_type
= 0;
1340 action_type
= MATCHACTION_DELETE
;
1341 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1345 gint action_type
= 0;
1347 action_type
= MATCHACTION_MARK
;
1348 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1352 gint action_type
= 0;
1354 action_type
= MATCHACTION_UNMARK
;
1355 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1359 gint action_type
= 0;
1361 action_type
= MATCHACTION_LOCK
;
1362 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1366 gint action_type
= 0;
1368 action_type
= MATCHACTION_UNLOCK
;
1369 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1371 | MATCHER_MARK_AS_READ
1373 gint action_type
= 0;
1375 action_type
= MATCHACTION_MARK_AS_READ
;
1376 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1378 | MATCHER_MARK_AS_UNREAD
1380 gint action_type
= 0;
1382 action_type
= MATCHACTION_MARK_AS_UNREAD
;
1383 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1385 | MATCHER_MARK_AS_SPAM
1387 gint action_type
= 0;
1389 action_type
= MATCHACTION_MARK_AS_SPAM
;
1390 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1392 | MATCHER_MARK_AS_HAM
1394 gint action_type
= 0;
1396 action_type
= MATCHACTION_MARK_AS_HAM
;
1397 action
= filteringaction_new
(action_type
, 0, NULL
, 0, 0, NULL
);
1399 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1401 gchar
*destination
= NULL
;
1402 gint action_type
= 0;
1403 gint account_id
= 0;
1405 action_type
= MATCHACTION_FORWARD
;
1406 account_id
= strtol
($2, NULL
, 10);
1408 action
= filteringaction_new
(action_type
,
1409 account_id
, destination
, 0, 0, NULL
);
1411 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1413 gchar
*destination
= NULL
;
1414 gint action_type
= 0;
1415 gint account_id
= 0;
1417 action_type
= MATCHACTION_FORWARD_AS_ATTACHMENT
;
1418 account_id
= strtol
($2, NULL
, 10);
1420 action
= filteringaction_new
(action_type
,
1421 account_id
, destination
, 0, 0, NULL
);
1423 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1425 gchar
*destination
= NULL
;
1426 gint action_type
= 0;
1427 gint account_id
= 0;
1429 action_type
= MATCHACTION_REDIRECT
;
1430 account_id
= strtol
($2, NULL
, 10);
1432 action
= filteringaction_new
(action_type
,
1433 account_id
, destination
, 0, 0, NULL
);
1435 | MATCHER_COLOR MATCHER_INTEGER
1437 gint action_type
= 0;
1440 action_type
= MATCHACTION_COLOR
;
1441 color
= strtol
($2, NULL
, 10);
1442 action
= filteringaction_new
(action_type
, 0, NULL
, color
, 0, NULL
);
1444 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1448 score
= strtol
($2, NULL
, 10);
1449 action
= filteringaction_new
(MATCHACTION_CHANGE_SCORE
, 0,
1450 NULL
, 0, score
, NULL
);
1452 /* backward compatibility */
1453 | MATCHER_SCORE MATCHER_INTEGER
1457 score
= strtol
($2, NULL
, 10);
1458 action
= filteringaction_new
(MATCHACTION_CHANGE_SCORE
, 0,
1459 NULL
, 0, score
, NULL
);
1461 | MATCHER_SET_SCORE MATCHER_INTEGER
1465 score
= strtol
($2, NULL
, 10);
1466 action
= filteringaction_new
(MATCHACTION_SET_SCORE
, 0,
1467 NULL
, 0, score
, NULL
);
1471 action
= filteringaction_new
(MATCHACTION_HIDE
, 0, NULL
, 0, 0, NULL
);
1475 action
= filteringaction_new
(MATCHACTION_IGNORE
, 0, NULL
, 0, 0, NULL
);
1479 action
= filteringaction_new
(MATCHACTION_WATCH
, 0, NULL
, 0, 0, NULL
);
1481 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1483 header
= g_strdup
($2);
1486 gchar
*addressbook
= NULL
;
1487 gint action_type
= 0;
1489 action_type
= MATCHACTION_ADD_TO_ADDRESSBOOK
;
1491 action
= filteringaction_new
(action_type
, 0, addressbook
, 0, 0, header
);
1496 action
= filteringaction_new
(MATCHACTION_STOP
, 0, NULL
, 0, 0, NULL
);