9
typedef int command_func_t(struct client *client);
11
struct mailbox_custom_flags {
11
struct mailbox_keywords {
12
12
pool_t pool; /* will be p_clear()ed when changed */
15
unsigned int custom_flags_count;
14
array_t ARRAY_DEFINE(keywords, const char *);
17
struct client_command_context {
18
struct client *client;
27
unsigned int uid:1; /* used UID command */
28
unsigned int param_error:1;
21
34
struct istream *input;
22
35
struct ostream *output;
24
struct mail_storage *storage;
37
struct namespace *namespaces;
25
38
struct mailbox *mailbox;
26
struct mailbox_custom_flags mailbox_flags;
39
struct mailbox_keywords keywords;
27
40
unsigned int select_counter; /* increased when mailbox is changed */
41
uint32_t messages_count, recent_count;
43
time_t last_input, last_output;
30
44
unsigned int bad_counter;
32
46
struct imap_parser *parser;
33
const char *cmd_tag; /* tag of command (allocated from parser pool), */
34
const char *cmd_name; /* command name (allocated from parser pool) */
35
command_func_t *cmd_func;
37
struct timeout *idle_to;
38
unsigned int idle_expunge;
40
unsigned int cmd_error:1;
41
unsigned int cmd_uid:1; /* used UID command */
42
unsigned int sync_flags_send_uid:1;
47
struct client_command_context cmd;
49
unsigned int command_pending:1;
50
unsigned int input_pending:1;
51
unsigned int output_pending:1;
43
52
unsigned int rawlog:1;
44
53
unsigned int input_skip_line:1; /* skip all the data until we've
45
54
found a new line */
48
57
/* Create new client with specified input/output handles. socket specifies
49
58
if the handle is a socket. */
50
struct client *client_create(int hin, int hout, struct mail_storage *storage);
59
struct client *client_create(int hin, int hout, struct namespace *namespaces);
51
60
void client_destroy(struct client *client);
53
62
/* Disconnect client connection */
54
63
void client_disconnect(struct client *client);
55
64
void client_disconnect_with_error(struct client *client, const char *msg);
57
/* Send a line of data to client */
58
void client_send_line(struct client *client, const char *data);
66
/* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
68
int client_send_line(struct client *client, const char *data);
59
69
/* Send line of data to client, prefixed with client->tag */
60
void client_send_tagline(struct client *client, const char *data);
70
void client_send_tagline(struct client_command_context *cmd, const char *data);
62
72
/* Send BAD command error to client. msg can be NULL. */
63
void client_send_command_error(struct client *client, const char *msg);
73
void client_send_command_error(struct client_command_context *cmd,
65
76
/* Read a number of arguments. Returns TRUE if everything was read or
66
FALSE if either needs more data or error occured. */
67
int client_read_args(struct client *client, unsigned int count,
77
FALSE if either needs more data or error occurred. */
78
int client_read_args(struct client_command_context *cmd, unsigned int count,
68
79
unsigned int flags, struct imap_arg **args);
69
80
/* Reads a number of string arguments. ... is a list of pointers where to
70
81
store the arguments. */
71
int client_read_string_args(struct client *client, unsigned int count, ...);
82
int client_read_string_args(struct client_command_context *cmd,
83
unsigned int count, ...);
73
85
void clients_init(void);
74
86
void clients_deinit(void);
88
void _client_reset_command(struct client *client);
76
89
void _client_input(void *context);
77
void _client_reset_command(struct client *client);
90
int _client_output(void *context);