Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-storage/mail-search.h @ 7284:346d4a44c2f4 HEAD
SEARCH SUBJECT now changes LWSP to spaces to match ENVELOPE's subject field.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 21 Feb 2008 22:52:38 +0200 |
parents | ae369569e7de |
children | 6dbd70663adf |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5599
diff
changeset
|
1 #ifndef MAIL_SEARCH_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5599
diff
changeset
|
2 #define MAIL_SEARCH_H |
0 | 3 |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
4 #include "mail-types.h" |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
5 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
6 enum mail_search_arg_type { |
0 | 7 SEARCH_OR, |
8 SEARCH_SUB, | |
9 | |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
10 /* sequence sets */ |
0 | 11 SEARCH_ALL, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
12 SEARCH_SEQSET, |
0 | 13 |
14 /* flags */ | |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
15 SEARCH_FLAGS, |
6965
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
16 SEARCH_KEYWORDS, |
0 | 17 |
18 /* dates */ | |
19 SEARCH_BEFORE, | |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
20 SEARCH_ON, /* time must point to beginning of the day */ |
0 | 21 SEARCH_SINCE, |
22 SEARCH_SENTBEFORE, | |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
23 SEARCH_SENTON, /* time must point to beginning of the day */ |
0 | 24 SEARCH_SENTSINCE, |
25 | |
26 /* sizes */ | |
27 SEARCH_SMALLER, | |
28 SEARCH_LARGER, | |
29 | |
30 /* headers */ | |
31 SEARCH_HEADER, | |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
32 SEARCH_HEADER_ADDRESS, |
7284
346d4a44c2f4
SEARCH SUBJECT now changes LWSP to spaces to match ENVELOPE's subject field.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
33 SEARCH_HEADER_COMPRESS_LWSP, |
0 | 34 |
35 /* body */ | |
36 SEARCH_BODY, | |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4906
diff
changeset
|
37 SEARCH_TEXT, |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4906
diff
changeset
|
38 SEARCH_BODY_FAST, |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4906
diff
changeset
|
39 SEARCH_TEXT_FAST |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
40 }; |
0 | 41 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
42 struct mail_search_seqset { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
43 uint32_t seq1, seq2; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
44 struct mail_search_seqset *next; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
45 }; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
46 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
47 struct mail_search_arg { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
48 struct mail_search_arg *next; |
0 | 49 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
50 enum mail_search_arg_type type; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
51 struct { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
52 struct mail_search_arg *subargs; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
53 struct mail_search_seqset *seqset; |
0 | 54 const char *str; |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
55 time_t time; |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
56 uoff_t size; |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
57 enum mail_flags flags; |
6965
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
58 struct mail_keywords *keywords; |
0 | 59 } value; |
60 | |
568
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
444
diff
changeset
|
61 void *context; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
62 const char *hdr_field_name; /* for SEARCH_HEADER* */ |
0 | 63 unsigned int not:1; |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
64 unsigned int match_always:1; /* result = 1 always */ |
0 | 65 |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
66 int result; /* -1 = unknown, 0 = unmatched, 1 = matched */ |
0 | 67 }; |
68 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
69 #define ARG_SET_RESULT(arg, res) \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
70 STMT_START { \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
71 (arg)->result = !(arg)->not ? (res) : \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
72 (res) == -1 ? -1 : !(res); \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
73 } STMT_END |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
74 |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
75 typedef void mail_search_foreach_callback_t(struct mail_search_arg *arg, |
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
76 void *context); |
0 | 77 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
78 /* Reset the results in search arguments. match_always is reset only if |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
79 full_reset is TRUE. */ |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
80 void mail_search_args_reset(struct mail_search_arg *args, bool full_reset); |
0 | 81 |
82 /* goes through arguments in list that don't have a result yet. | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
83 Returns 1 = search matched, 0 = search unmatched, -1 = don't know yet */ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
84 int mail_search_args_foreach(struct mail_search_arg *args, |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
85 mail_search_foreach_callback_t *callback, |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
86 void *context); |
4906
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
87 #ifdef CONTEXT_TYPE_SAFETY |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
88 # define mail_search_args_foreach(args, callback, context) \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
89 ({(void)(1 ? 0 : callback((struct mail_search_arg *)NULL, context)); \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
90 mail_search_args_foreach(args, \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
91 (mail_search_foreach_callback_t *)callback, context); }) |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
92 #else |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
93 # define mail_search_args_foreach(args, callback, context) \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
94 mail_search_args_foreach(args, \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
95 (mail_search_foreach_callback_t *)callback, context) |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
96 #endif |
0 | 97 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
98 /* Fills have_headers and have_body based on if such search argument exists |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
99 that needs to be checked. Returns the headers that we're searching for, or |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
100 NULL if we're searching for TEXT. */ |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
101 const char *const * |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
102 mail_search_args_analyze(struct mail_search_arg *args, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
103 bool *have_headers, bool *have_body); |
0 | 104 |
6899
69babcc2fb80
Simplify search arguments immediately when calling mailbox_search_init().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
105 /* 1) Change args so that SEARCH_SUB and SEARCH_OR will never have "not" set |
69babcc2fb80
Simplify search arguments immediately when calling mailbox_search_init().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
106 2) Drop unnecessary nested SEARCH_SUB and SEARCH_ORs */ |
69babcc2fb80
Simplify search arguments immediately when calling mailbox_search_init().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
107 void mail_search_args_simplify(struct mail_search_arg *args); |
69babcc2fb80
Simplify search arguments immediately when calling mailbox_search_init().
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
108 |
0 | 109 #endif |