SDL  2.0
SDL_rwops.c File Reference
#include "../SDL_internal.h"
#include "SDL_endian.h"
#include "SDL_rwops.h"
+ Include dependency graph for SDL_rwops.c:

Go to the source code of this file.

Macros

#define _LARGEFILE64_SOURCE
 

Functions

static Sint64 mem_size (SDL_RWops *context)
 
static Sint64 mem_seek (SDL_RWops *context, Sint64 offset, int whence)
 
static size_t mem_read (SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
 
static size_t mem_write (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
static size_t mem_writeconst (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
static int mem_close (SDL_RWops *context)
 
SDL_RWopsSDL_RWFromFile (const char *file, const char *mode)
 
SDL_RWopsSDL_RWFromFP (void *fp, SDL_bool autoclose)
 
SDL_RWopsSDL_RWFromMem (void *mem, int size)
 
SDL_RWopsSDL_RWFromConstMem (const void *mem, int size)
 
SDL_RWopsSDL_AllocRW (void)
 
void SDL_FreeRW (SDL_RWops *area)
 
Uint8 SDL_ReadU8 (SDL_RWops *src)
 
Uint16 SDL_ReadLE16 (SDL_RWops *src)
 
Uint16 SDL_ReadBE16 (SDL_RWops *src)
 
Uint32 SDL_ReadLE32 (SDL_RWops *src)
 
Uint32 SDL_ReadBE32 (SDL_RWops *src)
 
Uint64 SDL_ReadLE64 (SDL_RWops *src)
 
Uint64 SDL_ReadBE64 (SDL_RWops *src)
 
size_t SDL_WriteU8 (SDL_RWops *dst, Uint8 value)
 
size_t SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
 
size_t SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
 
size_t SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
 
size_t SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
 
size_t SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
 
size_t SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
 

Macro Definition Documentation

◆ _LARGEFILE64_SOURCE

#define _LARGEFILE64_SOURCE

Definition at line 22 of file SDL_rwops.c.

Function Documentation

◆ mem_close()

static int mem_close ( SDL_RWops context)
static

Definition at line 454 of file SDL_rwops.c.

References SDL_FreeRW().

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

455 {
456  if (context) {
457  SDL_FreeRW(context);
458  }
459  return 0;
460 }
void SDL_FreeRW(SDL_RWops *area)
Definition: SDL_rwops.c:651

◆ mem_read()

static size_t mem_read ( SDL_RWops context,
void ptr,
size_t  size,
size_t  maxnum 
)
static

Definition at line 413 of file SDL_rwops.c.

References SDL_RWops::hidden, SDL_RWops::mem, SDL_memcpy, and SDLCALL.

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

414 {
415  size_t total_bytes;
416  size_t mem_available;
417 
418  total_bytes = (maxnum * size);
419  if ((maxnum <= 0) || (size <= 0)
420  || ((total_bytes / maxnum) != (size_t) size)) {
421  return 0;
422  }
423 
424  mem_available = (context->hidden.mem.stop - context->hidden.mem.here);
425  if (total_bytes > mem_available) {
426  total_bytes = mem_available;
427  }
428 
429  SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
430  context->hidden.mem.here += total_bytes;
431 
432  return (total_bytes / size);
433 }
GLsizeiptr size
struct SDL_RWops::@10::@13 mem
unsigned int size_t
#define SDL_memcpy
union SDL_RWops::@10 hidden

◆ mem_seek()

static Sint64 mem_seek ( SDL_RWops context,
Sint64  offset,
int  whence 
)
static

Definition at line 385 of file SDL_rwops.c.

References SDL_RWops::hidden, SDL_RWops::mem, RW_SEEK_CUR, RW_SEEK_END, RW_SEEK_SET, SDL_SetError, and SDLCALL.

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

386 {
387  Uint8 *newpos;
388 
389  switch (whence) {
390  case RW_SEEK_SET:
391  newpos = context->hidden.mem.base + offset;
392  break;
393  case RW_SEEK_CUR:
394  newpos = context->hidden.mem.here + offset;
395  break;
396  case RW_SEEK_END:
397  newpos = context->hidden.mem.stop + offset;
398  break;
399  default:
400  return SDL_SetError("Unknown value for 'whence'");
401  }
402  if (newpos < context->hidden.mem.base) {
403  newpos = context->hidden.mem.base;
404  }
405  if (newpos > context->hidden.mem.stop) {
406  newpos = context->hidden.mem.stop;
407  }
408  context->hidden.mem.here = newpos;
409  return (Sint64)(context->hidden.mem.here - context->hidden.mem.base);
410 }
#define RW_SEEK_END
Definition: SDL_rwops.h:176
struct SDL_RWops::@10::@13 mem
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
GLintptr offset
#define SDL_SetError
union SDL_RWops::@10 hidden
#define RW_SEEK_SET
Definition: SDL_rwops.h:174
#define RW_SEEK_CUR
Definition: SDL_rwops.h:175
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:164

◆ mem_size()

static Sint64 mem_size ( SDL_RWops context)
static

Definition at line 379 of file SDL_rwops.c.

References SDL_RWops::hidden, SDL_RWops::mem, and SDLCALL.

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

380 {
381  return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base);
382 }
struct SDL_RWops::@10::@13 mem
union SDL_RWops::@10 hidden
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:164

◆ mem_write()

static size_t mem_write ( SDL_RWops context,
const void ptr,
size_t  size,
size_t  num 
)
static

Definition at line 436 of file SDL_rwops.c.

References SDL_RWops::hidden, SDL_RWops::mem, SDL_memcpy, and SDLCALL.

Referenced by SDL_RWFromMem().

437 {
438  if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) {
439  num = (context->hidden.mem.stop - context->hidden.mem.here) / size;
440  }
441  SDL_memcpy(context->hidden.mem.here, ptr, num * size);
442  context->hidden.mem.here += num * size;
443  return num;
444 }
GLuint num
GLsizeiptr size
struct SDL_RWops::@10::@13 mem
#define SDL_memcpy
union SDL_RWops::@10 hidden

◆ mem_writeconst()

static size_t mem_writeconst ( SDL_RWops context,
const void ptr,
size_t  size,
size_t  num 
)
static

Definition at line 447 of file SDL_rwops.c.

References SDL_SetError, and SDLCALL.

Referenced by SDL_RWFromConstMem().

448 {
449  SDL_SetError("Can't write to read-only memory");
450  return 0;
451 }
#define SDL_SetError

◆ SDL_AllocRW()

SDL_RWops* SDL_AllocRW ( void  )

Definition at line 637 of file SDL_rwops.c.

References NULL, SDL_malloc, SDL_OutOfMemory, SDL_RWOPS_UNKNOWN, and SDL_RWops::type.

Referenced by SDL_RWFromConstMem(), SDL_RWFromFile(), and SDL_RWFromMem().

638 {
639  SDL_RWops *area;
640 
641  area = (SDL_RWops *) SDL_malloc(sizeof *area);
642  if (area == NULL) {
643  SDL_OutOfMemory();
644  } else {
645  area->type = SDL_RWOPS_UNKNOWN;
646  }
647  return area;
648 }
#define SDL_RWOPS_UNKNOWN
Definition: SDL_rwops.h:42
Uint32 type
Definition: SDL_rwops.h:93
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
#define SDL_malloc

◆ SDL_FreeRW()

void SDL_FreeRW ( SDL_RWops area)

Definition at line 651 of file SDL_rwops.c.

References SDL_free().

Referenced by mem_close(), and SDL_RWFromFile().

652 {
653  SDL_free(area);
654 }
void SDL_free(void *mem)

◆ SDL_ReadBE16()

Uint16 SDL_ReadBE16 ( SDL_RWops src)

Definition at line 677 of file SDL_rwops.c.

References SDL_RWread, and SDL_SwapBE16.

678 {
679  Uint16 value = 0;
680 
681  SDL_RWread(src, &value, sizeof (value), 1);
682  return SDL_SwapBE16(value);
683 }
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
#define SDL_SwapBE16(X)
Definition: SDL_endian.h:215
GLsizei const GLfloat * value
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151

◆ SDL_ReadBE32()

Uint32 SDL_ReadBE32 ( SDL_RWops src)

Definition at line 695 of file SDL_rwops.c.

References SDL_RWread, and SDL_SwapBE32.

696 {
697  Uint32 value = 0;
698 
699  SDL_RWread(src, &value, sizeof (value), 1);
700  return SDL_SwapBE32(value);
701 }
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
#define SDL_SwapBE32(X)
Definition: SDL_endian.h:216
GLsizei const GLfloat * value

◆ SDL_ReadBE64()

Uint64 SDL_ReadBE64 ( SDL_RWops src)

Definition at line 713 of file SDL_rwops.c.

References SDL_RWread, and SDL_SwapBE64.

714 {
715  Uint64 value = 0;
716 
717  SDL_RWread(src, &value, sizeof (value), 1);
718  return SDL_SwapBE64(value);
719 }
#define SDL_SwapBE64(X)
Definition: SDL_endian.h:217
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:168
GLsizei const GLfloat * value

◆ SDL_ReadLE16()

Uint16 SDL_ReadLE16 ( SDL_RWops src)

Definition at line 668 of file SDL_rwops.c.

References SDL_RWread, and SDL_SwapLE16.

669 {
670  Uint16 value = 0;
671 
672  SDL_RWread(src, &value, sizeof (value), 1);
673  return SDL_SwapLE16(value);
674 }
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
GLsizei const GLfloat * value
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
#define SDL_SwapLE16(X)
Definition: SDL_endian.h:211

◆ SDL_ReadLE32()

Uint32 SDL_ReadLE32 ( SDL_RWops src)

Definition at line 686 of file SDL_rwops.c.

References SDL_RWread, and SDL_SwapLE32.

687 {
688  Uint32 value = 0;
689 
690  SDL_RWread(src, &value, sizeof (value), 1);
691  return SDL_SwapLE32(value);
692 }
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLsizei const GLfloat * value
#define SDL_SwapLE32(X)
Definition: SDL_endian.h:212

◆ SDL_ReadLE64()

Uint64 SDL_ReadLE64 ( SDL_RWops src)

Definition at line 704 of file SDL_rwops.c.

References SDL_RWread, and SDL_SwapLE64.

705 {
706  Uint64 value = 0;
707 
708  SDL_RWread(src, &value, sizeof (value), 1);
709  return SDL_SwapLE64(value);
710 }
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:168
#define SDL_SwapLE64(X)
Definition: SDL_endian.h:213
GLsizei const GLfloat * value

◆ SDL_ReadU8()

Uint8 SDL_ReadU8 ( SDL_RWops src)

Definition at line 659 of file SDL_rwops.c.

References SDL_RWread.

660 {
661  Uint8 value = 0;
662 
663  SDL_RWread(src, &value, sizeof (value), 1);
664  return value;
665 }
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
GLsizei const GLfloat * value
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143

◆ SDL_RWFromConstMem()

SDL_RWops* SDL_RWFromConstMem ( const void mem,
int  size 
)

Definition at line 609 of file SDL_rwops.c.

References SDL_RWops::close, SDL_RWops::hidden, SDL_RWops::mem, mem_close(), mem_read(), mem_seek(), mem_size(), mem_writeconst(), NULL, SDL_RWops::read, SDL_AllocRW(), SDL_InvalidParamError, SDL_RWOPS_MEMORY_RO, SDL_RWops::seek, SDL_RWops::size, SDL_RWops::type, and SDL_RWops::write.

610 {
611  SDL_RWops *rwops = NULL;
612  if (!mem) {
613  SDL_InvalidParamError("mem");
614  return rwops;
615  }
616  if (!size) {
617  SDL_InvalidParamError("size");
618  return rwops;
619  }
620 
621  rwops = SDL_AllocRW();
622  if (rwops != NULL) {
623  rwops->size = mem_size;
624  rwops->seek = mem_seek;
625  rwops->read = mem_read;
626  rwops->write = mem_writeconst;
627  rwops->close = mem_close;
628  rwops->hidden.mem.base = (Uint8 *) mem;
629  rwops->hidden.mem.here = rwops->hidden.mem.base;
630  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
631  rwops->type = SDL_RWOPS_MEMORY_RO;
632  }
633  return rwops;
634 }
size_t(* write)(struct SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.h:83
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
static size_t mem_writeconst(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:447
GLsizeiptr size
static Sint64 mem_size(SDL_RWops *context)
Definition: SDL_rwops.c:379
Uint32 type
Definition: SDL_rwops.h:93
struct SDL_RWops::@10::@13 mem
Sint64(* seek)(struct SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.h:65
SDL_RWops * SDL_AllocRW(void)
Definition: SDL_rwops.c:637
static int mem_close(SDL_RWops *context)
Definition: SDL_rwops.c:454
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
int(* close)(struct SDL_RWops *context)
Definition: SDL_rwops.h:91
static Sint64 mem_seek(SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.c:385
Sint64(* size)(struct SDL_RWops *context)
Definition: SDL_rwops.h:57
#define NULL
Definition: begin_code.h:143
union SDL_RWops::@10 hidden
#define SDL_RWOPS_MEMORY_RO
Definition: SDL_rwops.h:47
size_t(* read)(struct SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.h:74
static size_t mem_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:413

◆ SDL_RWFromFile()

SDL_RWops* SDL_RWFromFile ( const char *  file,
const char *  mode 
)

Definition at line 466 of file SDL_rwops.c.

References Android_JNI_FileClose(), Android_JNI_FileOpen(), Android_JNI_FileRead(), Android_JNI_FileSeek(), Android_JNI_FileSize(), Android_JNI_FileWrite(), SDL_RWops::close, SDL_RWops::hidden, NULL, SDL_RWops::read, SDL_AllocRW(), SDL_AndroidGetInternalStoragePath, SDL_FreeRW(), SDL_RWFromFP(), SDL_RWOPS_JNIFILE, SDL_RWOPS_STDFILE, SDL_RWOPS_WINFILE, SDL_SetError, SDL_snprintf, SDL_stack_alloc, SDL_stack_free, SDL_RWops::seek, SDL_RWops::size, SDL_RWops::stdio, SDL_RWops::type, and SDL_RWops::write.

467 {
468  SDL_RWops *rwops = NULL;
469  if (!file || !*file || !mode || !*mode) {
470  SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
471  return NULL;
472  }
473 #if defined(__ANDROID__)
474 #ifdef HAVE_STDIO_H
475  /* Try to open the file on the filesystem first */
476  if (*file == '/') {
477  FILE *fp = fopen(file, mode);
478  if (fp) {
479  return SDL_RWFromFP(fp, 1);
480  }
481  } else {
482  /* Try opening it from internal storage if it's a relative path */
483  char *path;
484  FILE *fp;
485 
486  path = SDL_stack_alloc(char, PATH_MAX);
487  if (path) {
488  SDL_snprintf(path, PATH_MAX, "%s/%s",
490  fp = fopen(path, mode);
491  SDL_stack_free(path);
492  if (fp) {
493  return SDL_RWFromFP(fp, 1);
494  }
495  }
496  }
497 #endif /* HAVE_STDIO_H */
498 
499  /* Try to open the file from the asset system */
500  rwops = SDL_AllocRW();
501  if (!rwops)
502  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
503  if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
504  SDL_FreeRW(rwops);
505  return NULL;
506  }
507  rwops->size = Android_JNI_FileSize;
508  rwops->seek = Android_JNI_FileSeek;
509  rwops->read = Android_JNI_FileRead;
510  rwops->write = Android_JNI_FileWrite;
511  rwops->close = Android_JNI_FileClose;
512  rwops->type = SDL_RWOPS_JNIFILE;
513 
514 #elif defined(__WIN32__)
515  rwops = SDL_AllocRW();
516  if (!rwops)
517  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
518  if (windows_file_open(rwops, file, mode) < 0) {
519  SDL_FreeRW(rwops);
520  return NULL;
521  }
522  rwops->size = windows_file_size;
523  rwops->seek = windows_file_seek;
524  rwops->read = windows_file_read;
525  rwops->write = windows_file_write;
526  rwops->close = windows_file_close;
527  rwops->type = SDL_RWOPS_WINFILE;
528 
529 #elif HAVE_STDIO_H
530  {
531  #ifdef __APPLE__
532  FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
533  #elif __WINRT__
534  FILE *fp = NULL;
535  fopen_s(&fp, file, mode);
536  #else
537  FILE *fp = fopen(file, mode);
538  #endif
539  if (fp == NULL) {
540  SDL_SetError("Couldn't open %s", file);
541  } else {
542  rwops = SDL_RWFromFP(fp, 1);
543  }
544  }
545 #else
546  SDL_SetError("SDL not compiled with stdio support");
547 #endif /* !HAVE_STDIO_H */
548 
549  return rwops;
550 }
int Android_JNI_FileClose(SDL_RWops *ctx)
void SDL_FreeRW(SDL_RWops *area)
Definition: SDL_rwops.c:651
#define SDL_RWOPS_WINFILE
Definition: SDL_rwops.h:43
size_t(* write)(struct SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.h:83
int Android_JNI_FileOpen(SDL_RWops *ctx, const char *fileName, const char *mode)
Uint32 type
Definition: SDL_rwops.h:93
Sint64(* seek)(struct SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.h:65
SDL_RWops * SDL_AllocRW(void)
Definition: SDL_rwops.c:637
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:328
int(* close)(struct SDL_RWops *context)
Definition: SDL_rwops.h:91
SDL_RWops * SDL_RWFromFP(void *fp, SDL_bool autoclose)
Definition: SDL_rwops.c:573
size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, size_t size, size_t num)
GLenum mode
Sint64(* size)(struct SDL_RWops *context)
Definition: SDL_rwops.h:57
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, size_t size, size_t maxnum)
size_t(* read)(struct SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.h:74
#define SDL_snprintf
GLsizei const GLchar *const * path
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:329
#define SDL_AndroidGetInternalStoragePath
Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence)
Sint64 Android_JNI_FileSize(SDL_RWops *ctx)
#define SDL_RWOPS_JNIFILE
Definition: SDL_rwops.h:45

◆ SDL_RWFromFP()

SDL_RWops* SDL_RWFromFP ( void fp,
SDL_bool  autoclose 
)

Definition at line 573 of file SDL_rwops.c.

References NULL, and SDL_SetError.

Referenced by SDL_RWFromFile().

574 {
575  SDL_SetError("SDL not compiled with stdio support");
576  return NULL;
577 }
#define NULL
Definition: begin_code.h:143
#define SDL_SetError

◆ SDL_RWFromMem()

SDL_RWops* SDL_RWFromMem ( void mem,
int  size 
)

Definition at line 581 of file SDL_rwops.c.

References SDL_RWops::close, SDL_RWops::hidden, SDL_RWops::mem, mem_close(), mem_read(), mem_seek(), mem_size(), mem_write(), NULL, SDL_RWops::read, SDL_AllocRW(), SDL_InvalidParamError, SDL_RWOPS_MEMORY, SDL_RWops::seek, SDL_RWops::size, SDL_RWops::type, and SDL_RWops::write.

582 {
583  SDL_RWops *rwops = NULL;
584  if (!mem) {
585  SDL_InvalidParamError("mem");
586  return rwops;
587  }
588  if (!size) {
589  SDL_InvalidParamError("size");
590  return rwops;
591  }
592 
593  rwops = SDL_AllocRW();
594  if (rwops != NULL) {
595  rwops->size = mem_size;
596  rwops->seek = mem_seek;
597  rwops->read = mem_read;
598  rwops->write = mem_write;
599  rwops->close = mem_close;
600  rwops->hidden.mem.base = (Uint8 *) mem;
601  rwops->hidden.mem.here = rwops->hidden.mem.base;
602  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
603  rwops->type = SDL_RWOPS_MEMORY;
604  }
605  return rwops;
606 }
size_t(* write)(struct SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.h:83
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
GLsizeiptr size
static Sint64 mem_size(SDL_RWops *context)
Definition: SDL_rwops.c:379
Uint32 type
Definition: SDL_rwops.h:93
struct SDL_RWops::@10::@13 mem
Sint64(* seek)(struct SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.h:65
static size_t mem_write(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:436
SDL_RWops * SDL_AllocRW(void)
Definition: SDL_rwops.c:637
static int mem_close(SDL_RWops *context)
Definition: SDL_rwops.c:454
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
int(* close)(struct SDL_RWops *context)
Definition: SDL_rwops.h:91
static Sint64 mem_seek(SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.c:385
Sint64(* size)(struct SDL_RWops *context)
Definition: SDL_rwops.h:57
#define NULL
Definition: begin_code.h:143
#define SDL_RWOPS_MEMORY
Definition: SDL_rwops.h:46
union SDL_RWops::@10 hidden
size_t(* read)(struct SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.h:74
static size_t mem_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:413

◆ SDL_WriteBE16()

size_t SDL_WriteBE16 ( SDL_RWops dst,
Uint16  value 
)

Definition at line 735 of file SDL_rwops.c.

References SDL_RWwrite, and SDL_SwapBE16.

736 {
737  const Uint16 swapped = SDL_SwapBE16(value);
738  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
739 }
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
#define SDL_SwapBE16(X)
Definition: SDL_endian.h:215
GLsizei const GLfloat * value
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151

◆ SDL_WriteBE32()

size_t SDL_WriteBE32 ( SDL_RWops dst,
Uint32  value 
)

Definition at line 749 of file SDL_rwops.c.

References SDL_RWwrite, and SDL_SwapBE32.

750 {
751  const Uint32 swapped = SDL_SwapBE32(value);
752  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
753 }
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
#define SDL_SwapBE32(X)
Definition: SDL_endian.h:216
GLsizei const GLfloat * value

◆ SDL_WriteBE64()

size_t SDL_WriteBE64 ( SDL_RWops dst,
Uint64  value 
)

Definition at line 763 of file SDL_rwops.c.

References SDL_RWwrite, and SDL_SwapBE64.

764 {
765  const Uint64 swapped = SDL_SwapBE64(value);
766  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
767 }
#define SDL_SwapBE64(X)
Definition: SDL_endian.h:217
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:168
GLsizei const GLfloat * value

◆ SDL_WriteLE16()

size_t SDL_WriteLE16 ( SDL_RWops dst,
Uint16  value 
)

Definition at line 728 of file SDL_rwops.c.

References SDL_RWwrite, and SDL_SwapLE16.

729 {
730  const Uint16 swapped = SDL_SwapLE16(value);
731  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
732 }
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
GLsizei const GLfloat * value
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
#define SDL_SwapLE16(X)
Definition: SDL_endian.h:211

◆ SDL_WriteLE32()

size_t SDL_WriteLE32 ( SDL_RWops dst,
Uint32  value 
)

Definition at line 742 of file SDL_rwops.c.

References SDL_RWwrite, and SDL_SwapLE32.

743 {
744  const Uint32 swapped = SDL_SwapLE32(value);
745  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
746 }
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
GLsizei const GLfloat * value
#define SDL_SwapLE32(X)
Definition: SDL_endian.h:212

◆ SDL_WriteLE64()

size_t SDL_WriteLE64 ( SDL_RWops dst,
Uint64  value 
)

Definition at line 756 of file SDL_rwops.c.

References SDL_RWwrite, and SDL_SwapLE64.

757 {
758  const Uint64 swapped = SDL_SwapLE64(value);
759  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
760 }
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:168
#define SDL_SwapLE64(X)
Definition: SDL_endian.h:213
GLsizei const GLfloat * value

◆ SDL_WriteU8()

size_t SDL_WriteU8 ( SDL_RWops dst,
Uint8  value 
)

Definition at line 722 of file SDL_rwops.c.

References SDL_RWwrite.

723 {
724  return SDL_RWwrite(dst, &value, sizeof (value), 1);
725 }
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
GLsizei const GLfloat * value