Initialize standard I/O streams statically.
This allows programmers to use them right away, much like their stdio counterparts. The mu_stdstream_setup and friends can be used to re-initialize them, should the need be. * include/mailutils/sys/file_stream.h (_MU_FILE_STREAM_STATIC_FILENAME): New flag. (_mu_file_stream_setup): New proto. * include/mailutils/sys/logstream.h (_mu_log_stream_setup): New proto. * include/mailutils/sys/stream.h (_MU_STR_EVENT_BOOTSTRAP): New event code. (_mu_stream) <destroy>: New method. * libmailutils/stdstream/basestr.c: Define the three standard streams statically, use bootstrap event to initialize them. * libmailutils/stdstream/strerr.c (mu_stdstream_strerr_create): Accept tag==NULL. * libmailutils/stream/file_stream.c (fd_done): Do not free filename if _MU_FILE_STREAM_STATIC_FILENAME is set. (_mu_file_stream_setup): New function. * libmailutils/stream/logstream.c (NEXT): Check size before advancing buffer pointer. (_mu_log_stream_setup): New function. * libmailutils/stream/stream.c (_bootstrap_event): New macro. (mu_stream_destroy): If .destroy is defined, use it instead of free(2). (mu_stream_open,mu_stream_seek,mu_stream_set_buffer) (mu_stream_read,mu_stream_readdelim,mu_stream_getdelim) (mu_stream_write,mu_stream_size,mu_stream_wait) (mu_stream_truncate,mu_stream_shutdown): Call _bootstrap_event at the beginning. * libmailutils/tests/.gitignore: Add strin, strout. * libmailutils/tests/Makefile.am (noinst_PROGRAMS): Add strin, strout. (TESTSUITE_AT): Add stdstream tests. * libmailutils/tests/testsuite.at: Include stdstream tests. * libmailutils/tests/strerr.at: New test case. * libmailutils/tests/strin.at: Likewise. * libmailutils/tests/strout.at: Likewise. * libmailutils/tests/strin.c: New test program. * libmailutils/tests/strout.c: Likewise.
Showing
16 changed files
with
476 additions
and
42 deletions
libmailutils/tests/strerr.at
0 → 100644
libmailutils/tests/strin.at
0 → 100644
libmailutils/tests/strin.c
0 → 100644
libmailutils/tests/strout.at
0 → 100644
libmailutils/tests/strout.c
0 → 100644
-
Please register or sign in to post a comment