mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Fixes some BFD bugs and makes logging thread-safe.
This commit is contained in:
37
lib/printf.c
37
lib/printf.c
@@ -410,3 +410,40 @@ int bsnprintf(char * buf, int size, const char *fmt, ...)
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
buffer_vprint(buffer *buf, const char *fmt, va_list args)
|
||||
{
|
||||
int i = bvsnprintf((char *) buf->pos, buf->end - buf->pos, fmt, args);
|
||||
buf->pos = (i >= 0) ? (buf->pos + i) : buf->end;
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
buffer_print(buffer *buf, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=bvsnprintf((char *) buf->pos, buf->end - buf->pos, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
buf->pos = (i >= 0) ? (buf->pos + i) : buf->end;
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
buffer_puts(buffer *buf, const char *str)
|
||||
{
|
||||
byte *bp = buf->pos;
|
||||
byte *be = buf->end;
|
||||
|
||||
while (bp < be && *str)
|
||||
*bp++ = *str++;
|
||||
|
||||
if (bp < be)
|
||||
*bp = 0;
|
||||
|
||||
buf->pos = bp;
|
||||
}
|
||||
|
Reference in New Issue
Block a user