summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
committerTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
commit5734f776f166b9fdf0f1a2d21227bf7ee6ed14b4 (patch)
treed37e73f013df96cfc762934ddb05408fa48a3d2c
parent3ae16012d9762c6c553e6f0e5c4083b528d0a810 (diff)
downloadacf-opennhrp-5734f776f166b9fdf0f1a2d21227bf7ee6ed14b4.tar.bz2
acf-opennhrp-5734f776f166b9fdf0f1a2d21227bf7ee6ed14b4.tar.xz
Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value.
git-svn-id: svn://svn.alpinelinux.org/acf/opennhrp/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--opennhrp-model.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/opennhrp-model.lua b/opennhrp-model.lua
index 78338f9..36c3480 100644
--- a/opennhrp-model.lua
+++ b/opennhrp-model.lua
@@ -193,7 +193,7 @@ function getinterfacedetails(interface)
details.type = cfe({ type="select", value="Unused", label="Interface type", option={"Unused", "NHRP Enabled", "Shortcut Destination"} })
details.map = cfe({ type="list", value={}, label="Static Peers", descr="List of static peer mappings of protocol-address to nbma-address. Optional 'register' parameter specifies Registration Request sent to this peer on startup. (protocol-address[/prefix] nbma-address [register])" })
- configfilecontent = configfilecontent or fs.read_file(configfile)
+ configfilecontent = configfilecontent or fs.read_file(configfile) or ""
config = config or parseconfigfile(configfilecontent)
if config and config[interface] then
if config[interface]["shortcut-destination"] then
@@ -214,7 +214,7 @@ function updateinterfacedetails(interfacedetails)
local success, interfacedetails = validateinterfacedetails(interfacedetails)
if success then
- configfilecontent = configfilecontent or fs.read_file(configfile)
+ configfilecontent = configfilecontent or fs.read_file(configfile) or ""
local startchar = string.find(configfilecontent or "", "interface%s+"..interfacedetails.value.interface.value)
local lines = {}
if startchar then
@@ -263,7 +263,7 @@ end
function listinterfaces(self)
local interfaces = {}
list_interfaces(self)
- configfilecontent = configfilecontent or fs.read_file(configfile)
+ configfilecontent = configfilecontent or fs.read_file(configfile) or ""
config = config or parseconfigfile(configfilecontent)
for name,intf in pairs(config) do
temp = {interface=name, type="NHRP Enabled", errtxt=intf.errtxt}