aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-15 09:26:17 -0400
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:24 -0500
commitee254d3e92900986526078bb9cbef1642a51dac1 (patch)
tree5e3197d7abbebde216024efec5b7189559ac6b4e /src/uri.c
parent9a8e06aa5bdc62ed589bd8ed5789bd059cec0700 (diff)
downloadserd-ee254d3e92900986526078bb9cbef1642a51dac1.tar.gz
serd-ee254d3e92900986526078bb9cbef1642a51dac1.tar.bz2
serd-ee254d3e92900986526078bb9cbef1642a51dac1.zip
Bring read/write interface closer to C standard
Diffstat (limited to 'src/uri.c')
-rw-r--r--src/uri.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/uri.c b/src/uri.c
index 88e1bd1e..780f7e72 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -57,18 +57,18 @@ serd_parse_file_uri(const char* uri, char** hostname)
for (const char* s = path; *s; ++s) {
if (*s == '%') {
if (*(s + 1) == '%') {
- serd_buffer_sink("%", 1, &buffer);
+ serd_buffer_sink("%", 1, 1, &buffer);
++s;
} else if (is_hexdig(*(s + 1)) && is_hexdig(*(s + 2))) {
const char code[3] = {*(s + 1), *(s + 2), 0};
const char c = (char)strtoul((const char*)code, NULL, 16);
- serd_buffer_sink(&c, 1, &buffer);
+ serd_buffer_sink(&c, 1, 1, &buffer);
s += 2;
} else {
s += 2; // Junk escape, ignore
}
} else {
- serd_buffer_sink(s, 1, &buffer);
+ serd_buffer_sink(s, 1, 1, &buffer);
}
}
@@ -415,48 +415,47 @@ serd_uri_is_within(const SerdURIView uri, const SerdURIView base)
/// See http://tools.ietf.org/html/rfc3986#section-5.3
size_t
-serd_write_uri(const SerdURIView uri, SerdSink sink, void* stream)
+serd_write_uri(const SerdURIView uri, SerdWriteFunc sink, void* stream)
{
size_t len = 0;
if (uri.scheme.buf) {
- len += sink(uri.scheme.buf, uri.scheme.len, stream);
- len += sink(":", 1, stream);
+ len += sink(uri.scheme.buf, 1, uri.scheme.len, stream);
+ len += sink(":", 1, 1, stream);
}
if (uri.authority.buf) {
- len += sink("//", 2, stream);
- len += sink(uri.authority.buf, uri.authority.len, stream);
+ len += sink("//", 1, 2, stream);
+ len += sink(uri.authority.buf, 1, uri.authority.len, stream);
if (uri.authority.len > 0 && uri_path_len(&uri) > 0 &&
uri_path_at(&uri, 0) != '/') {
// Special case: ensure path begins with a slash
// https://tools.ietf.org/html/rfc3986#section-3.2
- len += sink("/", 1, stream);
+ len += sink("/", 1, 1, stream);
}
}
if (uri.path_prefix.buf) {
- len += sink(uri.path_prefix.buf, uri.path_prefix.len, stream);
+ len += sink(uri.path_prefix.buf, 1, uri.path_prefix.len, stream);
} else if (uri.path_prefix.len) {
for (size_t i = 0; i < uri.path_prefix.len; ++i) {
- len += sink("../", 3, stream);
+ len += sink("../", 1, 3, stream);
}
}
if (uri.path.buf) {
- len += sink(uri.path.buf, uri.path.len, stream);
+ len += sink(uri.path.buf, 1, uri.path.len, stream);
}
if (uri.query.buf) {
- len += sink("?", 1, stream);
- len += sink(uri.query.buf, uri.query.len, stream);
+ len += sink("?", 1, 1, stream);
+ len += sink(uri.query.buf, 1, uri.query.len, stream);
}
if (uri.fragment.buf) {
// Note that uri.fragment.buf includes the leading `#'
- len += sink(uri.fragment.buf, uri.fragment.len, stream);
+ len += sink(uri.fragment.buf, 1, uri.fragment.len, stream);
}
-
return len;
}