summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-11-03 20:58:04 +0100
committerGravatar waker <wakeroid@gmail.com>2010-11-03 20:58:04 +0100
commitb3fdc2702ae846ae241ce306df0e0ce2f26e82af (patch)
treef63ec6aa2fa88b4ed4bba06dea3a98e68da91d0a /tools
parent9c8a436caa2a80830433bf1afa2ce75efe6d62de (diff)
added pluginfo tool useful for scripting
Diffstat (limited to 'tools')
-rw-r--r--tools/pluginfo/Makefile9
-rw-r--r--tools/pluginfo/pluginfo.c77
2 files changed, 86 insertions, 0 deletions
diff --git a/tools/pluginfo/Makefile b/tools/pluginfo/Makefile
new file mode 100644
index 00000000..108e47e7
--- /dev/null
+++ b/tools/pluginfo/Makefile
@@ -0,0 +1,9 @@
+#CC=../apbuild/apgcc
+CC=gcc
+CFLAGS=-Wall
+LDFLAGS=-lpthread -ldl -lm
+
+pluginfo: pluginfo.o
+
+clean:
+ rm *.o pluginfo
diff --git a/tools/pluginfo/pluginfo.c b/tools/pluginfo/pluginfo.c
new file mode 100644
index 00000000..db3f096d
--- /dev/null
+++ b/tools/pluginfo/pluginfo.c
@@ -0,0 +1,77 @@
+/*
+ DeaDBeeF - ultimate music player for GNU/Linux systems with X11
+ Copyright (C) 2009-2010 Alexey Yakovenko <waker@users.sourceforge.net>
+
+ This program 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 program 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include "../../deadbeef.h"
+
+int
+main (int argc, char *argv[]) {
+ char d_name[256];
+ void *handle;
+ size_t l;
+
+ if (argc <= 1) {
+ fprintf (stderr, "usage: pluginfo plugin.so\n");
+ exit (-1);
+ }
+ char *slash = strrchr (argv[1], '/');
+ if (!slash) {
+ slash = argv[1];
+ }
+ else {
+ slash++;
+ }
+ l = strlen (slash);
+ if (l < 3 || strcasecmp (&slash[l-3], ".so")) {
+ fprintf (stderr, "pluginfo: invalid fname %s\n", argv[1]);
+ exit (-1);
+ }
+
+ strcpy (d_name, slash);
+
+ handle = dlopen (argv[1], RTLD_NOW);
+ if (!handle) {
+ fprintf (stderr, "dlopen error: %s\n", dlerror ());
+ exit (-1);
+ }
+ d_name[l-3] = 0;
+ strcat (d_name, "_load");
+ DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name);
+ if (!plug_load) {
+ fprintf (stderr, "pluginfo: dlsym error: %s\n", dlerror ());
+ dlclose (handle);
+ exit (-1);
+ }
+
+ DB_plugin_t *plug = plug_load ((DB_functions_t *)0xdeadbeef);
+ printf ("type=\"%d\"\n", plug->type);
+ printf ("api_version=\"%d.%d\"\n", plug->api_vmajor, plug->api_vminor);
+ printf ("version=\"%d.%d\"\n", plug->version_major, plug->version_minor);
+ printf ("id=\"%s\"\n", plug->id);
+ printf ("name=\"%s\"\n", plug->name);
+ printf ("descr=\"%s\"\n", plug->descr);
+ printf ("author=\"%s\"\n", plug->author);
+ printf ("email=\"%s\"\n", plug->email);
+ printf ("website=\"%s\"\n", plug->website);
+
+ dlclose (handle);
+ return 0;
+}