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);
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);
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;
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
*
*/
* 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);
/*
* 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}
*
}
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);
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);