mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / builds / win32 / ftdebug.c
blobd1ca15ac95b151d6df2f6e145ecb094a244dcbb7
1 /***************************************************************************/
2 /* */
3 /* ftdebug.c */
4 /* */
5 /* Debugging and logging component for Win32 (body). */
6 /* */
7 /* Copyright 1996-2001, 2002, 2005, 2008, 2009 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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 /***************************************************************************/
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 /*************************************************************************/
44 #include <ft2build.h>
45 #include FT_INTERNAL_DEBUG_H
48 #ifdef FT_DEBUG_LEVEL_ERROR
51 #include <stdarg.h>
52 #include <stdlib.h>
53 #include <string.h>
55 #include <windows.h>
58 FT_BASE_DEF( void )
59 FT_Message( const char* fmt, ... )
61 static char buf[8192];
62 va_list ap;
65 va_start( ap, fmt );
66 vprintf( fmt, ap );
67 /* send the string to the debugger as well */
68 vsprintf( buf, fmt, ap );
69 OutputDebugStringA( buf );
70 va_end( ap );
74 FT_BASE_DEF( void )
75 FT_Panic( const char* fmt, ... )
77 static char buf[8192];
78 va_list ap;
81 va_start( ap, fmt );
82 vsprintf( buf, fmt, ap );
83 OutputDebugStringA( buf );
84 va_end( ap );
86 exit( EXIT_FAILURE );
90 #ifdef FT_DEBUG_LEVEL_TRACE
93 /* array of trace levels, initialized to 0 */
94 int ft_trace_levels[trace_count];
96 /* define array of trace toggle names */
97 #define FT_TRACE_DEF( x ) #x ,
99 static const char* ft_trace_toggles[trace_count + 1] =
101 #include FT_INTERNAL_TRACE_H
102 NULL
105 #undef FT_TRACE_DEF
108 /*************************************************************************/
109 /* */
110 /* Initialize the tracing sub-system. This is done by retrieving the */
111 /* value of the "FT2_DEBUG" environment variable. It must be a list of */
112 /* toggles, separated by spaces, `;' or `,'. Example: */
113 /* */
114 /* "any:3 memory:6 stream:5" */
115 /* */
116 /* This will request that all levels be set to 3, except the trace level */
117 /* for the memory and stream components which are set to 6 and 5, */
118 /* respectively. */
119 /* */
120 /* See the file <freetype/internal/fttrace.h> for details of the */
121 /* available toggle names. */
122 /* */
123 /* The level must be between 0 and 6; 0 means quiet (except for serious */
124 /* runtime errors), and 6 means _very_ verbose. */
125 /* */
126 FT_BASE_DEF( void )
127 ft_debug_init( void )
129 const char* ft2_debug = getenv( "FT2_DEBUG" );
132 if ( ft2_debug )
134 const char* p = ft2_debug;
135 const char* q;
138 for ( ; *p; p++ )
140 /* skip leading whitespace and separators */
141 if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
142 continue;
144 /* read toggle name, followed by ':' */
145 q = p;
146 while ( *p && *p != ':' )
147 p++;
149 if ( *p == ':' && p > q )
151 int n, i, len = p - q;
152 int level = -1, found = -1;
155 for ( n = 0; n < trace_count; n++ )
157 const char* toggle = ft_trace_toggles[n];
160 for ( i = 0; i < len; i++ )
162 if ( toggle[i] != q[i] )
163 break;
166 if ( i == len && toggle[i] == 0 )
168 found = n;
169 break;
173 /* read level */
174 p++;
175 if ( *p )
177 level = *p++ - '0';
178 if ( level < 0 || level > 7 )
179 level = -1;
182 if ( found >= 0 && level >= 0 )
184 if ( found == trace_any )
186 /* special case for "any" */
187 for ( n = 0; n < trace_count; n++ )
188 ft_trace_levels[n] = level;
190 else
191 ft_trace_levels[found] = level;
199 #else /* !FT_DEBUG_LEVEL_TRACE */
202 FT_BASE_DEF( void )
203 ft_debug_init( void )
205 /* nothing */
209 #endif /* !FT_DEBUG_LEVEL_TRACE */
211 #endif /* FT_DEBUG_LEVEL_ERROR */
214 /* END */