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 <wchar.h>
#include <inttypes.h>
#include <ctype.h>
#include <math.h>
#include <float.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_STRINGIFY_ARG(arg)   #arg
 
#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_compile_time_assert_ ## 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)
 
int SDL_wcscmp (const wchar_t *str1, const wchar_t *str2)
 
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)
 
size_t SDL_utf8strlen (const char *str)
 
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

#define SDL_MAX_SINT8   ((Sint8)0x7F) /* 127 */
 A signed 8-bit integer type. More...
 
#define SDL_MIN_SINT8   ((Sint8)(~0x7F)) /* -128 */
 
#define SDL_MAX_UINT8   ((Uint8)0xFF) /* 255 */
 An unsigned 8-bit integer type. More...
 
#define SDL_MIN_UINT8   ((Uint8)0x00) /* 0 */
 
#define SDL_MAX_SINT16   ((Sint16)0x7FFF) /* 32767 */
 A signed 16-bit integer type. More...
 
#define SDL_MIN_SINT16   ((Sint16)(~0x7FFF)) /* -32768 */
 
#define SDL_MAX_UINT16   ((Uint16)0xFFFF) /* 65535 */
 An unsigned 16-bit integer type. More...
 
#define SDL_MIN_UINT16   ((Uint16)0x0000) /* 0 */
 
#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */
 A signed 32-bit integer type. More...
 
#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
 
#define SDL_MAX_UINT32   ((Uint32)0xFFFFFFFFu) /* 4294967295 */
 An unsigned 32-bit integer type. More...
 
#define SDL_MIN_UINT32   ((Uint32)0x00000000) /* 0 */
 
#define SDL_MAX_SINT64   ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
 A signed 64-bit integer type. More...
 
#define SDL_MIN_SINT64   ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
 
#define SDL_MAX_UINT64   ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
 An unsigned 64-bit integer type. More...
 
#define SDL_MIN_UINT64   ((Uint64)(0x0000000000000000ull)) /* 0 */
 
enum  SDL_bool {
  SDL_FALSE = 0,
  SDL_TRUE = 1
}
 
typedef int8_t Sint8
 
typedef uint8_t Uint8
 
typedef int16_t Sint16
 
typedef uint16_t Uint16
 
typedef int32_t Sint32
 
typedef uint32_t Uint32
 
typedef int64_t Sint64
 
typedef uint64_t Uint64
 

Detailed Description

This is a general header that includes C language support.

Definition in file SDL_stdinc.h.

Macro Definition Documentation

◆ SDL_arraysize

◆ SDL_COMPILE_TIME_ASSERT

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

Definition at line 290 of file SDL_stdinc.h.

Referenced by SDL_AtomicTryLock(), and TestTypes().

◆ SDL_const_cast

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

Definition at line 117 of file SDL_stdinc.h.

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

◆ SDL_FOURCC

#define SDL_FOURCC (   A,
  B,
  C,
 
)
Value:
uint32_t Uint32
Definition: SDL_stdinc.h:181
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:116

Definition at line 122 of file SDL_stdinc.h.

◆ SDL_ICONV_E2BIG

#define SDL_ICONV_E2BIG   (size_t)-2

Definition at line 494 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

◆ SDL_ICONV_EILSEQ

#define SDL_ICONV_EILSEQ   (size_t)-3

Definition at line 495 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

◆ SDL_ICONV_EINVAL

#define SDL_ICONV_EINVAL   (size_t)-4

Definition at line 496 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

◆ SDL_ICONV_ERROR

#define SDL_ICONV_ERROR   (size_t)-1

Definition at line 493 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

◆ SDL_iconv_utf8_locale

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

Definition at line 514 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs2

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

Definition at line 515 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs4

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

Definition at line 516 of file SDL_stdinc.h.

◆ SDL_IN_BYTECAP

#define SDL_IN_BYTECAP (   x)

Definition at line 272 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_INOUT_Z_CAP

#define SDL_INOUT_Z_CAP (   x)

Definition at line 273 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_max

◆ SDL_MAX_SINT16

#define SDL_MAX_SINT16   ((Sint16)0x7FFF) /* 32767 */

A signed 16-bit integer type.

Definition at line 161 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_SINT32

#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */

A signed 32-bit integer type.

Definition at line 173 of file SDL_stdinc.h.

Referenced by SDL_CreateRGBSurfaceWithFormat(), and TestTypes().

◆ SDL_MAX_SINT64

#define SDL_MAX_SINT64   ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */

A signed 64-bit integer type.

Definition at line 186 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_SINT8

#define SDL_MAX_SINT8   ((Sint8)0x7F) /* 127 */

A signed 8-bit integer type.

Definition at line 149 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT16

#define SDL_MAX_UINT16   ((Uint16)0xFFFF) /* 65535 */

An unsigned 16-bit integer type.

Definition at line 167 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT32

#define SDL_MAX_UINT32   ((Uint32)0xFFFFFFFFu) /* 4294967295 */

An unsigned 32-bit integer type.

Definition at line 179 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT64

#define SDL_MAX_UINT64   ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */

An unsigned 64-bit integer type.

Definition at line 192 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT8

#define SDL_MAX_UINT8   ((Uint8)0xFF) /* 255 */

An unsigned 8-bit integer type.

Definition at line 155 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_min

◆ SDL_MIN_SINT16

#define SDL_MIN_SINT16   ((Sint16)(~0x7FFF)) /* -32768 */

Definition at line 162 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_SINT32

#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */

Definition at line 174 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_SINT64

#define SDL_MIN_SINT64   ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */

Definition at line 187 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_SINT8

#define SDL_MIN_SINT8   ((Sint8)(~0x7F)) /* -128 */

Definition at line 150 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT16

#define SDL_MIN_UINT16   ((Uint16)0x0000) /* 0 */

Definition at line 168 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT32

#define SDL_MIN_UINT32   ((Uint32)0x00000000) /* 0 */

Definition at line 180 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT64

#define SDL_MIN_UINT64   ((Uint64)(0x0000000000000000ull)) /* 0 */

Definition at line 193 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT8

#define SDL_MIN_UINT8   ((Uint8)0x00) /* 0 */

Definition at line 156 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_OUT_BYTECAP

#define SDL_OUT_BYTECAP (   x)

Definition at line 276 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_OUT_CAP

#define SDL_OUT_CAP (   x)

Definition at line 275 of file SDL_stdinc.h.

◆ SDL_OUT_Z_BYTECAP

#define SDL_OUT_Z_BYTECAP (   x)

Definition at line 277 of file SDL_stdinc.h.

◆ SDL_OUT_Z_CAP

#define SDL_OUT_Z_CAP (   x)

Definition at line 274 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRINTF_FORMAT_STRING

#define SDL_PRINTF_FORMAT_STRING

Definition at line 278 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRINTF_VARARG_FUNC

#define SDL_PRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 285 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRIs64

◆ SDL_PRIu64

◆ SDL_PRIx64

#define SDL_PRIx64   "I64x"

Definition at line 227 of file SDL_stdinc.h.

◆ SDL_PRIX64

#define SDL_PRIX64   "I64X"

Definition at line 238 of file SDL_stdinc.h.

Referenced by platform_testEndianessAndSwap(), and TestEndian().

◆ SDL_reinterpret_cast

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

Definition at line 115 of file SDL_stdinc.h.

◆ SDL_SCANF_FORMAT_STRING

#define SDL_SCANF_FORMAT_STRING

Definition at line 279 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_SCANF_VARARG_FUNC

#define SDL_SCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 286 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_stack_alloc

◆ SDL_stack_free

◆ SDL_static_cast

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

Definition at line 116 of file SDL_stdinc.h.

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

◆ SDL_STRINGIFY_ARG

#define SDL_STRINGIFY_ARG (   arg)    #arg

Macro useful for building other macros with strings in them

e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(FUNCTION) ": " X "\n")

Definition at line 101 of file SDL_stdinc.h.

◆ SDL_TABLESIZE

#define SDL_TABLESIZE (   table)    SDL_arraysize(table)

Definition at line 94 of file SDL_stdinc.h.

