Mercurial > dovecot > core-2.2
annotate src/lib-storage/mail-search.h @ 1069:8024a2cdc406 HEAD
Several search fixes, mostly related to matching multiple conditions.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 01 Feb 2003 13:24:17 +0200 |
parents | 8028c4dcf38f |
children | 8920600a8cfc |
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_FROM, | |
36 SEARCH_TO, | |
37 SEARCH_CC, | |
38 SEARCH_BCC, | |
39 SEARCH_SUBJECT, | |
40 SEARCH_HEADER, | |
41 | |
42 /* body */ | |
43 SEARCH_BODY, | |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
44 SEARCH_TEXT, |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
45 |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
46 /* our shortcuts for headers */ |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
47 SEARCH_IN_REPLY_TO, |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
48 SEARCH_MESSAGE_ID |
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 }; |
0 | 50 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
51 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
|
52 struct mail_search_arg *next; |
0 | 53 |
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 enum mail_search_arg_type type; |
0 | 55 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
|
56 struct mail_search_arg *subargs; |
0 | 57 const char *str; |
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; |
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
444
diff
changeset
|
61 const char *hdr_field_name; /* for SEARCH_HEADER */ |
0 | 62 unsigned int not:1; |
63 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
64 int result; /* -1 = unknown, 0 = unmatched, 1 = matched */ |
0 | 65 }; |
66 | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
67 #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
|
68 STMT_START { \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
69 (arg)->result = !(arg)->not ? (res) : \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
70 (res) == -1 ? -1 : !(res); \ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
71 } STMT_END |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
72 |
953
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
73 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
|
74 void *context); |
0 | 75 |
76 /* 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
|
77 void mail_search_args_reset(struct mail_search_arg *args); |
0 | 78 |
79 /* 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
|
80 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
|
81 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
|
82 mail_search_foreach_callback_t callback, |
411006be3c66
Naming change for function typedefs.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
83 void *context); |
0 | 84 |
85 /* Fills have_headers, have_body and have_text based on if such search | |
86 argument exists that needs to be checked. */ | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
568
diff
changeset
|
87 void mail_search_args_analyze(struct mail_search_arg *args, int *have_headers, |
0 | 88 int *have_body, int *have_text); |
89 | |
90 #endif |