3 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
4 * Copyright (c) 2001-2014 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;
53 static gboolean filtering_ptr_externally_managed = FALSE;
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 void matcher_parserpop_buffer_state(void);
78 int matcher_parserlex(void);
80 void matcher_parser_disable_warnings(const gboolean disable)
82 disable_warnings = disable;
85 void matcher_parser_start_parsing(FILE *f)
87 matcher_parserlineno = 1;
88 matcher_parserrestart(f);
90 matcher_parserparse();
94 void * matcher_parser_scan_string(const char * str);
96 FilteringProp *matcher_parser_get_filtering(gchar *str)
101 /* little hack to allow passing rules with no names */
102 if (!strncmp(str, "rulename ", 9))
103 tmp_str = g_strdup(str);
105 tmp_str = g_strconcat("rulename \"\" ", str, NULL);
107 /* bad coding to enable the sub-grammar matching
109 matcher_parserlineno = 1;
110 matcher_parse_op = MATCHER_PARSE_NO_EOL;
111 matcher_parserrestart(NULL);
112 matcher_parserpop_buffer_state();
113 matcher_parser_init();
114 bufstate = matcher_parser_scan_string((const char *) tmp_str);
115 matcher_parser_switch_to_buffer(bufstate);
116 /* Indicate that we will be using the global "filtering" pointer,
117 * so that yyparse does not free it in "filtering_action_list"
119 filtering_ptr_externally_managed = TRUE;
120 if (matcher_parserparse() != 0)
122 matcher_parse_op = MATCHER_PARSE_FILE;
123 matcher_parser_delete_buffer(bufstate);
125 filtering_ptr_externally_managed = FALSE; /* Return to normal. */
129 static gboolean check_quote_symetry(gchar *str)
135 return TRUE; /* heh, that's symetric */
138 for (walk = str; *walk; walk++) {
140 if (walk == str /* first char */
141 || *(walk - 1) != '\\') /* not escaped */
148 MatcherList *matcher_parser_get_name(gchar *str)
152 if (!check_quote_symetry(str)) {
157 /* bad coding to enable the sub-grammar matching
159 matcher_parserlineno = 1;
160 matcher_parse_op = MATCHER_PARSE_NAME;
161 matcher_parserrestart(NULL);
162 matcher_parserpop_buffer_state();
163 matcher_parser_init();
164 bufstate = matcher_parser_scan_string(str);
165 matcher_parserparse();
166 matcher_parse_op = MATCHER_PARSE_FILE;
167 matcher_parser_delete_buffer(bufstate);
171 MatcherList *matcher_parser_get_enabled(gchar *str)
175 if (!check_quote_symetry(str)) {
180 /* bad coding to enable the sub-grammar matching
182 matcher_parserlineno = 1;
183 matcher_parse_op = MATCHER_PARSE_ENABLED;
184 matcher_parserrestart(NULL);
185 matcher_parserpop_buffer_state();
186 matcher_parser_init();
187 bufstate = matcher_parser_scan_string(str);
188 matcher_parserparse();
189 matcher_parse_op = MATCHER_PARSE_FILE;
190 matcher_parser_delete_buffer(bufstate);
194 MatcherList *matcher_parser_get_account(gchar *str)
198 if (!check_quote_symetry(str)) {
203 /* bad coding to enable the sub-grammar matching
205 matcher_parserlineno = 1;
206 matcher_parse_op = MATCHER_PARSE_ACCOUNT;
207 matcher_parserrestart(NULL);
208 matcher_parserpop_buffer_state();
209 matcher_parser_init();
210 bufstate = matcher_parser_scan_string(str);
211 matcher_parserparse();
212 matcher_parse_op = MATCHER_PARSE_FILE;
213 matcher_parser_delete_buffer(bufstate);
217 MatcherList *matcher_parser_get_cond(gchar *str, gboolean *is_fast)
221 if (!check_quote_symetry(str)) {
226 matcher_is_fast = TRUE;
227 /* bad coding to enable the sub-grammar matching
229 matcher_parserlineno = 1;
230 matcher_parse_op = MATCHER_PARSE_CONDITION;
231 matcher_parserrestart(NULL);
232 matcher_parserpop_buffer_state();
233 matcher_parser_init();
234 bufstate = matcher_parser_scan_string(str);
235 matcher_parserparse();
236 matcher_parse_op = MATCHER_PARSE_FILE;
237 matcher_parser_delete_buffer(bufstate);
239 *is_fast = matcher_is_fast;
243 GSList *matcher_parser_get_action_list(gchar *str)
247 if (!check_quote_symetry(str)) {
252 /* bad coding to enable the sub-grammar matching
254 matcher_parserlineno = 1;
255 matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
256 matcher_parserrestart(NULL);
257 matcher_parserpop_buffer_state();
258 matcher_parser_init();
259 bufstate = matcher_parser_scan_string(str);
260 matcher_parserparse();
261 matcher_parse_op = MATCHER_PARSE_FILE;
262 matcher_parser_delete_buffer(bufstate);
266 MatcherProp *matcher_parser_get_prop(gchar *str)
271 matcher_parserlineno = 1;
272 list = matcher_parser_get_cond(str, NULL);
276 if (list->matchers == NULL)
279 if (list->matchers->next != NULL)
282 prop = list->matchers->data;
284 g_slist_free(list->matchers);
290 void matcher_parsererror(char *str)
295 for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
296 matcherprop_free((MatcherProp *)
300 g_slist_free(matchers_list);
301 matchers_list = NULL;
304 if (!disable_warnings)
305 g_warning("filtering parsing: %i: %s",
306 matcher_parserlineno, str);
310 int matcher_parserwrap(void)
320 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
321 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
322 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
323 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
324 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
325 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
326 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
327 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
328 %token MATCHER_AGE_GREATER_HOURS MATCHER_AGE_LOWER_HOURS
329 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
330 %token MATCHER_MESSAGEID MATCHER_NOT_MESSAGEID
331 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
332 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
333 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
334 %token MATCHER_HEADERS_CONT MATCHER_NOT_HEADERS_CONT
335 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
336 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
337 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
338 %token MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_IN
339 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK
340 %token MATCHER_LOCK MATCHER_UNLOCK
341 %token MATCHER_EXECUTE
342 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
343 %token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
344 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL
345 %token MATCHER_OR MATCHER_AND
346 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
347 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
348 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
349 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
350 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
351 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
352 %token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
353 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
354 %token MATCHER_ADD_TO_ADDRESSBOOK
355 %token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
356 %token MATCHER_SPAM MATCHER_NOT_SPAM
357 %token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
358 %token MATCHER_SIGNED MATCHER_NOT_SIGNED
359 %token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
360 %token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
364 %token MATCHER_ENABLED MATCHER_DISABLED
365 %token MATCHER_RULENAME
366 %token MATCHER_ACCOUNT
367 %token <str> MATCHER_STRING
368 %token <str> MATCHER_SECTION
369 %token <str> MATCHER_INTEGER
375 if (matcher_parse_op == MATCHER_PARSE_FILE) {
376 prefs_filtering = &pre_global_processing;
390 { action_list = NULL; }
397 section_notification:
398 MATCHER_SECTION MATCHER_EOL
401 FolderItem *item = NULL;
403 if (matcher_parse_op == MATCHER_PARSE_FILE) {
404 enable_compatibility = 0;
405 if (!strcmp(folder, "global")) {
406 /* backward compatibility */
407 enable_compatibility = 1;
409 else if (!strcmp(folder, "preglobal")) {
410 prefs_filtering = &pre_global_processing;
412 else if (!strcmp(folder, "postglobal")) {
413 prefs_filtering = &post_global_processing;
415 else if (!strcmp(folder, "filtering")) {
416 prefs_filtering = &filtering_rules;
419 item = folder_find_item_from_identifier(folder);
421 prefs_filtering = &item->prefs->processing;
423 prefs_filtering = NULL;
431 enabled name account condition filtering MATCHER_EOL
432 | enabled name account condition filtering
433 | enabled name condition filtering MATCHER_EOL
434 | enabled name condition filtering
435 | name condition filtering MATCHER_EOL
436 | name condition filtering
438 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
441 matcher_parsererror("parse error [no eol]");
447 if (matcher_parse_op == MATCHER_PARSE_ENABLED)
450 matcher_parsererror("parse error [enabled]");
456 if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
459 matcher_parsererror("parse error [account]");
465 if (matcher_parse_op == MATCHER_PARSE_NAME)
468 matcher_parsererror("parse error [name]");
474 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
477 matcher_parsererror("parse error [condition]");
481 | filtering_action_list
483 if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
486 matcher_parsererror("parse error [filtering action]");
505 MATCHER_RULENAME MATCHER_STRING
512 MATCHER_ACCOUNT MATCHER_INTEGER
514 account_id = strtol($2, NULL, 10);
519 filtering_action_list
521 filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
526 if (enable_compatibility) {
527 prefs_filtering = &filtering_rules;
528 if (action_list != NULL) {
529 FilteringAction * first_action;
531 first_action = action_list->data;
533 if (first_action->type == MATCHACTION_CHANGE_SCORE)
534 prefs_filtering = &pre_global_processing;
541 if ((matcher_parse_op == MATCHER_PARSE_FILE) &&
542 (prefs_filtering != NULL)) {
543 *prefs_filtering = g_slist_append(*prefs_filtering,
546 } else if (!filtering_ptr_externally_managed) {
547 /* If filtering_ptr_externally_managed was TRUE, it
548 * would mean that some function higher in the stack is
549 * interested in the data "filtering" is pointing at, so
550 * we would not free it. That function has to free it itself.
551 * At the time of writing this, the only function that
552 * does this is matcher_parser_get_filtering(). */
553 filteringprop_free(filtering);
559 filtering_action_list:
560 filtering_action_b filtering_action_list
567 action_list = g_slist_append(action_list, action);
575 match_type = MATCHTYPE_MATCHCASE;
579 match_type = MATCHTYPE_MATCH;
583 match_type = MATCHTYPE_REGEXPCASE;
587 match_type = MATCHTYPE_REGEXP;
594 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
595 matchers_list = NULL;
600 condition_list bool_op one_condition
602 matchers_list = g_slist_append(matchers_list, prop);
606 matchers_list = NULL;
607 matchers_list = g_slist_append(matchers_list, prop);
614 bool_op = MATCHERBOOL_AND;
618 bool_op = MATCHERBOOL_OR;
627 criteria = MATCHCRITERIA_ALL;
628 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
634 criteria = MATCHCRITERIA_UNREAD;
635 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
641 criteria = MATCHCRITERIA_NOT_UNREAD;
642 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
648 criteria = MATCHCRITERIA_NEW;
649 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
655 criteria = MATCHCRITERIA_NOT_NEW;
656 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
662 criteria = MATCHCRITERIA_MARKED;
663 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
669 criteria = MATCHCRITERIA_NOT_MARKED;
670 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
676 criteria = MATCHCRITERIA_DELETED;
677 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
679 | MATCHER_NOT_DELETED
683 criteria = MATCHCRITERIA_NOT_DELETED;
684 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
690 criteria = MATCHCRITERIA_REPLIED;
691 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
693 | MATCHER_NOT_REPLIED
697 criteria = MATCHCRITERIA_NOT_REPLIED;
698 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
704 criteria = MATCHCRITERIA_FORWARDED;
705 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
707 | MATCHER_NOT_FORWARDED
711 criteria = MATCHCRITERIA_NOT_FORWARDED;
712 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
718 criteria = MATCHCRITERIA_LOCKED;
719 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
725 criteria = MATCHCRITERIA_NOT_LOCKED;
726 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
732 criteria = MATCHCRITERIA_SPAM;
733 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
739 criteria = MATCHCRITERIA_NOT_SPAM;
740 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
742 | MATCHER_HAS_ATTACHMENT
746 criteria = MATCHCRITERIA_HAS_ATTACHMENT;
747 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
749 | MATCHER_HAS_NO_ATTACHMENT
753 criteria = MATCHCRITERIA_HAS_NO_ATTACHMENT;
754 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
760 criteria = MATCHCRITERIA_SIGNED;
761 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
767 criteria = MATCHCRITERIA_NOT_SIGNED;
768 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
774 criteria = MATCHCRITERIA_PARTIAL;
775 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
777 | MATCHER_NOT_PARTIAL
781 criteria = MATCHCRITERIA_NOT_PARTIAL;
782 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
784 | MATCHER_COLORLABEL MATCHER_INTEGER
789 criteria = MATCHCRITERIA_COLORLABEL;
790 value = strtol($2, NULL, 10);
791 if (value < 0) value = 0;
792 else if (value > COLORLABELS) value = COLORLABELS;
793 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
795 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
800 criteria = MATCHCRITERIA_NOT_COLORLABEL;
801 value = strtol($2, NULL, 0);
802 if (value < 0) value = 0;
803 else if (value > COLORLABELS) value = COLORLABELS;
804 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
806 | MATCHER_IGNORE_THREAD
810 criteria = MATCHCRITERIA_IGNORE_THREAD;
811 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
813 | MATCHER_NOT_IGNORE_THREAD
817 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
818 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
820 | MATCHER_WATCH_THREAD
824 criteria = MATCHCRITERIA_WATCH_THREAD;
825 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
827 | MATCHER_NOT_WATCH_THREAD
831 criteria = MATCHCRITERIA_NOT_WATCH_THREAD;
832 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
834 | MATCHER_SUBJECT match_type MATCHER_STRING
839 criteria = MATCHCRITERIA_SUBJECT;
841 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
843 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
848 criteria = MATCHCRITERIA_NOT_SUBJECT;
850 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
852 | MATCHER_FROM match_type MATCHER_STRING
857 criteria = MATCHCRITERIA_FROM;
859 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
861 | MATCHER_NOT_FROM match_type MATCHER_STRING
866 criteria = MATCHCRITERIA_NOT_FROM;
868 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
870 | MATCHER_TO match_type MATCHER_STRING
875 criteria = MATCHCRITERIA_TO;
877 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
879 | MATCHER_NOT_TO match_type MATCHER_STRING
884 criteria = MATCHCRITERIA_NOT_TO;
886 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
888 | MATCHER_CC match_type MATCHER_STRING
893 criteria = MATCHCRITERIA_CC;
895 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
897 | MATCHER_NOT_CC match_type MATCHER_STRING
902 criteria = MATCHCRITERIA_NOT_CC;
904 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
906 | MATCHER_TO_OR_CC match_type MATCHER_STRING
911 criteria = MATCHCRITERIA_TO_OR_CC;
913 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
915 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
920 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
922 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
924 | MATCHER_TAG match_type MATCHER_STRING
929 criteria = MATCHCRITERIA_TAG;
931 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
933 | MATCHER_NOT_TAG match_type MATCHER_STRING
938 criteria = MATCHCRITERIA_NOT_TAG;
940 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
946 criteria = MATCHCRITERIA_TAGGED;
947 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
953 criteria = MATCHCRITERIA_NOT_TAGGED;
954 prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
956 | MATCHER_AGE_GREATER MATCHER_INTEGER
961 criteria = MATCHCRITERIA_AGE_GREATER;
962 value = strtol($2, NULL, 0);
963 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
965 | MATCHER_AGE_LOWER MATCHER_INTEGER
970 criteria = MATCHCRITERIA_AGE_LOWER;
971 value = strtol($2, NULL, 0);
972 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
974 | MATCHER_AGE_GREATER_HOURS MATCHER_INTEGER
979 criteria = MATCHCRITERIA_AGE_GREATER_HOURS;
980 value = strtol($2, NULL, 0);
981 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
983 | MATCHER_AGE_LOWER_HOURS MATCHER_INTEGER
988 criteria = MATCHCRITERIA_AGE_LOWER_HOURS;
989 value = strtol($2, NULL, 0);
990 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
992 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
997 criteria = MATCHCRITERIA_NEWSGROUPS;
999 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1001 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
1006 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
1008 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1010 | MATCHER_MESSAGEID match_type MATCHER_STRING
1015 criteria = MATCHCRITERIA_MESSAGEID;
1017 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1019 | MATCHER_NOT_MESSAGEID match_type MATCHER_STRING
1024 criteria = MATCHCRITERIA_NOT_MESSAGEID;
1026 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1028 | MATCHER_INREPLYTO match_type MATCHER_STRING
1033 criteria = MATCHCRITERIA_INREPLYTO;
1035 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1037 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
1042 criteria = MATCHCRITERIA_NOT_INREPLYTO;
1044 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1046 | MATCHER_REFERENCES match_type MATCHER_STRING
1051 criteria = MATCHCRITERIA_REFERENCES;
1053 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1055 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
1060 criteria = MATCHCRITERIA_NOT_REFERENCES;
1062 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1064 | MATCHER_SCORE_GREATER MATCHER_INTEGER
1069 criteria = MATCHCRITERIA_SCORE_GREATER;
1070 value = strtol($2, NULL, 0);
1071 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1073 | MATCHER_SCORE_LOWER MATCHER_INTEGER
1078 criteria = MATCHCRITERIA_SCORE_LOWER;
1079 value = strtol($2, NULL, 0);
1080 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1082 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
1087 criteria = MATCHCRITERIA_SCORE_EQUAL;
1088 value = strtol($2, NULL, 0);
1089 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1091 | MATCHER_SIZE_GREATER MATCHER_INTEGER
1095 criteria = MATCHCRITERIA_SIZE_GREATER;
1096 value = strtol($2, NULL, 0);
1097 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1099 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
1103 criteria = MATCHCRITERIA_SIZE_SMALLER;
1104 value = strtol($2, NULL, 0);
1105 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1107 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
1111 criteria = MATCHCRITERIA_SIZE_EQUAL;
1112 value = strtol($2, NULL, 0);
1113 prop = matcherprop_new(criteria, NULL, 0, NULL, value);
1115 | MATCHER_HEADER MATCHER_STRING
1117 header = g_strdup($2);
1118 } match_type MATCHER_STRING
1122 matcher_is_fast = FALSE;
1123 criteria = MATCHCRITERIA_HEADER;
1125 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1128 | MATCHER_NOT_HEADER MATCHER_STRING
1130 header = g_strdup($2);
1131 } match_type MATCHER_STRING
1135 matcher_is_fast = FALSE;
1136 criteria = MATCHCRITERIA_NOT_HEADER;
1138 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1141 | MATCHER_HEADERS_PART match_type MATCHER_STRING
1145 matcher_is_fast = FALSE;
1146 criteria = MATCHCRITERIA_HEADERS_PART;
1148 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1150 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
1154 matcher_is_fast = FALSE;
1155 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
1157 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1159 | MATCHER_HEADERS_CONT match_type MATCHER_STRING
1163 matcher_is_fast = FALSE;
1164 criteria = MATCHCRITERIA_HEADERS_CONT;
1166 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1168 | MATCHER_NOT_HEADERS_CONT match_type MATCHER_STRING
1172 matcher_is_fast = FALSE;
1173 criteria = MATCHCRITERIA_NOT_HEADERS_CONT;
1175 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1177 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1179 header = g_strdup($2);
1180 } MATCHER_IN MATCHER_STRING
1185 criteria = MATCHCRITERIA_FOUND_IN_ADDRESSBOOK;
1187 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1190 | MATCHER_NOT_FOUND_IN_ADDRESSBOOK MATCHER_STRING
1192 header = g_strdup($2);
1193 } MATCHER_IN MATCHER_STRING
1198 criteria = MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK;
1200 prop = matcherprop_new(criteria, header, match_type, expr, 0);
1203 | MATCHER_MESSAGE match_type MATCHER_STRING
1207 matcher_is_fast = FALSE;
1208 criteria = MATCHCRITERIA_MESSAGE;
1210 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1212 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
1216 matcher_is_fast = FALSE;
1217 criteria = MATCHCRITERIA_NOT_MESSAGE;
1219 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1221 | MATCHER_BODY_PART match_type MATCHER_STRING
1225 matcher_is_fast = FALSE;
1226 criteria = MATCHCRITERIA_BODY_PART;
1228 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1230 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
1234 matcher_is_fast = FALSE;
1235 criteria = MATCHCRITERIA_NOT_BODY_PART;
1237 prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
1239 | MATCHER_TEST MATCHER_STRING
1243 matcher_is_fast = FALSE;
1244 criteria = MATCHCRITERIA_TEST;
1246 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1248 | MATCHER_NOT_TEST MATCHER_STRING
1252 matcher_is_fast = FALSE;
1253 criteria = MATCHCRITERIA_NOT_TEST;
1255 prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
1260 MATCHER_EXECUTE MATCHER_STRING
1263 gint action_type = 0;
1265 action_type = MATCHACTION_EXECUTE;
1267 action = filteringaction_new(action_type, 0, cmd, 0, 0, NULL);
1269 | MATCHER_MOVE MATCHER_STRING
1271 gchar *destination = NULL;
1272 gint action_type = 0;
1274 action_type = MATCHACTION_MOVE;
1276 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1278 | MATCHER_SET_TAG MATCHER_STRING
1280 gchar *destination = NULL;
1281 gint action_type = 0;
1283 action_type = MATCHACTION_SET_TAG;
1285 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1287 | MATCHER_UNSET_TAG MATCHER_STRING
1289 gchar *destination = NULL;
1290 gint action_type = 0;
1292 action_type = MATCHACTION_UNSET_TAG;
1294 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1296 | MATCHER_CLEAR_TAGS
1298 gint action_type = 0;
1300 action_type = MATCHACTION_CLEAR_TAGS;
1301 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1303 | MATCHER_COPY MATCHER_STRING
1305 gchar *destination = NULL;
1306 gint action_type = 0;
1308 action_type = MATCHACTION_COPY;
1310 action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
1314 gint action_type = 0;
1316 action_type = MATCHACTION_DELETE;
1317 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1321 gint action_type = 0;
1323 action_type = MATCHACTION_MARK;
1324 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1328 gint action_type = 0;
1330 action_type = MATCHACTION_UNMARK;
1331 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1335 gint action_type = 0;
1337 action_type = MATCHACTION_LOCK;
1338 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1342 gint action_type = 0;
1344 action_type = MATCHACTION_UNLOCK;
1345 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1347 | MATCHER_MARK_AS_READ
1349 gint action_type = 0;
1351 action_type = MATCHACTION_MARK_AS_READ;
1352 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1354 | MATCHER_MARK_AS_UNREAD
1356 gint action_type = 0;
1358 action_type = MATCHACTION_MARK_AS_UNREAD;
1359 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1361 | MATCHER_MARK_AS_SPAM
1363 gint action_type = 0;
1365 action_type = MATCHACTION_MARK_AS_SPAM;
1366 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1368 | MATCHER_MARK_AS_HAM
1370 gint action_type = 0;
1372 action_type = MATCHACTION_MARK_AS_HAM;
1373 action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
1375 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
1377 gchar *destination = NULL;
1378 gint action_type = 0;
1379 gint account_id = 0;
1381 action_type = MATCHACTION_FORWARD;
1382 account_id = strtol($2, NULL, 10);
1384 action = filteringaction_new(action_type,
1385 account_id, destination, 0, 0, NULL);
1387 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
1389 gchar *destination = NULL;
1390 gint action_type = 0;
1391 gint account_id = 0;
1393 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
1394 account_id = strtol($2, NULL, 10);
1396 action = filteringaction_new(action_type,
1397 account_id, destination, 0, 0, NULL);
1399 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
1401 gchar *destination = NULL;
1402 gint action_type = 0;
1403 gint account_id = 0;
1405 action_type = MATCHACTION_REDIRECT;
1406 account_id = strtol($2, NULL, 10);
1408 action = filteringaction_new(action_type,
1409 account_id, destination, 0, 0, NULL);
1411 | MATCHER_COLOR MATCHER_INTEGER
1413 gint action_type = 0;
1416 action_type = MATCHACTION_COLOR;
1417 color = strtol($2, NULL, 10);
1418 action = filteringaction_new(action_type, 0, NULL, color, 0, NULL);
1420 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
1424 score = strtol($2, NULL, 10);
1425 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1426 NULL, 0, score, NULL);
1428 /* backward compatibility */
1429 | MATCHER_SCORE MATCHER_INTEGER
1433 score = strtol($2, NULL, 10);
1434 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
1435 NULL, 0, score, NULL);
1437 | MATCHER_SET_SCORE MATCHER_INTEGER
1441 score = strtol($2, NULL, 10);
1442 action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
1443 NULL, 0, score, NULL);
1447 action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0, NULL);
1451 action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0, NULL);
1455 action = filteringaction_new(MATCHACTION_WATCH, 0, NULL, 0, 0, NULL);
1457 | MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
1459 header = g_strdup($2);
1462 gchar *addressbook = NULL;
1463 gint action_type = 0;
1465 action_type = MATCHACTION_ADD_TO_ADDRESSBOOK;
1467 action = filteringaction_new(action_type, 0, addressbook, 0, 0, header);
1472 action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0, NULL);