new matcher config file parser
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Sun, 8 Jul 2001 15:34:02 +0000 (15:34 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Sun, 8 Jul 2001 15:34:02 +0000 (15:34 +0000)
20 files changed:
ChangeLog.claws
src/.cvsignore
src/Makefile.am
src/filtering.c
src/filtering.h
src/inc.c
src/main.c
src/matcher.c
src/matcher.h
src/matcher_parser.h [new file with mode: 0644]
src/matcher_parser_lex.h [new file with mode: 0644]
src/matcher_parser_lex.l [new file with mode: 0644]
src/matcher_parser_parse.y [new file with mode: 0644]
src/mbox.c
src/prefs_filtering.c
src/prefs_matcher.c
src/prefs_scoring.c
src/scoring.c
src/scoring.h
src/summaryview.c

index 6c21fdf..f19c7c1 100644 (file)
@@ -1,3 +1,33 @@
+2001-07-08 [hoa]
+
+       * src/Makefile.am
+       * src/.cvsignore
+               added new config file parser
+
+       * src/scoring.c
+       * src/scoring.h
+       * src/filtering.c
+       * src/filtering.h
+       * src/matcher.c
+       * src/matcher.h
+       * src/prefs_filtering.c
+       * src/prefs_matcher.c
+       * src/prefs_scoring.c
+       * added src/matcher_parser.h
+       * added src/matcher_parser_lex.h
+       * added src/matcher_parser_lex.l
+       * added src/matcher_parser_parse.y
+               lex & yacc config file parser
+
+       * src/mbox.c
+       * src/inc.c
+       * src/main.c
+               changes prefs_filtering into global_filtering           
+
+       * src/summaryview.c
+               build threads with subjects only if "Re: " is at the
+               beginning of the subject
+
 2001-07-07 [paul]
 
        0.5.0claws
index 4f06dc2..69a7305 100644 (file)
@@ -9,3 +9,6 @@ TAGS
 quote_fmt_lex.c
 quote_fmt_parse.c
 quote_fmt_parse.h
+matcher_parser_lex.c
+matcher_parser_parse.c
+matcher_parser_parse.h
index 19be929..6ce4098 100644 (file)
@@ -89,6 +89,8 @@ sylpheed_SOURCES = \
        mbox_folder.c mbox_folder.h \
        quote_fmt_lex.l quote_fmt_lex.h \
        quote_fmt_parse.y quote_fmt.h \
+       matcher_parser_lex.l matcher_parser_lex.h \
+       matcher_parser_parse.y matcher_parser.h \
        addressitem.h \
        mgutils.c mgutils.h \
        vcard.c vcard.h \
index 4fa8e09..056c487 100644 (file)
 #include "filtering.h"
 #include "prefs.h"
 #include "compose.h"
+#include "matcher_parser.h"
 
 #define PREFSBUFSIZE           1024
 
-GSList * prefs_filtering = NULL;
+/* GSList * prefs_filtering = NULL; */
+GSList * global_filtering = NULL;
 
 FilteringAction * filteringaction_new(int type, int account_id,
                                      gchar * destination)
@@ -39,6 +41,7 @@ void filteringaction_free(FilteringAction * action)
        g_free(action);
 }
 
+/*
 FilteringAction * filteringaction_parse(gchar ** str)
 {
        FilteringAction * action;
@@ -131,7 +134,7 @@ FilteringProp * filteringprop_parse(gchar ** str)
        * str = tmp;
        return filtering;
 }
-
+*/
 
 FilteringProp * filteringprop_new(MatcherList * matchers,
                                  FilteringAction * action)
