SDL  2.0
SDL_stdinc.h File Reference
#include "SDL_config.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <inttypes.h>
#include <ctype.h>
#include <math.h>
#include <iconv.h>
#include "begin_code.h"
#include <alloca.h>
#include "close_code.h"
+ Include dependency graph for SDL_stdinc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SDL_arraysize(array)   (sizeof(array)/sizeof(array[0]))
 
#define SDL_TABLESIZE(table)   SDL_arraysize(table)
 
#define SDL_FOURCC(A, B, C, D)
 
#define SDL_PRIs64   "I64d"
 
#define SDL_PRIu64   "I64u"
 
#define SDL_PRIx64   "I64x"
 
#define SDL_PRIX64   "I64X"
 
#define SDL_IN_BYTECAP(x)
 
#define SDL_INOUT_Z_CAP(x)
 
#define SDL_OUT_Z_CAP(x)
 
#define SDL_OUT_CAP(x)
 
#define SDL_OUT_BYTECAP(x)
 
#define SDL_OUT_Z_BYTECAP(x)
 
#define SDL_PRINTF_FORMAT_STRING
 
#define SDL_SCANF_FORMAT_STRING
 
#define SDL_PRINTF_VARARG_FUNC(fmtargnumber)
 
#define SDL_SCANF_VARARG_FUNC(fmtargnumber)
 
#define SDL_COMPILE_TIME_ASSERT(name, x)   typedef int SDL_dummy_ ## name[(x) * 2 - 1]
 
#define SDL_stack_alloc(type, count)   (type*)alloca(sizeof(type)*(count))
 
#define SDL_stack_free(data)
 
#define SDL_min(x, y)   (((x) < (y)) ? (x) : (y))
 
#define SDL_max(x, y)   (((x) > (y)) ? (x) : (y))
 
#define SDL_zero(x)   SDL_memset(&(x), 0, sizeof((x)))
 
#define SDL_zerop(x)   SDL_memset((x), 0, sizeof(*(x)))
 
#define SDL_ICONV_ERROR   (size_t)-1
 
#define SDL_ICONV_E2BIG   (size_t)-2
 
#define SDL_ICONV_EILSEQ   (size_t)-3
 
#define SDL_ICONV_EINVAL   (size_t)-4
 
#define SDL_iconv_utf8_locale(S)   SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs2(S)   (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs4(S)   (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
 
Cast operators

Use proper C++ casts when compiled as C++ to be compatible with the option -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).

#define SDL_reinterpret_cast(type, expression)   ((type)(expression))
 
#define SDL_static_cast(type, expression)   ((type)(expression))
 
#define SDL_const_cast(type, expression)   ((type)(expression))
 

Functions

voidSDL_malloc (size_t size)
 
voidSDL_calloc (size_t nmemb, size_t size)
 
voidSDL_realloc (void *mem, size_t size)
 
void SDL_free (void *mem)
 
char * SDL_getenv (const char *name)
 
int SDL_setenv (const char *name, const char *value, int overwrite)
 
