From: Alan T. DeKok Date: Sun, 23 Nov 2025 14:14:39 +0000 (-0500) Subject: move fprintf pair routines to pair_print X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=170daf5605cc6d2df1a435daa1de342c0c8ce56b;p=thirdparty%2Ffreeradius-server.git move fprintf pair routines to pair_print --- diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 5f1384b32a8..167d2cf790d 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -3524,46 +3524,3 @@ void fr_pair_list_afrom_box(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t cons return; } } - -static const char spaces[] = " "; - -static void fprintf_pair_list(FILE *fp, fr_pair_list_t const *list, int depth) -{ - fr_pair_list_foreach(list, vp) { - fprintf(fp, "%.*s", depth, spaces); - - if (fr_type_is_leaf(vp->vp_type)) { - fr_fprintf(fp, "%s %s %pV\n", vp->da->name, fr_tokens[vp->op], &vp->data); - continue; - } - - fr_assert(fr_type_is_structural(vp->vp_type)); - - fprintf(fp, "%s = {\n", vp->da->name); - fprintf_pair_list(fp, &vp->vp_group, depth + 1); - fprintf(fp, "%.*s}\n", depth, spaces); - } -} - -void fr_fprintf_pair_list(FILE *fp, fr_pair_list_t const *list) -{ - fprintf_pair_list(fp, list, 0); -} - -/* - * print.c doesn't include pair.h, and doing so causes too many knock-on effects. - */ -void fr_fprintf_pair(FILE *fp, char const *msg, fr_pair_t const *vp) -{ - if (msg) fputs(msg, fp); - - if (fr_type_is_leaf(vp->vp_type)) { - fr_fprintf(fp, "%s %s %pV\n", vp->da->name, fr_tokens[vp->op], &vp->data); - } else { - fr_assert(fr_type_is_structural(vp->vp_type)); - - fprintf(fp, "%s = {\n", vp->da->name); - fprintf_pair_list(fp, &vp->vp_group, 1); - fprintf(fp, "}\n"); - } -} diff --git a/src/lib/util/pair_print.c b/src/lib/util/pair_print.c index e480a3d1e72..917531a091b 100644 --- a/src/lib/util/pair_print.c +++ b/src/lib/util/pair_print.c @@ -408,3 +408,46 @@ void fr_pair_debug(FILE *fp, fr_pair_t const *pair) fprintf(fp, "%pV\n", fr_box_strvalue_len(fr_sbuff_start(&sbuff), fr_sbuff_used(&sbuff))); } + +static const char spaces[] = " "; + +static void fprintf_pair_list(FILE *fp, fr_pair_list_t const *list, int depth) +{ + fr_pair_list_foreach(list, vp) { + fprintf(fp, "%.*s", depth, spaces); + + if (fr_type_is_leaf(vp->vp_type)) { + fr_fprintf(fp, "%s %s %pV\n", vp->da->name, fr_tokens[vp->op], &vp->data); + continue; + } + + fr_assert(fr_type_is_structural(vp->vp_type)); + + fprintf(fp, "%s = {\n", vp->da->name); + fprintf_pair_list(fp, &vp->vp_group, depth + 1); + fprintf(fp, "%.*s}\n", depth, spaces); + } +} + +void fr_fprintf_pair_list(FILE *fp, fr_pair_list_t const *list) +{ + fprintf_pair_list(fp, list, 0); +} + +/* + * print.c doesn't include pair.h, and doing so causes too many knock-on effects. + */ +void fr_fprintf_pair(FILE *fp, char const *msg, fr_pair_t const *vp) +{ + if (msg) fputs(msg, fp); + + if (fr_type_is_leaf(vp->vp_type)) { + fr_fprintf(fp, "%s %s %pV\n", vp->da->name, fr_tokens[vp->op], &vp->data); + } else { + fr_assert(fr_type_is_structural(vp->vp_type)); + + fprintf(fp, "%s = {\n", vp->da->name); + fprintf_pair_list(fp, &vp->vp_group, 1); + fprintf(fp, "}\n"); + } +}