mbox-open.c revision dec504e26667fb97d47f6145e5f65c0bc1c615ea
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "iobuffer.h"
#include "mbox-index.h"
#include "mail-index-util.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
{
unsigned int size;
char buf[7], *p;
&size);
"Missing location field for record %u",
return NULL;
}
/* location = offset to beginning of headers in message */
"Invalid location field for record %u",
return NULL;
}
if (fd == -1) {
return NULL;
}
if (pos == -1) {
return NULL;
}
/* make sure message size is valid */
(off_t)stop_offset) {
/* and check that we end with either EOF or to
beginning of next message */
if (ret >= 6) {
/* "[\r]\nFrom " expected */
if (buf[0] != '\r')
p = buf;
else {
p = buf+1;
ret--;
}
} else {
p = buf;
if (ret > 0 && *p == '\r') {
p++;
ret--;
}
if (ret > 0 && *p == '\n')
ret--;
if (ret == 0)
}
}
}
if (!failed) {
/* everything ok */
stop_offset - offset);
}
} else {
/* file has been updated, rescan it */
}
return NULL;
}