@@ -352,7 +355,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
        gchar * cmd;
 
        switch(action->type) {
-       case MATCHING_ACTION_MOVE:
+       case MATCHACTION_MOVE:
                dest_folder =
                        folder_find_item_from_identifier(action->destination);
                if (!dest_folder)
@@ -383,7 +386,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHING_ACTION_COPY:
+       case MATCHACTION_COPY:
                dest_folder =
                        folder_find_item_from_identifier(action->destination);
                if (!dest_folder)
@@ -404,7 +407,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                        
                return TRUE;
 
-       case MATCHING_ACTION_DELETE:
+       case MATCHACTION_DELETE:
                if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
                        return FALSE;
 
@@ -413,7 +416,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHING_ACTION_MARK:
+       case MATCHACTION_MARK:
                MSG_SET_FLAGS(info->flags, MSG_MARKED);
                filteringaction_update_mark(info);
 
@@ -421,7 +424,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHING_ACTION_UNMARK:
+       case MATCHACTION_UNMARK:
                MSG_UNSET_FLAGS(info->flags, MSG_MARKED);
                filteringaction_update_mark(info);
 
@@ -429,7 +432,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
                
-       case MATCHING_ACTION_MARK_AS_READ:
+       case MATCHACTION_MARK_AS_READ:
                MSG_UNSET_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                filteringaction_update_mark(info);
 
@@ -437,7 +440,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHING_ACTION_MARK_AS_UNREAD:
+       case MATCHACTION_MARK_AS_UNREAD:
                MSG_SET_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                filteringaction_update_mark(info);
 
@@ -445,7 +448,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                
                return TRUE;
 
-       case MATCHING_ACTION_FORWARD:
+       case MATCHACTION_FORWARD:
 
                account = account_find_from_id(action->account_id);
                compose = compose_forward(account, info, FALSE);
@@ -465,7 +468,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                gtk_widget_destroy(compose->window);
                return FALSE;
 
-       case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
+       case MATCHACTION_FORWARD_AS_ATTACHMENT:
 
                account = account_find_from_id(action->account_id);
                compose = compose_forward(account, info, TRUE);
@@ -485,7 +488,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                gtk_widget_destroy(compose->window);
                return FALSE;
 
-       case MATCHING_EXECUTE:
+       case MATCHACTION_EXECUTE:
 
                cmd = matching_build_command(action->destination, info);
                if (cmd == NULL)
@@ -533,17 +536,17 @@ static gboolean filteringprop_apply(FilteringProp * filtering, MsgInfo * info,
                g_free(action_str);
 
                switch(filtering->action->type) {
-               case MATCHING_ACTION_MOVE:
-               case MATCHING_ACTION_DELETE:
+               case MATCHACTION_MOVE:
+               case MATCHACTION_DELETE:
                        return TRUE;
-               case MATCHING_EXECUTE:
-               case MATCHING_ACTION_COPY:
-               case MATCHING_ACTION_MARK:
-               case MATCHING_ACTION_MARK_AS_READ:
-               case MATCHING_ACTION_UNMARK:
-               case MATCHING_ACTION_MARK_AS_UNREAD:
-               case MATCHING_ACTION_FORWARD:
-               case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
+               case MATCHACTION_EXECUTE:
+               case MATCHACTION_COPY:
+               case MATCHACTION_MARK:
+               case MATCHACTION_MARK_AS_READ:
+               case MATCHACTION_UNMARK:
+               case MATCHACTION_MARK_AS_UNREAD:
+               case MATCHACTION_FORWARD:
+               case MATCHACTION_FORWARD_AS_ATTACHMENT:
                        return FALSE;
                default:
                        return FALSE;
@@ -585,8 +588,8 @@ void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
                FilteringProp * filtering = (FilteringProp *) l->data;
 
                switch (filtering->action->type) {
-               case MATCHING_ACTION_MOVE:
-               case MATCHING_ACTION_DELETE:
+               case MATCHACTION_MOVE:
+               case MATCHACTION_DELETE:
                        if (filteringprop_apply(filtering, info, folder_table))
                                return;
                }
@@ -626,6 +629,34 @@ void filter_message(GSList * filtering_list, FolderItem * item,
        filter_msginfo(filtering_list, msginfo, folder_table);
 }
 
+void prefs_filtering_read_config(void)
+{
+       gchar *rcpath;
+       FILE *fp;
+
+       prefs_filtering_clear();
+
+       debug_print(_("Reading filtering configuration...\n"));
+
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+                            FILTERING_RC, NULL);
+       if ((fp = fopen(rcpath, "r")) == NULL) {
+               if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
+               g_free(rcpath);
+               return;
+       }
+
+       matcher_parserlineno = 1;
+       matcher_parserin = fp;
+       if (matcher_parserparse() != 0) {
+               printf("%s\n", rcpath);
+               prefs_filtering_clear();
+       }
+       g_free(rcpath);
+       fclose(fp);
+}
+
+/*
 void prefs_filtering_read_config(void)
 {
        gchar *rcpath;
@@ -643,8 +674,10 @@ void prefs_filtering_read_config(void)
                return;
        }
        g_free(rcpath);
+*/
 
        /* remove all filtering */
+/*
        while (prefs_filtering != NULL) {
                FilteringProp * filtering =
                        (FilteringProp *) prefs_filtering->data;
@@ -659,6 +692,8 @@ void prefs_filtering_read_config(void)
                g_strchomp(buf);
 
                if ((*buf != '#') && (*buf != '\0')) {
+                       matcher_parse(buf);
+
                        tmp = buf;
                        filtering = filteringprop_parse(&tmp);
                        if (tmp != NULL) {
@@ -667,7 +702,9 @@ void prefs_filtering_read_config(void)
                                                       filtering);
                        }
                        else {
+*/
                                /* debug */
+/*
                                g_warning(_("syntax error : %s\n"), buf);
                        }
                }
@@ -675,6 +712,7 @@ void prefs_filtering_read_config(void)
 
        fclose(fp);
 }
+*/
 
 gchar * filteringaction_to_string(FilteringAction * action)
 {
@@ -683,28 +721,28 @@ gchar * filteringaction_to_string(FilteringAction * action)
        gchar * account_id_str;
 
        command_str = NULL;
-       command_str = get_matchparser_tab_str(action->type);
+       command_str = get_matchaction_str(action->type);
 
        if (command_str == NULL)
                return NULL;
 
        switch(action->type) {
-       case MATCHING_ACTION_MOVE:
-       case MATCHING_ACTION_COPY:
-       case MATCHING_EXECUTE:
+       case MATCHACTION_MOVE:
+       case MATCHACTION_COPY:
+       case MATCHACTION_EXECUTE:
                return g_strconcat(command_str, " \"", action->destination,
                                   "\"", NULL);
 
-       case MATCHING_ACTION_DELETE:
-       case MATCHING_ACTION_MARK:
-       case MATCHING_ACTION_UNMARK:
-       case MATCHING_ACTION_MARK_AS_READ:
-       case MATCHING_ACTION_MARK_AS_UNREAD:
+       case MATCHACTION_DELETE:
+       case MATCHACTION_MARK:
+       case MATCHACTION_UNMARK:
+       case MATCHACTION_MARK_AS_READ:
+       case MATCHACTION_MARK_AS_UNREAD:
                return g_strdup(command_str);
                break;
 
-       case MATCHING_ACTION_FORWARD:
-       case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
+       case MATCHACTION_FORWARD:
+       case MATCHACTION_FORWARD_AS_ATTACHMENT:
                account_id_str = itos(action->account_id);
                return g_strconcat(command_str, " ", account_id_str,
                                   " \"", action->destination, "\"", NULL);
@@ -732,7 +770,7 @@ gchar * filteringprop_to_string(FilteringProp * prop)
                return NULL;
        }
 
-       filtering_str = g_strconcat(list_str, " ", action_str, NULL);
+       filtering_str = g_strconcat(list_str, " ", action_str, "\n", NULL);
        g_free(list_str);
        g_free(action_str);
 
@@ -756,14 +794,13 @@ void prefs_filtering_write_config(void)
                return;
        }
 
-       for (cur = prefs_filtering; cur != NULL; cur = cur->next) {
+       for (cur = global_filtering; cur != NULL; cur = cur->next) {
                gchar *filtering_str;
 
                prop = (FilteringProp *) cur->data;
                filtering_str = filteringprop_to_string(prop);
-               if (fputs(filtering_str, pfile->fp) == EOF ||
-                   fputc('\n', pfile->fp) == EOF) {
-                       FILE_OP_ERROR(rcpath, "fputs || fputc");
+               if (fputs(filtering_str, pfile->fp) == EOF) {
+                       FILE_OP_ERROR(rcpath, "fputs");
                        prefs_write_close_revert(pfile);
                        g_free(rcpath);
                        g_free(filtering_str);
@@ -779,3 +816,40 @@ void prefs_filtering_write_config(void)
                return;
        }
 }
+
+void prefs_filtering_free(GSList * prefs_filtering)
+{
+       while (prefs_filtering != NULL) {
+               FilteringProp * filtering =
+                       (FilteringProp *) prefs_filtering->data;
+               filteringprop_free(filtering);
+               prefs_filtering = g_slist_remove(prefs_filtering, filtering);
+       }
+}
+
+static gboolean prefs_filtering_free_func(GNode *node, gpointer data)
+{
+       FolderItem *item = node->data;
+
+       prefs_filtering_free(item->prefs->processing);
+       item->prefs->processing = NULL;
+
+       return FALSE;
+}
+
+
+void prefs_filtering_clear()
+{
+       GList * cur;
+
+       for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
+               Folder *folder;
+
+               folder = (Folder *) cur->data;
+               g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+                               prefs_filtering_free_func, NULL);
+       }
+
+       prefs_filtering_free(global_filtering);
+       global_filtering = NULL;
+}
index d4ef0c0..7cdd5e4 100644 (file)
@@ -21,20 +21,23 @@ struct _FilteringProp {
 
 typedef struct _FilteringProp FilteringProp;
 
-extern GSList * prefs_filtering;
+extern GSList * global_filtering;
 
 
 FilteringAction * filteringaction_new(int type, int account_id,
                                      gchar * destination);
 void filteringaction_free(FilteringAction * action);
+/*
 FilteringAction * filteringaction_parse(gchar ** str);
+*/
 
 FilteringProp * filteringprop_new(MatcherList * matchers,
                                  FilteringAction * action);
 void filteringprop_free(FilteringProp * prop);
 
+/*
 FilteringProp * filteringprop_parse(gchar ** str);
-
+*/
 
 void filter_msginfo(GSList * filtering_list, MsgInfo * info,
                    GHashTable *folder_table);
@@ -48,4 +51,6 @@ void prefs_filtering_write_config(void);
 void prefs_filtering_read_config(void);
 gchar * filteringprop_to_string(FilteringProp * prop);
 
+void prefs_filtering_clear();
+
 #endif
index 1e0b9c9..aac1acd 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -802,7 +802,7 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
                return -1;
        }
 
-       if (prefs_filtering == NULL) {
+       if (global_filtering == NULL) {
                /* old filtering */
                if (state->ac_prefs->filter_on_recv) {
                        dropfolder =
@@ -832,10 +832,10 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
                return -1;
        }
 
-       if (prefs_filtering != NULL) {
+       if (global_filtering != NULL) {
                /* new filtering */
                if (state->ac_prefs->filter_on_recv) {
-                       filter_message(prefs_filtering, dropfolder, msgnum,
+                       filter_message(global_filtering, dropfolder, msgnum,
                                       state->folder_table);
                }
        }
index 798b28a..b7bac27 100644 (file)
@@ -238,7 +238,6 @@ int main(int argc, char *argv[])
        prefs_filter_write_config();
        prefs_display_header_read_config();
        prefs_display_header_write_config();
-       prefs_filtering_read_config();
 
        gtkut_widget_init();
 
@@ -259,6 +258,7 @@ int main(int argc, char *argv[])
        account_set_missing_folder();
        folderview_set(folderview);
 
+       prefs_filtering_read_config();
        prefs_scoring_read_config();
 
        inc_autocheck_timer_init(mainwin);
index a43af9a..b72ba74 100644 (file)
@@ -7,6 +7,7 @@
 #include "procheader.h"
 #include "matcher.h"
 #include "intl.h"
+#include "matcher_parser.h"
 
 struct _MatchParser {
        gint id;
@@ -15,90 +16,114 @@ struct _MatchParser {
 
 typedef struct _MatchParser MatchParser;
 
-static MatchParser matchparser_tab[] = {
+static MatchParser matchcriteria_str_tab[] = {
        /* msginfo flags */
-       {MATCHING_ALL, "all"},
-       {MATCHING_UNREAD, "unread"},
-       {MATCHING_NOT_UNREAD, "~unread"},
-       {MATCHING_NEW, "new"},
-       {MATCHING_NOT_NEW, "~new"},
-       {MATCHING_MARKED, "marked"},
-       {MATCHING_NOT_MARKED, "~marked"},
-       {MATCHING_DELETED, "deleted"},
-       {MATCHING_NOT_DELETED, "~deleted"},
-       {MATCHING_REPLIED, "replied"},
-       {MATCHING_NOT_REPLIED, "~replied"},
-       {MATCHING_FORWARDED, "forwarded"},
-       {MATCHING_NOT_FORWARDED, "~forwarded"},
+       {MATCHCRITERIA_ALL, "all"},
+       {MATCHCRITERIA_UNREAD, "unread"},
+       {MATCHCRITERIA_NOT_UNREAD, "~unread"},
+       {MATCHCRITERIA_NEW, "new"},
+       {MATCHCRITERIA_NOT_NEW, "~new"},
+       {MATCHCRITERIA_MARKED, "marked"},
+       {MATCHCRITERIA_NOT_MARKED, "~marked"},
+       {MATCHCRITERIA_DELETED, "deleted"},
+       {MATCHCRITERIA_NOT_DELETED, "~deleted"},
+       {MATCHCRITERIA_REPLIED, "replied"},
+       {MATCHCRITERIA_NOT_REPLIED, "~replied"},
+       {MATCHCRITERIA_FORWARDED, "forwarded"},
+       {MATCHCRITERIA_NOT_FORWARDED, "~forwarded"},
 
        /* msginfo headers */
-       {MATCHING_SUBJECT, "subject"},
-       {MATCHING_NOT_SUBJECT, "~subject"},
-       {MATCHING_FROM, "from"},
-       {MATCHING_NOT_FROM, "~from"},
-       {MATCHING_TO, "to"},
-       {MATCHING_NOT_TO, "~to"},
-       {MATCHING_CC, "cc"},
-       {MATCHING_NOT_CC, "~cc"},
-       {MATCHING_TO_OR_CC, "to_or_cc"},
-       {MATCHING_NOT_TO_AND_NOT_CC, "~to_or_cc"},
-       {MATCHING_AGE_GREATER, "age_greater"},
-       {MATCHING_AGE_LOWER, "age_lower"},
-       {MATCHING_NEWSGROUPS, "newsgroups"},
-       {MATCHING_NOT_NEWSGROUPS, "~newsgroups"},
-       {MATCHING_INREPLYTO, "inreplyto"},
-       {MATCHING_NOT_INREPLYTO, "~inreplyto"},
-       {MATCHING_REFERENCES, "references"},
-       {MATCHING_NOT_REFERENCES, "~references"},
-       {MATCHING_SCORE_GREATER, "score_greater"},
-       {MATCHING_SCORE_LOWER, "score_lower"},
+       {MATCHCRITERIA_SUBJECT, "subject"},
+       {MATCHCRITERIA_NOT_SUBJECT, "~subject"},
+       {MATCHCRITERIA_FROM, "from"},
+       {MATCHCRITERIA_NOT_FROM, "~from"},
+       {MATCHCRITERIA_TO, "to"},
+       {MATCHCRITERIA_NOT_TO, "~to"},
+       {MATCHCRITERIA_CC, "cc"},
+       {MATCHCRITERIA_NOT_CC, "~cc"},
+       {MATCHCRITERIA_TO_OR_CC, "to_or_cc"},
+       {MATCHCRITERIA_NOT_TO_AND_NOT_CC, "~to_or_cc"},
+       {MATCHCRITERIA_AGE_GREATER, "age_greater"},
+       {MATCHCRITERIA_AGE_LOWER, "age_lower"},
+       {MATCHCRITERIA_NEWSGROUPS, "newsgroups"},
+       {MATCHCRITERIA_NOT_NEWSGROUPS, "~newsgroups"},
+       {MATCHCRITERIA_INREPLYTO, "inreplyto"},
+       {MATCHCRITERIA_NOT_INREPLYTO, "~inreplyto"},
+       {MATCHCRITERIA_REFERENCES, "references"},
+       {MATCHCRITERIA_NOT_REFERENCES, "~references"},
+       {MATCHCRITERIA_SCORE_GREATER, "score_greater"},
+       {MATCHCRITERIA_SCORE_LOWER, "score_lower"},
 
        /* content have to be read */
-       {MATCHING_HEADER, "header"},
-       {MATCHING_NOT_HEADER, "~header"},
-       {MATCHING_HEADERS_PART, "headers_part"},
-       {MATCHING_NOT_HEADERS_PART, "~headers_part"},
-       {MATCHING_MESSAGE, "message"},
-       {MATCHING_NOT_MESSAGE, "~message"},
-       {MATCHING_BODY_PART, "body_part"},
-       {MATCHING_NOT_BODY_PART, "~body_part"},
-       {MATCHING_EXECUTE, "execute"},
-       {MATCHING_NOT_EXECUTE, "~execute"},
+       {MATCHCRITERIA_HEADER, "header"},
+       {MATCHCRITERIA_NOT_HEADER, "~header"},
+       {MATCHCRITERIA_HEADERS_PART, "headers_part"},
+       {MATCHCRITERIA_NOT_HEADERS_PART, "~headers_part"},
+       {MATCHCRITERIA_MESSAGE, "message"},
+       {MATCHCRITERIA_NOT_MESSAGE, "~message"},
+       {MATCHCRITERIA_BODY_PART, "body_part"},
+       {MATCHCRITERIA_NOT_BODY_PART, "~body_part"},
+       {MATCHCRITERIA_EXECUTE, "execute"},
+       {MATCHCRITERIA_NOT_EXECUTE, "~execute"}
+};
 
+static MatchParser matchtype_str_tab[] = {
        /* match type */
-       {MATCHING_MATCHCASE, "matchcase"},
-       {MATCHING_MATCH, "match"},
-       {MATCHING_REGEXPCASE, "regexpcase"},
-       {MATCHING_REGEXP, "regexp"},
+       {MATCHTYPE_MATCHCASE, "matchcase"},
+       {MATCHTYPE_MATCH, "match"},
+       {MATCHTYPE_REGEXPCASE, "regexpcase"},
+       {MATCHTYPE_REGEXP, "regexp"}
+};
 
+static MatchParser matchaction_str_tab[] = {
        /* actions */
-       {MATCHING_SCORE, "score"},
+       {MATCHACTION_SCORE, "score"},
 
        /* actions */
-       {MATCHING_ACTION_MOVE, "move"},
-       {MATCHING_ACTION_COPY, "copy"},
-       {MATCHING_ACTION_DELETE, "delete"},
-       {MATCHING_ACTION_MARK, "mark"},
-       {MATCHING_ACTION_UNMARK, "unmark"},
-       {MATCHING_ACTION_MARK_AS_READ, "mark_as_read"},
-       {MATCHING_ACTION_MARK_AS_UNREAD, "mark_as_unread"},
-       {MATCHING_ACTION_FORWARD, "forward"},
-       {MATCHING_ACTION_FORWARD_AS_ATTACHMENT, "forward_as_attachment"},
-       /*      {MATCHING_EXECUTE, "execute"}, */
+       {MATCHACTION_MOVE, "move"},
+       {MATCHACTION_COPY, "copy"},
+       {MATCHACTION_DELETE, "delete"},
+       {MATCHACTION_MARK, "mark"},
+       {MATCHACTION_UNMARK, "unmark"},
+       {MATCHACTION_MARK_AS_READ, "mark_as_read"},
+       {MATCHACTION_MARK_AS_UNREAD, "mark_as_unread"},
+       {MATCHACTION_FORWARD, "forward"},
+       {MATCHACTION_FORWARD_AS_ATTACHMENT, "forward_as_attachment"},
+       {MATCHCRITERIA_EXECUTE, "execute"}
 };
 
-gchar * get_matchparser_tab_str(gint id)
+gchar * get_matchparser_str(MatchParser * tab, gint size, gint id)
 {
        gint i;
 
-       for(i = 0 ; i < (int) (sizeof(matchparser_tab) / sizeof(MatchParser)) ;
-           i++) {
-               if (matchparser_tab[i].id == id)
-                       return matchparser_tab[i].str;
+       for(i = 0 ; i < size ; i++) {
+               if (tab[i].id == id)
+                       return tab[i].str;
        }
        return NULL;
 }
 
+gchar * get_matchcriteria_str(gint id)
+{
+       return get_matchparser_str(matchcriteria_str_tab,
+                                  (int) (sizeof(matchcriteria_str_tab) /
+                                         sizeof(MatchParser)), id);
+}
+
+gchar * get_matchtype_str(gint id)
+{
+       return get_matchparser_str(matchtype_str_tab,
+                                  (int) (sizeof(matchtype_str_tab) /
+                                         sizeof(MatchParser)), id);
+}
+
+gchar * get_matchaction_str(gint id)
+{
+       return get_matchparser_str(matchaction_str_tab,
+                                  (int) (sizeof(matchaction_str_tab) /
+                                         sizeof(MatchParser)), id);
+}
+
 
 
 /*
@@ -120,6 +145,7 @@ static gboolean matcher_is_blank(gchar ch)
 
 /* parse for one condition */
 
+/*
 MatcherProp * matcherprop_parse(gchar ** str)
 {
        MatcherProp * prop;
@@ -138,10 +164,10 @@ MatcherProp * matcherprop_parse(gchar ** str)
        }
 
        switch (key) {
-       case MATCHING_AGE_LOWER:
-       case MATCHING_AGE_GREATER:
-       case MATCHING_SCORE_LOWER:
-       case MATCHING_SCORE_GREATER:
+       case MATCHCRITERIA_AGE_LOWER:
+       case MATCHCRITERIA_AGE_GREATER:
+       case MATCHCRITERIA_SCORE_LOWER:
+       case MATCHCRITERIA_SCORE_GREATER:
                value = matcher_parse_number(&tmp);
                if (tmp == NULL) {
                        * str = NULL;
@@ -153,51 +179,51 @@ MatcherProp * matcherprop_parse(gchar ** str)
 
                return prop;
 
-       case MATCHING_ALL:
-       case MATCHING_UNREAD:
-       case MATCHING_NOT_UNREAD:
-       case MATCHING_NEW:
-       case MATCHING_NOT_NEW:
-       case MATCHING_MARKED:
-       case MATCHING_NOT_MARKED:
-       case MATCHING_DELETED:
-       case MATCHING_NOT_DELETED:
-       case MATCHING_REPLIED:
-       case MATCHING_NOT_REPLIED:
-       case MATCHING_FORWARDED:
-       case MATCHING_NOT_FORWARDED:
+       case MATCHCRITERIA_ALL:
+       case MATCHCRITERIA_UNREAD:
+       case MATCHCRITERIA_NOT_UNREAD:
+       case MATCHCRITERIA_NEW:
+       case MATCHCRITERIA_NOT_NEW:
+       case MATCHCRITERIA_MARKED:
+       case MATCHCRITERIA_NOT_MARKED:
+       case MATCHCRITERIA_DELETED:
+       case MATCHCRITERIA_NOT_DELETED:
+       case MATCHCRITERIA_REPLIED:
+       case MATCHCRITERIA_NOT_REPLIED:
+       case MATCHCRITERIA_FORWARDED:
+       case MATCHCRITERIA_NOT_FORWARDED:
                prop = matcherprop_new(key, NULL, 0, NULL, 0);
                *str = tmp;
 
                return prop;
 
-       case MATCHING_SUBJECT:
-       case MATCHING_NOT_SUBJECT:
-       case MATCHING_FROM:
-       case MATCHING_NOT_FROM:
-       case MATCHING_TO:
-       case MATCHING_NOT_TO:
-       case MATCHING_CC:
-       case MATCHING_NOT_CC:
-       case MATCHING_TO_OR_CC:
-       case MATCHING_NOT_TO_AND_NOT_CC:
-       case MATCHING_NEWSGROUPS:
-       case MATCHING_NOT_NEWSGROUPS:
-       case MATCHING_INREPLYTO:
-       case MATCHING_NOT_REFERENCES:
-       case MATCHING_REFERENCES:
-       case MATCHING_NOT_INREPLYTO:
-       case MATCHING_MESSAGE:
-       case MATCHING_NOT_MESSAGE:
-       case MATCHING_EXECUTE:
-       case MATCHING_NOT_EXECUTE:
-       case MATCHING_HEADERS_PART:
-       case MATCHING_NOT_HEADERS_PART:
-       case MATCHING_BODY_PART:
-       case MATCHING_NOT_BODY_PART:
-       case MATCHING_HEADER:
-       case MATCHING_NOT_HEADER:
-               if ((key == MATCHING_HEADER) || (key == MATCHING_NOT_HEADER)) {
+       case MATCHCRITERIA_SUBJECT:
+       case MATCHCRITERIA_NOT_SUBJECT:
+       case MATCHCRITERIA_FROM:
+       case MATCHCRITERIA_NOT_FROM:
+       case MATCHCRITERIA_TO:
+       case MATCHCRITERIA_NOT_TO:
+       case MATCHCRITERIA_CC:
+       case MATCHCRITERIA_NOT_CC:
+       case MATCHCRITERIA_TO_OR_CC:
+       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
+       case MATCHCRITERIA_NEWSGROUPS:
+       case MATCHCRITERIA_NOT_NEWSGROUPS:
+       case MATCHCRITERIA_INREPLYTO:
+       case MATCHCRITERIA_NOT_REFERENCES:
+       case MATCHCRITERIA_REFERENCES:
+       case MATCHCRITERIA_NOT_INREPLYTO:
+       case MATCHCRITERIA_MESSAGE:
+       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHCRITERIA_EXECUTE:
+       case MATCHCRITERIA_NOT_EXECUTE:
+       case MATCHCRITERIA_HEADERS_PART:
+       case MATCHCRITERIA_NOT_HEADERS_PART:
+       case MATCHCRITERIA_BODY_PART:
+       case MATCHCRITERIA_NOT_BODY_PART:
+       case MATCHCRITERIA_HEADER:
+       case MATCHCRITERIA_NOT_HEADER:
+               if ((key == MATCHCRITERIA_HEADER) || (key == MATCHCRITERIA_NOT_HEADER)) {
                        header = matcher_parse_str(&tmp);
                        if (tmp == NULL) {
                                * str = NULL;
@@ -214,8 +240,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
                }
 
                switch(match) {
-               case MATCHING_REGEXP:
-               case MATCHING_REGEXPCASE:
+               case MATCHCRITERIA_REGEXP:
+               case MATCHCRITERIA_REGEXPCASE:
                        expr = matcher_parse_regexp(&tmp);
                        if (tmp == NULL) {
                                if (header)
@@ -228,8 +254,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
                        g_free(expr);
 
                        return prop;
-               case MATCHING_MATCH:
-               case MATCHING_MATCHCASE:
+               case MATCHCRITERIA_MATCH:
+               case MATCHCRITERIA_MATCHCASE:
                        expr = matcher_parse_str(&tmp);
                        if (tmp == NULL) {
                                if (header)
@@ -417,6 +443,7 @@ gchar * matcher_parse_str(gchar ** str)
        *str += dest - dup + 2;
        return g_strdup(start);
 }
+*/
 
 /* **************** data structure allocation **************** */
 
@@ -470,13 +497,14 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
                return FALSE;
 
        switch(prop->matchtype) {
-       case MATCHING_REGEXPCASE:
-       case MATCHING_REGEXP:
+       case MATCHTYPE_REGEXPCASE:
+       case MATCHTYPE_REGEXP:
                if (!prop->preg && (prop->error == 0)) {
                        prop->preg = g_new0(regex_t, 1);
                        if (regcomp(prop->preg, prop->expr,
                                    REG_NOSUB | REG_EXTENDED
-                                   | ((prop->matchtype == MATCHING_REGEXPCASE)
+                                   | ((prop->matchtype ==
+                                       MATCHTYPE_REGEXPCASE)
                                    ? REG_ICASE : 0)) != 0) {
                                prop->error = 1;
                                g_free(prop->preg);
@@ -490,10 +518,10 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
                else
                        return FALSE;
 
-       case MATCHING_MATCH:
+       case MATCHTYPE_MATCH:
                return (strstr(str, prop->expr) != NULL);
 
-       case MATCHING_MATCHCASE:
+       case MATCHTYPE_MATCHCASE:
                str2 = alloca(strlen(prop->expr) + 1);
                strcpy(str2, prop->expr);
                g_strup(str2);
@@ -531,79 +559,79 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
        time_t t;
 
        switch(prop->criteria) {
-       case MATCHING_ALL:
+       case MATCHCRITERIA_ALL:
                return 1;
-       case MATCHING_UNREAD:
+       case MATCHCRITERIA_UNREAD:
                return MSG_IS_UNREAD(info->flags);
-       case MATCHING_NOT_UNREAD:
+       case MATCHCRITERIA_NOT_UNREAD:
                return !MSG_IS_UNREAD(info->flags);
-       case MATCHING_NEW:
+       case MATCHCRITERIA_NEW:
                return MSG_IS_NEW(info->flags);
-       case MATCHING_NOT_NEW:
+       case MATCHCRITERIA_NOT_NEW:
                return !MSG_IS_NEW(info->flags);
-       case MATCHING_MARKED:
+       case MATCHCRITERIA_MARKED:
                return MSG_IS_MARKED(info->flags);
-       case MATCHING_NOT_MARKED:
+       case MATCHCRITERIA_NOT_MARKED:
                return !MSG_IS_MARKED(info->flags);
-       case MATCHING_DELETED:
+       case MATCHCRITERIA_DELETED:
                return MSG_IS_DELETED(info->flags);
-       case MATCHING_NOT_DELETED:
+       case MATCHCRITERIA_NOT_DELETED:
                return !MSG_IS_DELETED(info->flags);
-       case MATCHING_REPLIED:
+       case MATCHCRITERIA_REPLIED:
                return MSG_IS_REPLIED(info->flags);
-       case MATCHING_NOT_REPLIED:
+       case MATCHCRITERIA_NOT_REPLIED:
                return !MSG_IS_REPLIED(info->flags);
-       case MATCHING_FORWARDED:
+       case MATCHCRITERIA_FORWARDED:
                return MSG_IS_FORWARDED(info->flags);
-       case MATCHING_NOT_FORWARDED:
+       case MATCHCRITERIA_NOT_FORWARDED:
                return !MSG_IS_FORWARDED(info->flags);
-       case MATCHING_SUBJECT:
+       case MATCHCRITERIA_SUBJECT:
                return matcherprop_string_match(prop, info->subject);
-       case MATCHING_NOT_SUBJECT:
+       case MATCHCRITERIA_NOT_SUBJECT:
                return !matcherprop_string_match(prop, info->subject);
-       case MATCHING_FROM:
+       case MATCHCRITERIA_FROM:
                return matcherprop_string_match(prop, info->from);
-       case MATCHING_NOT_FROM:
+       case MATCHCRITERIA_NOT_FROM:
                return !matcherprop_string_match(prop, info->from);
-       case MATCHING_TO:
+       case MATCHCRITERIA_TO:
                return matcherprop_string_match(prop, info->to);
-       case MATCHING_NOT_TO:
+       case MATCHCRITERIA_NOT_TO:
                return !matcherprop_string_match(prop, info->to);
-       case MATCHING_CC:
+       case MATCHCRITERIA_CC:
                return matcherprop_string_match(prop, info->cc);
-       case MATCHING_NOT_CC:
+       case MATCHCRITERIA_NOT_CC:
                return !matcherprop_string_match(prop, info->cc);
-       case MATCHING_TO_OR_CC:
+       case MATCHCRITERIA_TO_OR_CC:
                return matcherprop_string_match(prop, info->to)
                        || matcherprop_string_match(prop, info->cc);
-       case MATCHING_NOT_TO_AND_NOT_CC:
+       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
                return !(matcherprop_string_match(prop, info->to)
                || matcherprop_string_match(prop, info->cc));
-       case MATCHING_AGE_GREATER:
+       case MATCHCRITERIA_AGE_GREATER:
                t = time(NULL);
                return ((t - info->date_t) / (60 * 60 * 24)) >= prop->value;
-       case MATCHING_AGE_LOWER:
+       case MATCHCRITERIA_AGE_LOWER:
                t = time(NULL);
                return ((t - info->date_t) / (60 * 60 * 24)) <= prop->value;
-       case MATCHING_SCORE_GREATER:
+       case MATCHCRITERIA_SCORE_GREATER:
                return info->score >= prop->value;
-       case MATCHING_SCORE_LOWER:
+       case MATCHCRITERIA_SCORE_LOWER:
                return info->score <= prop->value;
-       case MATCHING_NEWSGROUPS:
+       case MATCHCRITERIA_NEWSGROUPS:
                return matcherprop_string_match(prop, info->newsgroups);
-       case MATCHING_NOT_NEWSGROUPS:
+       case MATCHCRITERIA_NOT_NEWSGROUPS:
                return !matcherprop_string_match(prop, info->newsgroups);
-       case MATCHING_INREPLYTO:
+       case MATCHCRITERIA_INREPLYTO:
                return matcherprop_string_match(prop, info->inreplyto);
-       case MATCHING_NOT_INREPLYTO:
+       case MATCHCRITERIA_NOT_INREPLYTO:
                return !matcherprop_string_match(prop, info->inreplyto);
-       case MATCHING_REFERENCES:
+       case MATCHCRITERIA_REFERENCES:
                return matcherprop_string_match(prop, info->references);
-       case MATCHING_NOT_REFERENCES:
+       case MATCHCRITERIA_NOT_REFERENCES:
                return !matcherprop_string_match(prop, info->references);
-       case MATCHING_EXECUTE:
+       case MATCHCRITERIA_EXECUTE:
                return matcherprop_match_execute(prop, info);
-       case MATCHING_NOT_EXECUTE:
+       case MATCHCRITERIA_NOT_EXECUTE:
                return !matcherprop_match_execute(prop, info);
        default:
                return 0;
@@ -615,6 +643,7 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
 
 /* parse for a list of conditions */
 
+/*
 MatcherList * matcherlist_parse(gchar ** str)
 {
        gchar * tmp;
@@ -667,6 +696,7 @@ MatcherList * matcherlist_parse(gchar ** str)
 
        return cond;
 }
+*/
 
 MatcherList * matcherlist_new(GSList * matchers, gboolean bool_and)
 {
@@ -714,14 +744,14 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
        Header *header;
 
        switch(matcher->criteria) {
-       case MATCHING_HEADER:
-       case MATCHING_NOT_HEADER:
+       case MATCHCRITERIA_HEADER:
+       case MATCHCRITERIA_NOT_HEADER:
                header = procheader_parse_header(buf);
                if (!header)
                        return FALSE;
                if (procheader_headername_equal(header->name,
                                                matcher->header)) {
-                       if (matcher->criteria == MATCHING_HEADER)
+                       if (matcher->criteria == MATCHCRITERIA_HEADER)
                                result = matcherprop_string_match(matcher, header->body);
                        else
                                result = !matcherprop_string_match(matcher, header->body);
@@ -732,11 +762,11 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
                        procheader_header_free(header);
                }
                break;
-       case MATCHING_HEADERS_PART:
-       case MATCHING_MESSAGE:
+       case MATCHCRITERIA_HEADERS_PART:
+       case MATCHCRITERIA_MESSAGE:
                return matcherprop_string_match(matcher, buf);
-       case MATCHING_NOT_MESSAGE:
-       case MATCHING_NOT_HEADERS_PART:
+       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHCRITERIA_NOT_HEADERS_PART:
                return !matcherprop_string_match(matcher, buf);
        }
        return FALSE;
@@ -750,10 +780,10 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
 static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
 {
        switch(matcher->criteria) {
-       case MATCHING_HEADER:
-       case MATCHING_NOT_HEADER:
-       case MATCHING_HEADERS_PART:
-       case MATCHING_NOT_HEADERS_PART:
+       case MATCHCRITERIA_HEADER:
+       case MATCHCRITERIA_NOT_HEADER:
+       case MATCHCRITERIA_HEADERS_PART:
+       case MATCHCRITERIA_NOT_HEADERS_PART:
                return TRUE;
        default:
                return FALSE;
@@ -763,8 +793,8 @@ static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
 static gboolean matcherprop_criteria_message(MatcherProp * matcher)
 {
        switch(matcher->criteria) {
-       case MATCHING_MESSAGE:
-       case MATCHING_NOT_MESSAGE:
+       case MATCHCRITERIA_MESSAGE:
+       case MATCHCRITERIA_NOT_MESSAGE:
                return TRUE;
        default:
                return FALSE;
@@ -826,8 +856,8 @@ static gboolean matcherlist_match_headers(MatcherList * matchers, FILE * fp)
 static gboolean matcherprop_criteria_body(MatcherProp * matcher)
 {
        switch(matcher->criteria) {
-       case MATCHING_BODY_PART:
-       case MATCHING_NOT_BODY_PART:
+       case MATCHCRITERIA_BODY_PART:
+       case MATCHCRITERIA_NOT_BODY_PART:
                return TRUE;
        default:
                return FALSE;
@@ -842,11 +872,11 @@ static gboolean matcherprop_criteria_body(MatcherProp * matcher)
 static gboolean matcherprop_match_line(MatcherProp * matcher, gchar * line)
 {
        switch(matcher->criteria) {
-       case MATCHING_BODY_PART:
-       case MATCHING_MESSAGE:
+       case MATCHCRITERIA_BODY_PART:
+       case MATCHCRITERIA_MESSAGE:
                return matcherprop_string_match(matcher, line);
-       case MATCHING_NOT_BODY_PART:
-       case MATCHING_NOT_MESSAGE:
+       case MATCHCRITERIA_NOT_BODY_PART:
+       case MATCHCRITERIA_NOT_MESSAGE:
                return !matcherprop_string_match(matcher, line);
        }
        return FALSE;
@@ -995,41 +1025,41 @@ gboolean matcherlist_match(MatcherList * matchers, MsgInfo * info)
                MatcherProp * matcher = (MatcherProp *) l->data;
 
                switch(matcher->criteria) {
-               case MATCHING_ALL:
-               case MATCHING_UNREAD:
-               case MATCHING_NOT_UNREAD:
-               case MATCHING_NEW:
-               case MATCHING_NOT_NEW:
-               case MATCHING_MARKED:
-               case MATCHING_NOT_MARKED:
-               case MATCHING_DELETED:
-               case MATCHING_NOT_DELETED:
-               case MATCHING_REPLIED:
-               case MATCHING_NOT_REPLIED:
-               case MATCHING_FORWARDED:
-               case MATCHING_NOT_FORWARDED:
-               case MATCHING_SUBJECT:
-               case MATCHING_NOT_SUBJECT:
-               case MATCHING_FROM:
-               case MATCHING_NOT_FROM:
-               case MATCHING_TO:
-               case MATCHING_NOT_TO:
-               case MATCHING_CC:
-               case MATCHING_NOT_CC:
-               case MATCHING_TO_OR_CC:
-               case MATCHING_NOT_TO_AND_NOT_CC:
-               case MATCHING_AGE_GREATER:
-               case MATCHING_AGE_LOWER:
-               case MATCHING_NEWSGROUPS:
-               case MATCHING_NOT_NEWSGROUPS:
-               case MATCHING_INREPLYTO:
-               case MATCHING_NOT_INREPLYTO:
-               case MATCHING_REFERENCES:
-               case MATCHING_NOT_REFERENCES:
-               case MATCHING_SCORE_GREATER:
-               case MATCHING_SCORE_LOWER:
-               case MATCHING_EXECUTE:
-               case MATCHING_NOT_EXECUTE:
+               case MATCHCRITERIA_ALL:
+               case MATCHCRITERIA_UNREAD:
+               case MATCHCRITERIA_NOT_UNREAD:
+               case MATCHCRITERIA_NEW:
+               case MATCHCRITERIA_NOT_NEW:
+               case MATCHCRITERIA_MARKED:
+               case MATCHCRITERIA_NOT_MARKED:
+               case MATCHCRITERIA_DELETED:
+               case MATCHCRITERIA_NOT_DELETED:
+               case MATCHCRITERIA_REPLIED:
+               case MATCHCRITERIA_NOT_REPLIED:
+               case MATCHCRITERIA_FORWARDED:
+               case MATCHCRITERIA_NOT_FORWARDED:
+               case MATCHCRITERIA_SUBJECT:
+               case MATCHCRITERIA_NOT_SUBJECT:
+               case MATCHCRITERIA_FROM:
+               case MATCHCRITERIA_NOT_FROM:
+               case MATCHCRITERIA_TO:
+               case MATCHCRITERIA_NOT_TO:
+               case MATCHCRITERIA_CC:
+               case MATCHCRITERIA_NOT_CC:
+               case MATCHCRITERIA_TO_OR_CC:
+               case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
+               case MATCHCRITERIA_AGE_GREATER:
+               case MATCHCRITERIA_AGE_LOWER:
+               case MATCHCRITERIA_NEWSGROUPS:
+               case MATCHCRITERIA_NOT_NEWSGROUPS:
+               case MATCHCRITERIA_INREPLYTO:
+               case MATCHCRITERIA_NOT_INREPLYTO:
+               case MATCHCRITERIA_REFERENCES:
+               case MATCHCRITERIA_NOT_REFERENCES:
+               case MATCHCRITERIA_SCORE_GREATER:
+               case MATCHCRITERIA_SCORE_LOWER:
+               case MATCHCRITERIA_EXECUTE:
+               case MATCHCRITERIA_NOT_EXECUTE:
                        if (matcherprop_match(matcher, info)) {
                                if (!matchers->bool_and) {
                                        return TRUE;
@@ -1068,16 +1098,16 @@ static void matcherprop_print(MatcherProp * matcher)
        }
 
        switch (matcher->matchtype) {
-       case MATCHING_MATCH:
+       case MATCHCRITERIA_MATCH:
                printf("match\n");
                break;
-       case MATCHING_REGEXP:
+       case MATCHCRITERIA_REGEXP:
                printf("regexp\n");
                break;
-       case MATCHING_MATCHCASE:
+       case MATCHCRITERIA_MATCHCASE:
                printf("matchcase\n");
                break;
-       case MATCHING_REGEXPCASE:
+       case MATCHCRITERIA_REGEXPCASE:
                printf("regexpcase\n");
                break;
        }
@@ -1110,96 +1140,73 @@ gchar * matcherprop_to_string(MatcherProp * matcher)
        gchar * out;
 
        criteria_str = NULL;
-       for(i = 0 ; i < (int) (sizeof(matchparser_tab) / sizeof(MatchParser)) ;
-           i++) {
-               if (matchparser_tab[i].id == matcher->criteria)
-                       criteria_str = matchparser_tab[i].str;
-       }
+
+       criteria_str = get_matchcriteria_str(matcher->criteria);
+
        if (criteria_str == NULL)
                return NULL;
 
        switch(matcher->criteria) {
-       case MATCHING_AGE_GREATER:
-       case MATCHING_AGE_LOWER:
-       case MATCHING_SCORE_GREATER:
-       case MATCHING_SCORE_LOWER:
+       case MATCHCRITERIA_AGE_GREATER:
+       case MATCHCRITERIA_AGE_LOWER:
+       case MATCHCRITERIA_SCORE_GREATER:
+       case MATCHCRITERIA_SCORE_LOWER:
                return g_strdup_printf("%s %i", criteria_str, matcher->value);
                break;
-       case MATCHING_ALL:
-       case MATCHING_UNREAD:
-       case MATCHING_NOT_UNREAD:
-       case MATCHING_NEW:
-       case MATCHING_NOT_NEW:
-       case MATCHING_MARKED:
-       case MATCHING_NOT_MARKED:
-       case MATCHING_DELETED:
-       case MATCHING_NOT_DELETED:
-       case MATCHING_REPLIED:
-       case MATCHING_NOT_REPLIED:
-       case MATCHING_FORWARDED:
-       case MATCHING_NOT_FORWARDED:
+       case MATCHCRITERIA_ALL:
+       case MATCHCRITERIA_UNREAD:
+       case MATCHCRITERIA_NOT_UNREAD:
+       case MATCHCRITERIA_NEW:
+       case MATCHCRITERIA_NOT_NEW:
+       case MATCHCRITERIA_MARKED:
+       case MATCHCRITERIA_NOT_MARKED:
+       case MATCHCRITERIA_DELETED:
+       case MATCHCRITERIA_NOT_DELETED:
+       case MATCHCRITERIA_REPLIED:
+       case MATCHCRITERIA_NOT_REPLIED:
+       case MATCHCRITERIA_FORWARDED:
+       case MATCHCRITERIA_NOT_FORWARDED:
                return g_strdup(criteria_str);
        }
 
        matchtype_str = NULL;
-       for(i = 0 ; i < (int) (sizeof(matchparser_tab) / sizeof(MatchParser)) ;
-           i++) {
-               if (matchparser_tab[i].id == matcher->matchtype)
-                       matchtype_str = matchparser_tab[i].str;
-       }
+
+       matchtype_str = get_matchtype_str(matcher->matchtype);
 
        if (matchtype_str == NULL)
                return NULL;
 
-       switch (matcher->matchtype) {
-       case MATCHING_MATCH:
-       case MATCHING_MATCHCASE:
-               count = 0;
-               for(p = matcher->expr; *p != 0 ; p++)
-                       if (*p == '\"') count ++;
-               
-               expr_str = g_new(char, strlen(matcher->expr) + count + 1);
-
-               for(p = matcher->expr, out = expr_str ; *p != 0 ; p++, out++) {
-                       if (*p == '\"') {
-                               *out = '\\'; out++;
-                               *out = '\"';
-                       }
-                       else
-                               *out = *p;
+       count = 0;
+       for(p = matcher->expr; *p != 0 ; p++)
+               if (*p == '\"') count ++;
+       
+       expr_str = g_new(char, strlen(matcher->expr) + count + 1);
+       
+       for(p = matcher->expr, out = expr_str ; *p != 0 ; p++, out++) {
+               switch (*p) {
+               case '\"':
+               case '\\':
+                       *out = '\\'; out++;
+                       *out = '\"';
+                       break;
+               default:
+                       *out = *p;
                }
-               * out = '\0';
-
-               if (matcher->header)
-                       matcher_str =
-                               g_strdup_printf("%s \"%s\" %s \"%s\"",
-                                          criteria_str, matcher->header,
-                                          matchtype_str, expr_str);
-               else
-                       matcher_str =
-                               g_strdup_printf("%s %s \"%s\"", criteria_str,
-                                               matchtype_str, expr_str);
-               
-               g_free(expr_str);
-               
-               break;
-
-       case MATCHING_REGEXP:
-       case MATCHING_REGEXPCASE:
-
-               if (matcher->header)
-                       matcher_str =
-                               g_strdup_printf("%s \"%s\" %s /%s/",
-                                               criteria_str, matcher->header,
-                                               matchtype_str, matcher->expr);
-               else
-                       matcher_str =
-                               g_strdup_printf("%s %s /%s/", criteria_str,
-                                               matchtype_str, matcher->expr);
-
-               break;
        }
-
+       * out = '\0';
+       
+       if (matcher->header)
+               matcher_str =
+                       g_strdup_printf("%s \"%s\" %s \"%s\"",
+                                       criteria_str, matcher->header,
+                                       matchtype_str, expr_str);
+       else
+               matcher_str =
+                       g_strdup_printf("%s %s \"%s\"", criteria_str,
+                                       matchtype_str, expr_str);
+       
+       g_free(expr_str);
+               
        return matcher_str;
 }
 
@@ -1382,14 +1389,3 @@ gchar * matching_build_command(gchar * cmd, MsgInfo * info)
        }
        return processed_cmd;
 }
-
-
-/* ************************************************************ */
-
-/*
-static void matcher_parse              (gchar * str)
-{
-       matcher_parser_scan_string(str);
-       matcher_parserparse();
-}
-*/
index 6afad95..12ce5db 100644 (file)
@@ -7,8 +7,11 @@
 #include <glib.h>
 #include "procmsg.h"
 
+/*
 enum {
+*/
        /* msginfo flags */
+/*
        MATCHING_ALL,
        MATCHING_UNREAD,
        MATCHING_NOT_UNREAD,
@@ -22,8 +25,9 @@ enum {
        MATCHING_NOT_REPLIED,
        MATCHING_FORWARDED,
        MATCHING_NOT_FORWARDED,
-
+*/
        /* msginfo headers */
+/*
        MATCHING_SUBJECT,
        MATCHING_NOT_SUBJECT,
        MATCHING_FROM,
@@ -44,8 +48,9 @@ enum {
        MATCHING_NOT_REFERENCES,
        MATCHING_SCORE_GREATER,
        MATCHING_SCORE_LOWER,
-
+*/
        /* file content */
+/*
        MATCHING_HEADER,
        MATCHING_NOT_HEADER,
        MATCHING_MESSAGE,
@@ -56,11 +61,13 @@ enum {
        MATCHING_NOT_BODY_PART,
        MATCHING_EXECUTE,
        MATCHING_NOT_EXECUTE,
-
+*/
        /* scoring */
+/*
        MATCHING_SCORE,
-
+*/
        /* filtering */
+/*
        MATCHING_ACTION_MOVE,
        MATCHING_ACTION_COPY,
        MATCHING_ACTION_DELETE,
@@ -70,13 +77,15 @@ enum {
        MATCHING_ACTION_MARK_AS_UNREAD,
        MATCHING_ACTION_FORWARD,
        MATCHING_ACTION_FORWARD_AS_ATTACHMENT,
+*/
        /* MATCHING_ACTION_EXECUTE, */
-
+/*
        MATCHING_MATCH,
        MATCHING_REGEXP,
        MATCHING_MATCHCASE,
        MATCHING_REGEXPCASE
 };
+*/
 
 struct _MatcherProp {
        int matchtype;
@@ -103,21 +112,27 @@ MatcherProp * matcherprop_new(gint criteria, gchar * header,
                              gint matchtype, gchar * expr,
                              int age);
 void matcherprop_free(MatcherProp * prop);
+/*
 MatcherProp * matcherprop_parse(gchar ** str);
+*/
 
 gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info);
 
 MatcherList * matcherlist_new(GSList * matchers, gboolean bool_and);
 void matcherlist_free(MatcherList * cond);
+/*
 MatcherList * matcherlist_parse(gchar ** str);
+*/
 
 gboolean matcherlist_match(MatcherList * cond, MsgInfo * info);
 
+/*
 gint matcher_parse_keyword(gchar ** str);
 gint matcher_parse_number(gchar ** str);
 gboolean matcher_parse_boolean_op(gchar ** str);
 gchar * matcher_parse_regexp(gchar ** str);
 gchar * matcher_parse_str(gchar ** str);
+*/
 gchar * matcherprop_to_string(MatcherProp * matcher);
 gchar * matcherlist_to_string(MatcherList * matchers);
 gchar * matching_build_command(gchar * cmd, MsgInfo * info);
diff --git a/src/matcher_parser.h b/src/matcher_parser.h
new file mode 100644 (file)
index 0000000..85b4fac
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef MATCHER_PARSER_H
+
+#define MATCHER_PARSER_H
+
+#include "filtering.h"
+#include "scoring.h"
+#include <glib.h>
+
+#define MATCHER_BUF_SIZE 16384
+
+enum {
+       MATCHTYPE_MATCH,
+       MATCHTYPE_MATCHCASE,
+       MATCHTYPE_REGEXP,
+       MATCHTYPE_REGEXPCASE
+};
+
+enum {
+MATCHCRITERIA_ALL,
+MATCHCRITERIA_UNREAD, MATCHCRITERIA_NOT_UNREAD,
+MATCHCRITERIA_NEW, MATCHCRITERIA_NOT_NEW,
+MATCHCRITERIA_MARKED, MATCHCRITERIA_NOT_MARKED,
+MATCHCRITERIA_DELETED, MATCHCRITERIA_NOT_DELETED,
+MATCHCRITERIA_REPLIED, MATCHCRITERIA_NOT_REPLIED,
+MATCHCRITERIA_FORWARDED, MATCHCRITERIA_NOT_FORWARDED,
+MATCHCRITERIA_SUBJECT, MATCHCRITERIA_NOT_SUBJECT,
+MATCHCRITERIA_FROM, MATCHCRITERIA_NOT_FROM,
+MATCHCRITERIA_TO, MATCHCRITERIA_NOT_TO,
+MATCHCRITERIA_CC, MATCHCRITERIA_NOT_CC,
+MATCHCRITERIA_TO_OR_CC, MATCHCRITERIA_NOT_TO_AND_NOT_CC,
+MATCHCRITERIA_AGE_GREATER, MATCHCRITERIA_AGE_LOWER,
+MATCHCRITERIA_NEWSGROUPS, MATCHCRITERIA_NOT_NEWSGROUPS,
+MATCHCRITERIA_INREPLYTO, MATCHCRITERIA_NOT_INREPLYTO,
+MATCHCRITERIA_REFERENCES, MATCHCRITERIA_NOT_REFERENCES,
+MATCHCRITERIA_SCORE_GREATER, MATCHCRITERIA_SCORE_LOWER,
+MATCHCRITERIA_HEADER, MATCHCRITERIA_NOT_HEADER,
+MATCHCRITERIA_HEADERS_PART, MATCHCRITERIA_NOT_HEADERS_PART,
+MATCHCRITERIA_MESSAGE, MATCHCRITERIA_NOT_MESSAGE,
+MATCHCRITERIA_BODY_PART, MATCHCRITERIA_NOT_BODY_PART,
+MATCHCRITERIA_EXECUTE, MATCHCRITERIA_NOT_EXECUTE
+};
+
+enum {
+       MATCHACTION_SCORE,
+       MATCHACTION_EXECUTE,
+       MATCHACTION_MOVE,
+       MATCHACTION_COPY,
+       MATCHACTION_DELETE,
+       MATCHACTION_MARK,
+       MATCHACTION_UNMARK,
+       MATCHACTION_MARK_AS_READ,
+       MATCHACTION_MARK_AS_UNREAD,
+       MATCHACTION_FORWARD,
+       MATCHACTION_FORWARD_AS_ATTACHMENT
+};
+
+enum {
+       MATCHERBOOL_OR,
+       MATCHERBOOL_AND,
+};     
+
+extern FILE *matcher_parserin;
+extern int matcher_parserlineno;
+
+int matcher_parserparse(void);
+/* void matcher_parser_init();*/
+MatcherList * matcher_parser_get_cond(gchar * str);
+FilteringProp * matcher_parser_get_filtering(gchar * str);
+ScoringProp * matcher_parser_get_scoring(gchar * str);
+
+#endif
diff --git a/src/matcher_parser_lex.h b/src/matcher_parser_lex.h
new file mode 100644 (file)
index 0000000..4c3dade
--- /dev/null
@@ -0,0 +1,47 @@
+/* The following defines shamelessly stolen from GDB sources... */
+
+/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
+   as well as gratuitiously global symbol names, so we can have multiple
+   yacc generated parsers in gdb.  Note that these are only the variables
+   produced by yacc.  If other parser generators (bison, byacc, etc) produce
+   additional global names that conflict at link time, then those parser
+   generators need to be fixed instead of adding those names to this list. */
+
+#define        yymaxdepth matcher_parsermaxdepth
+#define        yyparse matcher_parserparse
+#define        yylex   matcher_parserlex
+#define        yyerror matcher_parsererror
+#define        yylval  matcher_parserlval
+#define        yychar  matcher_parserchar
+#define        yydebug matcher_parserdebug
+#define        yypact  matcher_parserpact      
+#define        yyr1    matcher_parserr1                        
+#define        yyr2    matcher_parserr2                        
+#define        yydef   matcher_parserdef               
+#define        yychk   matcher_parserchk               
+#define        yypgo   matcher_parserpgo               
+#define        yyact   matcher_parseract               
+#define        yyexca  matcher_parserexca
+#define yyerrflag matcher_parsererrflag
+#define yynerrs        matcher_parsernerrs
+#define        yyps    matcher_parserps
+#define        yypv    matcher_parserpv
+#define        yys     matcher_parsers
+#define        yy_yys  matcher_parseryys
+#define        yystate matcher_parserstate
+#define        yytmp   matcher_parsertmp
+#define        yyv     matcher_parserv
+#define        yy_yyv  matcher_parseryyv
+#define        yyval   matcher_parserval
+#define        yylloc  matcher_parserlloc
+#define yyreds matcher_parserreds              /* With YYDEBUG defined */
+#define yytoks matcher_parsertoks              /* With YYDEBUG defined */
+#define yylhs  matcher_parseryylhs
+#define yylen  matcher_parseryylen
+#define yydefred matcher_parseryydefred
+#define yydgoto        matcher_parseryydgoto
+#define yysindex matcher_parseryysindex
+#define yyrindex matcher_parseryyrindex
+#define yygindex matcher_parseryygindex
+#define yytable         matcher_parseryytable
+#define yycheck         matcher_parseryycheck
diff --git a/src/matcher_parser_lex.l b/src/matcher_parser_lex.l
new file mode 100644 (file)
index 0000000..f3b7a55
--- /dev/null
@@ -0,0 +1,116 @@
+%{
+#include "matcher_parser_lex.h"
+#include "matcher_parser_parse.h"
+#include <glib.h>
+
+#define MAX_STR_CONST 512
+
+char string_buf[MAX_STR_CONST];
+char * string_buf_ptr;
+
+static void add_char(char ch)
+{
+       if (string_buf_ptr - string_buf < sizeof(string_buf))
+               *string_buf_ptr++ = ch;
+}
+%}
+
+%option prefix="matcher_parser"
+%option outfile="lex.yy.c"
+%option yylineno
+
+%x string
+%x section
+
+%%
+
+"all"          return MATCHER_ALL;
+"unread"       return MATCHER_UNREAD;
+"~unread"      return MATCHER_NOT_UNREAD;
+"new"          return MATCHER_NEW;
+"~new"         return MATCHER_NOT_NEW;
+"marked"       return MATCHER_MARKED;
+"~marked"      return MATCHER_NOT_MARKED;
+"deleted"      return MATCHER_DELETED;
+"~deleted"     return MATCHER_NOT_DELETED;
+"replied"      return MATCHER_REPLIED;
+"~replied"     return MATCHER_NOT_REPLIED;
+"forwarded"    return MATCHER_FORWARDED;
+"~forwarded"   return MATCHER_NOT_FORWARDED;
+"subject"      return MATCHER_SUBJECT;
+"~subject"     return MATCHER_NOT_SUBJECT;
+"from"         return MATCHER_FROM;
+"~from"                return MATCHER_NOT_FROM;
+"to"           return MATCHER_TO;
+"~to"          return MATCHER_NOT_TO;
+"cc"           return MATCHER_CC;
+"~cc"          return MATCHER_NOT_CC;
+"to_or_cc"     return MATCHER_TO_OR_CC;
+"~to_or_cc"    return MATCHER_NOT_TO_AND_NOT_CC;
+"age_greater"  return MATCHER_AGE_GREATER;
+"age_lower"    return MATCHER_AGE_LOWER;
+"newsgroups"   return MATCHER_NEWSGROUPS;
+"~newsgroups"  return MATCHER_NOT_NEWSGROUPS;
+"inreplyto"    return MATCHER_INREPLYTO;
+"~inreplyto"   return MATCHER_NOT_INREPLYTO;
+"references"   return MATCHER_REFERENCES;
+"~references"  return MATCHER_NOT_REFERENCES;
+"score_greater"        return MATCHER_SCORE_GREATER;
+"score_lower"  return MATCHER_SCORE_LOWER;
+"header"       return MATCHER_HEADER;
+"~header"      return MATCHER_NOT_HEADER;
+"headers_part" return MATCHER_HEADERS_PART;
+"~headers_part"        return MATCHER_NOT_HEADERS_PART;
+"message"      return MATCHER_MESSAGE;
+"~message"     return MATCHER_NOT_MESSAGE;
+"body_part"    return MATCHER_BODY_PART;
+"~body_part"   return MATCHER_NOT_BODY_PART;
+"execute"      return MATCHER_EXECUTE;
+"~execute"     return MATCHER_NOT_EXECUTE;
+"matchcase"    return MATCHER_MATCHCASE;
+"match"                return MATCHER_MATCH;
+"regexpcase"   return MATCHER_REGEXPCASE;
+"regexp"       return MATCHER_REGEXP;
+"score"                return MATCHER_SCORE;
+"move"         return MATCHER_MOVE;
+"copy"         return MATCHER_COPY;
+"delete"       return MATCHER_DELETE;
+"mark"         return MATCHER_MARK;
+"unmark"       return MATCHER_UNMARK;
+"mark_as_read" return MATCHER_MARK_AS_READ;
+"mark_as_unread"       return MATCHER_MARK_AS_UNREAD;
+"forward"             return MATCHER_FORWARD;
+"forward_as_attachment"              return MATCHER_FORWARD_AS_ATTACHMENT;
+[ \t]+
+"\n"           return MATCHER_EOL;
+"&"            return MATCHER_AND;
+"|"            return MATCHER_OR;
+\"             {
+               BEGIN(string);
+               string_buf_ptr = string_buf;
+               }
+<string>\\n    add_char('\n');
+<string>\\t    add_char('\t');
+<string>\\r    add_char('\r');
+<string>\\b    add_char('\b');
+<string>\\f    add_char('\f');
+<string>\\.    add_char(yytext[1]);
+<string>\"     {
+               BEGIN(0);
+               *string_buf_ptr = '\0';
+               yylval.str = string_buf;
+               return MATCHER_STRING;
+               }
+<string>.      add_char(yytext[0]);
+\[[^\[\]]*\]   {
+                       BEGIN(0);
+                       yylval.str = yytext + 1;
+                       yytext[strlen(yytext) - 1] = '\0';
+                       return MATCHER_SECTION;
+                       }
+[-+]?[0-9]+    {
+               yylval.str = yytext;
+               return MATCHER_INTEGER;
+               }
+
+%%
diff --git a/src/matcher_parser_parse.y b/src/matcher_parser_parse.y
new file mode 100644 (file)
index 0000000..5031a8c
--- /dev/null
@@ -0,0 +1,751 @@
+%{
+#include "filtering.h"
+#include "scoring.h"
+#include "matcher.h"
+#include "matcher_parser.h"
+#include "matcher_parser_lex.h"
+#include "intl.h"
+#include <glib.h>
+
+static gint error = 0;
+static gint bool_op = 0;
+static gint match_type = 0;
+static gchar * header = NULL;
+
+static MatcherProp * prop;
+
+static GSList * matchers_list = NULL;
+
+static MatcherList * cond;
+static gint score = 0;
+static FilteringAction * action = NULL;
+
+static FilteringProp *  filtering;
+static ScoringProp * scoring = NULL;
+
+static GSList ** prefs_scoring = NULL;
+static GSList ** prefs_filtering = NULL;
+
+static int matcher_parser_dialog = 0;
+
+/*
+void matcher_parser_init()
+{
+       prefs_filtering_clear();
+       prefs_scoring_clear();
+}
+*/
+
+FilteringProp * matcher_parser_get_filtering(gchar * str)
+{
+       matcher_parserlineno = 1;
+       matcher_parser_dialog = 1;
+       matcher_parser_scan_string(str);
+       matcher_parserparse();
+       matcher_parser_dialog = 0;
+       return filtering;
+}
+
+ScoringProp * matcher_parser_get_scoring(gchar * str)
+{
+       matcher_parserlineno = 1;
+       matcher_parser_dialog = 1;
+       matcher_parser_scan_string(str);
+       matcher_parserparse();
+       matcher_parser_dialog = 0;
+       return scoring;
+}
+
+MatcherList * matcher_parser_get_cond(gchar * str)
+{
+       matcher_parserlineno = 1;
+       matcher_parser_dialog = 1;
+       matcher_parser_scan_string(str);
+       matcher_parserparse();
+       matcher_parser_dialog = 0;
+       return cond;
+}
+
+MatcherProp * matcher_parser_get_prop(gchar * str)
+{
+       MatcherList * list;
+       MatcherProp * prop;
+
+       printf("get matcher\n");
+
+       matcher_parserlineno = 1;
+       list = matcher_parser_get_cond(str);
+       if (list == NULL)
+               return NULL;
+
+       if (list->matchers == NULL)
+               return NULL;
+
+       if (list->matchers->next != NULL)
+               return NULL;
+
+       prop = list->matchers->data;
+
+       g_slist_free(list->matchers);
+       g_free(list);
+
+       printf("prop: %p\n", prop);
+}
+
+void matcher_parsererror(char * str)
+{
+       GSList * l;
+
+       if (matchers_list) {
+               for(l = matchers_list ; l != NULL ;
+                   l = g_slist_next(l))
+                       matcherprop_free((MatcherProp *)
+                                        l->data);
+               g_slist_free(matchers_list);
+               matchers_list = NULL;
+       }
+
+       g_warning(_("scoring / filtering parsing: %i: %s\n"),
+                 matcher_parserlineno, str);
+       error = 1;
+}
+
+int matcher_parserwrap(void)
+{
+       return 1;
+}
+%}
+
+%union {
+       char * str;
+       int value;
+}
+
+%token MATCHER_ALL MATCHER_UNREAD  MATCHER_NOT_UNREAD 
+%token MATCHER_NEW  MATCHER_NOT_NEW  MATCHER_MARKED
+%token MATCHER_NOT_MARKED  MATCHER_DELETED  MATCHER_NOT_DELETED
+%token MATCHER_REPLIED  MATCHER_NOT_REPLIED  MATCHER_FORWARDED
+%token MATCHER_NOT_FORWARDED  MATCHER_SUBJECT  MATCHER_NOT_SUBJECT
+%token MATCHER_FROM  MATCHER_NOT_FROM  MATCHER_TO  MATCHER_NOT_TO
+%token MATCHER_CC  MATCHER_NOT_CC  MATCHER_TO_OR_CC  MATCHER_NOT_TO_AND_NOT_CC
+%token MATCHER_AGE_GREATER  MATCHER_AGE_LOWER  MATCHER_NEWSGROUPS
+%token MATCHER_NOT_NEWSGROUPS  MATCHER_INREPLYTO  MATCHER_NOT_INREPLYTO
+%token MATCHER_REFERENCES  MATCHER_NOT_REFERENCES  MATCHER_SCORE_GREATER
+%token MATCHER_SCORE_LOWER  MATCHER_HEADER  MATCHER_NOT_HEADER
+%token MATCHER_HEADERS_PART  MATCHER_NOT_HEADERS_PART  MATCHER_MESSAGE
+%token MATCHER_NOT_MESSAGE  MATCHER_BODY_PART  MATCHER_NOT_BODY_PART
+%token MATCHER_EXECUTE  MATCHER_NOT_EXECUTE  MATCHER_MATCHCASE  MATCHER_MATCH
+%token MATCHER_REGEXPCASE  MATCHER_REGEXP  MATCHER_SCORE  MATCHER_MOVE
+%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK
+%token MATCHER_MARK_AS_READ  MATCHER_MARK_AS_UNREAD  MATCHER_FORWARD
+%token MATCHER_FORWARD_AS_ATTACHMENT  MATCHER_EOL  MATCHER_STRING  
+%token MATCHER_OR MATCHER_AND  
+
+%start file
+
+%token <str> MATCHER_STRING
+%token <str> MATCHER_SECTION
+%token <value> MATCHER_INTEGER
+
+%%
+
+file:
+{
+       if (!matcher_parser_dialog) {
+               prefs_scoring = &global_scoring;
+               prefs_filtering = &global_filtering;
+       }
+}
+file_line_list;
+
+file_line_list:
+file_line
+file_line_list
+| file_line
+;
+
+file_line:
+section_notification
+| instruction
+;
+
+section_notification:
+MATCHER_SECTION MATCHER_EOL
+{
+       gchar * folder = $1;
+       FolderItem * item = NULL;
+
+       if (!matcher_parser_dialog) {
+               item = folder_find_item_from_identifier(folder);
+               if (item == NULL) {
+                       prefs_scoring = &global_scoring;
+                       prefs_filtering = &global_scoring;
+               }
+               else {
+                       prefs_scoring = &item->prefs->scoring;
+                       prefs_filtering = &item->prefs->processing;
+               }
+       }
+}
+;
+
+instruction:
+condition filtering_or_scoring MATCHER_EOL
+| condition
+{
+       if (!matcher_parser_dialog) {
+               yyerror("parse error");
+               return 1;
+       }
+}
+| MATCHER_EOL
+;
+
+filtering_or_scoring:
+filtering_action
+{
+       filtering = filteringprop_new(cond, action);
+       cond = NULL;
+       action = NULL;
+       if (!matcher_parser_dialog) {
+               * prefs_filtering = g_slist_append(* prefs_filtering,
+                                                  filtering);
+               filtering = NULL;
+       }
+}
+| scoring_rule
+{
+       scoring = scoringprop_new(cond, score);
+       cond = NULL;
+       score = 0;
+       if (!matcher_parser_dialog) {
+               * prefs_scoring = g_slist_append(* prefs_scoring, scoring);
+               scoring = NULL;
+       }
+}
+;
+
+match_type:
+MATCHER_MATCHCASE
+{
+       match_type = MATCHTYPE_MATCHCASE;
+}
+| MATCHER_MATCH
+{
+       match_type = MATCHTYPE_MATCH;
+}
+| MATCHER_REGEXPCASE
+{
+       match_type = MATCHTYPE_REGEXPCASE;
+}
+| MATCHER_REGEXP
+{
+       match_type = MATCHTYPE_REGEXP;
+}
+;
+
+condition:
+condition_list
+{
+       cond = matcherlist_new(matchers_list, (bool_op == MATCHERBOOL_AND));
+       matchers_list = NULL;
+}
+;
+
+condition_list:
+condition_list bool_op one_condition
+{
+       matchers_list = g_slist_append(matchers_list, prop);
+}
+| one_condition
+{
+       matchers_list = NULL;
+       matchers_list = g_slist_append(matchers_list, prop);
+}
+;
+
+bool_op:
+MATCHER_AND
+{
+       bool_op = MATCHERBOOL_AND;
+}
+| MATCHER_OR
+{
+       bool_op = MATCHERBOOL_OR;
+}
+;
+
+one_condition:
+MATCHER_ALL
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_ALL;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_UNREAD
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_UNREAD;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_UNREAD 
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_UNREAD;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NEW
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NEW;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_NEW
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_NEW;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_MARKED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_MARKED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_MARKED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_MARKED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_DELETED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_DELETED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_DELETED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_DELETED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_REPLIED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_REPLIED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_REPLIED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_REPLIED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_FORWARDED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_FORWARDED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_FORWARDED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_FORWARDED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_SUBJECT match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_SUBJECT;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_SUBJECT match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_SUBJECT;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_FROM match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_FROM;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_FROM match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_FROM;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_TO match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_TO;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_TO match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_TO;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_CC match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_CC;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_CC match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_CC;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_TO_OR_CC match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_TO_OR_CC;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_AGE_GREATER MATCHER_INTEGER
+{
+       gint criteria = 0;
+       gint value = 0;
+
+       criteria = MATCHCRITERIA_AGE_GREATER;
+       value = atoi($2);
+       prop = matcherprop_new(criteria, NULL, 0, NULL, value);
+}
+| MATCHER_AGE_LOWER MATCHER_INTEGER
+{
+       gint criteria = 0;
+       gint value = 0;
+
+       criteria = MATCHCRITERIA_AGE_LOWER;
+       value = atoi($2);
+       prop = matcherprop_new(criteria, NULL, 0, NULL, value);
+}
+| MATCHER_NEWSGROUPS match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NEWSGROUPS;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_INREPLYTO match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_INREPLYTO;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_INREPLYTO;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_REFERENCES match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_REFERENCES;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_REFERENCES match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_REFERENCES;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_SCORE_GREATER MATCHER_INTEGER
+{
+       gint criteria = 0;
+       gint value = 0;
+
+       criteria = MATCHCRITERIA_SCORE_GREATER;
+       value = atoi($2);
+       prop = matcherprop_new(criteria, NULL, 0, NULL, value);
+}
+| MATCHER_SCORE_LOWER MATCHER_INTEGER
+{
+       gint criteria = 0;
+       gint value = 0;
+
+       criteria = MATCHCRITERIA_SCORE_LOWER;
+       value = atoi($2);
+       prop = matcherprop_new(criteria, NULL, 0, NULL, value);
+}
+| MATCHER_HEADER MATCHER_STRING
+{
+       header = g_strdup($2);
+} match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_HEADER;
+       expr = $2;
+       prop = matcherprop_new(criteria, header, match_type, expr, 0);
+       g_free(header);
+}
+| MATCHER_NOT_HEADER MATCHER_STRING
+{
+       header = g_strdup($2);
+} match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_HEADER;
+       expr = $2;
+       prop = matcherprop_new(criteria, header, match_type, expr, 0);
+       g_free(header);
+}
+| MATCHER_HEADERS_PART match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_HEADERS_PART;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_HEADERS_PART;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_MESSAGE match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_MESSAGE;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_MESSAGE match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_MESSAGE;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_BODY_PART match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_BODY_PART;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_BODY_PART match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_BODY_PART;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_MESSAGE match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_MESSAGE;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_EXECUTE MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_EXECUTE;
+       expr = $2;
+       prop = matcherprop_new(criteria, NULL, 0, expr, 0);
+}
+| MATCHER_NOT_EXECUTE MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar * expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_EXECUTE;
+       expr = $2;
+       prop = matcherprop_new(criteria, NULL, 0, expr, 0);
+}
+;
+
+filtering_action:
+MATCHER_EXECUTE MATCHER_STRING
+{
+       gchar * cmd = NULL;
+       gint action_type = 0;
+
+       action_type = MATCHACTION_EXECUTE;
+       cmd = $2;
+       action = filteringaction_new(action_type, 0, cmd);
+}
+| MATCHER_MOVE MATCHER_STRING
+{
+       gchar * destination = NULL;
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MOVE;
+       destination = $2;
+       action = filteringaction_new(action_type, 0, destination);
+}
+| MATCHER_COPY MATCHER_STRING
+{
+       gchar * destination = NULL;
+       gint action_type = 0;
+
+       action_type = MATCHACTION_COPY;
+       destination = $2;
+       action = filteringaction_new(action_type, 0, destination);
+}
+| MATCHER_DELETE
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_DELETE;
+       action = filteringaction_new(action_type, 0, NULL);
+}
+| MATCHER_MARK
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK;
+       action = filteringaction_new(action_type, 0, NULL);
+}
+| MATCHER_UNMARK
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_UNMARK;
+       action = filteringaction_new(action_type, 0, NULL);
+}
+| MATCHER_MARK_AS_READ
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK_AS_READ;
+       action = filteringaction_new(action_type, 0, NULL);
+}
+| MATCHER_MARK_AS_UNREAD
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK_AS_UNREAD;
+       action = filteringaction_new(action_type, 0, NULL);
+}
+| MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
+{
+       gchar * destination = NULL;
+       gint action_type = 0;
+       gint account_id = 0;
+
+       action_type = MATCHACTION_FORWARD;
+       account_id = $2;
+       destination = $3;
+       action = filteringaction_new(action_type, account_id, destination);
+}
+| MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
+{
+       gchar * destination = NULL;
+       gint action_type = 0;
+       gint account_id = 0;
+
+       action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
+       account_id = $2;
+       destination = $3;
+       action = filteringaction_new(action_type, account_id, destination);
+}
+;
+
+scoring_rule:
+MATCHER_SCORE MATCHER_INTEGER
+{
+       score = atoi($2);
+}
+;
index cf60a2c..fa3e22d 100644 (file)
@@ -202,7 +202,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, GHashTable *folder_table)
                }
 
                if (folder_table) {
-                       if (prefs_filtering == NULL) {
+                       if (global_filtering == NULL) {
                                /* old filtering */
                                dropfolder = filter_get_dest_folder
                                        (prefs_common.fltlist, tmp_file);
@@ -232,10 +232,10 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, GHashTable *folder_table)
 
                folder_item_scan(dropfolder);
                
-               if (prefs_filtering != NULL) {
+               if (global_filtering != NULL) {
                        /* new filtering */
                        if (folder_table) {
-                               filter_message(prefs_filtering, dropfolder,
+                               filter_message(global_filtering, dropfolder,
                                               msgnum, folder_table);
                        }
                }
index 87e4887..8a7faae 100644 (file)
@@ -46,6 +46,7 @@
 #include "alertpanel.h"
 #include "folder.h"
 #include "filtering.h"
+#include "matcher_parser.h"
 
 static struct Filtering {
        GtkWidget *window;
@@ -170,25 +171,25 @@ static gint prefs_filtering_get_matching_from_action(gint action_id)
 {
        switch(action_id) {
        case ACTION_MOVE:
-               return MATCHING_ACTION_MOVE;
+               return MATCHACTION_MOVE;
        case ACTION_COPY:
-               return MATCHING_ACTION_COPY;
+               return MATCHACTION_COPY;
        case ACTION_DELETE:
-               return MATCHING_ACTION_DELETE;
+               return MATCHACTION_DELETE;
        case ACTION_MARK:
-               return MATCHING_ACTION_MARK;
+               return MATCHACTION_MARK;
        case ACTION_UNMARK:
-               return MATCHING_ACTION_UNMARK;
+               return MATCHACTION_UNMARK;
        case ACTION_MARK_AS_READ:
-               return MATCHING_ACTION_MARK_AS_READ;
+               return MATCHACTION_MARK_AS_READ;
        case ACTION_MARK_AS_UNREAD:
-               return MATCHING_ACTION_MARK_AS_UNREAD;
+               return MATCHACTION_MARK_AS_UNREAD;
        case ACTION_FORWARD:
-               return MATCHING_ACTION_FORWARD;
+               return MATCHACTION_FORWARD;
        case ACTION_FORWARD_AS_ATTACHMENT:
-               return MATCHING_ACTION_FORWARD_AS_ATTACHMENT;
+               return MATCHACTION_FORWARD_AS_ATTACHMENT;
        case ACTION_EXECUTE:
-               return MATCHING_EXECUTE;
+               return MATCHACTION_EXECUTE;
        default:
                return -1;
        }
@@ -546,7 +547,7 @@ static void prefs_filtering_set_dialog(void)
        gtk_clist_clear(clist);
 
        prefs_filtering_clist_set_row(-1, NULL);
-       for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
+       for(cur = global_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
                FilteringProp * prop = (FilteringProp *) cur->data;
 
                prefs_filtering_clist_set_row(-1, prop);
@@ -574,19 +575,18 @@ static void prefs_filtering_set_list(void)
        gchar * filtering_str;
        gchar * tmp;
 
-       for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur))
+       for(cur = global_filtering ; cur != NULL ; cur = g_slist_next(cur))
                filteringprop_free((FilteringProp *) cur->data);
-       g_slist_free(prefs_filtering);
-       prefs_filtering = NULL;
+       g_slist_free(global_filtering);
+       global_filtering = NULL;
 
        while (gtk_clist_get_text(GTK_CLIST(filtering.cond_clist),
                                  row, 0, &filtering_str)) {
                if (strcmp(filtering_str, _("(New)")) != 0) {
-                       tmp = filtering_str;
-                       prop = filteringprop_parse(&tmp);
+                       prop = matcher_parser_get_filtering(filtering_str);
                        if (prop != NULL)
-                               prefs_filtering = g_slist_append(prefs_filtering,
-                                                              prop);
+                               global_filtering =
+                                       g_slist_append(global_filtering, prop);
                }
                row++;
        }
@@ -641,11 +641,9 @@ static void prefs_filtering_condition_define(void)
        cond_str = gtk_entry_get_text(GTK_ENTRY(filtering.cond_entry));
 
        if (*cond_str != '\0') {
-               gchar * tmp;
-               
-               tmp = cond_str;
-               matchers = matcherlist_parse(&tmp);
-               if (tmp == NULL)
+               matchers = matcher_parser_get_cond(cond_str);
+
+               if (matchers == NULL)
                        alertpanel_error(_("Match string is not valid."));
        }
 
@@ -702,10 +700,9 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(void)
        
        action = filteringaction_new(action_type, account_id, destination);
 
-       tmp = cond_str;
-       cond = matcherlist_parse(&tmp);
+       cond = matcher_parser_get_cond(cond_str);
 
-       if (tmp == NULL) {
+       if (cond == NULL) {
                alertpanel_error(_("Match string is not valid."));
                filteringaction_free(action);
                return NULL;
@@ -821,49 +818,49 @@ static void prefs_filtering_select_set(FilteringProp * prop)
                gtk_entry_set_text(GTK_ENTRY(filtering.dest_entry), "");
 
        switch(action->type) {
-       case MATCHING_ACTION_MOVE:
+       case MATCHACTION_MOVE:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_MOVE);
                break;
-       case MATCHING_ACTION_COPY:
+       case MATCHACTION_COPY:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_COPY);
                break;
-       case MATCHING_ACTION_DELETE:
+       case MATCHACTION_DELETE:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_DELETE);
                break;
-       case MATCHING_ACTION_MARK:
+       case MATCHACTION_MARK:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_MARK);
                break;
-       case MATCHING_ACTION_UNMARK:
+       case MATCHACTION_UNMARK:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_UNMARK);
                break;
-       case MATCHING_ACTION_MARK_AS_READ:
+       case MATCHACTION_MARK_AS_READ:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_MARK_AS_READ);
                break;
-       case MATCHING_ACTION_MARK_AS_UNREAD:
+       case MATCHACTION_MARK_AS_UNREAD:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_MARK_AS_UNREAD);
                break;
-       case MATCHING_ACTION_FORWARD:
+       case MATCHACTION_FORWARD:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_FORWARD);
                list_id = get_list_id_from_account_id(action->account_id);
                gtk_list_select_item(GTK_LIST(filtering.account_list),
                                     list_id);
                break;
-       case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
+       case MATCHACTION_FORWARD_AS_ATTACHMENT:
                list_id = get_list_id_from_account_id(action->account_id);
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_FORWARD_AS_ATTACHMENT);
                gtk_list_select_item(GTK_LIST(filtering.account_list),
                                     list_id);
                break;
-       case MATCHING_EXECUTE:
+       case MATCHACTION_EXECUTE:
                gtk_list_select_item(GTK_LIST(filtering.action_list),
                                     ACTION_EXECUTE);
                break;
@@ -888,9 +885,8 @@ static void prefs_filtering_select(GtkCList *clist, gint row, gint column,
                                row, 0, &filtering_str))
                return;
        
-       tmp = filtering_str;
-       prop = filteringprop_parse(&tmp);
-       if (tmp == NULL)
+       prop = matcher_parser_get_filtering(filtering_str);
+       if (prop == NULL)
                return;
 
        prefs_filtering_select_set(prop);
index 4a00c6b..d6abd4f 100644 (file)
@@ -45,6 +45,7 @@
 #include "gtkutils.h"
 #include "alertpanel.h"
 #include "folder.h"
+#include "matcher_parser.h"
 
 static struct Matcher {
        GtkWidget *window;
@@ -671,7 +672,6 @@ static MatcherList * prefs_matcher_get_list(void)
        gchar * matcher_str;
        MatcherProp * prop;
        gint row = 1;
-       gchar * tmp;
        gboolean bool_and;
        GSList * matcher_list;
        MatcherList * matchers;
@@ -682,10 +682,9 @@ static MatcherList * prefs_matcher_get_list(void)
                                  row, 0, &matcher_str)) {
 
                if (strcmp(matcher_str, _("(New)")) != 0) {
-                       tmp = matcher_str;
-                       prop = matcherprop_parse(&tmp);
+                       prop = matcher_parser_get_prop(matcher_str);
                        
-                       if (tmp == NULL)
+                       if (prop == NULL)
                                break;
                        
                        matcher_list = g_slist_append(matcher_list, prop);
@@ -703,74 +702,74 @@ static MatcherList * prefs_matcher_get_list(void)
 static gint prefs_matcher_get_criteria_from_matching(gint matching_id)
 {
        switch(matching_id) {
-       case MATCHING_ALL:
+       case MATCHCRITERIA_ALL:
                return CRITERIA_ALL;
-       case MATCHING_NOT_UNREAD:
-       case MATCHING_UNREAD:
+       case MATCHCRITERIA_NOT_UNREAD:
+       case MATCHCRITERIA_UNREAD:
                return CRITERIA_UNREAD;
-       case MATCHING_NOT_NEW:
-       case MATCHING_NEW:
+       case MATCHCRITERIA_NOT_NEW:
+       case MATCHCRITERIA_NEW:
                return CRITERIA_NEW;
-       case MATCHING_NOT_MARKED:
-       case MATCHING_MARKED:
+       case MATCHCRITERIA_NOT_MARKED:
+       case MATCHCRITERIA_MARKED:
                return CRITERIA_MARKED;
-       case MATCHING_NOT_DELETED:
-       case MATCHING_DELETED:
+       case MATCHCRITERIA_NOT_DELETED:
+       case MATCHCRITERIA_DELETED:
                return CRITERIA_DELETED;
                break;
-       case MATCHING_NOT_REPLIED:
-       case MATCHING_REPLIED:
+       case MATCHCRITERIA_NOT_REPLIED:
+       case MATCHCRITERIA_REPLIED:
                return CRITERIA_REPLIED;
-       case MATCHING_NOT_FORWARDED:
-       case MATCHING_FORWARDED:
+       case MATCHCRITERIA_NOT_FORWARDED:
+       case MATCHCRITERIA_FORWARDED:
                return CRITERIA_FORWARDED;
-       case MATCHING_NOT_SUBJECT:
-       case MATCHING_SUBJECT:
+       case MATCHCRITERIA_NOT_SUBJECT:
+       case MATCHCRITERIA_SUBJECT:
                return CRITERIA_SUBJECT;
-       case MATCHING_NOT_FROM:
-       case MATCHING_FROM:
+       case MATCHCRITERIA_NOT_FROM:
+       case MATCHCRITERIA_FROM:
                return CRITERIA_FROM;
-       case MATCHING_NOT_TO:
-       case MATCHING_TO:
+       case MATCHCRITERIA_NOT_TO:
+       case MATCHCRITERIA_TO:
                return CRITERIA_TO;
-       case MATCHING_NOT_CC:
-       case MATCHING_CC:
+       case MATCHCRITERIA_NOT_CC:
+       case MATCHCRITERIA_CC:
                return CRITERIA_CC;
-       case MATCHING_NOT_NEWSGROUPS:
-       case MATCHING_NEWSGROUPS:
+       case MATCHCRITERIA_NOT_NEWSGROUPS:
+       case MATCHCRITERIA_NEWSGROUPS:
                return CRITERIA_NEWSGROUPS;
-       case MATCHING_NOT_INREPLYTO:
-       case MATCHING_INREPLYTO:
+       case MATCHCRITERIA_NOT_INREPLYTO:
+       case MATCHCRITERIA_INREPLYTO:
                return CRITERIA_INREPLYTO;
-       case MATCHING_NOT_REFERENCES:
-       case MATCHING_REFERENCES:
+       case MATCHCRITERIA_NOT_REFERENCES:
+       case MATCHCRITERIA_REFERENCES:
                return CRITERIA_REFERENCES;
-       case MATCHING_NOT_TO_AND_NOT_CC:
-       case MATCHING_TO_OR_CC:
+       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
+       case MATCHCRITERIA_TO_OR_CC:
                return CRITERIA_TO_OR_CC;
-       case MATCHING_NOT_BODY_PART:
-       case MATCHING_BODY_PART:
+       case MATCHCRITERIA_NOT_BODY_PART:
+       case MATCHCRITERIA_BODY_PART:
                return CRITERIA_BODY_PART;
-       case MATCHING_NOT_MESSAGE:
-       case MATCHING_MESSAGE:
+       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHCRITERIA_MESSAGE:
                return CRITERIA_MESSAGE;
                break;
-       case MATCHING_NOT_HEADERS_PART:
-       case MATCHING_HEADERS_PART:
+       case MATCHCRITERIA_NOT_HEADERS_PART:
+       case MATCHCRITERIA_HEADERS_PART:
                return CRITERIA_HEADERS_PART;
-       case MATCHING_NOT_HEADER:
-       case MATCHING_HEADER:
+       case MATCHCRITERIA_NOT_HEADER:
+       case MATCHCRITERIA_HEADER:
                return CRITERIA_HEADER;
-       case MATCHING_AGE_GREATER:
+       case MATCHCRITERIA_AGE_GREATER:
                return CRITERIA_AGE_GREATER;
-       case MATCHING_AGE_LOWER:
+       case MATCHCRITERIA_AGE_LOWER:
                return CRITERIA_AGE_LOWER;
-       case MATCHING_SCORE_GREATER:
+       case MATCHCRITERIA_SCORE_GREATER:
                return CRITERIA_SCORE_GREATER;
-       case MATCHING_SCORE_LOWER:
+       case MATCHCRITERIA_SCORE_LOWER:
                return CRITERIA_SCORE_LOWER;
-       case MATCHING_NOT_EXECUTE:
-       case MATCHING_EXECUTE:
+       case MATCHCRITERIA_NOT_EXECUTE:
+       case MATCHCRITERIA_EXECUTE:
                return CRITERIA_EXECUTE;
                break;
        default:
@@ -782,53 +781,53 @@ static gint prefs_matcher_get_matching_from_criteria(gint criteria_id)
 {
        switch (criteria_id) {
        case CRITERIA_ALL:
-               return MATCHING_ALL;
+               return MATCHCRITERIA_ALL;
        case CRITERIA_UNREAD:
-               return MATCHING_UNREAD;
+               return MATCHCRITERIA_UNREAD;
        case CRITERIA_NEW:
-               return MATCHING_NEW;
+               return MATCHCRITERIA_NEW;
        case CRITERIA_MARKED:
-               return MATCHING_MARKED;
+               return MATCHCRITERIA_MARKED;
        case CRITERIA_DELETED:
-               return MATCHING_DELETED;
+               return MATCHCRITERIA_DELETED;
        case CRITERIA_REPLIED:
-               return MATCHING_REPLIED;
+               return MATCHCRITERIA_REPLIED;
        case CRITERIA_FORWARDED:
-               return MATCHING_FORWARDED;
+               return MATCHCRITERIA_FORWARDED;
        case CRITERIA_SUBJECT:
-               return MATCHING_SUBJECT;
+               return MATCHCRITERIA_SUBJECT;
        case CRITERIA_FROM:
-               return MATCHING_FROM;
+               return MATCHCRITERIA_FROM;
        case CRITERIA_TO:
-               return MATCHING_TO;
+               return MATCHCRITERIA_TO;
        case CRITERIA_CC:
-               return MATCHING_CC;
+               return MATCHCRITERIA_CC;
        case CRITERIA_TO_OR_CC:
-               return MATCHING_TO_OR_CC;
+               return MATCHCRITERIA_TO_OR_CC;
        case CRITERIA_NEWSGROUPS:
-               return MATCHING_NEWSGROUPS;
+               return MATCHCRITERIA_NEWSGROUPS;
        case CRITERIA_INREPLYTO:
-               return MATCHING_INREPLYTO;
+               return MATCHCRITERIA_INREPLYTO;
        case CRITERIA_REFERENCES:
-               return MATCHING_REFERENCES;
+               return MATCHCRITERIA_REFERENCES;
        case CRITERIA_AGE_GREATER:
-               return MATCHING_AGE_GREATER;
+               return MATCHCRITERIA_AGE_GREATER;
        case CRITERIA_AGE_LOWER:
-               return MATCHING_AGE_LOWER;
+               return MATCHCRITERIA_AGE_LOWER;
        case CRITERIA_SCORE_GREATER:
-               return MATCHING_SCORE_GREATER;
+               return MATCHCRITERIA_SCORE_GREATER;
        case CRITERIA_SCORE_LOWER:
-               return MATCHING_SCORE_LOWER;
+               return MATCHCRITERIA_SCORE_LOWER;
        case CRITERIA_HEADER:
-               return MATCHING_HEADER;
+               return MATCHCRITERIA_HEADER;
        case CRITERIA_HEADERS_PART:
-               return MATCHING_HEADERS_PART;
+               return MATCHCRITERIA_HEADERS_PART;
        case CRITERIA_BODY_PART:
-               return MATCHING_BODY_PART;
+               return MATCHCRITERIA_BODY_PART;
        case CRITERIA_MESSAGE:
-               return MATCHING_MESSAGE;
+               return MATCHCRITERIA_MESSAGE;
        case CRITERIA_EXECUTE:
-               return MATCHING_EXECUTE;
+               return MATCHCRITERIA_EXECUTE;
        default:
                return -1;
        }
@@ -837,44 +836,44 @@ static gint prefs_matcher_get_matching_from_criteria(gint criteria_id)
 static gint prefs_matcher_not_criteria(gint matcher_criteria)
 {
        switch(matcher_criteria) {
-       case MATCHING_UNREAD:
-               return MATCHING_NOT_UNREAD;
-       case MATCHING_NEW:
-               return MATCHING_NOT_NEW;
-       case MATCHING_MARKED:
-               return MATCHING_NOT_MARKED;
-       case MATCHING_DELETED:
-               return MATCHING_NOT_DELETED;
-       case MATCHING_REPLIED:
-               return MATCHING_NOT_REPLIED;
-       case MATCHING_FORWARDED:
-               return MATCHING_NOT_FORWARDED;
-       case MATCHING_SUBJECT:
-               return MATCHING_NOT_SUBJECT;
-       case MATCHING_FROM:
-               return MATCHING_NOT_FROM;
-       case MATCHING_TO:
-               return MATCHING_NOT_TO;
-       case MATCHING_CC:
-               return MATCHING_NOT_CC;
-       case MATCHING_TO_OR_CC:
-               return MATCHING_NOT_TO_AND_NOT_CC;
-       case MATCHING_NEWSGROUPS:
-               return MATCHING_NOT_NEWSGROUPS;
-       case MATCHING_INREPLYTO:
-               return MATCHING_NOT_INREPLYTO;
-       case MATCHING_REFERENCES:
-               return MATCHING_NOT_REFERENCES;
-       case MATCHING_HEADER:
-               return MATCHING_NOT_HEADER;
-       case MATCHING_HEADERS_PART:
-               return MATCHING_NOT_HEADERS_PART;
-       case MATCHING_MESSAGE:
-               return MATCHING_NOT_MESSAGE;
-       case MATCHING_EXECUTE:
-               return MATCHING_NOT_EXECUTE;
-       case MATCHING_BODY_PART:
-               return MATCHING_NOT_BODY_PART;
+       case MATCHCRITERIA_UNREAD:
+               return MATCHCRITERIA_NOT_UNREAD;
+       case MATCHCRITERIA_NEW:
+               return MATCHCRITERIA_NOT_NEW;
+       case MATCHCRITERIA_MARKED:
+               return MATCHCRITERIA_NOT_MARKED;
+       case MATCHCRITERIA_DELETED:
+               return MATCHCRITERIA_NOT_DELETED;
+       case MATCHCRITERIA_REPLIED:
+               return MATCHCRITERIA_NOT_REPLIED;
+       case MATCHCRITERIA_FORWARDED:
+               return MATCHCRITERIA_NOT_FORWARDED;
+       case MATCHCRITERIA_SUBJECT:
+               return MATCHCRITERIA_NOT_SUBJECT;
+       case MATCHCRITERIA_FROM:
+               return MATCHCRITERIA_NOT_FROM;
+       case MATCHCRITERIA_TO:
+               return MATCHCRITERIA_NOT_TO;
+       case MATCHCRITERIA_CC:
+               return MATCHCRITERIA_NOT_CC;
+       case MATCHCRITERIA_TO_OR_CC:
+               return MATCHCRITERIA_NOT_TO_AND_NOT_CC;
+       case MATCHCRITERIA_NEWSGROUPS:
+               return MATCHCRITERIA_NOT_NEWSGROUPS;
+       case MATCHCRITERIA_INREPLYTO:
+               return MATCHCRITERIA_NOT_INREPLYTO;
+       case MATCHCRITERIA_REFERENCES:
+               return MATCHCRITERIA_NOT_REFERENCES;
+       case MATCHCRITERIA_HEADER:
+               return MATCHCRITERIA_NOT_HEADER;
+       case MATCHCRITERIA_HEADERS_PART:
+               return MATCHCRITERIA_NOT_HEADERS_PART;
+       case MATCHCRITERIA_MESSAGE:
+               return MATCHCRITERIA_NOT_MESSAGE;
+       case MATCHCRITERIA_EXECUTE:
+               return MATCHCRITERIA_NOT_EXECUTE;
+       case MATCHCRITERIA_BODY_PART:
+               return MATCHCRITERIA_NOT_BODY_PART;
        default:
                return matcher_criteria;
        }
@@ -937,15 +936,15 @@ static MatcherProp * prefs_matcher_dialog_to_matcher()
 
        if (use_regexp) {
                if (case_sensitive)
-                       matchtype = MATCHING_REGEXP;
+                       matchtype = MATCHTYPE_REGEXP;
                else
-                       matchtype = MATCHING_REGEXPCASE;
+                       matchtype = MATCHTYPE_REGEXPCASE;
        }
        else {
                if (case_sensitive)
-                       matchtype = MATCHING_MATCH;
+                       matchtype = MATCHTYPE_MATCH;
                else
-                       matchtype = MATCHING_MATCHCASE;
+                       matchtype = MATCHTYPE_MATCHCASE;
        }
 
        header = NULL;
@@ -1121,9 +1120,8 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
                return;
        }
 
-       tmp = matcher_str;
-       prop = matcherprop_parse(&tmp);
-       if (tmp == NULL)
+       prop = matcher_parser_get_prop(matcher_str);
+       if (prop == NULL)
                return;
 
        criteria = prefs_matcher_get_criteria_from_matching(prop->criteria);
@@ -1132,66 +1130,66 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
                                     criteria);
 
        switch(prop->criteria) {
-       case MATCHING_NOT_UNREAD:
-       case MATCHING_NOT_NEW:
-       case MATCHING_NOT_MARKED:
-       case MATCHING_NOT_DELETED:
-       case MATCHING_NOT_REPLIED:
-       case MATCHING_NOT_FORWARDED:
-       case MATCHING_NOT_SUBJECT:
-       case MATCHING_NOT_FROM:
-       case MATCHING_NOT_TO:
-       case MATCHING_NOT_CC:
-       case MATCHING_NOT_NEWSGROUPS:
-       case MATCHING_NOT_INREPLYTO:
-       case MATCHING_NOT_REFERENCES:
-       case MATCHING_NOT_TO_AND_NOT_CC:
-       case MATCHING_NOT_BODY_PART:
-       case MATCHING_NOT_MESSAGE:
-       case MATCHING_NOT_HEADERS_PART:
-       case MATCHING_NOT_HEADER:
+       case MATCHCRITERIA_NOT_UNREAD:
+       case MATCHCRITERIA_NOT_NEW:
+       case MATCHCRITERIA_NOT_MARKED:
+       case MATCHCRITERIA_NOT_DELETED:
+       case MATCHCRITERIA_NOT_REPLIED:
+       case MATCHCRITERIA_NOT_FORWARDED:
+       case MATCHCRITERIA_NOT_SUBJECT:
+       case MATCHCRITERIA_NOT_FROM:
+       case MATCHCRITERIA_NOT_TO:
+       case MATCHCRITERIA_NOT_CC:
+       case MATCHCRITERIA_NOT_NEWSGROUPS:
+       case MATCHCRITERIA_NOT_INREPLYTO:
+       case MATCHCRITERIA_NOT_REFERENCES:
+       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
+       case MATCHCRITERIA_NOT_BODY_PART:
+       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHCRITERIA_NOT_HEADERS_PART:
+       case MATCHCRITERIA_NOT_HEADER:
                negative_cond = TRUE;
                break;
        }
        
        switch(prop->criteria) {
-       case MATCHING_ALL:
+       case MATCHCRITERIA_ALL:
                break;
 
-       case MATCHING_NOT_SUBJECT:
-       case MATCHING_NOT_FROM:
-       case MATCHING_NOT_TO:
-       case MATCHING_NOT_CC:
-       case MATCHING_NOT_TO_AND_NOT_CC:
-       case MATCHING_NOT_NEWSGROUPS:
-       case MATCHING_NOT_INREPLYTO:
-       case MATCHING_NOT_REFERENCES:
-       case MATCHING_NOT_HEADERS_PART:
-       case MATCHING_NOT_BODY_PART:
-       case MATCHING_NOT_MESSAGE:
-       case MATCHING_SUBJECT:
-       case MATCHING_FROM:
-       case MATCHING_TO:
-       case MATCHING_CC:
-       case MATCHING_TO_OR_CC:
-       case MATCHING_NEWSGROUPS:
-       case MATCHING_INREPLYTO:
-       case MATCHING_REFERENCES:
-       case MATCHING_HEADERS_PART:
-       case MATCHING_BODY_PART:
-       case MATCHING_MESSAGE:
+       case MATCHCRITERIA_NOT_SUBJECT:
+       case MATCHCRITERIA_NOT_FROM:
+       case MATCHCRITERIA_NOT_TO:
+       case MATCHCRITERIA_NOT_CC:
+       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
+       case MATCHCRITERIA_NOT_NEWSGROUPS:
+       case MATCHCRITERIA_NOT_INREPLYTO:
+       case MATCHCRITERIA_NOT_REFERENCES:
+       case MATCHCRITERIA_NOT_HEADERS_PART:
+       case MATCHCRITERIA_NOT_BODY_PART:
+       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHCRITERIA_SUBJECT:
+       case MATCHCRITERIA_FROM:
+       case MATCHCRITERIA_TO:
+       case MATCHCRITERIA_CC:
+       case MATCHCRITERIA_TO_OR_CC:
+       case MATCHCRITERIA_NEWSGROUPS:
+       case MATCHCRITERIA_INREPLYTO:
+       case MATCHCRITERIA_REFERENCES:
+       case MATCHCRITERIA_HEADERS_PART:
+       case MATCHCRITERIA_BODY_PART:
+       case MATCHCRITERIA_MESSAGE:
                gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), prop->expr);
                break;
 
-       case MATCHING_AGE_GREATER:
-       case MATCHING_AGE_LOWER:
-       case MATCHING_SCORE_GREATER:
-       case MATCHING_SCORE_LOWER:
+       case MATCHCRITERIA_AGE_GREATER:
+       case MATCHCRITERIA_AGE_LOWER:
+       case MATCHCRITERIA_SCORE_GREATER:
+       case MATCHCRITERIA_SCORE_LOWER:
                gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), itos(prop->value));
                break;
 
-       case MATCHING_NOT_HEADER:
-       case MATCHING_HEADER:
+       case MATCHCRITERIA_NOT_HEADER:
+       case MATCHCRITERIA_HEADER:
                gtk_entry_set_text(GTK_ENTRY(matcher.header_entry), prop->header);
                gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), prop->expr);
                break;
@@ -1203,22 +1201,22 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
                gtk_list_select_item(GTK_LIST(matcher.predicate_list), 0);
 
        switch(prop->matchtype) {
-       case MATCHING_MATCH:
+       case MATCHTYPE_MATCH:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), FALSE);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), TRUE);
                break;
 
-       case MATCHING_MATCHCASE:
+       case MATCHTYPE_MATCHCASE:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), FALSE);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), FALSE);
                break;
 
