common/status: add status_tracev() for making status wrappers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-10-11 20:32:50 +10:30 committed by Christian Decker
parent 9b589fb5ba
commit 8430e33f3b
2 changed files with 13 additions and 4 deletions

View file

@ -75,16 +75,13 @@ static void status_send_with_hdr(u16 type, const void *p, size_t len)
}
}
void status_trace(const char *fmt, ...)
void status_tracev(const char *fmt, va_list ap)
{
va_list ap;
char *str;
va_start(ap, fmt);
str = tal_vfmt(NULL, fmt, ap);
status_send_with_hdr(STATUS_TRACE, str, strlen(str));
tal_free(str);
va_end(ap);
/* Free up any temporary children. */
if (tal_first(trc)) {
@ -93,6 +90,15 @@ void status_trace(const char *fmt, ...)
}
}
void status_trace(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
status_tracev(fmt, ap);
va_end(ap);
}
void status_failed(enum status_fail code, const char *fmt, ...)
{
va_list ap;

View file

@ -3,6 +3,7 @@
#include "config.h"
#include <ccan/compiler/compiler.h>
#include <ccan/short_types/short_types.h>
#include <stdarg.h>
#include <stdlib.h>
struct daemon_conn;
@ -50,6 +51,8 @@ enum status_fail {
void status_send_sync(const u8 *msg);
/* Send a printf-style debugging trace. */
void status_trace(const char *fmt, ...) PRINTF_FMT(1,2);
/* vprintf-style */
void status_tracev(const char *fmt, va_list ap);
/* Send a failure status code with printf-style msg, and exit. */
void status_failed(enum status_fail, const char *fmt, ...) PRINTF_FMT(2,3) NORETURN;