diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2008-04-10 17:49:50 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2008-04-10 17:49:50 -0700 |
commit | f11c3e118f48d7bfd6d2a8d5d32309f2a83403fc (patch) | |
tree | 5623c3bc99d9a6623e6ffb65f958dc263a74f850 /src/cli_parse.y | |
parent | 6072a6950706da557fc2aaa66919239d07207578 (diff) | |
download | vyatta-cfg-f11c3e118f48d7bfd6d2a8d5d32309f2a83403fc.tar.gz vyatta-cfg-f11c3e118f48d7bfd6d2a8d5d32309f2a83403fc.zip |
partial fix for bug 2181: add new template field "priority".
Diffstat (limited to 'src/cli_parse.y')
-rw-r--r-- | src/cli_parse.y | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/cli_parse.y b/src/cli_parse.y index 6378bc9..dd3d7d2 100644 --- a/src/cli_parse.y +++ b/src/cli_parse.y @@ -1,8 +1,12 @@ %{ - #include <assert.h> #include <stdio.h> #include <string.h> +#include <errno.h> +#include <stdlib.h> + +#define __USE_ISOC99 +#include <limits.h> #include "cli_val.h" @@ -30,6 +34,7 @@ static void cli_deferror(const char *); %token TYPE %token HELP %token DEFAULT +%token PRIORITY %token PATTERN %token EXEC %token SYNTAX @@ -101,6 +106,7 @@ type: TYPE TYPE_DEF cause: help_cause | default_cause + | priority_stmt | syntax_cause | ACTION action { append(parse_defp->actions + $1, $2, 0);} | dummy_stmt @@ -126,6 +132,25 @@ default_cause: DEFAULT STRING parse_defp->def_default = $2; } +priority_stmt: PRIORITY VALUE + { + char *tmp = $2.val; + long long int cval = 0; + char *endp = NULL; + errno = 0; + cval = strtoll(tmp, &endp, 10); + if (($2.val_type != INT_TYPE) + || (errno == ERANGE + && (cval == LLONG_MAX || cval == LLONG_MIN)) + || (errno != 0 && cval == 0) + || (*endp != '\0') || (cval < 0) || (cval > UINT_MAX)) { + yy_cli_parse_error((const char *) + "Priority must be <u32>\n"); + } else { + parse_defp->def_priority = cval; + } + } + syntax_cause: SYNTAX exp {append(parse_defp->actions + syntax_act, $2, 0);} ; |