Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / protocols.aug
1 (*
2 Module: Protocols
3   Parses /etc/protocols
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man 5 protocols` where possible.
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    To be documented
15
16 About: Configuration files
17    This lens applies to /etc/protocols. See <filter>.
18
19 About: Examples
20    The <Test_Protocols> file contains various examples and tests.
21 *)
22
23
24 module Protocols =
25
26 autoload xfm
27
28 let protoname = /[^# \t\n]+/
29
30 (* View: entry *)
31 let entry =
32       let protocol = [ label "protocol" . store protoname ]
33    in let number   = [ label "number" . store Rx.integer ]
34    in let alias    = [ label "alias" . store protoname ]
35    in [ seq "protocol" . protocol
36       . Sep.space . number
37       . (Sep.space . Build.opt_list alias Sep.space)?
38       . Util.comment_or_eol ]
39
40 (* View: lns
41      The protocols lens *)
42 let lns = (Util.empty | Util.comment | entry)*
43
44 (* Variable: filter *)
45 let filter = incl "/etc/protocols"
46
47 let xfm = transform lns filter