File: debug.h

package info (click to toggle)
bezerk 0.3.2-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 920 kB
  • ctags: 1,027
  • sloc: ansic: 12,291; sh: 1,822; makefile: 92; tcl: 56
file content (69 lines) | stat: -rw-r--r-- 2,150 bytes parent folder | download | duplicates (2)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Bezerk
 * Copyright (C) 1998 Tony Gale.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 */
 
#ifndef __DEBUG_H__
#define __DEBUG_H__

#define BS_BUFFLEN 1024

#ifndef BS_DEBUG_FILE
#define BS_DEBUG_FILE stderr
#endif /* BS_DEBUG_FILE */

void bs_printf(unsigned level, char *format, ...);

#ifdef DEBUG

/*#include <glib.h>*/

extern unsigned debug_level;

#define bs_function_enter() if (debug_level >= 1)                                       \
			      fprintf(BS_DEBUG_FILE, "entering function %s, file %s\n", \
				       __PRETTY_FUNCTION__,                             \
				       __FILE__)

#define bs_function_leave() if (debug_level >= 1)                                       \
			      fprintf(BS_DEBUG_FILE, "leaving function %s, file %s\n",  \
				       __PRETTY_FUNCTION__,                             \
				       __FILE__)

#define BS_DEBUG(l,m) if (debug_level >= l) \
		       fprintf(BS_DEBUG_FILE, "%s"m, (l==3 ? "" : \
			    (l==2 ? "\t" : (l==1 ? "\t\t":""))))

#define BS_DEBUG_STR(l,m) if (debug_level >= l) \
		       fprintf(BS_DEBUG_FILE, "%s%s", m, (l==3 ? "" : \
			    (l==2 ? "\t" : (l==1 ? "\t\t":""))))

#define BS_DEBUG_NUM(l,d) if (debug_level >= l) \
		       fprintf(BS_DEBUG_FILE, "%d%s", d, (l==3 ? "" : \
			    (l==2 ? "\t" : (l==1 ? "\t\t":""))))



#else
#define bs_function_enter()
#define bs_function_leave()
#define BS_DEBUG(l,m)
#define BS_DEBUG_STR(l,m)
#define BS_DEBUG_NUM(l,d)

#endif /* DEBUG */

#endif /* __DEBUG_H__ */