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
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);
}
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;
+}
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);
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;
+}
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);