2 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
4 * Authors: Michael Zucchi <notzed@ximian.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU Lesser General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef CAMEL_SEARCH_PRIVATE_H
22 #define CAMEL_SEARCH_PRIVATE_H
24 /* POSIX requires <sys/types.h> be included before <regex.h> */
25 #include <sys/types.h>
29 #include <camel/camel.h>
34 CAMEL_SEARCH_MATCH_START = 1 << 0,
35 CAMEL_SEARCH_MATCH_END = 1 << 1,
36 CAMEL_SEARCH_MATCH_REGEX = 1 << 2, /* disables the first 2 */
37 CAMEL_SEARCH_MATCH_ICASE = 1 << 3,
38 CAMEL_SEARCH_MATCH_NEWLINE = 1 << 4
39 } camel_search_flags_t;
42 CAMEL_SEARCH_MATCH_EXACT,
43 CAMEL_SEARCH_MATCH_CONTAINS,
44 CAMEL_SEARCH_MATCH_WORD,
45 CAMEL_SEARCH_MATCH_STARTS,
46 CAMEL_SEARCH_MATCH_ENDS,
47 CAMEL_SEARCH_MATCH_SOUNDEX
48 } camel_search_match_t;
51 CAMEL_SEARCH_TYPE_ASIS,
52 CAMEL_SEARCH_TYPE_ENCODED,
53 CAMEL_SEARCH_TYPE_ADDRESS,
54 CAMEL_SEARCH_TYPE_ADDRESS_ENCODED,
55 CAMEL_SEARCH_TYPE_MLIST /* its a mailing list pseudo-header */
58 /* builds a regex that represents a string search */
59 gint camel_search_build_match_regex (regex_t *pattern, camel_search_flags_t type, gint argc, struct _CamelSExpResult **argv, GError **error);
60 gboolean camel_search_message_body_contains (CamelDataWrapper *object, regex_t *pattern);
62 gboolean camel_search_header_match (const gchar *value, const gchar *match, camel_search_match_t how, camel_search_t type, const gchar *default_charset);
63 gboolean camel_search_camel_header_soundex (const gchar *header, const gchar *match);
65 /* TODO: replace with a real search function */
66 const gchar *camel_ustrstrcase (const gchar *haystack, const gchar *needle);
68 /* Some crappy utility functions for handling multiple search words */
69 typedef enum _camel_search_word_t {
70 CAMEL_SEARCH_WORD_SIMPLE = 1,
71 CAMEL_SEARCH_WORD_COMPLEX = 2,
72 CAMEL_SEARCH_WORD_8BIT = 4
73 } camel_search_word_t;
75 struct _camel_search_word {
76 camel_search_word_t type;
80 struct _camel_search_words {
82 camel_search_word_t type; /* OR of all word types in list */
83 struct _camel_search_word **words;
86 struct _camel_search_words *camel_search_words_split (const guchar *in);
87 struct _camel_search_words *camel_search_words_simple (struct _camel_search_words *wordin);
88 void camel_search_words_free (struct _camel_search_words *);
92 #endif /* CAMEL_SEARCH_PRIVATE_H */