istream-sized.c revision bcb4e51a409d94ae670de96afb8483a4f7855294
/* Copyright (c) 2003-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-private.h"
#include "istream-sized.h"
struct sized_istream {
struct istream_private istream;
void *error_context;
bool min_size_only;
};
{
/* get to same position in parent stream */
}
}
static const char *
{
return t_strdup_printf("Stream is smaller than expected "
} else {
return t_strdup_printf("Stream is larger than expected "
}
}
static ssize_t
{
do {
break;
return ret;
}
{
struct sized_istream *sstream =
(struct sized_istream *)stream;
struct istream_sized_error_data data;
const char *error;
ret = 0;
else {
return -2;
}
/* we have exactly the wanted amount of data left, but we
don't know yet if there is more data in parent. */
}
/* we may or may not be finished, depending on whether
parent is at EOF. */
/* parent has more data available than expected */
if (!sstream->min_size_only) {
return -1;
}
ret = -1;
}
/* still more to read */
/* lost the file */
} else {
/* EOF before we reached the wanted size */
}
(ret == 0 ? 0 : -1);
return ret;
}
static int
{
/* parent stream may be base64-decoder. don't waste time decoding the
entire stream, since we already know what the size is supposed
to be. */
return -1;
}
return 0;
}
static struct sized_istream *
{
struct sized_istream *sstream;
i_stream_get_fd(input), 0);
return sstream;
}
{
struct sized_istream *sstream;
}
{
return ret;
}
{
return ret;
}
{
return ret;
}
struct istream *
void *context)
{
struct sized_istream *sstream;
}