69 #ifndef _MGUI_ENDIAN_RW_H 70 #define _MGUI_ENDIAN_RW_H 100 #define RWAREA_TYPE_UNKNOWN 0 101 #define RWAREA_TYPE_STDIO 1 102 #define RWAREA_TYPE_MEM 2 130 #ifdef _MGUSE_OWN_STDIO 132 int (*ungetc)(
struct _MG_RWops *context,
unsigned char c);
219 MG_EXPORT
MG_RWops* MGUI_RWFromMem(
void *mem,
size_t size);
236 MG_EXPORT
void MGUI_InitMemRW (
MG_RWops* area,
void *mem,
size_t size);
284 #define MGUI_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) 299 #define MGUI_RWtell(ctx) (ctx)->seek(ctx, 0, SEEK_CUR) 316 #define MGUI_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) 333 #define MGUI_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) 348 #define MGUI_RWclose(ctx) (ctx)->close(ctx) 363 #define MGUI_RWeof(ctx) (ctx)->eof(ctx) 411 #ifdef __arch__swab16 412 #define ArchSwap16 __arch__swab16 414 #ifdef __arch__swab32 415 #define ArchSwap32 __arch__swab32 426 return((D<<8)|(D>>8));
431 return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
434 #ifdef MGUI_HAS_64BIT_TYPE 440 lo = (
Uint32)(val&0xFFFFFFFF);
442 hi = (
Uint32)(val&0xFFFFFFFF);
443 val = ArchSwap32(lo);
445 val |= ArchSwap32(hi);
455 #define ArchSwap64(X) (X) 460 #if MGUI_BYTEORDER == MGUI_LIL_ENDIAN 462 #define ArchSwapLE16(X) (X) 464 #define ArchSwapLE32(X) (X) 466 #define ArchSwapLE64(X) (X) 468 #define ArchSwapBE16(X) ArchSwap16(X) 470 #define ArchSwapBE32(X) ArchSwap32(X) 472 #define ArchSwapBE64(X) ArchSwap64(X) 474 #define ArchSwapLE16(X) ArchSwap16(X) 475 #define ArchSwapLE32(X) ArchSwap32(X) 476 #define ArchSwapLE64(X) ArchSwap64(X) 477 #define ArchSwapBE16(X) (X) 478 #define ArchSwapBE32(X) (X) 479 #define ArchSwapBE64(X) (X) 722 static inline Uint16 MGUI_ReadLE16Mem (
const Uint8** data)
727 h1 = *(*data); (*data)++;
728 h2 = *(*data); (*data)++;
732 memcpy (&u, *data,
sizeof (
Uint16));
739 static inline Uint32 MGUI_ReadLE32Mem (
const Uint8** data)
744 q1 = *(*data); (*data)++;
745 q2 = *(*data); (*data)++;
746 q3 = *(*data); (*data)++;
747 q4 = *(*data); (*data)++;
748 return ((q4<<24)|(q3<<16)|(q2<<8)|(q1));
751 memcpy (&u, *data,
sizeof (
Uint32));
758 static inline Uint16 MGUI_ReadBE16Mem (
const Uint8** data)
763 h1 = *(*data); (*data)++;
764 h2 = *(*data); (*data)++;
768 memcpy (&u, *data,
sizeof (
Uint16));
775 static inline Uint32 MGUI_ReadBE32Mem (
const Uint8** data)
780 q1 = *(*data); (*data)++;
781 q2 = *(*data); (*data)++;
782 q3 = *(*data); (*data)++;
783 q4 = *(*data); (*data)++;
784 return ((q1<<24)|(q2<<16)|(q3<<8)|(q4));
787 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_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.
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