]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add temporary hack function
authorAlan T. DeKok <aland@freeradius.org>
Mon, 20 Dec 2021 13:59:47 +0000 (08:59 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Dec 2021 17:22:15 +0000 (12:22 -0500)
which will be removed as soon as we have the better function

src/lib/server/tmpl.h
src/lib/server/tmpl_eval.c

index 0dfae50397e7e28e3bf43dd7c5b44b634ac71729..4bef868b05ac105d43c4d63d41b711c7afafd6d7 100644 (file)
@@ -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
index 223693d996b361a19ddf07db9754cacbed99ef72..c294637a7ed03dd2dbff983274fc91a19e1dd0a9 100644 (file)
@@ -37,6 +37,47 @@ RCSID("$Id$")
 #include <freeradius-devel/util/value.h>
 #include <freeradius-devel/util/edit.h>
 
+/** 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, "<INVALID>"));
+
+       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