diff options
author | David Robillard <d@drobilla.net> | 2018-07-08 18:46:38 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-04-13 19:15:32 +0200 |
commit | 9aa551a5bada683db9272937ab73ae43882cb978 (patch) | |
tree | e17ee753336b1b715bc3bfedbadc74f121cc32f1 /serd | |
parent | 52a0e3cc05f0e865bd2652f5c956a853fb86dc0c (diff) | |
download | serd-9aa551a5bada683db9272937ab73ae43882cb978.tar.gz serd-9aa551a5bada683db9272937ab73ae43882cb978.tar.bz2 serd-9aa551a5bada683db9272937ab73ae43882cb978.zip |
Expose SerdByteSink in public API
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h index cec5d8f9..dc5efa85 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -105,6 +105,11 @@ typedef struct SerdWriterImpl SerdWriter; typedef struct SerdSinkImpl SerdSink; /** + A sink for bytes that receives string output. +*/ +typedef struct SerdByteSinkImpl SerdByteSink; + +/** Return status code. */ typedef enum { @@ -422,6 +427,43 @@ typedef size_t (*SerdWriteFunc)(const void* buf, void* stream); /** + Create a new byte sink. + + @param write_func Function called with bytes to consume. + @param stream Context parameter passed to `sink`. + @param block_size Number of bytes to write per call. +*/ +SERD_API +SerdByteSink* +serd_byte_sink_new(SerdWriteFunc write_func, void* stream, size_t block_size); + +/** + Write to `sink`. + + Compatible with SerdWriteFunc. +*/ +SERD_API +size_t +serd_byte_sink_write(const void* buf, + size_t size, + size_t nmemb, + SerdByteSink* sink); + +/** + Flush any pending output in `sink` to the underlying write function. +*/ +SERD_API +void +serd_byte_sink_flush(SerdByteSink* sink); + +/** + Free `sink`. +*/ +SERD_API +void +serd_byte_sink_free(SerdByteSink* sink); + +/** @} @name Syntax Utilities @{ |