void SDL_qsort (void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
 
int SDL_abs (int x)
 
int SDL_isdigit (int x)
 
int SDL_isspace (int x)
 
int SDL_toupper (int x)
 
int SDL_tolower (int x)
 
voidSDL_memset (SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
 
SDL_FORCE_INLINE void SDL_memset4 (void *dst, Uint32 val, size_t dwords)
 
voidSDL_memcpy (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
voidSDL_memmove (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
int SDL_memcmp (const void *s1, const void *s2, size_t len)
 
size_t SDL_wcslen (const wchar_t *wstr)
 
size_t SDL_wcslcpy (SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
 
size_t SDL_wcslcat (SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
 
size_t SDL_strlen (const char *str)
 
size_t SDL_strlcpy (SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
 
size_t SDL_utf8strlcpy (SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
 
size_t SDL_strlcat (SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
 
char * SDL_strdup (const char *str)
 
char * SDL_strrev (char *str)
 
char * SDL_strupr (char *str)
 
char * SDL_strlwr (char *str)
 
char * SDL_strchr (const char *str, int c)
 
char * SDL_strrchr (const char *str, int c)
 
char * SDL_strstr (const char *haystack, const char *needle)
 
char * SDL_itoa (int value, char *str, int radix)
 
char * SDL_uitoa (unsigned int value, char *str, int radix)
 
char * SDL_ltoa (long value, char *str, int radix)
 
char * SDL_ultoa (unsigned long value, char *str, int radix)
 
char * SDL_lltoa (Sint64 value, char *str, int radix)
 
char * SDL_ulltoa (Uint64 value, char *str, int radix)
 
int SDL_atoi (const char *str)
 
double SDL_atof (const char *str)
 
long SDL_strtol (const char *str, char **endp, int base)
 
unsigned long SDL_strtoul (const char *str, char **endp, int base)
 
Sint64 SDL_strtoll (const char *str, char **endp, int base)
 
Uint64 SDL_strtoull (const char *str, char **endp, int base)
 
double SDL_strtod (const char *str, char **endp)
 
int SDL_strcmp (const char *str1, const char *str2)
 
int SDL_strncmp (const char *str1, const char *str2, size_t maxlen)
 
int SDL_strcasecmp (const char *str1, const char *str2)
 
int SDL_strncasecmp (const char *str1, const char *str2, size_t len)
 
int SDL_sscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2)
 
int SDL_vsscanf (const char *text, const char *fmt, va_list ap)
 
int SDL_snprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(3)
 
int SDL_vsnprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
 
double SDL_acos (double x)
 
double SDL_asin (double x)
 
double SDL_atan (double x)
 
double SDL_atan2 (double x, double y)
 
double SDL_ceil (double x)
 
double SDL_copysign (double x, double y)
 
double SDL_cos (double x)
 
float SDL_cosf (float x)
 
double SDL_fabs (double x)
 
double SDL_floor (double x)
 
double SDL_log (double x)
 
double SDL_pow (double x, double y)
 
double SDL_scalbn (double x, int n)
 
double SDL_sin (double x)
 
float SDL_sinf (float x)
 
double SDL_sqrt (double x)
 
float SDL_sqrtf (float x)
 
double SDL_tan (double x)
 
float SDL_tanf (float x)
 
SDL_iconv_t SDL_iconv_open (const char *tocode, const char *fromcode)
 
int SDL_iconv_close (SDL_iconv_t cd)
 
size_t SDL_iconv (SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 
char * SDL_iconv_string (const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
 
SDL_FORCE_INLINE voidSDL_memcpy4 (SDL_OUT_BYTECAP(dwords *4) void *dst, SDL_IN_BYTECAP(dwords *4) const void *src, size_t dwords)
 

Basic data types

enum  SDL_bool {
  SDL_FALSE = 0,
  SDL_TRUE = 1
}
 
typedef int8_t Sint8
 A signed 8-bit integer type. More...
 
typedef uint8_t Uint8
 An unsigned 8-bit integer type. More...
 
typedef int16_t Sint16
 A signed 16-bit integer type. More...
 
typedef uint16_t Uint16
 An unsigned 16-bit integer type. More...
 
typedef int32_t Sint32
 A signed 32-bit integer type. More...
 
typedef uint32_t Uint32
 An unsigned 32-bit integer type. More...
 
typedef int64_t Sint64
 A signed 64-bit integer type. More...
 
typedef uint64_t Uint64
 An unsigned 64-bit integer type. More...
 

Detailed Description

This is a general header that includes C language support.

Definition in file SDL_stdinc.h.

Macro Definition Documentation

#define SDL_COMPILE_TIME_ASSERT (   name,
  x 
)    typedef int SDL_dummy_ ## name[(x) * 2 - 1]

Definition at line 260 of file SDL_stdinc.h.

#define SDL_const_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 110 of file SDL_stdinc.h.

Referenced by SDL_strchr(), SDL_strrchr(), SDL_strstr(), and SDL_TLSSet().

#define SDL_FOURCC (   A,
  B,
  C,
 
)
Value:
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:109

Definition at line 115 of file SDL_stdinc.h.

#define SDL_ICONV_E2BIG   (size_t)-2

Definition at line 462 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

#define SDL_ICONV_EILSEQ   (size_t)-3

Definition at line 463 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

#define SDL_ICONV_EINVAL   (size_t)-4

Definition at line 464 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

#define SDL_ICONV_ERROR   (size_t)-1

Definition at line 461 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

#define SDL_iconv_utf8_locale (   S)    SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 482 of file SDL_stdinc.h.

#define SDL_iconv_utf8_ucs2 (   S)    (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 483 of file SDL_stdinc.h.

#define SDL_iconv_utf8_ucs4 (   S)    (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 484 of file SDL_stdinc.h.

#define SDL_IN_BYTECAP (   x)

Definition at line 242 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_INOUT_Z_CAP (   x)

Definition at line 243 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_max (   x,
  y 
)    (((x) > (y)) ? (x) : (y))
#define SDL_OUT_BYTECAP (   x)

Definition at line 246 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_OUT_CAP (   x)

Definition at line 245 of file SDL_stdinc.h.

#define SDL_OUT_Z_BYTECAP (   x)

Definition at line 247 of file SDL_stdinc.h.

#define SDL_OUT_Z_CAP (   x)

Definition at line 244 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_PRINTF_FORMAT_STRING

Definition at line 248 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_PRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 255 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_PRIx64   "I64x"

Definition at line 197 of file SDL_stdinc.h.

#define SDL_PRIX64   "I64X"

Definition at line 208 of file SDL_stdinc.h.

Referenced by platform_testEndianessAndSwap(), and TestEndian().

#define SDL_reinterpret_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 108 of file SDL_stdinc.h.

#define SDL_SCANF_FORMAT_STRING

Definition at line 249 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_SCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 256 of file SDL_stdinc.h.

Referenced by SDL_memset4().

#define SDL_static_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 109 of file SDL_stdinc.h.

Referenced by SDL_memset4(), SDL_Swap16(), SDL_Swap32(), and SDL_Swap64().

#define SDL_TABLESIZE (   table)    SDL_arraysize(table)

Definition at line 94 of file SDL_stdinc.h.

Typedef Documentation

typedef int16_t Sint16

A signed 16-bit integer type.

Definition at line 143 of file SDL_stdinc.h.

typedef int32_t Sint32

A signed 32-bit integer type.

Definition at line 151 of file SDL_stdinc.h.

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) a int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64

A signed 64-bit integer type.

Definition at line 160 of file SDL_stdinc.h.

typedef int8_t Sint8

A signed 8-bit integer type.

Definition at line 135 of file SDL_stdinc.h.

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) d int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16

An unsigned 16-bit integer type.

Definition at line 147 of file SDL_stdinc.h.

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) c int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32

An unsigned 32-bit integer type.

Definition at line 155 of file SDL_stdinc.h.

typedef uint64_t Uint64

An unsigned 64-bit integer type.

Definition at line 164 of file SDL_stdinc.h.

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) b int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8

An unsigned 8-bit integer type.

Definition at line 139 of file SDL_stdinc.h.

Enumeration Type Documentation

enum SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) a int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool
Enumerator
SDL_FALSE 
SDL_TRUE 

Definition at line 126 of file SDL_stdinc.h.

127 {
128  SDL_FALSE = 0,
129  SDL_TRUE = 1
130 } SDL_bool;
SDL_bool
Definition: SDL_stdinc.h:126

Function Documentation

int SDL_abs ( int  x)

Definition at line 249 of file SDL_stdlib.c.

References SDL_isdigit(), SDL_isspace(), SDL_tolower(), and SDL_toupper().

250 {
251 #ifdef HAVE_ABS
252  return abs(x);
253 #else
254  return ((x) < 0 ? -(x) : (x));
255 #endif
256 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_acos ( double  x)

Definition at line 55 of file SDL_stdlib.c.

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_asin(), and SDL_memset4().

56 {
57 #if defined(HAVE_ACOS)
58  return acos(val);
59 #else
60  double result;
61  if (val == -1.0) {
62  result = M_PI;
63  } else {
64  result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
65  if (result < 0.0)
66  {
67  result += M_PI;
68  }
69  }
70  return result;
71 #endif
72 }
GLuint64EXT * result
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:210
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val
double SDL_asin ( double  x)

Definition at line 75 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_memset4().

76 {
77 #if defined(HAVE_ASIN)
78  return asin(val);
79 #else
80  double result;
81  if (val == -1.0) {
82  result = -(M_PI / 2.0);
83  } else {
84  result = (M_PI / 2.0) - SDL_acos(val);
85  }
86  return result;
87 #endif
88 }
GLuint64EXT * result
double SDL_acos(double val)
Definition: SDL_stdlib.c:55
GLuint GLfloat * val
double SDL_atan ( double  x)

Definition at line 35 of file SDL_stdlib.c.

References atan(), and SDL_uclibc_atan().

Referenced by SDL_acos(), and SDL_memset4().

36 {
37 #ifdef HAVE_ATAN
38  return atan(x);
39 #else
40  return SDL_uclibc_atan(x);
41 #endif /* HAVE_ATAN */
42 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_atan(double x)
double atan(double x)
Definition: s_atan.c:67
double SDL_atan2 ( double  x,
double  y 
)

Definition at line 45 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

Referenced by SDL_memset4().

46 {
47 #if defined(HAVE_ATAN2)
48  return atan2(x, y);
49 #else
50  return SDL_uclibc_atan2(x, y);
51 #endif /* HAVE_ATAN2 */
52 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_atan2(double y, double x)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
double SDL_atof ( const char *  str)

Definition at line 776 of file SDL_string.c.

References NULL, and SDL_strtod().

Referenced by SDL_memset4().

777 {
778 #ifdef HAVE_ATOF
779  return (double) atof(string);
780 #else
781  return SDL_strtod(string, NULL);
782 #endif /* HAVE_ATOF */
783 }
double SDL_strtod(const char *string, char **endp)
Definition: SDL_string.c:886
#define NULL
Definition: begin_code.h:143
int SDL_atoi ( const char *  str)

Definition at line 767 of file SDL_string.c.

References NULL, and SDL_strtol().

Referenced by SDL_memset4().

768 {
769 #ifdef HAVE_ATOI
770  return atoi(string);
771 #else
772  return SDL_strtol(string, NULL, 0);
773 #endif /* HAVE_ATOI */
774 }
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:786
#define NULL
Definition: begin_code.h:143
double SDL_ceil ( double  x)

Definition at line 91 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_memset4().

92 {
93 #ifdef HAVE_CEIL
94  return ceil(x);
95 #else
96  double integer = SDL_floor(x);
97  double fraction = x - integer;
98  if (fraction > 0.0) {
99  integer += 1.0;
100  }
101  return integer;
102 #endif /* HAVE_CEIL */
103 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_floor(double x)
Definition: SDL_stdlib.c:148
double SDL_copysign ( double  x,
double  y 
)

Definition at line 106 of file SDL_stdlib.c.

References copysign, and SDL_uclibc_copysign().

Referenced by SDL_memset4().

107 {
108 #if defined(HAVE_COPYSIGN)
109  return copysign(x, y);
110 #elif defined(HAVE__COPYSIGN)
111  return _copysign(x, y);
112 #else
113  return SDL_uclibc_copysign(x, y);
114 #endif /* HAVE_COPYSIGN */
115 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_copysign(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define copysign
Definition: math_private.h:34
double SDL_cos ( double  x)

Definition at line 118 of file SDL_stdlib.c.

References cos, and SDL_uclibc_cos().

Referenced by SDL_cosf(), and SDL_memset4().

119 {
120 #if defined(HAVE_COS)
121  return cos(x);
122 #else
123  return SDL_uclibc_cos(x);
124 #endif /* HAVE_COS */
125 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define cos
Definition: math_private.h:35
double SDL_uclibc_cos(double x)
float SDL_cosf ( float  x)

Definition at line 128 of file SDL_stdlib.c.

References SDL_cos().

Referenced by SDL_memset4().

129 {
130 #ifdef HAVE_COSF
131  return cosf(x);
132 #else
133  return (float)SDL_cos((double)x);
134 #endif
135 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:118
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_fabs ( double  x)

Definition at line 138 of file SDL_stdlib.c.

References fabs, and SDL_uclibc_fabs().

Referenced by SDL_memset4().

139 {
140 #if defined(HAVE_FABS)
141  return fabs(x);
142 #else
143  return SDL_uclibc_fabs(x);
144 #endif /* HAVE_FABS */
145 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_fabs(double x)
#define fabs
Definition: math_private.h:36
double SDL_floor ( double  x)

Definition at line 148 of file SDL_stdlib.c.

References floor, and SDL_uclibc_floor().

Referenced by SDL_ceil(), and SDL_memset4().

149 {
150 #if defined(HAVE_FLOOR)
151  return floor(x);
152 #else
153  return SDL_uclibc_floor(x);
154 #endif /* HAVE_FLOOR */
155 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_floor(double x)
#define floor
Definition: math_private.h:37
void SDL_free ( void mem)

Referenced by _compare(), audio_convertAudio(), clean_out_device_list(), clipboard_testClipboardTextFunctions(), clipboard_testGetClipboardText(), clipboard_testSetClipboardText(), free_audio_queue(), free_device_list(), hints_setHint(), IMA_ADPCM_decode(), IsSDLWindowEventPending(), keyboard_getScancodeFromNameNegative(), main(), MS_ADPCM_decode(), pixels_calcGammaRamp(), quit(), ReadChunk(), RLEAlphaSurface(), RLEColorkeySurface(), SDL_AddHintCallback(), SDL_AddTimer(), SDL_AllocFormat(), SDL_AllocPalette(), SDL_ClearHints(), SDL_CreateCond(), SDL_CreateMutex(), SDL_CreateSemaphore(), SDL_CreateThread(), SDL_CreateWindowTexture(), SDL_DelEventWatch(), SDL_DelHintCallback(), SDL_DelTouch(), SDL_DestroyCond(), SDL_DestroyMutex(), SDL_DestroySemaphore(), SDL_DestroyTexture(), SDL_DestroyWindow(), SDL_DestroyWindowTexture(), SDL_FreeBlitMap(), SDL_FreeFormat(), SDL_FreePalette(), SDL_FreeRW(), SDL_FreeShapeTree(), SDL_FreeSurface(), SDL_FreeWAV(), SDL_GameControllerAddMapping(), SDL_GameControllerAddMappingsFromRW(), SDL_GameControllerClose(), SDL_GameControllerLoadHints(), SDL_GameControllerOpen(), SDL_GameControllerQuit(), SDL_Generic_SetTLSData(), SDL_GetErrBuf(), SDL_GL_DeleteContext(), SDL_HapticClose(), SDL_HapticOpen(), SDL_HapticOpenFromJoystick(), SDL_iconv_close(), SDL_InvalidateMap(), SDL_JoystickClose(), SDL_JoystickOpen(), SDL_LoadWAV_RW(), SDL_LogOutput(), SDL_LogResetPriorities(), SDL_MouseQuit(), SDL_PrivateAddMappingForGUID(), SDL_RemoveTimer(), SDL_RunThread(), SDL_SetClipboardText(), SDL_setenv(), SDL_SetHintWithPriority(), SDL_SetWindowData(), SDL_SetWindowTitle(), SDL_StopEventLoop(), SDL_SW_DestroyYUVTexture(), SDL_SYS_RemoveJoystickDevice(), SDL_TimerQuit(), SDL_TLSCleanup(), SDL_TouchQuit(), SDL_UnRLESurface(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_UpdateTextureYUVPlanar(), SDL_VideoQuit(), SDL_WaitThread(), SDLTest_CommonEvent(), SDLTest_CommonQuit(), SDLTest_GenerateExecKey(), sdltest_generateRunSeed(), sdltest_randomAsciiString(), sdltest_randomAsciiStringOfSize(), sdltest_randomAsciiStringWithMaximumLength(), SDLTest_RunSuites(), SDLTest_ScreenShot(), stdlib_getsetenv(), SW_DestroyRenderer(), and video_getSetWindowData().

char* SDL_getenv ( const char *  name)

Definition at line 212 of file SDL_getenv.c.

References i, main, NULL, SDL_setenv(), SDL_strcmp, SDL_strlen, and SDL_strncmp.

Referenced by SDL_setenv().

213 {
214  int len, i;
215  char *value;
216 
217  /* Input validation */
218  if (!name || SDL_strlen(name)==0) {
219  return NULL;
220  }
221 
222  value = (char *) 0;
223  if (SDL_env) {
224  len = SDL_strlen(name);
225  for (i = 0; SDL_env[i] && !value; ++i) {
226  if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
227  (SDL_env[i][len] == '=')) {
228  value = &SDL_env[i][len + 1];
229  }
230  }
231  }
232  return value;
233 }
GLuint const GLchar * name
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:106
GLenum GLsizei len
GLsizei const GLfloat * value
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
#define NULL
Definition: begin_code.h:143
#define SDL_strlen
size_t SDL_iconv ( SDL_iconv_t  cd,
const char **  inbuf,
size_t inbytesleft,
char **  outbuf,
size_t outbytesleft 
)

Definition at line 246 of file SDL_iconv.c.

References ENCODING_ASCII, ENCODING_LATIN1, ENCODING_UCS2BE, ENCODING_UCS2LE, ENCODING_UCS4BE, ENCODING_UCS4LE, ENCODING_UTF16, ENCODING_UTF16BE, ENCODING_UTF16LE, ENCODING_UTF16NATIVE, ENCODING_UTF32, ENCODING_UTF32BE, ENCODING_UTF32LE, ENCODING_UTF32NATIVE, ENCODING_UTF8, SDL_FALSE, SDL_ICONV_E2BIG, SDL_ICONV_EINVAL, SDL_TRUE, UNICODE_BOM, UNKNOWN_ASCII, and UNKNOWN_UNICODE.

Referenced by SDL_iconv_string().

249 {
250  /* For simplicity, we'll convert everything to and from UCS-4 */
251  const char *src;
252  char *dst;
253  size_t srclen, dstlen;
254  Uint32 ch = 0;
255  size_t total;
256 
257  if (!inbuf || !*inbuf) {
258  /* Reset the context */
259  return 0;
260  }
261  if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) {
262  return SDL_ICONV_E2BIG;
263  }
264  src = *inbuf;
265  srclen = (inbytesleft ? *inbytesleft : 0);
266  dst = *outbuf;
267  dstlen = *outbytesleft;
268 
269  switch (cd->src_fmt) {
270  case ENCODING_UTF16:
271  /* Scan for a byte order marker */
272  {
273  Uint8 *p = (Uint8 *) src;
274  size_t n = srclen / 2;
275  while (n) {
276  if (p[0] == 0xFF && p[1] == 0xFE) {
277  cd->src_fmt = ENCODING_UTF16BE;
278  break;
279  } else if (p[0] == 0xFE && p[1] == 0xFF) {
280  cd->src_fmt = ENCODING_UTF16LE;
281  break;
282  }
283  p += 2;
284  --n;
285  }
286  if (n == 0) {
287  /* We can't tell, default to host order */
288  cd->src_fmt = ENCODING_UTF16NATIVE;
289  }
290  }
291  break;
292  case ENCODING_UTF32:
293  /* Scan for a byte order marker */
294  {
295  Uint8 *p = (Uint8 *) src;
296  size_t n = srclen / 4;
297  while (n) {
298  if (p[0] == 0xFF && p[1] == 0xFE &&
299  p[2] == 0x00 && p[3] == 0x00) {
300  cd->src_fmt = ENCODING_UTF32BE;
301  break;
302  } else if (p[0] == 0x00 && p[1] == 0x00 &&
303  p[2] == 0xFE && p[3] == 0xFF) {
304  cd->src_fmt = ENCODING_UTF32LE;
305  break;
306  }
307  p += 4;
308  --n;
309  }
310  if (n == 0) {
311  /* We can't tell, default to host order */
312  cd->src_fmt = ENCODING_UTF32NATIVE;
313  }
314  }
315  break;
316  }
317 
318  switch (cd->dst_fmt) {
319  case ENCODING_UTF16:
320  /* Default to host order, need to add byte order marker */
321  if (dstlen < 2) {
322  return SDL_ICONV_E2BIG;
323  }
324  *(Uint16 *) dst = UNICODE_BOM;
325  dst += 2;
326  dstlen -= 2;
327  cd->dst_fmt = ENCODING_UTF16NATIVE;
328  break;
329  case ENCODING_UTF32:
330  /* Default to host order, need to add byte order marker */
331  if (dstlen < 4) {
332  return SDL_ICONV_E2BIG;
333  }
334  *(Uint32 *) dst = UNICODE_BOM;
335  dst += 4;
336  dstlen -= 4;
337  cd->dst_fmt = ENCODING_UTF32NATIVE;
338  break;
339  }
340 
341  total = 0;
342  while (srclen > 0) {
343  /* Decode a character */
344  switch (cd->src_fmt) {
345  case ENCODING_ASCII:
346  {
347  Uint8 *p = (Uint8 *) src;
348  ch = (Uint32) (p[0] & 0x7F);
349  ++src;
350  --srclen;
351  }
352  break;
353  case ENCODING_LATIN1:
354  {
355  Uint8 *p = (Uint8 *) src;
356  ch = (Uint32) p[0];
357  ++src;
358  --srclen;
359  }
360  break;
361  case ENCODING_UTF8: /* RFC 3629 */
362  {
363  Uint8 *p = (Uint8 *) src;
364  size_t left = 0;
365  SDL_bool overlong = SDL_FALSE;
366  if (p[0] >= 0xFC) {
367  if ((p[0] & 0xFE) != 0xFC) {
368  /* Skip illegal sequences
369  return SDL_ICONV_EILSEQ;
370  */
371  ch = UNKNOWN_UNICODE;
372  } else {
373  if (p[0] == 0xFC && srclen > 1 && (p[1] & 0xFC) == 0x80) {
374  overlong = SDL_TRUE;
375  }
376  ch = (Uint32) (p[0] & 0x01);
377  left = 5;
378  }
379  } else if (p[0] >= 0xF8) {
380  if ((p[0] & 0xFC) != 0xF8) {
381  /* Skip illegal sequences
382  return SDL_ICONV_EILSEQ;
383  */
384  ch = UNKNOWN_UNICODE;
385  } else {
386  if (p[0] == 0xF8 && srclen > 1 && (p[1] & 0xF8) == 0x80) {
387  overlong = SDL_TRUE;
388  }
389  ch = (Uint32) (p[0] & 0x03);
390  left = 4;
391  }
392  } else if (p[0] >= 0xF0) {
393  if ((p[0] & 0xF8) != 0xF0) {
394  /* Skip illegal sequences
395  return SDL_ICONV_EILSEQ;
396  */
397  ch = UNKNOWN_UNICODE;
398  } else {
399  if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) {
400  overlong = SDL_TRUE;
401  }
402  ch = (Uint32) (p[0] & 0x07);
403  left = 3;
404  }
405  } else if (p[0] >= 0xE0) {
406  if ((p[0] & 0xF0) != 0xE0) {
407  /* Skip illegal sequences
408  return SDL_ICONV_EILSEQ;
409  */
410  ch = UNKNOWN_UNICODE;
411  } else {
412  if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) {
413  overlong = SDL_TRUE;
414  }
415  ch = (Uint32) (p[0] & 0x0F);
416  left = 2;
417  }
418  } else if (p[0] >= 0xC0) {
419  if ((p[0] & 0xE0) != 0xC0) {
420  /* Skip illegal sequences
421  return SDL_ICONV_EILSEQ;
422  */
423  ch = UNKNOWN_UNICODE;
424  } else {
425  if ((p[0] & 0xDE) == 0xC0) {
426  overlong = SDL_TRUE;
427  }
428  ch = (Uint32) (p[0] & 0x1F);
429  left = 1;
430  }
431  } else {
432  if ((p[0] & 0x80) != 0x00) {
433  /* Skip illegal sequences
434  return SDL_ICONV_EILSEQ;
435  */
436  ch = UNKNOWN_UNICODE;
437  } else {
438  ch = (Uint32) p[0];
439  }
440  }
441  ++src;
442  --srclen;
443  if (srclen < left) {
444  return SDL_ICONV_EINVAL;
445  }
446  while (left--) {
447  ++p;
448  if ((p[0] & 0xC0) != 0x80) {
449  /* Skip illegal sequences
450  return SDL_ICONV_EILSEQ;
451  */
452  ch = UNKNOWN_UNICODE;
453  break;
454  }
455  ch <<= 6;
456  ch |= (p[0] & 0x3F);
457  ++src;
458  --srclen;
459  }
460  if (overlong) {
461  /* Potential security risk
462  return SDL_ICONV_EILSEQ;
463  */
464  ch = UNKNOWN_UNICODE;
465  }
466  if ((ch >= 0xD800 && ch <= 0xDFFF) ||
467  (ch == 0xFFFE || ch == 0xFFFF) || ch > 0x10FFFF) {
468  /* Skip illegal sequences
469  return SDL_ICONV_EILSEQ;
470  */
471  ch = UNKNOWN_UNICODE;
472  }
473  }
474  break;
475  case ENCODING_UTF16BE: /* RFC 2781 */
476  {
477  Uint8 *p = (Uint8 *) src;
478  Uint16 W1, W2;
479  if (srclen < 2) {
480  return SDL_ICONV_EINVAL;
481  }
482  W1 = ((Uint16) p[0] << 8) | (Uint16) p[1];
483  src += 2;
484  srclen -= 2;
485  if (W1 < 0xD800 || W1 > 0xDFFF) {
486  ch = (Uint32) W1;
487  break;
488  }
489  if (W1 > 0xDBFF) {
490  /* Skip illegal sequences
491  return SDL_ICONV_EILSEQ;
492  */
493  ch = UNKNOWN_UNICODE;
494  break;
495  }
496  if (srclen < 2) {
497  return SDL_ICONV_EINVAL;
498  }
499  p = (Uint8 *) src;
500  W2 = ((Uint16) p[0] << 8) | (Uint16) p[1];
501  src += 2;
502  srclen -= 2;
503  if (W2 < 0xDC00 || W2 > 0xDFFF) {
504  /* Skip illegal sequences
505  return SDL_ICONV_EILSEQ;
506  */
507  ch = UNKNOWN_UNICODE;
508  break;
509  }
510  ch = (((Uint32) (W1 & 0x3FF) << 10) |
511  (Uint32) (W2 & 0x3FF)) + 0x10000;
512  }
513  break;
514  case ENCODING_UTF16LE: /* RFC 2781 */
515  {
516  Uint8 *p = (Uint8 *) src;
517  Uint16 W1, W2;
518  if (srclen < 2) {
519  return SDL_ICONV_EINVAL;
520  }
521  W1 = ((Uint16) p[1] << 8) | (Uint16) p[0];
522  src += 2;
523  srclen -= 2;
524  if (W1 < 0xD800 || W1 > 0xDFFF) {
525  ch = (Uint32) W1;
526  break;
527  }
528  if (W1 > 0xDBFF) {
529  /* Skip illegal sequences
530  return SDL_ICONV_EILSEQ;
531  */
532  ch = UNKNOWN_UNICODE;
533  break;
534  }
535  if (srclen < 2) {
536  return SDL_ICONV_EINVAL;
537  }
538  p = (Uint8 *) src;
539  W2 = ((Uint16) p[1] << 8) | (Uint16) p[0];
540  src += 2;
541  srclen -= 2;
542  if (W2 < 0xDC00 || W2 > 0xDFFF) {
543  /* Skip illegal sequences
544  return SDL_ICONV_EILSEQ;
545  */
546  ch = UNKNOWN_UNICODE;
547  break;
548  }
549  ch = (((Uint32) (W1 & 0x3FF) << 10) |
550  (Uint32) (W2 & 0x3FF)) + 0x10000;
551  }
552  break;
553  case ENCODING_UCS2LE:
554  {
555  Uint8 *p = (Uint8 *) src;
556  if (srclen < 2) {
557  return SDL_ICONV_EINVAL;
558  }
559  ch = ((Uint32) p[1] << 8) | (Uint32) p[0];
560  src += 2;
561  srclen -= 2;
562  }
563  break;
564  case ENCODING_UCS2BE:
565  {
566  Uint8 *p = (Uint8 *) src;
567  if (srclen < 2) {
568  return SDL_ICONV_EINVAL;
569  }
570  ch = ((Uint32) p[0] << 8) | (Uint32) p[1];
571  src += 2;
572  srclen -= 2;
573  }
574  break;
575  case ENCODING_UCS4BE:
576  case ENCODING_UTF32BE:
577  {
578  Uint8 *p = (Uint8 *) src;
579  if (srclen < 4) {
580  return SDL_ICONV_EINVAL;
581  }
582  ch = ((Uint32) p[0] << 24) |
583  ((Uint32) p[1] << 16) |
584  ((Uint32) p[2] << 8) | (Uint32) p[3];
585  src += 4;
586  srclen -= 4;
587  }
588  break;
589  case ENCODING_UCS4LE:
590  case ENCODING_UTF32LE:
591  {
592  Uint8 *p = (Uint8 *) src;
593  if (srclen < 4) {
594  return SDL_ICONV_EINVAL;
595  }
596  ch = ((Uint32) p[3] << 24) |
597  ((Uint32) p[2] << 16) |
598  ((Uint32) p[1] << 8) | (Uint32) p[0];
599  src += 4;
600  srclen -= 4;
601  }
602  break;
603  }
604 
605  /* Encode a character */
606  switch (cd->dst_fmt) {
607  case ENCODING_ASCII:
608  {
609  Uint8 *p = (Uint8 *) dst;
610  if (dstlen < 1) {
611  return SDL_ICONV_E2BIG;
612  }
613  if (ch > 0x7F) {
614  *p = UNKNOWN_ASCII;
615  } else {
616  *p = (Uint8) ch;
617  }
618  ++dst;
619  --dstlen;
620  }
621  break;
622  case ENCODING_LATIN1:
623  {
624  Uint8 *p = (Uint8 *) dst;
625  if (dstlen < 1) {
626  return SDL_ICONV_E2BIG;
627  }
628  if (ch > 0xFF) {
629  *p = UNKNOWN_ASCII;
630  } else {
631  *p = (Uint8) ch;
632  }
633  ++dst;
634  --dstlen;
635  }
636  break;
637  case ENCODING_UTF8: /* RFC 3629 */
638  {
639  Uint8 *p = (Uint8 *) dst;
640  if (ch > 0x10FFFF) {
641  ch = UNKNOWN_UNICODE;
642  }
643  if (ch <= 0x7F) {
644  if (dstlen < 1) {
645  return SDL_ICONV_E2BIG;
646  }
647  *p = (Uint8) ch;
648  ++dst;
649  --dstlen;
650  } else if (ch <= 0x7FF) {
651  if (dstlen < 2) {
652  return SDL_ICONV_E2BIG;
653  }
654  p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F);
655  p[1] = 0x80 | (Uint8) (ch & 0x3F);
656  dst += 2;
657  dstlen -= 2;
658  } else if (ch <= 0xFFFF) {
659  if (dstlen < 3) {
660  return SDL_ICONV_E2BIG;
661  }
662  p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F);
663  p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
664  p[2] = 0x80 | (Uint8) (ch & 0x3F);
665  dst += 3;
666  dstlen -= 3;
667  } else if (ch <= 0x1FFFFF) {
668  if (dstlen < 4) {
669  return SDL_ICONV_E2BIG;
670  }
671  p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07);
672  p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
673  p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
674  p[3] = 0x80 | (Uint8) (ch & 0x3F);
675  dst += 4;
676  dstlen -= 4;
677  } else if (ch <= 0x3FFFFFF) {
678  if (dstlen < 5) {
679  return SDL_ICONV_E2BIG;
680  }
681  p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03);
682  p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
683  p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
684  p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
685  p[4] = 0x80 | (Uint8) (ch & 0x3F);
686  dst += 5;
687  dstlen -= 5;
688  } else {
689  if (dstlen < 6) {
690  return SDL_ICONV_E2BIG;
691  }
692  p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01);
693  p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F);
694  p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
695  p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
696  p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
697  p[5] = 0x80 | (Uint8) (ch & 0x3F);
698  dst += 6;
699  dstlen -= 6;
700  }
701  }
702  break;
703  case ENCODING_UTF16BE: /* RFC 2781 */
704  {
705  Uint8 *p = (Uint8 *) dst;
706  if (ch > 0x10FFFF) {
707  ch = UNKNOWN_UNICODE;
708  }
709  if (ch < 0x10000) {
710  if (dstlen < 2) {
711  return SDL_ICONV_E2BIG;
712  }
713  p[0] = (Uint8) (ch >> 8);
714  p[1] = (Uint8) ch;
715  dst += 2;
716  dstlen -= 2;
717  } else {
718  Uint16 W1, W2;
719  if (dstlen < 4) {
720  return SDL_ICONV_E2BIG;
721  }
722  ch = ch - 0x10000;
723  W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF);
724  W2 = 0xDC00 | (Uint16) (ch & 0x3FF);
725  p[0] = (Uint8) (W1 >> 8);
726  p[1] = (Uint8) W1;
727  p[2] = (Uint8) (W2 >> 8);
728  p[3] = (Uint8) W2;
729  dst += 4;
730  dstlen -= 4;
731  }
732  }
733  break;
734  case ENCODING_UTF16LE: /* RFC 2781 */
735  {
736  Uint8 *p = (Uint8 *) dst;
737  if (ch > 0x10FFFF) {
738  ch = UNKNOWN_UNICODE;
739  }
740  if (ch < 0x10000) {
741  if (dstlen < 2) {
742  return SDL_ICONV_E2BIG;
743  }
744  p[1] = (Uint8) (ch >> 8);
745  p[0] = (Uint8) ch;
746  dst += 2;
747  dstlen -= 2;
748  } else {
749  Uint16 W1, W2;
750  if (dstlen < 4) {
751  return SDL_ICONV_E2BIG;
752  }
753  ch = ch - 0x10000;
754  W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF);
755  W2 = 0xDC00 | (Uint16) (ch & 0x3FF);
756  p[1] = (Uint8) (W1 >> 8);
757  p[0] = (Uint8) W1;
758  p[3] = (Uint8) (W2 >> 8);
759  p[2] = (Uint8) W2;
760  dst += 4;
761  dstlen -= 4;
762  }
763  }
764  break;
765  case ENCODING_UCS2BE:
766  {
767  Uint8 *p = (Uint8 *) dst;
768  if (ch > 0xFFFF) {
769  ch = UNKNOWN_UNICODE;
770  }
771  if (dstlen < 2) {
772  return SDL_ICONV_E2BIG;
773  }
774  p[0] = (Uint8) (ch >> 8);
775  p[1] = (Uint8) ch;
776  dst += 2;
777  dstlen -= 2;
778  }
779  break;
780  case ENCODING_UCS2LE:
781  {
782  Uint8 *p = (Uint8 *) dst;
783  if (ch > 0xFFFF) {
784  ch = UNKNOWN_UNICODE;
785  }
786  if (dstlen < 2) {
787  return SDL_ICONV_E2BIG;
788  }
789  p[1] = (Uint8) (ch >> 8);
790  p[0] = (Uint8) ch;
791  dst += 2;
792  dstlen -= 2;
793  }
794  break;
795  case ENCODING_UTF32BE:
796  if (ch > 0x10FFFF) {
797  ch = UNKNOWN_UNICODE;
798  }
799  case ENCODING_UCS4BE:
800  if (ch > 0x7FFFFFFF) {
801  ch = UNKNOWN_UNICODE;
802  }
803  {
804  Uint8 *p = (Uint8 *) dst;
805  if (dstlen < 4) {
806  return SDL_ICONV_E2BIG;
807  }
808  p[0] = (Uint8) (ch >> 24);
809  p[1] = (Uint8) (ch >> 16);
810  p[2] = (Uint8) (ch >> 8);
811  p[3] = (Uint8) ch;
812  dst += 4;
813  dstlen -= 4;
814  }
815  break;
816  case ENCODING_UTF32LE:
817  if (ch > 0x10FFFF) {
818  ch = UNKNOWN_UNICODE;
819  }
820  case ENCODING_UCS4LE:
821  if (ch > 0x7FFFFFFF) {
822  ch = UNKNOWN_UNICODE;
823  }
824  {
825  Uint8 *p = (Uint8 *) dst;
826  if (dstlen < 4) {
827  return SDL_ICONV_E2BIG;
828  }
829  p[3] = (Uint8) (ch >> 24);
830  p[2] = (Uint8) (ch >> 16);
831  p[1] = (Uint8) (ch >> 8);
832  p[0] = (Uint8) ch;
833  dst += 4;
834  dstlen -= 4;
835  }
836  break;
837  }
838 
839  /* Update state */
840  *inbuf = src;
841  *inbytesleft = srclen;
842  *outbuf = dst;
843  *outbytesleft = dstlen;
844  ++total;
845  }
846  return total;
847 }
GLenum GLenum dst
GLdouble n
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
#define UNKNOWN_UNICODE
Definition: SDL_iconv.c:96
GLfloat GLfloat p
SDL_bool
Definition: SDL_stdinc.h:126
#define UNICODE_BOM
Definition: SDL_iconv.c:93
GLint left
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
#define SDL_ICONV_E2BIG
Definition: SDL_stdinc.h:462
#define ENCODING_UTF32NATIVE
Definition: SDL_iconv.c:117
#define SDL_ICONV_EINVAL
Definition: SDL_stdinc.h:464
#define UNKNOWN_ASCII
Definition: SDL_iconv.c:95
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
#define ENCODING_UTF16NATIVE
Definition: SDL_iconv.c:116
GLenum src
int SDL_iconv_close ( SDL_iconv_t  cd)

Definition at line 850 of file SDL_iconv.c.

References SDL_free().

Referenced by SDL_iconv_string().

851 {
852  if (cd != (SDL_iconv_t)-1) {
853  SDL_free(cd);
854  }
855  return 0;
856 }
void SDL_free(void *mem)
SDL_iconv_t SDL_iconv_open ( const char *  tocode,
const char *  fromcode 
)

Definition at line 206 of file SDL_iconv.c.

References SDL_iconv_t::dst_fmt, ENCODING_UNKNOWN, encodings, getlocale(), i, SDL_arraysize, SDL_malloc, SDL_strcasecmp, and SDL_iconv_t::src_fmt.

Referenced by SDL_iconv_string().

207 {
208  int src_fmt = ENCODING_UNKNOWN;
209  int dst_fmt = ENCODING_UNKNOWN;
210  int i;
211  char fromcode_buffer[64];
212  char tocode_buffer[64];
213 
214  if (!fromcode || !*fromcode) {
215  fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer));
216  }
217  if (!tocode || !*tocode) {
218  tocode = getlocale(tocode_buffer, sizeof(tocode_buffer));
219  }
220  for (i = 0; i < SDL_arraysize(encodings); ++i) {
221  if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) {
222  src_fmt = encodings[i].format;
223  if (dst_fmt != ENCODING_UNKNOWN) {
224  break;
225  }
226  }
227  if (SDL_strcasecmp(tocode, encodings[i].name) == 0) {
228  dst_fmt = encodings[i].format;
229  if (src_fmt != ENCODING_UNKNOWN) {
230  break;
231  }
232  }
233  }
234  if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) {
235  SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd));
236  if (cd) {
237  cd->src_fmt = src_fmt;
238  cd->dst_fmt = dst_fmt;
239  return cd;
240  }
241  }
242  return (SDL_iconv_t) - 1;
243 }
static struct @26 encodings[]
GLuint const GLchar * name
#define SDL_strcasecmp
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93
#define SDL_malloc
static const char * getlocale(char *buffer, size_t bufsize)
Definition: SDL_iconv.c:171
char* SDL_iconv_string ( const char *  tocode,
const char *  fromcode,
const char *  inbuf,
size_t  inbytesleft 
)

