]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add i_stream_set_error()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 4 Jan 2022 16:39:09 +0000 (18:39 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 8 Feb 2022 09:48:24 +0000 (10:48 +0100)
src/lib/istream.c
src/lib/istream.h

index 5fc511247cd6b03060827c934d5d86266241e667..58e23048f582045f7f79bd375e6e2f63f0ecf853 100644 (file)
@@ -106,6 +106,17 @@ void i_stream_copy_fd(struct istream *dest, struct istream *source)
        dest->readable_fd = source->readable_fd;
 }
 
+void i_stream_set_error(struct istream *stream, int stream_errno,
+                       const char *fmt, ...)
+{
+       va_list args;
+
+       va_start(args, fmt);
+       stream->stream_errno = stream_errno;
+       io_stream_set_verror(&stream->real_stream->iostream, fmt, args);
+       va_end(args);
+}
+
 const char *i_stream_get_error(struct istream *stream)
 {
        struct istream *s;
index 671d3ffdbd79568400b5a2042eb1ce5eb8576f16..94c98b32e8d83ae70b18e337a3322b445a2b4522 100644 (file)
@@ -101,6 +101,9 @@ int i_stream_get_fd(struct istream *stream);
    The readable_fd is preserved. Assert-crashes if source doesn't have a
    file descriptor. */
 void i_stream_copy_fd(struct istream *dest, struct istream *source);
+/* Set error for istream. */
+void i_stream_set_error(struct istream *stream, int stream_errno,
+                       const char *fmt, ...) ATTR_FORMAT(3, 4);
 /* Returns error string for the last error. It also returns "EOF" in case there
    is no error, but eof is set. Otherwise it returns "<no error>". */
 const char *i_stream_get_error(struct istream *stream);