From: Michael Tremer Date: Tue, 28 Jan 2025 17:49:35 +0000 (+0000) Subject: log stream: Add a function to print custom content into the stream X-Git-Tag: 0.9.30~311 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aadff0972a86563e7fee4c8173dd917413659f1e;p=pakfire.git log stream: Add a function to print custom content into the stream Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/log_stream.c b/src/pakfire/log_stream.c index 5a001585..5ca90e0c 100644 --- a/src/pakfire/log_stream.c +++ b/src/pakfire/log_stream.c @@ -228,6 +228,17 @@ int pakfire_log_stream_in_child(struct pakfire_log_stream* stream) { return 0; } +int pakfire_log_stream_printf(struct pakfire_log_stream* stream, const char* format, ...) { + va_list args; + int r; + + va_start(args, format); + r = pakfire_log_stream_write(stream, format, args); + va_end(args); + + return r; +} + int pakfire_log_stream_write(struct pakfire_log_stream* stream, const char* format, va_list args) { // Fail if the pipe isn't open if (stream->pipe[1] < 0) diff --git a/src/pakfire/log_stream.h b/src/pakfire/log_stream.h index e9167548..7c6aa2e5 100644 --- a/src/pakfire/log_stream.h +++ b/src/pakfire/log_stream.h @@ -40,6 +40,8 @@ struct pakfire_log_stream* pakfire_log_stream_unref(struct pakfire_log_stream* s int pakfire_log_stream_in_parent(struct pakfire_log_stream* stream, sd_event* loop); int pakfire_log_stream_in_child(struct pakfire_log_stream* stream); +int pakfire_log_stream_printf(struct pakfire_log_stream* stream, + const char* format, ...) __attribute__((format(printf, 2, 3))); int pakfire_log_stream_write(struct pakfire_log_stream* stream, const char* format, va_list args) __attribute__((format(printf, 2, 0)));