Mercurial > dovecot > core-2.2
annotate src/lib-storage/mail-search.h @ 1672:8920600a8cfc HEAD
Index cache file rewrite. It's not finished yet and mbox support is
completely broken. But it's getting difficult to maintain outside cvs :)
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 06 Aug 2003 23:15:30 +0300 |
parents | 8024a2cdc406 |
children | 4c2678dd65f1 |
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; |
55 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
56 int result; /* -1 = unknown, 0 = unmatched, 1 = matched */ |
0 | 57 }; |
58 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
59 #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
|
60 STMT_START { \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
61 (arg)->result = !(arg)->not ? (res) : \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
62 (res) == -1 ? -1 : !(res); \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
63 } STMT_END |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
64 |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
65 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
|
66 void *context); |
0 | 67 |
68 /* Reset the results in search arguments */ | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
69 void mail_search_args_reset(struct mail_search_arg *args); |
0 | 70 |
71 /* 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
|
72 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
|
73 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
|
74 mail_search_foreach_callback_t callback, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
75 void *context); |
0 | 76 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1069
diff
changeset
|
77 /* 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 int *have_headers, int *have_body); |
0 | 83 |
84 #endif |