mbox-save.c revision 18565c69efcd7db003dbf27cf625ed822e889fb1
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "hostpid.h"
#include "ostream.h"
#include "str.h"
#include "write-full.h"
#include "mbox-storage.h"
#include "mbox-file.h"
#include "mbox-from.h"
#include "mbox-lock.h"
#include "mbox-sync-private.h"
#include "mail-save.h"
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
struct mbox_save_context {
struct index_mailbox *ibox;
struct mail_index_transaction *trans;
struct index_mail mail;
const struct mail_full_flags *flags;
unsigned int synced:1;
};
{
"Not enough disk space");
} else {
}
return -1;
}
{
char ch;
int fd;
return 0;
if (ch != '\n') {
return write_error(ctx);
*offset += 1;
}
return 0;
}
{
return write_error(ctx);
return TRUE;
}
const char *from_envelope)
{
if (*my_hostdomain == '\0') {
/* failed, use just the hostname */
name = my_hostname;
}
}
if (from_envelope == NULL) {
}
/* save in local timezone, no matter what it was given with */
return write_error(ctx);
return 0;
}
{
const char *str;
int ret = 0;
/* write Content-Length headers */
t_push();
ret = -1;
ret = -1;
} else {
ret = -1;
}
}
t_pop();
return ret;
}
void *context)
{
/* write our extra headers */
return -1;
return 1;
}
}
static int mbox_save_init_sync(struct mbox_transaction_context *t)
{
const struct mail_index_header *hdr;
return -1;
}
t->mbox_modified = TRUE;
return 0;
}
const struct mbox_flag_type *flags_list)
{
int i;
for (i = 0; flags_list[i].chr != 0; i++) {
}
}
{
if ((flags & STATUS_FLAGS_MASK) != 0) {
}
if ((flags & XSTATUS_FLAGS_MASK) != 0) {
}
}
const char *const *keywords,
unsigned int count)
{
unsigned int i;
for (i = 0; i < count; i++) {
}
}
const struct mail_full_flags *flags,
{
struct mbox_transaction_context *t =
(struct mbox_transaction_context *)_t;
enum mail_flags save_flags;
int ret;
/* FIXME: we could write timezone_offset to From-line.. */
}
return -1;
}
if (mbox_file_open(ibox) < 0)
return -1;
}
/* assign UIDs only if mbox doesn't require syncing */
if (ret < 0)
return -1;
if (ret == 0) {
if (mbox_save_init_sync(t) < 0)
return -1;
}
}
return -1;
4096, FALSE);
}
/* we'll need to assign UID for the mail immediately. */
return -1;
if (mbox_save_init_sync(t) < 0)
return -1;
}
if (!ibox->keep_recent)
save_flags &= ~MAIL_RECENT;
// FIXME: set keywords
}
t_push();
save_header_callback, ctx) < 0 ||
mbox_write_content_length(ctx) < 0 ||
mbox_append_lf(ctx) < 0) {
ret = -1;
} else {
ret = 0;
}
t_pop();
const struct mail_index_record *rec;
return -1;
}
return ret;
}
{
}
{
int ret = 0;
}
ret = -1;
}
}
return ret;
}
{
/* failed, truncate file back to original size.
output stream needs to be flushed before truncating
so unref() won't write anything. */
}
}