aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/import.lua13
-rw-r--r--util/logger.lua2
-rw-r--r--util/sasl.lua2
-rw-r--r--util/uuid.lua9
4 files changed, 24 insertions, 2 deletions
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
diff --git a/util/logger.lua b/util/logger.lua
index 3d672e94..623ceb67 100644
--- a/util/logger.lua
+++ b/util/logger.lua
@@ -9,7 +9,7 @@ function init(name)
name = nil; -- While this line is not commented, will automatically fill in file/line number info
return function (level, message, ...)
if not name then
- local inf = debug.getinfo(2, 'Snl');
+ local inf = debug.getinfo(3, 'Snl');
level = level .. ","..tostring(inf.short_src):match("[^/]*$")..":"..inf.currentline;
end
if ... then
diff --git a/util/sasl.lua b/util/sasl.lua
index 515bcf8a..dbd6326a 100644
--- a/util/sasl.lua
+++ b/util/sasl.lua
@@ -19,7 +19,7 @@ local function new_plain(onAuth, onSuccess, onFail, onWrite)
local authorization = s_match(response, "([^&%z]+)")
local authentication = s_match(response, "%z([^&%z]+)%z")
local password = s_match(response, "%z[^&%z]+%z([^&%z]+)")
- if self.onAuth(authorization, password) == true then
+ if self.onAuth(authentication, password) == true then
self.onWrite(st.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}))
self.onSuccess(authentication)
else
diff --git a/util/uuid.lua b/util/uuid.lua
new file mode 100644
index 00000000..489522aa
--- /dev/null
+++ b/util/uuid.lua
@@ -0,0 +1,9 @@
+
+local m_random = math.random;
+module "uuid"
+
+function uuid_generate()
+ return m_random(0, 99999999);
+end
+
+return _M; \ No newline at end of file