Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/imap/cmd-sort.c @ 5835:d59ed6a31b66 HEAD
Added more consts to imap-parser API
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 29 Jun 2007 19:03:45 +0300 |
parents | ff2272c228cc |
children | 9f869a7a3d73 |
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 "common.h" |
765
553f050c8313
Added buffer API. Point is to hide all buffer writing behind this API which
Timo Sirainen <tss@iki.fi>
parents:
764
diff
changeset
|
4 #include "buffer.h" |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "commands.h" |
988
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
924
diff
changeset
|
6 #include "imap-search.h" |
8028c4dcf38f
mail-storage.h interface changes, affects pretty much everything.
Timo Sirainen <tss@iki.fi>
parents:
924
diff
changeset
|
7 #include "imap-sort.h" |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
9 struct sort_name { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
10 enum mail_sort_type type; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 const char *name; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
12 }; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
14 static struct sort_name sort_names[] = { |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 { MAIL_SORT_ARRIVAL, "arrival" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 { MAIL_SORT_CC, "cc" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 { MAIL_SORT_DATE, "date" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 { MAIL_SORT_FROM, "from" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 { MAIL_SORT_SIZE, "size" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 { MAIL_SORT_SUBJECT, "subject" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 { MAIL_SORT_TO, "to" }, |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 { MAIL_SORT_END, NULL } |
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 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
26 static int |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
27 get_sort_program(struct client_command_context *cmd, |
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
28 const struct imap_arg *args, |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
29 enum mail_sort_type program[MAX_SORT_PROGRAM_SIZE]) |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 { |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
31 enum mail_sort_type mask = 0; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
32 unsigned int i, pos; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
33 bool reverse; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 |
1012
b2d9219c60af
Give nice error message for "SORT ()"
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
35 if (args->type == IMAP_ARG_EOL) { |
b2d9219c60af
Give nice error message for "SORT ()"
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
36 /* empyty list */ |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
37 client_send_command_error(cmd, "Empty sort program."); |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
38 return -1; |
1012
b2d9219c60af
Give nice error message for "SORT ()"
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
39 } |
b2d9219c60af
Give nice error message for "SORT ()"
Timo Sirainen <tss@iki.fi>
parents:
988
diff
changeset
|
40 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
41 pos = 0; reverse = FALSE; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
42 for (; args->type == IMAP_ARG_ATOM || args->type == IMAP_ARG_STRING; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
43 args++) { |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
44 const char *arg = IMAP_ARG_STR(args); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
46 if (strcasecmp(arg, "reverse") == 0) { |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
47 reverse = !reverse; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
48 continue; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
49 } |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 for (i = 0; sort_names[i].type != MAIL_SORT_END; i++) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 if (strcasecmp(arg, sort_names[i].name) == 0) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 break; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 if (sort_names[i].type == MAIL_SORT_END) { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
57 client_send_command_error(cmd, t_strconcat( |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 "Unknown sort argument: ", arg, NULL)); |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
59 return -1; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
62 if ((mask & sort_names[i].type) != 0) |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
63 continue; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
64 mask |= sort_names[i].type; |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
65 |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
66 /* @UNSAFE: mask check should prevent us from ever |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
67 overflowing */ |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
68 i_assert(pos < MAX_SORT_PROGRAM_SIZE-1); |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
69 program[pos++] = sort_names[i].type | |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
70 (reverse ? MAIL_SORT_FLAG_REVERSE : 0); |
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
71 reverse = FALSE; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
74 program[pos++] = MAIL_SORT_END; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 if (args->type != IMAP_ARG_EOL) { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
77 client_send_command_error(cmd, |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 "Invalid sort list argument."); |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
79 return -1; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
80 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
82 return 0; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 } |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3765
diff
changeset
|
85 bool cmd_sort(struct client_command_context *cmd) |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
86 { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
87 struct client *client = cmd->client; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
88 struct mail_search_arg *sargs; |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
89 enum mail_sort_type sorting[MAX_SORT_PROGRAM_SIZE]; |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
4939
diff
changeset
|
90 const struct imap_arg *args; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
91 int args_count; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
92 pool_t pool; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
93 const char *error, *charset; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
94 |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4303
diff
changeset
|
95 args_count = imap_parser_read_args(cmd->parser, 0, 0, &args); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
96 if (args_count == -2) |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 return FALSE; |
4939
ff2272c228cc
Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents:
4303
diff
changeset
|
98 client->input_lock = NULL; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
99 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 if (args_count < 3) { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
101 client_send_command_error(cmd, args_count < 0 ? NULL : |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
102 "Missing or invalid arguments."); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
103 return TRUE; |
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 |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
106 if (!client_verify_open_mailbox(cmd)) |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 return TRUE; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 /* sort program */ |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 if (args->type != IMAP_ARG_LIST) { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
111 client_send_command_error(cmd, "Invalid sort argument."); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 return TRUE; |
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 |
4303
5f03738219a6
Changed mail-storage API to do the mail sorting internally. Optimized it
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3863
diff
changeset
|
115 if (get_sort_program(cmd, IMAP_ARG_LIST(args)->args, sorting) < 0) |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
116 return TRUE; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 args++; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 /* charset */ |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 if (args->type != IMAP_ARG_ATOM && args->type != IMAP_ARG_STRING) { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
121 client_send_command_error(cmd, |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 "Invalid charset argument."); |
924
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
123 return TRUE; |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 } |
877
7935347f54f1
Don't access ImapArg's union members directly - too easy to mess up. Fixes a
Timo Sirainen <tss@iki.fi>
parents:
825
diff
changeset
|
125 charset = IMAP_ARG_STR(args); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 args++; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
127 |
924
4f697dde0fca
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
128 pool = pool_alloconly_create("mail_search_args", 2048); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
129 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
130 sargs = imap_search_args_build(pool, client->mailbox, args, &error); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
131 if (sargs == NULL) { |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
132 /* error in search arguments */ |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
133 client_send_tagline(cmd, t_strconcat("NO ", error, NULL)); |
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
134 } else if (imap_sort(cmd, charset, sargs, sorting) == 0) { |
2427
e1616067df5c
Syncing works now too without buffering everything. Also fixed handling
Timo Sirainen <tss@iki.fi>
parents:
2023
diff
changeset
|
135 pool_unref(pool); |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
136 return cmd_sync(cmd, MAILBOX_SYNC_FLAG_FAST | |
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
137 (cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES), |
3765
ce76b6b8ff11
UID STORE command must return UID parameter in FETCH replies.
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
138 0, "OK Sort completed."); |
761
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
139 } else { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2708
diff
changeset
|
140 client_send_storage_error(cmd, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
141 mailbox_get_storage(client->mailbox)); |
761
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 |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 pool_unref(pool); |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
145 return TRUE; |
d3bd41a56309
First implementation of SORT extension. String comparing still not up to
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 } |