Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / cgrules.aug
1 (*
2 Module: cgrules
3     Parses /etc/cgrules.conf
4
5 Author:
6     Raphael Pinson          <raphink@gmail.com>
7     Ivana Hutarova Varekova <varekova@redhat.com>
8
9 About: Licence
10     This file is licensed under the LGPL v2+, like the rest of Augeas.
11
12 About: Lens Usage
13     Sample usage of this lens in augtool:
14
15 About: Configuration files
16    This lens applies to /etc/cgconfig.conf. See <filter>.
17  *)
18
19 module Cgrules =
20    autoload xfm
21
22 (************************************************************************
23  * Group:                 USEFUL PRIMITIVES
24  *************************************************************************)
25
26 (* Group: Separators *)
27 (* Variable: ws *)
28    let ws = del /[ \t]+/ " "
29
30 (* Group: Comments and empty lines *)
31 (* Variable: eol *)
32    let eol     = Util.eol
33
34 (* Variable: comment *)
35    let comment = Util.comment
36
37 (* Variable: empty *)
38    let empty   = Util.empty
39
40 (* Group: Generic primitive definitions *)
41 (* Variable: name *)
42    let name       = /[^@%# \t\n][^ \t\n]*/
43 (* Variable: ctrl_key *)
44    let ctrl_key   = /[^ \t\n\/]+/
45 (* Variable: ctrl_value *)
46    let ctrl_value = /[^ \t\n]+/
47
48 (************************************************************************
49  * Group:                 CONTROLLER
50  *************************************************************************)
51
52 (* Variable: controller *)
53 let controller =  ws . [ key ctrl_key . ws . store ctrl_value ]
54
55 let more_controller = Util.del_str "%" . controller . eol
56
57 (************************************************************************
58  * Group:                 RECORDS
59  *************************************************************************)
60
61 let generic_record (lbl:string) (lns:lens) =
62                   [ label lbl . lns
63                   . controller . eol
64                   . more_controller* ]
65
66 (* Variable: user_record *)
67 let user_record = generic_record "user" (store name)
68
69 (* Variable: group_record *)
70 let group_record = generic_record "group" (Util.del_str "@" . store name)
71
72 (************************************************************************
73  * Group:                        LENS & FILTER
74  *************************************************************************)
75
76 (* View: lns
77      The main lens, any amount of
78        * <empty> lines
79        * <comment>
80        * <user_record>
81        * <group_record>
82 *)
83 let lns =  (  empty | comment | user_record | group_record )*
84
85 let xfm = transform lns (incl "/etc/cgrules.conf")