X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Feval.h;h=d68b9af474ce7f5806746dc7db2321d059104b7f;hb=696fe43d1855a97775c2bec17d1f2f002e32eb0e;hp=1d1f9e02d71b1c354f3ec72cfaf74f32b037771e;hpb=ac6925def2988f29fd21c8226e4b435bc0f34b62;p=netdata.git diff --git a/src/eval.h b/src/eval.h index 1d1f9e02..d68b9af4 100644 --- a/src/eval.h +++ b/src/eval.h @@ -1,8 +1,11 @@ #ifndef NETDATA_EVAL_H #define NETDATA_EVAL_H +#define EVAL_MAX_VARIABLE_NAME_LENGTH 300 + typedef struct eval_variable { char *name; + uint32_t hash; struct rrdvar *rrdvar; struct eval_variable *next; } EVAL_VARIABLE; @@ -11,6 +14,11 @@ typedef struct eval_expression { const char *source; const char *parsed_as; + int *status; + calculated_number *this; + time_t *after; + time_t *before; + calculated_number result; int error; @@ -20,28 +28,31 @@ typedef struct eval_expression { void *nodes; // custom data to be used for looking up variables - void *data; + struct rrdcalc *rrdcalc; } EVAL_EXPRESSION; -#define EVAL_VALUE_INVALID 0 -#define EVAL_VALUE_NUMBER 1 -#define EVAL_VALUE_VARIABLE 2 +#define EVAL_VALUE_INVALID 0 +#define EVAL_VALUE_NUMBER 1 +#define EVAL_VALUE_VARIABLE 2 #define EVAL_VALUE_EXPRESSION 3 -#define EVAL_ERROR_OK 0 +// parsing and evaluation +#define EVAL_ERROR_OK 0 // parsing errors -#define EVAL_ERROR_MISSING_CLOSE_SUBEXPRESSION 1 -#define EVAL_ERROR_UNKNOWN_OPERAND 2 -#define EVAL_ERROR_MISSING_OPERAND 3 -#define EVAL_ERROR_MISSING_OPERATOR 4 +#define EVAL_ERROR_MISSING_CLOSE_SUBEXPRESSION 1 +#define EVAL_ERROR_UNKNOWN_OPERAND 2 +#define EVAL_ERROR_MISSING_OPERAND 3 +#define EVAL_ERROR_MISSING_OPERATOR 4 +#define EVAL_ERROR_REMAINING_GARBAGE 5 +#define EVAL_ERROR_IF_THEN_ELSE_MISSING_ELSE 6 // evaluation errors -#define EVAL_ERROR_INVALID_VALUE 5 -#define EVAL_ERROR_INVALID_NUMBER_OF_OPERANDS 6 -#define EVAL_ERROR_VALUE_IS_NAN 7 -#define EVAL_ERROR_VALUE_IS_INFINITE 8 -#define EVAL_ERROR_UNKNOWN_VARIABLE 9 +#define EVAL_ERROR_INVALID_VALUE 101 +#define EVAL_ERROR_INVALID_NUMBER_OF_OPERANDS 102 +#define EVAL_ERROR_VALUE_IS_NAN 103 +#define EVAL_ERROR_VALUE_IS_INFINITE 104 +#define EVAL_ERROR_UNKNOWN_VARIABLE 105 // parse the given string as an expression and return: // a pointer to an expression if it parsed OK