aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-07-10 19:07:14 -0400
committerDavid Robillard <d@drobilla.net>2016-07-10 19:07:14 -0400
commit1e8c93c6e760c4453c4fd1f471feebd7886692d3 (patch)
tree0a7b77f7f27db3ceb401658cf18c883352dc7308 /src
parentaf9356818981e83d5eb9430d4717b19c7316c154 (diff)
downloadserd-1e8c93c6e760c4453c4fd1f471feebd7886692d3.tar.gz
serd-1e8c93c6e760c4453c4fd1f471feebd7886692d3.tar.bz2
serd-1e8c93c6e760c4453c4fd1f471feebd7886692d3.zip
Add serd_node_new_relative_uri()
Diffstat (limited to 'src')
-rw-r--r--src/node.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/node.c b/src/node.c
index 7d50f326..2a3a44b2 100644
--- a/src/node.c
+++ b/src/node.c
@@ -212,6 +212,32 @@ serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out)
return node;
}
+SERD_API
+SerdNode
+serd_node_new_relative_uri(const SerdURI* uri,
+ const SerdURI* base,
+ const SerdURI* root,
+ SerdURI* out)
+{
+ const size_t uri_len = serd_uri_string_length(uri);
+ const size_t base_len = serd_uri_string_length(base);
+ uint8_t* buf = (uint8_t*)malloc(uri_len + base_len + 1);
+ SerdNode node = { buf, 0, 0, 0, SERD_URI };
+ uint8_t* ptr = buf;
+ const size_t actual_len = serd_uri_serialise_relative(
+ uri, base, root, string_sink, &ptr);
+
+ buf[actual_len] = '\0';
+ node.n_bytes = actual_len;
+ node.n_chars = serd_strlen(buf, NULL, NULL);
+
+ if (out) {
+ serd_uri_parse(buf, out); // TODO: cleverly avoid double parse
+ }
+
+ return node;
+}
+
static inline unsigned
serd_digits(double abs)
{