add packaging
[platform/upstream/fribidi.git] / lib / debug.h
1 /* FriBidi
2  * debug.h - debug-only interfaces
3  *
4  * $Id: debug.h,v 1.10 2006-01-31 03:23:12 behdad Exp $
5  * $Author: behdad $
6  * $Date: 2006-01-31 03:23:12 $
7  * $Revision: 1.10 $
8  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/debug.h,v $
9  *
10  * Author:
11  *   Behdad Esfahbod, 2001, 2002, 2004
12  *
13  * Copyright (C) 2004 Sharif FarsiWeb, Inc.
14  * Copyright (C) 2001,2002 Behdad Esfahbod
15  * 
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  * 
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * Lesser General Public License for more details.
25  * 
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with this library, in a file named COPYING; if not, write to the
28  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29  * Boston, MA 02110-1301, USA
30  *
31  * For licensing issues, contact <license@farsiweb.info>.
32  */
33 #ifndef _DEBUG_H
34 #define _DEBUG_H
35
36 #include "common.h"
37
38 #include <fribidi-types.h>
39
40 #include <fribidi-begindecls.h>
41
42 #if DEBUG+0
43
44 /* These definitions should only be used in DEBUG mode: */
45 #ifndef __LINE__
46 # define __LINE__ 0
47 #endif /* !__LINE__ */
48 #ifndef __FILE__
49 # define __FILE__ "unknown"
50 #endif /* !__FILE__ */
51
52 #ifndef FRIBIDI_FPRINTF
53 # ifndef __FRIBIDI_DOC
54 #  include <stdio.h>
55 # endif /* !__FRIBIDI_DOC */
56 # define FRIBIDI_FPRINTF fprintf
57 # define FRIBIDI_STDERR_ stderr,
58 #endif /* !FRIBIDI_FPRINTF */
59
60 #ifndef MSG
61 #define MSG(s) \
62         FRIBIDI_BEGIN_STMT \
63         FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s); \
64         FRIBIDI_END_STMT
65 #define MSG2(s, t) \
66         FRIBIDI_BEGIN_STMT \
67         FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s, t); \
68         FRIBIDI_END_STMT
69 #define MSG5(s, t, u, v, w) \
70         FRIBIDI_BEGIN_STMT \
71         FRIBIDI_FPRINTF(FRIBIDI_STDERR_ s, t, u, v, w); \
72         FRIBIDI_END_STMT
73 #endif /* !MSG */
74
75 #ifndef DBG
76 # define DBG(s) \
77         FRIBIDI_BEGIN_STMT \
78         if (fribidi_debug_status()) { MSG(FRIBIDI ": " s "\n"); } \
79         FRIBIDI_END_STMT
80 # define DBG2(s, t) \
81         FRIBIDI_BEGIN_STMT \
82         if (fribidi_debug_status()) { MSG2(FRIBIDI ": " s "\n", t); } \
83         FRIBIDI_END_STMT
84 #endif /* !DBG */
85
86 #ifndef fribidi_assert
87 # define fribidi_assert(cond) \
88         FRIBIDI_BEGIN_STMT \
89         if (!(cond)) { \
90                 DBG(__FILE__ ":" STRINGIZE(__LINE__) ": " \
91                     "assertion failed (" STRINGIZE(cond) ")"); \
92         } \
93         FRIBIDI_END_STMT
94 #endif /* !fribidi_assert */
95
96 #else /* !DEBUG */
97
98 #ifndef DBG
99 # define DBG(s)                 FRIBIDI_EMPTY_STMT
100 # define DBG2(s, t)             FRIBIDI_EMPTY_STMT
101 #endif /* !DBG */
102 #ifndef fribidi_assert
103 # define fribidi_assert(cond)   FRIBIDI_EMPTY_STMT
104 #endif /* !fribidi_assert */
105
106 #endif /* !DEBUG */
107
108 #include <fribidi-enddecls.h>
109
110 #endif /* !_DEBUG_H */
111 /* Editor directions:
112  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
113  */