istream-header-filter.c revision fff56e138fc28fd6fa141122ac768162d6f7e4d1
/* Copyright (C) 2003-2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "message-parser.h"
#include "istream-internal.h"
#include "istream-header-filter.h"
#include <stdlib.h>
struct header_filter_istream {
struct message_header_parser_ctx *hdr_ctx;
const char **headers;
unsigned int headers_count;
void *context;
struct message_size header_size;
unsigned int cur_line, parsed_lines;
unsigned int header_read:1;
unsigned int header_parsed:1;
unsigned int exclude:1;
unsigned int crlf:1;
unsigned int hide_body:1;
};
{
}
{
struct header_filter_istream *mstream =
(struct header_filter_istream *)stream;
}
{
struct header_filter_istream *mstream =
(struct header_filter_istream *)stream;
}
{
struct message_header_line *hdr;
bool matched;
int hdr_ret;
if (mstream->header_read &&
/* we don't support mixing headers and body.
it shouldn't be needed. */
return -2;
}
}
&hdr)) > 0) {
if (!mstream->header_parsed &&
}
if (!matched)
continue;
else
continue;
}
bsearch_strcasecmp) != NULL;
}
/* ignore */
} else {
}
if (!hdr->no_newline) {
"\r\n", 2);
} else
}
/* we need more */
} else {
if (mstream->skip_count > 0) {
mstream->skip_count = 0;
}
break;
}
}
}
/* don't copy eof here because we're only returning headers here.
the body will be returned in separate read() call. */
if (hdr_ret == 0)
return ret;
/* finished */
}
if (ret == 0) {
return -2;
}
return ret;
}
{
struct header_filter_istream *mstream =
(struct header_filter_istream *)stream;
if (!mstream->header_read ||
return ret;
}
return -1;
}
return -2;
}
} else {
ret = 0;
}
(ret == 0 ? 0 : -1);
return ret;
}
{
while (!mstream->header_read) {
break;
}
}
bool mark __attr_unused__)
{
struct header_filter_istream *mstream =
(struct header_filter_istream *)stream;
}
/* seek into headers. we'll have to re-parse them, use
skip_count to set the wanted position */
} else {
/* body */
}
}
{
i_panic("istream-header-filter sync() not implemented");
}
static const struct stat *
{
struct header_filter_istream *mstream =
(struct header_filter_istream *)stream;
return st;
}
struct istream *
enum header_filter_flags flags,
const char *const *headers,
unsigned int headers_count,
{
struct header_filter_istream *mstream;
unsigned int i;
for (i = 0; i < headers_count; i++)
}