diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-20 01:12:09 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-20 01:12:09 +0000 |
commit | 1c1a470e219016fe0df22d943b9ff704eb29f655 (patch) | |
tree | 4889a25f2a775d484ead8b28cf5cb3491cd2294a /ppp-model.lua | |
parent | a65ebadc7db1133efb44300d3763c79983578c31 (diff) | |
download | acf-ppp-1c1a470e219016fe0df22d943b9ff704eb29f655.tar.bz2 acf-ppp-1c1a470e219016fe0df22d943b9ff704eb29f655.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 'ppp-model.lua')
-rw-r--r-- | ppp-model.lua | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/ppp-model.lua b/ppp-model.lua index 4bd4cdd..4565a96 100644 --- a/ppp-model.lua +++ b/ppp-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -21,7 +21,7 @@ local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin -- ################################################################################ -- PUBLIC FUNCTIONS -function getstatus() +function mymodule.getstatus() local status = {} local value, errtxt = processinfo.package_version(packagename) @@ -43,37 +43,37 @@ function getstatus() return cfe({ type="group", value=status, label="PPP Status" }) end -function read_papfiledetails() +function mymodule.read_papfiledetails() return modelfunctions.getfiledetails(papfile) end -function update_papfiledetails(self, filedetails) +function mymodule.update_papfiledetails(self, filedetails) local retval = modelfunctions.setfiledetails(self, filedetails, {papfile}) posix.chmod(papfile, "rw-------") return retval end -function read_chapfiledetails() +function mymodule.read_chapfiledetails() return modelfunctions.getfiledetails(chapfile) end -function update_chapfiledetails(self, filedetails) +function mymodule.update_chapfiledetails(self, filedetails) local retval = modelfunctions.setfiledetails(self, filedetails, {chapfile}) posix.chmod(chapfile, "rw-------") return retval end -function list_peers() +function mymodule.list_peers() return cfe({ type="list", value=fs.find_files_as_array(nil, peerspath), label="Peers" }) end -function get_newpeer() +function mymodule.get_newpeer() local newpeer = {} newpeer.name = cfe({ label="Name" }) return cfe({ type="group", value=newpeer, label="New Peer" }) end -function create_peer(self, newpeer) +function mymodule.create_peer(self, newpeer) newpeer.errtxt = "Failed to create peer" local path = newpeer.value.name.value if not string.find(path, "/") then @@ -94,13 +94,13 @@ function create_peer(self, newpeer) return newpeer end -function get_delete_peer(self, clientdata) +function mymodule.get_delete_peer(self, clientdata) retval = {} retval.name = cfe({ value=clientdata.name or "", label="Name" }) return cfe({ type="group", value=retval, label="Delete Peer File" }) end -function delete_peer(self, delpeer) +function mymodule.delete_peer(self, delpeer) delpeer.errtxt = "Failed to delete peer" delpeer.value.name.errtxt="Peer not found" @@ -116,10 +116,12 @@ function delete_peer(self, delpeer) return delpeer end -function read_peerfile(name) +function mymodule.read_peerfile(name) return modelfunctions.getfiledetails(name, fs.find_files_as_array(nil, peerspath)) end -function update_peerfile(self, filedetails) +function mymodule.update_peerfile(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, fs.find_files_as_array(nil, peerspath)) end + +return mymodule |