Any return value of false or nil can be interpreted as an error
+
+ToDo: Reimplement in Lua
+
FileId:
$Id$
module("ffluci.model.uci", package.seeall)
require("ffluci.util")
require("ffluci.fs")
+require("ffluci.sys")
-- The OS uci command
ucicmd = "uci"
-- Wrapper for "uci changes"
function Session.changes(self, config)
- return self:_uci3("changes " .. _path(config))
+ return self:_uci("changes " .. _path(config))
end
-function change(...)
- return default:change(...)
+function changes(...)
+ return default:changes(...)
end
end
function revert(...)
- return self:revert(...)
+ return default:revert(...)
end
-- Internal functions --
function Session._uci(self, cmd)
- local res = ffluci.util.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
if res:len() == 0 then
return nil
end
function Session._uci2(self, cmd)
- local res = ffluci.util.exec(self.ucicmd .. " 2>&1 " .. cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd)
if res:len() > 0 then
return false, res
end
function Session._uci3(self, cmd)
- local res = ffluci.util.execl(self.ucicmd .. " 2>&1 " .. cmd)
- if res[1]:sub(1, ucicmd:len() + 1) == ucicmd .. ":" then
+ local res = ffluci.sys.execl(self.ucicmd .. " 2>&1 " .. cmd)
+ if res[1] and res[1]:sub(1, self.ucicmd:len()+1) == self.ucicmd..":" then
return nil, res[1]
end
table = {}
-
+
for k,line in pairs(res) do
c, s, t = line:match("^([^.]-)%.([^.]-)=(.-)$")
if c then