bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenstatic int o_stream_buffer_seek(struct ostream_private *stream, uoff_t offset)
9929820d587fb6aa527a6baf89267b06950921c2Timo Sirainen struct buffer_ostream *bstream = (struct buffer_ostream *)stream;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Siraineno_stream_buffer_write_at(struct ostream_private *stream,
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen struct buffer_ostream *bstream = (struct buffer_ostream *)stream;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen buffer_write(bstream->buf, offset, data, size);
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Siraineno_stream_buffer_sendv(struct ostream_private *stream,
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen const struct const_iovec *iov, unsigned int iov_count)
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen struct buffer_ostream *bstream = (struct buffer_ostream *)stream;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen unsigned int i;
9929820d587fb6aa527a6baf89267b06950921c2Timo Sirainen offset = bstream->seeked ? stream->ostream.offset : bstream->buf->used;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen for (i = 0; i < iov_count; i++) {
9929820d587fb6aa527a6baf89267b06950921c2Timo Sirainen buffer_write(bstream->buf, offset, iov[i].iov_base, n);
176fd2cdb19937915c728b93fb1a73c8ae91a720Stephan Boscho_stream_buffer_get_used_size(const struct ostream_private *stream)
176fd2cdb19937915c728b93fb1a73c8ae91a720Stephan Bosch struct buffer_ostream *bstream = (struct buffer_ostream *)stream;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainenstruct ostream *o_stream_create_buffer(buffer_t *buf)
a067446575cf5ce63f4a64fa0eb4aac16e591e89Timo Sirainen /* we don't set buffer as blocking, because if max_buffer_size is
a067446575cf5ce63f4a64fa0eb4aac16e591e89Timo Sirainen changed it can get truncated. this is used in various places in
a067446575cf5ce63f4a64fa0eb4aac16e591e89Timo Sirainen unit tests. */
8f32e59200da904613506f5649ffa4d9f5989cebTimo Sirainen bstream->ostream.max_buffer_size = (size_t)-1;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen bstream->ostream.sendv = o_stream_buffer_sendv;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen bstream->ostream.write_at = o_stream_buffer_write_at;
176fd2cdb19937915c728b93fb1a73c8ae91a720Stephan Bosch bstream->ostream.get_used_size = o_stream_buffer_get_used_size;