ca5b232eb37ebd21a76ca2c058e5ebc1464a60b6
[project/luci.git] / core / src / ffluci / model / uci.lua
1 --[[
2 FFLuCI - UCI mpdel
3
4 Description:
5 Generalized UCI model
6
7 FileId:
8 $Id$
9
10 License:
11 Copyright 2008 Steven Barth <steven@midlink.org>
12
13 Licensed under the Apache License, Version 2.0 (the "License");
14 you may not use this file except in compliance with the License.
15 You may obtain a copy of the License at 
16
17         http://www.apache.org/licenses/LICENSE-2.0 
18
19 Unless required by applicable law or agreed to in writing, software
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24
25 ]]--
26 module("ffluci.model.uci", package.seeall)
27
28 -- Default savedir
29 savedir = "/tmp/.uci"
30
31 -- Test whether to load libuci-Wrapper or /sbin/uci-Wrapper
32 if pcall(require, "uci") then
33         Session = require("ffluci.model.uci.libuci").Session
34 else
35         Session = require("ffluci.model.uci.wrapper").Session
36 end
37
38 -- The default Session
39 local default = Session()
40 local state   = Session("/var/state")
41
42 -- The state Session
43 function StateSession()
44         return state
45 end
46
47
48 -- Wrapper for "uci add"
49 function add(...)
50         return default:add(...)
51 end
52
53
54 -- Wrapper for "uci changes"
55 function changes(...)
56         return default:changes(...)
57 end
58
59 -- Wrapper for "uci commit"
60 function commit(...)
61         return default:commit(...)
62 end
63
64
65 -- Wrapper for "uci del"
66 function del(...)
67         return default:del(...)
68 end
69
70
71 -- Wrapper for "uci get"
72 function get(...)
73         return default:get(...)
74 end
75
76
77 -- Wrapper for "uci revert"
78 function revert(...)
79         return default:revert(...)
80 end
81
82
83 -- Wrapper for "uci show"
84 function sections(...)
85         return default:sections(...)
86 end
87
88
89 -- Wrapper for "uci set"
90 function set(...)
91         return default:set(...)
92 end