dovecot-2.2: lib: Added [io]_stream_create_error_str()
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 22 04:42:06 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/a919c43ab91b
changeset: 16813:a919c43ab91b
user: Timo Sirainen <tss at iki.fi>
date: Sun Sep 22 04:39:35 2013 +0300
description:
lib: Added [io]_stream_create_error_str()
diffstat:
src/lib/iostream-private.h | 2 ++
src/lib/iostream.c | 8 +++++++-
src/lib/istream.c | 13 +++++++++++++
src/lib/istream.h | 3 +++
src/lib/ostream.c | 14 ++++++++++++++
src/lib/ostream.h | 3 +++
6 files changed, 42 insertions(+), 1 deletions(-)
diffs (99 lines):
diff -r 52d77a3d38b5 -r a919c43ab91b src/lib/iostream-private.h
--- a/src/lib/iostream-private.h Sun Sep 22 04:24:29 2013 +0300
+++ b/src/lib/iostream-private.h Sun Sep 22 04:39:35 2013 +0300
@@ -33,5 +33,7 @@
Setting this error replaces the previously set error. */
void io_stream_set_error(struct iostream_private *stream,
const char *fmt, ...) ATTR_FORMAT(2, 3);
+void io_stream_set_verror(struct iostream_private *stream,
+ const char *fmt, va_list args) ATTR_FORMAT(2, 0);
#endif
diff -r 52d77a3d38b5 -r a919c43ab91b src/lib/iostream.c
--- a/src/lib/iostream.c Sun Sep 22 04:24:29 2013 +0300
+++ b/src/lib/iostream.c Sun Sep 22 04:39:35 2013 +0300
@@ -68,7 +68,13 @@
va_list args;
va_start(args, fmt);
+ io_stream_set_verror(stream, fmt, args);
+ va_end(args);
+}
+
+void io_stream_set_verror(struct iostream_private *stream,
+ const char *fmt, va_list args)
+{
i_free(stream->error);
stream->error = i_strdup_vprintf(fmt, args);
- va_end(args);
}
diff -r 52d77a3d38b5 -r a919c43ab91b src/lib/istream.c
--- a/src/lib/istream.c Sun Sep 22 04:24:29 2013 +0300
+++ b/src/lib/istream.c Sun Sep 22 04:39:35 2013 +0300
@@ -766,3 +766,16 @@
i_stream_set_name(&stream->istream, "(error)");
return &stream->istream;
}
+
+struct istream *
+i_stream_create_error_str(int stream_errno, const char *fmt, ...)
+{
+ struct istream *input;
+ va_list args;
+
+ va_start(args, fmt);
+ input = i_stream_create_error(stream_errno);
+ io_stream_set_verror(&input->real_stream->iostream, fmt, args);
+ va_end(args);
+ return input;
+}
diff -r 52d77a3d38b5 -r a919c43ab91b src/lib/istream.h
--- a/src/lib/istream.h Sun Sep 22 04:24:29 2013 +0300
+++ b/src/lib/istream.h Sun Sep 22 04:39:35 2013 +0300
@@ -35,6 +35,9 @@
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);
+struct istream *
+i_stream_create_error_str(int stream_errno, const char *fmt, ...)
+ ATTR_FORMAT(2, 3);
/* Set name (e.g. path) for input stream. */
void i_stream_set_name(struct istream *stream, const char *name);
diff -r 52d77a3d38b5 -r a919c43ab91b src/lib/ostream.c
--- a/src/lib/ostream.c Sun Sep 22 04:24:29 2013 +0300
+++ b/src/lib/ostream.c Sun Sep 22 04:39:35 2013 +0300
@@ -560,6 +560,20 @@
stream->ostream.last_failed_errno = stream_errno;
output = o_stream_create(stream, NULL, -1);
+ o_stream_set_no_error_handling(output, TRUE);
o_stream_set_name(output, "(error)");
return output;
}
+
+struct ostream *
+o_stream_create_error_str(int stream_errno, const char *fmt, ...)
+{
+ struct ostream *output;
+ va_list args;
+
+ va_start(args, fmt);
+ output = o_stream_create_error(stream_errno);
+ io_stream_set_verror(&output->real_stream->iostream, fmt, args);
+ va_end(args);
+ return output;
+}
diff -r 52d77a3d38b5 -r a919c43ab91b src/lib/ostream.h
--- a/src/lib/ostream.h Sun Sep 22 04:24:29 2013 +0300
+++ b/src/lib/ostream.h Sun Sep 22 04:39:35 2013 +0300
@@ -38,6 +38,9 @@
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);
+struct ostream *
+o_stream_create_error_str(int stream_errno, const char *fmt, ...)
+ ATTR_FORMAT(2, 3);
/* 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