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;
50 static FilteringProp *filtering;
52 static GSList **prefs_filtering = NULL;
53 static int enable_compatibility = 0;
58 MATCHER_PARSE_ENABLED,
60 MATCHER_PARSE_ACCOUNT,
61 MATCHER_PARSE_CONDITION,
62 MATCHER_PARSE_FILTERING_ACTION,
65 static int matcher_parse_op = MATCHER_PARSE_FILE;
68 /* ******************************************************************** */
69 /* redeclarations to avoid warnings */
70 void matcher_parserrestart(FILE *input_file);
71 void matcher_parser_init(void);
72 void matcher_parser_switch_to_buffer(void * new_buffer);
73 void matcher_parser_delete_buffer(void * b);
74 void matcher_parserpop_buffer_state(void);
75 int matcher_parserlex(void);
77 void matcher_parser_start_parsing(FILE *f)
79 matcher_parserlineno = 1;
80 matcher_parserrestart(f);
82 matcher_parserparse();
86 void * matcher_parser_scan_string(const char * str);
88 FilteringProp *matcher_parser_get_filtering(gchar *str)
93 /* little hack to allow passing rules with no names */
94 if (!strncmp(str, "rulename ", 9))
95 tmp_str = g_strdup(str);
97 tmp_str = g_strconcat("rulename \"\" ", str, NULL);
99 /* bad coding to enable the sub-grammar matching
101 matcher_parserlineno = 1;
102 matcher_parse_op = MATCHER_PARSE_NO_EOL;
103 matcher_parserrestart(NULL);
104 matcher_parserpop_buffer_state();
105 matcher_parser_init();
106 bufstate = matcher_parser_scan_string((const char *) tmp_str);
107 matcher_parser_switch_to_buffer(bufstate);
108 if (matcher_parserparse() != 0)
110 matcher_parse_op = MATCHER_PARSE_FILE;
111 matcher_parser_delete_buffer(bufstate);
116 static gboolean check_quote_symetry(gchar *str)
122 return TRUE; /* heh, that's symetric */
125 for (walk = str; *walk; walk++) {
127 if (walk == str /* first char */
128 || *(walk - 1) != '\\') /* not escaped */
135 MatcherList *matcher_parser_get_name(gchar *str)
139 if (!check_quote_symetry(str)) {
144 /* bad coding to enable the sub-grammar matching
146 matcher_parserlineno = 1;
147 matcher_parse_op = MATCHER_PARSE_NAME;
148 matcher_parserrestart(NULL);
149 matcher_parserpop_buffer_state();
150 matcher_parser_init();
151 bufstate = matcher_parser_scan_string(str);
152 matcher_parserparse();
153 matcher_parse_op = MATCHER_PARSE_FILE;
154 matcher_parser_delete_buffer(bufstate);
158 MatcherList *matcher_parser_get_enabled(gchar *str)
162 if (!check_quote_symetry(str)) {
167 /* bad coding to enable the sub-grammar matching
169 matcher_parserlineno = 1;
170 matcher_parse_op = MATCHER_PARSE_ENABLED;
171 matcher_parserrestart(NULL);
172 matcher_parserpop_buffer_state();
173 matcher_parser_init();
174 bufstate = matcher_parser_scan_string(str);
175 matcher_parserparse();
176 matcher_parse_op = MATCHER_PARSE_FILE;
177 matcher_parser_delete_buffer(bufstate);
181 MatcherList *matcher_parser_get_account(gchar *str)
185 if (!check_quote_symetry(str)) {
190 /* bad coding to enable the sub-grammar matching
192 matcher_parserlineno = 1;
193 matcher_parse_op = MATCHER_PARSE_ACCOUNT;
194 matcher_parserrestart(NULL);
195 matcher_parserpop_buffer_state();
196 matcher_parser_init();
197 bufstate = matcher_parser_scan_string(str);
198 matcher_parserparse();
199 matcher_parse_op = MATCHER_PARSE_FILE;
200 matcher_parser_delete_buffer(bufstate);
204 MatcherList *matcher_parser_get_cond(gchar *str, gboolean *is_fast)
208 if (!check_quote_symetry(str)) {
213 matcher_is_fast = TRUE;
214 /* bad coding to enable the sub-grammar matching
216 matcher_parserlineno = 1;
217 matcher_parse_op = MATCHER_PARSE_CONDITION;
218 matcher_parserrestart(NULL);
219 matcher_parserpop_buffer_state();
220 matcher_parser_init();
221 bufstate = matcher_parser_scan_string(str);
222 matcher_parserparse();
223 matcher_parse_op = MATCHER_PARSE_FILE;
224 matcher_parser_delete_buffer(bufstate);
226 *is_fast = matcher_is_fast;
230 GSList *matcher_parser_get_action_list(gchar *str)
234 if (!check_quote_symetry(str)) {
239 /* bad coding to enable the sub-grammar matching
241 matcher_parserlineno = 1;
242 matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
243 matcher_parserrestart(NULL);
244 matcher_parserpop_buffer_state();
245 matcher_parser_init();
246 bufstate = matcher_parser_scan_string(str);
247 matcher_parserparse();
248 matcher_parse_op = MATCHER_PARSE_FILE;
249 matcher_parser_delete_buffer(bufstate);
253 MatcherProp *matcher_parser_get_prop(gchar *str)
258 matcher_parserlineno = 1;
259 list = matcher_parser_get_cond(str, NULL);
263 if (list->matchers == NULL)
266 if (list->matchers->next != NULL)
269 prop = list->matchers->data;
271 g_slist_free(list->matchers);
277 void matcher_parsererror(char *str)
282 for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
283 matcherprop_free((MatcherProp *)
287 g_slist_free(matchers_list);
288 matchers_list = NULL;
291 g_warning("filtering parsing: %i: %s\n",
292 matcher_parserlineno, str);
296 int matcher_parserwrap(void)
306 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
307 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
308 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
309 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
310 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
311 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
312 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
313 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
314 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
315 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
316 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
317 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
318 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
319 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
320 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
321 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
322 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
323 %token MATCHER_LOCK MATCHER_UNLOCK
324 %token MATCHER_EXECUTE
325 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
326 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
327 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
328 %token MATCHER_OR MATCHER_AND
329 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
330 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
331 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
332 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
333 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
334 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
335 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
336 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
337 %token MATCHER_ADD_TO_ADDRESSBOOK
338 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
339 %token MATCHER_SPAM MATCHER_NOT_SPAM
340 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
341 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
342 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
343 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
347 %token MATCHER_ENABLED MATCHER_DISABLED
348 %token MATCHER_RULENAME
349 %token MATCHER_ACCOUNT
350 %token <str> MATCHER_STRING
351 %token <str> MATCHER_SECTION
352 %token <str> MATCHER_INTEGER
358 if (matcher_parse_op == MATCHER_PARSE_FILE) {
359 prefs_filtering = &pre_global_processing;
373 { action_list = NULL; }
380 section_notification:
381 MATCHER_SECTION MATCHER_EOL
384 FolderItem *item = NULL;
386 if (matcher_parse_op == MATCHER_PARSE_FILE) {
387 enable_compatibility = 0;
388 if (!strcmp(folder, "global")) {
389 /* backward compatibility */
390 enable_compatibility = 1;
392 else if (!strcmp(folder, "preglobal")) {
393 prefs_filtering = &pre_global_processing;
395 else if (!strcmp(folder, "postglobal")) {
396 prefs_filtering = &post_global_processing;
398 else if (!strcmp(folder, "filtering")) {
399 prefs_filtering = &filtering_rules;
402 item = folder_find_item_from_identifier(folder);
404 prefs_filtering = &item->prefs->processing;
406 prefs_filtering = NULL;
414 enabled name account condition filtering MATCHER_EOL
415 | enabled name account condition filtering
416 | enabled name condition filtering MATCHER_EOL
417 | enabled name condition filtering
418 | name condition filtering MATCHER_EOL
419 | name condition filtering
421 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
424 matcher_parsererror("parse error [no eol]");
430 if (matcher_parse_op == MATCHER_PARSE_ENABLED)
433 matcher_parsererror("parse error [enabled]");
439 if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
442 matcher_parsererror("parse error [account]");
448 if (matcher_parse_op == MATCHER_PARSE_NAME)
451 matcher_parsererror("parse error [name]");
457 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
460 matcher_parsererror("parse error [condition]");
464 | filtering_action_list
466 if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
469 matcher_parsererror("parse error [filtering action]");
488 MATCHER_RULENAME MATCHER_STRING
495 MATCHER_ACCOUNT MATCHER_INTEGER
497 account_id = strtol($2, NULL, 10);
502 filtering_action_list
504 filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
509 if (enable_compatibility) {
510 prefs_filtering = &filtering_rules;
511 if (action_list != NULL) {
512 FilteringAction * first_action;
514 first_action = action_list->data;
516 if (first_action->type == MATCHACTION_CHANGE_SCORE)
517 prefs_filtering = &pre_global_processing;
524 if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
525 (prefs_filtering != NULL)) {
526 *prefs_filtering = g_slist_append(*prefs_filtering,
533 filtering_action_list:
534 filtering_action_b filtering_action_list
541 action_list = g_slist_append(action_list, action);
549 match_type = MATCHTYPE_MATCHCASE;
553 match_type = MATCHTYPE_MATCH;
557 match_type = MATCHTYPE_REGEXPCASE;
561 match_type = MATCHTYPE_REGEXP;
568 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
569 matchers_list = NULL;
574 condition_list bool_op one_condition
576 matchers_list = g_slist_append(matchers_list, prop);
580 matchers_list = NULL;
581 matchers_list = g_slist_append(matchers_list, prop);
588 bool_op = MATCHERBOOL_AND;
592 bool_op = MATCHERBOOL_OR;
601 criteria = MATCHCRITERIA_ALL;
602 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
608 criteria = MATCHCRITERIA_UNREAD;
609 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
615 criteria = MATCHCRITERIA_NOT_UNREAD;
616 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
622 criteria = MATCHCRITERIA_NEW;
623 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
629 criteria = MATCHCRITERIA_NOT_NEW;
630 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
636 criteria = MATCHCRITERIA_MARKED;
637 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
643 criteria = MATCHCRITERIA_NOT_MARKED;
644 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
650 criteria = MATCHCRITERIA_DELETED;
651 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
653 | MATCHER_NOT_DELETED
657 criteria = MATCHCRITERIA_NOT_DELETED;
658 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
664 criteria = MATCHCRITERIA_REPLIED;
665 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
667 | MATCHER_NOT_REPLIED
671 criteria = MATCHCRITERIA_NOT_REPLIED;
672 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
678 criteria = MATCHCRITERIA_FORWARDED;
679 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
681 | MATCHER_NOT_FORWARDED
685 criteria = MATCHCRITERIA_NOT_FORWARDED;
686 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
692 criteria = MATCHCRITERIA_LOCKED;
693 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
699 criteria = MATCHCRITERIA_NOT_LOCKED;
700 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
706 criteria = MATCHCRITERIA_SPAM;
707 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
713 criteria = MATCHCRITERIA_NOT_SPAM;
714 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
716 | MATCHER_HAS_ATTACHMENT
720 criteria = MATCHCRITERIA_HAS_ATTACHMENT;
721 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
723 | MATCHER_HAS_NO_ATTACHMENT
727 criteria = MATCHCRITERIA_HAS_NO_ATTACHMENT;
728 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
734 criteria = MATCHCRITERIA_SIGNED;
735 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
741 criteria = MATCHCRITERIA_NOT_SIGNED;
742 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
748 criteria = MATCHCRITERIA_PARTIAL;
749 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
751 | MATCHER_NOT_PARTIAL
755 criteria = MATCHCRITERIA_NOT_PARTIAL;
756 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
758 | MATCHER_COLORLABEL MATCHER_INTEGER
763 criteria = MATCHCRITERIA_COLORLABEL;
764 value = strtol($2, NULL, 10);
765 if (value < 0) value = 0;
766 else if (value > COLORLABELS) value = COLORLABELS;
767 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
769 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
774 criteria = MATCHCRITERIA_NOT_COLORLABEL;
775 value = strtol($2, NULL, 0);
776 if (value < 0) value = 0;
777 else if (value > COLORLABELS) value = COLORLABELS;
778 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
780 | MATCHER_IGNORE_THREAD
784 criteria = MATCHCRITERIA_IGNORE_THREAD;
785 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
787 | MATCHER_NOT_IGNORE_THREAD
791 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
792 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
794 | MATCHER_WATCH_THREAD
798 criteria = MATCHCRITERIA_WATCH_THREAD;
799 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
801 | MATCHER_NOT_WATCH_THREAD
805 criteria = MATCHCRITERIA_NOT_WATCH_THREAD;
806 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
808 | MATCHER_SUBJECT match_type MATCHER_STRING
813 criteria = MATCHCRITERIA_SUBJECT;
815 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
817 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
822 criteria = MATCHCRITERIA_NOT_SUBJECT;
824 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
826 | MATCHER_FROM match_type MATCHER_STRING
831 criteria = MATCHCRITERIA_FROM;
833 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
835 | MATCHER_NOT_FROM match_type MATCHER_STRING
840 criteria = MATCHCRITERIA_NOT_FROM;
842 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
844 | MATCHER_TO match_type MATCHER_STRING
849 criteria = MATCHCRITERIA_TO;
851 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
853 | MATCHER_NOT_TO match_type MATCHER_STRING
858 criteria = MATCHCRITERIA_NOT_TO;
860 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
862 | MATCHER_CC match_type MATCHER_STRING
867 criteria = MATCHCRITERIA_CC;
869 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
871 | MATCHER_NOT_CC match_type MATCHER_STRING
876 criteria = MATCHCRITERIA_NOT_CC;
878 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
880 | MATCHER_TO_OR_CC match_type MATCHER_STRING
885 criteria = MATCHCRITERIA_TO_OR_CC;
887 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
889 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
894 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
896 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
898 | MATCHER_TAG match_type MATCHER_STRING
903 criteria = MATCHCRITERIA_TAG;
905 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
907 | MATCHER_NOT_TAG match_type MATCHER_STRING
912 criteria = MATCHCRITERIA_NOT_TAG;
914 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
920 criteria = MATCHCRITERIA_TAGGED;
921 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
927 criteria = MATCHCRITERIA_NOT_TAGGED;
928 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
930 | MATCHER_AGE_GREATER MATCHER_INTEGER
935 criteria = MATCHCRITERIA_AGE_GREATER;
936 value = strtol($2, NULL, 0);
937 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
939 | MATCHER_AGE_LOWER MATCHER_INTEGER
944 criteria = MATCHCRITERIA_AGE_LOWER;
945 value = strtol($2, NULL, 0);
946 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
948 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
953 criteria = MATCHCRITERIA_NEWSGROUPS;
955 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
957 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
962 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
964 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
966 | MATCHER_INREPLYTO match_type MATCHER_STRING
971 criteria = MATCHCRITERIA_INREPLYTO;
973 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
975 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
980 criteria = MATCHCRITERIA_NOT_INREPLYTO;
982 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
984 | MATCHER_REFERENCES match_type MATCHER_STRING
989 criteria = MATCHCRITERIA_REFERENCES;
991 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
993 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
998 criteria = MATCHCRITERIA_NOT_REFERENCES;
1000 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1002 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1007 criteria = MATCHCRITERIA_SCORE_GREATER;
1008 value = strtol($2, NULL, 0);
1009 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1011 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1016 criteria = MATCHCRITERIA_SCORE_LOWER;
1017 value = strtol($2, NULL, 0);
1018 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1020 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1025 criteria = MATCHCRITERIA_SCORE_EQUAL;
1026 value = strtol($2, NULL, 0);
1027 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1029 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1033 criteria = MATCHCRITERIA_SIZE_GREATER;
1034 value = strtol($2, NULL, 0);
1035 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1037 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1041 criteria = MATCHCRITERIA_SIZE_SMALLER;
1042 value = strtol($2, NULL, 0);
1043 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1045 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1049 criteria = MATCHCRITERIA_SIZE_EQUAL;
1050 value = strtol($2, NULL, 0);
1051 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1053 | MATCHER_HEADER MATCHER_STRING
1055 header = g_strdup($2);
1056 } match_type MATCHER_STRING
1060 matcher_is_fast = FALSE;
1061 criteria = MATCHCRITERIA_HEADER;
1063 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1066 | MATCHER_NOT_HEADER MATCHER_STRING
1068 header = g_strdup($2);
1069 } match_type MATCHER_STRING
1073 matcher_is_fast = FALSE;
1074 criteria = MATCHCRITERIA_NOT_HEADER;
1076 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1079 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1083 matcher_is_fast = FALSE;
1084 criteria = MATCHCRITERIA_HEADERS_PART;
1086 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1088 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1092 matcher_is_fast = FALSE;
1093 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
1095 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1097 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1099 header = g_strdup($2);
1100 } MATCHER_IN MATCHER_STRING
1105 criteria = MATCHCRITERIA_FOUND_IN_ADDRESSBOOK;
1107 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1110 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1112 header = g_strdup($2);
1113 } MATCHER_IN MATCHER_STRING
1118 criteria = MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK;
1120 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1123 | MATCHER_MESSAGE match_type MATCHER_STRING
1127 matcher_is_fast = FALSE;
1128 criteria = MATCHCRITERIA_MESSAGE;
1130 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1132 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1136 matcher_is_fast = FALSE;
1137 criteria = MATCHCRITERIA_NOT_MESSAGE;
1139 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1141 | MATCHER_BODY_PART match_type MATCHER_STRING
1145 matcher_is_fast = FALSE;
1146 criteria = MATCHCRITERIA_BODY_PART;
1148 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1150 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1154 matcher_is_fast = FALSE;
1155 criteria = MATCHCRITERIA_NOT_BODY_PART;
1157 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1159 | MATCHER_TEST MATCHER_STRING
1163 matcher_is_fast = FALSE;
1164 criteria = MATCHCRITERIA_TEST;
1166 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1168 | MATCHER_NOT_TEST MATCHER_STRING
1172 matcher_is_fast = FALSE;
1173 criteria = MATCHCRITERIA_NOT_TEST;
1175 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1180 MATCHER_EXECUTE MATCHER_STRING
1183 gint action_type = 0;
1185 action_type = MATCHACTION_EXECUTE;
1187 action = filteringaction_new(action_type, 0, cmd, 0, 0, NULL);
1189 | MATCHER_MOVE MATCHER_STRING
1191 gchar *destination = NULL;
1192 gint action_type = 0;
1194 action_type = MATCHACTION_MOVE;
1196 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1198 | MATCHER_SET_TAG MATCHER_STRING
1200 gchar *destination = NULL;
1201 gint action_type = 0;
1203 action_type = MATCHACTION_SET_TAG;
1205 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1207 | MATCHER_UNSET_TAG MATCHER_STRING
1209 gchar *destination = NULL;
1210 gint action_type = 0;
1212 action_type = MATCHACTION_UNSET_TAG;
1214 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1216 | MATCHER_CLEAR_TAGS
1218 gint action_type = 0;
1220 action_type = MATCHACTION_CLEAR_TAGS;
1221 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1223 | MATCHER_COPY MATCHER_STRING
1225 gchar *destination = NULL;
1226 gint action_type = 0;
1228 action_type = MATCHACTION_COPY;
1230 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1234 gint action_type = 0;
1236 action_type = MATCHACTION_DELETE;
1237 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1241 gint action_type = 0;
1243 action_type = MATCHACTION_MARK;
1244 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1248 gint action_type = 0;
1250 action_type = MATCHACTION_UNMARK;
1251 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1255 gint action_type = 0;
1257 action_type = MATCHACTION_LOCK;
1258 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1262 gint action_type = 0;
1264 action_type = MATCHACTION_UNLOCK;
1265 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1267 | MATCHER_MARK_AS_READ
1269 gint action_type = 0;
1271 action_type = MATCHACTION_MARK_AS_READ;
1272 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1274 | MATCHER_MARK_AS_UNREAD
1276 gint action_type = 0;
1278 action_type = MATCHACTION_MARK_AS_UNREAD;
1279 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1281 | MATCHER_MARK_AS_SPAM
1283 gint action_type = 0;
1285 action_type = MATCHACTION_MARK_AS_SPAM;
1286 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1288 | MATCHER_MARK_AS_HAM
1290 gint action_type = 0;
1292 action_type = MATCHACTION_MARK_AS_HAM;
1293 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1295 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1297 gchar *destination = NULL;
1298 gint action_type = 0;
1299 gint account_id = 0;
1301 action_type = MATCHACTION_FORWARD;
1302 account_id = strtol($2, NULL, 10);
1304 action = filteringaction_new(action_type,
1305 account_id, destination, 0, 0, NULL);
1307 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1309 gchar *destination = NULL;
1310 gint action_type = 0;
1311 gint account_id = 0;
1313 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
1314 account_id = strtol($2, NULL, 10);
1316 action = filteringaction_new(action_type,
1317 account_id, destination, 0, 0, NULL);
1319 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1321 gchar *destination = NULL;
1322 gint action_type = 0;
1323 gint account_id = 0;
1325 action_type = MATCHACTION_REDIRECT;
1326 account_id = strtol($2, NULL, 10);
1328 action = filteringaction_new(action_type,
1329 account_id, destination, 0, 0, NULL);
1331 | MATCHER_COLOR MATCHER_INTEGER
1333 gint action_type = 0;
1336 action_type = MATCHACTION_COLOR;
1337 color = strtol($2, NULL, 10);
1338 action = filteringaction_new(action_type, 0, NULL, color, 0, NULL);
1340 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1344 score = strtol($2, NULL, 10);
1345 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1346 NULL, 0, score, NULL);
1348 /* backward compatibility */
1349 | MATCHER_SCORE MATCHER_INTEGER
1353 score = strtol($2, NULL, 10);
1354 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1355 NULL, 0, score, NULL);
1357 | MATCHER_SET_SCORE MATCHER_INTEGER
1361 score = strtol($2, NULL, 10);
1362 action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
1363 NULL, 0, score, NULL);
1367 action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0, NULL);
1371 action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0, NULL);
1375 action = filteringaction_new(MATCHACTION_WATCH, 0, NULL, 0, 0, NULL);
1377 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1379 header = g_strdup($2);
1382 gchar *addressbook = NULL;
1383 gint action_type = 0;
1385 action_type = MATCHACTION_ADD_TO_ADDRESSBOOK;
1387 action = filteringaction_new(action_type, 0, addressbook, 0, 0, header);
1392 action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0, NULL);