From 5b8969b8d9a926294b0f09b3f835ae994d58d012 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 29 Nov 2008 03:26:46 +0000 Subject: Fix for configmanager when config file can't be found --- core/configmanager.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/configmanager.lua b/core/configmanager.lua index 5f5648b9..a4a24fad 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -2,6 +2,7 @@ local _G = _G; local setmetatable, loadfile, pcall, rawget, rawset, io = setmetatable, loadfile, pcall, rawget, rawset, io; + module "configmanager" local parsers = {}; @@ -52,18 +53,21 @@ end function load(filename, format) format = format or filename:match("%w+$"); + if parsers[format] and parsers[format].load then - local f = io.open(filename); + local f, err = io.open(filename); if f then local ok, err = parsers[format].load(f:read("*a")); f:close(); return ok, err; end + return f, err; end + if not format then return nil, "no parser specified"; else - return false, "no parser"; + return nil, "no parser for "..(format); end end @@ -118,4 +122,4 @@ do end -return _M; \ No newline at end of file +return _M; -- cgit v1.2.3 From 7271c148cef981f9263a8794ebe27634423b07bd Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 29 Nov 2008 03:27:50 +0000 Subject: Update Makefile to now pass config paths to prosody. Update prosody, modulemanager and connectionlisteners to obey these paths. --- core/modulemanager.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/modulemanager.lua b/core/modulemanager.lua index ce34f3e6..31059512 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -1,4 +1,5 @@ +local plugin_dir = CFG_PLUGINDIR or "./plugins/"; local logger = require "util.logger"; local log = logger.init("modulemanager") @@ -11,8 +12,8 @@ local type = type; local tostring, print = tostring, print; +-- We need this to let modules access the real global namespace local _G = _G; -local debug = debug; module "modulemanager" @@ -30,7 +31,7 @@ function load(host, module_name, config) if not (host and module_name) then return nil, "insufficient-parameters"; end - local mod, err = loadfile("plugins/mod_"..module_name..".lua"); + local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua"); if not mod then log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); return nil, err; -- cgit v1.2.3