From 069a6adb190acf84a27bad9b2049378bebf19671 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 14 Apr 2013 12:55:02 +0200 Subject: If no path given, try to load plugins from config dir, not from install dir --- src/common/plugin.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/common/plugin.c') diff --git a/src/common/plugin.c b/src/common/plugin.c index c14db021..08198cb6 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -367,12 +367,30 @@ char * plugin_load (session *sess, char *filename, char *arg) { void *handle; + char *pluginpath; + char *error; + char *filepart; hexchat_init_func *init_func; hexchat_deinit_func *deinit_func; + /* get the filename without path */ + filepart = file_part (filename); + #ifdef USE_GMODULE /* load the plugin */ - handle = g_module_open (filename, 0); + if (!g_ascii_strcasecmp (filepart, filename)) + { + /* no path specified, it's just the filename, try to load from config dir */ + pluginpath = g_build_filename (get_xdir (), filename, NULL); + handle = g_module_open (pluginpath, 0); + g_free (pluginpath); + } + else + { + /* try to load with absolute path */ + handle = g_module_open (filename, 0); + } + if (handle == NULL) return (char *)g_module_error (); @@ -388,8 +406,6 @@ plugin_load (session *sess, char *filename, char *arg) deinit_func = NULL; #else - char *error; - char *filepart; /* OpenBSD lacks this! */ #ifndef RTLD_GLOBAL @@ -400,9 +416,6 @@ plugin_load (session *sess, char *filename, char *arg) #define RTLD_NOW 0 #endif - /* get the filename without path */ - filepart = file_part (filename); - /* load the plugin */ if (filepart && /* xsys draws in libgtk-1.2, causing crashes, so force RTLD_LOCAL */ -- cgit 1.4.1