diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2013-07-25 13:15:32 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2013-07-25 13:15:32 +0200 |
commit | 508d936078aecc8fbbb9ca1218104599c4a3cb4a (patch) | |
tree | d84c6b098342fc2f366d960bd90d6a158610ea48 /nest/cmds.c | |
parent | a0b176e3b2b50d3a30574afa927e0ee8ef65be68 (diff) |
Implements eval command and minor CLI cleanups.
Implemented eval command can be used to evaluate expressions.
The patch also documents echo command and allows to use log classes
instead of integer as a mask for echo.
Diffstat (limited to 'nest/cmds.c')
-rw-r--r-- | nest/cmds.c | 20 |
1 files changed, 20 insertions, 0 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(); +} |