qemu/util/qemu-print.c
<<
>>
Prefs
   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{
  23    if (cur_mon) {
  24        return monitor_vprintf(cur_mon, fmt, ap);
  25    }
  26    return vprintf(fmt, ap);
  27}
  28
  29/*
  30 * Print like printf().
  31 * Print to current monitor if we have one, else to stdout.
  32 */
  33int qemu_printf(const char *fmt, ...)
  34{
  35    va_list ap;
  36    int ret;
  37
  38    va_start(ap, fmt);
  39    ret = qemu_vprintf(fmt, ap);
  40    va_end(ap);
  41    return ret;
  42}
  43
  44/*
  45 * Print like vfprintf()
  46 * Print to @stream if non-null, else to current monitor.
  47 */
  48int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
  49{
  50    if (!stream) {
  51        return monitor_vprintf(cur_mon, fmt, ap);
  52    }
  53    return vfprintf(stream, fmt, ap);
  54}
  55
  56/*
  57 * Print like fprintf().
  58 * Print to @stream if non-null, else to current monitor.
  59 */
  60int qemu_fprintf(FILE *stream, const char *fmt, ...)
  61{
  62    va_list ap;
  63    int ret;
  64
  65    va_start(ap, fmt);
  66    ret = qemu_vfprintf(stream, fmt, ap);
  67    va_end(ap);
  68    return ret;
  69}
  70