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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include "filtering.h"
32 #include "matcher_parser.h"
33 #include "matcher_parser_lex.h"
36 #define MAX_COLORLABELS (MSG_CLABEL_7 - MSG_CLABEL_NONE)
38 static gint error = 0;
39 static gint bool_op = 0;
40 static gint match_type = 0;
41 static gchar *header = NULL;
43 static MatcherProp *prop;
45 static GSList *matchers_list = NULL;
47 static MatcherList *cond;
48 static gint score = 0;
49 static GSList *action_list = NULL;
50 static FilteringAction *action = NULL;
52 static FilteringProp *filtering;
53 static ScoringProp *scoring = NULL;
55 static GSList **prefs_scoring = NULL;
56 static GSList **prefs_filtering = NULL;
59 static int matcher_parser_dialog = 0;
65 MATCHER_PARSE_CONDITION,
66 MATCHER_PARSE_FILTERING_OR_SCORING,
69 static int matcher_parse_op = MATCHER_PARSE_NONE;
72 /* ******************************************************************** */
74 void matcher_parser_start_parsing(FILE *f)
76 matcher_parserrestart(f);
77 matcher_parserparse();
80 FilteringProp *matcher_parser_get_filtering(gchar *str)
84 /* bad coding to enable the sub-grammar matching
86 matcher_parserlineno = 1;
87 matcher_parse_op = MATCHER_PARSE_NO_EOL;
88 matcher_parserrestart(NULL);
89 matcher_parser_init();
90 bufstate = matcher_parser_scan_string(str);
91 matcher_parser_switch_to_buffer(bufstate);
92 if (matcher_parserparse() != 0)
94 matcher_parse_op = MATCHER_PARSE_NONE;
95 matcher_parser_delete_buffer(bufstate);
99 ScoringProp *matcher_parser_get_scoring(gchar *str)
103 /* bad coding to enable the sub-grammar matching
105 matcher_parserlineno = 1;
106 matcher_parse_op = MATCHER_PARSE_NO_EOL;
107 matcher_parserrestart(NULL);
108 matcher_parser_init();
109 bufstate = matcher_parser_scan_string(str);
110 matcher_parser_switch_to_buffer(bufstate);
111 if (matcher_parserparse() != 0)
113 matcher_parse_op = MATCHER_PARSE_NONE;
114 matcher_parser_delete_buffer(bufstate);
118 static gboolean check_quote_symetry(gchar *str)
124 return TRUE; /* heh, that's symetric */
127 for (walk = str; *walk; walk++) {
129 if (walk == str /* first char */
130 || *(walk - 1) != '\\') /* not escaped */
137 MatcherList *matcher_parser_get_cond(gchar *str)
141 if (!check_quote_symetry(str)) {
146 /* bad coding to enable the sub-grammar matching
148 matcher_parserlineno = 1;
149 matcher_parse_op = MATCHER_PARSE_CONDITION;
150 matcher_parserrestart(NULL);
151 matcher_parser_init();
152 bufstate = matcher_parser_scan_string(str);
153 matcher_parserparse();
154 matcher_parse_op = MATCHER_PARSE_NONE;
155 matcher_parser_delete_buffer(bufstate);
159 GSList *matcher_parser_get_action_list(gchar *str)
163 if (!check_quote_symetry(str)) {
168 /* bad coding to enable the sub-grammar matching
170 matcher_parserlineno = 1;
171 matcher_parse_op = MATCHER_PARSE_FILTERING_OR_SCORING;
172 matcher_parserrestart(NULL);
173 matcher_parser_init();
174 bufstate = matcher_parser_scan_string(str);
175 matcher_parserparse();
176 matcher_parse_op = MATCHER_PARSE_NONE;
177 matcher_parser_delete_buffer(bufstate);
181 MatcherProp *matcher_parser_get_prop(gchar *str)
186 matcher_parserlineno = 1;
187 list = matcher_parser_get_cond(str);
191 if (list->matchers == NULL)
194 if (list->matchers->next != NULL)
197 prop = list->matchers->data;
199 g_slist_free(list->matchers);
205 void matcher_parsererror(char *str)
210 for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
211 matcherprop_free((MatcherProp *)
215 g_slist_free(matchers_list);
216 matchers_list = NULL;
219 g_warning("scoring / filtering parsing: %i: %s\n",
220 matcher_parserlineno, str);
224 int matcher_parserwrap(void)
235 %token MATCHER_ALL MATCHER_UNREAD MATCHER_NOT_UNREAD
236 %token MATCHER_NEW MATCHER_NOT_NEW MATCHER_MARKED
237 %token MATCHER_NOT_MARKED MATCHER_DELETED MATCHER_NOT_DELETED
238 %token MATCHER_REPLIED MATCHER_NOT_REPLIED MATCHER_FORWARDED
239 %token MATCHER_NOT_FORWARDED MATCHER_SUBJECT MATCHER_NOT_SUBJECT
240 %token MATCHER_FROM MATCHER_NOT_FROM MATCHER_TO MATCHER_NOT_TO
241 %token MATCHER_CC MATCHER_NOT_CC MATCHER_TO_OR_CC MATCHER_NOT_TO_AND_NOT_CC
242 %token MATCHER_AGE_GREATER MATCHER_AGE_LOWER MATCHER_NEWSGROUPS
243 %token MATCHER_NOT_NEWSGROUPS MATCHER_INREPLYTO MATCHER_NOT_INREPLYTO
244 %token MATCHER_REFERENCES MATCHER_NOT_REFERENCES MATCHER_SCORE_GREATER
245 %token MATCHER_SCORE_LOWER MATCHER_HEADER MATCHER_NOT_HEADER
246 %token MATCHER_HEADERS_PART MATCHER_NOT_HEADERS_PART MATCHER_MESSAGE
247 %token MATCHER_NOT_MESSAGE MATCHER_BODY_PART MATCHER_NOT_BODY_PART
248 %token MATCHER_TEST MATCHER_NOT_TEST MATCHER_MATCHCASE MATCHER_MATCH
249 %token MATCHER_REGEXPCASE MATCHER_REGEXP MATCHER_SCORE MATCHER_MOVE
250 %token MATCHER_COPY MATCHER_DELETE MATCHER_MARK MATCHER_UNMARK MATCHER_LOCK MATCHER_UNLOCK
251 %token MATCHER_EXECUTE
252 %token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
253 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL MATCHER_STRING
254 %token MATCHER_OR MATCHER_AND
255 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
256 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
257 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
258 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
259 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
260 %token MATCHER_CHANGE_SCORE
264 %token <str> MATCHER_STRING
265 %token <str> MATCHER_SECTION
266 %token <str> MATCHER_INTEGER
272 if (matcher_parse_op == MATCHER_PARSE_NONE) {
273 prefs_scoring = &global_scoring;
274 prefs_filtering = &global_processing;
288 { action_list = NULL; }
295 section_notification:
296 MATCHER_SECTION MATCHER_EOL
299 FolderItem *item = NULL;
301 if (matcher_parse_op == MATCHER_PARSE_NONE) {
302 if (!strcmp(folder, "global")) {
303 prefs_scoring = &global_scoring;
304 prefs_filtering = &global_processing;
306 item = folder_find_item_from_identifier(folder);
308 prefs_scoring = &item->prefs->scoring;
309 prefs_filtering = &item->prefs->processing;
311 prefs_scoring = NULL;
312 prefs_filtering = NULL;
320 condition filtering_or_scoring MATCHER_EOL
321 | condition filtering_or_scoring
323 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
326 matcher_parsererror("parse error");
332 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
335 matcher_parsererror("parse error");
339 | filtering_action_list
341 if (matcher_parse_op == MATCHER_PARSE_FILTERING_OR_SCORING)
344 matcher_parsererror("parse error");
351 filtering_or_scoring:
352 filtering_action_list
354 filtering = filteringprop_new(cond, action_list);
357 if ((matcher_parse_op == MATCHER_PARSE_NONE) && (prefs_filtering != NULL)) {
358 *prefs_filtering = g_slist_append(*prefs_filtering,
365 scoring = scoringprop_new(cond, score);
368 if ((matcher_parse_op == MATCHER_PARSE_NONE)
369 && (prefs_scoring != NULL)) {
370 *prefs_scoring = g_slist_append(*prefs_scoring, scoring);
376 filtering_action_list:
377 filtering_action_b filtering_action_list
384 action_list = g_slist_append(action_list, action);
392 match_type = MATCHTYPE_MATCHCASE;
396 match_type = MATCHTYPE_MATCH;
400 match_type = MATCHTYPE_REGEXPCASE;
404 match_type = MATCHTYPE_REGEXP;
411 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
412 matchers_list = NULL;
417 condition_list bool_op one_condition
419 matchers_list = g_slist_append(matchers_list, prop);
423 matchers_list = NULL;
424 matchers_list = g_slist_append(matchers_list, prop);
431 bool_op = MATCHERBOOL_AND;
435 bool_op = MATCHERBOOL_OR;
444 criteria = MATCHCRITERIA_ALL;
445 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
451 criteria = MATCHCRITERIA_UNREAD;
452 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
458 criteria = MATCHCRITERIA_NOT_UNREAD;
459 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
465 criteria = MATCHCRITERIA_NEW;
466 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
472 criteria = MATCHCRITERIA_NOT_NEW;
473 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
479 criteria = MATCHCRITERIA_MARKED;
480 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
486 criteria = MATCHCRITERIA_NOT_MARKED;
487 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
493 criteria = MATCHCRITERIA_DELETED;
494 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
496 | MATCHER_NOT_DELETED
500 criteria = MATCHCRITERIA_NOT_DELETED;
501 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
507 criteria = MATCHCRITERIA_REPLIED;
508 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
510 | MATCHER_NOT_REPLIED
514 criteria = MATCHCRITERIA_NOT_REPLIED;
515 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
521 criteria = MATCHCRITERIA_FORWARDED;
522 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
524 | MATCHER_NOT_FORWARDED
528 criteria = MATCHCRITERIA_NOT_FORWARDED;
529 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
535 criteria = MATCHCRITERIA_LOCKED;
536 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
542 criteria = MATCHCRITERIA_NOT_LOCKED;
543 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
545 | MATCHER_COLORLABEL MATCHER_INTEGER
550 criteria = MATCHCRITERIA_COLORLABEL;
552 if (value < 1) value = 1;
553 else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
554 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
556 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
561 criteria = MATCHCRITERIA_NOT_COLORLABEL;
563 if (value < 1) value = 1;
564 else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
565 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
567 | MATCHER_IGNORE_THREAD
571 criteria = MATCHCRITERIA_IGNORE_THREAD;
572 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
574 | MATCHER_NOT_IGNORE_THREAD
578 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
579 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
581 | MATCHER_SUBJECT match_type MATCHER_STRING
586 criteria = MATCHCRITERIA_SUBJECT;
588 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
590 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
595 criteria = MATCHCRITERIA_NOT_SUBJECT;
597 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
599 | MATCHER_FROM match_type MATCHER_STRING
604 criteria = MATCHCRITERIA_FROM;
606 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
608 | MATCHER_NOT_FROM match_type MATCHER_STRING
613 criteria = MATCHCRITERIA_NOT_FROM;
615 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
617 | MATCHER_TO match_type MATCHER_STRING
622 criteria = MATCHCRITERIA_TO;
624 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
626 | MATCHER_NOT_TO match_type MATCHER_STRING
631 criteria = MATCHCRITERIA_NOT_TO;
633 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
635 | MATCHER_CC match_type MATCHER_STRING
640 criteria = MATCHCRITERIA_CC;
642 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
644 | MATCHER_NOT_CC match_type MATCHER_STRING
649 criteria = MATCHCRITERIA_NOT_CC;
651 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
653 | MATCHER_TO_OR_CC match_type MATCHER_STRING
658 criteria = MATCHCRITERIA_TO_OR_CC;
660 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
662 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
667 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
669 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
671 | MATCHER_AGE_GREATER MATCHER_INTEGER
676 criteria = MATCHCRITERIA_AGE_GREATER;
678 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
680 | MATCHER_AGE_LOWER MATCHER_INTEGER
685 criteria = MATCHCRITERIA_AGE_LOWER;
687 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
689 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
694 criteria = MATCHCRITERIA_NEWSGROUPS;
696 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
698 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
703 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
705 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
707 | MATCHER_INREPLYTO match_type MATCHER_STRING
712 criteria = MATCHCRITERIA_INREPLYTO;
714 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
716 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
721 criteria = MATCHCRITERIA_NOT_INREPLYTO;
723 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
725 | MATCHER_REFERENCES match_type MATCHER_STRING
730 criteria = MATCHCRITERIA_REFERENCES;
732 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
734 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
739 criteria = MATCHCRITERIA_NOT_REFERENCES;
741 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
743 | MATCHER_SCORE_GREATER MATCHER_INTEGER
748 criteria = MATCHCRITERIA_SCORE_GREATER;
750 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
752 | MATCHER_SCORE_LOWER MATCHER_INTEGER
757 criteria = MATCHCRITERIA_SCORE_LOWER;
759 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
761 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
766 criteria = MATCHCRITERIA_SCORE_EQUAL;
768 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
770 | MATCHER_SIZE_GREATER MATCHER_INTEGER
774 criteria = MATCHCRITERIA_SIZE_GREATER;
776 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
778 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
782 criteria = MATCHCRITERIA_SIZE_SMALLER;
784 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
786 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
790 criteria = MATCHCRITERIA_SIZE_EQUAL;
792 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
794 | MATCHER_HEADER MATCHER_STRING
796 header = g_strdup($2);
797 } match_type MATCHER_STRING
802 criteria = MATCHCRITERIA_HEADER;
804 prop = matcherprop_unquote_new(criteria, header, match_type, expr, 0);
807 | MATCHER_NOT_HEADER MATCHER_STRING
809 header = g_strdup($2);
810 } match_type MATCHER_STRING
815 criteria = MATCHCRITERIA_NOT_HEADER;
817 prop = matcherprop_unquote_new(criteria, header, match_type, expr, 0);
820 | MATCHER_HEADERS_PART match_type MATCHER_STRING
825 criteria = MATCHCRITERIA_HEADERS_PART;
827 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
829 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
834 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
836 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
838 | MATCHER_MESSAGE match_type MATCHER_STRING
843 criteria = MATCHCRITERIA_MESSAGE;
845 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
847 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
852 criteria = MATCHCRITERIA_NOT_MESSAGE;
854 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
856 | MATCHER_BODY_PART match_type MATCHER_STRING
861 criteria = MATCHCRITERIA_BODY_PART;
863 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
865 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
870 criteria = MATCHCRITERIA_NOT_BODY_PART;
872 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
874 | MATCHER_TEST MATCHER_STRING
879 criteria = MATCHCRITERIA_TEST;
881 prop = matcherprop_unquote_new(criteria, NULL, 0, expr, 0);
883 | MATCHER_NOT_TEST MATCHER_STRING
888 criteria = MATCHCRITERIA_NOT_TEST;
890 prop = matcherprop_unquote_new(criteria, NULL, 0, expr, 0);
895 MATCHER_EXECUTE MATCHER_STRING
898 gint action_type = 0;
900 action_type = MATCHACTION_EXECUTE;
902 action = filteringaction_new(action_type, 0, cmd, 0);
904 | MATCHER_MOVE MATCHER_STRING
906 gchar *destination = NULL;
907 gint action_type = 0;
909 action_type = MATCHACTION_MOVE;
911 action = filteringaction_new(action_type, 0, destination, 0);
913 | MATCHER_COPY MATCHER_STRING
915 gchar *destination = NULL;
916 gint action_type = 0;
918 action_type = MATCHACTION_COPY;
920 action = filteringaction_new(action_type, 0, destination, 0);
924 gint action_type = 0;
926 action_type = MATCHACTION_DELETE;
927 action = filteringaction_new(action_type, 0, NULL, 0);
931 gint action_type = 0;
933 action_type = MATCHACTION_MARK;
934 action = filteringaction_new(action_type, 0, NULL, 0);
938 gint action_type = 0;
940 action_type = MATCHACTION_UNMARK;
941 action = filteringaction_new(action_type, 0, NULL, 0);
945 gint action_type = 0;
947 action_type = MATCHACTION_LOCK;
948 action = filteringaction_new(action_type, 0, NULL, 0);
952 gint action_type = 0;
954 action_type = MATCHACTION_UNLOCK;
955 action = filteringaction_new(action_type, 0, NULL, 0);
957 | MATCHER_MARK_AS_READ
959 gint action_type = 0;
961 action_type = MATCHACTION_MARK_AS_READ;
962 action = filteringaction_new(action_type, 0, NULL, 0);
964 | MATCHER_MARK_AS_UNREAD
966 gint action_type = 0;
968 action_type = MATCHACTION_MARK_AS_UNREAD;
969 action = filteringaction_new(action_type, 0, NULL, 0);
971 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
973 gchar *destination = NULL;
974 gint action_type = 0;
977 action_type = MATCHACTION_FORWARD;
978 account_id = atoi($2);
980 action = filteringaction_new(action_type, account_id, destination, 0);
982 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
984 gchar *destination = NULL;
985 gint action_type = 0;
988 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
989 account_id = atoi($2);
991 action = filteringaction_new(action_type, account_id, destination, 0);
993 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
995 gchar *destination = NULL;
996 gint action_type = 0;
999 action_type = MATCHACTION_REDIRECT;
1000 account_id = atoi($2);
1002 action = filteringaction_new(action_type, account_id, destination, 0);
1004 | MATCHER_COLOR MATCHER_INTEGER
1006 gint action_type = 0;
1009 action_type = MATCHACTION_COLOR;
1011 action = filteringaction_new(action_type, 0, NULL, color);
1013 | MATCHER_CHANGE_SCORE MATCHER_STRING
1015 gint action_type = MATCHACTION_CHANGE_SCORE;
1016 char *last_tok = NULL;
1017 const gchar *first_tok;
1019 int change_type; /* -1 == decrement, 0 == assign, 1 == increment */
1021 #define is_number(x) ( ((x) == '+') || ((x) == '-') || (isdigit((x))) )
1023 for (first_tok = $2; *first_tok && !is_number(*first_tok); first_tok++)
1027 chscore = strtol(first_tok, &last_tok, 10);
1028 if (last_tok == first_tok || *last_tok == 0)
1030 change_type = *first_tok == '+' ? 1 : *first_tok == '-' ? -1 : 0;
1031 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, change_type,
1037 MATCHER_SCORE MATCHER_INTEGER