Mercurial > dovecot > core-2.2
annotate src/imap/imap-client.h @ 14682:d0d7b810646b
Make sure we check all the functions' return values. Minor API changes to simplify this.
Checked using a patched clang that adds attribute(warn_unused_result) to all
functions. This commit fixes several error handling mistakes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 25 Jun 2012 01:14:03 +0300 |
parents | c93ca5e46a8a |
children | f9d0ea98157f |
rev | line source |
---|---|
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
1 #ifndef IMAP_CLIENT_H |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
2 #define IMAP_CLIENT_H |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
3 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
4 #include "imap-commands.h" |
13563
690f60827f59
imap: Moved partial fetch cache from static variable into struct client.
Timo Sirainen <tss@iki.fi>
parents:
12755
diff
changeset
|
5 #include "message-size.h" |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
6 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
7 #define CLIENT_COMMAND_QUEUE_MAX_SIZE 4 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
8 /* Maximum number of CONTEXT=SEARCH UPDATEs. Clients probably won't need more |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
9 than a few, so this is mainly to avoid more or less accidental pointless |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
10 resource usage. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
11 #define CLIENT_MAX_SEARCH_UPDATES 10 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
12 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
13 struct client; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
14 struct mail_storage; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
15 struct imap_parser; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
16 struct imap_arg; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
17 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
18 struct mailbox_keywords { |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
19 /* All keyword names. The array itself exists in mail_index. |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
20 Keywords are currently only appended, they're never removed. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
21 const ARRAY_TYPE(keywords) *names; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
22 /* Number of keywords announced to client via FLAGS/PERMANENTFLAGS. |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
23 This relies on keywords not being removed while mailbox is |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
24 selected. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
25 unsigned int announce_count; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
26 }; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
27 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
28 struct imap_search_update { |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
29 char *tag; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
30 struct mail_search_result *result; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
31 bool return_uids; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
32 }; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
33 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
34 enum client_command_state { |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
35 /* Waiting for more input */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
36 CLIENT_COMMAND_STATE_WAIT_INPUT, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
37 /* Waiting to be able to send more output */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
38 CLIENT_COMMAND_STATE_WAIT_OUTPUT, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
39 /* Wait for other commands to finish execution */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
40 CLIENT_COMMAND_STATE_WAIT_UNAMBIGUITY, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
41 /* Waiting for other commands to finish so we can sync */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
42 CLIENT_COMMAND_STATE_WAIT_SYNC, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
43 /* Command is finished */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
44 CLIENT_COMMAND_STATE_DONE |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
45 }; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
46 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
47 struct client_command_context { |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
48 struct client_command_context *prev, *next; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
49 struct client *client; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
50 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
51 pool_t pool; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
52 /* IMAP command tag */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
53 const char *tag; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
54 /* Name of this command */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
55 const char *name; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
56 /* Parameters for this command. These are generated from parsed IMAP |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
57 arguments, so they may not be exactly the same as how client sent |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
58 them. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
59 const char *args; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
60 enum command_flags cmd_flags; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
61 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
62 command_func_t *func; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
63 void *context; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
64 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
65 /* Module-specific contexts. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
66 ARRAY_DEFINE(module_contexts, union imap_module_context *); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
67 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
68 struct imap_parser *parser; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
69 enum client_command_state state; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
70 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
71 struct client_sync_context *sync; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
72 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
73 unsigned int uid:1; /* used UID command */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
74 unsigned int cancel:1; /* command is wanted to be cancelled */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
75 unsigned int param_error:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
76 unsigned int search_save_result:1; /* search result is being updated */ |
12751
3053befe6a64
imap: Fixed infinite loop / memory eating with SEARCHRES + pipelining $.
Timo Sirainen <tss@iki.fi>
parents:
12496
diff
changeset
|
77 unsigned int search_save_result_used:1; /* command uses search save */ |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
78 unsigned int temp_executed:1; /* temporary execution state tracking */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
79 }; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
80 |
14219
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
81 struct imap_client_vfuncs { |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
82 void (*destroy)(struct client *client, const char *reason); |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
83 }; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
84 |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
85 struct client { |
9355
d6d4ec8ac06d
imap, pop3 no longer assume that there's only a single client in process.
Timo Sirainen <tss@iki.fi>
parents:
9235
diff
changeset
|
86 struct client *prev, *next; |
d6d4ec8ac06d
imap, pop3 no longer assume that there's only a single client in process.
Timo Sirainen <tss@iki.fi>
parents:
9235
diff
changeset
|
87 |
14219
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
88 struct imap_client_vfuncs v; |
14302
5bbcf636bbeb
Added a "session ID" string for imap/pop3 connections, available in %{session} variable.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
89 const char *session_id; |
14219
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
90 |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
91 int fd_in, fd_out; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
92 struct io *io; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
93 struct istream *input; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
94 struct ostream *output; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
95 struct timeout *to_idle, *to_idle_output; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
96 |
10696
57814e99b451
imap: Added module_contexts to struct client.
Timo Sirainen <tss@iki.fi>
parents:
10695
diff
changeset
|
97 pool_t pool; |
10130
d1384c2b08e5
Merged single and multi mail_storage_service_*() functions.
Timo Sirainen <tss@iki.fi>
parents:
10101
diff
changeset
|
98 struct mail_storage_service_user *service_user; |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
99 const struct imap_settings *set; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
100 string_t *capability_string; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
101 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
102 struct mail_user *user; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
103 struct mailbox *mailbox; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
104 struct mailbox_keywords keywords; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
105 unsigned int sync_counter; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
106 uint32_t messages_count, recent_count, uidvalidity; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
107 enum mailbox_feature enabled_features; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
108 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
109 time_t last_input, last_output; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
110 unsigned int bad_counter; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
111 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
112 /* one parser is kept here to be used for new commands */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
113 struct imap_parser *free_parser; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
114 /* command_pool is cleared when the command queue gets empty */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
115 pool_t command_pool; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
116 /* New commands are always prepended to the queue */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
117 struct client_command_context *command_queue; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
118 unsigned int command_queue_size; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
119 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
120 uint64_t sync_last_full_modseq; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
121 uint64_t highest_fetch_modseq; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
122 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
123 /* SEARCHRES extension: Last saved SEARCH result */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
124 ARRAY_TYPE(seq_range) search_saved_uidset; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
125 /* SEARCH=CONTEXT extension: Searches that get updated */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
126 ARRAY_DEFINE(search_updates, struct imap_search_update); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
127 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
128 /* client input/output is locked by this command */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
129 struct client_command_context *input_lock; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
130 struct client_command_context *output_lock; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
131 /* command changing the mailbox */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
132 struct client_command_context *mailbox_change_lock; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
133 |
10696
57814e99b451
imap: Added module_contexts to struct client.
Timo Sirainen <tss@iki.fi>
parents:
10695
diff
changeset
|
134 /* Module-specific contexts. */ |
57814e99b451
imap: Added module_contexts to struct client.
Timo Sirainen <tss@iki.fi>
parents:
10695
diff
changeset
|
135 ARRAY_DEFINE(module_contexts, union imap_module_context *); |
57814e99b451
imap: Added module_contexts to struct client.
Timo Sirainen <tss@iki.fi>
parents:
10695
diff
changeset
|
136 |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
137 /* syncing marks this TRUE when it sees \Deleted flags. this is by |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
138 EXPUNGE for Outlook-workaround. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
139 unsigned int sync_seen_deletes:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
140 unsigned int sync_seen_expunges:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
141 unsigned int disconnected:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
142 unsigned int destroyed:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
143 unsigned int handling_input:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
144 unsigned int syncing:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
145 unsigned int id_logged:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
146 unsigned int mailbox_examined:1; |
9235
2e2b957f1cca
Implemented anvil service, which is used to implement mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
9219
diff
changeset
|
147 unsigned int anvil_sent:1; |
10695
fd5141e85076
imap: Remember if TLS compression is enabled.
Timo Sirainen <tss@iki.fi>
parents:
10661
diff
changeset
|
148 unsigned int tls_compression:1; |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
149 unsigned int input_skip_line:1; /* skip all the data until we've |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
150 found a new line */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
151 unsigned int modseqs_sent_since_sync:1; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
152 }; |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
153 |
14219
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
154 struct imap_module_register { |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
155 unsigned int id; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
156 }; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
157 |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
158 union imap_module_context { |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
159 struct imap_client_vfuncs super; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
160 struct imap_module_register *reg; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
161 }; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
162 extern struct imap_module_register imap_module_register; |
e20af99c6d20
imap: Made client_destroy() a virtual method.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
163 |
10101
4fe8c4382712
Redesigned how login process passes connections to mail processes and changed related APIs.
Timo Sirainen <tss@iki.fi>
parents:
10093
diff
changeset
|
164 extern struct client *imap_clients; |
10192
585bceaf98bb
imap: Added support for verbose_proctitle=yes
Timo Sirainen <tss@iki.fi>
parents:
10130
diff
changeset
|
165 extern unsigned int imap_client_count; |
10101
4fe8c4382712
Redesigned how login process passes connections to mail processes and changed related APIs.
Timo Sirainen <tss@iki.fi>
parents:
10093
diff
changeset
|
166 |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
167 /* Create new client with specified input/output handles. socket specifies |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
168 if the handle is a socket. */ |
14302
5bbcf636bbeb
Added a "session ID" string for imap/pop3 connections, available in %{session} variable.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
169 struct client *client_create(int fd_in, int fd_out, const char *session_id, |
5bbcf636bbeb
Added a "session ID" string for imap/pop3 connections, available in %{session} variable.
Timo Sirainen <tss@iki.fi>
parents:
13563
diff
changeset
|
170 struct mail_user *user, |
10130
d1384c2b08e5
Merged single and multi mail_storage_service_*() functions.
Timo Sirainen <tss@iki.fi>
parents:
10101
diff
changeset
|
171 struct mail_storage_service_user *service_user, |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
172 const struct imap_settings *set); |
14629
c93ca5e46a8a
Marked functions parameters that are allowed to be NULL. Some APIs were also changed.
Timo Sirainen <tss@iki.fi>
parents:
14623
diff
changeset
|
173 void client_destroy(struct client *client, const char *reason) ATTR_NULL(2); |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
174 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
175 /* Disconnect client connection */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
176 void client_disconnect(struct client *client, const char *reason); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
177 void client_disconnect_with_error(struct client *client, const char *msg); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
178 |
14682
d0d7b810646b
Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents:
14629
diff
changeset
|
179 /* Send a line of data to client. */ |
d0d7b810646b
Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents:
14629
diff
changeset
|
180 void client_send_line(struct client *client, const char *data); |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
181 /* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full, |
14682
d0d7b810646b
Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents:
14629
diff
changeset
|
182 -1 if error. This should be used when you're (potentially) sending a lot of |
d0d7b810646b
Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents:
14629
diff
changeset
|
183 lines to client. */ |
d0d7b810646b
Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents:
14629
diff
changeset
|
184 int client_send_line_next(struct client *client, const char *data); |
10661
bd06d9b159fa
imap-client.h: Updated comments.
Timo Sirainen <tss@iki.fi>
parents:
10192
diff
changeset
|
185 /* Send line of data to client, prefixed with client->tag. You need to prefix |
bd06d9b159fa
imap-client.h: Updated comments.
Timo Sirainen <tss@iki.fi>
parents:
10192
diff
changeset
|
186 the data with "OK ", "NO " or "BAD ". */ |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
187 void client_send_tagline(struct client_command_context *cmd, const char *data); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
188 |
10661
bd06d9b159fa
imap-client.h: Updated comments.
Timo Sirainen <tss@iki.fi>
parents:
10192
diff
changeset
|
189 /* Send a BAD command reply to client via client_send_tagline(). If there have |
bd06d9b159fa
imap-client.h: Updated comments.
Timo Sirainen <tss@iki.fi>
parents:
10192
diff
changeset
|
190 been too many command errors, the client is disconnected. msg may be NULL, |
bd06d9b159fa
imap-client.h: Updated comments.
Timo Sirainen <tss@iki.fi>
parents:
10192
diff
changeset
|
191 in which case the error is looked up from imap_parser. */ |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
192 void client_send_command_error(struct client_command_context *cmd, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
193 const char *msg); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
194 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
195 /* Read a number of arguments. Returns TRUE if everything was read or |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
196 FALSE if either needs more data or error occurred. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
197 bool client_read_args(struct client_command_context *cmd, unsigned int count, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
198 unsigned int flags, const struct imap_arg **args_r); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
199 /* Reads a number of string arguments. ... is a list of pointers where to |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
200 store the arguments. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
201 bool client_read_string_args(struct client_command_context *cmd, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
202 unsigned int count, ...); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
203 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
204 /* SEARCHRES extension: Call if $ is being used/updated, returns TRUE if we |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
205 have to wait for an existing SEARCH SAVE to finish. */ |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
206 bool client_handle_search_save_ambiguity(struct client_command_context *cmd); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
207 |
12550
2c299c0e3bc8
lib-storage: Moved some items from mailbox_get_status() to a new mailbox_get_metadata().
Timo Sirainen <tss@iki.fi>
parents:
12496
diff
changeset
|
208 int client_enable(struct client *client, enum mailbox_feature features); |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
209 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
210 struct imap_search_update * |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
211 client_search_update_lookup(struct client *client, const char *tag, |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
212 unsigned int *idx_r); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
213 void client_search_updates_free(struct client *client); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
214 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
215 void client_command_cancel(struct client_command_context **cmd); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
216 void client_command_free(struct client_command_context **cmd); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
217 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
218 bool client_handle_unfinished_cmd(struct client_command_context *cmd); |
9385
89d2dbbfa4ca
imap: Cleaned up "command pending" handling code. Should fix hangs caused by recent changes.
Timo Sirainen <tss@iki.fi>
parents:
9355
diff
changeset
|
219 void client_continue_pending_input(struct client *client); |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
220 |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
221 void client_input(struct client *client); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
222 bool client_handle_input(struct client *client); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
223 int client_output(struct client *client); |
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
224 |
9355
d6d4ec8ac06d
imap, pop3 no longer assume that there's only a single client in process.
Timo Sirainen <tss@iki.fi>
parents:
9235
diff
changeset
|
225 void clients_destroy_all(void); |
d6d4ec8ac06d
imap, pop3 no longer assume that there's only a single client in process.
Timo Sirainen <tss@iki.fi>
parents:
9235
diff
changeset
|
226 |
9219
97cdfeb57129
Renamed headers to prevent collision if they were flattened on an install.
Mark Washenberger
parents:
diff
changeset
|
227 #endif |