* because references aren't threadsafe.
*/
MEM(value = fr_value_box_alloc_null(ctx));
- fr_value_box_bstrdup_buffer(value, value, NULL, node->fmt, false);
+ if (fr_value_box_copy(ctx, value, &node->data) < 0) goto fail;
fr_dcursor_append(out, value);
continue;
*/
case XLAT_LITERAL:
XLAT_DEBUG("%.*sxlat_sync_eval LITERAL", lvl, xlat_spaces);
- return talloc_typed_strdup(ctx, node->fmt);
+ {
+ char *out;
+ slen = fr_value_box_aprint(ctx, &out, &node->data, NULL);
+ if (slen < 0) return NULL;
+ return out;
+ }
case XLAT_GROUP:
XLAT_DEBUG("%.*sxlat_sync_eval CHILD", lvl, xlat_spaces);
return node;
}
+
/** Allocate an xlat node
*
* @param[in] ctx to allocate node in.
node->type = type;
if (in) node->fmt = talloc_bstrndup(node, in, inlen);
- node->flags.pure = (type == XLAT_LITERAL);
+ if (type == XLAT_LITERAL) {
+ node->flags.pure = true; /* literals are always pure */
+ node->flags.needs_async = false; /* literals are always non-async */
+ fr_value_box_strdup_shallow(&node->data, NULL, node->fmt, false);
+ }
return node;
}
node->type = type;
if (type == XLAT_LITERAL) {
- node->flags.needs_async = false; /* literals are always non-async */
node->flags.pure = true; /* literals are always pure */
+ node->flags.needs_async = false; /* literals are always non-async */
}
}
return -1;
}
+ /*
+ * The argument isn't of the correct type. Cast it.
+ */
+ if ((child->type == XLAT_LITERAL) && (child->data.type != arg_p->type) &&
+ (fr_value_box_cast_in_place(child, &child->data, arg_p->type, NULL) < 0)) {
+ return -1;
+ }
+
child = child->next;
}
if (len > 0) {
xlat_exp_set_type(node, XLAT_LITERAL);
xlat_exp_set_name_buffer_shallow(node, str);
+ fr_value_box_strdup_shallow(&node->data, NULL, str, false);
XLAT_DEBUG("LITERAL (%s)<-- %pV",
- escapes ? escapes->name : "(none)",
+ escapes ? escapes->name : "(none)",XXX
fr_box_strvalue_len(str, talloc_array_length(str) - 1));
XLAT_HEXDUMP((uint8_t const *)str, talloc_array_length(str) - 1, " LITERAL ");
fr_cursor_insert(&cursor, node);
goto next;
case XLAT_LITERAL:
- FR_SBUFF_IN_ESCAPE_BUFFER_RETURN(out, node->fmt, e_rules);
+ FR_SBUFF_RETURN(fr_value_box_print, out, &node->data, e_rules);
goto next;
case XLAT_ONE_LETTER:
value_parse_rules_single_quoted.terminals,
value_parse_rules_single_quoted.escapes);
if (slen < 0) goto error;
+
xlat_exp_set_name_buffer_shallow(node->child, str);
+ fr_value_box_strdup_shallow(&node->child->data, NULL, str, false);
xlat_flags_merge(flags, &node->flags);
}
break;