diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2016-11-18 12:06:57 +0100 |
|---|---|---|
| committer | Quentin Young <qlyoung@users.noreply.github.com> | 2017-05-15 10:27:43 -0400 |
| commit | 16705ecc653dd657c5b8149934d8734e89c27c07 (patch) | |
| tree | 382236b56dcc7542e95d302d031c686ae6618eb7 /lib/command.c | |
| parent | 6a72763d738c7c4132fbc4af03a688a7cc0e49e3 (diff) | |
lib: parser: add named variables in CLI
struct cmd_token now has a "varname" field which is derived from the
DEFUN's string definition. It can be manually specified with "$name"
after some token, e.g. "foo WORD$var". A later commit adds code to
automatically fill the value if nothing is specified.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/command.c b/lib/command.c index 2b8eee8de3..06d9422f70 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2772,6 +2772,7 @@ new_cmd_token (enum cmd_token_type type, u_char attr, token->refcnt = 1; token->arg = NULL; token->allowrepeat = false; + token->varname = NULL; return token; } @@ -2800,11 +2801,19 @@ copy_cmd_token (struct cmd_token *token) copy->text = token->text ? XSTRDUP (MTYPE_CMD_TEXT, token->text) : NULL; copy->desc = token->desc ? XSTRDUP (MTYPE_CMD_DESC, token->desc) : NULL; copy->arg = token->arg ? XSTRDUP (MTYPE_CMD_ARG, token->arg) : NULL; + copy->varname = token->varname ? XSTRDUP (MTYPE_CMD_ARG, token->varname) : NULL; return copy; } void +cmd_set_varname (struct cmd_token *token, const char *varname) +{ + XFREE (MTYPE_CMD_VAR, token->varname); + token->varname = varname ? XSTRDUP (MTYPE_CMD_VAR, varname) : NULL; +} + +void cmd_terminate () { struct cmd_node *cmd_node; |
