Skip to content

Commit c266c85

Browse files
committed
remove prefix flag from tmpl print routines
1 parent 82d32c2 commit c266c85

File tree

5 files changed

+24
-66
lines changed

5 files changed

+24
-66
lines changed

src/lib/redis/redis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ int fr_redis_tuple_from_map(TALLOC_CTX *pool, char const *out[], size_t out_len[
474474
fr_assert(tmpl_is_attr(map->lhs));
475475
fr_assert(tmpl_is_data(map->rhs));
476476

477-
slen = tmpl_print(&key_buf_sbuff, map->lhs, TMPL_ATTR_REF_PREFIX_NO, NULL);
477+
slen = tmpl_print(&key_buf_sbuff, map->lhs, NULL);
478478
if (slen < 0) {
479479
fr_strerror_printf("Key too long. Must be < " STRINGIFY(sizeof(key_buf)) " "
480480
"bytes, got %zu bytes", (size_t)(slen * -1));

src/lib/server/map.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ int map_afrom_vp(TALLOC_CTX *ctx, map_t **out, fr_pair_t *vp, tmpl_rules_t const
14591459
tmpl_attr_set_request_ref(map->lhs, rules->attr.request_def);
14601460
tmpl_attr_set_list(map->lhs, rules->attr.list_def);
14611461

1462-
tmpl_print(&buffer_sbuff, map->lhs, TMPL_ATTR_REF_PREFIX_AUTO, NULL);
1462+
tmpl_print(&buffer_sbuff, map->lhs, NULL);
14631463
tmpl_set_name(map->lhs, T_BARE_WORD, fr_sbuff_start(&buffer_sbuff), -1);
14641464

14651465
/*
@@ -2392,7 +2392,7 @@ ssize_t map_print(fr_sbuff_t *out, map_t const *map)
23922392
FR_SBUFF_IN_SPRINTF_RETURN(&our_out, "<%s>",
23932393
fr_type_to_str(tmpl_rules_cast(map->lhs)));
23942394
}
2395-
FR_SBUFF_RETURN(tmpl_print_quoted, &our_out, map->lhs, TMPL_ATTR_REF_PREFIX_AUTO);
2395+
FR_SBUFF_RETURN(tmpl_print_quoted, &our_out, map->lhs);
23962396

23972397
/*
23982398
* Print separators and operator
@@ -2426,7 +2426,7 @@ ssize_t map_print(fr_sbuff_t *out, map_t const *map)
24262426
/*
24272427
* Print the RHS.
24282428
*/
2429-
FR_SBUFF_RETURN(tmpl_print_quoted, &our_out, map->rhs, TMPL_ATTR_REF_PREFIX_AUTO);
2429+
FR_SBUFF_RETURN(tmpl_print_quoted, &our_out, map->rhs);
24302430

24312431
FR_SBUFF_SET_RETURN(out, &our_out);
24322432
}
@@ -2481,7 +2481,7 @@ void map_debug_log(request_t *request, map_t const *map, fr_pair_t const *vp)
24812481
* the quoting based on the data type.
24822482
*/
24832483
fr_pair_aprint_value_quoted(request, &value, vp, quote);
2484-
tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->rhs, TMPL_ATTR_REF_PREFIX_AUTO, NULL);
2484+
tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->rhs, NULL);
24852485
rhs = talloc_typed_asprintf(request, "%s -> %s", buffer, value);
24862486
}
24872487
break;
@@ -2493,7 +2493,7 @@ void map_debug_log(request_t *request, map_t const *map, fr_pair_t const *vp)
24932493

24942494
switch (map->lhs->type) {
24952495
case TMPL_TYPE_ATTR:
2496-
tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->lhs, TMPL_ATTR_REF_PREFIX_AUTO, NULL);
2496+
tmpl_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map->lhs, NULL);
24972497
RDEBUG2("%s %s %s", buffer, fr_table_str_by_value(fr_tokens_table, vp ? vp->op : map->op, "<INVALID>"), rhs);
24982498
break;
24992499

src/lib/server/tmpl.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,22 +1275,22 @@ fr_slen_t tmpl_request_ref_list_print(fr_sbuff_t *out, FR_DLIST_HEAD(tmpl_reque
12751275
static inline fr_slen_t tmpl_request_ref_list_aprint(TALLOC_CTX *ctx, char **out, FR_DLIST_HEAD(tmpl_request_list) const *rql)
12761276
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_request_ref_list_print, rql)
12771277

1278-
fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix) CC_HINT(nonnull(1,2));
1278+
fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt) CC_HINT(nonnull);
12791279

