Oolite
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 return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque, (const char*)filename, mode);
32 }
33}
const char * filename
Definition ioapi.h:125
const char int mode
Definition ioapi.h:125
zlib_filefunc64_def zfile_func64
Definition ioapi.h:166
open_file_func zopen32_file
Definition ioapi.h:167
open64_file_func zopen64_file
Definition ioapi.h:151

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.

Referenced by OF().

Here is the caller graph for this function:

◆ call_zseek64()

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

Definition at line 35 of file ioapi.c.

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

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.

Referenced by OF().

Here is the caller graph for this function:

◆ call_ztell64()

ZPOS64_T call_ztell64 ( const zlib_filefunc64_32_def * pfilefunc,
voidpf filestream )

Definition at line 48 of file ioapi.c.

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

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.

Referenced by OF().

Here is the caller graph for this function:

◆ fclose_file_func()

int ZCALLBACK fclose_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 193 of file ioapi.c.

194{
195 int ret;
196 ret = fclose((FILE*)stream);
197 return ret;
198}
voidpf stream
Definition ioapi.h:126

References ZCALLBACK.

Referenced by fill_fopen64_filefunc(), fill_fopen_filefunc(), and OF().

Here is the caller graph for this function:

◆ ferror_file_func()

int ZCALLBACK ferror_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 200 of file ioapi.c.

201{
202 int ret;
203 ret = ferror((FILE*)stream);
204 return ret;
205}

References ZCALLBACK.

Referenced by fill_fopen64_filefunc(), fill_fopen_filefunc(), and OF().

Here is the caller graph for this function:

◆ fill_fopen64_filefunc()

void fill_fopen64_filefunc ( zlib_filefunc64_def * pzlib_filefunc_def)

Definition at line 219 of file ioapi.c.

220{
221 pzlib_filefunc_def->zopen64_file = fopen64_file_func;
222 pzlib_filefunc_def->zread_file = fread_file_func;
223 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
224 pzlib_filefunc_def->ztell64_file = ftell64_file_func;
225 pzlib_filefunc_def->zseek64_file = fseek64_file_func;
226 pzlib_filefunc_def->zclose_file = fclose_file_func;
227 pzlib_filefunc_def->zerror_file = ferror_file_func;
228 pzlib_filefunc_def->opaque = NULL;
229}
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:138
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
Definition ioapi.c:168
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:200
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
Definition ioapi.c:124
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void *filename, int mode)
Definition ioapi.c:101
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
Definition ioapi.c:117
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:193
write_file_func zwrite_file
Definition ioapi.h:153
read_file_func zread_file
Definition ioapi.h:152
close_file_func zclose_file
Definition ioapi.h:156
testerror_file_func zerror_file
Definition ioapi.h:157

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 OF(), and 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 207 of file ioapi.c.

208{
209 pzlib_filefunc_def->zopen_file = fopen_file_func;
210 pzlib_filefunc_def->zread_file = fread_file_func;
211 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
212 pzlib_filefunc_def->ztell_file = ftell_file_func;
213 pzlib_filefunc_def->zseek_file = fseek_file_func;
214 pzlib_filefunc_def->zclose_file = fclose_file_func;
215 pzlib_filefunc_def->zerror_file = ferror_file_func;
216 pzlib_filefunc_def->opaque = NULL;
217}
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin)
Definition ioapi.c:145
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char *filename, int mode)
Definition ioapi.c:85
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream)
Definition ioapi.c:131
seek_file_func zseek_file
Definition ioapi.h:140
open_file_func zopen_file
Definition ioapi.h:136
testerror_file_func zerror_file
Definition ioapi.h:142
write_file_func zwrite_file
Definition ioapi.h:138
read_file_func zread_file
Definition ioapi.h:137
close_file_func zclose_file
Definition ioapi.h:141
tell_file_func ztell_file
Definition ioapi.h:139

References fclose_file_func(), ferror_file_func(), fopen_file_func(), fread_file_func(), fseek_file_func(), ftell_file_func(), fwrite_file_func(), zlib_filefunc_def_s::opaque, zlib_filefunc_def_s::zclose_file, zlib_filefunc_def_s::zerror_file, zlib_filefunc_def_s::zopen_file, zlib_filefunc_def_s::zread_file, zlib_filefunc_def_s::zseek_file, zlib_filefunc_def_s::ztell_file, and zlib_filefunc_def_s::zwrite_file.

Referenced by OF().

Here is the call graph for this function:
Here is the caller 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 61 of file ioapi.c.

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

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()

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

Definition at line 101 of file ioapi.c.

102{
103 FILE* file = NULL;
104 const char* mode_fopen = NULL;
106 mode_fopen = "rb";
108 mode_fopen = "r+b";
110 mode_fopen = "wb";
111
112 if ((filename != NULL) && (mode_fopen != NULL))
113 file = fopen64((const char*)filename, mode_fopen);
114 return file;
115}
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER
Definition ioapi.h:112
#define ZLIB_FILEFUNC_MODE_EXISTING
Definition ioapi.h:114
#define ZLIB_FILEFUNC_MODE_CREATE
Definition ioapi.h:115
#define ZLIB_FILEFUNC_MODE_READ
Definition ioapi.h:110

