dovecot-2.2: lib: Added o_stream_create_passthrough() for creati...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jan 17 02:16:11 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/071e46b032c8
changeset: 18165:071e46b032c8
user: Timo Sirainen <tss at iki.fi>
date: Sat Jan 17 04:14:09 2015 +0200
description:
lib: Added o_stream_create_passthrough() for creating simple wrapper ostreams
diffstat:
src/lib/ostream.c | 24 ++++++++++++++++++++++++
src/lib/ostream.h | 3 +++
2 files changed, 27 insertions(+), 0 deletions(-)
diffs (58 lines):
diff -r 4723cecff76c -r 071e46b032c8 src/lib/ostream.c
--- a/src/lib/ostream.c Sat Jan 17 04:13:13 2015 +0200
+++ b/src/lib/ostream.c Sat Jan 17 04:14:09 2015 +0200
@@ -528,6 +528,20 @@
return -1;
}
+static ssize_t
+o_stream_default_sendv(struct ostream_private *stream,
+ const struct const_iovec *iov, unsigned int iov_count)
+{
+ ssize_t ret;
+
+ if ((ret = o_stream_sendv(stream->parent, iov, iov_count)) < 0) {
+ o_stream_copy_error_from_parent(stream);
+ return -1;
+ }
+ stream->ostream.offset += ret;
+ return ret;
+}
+
static int
o_stream_default_write_at(struct ostream_private *_stream,
const void *data ATTR_UNUSED,
@@ -589,6 +603,8 @@
_stream->get_used_size = o_stream_default_get_used_size;
if (_stream->seek == NULL)
_stream->seek = o_stream_default_seek;
+ if (_stream->sendv == NULL)
+ _stream->sendv = o_stream_default_sendv;
if (_stream->write_at == NULL)
_stream->write_at = o_stream_default_write_at;
if (_stream->send_istream == NULL)
@@ -628,3 +644,11 @@
va_end(args);
return output;
}
+
+struct ostream *o_stream_create_passthrough(struct ostream *output)
+{
+ struct ostream_private *stream;
+
+ stream = i_new(struct ostream_private, 1);
+ return o_stream_create(stream, output, o_stream_get_fd(output));
+}
diff -r 4723cecff76c -r 071e46b032c8 src/lib/ostream.h
--- a/src/lib/ostream.h Sat Jan 17 04:13:13 2015 +0200
+++ b/src/lib/ostream.h Sat Jan 17 04:14:09 2015 +0200
@@ -45,6 +45,9 @@
struct ostream *
o_stream_create_error_str(int stream_errno, const char *fmt, ...)
ATTR_FORMAT(2, 3);
+/* Create an output stream that simply passes through data. This is mainly
+ useful as a wrapper when combined with destroy callbacks. */
+struct ostream *o_stream_create_passthrough(struct ostream *output);
/* Set name (e.g. path) for output stream. */
void o_stream_set_name(struct ostream *stream, const char *name);
More information about the dovecot-cvs
mailing list