]> git.proxmox.com Git - mirror_qemu.git/blame - util/qemu-print.c
Merge tag 'pull-maintainer-may24-160524-2' of https://gitlab.com/stsquad/qemu into...
[mirror_qemu.git] / util / qemu-print.c
CommitLineData
637de4db
MA
1/*
2 * Print to stream or current monitor
3 *
4 * Copyright (C) 2019 Red Hat Inc.
5 *
6 * Authors:
7 * Markus Armbruster <armbru@redhat.com>,
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12
13#include "qemu/osdep.h"
14#include "monitor/monitor.h"
15#include "qemu/qemu-print.h"
16
17/*
18 * Print like vprintf().
19 * Print to current monitor if we have one, else to stdout.
20 */
21int qemu_vprintf(const char *fmt, va_list ap)
22{
947e4744 23 Monitor *cur_mon = monitor_cur();
637de4db
MA
24 if (cur_mon) {
25 return monitor_vprintf(cur_mon, fmt, ap);
26 }
27 return vprintf(fmt, ap);
28}
29
30/*
31 * Print like printf().
32 * Print to current monitor if we have one, else to stdout.
33 */
34int qemu_printf(const char *fmt, ...)
35{
36 va_list ap;
37 int ret;
38
39 va_start(ap, fmt);
40 ret = qemu_vprintf(fmt, ap);
41 va_end(ap);
42 return ret;
43}
19aaa4c3
MA
44
45/*
46 * Print like vfprintf()
47 * Print to @stream if non-null, else to current monitor.
48 */
49int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
50{
51 if (!stream) {
947e4744 52 return monitor_vprintf(monitor_cur(), fmt, ap);
19aaa4c3
MA
53 }
54 return vfprintf(stream, fmt, ap);
55}
56
57/*
58 * Print like fprintf().
59 * Print to @stream if non-null, else to current monitor.
60 */
61int qemu_fprintf(FILE *stream, const char *fmt, ...)
62{
63 va_list ap;
64 int ret;
65
66 va_start(ap, fmt);
67 ret = qemu_vfprintf(stream, fmt, ap);
68 va_end(ap);
69 return ret;
70}