mod_posix: Check version of pposix
[prosody.git] / core / configmanager.lua
index 5f5648b9ce27160041387b50562512f78bc39614..a6e86347d105caf2f3409d8643ab8e89b2000156 100644 (file)
@@ -1,7 +1,28 @@
+-- Prosody IM v0.2
+-- Copyright (C) 2008 Matthew Wild
+-- Copyright (C) 2008 Waqas Hussain
+-- 
+-- This program is free software; you can redistribute it and/or
+-- modify it under the terms of the GNU General Public License
+-- as published by the Free Software Foundation; either version 2
+-- of the License, or (at your option) any later version.
+-- 
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+-- 
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+--
+
+
 
 local _G = _G;
 local  setmetatable, loadfile, pcall, rawget, rawset, io = 
                setmetatable, loadfile, pcall, rawget, rawset, io;
+
 module "configmanager"
 
 local parsers = {};
@@ -52,18 +73,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 +142,4 @@ do
        
 end
 
-return _M;
\ No newline at end of file
+return _M;