dovecot-2.2: Added [io]_stream_create_error() for creating strea...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 3 02:29:27 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/f860cdf156cf
changeset: 15174:f860cdf156cf
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Sep 30 19:11:55 2012 +0300
description:
Added [io]_stream_create_error() for creating streams that always fail reads/writes.

diffstat:

 src/lib/istream.c |  15 +++++++++++++++
 src/lib/istream.h |   1 +
 src/lib/ostream.c |  14 ++++++++++++++
 src/lib/ostream.h |   2 ++
 4 files changed, 32 insertions(+), 0 deletions(-)

diffs (66 lines):

diff -r ff66315076ce -r f860cdf156cf src/lib/istream.c
--- a/src/lib/istream.c	Wed Oct 03 00:41:18 2012 +0300
+++ b/src/lib/istream.c	Sun Sep 30 19:11:55 2012 +0300
@@ -685,3 +685,18 @@
 	io_stream_init(&_stream->iostream);
 	return &_stream->istream;
 }
+
+struct istream *i_stream_create_error(int stream_errno)
+{
+	struct istream_private *stream;
+
+	stream = i_new(struct istream_private, 1);
+	stream->istream.closed = TRUE;
+	stream->istream.readable_fd = FALSE;
+	stream->istream.blocking = TRUE;
+	stream->istream.seekable = TRUE;
+	stream->istream.stream_errno = stream_errno;
+	i_stream_create(stream, NULL, -1);
+	i_stream_set_name(&stream->istream, "(error)");
+	return &stream->istream;
+}
diff -r ff66315076ce -r f860cdf156cf src/lib/istream.h
--- a/src/lib/istream.h	Wed Oct 03 00:41:18 2012 +0300
+++ b/src/lib/istream.h	Sun Sep 30 19:11:55 2012 +0300
@@ -34,6 +34,7 @@
 struct istream *i_stream_create_limit(struct istream *input, uoff_t v_size);
 struct istream *i_stream_create_range(struct istream *input,
 				      uoff_t v_offset, uoff_t v_size);
+struct istream *i_stream_create_error(int stream_errno);
 
 /* Set name (e.g. path) for input stream. */
 void i_stream_set_name(struct istream *stream, const char *name);
diff -r ff66315076ce -r f860cdf156cf src/lib/ostream.c
--- a/src/lib/ostream.c	Wed Oct 03 00:41:18 2012 +0300
+++ b/src/lib/ostream.c	Sun Sep 30 19:11:55 2012 +0300
@@ -512,3 +512,17 @@
 	io_stream_init(&_stream->iostream);
 	return &_stream->ostream;
 }
+
+struct ostream *o_stream_create_error(int stream_errno)
+{
+	struct ostream_private *stream;
+	struct ostream *output;
+
+	stream = i_new(struct ostream_private, 1);
+	stream->ostream.closed = TRUE;
+	stream->ostream.stream_errno = stream_errno;
+
+	output = o_stream_create(stream, NULL, -1);
+	o_stream_set_name(output, "(error)");
+	return output;
+}
diff -r ff66315076ce -r f860cdf156cf src/lib/ostream.h
--- a/src/lib/ostream.h	Wed Oct 03 00:41:18 2012 +0300
+++ b/src/lib/ostream.h	Sun Sep 30 19:11:55 2012 +0300
@@ -36,6 +36,8 @@
 o_stream_create_fd_file(int fd, uoff_t offset, bool autoclose_fd);
 /* Create an output stream to a buffer. */
 struct ostream *o_stream_create_buffer(buffer_t *buf);
+/* Create an output streams that always fails the writes. */
+struct ostream *o_stream_create_error(int stream_errno);
 
 /* 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