cmd-append.c revision 57b38969882b61538660652b70e213f64bf20cb7
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen/* Don't allow internaldates to be too far in the future. At least with Maildir
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen they can cause problems with incremental backups since internaldate is
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen stored in file's mtime. But perhaps there are also some other reasons why
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen it might not be wanted. */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen unsigned int count;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenstatic void cmd_append_finish(struct cmd_append_context *ctx);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenstatic bool cmd_append_continue_message(struct client_command_context *cmd);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenstatic bool cmd_append_continue_parsing(struct client_command_context *cmd);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenstatic const char *get_disconnect_reason(struct cmd_append_context *ctx)
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen unsigned int secs = ioloop_time - ctx->started;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen str_printfa(str, "Disconnected in APPEND (%u msgs, %u secs",
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen str_printfa(str, ", %"PRIuUOFF_T"/%"PRIuUOFF_T" bytes",
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenstatic void client_input_append(struct client_command_context *cmd)
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen struct cmd_append_context *ctx = cmd->context;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen /* disconnected */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen /* Reset command so that client_destroy() doesn't try to call
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen cmd_append_continue_message() anymore. */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen /* message data, this is handled internally by
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen mailbox_save_continue() */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen /* parameter word is longer than max. input buffer size.
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen this is most likely an error, so skip the new data
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen until newline is found. */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen client_send_command_error(cmd, "Too long argument.");
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen if (!finished && cmd->state != CLIENT_COMMAND_STATE_DONE)
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenstatic void cmd_append_finish(struct cmd_append_context *ctx)
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen i_assert(ctx->client->input_lock == ctx->cmd);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen /* we must put back the original flush callback before beginning to
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen sync (the command is still unfinished at that point) */
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen o_stream_set_flush_callback(ctx->client->output,
return TRUE;
return TRUE;
return FALSE;
if (!nonsync) {
return TRUE;
const char *error;
int ret;
if (ret < 0) {
if (ret == 0) {
if (ret < 0) {
if (ret == 0) {
if (size == 0) {
ret = 0;
const char *catpart;
const char *caturl;
args++;
args++;
args++;
const char *msg;
int ret;
return TRUE;
if (fatal)
return TRUE;
if (ret < 0) {
return FALSE;
if (ret == 0) {
if (!nonsync) {
const char *const *keywords_list;
const char *internal_date_str;
bool valid;
(*args)++;
(*args)++;
(*args)++;
if (!valid) {
&keywords) < 0) {
flags = 0;
timezone_offset = 0;
timezone_offset = 0;
} else if (ret == 0) {
unsigned int save_count;
int ret;
return TRUE;
return TRUE;
if (ret < 0) {
return TRUE;
if (save_count == 0) {
sync_flags = 0;
imap_flags = 0;
const char *msg;
int ret;
return TRUE;
if (fatal)
return TRUE;
if (ret < 0) {
return FALSE;
args++;
if (ret < 0)
if (!nonsync) {
int ret = 0;
return TRUE;
} else if (!all_written) {
return TRUE;
return FALSE;
const char *mailbox;
return FALSE;
return FALSE;