aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-06-21 19:15:59 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-06-21 19:15:59 +0500
commitdc5b5334b89b26487ab2ac3982bcb55b0c208651 (patch)
treec9c926dffc0a090d508bc6b4ae4efbadaba121a7
parent0f51eb5fa1f49a1a094e291528bf954c63dfadfd (diff)
downloadprosody-dc5b5334b89b26487ab2ac3982bcb55b0c208651.tar.gz
prosody-dc5b5334b89b26487ab2ac3982bcb55b0c208651.zip
modulemanager: Added simple module:require implementation
-rw-r--r--core/modulemanager.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index d6220cec..4f24c0a1 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -30,7 +30,7 @@ local t_insert, t_concat = table.insert, table.concat;
local type = type;
local next = next;
local rawget = rawget;
-
+local error = error;
local tostring = tostring;
-- We need this to let modules access the real global namespace
@@ -400,6 +400,15 @@ function api:hook_stanza(xmlns, name, handler, priority)
return api.hook(self, "stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority);
end
+function api:require(lib)
+ local f, n = pluginloader.load_code(self.name, lib..".lib.lua");
+ if not f then
+ f, n = pluginloader.load_code(lib, lib..".lib.lua");
+ end
+ if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message
+ return f();
+end
+
--------------------------------------------------------------------
local actions = {};