Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-storage/index/index-search.c @ 7226:e6693a0ec8e1 HEAD
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
replaced them with T_BEGIN/END calls. T_FRAME() made it difficult to debug
code with gdb.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 11 Feb 2008 20:17:00 +0200 |
parents | 7ed926ed7aa4 |
children | a6c066f50877 |
rev | line source |
---|---|
7086
7ed926ed7aa4
Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents:
6966
diff
changeset
|
1 /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */ |
0 | 2 |
3 #include "lib.h" | |
4949
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
4 #include "ioloop.h" |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
5 #include "array.h" |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
761
diff
changeset
|
6 #include "istream.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
7 #include "str.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
8 #include "message-address.h" |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
9 #include "message-date.h" |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
10 #include "message-search.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
11 #include "message-parser.h" |
0 | 12 #include "index-storage.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
13 #include "index-mail.h" |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
14 #include "index-sort.h" |
0 | 15 #include "mail-search.h" |
16 | |
17 #include <stdlib.h> | |
18 #include <ctype.h> | |
19 | |
883
39e0b536e708
Storage can now specify if errors should be sent to user as BAD or NO.
Timo Sirainen <tss@iki.fi>
parents:
881
diff
changeset
|
20 #define TXT_UNKNOWN_CHARSET "[BADCHARSET] Unknown charset" |
608
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
21 #define TXT_INVALID_SEARCH_KEY "Invalid search key" |
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
22 |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
23 #define SEARCH_NONBLOCK_COUNT 20 |
4949
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
24 #define SEARCH_NOTIFY_INTERVAL_SECS 10 |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
25 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
26 struct index_search_context { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
27 struct mail_search_context mail_ctx; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
2190
diff
changeset
|
28 struct mail_index_view *view; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
29 struct index_mailbox *ibox; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
30 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
31 uint32_t seq1, seq2; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
32 struct mail *mail; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
33 struct index_mail *imail; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
34 |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
35 pool_t search_pool; |
568
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
36 const char *error; |
924
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
37 |
4949
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
38 struct timeval search_start_time, last_notify; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
39 |
3325
38eaa792c405
Don't call index_mail_parse_header() twice when searching headers. Caused
Timo Sirainen <tss@iki.fi>
parents:
3301
diff
changeset
|
40 unsigned int failed:1; |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
41 unsigned int sorted:1; |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
42 unsigned int have_seqsets:1; |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
43 unsigned int have_flags_or_keywords:1; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
44 }; |
0 | 45 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
46 struct search_header_context { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
47 struct index_search_context *index_context; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
48 struct mail_search_arg *args; |
0 | 49 |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
50 struct message_header_line *hdr; |
924
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
51 |
3325
38eaa792c405
Don't call index_mail_parse_header() twice when searching headers. Caused
Timo Sirainen <tss@iki.fi>
parents:
3301
diff
changeset
|
52 unsigned int parse_headers:1; |
924
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
53 unsigned int custom_header:1; |
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
54 unsigned int threading:1; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
55 }; |
0 | 56 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
57 struct search_body_context { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
58 struct index_search_context *index_ctx; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
59 struct istream *input; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
60 const struct message_part *part; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
61 }; |
0 | 62 |
5522
5dee807e53cf
Header parser has now flags parameter to tell it how to handle linefeeds.
Timo Sirainen <tss@iki.fi>
parents:
5516
diff
changeset
|
63 static const enum message_header_parser_flags hdr_parser_flags = |
5dee807e53cf
Header parser has now flags parameter to tell it how to handle linefeeds.
Timo Sirainen <tss@iki.fi>
parents:
5516
diff
changeset
|
64 MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE; |
5dee807e53cf
Header parser has now flags parameter to tell it how to handle linefeeds.
Timo Sirainen <tss@iki.fi>
parents:
5516
diff
changeset
|
65 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
66 static void search_parse_msgset_args(const struct mail_index_header *hdr, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
67 struct mail_search_arg *args, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
68 uint32_t *seq1_r, uint32_t *seq2_r); |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
69 |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
70 static void search_init_arg(struct mail_search_arg *arg, |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
71 struct index_search_context *ctx) |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
72 { |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
73 switch (arg->type) { |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
74 case SEARCH_SEQSET: |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
75 ctx->have_seqsets = TRUE; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
76 break; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
77 case SEARCH_FLAGS: |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
78 case SEARCH_KEYWORDS: |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
79 ctx->have_flags_or_keywords = TRUE; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
80 break; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
81 case SEARCH_ALL: |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
82 if (!arg->not) |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
83 arg->match_always = TRUE; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
84 break; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
85 default: |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
86 break; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
87 } |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
88 } |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
89 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
90 static int seqset_contains(struct mail_search_seqset *set, uint32_t seq) |
0 | 91 { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
92 while (set != NULL) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
93 if (seq >= set->seq1 && seq <= set->seq2) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
94 return TRUE; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
95 set = set->next; |
0 | 96 } |
97 | |
98 return FALSE; | |
99 } | |
100 | |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
101 static void search_seqset_arg(struct mail_search_arg *arg, |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
102 struct index_search_context *ctx) |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
103 { |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
104 if (arg->type == SEARCH_SEQSET) { |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
105 if (seqset_contains(arg->value.seqset, ctx->mail_ctx.seq)) |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
106 ARG_SET_RESULT(arg, 1); |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
107 else |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
108 ARG_SET_RESULT(arg, 0); |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
109 } |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
110 } |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
111 |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
112 static int search_arg_match_keywords(struct index_search_context *ctx, |
6965
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
113 struct mail_search_arg *arg) |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
114 { |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
115 ARRAY_TYPE(keyword_indexes) keyword_indexes_arr; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
116 const struct mail_keywords *search_kws = arg->value.keywords; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
117 const unsigned int *keyword_indexes; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
118 unsigned int i, j, count; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
119 |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
120 t_array_init(&keyword_indexes_arr, 128); |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
121 mail_index_lookup_keywords(ctx->view, ctx->mail_ctx.seq, |
6965
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
122 &keyword_indexes_arr); |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
123 keyword_indexes = array_get(&keyword_indexes_arr, &count); |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
124 |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
125 /* there probably aren't many keywords, so O(n*m) for now */ |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
126 for (i = 0; i < search_kws->count; i++) { |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
127 for (j = 0; j < count; j++) { |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
128 if (search_kws->idx[i] == keyword_indexes[j]) |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
129 break; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
130 } |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
131 if (j == count) |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
132 return 0; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
133 } |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
134 return 1; |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
135 } |
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
136 |
0 | 137 /* Returns >0 = matched, 0 = not matched, -1 = unknown */ |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
138 static int search_arg_match_index(struct index_search_context *ctx, |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
139 struct mail_search_arg *arg, |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
140 const struct mail_index_record *rec) |
0 | 141 { |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
142 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
|
143 int ret; |
1947 | 144 |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
145 switch (arg->type) { |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
146 case SEARCH_FLAGS: |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
147 flags = rec->flags; |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
148 if ((arg->value.flags & MAIL_RECENT) != 0 && |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
149 index_mailbox_is_recent(ctx->ibox, rec->uid)) |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
150 flags |= MAIL_RECENT; |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
151 return (flags & arg->value.flags) == arg->value.flags; |
6965
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
152 case SEARCH_KEYWORDS: |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
153 T_BEGIN { |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
154 ret = search_arg_match_keywords(ctx, arg); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
155 } T_END; |
6965
ae369569e7de
SEARCH_KEYWORDS now uses struct mail_keywords instead of a string array.
Timo Sirainen <tss@iki.fi>
parents:
6962
diff
changeset
|
156 return ret; |
0 | 157 |
158 default: | |
159 return -1; | |
160 } | |
161 } | |
162 | |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
163 static void search_index_arg(struct mail_search_arg *arg, |
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
164 struct index_search_context *ctx) |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
165 { |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
166 const struct mail_index_record *rec; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
167 |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
168 rec = mail_index_lookup(ctx->view, ctx->mail_ctx.seq); |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
169 switch (search_arg_match_index(ctx, arg, rec)) { |
0 | 170 case -1: |
171 /* unknown */ | |
172 break; | |
173 case 0: | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
174 ARG_SET_RESULT(arg, 0); |
0 | 175 break; |
176 default: | |
177 ARG_SET_RESULT(arg, 1); | |
178 break; | |
179 } | |
180 } | |
181 | |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
182 /* Returns >0 = matched, 0 = not matched, -1 = unknown */ |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
183 static int search_arg_match_cached(struct index_search_context *ctx, |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
184 struct mail_search_arg *arg) |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
185 { |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
186 uoff_t virtual_size; |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
187 time_t date; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
188 int timezone_offset; |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
189 |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
190 switch (arg->type) { |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
191 /* internal dates */ |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
192 case SEARCH_BEFORE: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
193 case SEARCH_ON: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
194 case SEARCH_SINCE: |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
195 if (mail_get_received_date(ctx->mail, &date) < 0) |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
196 return -1; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
197 |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
198 switch (arg->type) { |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
199 case SEARCH_BEFORE: |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
200 return date < arg->value.time; |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
201 case SEARCH_ON: |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
202 return date >= arg->value.time && |
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
203 date < arg->value.time + 3600*24; |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
204 case SEARCH_SINCE: |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
205 return date >= arg->value.time; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
206 default: |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
207 /* unreachable */ |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
208 break; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
209 } |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
210 |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
211 /* sent dates */ |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
212 case SEARCH_SENTBEFORE: |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
213 case SEARCH_SENTON: |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
214 case SEARCH_SENTSINCE: |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
215 /* NOTE: RFC-3501 specifies that timezone is ignored |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
216 in searches. date is returned as UTC, so change it. */ |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
217 if (mail_get_date(ctx->mail, &date, &timezone_offset) < 0) |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
218 return -1; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
219 date += timezone_offset * 60; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
220 |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
221 switch (arg->type) { |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
222 case SEARCH_SENTBEFORE: |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
223 return date < arg->value.time; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
224 case SEARCH_SENTON: |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
225 return date >= arg->value.time && |
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
226 date < arg->value.time + 3600*24; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
227 case SEARCH_SENTSINCE: |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
228 return date >= arg->value.time; |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
229 default: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
230 /* unreachable */ |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
231 break; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
232 } |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
233 |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
234 /* sizes */ |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
235 case SEARCH_SMALLER: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
236 case SEARCH_LARGER: |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
237 if (mail_get_virtual_size(ctx->mail, &virtual_size) < 0) |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
238 return -1; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
239 |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
240 if (arg->type == SEARCH_SMALLER) |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
241 return virtual_size < arg->value.size; |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
242 else |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
243 return virtual_size > arg->value.size; |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
244 |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
245 default: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
246 return -1; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
247 } |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
248 } |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
249 |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
250 static void search_cached_arg(struct mail_search_arg *arg, |
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
251 struct index_search_context *ctx) |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
252 { |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
253 switch (search_arg_match_cached(ctx, arg)) { |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
254 case -1: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
255 /* unknown */ |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
256 break; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
257 case 0: |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
258 ARG_SET_RESULT(arg, 0); |
525
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
259 break; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
260 default: |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
261 ARG_SET_RESULT(arg, 1); |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
262 break; |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
263 } |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
264 } |
2cb2e0a3423b
Moved several fields from .imap.index file to .imap.index.data file. Fixed
Timo Sirainen <tss@iki.fi>
parents:
505
diff
changeset
|
265 |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
266 static int search_sent(enum mail_search_arg_type type, time_t search_time, |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
267 const unsigned char *sent_value, size_t sent_value_len) |
0 | 268 { |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
269 time_t sent_time; |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
270 int timezone_offset; |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
271 |
880
d5168cca2052
SEARCHing headers with "" value should always match if the header is found.
Timo Sirainen <tss@iki.fi>
parents:
825
diff
changeset
|
272 if (sent_value == NULL) |
d5168cca2052
SEARCHing headers with "" value should always match if the header is found.
Timo Sirainen <tss@iki.fi>
parents:
825
diff
changeset
|
273 return 0; |
d5168cca2052
SEARCHing headers with "" value should always match if the header is found.
Timo Sirainen <tss@iki.fi>
parents:
825
diff
changeset
|
274 |
1340
087a9f4304ca
s/latest IMAP4rev1 draft/RFC-3501/
Timo Sirainen <tss@iki.fi>
parents:
1322
diff
changeset
|
275 /* NOTE: RFC-3501 specifies that timezone is ignored |
935
bd2d99a3d601
Even more rfc822 date timezone fixes
Timo Sirainen <tss@iki.fi>
parents:
934
diff
changeset
|
276 in searches. sent_time is returned as UTC, so change it. */ |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
277 if (!message_date_parse(sent_value, sent_value_len, |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
278 &sent_time, &timezone_offset)) |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
279 return 0; |
1604 | 280 sent_time += timezone_offset * 60; |
0 | 281 |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
282 switch (type) { |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
283 case SEARCH_SENTBEFORE: |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
284 return sent_time < search_time; |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
285 case SEARCH_SENTON: |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
286 return sent_time >= search_time && |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
287 sent_time < search_time + 3600*24; |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
288 case SEARCH_SENTSINCE: |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
289 return sent_time >= search_time; |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
290 default: |
546
e1254b838e0b
Added --enable-asserts (default) and fixed some warnings when building
Timo Sirainen <tss@iki.fi>
parents:
534
diff
changeset
|
291 i_unreached(); |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
292 } |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
293 } |
0 | 294 |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
295 static struct message_search_context * |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
296 msg_search_arg_context(struct index_search_context *ctx, |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
297 struct mail_search_arg *arg) |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
298 { |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
299 struct message_search_context *arg_ctx = arg->context; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
300 enum message_search_flags flags; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
301 int ret; |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
302 |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
303 if (arg_ctx != NULL) |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
304 return arg_ctx; |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
305 |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
306 if (ctx->search_pool == NULL) |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
307 ctx->search_pool = pool_alloconly_create("search pool", 8192); |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
308 |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
309 flags = (arg->type == SEARCH_BODY || arg->type == SEARCH_BODY_FAST) ? |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
310 MESSAGE_SEARCH_FLAG_SKIP_HEADERS : 0; |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
311 |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
312 ret = message_search_init(ctx->search_pool, arg->value.str, |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
313 ctx->mail_ctx.charset, flags, |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
314 &arg_ctx); |
5527 | 315 if (ret > 0) { |
316 arg->context = arg_ctx; | |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
317 return arg_ctx; |
5527 | 318 } |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
319 if (ret == 0) |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
320 ctx->error = TXT_UNKNOWN_CHARSET; |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
321 else |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
322 ctx->error = TXT_INVALID_SEARCH_KEY; |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
323 return NULL; |
0 | 324 } |
325 | |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
326 static void search_header_arg(struct mail_search_arg *arg, |
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
327 struct search_header_context *ctx) |
0 | 328 { |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
329 struct message_search_context *msg_search_ctx; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
330 struct message_block block; |
6574
ab3a1a8ade55
Header searches didn't decode MIME encoded words.
Timo Sirainen <tss@iki.fi>
parents:
6492
diff
changeset
|
331 struct message_header_line hdr; |
0 | 332 int ret; |
333 | |
334 /* first check that the field name matches to argument. */ | |
335 switch (arg->type) { | |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
336 case SEARCH_SENTBEFORE: |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
337 case SEARCH_SENTON: |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
338 case SEARCH_SENTSINCE: |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
339 /* date is handled differently than others */ |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
340 if (strcasecmp(ctx->hdr->name, "Date") == 0) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
341 if (ctx->hdr->continues) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
342 ctx->hdr->use_full_value = TRUE; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
343 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
344 } |
5599
6789ba80419b
Parse search dates already in IMAP code.
Timo Sirainen <tss@iki.fi>
parents:
5527
diff
changeset
|
345 ret = search_sent(arg->type, arg->value.time, |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
346 ctx->hdr->full_value, |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
347 ctx->hdr->full_value_len); |
1070 | 348 ARG_SET_RESULT(arg, ret); |
408
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
349 } |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
350 return; |
e057845d94ca
Dropped sent_time and alignment from MailIndexRecord. SEARCH can now use
Timo Sirainen <tss@iki.fi>
parents:
369
diff
changeset
|
351 |
0 | 352 case SEARCH_HEADER: |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
353 case SEARCH_HEADER_ADDRESS: |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
354 ctx->custom_header = TRUE; |
0 | 355 |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
356 if (strcasecmp(ctx->hdr->name, arg->hdr_field_name) != 0) |
0 | 357 return; |
5513 | 358 break; |
0 | 359 default: |
360 return; | |
361 } | |
362 | |
880
d5168cca2052
SEARCHing headers with "" value should always match if the header is found.
Timo Sirainen <tss@iki.fi>
parents:
825
diff
changeset
|
363 if (arg->value.str[0] == '\0') { |
d5168cca2052
SEARCHing headers with "" value should always match if the header is found.
Timo Sirainen <tss@iki.fi>
parents:
825
diff
changeset
|
364 /* we're just testing existence of the field. always matches. */ |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
365 ARG_SET_RESULT(arg, 1); |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
366 return; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
367 } |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
368 |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
369 if (ctx->hdr->continues) { |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
370 ctx->hdr->use_full_value = TRUE; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
371 return; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
372 } |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
373 |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
374 memset(&block, 0, sizeof(block)); |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
375 msg_search_ctx = msg_search_arg_context(ctx->index_context, arg); |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
376 if (msg_search_ctx == NULL) |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
377 ret = 0; |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
378 else if (arg->type == SEARCH_HEADER_ADDRESS) { |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
379 /* we have to match against normalized address */ |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
380 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
381 struct message_address *addr; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
382 string_t *str; |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
383 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
384 addr = message_address_parse(pool_datastack_create(), |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
385 ctx->hdr->full_value, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
386 ctx->hdr->full_value_len, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
387 (unsigned int)-1, TRUE); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
388 str = t_str_new(ctx->hdr->value_len); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
389 message_address_write(str, addr); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
390 hdr = *ctx->hdr; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
391 hdr.value = hdr.full_value = str_data(str); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
392 hdr.value_len = hdr.full_value_len = str_len(str); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
393 block.hdr = &hdr; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
394 ret = message_search_more(msg_search_ctx, &block); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
395 } T_END; |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
396 } else { |
6574
ab3a1a8ade55
Header searches didn't decode MIME encoded words.
Timo Sirainen <tss@iki.fi>
parents:
6492
diff
changeset
|
397 block.hdr = ctx->hdr; |
ab3a1a8ade55
Header searches didn't decode MIME encoded words.
Timo Sirainen <tss@iki.fi>
parents:
6492
diff
changeset
|
398 ret = message_search_more(msg_search_ctx, &block); |
568
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
399 } |
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
400 |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
401 if (ret > 0 || |
5507
65250cfebd74
Don't handle TEXT searches in header searches. It's done later anyway.
Timo Sirainen <tss@iki.fi>
parents:
5505
diff
changeset
|
402 (arg->type != SEARCH_HEADER && |
65250cfebd74
Don't handle TEXT searches in header searches. It's done later anyway.
Timo Sirainen <tss@iki.fi>
parents:
5505
diff
changeset
|
403 arg->type != SEARCH_HEADER_ADDRESS)) { |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
404 /* set only when we definitely know if it's a match */ |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
405 ARG_SET_RESULT(arg, ret); |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
406 } |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
407 } |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
408 |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
409 static void search_header_unmatch(struct mail_search_arg *arg, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
410 void *context ATTR_UNUSED) |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
411 { |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
412 switch (arg->type) { |
1070 | 413 case SEARCH_SENTBEFORE: |
414 case SEARCH_SENTON: | |
415 case SEARCH_SENTSINCE: | |
416 if (arg->not) { | |
417 /* date header not found, so we match only for | |
418 NOT searches */ | |
419 ARG_SET_RESULT(arg, 0); | |
420 } | |
421 break; | |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
422 case SEARCH_HEADER: |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
423 case SEARCH_HEADER_ADDRESS: |
1069
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
424 ARG_SET_RESULT(arg, 0); |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
425 break; |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
426 default: |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
427 break; |
8024a2cdc406
Several search fixes, mostly related to matching multiple conditions.
Timo Sirainen <tss@iki.fi>
parents:
1066
diff
changeset
|
428 } |
0 | 429 } |
430 | |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
431 static void search_header(struct message_header_line *hdr, |
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
432 struct search_header_context *ctx) |
0 | 433 { |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
434 if (hdr == NULL) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
435 /* end of headers, mark all unknown SEARCH_HEADERs unmatched */ |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
436 mail_search_args_foreach(ctx->args, search_header_unmatch, ctx); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
437 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
438 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
439 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
440 if (hdr->eoh) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
441 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
442 |
3325
38eaa792c405
Don't call index_mail_parse_header() twice when searching headers. Caused
Timo Sirainen <tss@iki.fi>
parents:
3301
diff
changeset
|
443 if (ctx->parse_headers) |
38eaa792c405
Don't call index_mail_parse_header() twice when searching headers. Caused
Timo Sirainen <tss@iki.fi>
parents:
3301
diff
changeset
|
444 index_mail_parse_header(NULL, hdr, ctx->index_context->imail); |
924
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
445 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
446 if (ctx->custom_header || strcasecmp(hdr->name, "Date") == 0) { |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1070
diff
changeset
|
447 ctx->hdr = hdr; |
0 | 448 |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
449 ctx->custom_header = FALSE; |
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
450 mail_search_args_foreach(ctx->args, search_header_arg, ctx); |
0 | 451 } |
452 } | |
453 | |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
454 static void search_body(struct mail_search_arg *arg, |
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4635
diff
changeset
|
455 struct search_body_context *ctx) |
0 | 456 { |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
457 struct message_search_context *msg_search_ctx; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3795
diff
changeset
|
458 int ret; |
0 | 459 |
608
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
460 if (ctx->index_ctx->error != NULL) |
0 | 461 return; |
462 | |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
463 switch (arg->type) { |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
464 case SEARCH_BODY: |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
465 case SEARCH_BODY_FAST: |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
466 case SEARCH_TEXT: |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
467 case SEARCH_TEXT_FAST: |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
468 break; |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
469 default: |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
470 return; |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
471 } |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
472 |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
473 msg_search_ctx = msg_search_arg_context(ctx->index_ctx, arg); |
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
474 if (msg_search_ctx == NULL) { |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
475 ARG_SET_RESULT(arg, 0); |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
476 return; |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
477 } |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
478 |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
479 i_stream_seek(ctx->input, 0); |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
480 ret = message_search_msg(msg_search_ctx, ctx->input, ctx->part); |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
481 if (ret < 0) { |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
482 mail_cache_set_corrupted(ctx->index_ctx->ibox->cache, |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
483 "Broken message structure for mail UID %u", |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
484 ctx->index_ctx->mail->uid); |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
485 |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
486 /* get the body parts, and try again */ |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
487 ctx->index_ctx->imail->data.parts = NULL; |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
488 |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
489 i_stream_seek(ctx->input, 0); |
5525
94bc3fbdecd5
Removed message body/header searchers. They're now combined into one
Timo Sirainen <tss@iki.fi>
parents:
5522
diff
changeset
|
490 ret = message_search_msg(msg_search_ctx, ctx->input, NULL); |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
491 if (ret < 0) |
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
492 i_panic("Couldn't fix broken body structure"); |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
493 } |
290
3dcc2275b4ca
IOBuffer cleanup, hopefully fixes some mbox problems.
Timo Sirainen <tss@iki.fi>
parents:
223
diff
changeset
|
494 |
3795
e6c42de08336
Allow message_body_search() to return "message_part is broken" error. If it
Timo Sirainen <tss@iki.fi>
parents:
3467
diff
changeset
|
495 ARG_SET_RESULT(arg, ret > 0); |
5
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
496 } |
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
497 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3795
diff
changeset
|
498 static bool search_arg_match_text(struct mail_search_arg *args, |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3795
diff
changeset
|
499 struct index_search_context *ctx) |
0 | 500 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
501 struct istream *input; |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
502 struct mailbox_header_lookup_ctx *headers_ctx; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
503 const char *const *headers; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3795
diff
changeset
|
504 bool have_headers, have_body; |
0 | 505 |
506 /* first check what we need to use */ | |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
507 headers = mail_search_args_analyze(args, &have_headers, &have_body); |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
508 if (!have_headers && !have_body) |
0 | 509 return TRUE; |
510 | |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
511 if (have_headers) { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
512 struct search_header_context hdr_ctx; |
5
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
513 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
514 if (have_body) |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
515 headers = NULL; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
516 |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
517 if (headers == NULL) { |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
518 headers_ctx = NULL; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
519 if (mail_get_stream(ctx->mail, NULL, NULL, &input) < 0) |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
520 return FALSE; |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
521 } else { |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
522 /* FIXME: do this once in init */ |
3301
dd19f2e8575f
Don't even try to allow searching zero number of headers.
Timo Sirainen <tss@iki.fi>
parents:
3248
diff
changeset
|
523 i_assert(*headers != NULL); |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
524 headers_ctx = |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
525 mailbox_header_lookup_init(&ctx->ibox->box, |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
526 headers); |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
527 if (mail_get_header_stream(ctx->mail, headers_ctx, |
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
528 &input) < 0) { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3873
diff
changeset
|
529 mailbox_header_lookup_deinit(&headers_ctx); |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
530 return FALSE; |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
531 } |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
532 } |
715
3e952f64b2ec
Non-envelope-cached header searching wasn't working. Also now search works
Timo Sirainen <tss@iki.fi>
parents:
678
diff
changeset
|
533 |
568
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
534 memset(&hdr_ctx, 0, sizeof(hdr_ctx)); |
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
535 hdr_ctx.index_context = ctx; |
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
536 hdr_ctx.custom_header = TRUE; |
f2aa58c2afd0
SEARCH CHARSET support. Currently we do it through iconv() and only ASCII
Timo Sirainen <tss@iki.fi>
parents:
559
diff
changeset
|
537 hdr_ctx.args = args; |
5516
96f0b56489a2
Don't feed index_mail_parser headers while searching message bodies, unless
Timo Sirainen <tss@iki.fi>
parents:
5513
diff
changeset
|
538 hdr_ctx.parse_headers = headers == NULL && |
96f0b56489a2
Don't feed index_mail_parser headers while searching message bodies, unless
Timo Sirainen <tss@iki.fi>
parents:
5513
diff
changeset
|
539 index_mail_want_parse_headers(ctx->imail); |
608
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
540 |
5516
96f0b56489a2
Don't feed index_mail_parser headers while searching message bodies, unless
Timo Sirainen <tss@iki.fi>
parents:
5513
diff
changeset
|
541 if (hdr_ctx.parse_headers) |
96f0b56489a2
Don't feed index_mail_parser headers while searching message bodies, unless
Timo Sirainen <tss@iki.fi>
parents:
5513
diff
changeset
|
542 index_mail_parse_header_init(ctx->imail, headers_ctx); |
5522
5dee807e53cf
Header parser has now flags parameter to tell it how to handle linefeeds.
Timo Sirainen <tss@iki.fi>
parents:
5516
diff
changeset
|
543 message_parse_header(input, NULL, hdr_parser_flags, |
5dee807e53cf
Header parser has now flags parameter to tell it how to handle linefeeds.
Timo Sirainen <tss@iki.fi>
parents:
5516
diff
changeset
|
544 search_header, &hdr_ctx); |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
545 if (headers_ctx != NULL) |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3873
diff
changeset
|
546 mailbox_header_lookup_deinit(&headers_ctx); |
715
3e952f64b2ec
Non-envelope-cached header searching wasn't working. Also now search works
Timo Sirainen <tss@iki.fi>
parents:
678
diff
changeset
|
547 } else { |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
548 struct message_size hdr_size; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
549 |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
550 if (mail_get_stream(ctx->mail, &hdr_size, NULL, &input) < 0) |
715
3e952f64b2ec
Non-envelope-cached header searching wasn't working. Also now search works
Timo Sirainen <tss@iki.fi>
parents:
678
diff
changeset
|
551 return FALSE; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
552 |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
553 i_stream_seek(input, hdr_size.physical_size); |
5
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
554 } |
0 | 555 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
556 if (have_body) { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
557 struct search_body_context body_ctx; |
0 | 558 |
608
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
559 memset(&body_ctx, 0, sizeof(body_ctx)); |
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
560 body_ctx.index_ctx = ctx; |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
761
diff
changeset
|
561 body_ctx.input = input; |
6280
eb7c9d8ece54
mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
562 (void)mail_get_parts(ctx->mail, &body_ctx.part); |
608
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
563 |
debb8468514e
SEARCH CHARSET now works properly with message bodies, and in general body
Timo Sirainen <tss@iki.fi>
parents:
569
diff
changeset
|
564 mail_search_args_foreach(args, search_body, &body_ctx); |
0 | 565 } |
5
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
566 return TRUE; |
0 | 567 } |
568 | |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
569 static bool search_msgset_fix_limits(const struct mail_index_header *hdr, |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
570 struct mail_search_seqset *set, bool not) |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
571 { |
6492
c6b85cf1e63a
Don't crash with empty messagesets.
Timo Sirainen <tss@iki.fi>
parents:
6487
diff
changeset
|
572 if (set == NULL) |
c6b85cf1e63a
Don't crash with empty messagesets.
Timo Sirainen <tss@iki.fi>
parents:
6487
diff
changeset
|
573 return FALSE; |
c6b85cf1e63a
Don't crash with empty messagesets.
Timo Sirainen <tss@iki.fi>
parents:
6487
diff
changeset
|
574 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
575 for (; set != NULL; set = set->next) { |
3467
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
576 if (set->seq1 > hdr->messages_count) { |
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
577 if (set->seq1 != (uint32_t)-1 && |
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
578 set->seq2 != (uint32_t)-1) { |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
579 if (not) |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
580 continue; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
581 |
3467
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
582 /* completely outside our range */ |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
583 return FALSE; |
3467
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
584 } |
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
585 /* either seq1 or seq2 is '*', so the last message is |
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
586 in range. */ |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
587 set->seq1 = hdr->messages_count; |
3467
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
588 } |
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
589 if (set->seq2 > hdr->messages_count) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
590 set->seq2 = hdr->messages_count; |
0 | 591 |
3467
b75125eced7f
Moved sequence set range checks to imap-specific code, so that SEARCH can
Timo Sirainen <tss@iki.fi>
parents:
3325
diff
changeset
|
592 if (set->seq1 == 0 || set->seq2 == 0) { |
5605
8b97d6bbff35
Don't try to handle 0 in messagesets by returning a nice error message.
Timo Sirainen <tss@iki.fi>
parents:
5599
diff
changeset
|
593 /* this shouldn't happen. treat as nonexisting. */ |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
594 return FALSE; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
595 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
596 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
597 return TRUE; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
598 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
599 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
600 static int mail_search_seqset_cmp(const void *p1, const void *p2) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
601 { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
602 struct mail_search_seqset *const *set1 = p1, *const *set2 = p2; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
603 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
604 return (*set1)->seq1 < (*set2)->seq2 ? -1 : |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
605 ((*set1)->seq1 > (*set2)->seq2 ? 1 : 0); |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
606 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
607 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
608 static struct mail_search_seqset * |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
609 search_msgset_sort(struct mail_search_seqset *set) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
610 { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
611 struct mail_search_seqset **sets, *cur; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
612 unsigned int i, count; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
613 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
614 for (cur = set, count = 0; cur != NULL; cur = cur->next) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
615 count++; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
616 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
617 /* @UNSAFE */ |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
618 sets = i_new(struct mail_search_seqset *, count); |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
619 for (i = 0, cur = set; i < count; i++, cur = cur->next) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
620 sets[i] = cur; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
621 qsort(sets, count, sizeof(*sets), mail_search_seqset_cmp); |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
622 for (i = 0; i < count-1; i++) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
623 sets[i]->next = sets[i+1]; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
624 sets[i]->next = NULL; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
625 set = sets[0]; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
626 i_free(sets); |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
627 return set; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
628 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
629 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
630 static void search_msgset_compress(struct mail_search_seqset *set, |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
631 struct mail_search_seqset **last_r) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
632 { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
633 struct mail_search_seqset *cur; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
634 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
635 for (cur = set; cur->next != NULL; ) { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
636 if (cur->seq2 + 1 >= cur->next->seq1) { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
637 if (cur->seq2 < cur->next->seq2) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
638 cur->seq2 = cur->next->seq2; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
639 cur->next = cur->next->next; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
640 } else { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
641 cur = cur->next; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
642 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
643 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
644 *last_r = cur; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
645 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
646 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
647 static void search_msgset_fix(const struct mail_index_header *hdr, |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
648 struct mail_search_seqset **set_p, |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
649 uint32_t *seq1_r, uint32_t *seq2_r, bool not) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
650 { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
651 struct mail_search_seqset *set = *set_p; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
652 struct mail_search_seqset *last; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
653 uint32_t min_seq, max_seq; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
654 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
655 if (!search_msgset_fix_limits(hdr, set, not)) { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
656 *seq1_r = (uint32_t)-1; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
657 *seq2_r = 0; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
658 return; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
659 } |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
660 set = *set_p = search_msgset_sort(set); |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
661 search_msgset_compress(set, &last); |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
662 |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
663 if (!not) { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
664 min_seq = set->seq1; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
665 max_seq = last->seq2; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
666 } else { |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
667 min_seq = set->seq1 > 1 ? 1 : set->seq2 + 1; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
668 max_seq = last->seq2 < hdr->messages_count ? |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
669 hdr->messages_count : last->seq1 - 1; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
670 if (min_seq > max_seq) { |
5605
8b97d6bbff35
Don't try to handle 0 in messagesets by returning a nice error message.
Timo Sirainen <tss@iki.fi>
parents:
5599
diff
changeset
|
671 *seq1_r = (uint32_t)-1; |
8b97d6bbff35
Don't try to handle 0 in messagesets by returning a nice error message.
Timo Sirainen <tss@iki.fi>
parents:
5599
diff
changeset
|
672 *seq2_r = 0; |
8b97d6bbff35
Don't try to handle 0 in messagesets by returning a nice error message.
Timo Sirainen <tss@iki.fi>
parents:
5599
diff
changeset
|
673 return; |
0 | 674 } |
962
3b139ccc1858
SEARCH didn't properly complain about invalid messagesets. high:low never
Timo Sirainen <tss@iki.fi>
parents:
951
diff
changeset
|
675 } |
4439
12b5fbb3a05c
Searching (storing, fetching) with sequence sets containing commas was
Timo Sirainen <tss@iki.fi>
parents:
4438
diff
changeset
|
676 |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
677 if (*seq1_r < min_seq || *seq1_r == 0) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
678 *seq1_r = min_seq; |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
679 if (*seq2_r > max_seq) |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
680 *seq2_r = max_seq; |
0 | 681 } |
682 | |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
683 static void search_or_parse_msgset_args(const struct mail_index_header *hdr, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
684 struct mail_search_arg *args, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
685 uint32_t *seq1_r, uint32_t *seq2_r) |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
686 { |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
687 uint32_t seq1, seq2, min_seq1 = 0, max_seq2 = 0; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
688 |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
689 for (; args != NULL; args = args->next) { |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
690 seq1 = 1; seq2 = hdr->messages_count; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
691 |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
692 if (args->type == SEARCH_SUB) { |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
693 i_assert(!args->not); |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
694 search_parse_msgset_args(hdr, args->value.subargs, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
695 &seq1, &seq2); |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
696 } else if (args->type == SEARCH_OR) { |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
697 i_assert(!args->not); |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
698 search_or_parse_msgset_args(hdr, args->value.subargs, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
699 &seq1, &seq2); |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
700 } else if (args->type == SEARCH_SEQSET) { |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
701 search_msgset_fix(hdr, &args->value.seqset, |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
702 &seq1, &seq2, args->not); |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
703 } |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
704 |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
705 if (min_seq1 == 0) { |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
706 min_seq1 = seq1; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
707 max_seq2 = seq2; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
708 } else { |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
709 if (seq1 < min_seq1) |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
710 min_seq1 = seq1; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
711 if (seq2 > max_seq2) |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
712 max_seq2 = seq2; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
713 } |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
714 } |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
715 i_assert(min_seq1 != 0); |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
716 |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
717 if (min_seq1 > *seq1_r) |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
718 *seq1_r = min_seq1; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
719 if (max_seq2 < *seq2_r) |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
720 *seq2_r = max_seq2; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
721 } |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
722 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
723 static void search_parse_msgset_args(const struct mail_index_header *hdr, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
724 struct mail_search_arg *args, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
725 uint32_t *seq1_r, uint32_t *seq2_r) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
726 { |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
727 for (; args != NULL; args = args->next) { |
1376 | 728 if (args->type == SEARCH_SUB) { |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
729 i_assert(!args->not); |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
730 search_parse_msgset_args(hdr, args->value.subargs, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
731 seq1_r, seq2_r); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
732 } else if (args->type == SEARCH_OR) { |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
733 /* go through our children and use the widest seqset |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
734 range */ |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
735 i_assert(!args->not); |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
736 search_or_parse_msgset_args(hdr, args->value.subargs, |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
737 seq1_r, seq2_r); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
738 } else if (args->type == SEARCH_SEQSET) { |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
739 search_msgset_fix(hdr, &args->value.seqset, |
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
740 seq1_r, seq2_r, args->not); |
0 | 741 } |
742 } | |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
743 } |
962
3b139ccc1858
SEARCH didn't properly complain about invalid messagesets. high:low never
Timo Sirainen <tss@iki.fi>
parents:
951
diff
changeset
|
744 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
745 static void search_limit_lowwater(struct index_search_context *ctx, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
746 uint32_t uid_lowwater, uint32_t *first_seq) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
747 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
748 uint32_t seq1, seq2; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
749 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
750 if (uid_lowwater == 0) |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
751 return; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
752 |
6677
90bcf480312d
Renamed mail_index_lookup_uid_range() to mail_index_lookup_seq_range(), made
Timo Sirainen <tss@iki.fi>
parents:
6574
diff
changeset
|
753 mail_index_lookup_seq_range(ctx->view, uid_lowwater, (uint32_t)-1, |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
754 &seq1, &seq2); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
755 if (*first_seq < seq1) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
756 *first_seq = seq1; |
0 | 757 } |
758 | |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
759 static bool search_limit_by_flags(struct index_search_context *ctx, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
760 const struct mail_index_header *hdr, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
761 struct mail_search_arg *args, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
762 uint32_t *seq1, uint32_t *seq2) |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
763 { |
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
764 for (; args != NULL; args = args->next) { |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
765 if (args->type != SEARCH_FLAGS) { |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
766 if (args->type == SEARCH_ALL) { |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
767 if (args->not) |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
768 return FALSE; |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
769 } |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
770 continue; |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
771 } |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
772 if ((args->value.flags & MAIL_SEEN) != 0) { |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
773 /* SEEN with 0 seen? */ |
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
774 if (!args->not && hdr->seen_messages_count == 0) |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
775 return FALSE; |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
776 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
777 if (hdr->seen_messages_count == hdr->messages_count) { |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
778 /* UNSEEN with all seen? */ |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
779 if (args->not) |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
780 return FALSE; |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
781 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
782 /* SEEN with all seen */ |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
783 args->match_always = TRUE; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
784 } else if (args->not) { |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
785 /* UNSEEN with lowwater limiting */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
786 search_limit_lowwater(ctx, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
787 hdr->first_unseen_uid_lowwater, seq1); |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
788 } |
6962
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
789 } |
659e4a606aae
Replaced SEARCH_<flag> with a generic SEARCH_FLAGS. Use value.size for
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
790 if ((args->value.flags & MAIL_DELETED) != 0) { |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
791 /* DELETED with 0 deleted? */ |
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
792 if (!args->not && hdr->deleted_messages_count == 0) |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
793 return FALSE; |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
794 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
795 if (hdr->deleted_messages_count == |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
796 hdr->messages_count) { |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
797 /* UNDELETED with all deleted? */ |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
798 if (args->not) |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
799 return FALSE; |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
800 |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
801 /* DELETED with all deleted */ |
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
802 args->match_always = TRUE; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
803 } else if (!args->not) { |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
804 /* DELETED with lowwater limiting */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
805 search_limit_lowwater(ctx, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
806 hdr->first_deleted_uid_lowwater, seq1); |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
807 } |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
808 } |
962
3b139ccc1858
SEARCH didn't properly complain about invalid messagesets. high:low never
Timo Sirainen <tss@iki.fi>
parents:
951
diff
changeset
|
809 } |
3b139ccc1858
SEARCH didn't properly complain about invalid messagesets. high:low never
Timo Sirainen <tss@iki.fi>
parents:
951
diff
changeset
|
810 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
811 return *seq1 <= *seq2; |
327
276b7a53c264
Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents:
317
diff
changeset
|
812 } |
0 | 813 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
814 static void search_get_seqset(struct index_search_context *ctx, |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
815 struct mail_search_arg *args) |
327
276b7a53c264
Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents:
317
diff
changeset
|
816 { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
817 const struct mail_index_header *hdr; |
0 | 818 |
2892
62d53b49110d
Changed mail_index_get_header() to return the header as return value because
Timo Sirainen <tss@iki.fi>
parents:
2883
diff
changeset
|
819 hdr = mail_index_get_header(ctx->view); |
1985
3ccd4eb52ee4
don't crash when requesting messages from empty mailbox
Timo Sirainen <tss@iki.fi>
parents:
1958
diff
changeset
|
820 if (hdr->messages_count == 0) { |
2899
1a05764af1e0
UID FETCH * gave error message with empty mailbox.
Timo Sirainen <tss@iki.fi>
parents:
2892
diff
changeset
|
821 /* no messages, don't check sequence ranges. although we could |
1a05764af1e0
UID FETCH * gave error message with empty mailbox.
Timo Sirainen <tss@iki.fi>
parents:
2892
diff
changeset
|
822 give error message then for FETCH, we shouldn't do it for |
1a05764af1e0
UID FETCH * gave error message with empty mailbox.
Timo Sirainen <tss@iki.fi>
parents:
2892
diff
changeset
|
823 UID FETCH. */ |
1985
3ccd4eb52ee4
don't crash when requesting messages from empty mailbox
Timo Sirainen <tss@iki.fi>
parents:
1958
diff
changeset
|
824 ctx->seq1 = 1; |
3ccd4eb52ee4
don't crash when requesting messages from empty mailbox
Timo Sirainen <tss@iki.fi>
parents:
1958
diff
changeset
|
825 ctx->seq2 = 0; |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
826 return; |
1985
3ccd4eb52ee4
don't crash when requesting messages from empty mailbox
Timo Sirainen <tss@iki.fi>
parents:
1958
diff
changeset
|
827 } |
3ccd4eb52ee4
don't crash when requesting messages from empty mailbox
Timo Sirainen <tss@iki.fi>
parents:
1958
diff
changeset
|
828 |
4431
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
829 ctx->seq1 = 1; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
830 ctx->seq2 = hdr->messages_count; |
2461061327ed
NOT condition wasn't handled correctly in SEARCH.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4303
diff
changeset
|
831 |
6485
2eff72b212fe
Simplify search tree by canonicalizing message sets, converting NOT away
Timo Sirainen <tss@iki.fi>
parents:
6457
diff
changeset
|
832 search_parse_msgset_args(hdr, args, &ctx->seq1, &ctx->seq2); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
833 if (ctx->seq1 == 0) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
834 ctx->seq1 = 1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
835 ctx->seq2 = hdr->messages_count; |
327
276b7a53c264
Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents:
317
diff
changeset
|
836 } |
4438
00db36e1b734
Don't crash when different search conditions reduce the search range so that
Timo Sirainen <tss@iki.fi>
parents:
4432
diff
changeset
|
837 if (ctx->seq1 > ctx->seq2) { |
4432
c13d8fe698f8
Don't crash if seqset restrictions caused no messages to be searched.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4431
diff
changeset
|
838 /* no matches */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
839 return; |
4432
c13d8fe698f8
Don't crash if seqset restrictions caused no messages to be searched.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4431
diff
changeset
|
840 } |
327
276b7a53c264
Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents:
317
diff
changeset
|
841 |
442
2a25bf21557b
SEARCH SEEN, UNSEEN, DELETED, UNDELETED, RECENT, UNRECENT optimizations.
Timo Sirainen <tss@iki.fi>
parents:
441
diff
changeset
|
842 /* UNSEEN and DELETED in root search level may limit the range */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
843 if (!search_limit_by_flags(ctx, hdr, args, &ctx->seq1, &ctx->seq2)) { |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
844 /* no matches */ |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
845 ctx->seq1 = 1; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
846 ctx->seq2 = 0; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
847 } |
0 | 848 } |
849 | |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
850 struct mail_search_context * |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
851 index_storage_search_init(struct mailbox_transaction_context *_t, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
852 const char *charset, struct mail_search_arg *args, |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
853 const enum mail_sort_type *sort_program) |
0 | 854 { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
855 struct index_transaction_context *t = |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
856 (struct index_transaction_context *)_t; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
857 struct index_search_context *ctx; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
858 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
859 ctx = i_new(struct index_search_context, 1); |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
860 ctx->mail_ctx.transaction = _t; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
861 ctx->ibox = t->ibox; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
2190
diff
changeset
|
862 ctx->view = t->trans_view; |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
863 ctx->mail_ctx.charset = i_strdup(charset); |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
864 ctx->mail_ctx.args = args; |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
865 ctx->mail_ctx.sort_program = index_sort_program_init(_t, sort_program); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
866 |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
867 array_create(&ctx->mail_ctx.module_contexts, default_pool, |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
868 sizeof(void *), 5); |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
869 |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
870 mail_search_args_reset(ctx->mail_ctx.args, TRUE); |
1844
4c2678dd65f1
Some optimizations to messageset handling in search.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
871 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
872 search_get_seqset(ctx, args); |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
873 (void)mail_search_args_foreach(args, search_init_arg, ctx); |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
874 |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
875 /* Need to reset results for match_always cases */ |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
876 mail_search_args_reset(ctx->mail_ctx.args, FALSE); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
877 return &ctx->mail_ctx; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
878 } |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
879 |
5527 | 880 static void search_arg_deinit(struct mail_search_arg *arg, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6280
diff
changeset
|
881 void *context ATTR_UNUSED) |
5527 | 882 { |
883 struct message_search_context *search_ctx = arg->context; | |
884 | |
885 if (search_ctx != NULL) { | |
886 message_search_deinit(&search_ctx); | |
887 arg->context = NULL; | |
888 } | |
889 } | |
890 | |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
891 int index_storage_search_deinit(struct mail_search_context *_ctx) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
892 { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
893 struct index_search_context *ctx = (struct index_search_context *)_ctx; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
894 int ret; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
895 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
896 ret = ctx->failed || ctx->error != NULL ? -1 : 0; |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
897 |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
898 if (ctx->error != NULL) { |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
899 mail_storage_set_error(ctx->ibox->box.storage, |
5613 | 900 MAIL_ERROR_PARAMS, ctx->error); |
962
3b139ccc1858
SEARCH didn't properly complain about invalid messagesets. high:low never
Timo Sirainen <tss@iki.fi>
parents:
951
diff
changeset
|
901 } |
327
276b7a53c264
Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents:
317
diff
changeset
|
902 |
5527 | 903 mail_search_args_reset(ctx->mail_ctx.args, FALSE); |
904 (void)mail_search_args_foreach(ctx->mail_ctx.args, | |
905 search_arg_deinit, NULL); | |
906 | |
5504
9414946e1eb0
Message body search API changed to init/search/deinit. Searching now builds
Timo Sirainen <tss@iki.fi>
parents:
4949
diff
changeset
|
907 if (ctx->search_pool != NULL) |
6428
7cad076906eb
pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents:
6411
diff
changeset
|
908 pool_unref(&ctx->search_pool); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
909 |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
910 if (ctx->mail_ctx.sort_program != NULL) |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
911 index_sort_program_deinit(&ctx->mail_ctx.sort_program); |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
912 array_free(&ctx->mail_ctx.module_contexts); |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
913 i_free(ctx->mail_ctx.charset); |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
914 i_free(ctx); |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
915 return ret; |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
916 } |
327
276b7a53c264
Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents:
317
diff
changeset
|
917 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3795
diff
changeset
|
918 static bool search_match_next(struct index_search_context *ctx) |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
919 { |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
920 struct mail_search_arg *arg; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
921 int ret; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
922 |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
923 /* next search only from cached arguments */ |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
924 ret = mail_search_args_foreach(ctx->mail_ctx.args, |
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
925 search_cached_arg, ctx); |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
926 if (ret >= 0) |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
927 return ret > 0; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
928 |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
929 /* open the mail file and check the rest */ |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
930 if (!search_arg_match_text(ctx->mail_ctx.args, ctx)) |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
931 return FALSE; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
932 |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
933 for (arg = ctx->mail_ctx.args; arg != NULL; arg = arg->next) { |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
934 if (arg->result != 1) |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
935 return FALSE; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
936 } |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
937 |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
938 return TRUE; |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
939 } |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
940 |
4949
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
941 static void index_storage_search_notify(struct mailbox *box, |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
942 struct index_search_context *ctx) |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
943 { |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
944 const struct mail_index_header *hdr; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
945 float percentage; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
946 unsigned int msecs, secs; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
947 |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
948 if (ctx->last_notify.tv_sec == 0) { |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
949 /* set the search time in here, in case a plugin |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
950 already spent some time indexing the mailbox */ |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
951 ctx->search_start_time = ioloop_timeval; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
952 } else if (box->storage->callbacks->notify_ok != NULL) { |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
953 hdr = mail_index_get_header(ctx->ibox->view); |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
954 |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
955 percentage = ctx->mail->seq * 100.0 / hdr->messages_count; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
956 msecs = (ioloop_timeval.tv_sec - |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
957 ctx->search_start_time.tv_sec) * 1000 + |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
958 (ioloop_timeval.tv_usec - |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
959 ctx->search_start_time.tv_usec) / 1000; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
960 secs = (msecs / (percentage / 100.0) - msecs) / 1000; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
961 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
962 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
963 const char *text; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
964 |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
965 text = t_strdup_printf("Searched %d%% of the mailbox, " |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
966 "ETA %d:%02d", (int)percentage, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
967 secs/60, secs%60); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
968 box->storage->callbacks-> |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
969 notify_ok(box, text, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
970 box->storage->callback_context); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
971 } T_END; |
4949
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
972 } |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
973 ctx->last_notify = ioloop_timeval; |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
974 } |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
975 |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
976 int index_storage_search_next_nonblock(struct mail_search_context *_ctx, |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
977 struct mail *mail, bool *tryagain_r) |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
962
diff
changeset
|
978 { |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
979 struct index_search_context *ctx = (struct index_search_context *)_ctx; |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
980 struct mailbox *box = _ctx->transaction->box; |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
981 unsigned int count = 0; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
982 int ret; |
0 | 983 |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
984 *tryagain_r = FALSE; |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
985 |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
986 if (ctx->sorted) { |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
987 /* everything searched at this point already. just returning |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
988 matches from sort list */ |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6276
diff
changeset
|
989 if (!index_sort_list_next(ctx->mail_ctx.sort_program, mail)) |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6276
diff
changeset
|
990 return 0; |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6276
diff
changeset
|
991 return 1; |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
992 } |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
993 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
994 ctx->mail = mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
995 ctx->imail = (struct index_mail *)mail; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
996 |
4949
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
997 if (ioloop_time - ctx->last_notify.tv_sec >= |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
998 SEARCH_NOTIFY_INTERVAL_SECS) |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
999 index_storage_search_notify(box, ctx); |
a959d4208b54
Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
1000 |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1001 while ((ret = box->v.search_next_update_seq(_ctx)) > 0) { |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6276
diff
changeset
|
1002 mail_set_seq(mail, _ctx->seq); |
453
0f6fd6802265
Modify log now stores the changes in ranges, so store 1:100 doesn't
Timo Sirainen <tss@iki.fi>
parents:
450
diff
changeset
|
1003 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
1004 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6899
diff
changeset
|
1005 ret = search_match_next(ctx) ? 1 : 0; |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
1006 } T_END; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
1007 |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
1008 mail_search_args_reset(ctx->mail_ctx.args, FALSE); |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1009 |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
1010 if (ctx->error != NULL) |
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
1011 ret = -1; |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1012 if (ret != 0) { |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
1013 if (ctx->mail_ctx.sort_program == NULL) |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1014 break; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1015 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6276
diff
changeset
|
1016 index_sort_list_add(ctx->mail_ctx.sort_program, mail); |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1017 } |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1018 |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1019 if (++count == SEARCH_NONBLOCK_COUNT) { |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1020 *tryagain_r = TRUE; |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1021 return 0; |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1022 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1845
diff
changeset
|
1023 } |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1024 if (ret < 0) |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1025 ctx->failed = TRUE; |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
1026 ctx->mail = NULL; |
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
1027 ctx->imail = NULL; |
1672
8920600a8cfc
Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents:
1638
diff
changeset
|
1028 |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
1029 if (ctx->mail_ctx.sort_program != NULL && ret == 0) { |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1030 /* finished searching the messages. now sort them and start |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1031 returning the messages. */ |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1032 ctx->sorted = TRUE; |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6276
diff
changeset
|
1033 index_sort_list_finish(ctx->mail_ctx.sort_program); |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1034 return index_storage_search_next_nonblock(_ctx, mail, |
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4907
diff
changeset
|
1035 tryagain_r); |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1036 } |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4259
diff
changeset
|
1037 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3039
diff
changeset
|
1038 return ret; |
0 | 1039 } |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1040 |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1041 int index_storage_search_next_update_seq(struct mail_search_context *_ctx) |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1042 { |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1043 struct index_search_context *ctx = (struct index_search_context *)_ctx; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1044 int ret; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1045 |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1046 if (_ctx->seq == 0) { |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1047 /* first time */ |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1048 _ctx->seq = ctx->seq1; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1049 } else { |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1050 _ctx->seq++; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1051 } |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1052 |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1053 if (!ctx->have_seqsets && !ctx->have_flags_or_keywords) |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1054 return _ctx->seq <= ctx->seq2 ? 1 : 0; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1055 |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1056 ret = 0; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1057 while (_ctx->seq <= ctx->seq2) { |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1058 /* check if the sequence matches */ |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
1059 ret = mail_search_args_foreach(ctx->mail_ctx.args, |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1060 search_seqset_arg, ctx); |
6966
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1061 if (ret != 0) { |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1062 /* check if flags/keywords match before anything else |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1063 is done. mail_set_seq() can be a bit slow. */ |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1064 if (!ctx->have_flags_or_keywords) |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1065 break; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1066 ret = mail_search_args_foreach(ctx->mail_ctx.args, |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1067 search_index_arg, ctx); |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1068 if (ret != 0) |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1069 break; |
7bb6ef75715c
Optimize searching flags and keywords.
Timo Sirainen <tss@iki.fi>
parents:
6965
diff
changeset
|
1070 } |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1071 |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1072 /* doesn't, try next one */ |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1073 _ctx->seq++; |
4607
71b3570946f8
Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents:
4439
diff
changeset
|
1074 mail_search_args_reset(ctx->mail_ctx.args, FALSE); |
4196
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1075 } |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1076 return ret == 0 ? 0 : 1; |
6ac0d63b297f
Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents:
4062
diff
changeset
|
1077 } |