int xlat_from_tmpl_attr(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flags_t *flags, tmpl_t **vpt_p);
-int xlat_copy(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t *in);
+int xlat_copy(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t const *in);
/*
* xlat_inst.c
* - 0 on success.
* - -1 on failure.
*/
-int xlat_copy(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t *in)
+int xlat_copy(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t const *in)
{
- xlat_exp_t *p;
- fr_cursor_t out_cursor, in_cursor;
+ xlat_exp_t const *p;
+ fr_cursor_t out_cursor;
if (!in) {
*out = NULL;
}
fr_cursor_talloc_init(&out_cursor, out, xlat_exp_t);
- fr_cursor_talloc_init(&in_cursor, &in, xlat_exp_t);
/*
* Copy everything in the list of nodes
*/
- while ((p = fr_cursor_next(&in_cursor))) {
+ for (p = in; p; p = p->next) {
xlat_exp_t *node;
MEM(node = xlat_exp_alloc(ctx, p->type, p->fmt, talloc_array_length(p->fmt) - 1));
case XLAT_BOX:
if (unlikely(fr_value_box_copy(node, &node->data, &p->data) < 0)) goto error;
- continue;
+ break;
case XLAT_ONE_LETTER: /* Done with format */
case XLAT_FUNC_UNRESOLVED:
case XLAT_VIRTUAL_UNRESOLVED:
- continue;
+ break;
case XLAT_FUNC:
case XLAT_VIRTUAL:
node->call.func = p->call.func;
node->call.ephemeral = p->call.ephemeral;
if (unlikely(xlat_copy(node, &node->child, p->child) < 0)) goto error;
- continue;
+ break;
case XLAT_ATTRIBUTE:
node->attr = tmpl_copy(node, p->attr);
#ifdef HAVE_REGEX
case XLAT_REGEX:
node->regex_index = p->regex_index;
- continue;
+ break;
#endif
case XLAT_ALTERNATE:
if (unlikely(xlat_copy(node, &node->alternate, p->alternate) < 0)) goto error;
- continue;
+ break;
case XLAT_GROUP:
if (unlikely(xlat_copy(node, &node->child, p->child) < 0)) goto error;
- continue;
+ break;
}
+
+ fr_cursor_insert(&out_cursor, node);
}
return 0;