istream-raw-mbox.c revision 9e59a1f3f095b3099478562cf3f3970a24736970
/* 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 eom:1;
unsigned int eof:1;
};
{
}
{
}
{
}
void (*timeout_cb)(void *), void *context)
{
}
{
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 */
/* EOF - shouldn't happen */
return -1;
}
}
if (rstream->from_offset != 0) {
buf++;
pos--;
}
/* 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;
}
{
/* "headers\n\nFrom ..", the second \n belongs to next
message which we didn't know at the time yet. */
}
}
{
static const char *mbox_from = "\nFrom ";
const unsigned char *buf;
const char *fromp;
/* missing \n from headers */
}
return -1;
}
do {
if (ret < 0) {
if (ret == -2)
return -2;
/* we've read the whole file, final byte should be
the \n trailer */
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. */
for (i = 0; i < pos; i++) {
eoh_char = '\0';
}
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_start_pos = i;
} else if (from_start_pos != 0) {
/* we have the whole From-line here now.
See if it's a valid one. */
&sender) == 0) {
/* yep, we stop here. */
/* rewind "\nFrom " */
from_start_pos -= 6;
break;
}
from_start_pos = 0;
}
} else {
fromp++;
}
}
/* we want to go at least one byte further next time */
if (from_start_pos != 0) {
/* we're waiting for the \n at the end of From-line */
} else {
/* leave out the beginnings of potential From-line */
}
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;
}
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 =
rstream->input_peak_offset = 0;
}
{
struct raw_mbox_istream *rstream =
int check;
rstream->input_peak_offset = 0;
return 0;
}
/* back to beginning of current message */
} else {
}
if (check)
}
{
struct raw_mbox_istream *rstream =
/* kludgy */
}
{
struct raw_mbox_istream *rstream =
}