istream-chain.c revision 1a3254b83ba00315cfc47d3c6e99e837914594cf
/* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "llist.h"
#include "istream-private.h"
#include "istream-chain.h"
struct chain_istream;
struct istream_chain_link {
bool eof;
};
struct istream_chain {
struct chain_istream *stream;
};
struct chain_istream {
struct istream_private istream;
struct istream_chain chain;
};
static void ATTR_NULL(2)
{
struct istream_chain_link *link;
return;
} else {
}
}
}
{
}
{
}
static void
{
}
}
{
}
}
{
struct istream *prev_input;
const unsigned char *data;
/* a) we have more streams, b) we have EOF, c) we need to wait
for more streams */
if (cstream->prev_stream_left > 0) {
/* we've already buffered some of the prev_input. continue
appending the rest to it. */
data += cur_data_pos;
} else {
cstream->prev_stream_left = 0;
}
/* we already verified that the data size is less than the
maximum buffer size */
if (data_size > 0) {
i_unreached();
}
}
{
const unsigned char *data;
return -1;
}
if (cstream->prev_stream_left == 0) {
/* no need to worry about buffers, skip everything */
/* we're still skipping inside buffer */
bytes_skipped = 0;
} else {
/* done with the buffer */
cstream->prev_stream_left = 0;
}
i_assert(bytes_skipped == 0);
return 0;
}
if (data_size > cur_data_pos)
ret = 0;
else {
/* need to read more */
return ret;
if (ret == -1) {
return -1;
}
/* EOF of this stream, go to next stream */
return i_stream_chain_read(stream);
}
/* we read something */
}
if (cstream->prev_stream_left == 0) {
/* we can point directly to the current stream's buffers */
} else if (data_size == cur_data_pos) {
/* nothing new read */
} else {
/* we still have some of the previous stream left. merge the
new data with it. */
return -2;
}
if (new_bytes_count > size)
}
(ret == 0 ? 0 : -1);
return ret;
}
{
struct chain_istream *cstream;
}