tmpl_t *vpt = NULL;
MEM(node = xlat_exp_alloc_null(ctx));
- xlat_exp_set_type(node, XLAT_ATTRIBUTE);
+ xlat_exp_set_type(node, XLAT_TMPL);
slen = tmpl_afrom_attr_substr(node, NULL, &vpt, &in, p_rules, t_rules);
if (slen <= 0) {
}
xlat_exp_set_name_buffer_shallow(node, vpt->name);
- node->attr = vpt;
+ node->vpt = vpt;
goto done;
}
/*
* Wrap the result in a cast.
*
- * @todo - if the node is an XLAT_ATTR or XLAT_BOX and is already of the correct data type, then reparent
+ * @todo - if the node is an XLAT_TMPL or XLAT_BOX and is already of the correct data type, then reparent
* "node" to the parent of "cast", and free "cast".
*/
if (cast) {
* If the LHS is typed, try to parse the RHS as the given
* type. Otherwise, don't parse the RHS using enums.
*/
- if (lhs->type == XLAT_ATTRIBUTE) {
- da = tmpl_da(lhs->attr);
+ if (lhs->type == XLAT_TMPL) {
+ fr_assert(tmpl_is_attr(lhs->vpt) || tmpl_is_list(lhs->vpt));
+ da = tmpl_da(lhs->vpt);
} else {
da = NULL;
}
XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
XLAT_VIRTUAL = 0x0010, //!< virtual attribute
XLAT_VIRTUAL_UNRESOLVED = 0x0020, //!< virtual attribute needs resolution during pass2.
- XLAT_ATTRIBUTE = 0x0040, //!< xlat attribute
+ XLAT_TMPL = 0x0040, //!< xlat attribute
#ifdef HAVE_REGEX
- XLAT_REGEX = 0x0080, //!< regex reference
+ XLAT_REGEX = 0x0080, //!< regex reference %{1}, etc.
#endif
XLAT_ALTERNATE = 0x0100, //!< xlat conditional syntax :-
XLAT_GROUP = 0x0200 //!< encapsulated string of xlats
union {
xlat_exp_t *alternate; //!< Alternative expansion if this expansion produced no values.
- /** An attribute reference
+ /** An tmpl_t reference
*
- * May be an attribute to expand, or provide context for a call.
+ * May be an attribute to expand, or an exec reference, or a value-box, ...
*/
- tmpl_t *attr;
+ tmpl_t *vpt;
/** A capture group, i.e. for %{1} and friends
*/
*/
xlat_exp_set_type(node, XLAT_VIRTUAL_UNRESOLVED);
xlat_exp_set_name_buffer_shallow(node, vpt->name);
- node->attr = vpt;
+ node->vpt = vpt;
node->flags.needs_resolving = true;
/*
* Deal with normal attribute (or list)
*/
} else {
do_attr:
- xlat_exp_set_type(node, XLAT_ATTRIBUTE);
+ xlat_exp_set_type(node, XLAT_TMPL);
xlat_exp_set_name_buffer_shallow(node, vpt->name);
- node->attr = vpt;
+ node->vpt = vpt;
}
done:
INFO_INDENT("percent (%c)", node->fmt[0]);
break;
- case XLAT_ATTRIBUTE:
- fr_assert(tmpl_da(node->attr) != NULL);
- INFO_INDENT("attribute (%s)", tmpl_da(node->attr)->name);
+ case XLAT_TMPL:
+ fr_assert(tmpl_da(node->vpt) != NULL);
+ INFO_INDENT("attribute (%s)", tmpl_da(node->vpt)->name);
fr_assert(node->child == NULL);
- if (tmpl_num(node->attr) != NUM_ANY) {
+ if (tmpl_num(node->vpt) != NUM_ANY) {
INFO_INDENT("{");
- INFO_INDENT("ref %d", tmpl_request(node->attr));
- INFO_INDENT("list %d", tmpl_list(node->attr));
- if (tmpl_num(node->attr) != NUM_ANY) {
- if (tmpl_num(node->attr) == NUM_COUNT) {
+ INFO_INDENT("ref %d", tmpl_request(node->vpt));
+ INFO_INDENT("list %d", tmpl_list(node->vpt));
+ if (tmpl_num(node->vpt) != NUM_ANY) {
+ if (tmpl_num(node->vpt) == NUM_COUNT) {
INFO_INDENT("[#]");
- } else if (tmpl_num(node->attr) == NUM_ALL) {
+ } else if (tmpl_num(node->vpt) == NUM_ALL) {
INFO_INDENT("[*]");
} else {
- INFO_INDENT("[%d]", tmpl_num(node->attr));
+ INFO_INDENT("[%d]", tmpl_num(node->vpt));
}
}
INFO_INDENT("}");
}
switch (node->type) {
- case XLAT_ATTRIBUTE:
- slen = tmpl_attr_print(out, node->attr, TMPL_ATTR_REF_PREFIX_NO);
+ case XLAT_TMPL:
+ slen = tmpl_attr_print(out, node->vpt, TMPL_ATTR_REF_PREFIX_NO);
if (slen < 0) {
error:
return slen;
*/
case XLAT_VIRTUAL_UNRESOLVED:
{
- if (xlat_resolve_virtual_attribute(node, node->attr) == 0) break;
+ if (xlat_resolve_virtual_attribute(node, node->vpt) == 0) break;
/*
* Try and resolve (in-place) as an attribute
*/
- if ((tmpl_resolve(node->attr, xr_rules->tr_rules) < 0) ||
- (node->attr->type != TMPL_TYPE_ATTR)) {
+ if ((tmpl_resolve(node->vpt, xr_rules->tr_rules) < 0) ||
+ (node->vpt->type != TMPL_TYPE_ATTR)) {
/*
* FIXME - Produce proper error with marker
*/
* Just need to flip the type as the tmpl
* should already have been fixed up
*/
- xlat_exp_set_type(node, XLAT_ATTRIBUTE);
+ xlat_exp_set_type(node, XLAT_TMPL);
/*
* Reset node flags
}
break;
- case XLAT_ATTRIBUTE:
+ case XLAT_TMPL:
if (!xr_rules->allow_unresolved) goto error_unresolved;
break;
{
tmpl_t *vpt;
- if (node->next || (node->type != XLAT_ATTRIBUTE) || !tmpl_is_attr(node->attr)) return NULL;
+ if (node->next || (node->type != XLAT_TMPL) || !tmpl_is_attr(node->vpt)) return NULL;
/*
* Concat means something completely different as an attribute reference
* Count isn't implemented.
*/
- if ((tmpl_num(node->attr) == NUM_COUNT) || (tmpl_num(node->attr) == NUM_ALL)) return NULL;
+ if ((tmpl_num(node->vpt) == NUM_COUNT) || (tmpl_num(node->vpt) == NUM_ALL)) return NULL;
vpt = tmpl_alloc(ctx, TMPL_TYPE_ATTR, T_BARE_WORD, node->fmt, talloc_array_length(node->fmt) - 1);
if (!vpt) return NULL;
- tmpl_attr_copy(vpt, node->attr);
+ tmpl_attr_copy(vpt, node->vpt);
TMPL_VERIFY(vpt);
* the assignment of the tmpl to the new
* xlat expression
*/
- node->attr = talloc_move(node, vpt_p);
+ node->vpt = talloc_move(node, vpt_p);
node->flags = (xlat_flags_t) { .needs_resolving = true };
*head = node;
xlat_flags_merge(flags, &node->flags);
virtual:
node = xlat_exp_alloc(ctx, XLAT_VIRTUAL, vpt->name, vpt->len);
- node->attr = talloc_move(node, vpt_p);
+ node->vpt = talloc_move(node, vpt_p);
node->call.func = func;
node->flags = func->flags;
}
}
- node = xlat_exp_alloc(ctx, XLAT_ATTRIBUTE, vpt->name, vpt->len);
- node->attr = talloc_move(node, vpt_p);
+ node = xlat_exp_alloc(ctx, XLAT_TMPL, vpt->name, vpt->len);
+ node->vpt = talloc_move(node, vpt_p);
return 0;
}
if (unlikely(xlat_copy(node, &node->child, p->child) < 0)) goto error;
break;
- case XLAT_ATTRIBUTE:
- node->attr = tmpl_copy(node, p->attr);
+ case XLAT_TMPL:
+ node->vpt = tmpl_copy(node, p->vpt);
continue;
#ifdef HAVE_REGEX