diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-18 22:29:04 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-18 22:29:04 +0000 |
commit | 6e6c8803a11dc23f2dfc5cced35b54981395fa9c (patch) | |
tree | 182cba17869721d350138ed5d7f5cd12a00b8046 | |
parent | 3cdbb88e20095542f951d580581df5b53960240d (diff) | |
download | acf-dnsmasq-6e6c8803a11dc23f2dfc5cced35b54981395fa9c.tar.bz2 acf-dnsmasq-6e6c8803a11dc23f2dfc5cced35b54981395fa9c.tar.xz |
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition.
This was also helpful in revealing places where the code relied on the global environment.
-rw-r--r-- | dnsmasq-controller.lua | 15 | ||||
-rw-r--r-- | dnsmasq-model.lua | 20 |
2 files changed, 19 insertions, 16 deletions
diff --git a/dnsmasq-controller.lua b/dnsmasq-controller.lua index 5ba412b..22fe912 100644 --- a/dnsmasq-controller.lua +++ b/dnsmasq-controller.lua @@ -1,24 +1,25 @@ -module(..., package.seeall) +local mymodule = {} -default_action = "status" +mymodule.default_action = "status" -function status(self) +function mymodule.status(self) return self.model.getstatus() end -function startstop(self) +function mymodule.startstop(self) return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end -function config(self) +function mymodule.config(self) return self.handle_form(self, self.model.getconfig, self.model.setconfig, self.clientdata, "Save", "Edit Config", "Configuration Set") end -function expert(self) +function mymodule.expert(self) return self.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config File", "Configuration File Set") end -function viewleases(self) +function mymodule.viewleases(self) return self.model.getleases() end +return mymodule diff --git a/dnsmasq-model.lua b/dnsmasq-model.lua index 181f2cd..c6e4ddd 100644 --- a/dnsmasq-model.lua +++ b/dnsmasq-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -267,19 +267,19 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) return modelfunctions.get_startstop(processname) end -function startstop_service(self, startstop, action) +function mymodule.startstop_service(self, startstop, action) return modelfunctions.startstop_service(startstop, action) end -function getstatus() +function mymodule.getstatus() return modelfunctions.getstatus(processname, packagename, "DNS Masq Status") end -function getconfig() +function mymodule.getconfig() local conf = parse_file(fs.read_file(configfile) or "") or {} local dns_filtering = {} dns_filtering.enabled = dns_filtering_is_enabled(conf) @@ -303,7 +303,7 @@ function getconfig() return cfe({ type="group", value=output, label="DNS Masq Config" }) end -function setconfig(self, config) +function mymodule.setconfig(self, config) local success, config = validateconfig(self, config) if success then @@ -330,16 +330,18 @@ function setconfig(self, config) return config end -function getconfigfile() +function mymodule.getconfigfile() -- FIXME Validate return modelfunctions.getfiledetails(configfile) end -function setconfigfile(self, filedetails) +function mymodule.setconfigfile(self, filedetails) -- FIXME Validate return modelfunctions.setfiledetails(self, filedetails, {configfile}) end -function getleases() +function mymodule.getleases() return modelfunctions.getfiledetails(leasefile) end + +return mymodule |