istream-raw-mbox.c revision 686cb2418d4daa7bc747d3551783c1895e7c41b9
/* Copyright (C) 2003 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "istream-internal.h"
#include "istream-raw-mbox.h"
#include "mbox-from.h"
struct raw_mbox_istream {
char *sender, *next_sender;
unsigned int corrupted:1;
unsigned int eof:1;
};
{
}
{
}
{
}
{
const unsigned char *buf, *p;
char *sender;
int skip;
/* from_offset points to "\nFrom ", so unless we're at the beginning
of the file, skip the initial \n */
skip++;
/* EOF - shouldn't happen */
return -1;
}
}
if (rstream->from_offset != 0) {
}
/* beginning of mbox */
/* broken From - should happen only at beginning of
file if this isn't a mbox.. */
return -1;
}
} else {
}
/* we'll skip over From-line */
return 0;
}
{
/* a) Header didn't have ending \n
b) "headers\n\nFrom ..", the second \n belongs to next
message which we didn't know at the time yet. */
rstream->body_offset ==
}
}
{
static const char *mbox_from = "\nFrom ";
const unsigned char *buf;
const char *fromp;
char *sender;
int eoh_char;
return -1;
ret = 0;
do {
if (pos > 1 &&
break;
} while (ret > 0);
if (ret < 0) {
if (ret == -2) {
return -2;
}
} else {
/* we've read the whole file, final byte should be
the \n trailer */
pos--;
pos--;
}
}
}
/* beginning of message, we haven't yet read our From-line */
if (mbox_read_from_line(rstream) < 0) {
return -1;
}
/* got it. we don't want to return it however,
so start again from headers */
if (pos == 0)
}
/* See if we have From-line here - note that it works right only
because all characters are different in mbox_from. */
eoh_char = -1;
}
if (*++fromp == '\0') {
/* potential From-line, see if we have the
rest of the line buffered.
FIXME: if From-line is longer than input
buffer, we break. probably irrelevant.. */
i++;
from_after_pos = i;
from_start_pos = i - 6;
if (from_start_pos > 0 &&
/* CR also belongs to it. */
}
/* we have the whole From-line here now.
See if it's a valid one. */
&sender) == 0) {
/* yep, we stop here. */
break;
}
}
} else {
fromp++;
}
}
/* we want to go at least one byte further next time */
/* we're waiting for the \n at the end of From-line */
} else {
/* leave out the beginnings of potential From-line + CR */
}
ret = -2;
} else {
}
return ret;
}
{
rstream->input_peak_offset = 0;
}
{
}
{
}
{
struct raw_mbox_istream *rstream;
}
{
const unsigned char *data;
char *sender;
/* minimal: "From x Thu Nov 29 22:33:52 2001" = 31 chars */
return -1;
/* EOF */
return TRUE;
}
data += 6;
size -= 6;
data += 7;
size -= 7;
} else {
return FALSE;
}
break;
}
return FALSE;
return TRUE;
}
{
struct raw_mbox_istream *rstream =
return rstream->from_offset;
}
{
struct raw_mbox_istream *rstream =
return rstream->hdr_offset;
}
{
struct raw_mbox_istream *rstream =
return rstream->body_offset;
break;
}
return rstream->body_offset;
}
{
struct raw_mbox_istream *rstream =
const unsigned char *data;
}
if (istream_raw_mbox_is_valid_from(rstream) > 0) {
return body_size;
}
}
/* have to read through the message body */
}
{
struct raw_mbox_istream *rstream =
return rstream->received_time;
}
{
struct raw_mbox_istream *rstream =
}
{
struct raw_mbox_istream *rstream =
}
{
struct raw_mbox_istream *rstream =
int check;
return 0;
}
/* back to beginning of current message */
} else {
}
if (check)
}
{
struct raw_mbox_istream *rstream =
}