Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-search-private.h
1 /*
2  *  Copyright (C) 2001 Ximian Inc.
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-exception.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_STARTS,
45         CAMEL_SEARCH_MATCH_ENDS,
46         CAMEL_SEARCH_MATCH_SOUNDEX,
47 } camel_search_match_t;
48
49 typedef enum {
50         CAMEL_SEARCH_TYPE_ASIS,
51         CAMEL_SEARCH_TYPE_ENCODED,
52         CAMEL_SEARCH_TYPE_ADDRESS,
53         CAMEL_SEARCH_TYPE_ADDRESS_ENCODED,
54         CAMEL_SEARCH_TYPE_MLIST, /* its a mailing list pseudo-header */
55 } camel_search_t;
56
57 /* builds a regex that represents a string search */
58 int camel_search_build_match_regex(regex_t *pattern, camel_search_flags_t type, int argc, struct _ESExpResult **argv, CamelException *ex);
59 gboolean camel_search_message_body_contains(CamelDataWrapper *object, regex_t *pattern);
60
61 gboolean camel_search_header_match(const char *value, const char *match, camel_search_match_t how, camel_search_t type, const char *default_charset);
62 gboolean camel_search_camel_header_soundex(const char *header, const char *match);
63
64 /* TODO: replace with a real search function */
65 const char *camel_ustrstrcase(const char *haystack, const char *needle);
66
67 /* Some crappy utility functions for handling multiple search words */
68 typedef enum _camel_search_word_t {
69         CAMEL_SEARCH_WORD_SIMPLE = 1,
70         CAMEL_SEARCH_WORD_COMPLEX = 2,
71         CAMEL_SEARCH_WORD_8BIT = 4,
72 } camel_search_word_t;
73
74 struct _camel_search_word {
75         camel_search_word_t type;
76         char *word;
77 };
78
79 struct _camel_search_words {
80         int len;
81         camel_search_word_t type;       /* OR of all word types in list */
82         struct _camel_search_word **words;
83 };
84
85 struct _camel_search_words *camel_search_words_split(const unsigned char *in);
86 struct _camel_search_words *camel_search_words_simple(struct _camel_search_words *wordin);
87 void camel_search_words_free(struct _camel_search_words *);
88
89 G_END_DECLS
90
91 #endif /* ! _CAMEL_SEARCH_PRIVATE_H */