From: Alan T. DeKok Date: Tue, 15 Jul 2025 13:05:10 +0000 (-0400) Subject: give expr.rcode() a better name: interpreter.rcode() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f1531ea693c3f8264d40cf63e474843eddf01f9;p=thirdparty%2Ffreeradius-server.git give expr.rcode() a better name: interpreter.rcode() the old one is still around for compatibility reasons --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 286e59b13b..09165db77c 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -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)); diff --git a/src/tests/unit/condition/base.txt b/src/tests/unit/condition/base.txt index 66647e760d..3665ee36a1 100644 --- a/src/tests/unit/condition/base.txt +++ b/src/tests/unit/condition/base.txt @@ -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" diff --git a/src/tests/unit/xlat/cond_base.txt b/src/tests/unit/xlat/cond_base.txt index e41ce2ee43..c356c9a07f 100644 --- a/src/tests/unit/xlat/cond_base.txt +++ b/src/tests/unit/xlat/cond_base.txt @@ -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 diff --git a/src/tests/unit/xlat/purify.txt b/src/tests/unit/xlat/purify.txt index 298f89b016..57798afdbb 100644 --- a/src/tests/unit/xlat/purify.txt +++ b/src/tests/unit/xlat/purify.txt @@ -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