summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-04 01:37:51 +0000
committerDavid Robillard <d@drobilla.net>2011-02-04 01:37:51 +0000
commit5b8c788cc4a42f9424d5cca7ca46ceb3cb427af7 (patch)
tree1c7f67590c255d27ae587ed27e026cae1d2958bf /src/util.c
parentcded478d952f14fee667e5ba9407923b17daaa65 (diff)
downloadlilv-5b8c788cc4a42f9424d5cca7ca46ceb3cb427af7.tar.gz
lilv-5b8c788cc4a42f9424d5cca7ca46ceb3cb427af7.tar.bz2
lilv-5b8c788cc4a42f9424d5cca7ca46ceb3cb427af7.zip
Drop librdf in favour of serd/sord.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2895 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/util.c b/src/util.c
index 9fee529..b6b7d85 100644
--- a/src/util.c
+++ b/src/util.c
@@ -92,32 +92,21 @@ slv2_get_lang()
char*
slv2_qname_expand(SLV2Plugin p, const char* qname)
{
- char* colon = strchr(qname, ':');
- if (!colon || colon == qname) {
- SLV2_ERRORF("Invalid QName `%s'\n", qname);
- return NULL;
- }
-
- const size_t prefix_len = colon - qname;
- char* prefix = malloc(prefix_len + 1);
- memcpy(prefix, qname, prefix_len);
- prefix[prefix_len] = '\0';
-
- char* namespace = librdf_hash_get(p->world->namespaces, prefix);
- free(prefix);
- if (!namespace) {
- SLV2_ERRORF("QName `%s' has Undefined prefix\n", qname);
+ const size_t qname_len = strlen(qname);
+ SerdNode qname_node = { SERD_CURIE, qname_len + 1, qname_len,
+ (const uint8_t*)qname };
+
+ SerdChunk uri_prefix;
+ SerdChunk uri_suffix;
+ if (serd_env_expand(p->world->namespaces, &qname_node, &uri_prefix, &uri_suffix)) {
+ const size_t uri_len = uri_prefix.len + uri_suffix.len;
+ char* uri = malloc(uri_len + 1);
+ memcpy(uri, uri_prefix.buf, uri_prefix.len);
+ memcpy(uri + uri_prefix.len, uri_suffix.buf, uri_suffix.len);
+ uri[uri_len] = '\0';
+ return uri;
+ } else {
+ SLV2_ERRORF("Failed to expand QName `%s'\n", qname);
return NULL;
}
-
- const size_t qname_len = strlen(qname);
- const size_t suffix_len = qname_len - prefix_len - 1;
- const size_t namespace_len = strlen(namespace);
- char* uri = malloc(namespace_len + suffix_len + 1);
- memcpy(uri, namespace, namespace_len);
- memcpy(uri + namespace_len, colon + 1, qname_len - prefix_len - 1);
- uri[namespace_len + suffix_len] = '\0';
-
- free(namespace);
- return uri;
}