* Fixed haserl-lua Makefile
[project/luci.git] / src / ffluci / model / uci.lua
index 2d6702b..8286597 100644 (file)
@@ -7,6 +7,9 @@ is comparable to the syntax of the uci application
 
 Any return value of false or nil can be interpreted as an error
 
+
+ToDo: Reimplement in Lua
+
 FileId:
 $Id$
 
@@ -29,6 +32,7 @@ limitations under the License.
 module("ffluci.model.uci", package.seeall)
 require("ffluci.util")
 require("ffluci.fs")
+require("ffluci.sys")
 
 -- The OS uci command
 ucicmd = "uci"
@@ -61,11 +65,11 @@ end
 
 -- 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
 
 
@@ -105,7 +109,7 @@ function Session.revert(self, config)
 end
 
 function revert(...)
-       return self:revert(...)
+       return default:revert(...)
 end
 
 
@@ -132,7 +136,7 @@ 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
@@ -142,7 +146,7 @@ function Session._uci(self, cmd)
 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
@@ -152,13 +156,13 @@ function Session._uci2(self, cmd)
 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