]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
preliminary code to interpret UNLANG_TYPE_VARIABLE
authorAlan T. DeKok <aland@freeradius.org>
Fri, 25 Nov 2022 14:41:28 +0000 (09:41 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 25 Nov 2022 19:59:43 +0000 (14:59 -0500)
does nothing right now, but at least doesn't crash if you try to
use local variables

src/lib/unlang/all.mk
src/lib/unlang/base.c
src/lib/unlang/unlang_priv.h
src/lib/unlang/variable.c [new file with mode: 0644]

index 8a743baf81a2e7aeeeb17750f358d43fb67b2834..148748918ef93a071a53823adaffe338b3f71dca 100644 (file)
@@ -24,6 +24,7 @@ SOURCES       :=      base.c \
                switch.c \
                timeout.c \
                tmpl.c \
+               variable.c \
                xlat.c \
                xlat_builtin.c \
                xlat_eval.c \
index 043a35c3e1c5a02ccade08234c93a59a249e6279..d7cb6458a5f0c8c16dd51667e2619ce59993a69b 100644 (file)
@@ -103,6 +103,7 @@ int unlang_init_global(void)
        unlang_edit_init();
        unlang_timeout_init();
        unlang_limit_init();
+       unlang_variable_init();
 
        instance_count++;
 
index 56f26e0f94041a855283ca1304b26006816e63ea..35bbc5062d34e1281d7271785136a8bd94de781c 100644 (file)
@@ -623,6 +623,8 @@ void                unlang_edit_init(void);
 void           unlang_timeout_init(void);
 
 void           unlang_limit_init(void);
+
+void           unlang_variable_init(void);
  /** @} */
 
 #ifdef __cplusplus
diff --git a/src/lib/unlang/variable.c b/src/lib/unlang/variable.c
new file mode 100644 (file)
index 0000000..6090222
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/**
+ * $Id$
+ *
+ * @file unlang/variable.c
+ * @brief Unlang local "variable"s
+ *
+ * @copyright 2022 Network RADIUS SAS (legal@networkradius.com)
+ */
+RCSID("$Id$")
+
+#include "group_priv.h"
+#include "variable_priv.h"
+
+static unlang_action_t unlang_variable(UNUSED rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
+{
+       unlang_variable_t               *var;
+
+       var = unlang_generic_to_variable(frame->instruction);
+
+       RDEBUG3("Creating varible max %d", var->max_attr);
+
+       return UNLANG_ACTION_CALCULATE_RESULT;
+}
+
+
+void unlang_variable_init(void)
+{
+       unlang_register(UNLANG_TYPE_VARIABLE,
+                          &(unlang_op_t){
+                               .name = "variable",
+                               .interpret = unlang_variable,
+                          });
+}