Mercurial > dovecot > core-2.2
annotate src/lib-storage/index/index-sort.c @ 792:d573c53946ac HEAD
Full not-too-well-tested support for SORT extension. Required a few
library interface changes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 17 Dec 2002 06:28:40 +0200 |
parents | f57c52738f90 |
children | 35abd7a5d381 |
rev | line source |
---|---|
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 /* Copyright (C) 2002 Timo Sirainen */ |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "lib.h" |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
761
diff
changeset
|
4 #include "ostream.h" |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "rfc822-date.h" |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "imap-envelope.h" |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "imap-message-cache.h" |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "mail-index.h" |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "index-storage.h" |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 #include "index-sort.h" |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 static ImapMessageCache *search_open_cache(IndexSortContext *ctx, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 unsigned int uid) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 if (ctx->last_uid != uid) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 ctx->cached = FALSE; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 ctx->last_uid = uid; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 ctx->rec = ctx->ibox->index->lookup_uid_range(ctx->ibox->index, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 uid, uid, NULL); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 if (ctx->rec == NULL) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 ctx->last_uid = 0; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 return NULL; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 if (!ctx->cached) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 ctx->cached = TRUE; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 (void)index_msgcache_open(ctx->ibox->cache, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 ctx->ibox->index, ctx->rec, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 IMAP_CACHE_ENVELOPE); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 return ctx->ibox->cache; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 static uoff_t _input_uofft(MailSortType type, unsigned int id, void *context) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 IndexSortContext *ctx = context; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 ImapMessageCache *cache; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 if (type != MAIL_SORT_SIZE) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 i_unreached(); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 return 0; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 cache = search_open_cache(ctx, id); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 return cache == NULL ? 0 : imap_msgcache_get_virtual_size(cache); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 |
792
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
50 static const char *_input_mailbox(MailSortType type, unsigned int id, |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
51 void *context) |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 IndexSortContext *ctx = context; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 ImapEnvelopeField env_field; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 const char *envelope; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 switch (type) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 case MAIL_SORT_CC: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 env_field = IMAP_ENVELOPE_CC; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 break; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 case MAIL_SORT_FROM: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 env_field = IMAP_ENVELOPE_FROM; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 break; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 case MAIL_SORT_TO: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 env_field = IMAP_ENVELOPE_TO; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 break; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 default: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 i_unreached(); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 return NULL; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 /* get field from hopefully cached envelope */ |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 envelope = imap_msgcache_get(search_open_cache(ctx, id), |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 IMAP_CACHE_ENVELOPE); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 return envelope == NULL ? NULL : |
792
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
76 imap_envelope_parse(envelope, env_field, |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
77 IMAP_ENVELOPE_RESULT_FIRST_MAILBOX); |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
78 } |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
79 |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
80 static const char *_input_str(MailSortType type, unsigned int id, void *context) |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
81 { |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
82 IndexSortContext *ctx = context; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
83 ImapEnvelopeField env_field; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
84 const char *envelope; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
85 |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
86 switch (type) { |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
87 case MAIL_SORT_DATE: |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
88 env_field = IMAP_ENVELOPE_DATE; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
89 break; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
90 case MAIL_SORT_SUBJECT: |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
91 env_field = IMAP_ENVELOPE_SUBJECT; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
92 break; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
93 default: |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
94 i_unreached(); |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
95 return NULL; |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
96 } |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
97 |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
98 /* get field from hopefully cached envelope */ |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
99 envelope = imap_msgcache_get(search_open_cache(ctx, id), |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
100 IMAP_CACHE_ENVELOPE); |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
101 return envelope == NULL ? NULL : |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
102 imap_envelope_parse(envelope, env_field, |
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
103 IMAP_ENVELOPE_RESULT_STRING); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
104 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
106 static time_t _input_time(MailSortType type, unsigned int id, void *context) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 IndexSortContext *ctx = context; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 ImapMessageCache *cache; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 const char *str; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 time_t time; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 int timezone_offset; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
114 switch (type) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 case MAIL_SORT_ARRIVAL: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
116 cache = search_open_cache(ctx, id); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 return cache == NULL ? 0 : |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 imap_msgcache_get_internal_date(cache); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 case MAIL_SORT_DATE: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 str = _input_str(type, id, context); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 if (str == NULL) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 return 0; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 if (!rfc822_parse_date(str, &time, &timezone_offset)) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 return 0; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
127 return time - timezone_offset*60; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
128 default: |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
129 i_unreached(); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
130 return 0; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
131 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
132 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
133 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
134 static void _input_reset(void *context) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
135 { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
136 IndexSortContext *ctx = context; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
137 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 ctx->cached = FALSE; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
139 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
140 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
141 static void _output(unsigned int *data, size_t count, void *context) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
142 { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
143 IndexSortContext *ctx = context; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 char num[MAX_INT_STRLEN+1]; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
145 size_t i, len; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
147 for (i = 0; i < count; i++) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
148 len = i_snprintf(num, sizeof(num), " %u", data[i]); |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
761
diff
changeset
|
149 o_stream_send(ctx->output, num, len); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
150 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
151 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
152 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
153 MailSortFuncs index_sort_funcs = { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
154 _input_time, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
155 _input_uofft, |
792
d573c53946ac
Full not-too-well-tested support for SORT extension. Required a few
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
156 _input_mailbox, |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
157 _input_str, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
158 _input_reset, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
159 _output |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
160 }; |