Parses channels.conf files
Author: Raphael Pinson raphink@gmail.com
| Channels | Parses channels.conf files | 
| Reference | See http://linuxtv.org | 
| License | This file is licenced under the LGPL v2+, like the rest of Augeas. | 
| Lens Usage | To be documented | 
| Configuration files | This lens applies to channels.conf files. | 
| Examples | The Test_Channels file contains various examples and tests. | 
| USEFUL PRIMITIVES | |
| eol | |
| comment | |
| equal | |
| colon | |
| comma | |
| semicol | |
| plus | |
| arroba | |
| no_colon | |
| no_semicolon | |
| FUNCTIONS | |
| field | A generic field | 
| field_no_colon | A field storing no_colon | 
| field_int | A field storing Rx.integer | 
| field_word | A field storing Rx.word | 
| ENTRIES | |
| vpid | |
| langs | |
| apid | |
| tpid | |
| caid | |
| entry | |
| entry_or_comment | |
| group | |
| lns | 
The Test_Channels file contains various examples and tests.
let field_int (name:string) = field name Rx.integer 
A field storing Rx.integer
let apid = let codec = [ arroba . label "codec" . store Rx.integer ] in let options = equal . ( (langs . codec?) | codec ) in let apid_entry (lbl:string) = [ label lbl . store Rx.integer . options? ] in Build.opt_list (apid_entry "apid") comma . ( semicol . Build.opt_list (apid_entry "apid_dolby") comma )? 
let entry = [ label "entry" . store no_semicolon . (semicol . field_no_colon "provider")? . colon . field_int "frequency" . colon . field_word "parameter" . colon . field_word "signal_source" . colon . field_int "symbol_rate" . colon . vpid . colon . apid . colon . tpid . colon . caid . colon . field_int "sid" . colon . field_int "nid" . colon . field_int "tid" . colon . field_int "rid" . eol ] 
let eol = Util.eol 
let comment = Util.comment_generic /;[ \t]*/ "; " 
let equal = Sep.equal 
let colon = Sep.colon 
let comma = Sep.comma 
let semicol = Util.del_str ";" 
let plus = Util.del_str "+" 
let arroba = Util.del_str "@" 
let no_colon = /[^: \t\n][^:\n]*[^: \t\n]|[^:\n]/ 
let no_semicolon = /[^;\n]+/ 
A generic field
let field (name:string) (sto:regexp) = [ label name . store sto ] 
A field storing no_colon
let field_no_colon (name:string) = field name no_colon 
A field storing Rx.integer
let field_int (name:string) = field name Rx.integer 
One or more digits
let integer = /[0-9]+/ 
A field storing Rx.word
let field_word (name:string) = field name Rx.word 
An alphanumeric string
let word = /[A-Za-z0-9_.-]+/ 
let vpid = let codec = [ equal . label "codec" . store Rx.integer ] in let vpid_entry (lbl:string) = [ label lbl . store Rx.integer . codec? ] in vpid_entry "vpid" . ( plus . vpid_entry "vpid_pcr" )? 
let langs = let lang = [ label "lang" . store Rx.word ] in Build.opt_list lang plus 
let apid = let codec = [ arroba . label "codec" . store Rx.integer ] in let options = equal . ( (langs . codec?) | codec ) in let apid_entry (lbl:string) = [ label lbl . store Rx.integer . options? ] in Build.opt_list (apid_entry "apid") comma . ( semicol . Build.opt_list (apid_entry "apid_dolby") comma )? 
let tpid = let tpid_bylang = [ label "tpid_bylang" . store Rx.integer . (equal . langs)? ] in field_int "tpid" . ( semicol . Build.opt_list tpid_bylang comma )? 
let caid = let caid_entry = [ label "caid" . store Rx.word ] in Build.opt_list caid_entry comma 
let entry = [ label "entry" . store no_semicolon . (semicol . field_no_colon "provider")? . colon . field_int "frequency" . colon . field_word "parameter" . colon . field_word "signal_source" . colon . field_int "symbol_rate" . colon . vpid . colon . apid . colon . tpid . colon . caid . colon . field_int "sid" . colon . field_int "nid" . colon . field_int "tid" . colon . field_int "rid" . eol ] 
let entry_or_comment = entry | comment 
let group = [ Util.del_str ":" . label "group" . store no_colon . eol . entry_or_comment* ] 
let lns = entry_or_comment* . group*