]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
give expr.rcode() a better name: interpreter.rcode()
authorAlan T. DeKok <aland@freeradius.org>
Tue, 15 Jul 2025 13:05:10 +0000 (09:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 15 Jul 2025 15:59:49 +0000 (11:59 -0400)
the old one is still around for compatibility reasons

src/lib/unlang/xlat_expr.c
src/tests/unit/condition/base.txt
src/tests/unit/xlat/cond_base.txt
src/tests/unit/xlat/purify.txt

index 286e59b13bbbdd6ae00da84412fb3140773391f9..09165db77c731055017a75d85c2af658f5dca319 100644 (file)
@@ -1588,7 +1588,7 @@ static fr_slen_t xlat_expr_print_rcode(fr_sbuff_t *out, xlat_exp_t const *node,
        size_t                  at_in = fr_sbuff_used_total(out);
        xlat_rcode_inst_t       *inst = instance;
 
-       FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "%expr.rcode('");
+       FR_SBUFF_IN_STRCPY_LITERAL_RETURN(out, "%interpreter.rcode('");
        if (xlat_exp_head(node->call.args)) {
                ssize_t slen;
 
@@ -1608,7 +1608,7 @@ static fr_slen_t xlat_expr_print_rcode(fr_sbuff_t *out, xlat_exp_t const *node,
  *
  * Example:
 @verbatim
-%expr.rcode('handled') == true
+%interpreter.rcode('handled') == true
 
 # ...or how it's used normally used
 if (handled) {
@@ -1895,7 +1895,12 @@ int xlat_register_expressions(void)
        XLAT_REGISTER_NARY_OP(T_LAND, logical_and, logical);
        XLAT_REGISTER_NARY_OP(T_LOR, logical_or, logical);
 
+       XLAT_REGISTER_BOOL("interpreter.rcode", xlat_func_expr_rcode, xlat_func_expr_rcode_arg, FR_TYPE_BOOL);
+       xlat_func_instantiate_set(xlat, xlat_instantiate_expr_rcode, xlat_rcode_inst_t, NULL, NULL);
+       xlat_func_print_set(xlat, xlat_expr_print_rcode);
+
        XLAT_REGISTER_BOOL("expr.rcode", xlat_func_expr_rcode, xlat_func_expr_rcode_arg, FR_TYPE_BOOL);
+       xlat->deprecated = true;
        xlat_func_instantiate_set(xlat, xlat_instantiate_expr_rcode, xlat_rcode_inst_t, NULL, NULL);
        xlat_func_print_set(xlat, xlat_expr_print_rcode);
 
@@ -2371,7 +2376,7 @@ static ssize_t tokenize_rcode(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_
        /*
         *      @todo - allow for attributes to have the name "ok-foo" ???
         */
-       func = xlat_func_find("expr.rcode", -1);
+       func = xlat_func_find("interpreter.rcode", -1);
        fr_assert(func != NULL);
 
        MEM(node = xlat_exp_alloc(head, XLAT_FUNC, fr_sbuff_start(&our_in), slen));
index 66647e760dea6d45497cd17a3d31e020c45ea1b5..3665ee36a1914a6a9417cfb3378803000855d2db 100644 (file)
@@ -64,7 +64,7 @@ match ERROR offset 4: Invalid operator
 
 # sillyness is OK, but cleaned up.
 condition ((((((ok))))))
-match %expr.rcode('ok')
+match %interpreter.rcode('ok')
 
 #
 #  Extra braces get squashed
@@ -73,10 +73,10 @@ condition (User-Name == User-Password)
 match (User-Name == User-Password)
 
 condition (!ok)
-match !%expr.rcode('ok')
+match !%interpreter.rcode('ok')
 
 condition !(ok)
-match !%expr.rcode('ok')
+match !%interpreter.rcode('ok')
 
 condition !!ok
 match ERROR offset 1: Double operator is invalid
@@ -85,7 +85,7 @@ match ERROR offset 1: Double operator is invalid
 # @todo - peephole - do optimization to get rid of double negation?
 #
 condition !(!ok)
-match !!%expr.rcode('ok')
+match !!%interpreter.rcode('ok')
 
 #
 #  These next two are identical after normalization
@@ -113,15 +113,15 @@ condition ((User-Name == 'b') || (Filter-Id == 'd')))
 match ERROR passed in 43, returned 42
 
 condition (handled && (Packet-Type == ::Access-Challenge))
-match (%expr.rcode('handled') && (Packet-Type == ::Access-Challenge))
+match (%interpreter.rcode('handled') && (Packet-Type == ::Access-Challenge))
 
 # This is OK, without the braces
 condition handled && Packet-Type == ::Access-Challenge
-match (%expr.rcode('handled') && (Packet-Type == ::Access-Challenge))
+match (%interpreter.rcode('handled') && (Packet-Type == ::Access-Challenge))
 
 # and this, though it's not a good idea.
 condition handled &&&Packet-Type == ::Access-Challenge
-match (%expr.rcode('handled') && (Packet-Type == ::Access-Challenge))
+match (%interpreter.rcode('handled') && (Packet-Type == ::Access-Challenge))
 
 condition reply == request
 match ERROR offset 0: Cannot use list references in condition
@@ -385,13 +385,13 @@ match ERROR offset 1: Attribute 'a' not found in namespace 'internal': Unresolve
 #  Module return codes are OK
 #
 condition (ok)
-match %expr.rcode('ok')
+match %interpreter.rcode('ok')
 
 condition (handled)
-match %expr.rcode('handled')
+match %interpreter.rcode('handled')
 
 condition (fail)
-match %expr.rcode('fail')
+match %interpreter.rcode('fail')
 
 condition ("a")
 match "a"
index e41ce2ee43fed94b045e2fb92ba3267a3a2f6834..c356c9a07fea854855b61ae1950cc553dd1a6a6a 100644 (file)
@@ -715,16 +715,16 @@ match ((User-Name == "bob") && ((User-Password == "bob") || EAP-Message))
 #  rcode tests
 #
 xlat_purify handled && (User-Name == "bob")
-match (%expr.rcode('handled') && (User-Name == "bob"))
+match (%interpreter.rcode('handled') && (User-Name == "bob"))
 
 xlat_purify (User-Name == "bob") && (User-Password == "bob") && handled
-match ((User-Name == "bob") && (User-Password == "bob") && %expr.rcode('handled'))
+match ((User-Name == "bob") && (User-Password == "bob") && %interpreter.rcode('handled'))
 
 xlat_purify handledx
 match ERROR offset 0: Attribute 'handledx' not found.  Searched in: RADIUS, internal: Unresolved attributes are not allowed here
 
 xlat_purify handled
-match %expr.rcode('handled')
+match %interpreter.rcode('handled')
 
 #
 #  Automatic casting
index 298f89b0160729f8c8b18210dfc882425697e3ab..57798afdbb47ade8ae4cf0ced0f89c886c347e01 100644 (file)
@@ -193,13 +193,13 @@ match false
 #  These are just booleans now.  We can subtract and invert them.
 #
 xlat_purify -fail
-match -%expr.rcode('fail')
+match -%interpreter.rcode('fail')
 
 xlat_purify ~fail
-match ~%expr.rcode('fail')
+match ~%interpreter.rcode('fail')
 
 xlat_purify !fail
-match !%expr.rcode('fail')
+match !%interpreter.rcode('fail')
 
 #
 #  Casts and such