dbox-save.c revision 777ff25e82e0305e2696bcbe3c6e0274e3e8ce10
/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "fdatasync-path.h"
#include "hex-dec.h"
#include "str.h"
#include "istream.h"
#include "istream-crlf.h"
#include "ostream.h"
#include "write-full.h"
#include "index-mail.h"
#include "dbox-storage.h"
#include "dbox-index.h"
#include "dbox-file.h"
#include "dbox-sync.h"
#include <stdlib.h>
struct dbox_save_mail {
};
struct dbox_save_context {
struct mail_save_context ctx;
struct dbox_mailbox *mbox;
struct mail_index_transaction *trans;
struct dbox_index_append_context *append_ctx;
struct dbox_sync_context *sync_ctx;
/* updated for each appended mail: */
struct ostream *cur_output;
unsigned int failed:1;
unsigned int finished:1;
};
struct mail_save_context *
{
struct dbox_transaction_context *t =
(struct dbox_transaction_context *)_t;
struct dbox_save_context *ctx;
}
{
struct dbox_message_header dbox_msg_hdr;
struct dbox_save_mail *save_mail;
struct istream *crlf_input;
enum mail_flags save_flags;
/* get the size of the mail to be saved, if possible */
return -1;
}
/* add to index */
}
}
/* write a dummy header. it'll get rewritten when we're finished */
sizeof(dbox_msg_hdr)) < 0) {
"o_stream_send(%s) failed: %m",
}
}
{
const char *cur_path;
return -1;
do {
if (!mail_storage_set_error_from_errno(storage)) {
"o_stream_send_istream(%s) failed: %m",
cur_path);
}
return -1;
}
/* both tee input readers may consume data from our primary
input stream. we'll have to make sure we don't return with
one of the streams still having data in them. */
return 0;
}
{
struct dbox_metadata_header metadata_hdr;
const char *guid;
sizeof(metadata_hdr.magic_post));
/* write first fields that don't change */
(unsigned long)ioloop_time);
i_unreached();
(unsigned long long)vsize);
}
{
struct dbox_message_header dbox_msg_hdr;
return -1;
}
return -1;
}
}
return 0;
}
{
struct dbox_save_mail *save_mail;
unsigned int count;
return -1;
const char *cur_path;
"o_stream_flush(%s) failed: %m", cur_path);
}
} T_END;
return -1;
} else {
}
return 0;
}
}
{
int ret;
return ret;
}
{
(void)dbox_save_finish(_ctx);
}
static int
{
file->append_offset_header_pos) < 0) {
return -1;
}
return 0;
}
{
}
{
/* temporary file, we'll just unlink it later */
return;
}
}
{
int ret;
if (ret == 0) {
/* the oldest sequence is first. this is needed for uncommit
to work right. */
}
return ret;
}
{
struct dbox_mail_index_record rec;
struct dbox_save_mail *mails;
unsigned int i, count;
int ret = 0;
/* assign UIDs to mails */
for (i = 0; i < count; i++)
/* update headers */
for (i = 0; i < count; i++) {
/* UID file - there's no need to write it to the
header */
continue;
}
dbox_save_mail_write_header(&mails[i]) < 0) {
ret = -1;
break;
}
/* write file header only once after all mails headers
have been written */
if (dbox_save_file_commit_header(&mails[i]) < 0) {
ret = -1;
break;
}
}
}
if (ret < 0) {
/* have to uncommit all written changes */
for (; i > 0; i--) {
continue;
}
return -1;
}
/* set file_id / offsets to records */
return -1;
for (i = 0; i < count; i++) {
}
}
return 0;
}
{
struct dbox_transaction_context *t =
const struct mail_index_header *hdr;
return -1;
}
return -1;
}
return 0;
}
{
i_error("fdatasync_path(%s) failed: %m",
}
}
}
{
}