From 613fcc9170bb5f97e2a9e23f590cf8a427a3e0e2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 3 Jun 2018 17:34:07 +0200 Subject: Move byte source/sink functions into their own section --- serd/serd.h | 68 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 31 deletions(-) (limited to 'serd/serd.h') diff --git a/serd/serd.h b/serd/serd.h index a5a3f882..f3d83515 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -322,6 +322,43 @@ SERD_API void* serd_base64_decode(const uint8_t* str, size_t len, size_t* size); +/** + @} + @name Byte Streams + @{ +*/ + +/** + Function to detect I/O stream errors. + + Identical semantics to `ferror`. + + @return Non-zero if `stream` has encountered an error. +*/ +typedef int (*SerdStreamErrorFunc)(void* stream); + +/** + Source function for raw string input. + + Identical semantics to `fread`, but may set errno for more informative error + reporting than supported by SerdStreamErrorFunc. + + @param buf Output buffer. + @param size Size of a single element of data in bytes (always 1). + @param nmemb Number of elements to read. + @param stream Stream to read from (FILE* for fread). + @return Number of elements (bytes) read. +*/ +typedef size_t (*SerdSource)(void* buf, + size_t size, + size_t nmemb, + void* stream); + +/** + Sink function for raw string output. +*/ +typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream); + /** @} @name URI @@ -378,37 +415,6 @@ SERD_API void serd_uri_resolve(const SerdURI* r, const SerdURI* base, SerdURI* t); -/** - Function to detect I/O stream errors. - - Identical semantics to `ferror`. - - @return Non-zero if `stream` has encountered an error. -*/ -typedef int (*SerdStreamErrorFunc)(void* stream); - -/** - Source function for raw string input. - - Identical semantics to `fread`, but may set errno for more informative error - reporting than supported by SerdStreamErrorFunc. - - @param buf Output buffer. - @param size Size of a single element of data in bytes (always 1). - @param nmemb Number of elements to read. - @param stream Stream to read from (FILE* for fread). - @return Number of elements (bytes) read. -*/ -typedef size_t (*SerdSource)(void* buf, - size_t size, - size_t nmemb, - void* stream); - -/** - Sink function for raw string output. -*/ -typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream); - /** Serialise `uri` with a series of calls to `sink`. */ -- cgit v1.2.1