* Rewrote ffluci.http, ffluci.model.uci
[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 -- Test whether to load libuci-Wrapper or /sbin/uci-Wrapper
29 if pcall(require, "uci") then
30         Session = require("ffluci.model.uci.libuci").Session
31 else
32         Session = require("ffluci.model.uci.wrapper").Session
33 end
34
35 -- The default Session
36 local default = Session()
37 local state   = Session("/var/state")
38
39 -- The state Session
40 function StateSession()
41         return state
42 end
43
44
45 -- Wrapper for "uci add"
46 function add(...)
47         return default:add(...)
48 end
49
50
51 -- Wrapper for "uci changes"
52 function changes(...)
53         return default:changes(...)
54 end
55
56
57 -- Wrapper for "uci commit"
58 function commit(...)
59         return default:commit(...)
60 end
61
62
63 -- Wrapper for "uci del"
64 function del(...)
65         return default:del(...)
66 end
67
68
69 -- Wrapper for "uci get"
70 function get(...)
71         return default:get(...)
72 end
73
74
75 -- Wrapper for "uci revert"
76 function revert(...)
77         return default:revert(...)
78 end
79
80
81 -- Wrapper for "uci show"
82 function sections(...)
83         return default:sections(...)
84 end
85
86
87 -- Wrapper for "uci set"
88 function set(...)
89         return default:set(...)
90 end