diff options
author | David Robillard <d@drobilla.net> | 2020-06-28 19:46:47 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:59 +0100 |
commit | ba2dc6b53c8dd840651fc9e2c10790989b9cee9f (patch) | |
tree | a824e5de81d054097cd8b2021d3d3f7340f096d4 /src/writer.c | |
parent | 834ca36d4cbbfd63789f7894ab2d5d370347d76f (diff) | |
download | serd-ba2dc6b53c8dd840651fc9e2c10790989b9cee9f.tar.gz serd-ba2dc6b53c8dd840651fc9e2c10790989b9cee9f.tar.bz2 serd-ba2dc6b53c8dd840651fc9e2c10790989b9cee9f.zip |
WIP: Make Writer always write to a ByteSink
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/writer.c b/src/writer.c index 697d0e7c..ed3be4e7 100644 --- a/src/writer.c +++ b/src/writer.c @@ -14,6 +14,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "byte_sink.h" #include "env.h" #include "node.h" #include "sink.h" @@ -131,8 +132,7 @@ struct SerdWriterImpl { SerdURI root_uri; WriteContext* anon_stack; size_t anon_stack_size; - SerdWriteFunc write_func; - void* stream; + SerdByteSink* byte_sink; SerdLogFunc log_func; void* log_handle; WriteContext context; @@ -236,7 +236,7 @@ ctx(SerdWriter* writer, const SerdField field) SERD_WARN_UNUSED_RESULT static inline size_t sink(const void* buf, size_t len, SerdWriter* writer) { - const size_t written = writer->write_func(buf, 1, len, writer->stream); + const size_t written = serd_byte_sink_write(buf, len, writer->byte_sink); if (written != len) { if (errno) { SERD_LOG_ERRORF(writer->world, SERD_ERR_BAD_WRITE, @@ -1077,22 +1077,22 @@ serd_writer_new(SerdWorld* world, SerdSyntax syntax, SerdWriterFlags flags, SerdEnv* env, - SerdWriteFunc write_func, - void* stream) + SerdByteSink* byte_sink) { const WriteContext context = WRITE_CONTEXT_NULL; SerdWriter* writer = (SerdWriter*)calloc(1, sizeof(SerdWriter)); - writer->world = world; - writer->syntax = syntax; - writer->flags = flags; - writer->env = env; - writer->root_node = NULL; - writer->root_uri = SERD_URI_NULL; - writer->anon_stack = (WriteContext*)calloc(anon_stack_capacity, sizeof(WriteContext)); - writer->write_func = write_func; - writer->stream = stream; - writer->context = context; - writer->empty = true; + + writer->world = world; + writer->syntax = syntax; + writer->flags = flags; + writer->env = env; + writer->root_node = NULL; + writer->root_uri = SERD_URI_NULL; + writer->anon_stack = + (WriteContext*)calloc(anon_stack_capacity, sizeof(WriteContext)); + writer->byte_sink = byte_sink; + writer->context = context; + writer->empty = true; writer->iface.handle = writer; writer->iface.on_event = (SerdEventFunc)serd_writer_on_event; |