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_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
323 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
324 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
325 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
326 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
327 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
328 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
329 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
330 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
331 %token MATCHER_LOCK MATCHER_UNLOCK
332 %token MATCHER_EXECUTE
333 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
334 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
335 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
336 %token MATCHER_OR MATCHER_AND
337 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
338 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
339 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
340 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
341 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
342 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
343 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
344 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
345 %token MATCHER_ADD_TO_ADDRESSBOOK
346 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
347 %token MATCHER_SPAM MATCHER_NOT_SPAM
348 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
349 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
350 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
351 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
355 %token MATCHER_ENABLED MATCHER_DISABLED
356 %token MATCHER_RULENAME
357 %token MATCHER_ACCOUNT
358 %token <str> MATCHER_STRING
359 %token <str> MATCHER_SECTION
360 %token <str> MATCHER_INTEGER
366 if (matcher_parse_op == MATCHER_PARSE_FILE) {
367 prefs_filtering = &pre_global_processing;
381 { action_list = NULL; }
388 section_notification:
389 MATCHER_SECTION MATCHER_EOL
392 FolderItem *item = NULL;
394 if (matcher_parse_op == MATCHER_PARSE_FILE) {
395 enable_compatibility = 0;
396 if (!strcmp(folder, "global")) {
397 /* backward compatibility */
398 enable_compatibility = 1;
400 else if (!strcmp(folder, "preglobal")) {
401 prefs_filtering = &pre_global_processing;
403 else if (!strcmp(folder, "postglobal")) {
404 prefs_filtering = &post_global_processing;
406 else if (!strcmp(folder, "filtering")) {
407 prefs_filtering = &filtering_rules;
410 item = folder_find_item_from_identifier(folder);
412 prefs_filtering = &item->prefs->processing;
414 prefs_filtering = NULL;
422 enabled name account condition filtering MATCHER_EOL
423 | enabled name account condition filtering
424 | enabled name condition filtering MATCHER_EOL
425 | enabled name condition filtering
426 | name condition filtering MATCHER_EOL
427 | name condition filtering
429 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
432 matcher_parsererror("parse error [no eol]");
438 if (matcher_parse_op == MATCHER_PARSE_ENABLED)
441 matcher_parsererror("parse error [enabled]");
447 if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
450 matcher_parsererror("parse error [account]");
456 if (matcher_parse_op == MATCHER_PARSE_NAME)
459 matcher_parsererror("parse error [name]");
465 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
468 matcher_parsererror("parse error [condition]");
472 | filtering_action_list
474 if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
477 matcher_parsererror("parse error [filtering action]");
496 MATCHER_RULENAME MATCHER_STRING
503 MATCHER_ACCOUNT MATCHER_INTEGER
505 account_id = strtol($2, NULL, 10);
510 filtering_action_list
512 filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
517 if (enable_compatibility) {
518 prefs_filtering = &filtering_rules;
519 if (action_list != NULL) {
520 FilteringAction * first_action;
522 first_action = action_list->data;
524 if (first_action->type == MATCHACTION_CHANGE_SCORE)
525 prefs_filtering = &pre_global_processing;
532 if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
533 (prefs_filtering != NULL)) {
534 *prefs_filtering = g_slist_append(*prefs_filtering,
541 filtering_action_list:
542 filtering_action_b filtering_action_list
549 action_list = g_slist_append(action_list, action);
557 match_type = MATCHTYPE_MATCHCASE;
561 match_type = MATCHTYPE_MATCH;
565 match_type = MATCHTYPE_REGEXPCASE;
569 match_type = MATCHTYPE_REGEXP;
576 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
577 matchers_list = NULL;
582 condition_list bool_op one_condition
584 matchers_list = g_slist_append(matchers_list, prop);
588 matchers_list = NULL;
589 matchers_list = g_slist_append(matchers_list, prop);
596 bool_op = MATCHERBOOL_AND;
600 bool_op = MATCHERBOOL_OR;
609 criteria = MATCHCRITERIA_ALL;
610 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
616 criteria = MATCHCRITERIA_UNREAD;
617 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
623 criteria = MATCHCRITERIA_NOT_UNREAD;
624 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
630 criteria = MATCHCRITERIA_NEW;
631 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
637 criteria = MATCHCRITERIA_NOT_NEW;
638 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
644 criteria = MATCHCRITERIA_MARKED;
645 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
651 criteria = MATCHCRITERIA_NOT_MARKED;
652 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
658 criteria = MATCHCRITERIA_DELETED;
659 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
661 | MATCHER_NOT_DELETED
665 criteria = MATCHCRITERIA_NOT_DELETED;
666 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
672 criteria = MATCHCRITERIA_REPLIED;
673 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
675 | MATCHER_NOT_REPLIED
679 criteria = MATCHCRITERIA_NOT_REPLIED;
680 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
686 criteria = MATCHCRITERIA_FORWARDED;
687 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
689 | MATCHER_NOT_FORWARDED
693 criteria = MATCHCRITERIA_NOT_FORWARDED;
694 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
700 criteria = MATCHCRITERIA_LOCKED;
701 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
707 criteria = MATCHCRITERIA_NOT_LOCKED;
708 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
714 criteria = MATCHCRITERIA_SPAM;
715 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
721 criteria = MATCHCRITERIA_NOT_SPAM;
722 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
724 | MATCHER_HAS_ATTACHMENT
728 criteria = MATCHCRITERIA_HAS_ATTACHMENT;
729 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
731 | MATCHER_HAS_NO_ATTACHMENT
735 criteria = MATCHCRITERIA_HAS_NO_ATTACHMENT;
736 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
742 criteria = MATCHCRITERIA_SIGNED;
743 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
749 criteria = MATCHCRITERIA_NOT_SIGNED;
750 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
756 criteria = MATCHCRITERIA_PARTIAL;
757 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
759 | MATCHER_NOT_PARTIAL
763 criteria = MATCHCRITERIA_NOT_PARTIAL;
764 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
766 | MATCHER_COLORLABEL MATCHER_INTEGER
771 criteria = MATCHCRITERIA_COLORLABEL;
772 value = strtol($2, NULL, 10);
773 if (value < 0) value = 0;
774 else if (value > COLORLABELS) value = COLORLABELS;
775 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
777 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
782 criteria = MATCHCRITERIA_NOT_COLORLABEL;
783 value = strtol($2, NULL, 0);
784 if (value < 0) value = 0;
785 else if (value > COLORLABELS) value = COLORLABELS;
786 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
788 | MATCHER_IGNORE_THREAD
792 criteria = MATCHCRITERIA_IGNORE_THREAD;
793 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
795 | MATCHER_NOT_IGNORE_THREAD
799 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
800 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
802 | MATCHER_WATCH_THREAD
806 criteria = MATCHCRITERIA_WATCH_THREAD;
807 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
809 | MATCHER_NOT_WATCH_THREAD
813 criteria = MATCHCRITERIA_NOT_WATCH_THREAD;
814 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
816 | MATCHER_SUBJECT match_type MATCHER_STRING
821 criteria = MATCHCRITERIA_SUBJECT;
823 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
825 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
830 criteria = MATCHCRITERIA_NOT_SUBJECT;
832 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
834 | MATCHER_FROM match_type MATCHER_STRING
839 criteria = MATCHCRITERIA_FROM;
841 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
843 | MATCHER_NOT_FROM match_type MATCHER_STRING
848 criteria = MATCHCRITERIA_NOT_FROM;
850 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
852 | MATCHER_TO match_type MATCHER_STRING
857 criteria = MATCHCRITERIA_TO;
859 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
861 | MATCHER_NOT_TO match_type MATCHER_STRING
866 criteria = MATCHCRITERIA_NOT_TO;
868 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
870 | MATCHER_CC match_type MATCHER_STRING
875 criteria = MATCHCRITERIA_CC;
877 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
879 | MATCHER_NOT_CC match_type MATCHER_STRING
884 criteria = MATCHCRITERIA_NOT_CC;
886 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
888 | MATCHER_TO_OR_CC match_type MATCHER_STRING
893 criteria = MATCHCRITERIA_TO_OR_CC;
895 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
897 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
902 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
904 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
906 | MATCHER_TAG match_type MATCHER_STRING
911 criteria = MATCHCRITERIA_TAG;
913 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
915 | MATCHER_NOT_TAG match_type MATCHER_STRING
920 criteria = MATCHCRITERIA_NOT_TAG;
922 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
928 criteria = MATCHCRITERIA_TAGGED;
929 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
935 criteria = MATCHCRITERIA_NOT_TAGGED;
936 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
938 | MATCHER_AGE_GREATER MATCHER_INTEGER
943 criteria = MATCHCRITERIA_AGE_GREATER;
944 value = strtol($2, NULL, 0);
945 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
947 | MATCHER_AGE_LOWER MATCHER_INTEGER
952 criteria = MATCHCRITERIA_AGE_LOWER;
953 value = strtol($2, NULL, 0);
954 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
956 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
961 criteria = MATCHCRITERIA_NEWSGROUPS;
963 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
965 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
970 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
972 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
974 | MATCHER_INREPLYTO match_type MATCHER_STRING
979 criteria = MATCHCRITERIA_INREPLYTO;
981 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
983 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
988 criteria = MATCHCRITERIA_NOT_INREPLYTO;
990 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
992 | MATCHER_REFERENCES match_type MATCHER_STRING
997 criteria = MATCHCRITERIA_REFERENCES;
999 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1001 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
1006 criteria = MATCHCRITERIA_NOT_REFERENCES;
1008 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1010 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1015 criteria = MATCHCRITERIA_SCORE_GREATER;
1016 value = strtol($2, NULL, 0);
1017 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1019 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1024 criteria = MATCHCRITERIA_SCORE_LOWER;
1025 value = strtol($2, NULL, 0);
1026 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1028 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1033 criteria = MATCHCRITERIA_SCORE_EQUAL;
1034 value = strtol($2, NULL, 0);
1035 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1037 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1041 criteria = MATCHCRITERIA_SIZE_GREATER;
1042 value = strtol($2, NULL, 0);
1043 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1045 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1049 criteria = MATCHCRITERIA_SIZE_SMALLER;
1050 value = strtol($2, NULL, 0);
1051 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1053 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1057 criteria = MATCHCRITERIA_SIZE_EQUAL;
1058 value = strtol($2, NULL, 0);
1059 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1061 | MATCHER_HEADER MATCHER_STRING
1063 header = g_strdup($2);
1064 } match_type MATCHER_STRING
1068 matcher_is_fast = FALSE;
1069 criteria = MATCHCRITERIA_HEADER;
1071 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1074 | MATCHER_NOT_HEADER MATCHER_STRING
1076 header = g_strdup($2);
1077 } match_type MATCHER_STRING
1081 matcher_is_fast = FALSE;
1082 criteria = MATCHCRITERIA_NOT_HEADER;
1084 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1087 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1091 matcher_is_fast = FALSE;
1092 criteria = MATCHCRITERIA_HEADERS_PART;
1094 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1096 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1100 matcher_is_fast = FALSE;
1101 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
1103 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1105 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1107 header = g_strdup($2);
1108 } MATCHER_IN MATCHER_STRING
1113 criteria = MATCHCRITERIA_FOUND_IN_ADDRESSBOOK;
1115 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1118 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1120 header = g_strdup($2);
1121 } MATCHER_IN MATCHER_STRING
1126 criteria = MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK;
1128 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1131 | MATCHER_MESSAGE match_type MATCHER_STRING
1135 matcher_is_fast = FALSE;
1136 criteria = MATCHCRITERIA_MESSAGE;
1138 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1140 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1144 matcher_is_fast = FALSE;
1145 criteria = MATCHCRITERIA_NOT_MESSAGE;
1147 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1149 | MATCHER_BODY_PART match_type MATCHER_STRING
1153 matcher_is_fast = FALSE;
1154 criteria = MATCHCRITERIA_BODY_PART;
1156 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1158 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1162 matcher_is_fast = FALSE;
1163 criteria = MATCHCRITERIA_NOT_BODY_PART;
1165 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1167 | MATCHER_TEST MATCHER_STRING
1171 matcher_is_fast = FALSE;
1172 criteria = MATCHCRITERIA_TEST;
1174 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1176 | MATCHER_NOT_TEST MATCHER_STRING
1180 matcher_is_fast = FALSE;
1181 criteria = MATCHCRITERIA_NOT_TEST;
1183 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1188 MATCHER_EXECUTE MATCHER_STRING
1191 gint action_type = 0;
1193 action_type = MATCHACTION_EXECUTE;
1195 action = filteringaction_new(action_type, 0, cmd, 0, 0, NULL);
1197 | MATCHER_MOVE MATCHER_STRING
1199 gchar *destination = NULL;
1200 gint action_type = 0;
1202 action_type = MATCHACTION_MOVE;
1204 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1206 | MATCHER_SET_TAG MATCHER_STRING
1208 gchar *destination = NULL;
1209 gint action_type = 0;
1211 action_type = MATCHACTION_SET_TAG;
1213 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1215 | MATCHER_UNSET_TAG MATCHER_STRING
1217 gchar *destination = NULL;
1218 gint action_type = 0;
1220 action_type = MATCHACTION_UNSET_TAG;
1222 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1224 | MATCHER_CLEAR_TAGS
1226 gint action_type = 0;
1228 action_type = MATCHACTION_CLEAR_TAGS;
1229 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1231 | MATCHER_COPY MATCHER_STRING
1233 gchar *destination = NULL;
1234 gint action_type = 0;
1236 action_type = MATCHACTION_COPY;
1238 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1242 gint action_type = 0;
1244 action_type = MATCHACTION_DELETE;
1245 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1249 gint action_type = 0;
1251 action_type = MATCHACTION_MARK;
1252 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1256 gint action_type = 0;
1258 action_type = MATCHACTION_UNMARK;
1259 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1263 gint action_type = 0;
1265 action_type = MATCHACTION_LOCK;
1266 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1270 gint action_type = 0;
1272 action_type = MATCHACTION_UNLOCK;
1273 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1275 | MATCHER_MARK_AS_READ
1277 gint action_type = 0;
1279 action_type = MATCHACTION_MARK_AS_READ;
1280 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1282 | MATCHER_MARK_AS_UNREAD
1284 gint action_type = 0;
1286 action_type = MATCHACTION_MARK_AS_UNREAD;
1287 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1289 | MATCHER_MARK_AS_SPAM
1291 gint action_type = 0;
1293 action_type = MATCHACTION_MARK_AS_SPAM;
1294 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1296 | MATCHER_MARK_AS_HAM
1298 gint action_type = 0;
1300 action_type = MATCHACTION_MARK_AS_HAM;
1301 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1303 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1305 gchar *destination = NULL;
1306 gint action_type = 0;
1307 gint account_id = 0;
1309 action_type = MATCHACTION_FORWARD;
1310 account_id = strtol($2, NULL, 10);
1312 action = filteringaction_new(action_type,
1313 account_id, destination, 0, 0, NULL);
1315 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1317 gchar *destination = NULL;
1318 gint action_type = 0;
1319 gint account_id = 0;
1321 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
1322 account_id = strtol($2, NULL, 10);
1324 action = filteringaction_new(action_type,
1325 account_id, destination, 0, 0, NULL);
1327 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1329 gchar *destination = NULL;
1330 gint action_type = 0;
1331 gint account_id = 0;
1333 action_type = MATCHACTION_REDIRECT;
1334 account_id = strtol($2, NULL, 10);
1336 action = filteringaction_new(action_type,
1337 account_id, destination, 0, 0, NULL);
1339 | MATCHER_COLOR MATCHER_INTEGER
1341 gint action_type = 0;
1344 action_type = MATCHACTION_COLOR;
1345 color = strtol($2, NULL, 10);
1346 action = filteringaction_new(action_type, 0, NULL, color, 0, NULL);
1348 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1352 score = strtol($2, NULL, 10);
1353 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1354 NULL, 0, score, NULL);
1356 /* backward compatibility */
1357 | MATCHER_SCORE MATCHER_INTEGER
1361 score = strtol($2, NULL, 10);
1362 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1363 NULL, 0, score, NULL);
1365 | MATCHER_SET_SCORE MATCHER_INTEGER
1369 score = strtol($2, NULL, 10);
1370 action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
1371 NULL, 0, score, NULL);
1375 action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0, NULL);
1379 action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0, NULL);
1383 action = filteringaction_new(MATCHACTION_WATCH, 0, NULL, 0, 0, NULL);
1385 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1387 header = g_strdup($2);
1390 gchar *addressbook = NULL;
1391 gint action_type = 0;
1393 action_type = MATCHACTION_ADD_TO_ADDRESSBOOK;
1395 action = filteringaction_new(action_type, 0, addressbook, 0, 0, header);
1400 action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0, NULL);