Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
ioapi.c File Reference
#include "ioapi.h"
+ Include dependency graph for ioapi.c:

Go to the source code of this file.

Functions

voidpf call_zopen64 (const zlib_filefunc64_32_def *pfilefunc, const void *filename, int mode)
 
long call_zseek64 (const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, ZPOS64_T offset, int origin)
 
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
 
void fill_zlib_filefunc64_32_def_from_filefunc32 (zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
 
static voidpf ZCALLBACK fopen_file_func OF ((voidpf opaque, const char *filename, int mode))
 
static uLong ZCALLBACK fread_file_func OF ((voidpf opaque, voidpf stream, void *buf, uLong size))
 
static uLong ZCALLBACK fwrite_file_func OF ((voidpf opaque, voidpf stream, const void *buf, uLong size))
 
static ZPOS64_T ZCALLBACK ftell64_file_func OF ((voidpf opaque, voidpf stream))
 
static long ZCALLBACK fseek64_file_func OF ((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin))
 
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char *filename, int mode)
 
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void *filename, int mode)
 
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void *buf, uLong size)
 
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void *buf, uLong size)
 
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
 
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
 
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
 
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
 
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
 
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
 
void fill_fopen_filefunc (zlib_filefunc_def *pzlib_filefunc_def)
 
void fill_fopen64_filefunc (zlib_filefunc64_def *pzlib_filefunc_def)
 

Function Documentation

◆ call_zopen64()

voidpf call_zopen64 ( const zlib_filefunc64_32_def * pfilefunc,
const void * filename,
int mode )

Definition at line 26 of file ioapi.c.

27{
28 if (pfilefunc->zfile_func64.zopen64_file != NULL)
29 return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
30 else
31 {
32 return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
33 }
34}
const char * filename
Definition ioapi.h:133
const char int mode
Definition ioapi.h:133
zlib_filefunc64_def zfile_func64
Definition ioapi.h:178
open_file_func zopen32_file
Definition ioapi.h:179
open64_file_func zopen64_file
Definition ioapi.h:162

References zlib_filefunc64_def_s::opaque, zlib_filefunc64_32_def_s::zfile_func64, zlib_filefunc64_32_def_s::zopen32_file, and zlib_filefunc64_def_s::zopen64_file.

◆ call_zseek64()

long call_zseek64 ( const zlib_filefunc64_32_def * pfilefunc,
voidpf filestream,
ZPOS64_T offset,
int origin )

Definition at line 36 of file ioapi.c.

37{
38 if (pfilefunc->zfile_func64.zseek64_file != NULL)
39 return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
40 else
41 {
42 uLong offsetTruncated = (uLong)offset;
43 if (offsetTruncated != offset)
44 return -1;
45 else
46 return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
47 }
48}
voidpf uLong int origin
Definition ioapi.h:140
voidpf uLong offset
Definition ioapi.h:140
mz_ulong uLong
Definition miniz.h:447
seek_file_func zseek32_file
Definition ioapi.h:181
seek64_file_func zseek64_file
Definition ioapi.h:166

References zlib_filefunc64_def_s::opaque, zlib_filefunc64_32_def_s::zfile_func64, zlib_filefunc64_32_def_s::zseek32_file, and zlib_filefunc64_def_s::zseek64_file.

◆ call_ztell64()

ZPOS64_T call_ztell64 ( const zlib_filefunc64_32_def * pfilefunc,
voidpf filestream )

Definition at line 50 of file ioapi.c.

51{
52 if (pfilefunc->zfile_func64.zseek64_file != NULL)
53 return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
54 else
55 {
56 uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
57 if ((tell_uLong) == ((uLong)-1))
58 return (ZPOS64_T)-1;
59 else
60 return tell_uLong;
61 }
62}
unsigned long long int ZPOS64_T
Definition ioapi.h:98
tell_file_func ztell32_file
Definition ioapi.h:180
tell64_file_func ztell64_file
Definition ioapi.h:165

