[Sysfence-commit] sysfence/parseopt parse.c,1.11,1.11.2.1
Status: Alpha
Brought to you by:
emes
|
From: Michal S. <em...@us...> - 2004-05-17 15:32:46
|
Update of /cvsroot/sysfence/sysfence/parseopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18568/parseopt Modified Files: Tag: get_stat_value_function parse.c Log Message: + introducing get_stat_value function. this won't work yet - stat value logging is now disabled; needs to be rewritten Index: parse.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/parseopt/parse.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -d -r1.11 -r1.11.2.1 --- parse.c 10 May 2004 13:57:52 -0000 1.11 +++ parse.c 17 May 2004 15:32:36 -0000 1.11.2.1 @@ -18,7 +18,7 @@ #include "../exit.h" #include "../xalloc.h" #include "../getstats.h" -#include "../expressions.h" +#include "../conditions.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> @@ -55,16 +55,6 @@ bail_out (EXIT_PARSE, buf); } -void collect_stats (expression *ex, int *tab) -{ - if (ex->type == ATOMIC) { - *(tab + ((atomic *) ex->arg1)->val_id) = 1; - } else { - collect_stats ((expression *) ex->arg1, tab); - collect_stats ((expression *) ex->arg2, tab); - } -} - parserdata * get_logdata (tokdata *tok) { /* grammar: @@ -255,39 +245,46 @@ switch (var->type) { case ID_LA1: - at->type = DOUBLE; - at->op = op->type; - at->val_id = STA_LA1; + at->thresh.type = DOUBLE; + at->op = op->type; + at->label = STA_LOAD; + at->arg1.simple = ARG_MIN1; break; case ID_LA5: - at->type = DOUBLE; - at->op = op->type; - at->val_id = STA_LA5; + at->thresh.type = DOUBLE; + at->op = op->type; + at->label = STA_LOAD; + at->arg1.simple = ARG_MIN5; break; case ID_LA15: - at->type = DOUBLE; - at->op = op->type; - at->val_id = STA_LA15; + at->thresh.type = DOUBLE; + at->op = op->type; + at->label = STA_LOAD; + at->arg1.simple = ARG_MIN15; break; case ID_MFREE: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_MFREE; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_MEMORY; + at->arg1.simple = ARG_FREE; break; case ID_MUSED: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_MUSED; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_MEMORY; + at->arg1.simple = ARG_USED; break; case ID_SFREE: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_SFREE; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_SWAP; + at->arg1.simple = ARG_FREE; break; case ID_SUSED: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_SUSED; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_SWAP; + at->arg1.simple = ARG_USED; break; default: return NULL; @@ -313,8 +310,8 @@ /* check value type */ if (val->type == VA_INT) { /* this is integer. convert it to type required by label */ - if (at->type == SIZE) val->type = VA_SIZ; - else if (at->type == DOUBLE) { + if (at->thresh.type == SIZE) val->type = VA_SIZ; + else if (at->thresh.type == DOUBLE) { /* long int 2 double */ val->type = VA_DBL; tmp = xalloc (NULL, sizeof (double)); @@ -324,8 +321,8 @@ } } - if (((at->type == SIZE) && (val->type != VA_SIZ)) || - ((at->type == DOUBLE) && (val->type != VA_DBL))) + if (((at->thresh.type == SIZE) && (val->type != VA_SIZ)) || + ((at->thresh.type == DOUBLE) && (val->type != VA_DBL))) #ifdef DEBUG parse_error (val, thisfuncname, "type mismatch"); #else @@ -333,7 +330,8 @@ #endif /* copy threshold value */ - at->thresh = val->val; + if (at->thresh.type == SIZE) at->thresh.val.intval = (long int) *((long int *) val->val); + else if (at->thresh.type == DOUBLE) at->thresh.val.dblval = (double) *((long int *) val->val); res = (parserdata *) xalloc (NULL, sizeof (parserdata)); res->ptr = tok; @@ -420,8 +418,6 @@ rlst->log = NULL; rlst->hit = 0; rlst->prevhit = 0; - for (i = 0; i < STA_LAST; i++) - rlst->showstat[i] = 0; /* ruleset begins with IF */ if (tok->type != KW_IF) @@ -432,11 +428,14 @@ #endif else tok ++; - /* then we may find an optional rule name. */ - if (tok->type == VA_STR) { - rlst->name = tok->val; - tok ++; - } + /* then we should find rule name. */ + if (tok->type == VA_STR) rlst->name = tok->val; +#ifdef DEBUG + else parse_error (tok, thisfuncname, "no rule name"); +#else + else parse_error (tok); +#endif + tok ++; /* next should be expression in block */ tmp = get_block_expression (tok); @@ -490,9 +489,6 @@ tok = tmp->ptr; rlst->step = *((unsigned int *) tmp->parsed); - /* search expression tree for used stats */ - collect_stats (rlst->expr, &(rlst->showstat[0])); - /* ok, now we got full ruleset structure. * we need only to skip to next token. */ |