00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00029 #ifndef _SDL_stdinc_h
00030 #define _SDL_stdinc_h
00031
00032 #include "SDL_config.h"
00033
00034
00035 #ifdef HAVE_SYS_TYPES_H
00036 #include <sys/types.h>
00037 #endif
00038 #ifdef HAVE_STDIO_H
00039 #include <stdio.h>
00040 #endif
00041 #if defined(STDC_HEADERS)
00042 # include <stdlib.h>
00043 # include <stddef.h>
00044 # include <stdarg.h>
00045 #else
00046 # if defined(HAVE_STDLIB_H)
00047 # include <stdlib.h>
00048 # elif defined(HAVE_MALLOC_H)
00049 # include <malloc.h>
00050 # endif
00051 # if defined(HAVE_STDDEF_H)
00052 # include <stddef.h>
00053 # endif
00054 # if defined(HAVE_STDARG_H)
00055 # include <stdarg.h>
00056 # endif
00057 #endif
00058 #ifdef HAVE_STRING_H
00059 # if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
00060 # include <memory.h>
00061 # endif
00062 # include <string.h>
00063 #endif
00064 #ifdef HAVE_STRINGS_H
00065 # include <strings.h>
00066 #endif
00067 #if defined(HAVE_INTTYPES_H)
00068 # include <inttypes.h>
00069 #elif defined(HAVE_STDINT_H)
00070 # include <stdint.h>
00071 #endif
00072 #ifdef HAVE_CTYPE_H
00073 # include <ctype.h>
00074 #endif
00075 #ifdef HAVE_MATH_H
00076 # include <math.h>
00077 #endif
00078 #ifdef HAVE_ICONV_H
00079 # include <iconv.h>
00080 #endif
00081
00082
00083 #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
00084 #define SDL_TABLESIZE(table) SDL_arraysize(table)
00085
00086
00087 typedef enum SDL_bool
00088 {
00089 SDL_FALSE = 0,
00090 SDL_TRUE = 1
00091 } SDL_bool;
00092
00097 typedef int8_t Sint8;
00102 typedef uint8_t Uint8;
00107 typedef int16_t Sint16;
00112 typedef uint16_t Uint16;
00117 typedef int32_t Sint32;
00122 typedef uint32_t Uint32;
00123
00124 #ifdef SDL_HAS_64BIT_TYPE
00125
00130 typedef int64_t Sint64;
00136 typedef uint64_t Uint64;
00137 #else
00138
00139 typedef Sint32 Sint64;
00140 typedef Uint32 Uint64;
00141 #endif
00142
00143
00144 #define SDL_COMPILE_TIME_ASSERT(name, x) \
00145 typedef int SDL_dummy_ ## name[(x) * 2 - 1]
00146 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
00147 SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
00148 SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
00149 SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
00150 SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
00151 SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
00152 SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
00153 #ifndef __NINTENDODS__
00154
00155
00156 SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
00157 SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
00158 #endif
00159 #endif
00160
00161
00162
00163
00164
00165
00166
00167 #ifdef __MWERKS__
00168 #pragma enumsalwaysint on
00169 #endif
00170
00171 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
00172 #ifndef __NINTENDODS__
00173 typedef enum
00174 {
00175 DUMMY_ENUM_VALUE
00176 } SDL_DUMMY_ENUM;
00177
00178 SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
00179 #endif
00180 #endif
00181
00182 #include "begin_code.h"
00183
00184 #ifdef __cplusplus
00185
00186 extern "C" {
00187
00188 #endif
00189
00190 #ifdef HAVE_MALLOC
00191 #define SDL_malloc malloc
00192 #else
00193 extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
00194 #endif
00195
00196 #ifdef HAVE_CALLOC
00197 #define SDL_calloc calloc
00198 #else
00199 extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
00200 #endif
00201
00202 #ifdef HAVE_REALLOC
00203 #define SDL_realloc realloc
00204 #else
00205 extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
00206 #endif
00207
00208 #ifdef HAVE_FREE
00209 #define SDL_free free
00210 #else
00211 extern DECLSPEC void SDLCALL SDL_free(void *mem);
00212 #endif
00213
00214 #if defined(HAVE_ALLOCA) && !defined(alloca)
00215 # if defined(HAVE_ALLOCA_H)
00216 # include <alloca.h>
00217 # elif defined(__GNUC__)
00218 # define alloca __builtin_alloca
00219 # elif defined(_MSC_VER)
00220 # include <malloc.h>
00221 # define alloca _alloca
00222 # elif defined(__WATCOMC__)
00223 # include <malloc.h>
00224 # elif defined(__BORLANDC__)
00225 # include <malloc.h>
00226 # elif defined(__DMC__)
00227 # include <stdlib.h>
00228 # elif defined(__AIX__)
00229 #pragma alloca
00230 # elif defined(__MRC__)
00231 void *alloca(unsigned);
00232 # else
00233 char *alloca();
00234 # endif
00235 #endif
00236 #ifdef HAVE_ALLOCA
00237 #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
00238 #define SDL_stack_free(data)
00239 #else
00240 #define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
00241 #define SDL_stack_free(data) SDL_free(data)
00242 #endif
00243
00244 #ifdef HAVE_GETENV
00245 #define SDL_getenv getenv
00246 #else
00247 extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
00248 #endif
00249
00250 #ifdef HAVE_PUTENV
00251 #define SDL_putenv putenv
00252 #else
00253 extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
00254 #endif
00255
00256 #ifdef HAVE_QSORT
00257 #define SDL_qsort qsort
00258 #else
00259 extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
00260 int (*compare) (const void *,
00261 const void *));
00262 #endif
00263
00264 #ifdef HAVE_ABS
00265 #define SDL_abs abs
00266 #else
00267 #define SDL_abs(X) ((X) < 0 ? -(X) : (X))
00268 #endif
00269
00270 #define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
00271 #define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
00272
00273 #ifdef HAVE_CTYPE_H
00274 #define SDL_isdigit(X) isdigit(X)
00275 #define SDL_isspace(X) isspace(X)
00276 #define SDL_toupper(X) toupper(X)
00277 #define SDL_tolower(X) tolower(X)
00278 #else
00279 #define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9'))
00280 #define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
00281 #define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
00282 #define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
00283 #endif
00284
00285 #ifdef HAVE_MEMSET
00286 #define SDL_memset memset
00287 #else
00288 extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
00289 #endif
00290 #define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
00291 #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
00292
00293 #if defined(__GNUC__) && defined(i386)
00294 #define SDL_memset4(dst, val, len) \
00295 do { \
00296 int u0, u1, u2; \
00297 __asm__ __volatile__ ( \
00298 "cld\n\t" \
00299 "rep ; stosl\n\t" \
00300 : "=&D" (u0), "=&a" (u1), "=&c" (u2) \
00301 : "0" (dst), "1" (val), "2" ((Uint32)(len)) \
00302 : "memory" ); \
00303 } while(0)
00304 #endif
00305 #ifndef SDL_memset4
00306 #define SDL_memset4(dst, val, len) \
00307 do { \
00308 unsigned _count = (len); \
00309 unsigned _n = (_count + 3) / 4; \
00310 Uint32 *_p = (Uint32 *)(dst); \
00311 Uint32 _val = (val); \
00312 switch (_count % 4) { \
00313 case 0: do { *_p++ = _val; \
00314 case 3: *_p++ = _val; \
00315 case 2: *_p++ = _val; \
00316 case 1: *_p++ = _val; \
00317 } while ( --_n ); \
00318 } \
00319 } while(0)
00320 #endif
00321
00322
00323 #if defined(__MACH__) && defined(__APPLE__)
00324 #define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
00325 #elif defined(__GNUC__) && defined(i386)
00326 #define SDL_memcpy(dst, src, len) \
00327 do { \
00328 int u0, u1, u2; \
00329 __asm__ __volatile__ ( \
00330 "cld\n\t" \
00331 "rep ; movsl\n\t" \
00332 "testb $2,%b4\n\t" \
00333 "je 1f\n\t" \
00334 "movsw\n" \
00335 "1:\ttestb $1,%b4\n\t" \
00336 "je 2f\n\t" \
00337 "movsb\n" \
00338 "2:" \
00339 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \
00340 : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
00341 : "memory" ); \
00342 } while(0)
00343 #endif
00344 #ifndef SDL_memcpy
00345 #ifdef HAVE_MEMCPY
00346 #define SDL_memcpy memcpy
00347 #elif defined(HAVE_BCOPY)
00348 #define SDL_memcpy(d, s, n) bcopy((s), (d), (n))
00349 #else
00350 extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
00351 size_t len);
00352 #endif
00353 #endif
00354
00355
00356 #if defined(__MACH__) && defined(__APPLE__)
00357 #define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
00358 #elif defined(__GNUC__) && defined(i386)
00359 #define SDL_memcpy4(dst, src, len) \
00360 do { \
00361 int ecx, edi, esi; \
00362 __asm__ __volatile__ ( \
00363 "cld\n\t" \
00364 "rep ; movsl" \
00365 : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
00366 : "0" ((unsigned)(len)), "1" (dst), "2" (src) \
00367 : "memory" ); \
00368 } while(0)
00369 #endif
00370 #ifndef SDL_memcpy4
00371 #define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2)
00372 #endif
00373
00374 #if defined(__GNUC__) && defined(i386)
00375 #define SDL_revcpy(dst, src, len) \
00376 do { \
00377 int u0, u1, u2; \
00378 char *dstp = (char *)(dst); \
00379 char *srcp = (char *)(src); \
00380 int n = (len); \
00381 if ( n >= 4 ) { \
00382 __asm__ __volatile__ ( \
00383 "std\n\t" \
00384 "rep ; movsl\n\t" \
00385 "cld\n\t" \
00386 : "=&c" (u0), "=&D" (u1), "=&S" (u2) \
00387 : "0" (n >> 2), \
00388 "1" (dstp+(n-4)), "2" (srcp+(n-4)) \
00389 : "memory" ); \
00390 } \
00391 switch (n & 3) { \
00392 case 3: dstp[2] = srcp[2]; \
00393 case 2: dstp[1] = srcp[1]; \
00394 case 1: dstp[0] = srcp[0]; \
00395 break; \
00396 default: \
00397 break; \
00398 } \
00399 } while(0)
00400 #endif
00401 #ifndef SDL_revcpy
00402 extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
00403 size_t len);
00404 #endif
00405
00406 #ifdef HAVE_MEMMOVE
00407 #define SDL_memmove memmove
00408 #elif defined(HAVE_BCOPY)
00409 #define SDL_memmove(d, s, n) bcopy((s), (d), (n))
00410 #else
00411 #define SDL_memmove(dst, src, len) \
00412 do { \
00413 if ( dst < src ) { \
00414 SDL_memcpy(dst, src, len); \
00415 } else { \
00416 SDL_revcpy(dst, src, len); \
00417 } \
00418 } while(0)
00419 #endif
00420
00421 #ifdef HAVE_MEMCMP
00422 #define SDL_memcmp memcmp
00423 #else
00424 extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
00425 size_t len);
00426 #endif
00427
00428 #ifdef HAVE_STRLEN
00429 #define SDL_strlen strlen
00430 #else
00431 extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
00432 #endif
00433
00434 #ifdef HAVE_WCSLEN
00435 #define SDL_wcslen wcslen
00436 #else
00437 #if !defined(wchar_t) && defined(__NINTENDODS__)
00438 #define wchar_t short
00439 #endif
00440 extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
00441 #endif
00442
00443 #ifdef HAVE_STRLCPY
00444 #define SDL_strlcpy strlcpy
00445 #else
00446 extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
00447 size_t maxlen);
00448 #endif
00449
00450 #ifdef HAVE_STRLCAT
00451 #define SDL_strlcat strlcat
00452 #else
00453 extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
00454 size_t maxlen);
00455 #endif
00456
00457 #ifdef HAVE_STRDUP
00458 #define SDL_strdup strdup
00459 #else
00460 extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
00461 #endif
00462
00463 #ifdef HAVE__STRREV
00464 #define SDL_strrev _strrev
00465 #else
00466 extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
00467 #endif
00468
00469 #ifdef HAVE__STRUPR
00470 #define SDL_strupr _strupr
00471 #else
00472 extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
00473 #endif
00474
00475 #ifdef HAVE__STRLWR
00476 #define SDL_strlwr _strlwr
00477 #else
00478 extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
00479 #endif
00480
00481 #ifdef HAVE_STRCHR
00482 #define SDL_strchr strchr
00483 #elif defined(HAVE_INDEX)
00484 #define SDL_strchr index
00485 #else
00486 extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
00487 #endif
00488
00489 #ifdef HAVE_STRRCHR
00490 #define SDL_strrchr strrchr
00491 #elif defined(HAVE_RINDEX)
00492 #define SDL_strrchr rindex
00493 #else
00494 extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
00495 #endif
00496
00497 #ifdef HAVE_STRSTR
00498 #define SDL_strstr strstr
00499 #else
00500 extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
00501 const char *needle);
00502 #endif
00503
00504 #ifdef HAVE_ITOA
00505 #define SDL_itoa itoa
00506 #else
00507 #define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
00508 #endif
00509
00510 #ifdef HAVE__LTOA
00511 #define SDL_ltoa _ltoa
00512 #else
00513 extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
00514 #endif
00515
00516 #ifdef HAVE__UITOA
00517 #define SDL_uitoa _uitoa
00518 #else
00519 #define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
00520 #endif
00521
00522 #ifdef HAVE__ULTOA
00523 #define SDL_ultoa _ultoa
00524 #else
00525 extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
00526 int radix);
00527 #endif
00528
00529 #ifdef HAVE_STRTOL
00530 #define SDL_strtol strtol
00531 #else
00532 extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
00533 int base);
00534 #endif
00535
00536 #ifdef HAVE_STRTOUL
00537 #define SDL_strtoul strtoul
00538 #else
00539 extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
00540 char **endp, int base);
00541 #endif
00542
00543 #ifdef SDL_HAS_64BIT_TYPE
00544
00545 #ifdef HAVE__I64TOA
00546 #define SDL_lltoa _i64toa
00547 #else
00548 extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
00549 int radix);
00550 #endif
00551
00552 #ifdef HAVE__UI64TOA
00553 #define SDL_ulltoa _ui64toa
00554 #else
00555 extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
00556 int radix);
00557 #endif
00558
00559 #ifdef HAVE_STRTOLL
00560 #define SDL_strtoll strtoll
00561 #else
00562 extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
00563 int base);
00564 #endif
00565
00566 #ifdef HAVE_STRTOULL
00567 #define SDL_strtoull strtoull
00568 #else
00569 extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
00570 int base);
00571 #endif
00572
00573 #endif
00574
00575 #ifdef HAVE_STRTOD
00576 #define SDL_strtod strtod
00577 #else
00578 extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
00579 #endif
00580
00581 #ifdef HAVE_ATOI
00582 #define SDL_atoi atoi
00583 #else
00584 #define SDL_atoi(X) SDL_strtol(X, NULL, 0)
00585 #endif
00586
00587 #ifdef HAVE_ATOF
00588 #define SDL_atof atof
00589 #else
00590 #define SDL_atof(X) SDL_strtod(X, NULL)
00591 #endif
00592
00593 #ifdef HAVE_STRCMP
00594 #define SDL_strcmp strcmp
00595 #else
00596 extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
00597 #endif
00598
00599 #ifdef HAVE_STRNCMP
00600 #define SDL_strncmp strncmp
00601 #else
00602 extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
00603 size_t maxlen);
00604 #endif
00605
00606 #ifdef HAVE_STRCASECMP
00607 #define SDL_strcasecmp strcasecmp
00608 #elif defined(HAVE__STRICMP)
00609 #define SDL_strcasecmp _stricmp
00610 #else
00611 extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
00612 const char *str2);
00613 #endif
00614
00615 #ifdef HAVE_STRNCASECMP
00616 #define SDL_strncasecmp strncasecmp
00617 #elif defined(HAVE__STRNICMP)
00618 #define SDL_strncasecmp _strnicmp
00619 #else
00620 extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
00621 const char *str2, size_t maxlen);
00622 #endif
00623
00624 #ifdef HAVE_SSCANF
00625 #define SDL_sscanf sscanf
00626 #else
00627 extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
00628 ...);
00629 #endif
00630
00631 #ifdef HAVE_SNPRINTF
00632 #define SDL_snprintf snprintf
00633 #else
00634 extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
00635 const char *fmt, ...);
00636 #endif
00637
00638 #ifdef HAVE_VSNPRINTF
00639 #define SDL_vsnprintf vsnprintf
00640 #else
00641 extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
00642 const char *fmt, va_list ap);
00643 #endif
00644
00645 #ifndef HAVE_M_PI
00646 #define M_PI 3.14159265358979323846264338327950288
00647 #endif
00648
00649 #ifdef HAVE_CEIL
00650 #define SDL_ceil ceil
00651 #else
00652 #define SDL_ceil(x) ((double)(int)((x)+0.5))
00653 #endif
00654
00655 #ifdef HAVE_COPYSIGN
00656 #define SDL_copysign copysign
00657 #else
00658 extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
00659 #endif
00660
00661 #ifdef HAVE_COS
00662 #define SDL_cos cos
00663 #else
00664 extern DECLSPEC double SDLCALL SDL_cos(double x);
00665 #endif
00666
00667 #ifdef HAVE_COSF
00668 #define SDL_cosf cosf
00669 #else
00670 #define SDL_cosf(x) (float)SDL_cos((double)x)
00671 #endif
00672
00673 #ifdef HAVE_FABS
00674 #define SDL_fabs fabs
00675 #else
00676 extern DECLSPEC double SDLCALL SDL_fabs(double x);
00677 #endif
00678
00679 #ifdef HAVE_FLOOR
00680 #define SDL_floor floor
00681 #else
00682 extern DECLSPEC double SDLCALL SDL_floor(double x);
00683 #endif
00684
00685 #ifdef HAVE_LOG
00686 #define SDL_log log
00687 #else
00688 extern DECLSPEC double SDLCALL SDL_log(double x);
00689 #endif
00690
00691 #ifdef HAVE_POW
00692 #define SDL_pow pow
00693 #else
00694 extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
00695 #endif
00696
00697 #ifdef HAVE_SCALBN
00698 #define SDL_scalbn scalbn
00699 #else
00700 extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
00701 #endif
00702
00703 #ifdef HAVE_SIN
00704 #define SDL_sin sin
00705 #else
00706 extern DECLSPEC double SDLCALL SDL_sin(double x);
00707 #endif
00708
00709 #ifdef HAVE_SINF
00710 #define SDL_sinf sinf
00711 #else
00712 #define SDL_sinf(x) (float)SDL_sin((double)x)
00713 #endif
00714
00715 #ifdef HAVE_SQRT
00716 #define SDL_sqrt sqrt
00717 #else
00718 extern DECLSPEC double SDLCALL SDL_sqrt(double x);
00719 #endif
00720
00721
00722 #define SDL_ICONV_ERROR (size_t)-1
00723 #define SDL_ICONV_E2BIG (size_t)-2
00724 #define SDL_ICONV_EILSEQ (size_t)-3
00725 #define SDL_ICONV_EINVAL (size_t)-4
00726
00727 #ifdef HAVE_ICONV
00728 #define SDL_iconv_t iconv_t
00729 #define SDL_iconv_open iconv_open
00730 #define SDL_iconv_close iconv_close
00731 #else
00732 typedef struct _SDL_iconv_t *SDL_iconv_t;
00733 extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
00734 const char *fromcode);
00735 extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
00736 #endif
00737 extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
00738 size_t * inbytesleft, char **outbuf,
00739 size_t * outbytesleft);
00740
00741
00742
00743 extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
00744 const char *fromcode,
00745 const char *inbuf,
00746 size_t inbytesleft);
00747 #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
00748 #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
00749 #define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
00750
00751
00752 #ifdef __cplusplus
00753
00754 }
00755
00756 #endif
00757 #include "close_code.h"
00758
00759 #endif
00760
00761