References zlib_filefunc64_def_s::opaque, zlib_filefunc64_32_def_s::zfile_func64, zlib_filefunc64_def_s::zseek64_file, zlib_filefunc64_32_def_s::ztell32_file, and zlib_filefunc64_def_s::ztell64_file.

◆ fclose_file_func()

static int ZCALLBACK fclose_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 205 of file ioapi.c.

206{
207 int ret;
208 ret = fclose((FILE *)stream);
209 return ret;
210}
voidpf stream
Definition ioapi.h:134

Referenced by fill_fopen64_filefunc(), and fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ ferror_file_func()

static int ZCALLBACK ferror_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 212 of file ioapi.c.

213{
214 int ret;
215 ret = ferror((FILE *)stream);
216 return ret;
217}

Referenced by fill_fopen64_filefunc(), and fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ fill_fopen64_filefunc()

void fill_fopen64_filefunc ( zlib_filefunc64_def * pzlib_filefunc_def)

Definition at line 232 of file ioapi.c.

233{
234 pzlib_filefunc_def->zopen64_file = fopen64_file_func;
235 pzlib_filefunc_def->zread_file = fread_file_func;
236 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
237 pzlib_filefunc_def->ztell64_file = ftell64_file_func;
238 pzlib_filefunc_def->zseek64_file = fseek64_file_func;
239 pzlib_filefunc_def->zclose_file = fclose_file_func;
240 pzlib_filefunc_def->zerror_file = ferror_file_func;
241 pzlib_filefunc_def->opaque = NULL;
242}
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:149
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
Definition ioapi.c:179
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:212
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
Definition ioapi.c:134
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void *filename, int mode)
Definition ioapi.c:108
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
Definition ioapi.c:127
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:205
write_file_func zwrite_file
Definition ioapi.h:164
read_file_func zread_file
Definition ioapi.h:163
close_file_func zclose_file
Definition ioapi.h:167
testerror_file_func zerror_file
Definition ioapi.h:168

References fclose_file_func(), ferror_file_func(), fopen64_file_func(), fread_file_func(), fseek64_file_func(), ftell64_file_func(), fwrite_file_func(), zlib_filefunc64_def_s::opaque, zlib_filefunc64_def_s::zclose_file, zlib_filefunc64_def_s::zerror_file, zlib_filefunc64_def_s::zopen64_file, zlib_filefunc64_def_s::zread_file, zlib_filefunc64_def_s::zseek64_file, zlib_filefunc64_def_s::ztell64_file, and zlib_filefunc64_def_s::zwrite_file.

Referenced by unzOpenInternal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill_fopen_filefunc()

void fill_fopen_filefunc ( zlib_filefunc_def* pzlib_filefunc_def)

Definition at line 219 of file ioapi.c.

221{
222 pzlib_filefunc_def->zopen_file = fopen_file_func;
223 pzlib_filefunc_def->zread_file = fread_file_func;
224 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
225 pzlib_filefunc_def->ztell_file = ftell_file_func;
226 pzlib_filefunc_def->zseek_file = fseek_file_func;
227 pzlib_filefunc_def->zclose_file = fclose_file_func;
228 pzlib_filefunc_def->zerror_file = ferror_file_func;
229 pzlib_filefunc_def->opaque = NULL;
230}
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin)
Definition ioapi.c:156
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char *filename, int mode)
Definition ioapi.c:90
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:141
seek_file_func zseek_file
Definition ioapi.h:150
open_file_func zopen_file
Definition ioapi.h:146
testerror_file_func zerror_file
Definition ioapi.h:152
write_file_func zwrite_file
Definition ioapi.h:148
read_file_func zread_file
Definition ioapi.h:147
close_file_func zclose_file
Definition ioapi.h:151
tell_file_func ztell_file
Definition ioapi.h:149

References fclose_file_func(), ferror_file_func(), fopen_file_func(), fread_file_func(), fseek_file_func(), ftell_file_func(), and fwrite_file_func().

