Upload Tizen:Main source
[external/augeas.git] / lenses / resolv.aug
1 (*
2 Module: Resolv
3   Parses /etc/resolv.conf
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man resolv.conf` where possible.
9
10 About: Licence
11   This file is licensed under the LGPLv2+, like the rest of Augeas.
12
13 About: Lens Usage
14
15 About: Configuration files
16   This lens applies to /etc/resolv.conf. See <filter>.
17 *)
18
19 module Resolv =
20 autoload xfm
21
22 (************************************************************************
23  * Group:                 USEFUL PRIMITIVES
24  *************************************************************************)
25
26 (* View: comment *)
27 let comment = Util.comment_generic /[ \t]*[;#][ \t]*/ "# "
28
29 (* View: empty *)
30 let empty = Util.empty
31
32
33 (************************************************************************
34  * Group:                 MAIN OPTIONS
35  *************************************************************************)
36
37 (* View: netmask
38 A network mask for IP addresses *)
39 let netmask = [ label "netmask" . Util.del_str "/" . store Rx.ip ]
40
41 (* View: ipaddr 
42 An IP address or range with an optional mask *) 
43 let ipaddr = [label "ipaddr" . store Rx.ip . netmask?]
44
45
46 (* View: nameserver
47      A nameserver entry *)
48 let nameserver = Build.key_value_line 
49                     "nameserver" Sep.space (store Rx.ip)
50
51 (* View: domain *)
52 let domain = Build.key_value_line
53                     "domain" Sep.space (store Rx.word)
54
55 (* View: search *)
56 let search = Build.key_value_line
57                     "search" Sep.space
58                     (Build.opt_list 
59                            [label "domain" . store Rx.word]
60                             Sep.space)
61
62 (* View: sortlist *)
63 let sortlist = Build.key_value_line
64                     "sortlist" Sep.space
65                     (Build.opt_list
66                            ipaddr
67                            Sep.space) 
68
69 (************************************************************************
70  * Group:                 SPECIAL OPTIONS
71  *************************************************************************)
72
73 (* View: ip6_dotint
74      ip6-dotint option, which supports negation *)
75 let ip6_dotint = 
76   let negate = [ del "no-" "no-" . label "negate" ]
77     in [ negate? . key "ip6-dotint" ]
78
79 (* View: options 
80      Options values *)
81 let options =
82       let options_entry = Build.key_value ("ndots"|"timeout"|"attempts") 
83                                           (Util.del_str ":") (store Rx.integer)
84                         | Build.flag ("debug"|"rotate"|"no-check-names"
85                                      |"inet6"|"ip6-bytestring"|"edns0")
86                         | ip6_dotint
87
88             in Build.key_value_line
89                     "options" Sep.space
90                     (Build.opt_list
91                            options_entry
92                            Sep.space)
93
94 (* View: entry *)
95 let entry = nameserver
96           | domain
97           | search
98           | sortlist
99           | options
100
101 (* View: lns *)
102 let lns = ( empty | comment | entry )*
103
104 (* Variable: filter *)
105 let filter = (incl "/etc/resolv.conf")
106     . Util.stdexcl
107
108 let xfm = transform lns filter
109