summaryrefslogtreecommitdiffstats
path: root/src/sord.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-09 23:51:52 +0000
committerDavid Robillard <d@drobilla.net>2012-03-09 23:51:52 +0000
commit90a703bad8e7df5c0b154c17dfb201dc708f6069 (patch)
tree3f1865e4d511815a246a237bfe13fda9adbc5770 /src/sord.c
parent99082336abd05045e4f224fc2d07776648fbcc46 (diff)
downloadsord-90a703bad8e7df5c0b154c17dfb201dc708f6069.tar.gz
sord-90a703bad8e7df5c0b154c17dfb201dc708f6069.tar.bz2
sord-90a703bad8e7df5c0b154c17dfb201dc708f6069.zip
Add sord_new_relative_uri().
git-svn-id: http://svn.drobilla.net/sord/trunk@204 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src/sord.c')
-rw-r--r--src/sord.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sord.c b/src/sord.c
index 2ffa414..5fab21e 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -959,6 +959,7 @@ sord_new_uri_counted(SordWorld* world, const uint8_t* str,
size_t n_bytes, size_t n_chars, bool copy)
{
if (!serd_uri_string_has_scheme(str)) {
+ fprintf(stderr, "Attempt to map invalid URI `%s'.\n", str);
return NULL; // Can't intern relative URIs
}
@@ -985,6 +986,25 @@ sord_new_uri(SordWorld* world, const uint8_t* str)
return sord_new_uri_counted(world, str, node.n_bytes, node.n_chars, true);
}
+SordNode*
+sord_new_relative_uri(SordWorld* world,
+ const uint8_t* str,
+ const uint8_t* base_str)
+{
+ if (serd_uri_string_has_scheme(str)) {
+ return sord_new_uri(world, str);
+ }
+ SerdURI buri = SERD_URI_NULL;
+ SerdNode base = serd_node_new_uri_from_string(base_str, NULL, &buri);
+ SerdNode node = serd_node_new_uri_from_string(str, &buri, NULL);
+
+ SordNode* ret = sord_new_uri_counted(
+ world, node.buf, node.n_bytes, node.n_chars, false);
+
+ serd_node_free(&base);
+ return ret;
+}
+
static SordNode*
sord_new_blank_counted(SordWorld* world, const uint8_t* str,
size_t n_bytes, size_t n_chars)