Mercurial > dovecot > core-2.2
annotate src/lib-storage/mail-search.h @ 1844:4c2678dd65f1 HEAD
Some optimizations to messageset handling in search.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 26 Oct 2003 21:41:09 +0200 |
parents | 8920600a8cfc |
children | 79790750c349 |
rev | line source |
---|---|
0 | 1 #ifndef __MAIL_SEARCH_H |
2 #define __MAIL_SEARCH_H | |
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 | |
8 /* message sets */ | |
9 SEARCH_ALL, | |
10 SEARCH_SET, | |
11 SEARCH_UID, | |
12 | |
13 /* flags */ | |
14 SEARCH_ANSWERED, | |
15 SEARCH_DELETED, | |
16 SEARCH_DRAFT, | |
17 SEARCH_FLAGGED, | |
18 SEARCH_SEEN, | |
19 SEARCH_RECENT, | |
20 SEARCH_KEYWORD, | |
21 | |
22 /* dates */ | |
23 SEARCH_BEFORE, | |
24 SEARCH_ON, | |
25 SEARCH_SINCE, | |
26 SEARCH_SENTBEFORE, | |
27 SEARCH_SENTON, | |
28 SEARCH_SENTSINCE, | |
29 | |
30 /* sizes */ | |
31 SEARCH_SMALLER, | |
32 SEARCH_LARGER, | |
33 | |
34 /* headers */ | |
35 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
|
36 SEARCH_HEADER_ADDRESS, |
0 | 37 |
38 /* body */ | |
39 SEARCH_BODY, | |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
40 SEARCH_TEXT |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
41 }; |
0 | 42 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
43 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
|
44 struct mail_search_arg *next; |
0 | 45 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
46 enum mail_search_arg_type type; |
0 | 47 union { |
903
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 *subargs; |
0 | 49 const char *str; |
50 } value; | |
51 | |
568
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
444
diff
changeset
|
52 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
|
53 const char *hdr_field_name; /* for SEARCH_HEADER* */ |
0 | 54 unsigned int not:1; |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
55 unsigned int match_always:1; /* result = 1 always */ |
0 | 56 |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
57 int result; /* -1 = unknown, 0 = unmatched, 1 = matched */ |
0 | 58 }; |
59 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
60 #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
|
61 STMT_START { \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
62 (arg)->result = !(arg)->not ? (res) : \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
63 (res) == -1 ? -1 : !(res); \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
64 } STMT_END |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
65 |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
66 typedef void (*mail_search_foreach_callback_t)(struct mail_search_arg *arg, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
67 void *context); |
0 | 68 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
69 /* 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
|
70 full_reset is TRUE. */ |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1672
diff
changeset
|
71 void mail_search_args_reset(struct mail_search_arg *args, int full_reset); |
0 | 72 |
73 /* 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
|
74 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
|
75 int mail_search_args_foreach(struct mail_search_arg *args, |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
76 mail_search_foreach_callback_t callback, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
77 void *context); |
0 | 78 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
79 /* 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
|
80 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
|
81 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
|
82 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
|
83 mail_search_args_analyze(struct mail_search_arg *args, |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
84 int *have_headers, int *have_body); |
0 | 85 |
86 #endif |