1280-
static inline fr_slen_t tmpl_attr_aprint(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix)
1281-
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_attr_print, vpt, ar_prefix)
1280+
static inline fr_slen_t tmpl_attr_aprint(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt)
1281+
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_attr_print, vpt)
12821282

12831283
fr_slen_t tmpl_print(fr_sbuff_t *out, tmpl_t const *vpt,
1284-
tmpl_attr_prefix_t ar_prefix, fr_sbuff_escape_rules_t const *e_rules) CC_HINT(nonnull(1,2));
1284+
fr_sbuff_escape_rules_t const *e_rules) CC_HINT(nonnull(1,2));
12851285

12861286
static inline fr_slen_t tmpl_aprint(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt,
1287-
tmpl_attr_prefix_t ar_prefix, fr_sbuff_escape_rules_t const *e_rules)
1288-
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_print, vpt, ar_prefix, e_rules)
1287+
fr_sbuff_escape_rules_t const *e_rules)
1288+
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_print, vpt, e_rules)
12891289

1290-
fr_slen_t tmpl_print_quoted(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix) CC_HINT(nonnull);
1290+
fr_slen_t tmpl_print_quoted(fr_sbuff_t *out, tmpl_t const *vpt) CC_HINT(nonnull);
12911291

1292-
static inline fr_slen_t tmpl_aprint_quoted(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix)
1293-
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_print_quoted, vpt, ar_prefix)
1292+
static inline fr_slen_t tmpl_aprint_quoted(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt)
1293+
SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(tmpl_print_quoted, vpt)
12941294
/** @} */
12951295

12961296
/** @name Expand the tmpl, returning one or more values

src/lib/server/tmpl_tokenize.c

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ int tmpl_attr_afrom_list(TALLOC_CTX *ctx, tmpl_t **out, tmpl_t const *list, fr_d
12771277
* We need to rebuild the attribute name, to be the
12781278
* one we copied from the source list.
12791279
*/
1280-
slen = tmpl_print(&FR_SBUFF_OUT(attr, sizeof(attr)), vpt, TMPL_ATTR_REF_PREFIX_AUTO,
1280+
slen = tmpl_print(&FR_SBUFF_OUT(attr, sizeof(attr)), vpt,
12811281
fr_value_escape_by_quote[list->quote]);
12821282
if (slen < 0) {
12831283
fr_strerror_printf("Serialized attribute too long. Must be < "
@@ -2274,11 +2274,10 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err,
22742274
}
22752275

22762276
/*
2277-
* We parsed the tmpl as &User-Name, or just User-Name, but NOT %{User-Name}.
2278-
* Mark it up as having a prefix.
2277+
* We parsed the tmpl as User-Name, but NOT %{User-Name}.
22792278
*/
22802279
MEM(vpt = tmpl_alloc(ctx, TMPL_TYPE_ATTR, T_BARE_WORD, NULL, 0));
2281-
vpt->data.attribute.ref_prefix = TMPL_ATTR_REF_PREFIX_YES;
2280+
vpt->data.attribute.ref_prefix = TMPL_ATTR_REF_PREFIX_NO;
22822281
vpt->rules.attr.prefix = at_rules->prefix;
22832282

22842283
/*
@@ -4649,18 +4648,12 @@ fr_slen_t tmpl_request_ref_list_print(fr_sbuff_t *out, FR_DLIST_HEAD(tmpl_reques
46494648
*
46504649
* @param[in] out Where to write the presentation format #tmpl_t string.
46514650
* @param[in] vpt to print.
4652-
* @param[in] ar_prefix Whether to print the '&' at the beginning of attribute
4653-
* references.
4654-
* - TMPL_ATTR_REF_PREFIX_YES - always print.
4655-
* - TMPL_ATTR_REF_PREFIX_NO - never print.
4656-
* - TMPL_ATTR_REF_PREFIX_AUTO - print if the original tmpl
4657-
* was prefixed.
46584651
* @return
46594652
* - >0 the number of bytes written to the out buffer.
46604653
* - 0 invalid argument.
46614654
* - <0 the number of bytes we would have needed to complete the print.
46624655
*/
4663-
fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix)
4656+
fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt)
46644657
{
46654658
tmpl_attr_t *ar = NULL;
46664659
fr_da_stack_t stack;
@@ -4682,22 +4675,6 @@ fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t
46824675
return 0;
46834676
}
46844677