+ Here is the call graph for this function:

◆ fill_zlib_filefunc64_32_def_from_filefunc32()

void fill_zlib_filefunc64_32_def_from_filefunc32 ( zlib_filefunc64_32_def * p_filefunc64_32,
const zlib_filefunc_def * p_filefunc32 )

Definition at line 64 of file ioapi.c.

65{
66 p_filefunc64_32->zfile_func64.zopen64_file = NULL;
67 p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
68 p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
69 p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
70 p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
71 p_filefunc64_32->zfile_func64.ztell64_file = NULL;
72 p_filefunc64_32->zfile_func64.zseek64_file = NULL;
73 p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
74 p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
75 p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
76 p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
77 p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
78}

References zlib_filefunc64_def_s::opaque, zlib_filefunc_def_s::opaque, zlib_filefunc64_def_s::zclose_file, zlib_filefunc_def_s::zclose_file, zlib_filefunc64_def_s::zerror_file, zlib_filefunc_def_s::zerror_file, zlib_filefunc64_32_def_s::zfile_func64, zlib_filefunc64_32_def_s::zopen32_file, zlib_filefunc64_def_s::zopen64_file, zlib_filefunc_def_s::zopen_file, zlib_filefunc64_def_s::zread_file, zlib_filefunc_def_s::zread_file, zlib_filefunc64_32_def_s::zseek32_file, zlib_filefunc64_def_s::zseek64_file, zlib_filefunc_def_s::zseek_file, zlib_filefunc64_32_def_s::ztell32_file, zlib_filefunc64_def_s::ztell64_file, zlib_filefunc_def_s::ztell_file, zlib_filefunc64_def_s::zwrite_file, and zlib_filefunc_def_s::zwrite_file.

Referenced by unzOpen2().

+ Here is the caller graph for this function:

◆ fopen64_file_func()

static voidpf ZCALLBACK fopen64_file_func ( voidpf opaque,
const void * filename,
int mode )
static

Definition at line 108 of file ioapi.c.

109{
110 FILE* file = NULL;
111 const char* mode_fopen = NULL;
113 mode_fopen = "rb";
114 else
116 mode_fopen = "r+b";
117 else
119 mode_fopen = "wb";
120
121 if ((filename!=NULL) && (mode_fopen != NULL))
122 file = fopen64((const char*)filename, mode_fopen);
123 return file;
124}
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER
Definition ioapi.h:116
#define ZLIB_FILEFUNC_MODE_EXISTING
Definition ioapi.h:118
#define ZLIB_FILEFUNC_MODE_CREATE
Definition ioapi.h:119
#define ZLIB_FILEFUNC_MODE_READ
Definition ioapi.h:114

References ZLIB_FILEFUNC_MODE_CREATE, ZLIB_FILEFUNC_MODE_EXISTING, ZLIB_FILEFUNC_MODE_READ, and ZLIB_FILEFUNC_MODE_READWRITEFILTER.

Referenced by fill_fopen64_filefunc().

+ Here is the caller graph for this function:

◆ fopen_file_func()

static voidpf ZCALLBACK fopen_file_func ( voidpf opaque,
const char * filename,
int mode )
static

Definition at line 90 of file ioapi.c.

91{
92 FILE* file = NULL;
93 const char* mode_fopen = NULL;
95 mode_fopen = "rb";
96 else
98 mode_fopen = "r+b";
99 else
101 mode_fopen = "wb";
102
103 if ((filename!=NULL) && (mode_fopen != NULL))
104 file = fopen(filename, mode_fopen);
105 return file;
106}

References ZLIB_FILEFUNC_MODE_CREATE, ZLIB_FILEFUNC_MODE_EXISTING, ZLIB_FILEFUNC_MODE_READ, and ZLIB_FILEFUNC_MODE_READWRITEFILTER.

Referenced by fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ fread_file_func()

