istream-concat.c revision a8c5a86d183db25a57bf193c06b41e092ec2e151
/* Copyright (c) 2007-2014 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "istream-private.h"
#include "istream-concat.h"
struct concat_istream {
struct istream_private istream;
unsigned int cur_idx, unknown_size_idx;
};
bool close_parent)
{
unsigned int i;
if (close_parent) {
}
}
{
unsigned int i;
}
static void
{
unsigned int i;
}
{
const unsigned char *data;
return;
}
/* we already verified that the data size is less than the
maximum buffer size */
if (data_size > 0) {
i_unreached();
}
}
{
const unsigned char *data;
bool last_stream;
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;
}
if (data_size > cur_data_pos)
ret = 0;
else {
/* need to read more */
return ret;
"read(%s) failed: %s",
return -1;
}
/* we either read something or we're at EOF */
return -2;
return i_stream_concat_read(stream);
}
}
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;
}
static unsigned int
{
unsigned int i;
if (*v_offset == 0) {
/* seek to beginning of this stream */
break;
}
if (i == cstream->unknown_size_idx) {
/* we'll need to figure out this stream's size */
"stat(%s) failed: %s",
i_error("istream-concat: stat(%s) failed: %s",
return UINT_MAX;
}
/* @UNSAFE */
}
break;
}
return i;
}
{
cstream->prev_stream_left = 0;
/* failed */
return;
}
}
static int
{
unsigned int i;
/* make sure we have all sizes */
return -1;
for (i = 0; i < cstream->unknown_size_idx; i++)
return 0;
}
{
struct concat_istream *cstream;
unsigned int count;
/* if any of the streams isn't blocking or seekable, set ourself also
if (cur_max > max_buffer_size)
}
}