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
... | @@ -68,6 +68,8 @@ struct _mu_stream | ... | @@ -68,6 +68,8 @@ struct _mu_stream |
68 | void (*event_cb) (struct _mu_stream *, int code, unsigned long, void *); | 68 | void (*event_cb) (struct _mu_stream *, int code, unsigned long, void *); |
69 | int event_mask; | 69 | int event_mask; |
70 | void *event_cb_data; | 70 | void *event_cb_data; |
71 | |||
72 | int (*setbuf_hook) (mu_stream_t, enum mu_buffer_type, size_t); | ||
71 | 73 | ||
72 | const char *(*error_string) (struct _mu_stream *, int); | 74 | const char *(*error_string) (struct _mu_stream *, int); |
73 | 75 | ... | ... |
... | @@ -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