1(*
2Module: Postfix_Transport
3  Parses /etc/postfix/transport
4
5Author: Raphael Pinson <raphael.pinson@camptocamp.com>
6
7About: Reference
8  This lens tries to keep as close as possible to `man 5 transport` where possible.
9
10About: License
11   This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13About: Lens Usage
14   To be documented
15
16About: Configuration files
17   This lens applies to /etc/postfix/transport. See <filter>.
18
19About: Examples
20   The <Test_Postfix_Transport> file contains various examples and tests.
21*)
22
23module Postfix_Transport =
24
25autoload xfm
26
27(* View: space_or_eol *)
28let space_or_eol = del /([ \t]*\n)?[ \t]+/ " "
29
30(* View: colon *)
31let colon = Sep.colon
32
33(* View: nexthop *)
34let nexthop =
35     let host_re = "[" . Rx.word . "]" | /[A-Za-z]([^\n]*[^ \t\n])?/
36  in [ label "nexthop" . (store host_re)? ]
37
38(* View: transport *)
39let transport = [ label "transport" . (store Rx.word)? ]
40                . colon . nexthop
41
42(* View: nexthop_smtp *)
43let 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 *)
50let record = [ label "pattern" . store /[A-Za-z0-9@\*.-]+/
51             . space_or_eol . (transport | nexthop_smtp)
52             . Util.eol ]
53
54(* View: lns *)
55let lns = (Util.empty | Util.comment | record)*
56
57(* Variable: filter *)
58let filter = incl "/etc/postfix/transport"
59           . incl "/usr/local/etc/postfix/transport"
60
61let xfm = transform lns filter
62