mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Added f_eval_int() and EVAL configuration command.
This commit is contained in:
parent
9449c91ab2
commit
1c20608e02
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD - filters
|
* BIRD - filters
|
||||||
*
|
*
|
||||||
* Copyright 1998,1999 Pavel Machek
|
* Copyright 1998--2000 Pavel Machek
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*
|
*
|
||||||
@ -33,7 +33,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
|
|||||||
ADD, DELETE, CONTAINS, RESET,
|
ADD, DELETE, CONTAINS, RESET,
|
||||||
PREPEND, MATCH,
|
PREPEND, MATCH,
|
||||||
EMPTY,
|
EMPTY,
|
||||||
FILTER, WHERE)
|
FILTER, WHERE, EVAL)
|
||||||
|
|
||||||
%nonassoc THEN
|
%nonassoc THEN
|
||||||
%nonassoc ELSE
|
%nonassoc ELSE
|
||||||
@ -59,6 +59,11 @@ filter_def:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
CF_ADDTO(conf, filter_eval)
|
||||||
|
filter_eval:
|
||||||
|
EVAL term { f_eval_int($2); }
|
||||||
|
;
|
||||||
|
|
||||||
type:
|
type:
|
||||||
INT { $$ = T_INT; }
|
INT { $$ = T_INT; }
|
||||||
| BOOL { $$ = T_BOOL; }
|
| BOOL { $$ = T_BOOL; }
|
||||||
@ -164,7 +169,7 @@ function_body:
|
|||||||
|
|
||||||
CF_ADDTO(conf, function_def)
|
CF_ADDTO(conf, function_def)
|
||||||
function_def:
|
function_def:
|
||||||
FUNCTION SYM { DBG( "Begining of function %s\n", $2->name ); cf_push_scope($2); } function_params function_body {
|
FUNCTION SYM { DBG( "Beginning of function %s\n", $2->name ); cf_push_scope($2); } function_params function_body {
|
||||||
extern struct f_inst *startup_func, *test1_func, *test2_func;
|
extern struct f_inst *startup_func, *test1_func, *test2_func;
|
||||||
cf_define_symbol($2, SYM_FUNCTION, $5);
|
cf_define_symbol($2, SYM_FUNCTION, $5);
|
||||||
if (!strcasecmp($2->name, "__startup"))
|
if (!strcasecmp($2->name, "__startup"))
|
||||||
|
@ -665,6 +665,23 @@ f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struc
|
|||||||
return res.val.i;
|
return res.val.i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
f_eval_int(struct f_inst *expr)
|
||||||
|
{
|
||||||
|
struct f_val res;
|
||||||
|
|
||||||
|
f_flags = 0;
|
||||||
|
f_tmp_attrs = NULL;
|
||||||
|
f_rte = NULL;
|
||||||
|
f_rte_old = NULL;
|
||||||
|
f_rta_copy = NULL;
|
||||||
|
f_pool = NULL;
|
||||||
|
res = interpret(expr);
|
||||||
|
if (res.type != T_INT)
|
||||||
|
cf_error("Integer expression expected");
|
||||||
|
return res.val.i;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
filters_postconfig(void)
|
filters_postconfig(void)
|
||||||
{
|
{
|
||||||
|
@ -71,6 +71,7 @@ struct ea_list;
|
|||||||
struct rte;
|
struct rte;
|
||||||
|
|
||||||
int f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struct linpool *tmp_pool, int flags);
|
int f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struct linpool *tmp_pool, int flags);
|
||||||
|
int f_eval_int(struct f_inst *expr);
|
||||||
char *filter_name(struct filter *filter);
|
char *filter_name(struct filter *filter);
|
||||||
int filter_same(struct filter *new, struct filter *old);
|
int filter_same(struct filter *new, struct filter *old);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user