aboutsummaryrefslogtreecommitdiffstats
path: root/serd/serd.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-07-08 18:46:38 +0200
committerDavid Robillard <d@drobilla.net>2018-11-25 22:12:47 +0100
commit5c6b16d108c0af6a93aba6aa629b5aa83e0116c9 (patch)
tree3e54104a7016e21bb1c07d025ed86cee667b4bc0 /serd/serd.h
parentb82920ddbd6c401a033ed1ff507379fdf7fcbc03 (diff)
downloadserd-5c6b16d108c0af6a93aba6aa629b5aa83e0116c9.tar.gz
serd-5c6b16d108c0af6a93aba6aa629b5aa83e0116c9.tar.bz2
serd-5c6b16d108c0af6a93aba6aa629b5aa83e0116c9.zip
Expose SerdByteSink in public API
Diffstat (limited to 'serd/serd.h')
-rw-r--r--serd/serd.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 93a2454d..5349afc1 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -106,6 +106,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 {
@@ -423,6 +428,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
@{