]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
start of API cleanup
authorAlan T. DeKok <aland@freeradius.org>
Thu, 12 May 2022 01:38:18 +0000 (21:38 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 May 2022 19:00:21 +0000 (15:00 -0400)
src/lib/unlang/xlat_priv.h
src/lib/unlang/xlat_tokenize.c

index 64b5f61b78d28966ecd17d2ce9db982c27f7f04b..5b8baa687ee7cf68784b023d98fb251b26edf468 100644 (file)
@@ -321,10 +321,10 @@ int               xlat_register_expressions(void);
 /*
  *     xlat_tokenize.c
  */
-int            xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *flags, fr_sbuff_t *in,
+int            xlat_tokenize_expansion(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in,
                                        tmpl_attr_rules_t const *t_rules);
 
-int            xlat_tokenize_function_args(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *flags, fr_sbuff_t *in,
+int            xlat_tokenize_function_args(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in,
                                            tmpl_attr_rules_t const *rules);
 
 ssize_t                xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t const *node, fr_sbuff_escape_rules_t const *e_rules);
index e449e154c44386cd70ad2c2429fef7f7527e0f18..75ad882d7638933f17342aa75ee2ef4ad7323a89 100644 (file)
@@ -169,26 +169,26 @@ void xlat_exp_free(xlat_exp_head_t **head)
 static int xlat_tokenize_string(xlat_exp_head_t *head, fr_sbuff_t *in, bool brace,
                                fr_sbuff_parse_rules_t const *p_rules, tmpl_attr_rules_t const *t_rules);
 
-static inline int xlat_tokenize_alternation(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *flags, fr_sbuff_t *in,
+static inline int xlat_tokenize_alternation(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in,
                                            tmpl_attr_rules_t const *t_rules, bool func_args)
 {
        xlat_exp_t      *node;
 
        XLAT_DEBUG("ALTERNATE <-- %pV", fr_box_strvalue_len(fr_sbuff_current(in), fr_sbuff_remaining(in)));
 
-       node = xlat_exp_alloc_null(ctx);
+       node = xlat_exp_alloc_null(head);
        xlat_exp_set_type(node, XLAT_ALTERNATE);
        MEM(node->alternate[0] = xlat_exp_head_alloc(node));
        MEM(node->alternate[1] = xlat_exp_head_alloc(node));
 
        if (func_args) {
-               if (xlat_tokenize_function_args(node->alternate[0], &node->alternate[0]->next, &node->alternate[0]->flags, in, t_rules) < 0) {
+               if (xlat_tokenize_function_args(node->alternate[0], &node->alternate[0]->next, in, t_rules) < 0) {
                error:
                        talloc_free(node);
                        return -1;
                }
        } else {
-               if (xlat_tokenize_expansion(node->alternate[0], &node->alternate[0]->next, &node->alternate[0]->flags, in, t_rules) < 0) goto error;
+               if (xlat_tokenize_expansion(node->alternate[0], &node->alternate[0]->next, in, t_rules) < 0) goto error;
        }
 
        if (!fr_sbuff_adv_past_str_literal(in, ":-")) {
@@ -221,7 +221,7 @@ static inline int xlat_tokenize_alternation(TALLOC_CTX *ctx, xlat_exp_t **out, x
        xlat_flags_merge(&node->flags, &node->alternate[1]->flags);
 
 done:
-       xlat_flags_merge(flags, &node->flags);
+       xlat_flags_merge(&head->flags, &node->flags);
        *out = node;
 
        return 0;
@@ -234,7 +234,7 @@ done:
  * @verbatim %{<num>} @endverbatim
  *
  */
-static inline int xlat_tokenize_regex(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *flags, fr_sbuff_t *in)
+static inline int xlat_tokenize_regex(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in)
 {
        uint8_t                 num;
        xlat_exp_t              *node;
@@ -269,14 +269,14 @@ static inline int xlat_tokenize_regex(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_fl
                return 1;
        }
 
-       node = xlat_exp_alloc(ctx, XLAT_REGEX, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s));
+       node = xlat_exp_alloc(head, XLAT_REGEX, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s));
        node->regex_index = num;
        node->flags.needs_async = false;
 
        fr_sbuff_marker_release(&m_s);
        fr_sbuff_next(in);      /* Skip '}' */
 
-       xlat_flags_merge(flags, &node->flags);
+       xlat_flags_merge(&head->flags, &node->flags);
        *out = node;
 
        return 0;
@@ -304,8 +304,8 @@ int xlat_validate_function_mono(xlat_exp_t *node)
  *     - 0 if the string was parsed into a function.
  *     - <0 on parse error.
  */
-static inline int xlat_tokenize_function_mono(TALLOC_CTX *ctx, xlat_exp_t **out,
-                                             xlat_flags_t *flags, fr_sbuff_t *in,
+static inline int xlat_tokenize_function_mono(xlat_exp_head_t *head, xlat_exp_t **out,
+                                             fr_sbuff_t *in,
                                              tmpl_attr_rules_t const *rules)
 {
        xlat_exp_t              *node;
@@ -343,7 +343,7 @@ static inline int xlat_tokenize_function_mono(TALLOC_CTX *ctx, xlat_exp_t **out,
        /*
         *      Allocate a node to hold the function
         */
-       MEM(node = xlat_exp_alloc(ctx, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s)));
+       MEM(node = xlat_exp_alloc(head, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s)));
        MEM(node->call.args = xlat_exp_head_alloc(node));
        if (!func) {
                if (!rules || !rules->allow_unresolved) {
@@ -398,7 +398,7 @@ static inline int xlat_tokenize_function_mono(TALLOC_CTX *ctx, xlat_exp_t **out,
        }
 
        xlat_flags_merge(&node->flags, &node->call.args->flags);
-       xlat_flags_merge(flags, &node->flags);
+       xlat_flags_merge(&head->flags, &node->flags);
        *out = node;
 
        return 0;
@@ -441,8 +441,8 @@ int xlat_validate_function_args(xlat_exp_t *node)
  *     - 0 if the string was parsed into a function.
  *     - <0 on parse error.
  */
-int xlat_tokenize_function_args(TALLOC_CTX *ctx, xlat_exp_t **out,
-                               xlat_flags_t *flags, fr_sbuff_t *in,
+int xlat_tokenize_function_args(xlat_exp_head_t *head, xlat_exp_t **out,
+                               fr_sbuff_t *in,
                                tmpl_attr_rules_t const *rules)
 {
        xlat_exp_t              *node;
@@ -480,7 +480,7 @@ int xlat_tokenize_function_args(TALLOC_CTX *ctx, xlat_exp_t **out,
        /*
         *      Allocate a node to hold the function
         */
-       node = xlat_exp_alloc(ctx, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s));
+       node = xlat_exp_alloc(head, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s));
        if (!func) {
                if (!rules || !rules->allow_unresolved) {
                        fr_strerror_const("Unresolved expansion functions are not allowed here");
@@ -533,7 +533,7 @@ int xlat_tokenize_function_args(TALLOC_CTX *ctx, xlat_exp_t **out,
                goto error;
        }
 
-       xlat_flags_merge(flags, &node->flags);
+       xlat_flags_merge(&head->flags, &node->flags);
        *out = node;
 
        return 0;
@@ -564,7 +564,7 @@ static int xlat_resolve_virtual_attribute(xlat_exp_t *node, tmpl_t *vpt)
 /** Parse an attribute ref or a virtual attribute
  *
  */
-static inline int xlat_tokenize_attribute(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *flags, fr_sbuff_t *in,
+static inline int xlat_tokenize_attribute(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in,
                                          fr_sbuff_parse_rules_t const *p_rules, tmpl_attr_rules_t const *t_rules)
 {
        ssize_t                 slen;
@@ -597,7 +597,7 @@ static inline int xlat_tokenize_attribute(TALLOC_CTX *ctx, xlat_exp_t **out, xla
 
        fr_sbuff_marker(&m_s, in);
 
-       MEM(node = xlat_exp_alloc_null(ctx));
+       MEM(node = xlat_exp_alloc_null(head));
        slen = tmpl_afrom_attr_substr(node, &err, &vpt, in, p_rules, &our_t_rules);
        if (slen <= 0) {
                fr_sbuff_advance(in, slen * -1);
@@ -684,13 +684,13 @@ done:
                goto error;
        }
 
-       xlat_flags_merge(flags, &node->flags);
+       xlat_flags_merge(&head->flags, &node->flags);
        *out = node;
        fr_sbuff_marker_release(&m_s);
        return 0;
 }
 
-int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *flags, fr_sbuff_t *in,
+int xlat_tokenize_expansion(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in,
                            tmpl_attr_rules_t const *t_rules)
 {
        size_t                  len;
@@ -714,14 +714,14 @@ int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *fla
         *      %{...}:-bar}
         */
        if (fr_sbuff_adv_past_str_literal(in, "%{")) {
-               return xlat_tokenize_alternation(ctx, out, flags, in, t_rules, false);
+               return xlat_tokenize_alternation(head, out, in, t_rules, false);
        }
 
        /*
         *      %(...):-bar}
         */
        if (fr_sbuff_adv_past_str_literal(in, "%(")) {
-               return xlat_tokenize_alternation(ctx, out, flags, in, t_rules, true);
+               return xlat_tokenize_alternation(head, out, in, t_rules, true);
        }
 
        /*
@@ -739,7 +739,7 @@ int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *fla
        if (fr_sbuff_is_digit(in)) {
                int ret;
 
-               ret = xlat_tokenize_regex(ctx, out, flags, in);
+               ret = xlat_tokenize_regex(head, out, in);
                if (ret <= 0) return ret;
 
                /* ret==1 means "nope, it's an attribute" */
@@ -801,7 +801,7 @@ int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *fla
                fr_sbuff_set(in, &s_m);         /* backtrack */
                fr_sbuff_marker_release(&s_m);
 
-               return xlat_tokenize_function_mono(ctx, out, flags, in, t_rules);
+               return xlat_tokenize_function_mono(head, out, in, t_rules);
 
        /*
         *      Hint token is a:
@@ -814,7 +814,7 @@ int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_flags_t *fla
                fr_sbuff_set(in, &s_m);         /* backtrack */
                fr_sbuff_marker_release(&s_m);
 
-               return xlat_tokenize_attribute(ctx, out, flags, in, &attr_p_rules, t_rules);
+               return xlat_tokenize_attribute(head, out, in, &attr_p_rules, t_rules);
 
        /*
         *      Hint token was whitespace
@@ -956,7 +956,7 @@ static int xlat_tokenize_string(xlat_exp_head_t *head,
                if (fr_sbuff_adv_past_str_literal(in, "%{")) {
                        if (slen == 0) TALLOC_FREE(node); /* Free the empty node */
 
-                       if (xlat_tokenize_expansion(head, &node, &head->flags, in, t_rules) < 0) goto error;
+                       if (xlat_tokenize_expansion(head, &node, in, t_rules) < 0) goto error;
                        xlat_exp_append(tail, node);
                        continue;
                }
@@ -967,7 +967,7 @@ static int xlat_tokenize_string(xlat_exp_head_t *head,
                if (fr_sbuff_adv_past_str_literal(in, "%(")) {
                        if (slen == 0) TALLOC_FREE(node); /* Free the empty node */
 
-                       if (xlat_tokenize_function_args(head, &node, &head->flags, in, t_rules) < 0) goto error;
+                       if (xlat_tokenize_function_args(head, &node, in, t_rules) < 0) goto error;
                        xlat_exp_append(tail, node);
                        continue;
                }