From: Alan T. DeKok Date: Sun, 1 Oct 2023 17:34:07 +0000 (-0400) Subject: move funtion to the only place which uses it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e84b7ea6274ce5b6dc6e2fd17d0411221a27e93d;p=thirdparty%2Ffreeradius-server.git move funtion to the only place which uses it --- diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index 40fbb4d8f2b..573285fb913 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -436,8 +436,6 @@ void xlat_debug_attr_vp(request_t *request, fr_pair_t *vp, tmpl_t const *vpt); /* * xlat_tokenize.c */ -xlat_exp_t *xlat_exp_func_alloc(TALLOC_CTX *ctx, xlat_t *func, xlat_exp_head_t const *args); - tmpl_t *xlat_to_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t *xlat); int xlat_from_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_head_t **head, tmpl_t **vpt_p); diff --git a/src/lib/unlang/xlat_redundant.c b/src/lib/unlang/xlat_redundant.c index 28c2bb83535..de270b03e20 100644 --- a/src/lib/unlang/xlat_redundant.c +++ b/src/lib/unlang/xlat_redundant.c @@ -186,6 +186,35 @@ static xlat_action_t xlat_redundant(TALLOC_CTX *ctx, fr_dcursor_t *out, return XLAT_ACTION_PUSH_UNLANG; } +/** Allocate an xlat node to call an xlat function + * + * @param[in] ctx to allocate the new node in. + * @param[in] func to call. + * @param[in] args Arguments to the function. Will be copied, + * and freed when the new xlat node is freed. + */ +static xlat_exp_t *xlat_exp_func_alloc(TALLOC_CTX *ctx, xlat_t *func, xlat_exp_head_t const *args) +{ + xlat_exp_t *node; + + MEM(node = xlat_exp_alloc(ctx, XLAT_FUNC, func->name, strlen(func->name))); + node->call.func = func; + if (unlikely(xlat_copy(node, node->call.args, args) < 0)) { + talloc_free(node); + return NULL; + } + node->flags = func->flags; + xlat_flags_merge(&node->flags, &args->flags); + + /* + * If the function is pure, AND it's arguments are pure, + * then remember that we need to call a pure function. + */ + node->flags.can_purify = (func->flags.pure && args->flags.pure) | args->flags.can_purify; + + return node; +} + /** Allocate additional nodes for evaluation * diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 0e6a399ea64..2e6cc0cf9ec 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -115,35 +115,6 @@ static fr_sbuff_parse_rules_t const xlat_new_arg_rules = { ), }; -/** Allocate an xlat node to call an xlat function - * - * @param[in] ctx to allocate the new node in. - * @param[in] func to call. - * @param[in] args Arguments to the function. Will be copied, - * and freed when the new xlat node is freed. - */ -xlat_exp_t *xlat_exp_func_alloc(TALLOC_CTX *ctx, xlat_t *func, xlat_exp_head_t const *args) -{ - xlat_exp_t *node; - - MEM(node = xlat_exp_alloc(ctx, XLAT_FUNC, func->name, strlen(func->name))); - node->call.func = func; - if (unlikely(xlat_copy(node, node->call.args, args) < 0)) { - talloc_free(node); - return NULL; - } - node->flags = func->flags; - xlat_flags_merge(&node->flags, &args->flags); - - /* - * If the function is pure, AND it's arguments are pure, - * then remember that we need to call a pure function. - */ - node->flags.can_purify = (func->flags.pure && args->flags.pure) | args->flags.can_purify; - - return node; -} - static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules);