summaryrefslogtreecommitdiff
path: root/include/mailutils/stream.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-08-09 00:39:48 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-08-09 00:45:42 +0300
commit93970a7554512add3e9192a8eeabd0abbedcc5c0 (patch)
treeacd4ab01a038dd293d86512a3ab8b4c316ae8acd /include/mailutils/stream.h
parentfd9a86d37b96789d59e25e64b5d9db8974158a2c (diff)
downloadmailutils-93970a7554512add3e9192a8eeabd0abbedcc5c0.tar.gz
mailutils-93970a7554512add3e9192a8eeabd0abbedcc5c0.tar.bz2
Implement temporary streams.
A temporary stream functions as a memory stream until its size reaches a preconfigured threshold value. Once it is reached, the stream storage is automatically converted to a temporary file, and all data written so far are transferred to the new storage. If the temporary file cannot be created, the stream continues to operate in memory-based mode. This stream type is intended to decrease the number of used file descriptors. * include/mailutils/sys/Makefile.am: Add temp_stream.h * include/mailutils/sys/temp_stream.h: New file. * include/mailutils/stream.h (mu_temp_file_threshold_size): New extern. (mu_temp_stream_create): New proto. * libmailutils/stream/Makefile.am: Add temp_stream.c. * libmailutils/stream/temp_stream.c: New file. * libmailutils/string/Makefile.am: Add strtosize.c * libmailutils/tests/.gitignore: Update. * libmailutils/tests/Makefile.am * libmailutils/tests/strtoc.c: Add tests for mu_c_hsize. * libmailutils/tests/temp_stream.c: New test program. * libmailutils/tests/testsuite.at: Test the temp_stream functionality. * testsuite/testsuite.inc (MU_CHECK): New macro. * libmailutils/mailbox/body.c (body_get_transport): Use mu_temp_stream_create.
Diffstat (limited to 'include/mailutils/stream.h')
-rw-r--r--include/mailutils/stream.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index a91f168de..dc3bb12ad 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -474,7 +474,10 @@ int mu_nullstream_create (mu_stream_t *pref, int flags);
int mu_wordwrap_stream_create (mu_stream_t *pstream, mu_stream_t transport,
size_t left_margin, size_t right_margin);
-
+
+extern size_t mu_temp_file_threshold_size;
+int mu_temp_stream_create (mu_stream_t *pstream, size_t threshold);
+
#ifdef __cplusplus
}
#endif

Return to:

Send suggestions and report system problems to the System administrator.