mbox-sync-full.c revision 29c8f5c5f7d659cc96f3c45aaf80b113f4ac2315
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "ibuffer.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_buffer_skip(inbuf, i);
}
}
unsigned char current_digest[16])
{
const unsigned char *old_digest;
/* MD5 sums must match */
}
{
const void *part_data;
void *part_data_copy;
/* update index record */
return TRUE;
/* update FIELD_TYPE_MESSAGEPART */
&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];
/* skip the From-line */
/* possibly broken message, find the next From-line and make
sure header parser won't pass it. */
}
/* get the MD5 sum of fixed headers and the current message flags
in Status and X-Status fields */
do {
/* 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;
return FALSE;
/* 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(inbuf)) {
/* they just went and broke it, even while
we had it locked. */
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
}
{
return FALSE;
if (unlock)
(void)mbox_unlock(index);
return !failed;
}