-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.h
54 lines (42 loc) · 1.24 KB
/
debug.h
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
53
54
/*
p0f - debug / error handling macros
-----------------------------------
Copyright (C) 2012 by Michal Zalewski <lcamtuf@coredump.cx>
Distributed under the terms and conditions of GNU LGPL.
*/
#ifndef _HAVE_DEBUG_H
#define _HAVE_DEBUG_H
#include "types.h"
#include "config.h"
#ifdef DEBUG_BUILD
# define DEBUG(x...) fprintf(stderr, x)
#else
# define DEBUG(x...) do {} while (0)
#endif /* ^DEBUG_BUILD */
#define ERRORF(x...) fprintf(stderr, x)
#define SAYF(x...) printf(x)
#define WARN(x...) do { \
ERRORF("[!] WARNING: " x); \
ERRORF("\n"); \
} while (0)
#define FATAL(x...) do { \
ERRORF("[-] PROGRAM ABORT : " x); \
ERRORF("\n Location : %s(), %s:%u\n\n", \
__FUNCTION__, __FILE__, __LINE__); \
exit(1); \
} while (0)
#define ABORT(x...) do { \
ERRORF("[-] PROGRAM ABORT : " x); \
ERRORF("\n Location : %s(), %s:%u\n\n", \
__FUNCTION__, __FILE__, __LINE__); \
abort(); \
} while (0)
#define PFATAL(x...) do { \
ERRORF("[-] SYSTEM ERROR : " x); \
ERRORF("\n Location : %s(), %s:%u\n", \
__FUNCTION__, __FILE__, __LINE__); \
perror(" OS message "); \
ERRORF("\n"); \
exit(1); \
} while (0)
#endif /* ! _HAVE_DEBUG_H */