forked from digineo/go-uci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
51 lines (39 loc) · 1.43 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Package uci implements a binding to OpenWRT's UCI (Unified Configuration
Interface) files in pure Go.
The typical use case is reading and modifying UCI config options:
import "github.com/digineo/go-uci"
uci.Get("network", "lan", "ifname") //=> []string{"eth0.1"}, true
uci.Set("network", "lan", "ipaddr", "192.168.7.1")
uci.Commit() // or uci.Revert()
For more details head over to the OpenWRT wiki, or dive into UCI's C
source code:
- https://openwrt.org/docs/guide-user/base-system/uci
- https://git.openwrt.org/?p=project/uci.git;a=summary
The lexer is heavily inspired by Rob Pike's 2011 GTUG Sydney talk
"Lexical Scanning in Go" (https://talks.golang.org/2011/lex.slide,
https://youtu.be/HxaD_trXwRE), which in turn was a presentation of
an early version of Go's text/template parser. It follows, that this
library borrows code from Go's standard library (BSD-style licensed).
The UCI grammar (for the purpose of this library) is defined as follows:
uci
packageDecl*
configDecl*
packageDecl
`package` value CRLF configDecl*
configDecl
`config` ident value? CRLF optionDecl*
optionDecl
`option` ident value
`list` ident value
ident
[_a-zA-Z0-9]+
value
`'` STRING `'`
`"` STRING `"`
ident
For now, UCI imports/exports (packageDecl production) are not supported
yet. The STRING token (value production) is also somewhat vaguely
defined, and needs to be aligned with the actual C implementation.
*/
package uci