summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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];