From 4de86fdfb643dbe7113e261998c5e159f940b7d4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 8 May 2012 23:51:51 +0000 Subject: Add incremental read interface suitable for reading from infinite streams. git-svn-id: http://svn.drobilla.net/serd/trunk@350 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- serd/serd.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'serd/serd.h') diff --git a/serd/serd.h b/serd/serd.h index 807664dd..cc2365f4 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -704,6 +704,40 @@ SerdStatus serd_reader_read_file(SerdReader* reader, const uint8_t* uri); +/** + Start an incremental read from a file handle. + + Iff @p bulk is true, @p file will be read a page at a time. This is more + efficient, but uses a page of memory and means that an entire page of input + must be ready before any callbacks will fire. To react as soon as input + arrives, set @p bulk to false. +*/ +SERD_API +SerdStatus +serd_reader_start_stream(SerdReader* me, + FILE* file, + const uint8_t* name, + bool bulk); + +/** + Read a single "chunk" of data during an incremental read. + + This function will read a single top level description, and return. This + may be a directive, statement, or several statements; essentially it reads + until a '.' is encountered. This is particularly useful for reading + directly from a pipe or socket. +*/ +SERD_API +SerdStatus +serd_reader_read_chunk(SerdReader* me); + +/** + Finish an incremental read from a file handle. +*/ +SERD_API +SerdStatus +serd_reader_end_stream(SerdReader* me); + /** Read @c file. */ -- cgit v1.2.1