Commit 8bff160c 8bff160caebe10ffc0e0c36e88f4cd30f3fd2bf5 by Sergey Poznyakoff

streams: introduce setbuf hooks.

* include/mailutils/sys/stream.h (_mu_stream) <setbuf_hook>: New member.
* libmailutils/stream/stream.c (mu_stream_set_buffer): Use setbuf_hook
to decide whether the operation is allowed.
1 parent 89feaf02
......@@ -68,6 +68,8 @@ struct _mu_stream
void (*event_cb) (struct _mu_stream *, int code, unsigned long, void *);
int event_mask;
void *event_cb_data;
int (*setbuf_hook) (mu_stream_t, enum mu_buffer_type, size_t);
const char *(*error_string) (struct _mu_stream *, int);
......
......@@ -554,6 +554,13 @@ mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type,
if (size == 0)
size = mu_stream_default_buffer_size;
if (stream->setbuf_hook)
{
int rc = stream->setbuf_hook (stream, type, size);
if (rc)
return rc;
}
if (stream->buffer)
{
mu_stream_flush (stream);
......