Merged difference between 7.12 and 7.15 into trunk.
[AROS.git] / external / openurl / prefs / debug.h
blob4aa3f680a4071d21010cad8718b629891631602f
1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
17 $Id$
19 ***************************************************************************/
21 #ifndef DEBUG_H
22 #define DEBUG_H
24 // first we make sure all previously defined symbols are undefined now so
25 // that no other debug system interferes with ours.
26 #undef ENTER
27 #undef LEAVE
28 #undef RETURN
29 #undef SHOWVALUE
30 #undef SHOWPOINTER
31 #undef SHOWSTRING
32 #undef SHOWMSG
33 #undef STARTCLOCK
34 #undef STOPCLOCK
35 #undef D
36 #undef E
37 #undef W
38 #undef ASSERT
40 #if defined(DEBUG)
42 #ifndef EXEC_TYPES_H
43 #include <exec/types.h>
44 #endif
46 #if defined(__amigaos4__)
47 #include <proto/exec.h>
48 #ifdef __USE_INLINE__
49 #ifdef DebugPrintF
50 #undef DebugPrintF
51 #endif
52 #endif
53 #ifndef kprintf
54 #define kprintf(format, args...) ((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
55 #endif
56 #elif defined(__MORPHOS__)
57 #include <exec/rawfmt.h>
58 #include <proto/exec.h>
59 #define KPutFmt(format, args) VNewRawDoFmt(format, (APTR)RAWFMTFUNC_SERIAL, NULL, args)
60 VOID kprintf(CONST_STRPTR formatString, ...);
61 #else
62 VOID kprintf(CONST_STRPTR formatString, ...);
63 #endif
65 // debug classes
66 #define DBC_CTRACE (1<<0) // call tracing (ENTER/LEAVE etc.)
67 #define DBC_REPORT (1<<1) // reports (SHOWVALUE/SHOWSTRING etc.)
68 #define DBC_ASSERT (1<<2) // asserts (ASSERT)
69 #define DBC_TIMEVAL (1<<3) // time evaluations (STARTCLOCK/STOPCLOCK)
70 #define DBC_DEBUG (1<<4) // debugging output D()
71 #define DBC_ERROR (1<<5) // error output E()
72 #define DBC_WARNING (1<<6) // warning output W()
73 #define DBC_ALL 0xffffffff
75 // debug flags
76 #define DBF_ALWAYS (1<<0)
77 #define DBF_STARTUP (1<<1) // for startup/shutdown events
78 #define DBF_ALL 0xffffffff
80 void SetupDebug(void);
82 void _ENTER(unsigned long dclass, const char *file, int line, const char *function);
83 void _LEAVE(unsigned long dclass, const char *file, int line, const char *function);
84 void _RETURN(unsigned long dclass, const char *file, int line, const char *function, unsigned long result);
85 void _SHOWVALUE(unsigned long dclass, unsigned long dflags, unsigned long value, int size, const char *name, const char *file, int line);
86 void _SHOWPOINTER(unsigned long dclass, unsigned long dflags, const void *p, const char *name, const char *file, int line);
87 void _SHOWSTRING(unsigned long dclass, unsigned long dflags, const char *string, const char *name, const char *file, int line);
88 void _SHOWMSG(unsigned long dclass, unsigned long dflags, const char *msg, const char *file, int line);
89 void _DPRINTF(unsigned long dclass, unsigned long dflags, const char *file, int line, const char *format, ...);
91 // Core class information class messages
92 #define ENTER() _ENTER(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
93 #define LEAVE() _LEAVE(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
94 #define RETURN(r) _RETURN(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__, (long)r)
95 #define SHOWVALUE(f, v) _SHOWVALUE(DBC_REPORT, f, (long)v, sizeof(v), #v, __FILE__, __LINE__)
96 #define SHOWPOINTER(f, p) _SHOWPOINTER(DBC_REPORT, f, p, #p, __FILE__, __LINE__)
97 #define SHOWSTRING(f, s) _SHOWSTRING(DBC_REPORT, f, s, #s, __FILE__, __LINE__)
98 #define SHOWMSG(f, m) _SHOWMSG(DBC_REPORT, f, m, __FILE__, __LINE__)
99 #define D(f, s, vargs...) _DPRINTF(DBC_DEBUG, f, __FILE__, __LINE__, s, ## vargs)
100 #define E(f, s, vargs...) _DPRINTF(DBC_ERROR, f, __FILE__, __LINE__, s, ## vargs)
101 #define W(f, s, vargs...) _DPRINTF(DBC_WARNING, f, __FILE__, __LINE__, s, ## vargs)
102 #define ASSERT(expression) \
103 ((void) \
104 ((expression) ? 0 : \
106 _DPRINTF(DBC_ASSERT, \
107 DBF_ALWAYS, \
108 __FILE__, \
109 __LINE__, \
110 "failed assertion '%s'", \
111 #expression), \
112 abort(), \
118 #else // DEBUG
120 #define ENTER() ((void)0)
121 #define LEAVE() ((void)0)
122 #define RETURN(r) ((void)0)
123 #define SHOWVALUE(f, v) ((void)0)
124 #define SHOWPOINTER(f, p) ((void)0)
125 #define SHOWSTRING(f, s) ((void)0)
126 #define SHOWMSG(f, m) ((void)0)
127 #define D(f, s, vargs...) ((void)0)
128 #define E(f, s, vargs...) ((void)0)
129 #define W(f, s, vargs...) ((void)0)
130 #define ASSERT(expression) ((void)0)
132 #endif // DEBUG
134 #endif // DEBUG_H