From: Alan T. DeKok Date: Mon, 20 Dec 2021 13:59:47 +0000 (-0500) Subject: add temporary hack function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d7adf35a1ab854434acf37fdfadd25b7ea00c47;p=thirdparty%2Ffreeradius-server.git add temporary hack function which will be removed as soon as we have the better function --- diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index 0dfae50397..4bef868b05 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -988,6 +988,8 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t bool tmpl_async_required(tmpl_t const *vpt); +fr_pair_t *tmpl_get_list(request_t *request, tmpl_t const *vpt); /* temporary hack */ + #undef _CONST #ifdef __cplusplus diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index 223693d996..c294637a7e 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -37,6 +37,47 @@ RCSID("$Id$") #include #include +/** Resolve a #tmpl_t into an #fr_pair_t + * + * @param[in] request containing the target lists. + * @param[in] vpt tmpl to resolve + * @return a pointer to the list in the #request_t. + * + * @This is just a temporary hack. + */ +fr_pair_t *tmpl_get_list(request_t *request, tmpl_t const *vpt) +{ + tmpl_pair_list_t list; + + if (!request) return NULL; + + list = tmpl_list(vpt); + + switch (list) { + /* Don't add default */ + case PAIR_LIST_UNKNOWN: + break; + + case PAIR_LIST_REQUEST: + return request->pair_list.request; + + case PAIR_LIST_REPLY: + return request->pair_list.reply; + + case PAIR_LIST_CONTROL: + return request->pair_list.control; + + case PAIR_LIST_STATE: + return request->pair_list.state; + } + + RWDEBUG2("List \"%s\" is not available", + fr_table_str_by_value(pair_list_table, list, "")); + + return NULL; +} + + /** Resolve attribute #pair_list_t value to an attribute list. * * The value returned is a pointer to the pointer of the HEAD of a #fr_pair_t list in the