From 2de1daae9e11f61400e7f6685079c491d166ac88 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 13 Aug 2010 07:58:56 +0200 Subject: Adding searchpath to LuaLoadPlugin --- src/lua-plugin.cc | 12 ++++++++---- src/lua-plugin.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lua-plugin.cc b/src/lua-plugin.cc index 1e4ebc7..3c08201 100644 --- a/src/lua-plugin.cc +++ b/src/lua-plugin.cc @@ -15,7 +15,7 @@ typedef void(*init_ptr_t)(Lua *); #include #include "MemoryModule.h" -void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) { +void LuaLoadPlugin(const String & _fname, const String & searchpath, Lua * L) throw (GeneralException) { HMODULE handle; String fname = _fname + "." SHARED_EXT; @@ -67,15 +67,19 @@ void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException) { #else #include -void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException) { +void LuaLoadPlugin(const String & fname, const String & searchpath, Lua * L) throw (GeneralException) { String full_fname = "./" + fname + "." SHARED_EXT; void * handle = dlopen(full_fname.to_charp(), RTLD_NOW | RTLD_GLOBAL); Base::printm(M_INFO, "Loading library " + fname + "\n"); if (!handle) { - LuaLoadPlugin(&Input(fname + "." SHARED_EXT), L); - return; + full_fname = searchpath + fname + "." SHARED_EXT + handle = dlopen(full_fname.to_charp(), RTLD_NOW | RTLD_GLOBAL); + if (!handle) { + LuaLoadPlugin(&Input(fname + "." SHARED_EXT), L); + return; + } } init_ptr_t init_ptr = (init_ptr_t) dlsym(handle, "init_plugin"); diff --git a/src/lua-plugin.h b/src/lua-plugin.h index e347b6b..9e4ed4c 100644 --- a/src/lua-plugin.h +++ b/src/lua-plugin.h @@ -5,7 +5,7 @@ #include #include -void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException); +void LuaLoadPlugin(const String & fname, const String & searchpath, Lua * L) throw (GeneralException); void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException); #endif -- cgit v1.2.3