summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2013-04-14 12:55:02 +0200
committerBerke Viktor <bviktor@hexchat.org>2013-04-14 12:55:02 +0200
commit069a6adb190acf84a27bad9b2049378bebf19671 (patch)
tree73d1da31d1e52003dc3c0475cb32e285fa8f32fa
parent9dd2c85df4a90f4edf1eca7470fe162623fe39e9 (diff)
If no path given, try to load plugins from config dir, not from install dir
-rw-r--r--src/common/plugin.c25
1 files changed, 19 insertions, 6 deletions
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 */