3 Parses channels.conf files
5 Author: Raphael Pinson <raphink@gmail.com>
8 See http://linuxtv.org/vdrwiki/index.php/Syntax_of_channels.conf
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
17 This lens applies to channels.conf files.
20 The <Test_Channels> file contains various examples and tests.
25 (************************************************************************
26 * Group: USEFUL PRIMITIVES
27 *************************************************************************)
33 let comment = Util.comment_generic /;[ \t]*/ "; "
46 let semicol = Util.del_str ";"
49 let plus = Util.del_str "+"
52 let arroba = Util.del_str "@"
55 let no_colon = /[^: \t\n][^:\n]*[^: \t\n]|[^:\n]/
57 (* View: no_semicolon *)
58 let no_semicolon = /[^;\n]+/
61 (************************************************************************
63 *************************************************************************)
67 let field (name:string) (sto:regexp) = [ label name . store sto ]
69 (* View: field_no_colon
70 A <field> storing <no_colon> *)
71 let field_no_colon (name:string) = field name no_colon
74 A <field> storing <Rx.integer> *)
75 let field_int (name:string) = field name Rx.integer
78 A <field> storing <Rx.word> *)
79 let field_word (name:string) = field name Rx.word
82 (************************************************************************
84 *************************************************************************)
89 [ equal . label "codec" . store Rx.integer ]
90 in let vpid_entry (lbl:string) =
91 [ label lbl . store Rx.integer . codec? ]
93 . ( plus . vpid_entry "vpid_pcr" )?
99 [ label "lang" . store Rx.word ]
100 in Build.opt_list lang plus
106 [ arroba . label "codec" . store Rx.integer ]
108 equal . ( (langs . codec?) | codec )
109 in let apid_entry (lbl:string) =
110 [ label lbl . store Rx.integer . options? ]
111 in Build.opt_list (apid_entry "apid") comma
113 . Build.opt_list (apid_entry "apid_dolby") comma )?
118 [ label "tpid_bylang" . store Rx.integer
121 . ( semicol . Build.opt_list tpid_bylang comma )?
126 [ label "caid" . store Rx.word ]
127 in Build.opt_list caid_entry comma
130 let entry = [ label "entry" . store no_semicolon
131 . (semicol . field_no_colon "provider")? . colon
132 . field_int "frequency" . colon
133 . field_word "parameter" . colon
134 . field_word "signal_source" . colon
135 . field_int "symbol_rate" . colon
140 . field_int "sid" . colon
141 . field_int "nid" . colon
142 . field_int "tid" . colon
143 . field_int "rid" . eol ]
145 (* View: entry_or_comment *)
146 let entry_or_comment = entry | comment
150 [ Util.del_str ":" . label "group"
151 . store no_colon . eol
152 . entry_or_comment* ]
155 let lns = entry_or_comment* . group*