14
14
#define _CRT_SECURE_NO_WARNINGS
15
15
#endif
16
16
17
- #if defined(__APPLE__ ) || defined(IOAPI_NO_64 )
17
+ #if defined(__APPLE__ ) || defined(IOAPI_NO_64 ) || defined( __HAIKU__ ) || defined( MINIZIP_FOPEN_NO_64 )
18
18
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
19
19
#define FOPEN_FUNC (filename , mode ) fopen(filename, mode)
20
20
#define FTELLO_FUNC (stream ) ftello(stream)
28
28
29
29
#include "ioapi.h"
30
30
31
- voidpf call_zopen64 (const zlib_filefunc64_32_def * pfilefunc ,const void * filename ,int mode )
32
- {
31
+ voidpf call_zopen64 (const zlib_filefunc64_32_def * pfilefunc , const void * filename , int mode ) {
33
32
if (pfilefunc -> zfile_func64 .zopen64_file != NULL )
34
33
return (* (pfilefunc -> zfile_func64 .zopen64_file )) (pfilefunc -> zfile_func64 .opaque ,filename ,mode );
35
34
else
@@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
38
37
}
39
38
}
40
39
41
- long call_zseek64 (const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream , ZPOS64_T offset , int origin )
42
- {
40
+ long call_zseek64 (const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream , ZPOS64_T offset , int origin ) {
43
41
if (pfilefunc -> zfile_func64 .zseek64_file != NULL )
44
42
return (* (pfilefunc -> zfile_func64 .zseek64_file )) (pfilefunc -> zfile_func64 .opaque ,filestream ,offset ,origin );
45
43
else
@@ -52,25 +50,22 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
52
50
}
53
51
}
54
52
55
- ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream )
56
- {
53
+ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def * pfilefunc , voidpf filestream ) {
57
54
if (pfilefunc -> zfile_func64 .zseek64_file != NULL )
58
55
return (* (pfilefunc -> zfile_func64 .ztell64_file )) (pfilefunc -> zfile_func64 .opaque ,filestream );
59
56
else
60
57
{
61
- uLong tell_uLong = (* (pfilefunc -> ztell32_file ))(pfilefunc -> zfile_func64 .opaque ,filestream );
58
+ uLong tell_uLong = (uLong )( * (pfilefunc -> ztell32_file ))(pfilefunc -> zfile_func64 .opaque ,filestream );
62
59
if ((tell_uLong ) == MAXU32 )
63
60
return (ZPOS64_T )- 1 ;
64
61
else
65
62
return tell_uLong ;
66
63
}
67
64
}
68
65
69
- void fill_zlib_filefunc64_32_def_from_filefunc32 (zlib_filefunc64_32_def * p_filefunc64_32 ,const zlib_filefunc_def * p_filefunc32 )
70
- {
66
+ void fill_zlib_filefunc64_32_def_from_filefunc32 (zlib_filefunc64_32_def * p_filefunc64_32 , const zlib_filefunc_def * p_filefunc32 ) {
71
67
p_filefunc64_32 -> zfile_func64 .zopen64_file = NULL ;
72
68
p_filefunc64_32 -> zopen32_file = p_filefunc32 -> zopen_file ;
73
- p_filefunc64_32 -> zfile_func64 .zerror_file = p_filefunc32 -> zerror_file ;
74
69
p_filefunc64_32 -> zfile_func64 .zread_file = p_filefunc32 -> zread_file ;
75
70
p_filefunc64_32 -> zfile_func64 .zwrite_file = p_filefunc32 -> zwrite_file ;
76
71
p_filefunc64_32 -> zfile_func64 .ztell64_file = NULL ;
@@ -84,18 +79,10 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
84
79
85
80
86
81
87
- static voidpf ZCALLBACK fopen_file_func OF ( (voidpf opaque , const char * filename , int mode ));
88
- static uLong ZCALLBACK fread_file_func OF ( (voidpf opaque , voidpf stream , void * buf , uLong size ));
89
- static uLong ZCALLBACK fwrite_file_func OF ( (voidpf opaque , voidpf stream , const void * buf ,uLong size ));
90
- static ZPOS64_T ZCALLBACK ftell64_file_func OF ( (voidpf opaque , voidpf stream ));
91
- static long ZCALLBACK fseek64_file_func OF ((voidpf opaque , voidpf stream , ZPOS64_T offset , int origin ));
92
- static int ZCALLBACK fclose_file_func OF ( (voidpf opaque , voidpf stream ));
93
- static int ZCALLBACK ferror_file_func OF ( (voidpf opaque , voidpf stream ));
94
-
95
- static voidpf ZCALLBACK fopen_file_func (voidpf opaque , const char * filename , int mode )
96
- {
82
+ static voidpf ZCALLBACK fopen_file_func (voidpf opaque , const char * filename , int mode ) {
97
83
FILE * file = NULL ;
98
84
const char * mode_fopen = NULL ;
85
+ (void )opaque ;
99
86
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER )== ZLIB_FILEFUNC_MODE_READ )
100
87
mode_fopen = "rb" ;
101
88
else
@@ -110,10 +97,10 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
110
97
return file ;
111
98
}
112
99
113
- static voidpf ZCALLBACK fopen64_file_func (voidpf opaque , const void * filename , int mode )
114
- {
100
+ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque , const void * filename , int mode ) {
115
101
FILE * file = NULL ;
116
102
const char * mode_fopen = NULL ;
103
+ (void )opaque ;
117
104
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER )== ZLIB_FILEFUNC_MODE_READ )
118
105
mode_fopen = "rb" ;
119
106
else
@@ -129,39 +116,39 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
129
116
}
130
117
131
118
132
- static uLong ZCALLBACK fread_file_func (voidpf opaque , voidpf stream , void * buf , uLong size )
133
- {
119
+ static uLong ZCALLBACK fread_file_func (voidpf opaque , voidpf stream , void * buf , uLong size ) {
134
120
uLong ret ;
121
+ (void )opaque ;
135
122
ret = (uLong )fread (buf , 1 , (size_t )size , (FILE * )stream );
136
123
return ret ;
137
124
}
138
125
139
- static uLong ZCALLBACK fwrite_file_func (voidpf opaque , voidpf stream , const void * buf , uLong size )
140
- {
126
+ static uLong ZCALLBACK fwrite_file_func (voidpf opaque , voidpf stream , const void * buf , uLong size ) {
141
127
uLong ret ;
128
+ (void )opaque ;
142
129
ret = (uLong )fwrite (buf , 1 , (size_t )size , (FILE * )stream );
143
130
return ret ;
144
131
}
145
132
146
- static long ZCALLBACK ftell_file_func (voidpf opaque , voidpf stream )
147
- {
133
+ static long ZCALLBACK ftell_file_func (voidpf opaque , voidpf stream ) {
148
134
long ret ;
135
+ (void )opaque ;
149
136
ret = ftell ((FILE * )stream );
150
137
return ret ;
151
138
}
152
139
153
140
154
- static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque , voidpf stream )
155
- {
141
+ static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque , voidpf stream ) {
156
142
ZPOS64_T ret ;
157
- ret = FTELLO_FUNC ((FILE * )stream );
143
+ (void )opaque ;
144
+ ret = (ZPOS64_T )FTELLO_FUNC ((FILE * )stream );
158
145
return ret ;
159
146
}
160
147
161
- static long ZCALLBACK fseek_file_func (voidpf opaque , voidpf stream , uLong offset , int origin )
162
- {
148
+ static long ZCALLBACK fseek_file_func (voidpf opaque , voidpf stream , uLong offset , int origin ) {
163
149
int fseek_origin = 0 ;
164
150
long ret ;
151
+ (void )opaque ;
165
152
switch (origin )
166
153
{
167
154
case ZLIB_FILEFUNC_SEEK_CUR :
@@ -176,15 +163,15 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
176
163
default : return -1 ;
177
164
}
178
165
ret = 0 ;
179
- if (fseek ((FILE * )stream , offset , fseek_origin ) != 0 )
166
+ if (fseek ((FILE * )stream , ( long ) offset , fseek_origin ) != 0 )
180
167
ret = -1 ;
181
168
return ret ;
182
169
}
183
170
184
- static long ZCALLBACK fseek64_file_func (voidpf opaque , voidpf stream , ZPOS64_T offset , int origin )
185
- {
171
+ static long ZCALLBACK fseek64_file_func (voidpf opaque , voidpf stream , ZPOS64_T offset , int origin ) {
186
172
int fseek_origin = 0 ;
187
173
long ret ;
174
+ (void )opaque ;
188
175
switch (origin )
189
176
{
190
177
case ZLIB_FILEFUNC_SEEK_CUR :
@@ -200,30 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
200
187
}
201
188
ret = 0 ;
202
189
203
- if (FSEEKO_FUNC ((FILE * )stream , offset , fseek_origin ) != 0 )
190
+ if (FSEEKO_FUNC ((FILE * )stream , ( z_off64_t ) offset , fseek_origin ) != 0 )
204
191
ret = -1 ;
205
192
206
193
return ret ;
207
194
}
208
195
209
196
210
- static int ZCALLBACK fclose_file_func (voidpf opaque , voidpf stream )
211
- {
197
+ static int ZCALLBACK fclose_file_func (voidpf opaque , voidpf stream ) {
212
198
int ret ;
199
+ (void )opaque ;
213
200
ret = fclose ((FILE * )stream );
214
201
return ret ;
215
202
}
216
203
217
- static int ZCALLBACK ferror_file_func (voidpf opaque , voidpf stream )
218
- {
204
+ static int ZCALLBACK ferror_file_func (voidpf opaque , voidpf stream ) {
219
205
int ret ;
206
+ (void )opaque ;
220
207
ret = ferror ((FILE * )stream );
221
208
return ret ;
222
209
}
223
210
224
- void fill_fopen_filefunc (pzlib_filefunc_def )
225
- zlib_filefunc_def * pzlib_filefunc_def ;
226
- {
211
+ void fill_fopen_filefunc (zlib_filefunc_def * pzlib_filefunc_def ) {
227
212
pzlib_filefunc_def -> zopen_file = fopen_file_func ;
228
213
pzlib_filefunc_def -> zread_file = fread_file_func ;
229
214
pzlib_filefunc_def -> zwrite_file = fwrite_file_func ;
@@ -234,8 +219,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
234
219
pzlib_filefunc_def -> opaque = NULL ;
235
220
}
236
221
237
- void fill_fopen64_filefunc (zlib_filefunc64_def * pzlib_filefunc_def )
238
- {
222
+ void fill_fopen64_filefunc (zlib_filefunc64_def * pzlib_filefunc_def ) {
239
223
pzlib_filefunc_def -> zopen64_file = fopen64_file_func ;
240
224
pzlib_filefunc_def -> zread_file = fread_file_func ;
241
225
pzlib_filefunc_def -> zwrite_file = fwrite_file_func ;
0 commit comments