util.sasl_cyrus: Automatically initialize Cyrus SASL with the first used service...
[prosody.git] / core / objectmanager.lua
index e96cbd90ae636e111dd20a97123ab73a410fb7db..293622c92e9d7d15b5f11060290d1293e7568ab8 100644 (file)
@@ -6,63 +6,63 @@
 -- COPYING file in the source package for more information.
 --
 
-\r
-local new_multitable = require "util.multitable".new;\r
-local t_insert = table.insert;\r
-local t_concat = table.concat;\r
-local tostring = tostring;\r
-local unpack = unpack;\r
-local pairs = pairs;\r
-local error = error;\r
-local type = type;\r
-local _G = _G;\r
-\r
-local data = new_multitable();\r
-\r
-module "objectmanager"\r
-\r
-function set(...)\r
-       return data:set(...);\r
-end\r
-function remove(...)\r
-       return data:remove(...);\r
-end\r
-function get(...)\r
-       return data:get(...);\r
-end\r
-\r
-local function get_path(path)\r
-       if type(path) == "table" then return path; end\r
-       local s = {};\r
-       for part in tostring(path):gmatch("[%w_]+") do\r
-               t_insert(s, part);\r
-       end\r
-       return s;\r
-end\r
-\r
-function get_object(path)\r
-       path = get_path(path)\r
-       return data:get(unpack(path)), path;\r
-end\r
-function set_object(path, object)\r
-       path = get_path(path);\r
-       data:set(unpack(path), object);\r
-end\r
-\r
-data:set("ls", function(_dir)\r
-       local obj, dir = get_object(_dir);\r
-       if not obj then error("object not found: " .. t_concat(dir, '/')); end\r
-       local r = {};\r
-       if type(obj) == "table" then\r
-               for key, val in pairs(obj) do\r
-                       r[key] = type(val);\r
-               end\r
-       end\r
-       return r;\r
-end);\r
-data:set("get", get_object);\r
-data:set("set", set_object);\r
-data:set("echo", function(...) return {...}; end);\r
-data:set("_G", _G);\r
-\r
-return _M;\r
+
+local new_multitable = require "util.multitable".new;
+local t_insert = table.insert;
+local t_concat = table.concat;
+local tostring = tostring;
+local unpack = unpack;
+local pairs = pairs;
+local error = error;
+local type = type;
+local _G = _G;
+
+local data = new_multitable();
+
+module "objectmanager"
+
+function set(...)
+       return data:set(...);
+end
+function remove(...)
+       return data:remove(...);
+end
+function get(...)
+       return data:get(...);
+end
+
+local function get_path(path)
+       if type(path) == "table" then return path; end
+       local s = {};
+       for part in tostring(path):gmatch("[%w_]+") do
+               t_insert(s, part);
+       end
+       return s;
+end
+
+function get_object(path)
+       path = get_path(path)
+       return data:get(unpack(path)), path;
+end
+function set_object(path, object)
+       path = get_path(path);
+       data:set(unpack(path), object);
+end
+
+data:set("ls", function(_dir)
+       local obj, dir = get_object(_dir);
+       if not obj then error("object not found: " .. t_concat(dir, '/')); end
+       local r = {};
+       if type(obj) == "table" then
+               for key, val in pairs(obj) do
+                       r[key] = type(val);
+               end
+       end
+       return r;
+end);
+data:set("get", get_object);
+data:set("set", set_object);
+data:set("echo", function(...) return {...}; end);
+data:set("_G", _G);
+
+return _M;