Software / code / prosody
Comparison
core/modulemanager.lua @ 467:66f145f5c932
Update Makefile to now pass config paths to prosody. Update prosody, modulemanager and connectionlisteners to obey these paths.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 29 Nov 2008 03:27:50 +0000 |
| parent | 439:6608ad3a72f3 |
| child | 519:cccd610a0ef9 |
comparison
equal
deleted
inserted
replaced
| 466:0ecfd89c2cc0 | 467:66f145f5c932 |
|---|---|
| 1 | 1 |
| 2 local plugin_dir = CFG_PLUGINDIR or "./plugins/"; | |
| 2 | 3 |
| 3 local logger = require "util.logger"; | 4 local logger = require "util.logger"; |
| 4 local log = logger.init("modulemanager") | 5 local log = logger.init("modulemanager") |
| 5 | 6 |
| 6 local loadfile, pcall = loadfile, pcall; | 7 local loadfile, pcall = loadfile, pcall; |
| 9 local t_insert = table.insert; | 10 local t_insert = table.insert; |
| 10 local type = type; | 11 local type = type; |
| 11 | 12 |
| 12 local tostring, print = tostring, print; | 13 local tostring, print = tostring, print; |
| 13 | 14 |
| 15 -- We need this to let modules access the real global namespace | |
| 14 local _G = _G; | 16 local _G = _G; |
| 15 local debug = debug; | |
| 16 | 17 |
| 17 module "modulemanager" | 18 module "modulemanager" |
| 18 | 19 |
| 19 local api = {}; -- Module API container | 20 local api = {}; -- Module API container |
| 20 | 21 |
| 28 | 29 |
| 29 function load(host, module_name, config) | 30 function load(host, module_name, config) |
| 30 if not (host and module_name) then | 31 if not (host and module_name) then |
| 31 return nil, "insufficient-parameters"; | 32 return nil, "insufficient-parameters"; |
| 32 end | 33 end |
| 33 local mod, err = loadfile("plugins/mod_"..module_name..".lua"); | 34 local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua"); |
| 34 if not mod then | 35 if not mod then |
| 35 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); | 36 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); |
| 36 return nil, err; | 37 return nil, err; |
| 37 end | 38 end |
| 38 | 39 |