Software /
code /
prosody
Comparison
core/modulemanager.lua @ 2278:8c10f13c0c20
modulemanager, net.dns: Remove trailing whitespace
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 02 Dec 2009 20:32:44 +0000 |
parent | 2270:97f25da177af |
child | 2349:e0d9f4000d6b |
comparison
equal
deleted
inserted
replaced
2277:c5d3905c98a6 | 2278:8c10f13c0c20 |
---|---|
173 function is_loaded(host, name) | 173 function is_loaded(host, name) |
174 return modulemap[host] and modulemap[host][name] and true; | 174 return modulemap[host] and modulemap[host][name] and true; |
175 end | 175 end |
176 | 176 |
177 function unload(host, name, ...) | 177 function unload(host, name, ...) |
178 local mod = get_module(host, name); | 178 local mod = get_module(host, name); |
179 if not mod then return nil, "module-not-loaded"; end | 179 if not mod then return nil, "module-not-loaded"; end |
180 | 180 |
181 if module_has_method(mod, "unload") then | 181 if module_has_method(mod, "unload") then |
182 local ok, err = call_module_method(mod, "unload"); | 182 local ok, err = call_module_method(mod, "unload"); |
183 if (not ok) and err then | 183 if (not ok) and err then |
280 function module_has_method(module, method) | 280 function module_has_method(module, method) |
281 return type(module.module[method]) == "function"; | 281 return type(module.module[method]) == "function"; |
282 end | 282 end |
283 | 283 |
284 function call_module_method(module, method, ...) | 284 function call_module_method(module, method, ...) |
285 if module_has_method(module, method) then | 285 if module_has_method(module, method) then |
286 local f = module.module[method]; | 286 local f = module.module[method]; |
287 return pcall(f, ...); | 287 return pcall(f, ...); |
288 else | 288 else |
289 return false, "no-such-method"; | 289 return false, "no-such-method"; |
290 end | 290 end |
291 end | 291 end |
292 | 292 |
293 ----- API functions exposed to modules ----------- | 293 ----- API functions exposed to modules ----------- |
294 -- Must all be in api.* | 294 -- Must all be in api.* |
295 | 295 |
296 -- Returns the name of the current module | 296 -- Returns the name of the current module |
297 function api:get_name() | 297 function api:get_name() |
298 return self.name; | 298 return self.name; |
299 end | 299 end |