Revision ba0fe87a

b/qemu-error.c
1
/*
2
 * Error reporting
3
 *
4
 * Copyright (C) 2010 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

  
1 13
#include <stdio.h>
2 14
#include "monitor.h"
3 15
#include "sysemu.h"
4 16

  
5
void qemu_error(const char *fmt, ...)
17
/*
18
 * Print to current monitor if we have one, else to stderr.
19
 * TODO should return int, so callers can calculate width, but that
20
 * requires surgery to monitor_vprintf().  Left for another day.
21
 */
22
void error_vprintf(const char *fmt, va_list ap)
6 23
{
7
    va_list args;
8

  
9
    va_start(args, fmt);
10 24
    if (cur_mon) {
11
        monitor_vprintf(cur_mon, fmt, args);
25
        monitor_vprintf(cur_mon, fmt, ap);
12 26
    } else {
13
        vfprintf(stderr, fmt, args);
27
        vfprintf(stderr, fmt, ap);
14 28
    }
15
    va_end(args);
29
}
30

  
31
/*
32
 * Print to current monitor if we have one, else to stderr.
33
 * TODO just like error_vprintf()
34
 */
35
void error_printf(const char *fmt, ...)
36
{
37
    va_list ap;
38

  
39
    va_start(ap, fmt);
40
    error_vprintf(fmt, ap);
41
    va_end(ap);
42
}
43

  
44
void qemu_error(const char *fmt, ...)
45
{
46
    va_list ap;
47

  
48
    va_start(ap, fmt);
49
    error_vprintf(fmt, ap);
50
    va_end(ap);
16 51
}
17 52

  
18 53
void qemu_error_internal(const char *file, int linenr, const char *func,
b/qemu-error.h
1
/*
2
 * Error reporting
3
 *
4
 * Copyright (C) 2010 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

  
1 13
#ifndef QEMU_ERROR_H
2 14
#define QEMU_ERROR_H
3 15

  
16
void error_vprintf(const char *fmt, va_list ap);
17
void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
4 18
void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
5 19
void qemu_error_internal(const char *file, int linenr, const char *func,
6 20
                         const char *fmt, ...)

Also available in: Unified diff