diff options
author | David Robillard <d@drobilla.net> | 2021-07-17 13:19:27 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | c3bc111f7fb2a44e068e5250f7823352e44c76dc (patch) | |
tree | 4ecfff5a04eaab39a5152f72a41906a6e64b08a9 /include/serd | |
parent | ea4b6e7d109ae3abc7f8ecdf99e3eb33e3484b77 (diff) | |
download | serd-c3bc111f7fb2a44e068e5250f7823352e44c76dc.tar.gz serd-c3bc111f7fb2a44e068e5250f7823352e44c76dc.tar.bz2 serd-c3bc111f7fb2a44e068e5250f7823352e44c76dc.zip |
Factor out and expose serd_write_file_uri()
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/buffer.h | 1 | ||||
-rw-r--r-- | include/serd/caret.h | 1 | ||||
-rw-r--r-- | include/serd/error.h | 1 | ||||
-rw-r--r-- | include/serd/memory.h | 1 | ||||
-rw-r--r-- | include/serd/node.h | 2 | ||||
-rw-r--r-- | include/serd/sink.h | 1 | ||||
-rw-r--r-- | include/serd/statement.h | 1 | ||||
-rw-r--r-- | include/serd/string_view.h | 1 | ||||
-rw-r--r-- | include/serd/uri.h | 27 | ||||
-rw-r--r-- | include/serd/world.h | 1 | ||||
-rw-r--r-- | include/serd/writer.h | 1 |
11 files changed, 27 insertions, 11 deletions
diff --git a/include/serd/buffer.h b/include/serd/buffer.h index cf2170c3..d4fd63fb 100644 --- a/include/serd/buffer.h +++ b/include/serd/buffer.h @@ -5,7 +5,6 @@ #define SERD_BUFFER_H #include "serd/attributes.h" -#include "zix/allocator.h" #include "zix/attributes.h" #include <stddef.h> diff --git a/include/serd/caret.h b/include/serd/caret.h index f8983899..429a6fcd 100644 --- a/include/serd/caret.h +++ b/include/serd/caret.h @@ -6,7 +6,6 @@ #include "serd/attributes.h" #include "serd/node.h" -#include "zix/allocator.h" #include "zix/attributes.h" #include <stdbool.h> diff --git a/include/serd/error.h b/include/serd/error.h index 16b28e83..79b22a29 100644 --- a/include/serd/error.h +++ b/include/serd/error.h @@ -7,6 +7,7 @@ #include "serd/attributes.h" #include "serd/caret.h" #include "serd/status.h" +#include "zix/attributes.h" #include <stdarg.h> diff --git a/include/serd/memory.h b/include/serd/memory.h index 0e50c4e3..050b7597 100644 --- a/include/serd/memory.h +++ b/include/serd/memory.h @@ -5,6 +5,7 @@ #define SERD_MEMORY_H #include "serd/attributes.h" +#include "zix/attributes.h" SERD_BEGIN_DECLS diff --git a/include/serd/node.h b/include/serd/node.h index 98fb3d1a..f745af6d 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -8,9 +8,7 @@ #include "serd/string_view.h" #include "serd/uri.h" #include "serd/write_result.h" -#include "zix/allocator.h" #include "zix/attributes.h" -#include "zix/string_view.h" #include <stdbool.h> #include <stddef.h> diff --git a/include/serd/sink.h b/include/serd/sink.h index 58932435..291e8d3f 100644 --- a/include/serd/sink.h +++ b/include/serd/sink.h @@ -9,7 +9,6 @@ #include "serd/node.h" #include "serd/statement.h" #include "serd/status.h" -#include "zix/allocator.h" #include "zix/attributes.h" SERD_BEGIN_DECLS diff --git a/include/serd/statement.h b/include/serd/statement.h index 2e8eddc2..9d987922 100644 --- a/include/serd/statement.h +++ b/include/serd/statement.h @@ -7,7 +7,6 @@ #include "serd/attributes.h" #include "serd/caret.h" #include "serd/node.h" -#include "zix/allocator.h" #include "zix/attributes.h" #include <stdbool.h> diff --git a/include/serd/string_view.h b/include/serd/string_view.h index 07b6dd69..6b8e078c 100644 --- a/include/serd/string_view.h +++ b/include/serd/string_view.h @@ -5,6 +5,7 @@ #define SERD_STRING_VIEW_H #include "serd/attributes.h" +#include "zix/attributes.h" #include <stddef.h> #include <string.h> diff --git a/include/serd/uri.h b/include/serd/uri.h index bee9fe78..7a63f183 100644 --- a/include/serd/uri.h +++ b/include/serd/uri.h @@ -7,9 +7,7 @@ #include "serd/attributes.h" #include "serd/stream.h" #include "serd/string_view.h" -#include "zix/allocator.h" #include "zix/attributes.h" -#include "zix/string_view.h" #include <stdbool.h> #include <stddef.h> @@ -145,7 +143,8 @@ serd_uri_string_length(SerdURIView uri); @param sink Sink to write string output to. @param stream Opaque user argument to pass to `sink`. - @return The number of bytes written, which is less than + @return The length of the written URI string (not including a null + terminator, which is not written), which may be less than `serd_uri_string_length(uri)` on error. */ SERD_API size_t @@ -154,6 +153,28 @@ serd_write_uri(SerdURIView uri, void* ZIX_NONNULL stream); /** + Write a file URI to `sink` from a path and optional hostname. + + Backslashes in Windows paths will be converted, and other characters will be + percent encoded as necessary. + + If `path` is relative, `hostname` is ignored. + + @param path File system path. + @param hostname Optional hostname. + @param sink Sink to write string output to. + @param stream Opaque user argument to pass to `sink`. + + @return The length of the written URI string (not including a null + terminator, which is not written) +*/ +SERD_API size_t +serd_write_file_uri(SerdStringView path, + SerdStringView hostname, + SerdWriteFunc ZIX_NONNULL sink, + void* ZIX_NONNULL stream); + +/** @} */ diff --git a/include/serd/world.h b/include/serd/world.h index 86e43bb1..0017b6eb 100644 --- a/include/serd/world.h +++ b/include/serd/world.h @@ -8,7 +8,6 @@ #include "serd/error.h" #include "serd/node.h" #include "serd/status.h" -#include "zix/allocator.h" #include "zix/attributes.h" #include <stddef.h> diff --git a/include/serd/writer.h b/include/serd/writer.h index 60220570..fabdcd61 100644 --- a/include/serd/writer.h +++ b/include/serd/writer.h @@ -13,7 +13,6 @@ #include "serd/syntax.h" #include "serd/world.h" #include "zix/attributes.h" -#include "zix/string_view.h" #include <stdint.h> |