123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- #ifndef _SDL_rwops_h
- #define _SDL_rwops_h
- #include "SDL_stdinc.h"
- #include "SDL_error.h"
- #include "begin_code.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define SDL_RWOPS_UNKNOWN 0
- #define SDL_RWOPS_WINFILE 1
- #define SDL_RWOPS_STDFILE 2
- #define SDL_RWOPS_JNIFILE 3
- #define SDL_RWOPS_MEMORY 4
- #define SDL_RWOPS_MEMORY_RO 5
- typedef struct SDL_RWops
- {
-
- Sint64 (SDLCALL * size) (struct SDL_RWops * context);
-
- Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset,
- int whence);
-
- size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr,
- size_t size, size_t maxnum);
-
- size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
- size_t size, size_t num);
-
- int (SDLCALL * close) (struct SDL_RWops * context);
- Uint32 type;
- union
- {
- #if defined(ANDROID)
- struct
- {
- void *fileNameRef;
- void *inputStreamRef;
- void *readableByteChannelRef;
- void *readMethod;
- void *assetFileDescriptorRef;
- long position;
- long size;
- long offset;
- int fd;
- } androidio;
- #elif defined(__WIN32__)
- struct
- {
- SDL_bool append;
- void *h;
- struct
- {
- void *data;
- size_t size;
- size_t left;
- } buffer;
- } windowsio;
- #endif
- #ifdef HAVE_STDIO_H
- struct
- {
- SDL_bool autoclose;
- FILE *fp;
- } stdio;
- #endif
- struct
- {
- Uint8 *base;
- Uint8 *here;
- Uint8 *stop;
- } mem;
- struct
- {
- void *data1;
- void *data2;
- } unknown;
- } hidden;
- } SDL_RWops;
- extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
- const char *mode);
- #ifdef HAVE_STDIO_H
- extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp,
- SDL_bool autoclose);
- #else
- extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp,
- SDL_bool autoclose);
- #endif
- extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
- extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem,
- int size);
- extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
- extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
- #define RW_SEEK_SET 0
- #define RW_SEEK_CUR 1
- #define RW_SEEK_END 2
- #define SDL_RWsize(ctx) (ctx)->size(ctx)
- #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
- #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
- #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
- #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
- #define SDL_RWclose(ctx) (ctx)->close(ctx)
- extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src);
- extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
- extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
- extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
- extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src);
- extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src);
- extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
- extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value);
- extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
- extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
- extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
- extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value);
- extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value);
- extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value);
- #ifdef __cplusplus
- }
- #endif
- #include "close_code.h"
- #endif
|