mbox-index.c revision 62505210a7e6d1b2e35fac335a6c875a7c98ccfb
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "iobuffer.h"
#include "rfc822-tokenize.h"
#include "mbox-index.h"
#include "mail-index-util.h"
#include "mail-index-data.h"
#include "mail-custom-flags.h"
#include <fcntl.h>
#include <unistd.h>
extern MailIndex mbox_index;
{
return FALSE;
}
{
if (reopen)
return NULL;
}
}
}
{
}
}
{
}
{
}
{
size_t i;
flags = 0;
for (i = 0; i < len; i++) {
switch (value[i]) {
case 'A':
flags |= MAIL_ANSWERED;
break;
case 'F':
flags |= MAIL_FLAGGED;
break;
case 'D':
flags |= MAIL_DRAFT;
break;
case 'R':
break;
case 'T':
flags |= MAIL_DELETED;
break;
}
}
return flags;
}
{
if (index >= 0)
}
static MailFlags
const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT])
{
flags = 0;
return flags;
}
{
const char **custom_flags, **old_flags;
/* skip <uid validity> and <last uid> fields */
spaces = 0;
if (++spaces == 2)
break;
}
}
return TRUE;
t_push();
/* we're at the 3rd field now, which begins the list of custom flags */
/* need more memory */
max *= 2;
sizeof(const char *) * idx);
}
custom_flags[idx++] =
}
break;
}
}
custom_flags, idx);
ctx->custom_flags =
t_pop();
return ret > 0;
}
void *context)
{
size_t i;
/* Pretty much copy&pasted from popa3d by Solar Designer */
switch (*name) {
case '\0':
/* End of headers */
if (!ctx->set_read_limit)
break;
/* a) use Content-Length, b) search for "From "-line */
if (ctx->content_length == 0 ||
}
break;
case 'R':
case 'r':
}
break;
case 'C':
case 'c':
/* manual parsing, so we can deal with uoff_t */
ctx->content_length = 0;
for (i = 0; i < value_len; i++) {
/* invalid */
ctx->content_length = 0;
break;
}
(value[i] - '0');
}
}
break;
case 'D':
case 'd':
if (name_len == 12)
else if (name_len == 4) {
/* Received-header contains date too,
and more trusted one */
}
break;
case 'M':
case 'm':
if (name_len == 10) {
/* Received-header contains unique ID too,
and more trusted one */
}
break;
case 'S':
case 's':
/* update message flags */
}
break;
case 'X':
case 'x':
if (name_len == 13) {
/* Let the local delivery agent help generate unique
ID's but don't blindly trust this header alone as
it could just as easily come from the remote. */
} else if (name_len == 8 &&
/* update message flags */
} else if (name_len == 10 &&
/* update custom message flags */
ctx->custom_flags);
} else if (name_len == 10 &&
/* update list of custom message flags */
}
break;
}
if (fixed)
}
const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT],
void *context)
{
int i;
for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) {
strlen(custom_flags[i]) : 0;
}
for (;;) {
/* skip whitespace */
value++;
len--;
}
if (len == 0)
break;
/* find the length of the item */
break;
}
/* check if it's found */
for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) {
if (custom_len[i] == item_len &&
break;
}
if (i == MAIL_CUSTOM_FLAGS_COUNT)
i = -1;
}
}
{
unsigned char *data;
pos = 0;
if (pos == 0) {
if (data[0] == '\n') {
return TRUE;
}
if (data[0] != '\r')
return FALSE;
pos++;
}
return FALSE;
return TRUE;
}
}
/* end of file */
return TRUE;
}
{
unsigned char *data;
/* skip empty lines at beginning */
}
}
{
unsigned char *msg;
i = startpos;
for (; i < size; i++) {
if (msg[i] == '\n') {
i -= startpos;
return mbox_from_parse_date((char *) msg,
size) != 0;
}
}
}
return FALSE;
}
{
unsigned char *msg;
int lastmsg;
/* read until "[\r]\nFrom " is found */
/* \n[\r]\n - end of header? */
i++;
break;
}
}
/* See if it's space after "From" */
/* check still that the From-line looks
actually valid, in outbox there
might be some lines beginning with
From. */
/* see if we had \r too */
i -= 5;
i--;
break;
}
}
}
}
if (i < size) {
startpos = i;
break;
}
i -= startpos;
io_buffer_skip(inbuf, i);
}
/* end of file, remove the last [\r]\n */
startpos--;
startpos--;
}
}
}
{
}
{
}
{
unsigned char *data;
/* don't bother parsing the whole body, just make
sure it ends properly */
/* end of file. a bit unexpected though,
since \n is missing. */
return TRUE;
}
/* read forward a bit */
return FALSE;
/* either there should be the next From-line,
or [\r]\n at end of file */
}
if (size > 0) {
if (data[0] != '\n')
return FALSE;
}
return size == 0 ||
}
{
*offset = 0;
return FALSE;
*offset = 0;
return FALSE;
} else {
return TRUE;
}
}
{
int len;
}
{
}
int external_change)
{
return FALSE;
if (!external_change) {
}
return TRUE;
}
MailIndex mbox_index = {
};