aboutsummaryrefslogtreecommitdiff
path: root/slirp/debug.h
blob: ff920f0b878661428fa6fd35203181f0b86db5fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright (c) 1995 Danny Gasparovski.
 *
 * Please read the file COPYRIGHT for the
 * terms and conditions of the copyright.
 */

#ifndef DEBUG_H_
#define DEBUG_H_

#define DBG_CALL 0x1
#define DBG_MISC 0x2
#define DBG_ERROR 0x4

#define dfd stderr

extern int slirp_debug;

#define DEBUG_CALL(fmt, ...) do {               \
    if (slirp_debug & DBG_CALL) {               \
        fprintf(dfd, fmt, ##__VA_ARGS__);       \
        fprintf(dfd, "...\n");                  \
        fflush(dfd);                            \
    }                                           \
} while (0)

#define DEBUG_ARG(fmt, ...) do {                \
    if (slirp_debug & DBG_CALL) {               \
        fputc(' ', dfd);                        \
        fprintf(dfd, fmt, ##__VA_ARGS__);       \
        fputc('\n', dfd);                       \
        fflush(dfd);                            \
    }                                           \
} while (0)

#define DEBUG_ARGS(fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__)

#define DEBUG_MISC(fmt, ...) do {               \
    if (slirp_debug & DBG_MISC) {               \
        fprintf(dfd, fmt, ##__VA_ARGS__);       \
        fflush(dfd);                            \
    }                                           \
} while (0)

#define DEBUG_ERROR(fmt, ...) do {              \
    if (slirp_debug & DBG_ERROR) {              \
        fprintf(dfd, fmt, ##__VA_ARGS__);       \
        fflush(dfd);                            \
    }                                           \
} while (0)

#endif /* DEBUG_H_ */