summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-18 03:06:19 +0000
committerDavid Robillard <d@drobilla.net>2011-05-18 03:06:19 +0000
commitd5235c880b6e23e4618ae02f38981051e599741e (patch)
treebce81ac30b6570235e6bbc0e951a22b689606b4b /src
parent3415c74d95538ef1269ec1104e332aa9987f1145 (diff)
downloadlilv-d5235c880b6e23e4618ae02f38981051e599741e.tar.gz
lilv-d5235c880b6e23e4618ae02f38981051e599741e.tar.bz2
lilv-d5235c880b6e23e4618ae02f38981051e599741e.zip
Update for new Sord API.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3274 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c41
-rw-r--r--src/world.c48
2 files changed, 52 insertions, 37 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 673ea2f..a31558f 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -114,17 +114,29 @@ lilv_plugin_get_unique(const LilvPlugin* p,
static void
lilv_plugin_load(LilvPlugin* p)
{
+ SordNode* bundle_uri_node = p->bundle_uri->val.uri_val;
+ const SerdNode* bundle_uri_snode = sord_node_to_serd_node(bundle_uri_node);
+
+ SerdEnv* env = serd_env_new(bundle_uri_snode);
+ SerdReader* reader = sord_new_reader(p->world->model, env, SERD_TURTLE,
+ bundle_uri_node);
+
// Parse all the plugin's data files into RDF model
LILV_FOREACH(nodes, i, p->data_uris) {
const LilvNode* data_uri_val = lilv_nodes_get(p->data_uris, i);
- SerdEnv* env = serd_env_new();
- sord_read_file(p->world->model,
- env,
- sord_node_get_string(data_uri_val->val.uri_val),
- NULL,
- p->bundle_uri->val.uri_val,
- lilv_world_blank_node_prefix(p->world));
- serd_env_free(env);
+ const char* data_uri_str = lilv_node_as_uri(data_uri_val);
+ if (strncmp((const char*)data_uri_str,
+ (const char*)bundle_uri_snode->buf,
+ bundle_uri_snode->n_bytes)) {
+ LILV_WARNF("Ignored data file <%s> not in bundle <%s>\n",
+ (const char*)data_uri_str,
+ (const char*)bundle_uri_snode->buf);
+ continue;
+ }
+
+ serd_reader_add_blank_prefix(reader,
+ lilv_world_blank_node_prefix(p->world));
+ serd_reader_read_file(reader, (const uint8_t*)data_uri_str);
}
#ifdef LILV_DYN_MANIFEST
@@ -154,15 +166,8 @@ lilv_plugin_load(LilvPlugin* p)
FILE* fd = tmpfile();
get_data_func(handle, fd, lilv_node_as_string(p->plugin_uri));
rewind(fd);
- SerdEnv* env = serd_env_new();
- sord_read_file_handle(p->world->model,
- env,
- fd,
- "(dyn-manifest)",
- (const uint8_t*)lilv_node_as_uri(p->dynman_uri),
- p->bundle_uri->val.uri_val,
- lilv_world_blank_node_prefix(p->world));
- serd_env_free(env);
+ serd_reader_read_file_handle(reader, fd,
+ (const uint8_t*)"(dyn-manifest)");
fclose(fd);
}
@@ -172,6 +177,8 @@ lilv_plugin_load(LilvPlugin* p)
close_func(handle);
}
#endif
+ serd_reader_free(reader);
+ serd_env_free(env);
p->loaded = true;
}
diff --git a/src/world.c b/src/world.c
index 387ba7f..12baf15 100644
--- a/src/world.c
+++ b/src/world.c
@@ -385,8 +385,8 @@ lilv_world_add_plugin(LilvWorld* world,
static void
lilv_world_load_dyn_manifest(LilvWorld* world,
- SordNode* bundle_node,
- SerdNode manifest_uri)
+ SordNode* bundle_node,
+ SerdNode manifest_uri)
{
#ifdef LILV_DYN_MANIFEST
if (!world->opt.dyn_manifest) {
@@ -462,10 +462,12 @@ lilv_world_load_dyn_manifest(LilvWorld* world,
rewind(fd);
// Parse generated data file
- SerdEnv* env = serd_env_new();
- sord_read_file_handle(world->model, env, fd, "(dyn-manifest)",
- lib_uri, bundle_node,
- lilv_world_blank_node_prefix(world));
+ SerdEnv* env = serd_env_new(bundle_node);
+ SerdReader* reader = sord_new_reader(
+ world->model, env, SERD_TURTLE, bundle_node);
+ serd_reader_read_file_handle(reader, fd,
+ (const uint8_t*)"(dyn-manifest)");
+ serd_reader_free(reader);
serd_env_free(env);
// Close (and automatically delete) temporary data file
@@ -496,7 +498,7 @@ void
lilv_world_load_bundle(LilvWorld* world, LilvNode* bundle_uri)
{
if (!lilv_node_is_uri(bundle_uri)) {
- LILV_ERRORF ("Bundle URI `%s' is not a URI\n", bundle_uri->str_val);
+ LILV_ERRORF("Bundle URI `%s' is not a URI\n", bundle_uri->str_val);
return;
}
@@ -506,13 +508,17 @@ lilv_world_load_bundle(LilvWorld* world, LilvNode* bundle_uri)
(const uint8_t*)"manifest.ttl",
(const uint8_t*)sord_node_get_string(bundle_node));
- SerdEnv* env = serd_env_new();
- if (!sord_read_file(world->model, env, manifest_uri.buf, NULL, bundle_node,
- lilv_world_blank_node_prefix(world))) {
- serd_env_free(env);
+ SerdEnv* env = serd_env_new(&manifest_uri);
+ SerdReader* reader = sord_new_reader(world->model, env, SERD_TURTLE,
+ bundle_node);
+ serd_reader_add_blank_prefix(reader, lilv_world_blank_node_prefix(world));
+
+ SerdStatus st = serd_reader_read_file(reader, manifest_uri.buf);
+ serd_env_free(env);
+ if (st) {
+ LILV_ERRORF("Error reading %s\n", manifest_uri.buf);
return;
}
- serd_env_free(env);
// ?plugin a lv2:Plugin
SordIter* plug_results = lilv_world_find_statements(
@@ -668,14 +674,16 @@ lilv_world_load_specifications(LilvWorld* world)
for (GSList* l = world->specs; l; l = l->next) {
LilvSpec* spec = (LilvSpec*)l->data;
LILV_FOREACH(nodes, f, spec->data_uris) {
- LilvNode* file = lilv_collection_get(spec->data_uris, f);
- SerdEnv* env = serd_env_new();
- sord_read_file(world->model,
- env,
- (const uint8_t*)lilv_node_as_uri(file),
- NULL,
- NULL,
- lilv_world_blank_node_prefix(world));
+ LilvNode* file = lilv_collection_get(spec->data_uris, f);
+ const uint8_t* file_uri = (const uint8_t*)lilv_node_as_uri(file);
+ SerdEnv* env = serd_env_new(
+ sord_node_to_serd_node(file->val.uri_val));
+ SerdReader* reader = sord_new_reader(world->model, env,
+ SERD_TURTLE, NULL);
+ serd_reader_add_blank_prefix(reader,
+ lilv_world_blank_node_prefix(world));
+ serd_reader_read_file(reader, file_uri);
+ serd_reader_free(reader);
serd_env_free(env);
}
}