aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-07-08 18:46:38 +0200
committerDavid Robillard <d@drobilla.net>2018-12-31 11:37:48 -0500
commit87a1b30968d422831615ffb2fce33603a3e24e84 (patch)
treeeb01a18356a0b7f6db9f102b84a9c013cf437990 /serd
parentb69236b298c0263f7233562d83df5e6278def5a7 (diff)
downloadserd-87a1b30968d422831615ffb2fce33603a3e24e84.tar.gz
serd-87a1b30968d422831615ffb2fce33603a3e24e84.tar.bz2
serd-87a1b30968d422831615ffb2fce33603a3e24e84.zip
Expose SerdByteSink in public API
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 610eb791..59d49661 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
@{