Mercurial > sdl-ios-xcode
comparison src/SDL_error.c @ 1330:450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
using Visual C++ 2005
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 06 Feb 2006 08:28:51 +0000 |
parents | c9b51268668f |
children | 3692456e7b0f |
comparison
equal
deleted
inserted
replaced
1329:bc67bbf87818 | 1330:450721ad5436 |
---|---|
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 | 22 |
23 /* Simple error handling in SDL */ | 23 /* Simple error handling in SDL */ |
24 | 24 |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <stdarg.h> | |
28 #include <string.h> | |
29 | |
30 #include "SDL_types.h" | 25 #include "SDL_types.h" |
31 #include "SDL_getenv.h" | 26 #include "SDL_stdlib.h" |
27 #include "SDL_string.h" | |
32 #include "SDL_error.h" | 28 #include "SDL_error.h" |
33 #include "SDL_error_c.h" | 29 #include "SDL_error_c.h" |
34 #ifndef DISABLE_THREADS | 30 #ifndef DISABLE_THREADS |
35 #include "SDL_thread_c.h" | 31 #include "SDL_thread_c.h" |
36 #endif | 32 #endif |
39 /* The default (non-thread-safe) global error variable */ | 35 /* The default (non-thread-safe) global error variable */ |
40 static SDL_error SDL_global_error; | 36 static SDL_error SDL_global_error; |
41 | 37 |
42 #define SDL_GetErrBuf() (&SDL_global_error) | 38 #define SDL_GetErrBuf() (&SDL_global_error) |
43 #endif /* DISABLE_THREADS */ | 39 #endif /* DISABLE_THREADS */ |
44 | |
45 #ifdef __CYGWIN__ | |
46 #define DISABLE_STDIO | |
47 #endif | |
48 | 40 |
49 #define SDL_ERRBUFIZE 1024 | 41 #define SDL_ERRBUFIZE 1024 |
50 | 42 |
51 /* Private functions */ | 43 /* Private functions */ |
52 | 44 |
119 } | 111 } |
120 } | 112 } |
121 } | 113 } |
122 va_end(ap); | 114 va_end(ap); |
123 | 115 |
124 #ifndef DISABLE_STDIO | |
125 /* If we are in debug mode, print out an error message */ | 116 /* If we are in debug mode, print out an error message */ |
126 #ifdef DEBUG_ERROR | 117 #ifdef DEBUG_ERROR |
127 fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); | 118 fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); |
128 #else | 119 #endif |
129 if ( getenv("SDL_DEBUG") ) { | |
130 fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); | |
131 } | |
132 #endif | |
133 #endif /* !DISABLE_STDIO */ | |
134 } | 120 } |
135 | 121 |
136 /* Print out an integer value to a UNICODE buffer */ | 122 /* Print out an integer value to a UNICODE buffer */ |
137 static int PrintInt(Uint16 *str, unsigned int maxlen, int value) | 123 static int PrintInt(Uint16 *str, unsigned int maxlen, int value) |
138 { | 124 { |
139 char tmp[128]; | 125 char tmp[128]; |
140 int len, i; | 126 int len, i; |
141 | 127 |
142 sprintf(tmp, "%d", value); | 128 snprintf(tmp, SDL_arraysize(tmp), "%d", value); |
143 len = 0; | 129 len = 0; |
144 if ( strlen(tmp) < maxlen ) { | 130 if ( strlen(tmp) < maxlen ) { |
145 for ( i=0; tmp[i]; ++i ) { | 131 for ( i=0; tmp[i]; ++i ) { |
146 *str++ = tmp[i]; | 132 *str++ = tmp[i]; |
147 ++len; | 133 ++len; |
153 static int PrintDouble(Uint16 *str, unsigned int maxlen, double value) | 139 static int PrintDouble(Uint16 *str, unsigned int maxlen, double value) |
154 { | 140 { |
155 char tmp[128]; | 141 char tmp[128]; |
156 int len, i; | 142 int len, i; |
157 | 143 |
158 sprintf(tmp, "%f", value); | 144 snprintf(tmp, SDL_arraysize(tmp), "%f", value); |
159 len = 0; | 145 len = 0; |
160 if ( strlen(tmp) < maxlen ) { | 146 if ( strlen(tmp) < maxlen ) { |
161 for ( i=0; tmp[i]; ++i ) { | 147 for ( i=0; tmp[i]; ++i ) { |
162 *str++ = tmp[i]; | 148 *str++ = tmp[i]; |
163 ++len; | 149 ++len; |
169 static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value) | 155 static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value) |
170 { | 156 { |
171 char tmp[128]; | 157 char tmp[128]; |
172 int len, i; | 158 int len, i; |
173 | 159 |
174 sprintf(tmp, "%p", value); | 160 snprintf(tmp, SDL_arraysize(tmp), "%p", value); |
175 len = 0; | 161 len = 0; |
176 if ( strlen(tmp) < maxlen ) { | 162 if ( strlen(tmp) < maxlen ) { |
177 for ( i=0; tmp[i]; ++i ) { | 163 for ( i=0; tmp[i]; ++i ) { |
178 *str++ = tmp[i]; | 164 *str++ = tmp[i]; |
179 ++len; | 165 ++len; |