mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
vshPrint: Add version using 'va_list'
Add a version for functions which may already need to take a printf format string. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
620d942749
commit
13af21fb74
36
tools/vsh.c
36
tools/vsh.c
@ -1865,34 +1865,46 @@ vshDebug(vshControl *ctl, int level, const char *format, ...)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vshPrintExtra(vshControl *ctl, const char *format, ...)
|
||||
vshPrintVa(vshControl *ctl G_GNUC_UNUSED,
|
||||
const char *format,
|
||||
va_list ap)
|
||||
{
|
||||
va_list ap;
|
||||
g_autofree char *str = NULL;
|
||||
|
||||
if (ctl && ctl->quiet)
|
||||
return;
|
||||
|
||||
va_start(ap, format);
|
||||
str = g_strdup_vprintf(format, ap);
|
||||
va_end(ap);
|
||||
fputs(str, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vshPrint(vshControl *ctl G_GNUC_UNUSED, const char *format, ...)
|
||||
vshPrintExtra(vshControl *ctl,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
g_autofree char *str = NULL;
|
||||
|
||||
if (ctl && ctl->quiet)
|
||||
return;
|
||||
|
||||
va_start(ap, format);
|
||||
str = g_strdup_vprintf(format, ap);
|
||||
vshPrintVa(ctl, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vshPrint(vshControl *ctl,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vshPrintVa(ctl, format, ap);
|
||||
va_end(ap);
|
||||
fputs(str, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
|
@ -302,6 +302,10 @@ const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, const vshCmd *cmd,
|
||||
bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv);
|
||||
int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout);
|
||||
|
||||
void vshPrintVa(vshControl *ctl,
|
||||
const char *format,
|
||||
va_list ap)
|
||||
G_GNUC_PRINTF(2, 0);
|
||||
void vshPrint(vshControl *ctl, const char *format, ...)
|
||||
G_GNUC_PRINTF(2, 3);
|
||||
void vshPrintExtra(vshControl *ctl, const char *format, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user