2 * Copyright (C) 2001 Ximian Inc.
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-exception.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_STARTS,
45 CAMEL_SEARCH_MATCH_ENDS,
46 CAMEL_SEARCH_MATCH_SOUNDEX,
47 } camel_search_match_t;
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 */
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);
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);
64 /* TODO: replace with a real search function */
65 const char *camel_ustrstrcase(const char *haystack, const char *needle);
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;
74 struct _camel_search_word {
75 camel_search_word_t type;
79 struct _camel_search_words {
81 camel_search_word_t type; /* OR of all word types in list */
82 struct _camel_search_word **words;
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 *);
91 #endif /* ! _CAMEL_SEARCH_PRIVATE_H */