diff options
Diffstat (limited to 'nest')
-rw-r--r-- | nest/cmds.c | 20 | ||||
-rw-r--r-- | nest/cmds.h | 3 | ||||
-rw-r--r-- | nest/config.Y | 8 |
3 files changed, 29 insertions, 2 deletions
diff --git a/nest/cmds.c b/nest/cmds.c index 54ace169..9bdd66cd 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -13,6 +13,7 @@ #include "nest/cmds.h" #include "lib/string.h" #include "lib/resource.h" +#include "filter/filter.h" extern int shutting_down; extern int configuring; @@ -90,3 +91,22 @@ cmd_show_memory(void) print_size("Total:", rmemsize(&root_pool)); cli_msg(0, ""); } + +extern const char *log_buffer_ptr; + +void +cmd_eval(struct f_inst *expr) +{ + struct f_val v = f_eval(expr, this_cli->parser_pool); + log_reset(); + + if (v.type == T_RETURN) + { + cli_msg(8008, "runtime error"); + return; + } + + val_print(v); + cli_msg(23, "%s", log_buffer_ptr); + log_reset(); +} diff --git a/nest/cmds.h b/nest/cmds.h index 8b0bff7e..4cf8fb1b 100644 --- a/nest/cmds.h +++ b/nest/cmds.h @@ -11,6 +11,9 @@ struct sym_show_data { struct symbol *sym; }; +struct f_inst; + void cmd_show_status(void); void cmd_show_symbols(struct sym_show_data *sym); void cmd_show_memory(void); +void cmd_eval(struct f_inst *expr); diff --git a/nest/config.Y b/nest/config.Y index b85a5733..a6f13808 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -612,7 +612,11 @@ CF_CLI(DUMP ROUTES,,, [[Dump routing table]]) CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]]) { protos_dump_all(); cli_msg(0, ""); } ; -CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) { +CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]]) +{ cmd_eval($2); } ; + +CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]]) +CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug | trace | info | remote | warning | error | auth }) [<buffer-size>], [[Control echoing of log messages]]) { cli_set_log_echo(this_cli, $2, $3); cli_msg(0, ""); } ; @@ -620,7 +624,7 @@ CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Config echo_mask: ALL { $$ = ~0; } | OFF { $$ = 0; } - | NUM + | '{' log_mask_list '}' { $$ = $2; } ; echo_size: |