10
#define LOG_NFACILITIES 24 /* current number of syslog facilities */
11
#define CNFFUNC_MAX_ARGS 32
12
/**< maximum number of arguments that any function can have (among
13
* others, this is used to size data structures).
16
extern int Debug; /* 1 if in debug mode, 0 otherwise -- to be enhanced */
31
cnfobjType2str(enum cnfobjType ot)
58
default:return "error: invalid cnfobjType";
62
enum cnfactType { CNFACT_V2, CNFACT_LEGACY };
64
/* a variant type, for example used for expression evaluation
65
* 2011-07-15/rger: note that there exists a "legacy" object var_t,
66
* which implements the same idea, but in a suboptimal manner. I have
67
* stipped this down as much as possible, but will keep it for a while
68
* to avoid unnecessary complexity during development. TODO: in the long
69
* term, var_t shall be replaced by struct var.
76
struct json_object *json;
78
char datatype; /* 'N' number, 'S' string, 'J' JSON, 'A' array
79
* Note: 'A' is only supported during config phase
84
enum cnfobjType objType;
86
struct objlst *subobjs;
87
struct cnfstmt *script;
100
/**< was this node used during config processing? If not, this
101
* indicates an error. After all, the user specified a setting
102
* that the software does not know.
106
/* the following structures support expressions, and may (very much later
107
* be the sole foundation for the AST.
109
* nodetypes (list not yet complete)
117
* ... plus the S_* #define's below:
120
#define S_PRIFILT 4001
121
#define S_PROPFILT 4002
124
#define S_NOP 4005 /* usually used to disable some statement */
129
enum cnfFiltType { CNFFILT_NONE, CNFFILT_PRI, CNFFILT_PROP, CNFFILT_SCRIPT };
131
cnfFiltType2str(enum cnfFiltType filttype)
135
return("filter:none");
137
return("filter:pri");
139
return("filter:prop");
141
return("filter:script");
143
return("error:invalid_filter_type"); /* should never be reached */
149
struct cnfstmt *next;
150
uchar *printable; /* printable text for debugging */
153
struct cnfexpr *expr;
154
struct cnfstmt *t_then;
155
struct cnfstmt *t_else;
159
struct cnfexpr *expr;
166
struct cnfstmt *stmt;
169
uchar pmask[LOG_NFACILITIES+1]; /* priority mask */
170
struct cnfstmt *t_then;
171
struct cnfstmt *t_else;
175
regex_t *regex_cache;/* cache for compiled REs, if used */
176
struct cstr_s *pCSCompValue;/* value to "compare" against */
178
uintTiny propID;/* ID of the requested property */
179
es_str_t *propName;/* name of property for CEE-based filters */
180
struct cnfstmt *t_then;
181
struct cnfstmt *t_else;
183
struct action_s *act;
198
struct cnfstringval {
214
struct cnffparamlst {
215
unsigned nodetype; /* P */
216
struct cnffparamlst *next;
217
struct cnfexpr *expr;
221
CNFFUNC_INVALID = 0, /**< defunct entry, do not use (should normally not be present) */
222
CNFFUNC_NAME = 1, /**< use name to call function (for future use) */
237
unsigned short nParams;
238
enum cnffuncid fID; /* function ID for built-ins, 0 means use name */
239
void *funcdata; /* global data for function-specific use (e.g. compiled regex) */
240
struct cnfexpr *expr[];
250
/* the following defines describe the parameter block for puling
251
* config parameters. Note that the focus is on ease and saveness of
252
* use, not performance. For example, we address parameters by name
253
* instead of index, because the former is less error-prone. The (severe)
254
* performance hit does not matter, as it is a one-time hit during config
255
* load but never during actual processing. So there is really no reason
258
struct cnfparamdescr { /* first the param description */
259
char *name; /**< not a es_str_t to ease definition in code */
260
ecslCmdHdrlType type;
263
/* flags for cnfparamdescr: */
264
#define CNFPARAM_REQUIRED 0x0001
266
struct cnfparamblk { /* now the actual param block use in API calls */
267
unsigned short version;
268
unsigned short nParams;
269
struct cnfparamdescr *descr;
271
#define CNFPARAMBLK_VERSION 1
272
/**< caller must have same version as engine -- else things may
273
* be messed up. But note that we may support multiple versions
274
* inside the engine, if at some later stage we want to do
275
* that. -- rgerhards, 2011-07-15
277
struct cnfparamvals { /* the values we obtained for param descr. */
282
struct funcData_prifilt {
283
uchar pmask[LOG_NFACILITIES+1]; /* priority mask */
287
int cnfParseBuffer(char *buf, unsigned lenBuf);
288
void readConfFile(FILE *fp, es_str_t **str);
289
struct objlst* objlstNew(struct cnfobj *obj);
290
void objlstDestruct(struct objlst *lst);
291
void objlstPrint(struct objlst *lst);
292
struct nvlst* nvlstNewArray(struct cnfarray *ar);
293
struct nvlst* nvlstNewStr(es_str_t *value);
294
struct nvlst* nvlstSetName(struct nvlst *lst, es_str_t *name);
295
void nvlstDestruct(struct nvlst *lst);
296
void nvlstPrint(struct nvlst *lst);
297
void nvlstChkUnused(struct nvlst *lst);
298
struct nvlst* nvlstFindName(struct nvlst *lst, es_str_t *name);
299
struct cnfobj* cnfobjNew(enum cnfobjType objType, struct nvlst *lst);
300
void cnfobjDestruct(struct cnfobj *o);
301
void cnfobjPrint(struct cnfobj *o);
302
struct cnfexpr* cnfexprNew(unsigned nodetype, struct cnfexpr *l, struct cnfexpr *r);
303
void cnfexprPrint(struct cnfexpr *expr, int indent);
304
void cnfexprEval(struct cnfexpr *expr, struct var *ret, void *pusr);
305
int cnfexprEvalBool(struct cnfexpr *expr, void *usrptr);
306
void cnfexprDestruct(struct cnfexpr *expr);
307
struct cnfnumval* cnfnumvalNew(long long val);
308
struct cnfstringval* cnfstringvalNew(es_str_t *estr);
309
struct cnfvar* cnfvarNew(char *name);
310
struct cnffunc * cnffuncNew(es_str_t *fname, struct cnffparamlst* paramlst);
311
struct cnffparamlst * cnffparamlstNew(struct cnfexpr *expr, struct cnffparamlst *next);
312
int cnfDoInclude(char *name);
313
int cnfparamGetIdx(struct cnfparamblk *params, char *name);
314
struct cnfparamvals* nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
315
struct cnfparamvals *vals);
316
void cnfparamsPrint(struct cnfparamblk *params, struct cnfparamvals *vals);
317
int cnfparamvalsIsSet(struct cnfparamblk *params, struct cnfparamvals *vals);
318
void varDelete(struct var *v);
319
void cnfparamvalsDestruct(struct cnfparamvals *paramvals, struct cnfparamblk *blk);
320
struct cnfstmt * cnfstmtNew(unsigned s_type);
321
void cnfstmtPrintOnly(struct cnfstmt *stmt, int indent, sbool subtree);
322
void cnfstmtPrint(struct cnfstmt *stmt, int indent);
323
struct cnfstmt* scriptAddStmt(struct cnfstmt *root, struct cnfstmt *s);
324
struct objlst* objlstAdd(struct objlst *root, struct cnfobj *o);
325
char *rmLeadingSpace(char *s);
326
struct cnfstmt * cnfstmtNewPRIFILT(char *prifilt, struct cnfstmt *t_then);
327
struct cnfstmt * cnfstmtNewPROPFILT(char *propfilt, struct cnfstmt *t_then);
328
struct cnfstmt * cnfstmtNewAct(struct nvlst *lst);
329
struct cnfstmt * cnfstmtNewLegaAct(char *actline);
330
struct cnfstmt * cnfstmtNewSet(char *var, struct cnfexpr *expr);
331
struct cnfstmt * cnfstmtNewUnset(char *var);
332
struct cnfstmt * cnfstmtNewCall(es_str_t *name);
333
struct cnfstmt * cnfstmtNewContinue(void);
334
void cnfstmtDestructLst(struct cnfstmt *root);
335
void cnfstmtOptimize(struct cnfstmt *root);
336
struct cnfarray* cnfarrayNew(es_str_t *val);
337
struct cnfarray* cnfarrayDup(struct cnfarray *old);
338
struct cnfarray* cnfarrayAdd(struct cnfarray *ar, es_str_t *val);
339
void cnfarrayContentDestruct(struct cnfarray *ar);
340
char* getFIOPName(unsigned iFIOP);
341
rsRetVal initRainerscript(void);
342
void unescapeStr(uchar *s, int len);
343
char * tokenval2str(int tok);
346
void cstrPrint(char *text, es_str_t *estr);