4685-
/*
4686-
* Suppress the prefix on new syntax.
4687-
*/
4688-
if (ar_prefix == TMPL_ATTR_REF_PREFIX_YES) {
4689-
ar_prefix = TMPL_ATTR_REF_PREFIX_AUTO;
4690-
}
4691-
4692-
/*
4693-
* Handle printing the request reference
4694-
* prefix.
4695-
*/
4696-
if ((ar_prefix == TMPL_ATTR_REF_PREFIX_YES) ||
4697-
((ar_prefix == TMPL_ATTR_REF_PREFIX_AUTO) && vpt->data.attribute.ref_prefix)) {
4698-
FR_SBUFF_IN_CHAR_RETURN(&our_out, '&');
4699-
}
4700-
47014678
/*
47024679
* Print request references
47034680
*/
@@ -4863,36 +4840,23 @@ fr_slen_t tmpl_attr_print(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t
48634840
*
48644841
* @param[out] out Where to write the presentation format #tmpl_t string.
48654842
* @param[in] vpt to print.
4866-
* @param[in] ar_prefix Whether to print the '&' at the beginning of attribute
4867-
* references.
4868-
* - TMPL_ATTR_REF_PREFIX_YES - always print.
4869-
* - TMPL_ATTR_REF_PREFIX_NO - never print.
4870-
* - TMPL_ATTR_REF_PREFIX_AUTO - print if the original tmpl
4871-
* was prefixed.
48724843
* @param[in] e_rules Escaping rules used to print strings.
48734844
* @return
48744845
* - >0 the number of bytes written to the out buffer.
48754846
* - 0 invalid argument.
48764847
* - <0 the number of bytes we would have needed to complete the print.
48774848
*/
48784849
fr_slen_t tmpl_print(fr_sbuff_t *out, tmpl_t const *vpt,
4879-
tmpl_attr_prefix_t ar_prefix, fr_sbuff_escape_rules_t const *e_rules)
4850+
fr_sbuff_escape_rules_t const *e_rules)
48804851
{
48814852
fr_sbuff_t our_out = FR_SBUFF(out);
48824853

48834854
TMPL_VERIFY(vpt);
48844855

4885-
/*
4886-
* Suppress the prefix on new syntax.
4887-
*/
4888-
if (ar_prefix == TMPL_ATTR_REF_PREFIX_YES) {
4889-
ar_prefix = TMPL_ATTR_REF_PREFIX_AUTO;
4890-
}
4891-
48924856
switch (vpt->type) {
48934857
case TMPL_TYPE_ATTR_UNRESOLVED:
48944858
case TMPL_TYPE_ATTR:
4895-
FR_SBUFF_RETURN(tmpl_attr_print, &our_out, vpt, ar_prefix);
4859+
FR_SBUFF_RETURN(tmpl_attr_print, &our_out, vpt);
48964860
break;
48974861

48984862
case TMPL_TYPE_DATA:
@@ -4953,26 +4917,20 @@ fr_slen_t tmpl_print(fr_sbuff_t *out, tmpl_t const *vpt,
49534917
*
49544918
* @param[out] out Where to write the presentation format #tmpl_t string.
49554919
* @param[in] vpt to print.
4956-
* @param[in] ar_prefix Whether to print the '&' at the beginning of attribute
4957-
* references.
4958-
* - TMPL_ATTR_REF_PREFIX_YES - always print.
4959-
* - TMPL_ATTR_REF_PREFIX_NO - never print.
4960-
* - TMPL_ATTR_REF_PREFIX_AUTO - print if the original tmpl
4961-
* was prefixed.
49624920
* @return
49634921
* - >0 the number of bytes written to the out buffer.
49644922
* - 0 invalid argument.
49654923
* - <0 the number of bytes we would have needed to complete the print.
49664924
*/
4967-
fr_slen_t tmpl_print_quoted(fr_sbuff_t *out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix)
4925+
fr_slen_t tmpl_print_quoted(fr_sbuff_t *out, tmpl_t const *vpt)
49684926
{
49694927
fr_sbuff_t our_out = FR_SBUFF(out);
49704928

49714929
char quote = fr_token_quote[vpt->quote];
49724930

49734931
if (quote != '\0') FR_SBUFF_IN_CHAR_RETURN(&our_out, quote);
49744932
FR_SBUFF_RETURN(tmpl_print, &our_out, vpt,
4975-
ar_prefix, fr_value_escape_by_quote[vpt->quote]);
4933+
fr_value_escape_by_quote[vpt->quote]);
49764934
if (quote != '\0') FR_SBUFF_IN_CHAR_RETURN(&our_out, quote);
49774935

49784936
/*

src/lib/unlang/xlat_tokenize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
11761176

11771177
switch (node->type) {
11781178
case XLAT_TMPL:
1179-
slen = tmpl_attr_print(out, node->vpt, TMPL_ATTR_REF_PREFIX_NO);
1179+
slen = tmpl_attr_print(out, node->vpt);
11801180
if (slen < 0) return slen;
11811181
break;
11821182

0 commit comments

Comments
 (0)