Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ftdebug.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftdebug.c */
4 /* */
5 /* Debugging and logging component for amiga (body). */
6 /* */
7 /* Copyright 1996-2001, 2002, 2004, 2005, 2013 by */
8 /* David Turner, Robert Wilhelm, Werner Lemberg and Detlef Würkner. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17 
18 
19  /*************************************************************************/
20  /* */
21  /* This component contains various macros and functions used to ease the */
22  /* debugging of the FreeType engine. Its main purpose is in assertion */
23  /* checking, tracing, and error detection. */
24  /* */
25  /* There are now three debugging modes: */
26  /* */
27  /* - trace mode */
28  /* */
29  /* Error and trace messages are sent to the log file (which can be the */
30  /* standard error output). */
31  /* */
32  /* - error mode */
33  /* */
34  /* Only error messages are generated. */
35  /* */
36  /* - release mode: */
37  /* */
38  /* No error message is sent or generated. The code is free from any */
39  /* debugging parts. */
40  /* */
41  /*************************************************************************/
42 
43 
44  /*
45  * Based on the default ftdebug.c,
46  * replaced vprintf() with KVPrintF(),
47  * commented out exit(),
48  * replaced getenv() with GetVar().
49  */
50 
51 #include <exec/types.h>
52 #include <utility/tagitem.h>
53 #include <dos/exall.h>
54 #include <dos/var.h>
55 #define __NOLIBBASE__
56 #define __NOLOBALIFACE__
57 #define __USE_INLINE__
58 #include <proto/dos.h>
59 #include <clib/debug_protos.h>
60 
61 #ifndef __amigaos4__
62  extern struct Library *DOSBase;
63 #else
64  extern struct DOSIFace *IDOS;
65 #endif
66 
67 
68 #include <ft2build.h>
69 #include FT_FREETYPE_H
70 #include FT_INTERNAL_DEBUG_H
71 
72 
73 #if defined( FT_DEBUG_LEVEL_ERROR )
74 
75  /* documentation is in ftdebug.h */
76 
77  FT_BASE_DEF( void )
78  FT_Message( const char* fmt,
79  ... )
80  {
81  va_list ap;
82 
83 
84  va_start( ap, fmt );
85  KVPrintF( fmt, ap );
86  va_end( ap );
87  }
88 
89 
90  /* documentation is in ftdebug.h */
91 
92  FT_BASE_DEF( void )
93  FT_Panic( const char* fmt,
94  ... )
95  {
96  va_list ap;
97 
98 
99  va_start( ap, fmt );
100  KVPrintF( fmt, ap );
101  va_end( ap );
102 
103 /* exit( EXIT_FAILURE ); */
104  }
105 
106 
107  /* documentation is in ftdebug.h */
108 
109  FT_BASE_DEF( int )
110  FT_Throw( FT_Error error,
111  int line,
112  const char* file )
113  {
114  FT_UNUSED( error );
115  FT_UNUSED( line );
116  FT_UNUSED( file );
117 
118  return 0;
119  }
120 
121 #endif /* FT_DEBUG_LEVEL_ERROR */
122 
123 
124 
125 #ifdef FT_DEBUG_LEVEL_TRACE
126 
127  /* array of trace levels, initialized to 0 */
128  int ft_trace_levels[trace_count];
129 
130 
131  /* define array of trace toggle names */
132 #define FT_TRACE_DEF( x ) #x ,
133 
134  static const char* ft_trace_toggles[trace_count + 1] =
135  {
136 #include FT_INTERNAL_TRACE_H
137  NULL
138  };
139 
140 #undef FT_TRACE_DEF
141 
142 
143  /* documentation is in ftdebug.h */
144 
146  FT_Trace_Get_Count( void )
147  {
148  return trace_count;
149  }
150 
151 
152  /* documentation is in ftdebug.h */
153 
154  FT_BASE_DEF( const char * )
156  {
157  int max = FT_Trace_Get_Count();
158 
159 
160  if ( idx < max )
161  return ft_trace_toggles[idx];
162  else
163  return NULL;
164  }
165 
166 
167  /*************************************************************************/
168  /* */
169  /* Initialize the tracing sub-system. This is done by retrieving the */
170  /* value of the `FT2_DEBUG' environment variable. It must be a list of */
171  /* toggles, separated by spaces, `;', or `,'. Example: */
172  /* */
173  /* export FT2_DEBUG="any:3 memory:7 stream:5" */
174  /* */
175  /* This requests that all levels be set to 3, except the trace level for */
176  /* the memory and stream components which are set to 7 and 5, */
177  /* respectively. */
178  /* */
179  /* See the file <include/freetype/internal/fttrace.h> for details of the */
180  /* available toggle names. */
181  /* */
182  /* The level must be between 0 and 7; 0 means quiet (except for serious */
183  /* runtime errors), and 7 means _very_ verbose. */
184  /* */
185  FT_BASE_DEF( void )
186  ft_debug_init( void )
187  {
188 /* const char* ft2_debug = getenv( "FT2_DEBUG" ); */
189  char buf[256];
190  const char* ft2_debug = &buf[0];
191 
192 
193 /* if ( ft2_debug ) */
194  if ( GetVar( "FT2_DEBUG", (STRPTR)ft2_debug, 256, LV_VAR ) > 0 )
195  {
196  const char* p = ft2_debug;
197  const char* q;
198 
199 
200  for ( ; *p; p++ )
201  {
202  /* skip leading whitespace and separators */
203  if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
204  continue;
205 
206  /* read toggle name, followed by ':' */
207  q = p;
208  while ( *p && *p != ':' )
209  p++;
210 
211  if ( *p == ':' && p > q )
212  {
213  FT_Int n, i, len = (FT_Int)( p - q );
214  FT_Int level = -1, found = -1;
215 
216 
217  for ( n = 0; n < trace_count; n++ )
218  {
219  const char* toggle = ft_trace_toggles[n];
220 
221 
222  for ( i = 0; i < len; i++ )
223  {
224  if ( toggle[i] != q[i] )
225  break;
226  }
227 
228  if ( i == len && toggle[i] == 0 )
229  {
230  found = n;
231  break;
232  }
233  }
234 
235  /* read level */
236  p++;
237  if ( *p )
238  {
239  level = *p++ - '0';
240  if ( level < 0 || level > 7 )
241  level = -1;
242  }
243 
244  if ( found >= 0 && level >= 0 )
245  {
246  if ( found == trace_any )
247  {
248  /* special case for `any' */
249  for ( n = 0; n < trace_count; n++ )
250  ft_trace_levels[n] = level;
251  }
252  else
253  ft_trace_levels[found] = level;
254  }
255  }
256  }
257  }
258  }
259 
260 
261 #else /* !FT_DEBUG_LEVEL_TRACE */
262 
263 
264  FT_BASE_DEF( void )
266  {
267  /* nothing */
268  }
269 
270 
273  {
274  return 0;
275  }
276 
277 
278  FT_BASE_DEF( const char * )
280  {
281  FT_UNUSED( idx );
282 
283  return NULL;
284  }
285 
286 
287 #endif /* !FT_DEBUG_LEVEL_TRACE */
288 
289 /*
290 Local Variables:
291 coding: latin-1
292 End:
293 */
294 /* END */
int FT_Error
Definition: fttypes.h:296
GLfloat GLfloat p
#define NULL
Definition: ftobjs.h:61
signed int FT_Int
Definition: fttypes.h:216
GLdouble GLdouble GLdouble GLdouble q
#define FT_UNUSED(arg)
Definition: ftconfig.h:76
png_uint_32 i
Definition: png.h:2640
GLenum GLuint GLenum GLsizei const GLchar * buf
FT_Trace_Get_Count(void)
Definition: ftdebug.c:272
#define FT_BASE_DEF(x)
Definition: ftconfig.h:258
GLenum GLsizei len
GLint level
FT_UInt idx
Definition: cffcmap.c:127
FT_Error error
Definition: cffdrivr.c:411
GLdouble n
local int max
Definition: enough.c:170
FT_Trace_Get_Name(FT_Int idx)
Definition: ftdebug.c:279
struct Library * DOSBase
ft_debug_init(void)
Definition: ftdebug.c:265