static uLong ZCALLBACK fread_file_func ( voidpf opaque,
voidpf stream,
void * buf,
uLong size )
static

Definition at line 127 of file ioapi.c.

128{
129 uLong ret;
130 ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
131 return ret;
132}
voidpf void uLong size
Definition ioapi.h:134
voidpf void * buf
Definition ioapi.h:134

Referenced by fill_fopen64_filefunc(), and fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ fseek64_file_func()

static long ZCALLBACK fseek64_file_func ( voidpf opaque,
voidpf stream,
ZPOS64_T offset,
int origin )
static

Definition at line 179 of file ioapi.c.

180{
181 int fseek_origin=0;
182 long ret;
183 switch (origin)
184 {
186 fseek_origin = SEEK_CUR;
187 break;
189 fseek_origin = SEEK_END;
190 break;
192 fseek_origin = SEEK_SET;
193 break;
194 default: return -1;
195 }
196 ret = 0;
197
198 if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
199 ret = -1;
200
201 return ret;
202}
#define ZLIB_FILEFUNC_SEEK_CUR
Definition ioapi.h:110
#define ZLIB_FILEFUNC_SEEK_SET
Definition ioapi.h:112
#define ZLIB_FILEFUNC_SEEK_END
Definition ioapi.h:111

References ZLIB_FILEFUNC_SEEK_CUR, ZLIB_FILEFUNC_SEEK_END, and ZLIB_FILEFUNC_SEEK_SET.

Referenced by fill_fopen64_filefunc().

+ Here is the caller graph for this function:

◆ fseek_file_func()

static long ZCALLBACK fseek_file_func ( voidpf opaque,
voidpf stream,
uLong offset,
int origin )
static

Definition at line 156 of file ioapi.c.

157{
158 int fseek_origin=0;
159 long ret;
160 switch (origin)
161 {
163 fseek_origin = SEEK_CUR;
164 break;
166 fseek_origin = SEEK_END;
167 break;
169 fseek_origin = SEEK_SET;
170 break;
171 default: return -1;
172 }
173 ret = 0;
174 if (fseek((FILE *)stream, offset, fseek_origin) != 0)
175 ret = -1;
176 return ret;
177}

References ZLIB_FILEFUNC_SEEK_CUR, ZLIB_FILEFUNC_SEEK_END, and ZLIB_FILEFUNC_SEEK_SET.

Referenced by fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ ftell64_file_func()

static ZPOS64_T ZCALLBACK ftell64_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 149 of file ioapi.c.

150{
151 ZPOS64_T ret;
152 ret = ftello64((FILE *)stream);
153 return ret;
154}

Referenced by fill_fopen64_filefunc().

+ Here is the caller graph for this function:

◆ ftell_file_func()

static long ZCALLBACK ftell_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 141 of file ioapi.c.

142{
143 long ret;
144 ret = ftell((FILE *)stream);
145 return ret;
146}

Referenced by fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ fwrite_file_func()

static uLong ZCALLBACK fwrite_file_func ( voidpf opaque,
voidpf stream,
const void * buf,
uLong size )
static

Definition at line 134 of file ioapi.c.

135{
136 uLong ret;
137 ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
138 return ret;
139}

Referenced by fill_fopen64_filefunc(), and fill_fopen_filefunc().

+ Here is the caller graph for this function:

◆ OF() [1/5]

static voidpf ZCALLBACK fopen_file_func OF ( (voidpf opaque, const char *filename, int mode) )
static

◆ OF() [2/5]

static int ZCALLBACK ferror_file_func OF ( (voidpf opaque, voidpf stream) )
static

◆ OF() [3/5]

static uLong ZCALLBACK fwrite_file_func OF ( (voidpf opaque, voidpf stream, const void *buf, uLong size) )
static

◆ OF() [4/5]

static uLong ZCALLBACK fread_file_func OF ( (voidpf opaque, voidpf stream, void *buf, uLong size) )
static

◆ OF() [5/5]