Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[platform/upstream/evolution-data-server.git] / camel / camel-search-private.h
1 /*
2  *  Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
3  *
4  *  Authors: Michael Zucchi <notzed@ximian.com>
5  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef CAMEL_SEARCH_PRIVATE_H
22 #define CAMEL_SEARCH_PRIVATE_H
23
24 /* POSIX requires <sys/types.h> be included before <regex.h> */
25 #include <sys/types.h>
26
27 #include <regex.h>
28
29 #include <camel/camel.h>
30
31 G_BEGIN_DECLS
32
33 typedef enum {
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;
40
41 typedef enum {
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;
49
50 typedef enum {
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 */
56 } camel_search_t;
57
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);
61
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);
64
65 /* TODO: replace with a real search function */
66 const gchar *camel_ustrstrcase (const gchar *haystack, const gchar *needle);
67
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;
74
75 struct _camel_search_word {
76         camel_search_word_t type;
77         gchar *word;
78 };
79
80 struct _camel_search_words {
81         gint len;
82         camel_search_word_t type;       /* OR of all word types in list */
83         struct _camel_search_word **words;
84 };
85
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 *);
89
90 G_END_DECLS
91
92 #endif /* CAMEL_SEARCH_PRIVATE_H */