mbox-sync-full.c revision a8767e3a8dd08bb782f05dacf2c8877f3cba644e
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "istream.h"
#include "hex-binary.h"
#include "message-parser.h"
#include "message-part-serialize.h"
#include "mbox-index.h"
#include "mbox-lock.h"
#include "mail-index-util.h"
#include <unistd.h>
#include <fcntl.h>
{
const unsigned char *msg;
for (i = 0; i < size; i++) {
if (msg[i] == '\n') {
return;
}
}
i_stream_skip(input, i);
}
}
unsigned char current_digest[16])
{
const unsigned char *old_digest;
/* MD5 sums must match */
}
{
const void *part_data;
void *part_data_copy;
/* update FIELD_HDR_HEADER_SIZE */
sizeof(hdr_size->physical_size));
/* reset FIELD_HDR_VIRTUAL_SIZE - we don't know it anymore */
&virtual_size, sizeof(virtual_size));
/* update DATA_FIELD_MESSAGEPART */
return TRUE;
&size);
/* well, this wasn't expected but don't bother failing */
return TRUE;
}
t_push();
/* copy & update the part data */
hdr_size)) {
t_pop();
return FALSE;
}
t_pop();
return TRUE;
}
{
unsigned char current_digest[16];
int hdr_size_fixed;
/* skip the From-line */
do {
return FALSE;
if (body_size == 0 && !hdr_size_fixed) {
/* possibly broken message, find the next From-line
and make sure header parser won't pass it. */
hdr_size = 0;
}
if (hdr_size == 0) {
/* get the MD5 sum of fixed headers and the current
message flags in Status and X-Status fields */
mbox_header_func, &ctx);
}
/* valid message */
/* update flags, unless we've changed them */
return FALSE;
/* update_flags() sets dirty flag, remove it */
} else {
}
/* update location */
return FALSE;
if (offset != header_offset) {
sizeof(uoff_t));
}
/* update size */
return FALSE;
}
return FALSE;
break;
}
/* try next message */
return TRUE;
}
{
const unsigned char *data;
unsigned int seq;
int dirty;
/* first make sure we start with a "From " line. If file is too
small, we'll just treat it as empty mbox file. */
return FALSE;
}
/* we'll go through the mailbox and index in order matching the
messages by their size and Message-ID. old mails aren't remembered,
so we handle well only the cases when mail has been deleted. if
mails have been reordered (eg. sorted by someone) most of the mails
will show up as being new. if we really wanted to support that well,
we could save the message-ids into hash but I don't know if it's
worth the trouble. */
seq = 1;
/* we're at the [\r]\n before the From-line,
skip it */
if (!mbox_skip_crlf(input)) {
/* they just went and broke it, even while
we had it locked. */
"Error syncing mbox file %s: "
"LF not found where expected",
return FALSE;
}
}
break;
return FALSE;
/* Get back to line before From */
break;
}
seq++;
}
/* delete the rest of the records */
}
/* no flags were dirty anymore, no need to rewrite */
}
return TRUE;
else
}
{
int failed;
return FALSE;
return !failed;
}