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"
32 #include "folder_item_prefs.h"
34 static gint error = 0;
35 static gint bool_op = 0;
36 static gint match_type = 0;
37 static gchar *header = NULL;
39 static MatcherProp *prop;
41 static GSList *matchers_list = NULL;
43 static gboolean enabled = TRUE;
44 static gchar *name = NULL;
45 static gint account_id = 0;
46 static MatcherList *cond;
47 static GSList *action_list = NULL;
48 static FilteringAction *action = NULL;
49 static gboolean matcher_is_fast = TRUE;
50 static gboolean disable_warnings = FALSE;
52 static FilteringProp *filtering;
54 static GSList **prefs_filtering = NULL;
55 static int enable_compatibility = 0;
60 MATCHER_PARSE_ENABLED,
62 MATCHER_PARSE_ACCOUNT,
63 MATCHER_PARSE_CONDITION,
64 MATCHER_PARSE_FILTERING_ACTION,
67 static int matcher_parse_op = MATCHER_PARSE_FILE;
70 /* ******************************************************************** */
71 /* redeclarations to avoid warnings */
72 void matcher_parserrestart(FILE *input_file);
73 void matcher_parser_init(void);
74 void matcher_parser_switch_to_buffer(void * new_buffer);
75 void matcher_parser_delete_buffer(void * b);
76 void matcher_parserpop_buffer_state(void);
77 int matcher_parserlex(void);
79 void matcher_parser_disable_warnings(const gboolean disable)
81 disable_warnings = disable;
84 void matcher_parser_start_parsing(FILE *f)
86 matcher_parserlineno = 1;
87 matcher_parserrestart(f);
89 matcher_parserparse();
93 void * matcher_parser_scan_string(const char * str);
95 FilteringProp *matcher_parser_get_filtering(gchar *str)
100 /* little hack to allow passing rules with no names */
101 if (!strncmp(str, "rulename ", 9))
102 tmp_str = g_strdup(str);
104 tmp_str = g_strconcat("rulename \"\" ", str, NULL);
106 /* bad coding to enable the sub-grammar matching
108 matcher_parserlineno = 1;
109 matcher_parse_op = MATCHER_PARSE_NO_EOL;
110 matcher_parserrestart(NULL);
111 matcher_parserpop_buffer_state();
112 matcher_parser_init();
113 bufstate = matcher_parser_scan_string((const char *) tmp_str);
114 matcher_parser_switch_to_buffer(bufstate);
115 if (matcher_parserparse() != 0)
117 matcher_parse_op = MATCHER_PARSE_FILE;
118 matcher_parser_delete_buffer(bufstate);
123 static gboolean check_quote_symetry(gchar *str)
129 return TRUE; /* heh, that's symetric */
132 for (walk = str; *walk; walk++) {
134 if (walk == str /* first char */
135 || *(walk - 1) != '\\') /* not escaped */
142 MatcherList *matcher_parser_get_name(gchar *str)
146 if (!check_quote_symetry(str)) {
151 /* bad coding to enable the sub-grammar matching
153 matcher_parserlineno = 1;
154 matcher_parse_op = MATCHER_PARSE_NAME;
155 matcher_parserrestart(NULL);
156 matcher_parserpop_buffer_state();
157 matcher_parser_init();
158 bufstate = matcher_parser_scan_string(str);
159 matcher_parserparse();
160 matcher_parse_op = MATCHER_PARSE_FILE;
161 matcher_parser_delete_buffer(bufstate);
165 MatcherList *matcher_parser_get_enabled(gchar *str)
169 if (!check_quote_symetry(str)) {
174 /* bad coding to enable the sub-grammar matching
176 matcher_parserlineno = 1;
177 matcher_parse_op = MATCHER_PARSE_ENABLED;
178 matcher_parserrestart(NULL);
179 matcher_parserpop_buffer_state();
180 matcher_parser_init();
181 bufstate = matcher_parser_scan_string(str);
182 matcher_parserparse();
183 matcher_parse_op = MATCHER_PARSE_FILE;
184 matcher_parser_delete_buffer(bufstate);
188 MatcherList *matcher_parser_get_account(gchar *str)
192 if (!check_quote_symetry(str)) {
197 /* bad coding to enable the sub-grammar matching
199 matcher_parserlineno = 1;
200 matcher_parse_op = MATCHER_PARSE_ACCOUNT;
201 matcher_parserrestart(NULL);
202 matcher_parserpop_buffer_state();
203 matcher_parser_init();
204 bufstate = matcher_parser_scan_string(str);
205 matcher_parserparse();
206 matcher_parse_op = MATCHER_PARSE_FILE;
207 matcher_parser_delete_buffer(bufstate);
211 MatcherList *matcher_parser_get_cond(gchar *str, gboolean *is_fast)
215 if (!check_quote_symetry(str)) {
220 matcher_is_fast = TRUE;
221 /* bad coding to enable the sub-grammar matching
223 matcher_parserlineno = 1;
224 matcher_parse_op = MATCHER_PARSE_CONDITION;
225 matcher_parserrestart(NULL);
226 matcher_parserpop_buffer_state();
227 matcher_parser_init();
228 bufstate = matcher_parser_scan_string(str);
229 matcher_parserparse();
230 matcher_parse_op = MATCHER_PARSE_FILE;
231 matcher_parser_delete_buffer(bufstate);
233 *is_fast = matcher_is_fast;
237 GSList *matcher_parser_get_action_list(gchar *str)
241 if (!check_quote_symetry(str)) {
246 /* bad coding to enable the sub-grammar matching
248 matcher_parserlineno = 1;
249 matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
250 matcher_parserrestart(NULL);
251 matcher_parserpop_buffer_state();
252 matcher_parser_init();
253 bufstate = matcher_parser_scan_string(str);
254 matcher_parserparse();
255 matcher_parse_op = MATCHER_PARSE_FILE;
256 matcher_parser_delete_buffer(bufstate);
260 MatcherProp *matcher_parser_get_prop(gchar *str)
265 matcher_parserlineno = 1;
266 list = matcher_parser_get_cond(str, NULL);
270 if (list->matchers == NULL)
273 if (list->matchers->next != NULL)
276 prop = list->matchers->data;
278 g_slist_free(list->matchers);
284 void matcher_parsererror(char *str)
289 for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
290 matcherprop_free((MatcherProp *)
294 g_slist_free(matchers_list);
295 matchers_list = NULL;
298 if (!disable_warnings)
299 g_warning("filtering parsing: %i: %s\n",
300 matcher_parserlineno, str);
304 int matcher_parserwrap(void)
314 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
315 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
316 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
317 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
318 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
319 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
320 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
321 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
322 %token MATCHER_AGE_GREATER_HOURS MATCHER_AGE_LOWER_HOURS
323 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
324 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
325 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
326 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
327 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
328 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
329 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
330 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
331 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
332 %token MATCHER_LOCK MATCHER_UNLOCK
333 %token MATCHER_EXECUTE
334 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
335 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
336 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
337 %token MATCHER_OR MATCHER_AND
338 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
339 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
340 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
341 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
342 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
343 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
344 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
345 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
346 %token MATCHER_ADD_TO_ADDRESSBOOK
347 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
348 %token MATCHER_SPAM MATCHER_NOT_SPAM
349 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
350 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
351 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
352 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
356 %token MATCHER_ENABLED MATCHER_DISABLED
357 %token MATCHER_RULENAME
358 %token MATCHER_ACCOUNT
359 %token <str> MATCHER_STRING
360 %token <str> MATCHER_SECTION
361 %token <str> MATCHER_INTEGER
367 if (matcher_parse_op == MATCHER_PARSE_FILE) {
368 prefs_filtering = &pre_global_processing;
382 { action_list = NULL; }
389 section_notification:
390 MATCHER_SECTION MATCHER_EOL
393 FolderItem *item = NULL;
395 if (matcher_parse_op == MATCHER_PARSE_FILE) {
396 enable_compatibility = 0;
397 if (!strcmp(folder, "global")) {
398 /* backward compatibility */
399 enable_compatibility = 1;
401 else if (!strcmp(folder, "preglobal")) {
402 prefs_filtering = &pre_global_processing;
404 else if (!strcmp(folder, "postglobal")) {
405 prefs_filtering = &post_global_processing;
407 else if (!strcmp(folder, "filtering")) {
408 prefs_filtering = &filtering_rules;
411 item = folder_find_item_from_identifier(folder);
413 prefs_filtering = &item->prefs->processing;
415 prefs_filtering = NULL;
423 enabled name account condition filtering MATCHER_EOL
424 | enabled name account condition filtering
425 | enabled name condition filtering MATCHER_EOL
426 | enabled name condition filtering
427 | name condition filtering MATCHER_EOL
428 | name condition filtering
430 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
433 matcher_parsererror("parse error [no eol]");
439 if (matcher_parse_op == MATCHER_PARSE_ENABLED)
442 matcher_parsererror("parse error [enabled]");
448 if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
451 matcher_parsererror("parse error [account]");
457 if (matcher_parse_op == MATCHER_PARSE_NAME)
460 matcher_parsererror("parse error [name]");
466 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
469 matcher_parsererror("parse error [condition]");
473 | filtering_action_list
475 if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
478 matcher_parsererror("parse error [filtering action]");
497 MATCHER_RULENAME MATCHER_STRING
504 MATCHER_ACCOUNT MATCHER_INTEGER
506 account_id = strtol($2, NULL, 10);
511 filtering_action_list
513 filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
518 if (enable_compatibility) {
519 prefs_filtering = &filtering_rules;
520 if (action_list != NULL) {
521 FilteringAction * first_action;
523 first_action = action_list->data;
525 if (first_action->type == MATCHACTION_CHANGE_SCORE)
526 prefs_filtering = &pre_global_processing;
533 if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
534 (prefs_filtering != NULL)) {
535 *prefs_filtering = g_slist_append(*prefs_filtering,
542 filtering_action_list:
543 filtering_action_b filtering_action_list
550 action_list = g_slist_append(action_list, action);
558 match_type = MATCHTYPE_MATCHCASE;
562 match_type = MATCHTYPE_MATCH;
566 match_type = MATCHTYPE_REGEXPCASE;
570 match_type = MATCHTYPE_REGEXP;
577 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
578 matchers_list = NULL;
583 condition_list bool_op one_condition
585 matchers_list = g_slist_append(matchers_list, prop);
589 matchers_list = NULL;
590 matchers_list = g_slist_append(matchers_list, prop);
597 bool_op = MATCHERBOOL_AND;
601 bool_op = MATCHERBOOL_OR;
610 criteria = MATCHCRITERIA_ALL;
611 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
617 criteria = MATCHCRITERIA_UNREAD;
618 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
624 criteria = MATCHCRITERIA_NOT_UNREAD;
625 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
631 criteria = MATCHCRITERIA_NEW;
632 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
638 criteria = MATCHCRITERIA_NOT_NEW;
639 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
645 criteria = MATCHCRITERIA_MARKED;
646 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
652 criteria = MATCHCRITERIA_NOT_MARKED;
653 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
659 criteria = MATCHCRITERIA_DELETED;
660 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
662 | MATCHER_NOT_DELETED
666 criteria = MATCHCRITERIA_NOT_DELETED;
667 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
673 criteria = MATCHCRITERIA_REPLIED;
674 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
676 | MATCHER_NOT_REPLIED
680 criteria = MATCHCRITERIA_NOT_REPLIED;
681 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
687 criteria = MATCHCRITERIA_FORWARDED;
688 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
690 | MATCHER_NOT_FORWARDED
694 criteria = MATCHCRITERIA_NOT_FORWARDED;
695 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
701 criteria = MATCHCRITERIA_LOCKED;
702 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
708 criteria = MATCHCRITERIA_NOT_LOCKED;
709 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
715 criteria = MATCHCRITERIA_SPAM;
716 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
722 criteria = MATCHCRITERIA_NOT_SPAM;
723 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
725 | MATCHER_HAS_ATTACHMENT
729 criteria = MATCHCRITERIA_HAS_ATTACHMENT;
730 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
732 | MATCHER_HAS_NO_ATTACHMENT
736 criteria = MATCHCRITERIA_HAS_NO_ATTACHMENT;
737 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
743 criteria = MATCHCRITERIA_SIGNED;
744 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
750 criteria = MATCHCRITERIA_NOT_SIGNED;
751 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
757 criteria = MATCHCRITERIA_PARTIAL;
758 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
760 | MATCHER_NOT_PARTIAL
764 criteria = MATCHCRITERIA_NOT_PARTIAL;
765 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
767 | MATCHER_COLORLABEL MATCHER_INTEGER
772 criteria = MATCHCRITERIA_COLORLABEL;
773 value = strtol($2, NULL, 10);
774 if (value < 0) value = 0;
775 else if (value > COLORLABELS) value = COLORLABELS;
776 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
778 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
783 criteria = MATCHCRITERIA_NOT_COLORLABEL;
784 value = strtol($2, NULL, 0);
785 if (value < 0) value = 0;
786 else if (value > COLORLABELS) value = COLORLABELS;
787 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
789 | MATCHER_IGNORE_THREAD
793 criteria = MATCHCRITERIA_IGNORE_THREAD;
794 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
796 | MATCHER_NOT_IGNORE_THREAD
800 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
801 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
803 | MATCHER_WATCH_THREAD
807 criteria = MATCHCRITERIA_WATCH_THREAD;
808 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
810 | MATCHER_NOT_WATCH_THREAD
814 criteria = MATCHCRITERIA_NOT_WATCH_THREAD;
815 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
817 | MATCHER_SUBJECT match_type MATCHER_STRING
822 criteria = MATCHCRITERIA_SUBJECT;
824 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
826 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
831 criteria = MATCHCRITERIA_NOT_SUBJECT;
833 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
835 | MATCHER_FROM match_type MATCHER_STRING
840 criteria = MATCHCRITERIA_FROM;
842 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
844 | MATCHER_NOT_FROM match_type MATCHER_STRING
849 criteria = MATCHCRITERIA_NOT_FROM;
851 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
853 | MATCHER_TO match_type MATCHER_STRING
858 criteria = MATCHCRITERIA_TO;
860 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
862 | MATCHER_NOT_TO match_type MATCHER_STRING
867 criteria = MATCHCRITERIA_NOT_TO;
869 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
871 | MATCHER_CC match_type MATCHER_STRING
876 criteria = MATCHCRITERIA_CC;
878 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
880 | MATCHER_NOT_CC match_type MATCHER_STRING
885 criteria = MATCHCRITERIA_NOT_CC;
887 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
889 | MATCHER_TO_OR_CC match_type MATCHER_STRING
894 criteria = MATCHCRITERIA_TO_OR_CC;
896 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
898 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
903 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
905 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
907 | MATCHER_TAG match_type MATCHER_STRING
912 criteria = MATCHCRITERIA_TAG;
914 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
916 | MATCHER_NOT_TAG match_type MATCHER_STRING
921 criteria = MATCHCRITERIA_NOT_TAG;
923 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
929 criteria = MATCHCRITERIA_TAGGED;
930 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
936 criteria = MATCHCRITERIA_NOT_TAGGED;
937 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
939 | MATCHER_AGE_GREATER MATCHER_INTEGER
944 criteria = MATCHCRITERIA_AGE_GREATER;
945 value = strtol($2, NULL, 0);
946 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
948 | MATCHER_AGE_LOWER MATCHER_INTEGER
953 criteria = MATCHCRITERIA_AGE_LOWER;
954 value = strtol($2, NULL, 0);
955 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
957 | MATCHER_AGE_GREATER_HOURS MATCHER_INTEGER
962 criteria = MATCHCRITERIA_AGE_GREATER_HOURS;
963 value = strtol($2, NULL, 0);
964 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
966 | MATCHER_AGE_LOWER_HOURS MATCHER_INTEGER
971 criteria = MATCHCRITERIA_AGE_LOWER_HOURS;
972 value = strtol($2, NULL, 0);
973 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
975 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
980 criteria = MATCHCRITERIA_NEWSGROUPS;
982 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
984 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
989 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
991 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
993 | MATCHER_INREPLYTO match_type MATCHER_STRING
998 criteria = MATCHCRITERIA_INREPLYTO;
1000 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1002 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
1007 criteria = MATCHCRITERIA_NOT_INREPLYTO;
1009 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1011 | MATCHER_REFERENCES match_type MATCHER_STRING
1016 criteria = MATCHCRITERIA_REFERENCES;
1018 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1020 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
1025 criteria = MATCHCRITERIA_NOT_REFERENCES;
1027 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1029 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1034 criteria = MATCHCRITERIA_SCORE_GREATER;
1035 value = strtol($2, NULL, 0);
1036 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1038 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1043 criteria = MATCHCRITERIA_SCORE_LOWER;
1044 value = strtol($2, NULL, 0);
1045 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1047 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1052 criteria = MATCHCRITERIA_SCORE_EQUAL;
1053 value = strtol($2, NULL, 0);
1054 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1056 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1060 criteria = MATCHCRITERIA_SIZE_GREATER;
1061 value = strtol($2, NULL, 0);
1062 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1064 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1068 criteria = MATCHCRITERIA_SIZE_SMALLER;
1069 value = strtol($2, NULL, 0);
1070 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1072 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1076 criteria = MATCHCRITERIA_SIZE_EQUAL;
1077 value = strtol($2, NULL, 0);
1078 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1080 | MATCHER_HEADER MATCHER_STRING
1082 header = g_strdup($2);
1083 } match_type MATCHER_STRING
1087 matcher_is_fast = FALSE;
1088 criteria = MATCHCRITERIA_HEADER;
1090 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1093 | MATCHER_NOT_HEADER MATCHER_STRING
1095 header = g_strdup($2);
1096 } match_type MATCHER_STRING
1100 matcher_is_fast = FALSE;
1101 criteria = MATCHCRITERIA_NOT_HEADER;
1103 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1106 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1110 matcher_is_fast = FALSE;
1111 criteria = MATCHCRITERIA_HEADERS_PART;
1113 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1115 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1119 matcher_is_fast = FALSE;
1120 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
1122 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1124 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1126 header = g_strdup($2);
1127 } MATCHER_IN MATCHER_STRING
1132 criteria = MATCHCRITERIA_FOUND_IN_ADDRESSBOOK;
1134 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1137 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1139 header = g_strdup($2);
1140 } MATCHER_IN MATCHER_STRING
1145 criteria = MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK;
1147 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1150 | MATCHER_MESSAGE match_type MATCHER_STRING
1154 matcher_is_fast = FALSE;
1155 criteria = MATCHCRITERIA_MESSAGE;
1157 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1159 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1163 matcher_is_fast = FALSE;
1164 criteria = MATCHCRITERIA_NOT_MESSAGE;
1166 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1168 | MATCHER_BODY_PART match_type MATCHER_STRING
1172 matcher_is_fast = FALSE;
1173 criteria = MATCHCRITERIA_BODY_PART;
1175 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1177 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1181 matcher_is_fast = FALSE;
1182 criteria = MATCHCRITERIA_NOT_BODY_PART;
1184 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1186 | MATCHER_TEST MATCHER_STRING
1190 matcher_is_fast = FALSE;
1191 criteria = MATCHCRITERIA_TEST;
1193 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1195 | MATCHER_NOT_TEST MATCHER_STRING
1199 matcher_is_fast = FALSE;
1200 criteria = MATCHCRITERIA_NOT_TEST;
1202 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1207 MATCHER_EXECUTE MATCHER_STRING
1210 gint action_type = 0;
1212 action_type = MATCHACTION_EXECUTE;
1214 action = filteringaction_new(action_type, 0, cmd, 0, 0, NULL);
1216 | MATCHER_MOVE MATCHER_STRING
1218 gchar *destination = NULL;
1219 gint action_type = 0;
1221 action_type = MATCHACTION_MOVE;
1223 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1225 | MATCHER_SET_TAG MATCHER_STRING
1227 gchar *destination = NULL;
1228 gint action_type = 0;
1230 action_type = MATCHACTION_SET_TAG;
1232 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1234 | MATCHER_UNSET_TAG MATCHER_STRING
1236 gchar *destination = NULL;
1237 gint action_type = 0;
1239 action_type = MATCHACTION_UNSET_TAG;
1241 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1243 | MATCHER_CLEAR_TAGS
1245 gint action_type = 0;
1247 action_type = MATCHACTION_CLEAR_TAGS;
1248 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1250 | MATCHER_COPY MATCHER_STRING
1252 gchar *destination = NULL;
1253 gint action_type = 0;
1255 action_type = MATCHACTION_COPY;
1257 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1261 gint action_type = 0;
1263 action_type = MATCHACTION_DELETE;
1264 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1268 gint action_type = 0;
1270 action_type = MATCHACTION_MARK;
1271 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1275 gint action_type = 0;
1277 action_type = MATCHACTION_UNMARK;
1278 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1282 gint action_type = 0;
1284 action_type = MATCHACTION_LOCK;
1285 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1289 gint action_type = 0;
1291 action_type = MATCHACTION_UNLOCK;
1292 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1294 | MATCHER_MARK_AS_READ
1296 gint action_type = 0;
1298 action_type = MATCHACTION_MARK_AS_READ;
1299 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1301 | MATCHER_MARK_AS_UNREAD
1303 gint action_type = 0;
1305 action_type = MATCHACTION_MARK_AS_UNREAD;
1306 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1308 | MATCHER_MARK_AS_SPAM
1310 gint action_type = 0;
1312 action_type = MATCHACTION_MARK_AS_SPAM;
1313 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1315 | MATCHER_MARK_AS_HAM
1317 gint action_type = 0;
1319 action_type = MATCHACTION_MARK_AS_HAM;
1320 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1322 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1324 gchar *destination = NULL;
1325 gint action_type = 0;
1326 gint account_id = 0;
1328 action_type = MATCHACTION_FORWARD;
1329 account_id = strtol($2, NULL, 10);
1331 action = filteringaction_new(action_type,
1332 account_id, destination, 0, 0, NULL);
1334 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1336 gchar *destination = NULL;
1337 gint action_type = 0;
1338 gint account_id = 0;
1340 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
1341 account_id = strtol($2, NULL, 10);
1343 action = filteringaction_new(action_type,
1344 account_id, destination, 0, 0, NULL);
1346 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1348 gchar *destination = NULL;
1349 gint action_type = 0;
1350 gint account_id = 0;
1352 action_type = MATCHACTION_REDIRECT;
1353 account_id = strtol($2, NULL, 10);
1355 action = filteringaction_new(action_type,
1356 account_id, destination, 0, 0, NULL);
1358 | MATCHER_COLOR MATCHER_INTEGER
1360 gint action_type = 0;
1363 action_type = MATCHACTION_COLOR;
1364 color = strtol($2, NULL, 10);
1365 action = filteringaction_new(action_type, 0, NULL, color, 0, NULL);
1367 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1371 score = strtol($2, NULL, 10);
1372 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1373 NULL, 0, score, NULL);
1375 /* backward compatibility */
1376 | MATCHER_SCORE MATCHER_INTEGER
1380 score = strtol($2, NULL, 10);
1381 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1382 NULL, 0, score, NULL);
1384 | MATCHER_SET_SCORE MATCHER_INTEGER
1388 score = strtol($2, NULL, 10);
1389 action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
1390 NULL, 0, score, NULL);
1394 action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0, NULL);
1398 action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0, NULL);
1402 action = filteringaction_new(MATCHACTION_WATCH, 0, NULL, 0, 0, NULL);
1404 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1406 header = g_strdup($2);
1409 gchar *addressbook = NULL;
1410 gint action_type = 0;
1412 action_type = MATCHACTION_ADD_TO_ADDRESSBOOK;
1414 action = filteringaction_new(action_type, 0, addressbook, 0, 0, header);
1419 action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0, NULL);