istream-concat.c revision 7026c16186f543e11af12b8b87f396006db93297
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2007 Dovecot authors, see the included COPYING file */
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainenstatic void i_stream_concat_close(struct iostream_private *stream)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen struct concat_istream *cstream = (struct concat_istream *)stream;
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen unsigned int i;
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainenstatic void i_stream_concat_destroy(struct iostream_private *stream)
9b7eeffb5752b500ac62ba1fd01c4a8c4ada14e9Timo Sirainen struct concat_istream *cstream = (struct concat_istream *)stream;
9b7eeffb5752b500ac62ba1fd01c4a8c4ada14e9Timo Sirainen unsigned int i;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Siraineni_stream_concat_set_max_buffer_size(struct iostream_private *stream,
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen struct concat_istream *cstream = (struct concat_istream *)stream;
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen unsigned int i;
cd56a23e21f1df3f79648cf07e2f4385e2fadebbTimo Sirainen i_stream_set_max_buffer_size(cstream->input[i], max_size);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenstatic void i_stream_concat_read_next(struct concat_istream *cstream)
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen const unsigned char *data;
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen cstream->cur_input = cstream->input[cstream->cur_idx];
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen if (cstream->istream.pos == cstream->istream.skip) {
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen /* we need to keep the current data */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen data = cstream->istream.buffer + cstream->istream.skip;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen data_size = cstream->istream.pos - cstream->istream.skip;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen cstream->istream.skip = cstream->istream.pos = 0;
683eebe490bbe5caec246c535a10ea9f93f5c330Timo Sirainen /* we already verified that the data size is less than the
683eebe490bbe5caec246c535a10ea9f93f5c330Timo Sirainen maximum buffer size */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen if (!i_stream_get_buffer_space(&cstream->istream, data_size, &size))
68a4946b12583b88fa802e52ebee45cd96056772Timo Sirainen memcpy(cstream->istream.w_buffer, data, data_size);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenstatic ssize_t i_stream_concat_read(struct istream_private *stream)
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen struct concat_istream *cstream = (struct concat_istream *)stream;
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen const unsigned char *data;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen /* we don't need the buffer anymore */
ret = 0;
return ret;
return ret;
if (*v_offset == 0) {
static const struct stat *
unsigned int count;