Mercurial > dovecot > core-2.2
annotate src/lib-storage/mail-search.h @ 6410:e4eb71ae8e96 HEAD
Changed .h ifdef/defines to use <NAME>_H format.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 16 Sep 2007 11:31:27 +0300 |
parents | 6789ba80419b |
children | 69babcc2fb80 |
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 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
4 enum mail_search_arg_type { |
0 | 5 SEARCH_OR, |
6 SEARCH_SUB, | |
7 | |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
8 /* sequence sets */ |
0 | 9 SEARCH_ALL, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
10 SEARCH_SEQSET, |
0 | 11 |
12 /* flags */ | |
13 SEARCH_ANSWERED, | |
14 SEARCH_DELETED, | |
15 SEARCH_DRAFT, | |
16 SEARCH_FLAGGED, | |
17 SEARCH_SEEN, | |
18 SEARCH_RECENT, | |
19 SEARCH_KEYWORD, | |
20 | |
21 /* dates */ | |
22 SEARCH_BEFORE, | |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
23 SEARCH_ON, /* time must point to beginning of the day */ |
0 | 24 SEARCH_SINCE, |
25 SEARCH_SENTBEFORE, | |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
26 SEARCH_SENTON, /* time must point to beginning of the day */ |
0 | 27 SEARCH_SENTSINCE, |
28 | |
29 /* sizes */ | |
30 SEARCH_SMALLER, | |
31 SEARCH_LARGER, | |
32 | |
33 /* headers */ | |
34 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
|
35 SEARCH_HEADER_ADDRESS, |
0 | 36 |
37 /* body */ | |
38 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
|
39 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
|
40 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
|
41 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
|
42 }; |
0 | 43 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
44 struct mail_search_seqset { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
45 uint32_t seq1, seq2; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
46 struct mail_search_seqset *next; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
47 }; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
48 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
49 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
|
50 struct mail_search_arg *next; |
0 | 51 |
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 enum mail_search_arg_type type; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
53 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
|
54 struct mail_search_arg *subargs; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1844
diff
changeset
|
55 struct mail_search_seqset *seqset; |
0 | 56 const char *str; |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
57 time_t time; |
0 | 58 } value; |
59 | |
568
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
444
diff
changeset
|
60 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
|
61 const char *hdr_field_name; /* for SEARCH_HEADER* */ |
0 | 62 unsigned int not:1; |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
63 unsigned int match_always:1; /* result = 1 always */ |
0 | 64 |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
65 int result; /* -1 = unknown, 0 = unmatched, 1 = matched */ |
0 | 66 }; |
67 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
68 #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
|
69 STMT_START { \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
70 (arg)->result = !(arg)->not ? (res) : \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
71 (res) == -1 ? -1 : !(res); \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
72 } STMT_END |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
73 |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
74 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
|
75 void *context); |
0 | 76 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
77 /* 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
|
78 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
|
79 void mail_search_args_reset(struct mail_search_arg *args, bool full_reset); |
0 | 80 |
81 /* 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
|
82 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
|
83 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
|
84 mail_search_foreach_callback_t *callback, |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
85 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
|
86 #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
|
87 # 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
|
88 ({(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
|
89 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
|
90 (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
|
91 #else |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
92 # 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
|
93 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
|
94 (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
|
95 #endif |
0 | 96 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
97 /* 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 bool *have_headers, bool *have_body); |
0 | 103 |
104 #endif |