This function converts a string between encodings in one pass, returning a string that must be freed with SDL_free() or NULL on error.

Definition at line 861 of file SDL_iconv.c.

References NULL, SDL_iconv(), SDL_iconv_close(), SDL_ICONV_E2BIG, SDL_ICONV_EILSEQ, SDL_ICONV_EINVAL, SDL_ICONV_ERROR, SDL_iconv_open(), SDL_malloc, SDL_memset, and SDL_realloc.

863 {
864  SDL_iconv_t cd;
865  char *string;
866  size_t stringsize;
867  char *outbuf;
868  size_t outbytesleft;
869  size_t retCode = 0;
870 
871  cd = SDL_iconv_open(tocode, fromcode);
872  if (cd == (SDL_iconv_t) - 1) {
873  /* See if we can recover here (fixes iconv on Solaris 11) */
874  if (!tocode || !*tocode) {
875  tocode = "UTF-8";
876  }
877  if (!fromcode || !*fromcode) {
878  fromcode = "UTF-8";
879  }
880  cd = SDL_iconv_open(tocode, fromcode);
881  }
882  if (cd == (SDL_iconv_t) - 1) {
883  return NULL;
884  }
885 
886  stringsize = inbytesleft > 4 ? inbytesleft : 4;
887  string = SDL_malloc(stringsize);
888  if (!string) {
889  SDL_iconv_close(cd);
890  return NULL;
891  }
892  outbuf = string;
893  outbytesleft = stringsize;
894  SDL_memset(outbuf, 0, 4);
895 
896  while (inbytesleft > 0) {
897  retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
898  switch (retCode) {
899  case SDL_ICONV_E2BIG:
900  {
901  char *oldstring = string;
902  stringsize *= 2;
903  string = SDL_realloc(string, stringsize);
904  if (!string) {
905  SDL_iconv_close(cd);
906  return NULL;
907  }
908  outbuf = string + (outbuf - oldstring);
909  outbytesleft = stringsize - (outbuf - string);
910  SDL_memset(outbuf, 0, 4);
911  }
912  break;
913  case SDL_ICONV_EILSEQ:
914  /* Try skipping some input data - not perfect, but... */
915  ++inbuf;
916  --inbytesleft;
917  break;
918  case SDL_ICONV_EINVAL:
919  case SDL_ICONV_ERROR:
920  /* We can't continue... */
921  inbytesleft = 0;
922  break;
923  }
924  }
925  SDL_iconv_close(cd);
926 
927  return string;
928 }
int SDL_iconv_close(SDL_iconv_t cd)
Definition: SDL_iconv.c:850
GLsizei const GLchar *const * string
#define SDL_ICONV_EILSEQ
Definition: SDL_stdinc.h:463
SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
Definition: SDL_iconv.c:206
#define SDL_realloc
#define SDL_ICONV_E2BIG
Definition: SDL_stdinc.h:462
#define SDL_ICONV_EINVAL
Definition: SDL_stdinc.h:464
#define NULL
Definition: begin_code.h:143
#define SDL_ICONV_ERROR
Definition: SDL_stdinc.h:461
#define SDL_malloc
size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: SDL_iconv.c:246
#define SDL_memset
int SDL_isdigit ( int  x)

