Parent Directory
|
Revision Log
Revision 1 - (view) (download) (as text)
| 1 : | mark | 1 | /*****************************************************************************/ |
| 2 : | /* */ | ||
| 3 : | /* File: cf3.defs.h */ | ||
| 4 : | /* */ | ||
| 5 : | /* Created: Thu Aug 2 11:09:47 2007 */ | ||
| 6 : | /* */ | ||
| 7 : | /* Author: > */ | ||
| 8 : | /* */ | ||
| 9 : | /* Revision: $Id$ */ | ||
| 10 : | /* */ | ||
| 11 : | /* Description: */ | ||
| 12 : | /* */ | ||
| 13 : | /*****************************************************************************/ | ||
| 14 : | |||
| 15 : | /* These files are hard links to the cfengine 2 sources */ | ||
| 16 : | |||
| 17 : | #include "cf.defs.h" | ||
| 18 : | #include "cf.extern.h" | ||
| 19 : | |||
| 20 : | #undef VERSION | ||
| 21 : | |||
| 22 : | #include "conf.h" | ||
| 23 : | |||
| 24 : | /*************************************************************************/ | ||
| 25 : | /* Fundamental (meta) types */ | ||
| 26 : | /*************************************************************************/ | ||
| 27 : | |||
| 28 : | #define CF_SCALAR 's' | ||
| 29 : | #define CF_LIST 'l' | ||
| 30 : | #define CF_FNCALL 'f' | ||
| 31 : | #define CF_STACK 'k' | ||
| 32 : | |||
| 33 : | #define CF_NOPROMISEE 'X' | ||
| 34 : | |||
| 35 : | #define CF_INBODY 1 | ||
| 36 : | #define CF_INBUNDLE 2 | ||
| 37 : | |||
| 38 : | #define CF_MAX_NESTING 3 | ||
| 39 : | |||
| 40 : | /*************************************************************************/ | ||
| 41 : | /* Parsing and syntax tree structures */ | ||
| 42 : | /*************************************************************************/ | ||
| 43 : | |||
| 44 : | #define CF_DEFINECLASSES "classes" | ||
| 45 : | #define CF_TRANSACTION "transaction" | ||
| 46 : | |||
| 47 : | #define CF3_MODULES 4 /* This value needs to be incremented when adding modules */ | ||
| 48 : | |||
| 49 : | /*************************************************************************/ | ||
| 50 : | |||
| 51 : | struct PromiseParser | ||
| 52 : | { | ||
| 53 : | char *block; /* body/bundle */ | ||
| 54 : | char *blocktype; | ||
| 55 : | char *blockid; | ||
| 56 : | |||
| 57 : | char *filename; | ||
| 58 : | int line_pos; | ||
| 59 : | int line_no; | ||
| 60 : | |||
| 61 : | int arg_nesting; | ||
| 62 : | int list_nesting; | ||
| 63 : | |||
| 64 : | char *lval; | ||
| 65 : | void *rval; | ||
| 66 : | char rtype; | ||
| 67 : | |||
| 68 : | char *promiser; | ||
| 69 : | void *promisee; | ||
| 70 : | |||
| 71 : | char *currentid; | ||
| 72 : | char *currentstring; | ||
| 73 : | char *currenttype; | ||
| 74 : | char *currentclasses; | ||
| 75 : | |||
| 76 : | struct Bundle *currentbundle; | ||
| 77 : | struct Body *currentbody; | ||
| 78 : | struct Promise *currentpromise; | ||
| 79 : | struct SubType *currentstype; | ||
| 80 : | struct Rlist *useargs; | ||
| 81 : | |||
| 82 : | struct RList *currentRlist; | ||
| 83 : | |||
| 84 : | char *currentfnid[CF_MAX_NESTING]; | ||
| 85 : | struct Rlist *giveargs[CF_MAX_NESTING]; | ||
| 86 : | struct FnCall *currentfncall[CF_MAX_NESTING]; | ||
| 87 : | }; | ||
| 88 : | |||
| 89 : | /*************************************************************************/ | ||
| 90 : | /* Abstract datatypes */ | ||
| 91 : | /*************************************************************************/ | ||
| 92 : | |||
| 93 : | enum cfdatatype | ||
| 94 : | { | ||
| 95 : | cf_str, | ||
| 96 : | cf_int, | ||
| 97 : | cf_real, | ||
| 98 : | cf_slist, | ||
| 99 : | cf_ilist, | ||
| 100 : | cf_rlist, | ||
| 101 : | cf_opts, | ||
| 102 : | cf_olist, | ||
| 103 : | cf_body, | ||
| 104 : | cf_class, | ||
| 105 : | cf_clist, | ||
| 106 : | cf_irange, | ||
| 107 : | cf_rrange, | ||
| 108 : | cf_notype | ||
| 109 : | }; | ||
| 110 : | |||
| 111 : | /*************************************************************************/ | ||
| 112 : | /* Syntax module range/pattern constants for type validation */ | ||
| 113 : | /*************************************************************************/ | ||
| 114 : | |||
| 115 : | #define CF_BOOL "true,false,yes,no,on,off" | ||
| 116 : | #define CF_BUNDLE (void*)1234 /* any non-null value, not used */ | ||
| 117 : | |||
| 118 : | #define CF_HIGHINIT 99999 | ||
| 119 : | #define CF_LOWINIT -999999 | ||
| 120 : | |||
| 121 : | #define CF_VALRANGE "0,999999" | ||
| 122 : | #define CF_INTRANGE "-9999999,999999" | ||
| 123 : | #define CF_REALRANGE "-9.99999E100,9.99999E100" | ||
| 124 : | |||
| 125 : | #define CF_CLASSRANGE "[a-zA-Z0-9_!&|.()]+" | ||
| 126 : | #define CF_IDRANGE "[a-zA-Z0-9_]+" | ||
| 127 : | #define CF_FNCALLRANGE "[a-zA-Z0-9_().$@]+" | ||
| 128 : | #define CF_ANYSTRING ".*" | ||
| 129 : | #define CF_PATHRANGE "/.*" | ||
| 130 : | #define CF_TIMERANGE "0,4026531839" | ||
| 131 : | |||
| 132 : | |||
| 133 : | /*************************************************************************/ | ||
| 134 : | |||
| 135 : | struct BodySyntax | ||
| 136 : | { | ||
| 137 : | char *lval; | ||
| 138 : | enum cfdatatype dtype; | ||
| 139 : | void *range; /* either char or struct BodySyntax **/ | ||
| 140 : | }; | ||
| 141 : | |||
| 142 : | /*************************************************************************/ | ||
| 143 : | |||
| 144 : | struct SubTypeSyntax | ||
| 145 : | { | ||
| 146 : | char *btype; | ||
| 147 : | char *subtype; | ||
| 148 : | struct BodySyntax *bs; | ||
| 149 : | }; | ||
| 150 : | |||
| 151 : | /*************************************************************************/ | ||
| 152 : | |||
| 153 : | struct FnCallType | ||
| 154 : | { | ||
| 155 : | char *name; | ||
| 156 : | enum cfdatatype dtype; | ||
| 157 : | int numargs; | ||
| 158 : | }; | ||
| 159 : | |||
| 160 : | /*************************************************************************/ | ||
| 161 : | |||
| 162 : | enum fncalltype | ||
| 163 : | { | ||
| 164 : | cfn_randomint, | ||
| 165 : | cfn_getuid, | ||
| 166 : | cfn_getgid, | ||
| 167 : | cfn_execresult, | ||
| 168 : | cfn_readtcp, | ||
| 169 : | cfn_returnszero, | ||
| 170 : | cfn_isnewerthan, | ||
| 171 : | cfn_accessedbefore, | ||
| 172 : | cfn_changedbefore, | ||
| 173 : | cfn_fileexists, | ||
| 174 : | cfn_isdir, | ||
| 175 : | cfn_islink, | ||
| 176 : | cfn_isplain, | ||
| 177 : | cfn_iprange, | ||
| 178 : | cfn_hostrange, | ||
| 179 : | cfn_isvariable, | ||
| 180 : | cfn_strcmp, | ||
| 181 : | cfn_regcmp, | ||
| 182 : | cfn_isgreaterthan, | ||
| 183 : | cfn_islessthan, | ||
| 184 : | cfn_userexists, | ||
| 185 : | cfn_groupexists, | ||
| 186 : | cfn_readstringlist, | ||
| 187 : | cfn_readintlist, | ||
| 188 : | cfn_readreallist, | ||
| 189 : | cfn_irange, | ||
| 190 : | cfn_rrange, | ||
| 191 : | cfn_date, | ||
| 192 : | cfn_ago, | ||
| 193 : | cfn_now, | ||
| 194 : | cfn_persiststate, | ||
| 195 : | cfn_erasestate, | ||
| 196 : | cfn_unknown, | ||
| 197 : | }; | ||
| 198 : | |||
| 199 : | /*************************************************************************/ | ||
| 200 : | |||
| 201 : | struct Bundle | ||
| 202 : | { | ||
| 203 : | char *type; | ||
| 204 : | char *name; | ||
| 205 : | struct Rlist *args; | ||
| 206 : | struct SubType *subtypes; | ||
| 207 : | struct Bundle *next; | ||
| 208 : | }; | ||
| 209 : | |||
| 210 : | /*************************************************************************/ | ||
| 211 : | |||
| 212 : | struct Body | ||
| 213 : | { | ||
| 214 : | char *type; | ||
| 215 : | char *name; | ||
| 216 : | struct Rlist *args; | ||
| 217 : | struct Constraint *conlist; | ||
| 218 : | struct Body *next; | ||
| 219 : | }; | ||
| 220 : | |||
| 221 : | /*************************************************************************/ | ||
| 222 : | |||
| 223 : | struct SubType | ||
| 224 : | { | ||
| 225 : | char *name; | ||
| 226 : | struct Promise *promiselist; | ||
| 227 : | struct SubType *next; | ||
| 228 : | }; | ||
| 229 : | |||
| 230 : | /*************************************************************************/ | ||
| 231 : | |||
| 232 : | struct Promise | ||
| 233 : | { | ||
| 234 : | char *classes; | ||
| 235 : | char *promiser; | ||
| 236 : | void *promisee; /* Can be a general rval */ | ||
| 237 : | char petype; /* rtype of promisee - list or scalar recipient? */ | ||
| 238 : | int lineno; | ||
| 239 : | char *bundle; | ||
| 240 : | char done; | ||
| 241 : | struct Audit *audit; | ||
| 242 : | struct Constraint *conlist; | ||
| 243 : | struct Promise *next; | ||
| 244 : | }; | ||
| 245 : | |||
| 246 : | /*************************************************************************/ | ||
| 247 : | |||
| 248 : | struct Constraint | ||
| 249 : | { | ||
| 250 : | char *lval; | ||
| 251 : | void *rval; /* should point to either string, Rlist or FnCall */ | ||
| 252 : | char type; /* scalar, list, or function */ | ||
| 253 : | char *classes; /* only used within bodies */ | ||
| 254 : | int lineno; | ||
| 255 : | struct Audit *audit; | ||
| 256 : | struct Constraint *next; | ||
| 257 : | }; | ||
| 258 : | |||
| 259 : | /*************************************************************************/ | ||
| 260 : | /* Rvalues and lists - basic workhorse structure */ | ||
| 261 : | /*************************************************************************/ | ||
| 262 : | |||
| 263 : | /* | ||
| 264 : | In an OO language one would probably think of Rval as a parent class | ||
| 265 : | and CF_SCALAR, CF_LIST and CF_FNCALL as children. There is more or | ||
| 266 : | less a sub-type polymorphism going on in the code around these structures, | ||
| 267 : | but it is not a proper inheritance relationship as lists could | ||
| 268 : | contain functions which return lists or scalars etc.. | ||
| 269 : | |||
| 270 : | */ | ||
| 271 : | |||
| 272 : | /*************************************************************************/ | ||
| 273 : | |||
| 274 : | struct Rval | ||
| 275 : | { | ||
| 276 : | void *item; /* (char *), (struct Rlist *), or (struct FnCall) */ | ||
| 277 : | char rtype; /* Points to CF_SCALAR, CF_LIST, CF_FNCALL usually */ | ||
| 278 : | }; | ||
| 279 : | |||
| 280 : | /*************************************************************************/ | ||
| 281 : | |||
| 282 : | struct Rlist | ||
| 283 : | { | ||
| 284 : | void *item; | ||
| 285 : | char type; | ||
| 286 : | struct Rlist *state_ptr; /* Points to "current" state/element of sub-list */ | ||
| 287 : | struct Rlist *next; | ||
| 288 : | }; | ||
| 289 : | |||
| 290 : | /*************************************************************************/ | ||
| 291 : | |||
| 292 : | struct FnCall | ||
| 293 : | { | ||
| 294 : | char *name; | ||
| 295 : | struct Rlist *args; | ||
| 296 : | int argc; | ||
| 297 : | }; | ||
| 298 : | |||
| 299 : | /*******************************************************************/ | ||
| 300 : | /* Variable processing */ | ||
| 301 : | /*******************************************************************/ | ||
| 302 : | |||
| 303 : | struct Scope /* $(bundlevar) $(scope.name) */ | ||
| 304 : | { | ||
| 305 : | char *scope; /* Name of scope */ | ||
| 306 : | char *classes; /* Private context classes */ | ||
| 307 : | struct CfAssoc *hashtable[CF_HASHTABLESIZE]; /* Variable heap */ | ||
| 308 : | struct Scope *next; | ||
| 309 : | }; | ||
| 310 : | |||
| 311 : | /*******************************************************************/ | ||
| 312 : | |||
| 313 : | struct CfAssoc /* variable reference linkage , with metatype*/ | ||
| 314 : | { | ||
| 315 : | char *lval; | ||
| 316 : | void *rval; | ||
| 317 : | char rtype; | ||
| 318 : | enum cfdatatype dtype; | ||
| 319 : | }; | ||
| 320 : | |||
| 321 : | /*******************************************************************/ | ||
| 322 : | /* Output options */ | ||
| 323 : | /*******************************************************************/ | ||
| 324 : | |||
| 325 : | struct CfOutput | ||
| 326 : | { | ||
| 327 : | FILE *stream; | ||
| 328 : | //graphfile | ||
| 329 : | // graph context - or adjacency matrix? | ||
| 330 : | }; | ||
| 331 : | |||
| 332 : | /*******************************************************************/ | ||
| 333 : | /* Return value signalling */ | ||
| 334 : | /*******************************************************************/ | ||
| 335 : | |||
| 336 : | #define FNCALL_NOP -1 | ||
| 337 : | #define FNCALL_SUCCESS 0 | ||
| 338 : | #define FNCALL_FAILURE 1 | ||
| 339 : | #define FNCALL_ALERT 2 | ||
| 340 : | |||
| 341 : | struct FnCallStatus /* from builtin functions */ | ||
| 342 : | { | ||
| 343 : | int status; | ||
| 344 : | char message[CF_BUFSIZE]; | ||
| 345 : | char fncall_classes[CF_BUFSIZE]; /* set by functions in the form fncall_CLASS */ | ||
| 346 : | }; | ||
| 347 : | |||
| 348 : | #include "prototypes3.h" |
| Administrator | ViewVC Help |
| Powered by ViewVC 1.0.3 |