diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-20 00:37:15 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-20 00:37:15 +0000 |
commit | 6a0cfe40de67399119a4a689cd0c0a9e62ef8fee (patch) | |
tree | 1e55e0b848670a8c90f227d60897954fcc12bb74 | |
parent | f4818065de65fde4b2a76f1ea0c13e92fb448822 (diff) | |
download | acf-opennhrp-6a0cfe40de67399119a4a689cd0c0a9e62ef8fee.tar.bz2 acf-opennhrp-6a0cfe40de67399119a4a689cd0c0a9e62ef8fee.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-- | opennhrp-controller.lua | 18 | ||||
-rw-r--r-- | opennhrp-model.lua | 22 |
2 files changed, 22 insertions, 18 deletions
diff --git a/opennhrp-controller.lua b/opennhrp-controller.lua index 832db2e..84191a4 100644 --- a/opennhrp-controller.lua +++ b/opennhrp-controller.lua @@ -1,27 +1,29 @@ -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 show(self) +function mymodule.show(self) return self.model.getshowreport() 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 listinterfaces(self) +function mymodule.listinterfaces(self) return self.model.listinterfaces(self) end -function editinterface(self) +function mymodule.editinterface(self) return self.handle_form(self, function() return self.model.getinterfacedetails(self.clientdata.interface) end, self.model.updateinterfacedetails, self.clientdata, "Save", "Edit Interface Config", "Interface 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", "Configuration Set") end + +return mymodule diff --git a/opennhrp-model.lua b/opennhrp-model.lua index 29f2e1f..c9a8e4c 100644 --- a/opennhrp-model.lua +++ b/opennhrp-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -179,19 +179,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, "OpenNHRP Status") end -function getshowreport() +function mymodule.getshowreport() local peers_list = cfe({ type="structure", value={}, label="Peers" }) local opennhrpstatus = cfe({ value="Show report not available", label="Status" }) local content = modelfunctions.run_executable({"opennhrpctl", "show"}) @@ -218,7 +218,7 @@ function getshowreport() return cfe({ type="group", value={peers_list=peers_list, status=opennhrpstatus}, label="OpenNHRP Show Report" }) end -function getinterfacedetails(interface) +function mymodule.getinterfacedetails(interface) local details = {} details.interface = cfe({ value=interface, label="Interface" }) details.type = cfe({ type="select", value="Unused", label="Interface type", option={"Unused", "NHRP Enabled", "Shortcut Destination"} }) @@ -245,7 +245,7 @@ function getinterfacedetails(interface) return cfe({ type="group", value=details, label="OpenNHRP Interface Configuration" }) end -function updateinterfacedetails(self, interfacedetails) +function mymodule.updateinterfacedetails(self, interfacedetails) local success, interfacedetails = validateinterfacedetails(interfacedetails) if success then @@ -298,7 +298,7 @@ function updateinterfacedetails(self, interfacedetails) return interfacedetails end -function listinterfaces(self) +function mymodule.listinterfaces(self) local interfaces = {} list_interfaces(self) configfilecontent = configfilecontent or fs.read_file(configfile) or "" @@ -328,11 +328,11 @@ function listinterfaces(self) return cfe({ type="structure", value=interfaces, label="OpenNHRP Interfaces" }) end -function getconfigfile(self) +function mymodule.getconfigfile(self) return validateconfigfile(self, modelfunctions.getfiledetails(configfile)) end -function setconfigfile(self, filedetails) +function mymodule.setconfigfile(self, filedetails) filedetails = modelfunctions.setfiledetails(self, filedetails, {configfile}) if not filedetails.errtxt then configfilecontent = nil @@ -340,3 +340,5 @@ function setconfigfile(self, filedetails) end return validateconfigfile(self, filedetails) end + +return mymodule |