00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <ft2build.h>
00045 #include FT_INTERNAL_DEBUG_H
00046
00047
00048 #ifdef FT_DEBUG_LEVEL_ERROR
00049
00050
00051 #include <stdarg.h>
00052 #include <stdlib.h>
00053 #include <string.h>
00054
00055 #include <windows.h>
00056
00057
00058 void
00059 OutputDebugStringEx( const char* str )
00060 {
00061 static WCHAR buf[8192];
00062
00063
00064 int sz = MultiByteToWideChar( CP_ACP, 0, str, -1, buf,
00065 sizeof ( buf ) / sizeof ( *buf ) );
00066 if ( !sz )
00067 lstrcpyW( buf, L"OutputDebugStringEx: MultiByteToWideChar failed" );
00068
00069 OutputDebugStringW( buf );
00070 }
00071
00072
00073 FT_BASE_DEF( void )
00074 FT_Message( const char* fmt, ... )
00075 {
00076 static char buf[8192];
00077 va_list ap;
00078
00079
00080 va_start( ap, fmt );
00081 vprintf( fmt, ap );
00082
00083 vsprintf( buf, fmt, ap );
00084 OutputDebugStringEx( buf );
00085 va_end( ap );
00086 }
00087
00088
00089 FT_BASE_DEF( void )
00090 FT_Panic( const char* fmt, ... )
00091 {
00092 static char buf[8192];
00093 va_list ap;
00094
00095
00096 va_start( ap, fmt );
00097 vsprintf( buf, fmt, ap );
00098 OutputDebugStringEx( buf );
00099 va_end( ap );
00100
00101 exit( EXIT_FAILURE );
00102 }
00103
00104
00105 #ifdef FT_DEBUG_LEVEL_TRACE
00106
00107
00108
00109 int ft_trace_levels[trace_count];
00110
00111
00112 #define FT_TRACE_DEF( x ) #x ,
00113
00114 static const char* ft_trace_toggles[trace_count + 1] =
00115 {
00116 #include FT_INTERNAL_TRACE_H
00117 NULL
00118 };
00119
00120 #undef FT_TRACE_DEF
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 FT_BASE_DEF( void )
00142 ft_debug_init( void )
00143 {
00144
00145
00146
00147
00148
00149
00150
00151 const char* ft2_debug = 0;
00152
00153
00154 if ( ft2_debug )
00155 {
00156 const char* p = ft2_debug;
00157 const char* q;
00158
00159
00160 for ( ; *p; p++ )
00161 {
00162
00163 if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
00164 continue;
00165
00166
00167 q = p;
00168 while ( *p && *p != ':' )
00169 p++;
00170
00171 if ( *p == ':' && p > q )
00172 {
00173 int n, i, len = p - q;
00174 int level = -1, found = -1;
00175
00176
00177 for ( n = 0; n < trace_count; n++ )
00178 {
00179 const char* toggle = ft_trace_toggles[n];
00180
00181
00182 for ( i = 0; i < len; i++ )
00183 {
00184 if ( toggle[i] != q[i] )
00185 break;
00186 }
00187
00188 if ( i == len && toggle[i] == 0 )
00189 {
00190 found = n;
00191 break;
00192 }
00193 }
00194
00195
00196 p++;
00197 if ( *p )
00198 {
00199 level = *p++ - '0';
00200 if ( level < 0 || level > 7 )
00201 level = -1;
00202 }
00203
00204 if ( found >= 0 && level >= 0 )
00205 {
00206 if ( found == trace_any )
00207 {
00208
00209 for ( n = 0; n < trace_count; n++ )
00210 ft_trace_levels[n] = level;
00211 }
00212 else
00213 ft_trace_levels[found] = level;
00214 }
00215 }
00216 }
00217 }
00218 }
00219
00220
00221 #else
00222
00223
00224 FT_BASE_DEF( void )
00225 ft_debug_init( void )
00226 {
00227
00228 }
00229
00230
00231 #endif
00232
00233 #endif
00234
00235
00236