1 /* 2 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 3 * 4 * This library is free software: you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation. 7 * 8 * This library is distributed in the hope that it will be useful, but 9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 * for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this library. If not, see <http://www.gnu.org/licenses/>. 15 * 16 * Authors: Michael Zucchi <notzed@ximian.com> 17 */ 18 19 #ifndef CAMEL_SEARCH_PRIVATE_H 20 #define CAMEL_SEARCH_PRIVATE_H 21 22 /* POSIX requires <sys/types.h> be included before <regex.h> */ 23 #include <sys/types.h> 24 25 #include <regex.h> 26 27 #include <camel/camel.h> 28 29 G_BEGIN_DECLS 30 31 typedef enum { 32 CAMEL_SEARCH_MATCH_START = 1 << 0, 33 CAMEL_SEARCH_MATCH_END = 1 << 1, 34 CAMEL_SEARCH_MATCH_REGEX = 1 << 2, /* disables the first 2 */ 35 CAMEL_SEARCH_MATCH_ICASE = 1 << 3, 36 CAMEL_SEARCH_MATCH_NEWLINE = 1 << 4 37 } camel_search_flags_t; 38 39 typedef enum { 40 CAMEL_SEARCH_MATCH_EXACT, 41 CAMEL_SEARCH_MATCH_CONTAINS, 42 CAMEL_SEARCH_MATCH_WORD, 43 CAMEL_SEARCH_MATCH_STARTS, 44 CAMEL_SEARCH_MATCH_ENDS, 45 CAMEL_SEARCH_MATCH_SOUNDEX 46 } camel_search_match_t; 47 48 typedef enum { 49 CAMEL_SEARCH_TYPE_ASIS, 50 CAMEL_SEARCH_TYPE_ENCODED, 51 CAMEL_SEARCH_TYPE_ADDRESS, 52 CAMEL_SEARCH_TYPE_ADDRESS_ENCODED, 53 CAMEL_SEARCH_TYPE_MLIST /* its a mailing list pseudo-header */ 54 } camel_search_t; 55 56 /* builds a regex that represents a string search */ 57 gint camel_search_build_match_regex (regex_t *pattern, 58 camel_search_flags_t type, 59 gint argc, 60 CamelSExpResult **argv, 61 GError **error); 62 gboolean camel_search_message_body_contains 63 (CamelDataWrapper *object, 64 regex_t *pattern); 65 66 gboolean camel_search_header_match (const gchar *value, 67 const gchar *match, 68 camel_search_match_t how, 69 camel_search_t type, 70 const gchar *default_charset); 71 gboolean camel_search_camel_header_soundex 72 (const gchar *header, 73 const gchar *match); 74 75 /* TODO: replace with a real search function */ 76 const gchar * camel_ustrstrcase (const gchar *haystack, 77 const gchar *needle); 78 79 /* Some crappy utility functions for handling multiple search words */ 80 typedef enum _camel_search_word_t { 81 CAMEL_SEARCH_WORD_SIMPLE = 1, 82 CAMEL_SEARCH_WORD_COMPLEX = 2, 83 CAMEL_SEARCH_WORD_8BIT = 4 84 } camel_search_word_t; 85 86 struct _camel_search_word { 87 camel_search_word_t type; 88 gchar *word; 89 }; 90 91 struct _camel_search_words { 92 gint len; 93 camel_search_word_t type; /* OR of all word types in list */ 94 struct _camel_search_word **words; 95 }; 96 97 struct _camel_search_words * 98 camel_search_words_split (const guchar *in); 99 struct _camel_search_words * 100 camel_search_words_simple (struct _camel_search_words *words); 101 void camel_search_words_free (struct _camel_search_words *words); 102 103 gboolean camel_search_header_is_address (const gchar *header_name); 104 const gchar * camel_search_get_default_charset_from_message 105 (CamelMimeMessage *message); 106 const gchar * camel_search_get_default_charset_from_headers 107 (const CamelNameValueArray *headers); 108 gchar * camel_search_get_header_decoded (const gchar *header_name, 109 const gchar *header_value, 110 const gchar *default_charset); 111 gchar * camel_search_get_headers_decoded(const CamelNameValueArray *headers, 112 const gchar *default_charset); 113 gchar * camel_search_get_all_headers_decoded 114 (CamelMimeMessage *message); 115 116 G_END_DECLS 117 118 #endif /* CAMEL_SEARCH_PRIVATE_H */ 119