Referenced by handleKeyboardEvent().

◆ SDL_zero

◆ SDL_zerop

Typedef Documentation

◆ Sint16

typedef int16_t Sint16

Definition at line 163 of file SDL_stdinc.h.

◆ Sint32

typedef int32_t Sint32

Definition at line 175 of file SDL_stdinc.h.

◆ Sint64

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

Definition at line 188 of file SDL_stdinc.h.

◆ Sint8

typedef int8_t Sint8

Definition at line 151 of file SDL_stdinc.h.

◆ Uint16

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

Definition at line 169 of file SDL_stdinc.h.

◆ Uint32

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(*) e 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 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32

Definition at line 181 of file SDL_stdinc.h.

◆ Uint64

typedef uint64_t Uint64

Definition at line 194 of file SDL_stdinc.h.

◆ Uint8

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

Definition at line 157 of file SDL_stdinc.h.

Enumeration Type Documentation

◆ SDL_bool

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(*) 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 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 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32 return const char SDL_bool
Enumerator
SDL_FALSE 
SDL_TRUE 

Definition at line 139 of file SDL_stdinc.h.

140 {
141  SDL_FALSE = 0,
142  SDL_TRUE = 1
143 } SDL_bool;
SDL_bool
Definition: SDL_stdinc.h:139

Function Documentation

◆ SDL_abs()

int SDL_abs ( int  x)

Definition at line 259 of file SDL_stdlib.c.

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

