istream-metawrap.c revision 2974dca6be5120e49279f06c8aa952e5fac56048
/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-private.h"
#include "istream-metawrap.h"
#define METAWRAP_MAX_METADATA_LINE_LEN 8192
struct metawrap_istream {
struct istream_private istream;
void *context;
bool in_metadata;
};
{
char *line, *p;
if (*line == '\0') {
return 1;
}
if (p == NULL) {
"Metadata header line is missing ':' at offset %"PRIuUOFF_T,
return -1;
}
*p++ = '\0';
}
} else {
"Metadata header is missing ending line at offset %"PRIuUOFF_T,
return -1;
}
return -1;
}
return 0;
}
{
int ret;
if (mstream->in_metadata) {
if (ret <= 0)
return ret;
/* this stream is kind of silently skipping over the metadata */
if (mstream->pending_seek != 0) {
}
}
/* after metadata header it's all just passthrough */
}
static void
{
if (!mstream->in_metadata) {
/* already read through metadata. we can skip directly. */
mstream->pending_seek = 0;
} else {
/* we need to read through the metadata first */
}
}
{
int ret;
return -1;
}
if (mstream->in_metadata) {
return -1;
if (ret == 0) {
return 0;
}
}
return 0;
}
struct istream *
{
struct metawrap_istream *mstream;
i_stream_get_fd(input), 0);
}