summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-04-10 17:49:50 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2008-04-10 17:49:50 -0700
commitf11c3e118f48d7bfd6d2a8d5d32309f2a83403fc (patch)
tree5623c3bc99d9a6623e6ffb65f958dc263a74f850
parent6072a6950706da557fc2aaa66919239d07207578 (diff)
downloadvyatta-cfg-f11c3e118f48d7bfd6d2a8d5d32309f2a83403fc.tar.gz
vyatta-cfg-f11c3e118f48d7bfd6d2a8d5d32309f2a83403fc.zip
partial fix for bug 2181: add new template field "priority".
-rw-r--r--src/cli_def.l7
-rw-r--r--src/cli_parse.y27
-rw-r--r--src/cli_val.h1
3 files changed, 31 insertions, 4 deletions
diff --git a/src/cli_def.l b/src/cli_def.l
index 07c9c68..d73f1c4 100644
--- a/src/cli_def.l
+++ b/src/cli_def.l
@@ -19,8 +19,9 @@ static char str_delim = 0;
static int eof_seen = 0;
static int pre_str_state = 0;
-static char *reg_fields[] = { "default", "tag", "type", "multi", NULL };
-static int reg_fields_t[] = { DEFAULT, TAG, TYPE, MULTI, 0 };
+static char *reg_fields[] = { "default", "tag", "type", "multi", "priority",
+ NULL };
+static int reg_fields_t[] = { DEFAULT, TAG, TYPE, MULTI, PRIORITY, 0 };
static char *act_fields[] = { "help", "syntax", "commit",
"delete", "update", "activate", "create",
"begin", "end",
@@ -262,7 +263,7 @@ RE_OP_COND (==|!=|<|>|<=|>=|in)
RE_OP_OTHER (pattern|exec|,|\|\||&&|=|!|\(|\)|;)
/* template fields */
-RE_REG_FIELD (default|tag|type|multi)
+RE_REG_FIELD (default|tag|type|multi|priority)
RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end|comp_help|allowed)
%%
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);}
;
diff --git a/src/cli_val.h b/src/cli_val.h
index edbda41..520fa8e 100644
--- a/src/cli_val.h
+++ b/src/cli_val.h
@@ -101,6 +101,7 @@ typedef struct {
char *def_type_help;
char *def_node_help;
char *def_default;
+ unsigned int def_priority;
boolean tag;
boolean multi;
vtw_list actions[top_act];