-       case MATCHING_REGEXP:
+       case MATCHTYPE_REGEXP:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), TRUE);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), TRUE);
                break;
 
-       case MATCHING_REGEXPCASE:
+       case MATCHTYPE_REGEXPCASE:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), TRUE);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), FALSE);
                break;
index 7eeddbb..31cee3b 100644 (file)
@@ -46,6 +46,7 @@
 #include "alertpanel.h"
 #include "folder.h"
 #include "scoring.h"
+#include "matcher_parser.h"
 
 static struct Scoring {
        GtkWidget *window;
@@ -457,8 +458,7 @@ static void prefs_scoring_set_list(void)
        while (gtk_clist_get_text(GTK_CLIST(scoring.cond_clist),
                                  row, 0, &scoring_str)) {
                if (strcmp(scoring_str, _("(New)")) != 0) {
-                       tmp = scoring_str;
-                       prop = scoringprop_parse(&tmp);
+                       prop = matcher_parser_get_scoring(scoring_str);
                        if (prop != NULL)
                                prefs_scoring = g_slist_append(prefs_scoring,
                                                               prop);
@@ -530,11 +530,9 @@ static void prefs_scoring_condition_define(void)
        cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
 
        if (*cond_str != '\0') {
-               gchar * tmp;
-               
-               tmp = cond_str;
-               matchers = matcherlist_parse(&tmp);
-               if (tmp == NULL)
+               matchers = matcher_parser_get_cond(cond_str);
+
+               if (matchers == NULL)
                        alertpanel_error(_("Match string is not valid."));
        }
 
@@ -554,7 +552,6 @@ static void prefs_scoring_register_cb(void)
        gchar * score_str;
        ScoringProp * prop;
        gint score;
-       gchar * tmp;
 
        cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
        if (*cond_str == '\0') {
@@ -569,10 +566,9 @@ static void prefs_scoring_register_cb(void)
        }
 
        score = atoi(score_str);
-       tmp = cond_str;
-       cond = matcherlist_parse(&tmp);
+       cond = matcher_parser_get_cond(cond_str);
 
-       if (tmp == NULL) {
+       if (cond == NULL) {
                alertpanel_error(_("Match string is not valid."));
                return;
        }
@@ -615,10 +611,9 @@ static void prefs_scoring_substitute_cb(void)
        }
 
        score = atoi(score_str);
-       tmp = cond_str;
-       cond = matcherlist_parse(&tmp);
+       cond = matcher_parser_get_cond(cond_str);
 
-       if (tmp == NULL) {
+       if (cond) {
                alertpanel_error(_("Match string is not valid."));
                return;
        }
@@ -714,9 +709,8 @@ static void prefs_scoring_select(GtkCList *clist, gint row, gint column,
                                row, 0, &scoring_str))
                return;
 
-       tmp = scoring_str;
-       prop = scoringprop_parse(&tmp);
-       if (tmp == NULL)
+       prop = matcher_parser_get_scoring(scoring_str);
+       if (prop == NULL)
                return;
 
        prefs_scoring_select_set_dialog(prop);
index 9ff0ee9..9667df8 100644 (file)
 #include "scoring.h"
 #include "prefs.h"
 #include "folder.h"
+#include "matcher_parser.h"
 
 #define PREFSBUFSIZE           1024
 
 
 GSList * global_scoring;
 
+/*
 ScoringProp * scoringprop_parse(gchar ** str)
 {
        gchar * tmp;
@@ -60,7 +62,7 @@ ScoringProp * scoringprop_parse(gchar ** str)
        * str = tmp;
        return scoring;
 }
-
+*/
 
 ScoringProp * scoringprop_new(MatcherList * matchers, int score)
 {
@@ -197,7 +199,7 @@ gchar * scoringprop_to_string(ScoringProp * prop)
                return NULL;
 
        score_str = itos(prop->score);
-       scoring_str = g_strconcat(list_str, " score ", score_str, NULL);
+       scoring_str = g_strconcat(list_str, " score ", score_str, "\n", NULL);
        g_free(list_str);
 
        return scoring_str;
@@ -265,7 +267,7 @@ static gboolean prefs_scoring_free_func(GNode *node, gpointer data)
        return FALSE;
 }
 
-static void prefs_scoring_clear()
+void prefs_scoring_clear()
 {
        GList * cur;
 
@@ -281,6 +283,34 @@ static void prefs_scoring_clear()
        global_scoring = NULL;
 }
 
+void prefs_scoring_read_config(void)
+{
+       gchar *rcpath;
+       FILE *fp;
+
+       prefs_scoring_clear();
+
+       debug_print(_("Reading scoring configuration...\n"));
+
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+                            SCORING_RC, NULL);
+       if ((fp = fopen(rcpath, "r")) == NULL) {
+               if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
+               g_free(rcpath);
+               return;
+       }
+
+       matcher_parserlineno = 1;
+       matcher_parserin = fp;
+       if (matcher_parserparse() != 0) {
+               printf("%s\n", rcpath);
+               prefs_scoring_clear();
+       }
+       g_free(rcpath);
+       fclose(fp);
+}
+
+/*
 void prefs_scoring_read_config(void)
 {
        gchar *rcpath;
@@ -289,7 +319,7 @@ void prefs_scoring_read_config(void)
        GSList * prefs_scoring = NULL;
        FolderItem * item = NULL;
 
-       debug_print(_("Reading headers configuration...\n"));
+       debug_print(_("Reading scoring configuration...\n"));
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, SCORING_RC, NULL);
        if ((fp = fopen(rcpath, "r")) == NULL) {
@@ -340,7 +370,9 @@ void prefs_scoring_read_config(void)
                                                               scoring);
                        }
                        else {
+*/
                                /* debug */
+/*
                                g_warning(_("syntax error : %s\n"), buf);
                        }
                }
@@ -353,6 +385,7 @@ void prefs_scoring_read_config(void)
 
        fclose(fp);
 }
+*/
 
 static void prefs_scoring_write(FILE * fp, GSList * prefs_scoring)
 {
@@ -364,9 +397,8 @@ static void prefs_scoring_write(FILE * fp, GSList * prefs_scoring)
 
                prop = (ScoringProp *) cur->data;
                scoring_str = scoringprop_to_string(prop);
-               if (fputs(scoring_str, fp) == EOF ||
-                   fputc('\n', fp) == EOF) {
-                       FILE_OP_ERROR("scoring config", "fputs || fputc");
+               if (fputs(scoring_str, fp) == EOF) {
+                       FILE_OP_ERROR("scoring config", "fputs");
                        g_free(scoring_str);
                        return;
                }
index e8627ac..771437d 100644 (file)
@@ -24,8 +24,9 @@ ScoringProp * scoringprop_new(MatcherList * matchers, int score);
 void scoringprop_free(ScoringProp * prop);
 gint scoringprop_score_message(ScoringProp * scoring, MsgInfo * info);
 
+/*
 ScoringProp * scoringprop_parse(gchar ** str);
-
+*/
 
 gint score_message(GSList * scoring_list, MsgInfo * info);
 
@@ -35,4 +36,6 @@ gchar * scoringprop_to_string(ScoringProp * prop);
 
 void prefs_scoring_free(GSList * prefs_scoring);
 
+void prefs_scoring_clear();
+
 #endif
index 7ee64d0..85b01a3 100644 (file)
@@ -1698,7 +1698,8 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                                parent = g_hash_table_lookup
                                        (msgid_table, msginfo->inreplyto);
                        }
-                       if (parent == NULL && msginfo->subject) {
+                       if (parent == NULL && msginfo->subject &&
+                           g_strncasecmp(msginfo->subject, "Re: ", 4) == 0) {
                                parent = subject_table_lookup
                                        (subject_table, msginfo->subject);
                        }
@@ -1764,7 +1765,10 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                                    *cur_msginfo->inreplyto) {
                                        cur_parent = g_hash_table_lookup(msgid_table, cur_msginfo->inreplyto);
                                }
-                               if (cur_parent == NULL && cur_msginfo->subject) {
+                               if (cur_parent == NULL &&
+                                   cur_msginfo->subject &&
+                                   g_strncasecmp(cur_msginfo->subject,
+                                                 "Re: ", 4) == 0) {
                                        cur_parent = subject_table_lookup(subject_table, cur_msginfo->subject);
                                }
                        }
@@ -2972,7 +2976,8 @@ static void summary_thread_func(GtkCTree *ctree, GtkCTreeNode *node,
        if(msginfo->inreplyto) {
            parent = g_hash_table_lookup(msgid_table, msginfo->inreplyto);
        }
-       if (parent == NULL && msginfo->subject) {
+       if (parent == NULL && msginfo->subject &&
+           g_strncasecmp(msginfo->subject, "Re: ", 4) == 0) {
                parent = subject_table_lookup(subject_table, msginfo->subject);
        }
 
@@ -3042,7 +3047,7 @@ void summary_filter(SummaryView *summaryview)
 
        gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
 
-       if (prefs_filtering == NULL) {
+       if (global_filtering == NULL) {
                gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
                                        GTK_CTREE_FUNC(summary_filter_func),
                                        summaryview);
@@ -3085,7 +3090,7 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
        gchar *file;
        FolderItem *dest;
 
-       if (prefs_filtering == NULL) {
+       if (global_filtering == NULL) {
                /* old filtering */
                file = procmsg_get_message_file_path(msginfo);
                dest = filter_get_dest_folder(prefs_common.fltlist, file);
@@ -3096,7 +3101,7 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
                        summary_move_row_to(summaryview, node, dest);
        }
        else
-               filter_msginfo_move_or_delete(prefs_filtering, msginfo,
+               filter_msginfo_move_or_delete(global_filtering, msginfo,
                                              summaryview->folder_table);
 }