Committing reverts
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Thu, 12 Jul 2001 14:00:15 +0000 (14:00 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Thu, 12 Jul 2001 14:00:15 +0000 (14:00 +0000)
src/filtering.c
src/filtering.h
src/inc.c
src/main.c
src/matcher.c
src/matcher.h
src/mbox.c
src/prefs_matcher.c
src/prefs_scoring.c
src/scoring.c
src/scoring.h

index 6b19d88..4fa8e09 100644 (file)
 #include "filtering.h"
 #include "prefs.h"
 #include "compose.h"
-#include "matcher_parser.h"
 
 #define PREFSBUFSIZE           1024
 
-/* GSList * prefs_filtering = NULL; */
-GSList * global_filtering = NULL;
+GSList * prefs_filtering = NULL;
 
 FilteringAction * filteringaction_new(int type, int account_id,
                                      gchar * destination)
@@ -41,7 +39,6 @@ void filteringaction_free(FilteringAction * action)
        g_free(action);
 }
 
-/*
 FilteringAction * filteringaction_parse(gchar ** str)
 {
        FilteringAction * action;
@@ -134,7 +131,7 @@ FilteringProp * filteringprop_parse(gchar ** str)
        * str = tmp;
        return filtering;
 }
-*/
+
 
 FilteringProp * filteringprop_new(MatcherList * matchers,
                                  FilteringAction * action)
