bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
e2ce8d4a6ac5d82a906178148453e7613fab9ba0Timo Sirainenstatic void o_stream_rawlog_close(struct iostream_private *stream,
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen struct rawlog_ostream *rstream = (struct rawlog_ostream *)stream;
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Siraineno_stream_rawlog_sendv(struct ostream_private *stream,
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen const struct const_iovec *iov, unsigned int iov_count)
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen struct rawlog_ostream *rstream = (struct rawlog_ostream *)stream;
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen unsigned int i;
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen if ((ret = o_stream_sendv(stream->parent, iov, iov_count)) < 0) {
3f7b9d04c1fb9b0a55ea2082214ea66a0ace96c7Timo Sirainen for (i = 0; i < iov_count && bytes > 0; i++) {
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Siraineno_stream_create_rawlog(struct ostream *output, const char *rawlog_path,
f1ed4fa248aaf6841ba638b9d66b2738d9f7aa18Timo Sirainen int rawlog_fd, enum iostream_rawlog_flags flags)
76d4ff1c1b31a1a09f6cbfe613a8d0efe62cbfd2Timo Sirainen bool autoclose_fd = (flags & IOSTREAM_RAWLOG_FLAG_AUTOCLOSE) != 0;
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi o_stream_create_fd_autoclose(&rawlog_fd, 0):
76d4ff1c1b31a1a09f6cbfe613a8d0efe62cbfd2Timo Sirainen return o_stream_create_rawlog_from_stream(output, rawlog_output, flags);
76d4ff1c1b31a1a09f6cbfe613a8d0efe62cbfd2Timo Siraineno_stream_create_rawlog_from_stream(struct ostream *output,
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen rstream->ostream.sendv = o_stream_rawlog_sendv;
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen rstream->ostream.iostream.close = o_stream_rawlog_close;
76d4ff1c1b31a1a09f6cbfe613a8d0efe62cbfd2Timo Sirainen rstream->riostream.rawlog_output = rawlog_output;
f1ed4fa248aaf6841ba638b9d66b2738d9f7aa18Timo Sirainen iostream_rawlog_init(&rstream->riostream, flags, FALSE);