5 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
6 * Copyright (c) 2001-2002 by Hiroyuki Yamamoto & The Sylpheed Claws Team.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <glib/gi18n.h>
29 #include "filtering.h"
31 #include "matcher_parser.h"
32 #include "matcher_parser_lex.h"
35 #define MAX_COLORLABELS (MSG_CLABEL_7 - MSG_CLABEL_NONE)
37 static gint error = 0;
38 static gint bool_op = 0;
39 static gint match_type = 0;
40 static gchar *header = NULL;
42 static MatcherProp *prop;
44 static GSList *matchers_list = NULL;
46 static gboolean enabled = TRUE;
47 static gchar *name = NULL;
48 static gint account_id = 0;
49 static MatcherList *cond;
50 static GSList *action_list = NULL;
51 static FilteringAction *action = NULL;
53 static FilteringProp *filtering;
55 static GSList **prefs_filtering = NULL;
56 static int enable_compatibility = 0;
61 MATCHER_PARSE_ENABLED,
63 MATCHER_PARSE_ACCOUNT,
64 MATCHER_PARSE_CONDITION,
65 MATCHER_PARSE_FILTERING_ACTION,
68 static int matcher_parse_op = MATCHER_PARSE_FILE;
71 /* ******************************************************************** */
72 /* redeclarations to avoid warnings */
73 void matcher_parserrestart(FILE *input_file);
74 void matcher_parser_init(void);
75 void matcher_parser_switch_to_buffer(void * new_buffer);
76 void matcher_parser_delete_buffer(void * b);
77 int matcher_parserlex(void);
79 void matcher_parser_start_parsing(FILE *f)
81 matcher_parserrestart(f);
83 matcher_parserparse();
87 void * matcher_parser_scan_string(const char * str);
89 FilteringProp *matcher_parser_get_filtering(gchar *str)
94 /* little hack to allow passing rules with no names */
95 if (!strncmp(str, "rulename ", 9))
96 tmp_str = g_strdup(str);
98 tmp_str = g_strconcat("rulename \"\" ", str, NULL);
100 /* bad coding to enable the sub-grammar matching
102 matcher_parserlineno = 1;
103 matcher_parse_op = MATCHER_PARSE_NO_EOL;
104 matcher_parserrestart(NULL);
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_parser_init();
150 bufstate = matcher_parser_scan_string(str);
151 matcher_parserparse();
152 matcher_parse_op = MATCHER_PARSE_FILE;
153 matcher_parser_delete_buffer(bufstate);
157 MatcherList *matcher_parser_get_enabled(gchar *str)
161 if (!check_quote_symetry(str)) {
166 /* bad coding to enable the sub-grammar matching
168 matcher_parserlineno = 1;
169 matcher_parse_op = MATCHER_PARSE_ENABLED;
170 matcher_parserrestart(NULL);
171 matcher_parser_init();
172 bufstate = matcher_parser_scan_string(str);
173 matcher_parserparse();
174 matcher_parse_op = MATCHER_PARSE_FILE;
175 matcher_parser_delete_buffer(bufstate);
179 MatcherList *matcher_parser_get_account(gchar *str)
183 if (!check_quote_symetry(str)) {
188 /* bad coding to enable the sub-grammar matching
190 matcher_parserlineno = 1;
191 matcher_parse_op = MATCHER_PARSE_ACCOUNT;
192 matcher_parserrestart(NULL);
193 matcher_parser_init();
194 bufstate = matcher_parser_scan_string(str);
195 matcher_parserparse();
196 matcher_parse_op = MATCHER_PARSE_FILE;
197 matcher_parser_delete_buffer(bufstate);
201 MatcherList *matcher_parser_get_cond(gchar *str)
205 if (!check_quote_symetry(str)) {
210 /* bad coding to enable the sub-grammar matching
212 matcher_parserlineno = 1;
213 matcher_parse_op = MATCHER_PARSE_CONDITION;
214 matcher_parserrestart(NULL);
215 matcher_parser_init();
216 bufstate = matcher_parser_scan_string(str);
217 matcher_parserparse();
218 matcher_parse_op = MATCHER_PARSE_FILE;
219 matcher_parser_delete_buffer(bufstate);
223 GSList *matcher_parser_get_action_list(gchar *str)
227 if (!check_quote_symetry(str)) {
232 /* bad coding to enable the sub-grammar matching
234 matcher_parserlineno = 1;
235 matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
236 matcher_parserrestart(NULL);
237 matcher_parser_init();
238 bufstate = matcher_parser_scan_string(str);
239 matcher_parserparse();
240 matcher_parse_op = MATCHER_PARSE_FILE;
241 matcher_parser_delete_buffer(bufstate);
245 MatcherProp *matcher_parser_get_prop(gchar *str)
250 matcher_parserlineno = 1;
251 list = matcher_parser_get_cond(str);
255 if (list->matchers == NULL)
258 if (list->matchers->next != NULL)
261 prop = list->matchers->data;
263 g_slist_free(list->matchers);
269 void matcher_parsererror(char *str)
274 for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
275 matcherprop_free((MatcherProp *)
279 g_slist_free(matchers_list);
280 matchers_list = NULL;
283 g_warning("filtering parsing: %i: %s\n",
284 matcher_parserlineno, str);
288 int matcher_parserwrap(void)
298 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
299 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
300 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
301 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
302 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
303 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
304 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
305 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
306 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
307 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
308 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
309 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
310 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
311 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
312 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
313 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
314 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
315 %token MATCHER_LOCK MATCHER_UNLOCK
316 %token MATCHER_EXECUTE
317 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
318 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL MATCHER_STRING
319 %token MATCHER_OR MATCHER_AND
320 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
321 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
322 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
323 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
324 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
325 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
326 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
327 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE
331 %token MATCHER_ENABLED MATCHER_DISABLED
332 %token MATCHER_RULENAME
333 %token MATCHER_ACCOUNT
334 %token <str> MATCHER_STRING
335 %token <str> MATCHER_SECTION
336 %token <str> MATCHER_INTEGER
342 if (matcher_parse_op == MATCHER_PARSE_FILE) {
343 prefs_filtering = &pre_global_processing;
357 { action_list = NULL; }
364 section_notification:
365 MATCHER_SECTION MATCHER_EOL
368 FolderItem *item = NULL;
370 if (matcher_parse_op == MATCHER_PARSE_FILE) {
371 enable_compatibility = 0;
372 if (!strcmp(folder, "global")) {
373 /* backward compatibility */
374 enable_compatibility = 1;
376 else if (!strcmp(folder, "preglobal")) {
377 prefs_filtering = &pre_global_processing;
379 else if (!strcmp(folder, "postglobal")) {
380 prefs_filtering = &post_global_processing;
382 else if (!strcmp(folder, "filtering")) {
383 prefs_filtering = &filtering_rules;
386 item = folder_find_item_from_identifier(folder);
388 prefs_filtering = &item->prefs->processing;
390 prefs_filtering = NULL;
398 enabled name account condition filtering MATCHER_EOL
399 | enabled name account condition filtering
400 | enabled name condition filtering MATCHER_EOL
401 | enabled name condition filtering
402 | name condition filtering MATCHER_EOL
403 | name condition filtering
405 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
408 matcher_parsererror("parse error [no eol]");
414 if (matcher_parse_op == MATCHER_PARSE_ENABLED)
417 matcher_parsererror("parse error [enabled]");
423 if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
426 matcher_parsererror("parse error [account]");
432 if (matcher_parse_op == MATCHER_PARSE_NAME)
435 matcher_parsererror("parse error [name]");
441 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
444 matcher_parsererror("parse error [condition]");
448 | filtering_action_list
450 if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
453 matcher_parsererror("parse error [filtering action]");
472 MATCHER_RULENAME MATCHER_STRING
479 MATCHER_ACCOUNT MATCHER_INTEGER
481 account_id = strtol($2, NULL, 10);
482 fprintf(stderr, "parser %d\n", account_id);
488 filtering_action_list
490 filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
495 if (enable_compatibility) {
496 prefs_filtering = &filtering_rules;
497 if (action_list != NULL) {
498 FilteringAction * first_action;
500 first_action = action_list->data;
502 if (first_action->type == MATCHACTION_CHANGE_SCORE)
503 prefs_filtering = &pre_global_processing;
510 if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
511 (prefs_filtering != NULL)) {
512 *prefs_filtering = g_slist_append(*prefs_filtering,
519 filtering_action_list:
520 filtering_action_b filtering_action_list
527 action_list = g_slist_append(action_list, action);
535 match_type = MATCHTYPE_MATCHCASE;
539 match_type = MATCHTYPE_MATCH;
543 match_type = MATCHTYPE_REGEXPCASE;
547 match_type = MATCHTYPE_REGEXP;
554 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
555 matchers_list = NULL;
560 condition_list bool_op one_condition
562 matchers_list = g_slist_append(matchers_list, prop);
566 matchers_list = NULL;
567 matchers_list = g_slist_append(matchers_list, prop);
574 bool_op = MATCHERBOOL_AND;
578 bool_op = MATCHERBOOL_OR;
587 criteria = MATCHCRITERIA_ALL;
588 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
594 criteria = MATCHCRITERIA_UNREAD;
595 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
601 criteria = MATCHCRITERIA_NOT_UNREAD;
602 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
608 criteria = MATCHCRITERIA_NEW;
609 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
615 criteria = MATCHCRITERIA_NOT_NEW;
616 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
622 criteria = MATCHCRITERIA_MARKED;
623 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
629 criteria = MATCHCRITERIA_NOT_MARKED;
630 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
636 criteria = MATCHCRITERIA_DELETED;
637 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
639 | MATCHER_NOT_DELETED
643 criteria = MATCHCRITERIA_NOT_DELETED;
644 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
650 criteria = MATCHCRITERIA_REPLIED;
651 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
653 | MATCHER_NOT_REPLIED
657 criteria = MATCHCRITERIA_NOT_REPLIED;
658 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
664 criteria = MATCHCRITERIA_FORWARDED;
665 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
667 | MATCHER_NOT_FORWARDED
671 criteria = MATCHCRITERIA_NOT_FORWARDED;
672 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
678 criteria = MATCHCRITERIA_LOCKED;
679 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
685 criteria = MATCHCRITERIA_NOT_LOCKED;
686 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
692 criteria = MATCHCRITERIA_PARTIAL;
693 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
695 | MATCHER_NOT_PARTIAL
699 criteria = MATCHCRITERIA_NOT_PARTIAL;
700 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
702 | MATCHER_COLORLABEL MATCHER_INTEGER
707 criteria = MATCHCRITERIA_COLORLABEL;
708 value = strtol($2, NULL, 10);
709 if (value < 0) value = 0;
710 else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
711 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
713 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
718 criteria = MATCHCRITERIA_NOT_COLORLABEL;
719 value = strtol($2, NULL, 0);
720 if (value < 0) value = 0;
721 else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
722 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
724 | MATCHER_IGNORE_THREAD
728 criteria = MATCHCRITERIA_IGNORE_THREAD;
729 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
731 | MATCHER_NOT_IGNORE_THREAD
735 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
736 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
738 | MATCHER_SUBJECT match_type MATCHER_STRING
743 criteria = MATCHCRITERIA_SUBJECT;
745 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
747 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
752 criteria = MATCHCRITERIA_NOT_SUBJECT;
754 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
756 | MATCHER_FROM match_type MATCHER_STRING
761 criteria = MATCHCRITERIA_FROM;
763 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
765 | MATCHER_NOT_FROM match_type MATCHER_STRING
770 criteria = MATCHCRITERIA_NOT_FROM;
772 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
774 | MATCHER_TO match_type MATCHER_STRING
779 criteria = MATCHCRITERIA_TO;
781 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
783 | MATCHER_NOT_TO match_type MATCHER_STRING
788 criteria = MATCHCRITERIA_NOT_TO;
790 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
792 | MATCHER_CC match_type MATCHER_STRING
797 criteria = MATCHCRITERIA_CC;
799 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
801 | MATCHER_NOT_CC match_type MATCHER_STRING
806 criteria = MATCHCRITERIA_NOT_CC;
808 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
810 | MATCHER_TO_OR_CC match_type MATCHER_STRING
815 criteria = MATCHCRITERIA_TO_OR_CC;
817 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
819 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
824 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
826 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
828 | MATCHER_AGE_GREATER MATCHER_INTEGER
833 criteria = MATCHCRITERIA_AGE_GREATER;
834 value = strtol($2, NULL, 0);
835 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
837 | MATCHER_AGE_LOWER MATCHER_INTEGER
842 criteria = MATCHCRITERIA_AGE_LOWER;
843 value = strtol($2, NULL, 0);
844 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
846 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
851 criteria = MATCHCRITERIA_NEWSGROUPS;
853 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
855 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
860 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
862 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
864 | MATCHER_INREPLYTO match_type MATCHER_STRING
869 criteria = MATCHCRITERIA_INREPLYTO;
871 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
873 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
878 criteria = MATCHCRITERIA_NOT_INREPLYTO;
880 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
882 | MATCHER_REFERENCES match_type MATCHER_STRING
887 criteria = MATCHCRITERIA_REFERENCES;
889 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
891 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
896 criteria = MATCHCRITERIA_NOT_REFERENCES;
898 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
900 | MATCHER_SCORE_GREATER MATCHER_INTEGER
905 criteria = MATCHCRITERIA_SCORE_GREATER;
906 value = strtol($2, NULL, 0);
907 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
909 | MATCHER_SCORE_LOWER MATCHER_INTEGER
914 criteria = MATCHCRITERIA_SCORE_LOWER;
915 value = strtol($2, NULL, 0);
916 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
918 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
923 criteria = MATCHCRITERIA_SCORE_EQUAL;
924 value = strtol($2, NULL, 0);
925 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
927 | MATCHER_SIZE_GREATER MATCHER_INTEGER
931 criteria = MATCHCRITERIA_SIZE_GREATER;
932 value = strtol($2, NULL, 0);
933 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
935 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
939 criteria = MATCHCRITERIA_SIZE_SMALLER;
940 value = strtol($2, NULL, 0);
941 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
943 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
947 criteria = MATCHCRITERIA_SIZE_EQUAL;
948 value = strtol($2, NULL, 0);
949 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
951 | MATCHER_HEADER MATCHER_STRING
953 header = g_strdup($2);
954 } match_type MATCHER_STRING
959 criteria = MATCHCRITERIA_HEADER;
961 prop = matcherprop_new(criteria, header, match_type, expr, 0);
964 | MATCHER_NOT_HEADER MATCHER_STRING
966 header = g_strdup($2);
967 } match_type MATCHER_STRING
972 criteria = MATCHCRITERIA_NOT_HEADER;
974 prop = matcherprop_new(criteria, header, match_type, expr, 0);
977 | MATCHER_HEADERS_PART match_type MATCHER_STRING
982 criteria = MATCHCRITERIA_HEADERS_PART;
984 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
986 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
991 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
993 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
995 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
997 header = g_strdup($2);
998 } MATCHER_IN MATCHER_STRING
1003 criteria = MATCHCRITERIA_FOUND_IN_ADDRESSBOOK;
1005 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1008 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1010 header = g_strdup($2);
1011 } MATCHER_IN MATCHER_STRING
1016 criteria = MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK;
1018 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1021 | MATCHER_MESSAGE match_type MATCHER_STRING
1026 criteria = MATCHCRITERIA_MESSAGE;
1028 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1030 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1035 criteria = MATCHCRITERIA_NOT_MESSAGE;
1037 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1039 | MATCHER_BODY_PART match_type MATCHER_STRING
1044 criteria = MATCHCRITERIA_BODY_PART;
1046 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1048 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1053 criteria = MATCHCRITERIA_NOT_BODY_PART;
1055 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1057 | MATCHER_TEST MATCHER_STRING
1062 criteria = MATCHCRITERIA_TEST;
1064 prop = matcherprop_new(criteria, NULL, 0, expr, 0);
1066 | MATCHER_NOT_TEST MATCHER_STRING
1071 criteria = MATCHCRITERIA_NOT_TEST;
1073 prop = matcherprop_new(criteria, NULL, 0, expr, 0);
1078 MATCHER_EXECUTE MATCHER_STRING
1081 gint action_type = 0;
1083 action_type = MATCHACTION_EXECUTE;
1085 action = filteringaction_new(action_type, 0, cmd, 0, 0);
1087 | MATCHER_MOVE MATCHER_STRING
1089 gchar *destination = NULL;
1090 gint action_type = 0;
1092 action_type = MATCHACTION_MOVE;
1094 action = filteringaction_new(action_type, 0, destination, 0, 0);
1096 | MATCHER_COPY MATCHER_STRING
1098 gchar *destination = NULL;
1099 gint action_type = 0;
1101 action_type = MATCHACTION_COPY;
1103 action = filteringaction_new(action_type, 0, destination, 0, 0);
1107 gint action_type = 0;
1109 action_type = MATCHACTION_DELETE;
1110 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1114 gint action_type = 0;
1116 action_type = MATCHACTION_MARK;
1117 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1121 gint action_type = 0;
1123 action_type = MATCHACTION_UNMARK;
1124 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1128 gint action_type = 0;
1130 action_type = MATCHACTION_LOCK;
1131 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1135 gint action_type = 0;
1137 action_type = MATCHACTION_UNLOCK;
1138 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1140 | MATCHER_MARK_AS_READ
1142 gint action_type = 0;
1144 action_type = MATCHACTION_MARK_AS_READ;
1145 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1147 | MATCHER_MARK_AS_UNREAD
1149 gint action_type = 0;
1151 action_type = MATCHACTION_MARK_AS_UNREAD;
1152 action = filteringaction_new(action_type, 0, NULL, 0, 0);
1154 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1156 gchar *destination = NULL;
1157 gint action_type = 0;
1158 gint account_id = 0;
1160 action_type = MATCHACTION_FORWARD;
1161 account_id = strtol($2, NULL, 10);
1163 action = filteringaction_new(action_type,
1164 account_id, destination, 0, 0);
1166 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1168 gchar *destination = NULL;
1169 gint action_type = 0;
1170 gint account_id = 0;
1172 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
1173 account_id = strtol($2, NULL, 10);
1175 action = filteringaction_new(action_type,
1176 account_id, destination, 0, 0);
1178 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1180 gchar *destination = NULL;
1181 gint action_type = 0;
1182 gint account_id = 0;
1184 action_type = MATCHACTION_REDIRECT;
1185 account_id = strtol($2, NULL, 10);
1187 action = filteringaction_new(action_type,
1188 account_id, destination, 0, 0);
1190 | MATCHER_COLOR MATCHER_INTEGER
1192 gint action_type = 0;
1195 action_type = MATCHACTION_COLOR;
1196 color = strtol($2, NULL, 10);
1197 action = filteringaction_new(action_type, 0, NULL, color, 0);
1199 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1203 score = strtol($2, NULL, 10);
1204 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1207 /* backward compatibility */
1208 | MATCHER_SCORE MATCHER_INTEGER
1212 score = strtol($2, NULL, 10);
1213 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1216 | MATCHER_SET_SCORE MATCHER_INTEGER
1220 score = strtol($2, NULL, 10);
1221 action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
1226 action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0);
1230 action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0);
1234 action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0);