From: Alan T. DeKok Date: Tue, 17 May 2022 15:08:19 +0000 (-0400) Subject: add dict in preparation for xlat_purify X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4709c0689a7be1663045c539e9b5ed16b7d4953;p=thirdparty%2Ffreeradius-server.git add dict in preparation for xlat_purify --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 8d9d8887daf..811bc681c30 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1282,9 +1282,12 @@ ssize_t xlat_tokenize_expression(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuf terminal_rules->terminals, &bracket_terms)); - if (!t_rules) t_rules = &my_rules; - MEM(head = xlat_exp_head_alloc(ctx)); + if (t_rules) { + head->dict = t_rules->attr.dict_def; + } else { + t_rules = &my_rules; + } slen = tokenize_expression(head, NULL, in, terminal_rules, t_rules, T_INVALID, bracket_rules); talloc_free(bracket_rules); @@ -1359,13 +1362,15 @@ ssize_t xlat_tokenize_ephemeral_expression(TALLOC_CTX *ctx, xlat_exp_head_t **ou MEM(bracket_rules->terminals = fr_sbuff_terminals_amerge(bracket_rules, terminal_rules->terminals, &bracket_terms)); + MEM(head = xlat_exp_head_alloc(ctx)); + if (t_rules) { my_rules = *t_rules; + head->dict = t_rules->attr.dict_def; } - my_rules.xlat.runtime_el = el; - MEM(head = xlat_exp_head_alloc(ctx)); + my_rules.xlat.runtime_el = el; slen = tokenize_expression(head, NULL, in, terminal_rules, &my_rules, T_INVALID, bracket_rules); talloc_free(bracket_rules); diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index 7a8ba508c61..82e86a51091 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -151,6 +151,7 @@ struct xlat_exp { struct xlat_exp_head { char const *fmt; //!< The original format string (a talloced buffer). xlat_flags_t flags; //!< Flags that control resolution and evaluation. + fr_dict_t const *dict; //!< dictionary for this xlat fr_dlist_head_t dlist; }; diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 2c0b8ce7392..9f69a5195b7 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -1270,7 +1270,10 @@ ssize_t xlat_tokenize_ephemeral(TALLOC_CTX *ctx, xlat_exp_head_t **out, MEM(head = xlat_exp_head_alloc(ctx)); - if (t_rules) our_t_rules = *t_rules; + if (t_rules) { + head->dict = t_rules->attr.dict_def; + our_t_rules = *t_rules; + } our_t_rules.xlat.runtime_el = el; @@ -1329,6 +1332,7 @@ ssize_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *i xlat_exp_head_t *head; MEM(head = xlat_exp_head_alloc(ctx)); + if (t_rules) head->dict = t_rules->dict_def; if (p_rules && p_rules->terminals) { tmp_p_rules = (fr_sbuff_parse_rules_t){ /* Stack allocated due to CL scope */ @@ -1492,6 +1496,7 @@ ssize_t xlat_tokenize(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in, xlat_exp_head_t *head; MEM(head = xlat_exp_head_alloc(ctx)); + if (t_rules) head->dict = t_rules->dict_def; fr_strerror_clear(); /* Clear error buffer */