References ZCALLBACK, 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()

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

Definition at line 85 of file ioapi.c.

86{
87 FILE* file = NULL;
88 const char* mode_fopen = NULL;
90 mode_fopen = "rb";
92 mode_fopen = "r+b";
94 mode_fopen = "wb";
95
96 if ((filename != NULL) && (mode_fopen != NULL))
97 file = fopen(filename, mode_fopen);
98 return file;
99}

References ZCALLBACK, ZLIB_FILEFUNC_MODE_CREATE, ZLIB_FILEFUNC_MODE_EXISTING, ZLIB_FILEFUNC_MODE_READ, and ZLIB_FILEFUNC_MODE_READWRITEFILTER.

Referenced by fill_fopen_filefunc(), and OF().

Here is the caller graph for this function:

◆ fread_file_func()

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

Definition at line 117 of file ioapi.c.

118{
119 uLong ret;
120 ret = (uLong)fread(buf, 1, (size_t)size, (FILE*)stream);
121 return ret;
122}
voidpf void uLong size
Definition ioapi.h:126
voidpf void * buf
Definition ioapi.h:126

References ZCALLBACK.

Referenced by fill_fopen64_filefunc(), fill_fopen_filefunc(), and OF().

Here is the caller graph for this function:

◆ fseek64_file_func()

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

Definition at line 168 of file ioapi.c.

169{
170 int fseek_origin = 0;
171 long ret;
172 switch (origin) {
174 fseek_origin = SEEK_CUR;
175 break;
177 fseek_origin = SEEK_END;
178 break;
180 fseek_origin = SEEK_SET;
181 break;
182 default:
183 return -1;
184 }
185 ret = 0;
186
187 if (fseeko64((FILE*)stream, offset, fseek_origin) != 0)
188 ret = -1;
189
190 return ret;
191}
#define ZLIB_FILEFUNC_SEEK_CUR
Definition ioapi.h:106
#define ZLIB_FILEFUNC_SEEK_SET
Definition ioapi.h:108
#define ZLIB_FILEFUNC_SEEK_END
Definition ioapi.h:107

References ZCALLBACK, ZLIB_FILEFUNC_SEEK_CUR, ZLIB_FILEFUNC_SEEK_END, and ZLIB_FILEFUNC_SEEK_SET.

Referenced by fill_fopen64_filefunc(), and OF().

Here is the caller graph for this function:

◆ fseek_file_func()

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

Definition at line 145 of file ioapi.c.

146{
147 int fseek_origin = 0;
148 long ret;
149 switch (origin) {
151 fseek_origin = SEEK_CUR;
152 break;
154 fseek_origin = SEEK_END;
155 break;
157 fseek_origin = SEEK_SET;
158 break;
159 default:
160 return -1;
161 }
162 ret = 0;
163 if (fseek((FILE*)stream, offset, fseek_origin) != 0)
164 ret = -1;
165 return ret;
166}

References ZCALLBACK, 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()

ZPOS64_T ZCALLBACK ftell64_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 138 of file ioapi.c.

139{
140 ZPOS64_T ret;
141 ret = ftello64((FILE*)stream);
142 return ret;
143}

References ZCALLBACK.

Referenced by fill_fopen64_filefunc(), and OF().

Here is the caller graph for this function:

◆ ftell_file_func()

long ZCALLBACK ftell_file_func ( voidpf opaque,
voidpf stream )
static

Definition at line 131 of file ioapi.c.

132{
133 long ret;
134 ret = ftell((FILE*)stream);
135 return ret;
136}

References ZCALLBACK.

Referenced by fill_fopen_filefunc().

Here is the caller graph for this function:

◆ fwrite_file_func()

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

Definition at line 124 of file ioapi.c.

125{
126 uLong ret;
127 ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE*)stream);
128 return ret;
129}

References ZCALLBACK.

Referenced by fill_fopen64_filefunc(), fill_fopen_filefunc(), and OF().

Here is the caller graph for this function:

◆ OF() [1/5]

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

References fopen_file_func(), and ZCALLBACK.

Here is the call graph for this function:

◆ OF() [2/5]

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

References ftell64_file_func(), and ZCALLBACK.

Here is the call graph for this function:

◆ OF() [3/5]

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

References fwrite_file_func(), and ZCALLBACK.

Here is the call graph for this function:

◆ OF() [4/5]

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

References fread_file_func(), and ZCALLBACK.

Here is the call graph for this function:

◆ OF() [5/5]

References fclose_file_func(), ferror_file_func(), fseek64_file_func(), and ZCALLBACK.

Here is the call graph for this function: