From 0a04be1e9e8f3c6b355c014f5755bb30da0d5aec Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 13 May 2009 16:04:14 +0000 Subject: Strip trailing whitespace. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1999 a436a847-0d15-0410-975c-d299462d15a1 --- src/collections.c | 16 +++---- src/plugin.c | 78 ++++++++++++++++----------------- src/pluginclass.c | 2 +- src/plugininstance.c | 20 ++++----- src/plugins.c | 10 ++--- src/pluginui.c | 12 ++--- src/pluginuiinstance.c | 28 ++++++------ src/port.c | 40 ++++++++--------- src/query.c | 16 +++---- src/scalepoint.c | 2 +- src/slv2_internal.h | 6 +-- src/util.c | 4 +- src/value.c | 14 +++--- src/world.c | 116 ++++++++++++++++++++++++------------------------- 14 files changed, 182 insertions(+), 182 deletions(-) (limited to 'src') diff --git a/src/collections.c b/src/collections.c index 4598eab..a16c7fb 100644 --- a/src/collections.c +++ b/src/collections.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2008 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -75,19 +75,19 @@ SLV2PluginClass slv2_plugin_classes_get_by_uri(SLV2PluginClasses list, SLV2Value uri) { // good old fashioned binary search - + int lower = 0; int upper = raptor_sequence_size(list) - 1; int i; - + while (upper >= lower) { i = lower + ((upper - lower) / 2); SLV2PluginClass p = raptor_sequence_get_at(list, i); - + const int cmp = strcmp(slv2_value_as_uri(slv2_plugin_class_get_uri(p)), slv2_value_as_uri(uri)); - + if (cmp == 0) return p; else if (cmp > 0) @@ -109,7 +109,7 @@ slv2_values_contains(SLV2Values list, SLV2Value value) for (unsigned i=0; i < slv2_values_size(list); ++i) if (slv2_value_equals(slv2_values_get_at(list, i), value)) return true; - + return false; } @@ -129,11 +129,11 @@ SLV2UI slv2_uis_get_by_uri(SLV2UIs list, SLV2Value uri) { // good old fashioned binary search - + int lower = 0; int upper = raptor_sequence_size(list) - 1; int i; - + while (upper >= lower) { i = lower + ((upper - lower) / 2); diff --git a/src/plugin.c b/src/plugin.c index 314bbbe..6987f4c 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -59,13 +59,13 @@ slv2_plugin_free(SLV2Plugin p) { slv2_value_free(p->plugin_uri); p->plugin_uri = NULL; - + slv2_value_free(p->bundle_uri); p->bundle_uri = NULL; - + slv2_value_free(p->binary_uri); p->binary_uri = NULL; - + if (p->ports) raptor_free_sequence(p->ports); p->ports = NULL; @@ -74,12 +74,12 @@ slv2_plugin_free(SLV2Plugin p) librdf_free_model(p->rdf); p->rdf = NULL; } - + if (p->storage) { librdf_free_storage(p->storage); p->storage = NULL; } - + slv2_values_free(p->data_uris); p->data_uris = NULL; @@ -331,7 +331,7 @@ slv2_plugin_get_class(SLV2Plugin p) bool slv2_plugin_verify(SLV2Plugin plugin) { - char* query_str = + char* query_str = "SELECT DISTINCT ?type ?name ?license ?port WHERE {\n" "<> a ?type ;\n" "doap:name ?name ;\n" @@ -353,13 +353,13 @@ slv2_plugin_verify(SLV2Plugin plugin) if (librdf_node_get_type(type_node) == LIBRDF_NODE_TYPE_RESOURCE) has_type = true; - + if (name_node) has_name = true; - + if (license_node) has_license = true; - + if (port_node) has_port = true; @@ -388,7 +388,7 @@ slv2_plugin_get_name(SLV2Plugin plugin) { SLV2Values results = slv2_plugin_get_value_by_qname_i18n(plugin, "doap:name"); SLV2Value ret = NULL; - + if (results) { SLV2Value val = slv2_values_get_at(results, 0); if (slv2_value_is_string(val)) @@ -411,7 +411,7 @@ slv2_plugin_get_value(SLV2Plugin p, SLV2Value predicate) { char* query = NULL; - + /* Hack around broken RASQAL, full URI predicates don't work :/ */ query = slv2_strjoin( "PREFIX slv2predicate: <", slv2_value_as_string(predicate), ">\n", @@ -420,7 +420,7 @@ slv2_plugin_get_value(SLV2Plugin p, "}\n", NULL); SLV2Values result = slv2_plugin_query_variable(p, query, 0); - + free(query); return result; @@ -438,13 +438,13 @@ slv2_plugin_get_value_by_qname(SLV2Plugin p, "}\n", NULL); SLV2Values result = slv2_plugin_query_variable(p, query, 0); - + free(query); return result; } - + /* internal: get i18n value if possible */ SLV2Values slv2_plugin_get_value_by_qname_i18n(SLV2Plugin p, @@ -457,13 +457,13 @@ slv2_plugin_get_value_by_qname_i18n(SLV2Plugin p, "}\n", NULL); SLV2Values result = slv2_plugin_query_variable(p, query, 0); - + free(query); return result; } - + SLV2Values slv2_plugin_get_value_for_subject(SLV2Plugin p, SLV2Value subject, @@ -489,7 +489,7 @@ slv2_plugin_get_value_for_subject(SLV2Plugin p, "}\n", NULL); SLV2Values result = slv2_plugin_query_variable(p, query, 0); - + free(query); free(subject_token); @@ -525,7 +525,7 @@ void slv2_plugin_get_port_float_values(SLV2Plugin p, const char* qname, float* values) -{ +{ slv2_plugin_load_ports_if_necessary(p); for (int i = 0; i < raptor_sequence_size(p->ports); ++i) @@ -565,8 +565,8 @@ slv2_plugin_get_port_float_values(SLV2Plugin p, void -slv2_plugin_get_port_ranges_float(SLV2Plugin p, - float* min_values, +slv2_plugin_get_port_ranges_float(SLV2Plugin p, + float* min_values, float* max_values, float* def_values) { @@ -596,7 +596,7 @@ slv2_plugin_get_num_ports_of_class(SLV2Plugin p, continue; va_start(args, class_1); - + bool matches = true; for (SLV2Value class_i = NULL; (class_i = va_arg(args, SLV2Value)) != NULL ; ) { if (!slv2_port_is_a(p, port, class_i)) { @@ -619,7 +619,7 @@ slv2_plugin_get_num_ports_of_class(SLV2Plugin p, bool slv2_plugin_has_latency(SLV2Plugin p) { - const char* const query = + const char* const query = "SELECT ?index WHERE {\n" " <> lv2:port ?port .\n" " ?port lv2:portProperty lv2:reportsLatency ;\n" @@ -629,7 +629,7 @@ slv2_plugin_has_latency(SLV2Plugin p) SLV2Values results = slv2_plugin_query_variable(p, query, 0); const bool latent = (slv2_values_size(results) > 0); slv2_values_free(results); - + return latent; } @@ -637,7 +637,7 @@ slv2_plugin_has_latency(SLV2Plugin p) uint32_t slv2_plugin_get_latency_port_index(SLV2Plugin p) { - const char* const query = + const char* const query = "SELECT ?index WHERE {\n" " <> lv2:port ?port .\n" " ?port lv2:portProperty lv2:reportsLatency ;\n" @@ -645,7 +645,7 @@ slv2_plugin_get_latency_port_index(SLV2Plugin p) "}\n"; SLV2Values result = slv2_plugin_query_variable(p, query, 0); - + // FIXME: need a sane error handling strategy assert(slv2_values_size(result) > 0); SLV2Value val = slv2_values_get_at(result, 0); @@ -656,13 +656,13 @@ slv2_plugin_get_latency_port_index(SLV2Plugin p) return ret; } - + bool slv2_plugin_has_feature(SLV2Plugin p, SLV2Value feature) { SLV2Values features = slv2_plugin_get_supported_features(p); - + const bool ret = features && feature && slv2_values_contains(features, feature); slv2_values_free(features); @@ -675,7 +675,7 @@ slv2_plugin_get_supported_features(SLV2Plugin p) { SLV2Values optional = slv2_plugin_get_optional_features(p); SLV2Values required = slv2_plugin_get_required_features(p); - + SLV2Values result = slv2_values_new(); unsigned n_optional = slv2_values_size(optional); unsigned n_required = slv2_values_size(required); @@ -687,7 +687,7 @@ slv2_plugin_get_supported_features(SLV2Plugin p) slv2_values_free(optional); slv2_values_free(required); - + return result; } @@ -735,14 +735,14 @@ slv2_plugin_get_author_name(SLV2Plugin plugin) { SLV2Value ret = NULL; - const char* const query = + const char* const query = "SELECT ?name WHERE {\n" " <> doap:maintainer ?maint . \n" " ?maint foaf:name ?name . \n" "}\n"; SLV2Values results = slv2_plugin_query_variable(plugin, query, 0); - + if (results && slv2_values_size(results) > 0) { SLV2Value val = slv2_values_get_at(results, 0); if (slv2_value_is_string(val)) @@ -761,14 +761,14 @@ slv2_plugin_get_author_email(SLV2Plugin plugin) { SLV2Value ret = NULL; - const char* const query = + const char* const query = "SELECT ?email WHERE {\n" " <> doap:maintainer ?maint . \n" " ?maint foaf:mbox ?email . \n" "}\n"; - + SLV2Values results = slv2_plugin_query_variable(plugin, query, 0); - + if (results && slv2_values_size(results) > 0) { SLV2Value val = slv2_values_get_at(results, 0); if (slv2_value_is_uri(val)) @@ -781,20 +781,20 @@ slv2_plugin_get_author_email(SLV2Plugin plugin) return ret; } - + SLV2Value slv2_plugin_get_author_homepage(SLV2Plugin plugin) { SLV2Value ret = NULL; - const char* const query = + const char* const query = "SELECT ?page WHERE {\n" " <> doap:maintainer ?maint . \n" " ?maint foaf:homepage ?page . \n" "}\n"; - + SLV2Values results = slv2_plugin_query_variable(plugin, query, 0); - + if (results && slv2_values_size(results) > 0) { SLV2Value val = slv2_values_get_at(results, 0); if (slv2_value_is_uri(val)) diff --git a/src/pluginclass.c b/src/pluginclass.c index 6cc3bfe..cf7acf0 100644 --- a/src/pluginclass.c +++ b/src/pluginclass.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) diff --git a/src/plugininstance.c b/src/plugininstance.c index c3e0601..365535b 100644 --- a/src/plugininstance.c +++ b/src/plugininstance.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -37,19 +37,19 @@ slv2_plugin_instantiate(SLV2Plugin plugin, const LV2_Feature*const* features) { struct _Instance* result = NULL; - + const LV2_Feature** local_features = NULL; if (features == NULL) { local_features = malloc(sizeof(LV2_Feature)); local_features[0] = NULL; } - + const char* const lib_uri = slv2_value_as_uri(slv2_plugin_get_library_uri(plugin)); const char* const lib_path = slv2_uri_to_path(lib_uri); - + if (!lib_path) return NULL; - + dlerror(); void* lib = dlopen(lib_path, RTLD_NOW); if (!lib) { @@ -66,24 +66,24 @@ slv2_plugin_instantiate(SLV2Plugin plugin, return NULL; } else { // Search for plugin by URI - + // FIXME: Kludge to get bundle path (containing directory of binary) const char* bundle_path = slv2_uri_to_path(slv2_value_as_uri( slv2_plugin_get_bundle_uri(plugin))); //printf("Bundle path: %s\n", bundle_path); - + for (uint32_t i=0; 1; ++i) { - + const LV2_Descriptor* ld = df(i); - + if (!ld) { fprintf(stderr, "Did not find plugin %s in %s\n", slv2_value_as_uri(slv2_plugin_get_uri(plugin)), lib_path); dlclose(lib); break; // return NULL } else if (!strcmp(ld->URI, slv2_value_as_uri(slv2_plugin_get_uri(plugin)))) { - + assert(plugin->plugin_uri); //printf("Found %s at index %u in:\n\t%s\n\n", diff --git a/src/plugins.c b/src/plugins.c index f392bcd..97e1323 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -29,7 +29,7 @@ #include "slv2/util.h" #include "slv2_internal.h" - + SLV2Plugins slv2_plugins_new() { @@ -71,11 +71,11 @@ SLV2Plugin slv2_plugins_get_by_uri(SLV2Plugins list, SLV2Value uri) { // good old fashioned binary search - + int lower = 0; int upper = raptor_sequence_size(list) - 1; int i; - + while (upper >= lower) { i = lower + ((upper - lower) / 2); @@ -98,7 +98,7 @@ slv2_plugins_get_by_uri(SLV2Plugins list, SLV2Value uri) SLV2Plugin slv2_plugins_get_at(SLV2Plugins list, unsigned index) -{ +{ if (index > INT_MAX) return NULL; else diff --git a/src/pluginui.c b/src/pluginui.c index fb87f63..0ac3dca 100644 --- a/src/pluginui.c +++ b/src/pluginui.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -40,9 +40,9 @@ slv2_ui_new(SLV2World world, ui->world = world; ui->uri = slv2_value_new_librdf_uri(world, uri); ui->binary_uri = slv2_value_new_librdf_uri(world, binary_uri); - + assert(ui->binary_uri); - + // FIXME: kludge char* bundle = strdup(slv2_value_as_string(ui->binary_uri)); char* last_slash = strrchr(bundle, '/') + 1; @@ -63,15 +63,15 @@ slv2_ui_free(SLV2UI ui) { slv2_value_free(ui->uri); ui->uri = NULL; - + slv2_value_free(ui->bundle_uri); ui->bundle_uri = NULL; - + slv2_value_free(ui->binary_uri); ui->binary_uri = NULL; slv2_values_free(ui->classes); - + free(ui); } diff --git a/src/pluginuiinstance.c b/src/pluginuiinstance.c index c1c4720..44b41e5 100644 --- a/src/pluginuiinstance.c +++ b/src/pluginuiinstance.c @@ -40,48 +40,48 @@ slv2_ui_instantiate(SLV2Plugin plugin, const LV2_Feature* const* features) { struct _SLV2UIInstance* result = NULL; - + bool local_features = (features == NULL); if (local_features) { features = malloc(sizeof(LV2_Feature)); ((LV2_Feature**)features)[0] = NULL; } - + const char* const lib_uri = slv2_value_as_string(slv2_ui_get_binary_uri(ui)); const char* const lib_path = slv2_uri_to_path(lib_uri); - + if (!lib_path) return NULL; - + dlerror(); void* lib = dlopen(lib_path, RTLD_NOW); if (!lib) { fprintf(stderr, "Unable to open UI library %s (%s)\n", lib_path, dlerror()); return NULL; } - + LV2UI_DescriptorFunction df = dlsym(lib, "lv2ui_descriptor"); - + if (!df) { fprintf(stderr, "Could not find symbol 'lv2ui_descriptor', " "%s is not a LV2 plugin UI.\n", lib_path); dlclose(lib); return NULL; } else { - + const char* bundle_path = slv2_uri_to_path(slv2_value_as_uri(slv2_ui_get_bundle_uri(ui))); - + for (uint32_t i=0; 1; ++i) { - + const LV2UI_Descriptor* ld = df(i); - + if (!ld) { fprintf(stderr, "Did not find UI %s in %s\n", slv2_value_as_uri(slv2_ui_get_uri(ui)), lib_path); dlclose(lib); break; // return NULL } else if (!strcmp(ld->URI, slv2_value_as_uri(slv2_ui_get_uri(ui)))) { - + assert(plugin->plugin_uri); printf("Found UI %s at index %u in:\n\t%s\n\n", @@ -93,9 +93,9 @@ slv2_ui_instantiate(SLV2Plugin plugin, result = malloc(sizeof(struct _SLV2UIInstance)); struct _SLV2UIInstanceImpl* impl = malloc(sizeof(struct _SLV2UIInstanceImpl)); impl->lv2ui_descriptor = ld; - impl->lv2ui_handle = ld->instantiate(ld, + impl->lv2ui_handle = ld->instantiate(ld, slv2_value_as_uri(slv2_plugin_get_uri(plugin)), - (char*)bundle_path, + (char*)bundle_path, write_function, controller, &impl->widget, @@ -114,7 +114,7 @@ slv2_ui_instantiate(SLV2Plugin plugin, free(result); return NULL; } - + // Failed to create a widget, but still got a handle - this means that // the plugin is buggy if (result->pimpl->widget == NULL) { diff --git a/src/port.c b/src/port.c index e72aba0..6ccd0f3 100644 --- a/src/port.c +++ b/src/port.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -90,12 +90,12 @@ slv2_port_has_property(SLV2Plugin p, "<", slv2_value_as_uri(p->plugin_uri), "> lv2:port ?port ." "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\";\n", " lv2:portProperty <", slv2_value_as_uri(property), "> .\n}", NULL); - + SLV2Values results = slv2_plugin_query_variable(p, query, 0); const bool ret = (slv2_values_size(results) > 0); slv2_values_free(results); free(query); - + return ret; } @@ -113,7 +113,7 @@ slv2_port_supports_event(SLV2Plugin p, "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\";\n", " lv2ev:supportsEvent <", slv2_value_as_uri(event), "> .\n" "}", NULL); - + SLV2Results results = slv2_plugin_query_sparql(p, query); assert(librdf_query_results_is_boolean(results->rdf_results)); @@ -121,7 +121,7 @@ slv2_port_supports_event(SLV2Plugin p, free(query); slv2_results_free(results); - + return ret; } @@ -140,7 +140,7 @@ slv2_port_get_value_by_qname(SLV2Plugin p, "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\";\n\t", property, " ?value .\n" "FILTER(lang(?value) = \"\") }", NULL); - + results = slv2_plugin_query_variable(p, query, 0); free(query); @@ -154,7 +154,7 @@ slv2_port_get_value(SLV2Plugin p, SLV2Value predicate) { char* query = NULL; - + /* Hack around broken RASQAL, full URI predicates don't work :/ */ query = slv2_strjoin( "PREFIX slv2predicate: <", slv2_value_as_string(predicate), ">", @@ -165,7 +165,7 @@ slv2_port_get_value(SLV2Plugin p, "}\n", NULL); SLV2Values result = slv2_plugin_query_variable(p, query, 0); - + free(query); return result; @@ -185,9 +185,9 @@ slv2_port_get_value_by_qname_i18n(SLV2Plugin p, "<", slv2_value_as_uri(p->plugin_uri), "> lv2:port ?port .\n" "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\";\n\t", property, " ?value .\n" - "FILTER(lang(?value) = \"", slv2_get_lang(), + "FILTER(lang(?value) = \"", slv2_get_lang(), "\") }", NULL); - + results = slv2_plugin_query_variable(p, query, 0); free(query); @@ -202,7 +202,7 @@ slv2_port_get_symbol(SLV2Plugin p, return port->symbol; } - + SLV2Value slv2_port_get_name(SLV2Plugin p, SLV2Port port) @@ -217,13 +217,13 @@ slv2_port_get_name(SLV2Plugin p, if (results && slv2_values_size(results) > 0) ret = slv2_value_duplicate(slv2_values_get_at(results, 0)); } - + slv2_values_free(results); return ret; } - + SLV2Values slv2_port_get_classes(SLV2Plugin p, SLV2Port port) @@ -233,7 +233,7 @@ slv2_port_get_classes(SLV2Plugin p, void -slv2_port_get_range(SLV2Plugin p, +slv2_port_get_range(SLV2Plugin p, SLV2Port port, SLV2Value* def, SLV2Value* min, @@ -254,7 +254,7 @@ slv2_port_get_range(SLV2Plugin p, "OPTIONAL { ?port lv2:minimum ?min }\n", "OPTIONAL { ?port lv2:maximum ?max }\n", "\n}", NULL); - + SLV2Results results = slv2_plugin_query_sparql(p, query); while (!librdf_query_results_finished(results->rdf_results)) { @@ -274,7 +274,7 @@ slv2_port_get_range(SLV2Plugin p, librdf_query_results_next(results->rdf_results); } - + slv2_results_free(results); free(query); @@ -293,9 +293,9 @@ slv2_port_get_scale_points(SLV2Plugin p, "?point rdf:value ?value ;\n" " rdfs:label ?label .\n" "\n} ORDER BY ?value", NULL); - + SLV2Results results = slv2_plugin_query_sparql(p, query); - + SLV2ScalePoints ret = NULL; if (!slv2_results_finished(results)) @@ -307,10 +307,10 @@ slv2_port_get_scale_points(SLV2Plugin p, if (value && label) raptor_sequence_push(ret, slv2_scale_point_new(value, label)); - + slv2_results_next(results); } - + slv2_results_free(results); free(query); diff --git a/src/query.c b/src/query.c index 8990c9b..8655eab 100644 --- a/src/query.c +++ b/src/query.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -137,24 +137,24 @@ slv2_plugin_query_sparql(SLV2Plugin plugin, char* query_str = slv2_strjoin(slv2_query_prefixes, sparql_str, NULL); //printf("******** Query \n%s********\n", query_str); - + librdf_query* query = librdf_new_query(plugin->world->world, "sparql", NULL, (const unsigned char*)query_str, base_uri); - + if (!query) { fprintf(stderr, "ERROR: Could not create query\n"); return NULL; } - + // FIXME: locale kludges to work around librdf bug char* locale = strdup(setlocale(LC_NUMERIC, NULL)); setlocale(LC_NUMERIC, "POSIX"); librdf_query_results* results = librdf_query_execute(query, plugin->rdf); setlocale(LC_NUMERIC, locale); - + free(locale); - + librdf_free_query(query); free(query_str); @@ -225,7 +225,7 @@ slv2_plugin_query_variable(SLV2Plugin plugin, SLV2Values ret = slv2_query_get_variable_bindings(plugin->world, results, (int)variable); - + slv2_results_free(results); return ret; @@ -236,7 +236,7 @@ slv2_plugin_query_variable(SLV2Plugin plugin, * * More efficient than slv2_plugin_simple_query if you're only interested * in the number of results (ie slv2_plugin_num_ports). - * + * * Note the result of this function is probably meaningless unless the query * is a SELECT DISTINCT. */ diff --git a/src/scalepoint.c b/src/scalepoint.c index 29bedf9..8c22ce2 100644 --- a/src/scalepoint.c +++ b/src/scalepoint.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) diff --git a/src/slv2_internal.h b/src/slv2_internal.h index a6de9ad..d55c0dc 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -157,7 +157,7 @@ void slv2_world_load_path(SLV2World world, const char* search_path); - + void slv2_world_load_specifications(SLV2World world); @@ -210,7 +210,7 @@ SLV2Value slv2_value_new_librdf_node(SLV2World world, librdf_node* node); SLV2Value slv2_value_new_librdf_uri(SLV2World world, librdf_uri* uri); librdf_uri* slv2_value_as_librdf_uri(SLV2Value value); - + /* ********* Values ********* */ void slv2_values_set_at(SLV2Values list, unsigned index, void* value); diff --git a/src/util.c b/src/util.c index 71094ab..3e6afb9 100644 --- a/src/util.c +++ b/src/util.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -71,7 +71,7 @@ slv2_uri_to_path(const char* uri) } -char* +char* slv2_get_lang() { static char lang[32]; diff --git a/src/value.c b/src/value.c index ae24a68..d05ba58 100644 --- a/src/value.c +++ b/src/value.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -45,7 +45,7 @@ slv2_value_set_numerics_from_string(SLV2Value val) val->val.float_val = strtod(val->str_val, &endptr); setlocale(LC_NUMERIC, locale); } - + free(locale); } @@ -78,7 +78,7 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node) SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value)); val->type = SLV2_VALUE_STRING; val->str_val = NULL; - + librdf_uri* datatype_uri = NULL; switch (librdf_node_get_type(node)) { @@ -107,7 +107,7 @@ slv2_value_new_librdf_node(SLV2World world, librdf_node* node) val = NULL; break; } - + if (val) slv2_value_set_numerics_from_string(val); @@ -227,7 +227,7 @@ slv2_value_get_turtle_token(SLV2Value value) size_t len = 0; char* result = NULL; char* locale = strdup(setlocale(LC_NUMERIC, NULL)); - + // FIXME: locale kludges to work around librdf bug switch (value->type) { @@ -258,7 +258,7 @@ slv2_value_get_turtle_token(SLV2Value value) } free(locale); - + return result; } @@ -277,7 +277,7 @@ slv2_value_as_uri(SLV2Value value) return value->str_val; } - + /* private */ librdf_uri* slv2_value_as_librdf_uri(SLV2Value value) diff --git a/src/world.c b/src/world.c index 88a1f63..d905e52 100644 --- a/src/world.c +++ b/src/world.c @@ -1,6 +1,6 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * + * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) @@ -44,7 +44,7 @@ slv2_world_new_internal(SLV2World world) world->storage = librdf_new_storage(world->world, "hashes", NULL, "hash-type='memory'"); } - + if (!world->storage) goto fail; @@ -57,27 +57,27 @@ slv2_world_new_internal(SLV2World world) goto fail; world->plugin_classes = slv2_plugin_classes_new(); - + world->plugins = slv2_plugins_new(); - + world->lv2_specification_node = librdf_new_node_from_uri_string(world->world, (const unsigned char*)"http://lv2plug.in/ns/lv2core#Specification"); - + world->lv2_plugin_node = librdf_new_node_from_uri_string(world->world, (const unsigned char*)"http://lv2plug.in/ns/lv2core#Plugin"); - + world->rdf_a_node = librdf_new_node_from_uri_string(world->world, (const unsigned char*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); - + world->xsd_integer_node = librdf_new_node_from_uri_string(world->world, (const unsigned char*)"http://www.w3.org/2001/XMLSchema#integer"); - + world->xsd_decimal_node = librdf_new_node_from_uri_string(world->world, (const unsigned char*)"http://www.w3.org/2001/XMLSchema#decimal"); - + world->lv2_plugin_class = slv2_plugin_class_new(world, NULL, librdf_node_get_uri(world->lv2_plugin_node), "Plugin"); - + return world; fail: @@ -96,11 +96,11 @@ slv2_world_new() free(world); return NULL; } - + world->local_world = true; - + librdf_world_open(world->world); - + return slv2_world_new_internal(world); } @@ -136,24 +136,24 @@ slv2_world_free(SLV2World world) slv2_plugin_free(raptor_sequence_get_at(world->plugins, i)); raptor_free_sequence(world->plugins); world->plugins = NULL; - + raptor_free_sequence(world->plugin_classes); world->plugin_classes = NULL; - + librdf_free_parser(world->parser); world->parser = NULL; - + librdf_free_model(world->model); world->model = NULL; - + librdf_free_storage(world->storage); world->storage = NULL; - + if (world->local_world) librdf_free_world(world->world); world->world = NULL; - + free(world); } @@ -181,7 +181,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_model* manifest_model = librdf_new_model(world->world, manifest_storage, NULL); - librdf_parser_parse_into_model(world->parser, manifest_uri, NULL, + librdf_parser_parse_into_model(world->parser, manifest_uri, NULL, manifest_model); /* Query statement: ?plugin a lv2:Plugin */ @@ -198,16 +198,16 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) /* Add ?plugin rdfs:seeAlso */ librdf_node* subject = plugin_node; - librdf_node* predicate = librdf_new_node_from_uri_string(world->world, + librdf_node* predicate = librdf_new_node_from_uri_string(world->world, (unsigned char*)"http://www.w3.org/2000/01/rdf-schema#seeAlso"); librdf_node* object = librdf_new_node_from_uri(world->world, manifest_uri); librdf_model_add(world->model, subject, predicate, object); - + /* Add ?plugin slv2:bundleURI */ subject = librdf_new_node_from_node(plugin_node); - predicate = librdf_new_node_from_uri_string(world->world, + predicate = librdf_new_node_from_uri_string(world->world, (unsigned char*)"http://drobilla.net/ns/slv2#bundleURI"); object = librdf_new_node_from_uri(world->world, bundle_uri->val.uri_val); @@ -215,10 +215,10 @@ 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 */ q = librdf_new_statement_from_nodes(world->world, NULL, librdf_new_node_from_node(world->rdf_a_node), @@ -233,16 +233,16 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) /* Add ?specification rdfs:seeAlso */ librdf_node* subject = spec_node; - librdf_node* predicate = librdf_new_node_from_uri_string(world->world, + librdf_node* predicate = librdf_new_node_from_uri_string(world->world, (unsigned char*)"http://www.w3.org/2000/01/rdf-schema#seeAlso"); librdf_node* object = librdf_new_node_from_uri(world->world, manifest_uri); - + librdf_model_add(world->model, subject, predicate, object); - + /* Add ?specification slv2:bundleURI */ subject = librdf_new_node_from_node(spec_node); - predicate = librdf_new_node_from_uri_string(world->world, + predicate = librdf_new_node_from_uri_string(world->world, (unsigned char*)"http://drobilla.net/ns/slv2#bundleURI"); object = librdf_new_node_from_uri(world->world, bundle_uri->val.uri_val); @@ -250,10 +250,10 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_stream_next(results); } - + librdf_free_stream(results); librdf_free_statement(q); - + /* Join the temporary model to the main model */ librdf_stream* manifest_stream = librdf_model_as_stream(manifest_model); librdf_model_add_statements(world->model, manifest_stream); @@ -274,7 +274,7 @@ slv2_world_load_directory(SLV2World world, const char* dir) DIR* pdir = opendir(dir); if (!pdir) return; - + struct dirent* pfile; while ((pfile = readdir(pdir))) { if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, "..")) @@ -291,7 +291,7 @@ slv2_world_load_directory(SLV2World world, const char* dir) slv2_world_load_bundle(world, uri_val); slv2_value_free(uri_val); } - + free(uri); } @@ -305,19 +305,19 @@ slv2_world_load_path(SLV2World world, { char* path = slv2_strjoin(lv2_path, ":", NULL); char* dir = path; // Pointer into path - + // Go through string replacing ':' with '\0', using the substring, // then replacing it with 'X' and moving on. i.e. strtok on crack. while (strchr(path, ':') != NULL) { char* delim = strchr(path, ':'); *delim = '\0'; - + slv2_world_load_directory(world, dir); - + *delim = 'X'; dir = delim + 1; } - + free(path); } @@ -356,9 +356,9 @@ slv2_world_load_specifications(SLV2World world) " ?spec a :Specification ;\n" " rdfs:seeAlso ?data .\n" "}\n"; - + librdf_query* q = librdf_new_query(world->world, "sparql", NULL, query_string, NULL); - + librdf_query_results* results = librdf_query_execute(q, world->model); while (!librdf_query_results_finished(results)) { @@ -385,9 +385,9 @@ slv2_world_load_plugin_classes(SLV2World world) { // FIXME: This will need to be a bit more clever when more data is around // then the ontology (ie classes which aren't LV2 plugin_classes) - + // FIXME: This loads things that aren't plugin categories - + unsigned char* query_string = (unsigned char*) "PREFIX : \n" "PREFIX rdfs: \n" @@ -395,10 +395,10 @@ slv2_world_load_plugin_classes(SLV2World world) //" ?plugin a ?class .\n" " ?class a rdfs:Class; rdfs:subClassOf ?parent; rdfs:label ?label\n" "}\n"; // ORDER BY ?class\n"; - + librdf_query* q = librdf_new_query(world->world, "sparql", NULL, query_string, NULL); - + librdf_query_results* results = librdf_query_execute(q, world->model); while (!librdf_query_results_finished(results)) { @@ -425,7 +425,7 @@ slv2_world_load_plugin_classes(SLV2World world) } // FIXME: filter list here - + librdf_free_query_results(results); librdf_free_query(q); } @@ -463,7 +463,7 @@ slv2_world_load_all(SLV2World world) free(lv2_path); } - + /* 2. Query out things to cache */ slv2_world_load_specifications(world); @@ -478,10 +478,10 @@ slv2_world_load_all(SLV2World world) "SELECT DISTINCT ?plugin ?data ?bundle\n" "WHERE { ?plugin a :Plugin; slv2:bundleURI ?bundle; rdfs:seeAlso ?data }\n"; //"ORDER BY ?plugin\n"; - + librdf_query* q = librdf_new_query(world->world, "sparql", NULL, query_string, NULL); - + librdf_query_results* results = librdf_query_execute(q, world->model); while (!librdf_query_results_finished(results)) { @@ -524,7 +524,7 @@ slv2_world_load_all(SLV2World world) if (results) librdf_free_query_results(results); - + librdf_free_query(q); } @@ -535,7 +535,7 @@ slv2_world_serialize(const char* filename) { librdf_uri* lv2_uri = librdf_new_uri(slv2_rdf_world, (unsigned char*)"http://lv2plug.in/ns/lv2core#"); - + librdf_uri* rdfs_uri = librdf_new_uri(slv2_rdf_world, (unsigned char*)"http://www.w3.org/2000/01/rdf-schema#"); @@ -590,17 +590,17 @@ slv2_world_get_plugins_by_filter(SLV2World world, bool (*include)(SLV2Plugin)) SLV2Plugins slv2_world_get_plugins_by_query(SLV2World world, const char* query) { - SLV2Plugins list = slv2_plugins_new(); + SLV2Plugins list = slv2_plugins_new(); librdf_query* rq = librdf_new_query(world->world, "sparql", NULL, (const unsigned char*)query, NULL); - + librdf_query_results* results = librdf_query_execute(rq, world->model); - + while (!librdf_query_results_finished(results)) { librdf_node* plugin_node = librdf_query_results_get_binding_value(results, 0); librdf_uri* plugin_uri = librdf_node_get_uri(plugin_node); - + SLV2Plugin plugin = slv2_plugins_get_by_uri(list, (const char*)librdf_uri_as_string(plugin_uri)); @@ -609,15 +609,15 @@ slv2_world_get_plugins_by_query(SLV2World world, const char* query) SLV2Plugin new_plugin = slv2_plugin_new(world, plugin_uri); raptor_sequence_push(list, new_plugin); } - + librdf_free_node(plugin_node); - + librdf_query_results_next(results); - } - + } + if (results) librdf_free_query_results(results); - + librdf_free_query(rq); return list; -- cgit v1.2.1