@@ -355,7 +352,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
        gchar * cmd;
 
        switch(action->type) {
-       case MATCHACTION_MOVE:
+       case MATCHING_ACTION_MOVE:
                dest_folder =
                        folder_find_item_from_identifier(action->destination);
                if (!dest_folder)
@@ -386,7 +383,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHACTION_COPY:
+       case MATCHING_ACTION_COPY:
                dest_folder =
                        folder_find_item_from_identifier(action->destination);
                if (!dest_folder)
@@ -407,7 +404,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                        
                return TRUE;
 
-       case MATCHACTION_DELETE:
+       case MATCHING_ACTION_DELETE:
                if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
                        return FALSE;
 
@@ -416,7 +413,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHACTION_MARK:
+       case MATCHING_ACTION_MARK:
                MSG_SET_FLAGS(info->flags, MSG_MARKED);
                filteringaction_update_mark(info);
 
@@ -424,7 +421,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHACTION_UNMARK:
+       case MATCHING_ACTION_UNMARK:
                MSG_UNSET_FLAGS(info->flags, MSG_MARKED);
                filteringaction_update_mark(info);
 
@@ -432,7 +429,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
                
-       case MATCHACTION_MARK_AS_READ:
+       case MATCHING_ACTION_MARK_AS_READ:
                MSG_UNSET_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                filteringaction_update_mark(info);
 
@@ -440,7 +437,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
 
                return TRUE;
 
-       case MATCHACTION_MARK_AS_UNREAD:
+       case MATCHING_ACTION_MARK_AS_UNREAD:
                MSG_SET_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
                filteringaction_update_mark(info);
 
@@ -448,7 +445,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                
                return TRUE;
 
-       case MATCHACTION_FORWARD:
+       case MATCHING_ACTION_FORWARD:
 
                account = account_find_from_id(action->account_id);
                compose = compose_forward(account, info, FALSE);
@@ -468,7 +465,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                gtk_widget_destroy(compose->window);
                return FALSE;
 
-       case MATCHACTION_FORWARD_AS_ATTACHMENT:
+       case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
 
                account = account_find_from_id(action->account_id);
                compose = compose_forward(account, info, TRUE);
@@ -488,7 +485,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                gtk_widget_destroy(compose->window);
                return FALSE;
 
-       case MATCHACTION_EXECUTE:
+       case MATCHING_EXECUTE:
 
                cmd = matching_build_command(action->destination, info);
                if (cmd == NULL)
@@ -536,17 +533,17 @@ static gboolean filteringprop_apply(FilteringProp * filtering, MsgInfo * info,
                g_free(action_str);
 
                switch(filtering->action->type) {
-               case MATCHACTION_MOVE:
-               case MATCHACTION_DELETE:
+               case MATCHING_ACTION_MOVE:
+               case MATCHING_ACTION_DELETE:
                        return TRUE;
-               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:
+               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:
                        return FALSE;
                default:
                        return FALSE;
@@ -588,8 +585,8 @@ void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
                FilteringProp * filtering = (FilteringProp *) l->data;
 
                switch (filtering->action->type) {
-               case MATCHACTION_MOVE:
-               case MATCHACTION_DELETE:
+               case MATCHING_ACTION_MOVE:
+               case MATCHING_ACTION_DELETE:
                        if (filteringprop_apply(filtering, info, folder_table))
                                return;
                }
@@ -629,34 +626,6 @@ 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_parserrestart(fp);
-       if (matcher_parserparse() != 0) {
-               prefs_filtering_clear();
-       }
-       g_free(rcpath);
-       fclose(fp);
-}
-
-/*
 void prefs_filtering_read_config(void)
 {
        gchar *rcpath;
@@ -674,10 +643,8 @@ void prefs_filtering_read_config(void)
                return;
        }
        g_free(rcpath);
-*/
 
        /* remove all filtering */
-/*
        while (prefs_filtering != NULL) {
                FilteringProp * filtering =
                        (FilteringProp *) prefs_filtering->data;
@@ -692,8 +659,6 @@ 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) {
@@ -702,9 +667,7 @@ void prefs_filtering_read_config(void)
                                                       filtering);
                        }
                        else {
-*/
                                /* debug */
-/*
                                g_warning(_("syntax error : %s\n"), buf);
                        }
                }
@@ -712,7 +675,6 @@ void prefs_filtering_read_config(void)
 
        fclose(fp);
 }
-*/
 
 gchar * filteringaction_to_string(FilteringAction * action)
 {
@@ -721,28 +683,28 @@ gchar * filteringaction_to_string(FilteringAction * action)
        gchar * account_id_str;
 
        command_str = NULL;
-       command_str = get_matchaction_str(action->type);
+       command_str = get_matchparser_tab_str(action->type);
 
        if (command_str == NULL)
                return NULL;
 
        switch(action->type) {
-       case MATCHACTION_MOVE:
-       case MATCHACTION_COPY:
-       case MATCHACTION_EXECUTE:
+       case MATCHING_ACTION_MOVE:
+       case MATCHING_ACTION_COPY:
+       case MATCHING_EXECUTE:
                return g_strconcat(command_str, " \"", action->destination,
                                   "\"", NULL);
 
-       case MATCHACTION_DELETE:
-       case MATCHACTION_MARK:
-       case MATCHACTION_UNMARK:
-       case MATCHACTION_MARK_AS_READ:
-       case MATCHACTION_MARK_AS_UNREAD:
+       case MATCHING_ACTION_DELETE:
+       case MATCHING_ACTION_MARK:
+       case MATCHING_ACTION_UNMARK:
+       case MATCHING_ACTION_MARK_AS_READ:
+       case MATCHING_ACTION_MARK_AS_UNREAD:
                return g_strdup(command_str);
                break;
 
-       case MATCHACTION_FORWARD:
-       case MATCHACTION_FORWARD_AS_ATTACHMENT:
+       case MATCHING_ACTION_FORWARD:
+       case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
                account_id_str = itos(action->account_id);
                return g_strconcat(command_str, " ", account_id_str,
                                   " \"", action->destination, "\"", NULL);
@@ -770,7 +732,7 @@ gchar * filteringprop_to_string(FilteringProp * prop)
                return NULL;
        }
 
-       filtering_str = g_strconcat(list_str, " ", action_str, "\n", NULL);
+       filtering_str = g_strconcat(list_str, " ", action_str, NULL);
        g_free(list_str);
        g_free(action_str);
 
@@ -794,13 +756,14 @@ void prefs_filtering_write_config(void)
                return;
        }
 
-       for (cur = global_filtering; cur != NULL; cur = cur->next) {
+       for (cur = prefs_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) {
-                       FILE_OP_ERROR(rcpath, "fputs");
+               if (fputs(filtering_str, pfile->fp) == EOF ||
+                   fputc('\n', pfile->fp) == EOF) {
+                       FILE_OP_ERROR(rcpath, "fputs || fputc");
                        prefs_write_close_revert(pfile);
                        g_free(rcpath);
                        g_free(filtering_str);
@@ -816,40 +779,3 @@ 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 7cdd5e4..d4ef0c0 100644 (file)
@@ -21,23 +21,20 @@ struct _FilteringProp {
 
 typedef struct _FilteringProp FilteringProp;
 
-extern GSList * global_filtering;
+extern GSList * prefs_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);
@@ -51,6 +48,4 @@ void prefs_filtering_write_config(void);
 void prefs_filtering_read_config(void);
 gchar * filteringprop_to_string(FilteringProp * prop);
 
-void prefs_filtering_clear();
-
 #endif
index 58f6ceb..1e0b9c9 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -262,10 +262,7 @@ static IncProgressDialog *inc_progress_dialog_create(void)
                           GTK_SIGNAL_FUNC(inc_cancel), dialog);
        gtk_signal_connect(GTK_OBJECT(progress->window), "delete_event",
                           GTK_SIGNAL_FUNC(gtk_true), NULL);
-       if((prefs_common.receive_dialog == RECVDIALOG_ALWAYS) ||
-           ((prefs_common.receive_dialog == RECVDIALOG_WINDOW_ACTIVE) && focus_window)) {
-               manage_window_set_transient(GTK_WINDOW(progress->window));
-       }
+       manage_window_set_transient(GTK_WINDOW(progress->window));
 
        progress_dialog_set_value(progress, 0.0);
 
@@ -404,11 +401,8 @@ static void inc_start(IncProgressDialog *inc_dialog)
                        pass = input_dialog_with_invisible(_("Input password"),
                                                           message, NULL);
                        g_free(message);
-                       if((prefs_common.receive_dialog == RECVDIALOG_ALWAYS) ||
-                           ((prefs_common.receive_dialog == RECVDIALOG_WINDOW_ACTIVE) && focus_window)) {
-                               manage_window_focus_in(inc_dialog->mainwin->window,
-                                                      NULL, NULL);
-                       }
+                       manage_window_focus_in(inc_dialog->mainwin->window,
+                                              NULL, NULL);
                        if (pass) {
                                pop3_state->ac_prefs->tmp_pass = g_strdup(pass);
                                pop3_state->pass = pass;
@@ -436,10 +430,7 @@ static void inc_start(IncProgressDialog *inc_dialog)
 
                if (pop3_state->error_val == PS_AUTHFAIL) {
                        if(!prefs_common.noerrorpanel) {
-                               if((prefs_common.receive_dialog == RECVDIALOG_ALWAYS) ||
-                                   ((prefs_common.receive_dialog == RECVDIALOG_WINDOW_ACTIVE) && focus_window)) {
-                                       manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
-                               }
+                               manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
                                alertpanel_error
                                        (_("Authorization for %s on %s failed"),
                                         pop3_state->user,
@@ -448,11 +439,8 @@ static void inc_start(IncProgressDialog *inc_dialog)
                }
 
                statusbar_pop_all();
-               if((prefs_common.receive_dialog == RECVDIALOG_ALWAYS) ||
-                   ((prefs_common.receive_dialog == RECVDIALOG_WINDOW_ACTIVE) && focus_window)) {
-                       manage_window_focus_in(inc_dialog->mainwin->window, NULL, NULL);
-               }
-               
+               manage_window_focus_in(inc_dialog->mainwin->window, NULL, NULL);
+
                folder_item_scan_foreach(pop3_state->folder_table);
                folderview_update_item_foreach(pop3_state->folder_table);
 
@@ -537,13 +525,8 @@ static IncState inc_pop3_session_do(IncSession *session)
        atm->num = POP3_GREETING_RECV;
 
        server = pop3_state->ac_prefs->recv_server;
-#if USE_SSL
-       port = pop3_state->ac_prefs->set_popport ?
-               pop3_state->ac_prefs->popport : (pop3_state->ac_prefs->pop_ssl ? 995 : 110);
-#else
        port = pop3_state->ac_prefs->set_popport ?
                pop3_state->ac_prefs->popport : 110;
-#endif
 
        buf = g_strdup_printf(_("Connecting to POP3 server: %s ..."), server);
        log_message("%s\n", buf);
@@ -559,10 +542,7 @@ static IncState inc_pop3_session_do(IncSession *session)
                log_warning(_("Can't connect to POP3 server: %s:%d\n"),
                            server, port);
                if(!prefs_common.noerrorpanel) {
-                       if((prefs_common.receive_dialog == RECVDIALOG_ALWAYS) ||
-                           ((prefs_common.receive_dialog == RECVDIALOG_WINDOW_ACTIVE) && focus_window)) {
-                               manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
-                       }
+                       manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
                        alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
                                         server, port);
                        manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
@@ -578,66 +558,6 @@ static IncState inc_pop3_session_do(IncSession *session)
        pop3_state->sockinfo = sockinfo;
        atm->help_sock = sockinfo;
 
-#ifdef USE_SSL
-       if(pop3_state->ac_prefs->pop_ssl) {
-               X509 *server_cert;
-
-               if(ssl_ctx == NULL) {
-                       log_warning(_("SSL not available\n"));
-
-                       pop3_automaton_terminate(NULL, atm);
-                       automaton_destroy(atm);
-
-                       return INC_ERROR;
-               }
-
-               sockinfo->ssl = SSL_new(ssl_ctx);
-               if(sockinfo->ssl == NULL) {
-                       log_warning(_("Error creating ssl context\n"));
-
-                       pop3_automaton_terminate(NULL, atm);
-                       automaton_destroy(atm);
-
-                       return INC_ERROR;
-               }
-               SSL_set_fd(sockinfo->ssl, sockinfo->sock);
-               if(SSL_connect(sockinfo->ssl) == -1) {
-                       log_warning(_("SSL connect failed\n"));
-
-                       pop3_automaton_terminate(NULL, atm);
-                       automaton_destroy(atm);
-
-                       return INC_ERROR;
-               }
-               
-               /* Get the cipher */
-
-               log_print(_("SSL connection using %s\n"), SSL_get_cipher(sockinfo->ssl));
-  
-               /* Get server's certificate (note: beware of dynamic allocation) */
-
-               if((server_cert = SSL_get_peer_certificate(sockinfo->ssl)) != NULL) {
-                       char *str;
-                       
-                       log_print(_("Server certificate:\n"));
-  
-                       if((str = X509_NAME_oneline(X509_get_subject_name (server_cert),0,0)) != NULL) {
-                               log_print(_("  Subject: %s\n"), str);
-                               free(str);
-                       }
-                       
-                       if((str = X509_NAME_oneline(X509_get_issuer_name  (server_cert),0,0)) != NULL) {
-                               log_print(_("  Issuer: %s\n"), str);
-                               free(str);
-                       }
-
-                       X509_free(server_cert);
-               }
-       } else {
-               sockinfo->ssl = NULL;
-       }
-#endif
-
        recv_set_ui_func(inc_pop3_recv_func, session);
 
 #if USE_THREADS
@@ -658,13 +578,6 @@ static IncState inc_pop3_session_do(IncSession *session)
        pthread_join(sockinfo->connect_thr, NULL);
 */     
 #endif
-
-#if USE_SSL
-       if(sockinfo->ssl) {
-               SSL_free(sockinfo->ssl);
-       }
-#endif
-
        automaton_destroy(atm);
 
        return pop3_state->inc_state;
@@ -766,10 +679,7 @@ static gint connection_check_cb(Automaton *atm)
                log_warning(_("Can't connect to POP3 server: %s:%d\n"),
                            sockinfo->hostname, sockinfo->port);
                if(!prefs_common.noerrorpanel) {
-                       if((prefs_common.receive_dialog == RECVDIALOG_ALWAYS) ||
-                           ((prefs_common.receive_dialog == RECVDIALOG_WINDOW_ACTIVE) && focus_window)) {
-                               manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
-                       }
+                       manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
                        alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
                                         sockinfo->hostname, sockinfo->port);
                        manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
@@ -892,7 +802,7 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
                return -1;
        }
 
-       if (global_filtering == NULL) {
+       if (prefs_filtering == NULL) {
                /* old filtering */
                if (state->ac_prefs->filter_on_recv) {
                        dropfolder =
@@ -922,10 +832,10 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
                return -1;
        }
 
-       if (global_filtering != NULL) {
+       if (prefs_filtering != NULL) {
                /* new filtering */
                if (state->ac_prefs->filter_on_recv) {
-                       filter_message(global_filtering, dropfolder, msgnum,
+                       filter_message(prefs_filtering, dropfolder, msgnum,
                                       state->folder_table);
                }
        }
@@ -1052,8 +962,6 @@ static gint get_spool(FolderItem *dest, const gchar *mbox)
        unlock_mbox(mbox, lockfd, LOCK_FLOCK);
 
        if (folder_table) {
-               g_hash_table_insert(folder_table, dest,
-                                   GINT_TO_POINTER(1));
                folder_item_scan_foreach(folder_table);
                folderview_update_item_foreach(folder_table);
                g_hash_table_destroy(folder_table);
index 61f4419..798b28a 100644 (file)
@@ -83,10 +83,6 @@ gboolean debug_mode = FALSE;
 static gint lock_socket = -1;
 static gint lock_socket_tag = 0;
 
-#if USE_SSL
-SSL_CTX *ssl_ctx;
-#endif
-
 static struct Cmd {
        gboolean receive;
        gboolean receive_all;
@@ -237,27 +233,12 @@ int main(int argc, char *argv[])
        gpgme_register_idle(idle_function_for_gpgme);
 #endif
 
-#if USE_SSL
-       {
-               SSL_METHOD *meth;
-               
-               SSLeay_add_ssl_algorithms();
-               meth = SSLv2_client_method();
-               SSL_load_error_strings();
-               ssl_ctx = SSL_CTX_new(meth);
-               if(ssl_ctx == NULL) {
-                       debug_print(_("SSL disabled\n"));
-               } else {
-                       debug_print(_("SSL loaded: \n"));
-               }
-       }
-#endif
-
        prefs_common_save_config();
        prefs_filter_read_config();
        prefs_filter_write_config();
        prefs_display_header_read_config();
        prefs_display_header_write_config();
+       prefs_filtering_read_config();
 
        gtkut_widget_init();
 
@@ -278,7 +259,6 @@ 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);
@@ -298,12 +278,6 @@ int main(int argc, char *argv[])
 
        gtk_main();
 
-#if USE_SSL
-       if(ssl_ctx) {
-               SSL_CTX_free(ssl_ctx);
-       }
-#endif
-
        return 0;
 }
 
index 5fea39c..a43af9a 100644 (file)
@@ -7,7 +7,6 @@
 #include "procheader.h"
 #include "matcher.h"
 #include "intl.h"
-#include "matcher_parser.h"
 
 struct _MatchParser {
        gint id;
@@ -16,114 +15,90 @@ struct _MatchParser {
 
 typedef struct _MatchParser MatchParser;
 
-static MatchParser matchcriteria_str_tab[] = {
+static MatchParser matchparser_tab[] = {
        /* msginfo flags */
-       {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"},
+       {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"},
 
        /* msginfo headers */
-       {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"},
+       {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"},
 
        /* content have to be read */
-       {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"}
-};
+       {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"},
 
-static MatchParser matchtype_str_tab[] = {
        /* match type */
-       {MATCHTYPE_MATCHCASE, "matchcase"},
-       {MATCHTYPE_MATCH, "match"},
-       {MATCHTYPE_REGEXPCASE, "regexpcase"},
-       {MATCHTYPE_REGEXP, "regexp"}
-};
+       {MATCHING_MATCHCASE, "matchcase"},
+       {MATCHING_MATCH, "match"},
+       {MATCHING_REGEXPCASE, "regexpcase"},
+       {MATCHING_REGEXP, "regexp"},
 
-static MatchParser matchaction_str_tab[] = {
        /* actions */
-       {MATCHACTION_SCORE, "score"},
+       {MATCHING_SCORE, "score"},
 
        /* actions */
-       {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"}
+       {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"}, */
 };
 
-gchar * get_matchparser_str(MatchParser * tab, gint size, gint id)
+gchar * get_matchparser_tab_str(gint id)
 {
        gint i;
 
-       for(i = 0 ; i < size ; i++) {
-               if (tab[i].id == id)
-                       return tab[i].str;
+       for(i = 0 ; i < (int) (sizeof(matchparser_tab) / sizeof(MatchParser)) ;
+           i++) {
+               if (matchparser_tab[i].id == id)
+                       return matchparser_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);
-}
-
 
 
 /*
@@ -145,7 +120,6 @@ static gboolean matcher_is_blank(gchar ch)
 
 /* parse for one condition */
 
-/*
 MatcherProp * matcherprop_parse(gchar ** str)
 {
        MatcherProp * prop;
@@ -164,10 +138,10 @@ MatcherProp * matcherprop_parse(gchar ** str)
        }
 
        switch (key) {
-       case MATCHCRITERIA_AGE_LOWER:
-       case MATCHCRITERIA_AGE_GREATER:
-       case MATCHCRITERIA_SCORE_LOWER:
-       case MATCHCRITERIA_SCORE_GREATER:
+       case MATCHING_AGE_LOWER:
+       case MATCHING_AGE_GREATER:
+       case MATCHING_SCORE_LOWER:
+       case MATCHING_SCORE_GREATER:
                value = matcher_parse_number(&tmp);
                if (tmp == NULL) {
                        * str = NULL;
@@ -179,51 +153,51 @@ MatcherProp * matcherprop_parse(gchar ** str)
 
                return prop;
 
-       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 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:
                prop = matcherprop_new(key, NULL, 0, NULL, 0);
                *str = tmp;
 
                return prop;
 
-       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)) {
+       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)) {
                        header = matcher_parse_str(&tmp);
                        if (tmp == NULL) {
                                * str = NULL;
@@ -240,8 +214,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
                }
 
                switch(match) {
-               case MATCHCRITERIA_REGEXP:
-               case MATCHCRITERIA_REGEXPCASE:
+               case MATCHING_REGEXP:
+               case MATCHING_REGEXPCASE:
                        expr = matcher_parse_regexp(&tmp);
                        if (tmp == NULL) {
                                if (header)
@@ -254,8 +228,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
                        g_free(expr);
 
                        return prop;
-               case MATCHCRITERIA_MATCH:
-               case MATCHCRITERIA_MATCHCASE:
+               case MATCHING_MATCH:
+               case MATCHING_MATCHCASE:
                        expr = matcher_parse_str(&tmp);
                        if (tmp == NULL) {
                                if (header)
@@ -443,7 +417,6 @@ gchar * matcher_parse_str(gchar ** str)
        *str += dest - dup + 2;
        return g_strdup(start);
 }
-*/
 
 /* **************** data structure allocation **************** */
 
@@ -497,14 +470,13 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
                return FALSE;
 
        switch(prop->matchtype) {
-       case MATCHTYPE_REGEXPCASE:
-       case MATCHTYPE_REGEXP:
+       case MATCHING_REGEXPCASE:
+       case MATCHING_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 ==
-                                       MATCHTYPE_REGEXPCASE)
+                                   | ((prop->matchtype == MATCHING_REGEXPCASE)
                                    ? REG_ICASE : 0)) != 0) {
                                prop->error = 1;
                                g_free(prop->preg);
@@ -518,10 +490,10 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
                else
                        return FALSE;
 
-       case MATCHTYPE_MATCH:
+       case MATCHING_MATCH:
                return (strstr(str, prop->expr) != NULL);
 
-       case MATCHTYPE_MATCHCASE:
+       case MATCHING_MATCHCASE:
                str2 = alloca(strlen(prop->expr) + 1);
                strcpy(str2, prop->expr);
                g_strup(str2);
@@ -559,79 +531,79 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
        time_t t;
 
        switch(prop->criteria) {
-       case MATCHCRITERIA_ALL:
+       case MATCHING_ALL:
                return 1;
-       case MATCHCRITERIA_UNREAD:
+       case MATCHING_UNREAD:
                return MSG_IS_UNREAD(info->flags);
-       case MATCHCRITERIA_NOT_UNREAD:
+       case MATCHING_NOT_UNREAD:
                return !MSG_IS_UNREAD(info->flags);
-       case MATCHCRITERIA_NEW:
+       case MATCHING_NEW:
                return MSG_IS_NEW(info->flags);
-       case MATCHCRITERIA_NOT_NEW:
+       case MATCHING_NOT_NEW:
                return !MSG_IS_NEW(info->flags);
-       case MATCHCRITERIA_MARKED:
+       case MATCHING_MARKED:
                return MSG_IS_MARKED(info->flags);
-       case MATCHCRITERIA_NOT_MARKED:
+       case MATCHING_NOT_MARKED:
                return !MSG_IS_MARKED(info->flags);
-       case MATCHCRITERIA_DELETED:
+       case MATCHING_DELETED:
                return MSG_IS_DELETED(info->flags);
-       case MATCHCRITERIA_NOT_DELETED:
+       case MATCHING_NOT_DELETED:
                return !MSG_IS_DELETED(info->flags);
-       case MATCHCRITERIA_REPLIED:
+       case MATCHING_REPLIED:
                return MSG_IS_REPLIED(info->flags);
-       case MATCHCRITERIA_NOT_REPLIED:
+       case MATCHING_NOT_REPLIED:
                return !MSG_IS_REPLIED(info->flags);
-       case MATCHCRITERIA_FORWARDED:
+       case MATCHING_FORWARDED:
                return MSG_IS_FORWARDED(info->flags);
-       case MATCHCRITERIA_NOT_FORWARDED:
+       case MATCHING_NOT_FORWARDED:
                return !MSG_IS_FORWARDED(info->flags);
-       case MATCHCRITERIA_SUBJECT:
+       case MATCHING_SUBJECT:
                return matcherprop_string_match(prop, info->subject);
-       case MATCHCRITERIA_NOT_SUBJECT:
+       case MATCHING_NOT_SUBJECT:
                return !matcherprop_string_match(prop, info->subject);
-       case MATCHCRITERIA_FROM:
+       case MATCHING_FROM:
                return matcherprop_string_match(prop, info->from);
-       case MATCHCRITERIA_NOT_FROM:
+       case MATCHING_NOT_FROM:
                return !matcherprop_string_match(prop, info->from);
-       case MATCHCRITERIA_TO:
+       case MATCHING_TO:
                return matcherprop_string_match(prop, info->to);
-       case MATCHCRITERIA_NOT_TO:
+       case MATCHING_NOT_TO:
                return !matcherprop_string_match(prop, info->to);
-       case MATCHCRITERIA_CC:
+       case MATCHING_CC:
                return matcherprop_string_match(prop, info->cc);
-       case MATCHCRITERIA_NOT_CC:
+       case MATCHING_NOT_CC:
                return !matcherprop_string_match(prop, info->cc);
-       case MATCHCRITERIA_TO_OR_CC:
+       case MATCHING_TO_OR_CC:
                return matcherprop_string_match(prop, info->to)
                        || matcherprop_string_match(prop, info->cc);
-       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
+       case MATCHING_NOT_TO_AND_NOT_CC:
                return !(matcherprop_string_match(prop, info->to)
                || matcherprop_string_match(prop, info->cc));
-       case MATCHCRITERIA_AGE_GREATER:
+       case MATCHING_AGE_GREATER:
                t = time(NULL);
                return ((t - info->date_t) / (60 * 60 * 24)) >= prop->value;
-       case MATCHCRITERIA_AGE_LOWER:
+       case MATCHING_AGE_LOWER:
                t = time(NULL);
                return ((t - info->date_t) / (60 * 60 * 24)) <= prop->value;
-       case MATCHCRITERIA_SCORE_GREATER:
+       case MATCHING_SCORE_GREATER:
                return info->score >= prop->value;
-       case MATCHCRITERIA_SCORE_LOWER:
+       case MATCHING_SCORE_LOWER:
                return info->score <= prop->value;
-       case MATCHCRITERIA_NEWSGROUPS:
+       case MATCHING_NEWSGROUPS:
                return matcherprop_string_match(prop, info->newsgroups);
-       case MATCHCRITERIA_NOT_NEWSGROUPS:
+       case MATCHING_NOT_NEWSGROUPS:
                return !matcherprop_string_match(prop, info->newsgroups);
-       case MATCHCRITERIA_INREPLYTO:
+       case MATCHING_INREPLYTO:
                return matcherprop_string_match(prop, info->inreplyto);
-       case MATCHCRITERIA_NOT_INREPLYTO:
+       case MATCHING_NOT_INREPLYTO:
                return !matcherprop_string_match(prop, info->inreplyto);
-       case MATCHCRITERIA_REFERENCES:
+       case MATCHING_REFERENCES:
                return matcherprop_string_match(prop, info->references);
-       case MATCHCRITERIA_NOT_REFERENCES:
+       case MATCHING_NOT_REFERENCES:
                return !matcherprop_string_match(prop, info->references);
-       case MATCHCRITERIA_EXECUTE:
+       case MATCHING_EXECUTE:
                return matcherprop_match_execute(prop, info);
-       case MATCHCRITERIA_NOT_EXECUTE:
+       case MATCHING_NOT_EXECUTE:
                return !matcherprop_match_execute(prop, info);
        default:
                return 0;
@@ -643,7 +615,6 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
 
 /* parse for a list of conditions */
 
-/*
 MatcherList * matcherlist_parse(gchar ** str)
 {
        gchar * tmp;
@@ -696,7 +667,6 @@ MatcherList * matcherlist_parse(gchar ** str)
 
        return cond;
 }
-*/
 
 MatcherList * matcherlist_new(GSList * matchers, gboolean bool_and)
 {
@@ -744,14 +714,14 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
        Header *header;
 
        switch(matcher->criteria) {
-       case MATCHCRITERIA_HEADER:
-       case MATCHCRITERIA_NOT_HEADER:
+       case MATCHING_HEADER:
+       case MATCHING_NOT_HEADER:
                header = procheader_parse_header(buf);
                if (!header)
                        return FALSE;
                if (procheader_headername_equal(header->name,
                                                matcher->header)) {
-                       if (matcher->criteria == MATCHCRITERIA_HEADER)
+                       if (matcher->criteria == MATCHING_HEADER)
                                result = matcherprop_string_match(matcher, header->body);
                        else
                                result = !matcherprop_string_match(matcher, header->body);
@@ -762,11 +732,11 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
                        procheader_header_free(header);
                }
                break;
-       case MATCHCRITERIA_HEADERS_PART:
-       case MATCHCRITERIA_MESSAGE:
+       case MATCHING_HEADERS_PART:
+       case MATCHING_MESSAGE:
                return matcherprop_string_match(matcher, buf);
-       case MATCHCRITERIA_NOT_MESSAGE:
-       case MATCHCRITERIA_NOT_HEADERS_PART:
+       case MATCHING_NOT_MESSAGE:
+       case MATCHING_NOT_HEADERS_PART:
                return !matcherprop_string_match(matcher, buf);
        }
        return FALSE;
@@ -780,10 +750,10 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
 static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
 {
        switch(matcher->criteria) {
-       case MATCHCRITERIA_HEADER:
-       case MATCHCRITERIA_NOT_HEADER:
-       case MATCHCRITERIA_HEADERS_PART:
-       case MATCHCRITERIA_NOT_HEADERS_PART:
+       case MATCHING_HEADER:
+       case MATCHING_NOT_HEADER:
+       case MATCHING_HEADERS_PART:
+       case MATCHING_NOT_HEADERS_PART:
                return TRUE;
        default:
                return FALSE;
@@ -793,8 +763,8 @@ static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
 static gboolean matcherprop_criteria_message(MatcherProp * matcher)
 {
        switch(matcher->criteria) {
-       case MATCHCRITERIA_MESSAGE:
-       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHING_MESSAGE:
+       case MATCHING_NOT_MESSAGE:
                return TRUE;
        default:
                return FALSE;
@@ -856,8 +826,8 @@ static gboolean matcherlist_match_headers(MatcherList * matchers, FILE * fp)
 static gboolean matcherprop_criteria_body(MatcherProp * matcher)
 {
        switch(matcher->criteria) {
-       case MATCHCRITERIA_BODY_PART:
-       case MATCHCRITERIA_NOT_BODY_PART:
+       case MATCHING_BODY_PART:
+       case MATCHING_NOT_BODY_PART:
                return TRUE;
        default:
                return FALSE;
@@ -872,11 +842,11 @@ static gboolean matcherprop_criteria_body(MatcherProp * matcher)
 static gboolean matcherprop_match_line(MatcherProp * matcher, gchar * line)
 {
        switch(matcher->criteria) {
-       case MATCHCRITERIA_BODY_PART:
-       case MATCHCRITERIA_MESSAGE:
+       case MATCHING_BODY_PART:
+       case MATCHING_MESSAGE:
                return matcherprop_string_match(matcher, line);
-       case MATCHCRITERIA_NOT_BODY_PART:
-       case MATCHCRITERIA_NOT_MESSAGE:
+       case MATCHING_NOT_BODY_PART:
+       case MATCHING_NOT_MESSAGE:
                return !matcherprop_string_match(matcher, line);
        }
        return FALSE;
@@ -1025,41 +995,41 @@ gboolean matcherlist_match(MatcherList * matchers, MsgInfo * info)
                MatcherProp * matcher = (MatcherProp *) l->data;
 
                switch(matcher->criteria) {
-               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:
+               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:
                        if (matcherprop_match(matcher, info)) {
                                if (!matchers->bool_and) {
                                        return TRUE;
@@ -1098,16 +1068,16 @@ static void matcherprop_print(MatcherProp * matcher)
        }
 
        switch (matcher->matchtype) {
-       case MATCHCRITERIA_MATCH:
+       case MATCHING_MATCH:
                printf("match\n");
                break;
-       case MATCHCRITERIA_REGEXP:
+       case MATCHING_REGEXP:
                printf("regexp\n");
                break;
-       case MATCHCRITERIA_MATCHCASE:
+       case MATCHING_MATCHCASE:
                printf("matchcase\n");
                break;
-       case MATCHCRITERIA_REGEXPCASE:
+       case MATCHING_REGEXPCASE:
                printf("regexpcase\n");
                break;
        }
@@ -1140,73 +1110,96 @@ gchar * matcherprop_to_string(MatcherProp * matcher)
        gchar * out;
 
        criteria_str = NULL;
-
-       criteria_str = get_matchcriteria_str(matcher->criteria);
-
+       for(i = 0 ; i < (int) (sizeof(matchparser_tab) / sizeof(MatchParser)) ;
+           i++) {
+               if (matchparser_tab[i].id == matcher->criteria)
+                       criteria_str = matchparser_tab[i].str;
+       }
        if (criteria_str == NULL)
                return NULL;
 
        switch(matcher->criteria) {
-       case MATCHCRITERIA_AGE_GREATER:
-       case MATCHCRITERIA_AGE_LOWER:
-       case MATCHCRITERIA_SCORE_GREATER:
-       case MATCHCRITERIA_SCORE_LOWER:
+       case MATCHING_AGE_GREATER:
+       case MATCHING_AGE_LOWER:
+       case MATCHING_SCORE_GREATER:
+       case MATCHING_SCORE_LOWER:
                return g_strdup_printf("%s %i", criteria_str, matcher->value);
                break;
-       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 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:
                return g_strdup(criteria_str);
        }
 
        matchtype_str = NULL;
-
-       matchtype_str = get_matchtype_str(matcher->matchtype);
+       for(i = 0 ; i < (int) (sizeof(matchparser_tab) / sizeof(MatchParser)) ;
+           i++) {
+               if (matchparser_tab[i].id == matcher->matchtype)
+                       matchtype_str = matchparser_tab[i].str;
+       }
 
        if (matchtype_str == NULL)
                return NULL;
 
-       count = 0;
-       for(p = matcher->expr; *p != 0 ; p++)
-               if ((*p == '\"') || (*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 = *p;
-                       break;
-               default:
-                       *out = *p;
+       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;
                }
-       }
-       * 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);
+               * 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;
+       }
+
        return matcher_str;
 }
 
@@ -1389,3 +1382,14 @@ 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 12ce5db..6afad95 100644 (file)
@@ -7,11 +7,8 @@
 #include <glib.h>
 #include "procmsg.h"
 
-/*
 enum {
-*/
        /* msginfo flags */
-/*
        MATCHING_ALL,
        MATCHING_UNREAD,
        MATCHING_NOT_UNREAD,
@@ -25,9 +22,8 @@ enum {
        MATCHING_NOT_REPLIED,
        MATCHING_FORWARDED,
        MATCHING_NOT_FORWARDED,
-*/
+
        /* msginfo headers */
-/*
        MATCHING_SUBJECT,
        MATCHING_NOT_SUBJECT,
        MATCHING_FROM,
@@ -48,9 +44,8 @@ enum {
        MATCHING_NOT_REFERENCES,
        MATCHING_SCORE_GREATER,
        MATCHING_SCORE_LOWER,
-*/
+
        /* file content */
-/*
        MATCHING_HEADER,
        MATCHING_NOT_HEADER,
        MATCHING_MESSAGE,
@@ -61,13 +56,11 @@ enum {
        MATCHING_NOT_BODY_PART,
        MATCHING_EXECUTE,
        MATCHING_NOT_EXECUTE,
-*/
+
        /* scoring */
-/*
        MATCHING_SCORE,
-*/
+
        /* filtering */
-/*
        MATCHING_ACTION_MOVE,
        MATCHING_ACTION_COPY,
        MATCHING_ACTION_DELETE,
@@ -77,15 +70,13 @@ 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;
@@ -112,27 +103,21 @@ 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);
index fa3e22d..cf60a2c 100644 (file)
@@ -202,7 +202,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, GHashTable *folder_table)
                }
 
                if (folder_table) {
-                       if (global_filtering == NULL) {
+                       if (prefs_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 (global_filtering != NULL) {
+               if (prefs_filtering != NULL) {
                        /* new filtering */
                        if (folder_table) {
-                               filter_message(global_filtering, dropfolder,
+                               filter_message(prefs_filtering, dropfolder,
                                               msgnum, folder_table);
                        }
                }
index d6abd4f..4a00c6b 100644 (file)
@@ -45,7 +45,6 @@
 #include "gtkutils.h"
 #include "alertpanel.h"
 #include "folder.h"
-#include "matcher_parser.h"
 
 static struct Matcher {
        GtkWidget *window;
@@ -672,6 +671,7 @@ 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,9 +682,10 @@ static MatcherList * prefs_matcher_get_list(void)
                                  row, 0, &matcher_str)) {
 
                if (strcmp(matcher_str, _("(New)")) != 0) {
-                       prop = matcher_parser_get_prop(matcher_str);
+                       tmp = matcher_str;
+                       prop = matcherprop_parse(&tmp);
                        
-                       if (prop == NULL)
+                       if (tmp == NULL)
                                break;
                        
                        matcher_list = g_slist_append(matcher_list, prop);
@@ -702,74 +703,74 @@ static MatcherList * prefs_matcher_get_list(void)
 static gint prefs_matcher_get_criteria_from_matching(gint matching_id)
 {
        switch(matching_id) {
-       case MATCHCRITERIA_ALL:
+       case MATCHING_ALL:
                return CRITERIA_ALL;
-       case MATCHCRITERIA_NOT_UNREAD:
-       case MATCHCRITERIA_UNREAD:
+       case MATCHING_NOT_UNREAD:
+       case MATCHING_UNREAD:
                return CRITERIA_UNREAD;
-       case MATCHCRITERIA_NOT_NEW:
-       case MATCHCRITERIA_NEW:
+       case MATCHING_NOT_NEW:
+       case MATCHING_NEW:
                return CRITERIA_NEW;
-       case MATCHCRITERIA_NOT_MARKED:
-       case MATCHCRITERIA_MARKED:
+       case MATCHING_NOT_MARKED:
+       case MATCHING_MARKED:
                return CRITERIA_MARKED;
-       case MATCHCRITERIA_NOT_DELETED:
-       case MATCHCRITERIA_DELETED:
+       case MATCHING_NOT_DELETED:
+       case MATCHING_DELETED:
                return CRITERIA_DELETED;
                break;
-       case MATCHCRITERIA_NOT_REPLIED:
-       case MATCHCRITERIA_REPLIED:
+       case MATCHING_NOT_REPLIED:
+       case MATCHING_REPLIED:
                return CRITERIA_REPLIED;
-       case MATCHCRITERIA_NOT_FORWARDED:
-       case MATCHCRITERIA_FORWARDED:
+       case MATCHING_NOT_FORWARDED:
+       case MATCHING_FORWARDED:
                return CRITERIA_FORWARDED;
-       case MATCHCRITERIA_NOT_SUBJECT:
-       case MATCHCRITERIA_SUBJECT:
+       case MATCHING_NOT_SUBJECT:
+       case MATCHING_SUBJECT:
                return CRITERIA_SUBJECT;
-       case MATCHCRITERIA_NOT_FROM:
-       case MATCHCRITERIA_FROM:
+       case MATCHING_NOT_FROM:
+       case MATCHING_FROM:
                return CRITERIA_FROM;
-       case MATCHCRITERIA_NOT_TO:
-       case MATCHCRITERIA_TO:
+       case MATCHING_NOT_TO:
+       case MATCHING_TO:
                return CRITERIA_TO;
-       case MATCHCRITERIA_NOT_CC:
-       case MATCHCRITERIA_CC:
+       case MATCHING_NOT_CC:
+       case MATCHING_CC:
                return CRITERIA_CC;
-       case MATCHCRITERIA_NOT_NEWSGROUPS:
-       case MATCHCRITERIA_NEWSGROUPS:
+       case MATCHING_NOT_NEWSGROUPS:
+       case MATCHING_NEWSGROUPS:
                return CRITERIA_NEWSGROUPS;
-       case MATCHCRITERIA_NOT_INREPLYTO:
-       case MATCHCRITERIA_INREPLYTO:
+       case MATCHING_NOT_INREPLYTO:
+       case MATCHING_INREPLYTO:
                return CRITERIA_INREPLYTO;
-       case MATCHCRITERIA_NOT_REFERENCES:
-       case MATCHCRITERIA_REFERENCES:
+       case MATCHING_NOT_REFERENCES:
+       case MATCHING_REFERENCES:
                return CRITERIA_REFERENCES;
-       case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
-       case MATCHCRITERIA_TO_OR_CC:
+       case MATCHING_NOT_TO_AND_NOT_CC:
+       case MATCHING_TO_OR_CC:
                return CRITERIA_TO_OR_CC;
-       case MATCHCRITERIA_NOT_BODY_PART:
-       case MATCHCRITERIA_BODY_PART:
+       case MATCHING_NOT_BODY_PART:
+       case MATCHING_BODY_PART:
                return CRITERIA_BODY_PART;
-       case MATCHCRITERIA_NOT_MESSAGE:
-       case MATCHCRITERIA_MESSAGE:
+       case MATCHING_NOT_MESSAGE:
+       case MATCHING_MESSAGE:
                return CRITERIA_MESSAGE;
                break;
-       case MATCHCRITERIA_NOT_HEADERS_PART:
-       case MATCHCRITERIA_HEADERS_PART:
+       case MATCHING_NOT_HEADERS_PART:
+       case MATCHING_HEADERS_PART:
                return CRITERIA_HEADERS_PART;
-       case MATCHCRITERIA_NOT_HEADER:
-       case MATCHCRITERIA_HEADER:
+       case MATCHING_NOT_HEADER:
+       case MATCHING_HEADER:
                return CRITERIA_HEADER;
-       case MATCHCRITERIA_AGE_GREATER:
+       case MATCHING_AGE_GREATER:
                return CRITERIA_AGE_GREATER;
-       case MATCHCRITERIA_AGE_LOWER:
+       case MATCHING_AGE_LOWER:
                return CRITERIA_AGE_LOWER;
-       case MATCHCRITERIA_SCORE_GREATER:
+       case MATCHING_SCORE_GREATER:
                return CRITERIA_SCORE_GREATER;
-       case MATCHCRITERIA_SCORE_LOWER:
+       case MATCHING_SCORE_LOWER:
                return CRITERIA_SCORE_LOWER;
-       case MATCHCRITERIA_NOT_EXECUTE:
-       case MATCHCRITERIA_EXECUTE:
+       case MATCHING_NOT_EXECUTE:
+       case MATCHING_EXECUTE:
                return CRITERIA_EXECUTE;
                break;
        default:
@@ -781,53 +782,53 @@ static gint prefs_matcher_get_matching_from_criteria(gint criteria_id)
 {
        switch (criteria_id) {
        case CRITERIA_ALL:
-               return MATCHCRITERIA_ALL;
+               return MATCHING_ALL;
        case CRITERIA_UNREAD:
-               return MATCHCRITERIA_UNREAD;
+               return MATCHING_UNREAD;
        case CRITERIA_NEW:
-               return MATCHCRITERIA_NEW;
+               return MATCHING_NEW;
        case CRITERIA_MARKED:
-               return MATCHCRITERIA_MARKED;
+               return MATCHING_MARKED;
        case CRITERIA_DELETED:
-               return MATCHCRITERIA_DELETED;
+               return MATCHING_DELETED;
        case CRITERIA_REPLIED:
-               return MATCHCRITERIA_REPLIED;
+               return MATCHING_REPLIED;
        case CRITERIA_FORWARDED:
-               return MATCHCRITERIA_FORWARDED;
+               return MATCHING_FORWARDED;
        case CRITERIA_SUBJECT:
-               return MATCHCRITERIA_SUBJECT;
+               return MATCHING_SUBJECT;
        case CRITERIA_FROM:
-               return MATCHCRITERIA_FROM;
+               return MATCHING_FROM;
        case CRITERIA_TO:
-               return MATCHCRITERIA_TO;
+               return MATCHING_TO;
        case CRITERIA_CC:
-               return MATCHCRITERIA_CC;
+               return MATCHING_CC;
        case CRITERIA_TO_OR_CC:
-               return MATCHCRITERIA_TO_OR_CC;
+               return MATCHING_TO_OR_CC;
        case CRITERIA_NEWSGROUPS:
-               return MATCHCRITERIA_NEWSGROUPS;
+               return MATCHING_NEWSGROUPS;
        case CRITERIA_INREPLYTO:
-               return MATCHCRITERIA_INREPLYTO;
+               return MATCHING_INREPLYTO;
        case CRITERIA_REFERENCES:
-               return MATCHCRITERIA_REFERENCES;
+               return MATCHING_REFERENCES;
        case CRITERIA_AGE_GREATER:
-               return MATCHCRITERIA_AGE_GREATER;
+               return MATCHING_AGE_GREATER;
        case CRITERIA_AGE_LOWER:
-               return MATCHCRITERIA_AGE_LOWER;
+               return MATCHING_AGE_LOWER;
        case CRITERIA_SCORE_GREATER:
-               return MATCHCRITERIA_SCORE_GREATER;
+               return MATCHING_SCORE_GREATER;
        case CRITERIA_SCORE_LOWER:
-               return MATCHCRITERIA_SCORE_LOWER;
+               return MATCHING_SCORE_LOWER;
        case CRITERIA_HEADER:
-               return MATCHCRITERIA_HEADER;
+               return MATCHING_HEADER;
        case CRITERIA_HEADERS_PART:
-               return MATCHCRITERIA_HEADERS_PART;
+               return MATCHING_HEADERS_PART;
        case CRITERIA_BODY_PART:
-               return MATCHCRITERIA_BODY_PART;
+               return MATCHING_BODY_PART;
        case CRITERIA_MESSAGE:
-               return MATCHCRITERIA_MESSAGE;
+               return MATCHING_MESSAGE;
        case CRITERIA_EXECUTE:
-               return MATCHCRITERIA_EXECUTE;
+               return MATCHING_EXECUTE;
        default:
                return -1;
        }
@@ -836,44 +837,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 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;
+       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;
        default:
                return matcher_criteria;
        }
@@ -936,15 +937,15 @@ static MatcherProp * prefs_matcher_dialog_to_matcher()
 
        if (use_regexp) {
                if (case_sensitive)
-                       matchtype = MATCHTYPE_REGEXP;
+                       matchtype = MATCHING_REGEXP;
                else
-                       matchtype = MATCHTYPE_REGEXPCASE;
+                       matchtype = MATCHING_REGEXPCASE;
        }
        else {
                if (case_sensitive)
-                       matchtype = MATCHTYPE_MATCH;
+                       matchtype = MATCHING_MATCH;
                else
-                       matchtype = MATCHTYPE_MATCHCASE;
+                       matchtype = MATCHING_MATCHCASE;
        }
 
        header = NULL;
@@ -1120,8 +1121,9 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
                return;
        }
 
-       prop = matcher_parser_get_prop(matcher_str);
-       if (prop == NULL)
+       tmp = matcher_str;
+       prop = matcherprop_parse(&tmp);
+       if (tmp == NULL)
                return;
 
        criteria = prefs_matcher_get_criteria_from_matching(prop->criteria);
@@ -1130,66 +1132,66 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
                                     criteria);
 
        switch(prop->criteria) {
-       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:
+       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:
                negative_cond = TRUE;
                break;
        }
        
        switch(prop->criteria) {
-       case MATCHCRITERIA_ALL:
+       case MATCHING_ALL:
                break;
 
-       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:
+       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:
                gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), prop->expr);
                break;
 
-       case MATCHCRITERIA_AGE_GREATER:
-       case MATCHCRITERIA_AGE_LOWER:
-       case MATCHCRITERIA_SCORE_GREATER:
-       case MATCHCRITERIA_SCORE_LOWER:
+       case MATCHING_AGE_GREATER:
+       case MATCHING_AGE_LOWER:
+       case MATCHING_SCORE_GREATER:
+       case MATCHING_SCORE_LOWER:
                gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), itos(prop->value));
                break;
 
-       case MATCHCRITERIA_NOT_HEADER:
-       case MATCHCRITERIA_HEADER:
+       case MATCHING_NOT_HEADER:
+       case MATCHING_HEADER:
                gtk_entry_set_text(GTK_ENTRY(matcher.header_entry), prop->header);
                gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), prop->expr);
                break;
@@ -1201,22 +1203,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 MATCHTYPE_MATCH:
+       case MATCHING_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 MATCHTYPE_MATCHCASE:
+       case MATCHING_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 MATCHTYPE_REGEXP:
+       case MATCHING_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 MATCHTYPE_REGEXPCASE:
+       case MATCHING_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 1c3102c..7eeddbb 100644 (file)
@@ -46,7 +46,6 @@
 #include "alertpanel.h"
 #include "folder.h"
 #include "scoring.h"
-#include "matcher_parser.h"
 
 static struct Scoring {
        GtkWidget *window;
@@ -441,6 +440,7 @@ static void prefs_scoring_set_list(void)
        ScoringProp *prop;
        GSList * cur;
        gchar * scoring_str;
+       gchar * tmp;
        GSList * prefs_scoring;
 
        if (cur_item == NULL)
@@ -457,7 +457,8 @@ 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) {
-                       prop = matcher_parser_get_scoring(scoring_str);
+                       tmp = scoring_str;
+                       prop = scoringprop_parse(&tmp);
                        if (prop != NULL)
                                prefs_scoring = g_slist_append(prefs_scoring,
                                                               prop);
@@ -529,9 +530,11 @@ static void prefs_scoring_condition_define(void)
        cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
 
        if (*cond_str != '\0') {
-               matchers = matcher_parser_get_cond(cond_str);
-
-               if (matchers == NULL)
+               gchar * tmp;
+               
+               tmp = cond_str;
+               matchers = matcherlist_parse(&tmp);
+               if (tmp == NULL)
                        alertpanel_error(_("Match string is not valid."));
        }
 
@@ -551,6 +554,7 @@ 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') {
@@ -565,9 +569,10 @@ static void prefs_scoring_register_cb(void)
        }
 
        score = atoi(score_str);
-       cond = matcher_parser_get_cond(cond_str);
+       tmp = cond_str;
+       cond = matcherlist_parse(&tmp);
 
-       if (cond == NULL) {
+       if (tmp == NULL) {
                alertpanel_error(_("Match string is not valid."));
                return;
        }
@@ -590,6 +595,7 @@ static void prefs_scoring_substitute_cb(void)
        gchar * score_str;
        ScoringProp * prop;
        gint score;
+       gchar * tmp;
 
        if (!clist->selection) return;
 
@@ -609,9 +615,10 @@ static void prefs_scoring_substitute_cb(void)
        }
 
        score = atoi(score_str);
-       cond = matcher_parser_get_cond(cond_str);
+       tmp = cond_str;
+       cond = matcherlist_parse(&tmp);
 
-       if (cond) {
+       if (tmp == NULL) {
                alertpanel_error(_("Match string is not valid."));
                return;
        }
@@ -694,6 +701,7 @@ static void prefs_scoring_select(GtkCList *clist, gint row, gint column,
                                GdkEvent *event)
 {
        ScoringProp * prop;
+       gchar * tmp;
 
        gchar * scoring_str;
 
@@ -706,8 +714,9 @@ static void prefs_scoring_select(GtkCList *clist, gint row, gint column,
                                row, 0, &scoring_str))
                return;
 
-       prop = matcher_parser_get_scoring(scoring_str);
-       if (prop == NULL)
+       tmp = scoring_str;
+       prop = scoringprop_parse(&tmp);
+       if (tmp == NULL)
                return;
 
        prefs_scoring_select_set_dialog(prop);
index 2f3ed24..9ff0ee9 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;
@@ -62,7 +60,7 @@ ScoringProp * scoringprop_parse(gchar ** str)
        * str = tmp;
        return scoring;
 }
-*/
+
 
 ScoringProp * scoringprop_new(MatcherList * matchers, int score)
 {
@@ -199,7 +197,7 @@ gchar * scoringprop_to_string(ScoringProp * prop)
                return NULL;
 
        score_str = itos(prop->score);
-       scoring_str = g_strconcat(list_str, " score ", score_str, "\n", NULL);
+       scoring_str = g_strconcat(list_str, " score ", score_str, NULL);
        g_free(list_str);
 
        return scoring_str;
@@ -267,7 +265,7 @@ static gboolean prefs_scoring_free_func(GNode *node, gpointer data)
        return FALSE;
 }
 
-void prefs_scoring_clear()
+static void prefs_scoring_clear()
 {
        GList * cur;
 
@@ -283,33 +281,6 @@ 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_parserrestart(fp);
-       if (matcher_parserparse() != 0) {
-               prefs_scoring_clear();
-       }
-       g_free(rcpath);
-       fclose(fp);
-}
-
-/*
 void prefs_scoring_read_config(void)
 {
        gchar *rcpath;
@@ -318,7 +289,7 @@ void prefs_scoring_read_config(void)
        GSList * prefs_scoring = NULL;
        FolderItem * item = NULL;
 
-       debug_print(_("Reading scoring configuration...\n"));
+       debug_print(_("Reading headers configuration...\n"));
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, SCORING_RC, NULL);
        if ((fp = fopen(rcpath, "r")) == NULL) {
@@ -369,9 +340,7 @@ void prefs_scoring_read_config(void)
                                                               scoring);
                        }
                        else {
-*/
                                /* debug */
-/*
                                g_warning(_("syntax error : %s\n"), buf);
                        }
                }
@@ -384,7 +353,6 @@ void prefs_scoring_read_config(void)
 
        fclose(fp);
 }
-*/
 
 static void prefs_scoring_write(FILE * fp, GSList * prefs_scoring)
 {
@@ -396,8 +364,9 @@ 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) {
-                       FILE_OP_ERROR("scoring config", "fputs");
+               if (fputs(scoring_str, fp) == EOF ||
+                   fputc('\n', fp) == EOF) {
+                       FILE_OP_ERROR("scoring config", "fputs || fputc");
                        g_free(scoring_str);
                        return;
                }
index 771437d..e8627ac 100644 (file)
@@ -24,9 +24,8 @@ 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);
 
@@ -36,6 +35,4 @@ gchar * scoringprop_to_string(ScoringProp * prop);
 
 void prefs_scoring_free(GSList * prefs_scoring);
 
-void prefs_scoring_clear();
-
 #endif