Add a fast way to search for Message-ID (at least)
[claws.git] / src / matcher.h
index 55998b3b848622917b91d440489737b7c405d76c..66cd8c7da88b376aa685f17c0b23a88fc72fe27b 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002 by the Claws Mail Team and Hiroyuki Yamamoto
+ * Copyright (C) 2002-2014 by the Claws Mail Team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifndef MATCHER_H
 #include <sys/types.h>
 #include <regex.h>
 #include <glib.h>
-#include "procmsg.h"
+#include "proctypes.h"
+#include "matchertypes.h"
 
 /* constants generated by yacc */
-#if !defined(YYBISON) && !defined(MATCHER_ALL)
-#       include "matcher_parser_lex.h"
-#      include "matcher_parser_parse.h"
-#endif
+#include "matcher_parser_lex.h"
+#include "matcher_parser_parse.h"
 
 struct _MatcherProp {
        int matchtype;
@@ -37,21 +36,19 @@ struct _MatcherProp {
        gchar *header;
        gchar *expr;
        int value;
+#ifndef G_OS_WIN32
        regex_t *preg;
+#endif
        int error;
        gboolean result;
        gboolean done;
 };
 
-typedef struct _MatcherProp MatcherProp;
-
 struct _MatcherList {
        GSList *matchers;
        gboolean bool_and;
 };
 
-typedef struct _MatcherList MatcherList;
-
 
 /* map MATCHCRITERIA_ to yacc's MATCHER_ */
 #define MC_(name) \
@@ -80,21 +77,27 @@ enum {
        MC_(FORWARDED), MC_(NOT_FORWARDED),
        MC_(LOCKED), MC_(NOT_LOCKED),
        MC_(SPAM),MC_(NOT_SPAM),
+       MC_(HAS_ATTACHMENT), MC_(HAS_NO_ATTACHMENT),
+       MC_(SIGNED), MC_(NOT_SIGNED),
        MC_(PARTIAL), MC_(NOT_PARTIAL),
        MC_(COLORLABEL), MC_(NOT_COLORLABEL),
        MC_(IGNORE_THREAD), MC_(NOT_IGNORE_THREAD),
+       MC_(WATCH_THREAD), MC_(NOT_WATCH_THREAD),
        MC_(SUBJECT), MC_(NOT_SUBJECT),
        MC_(FROM), MC_(NOT_FROM),
        MC_(TO), MC_(NOT_TO),
        MC_(CC), MC_(NOT_CC),
        MC_(TO_OR_CC), MC_(NOT_TO_AND_NOT_CC),
        MC_(AGE_GREATER), MC_(AGE_LOWER),
+       MC_(AGE_GREATER_HOURS), MC_(AGE_LOWER_HOURS),
        MC_(NEWSGROUPS), MC_(NOT_NEWSGROUPS),
+       MC_(MESSAGEID), MC_(NOT_MESSAGEID),
        MC_(INREPLYTO), MC_(NOT_INREPLYTO),
        MC_(REFERENCES), MC_(NOT_REFERENCES),
        MC_(SCORE_GREATER), MC_(SCORE_LOWER),
        MC_(HEADER), MC_(NOT_HEADER),
        MC_(HEADERS_PART), MC_(NOT_HEADERS_PART),
+       MC_(HEADERS_CONT), MC_(NOT_HEADERS_CONT),
        MC_(MESSAGE), MC_(NOT_MESSAGE),
        MC_(BODY_PART), MC_(NOT_BODY_PART),
        MC_(TEST), MC_(NOT_TEST),
@@ -103,6 +106,8 @@ enum {
        MC_(SIZE_SMALLER),
        MC_(SIZE_EQUAL),
        MC_(FOUND_IN_ADDRESSBOOK),MC_(NOT_FOUND_IN_ADDRESSBOOK),
+       MC_(TAG),MC_(NOT_TAG),
+       MC_(TAGGED),MC_(NOT_TAGGED),
 
        /* match type */
        MT_(MATCHCASE),
@@ -132,11 +137,19 @@ enum {
        MA_(STOP),
        MA_(HIDE),
        MA_(IGNORE),
+       MA_(WATCH),
+       MA_(ADD_TO_ADDRESSBOOK),
+       MA_(SET_TAG),
+       MA_(UNSET_TAG),
+       MA_(CLEAR_TAGS),
        /* boolean operations */
        MB_(OR),
        MB_(AND)
 };
 
+void matcher_init(void);
+void matcher_done(void);
+
 const gchar *get_matchparser_tab_str   (gint id);
 gint get_matchparser_tab_id            (const gchar *str); 
 
@@ -151,11 +164,11 @@ MatcherProp *matcherprop_parse            (gchar  **str);
 
 MatcherProp *matcherprop_copy          (const MatcherProp *src);
 
-gboolean matcherprop_match             (MatcherProp    *prop, 
-                                        MsgInfo        *info);
-
 MatcherList * matcherlist_new          (GSList         *matchers, 
                                         gboolean       bool_and);
+MatcherList * matcherlist_new_from_lines(gchar         *lines,
+                                        gboolean       bool_and,
+                                        gboolean       case_sensitive);
 void matcherlist_free                  (MatcherList    *cond);
 
 MatcherList *matcherlist_parse         (gchar          **str);