Add optimized indexing capabilities for phone number values.
[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,
60                                                  camel_search_flags_t type,
61                                                  gint argc,
62                                                  CamelSExpResult **argv,
63                                                  GError **error);
64 gboolean        camel_search_message_body_contains
65                                                 (CamelDataWrapper *object,
66                                                  regex_t *pattern);
67
68 gboolean        camel_search_header_match       (const gchar *value,
69                                                  const gchar *match,
70                                                  camel_search_match_t how,
71                                                  camel_search_t type,
72                                                  const gchar *default_charset);
73 gboolean        camel_search_camel_header_soundex
74                                                 (const gchar *header,
75                                                  const gchar *match);
76
77 /* TODO: replace with a real search function */
78 const gchar *   camel_ustrstrcase               (const gchar *haystack,
79                                                  const gchar *needle);
80
81 /* Some crappy utility functions for handling multiple search words */
82 typedef enum _camel_search_word_t {
83         CAMEL_SEARCH_WORD_SIMPLE = 1,
84         CAMEL_SEARCH_WORD_COMPLEX = 2,
85         CAMEL_SEARCH_WORD_8BIT = 4
86 } camel_search_word_t;
87
88 struct _camel_search_word {
89         camel_search_word_t type;
90         gchar *word;
91 };
92
93 struct _camel_search_words {
94         gint len;
95         camel_search_word_t type;       /* OR of all word types in list */
96         struct _camel_search_word **words;
97 };
98
99 struct _camel_search_words *
100                 camel_search_words_split        (const guchar *in);
101 struct _camel_search_words *
102                 camel_search_words_simple       (struct _camel_search_words *words);
103 void            camel_search_words_free         (struct _camel_search_words *words);
104
105 G_END_DECLS
106
107 #endif /* CAMEL_SEARCH_PRIVATE_H */