Software / code / prosody
Comparison
core/configmanager.lua @ 5420:706053e3f9f5
Merge 0.9->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 03 Apr 2013 13:53:21 +0100 |
| parent | 5413:0bf5e90be086 |
| child | 5776:bd0ff8ae98a8 |
| child | 5811:27ae988f5b70 |
comparison
equal
deleted
inserted
replaced
| 5400:dd91b72a3ba0 | 5420:706053e3f9f5 |
|---|---|
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 local _G = _G; | 9 local _G = _G; |
| 10 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table = | 10 local setmetatable, rawget, rawset, io, error, dofile, type, pairs, table = |
| 11 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table; | 11 setmetatable, rawget, rawset, io, error, dofile, type, pairs, table; |
| 12 local format, math_max = string.format, math.max; | 12 local format, math_max = string.format, math.max; |
| 13 | 13 |
| 14 local fire_event = prosody and prosody.events.fire_event or function () end; | 14 local fire_event = prosody and prosody.events.fire_event or function () end; |
| 15 | 15 |
| 16 local envload = require"util.envload".envload; | 16 local envload = require"util.envload".envload; |
| 66 return set(config, host, key, value); | 66 return set(config, host, key, value); |
| 67 end | 67 end |
| 68 | 68 |
| 69 -- Helper function to resolve relative paths (needed by config) | 69 -- Helper function to resolve relative paths (needed by config) |
| 70 do | 70 do |
| 71 local rel_path_start = ".."..path_sep; | |
| 72 function resolve_relative_path(parent_path, path) | 71 function resolve_relative_path(parent_path, path) |
| 73 if path then | 72 if path then |
| 74 -- Some normalization | 73 -- Some normalization |
| 75 parent_path = parent_path:gsub("%"..path_sep.."+$", ""); | 74 parent_path = parent_path:gsub("%"..path_sep.."+$", ""); |
| 76 path = path:gsub("^%.%"..path_sep.."+", ""); | 75 path = path:gsub("^%.%"..path_sep.."+", ""); |
| 150 end | 149 end |
| 151 | 150 |
| 152 -- Built-in Lua parser | 151 -- Built-in Lua parser |
| 153 do | 152 do |
| 154 local pcall, setmetatable = _G.pcall, _G.setmetatable; | 153 local pcall, setmetatable = _G.pcall, _G.setmetatable; |
| 155 local rawget, tostring = _G.rawget, _G.tostring; | 154 local rawget = _G.rawget; |
| 156 parsers.lua = {}; | 155 parsers.lua = {}; |
| 157 function parsers.lua.load(data, config_file, config) | 156 function parsers.lua.load(data, config_file, config) |
| 158 local env; | 157 local env; |
| 159 -- The ' = true' are needed so as not to set off __newindex when we assign the functions below | 158 -- The ' = true' are needed so as not to set off __newindex when we assign the functions below |
| 160 env = setmetatable({ | 159 env = setmetatable({ |
| 211 return handle_config_options(module); | 210 return handle_config_options(module); |
| 212 end | 211 end |
| 213 end | 212 end |
| 214 env.component = env.Component; | 213 env.component = env.Component; |
| 215 | 214 |
| 216 function env.Include(file, wildcard) | 215 function env.Include(file) |
| 217 if file:match("[*?]") then | 216 if file:match("[*?]") then |
| 218 local path_pos, glob = file:match("()([^"..path_sep.."]+)$"); | 217 local path_pos, glob = file:match("()([^"..path_sep.."]+)$"); |
| 219 local path = file:sub(1, math_max(path_pos-2,0)); | 218 local path = file:sub(1, math_max(path_pos-2,0)); |
| 220 local config_path = config_file:gsub("[^"..path_sep.."]+$", ""); | 219 local config_path = config_file:gsub("[^"..path_sep.."]+$", ""); |
| 221 if #path > 0 then | 220 if #path > 0 then |