From: Alan T. DeKok Date: Fri, 20 Jan 2023 14:35:29 +0000 (-0500) Subject: add tmpl_set_xlat() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc6b4b6d1d2dedbb8b2537a258c0689aba513bf5;p=thirdparty%2Ffreeradius-server.git add tmpl_set_xlat() for use with edit expressions --- diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index 11c3db373f2..b6f254e2d2e 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -1106,6 +1106,8 @@ void tmpl_set_name(tmpl_t *vpt, fr_token_t quote, char const *name, ssize_t le void tmpl_set_dict_def(tmpl_t *vpt, fr_dict_t const *dict) CC_HINT(nonnull); +void tmpl_set_xlat(tmpl_t *vpt, xlat_exp_head_t *xlat) CC_HINT(nonnull); + int tmpl_afrom_value_box(TALLOC_CTX *ctx, tmpl_t **out, fr_value_box_t *data, bool steal) CC_HINT(nonnull); void tmpl_attr_ref_debug(const tmpl_attr_t *ar, int idx) CC_HINT(nonnull); diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index c1234bddafc..874b0faa6a5 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -828,6 +828,19 @@ void tmpl_set_dict_def(tmpl_t *vpt, fr_dict_t const *dict) vpt->rules.attr.dict_def = dict; } +/** Change the default dictionary in the tmpl's resolution rules + * + * @param[in] vpt to alter. + * @param[in] xlat to set. + */ +void tmpl_set_xlat(tmpl_t *vpt, xlat_exp_head_t *xlat) +{ + fr_assert(vpt->type == TMPL_TYPE_XLAT); + + tmpl_xlat(vpt) = xlat; +} + + /** Initialise a tmpl using a format string to create the name * * @param[in] vpt to initialise.