260 {
261 #if defined(HAVE_ABS)
262  return abs(x);
263 #else
264  return ((x) < 0 ? -(x) : (x));
265 #endif
266 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_acos()

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:220
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val

◆ SDL_asin()

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

◆ SDL_atan()

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 #if defined(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:1574
double SDL_uclibc_atan(double x)
double atan(double x)
Definition: s_atan.c:67

◆ SDL_atan2()

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:1574
double SDL_uclibc_atan2(double y, double x)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_atof()

double SDL_atof ( const char *  str)

Definition at line 806 of file SDL_string.c.

References NULL, and SDL_strtod().

Referenced by SDL_memset4().

807 {
808 #ifdef HAVE_ATOF
809  return (double) atof(string);
810 #else
811  return SDL_strtod(string, NULL);
812 #endif /* HAVE_ATOF */
813 }
double SDL_strtod(const char *string, char **endp)
Definition: SDL_string.c:916
#define NULL
Definition: begin_code.h:164

◆ SDL_atoi()

int SDL_atoi ( const char *  str)

Definition at line 797 of file SDL_string.c.

References NULL, and SDL_strtol().

Referenced by SDL_memset4().

798 {
799 #ifdef HAVE_ATOI
800  return atoi(string);
801 #else
802  return SDL_strtol(string, NULL, 0);
803 #endif /* HAVE_ATOI */
804 }
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:816
#define NULL
Definition: begin_code.h:164

◆ SDL_calloc()

◆ SDL_ceil()

double SDL_ceil ( double  x)

Definition at line 91 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_memset4().

92 {
93 #if defined(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:1574
double SDL_floor(double x)
Definition: SDL_stdlib.c:154

◆ SDL_copysign()

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 #elif defined(__WATCOMC__) && defined(__386__)
113  /* this is nasty as hell, but it works.. */
114  unsigned int *xi = (unsigned int *) &x,
115  *yi = (unsigned int *) &y;
116  xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
117  return x;
118 #else
119  return SDL_uclibc_copysign(x, y);
120 #endif /* HAVE_COPYSIGN */
121 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_copysign(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
#define copysign
Definition: math_private.h:34

◆ SDL_cos()

double SDL_cos ( double  x)

Definition at line 124 of file SDL_stdlib.c.

References cos, and SDL_uclibc_cos().

Referenced by SDL_cosf(), and SDL_memset4().

125 {
126 #if defined(HAVE_COS)
127  return cos(x);
128 #else
129  return SDL_uclibc_cos(x);
130 #endif /* HAVE_COS */
131 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define cos
Definition: math_private.h:35
double SDL_uclibc_cos(double x)

◆ SDL_cosf()

float SDL_cosf ( float  x)

Definition at line 134 of file SDL_stdlib.c.

References SDL_cos().

Referenced by SDL_memset4().

135 {
136 #if defined(HAVE_COSF)
137  return cosf(x);
138 #else
139  return (float)SDL_cos((double)x);
140 #endif
141 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:124
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_fabs()

double SDL_fabs ( double  x)

Definition at line 144 of file SDL_stdlib.c.

References fabs, and SDL_uclibc_fabs().

Referenced by SDL_memset4().

145 {
146 #if defined(HAVE_FABS)
147  return fabs(x);
148 #else
149  return SDL_uclibc_fabs(x);
150 #endif /* HAVE_FABS */
151 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_fabs(double x)
#define fabs
Definition: math_private.h:36

◆ SDL_floor()

double SDL_floor ( double  x)

Definition at line 154 of file SDL_stdlib.c.

References floor, and SDL_uclibc_floor().

Referenced by SDL_ceil(), and SDL_memset4().

155 {
156 #if defined(HAVE_FLOOR)
157  return floor(x);
158 #else
159  return SDL_uclibc_floor(x);
160 #endif /* HAVE_FLOOR */
161 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_floor(double x)
#define floor
Definition: math_private.h:37

◆ SDL_free()

void SDL_free ( void mem)

Referenced by _compare(), audio_convertAudio(), clean_out_device_list(), clipboard_testClipboardTextFunctions(), clipboard_testGetClipboardText(), clipboard_testSetClipboardText(), close_audio_device(), createCommandBuffers(), createFences(), createInstance(), createWindow(), deleteDevice(), destroyCommandBuffers(), destroyFences(), destroySwapchain(), findPhysicalDevice(), free_device_list(), getSurfaceFormats(), getSwapchainImages(), 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_CleanupAudioStreamResampler(), SDL_ClearHints(), SDL_CreateCond(), SDL_CreateMutex(), SDL_CreateSemaphore(), SDL_CreateThreadWithStackSize(), SDL_CreateWindowTexture(), SDL_DelEventWatch(), SDL_DelHintCallback(), SDL_DelTouch(), SDL_DestroyCond(), SDL_DestroyMutex(), SDL_DestroySemaphore(), SDL_DestroyTexture(), SDL_DestroyWindow(), SDL_DestroyWindowTexture(), SDL_FreeAudioStream(), SDL_FreeBlitMap(), SDL_FreeDataQueue(), SDL_FreeDataQueueList(), SDL_FreeFormat(), SDL_FreePalette(), SDL_FreeResampleFilter(), SDL_FreeRW(), SDL_FreeShapeTree(), SDL_FreeSurface(), SDL_FreeWAV(), SDL_GameControllerAddMappingsFromRW(), SDL_GameControllerClose(), SDL_GameControllerLoadHints(), SDL_GameControllerOpen(), SDL_GameControllerQuitMappings(), SDL_Generic_SetTLSData(), SDL_GestureDelTouch(), SDL_GestureQuit(), SDL_GetErrBuf(), SDL_GL_DeleteContext(), SDL_HapticClose(), SDL_HapticOpen(), SDL_HapticOpenFromJoystick(), SDL_iconv_close(), SDL_InvalidateMap(), SDL_JoystickClose(), SDL_JoystickOpen(), SDL_LoadFile_RW(), SDL_LoadVIDPIDListFromHint(), SDL_LoadWAV_RW(), SDL_LogOutput(), SDL_LogResetPriorities(), SDL_MouseQuit(), SDL_NewAudioStream(), SDL_PrepareResampleFilter(), SDL_PrivateAddMappingForGUID(), SDL_PrivateGameControllerAddMapping(), SDL_RemoveTimer(), SDL_RunThread(), SDL_SetClipboardText(), SDL_setenv(), SDL_SetHintWithPriority(), SDL_SetWindowData(), SDL_SetWindowTitle(), SDL_StopEventLoop(), SDL_SW_DestroyYUVTexture(), SDL_SYS_AddJoystickDevice(), SDL_SYS_RemoveJoystickDevice(), SDL_TimerQuit(), SDL_TLSCleanup(), SDL_TouchQuit(), SDL_UnRLESurface(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_UpdateTextureYUVPlanar(), SDL_VideoQuit(), SDL_vsnprintf(), SDL_WaitThread(), SDLTest_CommonEvent(), SDLTest_CommonQuit(), SDLTest_GenerateExecKey(), sdltest_generateRunSeed(), sdltest_randomAsciiString(), sdltest_randomAsciiStringOfSize(), sdltest_randomAsciiStringWithMaximumLength(), SDLTest_RunSuites(), SDLTest_ScreenShot(), shutdownVulkan(), stdlib_getsetenv(), SW_DestroyRenderer(), unifont_cleanup(), unifont_load_texture(), video_getSetWindowData(), WatchGameController(), and WatchJoystick().

◆ SDL_getenv()

char* SDL_getenv ( const char *  name)

Definition at line 210 of file SDL_getenv.c.

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

Referenced by SDL_setenv().

211 {
212  int len, i;
213  char *value;
214 
215  /* Input validation */
216  if (!name || SDL_strlen(name)==0) {
217  return NULL;
218  }
219 
220  value = (char *) 0;
221  if (SDL_env) {
222  len = SDL_strlen(name);
223  for (i = 0; SDL_env[i] && !value; ++i) {
224  if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
225  (SDL_env[i][len] == '=')) {
226  value = &SDL_env[i][len + 1];
227  }
228  }
229  }
230  return value;
231 }
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:104
GLenum GLsizei len
GLuint const GLchar * name
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:50
#define NULL
Definition: begin_code.h:164
#define SDL_strlen

◆ SDL_iconv()

size_t SDL_iconv ( SDL_iconv_t  cd,
const char **  inbuf,
size_t inbytesleft,
char **  outbuf,
size_t outbytesleft 
)

Definition at line 248 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().

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

◆ SDL_iconv_close()

int SDL_iconv_close ( SDL_iconv_t  cd)

Definition at line 854 of file SDL_iconv.c.

References SDL_free().

Referenced by SDL_iconv_string().

855 {
856  if (cd != (SDL_iconv_t)-1) {
857  SDL_free(cd);
858  }
859  return 0;
860 }
void SDL_free(void *mem)

◆ SDL_iconv_open()

SDL_iconv_t SDL_iconv_open ( const char *  tocode,
const char *  fromcode 
)

Definition at line 208 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().

209 {
210  int src_fmt = ENCODING_UNKNOWN;
211  int dst_fmt = ENCODING_UNKNOWN;
212  int i;
213  char fromcode_buffer[64];
214  char tocode_buffer[64];
215 
216  if (!fromcode || !*fromcode) {
217  fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer));
218  }
219  if (!tocode || !*tocode) {
220  tocode = getlocale(tocode_buffer, sizeof(tocode_buffer));
221  }
222  for (i = 0; i < SDL_arraysize(encodings); ++i) {
223  if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) {
224  src_fmt = encodings[i].format;
225  if (dst_fmt != ENCODING_UNKNOWN) {
226  break;
227  }
228  }
229  if (SDL_strcasecmp(tocode, encodings[i].name) == 0) {
230  dst_fmt = encodings[i].format;
231  if (src_fmt != ENCODING_UNKNOWN) {
232  break;
233  }
234  }
235  }
236  if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) {
237  SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd));
238  if (cd) {
239  cd->src_fmt = src_fmt;
240  cd->dst_fmt = dst_fmt;
241  return cd;
242  }
243  }
244  return (SDL_iconv_t) - 1;
245 }
static struct @31 encodings[]
#define SDL_strcasecmp
GLuint const GLchar * name
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:50
#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:173

◆ SDL_iconv_string()

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 865 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.

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

◆ SDL_isdigit()

int SDL_isdigit ( int  x)

Definition at line 274 of file SDL_stdlib.c.

Referenced by SDL_abs().

274 { return ((x) >= '0') && ((x) <= '9'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_isspace()

int SDL_isspace ( int  x)

Definition at line 275 of file SDL_stdlib.c.

Referenced by SDL_abs().

275 { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_itoa()

char* SDL_itoa ( int  value,
char *  str,
int  radix 
)

Definition at line 690 of file SDL_string.c.

References SDL_ltoa().

Referenced by SDL_memset4().

691 {
692 #ifdef HAVE_ITOA
693  return itoa(value, string, radix);
694 #else
695  return SDL_ltoa((long)value, string, radix);
696 #endif /* HAVE_ITOA */
697 }
GLsizei const GLfloat * value
char * SDL_ltoa(long value, char *string, int radix)
Definition: SDL_string.c:710

◆ SDL_lltoa()

char* SDL_lltoa ( Sint64  value,
char *  str,
int  radix 
)

Definition at line 754 of file SDL_string.c.

References SDL_ulltoa().

Referenced by SDL_memset4(), and SDL_PrintLongLong().

755 {
756 #if defined(HAVE__I64TOA)
757  return _i64toa(value, string, radix);
758 #else
759  char *bufp = string;
760 
761  if (value < 0) {
762  *bufp++ = '-';
763  SDL_ulltoa(-value, bufp, radix);
764  } else {
765  SDL_ulltoa(value, bufp, radix);
766  }
767 
768  return string;
769 #endif /* HAVE__I64TOA */
770 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:773

◆ SDL_log()

double SDL_log ( double  x)

Definition at line 164 of file SDL_stdlib.c.

References SDL_uclibc_log().

Referenced by SDL_memset4().

165 {
166 #if defined(HAVE_LOG)
167  return log(x);
168 #else
169  return SDL_uclibc_log(x);
170 #endif /* HAVE_LOG */
171 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_ltoa()

char* SDL_ltoa ( long  value,
char *  str,
int  radix 
)

Definition at line 710 of file SDL_string.c.

References SDL_ultoa().

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

711 {
712 #if defined(HAVE__LTOA)
713  return _ltoa(value, string, radix);
714 #else
715  char *bufp = string;
716 
717  if (value < 0) {
718  *bufp++ = '-';
719  SDL_ultoa(-value, bufp, radix);
720  } else {
721  SDL_ultoa(value, bufp, radix);
722  }
723 
724  return string;
725 #endif /* HAVE__LTOA */
726 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:729

◆ SDL_malloc()

void* SDL_malloc ( size_t  size)

◆ SDL_memcmp()

int SDL_memcmp ( const void s1,
const void s2,
size_t  len 
)

Definition at line 387 of file SDL_string.c.

Referenced by SDL_memset4().

388 {
389 #if defined(HAVE_MEMCMP)
390  return memcmp(s1, s2, len);
391 #else
392  char *s1p = (char *) s1;
393  char *s2p = (char *) s2;
394  while (len--) {
395  if (*s1p != *s2p) {
396  return (*s1p - *s2p);
397  }
398  ++s1p;
399  ++s2p;
400  }
401  return 0;
402 #endif /* HAVE_MEMCMP */
403 }
GLenum GLsizei len
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1

◆ SDL_memcpy()

void* SDL_memcpy ( SDL_OUT_BYTECAP(len) void dst,
SDL_IN_BYTECAP(len) const void src,
size_t  len 
)

Definition at line 310 of file SDL_string.c.

References memcpy.

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

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

◆ SDL_memcpy4()

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 546 of file SDL_stdinc.h.

References SDL_memcpy().

547 {
548  return SDL_memcpy(dst, src, dwords * 4);
549 }
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:310
GLenum src

◆ SDL_memmove()

void* SDL_memmove ( SDL_OUT_BYTECAP(len) void dst,
SDL_IN_BYTECAP(len) const void src,
size_t  len 
)

Definition at line 363 of file SDL_string.c.

References memmove.

Referenced by SDL_memset4().

364 {
365 #if defined(HAVE_MEMMOVE)
366  return memmove(dst, src, len);
367 #else
368  char *srcp = (char *) src;
369  char *dstp = (char *) dst;
370 
371  if (src < dst) {
372  srcp += len - 1;
373  dstp += len - 1;
374  while (len--) {
375  *dstp-- = *srcp--;
376  }
377  } else {
378  while (len--) {
379  *dstp++ = *srcp++;
380  }
381  }
382  return dst;
383 #endif /* HAVE_MEMMOVE */
384 }
GLenum GLenum dst
#define memmove
Definition: SDL_qsort.c:59
GLenum src
GLenum GLsizei len

◆ SDL_memset()

void* SDL_memset ( SDL_OUT_BYTECAP(len) void dst,
int  c,
size_t  len 
)

Definition at line 266 of file SDL_string.c.

References memset.

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

◆ SDL_memset4()

SDL_FORCE_INLINE void SDL_memset4 ( void dst,
Uint32  val,
size_t  dwords 
)

Definition at line 389 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_utf8strlen(), SDL_vsnprintf(), SDL_vsscanf(), SDL_wcscmp(), SDL_wcslcat(), SDL_wcslcpy(), SDL_wcslen(), SDLCALL, and text.

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

390 {
391 #if defined(__GNUC__) && defined(i386)
392  int u0, u1, u2;
393  __asm__ __volatile__ (
394  "cld \n\t"
395  "rep ; stosl \n\t"
396  : "=&D" (u0), "=&a" (u1), "=&c" (u2)
397  : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
398  : "memory"
399  );
400 #else
401  size_t _n = (dwords + 3) / 4;
402  Uint32 *_p = SDL_static_cast(Uint32 *, dst);
403  Uint32 _val = (val);
404  if (dwords == 0)
405  return;
406  switch (dwords % 4)
407  {
408  case 0: do { *_p++ = _val; /* fallthrough */
409  case 3: *_p++ = _val; /* fallthrough */
410  case 2: *_p++ = _val; /* fallthrough */
411  case 1: *_p++ = _val; /* fallthrough */
412  } while ( --_n );
413  }
414 #endif
415 }
GLenum GLenum dst
GLfixed u1
uint32_t Uint32
Definition: SDL_stdinc.h:181
GLfixed GLfixed u2
GLuint GLfloat * val
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:116

◆ SDL_pow()

double SDL_pow ( double  x,
double  y 
)

Definition at line 174 of file SDL_stdlib.c.

References SDL_uclibc_pow().

Referenced by SDL_memset4().

175 {
176 #if defined(HAVE_POW)
177  return pow(x, y);
178 #else
179  return SDL_uclibc_pow(x, y);
180 #endif /* HAVE_POW */
181 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_pow(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_qsort()

void SDL_qsort ( void base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compare 
)

◆ SDL_realloc()

void* SDL_realloc ( void mem,
size_t  size 
)

◆ SDL_scalbn()

double SDL_scalbn ( double  x,
int  n 
)

Definition at line 184 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_memset4().

185 {
186 #if defined(HAVE_SCALBN)
187  return scalbn(x, n);
188 #elif defined(HAVE__SCALB)
189  return _scalb(x, n);
190 #elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
191 /* from scalbn(3): If FLT_RADIX equals 2 (which is
192  * usual), then scalbn() is equivalent to ldexp(3). */
193  return ldexp(x, n);
194 #else
195  return SDL_uclibc_scalbn(x, n);
196 #endif /* HAVE_SCALBN */
197 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define scalbn
Definition: math_private.h:40
GLdouble n
double SDL_uclibc_scalbn(double x, int n)

◆ SDL_setenv()

int SDL_setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Definition at line 106 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().

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

◆ SDL_sin()

double SDL_sin ( double  x)

Definition at line 200 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin.

Referenced by SDL_memset4(), and SDL_sinf().

201 {
202 #if defined(HAVE_SIN)
203  return sin(x);
204 #else
205  return SDL_uclibc_sin(x);
206 #endif /* HAVE_SIN */
207 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sin(double x)
#define sin
Definition: math_private.h:41

◆ SDL_sinf()

float SDL_sinf ( float  x)

Definition at line 210 of file SDL_stdlib.c.

References SDL_sin().

Referenced by SDL_memset4().

211 {
212 #if defined(HAVE_SINF)
213  return sinf(x);
214 #else
215  return (float)SDL_sin((double)x);
216 #endif /* HAVE_SINF */
217 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sin(double x)
Definition: SDL_stdlib.c:200

◆ SDL_snprintf()

int SDL_snprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 1314 of file SDL_string.c.

References retval, SDL_OUT_Z_CAP, and SDL_vsnprintf().

Referenced by SDL_memset4().

1315 {
1316  va_list ap;
1317  int retval;
1318 
1319  va_start(ap, fmt);
1320  retval = SDL_vsnprintf(text, maxlen, fmt, ap);
1321  va_end(ap);
1322 
1323  return retval;
1324 }
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1528
SDL_bool retval
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47

◆ SDL_sqrt()

double SDL_sqrt ( double  x)

Definition at line 220 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

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

221 {
222 #if defined(HAVE_SQRT)
223  return sqrt(x);
224 #else
225  return SDL_uclibc_sqrt(x);
226 #endif
227 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sqrt(double x)

◆ SDL_sqrtf()

float SDL_sqrtf ( float  x)

Definition at line 230 of file SDL_stdlib.c.

References SDL_sqrt().

Referenced by SDL_memset4().

231 {
232 #if defined(HAVE_SQRTF)
233  return sqrtf(x);
234 #else
235  return (float)SDL_sqrt((double)x);
236 #endif
237 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:220

◆ SDL_sscanf()

int SDL_sscanf ( const char *  text,
SDL_SCANF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 1022 of file SDL_string.c.

References SDL_vsscanf(), and text.

Referenced by SDL_memset4().

1023 {
1024  int rc;
1025  va_list ap;
1026  va_start(ap, fmt);
1027  rc = SDL_vsscanf(text, fmt, ap);
1028  va_end(ap);
1029  return rc;
1030 }
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
Definition: SDL_string.c:1040

◆ SDL_strcasecmp()

int SDL_strcasecmp ( const char *  str1,
const char *  str2 
)

Definition at line 969 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4().

970 {
971 #ifdef HAVE_STRCASECMP
972  return strcasecmp(str1, str2);
973 #elif defined(HAVE__STRICMP)
974  return _stricmp(str1, str2);
975 #else
976  char a = 0;
977  char b = 0;
978  while (*str1 && *str2) {
979  a = SDL_toupper((unsigned char) *str1);
980  b = SDL_toupper((unsigned char) *str2);
981  if (a != b)
982  break;
983  ++str1;
984  ++str2;
985  }
986  a = SDL_toupper(*str1);
987  b = SDL_toupper(*str2);
988  return (int) ((unsigned char) a - (unsigned char) b);
989 #endif /* HAVE_STRCASECMP */
990 }
#define SDL_toupper
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strchr()

char* SDL_strchr ( const char *  str,
int  c 
)

Definition at line 626 of file SDL_string.c.

References NULL, and SDL_const_cast.

Referenced by SDL_memset4().

627 {
628 #ifdef HAVE_STRCHR
629  return SDL_const_cast(char*,strchr(string, c));
630 #elif defined(HAVE_INDEX)
631  return SDL_const_cast(char*,index(string, c));
632 #else
633  while (*string) {
634  if (*string == c) {
635  return (char *) string;
636  }
637  ++string;
638  }
639  return NULL;
640 #endif /* HAVE_STRCHR */
641 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:117
GLsizei const GLchar *const * string
const GLubyte * c
GLuint index
#define NULL
Definition: begin_code.h:164

◆ SDL_strcmp()

int SDL_strcmp ( const char *  str1,
const char *  str2 
)

Definition at line 933 of file SDL_string.c.

Referenced by SDL_memset4().

934 {
935 #if defined(HAVE_STRCMP)
936  return strcmp(str1, str2);
937 #else
938  while (*str1 && *str2) {
939  if (*str1 != *str2)
940  break;
941  ++str1;
942  ++str2;
943  }
944  return (int)((unsigned char) *str1 - (unsigned char) *str2);
945 #endif /* HAVE_STRCMP */
946 }

◆ SDL_strdup()

char* SDL_strdup ( const char *  str)

Definition at line 562 of file SDL_string.c.

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

Referenced by SDL_memset4().

563 {
564 #if defined(HAVE_STRDUP)
565  return strdup(string);
566 #else
567  size_t len = SDL_strlen(string) + 1;
568  char *newstr = SDL_malloc(len);
569  if (newstr) {
570  SDL_strlcpy(newstr, string, len);
571  }
572  return newstr;
573 #endif /* HAVE_STRDUP */
574 }
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:481
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
#define SDL_malloc

◆ SDL_strlcat()

size_t SDL_strlcat ( SDL_INOUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)

Definition at line 547 of file SDL_string.c.

References SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

548 {
549 #if defined(HAVE_STRLCAT)
550  return strlcat(dst, src, maxlen);
551 #else
552  size_t dstlen = SDL_strlen(dst);
553  size_t srclen = SDL_strlen(src);
554  if (dstlen < maxlen) {
555  SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
556  }
557  return dstlen + srclen;
558 #endif /* HAVE_STRLCAT */
559 }
GLenum GLenum dst
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:481
GLenum src
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406

◆ SDL_strlcpy()

size_t SDL_strlcpy ( SDL_OUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)

Definition at line 481 of file SDL_string.c.

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

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

482 {
483 #if defined(HAVE_STRLCPY)
484  return strlcpy(dst, src, maxlen);
485 #else
486  size_t srclen = SDL_strlen(src);
487  if (maxlen > 0) {
488  size_t len = SDL_min(srclen, maxlen - 1);
489  SDL_memcpy(dst, src, len);
490  dst[len] = '\0';
491  }
492  return srclen;
493 #endif /* HAVE_STRLCPY */
494 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:375
GLenum GLenum dst
GLenum src
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310

◆ SDL_strlen()

size_t SDL_strlen ( const char *  str)

Definition at line 406 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().

407 {
408 #if defined(HAVE_STRLEN)
409  return strlen(string);
410 #else
411  size_t len = 0;
412  while (*string++) {
413  ++len;
414  }
415  return len;
416 #endif /* HAVE_STRLEN */
417 }
GLenum GLsizei len

◆ SDL_strlwr()

char* SDL_strlwr ( char *  str)

Definition at line 611 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4(), and SDL_PrintString().

612 {
613 #if defined(HAVE__STRLWR)
614  return _strlwr(string);
615 #else
616  char *bufp = string;
617  while (*bufp) {
618  *bufp = SDL_tolower((unsigned char) *bufp);
619  ++bufp;
620  }
621  return string;
622 #endif /* HAVE__STRLWR */
623 }
GLsizei const GLchar *const * string
#define SDL_tolower

◆ SDL_strncasecmp()

int SDL_strncasecmp ( const char *  str1,
const char *  str2,
size_t  len 
)

Definition at line 993 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4().

994 {
995 #ifdef HAVE_STRNCASECMP
996  return strncasecmp(str1, str2, maxlen);
997 #elif defined(HAVE__STRNICMP)
998  return _strnicmp(str1, str2, maxlen);
999 #else
1000  char a = 0;
1001  char b = 0;
1002  while (*str1 && *str2 && maxlen) {
1003  a = SDL_tolower((unsigned char) *str1);
1004  b = SDL_tolower((unsigned char) *str2);
1005  if (a != b)
1006  break;
1007  ++str1;
1008  ++str2;
1009  --maxlen;
1010  }
1011  if (maxlen == 0) {
1012  return 0;
1013  } else {
1014  a = SDL_tolower((unsigned char) *str1);
1015  b = SDL_tolower((unsigned char) *str2);
1016  return (int) ((unsigned char) a - (unsigned char) b);
1017  }
1018 #endif /* HAVE_STRNCASECMP */
1019 }
#define SDL_tolower
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strncmp()

int SDL_strncmp ( const char *  str1,
const char *  str2,
size_t  maxlen 
)

Definition at line 949 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().

950 {
951 #if defined(HAVE_STRNCMP)
952  return strncmp(str1, str2, maxlen);
953 #else
954  while (*str1 && *str2 && maxlen) {
955  if (*str1 != *str2)
956  break;
957  ++str1;
958  ++str2;
959  --maxlen;
960  }
961  if (!maxlen) {
962  return 0;
963  }
964  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
965 #endif /* HAVE_STRNCMP */
966 }

◆ SDL_strrchr()

char* SDL_strrchr ( const char *  str,
int  c 
)

Definition at line 644 of file SDL_string.c.

References NULL, SDL_const_cast, and SDL_strlen().

Referenced by SDL_memset4().

645 {
646 #ifdef HAVE_STRRCHR
647  return SDL_const_cast(char*,strrchr(string, c));
648 #elif defined(HAVE_RINDEX)
649  return SDL_const_cast(char*,rindex(string, c));
650 #else
651  const char *bufp = string + SDL_strlen(string) - 1;
652  while (bufp >= string) {
653  if (*bufp == c) {
654  return (char *) bufp;
655  }
656  --bufp;
657  }
658  return NULL;
659 #endif /* HAVE_STRRCHR */
660 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:117
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
const GLubyte * c
#define NULL
Definition: begin_code.h:164

◆ SDL_strrev()

char* SDL_strrev ( char *  str)

Definition at line 577 of file SDL_string.c.

References SDL_strlen().

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

578 {
579 #if defined(HAVE__STRREV)
580  return _strrev(string);
581 #else
582  size_t len = SDL_strlen(string);
583  char *a = &string[0];
584  char *b = &string[len - 1];
585  len /= 2;
586  while (len--) {
587  char c = *a;
588  *a++ = *b;
589  *b-- = c;
590  }
591  return string;
592 #endif /* HAVE__STRREV */
593 }
GLsizei const GLchar *const * string
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
const GLubyte * c
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strstr()

char* SDL_strstr ( const char *  haystack,
const char *  needle 
)

Definition at line 663 of file SDL_string.c.

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

Referenced by SDL_memset4().

664 {
665 #if defined(HAVE_STRSTR)
666  return SDL_const_cast(char*,strstr(haystack, needle));
667 #else
668  size_t length = SDL_strlen(needle);
669  while (*haystack) {
670  if (SDL_strncmp(haystack, needle, length) == 0) {
671  return (char *) haystack;
672  }
673  ++haystack;
674  }
675  return NULL;
676 #endif /* HAVE_STRSTR */
677 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:117
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
#define NULL
Definition: begin_code.h:164
GLuint GLsizei GLsizei * length

◆ SDL_strtod()

double SDL_strtod ( const char *  str,
char **  endp 
)

Definition at line 916 of file SDL_string.c.

References SDL_ScanFloat().

Referenced by SDL_atof(), and SDL_memset4().

917 {
918 #if defined(HAVE_STRTOD)
919  return strtod(string, endp);
920 #else
921  size_t len;
922  double value = 0.0;
923 
924  len = SDL_ScanFloat(string, &value);
925  if (endp) {
926  *endp = (char *) string + len;
927  }
928  return value;
929 #endif /* HAVE_STRTOD */
930 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:231
GLenum GLsizei len
GLsizei const GLfloat * value

◆ SDL_strtol()

long SDL_strtol ( const char *  str,
char **  endp,
int  base 
)

Definition at line 816 of file SDL_string.c.

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

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

817 {
818 #if defined(HAVE_STRTOL)
819  return strtol(string, endp, base);
820 #else
821  size_t len;
822  long value = 0;
823 
824  if (!base) {
825  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
826  base = 16;
827  } else {
828  base = 10;
829  }
830  }
831 
832  len = SDL_ScanLong(string, base, &value);
833  if (endp) {
834  *endp = (char *) string + len;
835  }
836  return value;
837 #endif /* HAVE_STRTOL */
838 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:53
GLsizei const GLfloat * value

◆ SDL_strtoll()

Sint64 SDL_strtoll ( const char *  str,
char **  endp,
int  base 
)

Definition at line 866 of file SDL_string.c.

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

Referenced by SDL_memset4().

867 {
868 #if defined(HAVE_STRTOLL)
869  return strtoll(string, endp, base);
870 #else
871  size_t len;
872  Sint64 value = 0;
873 
874  if (!base) {
875  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
876  base = 16;
877  } else {
878  base = 10;
879  }
880  }
881 
882  len = SDL_ScanLongLong(string, base, &value);
883  if (endp) {
884  *endp = (char *) string + len;
885  }
886  return value;
887 #endif /* HAVE_STRTOLL */
888 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
GLsizei const GLfloat * value
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:158
int64_t Sint64
Definition: SDL_stdinc.h:188

◆ SDL_strtoul()

unsigned long SDL_strtoul ( const char *  str,
char **  endp,
int  base 
)

Definition at line 841 of file SDL_string.c.

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

Referenced by SDL_memset4().

842 {
843 #if defined(HAVE_STRTOUL)
844  return strtoul(string, endp, base);
845 #else
846  size_t len;
847  unsigned long value = 0;
848 
849  if (!base) {
850  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
851  base = 16;
852  } else {
853  base = 10;
854  }
855  }
856 
857  len = SDL_ScanUnsignedLong(string, base, &value);
858  if (endp) {
859  *endp = (char *) string + len;
860  }
861  return value;
862 #endif /* HAVE_STRTOUL */
863 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:94

◆ SDL_strtoull()

Uint64 SDL_strtoull ( const char *  str,
char **  endp,
int  base 
)

Definition at line 891 of file SDL_string.c.

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

Referenced by SDL_memset4().

892 {
893 #if defined(HAVE_STRTOULL)
894  return strtoull(string, endp, base);
895 #else
896  size_t len;
897  Uint64 value = 0;
898 
899  if (!base) {
900  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
901  base = 16;
902  } else {
903  base = 10;
904  }
905  }
906 
907  len = SDL_ScanUnsignedLongLong(string, base, &value);
908  if (endp) {
909  *endp = (char *) string + len;
910  }
911  return value;
912 #endif /* HAVE_STRTOULL */
913 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
uint64_t Uint64
Definition: SDL_stdinc.h:194
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:199

◆ SDL_strupr()

char* SDL_strupr ( char *  str)

Definition at line 596 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4(), and SDL_PrintString().

597 {
598 #if defined(HAVE__STRUPR)
599  return _strupr(string);
600 #else
601  char *bufp = string;
602  while (*bufp) {
603  *bufp = SDL_toupper((unsigned char) *bufp);
604  ++bufp;
605  }
606  return string;
607 #endif /* HAVE__STRUPR */
608 }
GLsizei const GLchar *const * string
#define SDL_toupper

◆ SDL_tan()

double SDL_tan ( double  x)

Definition at line 240 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_memset4(), and SDL_tanf().

241 {
242 #if defined(HAVE_TAN)
243  return tan(x);
244 #else
245  return SDL_uclibc_tan(x);
246 #endif
247 }
double tan(double x)
Definition: s_tan.c:45
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_tan(double x)

◆ SDL_tanf()

float SDL_tanf ( float  x)

Definition at line 250 of file SDL_stdlib.c.

References SDL_tan().

Referenced by SDL_memset4().

251 {
252 #if defined(HAVE_TANF)
253  return tanf(x);
254 #else
255  return (float)SDL_tan((double)x);
256 #endif
257 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_tan(double x)
Definition: SDL_stdlib.c:240

◆ SDL_tolower()

int SDL_tolower ( int  x)

Definition at line 277 of file SDL_stdlib.c.

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

Referenced by SDL_abs().

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

◆ SDL_toupper()

int SDL_toupper ( int  x)

Definition at line 276 of file SDL_stdlib.c.

Referenced by SDL_abs().

276 { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_uitoa()

char* SDL_uitoa ( unsigned int  value,
char *  str,
int  radix 
)

Definition at line 700 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_memset4().

701 {
702 #ifdef HAVE__UITOA
703  return _uitoa(value, string, radix);
704 #else
705  return SDL_ultoa((unsigned long)value, string, radix);
706 #endif /* HAVE__UITOA */
707 }
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:729

◆ SDL_ulltoa()

char* SDL_ulltoa ( Uint64  value,
char *  str,
int  radix 
)

Definition at line 773 of file SDL_string.c.

References SDL_strrev().

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

774 {
775 #if defined(HAVE__UI64TOA)
776  return _ui64toa(value, string, radix);
777 #else
778  char *bufp = string;
779 
780  if (value) {
781  while (value > 0) {
782  *bufp++ = ntoa_table[value % radix];
783  value /= radix;
784  }
785  } else {
786  *bufp++ = '0';
787  }
788  *bufp = '\0';
789 
790  /* The numbers went into the string backwards. :) */
791  SDL_strrev(string);
792 
793  return string;
794 #endif /* HAVE__UI64TOA */
795 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:681
char * SDL_strrev(char *string)
Definition: SDL_string.c:577
GLsizei const GLfloat * value

◆ SDL_ultoa()

char* SDL_ultoa ( unsigned long  value,
char *  str,
int  radix 
)

Definition at line 729 of file SDL_string.c.

References SDL_strrev().

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

730 {
731 #if defined(HAVE__ULTOA)
732  return _ultoa(value, string, radix);
733 #else
734  char *bufp = string;
735 
736  if (value) {
737  while (value > 0) {
738  *bufp++ = ntoa_table[value % radix];
739  value /= radix;
740  }
741  } else {
742  *bufp++ = '0';
743  }
744  *bufp = '\0';
745 
746  /* The numbers went into the string backwards. :) */
747  SDL_strrev(string);
748 
749  return string;
750 #endif /* HAVE__ULTOA */
751 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:681
char * SDL_strrev(char *string)
Definition: SDL_string.c:577
GLsizei const GLfloat * value

◆ SDL_utf8strlcpy()

size_t SDL_utf8strlcpy ( SDL_OUT_Z_CAP(dst_bytes) char *  dst,
const char *  src,
size_t  dst_bytes 
)

Definition at line 497 of file SDL_string.c.

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

Referenced by SDL_memset4().

498 {
499  size_t src_bytes = SDL_strlen(src);
500  size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
501  size_t i = 0;
502  char trailing_bytes = 0;
503  if (bytes)
504  {
505  unsigned char c = (unsigned char)src[bytes - 1];
506  if (UTF8_IsLeadByte(c))
507  --bytes;
508  else if (UTF8_IsTrailingByte(c))
509  {
510  for (i = bytes - 1; i != 0; --i)
511  {
512  c = (unsigned char)src[i];
513  trailing_bytes = UTF8_TrailingBytes(c);
514  if (trailing_bytes)
515  {
516  if (bytes - i != trailing_bytes + 1)
517  bytes = i;
518 
519  break;
520  }
521  }
522  }
523  SDL_memcpy(dst, src, bytes);
524  }
525  dst[bytes] = '\0';
526  return bytes;
527 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:375
GLenum GLenum dst
GLenum src
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:36
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:50
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:39
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:37

◆ SDL_utf8strlen()

size_t SDL_utf8strlen ( const char *  str)

Definition at line 530 of file SDL_string.c.

References retval.

Referenced by SDL_memset4().

531 {
532  size_t retval = 0;
533  const char *p = str;
534  char ch;
535 
536  while ((ch = *(p++))) {
537  /* if top two bits are 1 and 0, it's a continuation byte. */
538  if ((ch & 0xc0) != 0x80) {
539  retval++;
540  }
541  }
542 
543  return retval;
544 }
GLfloat GLfloat p
SDL_bool retval

◆ SDL_vsnprintf()

int SDL_vsnprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
const char *  fmt,
va_list  ap 
)

Definition at line 1528 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_free(), SDL_iconv_string, SDL_min, SDL_PrintFloat(), SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintString(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), SDL_strncmp(), SDL_strtol(), SDL_TRUE, SDL_wcslen(), SDL_zero, text, and SDL_FormatInfo::width.

Referenced by SDL_memset4(), and SDL_snprintf().

1529 {
1530  size_t left = maxlen;
1531  char *textstart = text;
1532 
1533  if (!fmt) {
1534  fmt = "";
1535  }
1536  while (*fmt && left > 1) {
1537  if (*fmt == '%') {
1539  size_t len = 0;
1540  SDL_bool check_flag;
1541  SDL_FormatInfo info;
1542  enum
1543  {
1544  DO_INT,
1545  DO_LONG,
1546  DO_LONGLONG
1547  } inttype = DO_INT;
1548 
1549  SDL_zero(info);
1550  info.radix = 10;
1551  info.precision = -1;
1552 
1553  check_flag = SDL_TRUE;
1554  while (check_flag) {
1555  ++fmt;
1556  switch (*fmt) {
1557  case '-':
1558  info.left_justify = SDL_TRUE;
1559  break;
1560  case '+':
1561  info.force_sign = SDL_TRUE;
1562  break;
1563  case '#':
1564  info.force_type = SDL_TRUE;
1565  break;
1566  case '0':
1567  info.pad_zeroes = SDL_TRUE;
1568  break;
1569  default:
1570  check_flag = SDL_FALSE;
1571  break;
1572  }
1573  }
1574 
1575  if (*fmt >= '0' && *fmt <= '9') {
1576  info.width = SDL_strtol(fmt, (char **)&fmt, 0);
1577  }
1578 
1579  if (*fmt == '.') {
1580  ++fmt;
1581  if (*fmt >= '0' && *fmt <= '9') {
1582  info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
1583  } else {
1584  info.precision = 0;
1585  }
1586  }
1587 
1588  while (!done) {
1589  switch (*fmt) {
1590  case '%':
1591  if (left > 1) {
1592  *text = '%';
1593  }
1594  len = 1;
1595  done = SDL_TRUE;
1596  break;
1597  case 'c':
1598  /* char is promoted to int when passed through (...) */
1599  if (left > 1) {
1600  *text = (char) va_arg(ap, int);
1601  }
1602  len = 1;
1603  done = SDL_TRUE;
1604  break;
1605  case 'h':
1606  /* short is promoted to int when passed through (...) */
1607  break;
1608  case 'l':
1609  if (inttype < DO_LONGLONG) {
1610  ++inttype;
1611  }
1612  break;
1613  case 'I':
1614  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1615  fmt += 2;
1616  inttype = DO_LONGLONG;
1617  }
1618  break;
1619  case 'i':
1620  case 'd':
1621  switch (inttype) {
1622  case DO_INT:
1623  len = SDL_PrintLong(text, left, &info,
1624  (long) va_arg(ap, int));
1625  break;
1626  case DO_LONG:
1627  len = SDL_PrintLong(text, left, &info,
1628  va_arg(ap, long));
1629  break;
1630  case DO_LONGLONG:
1631  len = SDL_PrintLongLong(text, left, &info,
1632  va_arg(ap, Sint64));
1633  break;
1634  }
1635  done = SDL_TRUE;
1636  break;
1637  case 'p':
1638  case 'x':
1639  info.force_case = SDL_CASE_LOWER;
1640  /* Fall through to 'X' handling */
1641  case 'X':
1642  if (info.force_case == SDL_CASE_NOCHANGE) {
1643  info.force_case = SDL_CASE_UPPER;
1644  }
1645  if (info.radix == 10) {
1646  info.radix = 16;
1647  }
1648  if (*fmt == 'p') {
1649  inttype = DO_LONG;
1650  }
1651  /* Fall through to unsigned handling */
1652  case 'o':
1653  if (info.radix == 10) {
1654  info.radix = 8;
1655  }
1656  /* Fall through to unsigned handling */
1657  case 'u':
1658  info.pad_zeroes = SDL_TRUE;
1659  switch (inttype) {
1660  case DO_INT:
1661  len = SDL_PrintUnsignedLong(text, left, &info,
1662  (unsigned long)
1663  va_arg(ap, unsigned int));
1664  break;
1665  case DO_LONG:
1666  len = SDL_PrintUnsignedLong(text, left, &info,
1667  va_arg(ap, unsigned long));
1668  break;
1669  case DO_LONGLONG:
1670  len = SDL_PrintUnsignedLongLong(text, left, &info,
1671  va_arg(ap, Uint64));
1672  break;
1673  }
1674  done = SDL_TRUE;
1675  break;
1676  case 'f':
1677  len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
1678  done = SDL_TRUE;
1679  break;
1680  case 'S':
1681  {
1682  /* In practice this is used on Windows for WCHAR strings */
1683  wchar_t *wide_arg = va_arg(ap, wchar_t *);
1684  char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
1685  len = SDL_PrintString(text, left, &info, arg);
1686  SDL_free(arg);
1687  done = SDL_TRUE;
1688  }
1689  break;
1690  case 's':
1691  len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
1692  done = SDL_TRUE;
1693  break;
1694  default:
1695  done = SDL_TRUE;
1696  break;
1697  }
1698  ++fmt;
1699  }
1700  if (len >= left) {
1701  text += (left > 1) ? left - 1 : 0;
1702  left = SDL_min(left, 1);
1703  } else {
1704  text += len;
1705  left -= len;
1706  }
1707  } else {
1708  *text++ = *fmt++;
1709  --left;
1710  }
1711  }
1712  if (left > 0) {
1713  *text = '\0';
1714  }
1715  return (int)(text - textstart);
1716 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:420
#define SDL_min(x, y)
Definition: SDL_stdinc.h:375
SDL_bool left_justify
Definition: SDL_string.c:1345
SDL_bool pad_zeroes
Definition: SDL_string.c:1348
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
SDL_bool force_type
Definition: SDL_string.c:1347
uint64_t Uint64
Definition: SDL_stdinc.h:194
GLenum GLsizei len
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:816
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1407
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1389
SDL_bool force_sign
Definition: SDL_string.c:1346
void SDL_free(void *mem)
int done
Definition: checkkeys.c:28
#define SDL_zero(x)
Definition: SDL_stdinc.h:385
SDL_bool
Definition: SDL_stdinc.h:139
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
#define SDL_iconv_string
SDL_letter_case force_case
Definition: SDL_string.c:1349
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1416
int64_t Sint64
Definition: SDL_stdinc.h:188
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1356
GLint left
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1398
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1425

◆ SDL_vsscanf()

int SDL_vsscanf ( const char *  text,
const char *  fmt,
va_list  ap 
)

Definition at line 1040 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().

1041 {
1042  int retval = 0;
1043 
1044  if (!text || !*text) {
1045  return -1;
1046  }
1047 
1048  while (*fmt) {
1049  if (*fmt == ' ') {
1050  while (SDL_isspace((unsigned char) *text)) {
1051  ++text;
1052  }
1053  ++fmt;
1054  continue;
1055  }
1056  if (*fmt == '%') {
1058  long count = 0;
1059  int radix = 10;
1060  enum
1061  {
1062  DO_SHORT,
1063  DO_INT,
1064  DO_LONG,
1065  DO_LONGLONG
1066  } inttype = DO_INT;
1067  size_t advance;
1068  SDL_bool suppress = SDL_FALSE;
1069 
1070  ++fmt;
1071  if (*fmt == '%') {
1072  if (*text == '%') {
1073  ++text;
1074  ++fmt;
1075  continue;
1076  }
1077  break;
1078  }
1079  if (*fmt == '*') {
1080  suppress = SDL_TRUE;
1081  ++fmt;
1082  }
1083  fmt += SDL_ScanLong(fmt, 10, &count);
1084 
1085  if (*fmt == 'c') {
1086  if (!count) {
1087  count = 1;
1088  }
1089  if (suppress) {
1090  while (count--) {
1091  ++text;
1092  }
1093  } else {
1094  char *valuep = va_arg(ap, char *);
1095  while (count--) {
1096  *valuep++ = *text++;
1097  }
1098  ++retval;
1099  }
1100  continue;
1101  }
1102 
1103  while (SDL_isspace((unsigned char) *text)) {
1104  ++text;
1105  }
1106 
1107  /* FIXME: implement more of the format specifiers */
1108  while (!done) {
1109  switch (*fmt) {
1110  case '*':
1111  suppress = SDL_TRUE;
1112  break;
1113  case 'h':
1114  if (inttype > DO_SHORT) {
1115  ++inttype;
1116  }
1117  break;
1118  case 'l':
1119  if (inttype < DO_LONGLONG) {
1120  ++inttype;
1121  }
1122  break;
1123  case 'I':
1124  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1125  fmt += 2;
1126  inttype = DO_LONGLONG;
1127  }
1128  break;
1129  case 'i':
1130  {
1131  int index = 0;
1132  if (text[index] == '-') {
1133  ++index;
1134  }
1135  if (text[index] == '0') {
1136  if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
1137  radix = 16;
1138  } else {
1139  radix = 8;
1140  }
1141  }
1142  }
1143  /* Fall through to %d handling */
1144  case 'd':
1145  if (inttype == DO_LONGLONG) {
1146  Sint64 value;
1147  advance = SDL_ScanLongLong(text, radix, &value);
1148  text += advance;
1149  if (advance && !suppress) {
1150  Sint64 *valuep = va_arg(ap, Sint64 *);
1151  *valuep = value;
1152  ++retval;
1153  }
1154  } else {
1155  long value;
1156  advance = SDL_ScanLong(text, radix, &value);
1157  text += advance;
1158  if (advance && !suppress) {
1159  switch (inttype) {
1160  case DO_SHORT:
1161  {
1162  short *valuep = va_arg(ap, short *);
1163  *valuep = (short) value;
1164  }
1165  break;
1166  case DO_INT:
1167  {
1168  int *valuep = va_arg(ap, int *);
1169  *valuep = (int) value;
1170  }
1171  break;
1172  case DO_LONG:
1173  {
1174  long *valuep = va_arg(ap, long *);
1175  *valuep = value;
1176  }
1177  break;
1178  case DO_LONGLONG:
1179  /* Handled above */
1180  break;
1181  }
1182  ++retval;
1183  }
1184  }
1185  done = SDL_TRUE;
1186  break;
1187  case 'o':
1188  if (radix == 10) {
1189  radix = 8;
1190  }
1191  /* Fall through to unsigned handling */
1192  case 'x':
1193  case 'X':
1194  if (radix == 10) {
1195  radix = 16;
1196  }
1197  /* Fall through to unsigned handling */
1198  case 'u':
1199  if (inttype == DO_LONGLONG) {
1200  Uint64 value = 0;
1201  advance = SDL_ScanUnsignedLongLong(text, radix, &value);
1202  text += advance;
1203  if (advance && !suppress) {
1204  Uint64 *valuep = va_arg(ap, Uint64 *);
1205  *valuep = value;
1206  ++retval;
1207  }
1208  } else {
1209  unsigned long value = 0;
1210  advance = SDL_ScanUnsignedLong(text, radix, &value);
1211  text += advance;
1212  if (advance && !suppress) {
1213  switch (inttype) {
1214  case DO_SHORT:
1215  {
1216  short *valuep = va_arg(ap, short *);
1217  *valuep = (short) value;
1218  }
1219  break;
1220  case DO_INT:
1221  {
1222  int *valuep = va_arg(ap, int *);
1223  *valuep = (int) value;
1224  }
1225  break;
1226  case DO_LONG:
1227  {
1228  long *valuep = va_arg(ap, long *);
1229  *valuep = value;
1230  }
1231  break;
1232  case DO_LONGLONG:
1233  /* Handled above */
1234  break;
1235  }
1236  ++retval;
1237  }
1238  }
1239  done = SDL_TRUE;
1240  break;
1241  case 'p':
1242  {
1243  uintptr_t value = 0;
1244  advance = SDL_ScanUintPtrT(text, 16, &value);
1245  text += advance;
1246  if (advance && !suppress) {
1247  void **valuep = va_arg(ap, void **);
1248  *valuep = (void *) value;
1249  ++retval;
1250  }
1251  }
1252  done = SDL_TRUE;
1253  break;
1254  case 'f':
1255  {
1256  double value;
1257  advance = SDL_ScanFloat(text, &value);
1258  text += advance;
1259  if (advance && !suppress) {
1260  float *valuep = va_arg(ap, float *);
1261  *valuep = (float) value;
1262  ++retval;
1263  }
1264  }
1265  done = SDL_TRUE;
1266  break;
1267  case 's':
1268  if (suppress) {
1269  while (!SDL_isspace((unsigned char) *text)) {
1270  ++text;
1271  if (count) {
1272  if (--count == 0) {
1273  break;
1274  }
1275  }
1276  }
1277  } else {
1278  char *valuep = va_arg(ap, char *);
1279  while (!SDL_isspace((unsigned char) *text)) {
1280  *valuep++ = *text++;
1281  if (count) {
1282  if (--count == 0) {
1283  break;
1284  }
1285  }
1286  }
1287  *valuep = '\0';
1288  ++retval;
1289  }
1290  done = SDL_TRUE;
1291  break;
1292  default:
1293  done = SDL_TRUE;
1294  break;
1295  }
1296  ++fmt;
1297  }
1298  continue;
1299  }
1300  if (*text == *fmt) {
1301  ++text;
1302  ++fmt;
1303  continue;
1304  }
1305  /* Text didn't match format specifier */
1306  break;
1307  }
1308 
1309  return retval;
1310 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:231
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:949
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
#define SDL_tolower
uint64_t Uint64
Definition: SDL_stdinc.h:194
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:126
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:53
SDL_bool retval
int done
Definition: checkkeys.c:28
GLsizei const GLfloat * value
unsigned int uintptr_t
#define SDL_isspace
GLuint index
SDL_bool
Definition: SDL_stdinc.h:139
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:158
int64_t Sint64
Definition: SDL_stdinc.h:188
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:199
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:94

◆ SDL_wcscmp()

int SDL_wcscmp ( const wchar_t *  str1,
const wchar_t *  str2 
)

Definition at line 465 of file SDL_string.c.

Referenced by SDL_memset4().

466 {
467 #if defined(HAVE_WCSCMP)
468  return wcscmp(str1, str2);
469 #else
470  while (*str1 && *str2) {
471  if (*str1 != *str2)
472  break;
473  ++str1;
474  ++str2;
475  }
476  return (int)(*str1 - *str2);
477 #endif /* HAVE_WCSCMP */
478 }

◆ SDL_wcslcat()

size_t SDL_wcslcat ( SDL_INOUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)

Definition at line 450 of file SDL_string.c.

References SDL_wcslcpy(), and SDL_wcslen().

Referenced by SDL_memset4().

451 {
452 #if defined(HAVE_WCSLCAT)
453  return wcslcat(dst, src, maxlen);
454 #else
455  size_t dstlen = SDL_wcslen(dst);
456  size_t srclen = SDL_wcslen(src);
457  if (dstlen < maxlen) {
458  SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
459  }
460  return dstlen + srclen;
461 #endif /* HAVE_WCSLCAT */
462 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:420
GLenum GLenum dst
GLenum src
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:434

◆ SDL_wcslcpy()

size_t SDL_wcslcpy ( SDL_OUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)

Definition at line 434 of file SDL_string.c.

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

Referenced by SDL_memset4(), and SDL_wcslcat().

435 {
436 #if defined(HAVE_WCSLCPY)
437  return wcslcpy(dst, src, maxlen);
438 #else
439  size_t srclen = SDL_wcslen(src);
440  if (maxlen > 0) {
441  size_t len = SDL_min(srclen, maxlen - 1);
442  SDL_memcpy(dst, src, len * sizeof(wchar_t));
443  dst[len] = '\0';
444  }
445  return srclen;
446 #endif /* HAVE_WCSLCPY */
447 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:420
#define SDL_min(x, y)
Definition: SDL_stdinc.h:375
GLenum GLenum dst
GLenum src
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:310

◆ SDL_wcslen()

size_t SDL_wcslen ( const wchar_t *  wstr)

Definition at line 420 of file SDL_string.c.

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

421 {
422 #if defined(HAVE_WCSLEN)
423  return wcslen(string);
424 #else
425  size_t len = 0;
426  while (*string++) {
427  ++len;
428  }
429  return len;
430 #endif /* HAVE_WCSLEN */
431 }
GLenum GLsizei len