mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
Lib: recursive printf
Use like this: void func(const char *msg, va_list args) { ... bvsnprintf(buf, len, "file %s, line %d: %V (foo %d, bar %d)", file, line, msg, &args, foo, bar); ... }
This commit is contained in:
parent
765f400f6b
commit
64c5ad58d2
11
lib/printf.c
11
lib/printf.c
@ -270,6 +270,17 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
|
||||
*str++ = ' ';
|
||||
continue;
|
||||
|
||||
case 'V': {
|
||||
const char *vfmt = va_arg(args, const char *);
|
||||
va_list *vargs = va_arg(args, va_list *);
|
||||
int res = bvsnprintf(str, size, vfmt, *vargs);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
str += res;
|
||||
size -= res;
|
||||
continue;
|
||||
}
|
||||
|
||||
case 'p':
|
||||
if (field_width == -1) {
|
||||
field_width = 2*sizeof(void *);
|
||||
|
Loading…
Reference in New Issue
Block a user