]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add o_stream_get_flush_callback()
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 8 Feb 2024 10:31:18 +0000 (12:31 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 9 Feb 2024 13:51:38 +0000 (15:51 +0200)
Allows getting the current flush callback.

src/lib/ostream.c
src/lib/ostream.h

index 2f9c49dd9d87f5995a0b7f6da5369f1e6587b860..19ac1846ce9212876ef38df50b3e87e7c4cd5cb8 100644 (file)
@@ -148,6 +148,14 @@ void o_stream_unset_flush_callback(struct ostream *stream)
        _stream->set_flush_callback(_stream, NULL, NULL);
 }
 
+stream_flush_callback_t *
+o_stream_get_flush_callback(struct ostream *stream, void **context_r)
+{
+       struct ostream_private *_stream = stream->real_stream;
+       *context_r = _stream->context;
+       return _stream->callback;
+}
+
 void o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size)
 {
        io_stream_set_max_buffer_size(&stream->real_stream->iostream, max_size);
index 6d756b1da9bc1447b00bd2c07c588923bbd5158e..abce2c186eb8514f1a2b06a5fb42761a47e1f6c9 100644 (file)
@@ -143,6 +143,10 @@ void o_stream_set_flush_callback(struct ostream *stream,
                CALLBACK_TYPECHECK(callback, int (*)(typeof(context))), \
                (stream_flush_callback_t *)callback, context)
 void o_stream_unset_flush_callback(struct ostream *stream);
+/* Get the current flush callback, returns NULL if none set. */
+stream_flush_callback_t *
+o_stream_get_flush_callback(struct ostream *stream, void **context_r);
+
 /* Change the maximum size for stream's output buffer to grow. */
 void o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size);
 /* Returns the current max. buffer size. */