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:
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;
}
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:
* 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;
}
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,
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;
* 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 },