[Cfengine-3] / trunk / src / mod_common.c Repository:
ViewVC logotype

Annotation of /trunk/src/mod_common.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download) (as text)

1 : mark 1 /*
2 :    
3 :     Copyright (C) 1994-
4 :     Free Software Foundation, Inc.
5 :    
6 :     This file is part of GNU cfengine - written and maintained
7 :     by Mark Burgess, Dept of Computing and Engineering, Oslo College,
8 :     Dept. of Theoretical physics, University of Oslo
9 :    
10 :     This program is free software; you can redistribute it and/or modify it
11 :     under the terms of the GNU General Public License as published by the
12 :     Free Software Foundation; either version 3, or (at your option) any
13 :     later version.
14 :    
15 :     This program is distributed in the hope that it will be useful,
16 :     but WITHOUT ANY WARRANTY; without even the implied warranty of
17 :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 :     GNU General Public License for more details.
19 :    
20 :     You should have received a copy of the GNU General Public License
21 :     along with this program; if not, write to the Free Software
22 :     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
23 :    
24 :     */
25 :    
26 :     /*****************************************************************************/
27 :     /* */
28 :     /* File: mod_common.c */
29 :     /* */
30 :     /* This is a root node in the syntax tree */
31 :     /* */
32 :     /*****************************************************************************/
33 :    
34 :     #define CF3_MOD_COMMON
35 :    
36 :     #include "cf3.defs.h"
37 :     #include "cf3.extern.h"
38 :    
39 :    
40 :     /*********************************************************/
41 :     /* FnCalls are lvalues in certain promise constraints */
42 :     /*********************************************************/
43 :    
44 :     /* see cf3.defs.h enum fncalltype */
45 :    
46 :     struct FnCallType CF_FNCALL_TYPES[] =
47 :     {
48 :     {"randomint",cf_int,2},
49 :     {"getuid",cf_int,1},
50 :     {"getgid",cf_int,1},
51 :     {"execresult",cf_str,2},
52 :     {"readtcp",cf_str,4},
53 :     {"returnszero",cf_class,2},
54 :     {"isnewerthan",cf_class,2},
55 :     {"accessedbefore",cf_class,2},
56 :     {"changedbefore",cf_class,2},
57 :     {"fileexists",cf_class,1},
58 :     {"isdir",cf_class,1},
59 :     {"islink",cf_class,1},
60 :     {"isplain",cf_class,1},
61 :     {"iprange",cf_class,1},
62 :     {"hostrange",cf_class,2},
63 :     {"isvariable",cf_class,1},
64 :     {"strcmp",cf_class,2},
65 :     {"regcmp",cf_class,2},
66 :     {"isgreaterthan",cf_class,2},
67 :     {"islessthan",cf_class,2},
68 :     {"userexists",cf_class,1},
69 :     {"groupexists",cf_class,1},
70 :     {"readstringlist",cf_slist,4},
71 :     {"readintlist",cf_ilist,4},
72 :     {"readreallist",cf_rlist,4},
73 :     {"irange",cf_irange,2},
74 :     {"rrange",cf_rrange,2},
75 :     {"ondate",cf_int,6},
76 :     {"ago",cf_int,6},
77 :     {"now",cf_int,0},
78 :     {"persiststate",cf_class,3},
79 :     {"erasestate",cf_class,1},
80 :     {NULL,cf_notype}
81 :     };
82 :    
83 :     /*********************************************************/
84 :    
85 :     struct BodySyntax CF_TRANSACTION_BODY[] =
86 :     {
87 :     {"action",cf_opts,"fix,warn,nop"},
88 :     {"ifelapsed",cf_int,CF_VALRANGE},
89 :     {"expireafter",cf_int,CF_VALRANGE},
90 :     {"logstring",cf_str,""},
91 :     {"loglevel",cf_str,""},
92 :     {"audit",cf_opts,CF_BOOL},
93 :     {"reportlevel",cf_opts,"inform,verbose,debug,logonly"},
94 :     {NULL,cf_notype,NULL}
95 :     };
96 :    
97 :     /*********************************************************/
98 :    
99 :     struct BodySyntax CF_DEFINECLASS_BODY[] =
100 :     {
101 :     {"success",cf_slist,CF_IDRANGE},
102 :     {"reportsuccess",cf_str,CF_ANYSTRING},
103 :     {"failure",cf_slist,CF_IDRANGE},
104 :     {"reportfailure",cf_str,CF_ANYSTRING},
105 :     {"alert",cf_slist,CF_IDRANGE},
106 :     {"reportalert",cf_str,CF_ANYSTRING},
107 :     {NULL,cf_notype,NULL}
108 :     };
109 :    
110 :     /*********************************************************/
111 :    
112 :     struct BodySyntax CF_TRIGGER_BODY[] =
113 :     {
114 :     {"followup",cf_slist,CF_FNCALLRANGE},
115 :     {"cleanup",cf_slist,CF_FNCALLRANGE},
116 :     {NULL,cf_notype,NULL}
117 :     };
118 :    
119 :     /*********************************************************/
120 :    
121 :     struct BodySyntax CF_VARBODY[] =
122 :     {
123 :     {"string",cf_str,""},
124 :     {"int",cf_int,CF_INTRANGE},
125 :     {"real",cf_real,CF_REALRANGE},
126 :     {"slist",cf_slist,""},
127 :     {"ilist",cf_ilist,CF_INTRANGE},
128 :     {"rlist",cf_rlist,CF_REALRANGE},
129 :     {"policy",cf_opts,"free,overridable,constant"},
130 :     {NULL,cf_notype,NULL}
131 :     };
132 :    
133 :     /*********************************************************/
134 :    
135 :     struct BodySyntax CF_CLASSBODY[] =
136 :     {
137 :     {"or",cf_clist,CF_CLASSRANGE},
138 :     {"and",cf_clist,CF_CLASSRANGE},
139 :     {"xor",cf_clist,CF_CLASSRANGE},
140 :     {"policy",cf_str,CF_IDRANGE},
141 :     {"dist",cf_rlist,CF_REALRANGE},
142 :     {"expression",cf_str,CF_CLASSRANGE},
143 :     {NULL,cf_notype,NULL}
144 :     };
145 :    
146 :     /*********************************************************/
147 :    
148 :     struct BodySyntax CF_REPORTBODY[] =
149 :     {
150 :     {NULL,cf_notype,NULL}
151 :     };
152 :    
153 :     /***************************************************************/
154 :    
155 :     struct BodySyntax CF_SELECT_BODY[] =
156 :     {
157 :     {"include",cf_slist,".*"},
158 :     {"exclude",cf_slist,".*"},
159 :     {NULL,cf_notype,NULL}
160 :     };
161 :    
162 :     /*********************************************************/
163 :     /* Control bodies */
164 :     /*********************************************************/
165 :    
166 :     struct BodySyntax CFG_CONTROLBODY[] =
167 :     {
168 :     {"bundlesequence",cf_slist,".*"},
169 :     {"inputs",cf_slist,".*"},
170 :     {NULL,cf_notype,NULL}
171 :     };
172 :    
173 :     struct BodySyntax CFA_CONTROLBODY[] =
174 :     {
175 :     {"splaytime",cf_int,".*"},
176 :     {"access",cf_slist,".*"},
177 :     {NULL,cf_notype,NULL}
178 :     };
179 :    
180 :     struct BodySyntax CFS_CONTROLBODY[] =
181 :     {
182 :     {NULL,cf_notype,NULL}
183 :     };
184 :    
185 :    
186 :     struct BodySyntax CFM_CONTROLBODY[] =
187 :     {
188 :     {"emailfrom",cf_str,".*"},
189 :     {"emailto",cf_str,".*"},
190 :     {"threshold",cf_real,"0,1"},
191 :     {"forgetrate",cf_real,"0,1"},
192 :     {NULL,cf_notype,NULL}
193 :     };
194 :    
195 :     struct BodySyntax CFR_CONTROLBODY[] =
196 :     {
197 :     {NULL,cf_notype,NULL}
198 :     };
199 :    
200 :     struct BodySyntax CFEX_CONTROLBODY[] =
201 :     {
202 :     {"schedule",cf_ilist,".*"},
203 :     {NULL,cf_notype,NULL}
204 :     };
205 :    
206 :    
207 :     /*********************************************************/
208 :    
209 :     /* This list is for checking free standing body lval => rval bindings */
210 :    
211 :     struct SubTypeSyntax CF_ALL_BODIES[] =
212 :     {
213 :     {"common","control",CFG_CONTROLBODY},
214 :     {"agent","control",CFA_CONTROLBODY},
215 :     {"server","control",CFS_CONTROLBODY},
216 :     {"monitor","control",CFM_CONTROLBODY},
217 :    
218 :     // get others from modules e.g. "agent","files",CF_FILES_BODIES,
219 :    
220 :     {NULL,NULL,NULL}
221 :     };
222 :    
223 :    
224 :     /* REMEMBER TO REGISTER THESE IN cf3.extern.h */
225 :    
226 :     /*********************************************************/
227 :     /* */
228 :     /* Constraint values/types */
229 :     /* */
230 :     /*********************************************************/
231 :    
232 :     /* This is where we place lval => rval bindings that
233 :     apply to more than one subtype, e.g. generic
234 :     processing behavioural details */
235 :    
236 :     struct BodySyntax CF_COMMON_BODIES[] =
237 :     {
238 :     {CF_TRANSACTION,cf_body,CF_TRANSACTION_BODY},
239 :     {CF_DEFINECLASSES,cf_body,CF_DEFINECLASS_BODY},
240 :     {"trigger",cf_body,CF_TRIGGER_BODY},
241 :     {"name_select",cf_body,CF_SELECT_BODY},
242 :     {NULL,cf_notype,NULL}
243 :     };
244 :    
245 :     /*********************************************************/
246 :    
247 :     /* This is where we place promise subtypes that apply
248 :     to more than one type of bundle, e.g. agent,server.. */
249 :    
250 :     struct SubTypeSyntax CF_COMMON_SUBTYPES[] =
251 :     {
252 :     {"*","vars",CF_VARBODY},
253 :     {"*","classes",CF_CLASSBODY},
254 :     {"*","report",CF_REPORTBODY},
255 :     {"agent","*",CF_COMMON_BODIES},
256 :     {NULL,NULL,NULL}
257 :     };
258 :    
259 :     /*********************************************************/
260 :     /* THIS IS WHERE TO ATTACH SYNTAX MODULES */
261 :     /*********************************************************/
262 :    
263 :     /* Read in all parsable Bundle definitions */
264 :    
265 :     struct SubTypeSyntax *CF_ALL_SUBTYPES[CF3_MODULES] =
266 :     {
267 :     CF_COMMON_SUBTYPES, /* Add modules after this */
268 :     CF_FILES_SUBTYPES, /* mod_files.c */
269 :     CF_EXEC_SUBTYPES, /* mod_exec.c */
270 :     CF_PROCESS_SUBTYPES,/* mod_process.c */
271 :    
272 :     /* update CF3_MODULES in cf3.defs.h */
273 :     };

Administrator
ViewVC Help
Powered by ViewVC 1.0.3