summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-30 22:01:22 +0000
committerDavid Robillard <d@drobilla.net>2009-05-30 22:01:22 +0000
commit2e802fe1337cec54522e5439742c7c450516cb31 (patch)
treedf34420324015cf5f2e1a4fa9fab14795d78f885 /src
parentb039c0a764f13fa0bb5a38147ed8e0f17c0931d3 (diff)
downloadlilv-2e802fe1337cec54522e5439742c7c450516cb31.tar.gz
lilv-2e802fe1337cec54522e5439742c7c450516cb31.tar.bz2
lilv-2e802fe1337cec54522e5439742c7c450516cb31.zip
Partial implementation of lv2 dynamic manifest extension (configure --dyn-manifest).
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2057 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/world.c57
1 files changed, 51 insertions, 6 deletions
diff --git a/src/world.c b/src/world.c
index cecd690..44028ed 100644
--- a/src/world.c
+++ b/src/world.c
@@ -24,11 +24,15 @@
#include <dirent.h>
#include <string.h>
#include <librdf.h>
+#include <dlfcn.h>
#include "slv2/types.h"
#include "slv2/world.h"
#include "slv2/slv2.h"
#include "slv2/util.h"
#include "slv2_internal.h"
+#ifdef SLV2_DYN_MANIFEST
+#include "lv2_dyn_manifest.h"
+#endif
/* private */
@@ -185,13 +189,56 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
librdf_parser_parse_into_model(world->parser, manifest_uri, NULL,
manifest_model);
- /* Query statement: ?plugin a lv2:Plugin */
+#ifdef SLV2_DYN_MANIFEST
+ const unsigned char* const query_str = (const unsigned char* const)
+ "PREFIX : <http://lv2plug.in/ns/lv2core#>\n"
+ "PREFIX dynman: <http://naspro.atheme.org/rdf/dman#>\n"
+ "SELECT DISTINCT ?dynman ?binary WHERE {\n"
+ "?dynman a dynman:DynManifest ;\n"
+ " :binary ?binary .\n"
+ "}";
+
+ librdf_query* query = librdf_new_query(world->world, "sparql", NULL, query_str, NULL);
+ librdf_query_results* query_results = librdf_query_execute(query, manifest_model);
+ while (!librdf_query_results_finished(query_results)) {
+ librdf_node* dynman_node = librdf_query_results_get_binding_value(query_results, 0);
+ librdf_node* binary_node = librdf_query_results_get_binding_value(query_results, 1);
+
+ if (librdf_node_get_type(binary_node) == LIBRDF_NODE_TYPE_RESOURCE) {
+ const char* lib_path = slv2_uri_to_path(
+ (const char*)librdf_uri_as_string(librdf_node_get_uri(binary_node)));
+
+ if (lib_path) {
+ void* lib = dlopen(lib_path, RTLD_NOW);
+ typedef int (*DynManifestGetFunc)(FILE*);
+ DynManifestGetFunc func = (DynManifestGetFunc)dlsym(lib, "lv2_dyn_manifest_write");
+ if (func) {
+ printf("DYNAMIC MANIFEST <%s> @ <%s> {\n",
+ librdf_uri_as_string(librdf_node_get_uri(dynman_node)),
+ librdf_uri_as_string(librdf_node_get_uri(binary_node)));
+ FILE* dyn_manifest = fopen("/home/dave/dynmanifest.ttl", "w+");//tmpfile();
+ func(dyn_manifest);
+ rewind(dyn_manifest);
+ librdf_parser_parse_file_handle_into_model(world->parser,
+ dyn_manifest, 0, manifest_uri, manifest_model);
+ fclose(dyn_manifest);
+ }
+ }
+
+ }
+
+ librdf_query_results_next(query_results);
+ }
+ librdf_free_query_results(query_results);
+ librdf_free_query(query);
+#endif
+
+ /* ?plugin a lv2:Plugin */
librdf_statement* q = librdf_new_statement_from_nodes(world->world,
NULL, librdf_new_node_from_node(world->rdf_a_node),
librdf_new_node_from_node(world->lv2_plugin_node));
librdf_stream* results = librdf_model_find_statements(manifest_model, q);
-
while (!librdf_stream_end(results)) {
librdf_statement* s = librdf_stream_get_object(results);
@@ -216,17 +263,16 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
librdf_stream_next(results);
}
-
librdf_free_stream(results);
librdf_free_statement(q);
- /* Query statement: ?specification a lv2:Specification */
+
+ /* ?specification a lv2:Specification */
q = librdf_new_statement_from_nodes(world->world,
NULL, librdf_new_node_from_node(world->rdf_a_node),
librdf_new_node_from_node(world->lv2_specification_node));
results = librdf_model_find_statements(manifest_model, q);
-
while (!librdf_stream_end(results)) {
librdf_statement* s = librdf_stream_get_object(results);
@@ -251,7 +297,6 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
librdf_stream_next(results);
}
-
librdf_free_stream(results);
librdf_free_statement(q);