From f340d22e82760166d24a037d8466501217b06a3e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 18 Feb 2007 20:08:45 +0000 Subject: API updates (removed SLV2Value (binary compatibility nightmare waiting to happen) and added consistent SLV2Plugins and SLV2Strings). Documentation cleanups. git-svn-id: http://svn.drobilla.net/lad/slv2@314 a436a847-0d15-0410-975c-d299462d15a1 --- src/Makefile.am | 2 +- src/plugin.c | 71 ++++++++++++++++++++++++++----------------------------- src/pluginlist.c | 39 +++++++++++++++--------------- src/port.c | 72 ++++++++++++++++++++++++++------------------------------ src/query.c | 64 ++++++++++++++++++++++++++----------------------- src/stringlist.c | 54 ++++++++++++++++++++++++++++++++++++++++++ src/types.c | 54 ------------------------------------------ 7 files changed, 177 insertions(+), 179 deletions(-) create mode 100644 src/stringlist.c delete mode 100644 src/types.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 5ad71df..43aa62a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,4 +13,4 @@ libslv2_la_SOURCES = \ util.c \ plugininstance.c \ library.c \ - types.c + stringlist.c diff --git a/src/plugin.c b/src/plugin.c index 30e737a..703b2a3 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -27,6 +27,7 @@ #include #include #include +#include SLV2Plugin* @@ -38,9 +39,9 @@ slv2_plugin_duplicate(const SLV2Plugin* p) result->bundle_url = p->bundle_url; result->lib_uri = p->lib_uri; - result->data_uris = slv2_uri_list_new(); - for (int i=0; i < slv2_uri_list_size(p->data_uris); ++i) - raptor_sequence_push(result->data_uris, strdup(slv2_uri_list_get_at(p->data_uris, i))); + result->data_uris = slv2_strings_new(); + for (int i=0; i < slv2_strings_size(p->data_uris); ++i) + raptor_sequence_push(result->data_uris, strdup(slv2_strings_get_at(p->data_uris, i))); return result; } @@ -53,7 +54,7 @@ slv2_plugin_get_uri(const SLV2Plugin* p) } -SLV2URIList +SLV2Strings slv2_plugin_get_data_uris(const SLV2Plugin* p) { assert(p); @@ -76,10 +77,10 @@ slv2_plugin_verify(const SLV2Plugin* plugin) size_t num_values = 0; - struct _Value* prop = slv2_plugin_get_value(plugin, "doap:name"); + SLV2Strings prop = slv2_plugin_get_value(plugin, "doap:name"); if (prop) { - num_values = prop->num_values; - free(prop); + num_values = slv2_strings_size(prop); + slv2_strings_free(prop); } if (num_values < 1) return false; @@ -97,19 +98,21 @@ slv2_plugin_verify(const SLV2Plugin* plugin) char* slv2_plugin_get_name(const SLV2Plugin* plugin) { -// FIXME: leak - char* result = NULL; - struct _Value* prop = slv2_plugin_get_value(plugin, "doap:name"); + char* result = NULL; + SLV2Strings prop = slv2_plugin_get_value(plugin, "doap:name"); // FIXME: guaranteed to be the untagged one? - if (prop && prop->num_values >= 1) - result = prop->values[0]; + if (prop && slv2_strings_size(prop) >= 1) + result = strdup(slv2_strings_get_at(prop, 0)); + + if (prop) + slv2_strings_free(prop); return result; } -SLV2Value +SLV2Strings slv2_plugin_get_value(const SLV2Plugin* p, const char* predicate) { @@ -134,7 +137,7 @@ slv2_plugin_get_value(const SLV2Plugin* p, "plugin: ", predicate, " ?value .\n" "}\n", NULL); - SLV2Value result = slv2_plugin_simple_query(p, query, "value"); + SLV2Strings result = slv2_plugin_simple_query(p, query, "value"); free(query); @@ -142,14 +145,14 @@ slv2_plugin_get_value(const SLV2Plugin* p, } -SLV2Value +SLV2Strings slv2_plugin_get_properties(const SLV2Plugin* p) { return slv2_plugin_get_value(p, "lv2:pluginProperty"); } -SLV2Value +SLV2Strings slv2_plugin_get_hints(const SLV2Plugin* p) { return slv2_plugin_get_value(p, "lv2:pluginHint"); @@ -160,16 +163,10 @@ uint32_t slv2_plugin_get_num_ports(const SLV2Plugin* p) { const char* const query = - "SELECT DISTINCT ?value\n" - "WHERE { plugin: lv2:port ?value }\n"; - - SLV2Value results = slv2_plugin_simple_query(p, query, "value"); - - size_t count = results->num_values; - - slv2_value_free(results); + "SELECT DISTINCT ?port\n" + "WHERE { plugin: lv2:port ?port }\n"; - return count; + return (uint32_t)slv2_plugin_query_count(p, query); } @@ -182,11 +179,11 @@ slv2_plugin_has_latency(const SLV2Plugin* p) " ?port lv2:portHint lv2:reportsLatency .\n" "}\n"; - SLV2Value results = slv2_plugin_simple_query(p, query, "port"); + SLV2Strings results = slv2_plugin_simple_query(p, query, "port"); - bool exists = (results->num_values > 0); + bool exists = (slv2_strings_size(results) > 0); - slv2_value_free(results); + slv2_strings_free(results); return exists; } @@ -202,19 +199,19 @@ slv2_plugin_get_latency_port(const SLV2Plugin* p) " lv2:index ?index .\n" "}\n"; - SLV2Value result = slv2_plugin_simple_query(p, query, "index"); + SLV2Strings result = slv2_plugin_simple_query(p, query, "index"); // FIXME: need a sane error handling strategy - assert(result->num_values == 1); + assert(slv2_strings_size(result) == 1); char* endptr = 0; - uint32_t index = strtol(result->values[0], &endptr, 10); + uint32_t index = strtol(slv2_strings_get_at(result, 0), &endptr, 10); // FIXME: check.. stuff.. return index; } -SLV2Value +SLV2Strings slv2_plugin_get_supported_features(const SLV2Plugin* p) { const char* const query = @@ -224,13 +221,13 @@ slv2_plugin_get_supported_features(const SLV2Plugin* p) " { plugin: lv2:requiredHostFeature ?feature }\n" "}\n"; - SLV2Value result = slv2_plugin_simple_query(p, query, "feature"); + SLV2Strings result = slv2_plugin_simple_query(p, query, "feature"); return result; } -SLV2Value +SLV2Strings slv2_plugin_get_optional_features(const SLV2Plugin* p) { const char* const query = @@ -238,13 +235,13 @@ slv2_plugin_get_optional_features(const SLV2Plugin* p) " plugin: lv2:optionalHostFeature ?feature .\n" "}\n"; - SLV2Value result = slv2_plugin_simple_query(p, query, "feature"); + SLV2Strings result = slv2_plugin_simple_query(p, query, "feature"); return result; } -SLV2Value +SLV2Strings slv2_plugin_get_required_features(const SLV2Plugin* p) { const char* const query = @@ -252,7 +249,7 @@ slv2_plugin_get_required_features(const SLV2Plugin* p) " plugin: lv2:requiredHostFeature ?feature .\n" "}\n"; - SLV2Value result = slv2_plugin_simple_query(p, query, "feature"); + SLV2Strings result = slv2_plugin_simple_query(p, query, "feature"); return result; } diff --git a/src/pluginlist.c b/src/pluginlist.c index d9bbe7b..1c28f01 100644 --- a/src/pluginlist.c +++ b/src/pluginlist.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -40,14 +41,14 @@ slv2_plugin_new() result->bundle_url = NULL; result->lib_uri = NULL; - result->data_uris = slv2_uri_list_new(); + result->data_uris = slv2_strings_new(); return result; } struct _PluginList* -slv2_list_new() +slv2_plugins_new() { struct _PluginList* result = malloc(sizeof(struct _PluginList)); result->num_plugins = 0; @@ -57,7 +58,7 @@ slv2_list_new() void -slv2_list_free(SLV2List list) +slv2_plugins_free(SLV2Plugins list) { list->num_plugins = 0; free(list->plugins); @@ -66,14 +67,14 @@ slv2_list_free(SLV2List list) void -slv2_list_load_all(SLV2List list) +slv2_plugins_load_all(SLV2Plugins list) { assert(list != NULL); char* slv2_path = getenv("LV2_PATH"); if (slv2_path) { - slv2_list_load_path(list, slv2_path); + slv2_plugins_load_path(list, slv2_path); } else { const char* const home = getenv("HOME"); const char* const suffix = "/.lv2:/usr/local/lib/lv2:usr/lib/lv2"; @@ -82,10 +83,10 @@ slv2_list_load_all(SLV2List list) fprintf(stderr, "$LV2_PATH is unset. Using default path %s\n", slv2_path); /* pass 1: find all plugins */ - slv2_list_load_path(list, slv2_path); + slv2_plugins_load_path(list, slv2_path); /* pass 2: find all data files for plugins */ - slv2_list_load_path(list, slv2_path); + slv2_plugins_load_path(list, slv2_path); free(slv2_path); } @@ -96,7 +97,7 @@ slv2_list_load_all(SLV2List list) * This is called twice on each bundle in the discovery process, which is (much) less * efficient than it could be.... */ void -slv2_list_load_bundle(SLV2List list, +slv2_plugins_load_bundle(SLV2Plugins list, const char* bundle_base_url) { unsigned char* manifest_url = malloc( @@ -127,7 +128,7 @@ slv2_list_load_bundle(SLV2List list, rasqal_literal* literal = rasqal_query_results_get_binding_value(results, 0); assert(literal); - if (!slv2_list_get_plugin_by_uri(list, (const char*)rasqal_literal_as_string(literal))) { + if (!slv2_plugins_get_by_uri(list, (const char*)rasqal_literal_as_string(literal))) { /* Create a new plugin */ struct _Plugin* new_plugin = slv2_plugin_new(); new_plugin->plugin_uri = strdup((const char*)rasqal_literal_as_string(literal)); @@ -178,13 +179,13 @@ slv2_list_load_bundle(SLV2List list, const char* binary = (const char*)rasqal_literal_as_string( rasqal_query_results_get_binding_value(results, 2)); - struct _Plugin* plugin = slv2_list_get_plugin_by_uri(list, subject); + SLV2Plugin* plugin = slv2_plugins_get_by_uri(list, subject); - if (plugin && data_uri && !slv2_uri_list_contains(plugin->data_uris, data_uri)) + if (plugin && data_uri && !slv2_strings_contains(plugin->data_uris, data_uri)) raptor_sequence_push(plugin->data_uris, strdup(data_uri)); if (plugin && binary && !plugin->lib_uri) - plugin->lib_uri = strdup(binary); + ((struct _Plugin*)plugin)->lib_uri = strdup(binary); rasqal_query_results_next(results); @@ -205,7 +206,7 @@ slv2_list_load_bundle(SLV2List list, * (Private helper function, not exposed in public API) */ void -slv2_list_load_dir(SLV2List list, const char* dir) +slv2_plugins_load_dir(SLV2Plugins list, const char* dir) { DIR* pdir = opendir(dir); if (!pdir) @@ -223,7 +224,7 @@ slv2_list_load_dir(SLV2List list, const char* dir) if (bundle_dir != NULL) { closedir(bundle_dir); - slv2_list_load_bundle(list, bundle_url); + slv2_plugins_load_bundle(list, bundle_url); //printf("Loaded bundle %s\n", bundle_url); } @@ -235,7 +236,7 @@ slv2_list_load_dir(SLV2List list, const char* dir) void -slv2_list_load_path(SLV2List list, +slv2_plugins_load_path(SLV2Plugins list, const char* lv2_path) { char* path = slv2_strjoin(lv2_path, ":", NULL); @@ -248,7 +249,7 @@ slv2_list_load_path(SLV2List list, char* delim = strchr(path, ':'); *delim = '\0'; - slv2_list_load_dir(list, dir); + slv2_plugins_load_dir(list, dir); *delim = 'X'; dir = delim + 1; @@ -261,7 +262,7 @@ slv2_list_load_path(SLV2List list, size_t -slv2_list_get_length(const SLV2List list) +slv2_plugins_size(const SLV2Plugins list) { assert(list != NULL); return list->num_plugins; @@ -269,7 +270,7 @@ slv2_list_get_length(const SLV2List list) SLV2Plugin* -slv2_list_get_plugin_by_uri(const SLV2List list, const char* uri) +slv2_plugins_get_by_uri(const SLV2Plugins list, const char* uri) { if (list->num_plugins > 0) { assert(list->plugins != NULL); @@ -284,7 +285,7 @@ slv2_list_get_plugin_by_uri(const SLV2List list, const char* uri) SLV2Plugin* -slv2_list_get_plugin_by_index(const SLV2List list, size_t index) +slv2_plugins_get_at(const SLV2Plugins list, size_t index) { if (list->num_plugins == 0) return NULL; diff --git a/src/port.c b/src/port.c index b92e12b..478a070 100644 --- a/src/port.c +++ b/src/port.c @@ -53,26 +53,24 @@ SLV2PortClass slv2_port_get_class(SLV2Plugin* p, SLV2PortID id) { - struct _Value* class = slv2_port_get_value(p, id, "rdf:type"); - assert(class); - assert(class->num_values > 0); - assert(class->values); + SLV2Strings class = slv2_port_get_value(p, id, "rdf:type"); SLV2PortClass ret = SLV2_UNKNOWN_PORT_CLASS; int io = -1; // 0 = in, 1 = out enum { UNKNOWN, AUDIO, CONTROL, MIDI } type = UNKNOWN; - for (size_t i=0; i < class->num_values; ++i) { - if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#InputPort")) + for (int i=0; i < slv2_strings_size(class); ++i) { + char* value = slv2_strings_get_at(class, i); + if (!strcmp(value, "http://lv2plug.in/ontology#InputPort")) io = 0; - else if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#OutputPort")) + else if (!strcmp(value, "http://lv2plug.in/ontology#OutputPort")) io = 1; - else if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#ControlPort")) + else if (!strcmp(value, "http://lv2plug.in/ontology#ControlPort")) type = CONTROL; - else if (!strcmp((char*)class->values[i], "http://lv2plug.in/ontology#AudioPort")) + else if (!strcmp(value, "http://lv2plug.in/ontology#AudioPort")) type = AUDIO; - else if (!strcmp((char*)class->values[i], "http://ll-plugins.nongnu.org/lv2/ext/MidiPort")) + else if (!strcmp(value, "http://ll-plugins.nongnu.org/lv2/ext/MidiPort")) type = MIDI; } @@ -92,20 +90,20 @@ slv2_port_get_class(SLV2Plugin* p, ret = SLV2_MIDI_OUTPUT; } - slv2_value_free(class); + slv2_strings_free(class); return ret; } -SLV2Value +SLV2Strings slv2_port_get_value(SLV2Plugin* p, SLV2PortID id, const char* property) { assert(property); - SLV2Value result = NULL; + SLV2Strings result = NULL; if (id.is_index) { char index_str[16]; @@ -143,15 +141,13 @@ slv2_port_get_symbol(SLV2Plugin* p, { char* result = NULL; - SLV2Value prop + SLV2Strings prop = slv2_port_get_value(p, id, "lv2:symbol"); - if (prop && prop->num_values == 1) { - result = prop->values[0]; - prop->values[0] = NULL; // prevent deletion - } + if (prop && slv2_strings_size(prop) == 1) + result = strdup(slv2_strings_get_at(prop, 0)); - slv2_value_free(prop); + slv2_strings_free(prop); return result; } @@ -163,15 +159,13 @@ slv2_port_get_name(SLV2Plugin* p, { char* result = NULL; - SLV2Value prop + SLV2Strings prop = slv2_port_get_value(p, id, "lv2:name"); - if (prop && prop->num_values == 1) { - result = prop->values[0]; - prop->values[0] = NULL; // prevent deletion - } + if (prop && slv2_strings_size(prop) == 1) + result = strdup(slv2_strings_get_at(prop, 0)); - slv2_value_free(prop); + slv2_strings_free(prop); return result; } @@ -185,13 +179,13 @@ slv2_port_get_default_value(SLV2Plugin* p, float result = 0.0f; - SLV2Value prop + SLV2Strings prop = slv2_port_get_value(p, id, "lv2:default"); - if (prop && prop->num_values == 1) - result = atof((char*)prop->values[0]); + if (prop && slv2_strings_size(prop) == 1) + result = atof(slv2_strings_get_at(prop, 0)); - slv2_value_free(prop); + slv2_strings_free(prop); return result; } @@ -205,13 +199,13 @@ slv2_port_get_minimum_value(SLV2Plugin* p, float result = 0.0f; - SLV2Value prop + SLV2Strings prop = slv2_port_get_value(p, id, "lv2:minimum"); - if (prop && prop->num_values == 1) - result = atof((char*)prop->values[0]); + if (prop && slv2_strings_size(prop) == 1) + result = atof(slv2_strings_get_at(prop, 0)); - slv2_value_free(prop); + slv2_strings_free(prop); return result; } @@ -225,19 +219,19 @@ slv2_port_get_maximum_value(SLV2Plugin* p, float result = 0.0f; - SLV2Value prop + SLV2Strings prop = slv2_port_get_value(p, id, "lv2:maximum"); - if (prop && prop->num_values == 1) - result = atof((char*)prop->values[0]); + if (prop && slv2_strings_size(prop) == 1) + result = atof(slv2_strings_get_at(prop, 0)); - slv2_value_free(prop); + slv2_strings_free(prop); return result; } -SLV2Value +SLV2Strings slv2_port_get_properties(const SLV2Plugin* p, SLV2PortID id) { @@ -245,7 +239,7 @@ slv2_port_get_properties(const SLV2Plugin* p, } -SLV2Value +SLV2Strings slv2_port_get_hints(const SLV2Plugin* p, SLV2PortID id) { diff --git a/src/query.c b/src/query.c index 0d44533..311ef50 100644 --- a/src/query.c +++ b/src/query.c @@ -23,13 +23,14 @@ #include #include #include +#include char* slv2_query_header(const SLV2Plugin* p) { const char* const plugin_uri = slv2_plugin_get_uri(p); - //SLV2URIList files = slv2_plugin_get_data_uris(p); + //SLV2Strings files = slv2_plugin_get_data_uris(p); char* query_string = slv2_strjoin( "PREFIX rdf: \n" @@ -38,8 +39,8 @@ slv2_query_header(const SLV2Plugin* p) "PREFIX lv2: \n" "PREFIX plugin: <", plugin_uri, ">\n", NULL); - /*for (int i=0; i < slv2_uri_list_size(files); ++i) { - const char* file_uri = slv2_uri_list_get_at(files, i); + /*for (int i=0; i < slv2_strings_size(files); ++i) { + const char* file_uri = slv2_strings_get_at(files, i); slv2_strappend(&query_string, "PREFIX data: <"); slv2_strappend(&query_string, file_uri); slv2_strappend(&query_string, ">\n"); @@ -68,17 +69,14 @@ slv2_query_lang_filter(const char* variable) } -SLV2Value +SLV2Strings slv2_query_get_variable_bindings(rasqal_query_results* results, const char* variable) { - struct _Value* result = NULL; + SLV2Strings result = NULL; - if (rasqal_query_results_get_bindings_count(results) > 0) { - result = malloc(sizeof(struct _Value)); - result->num_values = 0; - result->values = NULL; - } + if (rasqal_query_results_get_bindings_count(results) > 0) + result = slv2_strings_new(); while (!rasqal_query_results_finished(results)) { @@ -86,12 +84,7 @@ slv2_query_get_variable_bindings(rasqal_query_results* results, rasqal_query_results_get_binding_value_by_name(results, (const unsigned char*)variable); assert(literal != NULL); - // Add value on to the array, reallocing all the way. - // Yes, this is disgusting. Roughly as disgusting as the rasqal query - // results API. coincidentally. - result->num_values++; - result->values = realloc(result->values, result->num_values * sizeof(char*)); - result->values[result->num_values-1] = strdup((const char*)rasqal_literal_as_string(literal)); + raptor_sequence_push(result, strdup((const char*)rasqal_literal_as_string(literal))); rasqal_query_results_next(results); } @@ -101,7 +94,7 @@ slv2_query_get_variable_bindings(rasqal_query_results* results, size_t -slv2_query_count_variable_bindings(rasqal_query_results* results) +slv2_query_count_bindings(rasqal_query_results* results) { size_t count = 0; @@ -134,8 +127,8 @@ slv2_plugin_query(SLV2Plugin* plugin, NULL, RASQAL_DATA_GRAPH_BACKGROUND); // Add all plugin data files to query sources - for (int i=0; i < slv2_uri_list_size(plugin->data_uris); ++i) { - const char* file_uri_str = slv2_uri_list_get_at(plugin->data_uris, i); + for (int i=0; i < slv2_strings_size(plugin->data_uris); ++i) { + const char* file_uri_str = slv2_strings_get_at(plugin->data_uris, i); raptor_uri* file_uri = raptor_new_uri((const unsigned char*)file_uri_str); rasqal_query_add_data_graph(rq, file_uri, NULL, RASQAL_DATA_GRAPH_BACKGROUND); @@ -151,7 +144,7 @@ slv2_plugin_query(SLV2Plugin* plugin, return results; /* - SLV2Value ret = slv2_query_get_variable_bindings(results, var_name); + SLV2Strings ret = slv2_query_get_variable_bindings(results, var_name); rasqal_free_query_results(results); rasqal_free_query(rq); @@ -161,13 +154,30 @@ slv2_plugin_query(SLV2Plugin* plugin, /** Query a single variable */ -SLV2Value +SLV2Strings slv2_plugin_simple_query(SLV2Plugin* plugin, const char* sparql_str, const char* variable) { rasqal_query_results* results = slv2_plugin_query(plugin, sparql_str); - SLV2Value ret = slv2_query_get_variable_bindings(results, variable); + SLV2Strings ret = slv2_query_get_variable_bindings(results, variable); + rasqal_free_query_results(results); + + return ret; +} + + +/** Run a query and count number of matches. + * + * More efficient than slv2_plugin_simple_query if you're only interested + * in the number of results (ie slv2_plugin_num_ports). + */ +unsigned +slv2_plugin_query_count(SLV2Plugin* plugin, + const char* sparql_str) +{ + rasqal_query_results* results = slv2_plugin_query(plugin, sparql_str); + unsigned ret = slv2_query_count_bindings(results); rasqal_free_query_results(results); return ret; @@ -198,7 +208,7 @@ slv2_query_count_results(const SLV2Plugin* p, rasqal_query_results* results = rasqal_query_execute(rq); assert(results); - size_t count = slv2_query_count_variable_bindings(results); + size_t count = slv2_query_count_bindings(results); rasqal_free_query_results(results); rasqal_free_query(rq); @@ -230,12 +240,8 @@ slv2_query_get_num_results(rasqal_query_results* results, const char* var_name) */ void -slv2_value_free(struct _Value* prop) +slv2_strings_free(SLV2Strings list) { - for (size_t i=0; i < prop->num_values; ++i) - free(prop->values[i]); - - free(prop->values); - free(prop); + raptor_free_sequence(list); } diff --git a/src/stringlist.c b/src/stringlist.c new file mode 100644 index 0000000..04f2de7 --- /dev/null +++ b/src/stringlist.c @@ -0,0 +1,54 @@ +/* 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) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include + + +SLV2Strings +slv2_strings_new() +{ + return raptor_new_sequence(&free, NULL); +} + + +int +slv2_strings_size(const SLV2Strings list) +{ + return raptor_sequence_size(list); +} + + +char* +slv2_strings_get_at(const SLV2Strings list, int index) +{ + return (char*)raptor_sequence_get_at(list, index); +} + + +bool +slv2_strings_contains(const SLV2Strings list, const char* uri) +{ + for (int i=0; i < slv2_strings_size(list); ++i) + if (!strcmp(slv2_strings_get_at(list, i), uri)) + return true; + + return false; +} diff --git a/src/types.c b/src/types.c deleted file mode 100644 index 76521c0..0000000 --- a/src/types.c +++ /dev/null @@ -1,54 +0,0 @@ -/* 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) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - - -SLV2URIList -slv2_uri_list_new() -{ - return raptor_new_sequence(&free, NULL); -} - - -int -slv2_uri_list_size(const SLV2URIList list) -{ - return raptor_sequence_size(list); -} - - -char* -slv2_uri_list_get_at(const SLV2URIList list, int index) -{ - return (char*)raptor_sequence_get_at(list, index); -} - - -bool -slv2_uri_list_contains(const SLV2URIList list, const char* uri) -{ - for (int i=0; i < slv2_uri_list_size(list); ++i) - if (!strcmp(slv2_uri_list_get_at(list, i), uri)) - return true; - - return false; -} -- cgit v1.2.1