configmanager: Add parsers() method to return an array of supported config formats
[prosody.git] / core / actions.lua
1 -- Prosody IM
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9 \r
10 local actions = {};\r
11 \r
12 function register(path, t)\r
13         local curr = actions;\r
14         for comp in path:gmatch("([^/]+)/") do\r
15                 if curr[comp] == nil then\r
16                         curr[comp] = {};\r
17                 end\r
18                 curr = curr[comp];\r
19                 if type(curr) ~= "table" then\r
20                         return nil, "path-taken";\r
21                 end\r
22         end\r
23         curr[path:match("/([^/]+)$")] = t;\r
24         return true;\r
25 end\r
26 \r
27 return { actions = actions, register= register };