From cbf01be4126cbc0f6d80364a7e0b6ad777a7d8ae Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 9 Oct 2021 13:44:31 -0400 Subject: Fix handling of deferred write errors that happen when closing --- include/serd/serd.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include/serd') diff --git a/include/serd/serd.h b/include/serd/serd.h index d606f4bb..35d31a57 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -2201,8 +2201,8 @@ serd_node_to_syntax(const SerdNode* SERD_NONNULL node, /// An input stream that produces bytes typedef struct { void* SERD_NULLABLE stream; ///< Opaque parameter for functions - SerdReadFunc SERD_NULLABLE read; ///< Read bytes to input - SerdErrorFunc SERD_NONNULL error; ///< Stream error accessor + SerdReadFunc SERD_NONNULL read; ///< Read bytes from input + SerdErrorFunc SERD_NULLABLE error; ///< Stream error accessor SerdCloseFunc SERD_NULLABLE close; ///< Close input } SerdInputStream; @@ -2468,7 +2468,8 @@ serd_buffer_close(void* SERD_NONNULL stream); /// An output stream that receives bytes typedef struct { void* SERD_NULLABLE stream; ///< Opaque parameter for functions - SerdWriteFunc SERD_NULLABLE write; ///< Write bytes to output + SerdWriteFunc SERD_NONNULL write; ///< Write bytes to output + SerdErrorFunc SERD_NULLABLE error; ///< Stream error accessor SerdCloseFunc SERD_NULLABLE close; ///< Close output } SerdOutputStream; @@ -2476,6 +2477,7 @@ typedef struct { Open a stream that writes to a provided function. @param write_func Function to write output. + @param error_func Function used to detect errors. @param close_func Function to close the stream after writing is done. @param stream Opaque stream parameter for write_func and close_func. @@ -2484,6 +2486,7 @@ typedef struct { SERD_CONST_API SerdOutputStream serd_open_output_stream(SerdWriteFunc SERD_NONNULL write_func, + SerdErrorFunc SERD_NULLABLE error_func, SerdCloseFunc SERD_NULLABLE close_func, void* SERD_NULLABLE stream); @@ -2519,7 +2522,8 @@ serd_open_output_file(const char* SERD_NONNULL path); This will call the close function, and reset the stream internally so that no further writes can be made. For convenience, this is safe to call on - NULL, and safe to call several times on the same output. + NULL, and safe to call several times on the same output. Failure is + returned in both of those cases. */ SERD_API SerdStatus -- cgit v1.2.1