summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-21 00:32:45 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-21 00:32:45 +0000
commit64aa23cf7fcbd49b4b52a6731f2c64bd9db1fc29 (patch)
tree9e9cbb7f4631dd8f1039e9fda4260d5dee6bfbb9
parent0e0a8293f75edce4d19dbb170ccaa7ab8c790929 (diff)
downloadacf-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.
-rw-r--r--shorewall-controller.lua22
-rw-r--r--shorewall-model.lua30
2 files changed, 28 insertions, 24 deletions
diff --git a/shorewall-controller.lua b/shorewall-controller.lua
index 934e92c..59f6394 100644
--- a/shorewall-controller.lua
+++ b/shorewall-controller.lua
@@ -1,32 +1,32 @@
-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 details(self)
+function mymodule.details(self)
return self.model.getstatusdetails()
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 listfiles(self)
+function mymodule.listfiles(self)
return self.model.getfilelist()
end
-function edit(self)
+function mymodule.edit(self)
return self.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit File", "File Saved")
end
-function logfile(self)
+function mymodule.logfile(self)
return self.model.getlogfile()
end
--[[
-function editrecords(self,types,record,errormessage)
+function mymodule.editrecords(self,types,record,errormessage)
local recorddetails = {}
local edit = {}
local config=self.model:getconfig()
@@ -447,7 +447,7 @@ function editrecords(self,types,record,errormessage)
}
end
-function config(self)
+function mymodule.config(self)
-- If we made some changes to a recods... then proceed with the modification
local savesuccess, configmessage
@@ -615,3 +615,5 @@ function config(self)
}
end
--]]
+
+return mymodule
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