summaryrefslogtreecommitdiffstats
path: root/utils/lv2ls.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-29 18:48:45 +0000
committerDavid Robillard <d@drobilla.net>2011-04-29 18:48:45 +0000
commit9839d7e46892d695bbfdf0ddcf2fcb616e41b1ec (patch)
treed502826e4fb60c78aa25889d029aa674f57f13d8 /utils/lv2ls.c
parent1e7b27c7b322476c437a8524cff4a88245c5efbf (diff)
downloadlilv-9839d7e46892d695bbfdf0ddcf2fcb616e41b1ec.tar.gz
lilv-9839d7e46892d695bbfdf0ddcf2fcb616e41b1ec.tar.bz2
lilv-9839d7e46892d695bbfdf0ddcf2fcb616e41b1ec.zip
Rename command line utilities to avoid clashing with slv2.
Fix indentation. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3235 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'utils/lv2ls.c')
-rw-r--r--utils/lv2ls.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/utils/lv2ls.c b/utils/lv2ls.c
new file mode 100644
index 0000000..c8db8aa
--- /dev/null
+++ b/utils/lv2ls.c
@@ -0,0 +1,94 @@
+/*
+ Copyright 2007-2011 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "lilv/lilv.h"
+
+#include "lilv-config.h"
+
+void
+list_plugins(const LilvPlugins* list, bool show_names)
+{
+ LILV_FOREACH(plugins, i, list) {
+ const LilvPlugin* p = lilv_plugins_get(list, i);
+ if (show_names) {
+ LilvNode* n = lilv_plugin_get_name(p);
+ printf("%s\n", lilv_node_as_string(n));
+ lilv_node_free(n);
+ } else {
+ printf("%s\n", lilv_node_as_uri(lilv_plugin_get_uri(p)));
+ }
+ }
+}
+
+void
+print_version()
+{
+ printf(
+ "lv2_list (lilv) " LILV_VERSION "\n"
+ "Copyright 2007-2011 David Robillard <http://drobilla.net>\n"
+ "License: <http://www.opensource.org/licenses/isc-license>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n");
+}
+
+void
+print_usage()
+{
+ printf("Usage: lv2_list [OPTIONS]\n");
+ printf("List all installed LV2 plugins.\n");
+ printf("\n");
+ printf(" -n, --names Show names instead of URIs\n");
+ printf(" --help Display this help and exit\n");
+ printf(" --version Output version information and exit\n");
+ printf("\n");
+ printf("The environment variable LV2_PATH can be used to control where\n");
+ printf("this (and all other lilv based LV2 hosts) will search for plugins.\n");
+}
+
+int
+main(int argc, char** argv)
+{
+ bool show_names = false;
+ for (int i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--names") || !strcmp(argv[i], "-n")) {
+ show_names = true;
+ } else if (!strcmp(argv[i], "--version")) {
+ print_version();
+ return 0;
+ } else if (!strcmp(argv[i], "--help")) {
+ print_usage();
+ return 0;
+ } else {
+ print_usage();
+ return 1;
+ }
+ }
+
+ LilvWorld* world = lilv_world_new();
+ lilv_world_load_all(world);
+
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+
+ list_plugins(plugins, show_names);
+
+ lilv_world_free(world);
+
+ return 0;
+}