Imported Upstream version 1.3.0
[platform/upstream/augeas.git] / lenses / postfix_transport.aug
1 (*
2 Module: Postfix_Transport
3   Parses /etc/postfix/transport
4
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man 5 transport` 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/postfix/transport. See <filter>.
18
19 About: Examples
20    The <Test_Postfix_Transport> file contains various examples and tests.
21 *)
22
23 module Postfix_Transport =
24
25 autoload xfm
26
27 (* View: space_or_eol *)
28 let space_or_eol = del /([ \t]*\n)?[ \t]+/ " "
29
30 (* View: colon *)
31 let colon = Sep.colon
32
33 (* View: nexthop *)
34 let nexthop =
35      let host_re = "[" . Rx.word . "]" | /[A-Za-z]([^\n]*[^ \t\n])?/
36   in [ label "nexthop" . (store host_re)? ]
37
38 (* View: transport *)
39 let transport = [ label "transport" . (store Rx.word)? ]
40                 . colon . nexthop
41
42 (* View: nexthop_smtp *)
43 let nexthop_smtp =
44      let host_re = "[" . Rx.word . "]" | Rx.word
45   in [ label "host" . store host_re ]
46      . colon
47      . [ label "port" . store Rx.integer ]
48
49 (* View: record *)
50 let record = [ label "pattern" . store /[A-Za-z0-9@\*.-]+/
51              . space_or_eol . (transport | nexthop_smtp)
52              . Util.eol ]
53
54 (* View: lns *)
55 let lns = (Util.empty | Util.comment | record)*
56
57 (* Variable: filter *)
58 let filter = incl "/etc/postfix/transport"
59
60 let xfm = transform lns filter