From: Alan T. DeKok Date: Fri, 10 Dec 2021 21:35:06 +0000 (-0500) Subject: remove fr_pair_mark_xlat(), as nothing uses it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd0465d59ec9cf932ef792215a3d1385969036e3;p=thirdparty%2Ffreeradius-server.git remove fr_pair_mark_xlat(), as nothing uses it --- diff --git a/src/lib/util/pair_legacy.c b/src/lib/util/pair_legacy.c index 846994fd63..2aa6b42854 100644 --- a/src/lib/util/pair_legacy.c +++ b/src/lib/util/pair_legacy.c @@ -55,41 +55,6 @@ static fr_sbuff_term_t const bareword_terminals = L("||"), /* Logical operator */ ); -/** Mark a valuepair for xlat expansion - * - * Copies xlat source (unprocessed) string to valuepair value, and sets value type. - * - * @param vp to mark for expansion. - * @param value to expand. - * @return - * - 0 if marking succeeded. - * - -1 if #fr_pair_t already had a value, or OOM. - */ -int fr_pair_mark_xlat(fr_pair_t *vp, char const *value) -{ - char *raw; - - /* - * valuepair should not already have a value. - */ - if (vp->type != VT_NONE) { - fr_strerror_const("Pair already has a value"); - return -1; - } - - raw = talloc_typed_strdup(vp, value); - if (!raw) { - fr_strerror_const("Out of memory"); - return -1; - } - - vp->type = VT_XLAT; - vp->xlat = raw; - vp->vp_length = 0; - - return 0; -} - /** Create a valuepair from an ASCII attribute and value * * Where the attribute name is in the form: @@ -222,7 +187,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * fr_pair_list_t tmp_list; fr_pair_t *vp = NULL; fr_pair_t *my_relative_vp; - char const *p, *q, *next; + char const *p, *next; fr_token_t quote, last_token = T_INVALID; fr_pair_t_RAW raw; fr_dict_attr_t const *internal = NULL; @@ -401,22 +366,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * } switch (quote) { - /* - * Perhaps do xlat's - */ case T_DOUBLE_QUOTED_STRING: - /* - * Only report as double quoted if it contained valid - * a valid xlat expansion. - */ - q = strchr(raw.r_opand, '%'); - if (q && (q[1] == '{')) { - raw.quote = quote; - } else { - raw.quote = T_SINGLE_QUOTED_STRING; - } - break; - case T_SINGLE_QUOTED_STRING: case T_BACK_QUOTED_STRING: case T_BARE_WORD: @@ -449,18 +399,10 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * * ignore it. */ break; + } - /* - * fr_pair_raw_from_str() only returns this when - * the input looks like it needs to be xlat'd. - */ - } if (raw.quote == T_DOUBLE_QUOTED_STRING) { - if (fr_pair_mark_xlat(vp, raw.r_opand) < 0) { - talloc_free(vp); - goto error; - } - } else if (fr_pair_value_from_str(vp, raw.r_opand, strlen(raw.r_opand), - fr_value_unescape_by_quote[quote], false) < 0) { + if (fr_pair_value_from_str(vp, raw.r_opand, strlen(raw.r_opand), + fr_value_unescape_by_quote[quote], false) < 0) { talloc_free(vp); goto error; } diff --git a/src/lib/util/pair_legacy.h b/src/lib/util/pair_legacy.h index 0afb5bcda9..9568adac34 100644 --- a/src/lib/util/pair_legacy.h +++ b/src/lib/util/pair_legacy.h @@ -37,8 +37,6 @@ extern "C" { fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *vps, char const *attribute, char const *value); -int fr_pair_mark_xlat(fr_pair_t *vp, char const *value); - fr_token_t fr_pair_list_afrom_str(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *buffer, size_t len, fr_pair_list_t *head); int fr_pair_list_afrom_file(TALLOC_CTX *ctx, fr_dict_t const *dict, diff --git a/src/lib/util/pair_legacy_tests.c b/src/lib/util/pair_legacy_tests.c index 1b75e641a3..e9f4bef8c9 100644 --- a/src/lib/util/pair_legacy_tests.c +++ b/src/lib/util/pair_legacy_tests.c @@ -103,29 +103,6 @@ static void test_fr_pair_make(void) fr_pair_list_free(&list); } -static void test_fr_pair_mark_xlat(void) -{ - fr_pair_t *vp; - - TEST_CASE("Find 'Test-String-0'"); - TEST_CHECK((vp = fr_pair_find_by_da_idx(&test_pairs, fr_dict_attr_test_string, 0)) != NULL); - - TEST_CASE("Validating PAIR_VERIFY()"); - PAIR_VERIFY(vp); - - TEST_CASE("Marking 'vp' using fr_pair_mark_xlat()"); - TEST_CHECK(fr_pair_mark_xlat(vp, "Hello %{Test-Uint32-0}") == 0); - - TEST_CASE("Validating PAIR_VERIFY()"); - PAIR_VERIFY(vp); - - TEST_CASE("Check (vp->xlat == 'Hello %{Test-Uint32-0}')"); - TEST_CHECK(vp && strcmp(vp->xlat, "Hello %{Test-Uint32-0}") == 0); - TEST_CHECK(vp && vp->type == VT_XLAT); - - talloc_free(vp); -} - static void test_fr_pair_list_afrom_str(void) { fr_pair_t *vp; @@ -260,7 +237,6 @@ TEST_LIST = { * Legacy calls */ { "fr_pair_make", test_fr_pair_make }, - { "fr_pair_mark_xlat", test_fr_pair_mark_xlat }, { "fr_pair_list_afrom_str", test_fr_pair_list_afrom_str }, { "fr_pair_list_afrom_file", test_fr_pair_list_afrom_file }, { "fr_pair_list_move_op", test_fr_pair_list_move_op },