cmd-append.c revision b2c1349cf07410aefab0f5b17153af9e5cfcf48f
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "commands.h"
#include "imap-parser.h"
#include "imap-date.h"
#include "mail-storage.h"
struct cmd_append_context {
struct mail_storage *storage;
struct mailbox_transaction_context *t;
struct imap_parser *save_parser;
struct mail_save_context *save_ctx;
};
static void client_input(void *context)
{
case -1:
/* disconnected */
return;
case -2:
if (client->command_pending) {
/* message data, this is handled internally by
mailbox_save_continue() */
break;
}
/* parameter word is longer than max. input buffer size.
this is most likely an error, so skip the new data
until newline is found. */
break;
}
/* command execution was finished */
client->bad_counter = 0;
if (client->input_pending)
}
}
/* Returns -1 = error, 0 = need more data, 1 = successful. flags and
internal_date may be NULL as a result, but mailbox and msg_size are always
set when successful. */
int *nonsync)
{
/* [<flags>] */
else {
args++;
}
/* [<internal date>] */
*internal_date = NULL;
else {
args++;
}
return FALSE;
return TRUE;
}
{
}
{
struct imap_arg_list *flags_list;
struct mail_full_flags flags;
const char *internal_date_str;
/* if error occurs, the CRLF is already read. */
/* [<flags>] [<internal date>] <message literal> */
if (ret == -1) {
return TRUE;
}
if (ret < 0) {
/* need more data */
return FALSE;
}
/* last message */
enum mailbox_sync_flags sync_flags;
if (ret < 0) {
return TRUE;
}
}
return TRUE;
}
if (flags_list != NULL) {
return TRUE;
}
} else {
}
if (internal_date_str == NULL) {
/* no time given, default to now. */
timezone_offset = 0;
} else if (!imap_parse_datetime(internal_date_str,
&internal_date, &timezone_offset)) {
return TRUE;
}
/* no message data, abort */
return TRUE;
}
if (!nonsync) {
}
/* after literal comes CRLF, if we fail make sure we eat it away */
/* save the mail */
return cmd_append_continue_message(client);
}
{
int failed;
/* we still have to finish reading the message
from client */
}
}
}
/* finished */
/* failed above */
/* client disconnected */
} else {
}
if (failed) {
return TRUE;
}
/* prepare for next message */
return cmd_append_continue_parsing(client);
}
return FALSE;
}
{
struct cmd_append_context *ctx;
struct mail_storage *storage;
struct mailbox_status status;
const char *mailbox;
/* <mailbox> */
return FALSE;
return TRUE;
return TRUE;
else {
return TRUE;
}
}
return TRUE;
}
return cmd_append_continue_parsing(client);
}