57 #ifndef _MGUI_ENDIAN_RW_H 58 #define _MGUI_ENDIAN_RW_H 88 #define RWAREA_TYPE_UNKNOWN 0 89 #define RWAREA_TYPE_STDIO 1 90 #define RWAREA_TYPE_MEM 2 118 #ifdef _MGUSE_OWN_STDIO 120 int (*ungetc)(
struct _MG_RWops *context,
unsigned char c);
272 #define MGUI_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) 287 #define MGUI_RWtell(ctx) (ctx)->seek(ctx, 0, SEEK_CUR) 304 #define MGUI_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) 321 #define MGUI_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) 336 #define MGUI_RWclose(ctx) (ctx)->close(ctx) 351 #define MGUI_RWeof(ctx) (ctx)->eof(ctx) 399 #ifdef __arch__swab16 400 #define ArchSwap16 __arch__swab16 402 #ifdef __arch__swab32 403 #define ArchSwap32 __arch__swab32 414 return((D<<8)|(D>>8));
419 return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
422 #ifdef MGUI_HAS_64BIT_TYPE 428 lo = (
Uint32)(val&0xFFFFFFFF);
430 hi = (
Uint32)(val&0xFFFFFFFF);
431 val = ArchSwap32(lo);
433 val |= ArchSwap32(hi);
443 #define ArchSwap64(X) (X) 448 #if MGUI_BYTEORDER == MGUI_LIL_ENDIAN 450 #define ArchSwapLE16(X) (X) 452 #define ArchSwapLE32(X) (X) 454 #define ArchSwapLE64(X) (X) 456 #define ArchSwapBE16(X) ArchSwap16(X) 458 #define ArchSwapBE32(X) ArchSwap32(X) 460 #define ArchSwapBE64(X) ArchSwap64(X) 462 #define ArchSwapLE16(X) ArchSwap16(X) 463 #define ArchSwapLE32(X) ArchSwap32(X) 464 #define ArchSwapLE64(X) ArchSwap64(X) 465 #define ArchSwapBE16(X) (X) 466 #define ArchSwapBE32(X) (X) 467 #define ArchSwapBE64(X) (X) 710 static inline Uint16 MGUI_ReadLE16Mem (
const Uint8** data)
715 h1 = *(*data); (*data)++;
716 h2 = *(*data); (*data)++;
720 memcpy (&u, *data,
sizeof (
Uint16));
727 static inline Uint32 MGUI_ReadLE32Mem (
const Uint8** data)
732 q1 = *(*data); (*data)++;
733 q2 = *(*data); (*data)++;
734 q3 = *(*data); (*data)++;
735 q4 = *(*data); (*data)++;
736 return ((q4<<24)|(q3<<16)|(q2<<8)|(q1));
739 memcpy (&u, *data,
sizeof (
Uint32));
746 static inline Uint16 MGUI_ReadBE16Mem (
const Uint8** data)
751 h1 = *(*data); (*data)++;
752 h2 = *(*data); (*data)++;
756 memcpy (&u, *data,
sizeof (
Uint16));
763 static inline Uint32 MGUI_ReadBE32Mem (
const Uint8** data)
768 q1 = *(*data); (*data)++;
769 q2 = *(*data); (*data)++;
770 q3 = *(*data); (*data)++;
771 q4 = *(*data); (*data)++;
772 return ((q1<<24)|(q2<<16)|(q3<<8)|(q4));
775 memcpy (&u, *data,
sizeof (
Uint32));
int(* seek)(struct _MG_RWops *context, int offset, int whence)
Uint32 MGUI_ReadLE32FP(FILE *src)
Reads a 32-bit little endian integer from a stdio FILE object.
Uint16 MGUI_ReadLE16FP(FILE *src)
Reads a 16-bit little endian integer from a stdio FILE object.
MG_EXPORT void MGUI_FreeRW(MG_RWops *area)
Frees an MG_RWops object.
int(* write)(struct _MG_RWops *context, const void *ptr, int objsize, int num)
int MGUI_WriteBE64(MG_RWops *dst, Uint64 value)
Writes an 64-bit integer of native format to a MG_RWops object in big endianness. ...
Uint64 MGUI_ReadBE64(MG_RWops *src)
Reads a 64-bit big endian integer from a MG_RWops object.
unsigned long long Uint64
A type definition for a 64-bit unsigned integer.
int MGUI_WriteLE16FP(FILE *dst, Uint16 value)
Writes an 16-bit integer of native format to a stdio FILE object in littlen endianness.
MG_EXPORT int MGUI_RWgetc(MG_RWops *area)
Reads the next character from an data source.
unsigned short Uint16
A type definition for a 16-bit unsigned integer.
int MGUI_WriteLE64(MG_RWops *dst, Uint64 value)
Writes an 64-bit integer of native format to a MG_RWops object in littlen endianness.
Uint32 MGUI_ReadLE32(MG_RWops *src)
Reads a 32-bit little endian integer from a MG_RWops object.
int MGUI_WriteLE16(MG_RWops *dst, Uint16 value)
Writes an 16-bit integer of native format to a MG_RWops object in littlen endianness.
int(* close)(struct _MG_RWops *context)
MG_EXPORT MG_RWops * MGUI_RWFromMem(void *mem, int size)
Creates an MG_RWops object from a block of memory.
MG_EXPORT MG_RWops * MGUI_RWFromFP(FILE *fp, int autoclose)
Creates an MG_RWops object from an opened stdio FILE object.
Uint16 MGUI_ReadLE16(MG_RWops *src)
Reads a 16-bit little endian integer from a MG_RWops object.
MG_EXPORT void MGUI_InitMemRW(MG_RWops *area, void *mem, int size)
Initializes an MG_RWops object from a block of memory.
int MGUI_WriteBE32(MG_RWops *dst, Uint32 value)
Writes an 32-bit integer of native format to a MG_RWops object in big endianness. ...
Uint16 MGUI_ReadBE16(MG_RWops *src)
Reads a 16-bit big endian integer from a MG_RWops object.
int(* eof)(struct _MG_RWops *context)
unsigned char Uint8
A type definition for an 8-bit unsigned character.
int MGUI_WriteLE32(MG_RWops *dst, Uint32 value)
Writes an 32-bit integer of native format to a MG_RWops object in littlen endianness.
unsigned int Uint32
A type definition for a 32-bit unsigned integer.
MG_EXPORT MG_RWops * MGUI_RWFromFile(const char *file, const char *mode)
Creates an MG_RWops object from a file.
int MGUI_WriteBE16(MG_RWops *dst, Uint16 value)
Writes an 16-bit integer of native format to a MG_RWops object in big endianness. ...
Uint64 MGUI_ReadLE64(MG_RWops *src)
Reads a 64-bit little endian integer from a MG_RWops object.
int(* read)(struct _MG_RWops *context, void *ptr, int objsize, int num)
int MGUI_WriteLE32FP(FILE *dst, Uint32 value)
Writes an 32-bit integer of native format to a stdio FILE object in littlen endianness.
Uint32 MGUI_ReadBE32(MG_RWops *src)
Reads a 32-bit big endian integer from a MG_RWops object.
MG_EXPORT MG_RWops * MGUI_AllocRW(void)
Allocates an uninitialized MG_RWops object.
struct _MG_RWops MG_RWops