Search
lxdream.org :: lxdream :: r1027:4e527bc96109
lxdream 0.9.1
released Jun 29
Download Now
changeset1027:4e527bc96109
parent1026:a0aa3c503103
child1028:f99eeaf084c2
authornkeynes
dateSat Jun 13 07:12:51 2009 +0000 (11 years ago)
Load plugins from the directory containing the executable first if they're there -
simplifies development testing.
Add dummy plugin for easy identification of the plugin directory
src/Makefile.am
src/Makefile.in
src/drivers/dummy.c
src/main.c
src/plugin.c
src/plugin.h
1.1 --- a/src/Makefile.am Sat Jun 13 07:04:24 2009 +0000
1.2 +++ b/src/Makefile.am Sat Jun 13 07:12:51 2009 +0000
1.3 @@ -16,7 +16,7 @@
1.4 check_PROGRAMS = test/testxlt
1.5
1.6 pkglib_PROGRAMS=
1.7 -EXTRA_DIST=drivers/genkeymap.pl checkver.pl
1.8 +EXTRA_DIST=drivers/genkeymap.pl checkver.pl drivers/dummy.c
1.9 AM_CFLAGS = -D__EXTENSIONS__ -D_BSD_SOURCE -D_GNU_SOURCE
1.10
1.11 .PHONY: checkversion
1.12 @@ -30,7 +30,8 @@
1.13 pvr2/gl_slsrc.c drivers/mac_keymap.h version.c
1.14 CLEANFILES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c sh4/sh4stat.c \
1.15 pvr2/gl_slsrc.c drivers/mac_keymap.h version.c \
1.16 - audio_alsa.lo audio_sdl.lo audio_esd.lo audio_pulse.lo input_lirc.lo
1.17 + audio_alsa.lo audio_sdl.lo audio_esd.lo audio_pulse.lo input_lirc.lo \
1.18 + lxdream_dummy.lo
1.19
1.20 #all-am: checkversion
1.21
1.22 @@ -129,6 +130,14 @@
1.23 endif
1.24
1.25 if BUILD_SHARED
1.26 +
1.27 +pkglib_PROGRAMS += lxdream_dummy.@SOEXT@
1.28 +lxdream_dummy_@SOEXT@_SOURCES =
1.29 +lxdream_dummy_@SOEXT@_LDADD = lxdream_dummy.lo @SDL_LIBS@
1.30 +lxdream_dummy_@SOEXT@_LDFLAGS = $(PLUGINLDFLAGS)
1.31 +lxdream_dummy.lo: drivers/dummy.c
1.32 + $(COMPILE) -DPLUGIN $(PLUGINCFLAGS) -c $< -o $@
1.33 +
1.34 if AUDIO_SDL
1.35 pkglib_PROGRAMS += audio_sdl.@SOEXT@
1.36 audio_sdl_@SOEXT@_SOURCES =
2.1 --- a/src/Makefile.in Sat Jun 13 07:04:24 2009 +0000
2.2 +++ b/src/Makefile.in Sat Jun 13 07:12:51 2009 +0000
2.3 @@ -40,7 +40,7 @@
2.4 noinst_PROGRAMS = gendec$(EXEEXT) genglsl$(EXEEXT)
2.5 check_PROGRAMS = test/testxlt$(EXEEXT) $(am__EXEEXT_1)
2.6 pkglib_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4) \
2.7 - $(am__EXEEXT_5) $(am__EXEEXT_6)
2.8 + $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7)
2.9 @BUILD_SHARED_TRUE@am__append_1 = plugin.c plugin.h
2.10 @BUILD_SH4X86_TRUE@am__append_2 = sh4/sh4x86.c xlat/x86/x86op.h \
2.11 @BUILD_SH4X86_TRUE@ xlat/x86/ia32abi.h xlat/x86/amd64abi.h \
2.12 @@ -68,25 +68,26 @@
2.13 @VIDEO_GLX_TRUE@am__append_8 = drivers/video_glx.c drivers/video_glx.h
2.14 @VIDEO_NSGL_TRUE@am__append_9 = drivers/video_nsgl.m drivers/video_nsgl.h
2.15 @AUDIO_OSX_TRUE@am__append_10 = drivers/audio_osx.m
2.16 -@AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@am__append_11 = audio_sdl.@SOEXT@
2.17 -@AUDIO_PULSE_TRUE@@BUILD_SHARED_TRUE@am__append_12 = audio_pulse.@SOEXT@
2.18 -@AUDIO_ESOUND_TRUE@@BUILD_SHARED_TRUE@am__append_13 = audio_esd.@SOEXT@
2.19 -@AUDIO_ALSA_TRUE@@BUILD_SHARED_TRUE@am__append_14 = audio_alsa.@SOEXT@
2.20 -@BUILD_SHARED_TRUE@@INPUT_LIRC_TRUE@am__append_15 = input_lirc.@SOEXT@
2.21 -@AUDIO_SDL_TRUE@@BUILD_SHARED_FALSE@am__append_16 = drivers/audio_sdl.c
2.22 -@AUDIO_SDL_TRUE@@BUILD_SHARED_FALSE@am__append_17 = @SDL_LIBS@
2.23 -@AUDIO_PULSE_TRUE@@BUILD_SHARED_FALSE@am__append_18 = drivers/audio_pulse.c
2.24 -@AUDIO_PULSE_TRUE@@BUILD_SHARED_FALSE@am__append_19 = @PULSE_LIBS@
2.25 -@AUDIO_ESOUND_TRUE@@BUILD_SHARED_FALSE@am__append_20 = drivers/audio_esd.c
2.26 -@AUDIO_ESOUND_TRUE@@BUILD_SHARED_FALSE@am__append_21 = @ESOUND_LIBS@
2.27 -@AUDIO_ALSA_TRUE@@BUILD_SHARED_FALSE@am__append_22 = drivers/audio_alsa.c
2.28 -@AUDIO_ALSA_TRUE@@BUILD_SHARED_FALSE@am__append_23 = @ALSA_LIBS@
2.29 -@BUILD_SHARED_FALSE@@INPUT_LIRC_TRUE@am__append_24 = drivers/input_lirc.c
2.30 -@BUILD_SHARED_FALSE@@INPUT_LIRC_TRUE@am__append_25 = -llirc_client
2.31 -@CDROM_LINUX_TRUE@am__append_26 = drivers/cd_linux.c
2.32 -@CDROM_OSX_TRUE@am__append_27 = drivers/cd_osx.c drivers/osx_iokit.m drivers/osx_iokit.h
2.33 -@CDROM_NONE_TRUE@am__append_28 = drivers/cd_none.c
2.34 -@JOY_LINUX_TRUE@am__append_29 = drivers/joy_linux.c drivers/joy_linux.h
2.35 +@BUILD_SHARED_TRUE@am__append_11 = lxdream_dummy.@SOEXT@
2.36 +@AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@am__append_12 = audio_sdl.@SOEXT@
2.37 +@AUDIO_PULSE_TRUE@@BUILD_SHARED_TRUE@am__append_13 = audio_pulse.@SOEXT@
2.38 +@AUDIO_ESOUND_TRUE@@BUILD_SHARED_TRUE@am__append_14 = audio_esd.@SOEXT@
2.39 +@AUDIO_ALSA_TRUE@@BUILD_SHARED_TRUE@am__append_15 = audio_alsa.@SOEXT@
2.40 +@BUILD_SHARED_TRUE@@INPUT_LIRC_TRUE@am__append_16 = input_lirc.@SOEXT@
2.41 +@AUDIO_SDL_TRUE@@BUILD_SHARED_FALSE@am__append_17 = drivers/audio_sdl.c
2.42 +@AUDIO_SDL_TRUE@@BUILD_SHARED_FALSE@am__append_18 = @SDL_LIBS@
2.43 +@AUDIO_PULSE_TRUE@@BUILD_SHARED_FALSE@am__append_19 = drivers/audio_pulse.c
2.44 +@AUDIO_PULSE_TRUE@@BUILD_SHARED_FALSE@am__append_20 = @PULSE_LIBS@
2.45 +@AUDIO_ESOUND_TRUE@@BUILD_SHARED_FALSE@am__append_21 = drivers/audio_esd.c
2.46 +@AUDIO_ESOUND_TRUE@@BUILD_SHARED_FALSE@am__append_22 = @ESOUND_LIBS@
2.47 +@AUDIO_ALSA_TRUE@@BUILD_SHARED_FALSE@am__append_23 = drivers/audio_alsa.c
2.48 +@AUDIO_ALSA_TRUE@@BUILD_SHARED_FALSE@am__append_24 = @ALSA_LIBS@
2.49 +@BUILD_SHARED_FALSE@@INPUT_LIRC_TRUE@am__append_25 = drivers/input_lirc.c
2.50 +@BUILD_SHARED_FALSE@@INPUT_LIRC_TRUE@am__append_26 = -llirc_client
2.51 +@CDROM_LINUX_TRUE@am__append_27 = drivers/cd_linux.c
2.52 +@CDROM_OSX_TRUE@am__append_28 = drivers/cd_osx.c drivers/osx_iokit.m drivers/osx_iokit.h
2.53 +@CDROM_NONE_TRUE@am__append_29 = drivers/cd_none.c
2.54 +@JOY_LINUX_TRUE@am__append_30 = drivers/joy_linux.c drivers/joy_linux.h
2.55 subdir = src
2.56 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
2.57 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
2.58 @@ -100,12 +101,13 @@
2.59 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibdir)"
2.60 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
2.61 @BUILD_SH4X86_TRUE@am__EXEEXT_1 = test/testsh4x86$(EXEEXT)
2.62 -@AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_2 = \
2.63 +@BUILD_SHARED_TRUE@am__EXEEXT_2 = lxdream_dummy.@SOEXT@$(EXEEXT)
2.64 +@AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_3 = \
2.65 @AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@ audio_sdl.@SOEXT@$(EXEEXT)
2.66 -@AUDIO_PULSE_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_3 = audio_pulse.@SOEXT@$(EXEEXT)
2.67 -@AUDIO_ESOUND_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_4 = audio_esd.@SOEXT@$(EXEEXT)
2.68 -@AUDIO_ALSA_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_5 = audio_alsa.@SOEXT@$(EXEEXT)
2.69 -@BUILD_SHARED_TRUE@@INPUT_LIRC_TRUE@am__EXEEXT_6 = input_lirc.@SOEXT@$(EXEEXT)
2.70 +@AUDIO_PULSE_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_4 = audio_pulse.@SOEXT@$(EXEEXT)
2.71 +@AUDIO_ESOUND_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_5 = audio_esd.@SOEXT@$(EXEEXT)
2.72 +@AUDIO_ALSA_TRUE@@BUILD_SHARED_TRUE@am__EXEEXT_6 = audio_alsa.@SOEXT@$(EXEEXT)
2.73 +@BUILD_SHARED_TRUE@@INPUT_LIRC_TRUE@am__EXEEXT_7 = input_lirc.@SOEXT@$(EXEEXT)
2.74 pkglibPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
2.75 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(pkglib_PROGRAMS)
2.76 am_audio_alsa_@SOEXT@_OBJECTS =
2.77 @@ -273,6 +275,10 @@
2.78 lxdream_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
2.79 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
2.80 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
2.81 +am_lxdream_dummy_@SOEXT@_OBJECTS =
2.82 +lxdream_dummy_@SOEXT@_OBJECTS = $(am_lxdream_dummy_@SOEXT@_OBJECTS)
2.83 +@BUILD_SHARED_TRUE@lxdream_dummy_@SOEXT@_DEPENDENCIES = \
2.84 +@BUILD_SHARED_TRUE@ lxdream_dummy.lo
2.85 am__test_testsh4x86_SOURCES_DIST = test/testsh4x86.c x86dasm/x86dasm.c \
2.86 x86dasm/x86dasm.h x86dasm/i386-dis.c x86dasm/dis-init.c \
2.87 x86dasm/dis-buf.c sh4/sh4trans.c sh4/sh4x86.c xlat/xltcache.c \
2.88 @@ -310,12 +316,13 @@
2.89 $(audio_pulse_@SOEXT@_SOURCES) $(audio_sdl_@SOEXT@_SOURCES) \
2.90 $(gendec_SOURCES) $(genglsl_SOURCES) \
2.91 $(input_lirc_@SOEXT@_SOURCES) $(lxdream_SOURCES) \
2.92 - $(test_testsh4x86_SOURCES) $(test_testxlt_SOURCES)
2.93 + $(lxdream_dummy_@SOEXT@_SOURCES) $(test_testsh4x86_SOURCES) \
2.94 + $(test_testxlt_SOURCES)
2.95 DIST_SOURCES = $(audio_alsa_@SOEXT@_SOURCES) \
2.96 $(audio_esd_@SOEXT@_SOURCES) $(audio_pulse_@SOEXT@_SOURCES) \
2.97 $(audio_sdl_@SOEXT@_SOURCES) $(gendec_SOURCES) \
2.98 $(genglsl_SOURCES) $(input_lirc_@SOEXT@_SOURCES) \
2.99 - $(am__lxdream_SOURCES_DIST) \
2.100 + $(am__lxdream_SOURCES_DIST) $(lxdream_dummy_@SOEXT@_SOURCES) \
2.101 $(am__test_testsh4x86_SOURCES_DIST) $(test_testxlt_SOURCES)
2.102 ETAGS = etags
2.103 CTAGS = ctags
2.104 @@ -510,7 +517,7 @@
2.105 -Ish4 \
2.106 @GLIB_CFLAGS@ @GTK_CFLAGS@ @LIBPNG_CFLAGS@ @PULSE_CFLAGS@ @ESOUND_CFLAGS@ @ALSA_CFLAGS@ @SDL_CFLAGS@
2.107
2.108 -EXTRA_DIST = drivers/genkeymap.pl checkver.pl
2.109 +EXTRA_DIST = drivers/genkeymap.pl checkver.pl drivers/dummy.c
2.110 AM_CFLAGS = -D__EXTENSIONS__ -D_BSD_SOURCE -D_GNU_SOURCE
2.111 TESTS = test/testxlt
2.112 BUILT_SOURCES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c sh4/sh4stat.c \
2.113 @@ -518,7 +525,8 @@
2.114
2.115 CLEANFILES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c sh4/sh4stat.c \
2.116 pvr2/gl_slsrc.c drivers/mac_keymap.h version.c \
2.117 - audio_alsa.lo audio_sdl.lo audio_esd.lo audio_pulse.lo input_lirc.lo
2.118 + audio_alsa.lo audio_sdl.lo audio_esd.lo audio_pulse.lo input_lirc.lo \
2.119 + lxdream_dummy.lo
2.120
2.121
2.122 #all-am: checkversion
2.123 @@ -526,8 +534,8 @@
2.124 genglsl_SOURCES = tools/genglsl.c
2.125 lxdream_LINK = $(LINK) @LXDREAMLDFLAGS@
2.126 lxdream_LDADD = @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@ $(INTLLIBS) \
2.127 - $(am__append_17) $(am__append_19) $(am__append_21) \
2.128 - $(am__append_23) $(am__append_25)
2.129 + $(am__append_18) $(am__append_20) $(am__append_22) \
2.130 + $(am__append_24) $(am__append_26)
2.131 lxdream_SOURCES = main.c version.c config.c config.h lxdream.h dream.h \
2.132 gui.h cpu.h hook.h gettext.h mem.c mem.h sdram.c mmio.h \
2.133 watch.c asic.c asic.h clock.h serial.h syscall.c syscall.h \
2.134 @@ -559,9 +567,9 @@
2.135 hotkeys.h $(am__append_1) $(am__append_2) $(am__append_4) \
2.136 $(am__append_5) $(am__append_6) $(am__append_7) \
2.137 $(am__append_8) $(am__append_9) $(am__append_10) \
2.138 - $(am__append_16) $(am__append_18) $(am__append_20) \
2.139 - $(am__append_22) $(am__append_24) $(am__append_26) \
2.140 - $(am__append_27) $(am__append_28) $(am__append_29)
2.141 + $(am__append_17) $(am__append_19) $(am__append_21) \
2.142 + $(am__append_23) $(am__append_25) $(am__append_27) \
2.143 + $(am__append_28) $(am__append_29) $(am__append_30)
2.144 lxdream_CPPFLAGS = @LXDREAMCPPFLAGS@
2.145 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@
2.146 @BUILD_SH4X86_TRUE@test_testsh4x86_CPPFLAGS = @LXDREAMCPPFLAGS@
2.147 @@ -571,6 +579,9 @@
2.148 @BUILD_SH4X86_TRUE@ sh4/sh4trans.c sh4/sh4x86.c xlat/xltcache.c \
2.149 @BUILD_SH4X86_TRUE@ xlat/xltcache.h mem.c util.c
2.150
2.151 +@BUILD_SHARED_TRUE@lxdream_dummy_@SOEXT@_SOURCES =
2.152 +@BUILD_SHARED_TRUE@lxdream_dummy_@SOEXT@_LDADD = lxdream_dummy.lo @SDL_LIBS@
2.153 +@BUILD_SHARED_TRUE@lxdream_dummy_@SOEXT@_LDFLAGS = $(PLUGINLDFLAGS)
2.154 @AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@audio_sdl_@SOEXT@_SOURCES =
2.155 @AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@audio_sdl_@SOEXT@_LDADD = audio_sdl.lo @SDL_LIBS@
2.156 @AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@audio_sdl_@SOEXT@_LDFLAGS = $(PLUGINLDFLAGS)
2.157 @@ -699,6 +710,9 @@
2.158 lxdream$(EXEEXT): $(lxdream_OBJECTS) $(lxdream_DEPENDENCIES)
2.159 @rm -f lxdream$(EXEEXT)
2.160 $(lxdream_LINK) $(lxdream_LDFLAGS) $(lxdream_OBJECTS) $(lxdream_LDADD) $(LIBS)
2.161 +lxdream_dummy.@SOEXT@$(EXEEXT): $(lxdream_dummy_@SOEXT@_OBJECTS) $(lxdream_dummy_@SOEXT@_DEPENDENCIES)
2.162 + @rm -f lxdream_dummy.@SOEXT@$(EXEEXT)
2.163 + $(LINK) $(lxdream_dummy_@SOEXT@_LDFLAGS) $(lxdream_dummy_@SOEXT@_OBJECTS) $(lxdream_dummy_@SOEXT@_LDADD) $(LIBS)
2.164 test/$(am__dirstamp):
2.165 @$(mkdir_p) test
2.166 @: > test/$(am__dirstamp)
2.167 @@ -2923,6 +2937,8 @@
2.168 @$(srcdir)/checkver.pl "$(VERSION)" "$(top_srcdir)" version.c
2.169
2.170 version.c: checkversion
2.171 +@BUILD_SHARED_TRUE@lxdream_dummy.lo: drivers/dummy.c
2.172 +@BUILD_SHARED_TRUE@ $(COMPILE) -DPLUGIN $(PLUGINCFLAGS) -c $< -o $@
2.173 @AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@audio_sdl.lo: drivers/audio_sdl.c
2.174 @AUDIO_SDL_TRUE@@BUILD_SHARED_TRUE@ $(COMPILE) -DPLUGIN $(PLUGINCFLAGS) -c $< -o $@
2.175 @AUDIO_PULSE_TRUE@@BUILD_SHARED_TRUE@audio_pulse.lo: drivers/audio_pulse.c
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/src/drivers/dummy.c Sat Jun 13 07:12:51 2009 +0000
3.3 @@ -0,0 +1,22 @@
3.4 +/**
3.5 + * $Id$
3.6 + *
3.7 + * Dummy plugin that exists to mark the plugin directory (and also for testing
3.8 + * purposes)
3.9 + *
3.10 + * Copyright (c) 2009 Nathan Keynes.
3.11 + *
3.12 + * This program is free software; you can redistribute it and/or modify
3.13 + * it under the terms of the GNU General Public License as published by
3.14 + * the Free Software Foundation; either version 2 of the License, or
3.15 + * (at your option) any later version.
3.16 + *
3.17 + * This program is distributed in the hope that it will be useful,
3.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.20 + * GNU General Public License for more details.
3.21 + */
3.22 +
3.23 +#include "plugin.h"
3.24 +
3.25 +DEFINE_PLUGIN( PLUGIN_NONE, "dummy", NULL );
4.1 --- a/src/main.c Sat Jun 13 07:04:24 2009 +0000
4.2 +++ b/src/main.c Sat Jun 13 07:12:51 2009 +0000
4.3 @@ -198,7 +198,7 @@
4.4 }
4.5
4.6 #ifdef ENABLE_SHARED
4.7 - plugin_init(get_plugin_path());
4.8 + plugin_init();
4.9 #endif
4.10
4.11 lxdream_load_config( );
5.1 --- a/src/plugin.c Sat Jun 13 07:04:24 2009 +0000
5.2 +++ b/src/plugin.c Sat Jun 13 07:12:51 2009 +0000
5.3 @@ -16,6 +16,7 @@
5.4 * GNU General Public License for more details.
5.5 */
5.6
5.7 +#include <sys/stat.h>
5.8 #include <dirent.h>
5.9 #include <dlfcn.h>
5.10 #include <string.h>
5.11 @@ -30,9 +31,40 @@
5.12 #define SOEXT ".so"
5.13 #endif
5.14
5.15 -const char *plugin_type_string[] = { "Undefined", "Audio driver", "Input driver" };
5.16 +/** Dummy plugin used as a plugin directory marker */
5.17 +#define DUMMY_PLUGIN ("lxdream_dummy" SOEXT)
5.18
5.19 -gboolean plugin_load( const gchar *plugin_path )
5.20 +const char *plugin_type_string[] = { "undefined", "audio driver", "input driver" };
5.21 +
5.22 +int main(int argc, char *argv[]);
5.23 +static const char *exec_path = NULL;
5.24 +
5.25 +/**
5.26 + * Return the full path to the main binary
5.27 + */
5.28 +static const char *get_exec_path()
5.29 +{
5.30 + if( exec_path == NULL ) {
5.31 + Dl_info dli;
5.32 +
5.33 + /* Use dladdr for this, since it should be available for any platform
5.34 + * that we can support plugins on at all.
5.35 + */
5.36 + if( dladdr( main, &dli) ) {
5.37 + gchar *path = g_strdup( dli.dli_fname );
5.38 + char *i = strrchr( path, '/' );
5.39 + if( i > path ) {
5.40 + *i = '\0';
5.41 + exec_path = path;
5.42 + } else {
5.43 + g_free(path);
5.44 + }
5.45 + }
5.46 + }
5.47 + return exec_path;
5.48 +}
5.49 +
5.50 +static gboolean plugin_load( const gchar *plugin_path )
5.51 {
5.52 void *so = dlopen(plugin_path, RTLD_NOW|RTLD_LOCAL);
5.53 if( so == NULL ) {
5.54 @@ -53,6 +85,12 @@
5.55 return FALSE;
5.56 }
5.57
5.58 + if( plugin->type == PLUGIN_NONE ) {
5.59 + /* 'dummy' plugin - we don't actually want to load it */
5.60 + dlclose(so);
5.61 + return FALSE;
5.62 + }
5.63 +
5.64 if( plugin->type < PLUGIN_MIN_TYPE || plugin->type > PLUGIN_MAX_TYPE ) {
5.65 WARN("Failed to load plugin: '%s': Unrecognized plugin type (%d)", plugin_path, plugin->type );
5.66 dlclose(so);
5.67 @@ -64,17 +102,30 @@
5.68 dlclose(so);
5.69 return FALSE;
5.70 }
5.71 - INFO("Loaded %s plugin '%s'", plugin_type_string[plugin->type], plugin->name);
5.72 + INFO("Loaded %s '%s'", plugin_type_string[plugin->type], plugin->name);
5.73 return TRUE;
5.74 }
5.75
5.76 +static gboolean has_plugins( const gchar *path )
5.77 +{
5.78 + struct stat st;
5.79 +
5.80 + gchar *dummy_name = g_strdup_printf( "%s/%s", path, DUMMY_PLUGIN );
5.81 + if( stat( dummy_name, &st ) == 0 ) {
5.82 + return TRUE;
5.83 + } else {
5.84 + return FALSE;
5.85 + }
5.86 +}
5.87 +
5.88 /**
5.89 * Scan the plugin dir and load all valid plugins.
5.90 */
5.91 -int plugin_init( const gchar *plugin_dir )
5.92 +static int plugin_load_all( const gchar *plugin_dir )
5.93 {
5.94 int plugin_count;
5.95 struct dirent *ent;
5.96 +
5.97 DIR *dir = opendir(plugin_dir);
5.98 if( dir == NULL ) {
5.99 WARN( "Unable to open plugin directory '%s'", plugin_dir );
5.100 @@ -93,3 +144,14 @@
5.101 }
5.102 return plugin_count;
5.103 }
5.104 +
5.105 +int plugin_init()
5.106 +{
5.107 + const char *path = get_exec_path();
5.108 + if( path == NULL || !has_plugins(path) ) {
5.109 + path = get_plugin_path();
5.110 + }
5.111 +
5.112 + INFO( "Plugin directory: %s", path );
5.113 + return plugin_load_all( path );
5.114 +}
6.1 --- a/src/plugin.h Sat Jun 13 07:04:24 2009 +0000
6.2 +++ b/src/plugin.h Sat Jun 13 07:12:51 2009 +0000
6.3 @@ -64,7 +64,7 @@
6.4
6.5 #endif /* ENABLE_SHARED */
6.6
6.7 -gboolean plugin_init(const gchar *path);
6.8 +gboolean plugin_init();
6.9
6.10 #ifdef __cplusplus
6.11 }
.