diff options
Diffstat (limited to 'include/serd/stream.h')
-rw-r--r-- | include/serd/stream.h | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/include/serd/stream.h b/include/serd/stream.h index 8b023add..992db552 100644 --- a/include/serd/stream.h +++ b/include/serd/stream.h @@ -32,26 +32,38 @@ SERD_BEGIN_DECLS typedef int (*SerdStreamErrorFunc)(void* SERD_NONNULL stream); /** - Source function for raw string input. + Function for reading input bytes from a stream. - Identical semantics to `fread`, but may set errno for more informative error - reporting than supported by SerdStreamErrorFunc. + This has 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. + @return Number of elements (bytes) read, which is short on error. */ -typedef size_t (*SerdSource)(void* SERD_NONNULL buf, - size_t size, - size_t nmemb, - void* SERD_NONNULL stream); - -/// Sink function for raw string output -typedef size_t (*SerdSink)(const void* SERD_NONNULL buf, - size_t len, - void* SERD_NONNULL stream); +typedef size_t (*SerdReadFunc)(void* SERD_NONNULL buf, + size_t size, + size_t nmemb, + void* SERD_NONNULL stream); + +/** + Function for writing output bytes to a stream. + + This has identical semantics to `fwrite`, but may set `errno` for more + informative error reporting than supported by #SerdStreamErrorFunc. + + @param buf Input 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 write to (FILE* for fread). + @return Number of elements (bytes) written, which is short on error. +*/ +typedef size_t (*SerdWriteFunc)(const void* SERD_NONNULL buf, + size_t size, + size_t nmemb, + void* SERD_NONNULL stream); /** @} |