update for HEAD-2003050101
[reactos.git] / lib / freetype / builds / amiga / src / base / ftdebug.c
1 // TetiSoft: replaced vprintf() with KVPrintF() and commented out exit()
2 extern void __stdargs KVPrintF( const char *formatString, const void *values );
3
4 /***************************************************************************/
5 /*                                                                         */
6 /*  ftdebug.c                                                              */
7 /*                                                                         */
8 /*    Debugging and logging component (body).                              */
9 /*                                                                         */
10 /*  Copyright 1996-2001 by                                                 */
11 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
12 /*                                                                         */
13 /*  This file is part of the FreeType project, and may only be used,       */
14 /*  modified, and distributed under the terms of the FreeType project      */
15 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
16 /*  this file you indicate that you have read the license and              */
17 /*  understand and accept it fully.                                        */
18 /*                                                                         */
19 /***************************************************************************/
20
21
22   /*************************************************************************/
23   /*                                                                       */
24   /* This component contains various macros and functions used to ease the */
25   /* debugging of the FreeType engine.  Its main purpose is in assertion   */
26   /* checking, tracing, and error detection.                               */
27   /*                                                                       */
28   /* There are now three debugging modes:                                  */
29   /*                                                                       */
30   /* - trace mode                                                          */
31   /*                                                                       */
32   /*   Error and trace messages are sent to the log file (which can be the */
33   /*   standard error output).                                             */
34   /*                                                                       */
35   /* - error mode                                                          */
36   /*                                                                       */
37   /*   Only error messages are generated.                                  */
38   /*                                                                       */
39   /* - release mode:                                                       */
40   /*                                                                       */
41   /*   No error message is sent or generated.  The code is free from any   */
42   /*   debugging parts.                                                    */
43   /*                                                                       */
44   /*************************************************************************/
45
46
47 #include <ft2build.h>
48 #include FT_INTERNAL_DEBUG_H
49
50
51 #ifdef FT_DEBUG_LEVEL_TRACE
52   char  ft_trace_levels[trace_max];
53 #endif
54
55
56 #if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
57
58
59 #include <stdarg.h>
60 #include <stdlib.h>
61
62
63   FT_EXPORT_DEF( void )
64   FT_Message( const char*  fmt, ... )
65   {
66     va_list  ap;
67
68
69     va_start( ap, fmt );
70 //  vprintf( fmt, ap );
71     KVPrintF( fmt, ap );
72     va_end( ap );
73   }
74
75
76   FT_EXPORT_DEF( void )
77   FT_Panic( const char*  fmt, ... )
78   {
79     va_list  ap;
80
81
82     va_start( ap, fmt );
83 //  vprintf( fmt, ap );
84     KVPrintF( fmt, ap );
85     va_end( ap );
86
87 //  exit( EXIT_FAILURE );
88   }
89
90
91
92   /* since I don't know wether "getenv" is available on the Amiga */
93   /* I prefer to simply disable this code for now in all builds   */
94   /*                                                              */
95
96 /* #ifdef FT_DEBUG_LEVEL_TRACE */
97 #if 0
98
99   FT_BASE_DEF( void )
100   ft_debug_init( void )
101   {
102     const char*  ft2_debug = getenv( "FT2_DEBUG" );
103
104
105     if ( ft2_debug )
106     {
107       const char*  p = ft2_debug;
108       const char*  q;
109
110
111       for ( ; *p; p++ )
112       {
113         /* skip leading whitespace and separators */
114         if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
115           continue;
116
117         /* read toggle name, followed by '=' */
118         q = p;
119         while ( *p && *p != ':' )
120           p++;
121
122         if ( *p == ':' && p > q )
123         {
124           int  n, i, len = p - q;
125           int  level = -1, found = -1;
126
127
128           for ( n = 0; n < trace_count; n++ )
129           {
130             const char*  toggle = ft_trace_toggles[n];
131
132
133             for ( i = 0; i < len; i++ )
134             {
135               if ( toggle[i] != q[i] )
136                 break;
137             }
138
139             if ( i == len && toggle[i] == 0 )
140             {
141               found = n;
142               break;
143             }
144           }
145
146           /* read level */
147           p++;
148           if ( *p )
149           {
150             level = *p++ - '0';
151             if ( level < 0 || level > 6 )
152               level = -1;
153           }
154
155           if ( found >= 0 && level >= 0 )
156           {
157             if ( found == trace_any )
158             {
159               /* special case for "any" */
160               for ( n = 0; n < trace_count; n++ )
161                 ft_trace_levels[n] = level;
162             }
163             else
164               ft_trace_levels[found] = level;
165           }
166         }
167       }
168     }
169   }
170
171
172 #else  /* !FT_DEBUG_LEVEL_TRACE */
173
174
175   FT_BASE_DEF( void )
176   ft_debug_init( void )
177   {
178     /* nothing */
179   }
180
181
182 #endif /* !FT_DEBUG_LEVEL_TRACE */
183
184
185 /* END */