Improve stream statistics interface. Introduce "null stream".
* include/mailutils/stream.h (MU_IOCTL_NULLSTREAM_SET_PATTERN) (MU_IOCTL_NULLSTREAM_SET_PATCLASS) (MU_IOCTL_NULLSTREAM_SETSIZE) (MU_IOCTL_NULLSTREAM_CLRSIZE): New ioctl opcodes. (mu_nullstream_pattern): New struct. (MU_STREAM_STAT_IN,MU_STREAM_STAT_OUT) (MU_STREAM_STAT_READS,MU_STREAM_STAT_WRITES) (MU_STREAM_STAT_SEEKS,_MU_STREAM_STAT_MAX): New defines. (MU_STREAM_STAT_MASK): New macro. (MU_STREAM_STAT_MASK_ALL): New define. (mu_stream_stat_buffer): New typedef. (mu_stream_set_stat, mu_stream_get_stat) (mu_nullstream_create): New protos. (mu_stream_bytes_in, mu_stream_bytes_out): Remove protos. * include/mailutils/sys/nullstream.h: New file. * include/mailutils/sys/stream.h (_mu_stream) <bytes_in>, <bytes_out>: Remove. <statmask,statbuf>: New members. * include/mailutils/sys/Makefile.am (sysinclude_HEADERS): Add nullstream.h. * libmailutils/stream/nullstream.c: New file. * libmailutils/stream/stream.c (_stream_read, _stream_write) (_stream_seek, _stream_stat_incr): New macros. (_stream_fill_buffer, mu_stream_seek) (_stream_read_unbuffered) (_stream_write_unbuffered): Use _stream_read, _stream_write and _stream_seek instead of calling the corresponding methods directly. (mu_stream_bytes_in, mu_stream_bytes_out): Remove. (mu_stream_unref): Clear statbuf, if provided. (mu_stream_set_stat, mu_stream_get_stat): New functions. * libmailutils/stream/Makefile.am (libstream_la_SOURCES): Add nullstream.c. * libmailutils/stream/fltstream.c (filter_wr_close): Check for fs->eof. * examples/base64.c (c_copy): Use new statistics interface. * libmailutils/tests/fltst.c: Likewise.
Showing
10 changed files
with
406 additions
and
35 deletions
include/mailutils/sys/nullstream.h
0 → 100644
libmailutils/stream/nullstream.c
0 → 100644
-
Please register or sign in to post a comment