From 84b63e040c4dd3f55aafc6089b36cbe1066a58f7 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 18 Oct 2013 20:08:58 +0000 Subject: 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. --- clamav-controller.lua | 18 ++++++++++-------- clamav-model.lua | 20 +++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/clamav-controller.lua b/clamav-controller.lua index dcce6e5..ee54309 100644 --- a/clamav-controller.lua +++ b/clamav-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 startstop(self) +function mymodule.startstop(self) return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end -function details(self) +function mymodule.details(self) return self.model.getstatusdetails() end -function listfiles(self) +function mymodule.listfiles(self) return self.model.getfilelist() end -function expert(self) +function mymodule.expert(self) return self.handle_form(self, self.model.getfiledetails, self.model.updatefiledetails, self.clientdata, "Save", "Edit ClamAV File", "File Saved") end -function logfile(self) +function mymodule.logfile(self) return self.model.getlogfile() end + +return mymodule diff --git a/clamav-model.lua b/clamav-model.lua index d83484d..c1e1d2a 100644 --- a/clamav-model.lua +++ b/clamav-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -18,23 +18,23 @@ local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin -- ################################################################################ -- 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, "ClamAV Status") end -function getstatusdetails() +function mymodule.getstatusdetails() return cfe({ type="longtext", value="", label="ClamAV Status Details" }) end -function getfilelist() +function mymodule.getfilelist() local listed_files = {} for i,name in ipairs(filelist) do @@ -47,15 +47,15 @@ function getfilelist() return cfe({ type="list", value=listed_files, label="ClamAV File List" }) end -function getfiledetails(self, clientdata) +function mymodule.getfiledetails(self, clientdata) return modelfunctions.getfiledetails(clientdata.filename, filelist) end -function updatefiledetails(self, filedetails) +function mymodule.updatefiledetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, filelist) end -function getlogfile () +function mymodule.getlogfile () local files = {} local logfilepath = format.parse_configfile(fs.read_file(filelist[1]) or "").LogFile if not logfilepath then @@ -71,3 +71,5 @@ function getlogfile () end return cfe({ value=files, label="ClamAV logfiles" }) end + +return mymodule -- cgit v1.2.3