diff options
author | David Robillard <d@drobilla.net> | 2018-07-08 18:46:38 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:04 +0200 |
commit | a018e7a0c9e3146a6266e8de7a9af5069ef69bbd (patch) | |
tree | 27b513fa21c9af44756bf7ff4b1a345abfa3eb24 /serd | |
parent | a8fade27de9691ce329894fcb4e63f52a1ec719c (diff) | |
download | serd-a018e7a0c9e3146a6266e8de7a9af5069ef69bbd.tar.gz serd-a018e7a0c9e3146a6266e8de7a9af5069ef69bbd.tar.bz2 serd-a018e7a0c9e3146a6266e8de7a9af5069ef69bbd.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 50feb039..21b0106c 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -104,6 +104,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 { @@ -414,6 +419,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 @{ |