1 (* Intefraces module for Augeas
2 Author: Free Ekanayaka <free@64studio.com>
4 Reference: man dhclient.conf
5 The only difference with the reference syntax is that this lens assumes
6 that statements end with a new line, while the reference syntax allows
7 new statements to be started right after the trailing ";" of the
8 previous statement. This should not be a problem in real-life
9 configuration files as statements get usually splitted across several
10 lines, rather than merged in a single one.
12 TODO: support the "default", "supersede", "append" and "prepend"
20 (************************************************************************
22 *************************************************************************)
25 let comment = Util.comment
26 let comment_or_eol = Util.comment_or_eol
27 let empty = Util.empty
29 (* Define separators *)
30 let sep_spc = del /[ \t\n]+/ " "
31 let sep_scl = del /[ \t]*;/ ";"
32 let sep_obr = del /[ \t\n]*\{\n]*/ " {\n"
33 let sep_cbr = del /[ \t\n]*\}/ " }"
34 let sep_com = del /[ \t\n]*,[ \t\n]*/ ","
35 let sep_slh = del "\/" "/"
36 let sep_col = del ":" ":"
37 let sep_eq = del /[ \t]*=[ \t]*/ "="
39 (* Define basic types *)
40 let word = /[A-Za-z0-9_.-]+(\[[0-9]+\])?/
44 (* TODO: there could be a " " in the middle of a value ... *)
45 let sto_to_spc = store /[^\\#,;{}" \t\n]+|"[^\\#"\n]+"/
46 let sto_to_scl = store /[^ \t][^;\n]+[^ \t]|[^ \t;\n]+/
47 let rfc_code = [ key "code" . sep_spc . store word ]
49 . [ label "value" . sto_to_scl ]
50 let sto_number = store /[0-9][0-9]*/
52 (************************************************************************
54 *************************************************************************)
56 let stmt_simple_re = "timeout"
62 | "do-forward-updates"
65 let stmt_simple = [ key stmt_simple_re
72 (************************************************************************
74 *************************************************************************)
76 (* TODO: the array could also be empty, like in the request statement *)
77 let stmt_array_re = "media"
81 let stmt_array = [ key stmt_array_re
83 . counter "stmt_array"
84 . [ seq "stmt_array" . sto_to_spc ]
85 . [ sep_com . seq "stmt_array" . sto_to_spc ]*
86 . sep_scl . comment_or_eol ]
88 (************************************************************************
90 *************************************************************************)
92 let stmt_hash_re = "send"
95 let stmt_hash = [ key stmt_hash_re
97 . [ key word . sep_spc . (sto_to_spc|rfc_code) ]
101 (************************************************************************
103 *************************************************************************)
105 let stmt_block_re = "interface"
109 let stmt_block_opt_re = "interface"
116 | "vendor option space"
118 (* TODO: some options could take no argument like bootp *)
119 let stmt_block_opt = [ key stmt_block_opt_re
125 let stmt_block_date_re
130 let stmt_block_date = [ key stmt_block_date_re
131 . [ sep_spc . label "weekday" . sto_number ]
132 . [ sep_spc . label "year" . sto_number ]
133 . [ sep_slh . label "month" . sto_number ]
134 . [ sep_slh . label "day" . sto_number ]
135 . [ sep_spc . label "hour" . sto_number ]
136 . [ sep_col . label "minute" . sto_number ]
137 . [ sep_col . label "second" . sto_number ]
141 let stmt_block_arg = sep_spc . sto_to_spc
143 let stmt_block_entry = sep_spc
149 let stmt_block = [ key stmt_block_re
156 (************************************************************************
158 *************************************************************************)
160 let statement = (stmt_simple|stmt_array|stmt_hash|stmt_block)
166 let filter = incl "/etc/dhcp3/dhclient.conf"
169 let xfm = transform lns filter