aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/sessionmanager.lua10
-rw-r--r--main.lua2
-rw-r--r--util/import.lua13
3 files changed, 19 insertions, 6 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index f2542ed2..b257e532 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -1,11 +1,9 @@
local tonumber, tostring = tonumber, tostring;
-local ipairs = ipairs;
+local ipairs, print= ipairs, print;
-local m_random = math.random;
-local format = string.format;
-
-local print = print;
+local m_random = import("math", "random");
+local format = import("string", "format");
local hosts = hosts;
@@ -79,7 +77,7 @@ function streamopened(session, attr)
end
send("</stream:features>");
- log("info", "core", "Stream opened successfully");
+ log("info", "Stream opened successfully");
session.notopen = nil;
end
diff --git a/main.lua b/main.lua
index 6712694d..027a472c 100644
--- a/main.lua
+++ b/main.lua
@@ -13,6 +13,7 @@ dofile "lxmppd.cfg"
sessions = {};
+require "util.import"
require "core.stanza_dispatch"
require "core.xmlhandlers"
require "core.rostermanager"
@@ -24,6 +25,7 @@ require "core.stanza_router"
require "net.connhandlers"
require "util.stanza"
require "util.jid"
+
-- Locals for faster access --
local t_insert = table.insert;
diff --git a/util/import.lua b/util/import.lua
new file mode 100644
index 00000000..6aab0d45
--- /dev/null
+++ b/util/import.lua
@@ -0,0 +1,13 @@
+
+local t_insert = table.insert;
+function import(module, ...)
+ local m = package.loaded[module] or require(module);
+ if type(m) == "table" and ... then
+ local ret = {};
+ for _, f in ipairs{...} do
+ t_insert(ret, m[f]);
+ end
+ return unpack(ret);
+ end
+ return m;
+end