diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2023-08-24 16:59:23 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-08-24 16:59:23 +0200 |
commit | f411a19bb0467cfc421f8aa6f5ead49972bab058 (patch) | |
tree | 4852ae63fc2657934eadb877c467ab1b26fb2593 /conf | |
parent | 0dbcc927260c6da918fa1bd78c86800e41ab05a8 (diff) |
Conf: Use nonterminal bytestring instead of BYTETEXT
Nonterminal bytestring allows to provide expressions to be evaluated in
places where BYTETEXT is used now: passwords, radv custom option.
Based on the patch from Alexander Zubkov <green@qrator.net>, thanks!
Diffstat (limited to 'conf')
-rw-r--r-- | conf/confbase.Y | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y index e109ddf5..f8d24415 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -117,9 +117,13 @@ CF_DECLS %type <mls> label_stack_start label_stack %type <t> text opttext +%type <bs> bytestring %type <s> symbol %type <kw> kw_sym +%type <v> bytestring_text +%type <x> bytestring_expr + %nonassoc PREFIX_DUMMY %left AND OR %nonassoc '=' '<' '>' '~' GEQ LEQ NEQ NMA PO PC @@ -395,6 +399,27 @@ opttext: | /* empty */ { $$ = NULL; } ; +bytestring: + BYTETEXT + | bytestring_expr { $$ = cf_eval($1, T_BYTESTRING).val.bs; } + ; + +bytestring_text: + BYTETEXT { $$.type = T_BYTESTRING; $$.val.bs = $1; } + | TEXT { $$.type = T_STRING; $$.val.s = $1; } + | bytestring_expr { + $$ = cf_eval($1, T_VOID); + if (($$.type != T_BYTESTRING) && ($$.type != T_STRING)) + cf_error("Bytestring or string value expected"); + } + ; + +bytestring_expr: + symbol_value + | term_bs + | '(' term ')' { $$ = $2; } + ; + CF_CODE |