3 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
4 * Copyright (c) 2001-2007 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"
33 static gint error = 0;
34 static gint bool_op = 0;
35 static gint match_type = 0;
36 static gchar *header = NULL;
38 static MatcherProp *prop;
40 static GSList *matchers_list = NULL;
42 static gboolean enabled = TRUE;
43 static gchar *name = NULL;
44 static gint account_id = 0;
45 static MatcherList *cond;
46 static GSList *action_list = NULL;
47 static FilteringAction *action = NULL;
48 static gboolean matcher_is_fast = TRUE;
49 static gboolean disable_warnings = FALSE;
51 static FilteringProp *filtering;
53 static GSList **prefs_filtering = NULL;
54 static int enable_compatibility = 0;
59 MATCHER_PARSE_ENABLED,
61 MATCHER_PARSE_ACCOUNT,
62 MATCHER_PARSE_CONDITION,
63 MATCHER_PARSE_FILTERING_ACTION,
66 static int matcher_parse_op = MATCHER_PARSE_FILE;
69 /* ******************************************************************** */
70 /* redeclarations to avoid warnings */
71 void matcher_parserrestart(FILE *input_file);
72 void matcher_parser_init(void);
73 void matcher_parser_switch_to_buffer(void * new_buffer);
74 void matcher_parser_delete_buffer(void * b);
75 void matcher_parserpop_buffer_state(void);
76 int matcher_parserlex(void);
78 void matcher_parser_disable_warnings(const gboolean disable)
80 disable_warnings = disable;
83 void matcher_parser_start_parsing(FILE *f)
85 matcher_parserlineno = 1;
86 matcher_parserrestart(f);
88 matcher_parserparse();
92 void * matcher_parser_scan_string(const char * str);
94 FilteringProp *matcher_parser_get_filtering(gchar *str)
99 /* little hack to allow passing rules with no names */
100 if (!strncmp(str, "rulename ", 9))
101 tmp_str = g_strdup(str);
103 tmp_str = g_strconcat("rulename \"\" ", str, NULL);
105 /* bad coding to enable the sub-grammar matching
107 matcher_parserlineno = 1;
108 matcher_parse_op = MATCHER_PARSE_NO_EOL;
109 matcher_parserrestart(NULL);
110 matcher_parserpop_buffer_state();
111 matcher_parser_init();
112 bufstate = matcher_parser_scan_string((const char *) tmp_str);
113 matcher_parser_switch_to_buffer(bufstate);
114 if (matcher_parserparse() != 0)
116 matcher_parse_op = MATCHER_PARSE_FILE;
117 matcher_parser_delete_buffer(bufstate);
122 static gboolean check_quote_symetry(gchar *str)
128 return TRUE; /* heh, that's symetric */
131 for (walk = str; *walk; walk++) {
133 if (walk == str /* first char */
134 || *(walk - 1) != '\\') /* not escaped */
141 MatcherList *matcher_parser_get_name(gchar *str)
145 if (!check_quote_symetry(str)) {
150 /* bad coding to enable the sub-grammar matching
152 matcher_parserlineno = 1;
153 matcher_parse_op = MATCHER_PARSE_NAME;
154 matcher_parserrestart(NULL);
155 matcher_parserpop_buffer_state();
156 matcher_parser_init();
157 bufstate = matcher_parser_scan_string(str);
158 matcher_parserparse();
159 matcher_parse_op = MATCHER_PARSE_FILE;
160 matcher_parser_delete_buffer(bufstate);
164 MatcherList *matcher_parser_get_enabled(gchar *str)
168 if (!check_quote_symetry(str)) {
173 /* bad coding to enable the sub-grammar matching
175 matcher_parserlineno = 1;
176 matcher_parse_op = MATCHER_PARSE_ENABLED;
177 matcher_parserrestart(NULL);
178 matcher_parserpop_buffer_state();
179 matcher_parser_init();
180 bufstate = matcher_parser_scan_string(str);
181 matcher_parserparse();
182 matcher_parse_op = MATCHER_PARSE_FILE;
183 matcher_parser_delete_buffer(bufstate);
187 MatcherList *matcher_parser_get_account(gchar *str)
191 if (!check_quote_symetry(str)) {
196 /* bad coding to enable the sub-grammar matching
198 matcher_parserlineno = 1;
199 matcher_parse_op = MATCHER_PARSE_ACCOUNT;
200 matcher_parserrestart(NULL);
201 matcher_parserpop_buffer_state();
202 matcher_parser_init();
203 bufstate = matcher_parser_scan_string(str);
204 matcher_parserparse();
205 matcher_parse_op = MATCHER_PARSE_FILE;
206 matcher_parser_delete_buffer(bufstate);
210 MatcherList *matcher_parser_get_cond(gchar *str, gboolean *is_fast)
214 if (!check_quote_symetry(str)) {
219 matcher_is_fast = TRUE;
220 /* bad coding to enable the sub-grammar matching
222 matcher_parserlineno = 1;
223 matcher_parse_op = MATCHER_PARSE_CONDITION;
224 matcher_parserrestart(NULL);
225 matcher_parserpop_buffer_state();
226 matcher_parser_init();
227 bufstate = matcher_parser_scan_string(str);
228 matcher_parserparse();
229 matcher_parse_op = MATCHER_PARSE_FILE;
230 matcher_parser_delete_buffer(bufstate);
232 *is_fast = matcher_is_fast;
236 GSList *matcher_parser_get_action_list(gchar *str)
240 if (!check_quote_symetry(str)) {
245 /* bad coding to enable the sub-grammar matching
247 matcher_parserlineno = 1;
248 matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
249 matcher_parserrestart(NULL);
250 matcher_parserpop_buffer_state();
251 matcher_parser_init();
252 bufstate = matcher_parser_scan_string(str);
253 matcher_parserparse();
254 matcher_parse_op = MATCHER_PARSE_FILE;
255 matcher_parser_delete_buffer(bufstate);
259 MatcherProp *matcher_parser_get_prop(gchar *str)
264 matcher_parserlineno = 1;
265 list = matcher_parser_get_cond(str, NULL);
269 if (list->matchers == NULL)
272 if (list->matchers->next != NULL)
275 prop = list->matchers->data;
277 g_slist_free(list->matchers);
283 void matcher_parsererror(char *str)
288 for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
289 matcherprop_free((MatcherProp *)
293 g_slist_free(matchers_list);
294 matchers_list = NULL;
297 if (!disable_warnings)
298 g_warning("filtering parsing: %i: %s\n",
299 matcher_parserlineno, str);
303 int matcher_parserwrap(void)
313 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
314 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
315 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
316 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
317 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
318 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
319 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
320 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
321 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
322 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
323 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
324 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
325 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
326 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
327 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
328 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
329 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
330 %token MATCHER_LOCK MATCHER_UNLOCK
331 %token MATCHER_EXECUTE
332 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
333 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
334 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
335 %token MATCHER_OR MATCHER_AND
336 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
337 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
338 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
339 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
340 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
341 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
342 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
343 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
344 %token MATCHER_ADD_TO_ADDRESSBOOK
345 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
346 %token MATCHER_SPAM MATCHER_NOT_SPAM
347 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
348 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
349 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
350 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
354 %token MATCHER_ENABLED MATCHER_DISABLED
355 %token MATCHER_RULENAME
356 %token MATCHER_ACCOUNT
357 %token <str> MATCHER_STRING
358 %token <str> MATCHER_SECTION
359 %token <str> MATCHER_INTEGER
365 if (matcher_parse_op == MATCHER_PARSE_FILE) {
366 prefs_filtering = &pre_global_processing;
380 { action_list = NULL; }
387 section_notification:
388 MATCHER_SECTION MATCHER_EOL
391 FolderItem *item = NULL;
393 if (matcher_parse_op == MATCHER_PARSE_FILE) {
394 enable_compatibility = 0;
395 if (!strcmp(folder, "global")) {
396 /* backward compatibility */
397 enable_compatibility = 1;
399 else if (!strcmp(folder, "preglobal")) {
400 prefs_filtering = &pre_global_processing;
402 else if (!strcmp(folder, "postglobal")) {
403 prefs_filtering = &post_global_processing;
405 else if (!strcmp(folder, "filtering")) {
406 prefs_filtering = &filtering_rules;
409 item = folder_find_item_from_identifier(folder);
411 prefs_filtering = &item->prefs->processing;
413 prefs_filtering = NULL;
421 enabled name account condition filtering MATCHER_EOL
422 | enabled name account condition filtering
423 | enabled name condition filtering MATCHER_EOL
424 | enabled name condition filtering
425 | name condition filtering MATCHER_EOL
426 | name condition filtering
428 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
431 matcher_parsererror("parse error [no eol]");
437 if (matcher_parse_op == MATCHER_PARSE_ENABLED)
440 matcher_parsererror("parse error [enabled]");
446 if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
449 matcher_parsererror("parse error [account]");
455 if (matcher_parse_op == MATCHER_PARSE_NAME)
458 matcher_parsererror("parse error [name]");
464 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
467 matcher_parsererror("parse error [condition]");
471 | filtering_action_list
473 if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
476 matcher_parsererror("parse error [filtering action]");
495 MATCHER_RULENAME MATCHER_STRING
502 MATCHER_ACCOUNT MATCHER_INTEGER
504 account_id = strtol($2, NULL, 10);
509 filtering_action_list
511 filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
516 if (enable_compatibility) {
517 prefs_filtering = &filtering_rules;
518 if (action_list != NULL) {
519 FilteringAction * first_action;
521 first_action = action_list->data;
523 if (first_action->type == MATCHACTION_CHANGE_SCORE)
524 prefs_filtering = &pre_global_processing;
531 if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
532 (prefs_filtering != NULL)) {
533 *prefs_filtering = g_slist_append(*prefs_filtering,
540 filtering_action_list:
541 filtering_action_b filtering_action_list
548 action_list = g_slist_append(action_list, action);
556 match_type = MATCHTYPE_MATCHCASE;
560 match_type = MATCHTYPE_MATCH;
564 match_type = MATCHTYPE_REGEXPCASE;
568 match_type = MATCHTYPE_REGEXP;
575 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
576 matchers_list = NULL;
581 condition_list bool_op one_condition
583 matchers_list = g_slist_append(matchers_list, prop);
587 matchers_list = NULL;
588 matchers_list = g_slist_append(matchers_list, prop);
595 bool_op = MATCHERBOOL_AND;
599 bool_op = MATCHERBOOL_OR;
608 criteria = MATCHCRITERIA_ALL;
609 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
615 criteria = MATCHCRITERIA_UNREAD;
616 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
622 criteria = MATCHCRITERIA_NOT_UNREAD;
623 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
629 criteria = MATCHCRITERIA_NEW;
630 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
636 criteria = MATCHCRITERIA_NOT_NEW;
637 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
643 criteria = MATCHCRITERIA_MARKED;
644 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
650 criteria = MATCHCRITERIA_NOT_MARKED;
651 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
657 criteria = MATCHCRITERIA_DELETED;
658 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
660 | MATCHER_NOT_DELETED
664 criteria = MATCHCRITERIA_NOT_DELETED;
665 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
671 criteria = MATCHCRITERIA_REPLIED;
672 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
674 | MATCHER_NOT_REPLIED
678 criteria = MATCHCRITERIA_NOT_REPLIED;
679 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
685 criteria = MATCHCRITERIA_FORWARDED;
686 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
688 | MATCHER_NOT_FORWARDED
692 criteria = MATCHCRITERIA_NOT_FORWARDED;
693 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
699 criteria = MATCHCRITERIA_LOCKED;
700 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
706 criteria = MATCHCRITERIA_NOT_LOCKED;
707 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
713 criteria = MATCHCRITERIA_SPAM;
714 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
720 criteria = MATCHCRITERIA_NOT_SPAM;
721 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
723 | MATCHER_HAS_ATTACHMENT
727 criteria = MATCHCRITERIA_HAS_ATTACHMENT;
728 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
730 | MATCHER_HAS_NO_ATTACHMENT
734 criteria = MATCHCRITERIA_HAS_NO_ATTACHMENT;
735 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
741 criteria = MATCHCRITERIA_SIGNED;
742 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
748 criteria = MATCHCRITERIA_NOT_SIGNED;
749 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
755 criteria = MATCHCRITERIA_PARTIAL;
756 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
758 | MATCHER_NOT_PARTIAL
762 criteria = MATCHCRITERIA_NOT_PARTIAL;
763 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
765 | MATCHER_COLORLABEL MATCHER_INTEGER
770 criteria = MATCHCRITERIA_COLORLABEL;
771 value = strtol($2, NULL, 10);
772 if (value < 0) value = 0;
773 else if (value > COLORLABELS) value = COLORLABELS;
774 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
776 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
781 criteria = MATCHCRITERIA_NOT_COLORLABEL;
782 value = strtol($2, NULL, 0);
783 if (value < 0) value = 0;
784 else if (value > COLORLABELS) value = COLORLABELS;
785 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
787 | MATCHER_IGNORE_THREAD
791 criteria = MATCHCRITERIA_IGNORE_THREAD;
792 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
794 | MATCHER_NOT_IGNORE_THREAD
798 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
799 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
801 | MATCHER_WATCH_THREAD
805 criteria = MATCHCRITERIA_WATCH_THREAD;
806 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
808 | MATCHER_NOT_WATCH_THREAD
812 criteria = MATCHCRITERIA_NOT_WATCH_THREAD;
813 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
815 | MATCHER_SUBJECT match_type MATCHER_STRING
820 criteria = MATCHCRITERIA_SUBJECT;
822 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
824 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
829 criteria = MATCHCRITERIA_NOT_SUBJECT;
831 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
833 | MATCHER_FROM match_type MATCHER_STRING
838 criteria = MATCHCRITERIA_FROM;
840 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
842 | MATCHER_NOT_FROM match_type MATCHER_STRING
847 criteria = MATCHCRITERIA_NOT_FROM;
849 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
851 | MATCHER_TO match_type MATCHER_STRING
856 criteria = MATCHCRITERIA_TO;
858 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
860 | MATCHER_NOT_TO match_type MATCHER_STRING
865 criteria = MATCHCRITERIA_NOT_TO;
867 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
869 | MATCHER_CC match_type MATCHER_STRING
874 criteria = MATCHCRITERIA_CC;
876 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
878 | MATCHER_NOT_CC match_type MATCHER_STRING
883 criteria = MATCHCRITERIA_NOT_CC;
885 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
887 | MATCHER_TO_OR_CC match_type MATCHER_STRING
892 criteria = MATCHCRITERIA_TO_OR_CC;
894 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
896 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
901 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
903 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
905 | MATCHER_TAG match_type MATCHER_STRING
910 criteria = MATCHCRITERIA_TAG;
912 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
914 | MATCHER_NOT_TAG match_type MATCHER_STRING
919 criteria = MATCHCRITERIA_NOT_TAG;
921 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
927 criteria = MATCHCRITERIA_TAGGED;
928 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
934 criteria = MATCHCRITERIA_NOT_TAGGED;
935 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
937 | MATCHER_AGE_GREATER MATCHER_INTEGER
942 criteria = MATCHCRITERIA_AGE_GREATER;
943 value = strtol($2, NULL, 0);
944 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
946 | MATCHER_AGE_LOWER MATCHER_INTEGER
951 criteria = MATCHCRITERIA_AGE_LOWER;
952 value = strtol($2, NULL, 0);
953 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
955 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
960 criteria = MATCHCRITERIA_NEWSGROUPS;
962 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
964 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
969 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
971 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
973 | MATCHER_INREPLYTO match_type MATCHER_STRING
978 criteria = MATCHCRITERIA_INREPLYTO;
980 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
982 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
987 criteria = MATCHCRITERIA_NOT_INREPLYTO;
989 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
991 | MATCHER_REFERENCES match_type MATCHER_STRING
996 criteria = MATCHCRITERIA_REFERENCES;
998 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1000 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
1005 criteria = MATCHCRITERIA_NOT_REFERENCES;
1007 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1009 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1014 criteria = MATCHCRITERIA_SCORE_GREATER;
1015 value = strtol($2, NULL, 0);
1016 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1018 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1023 criteria = MATCHCRITERIA_SCORE_LOWER;
1024 value = strtol($2, NULL, 0);
1025 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1027 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1032 criteria = MATCHCRITERIA_SCORE_EQUAL;
1033 value = strtol($2, NULL, 0);
1034 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1036 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1040 criteria = MATCHCRITERIA_SIZE_GREATER;
1041 value = strtol($2, NULL, 0);
1042 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1044 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1048 criteria = MATCHCRITERIA_SIZE_SMALLER;
1049 value = strtol($2, NULL, 0);
1050 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1052 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1056 criteria = MATCHCRITERIA_SIZE_EQUAL;
1057 value = strtol($2, NULL, 0);
1058 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1060 | MATCHER_HEADER MATCHER_STRING
1062 header = g_strdup($2);
1063 } match_type MATCHER_STRING
1067 matcher_is_fast = FALSE;
1068 criteria = MATCHCRITERIA_HEADER;
1070 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1073 | MATCHER_NOT_HEADER MATCHER_STRING
1075 header = g_strdup($2);
1076 } match_type MATCHER_STRING
1080 matcher_is_fast = FALSE;
1081 criteria = MATCHCRITERIA_NOT_HEADER;
1083 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1086 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1090 matcher_is_fast = FALSE;
1091 criteria = MATCHCRITERIA_HEADERS_PART;
1093 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1095 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1099 matcher_is_fast = FALSE;
1100 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
1102 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1104 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1106 header = g_strdup($2);
1107 } MATCHER_IN MATCHER_STRING
1112 criteria = MATCHCRITERIA_FOUND_IN_ADDRESSBOOK;
1114 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1117 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1119 header = g_strdup($2);
1120 } MATCHER_IN MATCHER_STRING
1125 criteria = MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK;
1127 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1130 | MATCHER_MESSAGE match_type MATCHER_STRING
1134 matcher_is_fast = FALSE;
1135 criteria = MATCHCRITERIA_MESSAGE;
1137 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1139 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1143 matcher_is_fast = FALSE;
1144 criteria = MATCHCRITERIA_NOT_MESSAGE;
1146 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1148 | MATCHER_BODY_PART match_type MATCHER_STRING
1152 matcher_is_fast = FALSE;
1153 criteria = MATCHCRITERIA_BODY_PART;
1155 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1157 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1161 matcher_is_fast = FALSE;
1162 criteria = MATCHCRITERIA_NOT_BODY_PART;
1164 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1166 | MATCHER_TEST MATCHER_STRING
1170 matcher_is_fast = FALSE;
1171 criteria = MATCHCRITERIA_TEST;
1173 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1175 | MATCHER_NOT_TEST MATCHER_STRING
1179 matcher_is_fast = FALSE;
1180 criteria = MATCHCRITERIA_NOT_TEST;
1182 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1187 MATCHER_EXECUTE MATCHER_STRING
1190 gint action_type = 0;
1192 action_type = MATCHACTION_EXECUTE;
1194 action = filteringaction_new(action_type, 0, cmd, 0, 0, NULL);
1196 | MATCHER_MOVE MATCHER_STRING
1198 gchar *destination = NULL;
1199 gint action_type = 0;
1201 action_type = MATCHACTION_MOVE;
1203 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1205 | MATCHER_SET_TAG MATCHER_STRING
1207 gchar *destination = NULL;
1208 gint action_type = 0;
1210 action_type = MATCHACTION_SET_TAG;
1212 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1214 | MATCHER_UNSET_TAG MATCHER_STRING
1216 gchar *destination = NULL;
1217 gint action_type = 0;
1219 action_type = MATCHACTION_UNSET_TAG;
1221 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1223 | MATCHER_CLEAR_TAGS
1225 gint action_type = 0;
1227 action_type = MATCHACTION_CLEAR_TAGS;
1228 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1230 | MATCHER_COPY MATCHER_STRING
1232 gchar *destination = NULL;
1233 gint action_type = 0;
1235 action_type = MATCHACTION_COPY;
1237 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1241 gint action_type = 0;
1243 action_type = MATCHACTION_DELETE;
1244 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1248 gint action_type = 0;
1250 action_type = MATCHACTION_MARK;
1251 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1255 gint action_type = 0;
1257 action_type = MATCHACTION_UNMARK;
1258 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1262 gint action_type = 0;
1264 action_type = MATCHACTION_LOCK;
1265 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1269 gint action_type = 0;
1271 action_type = MATCHACTION_UNLOCK;
1272 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1274 | MATCHER_MARK_AS_READ
1276 gint action_type = 0;
1278 action_type = MATCHACTION_MARK_AS_READ;
1279 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1281 | MATCHER_MARK_AS_UNREAD
1283 gint action_type = 0;
1285 action_type = MATCHACTION_MARK_AS_UNREAD;
1286 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1288 | MATCHER_MARK_AS_SPAM
1290 gint action_type = 0;
1292 action_type = MATCHACTION_MARK_AS_SPAM;
1293 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1295 | MATCHER_MARK_AS_HAM
1297 gint action_type = 0;
1299 action_type = MATCHACTION_MARK_AS_HAM;
1300 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1302 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1304 gchar *destination = NULL;
1305 gint action_type = 0;
1306 gint account_id = 0;
1308 action_type = MATCHACTION_FORWARD;
1309 account_id = strtol($2, NULL, 10);
1311 action = filteringaction_new(action_type,
1312 account_id, destination, 0, 0, NULL);
1314 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1316 gchar *destination = NULL;
1317 gint action_type = 0;
1318 gint account_id = 0;
1320 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
1321 account_id = strtol($2, NULL, 10);
1323 action = filteringaction_new(action_type,
1324 account_id, destination, 0, 0, NULL);
1326 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1328 gchar *destination = NULL;
1329 gint action_type = 0;
1330 gint account_id = 0;
1332 action_type = MATCHACTION_REDIRECT;
1333 account_id = strtol($2, NULL, 10);
1335 action = filteringaction_new(action_type,
1336 account_id, destination, 0, 0, NULL);
1338 | MATCHER_COLOR MATCHER_INTEGER
1340 gint action_type = 0;
1343 action_type = MATCHACTION_COLOR;
1344 color = strtol($2, NULL, 10);
1345 action = filteringaction_new(action_type, 0, NULL, color, 0, NULL);
1347 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1351 score = strtol($2, NULL, 10);
1352 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1353 NULL, 0, score, NULL);
1355 /* backward compatibility */
1356 | MATCHER_SCORE MATCHER_INTEGER
1360 score = strtol($2, NULL, 10);
1361 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1362 NULL, 0, score, NULL);
1364 | MATCHER_SET_SCORE MATCHER_INTEGER
1368 score = strtol($2, NULL, 10);
1369 action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
1370 NULL, 0, score, NULL);
1374 action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0, NULL);
1378 action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0, NULL);
1382 action = filteringaction_new(MATCHACTION_WATCH, 0, NULL, 0, 0, NULL);
1384 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1386 header = g_strdup($2);
1389 gchar *addressbook = NULL;
1390 gint action_type = 0;
1392 action_type = MATCHACTION_ADD_TO_ADDRESSBOOK;
1394 action = filteringaction_new(action_type, 0, addressbook, 0, 0, header);
1399 action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0, NULL);