Skip to content

Commit ba51f7e

Browse files
committed
remove old foreach, along with XLAT_VIRTUAL
1 parent 8ece066 commit ba51f7e

File tree

5 files changed

+10
-75
lines changed

5 files changed

+10
-75
lines changed

src/lib/unlang/xlat_alloc.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,6 @@ static int CC_HINT(nonnull) _xlat_copy_internal(NDEBUG_LOCATION_ARGS TALLOC_CTX
274274
case XLAT_FUNC_UNRESOLVED:
275275
break;
276276

277-
case XLAT_VIRTUAL:
278-
node->call.func = p->call.func;
279-
node->call.dict = p->call.dict;
280-
node->call.ephemeral = p->call.ephemeral;
281-
break;
282-
283277
case XLAT_FUNC:
284278
/*
285279
* Only copy the function pointer, and whether this

src/lib/unlang/xlat_eval.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ static fr_slen_t xlat_fmt_print(fr_sbuff_t *out, xlat_exp_t const *node)
169169
return fr_sbuff_in_sprintf(out, "%%{%pV}", fr_box_strvalue_buffer(node->fmt));
170170
}
171171

172-
case XLAT_VIRTUAL:
173-
return fr_sbuff_in_sprintf(out, "%%{%s}", node->call.func->name);
174-
175172
#ifdef HAVE_REGEX
176173
case XLAT_REGEX:
177174
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_
12451242
fr_value_box_list_move((fr_value_box_list_t *)out->dlist, &result);
12461243
continue;
12471244

1248-
case XLAT_VIRTUAL:
1249-
{
1250-
XLAT_DEBUG("** [%i] %s(virtual) - %%{%s}", unlang_interpret_stack_depth(request), __FUNCTION__,
1251-
node->fmt);
1252-
1253-
xlat_debug_log_expansion(request, node, NULL, __LINE__);
1254-
xa = node->call.func->func(ctx, out,
1255-
XLAT_CTX(node->call.func->uctx, NULL, NULL, NULL, NULL),
1256-
request, NULL);
1257-
fr_dcursor_next(out);
1258-
1259-
xlat_debug_log_result(request, node, fr_dcursor_current(out));
1260-
}
1261-
continue;
1262-
12631245
case XLAT_FUNC:
12641246
XLAT_DEBUG("** [%i] %s(func) - %%%s(...)", unlang_interpret_stack_depth(request), __FUNCTION__,
12651247
node->fmt);

src/lib/unlang/xlat_priv.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ typedef enum {
108108
XLAT_ONE_LETTER = 0x0002, //!< Special "one-letter" expansion
109109
XLAT_FUNC = 0x0004, //!< xlat module
110110
XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
111-
XLAT_VIRTUAL = 0x0010, //!< virtual attribute
112-
XLAT_TMPL = 0x0020, //!< xlat attribute
111+
XLAT_TMPL = 0x0010, //!< xlat attribute
113112
#ifdef HAVE_REGEX
114-
XLAT_REGEX = 0x0040, //!< regex reference %{1}, etc.
113+
XLAT_REGEX = 0x0020, //!< regex reference %{1}, etc.
115114
#endif
116115
XLAT_GROUP = 0x0100 //!< encapsulated string of xlats
117116
} xlat_type_t;

src/lib/unlang/xlat_purify.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request,
162162

163163
case XLAT_INVALID:
164164
case XLAT_FUNC_UNRESOLVED:
165-
case XLAT_VIRTUAL:
166165
fr_assert(0);
167166
return -1;
168167

src/lib/unlang/xlat_tokenize.c

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -467,28 +467,6 @@ static CC_HINT(nonnull) int xlat_tokenize_function_args(xlat_exp_head_t *head, f
467467
return 0;
468468
}
469469

470-
static int xlat_resolve_virtual_attribute(xlat_exp_t *node, tmpl_t *vpt)
471-
{
472-
xlat_t *func;
473-
474-
if (tmpl_is_attr(vpt)) {
475-
func = xlat_func_find(tmpl_attr_tail_da(vpt)->name, -1);
476-
} else {
477-
func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1);
478-
}
479-
if (!func) return -1;
480-
481-
xlat_exp_set_type(node, XLAT_VIRTUAL);
482-
xlat_exp_set_name_shallow(node, vpt->name);
483-
484-
XLAT_DEBUG("VIRTUAL <-- %pV",
485-
fr_box_strvalue_len(vpt->name, vpt->len));
486-
node->call.func = func;
487-
node->flags = func->flags;
488-
489-
return 0;
490-
}
491-
492470
/** Parse an attribute ref or a virtual attribute
493471
*
494472
*/
@@ -553,11 +531,6 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t *
553531
* Deal with unresolved attributes.
554532
*/
555533
if (tmpl_is_attr_unresolved(vpt)) {
556-
/*
557-
* Could it be a virtual attribute?
558-
*/
559-
if ((tmpl_attr_num_elements(vpt) == 2) && (xlat_resolve_virtual_attribute(node, vpt) == 0)) goto done;
560-
561534
if (!t_rules->attr.allow_unresolved) {
562535
talloc_free(vpt);
563536

@@ -569,21 +542,16 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t *
569542
/*
570543
* Try to resolve it later
571544
*/
572-
xlat_exp_set_type(node, XLAT_TMPL);
573-
xlat_exp_set_name_shallow(node, vpt->name);
574-
node->vpt = vpt;
575545
node->flags.needs_resolving = true;
576-
577-
} else {
578-
/*
579-
* Deal with normal attribute (or list)
580-
*/
581-
xlat_exp_set_type(node, XLAT_TMPL);
582-
xlat_exp_set_name_shallow(node, vpt->name);
583-
node->vpt = vpt;
584546
}
585547

586-
done:
548+
/*
549+
* Deal with normal attribute (or list)
550+
*/
551+
xlat_exp_set_type(node, XLAT_TMPL);
552+
xlat_exp_set_name_shallow(node, vpt->name);
553+
node->vpt = vpt;
554+
587555
/*
588556
* Remember that it was %{User-Name}
589557
*
@@ -1029,11 +997,6 @@ static void _xlat_debug_node(xlat_exp_t const *node, int depth)
1029997
}
1030998
break;
1031999

1032-
case XLAT_VIRTUAL:
1033-
fr_assert(node->fmt != NULL);
1034-
INFO_INDENT("virtual (%s)", node->fmt);
1035-
break;
1036-
10371000
case XLAT_FUNC:
10381001
fr_assert(node->call.func != NULL);
10391002
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
12701233
slen = tmpl_attr_print(out, node->vpt, TMPL_ATTR_REF_PREFIX_NO);
12711234
if (slen < 0) return slen;
12721235
break;
1236+
12731237
#ifdef HAVE_REGEX
12741238
case XLAT_REGEX:
12751239
FR_SBUFF_IN_SPRINTF_RETURN(out, "%i", node->regex_index);
12761240
break;
12771241
#endif
1278-
case XLAT_VIRTUAL:
1279-
FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name);
1280-
break;
12811242

12821243
case XLAT_FUNC:
12831244
FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name);

0 commit comments

Comments
 (0)