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