Definition at line 264 of file SDL_stdlib.c.

Referenced by SDL_abs().

264 { return ((x) >= '0') && ((x) <= '9'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
int SDL_isspace ( int  x)

Definition at line 265 of file SDL_stdlib.c.

Referenced by SDL_abs().

265 { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
char* SDL_itoa ( int  value,
char *  str,
int  radix 
)

Definition at line 660 of file SDL_string.c.

References SDL_ltoa().

Referenced by SDL_memset4().

661 {
662 #ifdef HAVE_ITOA
663  return itoa(value, string, radix);
664 #else
665  return SDL_ltoa((long)value, string, radix);
666 #endif /* HAVE_ITOA */
667 }
GLsizei const GLfloat * value
char * SDL_ltoa(long value, char *string, int radix)
Definition: SDL_string.c:680
char* SDL_lltoa ( Sint64  value,
char *  str,
int  radix 
)

Definition at line 724 of file SDL_string.c.

References SDL_ulltoa().

Referenced by SDL_memset4(), and SDL_PrintLongLong().

725 {
726 #if defined(HAVE__I64TOA)
727  return _i64toa(value, string, radix);
728 #else
729  char *bufp = string;
730 
731  if (value < 0) {
732  *bufp++ = '-';
733  SDL_ulltoa(-value, bufp, radix);
734  } else {
735  SDL_ulltoa(value, bufp, radix);
736  }
737 
738  return string;
739 #endif /* HAVE__I64TOA */
740 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:743
double SDL_log ( double  x)

Definition at line 158 of file SDL_stdlib.c.

References SDL_uclibc_log().

Referenced by SDL_memset4().

159 {
160 #if defined(HAVE_LOG)
161  return log(x);
162 #else
163  return SDL_uclibc_log(x);
164 #endif /* HAVE_LOG */
165 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
char* SDL_ltoa ( long  value,
char *  str,
int  radix 
)

Definition at line 680 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_itoa(), SDL_memset4(), and SDL_PrintLong().

681 {
682 #if defined(HAVE__LTOA)
683  return _ltoa(value, string, radix);
684 #else
685  char *bufp = string;
686 
687  if (value < 0) {
688  *bufp++ = '-';
689  SDL_ultoa(-value, bufp, radix);
690  } else {
691  SDL_ultoa(value, bufp, radix);
692  }
693 
694  return string;
695 #endif /* HAVE__LTOA */
696 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699
void* SDL_malloc ( size_t  size)
int SDL_memcmp ( const void s1,
const void s2,
size_t  len 
)

Definition at line 391 of file SDL_string.c.

Referenced by SDL_memset4().

392 {
393 #if defined(HAVE_MEMCMP)
394  return memcmp(s1, s2, len);
395 #else
396  char *s1p = (char *) s1;
397  char *s2p = (char *) s2;
398  while (len--) {
399  if (*s1p != *s2p) {
400  return (*s1p - *s2p);
401  }
402  ++s1p;
403  ++s2p;
404  }
405  return 0;
406 #endif /* HAVE_MEMCMP */
407 }
GLenum GLsizei len
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
void* SDL_memcpy ( SDL_OUT_BYTECAP(len) void dst,
SDL_IN_BYTECAP(len) const void src,
size_t  len 
)

Definition at line 314 of file SDL_string.c.

References memcpy.

Referenced by SDL_memcpy4(), SDL_memset4(), SDL_strlcpy(), SDL_utf8strlcpy(), and SDL_wcslcpy().

315 {
316 #ifdef __GNUC__
317  /* Presumably this is well tuned for speed.
318  On my machine this is twice as fast as the C code below.
319  */
320  return __builtin_memcpy(dst, src, len);
321 #elif defined(HAVE_MEMCPY)
322  return memcpy(dst, src, len);
323 #elif defined(HAVE_BCOPY)
324  bcopy(src, dst, len);
325  return dst;
326 #else
327  /* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
328  using Uint32* pointers, so we need to make sure the pointers are
329  aligned before we loop using them.
330  */
331  if (((intptr_t)src & 0x3) || ((intptr_t)dst & 0x3)) {
332  /* Do an unaligned byte copy */
333  Uint8 *srcp1 = (Uint8 *)src;
334  Uint8 *dstp1 = (Uint8 *)dst;
335 
336  while (len--) {
337  *dstp1++ = *srcp1++;
338  }
339  } else {
340  size_t left = (len % 4);
341  Uint32 *srcp4, *dstp4;
342  Uint8 *srcp1, *dstp1;
343 
344  srcp4 = (Uint32 *) src;
345  dstp4 = (Uint32 *) dst;
346  len /= 4;
347  while (len--) {
348  *dstp4++ = *srcp4++;
349  }
350 
351  srcp1 = (Uint8 *) srcp4;
352  dstp1 = (Uint8 *) dstp4;
353  switch (left) {
354  case 3:
355  *dstp1++ = *srcp1++;
356  case 2:
357  *dstp1++ = *srcp1++;
358  case 1:
359  *dstp1++ = *srcp1++;
360  }
361  }
362  return dst;
363 #endif /* __GNUC__ */
364 }
GLenum GLenum dst
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
GLenum GLsizei len
GLint left
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
#define memcpy
Definition: SDL_malloc.c:640
GLenum src
SDL_FORCE_INLINE void* SDL_memcpy4 ( SDL_OUT_BYTECAP(dwords *4) void dst,
SDL_IN_BYTECAP(dwords *4) const void src,
size_t  dwords 
)

Definition at line 514 of file SDL_stdinc.h.

References SDL_memcpy().

515 {
516  return SDL_memcpy(dst, src, dwords * 4);
517 }
GLenum GLenum dst
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
GLenum src
void* SDL_memmove ( SDL_OUT_BYTECAP(len) void dst,
SDL_IN_BYTECAP(len) const void src,
size_t  len 
)

Definition at line 367 of file SDL_string.c.

References memmove.

Referenced by SDL_memset4().

368 {
369 #if defined(HAVE_MEMMOVE)
370  return memmove(dst, src, len);
371 #else
372  char *srcp = (char *) src;
373  char *dstp = (char *) dst;
374 
375  if (src < dst) {
376  srcp += len - 1;
377  dstp += len - 1;
378  while (len--) {
379  *dstp-- = *srcp--;
380  }
381  } else {
382  while (len--) {
383  *dstp++ = *srcp++;
384  }
385  }
386  return dst;
387 #endif /* HAVE_MEMMOVE */
388 }
GLenum GLenum dst
#define memmove
Definition: SDL_qsort.c:86
GLenum GLsizei len
GLenum src
void* SDL_memset ( SDL_OUT_BYTECAP(len) void dst,
int  c,
size_t  len 
)

Definition at line 270 of file SDL_string.c.

References memset.

271 {
272 #if defined(HAVE_MEMSET)
273  return memset(dst, c, len);
274 #else
275  size_t left;
276  Uint32 *dstp4;
277  Uint8 *dstp1 = (Uint8 *) dst;
278  Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24));
279  Uint8 value1 = (Uint8) c;
280 
281  /* The destination pointer needs to be aligned on a 4-byte boundary to
282  * execute a 32-bit set. Set first bytes manually if needed until it is
283  * aligned. */
284  while ((intptr_t)dstp1 & 0x3) {
285  if (len--) {
286  *dstp1++ = value1;
287  } else {
288  return dst;
289  }
290  }
291 
292  dstp4 = (Uint32 *) dstp1;
293  left = (len % 4);
294  len /= 4;
295  while (len--) {
296  *dstp4++ = value4;
297  }
298 
299  dstp1 = (Uint8 *) dstp4;
300  switch (left) {
301  case 3:
302  *dstp1++ = value1;
303  case 2:
304  *dstp1++ = value1;
305  case 1:
306  *dstp1++ = value1;
307  }
308 
309  return dst;
310 #endif /* HAVE_MEMSET */
311 }
GLenum GLenum dst
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
#define memset
Definition: SDL_malloc.c:639
GLenum GLsizei len
GLint left
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
const GLubyte * c
SDL_FORCE_INLINE void SDL_memset4 ( void dst,
Uint32  val,
size_t  dwords 
)

Definition at line 359 of file SDL_stdinc.h.

References DECLSPEC, SDL_acos(), SDL_asin(), SDL_atan(), SDL_atan2(), SDL_atof(), SDL_atoi(), SDL_ceil(), SDL_copysign(), SDL_cos(), SDL_cosf(), SDL_fabs(), SDL_floor(), SDL_IN_BYTECAP, SDL_INOUT_Z_CAP, SDL_itoa(), SDL_lltoa(), SDL_log(), SDL_ltoa(), SDL_memcmp(), SDL_memcpy(), SDL_memmove(), SDL_OUT_BYTECAP, SDL_OUT_Z_CAP, SDL_pow(), SDL_PRINTF_FORMAT_STRING, SDL_PRINTF_VARARG_FUNC, SDL_scalbn(), SDL_SCANF_FORMAT_STRING, SDL_SCANF_VARARG_FUNC, SDL_sin(), SDL_sinf(), SDL_snprintf(), SDL_sqrt(), SDL_sqrtf(), SDL_sscanf(), SDL_static_cast, SDL_strcasecmp(), SDL_strchr(), SDL_strcmp(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strlen(), SDL_strlwr(), SDL_strncasecmp(), SDL_strncmp(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtod(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_strupr(), SDL_tan(), SDL_tanf(), SDL_uitoa(), SDL_ulltoa(), SDL_ultoa(), SDL_utf8strlcpy(), SDL_vsnprintf(), SDL_vsscanf(), SDL_wcslcat(), SDL_wcslcpy(), SDL_wcslen(), SDLCALL, and text.

Referenced by SDL_FillRect1(), SDL_FillRect2(), and SDL_FillRect4().

360 {
361 #if defined(__GNUC__) && defined(i386)
362  int u0, u1, u2;
363  __asm__ __volatile__ (
364  "cld \n\t"
365  "rep ; stosl \n\t"
366  : "=&D" (u0), "=&a" (u1), "=&c" (u2)
367  : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
368  : "memory"
369  );
370 #else
371  size_t _n = (dwords + 3) / 4;
372  Uint32 *_p = SDL_static_cast(Uint32 *, dst);
373  Uint32 _val = (val);
374  if (dwords == 0)
375  return;
376  switch (dwords % 4)
377  {
378  case 0: do { *_p++ = _val;
379  case 3: *_p++ = _val;
380  case 2: *_p++ = _val;
381  case 1: *_p++ = _val;
382  } while ( --_n );
383  }
384 #endif
385 }
GLenum GLenum dst
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
GLfixed u1
GLfixed GLfixed u2
GLuint GLfloat * val
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:109
double SDL_pow ( double  x,
double  y 
)

Definition at line 168 of file SDL_stdlib.c.

References SDL_uclibc_pow().

Referenced by SDL_memset4().

169 {
170 #if defined(HAVE_POW)
171  return pow(x, y);
172 #else
173  return SDL_uclibc_pow(x, y);
174 #endif /* HAVE_POW */
175 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_pow(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
void SDL_qsort ( void base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compare 
)
void* SDL_realloc ( void mem,
size_t  size 
)
double SDL_scalbn ( double  x,
int  n 
)

Definition at line 178 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_memset4().

179 {
180 #if defined(HAVE_SCALBN)
181  return scalbn(x, n);
182 #elif defined(HAVE__SCALB)
183  return _scalb(x, n);
184 #else
185  return SDL_uclibc_scalbn(x, n);
186 #endif /* HAVE_SCALBN */
187 }
GLdouble n
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define scalbn
Definition: math_private.h:40
double SDL_uclibc_scalbn(double x, int n)
int SDL_setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Definition at line 108 of file SDL_getenv.c.

References i, NULL, SDL_free(), SDL_getenv(), SDL_malloc, SDL_realloc, SDL_snprintf, SDL_strchr, SDL_strlen, and SDL_strncmp.

Referenced by SDL_getenv().

109 {
110  int added;
111  int len, i;
112  char **new_env;
113  char *new_variable;
114 
115  /* Input validation */
116  if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
117  return (-1);
118  }
119 
120  /* See if it already exists */
121  if (!overwrite && SDL_getenv(name)) {
122  return 0;
123  }
124 
125  /* Allocate memory for the variable */
126  len = SDL_strlen(name) + SDL_strlen(value) + 2;
127  new_variable = (char *) SDL_malloc(len);
128  if (!new_variable) {
129  return (-1);
130  }
131 
132  SDL_snprintf(new_variable, len, "%s=%s", name, value);
133  value = new_variable + SDL_strlen(name) + 1;
134  name = new_variable;
135 
136  /* Actually put it into the environment */
137  added = 0;
138  i = 0;
139  if (SDL_env) {
140  /* Check to see if it's already there... */
141  len = (value - name);
142  for (; SDL_env[i]; ++i) {
143  if (SDL_strncmp(SDL_env[i], name, len) == 0) {
144  break;
145  }
146  }
147  /* If we found it, just replace the entry */
148  if (SDL_env[i]) {
149  SDL_free(SDL_env[i]);
150  SDL_env[i] = new_variable;
151  added = 1;
152  }
153  }
154 
155  /* Didn't find it in the environment, expand and add */
156  if (!added) {
157  new_env = SDL_realloc(SDL_env, (i + 2) * sizeof(char *));
158  if (new_env) {
159  SDL_env = new_env;
160  SDL_env[i++] = new_variable;
161  SDL_env[i++] = (char *) 0;
162  added = 1;
163  } else {
164  SDL_free(new_variable);
165  }
166  }
167  return (added ? 0 : -1);
168 }
char * SDL_getenv(const char *name)
Definition: SDL_getenv.c:212
GLuint const GLchar * name
#define SDL_realloc
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:106
GLenum GLsizei len
#define SDL_strchr
GLsizei const GLfloat * value
void SDL_free(void *mem)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
#define NULL
Definition: begin_code.h:143
#define SDL_strlen
#define SDL_snprintf
#define SDL_malloc
double SDL_sin ( double  x)

Definition at line 190 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin.

Referenced by SDL_memset4(), and SDL_sinf().

191 {
192 #if defined(HAVE_SIN)
193  return sin(x);
194 #else
195  return SDL_uclibc_sin(x);
196 #endif /* HAVE_SIN */
197 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_sin(double x)
#define sin
Definition: math_private.h:41
float SDL_sinf ( float  x)

Definition at line 200 of file SDL_stdlib.c.

References SDL_sin().

Referenced by SDL_memset4().

201 {
202 #ifdef HAVE_SINF
203  return sinf(x);
204 #else
205  return (float)SDL_sin((double)x);
206 #endif /* HAVE_SINF */
207 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_sin(double x)
Definition: SDL_stdlib.c:190
int SDL_snprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 1273 of file SDL_string.c.

References retval, SDL_OUT_Z_CAP, and SDL_vsnprintf().

Referenced by SDL_memset4().

1274 {
1275  va_list ap;
1276  int retval;
1277 
1278  va_start(ap, fmt);
1279  retval = SDL_vsnprintf(text, maxlen, fmt, ap);
1280  va_end(ap);
1281 
1282  return retval;
1283 }
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1478
SDL_bool retval
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
double SDL_sqrt ( double  x)

Definition at line 210 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

Referenced by SDL_acos(), SDL_memset4(), and SDL_sqrtf().

211 {
212 #if defined(HAVE_SQRT)
213  return sqrt(x);
214 #else
215  return SDL_uclibc_sqrt(x);
216 #endif
217 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_sqrt(double x)
float SDL_sqrtf ( float  x)

Definition at line 220 of file SDL_stdlib.c.

References SDL_sqrt().

Referenced by SDL_memset4().

221 {
222 #if defined(HAVE_SQRTF)
223  return sqrtf(x);
224 #else
225  return (float)SDL_sqrt((double)x);
226 #endif
227 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:210
int SDL_sscanf ( const char *  text,
SDL_SCANF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 992 of file SDL_string.c.

References SDL_vsscanf(), and text.

Referenced by SDL_memset4().

993 {
994  int rc;
995  va_list ap;
996  va_start(ap, fmt);
997  rc = SDL_vsscanf(text, fmt, ap);
998  va_end(ap);
999  return rc;
1000 }
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
Definition: SDL_string.c:1010
int SDL_strcasecmp ( const char *  str1,
const char *  str2 
)

Definition at line 939 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4().

940 {
941 #ifdef HAVE_STRCASECMP
942  return strcasecmp(str1, str2);
943 #elif defined(HAVE__STRICMP)
944  return _stricmp(str1, str2);
945 #else
946  char a = 0;
947  char b = 0;
948  while (*str1 && *str2) {
949  a = SDL_toupper((unsigned char) *str1);
950  b = SDL_toupper((unsigned char) *str2);
951  if (a != b)
952  break;
953  ++str1;
954  ++str2;
955  }
956  a = SDL_toupper(*str1);
957  b = SDL_toupper(*str2);
958  return (int) ((unsigned char) a - (unsigned char) b);
959 #endif /* HAVE_STRCASECMP */
960 }
#define SDL_toupper
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b
char* SDL_strchr ( const char *  str,
int  c 
)

Definition at line 596 of file SDL_string.c.

References NULL, and SDL_const_cast.

Referenced by SDL_memset4().

597 {
598 #ifdef HAVE_STRCHR
599  return SDL_const_cast(char*,strchr(string, c));
600 #elif defined(HAVE_INDEX)
601  return SDL_const_cast(char*,index(string, c));
602 #else
603  while (*string) {
604  if (*string == c) {
605  return (char *) string;
606  }
607  ++string;
608  }
609  return NULL;
610 #endif /* HAVE_STRCHR */
611 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:110
GLsizei const GLchar *const * string
const GLubyte * c
GLuint index
#define NULL
Definition: begin_code.h:143
int SDL_strcmp ( const char *  str1,
const char *  str2 
)

Definition at line 903 of file SDL_string.c.

Referenced by SDL_memset4().

904 {
905 #if defined(HAVE_STRCMP)
906  return strcmp(str1, str2);
907 #else
908  while (*str1 && *str2) {
909  if (*str1 != *str2)
910  break;
911  ++str1;
912  ++str2;
913  }
914  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
915 #endif /* HAVE_STRCMP */
916 }
char* SDL_strdup ( const char *  str)

Definition at line 532 of file SDL_string.c.

References SDL_malloc, SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

533 {
534 #if defined(HAVE_STRDUP)
535  return strdup(string);
536 #else
537  size_t len = SDL_strlen(string) + 1;
538  char *newstr = SDL_malloc(len);
539  if (newstr) {
540  SDL_strlcpy(newstr, string, len);
541  }
542  return newstr;
543 #endif /* HAVE_STRDUP */
544 }
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
#define SDL_malloc
size_t SDL_strlcat ( SDL_INOUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)

Definition at line 517 of file SDL_string.c.

References SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

518 {
519 #if defined(HAVE_STRLCAT)
520  return strlcat(dst, src, maxlen);
521 #else
522  size_t dstlen = SDL_strlen(dst);
523  size_t srclen = SDL_strlen(src);
524  if (dstlen < maxlen) {
525  SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
526  }
527  return dstlen + srclen;
528 #endif /* HAVE_STRLCAT */
529 }
GLenum GLenum dst
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLenum src
size_t SDL_strlcpy ( SDL_OUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)

Definition at line 469 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_strlen().

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), and SDL_strlcat().

470 {
471 #if defined(HAVE_STRLCPY)
472  return strlcpy(dst, src, maxlen);
473 #else
474  size_t srclen = SDL_strlen(src);
475  if (maxlen > 0) {
476  size_t len = SDL_min(srclen, maxlen - 1);
477  SDL_memcpy(dst, src, len);
478  dst[len] = '\0';
479  }
480  return srclen;
481 #endif /* HAVE_STRLCPY */
482 }
GLenum GLenum dst
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
GLenum src
size_t SDL_strlen ( const char *  str)

Definition at line 410 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), and SDL_utf8strlcpy().

411 {
412 #if defined(HAVE_STRLEN)
413  return strlen(string);
414 #else
415  size_t len = 0;
416  while (*string++) {
417  ++len;
418  }
419  return len;
420 #endif /* HAVE_STRLEN */
421 }
GLenum GLsizei len
char* SDL_strlwr ( char *  str)

Definition at line 581 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4(), and SDL_PrintString().

582 {
583 #if defined(HAVE__STRLWR)
584  return _strlwr(string);
585 #else
586  char *bufp = string;
587  while (*bufp) {
588  *bufp = SDL_tolower((unsigned char) *bufp);
589  ++bufp;
590  }
591  return string;
592 #endif /* HAVE__STRLWR */
593 }
GLsizei const GLchar *const * string
#define SDL_tolower
int SDL_strncasecmp ( const char *  str1,
const char *  str2,
size_t  len 
)

Definition at line 963 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4().

964 {
965 #ifdef HAVE_STRNCASECMP
966  return strncasecmp(str1, str2, maxlen);
967 #elif defined(HAVE__STRNICMP)
968  return _strnicmp(str1, str2, maxlen);
969 #else
970  char a = 0;
971  char b = 0;
972  while (*str1 && *str2 && maxlen) {
973  a = SDL_tolower((unsigned char) *str1);
974  b = SDL_tolower((unsigned char) *str2);
975  if (a != b)
976  break;
977  ++str1;
978  ++str2;
979  --maxlen;
980  }
981  if (maxlen == 0) {
982  return 0;
983  } else {
984  a = SDL_tolower((unsigned char) *str1);
985  b = SDL_tolower((unsigned char) *str2);
986  return (int) ((unsigned char) a - (unsigned char) b);
987  }
988 #endif /* HAVE_STRNCASECMP */
989 }
#define SDL_tolower
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b
int SDL_strncmp ( const char *  str1,
const char *  str2,
size_t  maxlen 
)

Definition at line 919 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_vsnprintf(), and SDL_vsscanf().

920 {
921 #if defined(HAVE_STRNCMP)
922  return strncmp(str1, str2, maxlen);
923 #else
924  while (*str1 && *str2 && maxlen) {
925  if (*str1 != *str2)
926  break;
927  ++str1;
928  ++str2;
929  --maxlen;
930  }
931  if (!maxlen) {
932  return 0;
933  }
934  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
935 #endif /* HAVE_STRNCMP */
936 }
char* SDL_strrchr ( const char *  str,
int  c 
)

Definition at line 614 of file SDL_string.c.

References NULL, SDL_const_cast, and SDL_strlen().

Referenced by SDL_memset4().

615 {
616 #ifdef HAVE_STRRCHR
617  return SDL_const_cast(char*,strrchr(string, c));
618 #elif defined(HAVE_RINDEX)
619  return SDL_const_cast(char*,rindex(string, c));
620 #else
621  const char *bufp = string + SDL_strlen(string) - 1;
622  while (bufp >= string) {
623  if (*bufp == c) {
624  return (char *) bufp;
625  }
626  --bufp;
627  }
628  return NULL;
629 #endif /* HAVE_STRRCHR */
630 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:110
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
const GLubyte * c
#define NULL
Definition: begin_code.h:143
char* SDL_strrev ( char *  str)

Definition at line 547 of file SDL_string.c.

References SDL_strlen().

Referenced by SDL_memset4(), SDL_ulltoa(), and SDL_ultoa().

548 {
549 #if defined(HAVE__STRREV)
550  return _strrev(string);
551 #else
552  size_t len = SDL_strlen(string);
553  char *a = &string[0];
554  char *b = &string[len - 1];
555  len /= 2;
556  while (len--) {
557  char c = *a;
558  *a++ = *b;
559  *b-- = c;
560  }
561  return string;
562 #endif /* HAVE__STRREV */
563 }
GLsizei const GLchar *const * string
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
const GLubyte * c
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b
char* SDL_strstr ( const char *  haystack,
const char *  needle 
)

Definition at line 633 of file SDL_string.c.

References NULL, SDL_const_cast, SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

634 {
635 #if defined(HAVE_STRSTR)
636  return SDL_const_cast(char*,strstr(haystack, needle));
637 #else
638  size_t length = SDL_strlen(needle);
639  while (*haystack) {
640  if (SDL_strncmp(haystack, needle, length) == 0) {
641  return (char *) haystack;
642  }
643  ++haystack;
644  }
645  return NULL;
646 #endif /* HAVE_STRSTR */
647 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:110
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
#define NULL
Definition: begin_code.h:143
GLuint GLsizei GLsizei * length
double SDL_strtod ( const char *  str,
char **  endp 
)

Definition at line 886 of file SDL_string.c.

References SDL_ScanFloat().

Referenced by SDL_atof(), and SDL_memset4().

887 {
888 #if defined(HAVE_STRTOD)
889  return strtod(string, endp);
890 #else
891  size_t len;
892  double value;
893 
894  len = SDL_ScanFloat(string, &value);
895  if (endp) {
896  *endp = (char *) string + len;
897  }
898  return value;
899 #endif /* HAVE_STRTOD */
900 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:235
GLenum GLsizei len
GLsizei const GLfloat * value
long SDL_strtol ( const char *  str,
char **  endp,
int  base 
)

Definition at line 786 of file SDL_string.c.

References SDL_ScanLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_atoi(), SDL_memset4(), and SDL_vsnprintf().

787 {
788 #if defined(HAVE_STRTOL)
789  return strtol(string, endp, base);
790 #else
791  size_t len;
792  long value;
793 
794  if (!base) {
795  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
796  base = 16;
797  } else {
798  base = 10;
799  }
800  }
801 
802  len = SDL_ScanLong(string, base, &value);
803  if (endp) {
804  *endp = (char *) string + len;
805  }
806  return value;
807 #endif /* HAVE_STRTOL */
808 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:57
GLsizei const GLfloat * value
Sint64 SDL_strtoll ( const char *  str,
char **  endp,
int  base 
)

Definition at line 836 of file SDL_string.c.

References SDL_ScanLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

837 {
838 #if defined(HAVE_STRTOLL)
839  return strtoll(string, endp, base);
840 #else
841  size_t len;
842  Sint64 value;
843 
844  if (!base) {
845  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
846  base = 16;
847  } else {
848  base = 10;
849  }
850  }
851 
852  len = SDL_ScanLongLong(string, base, &value);
853  if (endp) {
854  *endp = (char *) string + len;
855  }
856  return value;
857 #endif /* HAVE_STRTOLL */
858 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLsizei const GLfloat * value
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:162
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160
unsigned long SDL_strtoul ( const char *  str,
char **  endp,
int  base 
)

Definition at line 811 of file SDL_string.c.

References SDL_ScanUnsignedLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

812 {
813 #if defined(HAVE_STRTOUL)
814  return strtoul(string, endp, base);
815 #else
816  size_t len;
817  unsigned long value;
818 
819  if (!base) {
820  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
821  base = 16;
822  } else {
823  base = 10;
824  }
825  }
826 
827  len = SDL_ScanUnsignedLong(string, base, &value);
828  if (endp) {
829  *endp = (char *) string + len;
830  }
831  return value;
832 #endif /* HAVE_STRTOUL */
833 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98
Uint64 SDL_strtoull ( const char *  str,
char **  endp,
int  base 
)

Definition at line 861 of file SDL_string.c.

References SDL_ScanUnsignedLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

862 {
863 #if defined(HAVE_STRTOULL)
864  return strtoull(string, endp, base);
865 #else
866  size_t len;
867  Uint64 value;
868 
869  if (!base) {
870  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
871  base = 16;
872  } else {
873  base = 10;
874  }
875  }
876 
877  len = SDL_ScanUnsignedLongLong(string, base, &value);
878  if (endp) {
879  *endp = (char *) string + len;
880  }
881  return value;
882 #endif /* HAVE_STRTOULL */
883 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:203
char* SDL_strupr ( char *  str)

Definition at line 566 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4(), and SDL_PrintString().

567 {
568 #if defined(HAVE__STRUPR)
569  return _strupr(string);
570 #else
571  char *bufp = string;
572  while (*bufp) {
573  *bufp = SDL_toupper((unsigned char) *bufp);
574  ++bufp;
575  }
576  return string;
577 #endif /* HAVE__STRUPR */
578 }
GLsizei const GLchar *const * string
#define SDL_toupper
double SDL_tan ( double  x)

Definition at line 230 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_memset4(), and SDL_tanf().

231 {
232 #if defined(HAVE_TAN)
233  return tan(x);
234 #else
235  return SDL_uclibc_tan(x);
236 #endif
237 }
double tan(double x)
Definition: s_tan.c:45
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_uclibc_tan(double x)
float SDL_tanf ( float  x)

Definition at line 240 of file SDL_stdlib.c.

References SDL_tan().

Referenced by SDL_memset4().

241 {
242 #if defined(HAVE_TANF)
243  return tanf(x);
244 #else
245  return (float)SDL_tan((double)x);
246 #endif
247 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
double SDL_tan(double x)
Definition: SDL_stdlib.c:230
int SDL_tolower ( int  x)

Definition at line 267 of file SDL_stdlib.c.

References i, L1, L2, L3, L4, L5, L6, memcpy, and pop.

Referenced by SDL_abs().

267 { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
int SDL_toupper ( int  x)

Definition at line 266 of file SDL_stdlib.c.

Referenced by SDL_abs().

266 { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
char* SDL_uitoa ( unsigned int  value,
char *  str,
int  radix 
)

Definition at line 670 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_memset4().

671 {
672 #ifdef HAVE__UITOA
673  return _uitoa(value, string, radix);
674 #else
675  return SDL_ultoa((unsigned long)value, string, radix);
676 #endif /* HAVE__UITOA */
677 }
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699
char* SDL_ulltoa ( Uint64  value,
char *  str,
int  radix 
)

Definition at line 743 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_lltoa(), SDL_memset4(), and SDL_PrintUnsignedLongLong().

744 {
745 #if defined(HAVE__UI64TOA)
746  return _ui64toa(value, string, radix);
747 #else
748  char *bufp = string;
749 
750  if (value) {
751  while (value > 0) {
752  *bufp++ = ntoa_table[value % radix];
753  value /= radix;
754  }
755  } else {
756  *bufp++ = '0';
757  }
758  *bufp = '\0';
759 
760  /* The numbers went into the string backwards. :) */
761  SDL_strrev(string);
762 
763  return string;
764 #endif /* HAVE__UI64TOA */
765 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:651
char * SDL_strrev(char *string)
Definition: SDL_string.c:547
GLsizei const GLfloat * value
char* SDL_ultoa ( unsigned long  value,
char *  str,
int  radix 
)

Definition at line 699 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_ltoa(), SDL_memset4(), SDL_PrintUnsignedLong(), and SDL_uitoa().

700 {
701 #if defined(HAVE__ULTOA)
702  return _ultoa(value, string, radix);
703 #else
704  char *bufp = string;
705 
706  if (value) {
707  while (value > 0) {
708  *bufp++ = ntoa_table[value % radix];
709  value /= radix;
710  }
711  } else {
712  *bufp++ = '0';
713  }
714  *bufp = '\0';
715 
716  /* The numbers went into the string backwards. :) */
717  SDL_strrev(string);
718 
719  return string;
720 #endif /* HAVE__ULTOA */
721 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:651
char * SDL_strrev(char *string)
Definition: SDL_string.c:547
GLsizei const GLfloat * value
size_t SDL_utf8strlcpy ( SDL_OUT_Z_CAP(dst_bytes) char *  dst,
const char *  src,
size_t  dst_bytes 
)

Definition at line 484 of file SDL_string.c.

References i, SDL_memcpy(), SDL_min, SDL_strlen(), UTF8_IsLeadByte, UTF8_IsTrailingByte, and UTF8_TrailingBytes().

Referenced by SDL_memset4().

485 {
486  size_t src_bytes = SDL_strlen(src);
487  size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
488  size_t i = 0;
489  char trailing_bytes = 0;
490  if (bytes)
491  {
492  unsigned char c = (unsigned char)src[bytes - 1];
493  if (UTF8_IsLeadByte(c))
494  --bytes;
495  else if (UTF8_IsTrailingByte(c))
496  {
497  for (i = bytes - 1; i != 0; --i)
498  {
499  c = (unsigned char)src[i];
500  trailing_bytes = UTF8_TrailingBytes(c);
501  if (trailing_bytes)
502  {
503  if (bytes - i != trailing_bytes + 1)
504  bytes = i;
505 
506  break;
507  }
508  }
509  }
510  SDL_memcpy(dst, src, bytes);
511  }
512  dst[bytes] = '\0';
513  return bytes;
514 }
GLenum GLenum dst
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:40
const GLubyte * c
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:43
GLenum src
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:41
int SDL_vsnprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
const char *  fmt,
va_list  ap 
)

Definition at line 1478 of file SDL_string.c.

References done, SDL_FormatInfo::force_case, SDL_FormatInfo::force_sign, SDL_FormatInfo::force_type, SDL_FormatInfo::left_justify, SDL_FormatInfo::pad_zeroes, SDL_FormatInfo::precision, SDL_FormatInfo::radix, SDL_CASE_LOWER, SDL_CASE_NOCHANGE, SDL_CASE_UPPER, SDL_FALSE, SDL_min, SDL_PrintFloat(), SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintString(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), SDL_strncmp(), SDL_strtol(), SDL_TRUE, SDL_zero, text, and SDL_FormatInfo::width.

Referenced by SDL_memset4(), and SDL_snprintf().

1479 {
1480  size_t left = maxlen;
1481  char *textstart = text;
1482 
1483  if (!fmt) {
1484  fmt = "";
1485  }
1486  while (*fmt) {
1487  if (*fmt == '%') {
1489  size_t len = 0;
1490  SDL_bool check_flag;
1491  SDL_FormatInfo info;
1492  enum
1493  {
1494  DO_INT,
1495  DO_LONG,
1496  DO_LONGLONG
1497  } inttype = DO_INT;
1498 
1499  SDL_zero(info);
1500  info.radix = 10;
1501  info.precision = -1;
1502 
1503  check_flag = SDL_TRUE;
1504  while (check_flag) {
1505  ++fmt;
1506  switch (*fmt) {
1507  case '-':
1508  info.left_justify = SDL_TRUE;
1509  break;
1510  case '+':
1511  info.force_sign = SDL_TRUE;
1512  break;
1513  case '#':
1514  info.force_type = SDL_TRUE;
1515  break;
1516  case '0':
1517  info.pad_zeroes = SDL_TRUE;
1518  break;
1519  default:
1520  check_flag = SDL_FALSE;
1521  break;
1522  }
1523  }
1524 
1525  if (*fmt >= '0' && *fmt <= '9') {
1526  info.width = SDL_strtol(fmt, (char **)&fmt, 0);
1527  }
1528 
1529  if (*fmt == '.') {
1530  ++fmt;
1531  if (*fmt >= '0' && *fmt <= '9') {
1532  info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
1533  } else {
1534  info.precision = 0;
1535  }
1536  }
1537 
1538  while (!done) {
1539  switch (*fmt) {
1540  case '%':
1541  if (left > 1) {
1542  *text = '%';
1543  }
1544  len = 1;
1545  done = SDL_TRUE;
1546  break;
1547  case 'c':
1548  /* char is promoted to int when passed through (...) */
1549  if (left > 1) {
1550  *text = (char) va_arg(ap, int);
1551  }
1552  len = 1;
1553  done = SDL_TRUE;
1554  break;
1555  case 'h':
1556  /* short is promoted to int when passed through (...) */
1557  break;
1558  case 'l':
1559  if (inttype < DO_LONGLONG) {
1560  ++inttype;
1561  }
1562  break;
1563  case 'I':
1564  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1565  fmt += 2;
1566  inttype = DO_LONGLONG;
1567  }
1568  break;
1569  case 'i':
1570  case 'd':
1571  switch (inttype) {
1572  case DO_INT:
1573  len = SDL_PrintLong(text, left, &info,
1574  (long) va_arg(ap, int));
1575  break;
1576  case DO_LONG:
1577  len = SDL_PrintLong(text, left, &info,
1578  va_arg(ap, long));
1579  break;
1580  case DO_LONGLONG:
1581  len = SDL_PrintLongLong(text, left, &info,
1582  va_arg(ap, Sint64));
1583  break;
1584  }
1585  done = SDL_TRUE;
1586  break;
1587  case 'p':
1588  case 'x':
1589  info.force_case = SDL_CASE_LOWER;
1590  /* Fall through to 'X' handling */
1591  case 'X':
1592  if (info.force_case == SDL_CASE_NOCHANGE) {
1593  info.force_case = SDL_CASE_UPPER;
1594  }
1595  if (info.radix == 10) {
1596  info.radix = 16;
1597  }
1598  if (*fmt == 'p') {
1599  inttype = DO_LONG;
1600  }
1601  /* Fall through to unsigned handling */
1602  case 'o':
1603  if (info.radix == 10) {
1604  info.radix = 8;
1605  }
1606  /* Fall through to unsigned handling */
1607  case 'u':
1608  info.pad_zeroes = SDL_TRUE;
1609  switch (inttype) {
1610  case DO_INT:
1611  len = SDL_PrintUnsignedLong(text, left, &info,
1612  (unsigned long)
1613  va_arg(ap, unsigned int));
1614  break;
1615  case DO_LONG:
1616  len = SDL_PrintUnsignedLong(text, left, &info,
1617  va_arg(ap, unsigned long));
1618  break;
1619  case DO_LONGLONG:
1620  len = SDL_PrintUnsignedLongLong(text, left, &info,
1621  va_arg(ap, Uint64));
1622  break;
1623  }
1624  done = SDL_TRUE;
1625  break;
1626  case 'f':
1627  len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
1628  done = SDL_TRUE;
1629  break;
1630  case 's':
1631  len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
1632  done = SDL_TRUE;
1633  break;
1634  default:
1635  done = SDL_TRUE;
1636  break;
1637  }
1638  ++fmt;
1639  }
1640  text += len;
1641  if (len >= left) {
1642  left = SDL_min(left, 1);
1643  } else {
1644  left -= len;
1645  }
1646  } else {
1647  if (left > 1) {
1648  *text = *fmt;
1649  --left;
1650  }
1651  ++fmt;
1652  ++text;
1653  }
1654  }
1655  if (left > 0) {
1656  *text = '\0';
1657  }
1658  return (int)(text - textstart);
1659 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
SDL_bool left_justify
Definition: SDL_string.c:1304
SDL_bool pad_zeroes
Definition: SDL_string.c:1307
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_bool force_type
Definition: SDL_string.c:1306
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
GLenum GLsizei len
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:786
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1360
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1342
SDL_bool
Definition: SDL_stdinc.h:126
SDL_bool force_sign
Definition: SDL_string.c:1305
GLint left
int done
Definition: checkkeys.c:28
#define SDL_zero(x)
Definition: SDL_stdinc.h:355
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_letter_case force_case
Definition: SDL_string.c:1308
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1369
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1351
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1378
int SDL_vsscanf ( const char *  text,
const char *  fmt,
va_list  ap 
)

Definition at line 1010 of file SDL_string.c.

References done, retval, SDL_FALSE, SDL_isspace, SDL_ScanFloat(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strncmp(), SDL_tolower, SDL_TRUE, and text.

Referenced by SDL_memset4(), and SDL_sscanf().

1011 {
1012  int retval = 0;
1013 
1014  while (*fmt) {
1015  if (*fmt == ' ') {
1016  while (SDL_isspace((unsigned char) *text)) {
1017  ++text;
1018  }
1019  ++fmt;
1020  continue;
1021  }
1022  if (*fmt == '%') {
1024  long count = 0;
1025  int radix = 10;
1026  enum
1027  {
1028  DO_SHORT,
1029  DO_INT,
1030  DO_LONG,
1031  DO_LONGLONG
1032  } inttype = DO_INT;
1033  SDL_bool suppress = SDL_FALSE;
1034 
1035  ++fmt;
1036  if (*fmt == '%') {
1037  if (*text == '%') {
1038  ++text;
1039  ++fmt;
1040  continue;
1041  }
1042  break;
1043  }
1044  if (*fmt == '*') {
1045  suppress = SDL_TRUE;
1046  ++fmt;
1047  }
1048  fmt += SDL_ScanLong(fmt, 10, &count);
1049 
1050  if (*fmt == 'c') {
1051  if (!count) {
1052  count = 1;
1053  }
1054  if (suppress) {
1055  while (count--) {
1056  ++text;
1057  }
1058  } else {
1059  char *valuep = va_arg(ap, char *);
1060  while (count--) {
1061  *valuep++ = *text++;
1062  }
1063  ++retval;
1064  }
1065  continue;
1066  }
1067 
1068  while (SDL_isspace((unsigned char) *text)) {
1069  ++text;
1070  }
1071 
1072  /* FIXME: implement more of the format specifiers */
1073  while (!done) {
1074  switch (*fmt) {
1075  case '*':
1076  suppress = SDL_TRUE;
1077  break;
1078  case 'h':
1079  if (inttype > DO_SHORT) {
1080  ++inttype;
1081  }
1082  break;
1083  case 'l':
1084  if (inttype < DO_LONGLONG) {
1085  ++inttype;
1086  }
1087  break;
1088  case 'I':
1089  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1090  fmt += 2;
1091  inttype = DO_LONGLONG;
1092  }
1093  break;
1094  case 'i':
1095  {
1096  int index = 0;
1097  if (text[index] == '-') {
1098  ++index;
1099  }
1100  if (text[index] == '0') {
1101  if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
1102  radix = 16;
1103  } else {
1104  radix = 8;
1105  }
1106  }
1107  }
1108  /* Fall through to %d handling */
1109  case 'd':
1110  if (inttype == DO_LONGLONG) {
1111  Sint64 value;
1112  text += SDL_ScanLongLong(text, radix, &value);
1113  if (!suppress) {
1114  Sint64 *valuep = va_arg(ap, Sint64 *);
1115  *valuep = value;
1116  ++retval;
1117  }
1118  } else {
1119  long value;
1120  text += SDL_ScanLong(text, radix, &value);
1121  if (!suppress) {
1122  switch (inttype) {
1123  case DO_SHORT:
1124  {
1125  short *valuep = va_arg(ap, short *);
1126  *valuep = (short) value;
1127  }
1128  break;
1129  case DO_INT:
1130  {
1131  int *valuep = va_arg(ap, int *);
1132  *valuep = (int) value;
1133  }
1134  break;
1135  case DO_LONG:
1136  {
1137  long *valuep = va_arg(ap, long *);
1138  *valuep = value;
1139  }
1140  break;
1141  case DO_LONGLONG:
1142  /* Handled above */
1143  break;
1144  }
1145  ++retval;
1146  }
1147  }
1148  done = SDL_TRUE;
1149  break;
1150  case 'o':
1151  if (radix == 10) {
1152  radix = 8;
1153  }
1154  /* Fall through to unsigned handling */
1155  case 'x':
1156  case 'X':
1157  if (radix == 10) {
1158  radix = 16;
1159  }
1160  /* Fall through to unsigned handling */
1161  case 'u':
1162  if (inttype == DO_LONGLONG) {
1163  Uint64 value;
1164  text += SDL_ScanUnsignedLongLong(text, radix, &value);
1165  if (!suppress) {
1166  Uint64 *valuep = va_arg(ap, Uint64 *);
1167  *valuep = value;
1168  ++retval;
1169  }
1170  } else {
1171  unsigned long value;
1172  text += SDL_ScanUnsignedLong(text, radix, &value);
1173  if (!suppress) {
1174  switch (inttype) {
1175  case DO_SHORT:
1176  {
1177  short *valuep = va_arg(ap, short *);
1178  *valuep = (short) value;
1179  }
1180  break;
1181  case DO_INT:
1182  {
1183  int *valuep = va_arg(ap, int *);
1184  *valuep = (int) value;
1185  }
1186  break;
1187  case DO_LONG:
1188  {
1189  long *valuep = va_arg(ap, long *);
1190  *valuep = value;
1191  }
1192  break;
1193  case DO_LONGLONG:
1194  /* Handled above */
1195  break;
1196  }
1197  ++retval;
1198  }
1199  }
1200  done = SDL_TRUE;
1201  break;
1202  case 'p':
1203  {
1204  uintptr_t value;
1205  text += SDL_ScanUintPtrT(text, 16, &value);
1206  if (!suppress) {
1207  void **valuep = va_arg(ap, void **);
1208  *valuep = (void *) value;
1209  ++retval;
1210  }
1211  }
1212  done = SDL_TRUE;
1213  break;
1214  case 'f':
1215  {
1216  double value;
1217  text += SDL_ScanFloat(text, &value);
1218  if (!suppress) {
1219  float *valuep = va_arg(ap, float *);
1220  *valuep = (float) value;
1221  ++retval;
1222  }
1223  }
1224  done = SDL_TRUE;
1225  break;
1226  case 's':
1227  if (suppress) {
1228  while (!SDL_isspace((unsigned char) *text)) {
1229  ++text;
1230  if (count) {
1231  if (--count == 0) {
1232  break;
1233  }
1234  }
1235  }
1236  } else {
1237  char *valuep = va_arg(ap, char *);
1238  while (!SDL_isspace((unsigned char) *text)) {
1239  *valuep++ = *text++;
1240  if (count) {
1241  if (--count == 0) {
1242  break;
1243  }
1244  }
1245  }
1246  *valuep = '\0';
1247  ++retval;
1248  }
1249  done = SDL_TRUE;
1250  break;
1251  default:
1252  done = SDL_TRUE;
1253  break;
1254  }
1255  ++fmt;
1256  }
1257  continue;
1258  }
1259  if (*text == *fmt) {
1260  ++text;
1261  ++fmt;
1262  continue;
1263  }
1264  /* Text didn't match format specifier */
1265  break;
1266  }
1267 
1268  return retval;
1269 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:235
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
#define SDL_tolower
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:130
SDL_bool
Definition: SDL_stdinc.h:126
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:57
SDL_bool retval
GLsizei const GLfloat * value
int done
Definition: checkkeys.c:28
unsigned int uintptr_t
#define SDL_isspace
GLuint index
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:162
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:203
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98
size_t SDL_wcslcat ( SDL_INOUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)

Definition at line 454 of file SDL_string.c.

References SDL_wcslcpy(), and SDL_wcslen().

Referenced by SDL_memset4().

455 {
456 #if defined(HAVE_WCSLCAT)
457  return wcslcat(dst, src, maxlen);
458 #else
459  size_t dstlen = SDL_wcslen(dst);
460  size_t srclen = SDL_wcslen(src);
461  if (dstlen < maxlen) {
462  SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
463  }
464  return dstlen + srclen;
465 #endif /* HAVE_WCSLCAT */
466 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:424
GLenum GLenum dst
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:438
GLenum src
size_t SDL_wcslcpy ( SDL_OUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)

Definition at line 438 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_wcslen().

Referenced by SDL_memset4(), and SDL_wcslcat().

439 {
440 #if defined(HAVE_WCSLCPY)
441  return wcslcpy(dst, src, maxlen);
442 #else
443  size_t srclen = SDL_wcslen(src);
444  if (maxlen > 0) {
445  size_t len = SDL_min(srclen, maxlen - 1);
446  SDL_memcpy(dst, src, len * sizeof(wchar_t));
447  dst[len] = '\0';
448  }
449  return srclen;
450 #endif /* HAVE_WCSLCPY */
451 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:424
GLenum GLenum dst
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
GLenum GLsizei len
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
GLenum src
size_t SDL_wcslen ( const wchar_t *  wstr)

Definition at line 424 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_wcslcat(), and SDL_wcslcpy().

425 {
426 #if defined(HAVE_WCSLEN)
427  return wcslen(string);
428 #else
429  size_t len = 0;
430  while (*string++) {
431  ++len;
432  }
433  return len;
434 #endif /* HAVE_WCSLEN */
435 }
GLenum GLsizei len