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