summaryrefslogtreecommitdiffstats
path: root/lib/printf/glue.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-03-02 20:45:57 +0100
committerDavid Lamparter <equinox@diac24.net>2021-03-30 22:32:59 +0200
commit9c4380daee0e495ea63d161af61d7f7e70c9d9ea (patch)
tree6399c667867d1f6618d15894f5bb1b1f42cfdf7a /lib/printf/glue.c
parentlib: add `FMT_NSTD()` for non-standard printf exts (diff)
downloadfrr-9c4380daee0e495ea63d161af61d7f7e70c9d9ea.tar.xz
frr-9c4380daee0e495ea63d161af61d7f7e70c9d9ea.zip
lib: add `%pVA` recursive printfrr
Analogous to Linux kernel `%pV` (but our mechanism expects 2 specifier chars and `%pVA` is clearer anyway.) Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/printf/glue.c')
-rw-r--r--lib/printf/glue.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/printf/glue.c b/lib/printf/glue.c
index 389f503c3..2c97dd639 100644
--- a/lib/printf/glue.c
+++ b/lib/printf/glue.c
@@ -255,3 +255,21 @@ ssize_t printfrr_exti(struct fbuf *buf, struct printfrr_eargs *ea,
}
return -1;
}
+
+printfrr_ext_autoreg_p("VA", printfrr_va)
+static ssize_t printfrr_va(struct fbuf *buf, struct printfrr_eargs *ea,
+ const void *ptr)
+{
+ const struct va_format *vaf = ptr;
+ va_list ap;
+
+ if (!vaf || !vaf->fmt || !vaf->va)
+ return bputs(buf, "NULL");
+
+ /* make sure we don't alter the data passed in - especially since
+ * bprintfrr (and thus this) might be called on the same format twice,
+ * when allocating a larger buffer in asnprintfrr()
+ */
+ va_copy(ap, *vaf->va);
+ return vbprintfrr(buf, vaf->fmt, ap);
+}