output: support printf type usage

Closes: #289
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2016-05-20 14:16:14 -04:00 committed by Atomic Bot
parent ca162dece2
commit 1ccc560c26
2 changed files with 26 additions and 8 deletions

View File

@ -72,17 +72,35 @@ rpmostree_output_set_callback (void (*cb)(RpmOstreeOutputType, void*, void*),
}
void
rpmostree_output_task_begin (const char *text)
rpmostree_output_task_begin (const char *format, ...)
{
RpmOstreeOutputTaskBegin task = { text };
active_cb (RPMOSTREE_OUTPUT_TASK_BEGIN, &task, active_cb_opaque);
g_autofree char *final = NULL;
va_list args;
va_start (args, format);
final = g_strdup_vprintf (format, args);
va_end (args);
{
RpmOstreeOutputTaskBegin task = { final };
active_cb (RPMOSTREE_OUTPUT_TASK_BEGIN, &task, active_cb_opaque);
}
}
void
rpmostree_output_task_end (const char *text)
rpmostree_output_task_end (const char *format, ...)
{
RpmOstreeOutputTaskEnd task = { text };
active_cb (RPMOSTREE_OUTPUT_TASK_END, &task, active_cb_opaque);
g_autofree char *final = NULL;
va_list args;
va_start (args, format);
final = g_strdup_vprintf (format, args);
va_end (args);
{
RpmOstreeOutputTaskEnd task = { final };
active_cb (RPMOSTREE_OUTPUT_TASK_END, &task, active_cb_opaque);
}
}
void

View File

@ -36,12 +36,12 @@ typedef struct {
} RpmOstreeOutputTaskBegin;
void
rpmostree_output_task_begin (const char *text);
rpmostree_output_task_begin (const char *format, ...) G_GNUC_PRINTF (1,2);
typedef RpmOstreeOutputTaskBegin RpmOstreeOutputTaskEnd;
void
rpmostree_output_task_end (const char *text);
rpmostree_output_task_end (const char *format, ...) G_GNUC_PRINTF (1,2);
typedef struct {
const char *text;