diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-21 00:32:45 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-21 00:32:45 +0000 |
commit | 64aa23cf7fcbd49b4b52a6731f2c64bd9db1fc29 (patch) | |
tree | 9e9cbb7f4631dd8f1039e9fda4260d5dee6bfbb9 /shorewall-model.lua | |
parent | 0e0a8293f75edce4d19dbb170ccaa7ab8c790929 (diff) | |
download | acf-shorewall-64aa23cf7fcbd49b4b52a6731f2c64bd9db1fc29.tar.bz2 acf-shorewall-64aa23cf7fcbd49b4b52a6731f2c64bd9db1fc29.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.
Diffstat (limited to 'shorewall-model.lua')
-rw-r--r-- | shorewall-model.lua | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/shorewall-model.lua b/shorewall-model.lua index 765157a..75fccb5 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -41,7 +41,7 @@ local function addremove_config( addremove, file, value, orgvalue ) -- Check if we are about to change a valid filename local isvalidfile - for k,v in pairs(getfilelist()) do + for k,v in pairs(mymodule.getfilelist()) do isvalidfile = true if (v.value == filepath) then break @@ -170,29 +170,29 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -function getstatus() +function mymodule.getstatus() return modelfunctions.getstatus(processname, packagename, "Shorewall Status") end -function getstatusdetails() +function mymodule.getstatusdetails() local programstate, errtxt = modelfunctions.run_executable({"shorewall", "status"}, true) return cfe({ value=programstate, label="Shorewall status report", errtxt=errtxt }) end -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 getlogfile () +function mymodule.getlogfile () local logfilepath = format.parse_ini_file(fs.read_file(configfile) or "","","LOGFILE") or "" return cfe({ value=logfilepath, label="Shorewall logfile" }) end -function getfilelist () +function mymodule.getfilelist () local listed_files = {} if fs.is_dir(baseurl) then @@ -210,7 +210,7 @@ function getfilelist () end local function is_valid_filename(filename) - local available_files = getfilelist() + local available_files = mymodule.getfilelist() for i,file in ipairs(available_files.value) do if file.filename == filename then return true @@ -219,20 +219,20 @@ local function is_valid_filename(filename) return false end -function getfiledetails(filename) +function mymodule.getfiledetails(filename) return modelfunctions.getfiledetails(filename, is_valid_filename) end -function updatefiledetails(self, filedetails) +function mymodule.updatefiledetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, is_valid_filename) end --[[ -function modify_config(self, addremove, file, value, orgvalue ) +function mymodule.modify_config(self, addremove, file, value, orgvalue ) return addremove_config(addremove, file, value, orgvalue ) end -function getconfig() +function mymodule.getconfig() local config = {} config.params = cfe({ @@ -285,7 +285,7 @@ function getconfig() end -function get_defined_zones () +function mymodule.get_defined_zones () local output = {} for k,v in pairs(read_config("zones")) do table.insert(output, string.match(v, "^%s*(%S*)")) @@ -293,3 +293,5 @@ function get_defined_zones () return output end --]] + +return mymodule |