]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add dict in preparation for xlat_purify
authorAlan T. DeKok <aland@freeradius.org>
Tue, 17 May 2022 15:08:19 +0000 (11:08 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 17 May 2022 15:17:43 +0000 (11:17 -0400)
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_priv.h
src/lib/unlang/xlat_tokenize.c

index 8d9d8887dafae7c8bac037ecebf21b6fd14ccd64..811bc681c306f7c64c062f0a9182e57e0201233e 100644 (file)
@@ -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);
index 7a8ba508c618233d7cfc930fa63e819282700264..82e86a51091d97324c97bcf16b95ca771e410323 100644 (file)
@@ -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;
 };
 
index 2c0b8ce73925fb4c2b8568ef07c41569b108c01a..9f69a5195b758e5afe13b4c60bdab8721f420a59 100644 (file)
@@ -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 */