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(const 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(const 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(const 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(const 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(const 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_EXECUTE MATCHER_NOT_EXECUTE 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_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
252 %token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL MATCHER_STRING
253 %token MATCHER_OR MATCHER_AND
254 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT
255 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
256 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
257 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
258 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
259 %token MATCHER_CHANGE_SCORE
263 %token <str> MATCHER_STRING
264 %token <str> MATCHER_SECTION
265 %token <str> MATCHER_INTEGER
271 if (matcher_parse_op == MATCHER_PARSE_NONE) {
272 prefs_scoring = &global_scoring;
273 prefs_filtering = &global_processing;
287 { action_list = NULL; }
294 section_notification:
295 MATCHER_SECTION MATCHER_EOL
298 FolderItem *item = NULL;
300 if (matcher_parse_op == MATCHER_PARSE_NONE) {
301 if (!strcmp(folder, "global")) {
302 prefs_scoring = &global_scoring;
303 prefs_filtering = &global_processing;
305 item = folder_find_item_from_identifier(folder);
307 prefs_scoring = &item->prefs->scoring;
308 prefs_filtering = &item->prefs->processing;
310 prefs_scoring = NULL;
311 prefs_filtering = NULL;
319 condition filtering_or_scoring MATCHER_EOL
320 | condition filtering_or_scoring
322 if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
325 matcher_parsererror("parse error");
331 if (matcher_parse_op == MATCHER_PARSE_CONDITION)
334 matcher_parsererror("parse error");
338 | filtering_action_list
340 if (matcher_parse_op == MATCHER_PARSE_FILTERING_OR_SCORING)
343 matcher_parsererror("parse error");
350 filtering_or_scoring:
351 filtering_action_list
353 filtering = filteringprop_new(cond, action_list);
356 if ((matcher_parse_op == MATCHER_PARSE_NONE) && (prefs_filtering != NULL)) {
357 *prefs_filtering = g_slist_append(*prefs_filtering,
364 scoring = scoringprop_new(cond, score);
367 if ((matcher_parse_op == MATCHER_PARSE_NONE)
368 && (prefs_scoring != NULL)) {
369 *prefs_scoring = g_slist_append(*prefs_scoring, scoring);
375 filtering_action_list:
376 filtering_action_b filtering_action_list
383 action_list = g_slist_append(action_list, action);
391 match_type = MATCHTYPE_MATCHCASE;
395 match_type = MATCHTYPE_MATCH;
399 match_type = MATCHTYPE_REGEXPCASE;
403 match_type = MATCHTYPE_REGEXP;
410 cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
411 matchers_list = NULL;
416 condition_list bool_op one_condition
418 matchers_list = g_slist_append(matchers_list, prop);
422 matchers_list = NULL;
423 matchers_list = g_slist_append(matchers_list, prop);
430 bool_op = MATCHERBOOL_AND;
434 bool_op = MATCHERBOOL_OR;
443 criteria = MATCHCRITERIA_ALL;
444 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
450 criteria = MATCHCRITERIA_UNREAD;
451 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
457 criteria = MATCHCRITERIA_NOT_UNREAD;
458 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
464 criteria = MATCHCRITERIA_NEW;
465 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
471 criteria = MATCHCRITERIA_NOT_NEW;
472 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
478 criteria = MATCHCRITERIA_MARKED;
479 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
485 criteria = MATCHCRITERIA_NOT_MARKED;
486 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
492 criteria = MATCHCRITERIA_DELETED;
493 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
495 | MATCHER_NOT_DELETED
499 criteria = MATCHCRITERIA_NOT_DELETED;
500 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
506 criteria = MATCHCRITERIA_REPLIED;
507 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
509 | MATCHER_NOT_REPLIED
513 criteria = MATCHCRITERIA_NOT_REPLIED;
514 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
520 criteria = MATCHCRITERIA_FORWARDED;
521 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
523 | MATCHER_NOT_FORWARDED
527 criteria = MATCHCRITERIA_NOT_FORWARDED;
528 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
534 criteria = MATCHCRITERIA_LOCKED;
535 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
541 criteria = MATCHCRITERIA_NOT_LOCKED;
542 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
544 | MATCHER_COLORLABEL MATCHER_INTEGER
549 criteria = MATCHCRITERIA_COLORLABEL;
551 if (value < 1) value = 1;
552 else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
553 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
555 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
560 criteria = MATCHCRITERIA_NOT_COLORLABEL;
562 if (value < 1) value = 1;
563 else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
564 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
566 | MATCHER_IGNORE_THREAD
570 criteria = MATCHCRITERIA_IGNORE_THREAD;
571 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
573 | MATCHER_NOT_IGNORE_THREAD
577 criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
578 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
580 | MATCHER_SUBJECT match_type MATCHER_STRING
585 criteria = MATCHCRITERIA_SUBJECT;
587 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
589 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
594 criteria = MATCHCRITERIA_NOT_SUBJECT;
596 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
598 | MATCHER_FROM match_type MATCHER_STRING
603 criteria = MATCHCRITERIA_FROM;
605 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
607 | MATCHER_NOT_FROM match_type MATCHER_STRING
612 criteria = MATCHCRITERIA_NOT_FROM;
614 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
616 | MATCHER_TO match_type MATCHER_STRING
621 criteria = MATCHCRITERIA_TO;
623 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
625 | MATCHER_NOT_TO match_type MATCHER_STRING
630 criteria = MATCHCRITERIA_NOT_TO;
632 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
634 | MATCHER_CC match_type MATCHER_STRING
639 criteria = MATCHCRITERIA_CC;
641 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
643 | MATCHER_NOT_CC match_type MATCHER_STRING
648 criteria = MATCHCRITERIA_NOT_CC;
650 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
652 | MATCHER_TO_OR_CC match_type MATCHER_STRING
657 criteria = MATCHCRITERIA_TO_OR_CC;
659 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
661 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
666 criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
668 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
670 | MATCHER_AGE_GREATER MATCHER_INTEGER
675 criteria = MATCHCRITERIA_AGE_GREATER;
677 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
679 | MATCHER_AGE_LOWER MATCHER_INTEGER
684 criteria = MATCHCRITERIA_AGE_LOWER;
686 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
688 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
693 criteria = MATCHCRITERIA_NEWSGROUPS;
695 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
697 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
702 criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
704 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
706 | MATCHER_INREPLYTO match_type MATCHER_STRING
711 criteria = MATCHCRITERIA_INREPLYTO;
713 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
715 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
720 criteria = MATCHCRITERIA_NOT_INREPLYTO;
722 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
724 | MATCHER_REFERENCES match_type MATCHER_STRING
729 criteria = MATCHCRITERIA_REFERENCES;
731 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
733 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
738 criteria = MATCHCRITERIA_NOT_REFERENCES;
740 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
742 | MATCHER_SCORE_GREATER MATCHER_INTEGER
747 criteria = MATCHCRITERIA_SCORE_GREATER;
749 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
751 | MATCHER_SCORE_LOWER MATCHER_INTEGER
756 criteria = MATCHCRITERIA_SCORE_LOWER;
758 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
760 | MATCHER_SCORE_EQUAL MATCHER_INTEGER
765 criteria = MATCHCRITERIA_SCORE_EQUAL;
767 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
769 | MATCHER_SIZE_GREATER MATCHER_INTEGER
773 criteria = MATCHCRITERIA_SIZE_GREATER;
775 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
777 | MATCHER_SIZE_SMALLER MATCHER_INTEGER
781 criteria = MATCHCRITERIA_SIZE_SMALLER;
783 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
785 | MATCHER_SIZE_EQUAL MATCHER_INTEGER
789 criteria = MATCHCRITERIA_SIZE_EQUAL;
791 prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
793 | MATCHER_HEADER MATCHER_STRING
795 header = g_strdup($2);
796 } match_type MATCHER_STRING
801 criteria = MATCHCRITERIA_HEADER;
803 prop = matcherprop_unquote_new(criteria, header, match_type, expr, 0);
806 | MATCHER_NOT_HEADER MATCHER_STRING
808 header = g_strdup($2);
809 } match_type MATCHER_STRING
814 criteria = MATCHCRITERIA_NOT_HEADER;
816 prop = matcherprop_unquote_new(criteria, header, match_type, expr, 0);
819 | MATCHER_HEADERS_PART match_type MATCHER_STRING
824 criteria = MATCHCRITERIA_HEADERS_PART;
826 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
828 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
833 criteria = MATCHCRITERIA_NOT_HEADERS_PART;
835 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
837 | MATCHER_MESSAGE match_type MATCHER_STRING
842 criteria = MATCHCRITERIA_MESSAGE;
844 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
846 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
851 criteria = MATCHCRITERIA_NOT_MESSAGE;
853 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
855 | MATCHER_BODY_PART match_type MATCHER_STRING
860 criteria = MATCHCRITERIA_BODY_PART;
862 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
864 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
869 criteria = MATCHCRITERIA_NOT_BODY_PART;
871 prop = matcherprop_unquote_new(criteria, NULL, match_type, expr, 0);
873 | MATCHER_EXECUTE MATCHER_STRING
878 criteria = MATCHCRITERIA_EXECUTE;
880 prop = matcherprop_unquote_new(criteria, NULL, 0, expr, 0);
882 | MATCHER_NOT_EXECUTE MATCHER_STRING
887 criteria = MATCHCRITERIA_NOT_EXECUTE;
889 prop = matcherprop_unquote_new(criteria, NULL, 0, expr, 0);
894 MATCHER_EXECUTE MATCHER_STRING
897 gint action_type = 0;
899 action_type = MATCHACTION_EXECUTE;
901 action = filteringaction_new(action_type, 0, cmd, 0);
903 | MATCHER_MOVE MATCHER_STRING
905 gchar *destination = NULL;
906 gint action_type = 0;
908 action_type = MATCHACTION_MOVE;
910 action = filteringaction_new(action_type, 0, destination, 0);
912 | MATCHER_COPY MATCHER_STRING
914 gchar *destination = NULL;
915 gint action_type = 0;
917 action_type = MATCHACTION_COPY;
919 action = filteringaction_new(action_type, 0, destination, 0);
923 gint action_type = 0;
925 action_type = MATCHACTION_DELETE;
926 action = filteringaction_new(action_type, 0, NULL, 0);
930 gint action_type = 0;
932 action_type = MATCHACTION_MARK;
933 action = filteringaction_new(action_type, 0, NULL, 0);
937 gint action_type = 0;
939 action_type = MATCHACTION_UNMARK;
940 action = filteringaction_new(action_type, 0, NULL, 0);
944 gint action_type = 0;
946 action_type = MATCHACTION_LOCK;
947 action = filteringaction_new(action_type, 0, NULL, 0);
951 gint action_type = 0;
953 action_type = MATCHACTION_UNLOCK;
954 action = filteringaction_new(action_type, 0, NULL, 0);
956 | MATCHER_MARK_AS_READ
958 gint action_type = 0;
960 action_type = MATCHACTION_MARK_AS_READ;
961 action = filteringaction_new(action_type, 0, NULL, 0);
963 | MATCHER_MARK_AS_UNREAD
965 gint action_type = 0;
967 action_type = MATCHACTION_MARK_AS_UNREAD;
968 action = filteringaction_new(action_type, 0, NULL, 0);
970 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
972 gchar *destination = NULL;
973 gint action_type = 0;
976 action_type = MATCHACTION_FORWARD;
977 account_id = atoi($2);
979 action = filteringaction_new(action_type, account_id, destination, 0);
981 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
983 gchar *destination = NULL;
984 gint action_type = 0;
987 action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
988 account_id = atoi($2);
990 action = filteringaction_new(action_type, account_id, destination, 0);
992 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
994 gchar *destination = NULL;
995 gint action_type = 0;
998 action_type = MATCHACTION_REDIRECT;
999 account_id = atoi($2);
1001 action = filteringaction_new(action_type, account_id, destination, 0);
1003 | MATCHER_COLOR MATCHER_INTEGER
1005 gint action_type = 0;
1008 action_type = MATCHACTION_COLOR;
1010 action = filteringaction_new(action_type, 0, NULL, color);
1012 | MATCHER_CHANGE_SCORE MATCHER_STRING
1014 gint action_type = MATCHACTION_CHANGE_SCORE;
1015 char *last_tok = NULL;
1016 const gchar *first_tok;
1018 int change_type; /* -1 == decrement, 0 == assign, 1 == increment */
1020 #define is_number(x) ( ((x) == '+') || ((x) == '-') || (isdigit((x))) )
1022 for (first_tok = $2; *first_tok && !is_number(*first_tok); first_tok++)
1026 chscore = strtol(first_tok, &last_tok, 10);
1027 if (last_tok == first_tok || *last_tok == 0)
1029 change_type = *first_tok == '+' ? 1 : *first_tok == '-' ? -1 : 0;
1030 action = filteringaction_new(MATCHACTION_CHANGE_SCORE, change_type,
1036 MATCHER_SCORE MATCHER_INTEGER