mbox-sync.c revision d252f81a2ff1bdd5439f9d2b3df715b70a4bcd3d
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi/* Copyright (C) 2004 Timo Sirainen */
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd Modifying mbox can be slow, so we try to do it all at once minimizing the
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd required disk I/O. We may need to:
6ae232055d4d8a97267517c5e50074c2c819941and - Update message flags in Status, X-Status and X-Keywords headers
dc0d8d65d35787d30a275895ccad8d8e1b58a5ednd - Write missing X-UID and X-IMAPbase headers
6ae232055d4d8a97267517c5e50074c2c819941and - Write missing or broken Content-Length header if there's space
a78048ccbdb6256da15e6b0e7e95355e480c2301nd - Expunge specified messages
a78048ccbdb6256da15e6b0e7e95355e480c2301nd Here's how we do it:
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end - Start reading the mails from the beginning
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end - X-Keywords, X-UID and X-IMAPbase headers may contain padding at the end
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end of them, remember how much each message has and offset to beginning of the
#include "lib.h"
#include "ioloop.h"
#include "buffer.h"
#include "istream.h"
#include "file-set-size.h"
#include "str.h"
#include "write-full.h"
#include "istream-raw-mbox.h"
#include "mbox-storage.h"
#include "mbox-file.h"
#include "mbox-lock.h"
#include "mbox-sync-private.h"
#include <stddef.h>
dest++;
for (i = 0; i < size; i++) {
return TRUE;
return FALSE;
int ret;
if (uid == 0) {
sizeof(*sync_rec));
if (ret < 0) {
if (ret == 0) {
if (!*sync_expunge_r)
for (i = 0; i < size; i++) {
int ret = 0;
if (ret < 0) {
ret = 0;
return ret;
unsigned char hdr_md5_sum[],
const void *data;
int ret;
if (ret < 0) {
&data) < 0) {
const void *data;
&data) < 0) {
int nocheck)
if (!nocheck) {
&offset) < 0)
INDEX_KEYWORDS_BYTE_COUNT) != 0) {
const unsigned char *data;
if (from_line_size == 0)
idx = 0;
if (idx_seq == 0) {
&offset);
int ret;
if (ret < 0)
if (ret > 0) {
if (seq == 0) {
seq++;
if (ret < 0) {
if (ret == 0) {
old_offset) < 0) {
messages_count : 0);
&expunged) < 0)
if (size == 0)
if (ret <= 0)
return ret;
uid = 0;
if (ret < 0)
if (ret == 0)
uid = 0;
&rec) < 0)
if (!expunged) {
if (ret < 0)
if (!expunged) {
rec) < 0)
if (!expunged) {
if (!partial)
int need_rewrite;
if (need_rewrite) {
trailer_size) < 0)
min_msg_count = 0;
if (ret <= 0) {
if (ret < 0)
unsigned int lock_id = 0;
if (!changed)
lock_id = 0;
if (changed) {
if (ret <= 0) {
if (ret < 0)
if (lock_id != 0)
return ret;
if (lock_id != 0)
if (lock_id == 0) {
goto __again;
if (ret < 0)
if (ret < 0)
if (ret < 0)
&seq,
&offset) < 0) {
index_sync_ctx) < 0) {
unsigned int read_lock_id = 0;
return ret;
struct mailbox_sync_context *
int ret = 0;