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.
Showing
2 changed files
with
9 additions
and
0 deletions
... | @@ -69,6 +69,8 @@ struct _mu_stream | ... | @@ -69,6 +69,8 @@ struct _mu_stream |
69 | int event_mask; | 69 | int event_mask; |
70 | void *event_cb_data; | 70 | void *event_cb_data; |
71 | 71 | ||
72 | int (*setbuf_hook) (mu_stream_t, enum mu_buffer_type, size_t); | ||
73 | |||
72 | const char *(*error_string) (struct _mu_stream *, int); | 74 | const char *(*error_string) (struct _mu_stream *, int); |
73 | 75 | ||
74 | }; | 76 | }; | ... | ... |
... | @@ -554,6 +554,13 @@ mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type, | ... | @@ -554,6 +554,13 @@ mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type, |
554 | if (size == 0) | 554 | if (size == 0) |
555 | size = mu_stream_default_buffer_size; | 555 | size = mu_stream_default_buffer_size; |
556 | 556 | ||
557 | if (stream->setbuf_hook) | ||
558 | { | ||
559 | int rc = stream->setbuf_hook (stream, type, size); | ||
560 | if (rc) | ||
561 | return rc; | ||
562 | } | ||
563 | |||
557 | if (stream->buffer) | 564 | if (stream->buffer) |
558 | { | 565 | { |
559 | mu_stream_flush (stream); | 566 | mu_stream_flush (stream); | ... | ... |
-
Please register or sign in to post a comment