summaryrefslogtreecommitdiff
blob: 67bbf2cb6765606692d9850c8b1bd469f160de0e (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
/*
 * ufed-debug.h
 *
 *  Created on: 28.01.2013
 *      Author: Sven Eden
 */
#pragma once
#ifndef UFED_DEBUG_H_INCLUDED
#define UFED_DEBUG_H_INCLUDED 1

/* These are debugging macros that can be turned on/off by
 * defining/undefining their guards.
 */
#define DEBUG_EXIT 1 /* If defined ERROR_EXIT() prints an error message */
#undef DEBUG_TRACE /* If defined TRACE() prints current file, line, function */

// DEBUG_EXIT -> ERROR_EXIT() macro
#if defined(DEBUG_EXIT)
#  define ERROR_EXIT(code, fmt, ...) { \
	cursesdone(); \
	fprintf(stderr, "\nERROR in %s:%d (%s): \n -> ", \
		__FILE__, __LINE__, __FUNCTION__); \
	fprintf(stderr, fmt, __VA_ARGS__); \
	exit(code); \
}
#else
#  define ERROR_EXIT(code, ...) { cursesdone(); exit(code); }
#endif // DEBUG_EXIT

// DEBUG_TRACE -> TRACE macro
#if defined(DEBUG_TRACE)
# define TRACE { \
	fprintf(stderr, "(TRACE) %s:%d - %s\n", __FILE__, __LINE__, __FUNCTION__); \
}
#else
# define TRACE
#endif // DEBUG_TRACE


#endif /* UFED_DEBUG_H_INCLUDED */