Imported Upstream version 1.3.0
[platform/upstream/augeas.git] / lenses / sip_conf.aug
1 (*
2 Module: Sip_Conf
3   Parses /etc/asterisk/sip.conf
4
5 Author: Rob Tucker <rtucker@mozilla.com>
6
7 About: Reference
8   Lens parses the sip.conf with support for template structure
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/asterisk/sip.conf. See <filter>.
18 *)
19
20 module Sip_Conf =
21   autoload xfm
22
23 (************************************************************************
24  * INI File settings
25  *************************************************************************)
26
27 let comment        = IniFile.comment IniFile.comment_re IniFile.comment_default
28 let sep            = IniFile.sep IniFile.sep_re IniFile.sep_default
29 let empty          = IniFile.empty
30 let eol            = IniFile.eol
31 let comment_or_eol = comment | eol
32
33
34 let entry    = IniFile.indented_entry IniFile.entry_re sep comment
35
36 let text_re = Rx.word
37 let tmpl    =
38   let is_tmpl = [ label "@is_template" . Util.del_str "!" ]
39     in let use_tmpl = [ label "@use_template" . store Rx.word ]
40     in let comma = Util.delim ","
41     in Util.del_str "(" . Sep.opt_space
42       . Build.opt_list (is_tmpl|use_tmpl) comma
43       . Sep.opt_space . Util.del_str ")"
44 let title_comment_re = /[ \t]*[#;].*$/
45
46 let title_comment = [ label "#title_comment"
47   . store title_comment_re ]
48 let title   = label "title" . Util.del_str "["
49             . store text_re . Util.del_str "]"
50             . tmpl? . title_comment? . eol
51 let record  = IniFile.record title entry
52
53 let lns     = IniFile.lns record comment
54
55 let filter = incl "/etc/asterisk/sip.conf"
56
57 let xfm = transform lns filter