From: Alan T. DeKok Date: Thu, 20 Mar 2025 10:06:33 +0000 (+0700) Subject: remove old foreach, along with XLAT_VIRTUAL X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba51f7e511f276865f4bd3c8d3e2385d540e2337;p=thirdparty%2Ffreeradius-server.git remove old foreach, along with XLAT_VIRTUAL --- diff --git a/src/lib/unlang/xlat_alloc.c b/src/lib/unlang/xlat_alloc.c index e19074186aa..7f34225cf1e 100644 --- a/src/lib/unlang/xlat_alloc.c +++ b/src/lib/unlang/xlat_alloc.c @@ -274,12 +274,6 @@ static int CC_HINT(nonnull) _xlat_copy_internal(NDEBUG_LOCATION_ARGS TALLOC_CTX case XLAT_FUNC_UNRESOLVED: break; - case XLAT_VIRTUAL: - node->call.func = p->call.func; - node->call.dict = p->call.dict; - node->call.ephemeral = p->call.ephemeral; - break; - case XLAT_FUNC: /* * Only copy the function pointer, and whether this diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 1bc2b98fbfb..1427de2dae4 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -169,9 +169,6 @@ static fr_slen_t xlat_fmt_print(fr_sbuff_t *out, xlat_exp_t const *node) return fr_sbuff_in_sprintf(out, "%%{%pV}", fr_box_strvalue_buffer(node->fmt)); } - case XLAT_VIRTUAL: - return fr_sbuff_in_sprintf(out, "%%{%s}", node->call.func->name); - #ifdef HAVE_REGEX case XLAT_REGEX: return fr_sbuff_in_sprintf(out, "%%{%u}", node->regex_index); @@ -1245,21 +1242,6 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_ fr_value_box_list_move((fr_value_box_list_t *)out->dlist, &result); continue; - case XLAT_VIRTUAL: - { - XLAT_DEBUG("** [%i] %s(virtual) - %%{%s}", unlang_interpret_stack_depth(request), __FUNCTION__, - node->fmt); - - xlat_debug_log_expansion(request, node, NULL, __LINE__); - xa = node->call.func->func(ctx, out, - XLAT_CTX(node->call.func->uctx, NULL, NULL, NULL, NULL), - request, NULL); - fr_dcursor_next(out); - - xlat_debug_log_result(request, node, fr_dcursor_current(out)); - } - continue; - case XLAT_FUNC: XLAT_DEBUG("** [%i] %s(func) - %%%s(...)", unlang_interpret_stack_depth(request), __FUNCTION__, node->fmt); diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index dfa980d64c1..197821d1ed4 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -108,10 +108,9 @@ typedef enum { XLAT_ONE_LETTER = 0x0002, //!< Special "one-letter" expansion XLAT_FUNC = 0x0004, //!< xlat module XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2. - XLAT_VIRTUAL = 0x0010, //!< virtual attribute - XLAT_TMPL = 0x0020, //!< xlat attribute + XLAT_TMPL = 0x0010, //!< xlat attribute #ifdef HAVE_REGEX - XLAT_REGEX = 0x0040, //!< regex reference %{1}, etc. + XLAT_REGEX = 0x0020, //!< regex reference %{1}, etc. #endif XLAT_GROUP = 0x0100 //!< encapsulated string of xlats } xlat_type_t; diff --git a/src/lib/unlang/xlat_purify.c b/src/lib/unlang/xlat_purify.c index a704315ab64..d8be73fd9d2 100644 --- a/src/lib/unlang/xlat_purify.c +++ b/src/lib/unlang/xlat_purify.c @@ -162,7 +162,6 @@ static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request, case XLAT_INVALID: case XLAT_FUNC_UNRESOLVED: - case XLAT_VIRTUAL: fr_assert(0); return -1; diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 11769147ae2..1a9e2775642 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -467,28 +467,6 @@ error: return 0; } -static int xlat_resolve_virtual_attribute(xlat_exp_t *node, tmpl_t *vpt) -{ - xlat_t *func; - - if (tmpl_is_attr(vpt)) { - func = xlat_func_find(tmpl_attr_tail_da(vpt)->name, -1); - } else { - func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1); - } - if (!func) return -1; - - xlat_exp_set_type(node, XLAT_VIRTUAL); - xlat_exp_set_name_shallow(node, vpt->name); - - XLAT_DEBUG("VIRTUAL <-- %pV", - fr_box_strvalue_len(vpt->name, vpt->len)); - node->call.func = func; - node->flags = func->flags; - - return 0; -} - /** Parse an attribute ref or a virtual attribute * */ @@ -553,11 +531,6 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t * * Deal with unresolved attributes. */ if (tmpl_is_attr_unresolved(vpt)) { - /* - * Could it be a virtual attribute? - */ - if ((tmpl_attr_num_elements(vpt) == 2) && (xlat_resolve_virtual_attribute(node, vpt) == 0)) goto done; - if (!t_rules->attr.allow_unresolved) { talloc_free(vpt); @@ -569,21 +542,16 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t * /* * Try to resolve it later */ - xlat_exp_set_type(node, XLAT_TMPL); - xlat_exp_set_name_shallow(node, vpt->name); - node->vpt = vpt; node->flags.needs_resolving = true; - - } else { - /* - * Deal with normal attribute (or list) - */ - xlat_exp_set_type(node, XLAT_TMPL); - xlat_exp_set_name_shallow(node, vpt->name); - node->vpt = vpt; } -done: + /* + * Deal with normal attribute (or list) + */ + xlat_exp_set_type(node, XLAT_TMPL); + xlat_exp_set_name_shallow(node, vpt->name); + node->vpt = vpt; + /* * Remember that it was %{User-Name} * @@ -1029,11 +997,6 @@ static void _xlat_debug_node(xlat_exp_t const *node, int depth) } break; - case XLAT_VIRTUAL: - fr_assert(node->fmt != NULL); - INFO_INDENT("virtual (%s)", node->fmt); - break; - case XLAT_FUNC: fr_assert(node->call.func != NULL); INFO_INDENT("func (%s)", node->call.func->name); @@ -1270,14 +1233,12 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t slen = tmpl_attr_print(out, node->vpt, TMPL_ATTR_REF_PREFIX_NO); if (slen < 0) return slen; break; + #ifdef HAVE_REGEX case XLAT_REGEX: FR_SBUFF_IN_SPRINTF_RETURN(out, "%i", node->regex_index); break; #endif - case XLAT_VIRTUAL: - FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name); - break; case XLAT_FUNC: FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name);