diff options
Diffstat (limited to 'lib/printf/glue.c')
| -rw-r--r-- | lib/printf/glue.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/printf/glue.c b/lib/printf/glue.c index 2c97dd639e..1147901236 100644 --- a/lib/printf/glue.c +++ b/lib/printf/glue.c @@ -256,6 +256,28 @@ ssize_t printfrr_exti(struct fbuf *buf, struct printfrr_eargs *ea, return -1; } +printfrr_ext_autoreg_p("FB", printfrr_fb) +static ssize_t printfrr_fb(struct fbuf *out, struct printfrr_eargs *ea, + const void *ptr) +{ + const struct fbuf *in = ptr; + ptrdiff_t copy_len; + + if (!in) + return bputs(out, "NULL"); + + if (out) { + copy_len = MIN(in->pos - in->buf, + out->buf + out->len - out->pos); + if (copy_len > 0) { + memcpy(out->pos, in->buf, copy_len); + out->pos += copy_len; + } + } + + return in->pos - in->buf; +} + printfrr_ext_autoreg_p("VA", printfrr_va) static ssize_t printfrr_va(struct fbuf *buf, struct printfrr_eargs *ea, const void *ptr) |
