From b3fdc2702ae846ae241ce306df0e0ce2f26e82af Mon Sep 17 00:00:00 2001 From: waker Date: Wed, 3 Nov 2010 20:58:04 +0100 Subject: added pluginfo tool useful for scripting --- tools/pluginfo/Makefile | 9 ++++++ tools/pluginfo/pluginfo.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tools/pluginfo/Makefile create mode 100644 tools/pluginfo/pluginfo.c (limited to 'tools') 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 + + 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 +#include +#include +#include +#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; +} -- cgit v1.2.3