diff options
Diffstat (limited to 'libmailutils/stream/fltstream.c')
-rw-r--r-- | libmailutils/stream/fltstream.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libmailutils/stream/fltstream.c b/libmailutils/stream/fltstream.c index b9c77a43a..ae16b7fb3 100644 --- a/libmailutils/stream/fltstream.c +++ b/libmailutils/stream/fltstream.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2009-2019 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -529,6 +529,15 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr) break; case MU_IOCTL_OP_SET: + if (pstr[1] != NULL) + { + mu_stream_t iostr; + status = mu_iostream_create (&iostr, pstr[0], pstr[1]); + if (status) + return status; + pstr[0] = iostr; + } + mu_stream_unref (fs->transport); fs->transport = pstr[0]; mu_stream_ref (fs->transport); @@ -648,6 +657,17 @@ filter_wait (struct _mu_stream *stream, int *pflags, struct timeval *tvp) return mu_stream_wait (fs->transport, pflags, tvp); } +static void +filter_event (struct _mu_stream *str, int code, + unsigned long lval, void *pval) +{ + struct _mu_filter_stream *fs = (struct _mu_filter_stream *)str; + if (code == _MU_STR_EVENT_CLRFLAG && lval == _MU_STR_ERR) + { + mu_stream_clearerr (fs->transport); + } +} + int mu_filter_stream_create (mu_stream_t *pflt, @@ -705,6 +725,8 @@ mu_filter_stream_create (mu_stream_t *pflt, fs->stream.ctl = filter_ctl; fs->stream.wait = filter_wait; fs->stream.error_string = filter_error_string; + fs->stream.event_cb = filter_event; + fs->stream.event_mask = _MU_STR_EVMASK (_MU_STR_EVENT_CLRFLAG); fs->stream.flags = flags; mu_stream_ref (str); @@ -719,6 +741,7 @@ mu_filter_stream_create (mu_stream_t *pflt, rc = filter_stream_init (fs); if (rc) { + mu_stream_unref (str); free (fs); return rc; } |