00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef _SDL_rwops_h
00029 #define _SDL_rwops_h
00030
00031 #include "SDL_stdinc.h"
00032 #include "SDL_error.h"
00033
00034 #include "begin_code.h"
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00042 typedef struct SDL_RWops {
00047 int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
00048
00053 int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
00054
00059 int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
00060
00062 int (SDLCALL *close)(struct SDL_RWops *context);
00063
00064 Uint32 type;
00065 union {
00066 #if defined(__WIN32__) && !defined(__SYMBIAN32__)
00067 struct {
00068 int append;
00069 void *h;
00070 struct {
00071 void *data;
00072 int size;
00073 int left;
00074 } buffer;
00075 } win32io;
00076 #endif
00077 #ifdef HAVE_STDIO_H
00078 struct {
00079 int autoclose;
00080 FILE *fp;
00081 } stdio;
00082 #endif
00083 struct {
00084 Uint8 *base;
00085 Uint8 *here;
00086 Uint8 *stop;
00087 } mem;
00088 struct {
00089 void *data1;
00090 } unknown;
00091 } hidden;
00092
00093 } SDL_RWops;
00094
00095
00098
00099 extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
00100
00101 #ifdef HAVE_STDIO_H
00102 extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose);
00103 #endif
00104
00105 extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size);
00106 extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
00107
00108 extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
00109 extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
00110
00115 #define RW_SEEK_SET 0
00116 #define RW_SEEK_CUR 1
00117 #define RW_SEEK_END 2
00119
00120
00122 #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
00123 #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
00124 #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
00125 #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
00126 #define SDL_RWclose(ctx) (ctx)->close(ctx)
00127
00131 extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
00132 extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
00133 extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
00134 extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
00135 extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
00136 extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
00141 extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
00142 extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
00143 extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
00144 extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
00145 extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
00146 extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
00149
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153 #include "close_code.h"
00154
00155 #endif