mbox-append.c revision 5cb180be2aec8458c0a9d6d2acb5d2cd92bbe7bf
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "iobuffer.h"
#include "hex-binary.h"
#include "md5.h"
#include "mbox-index.h"
#include "mail-index-util.h"
{
return NULL;
return rec;
}
{
unsigned char *msg;
int lastmsg;
/* read until "[\r]\nFrom " is found */
/* See if it's space after "From" */
/* yes, see if we had \r too */
i -= 5;
i--;
break;
}
}
}
if (i < size) {
startpos = i;
break;
}
if (i > 0) {
i -= startpos;
io_buffer_skip(inbuf, i);
}
}
/* end of file, remove the last [\r]\n */
startpos--;
startpos--;
}
}
}
{
int failed;
/* get the From-line */
pos = 0;
break;
}
break;
}
/* a) no \n found, or line too long
b) not a From-line */
"From-line not found where expected",
return FALSE;
}
/* parse the From-line */
if (internal_date <= 0)
/* now, find the ending "[\r]\nFrom " */
/* add message to index */
return FALSE;
/* location = offset to beginning of headers in message */
&abs_start_offset, sizeof(uoff_t));
/* parse the header and cache wanted fields. get the message flags
from Status and X-Status fields. temporarily limit the buffer size
so the message body is parsed properly (FIXME: does this have
side effects?) */
/* save MD5 */
md5_digest, sizeof(md5_digest));
/* failed - delete the record */
} else {
/* save message flags */
}
return !failed;
}
{
/* no new data */
return TRUE;
}
return FALSE;
for (;;) {
/* we're at the [\r]\n before the From-line,
skip it */
if (!mbox_skip_crlf(inbuf)) {
"Error indexing mbox file %s: "
"LF not found where expected",
return FALSE;
}
}
break;
return FALSE;
}
return TRUE;
}