2323#ifndef _ZLIBIOAPI64_H
2424#define _ZLIBIOAPI64_H
2525
26- #if (!defined(_WIN32 )) && (!defined(WIN32 ))
26+ #if (!defined(_WIN32 )) && (!defined(WIN32 )) && (!defined( __APPLE__ ))
2727
2828 // Linux needs this to support file operation on files larger then 4+GB
2929 // But might need better if/def to select just the platforms that needs them.
4040 #ifndef _FILE_OFFSET_BIT
4141 #define _FILE_OFFSET_BIT 64
4242 #endif
43+
4344#endif
4445
4546#include <stdio.h>
5152#define ftello64 ftell
5253#define fseeko64 fseek
5354#else
55+ #if defined(__FreeBSD__ ) || defined(__OpenBSD__ ) || defined(__NetBSD__ ) || defined(__HAIKU__ ) || defined(MINIZIP_FOPEN_NO_64 )
56+ #define fopen64 fopen
57+ #define ftello64 ftello
58+ #define fseeko64 fseeko
59+ #endif
5460#ifdef _MSC_VER
5561 #define fopen64 fopen
5662 #if (_MSC_VER >= 1400 ) && (!(defined(NO_MSCVER_FILE64_FUNC )))
7884#include "mz64conf.h"
7985#endif
8086
81- /* a type choosen by DEFINE */
87+ /* a type chosen by DEFINE */
8288#ifdef HAVE_64BIT_INT_CUSTOM
8389typedef 64B IT_INT_CUSTOM_TYPE ZPOS64_T ;
8490#else
@@ -88,6 +94,7 @@ typedef uint64_t ZPOS64_T;
8894#else
8995
9096
97+
9198#if defined(_MSC_VER ) || defined(__BORLANDC__ )
9299typedef unsigned __int64 ZPOS64_T ;
93100#else
@@ -96,15 +103,15 @@ typedef unsigned long long int ZPOS64_T;
96103#endif
97104#endif
98105
99-
106+ /* Maximum unsigned 32-bit value used as placeholder for zip64 */
107+ #ifndef MAXU32
108+ #define MAXU32 (0xffffffff)
109+ #endif
100110
101111#ifdef __cplusplus
102112extern "C" {
103113#endif
104114
105- #ifndef OF
106- #define OF _Z_OF
107- #endif
108115
109116#define ZLIB_FILEFUNC_SEEK_CUR (1)
110117#define ZLIB_FILEFUNC_SEEK_END (2)
@@ -129,17 +136,17 @@ extern "C" {
129136
130137
131138
132- typedef voidpf (ZCALLBACK * open_file_func ) OF ( ( voidpf opaque , voidpf file , int mode ) );
133- typedef uLong (ZCALLBACK * read_file_func ) OF ( ( voidpf opaque , voidpf stream , void * buf , uLong size ) );
134- typedef uLong (ZCALLBACK * write_file_func ) OF ( ( voidpf opaque , voidpf stream , const void * buf , uLong size ) );
135- typedef int (ZCALLBACK * close_file_func ) OF (( voidpf opaque , voidpf stream ) );
136- typedef int (ZCALLBACK * testerror_file_func ) OF (( voidpf opaque , voidpf stream ) );
139+ typedef voidpf (ZCALLBACK * open_file_func ) ( voidpf opaque , voidpf file , int mode );
140+ typedef uLong (ZCALLBACK * read_file_func ) ( voidpf opaque , voidpf stream , void * buf , uLong size );
141+ typedef uLong (ZCALLBACK * write_file_func ) ( voidpf opaque , voidpf stream , const void * buf , uLong size );
142+ typedef int (ZCALLBACK * close_file_func ) ( voidpf opaque , voidpf stream );
143+ typedef int (ZCALLBACK * testerror_file_func ) ( voidpf opaque , voidpf stream );
137144
138- typedef uLong (ZCALLBACK * tell_file_func ) OF ( ( voidpf opaque , voidpf stream ) );
139- typedef int (ZCALLBACK * seek_file_func ) OF (( voidpf opaque , voidpf stream , uLong offset , int origin ) );
145+ typedef long (ZCALLBACK * tell_file_func ) ( voidpf opaque , voidpf stream );
146+ typedef long (ZCALLBACK * seek_file_func ) ( voidpf opaque , voidpf stream , uLong offset , int origin );
140147
141148
142- /* here is the "old" 32 bits structure structure */
149+ /* here is the "old" 32 bits structure */
143150typedef struct zlib_filefunc_def_s
144151{
145152 open_file_func zopen_file ;
@@ -152,9 +159,9 @@ typedef struct zlib_filefunc_def_s
152159 voidpf opaque ;
153160} zlib_filefunc_def ;
154161
155- typedef ZPOS64_T (ZCALLBACK * tell64_file_func ) OF ( ( voidpf opaque , voidpf stream ) );
156- typedef int (ZCALLBACK * seek64_file_func ) OF (( voidpf opaque , voidpf stream , ZPOS64_T offset , int origin ) );
157- typedef voidpf (ZCALLBACK * open64_file_func ) OF ( ( voidpf opaque , voidpf file , int mode ) );
162+ typedef ZPOS64_T (ZCALLBACK * tell64_file_func ) ( voidpf opaque , voidpf stream );
163+ typedef long (ZCALLBACK * seek64_file_func ) ( voidpf opaque , voidpf stream , ZPOS64_T offset , int origin );
164+ typedef voidpf (ZCALLBACK * open64_file_func ) ( voidpf opaque , voidpf file , int mode );
158165
159166typedef struct zlib_filefunc64_def_s
160167{
@@ -169,8 +176,8 @@ typedef struct zlib_filefunc64_def_s
169176 close_file_func zfakeclose_file ; // for no-auto-close flag
170177} zlib_filefunc64_def ;
171178
172- void fill_qiodevice64_filefunc OF (( zlib_filefunc64_def * pzlib_filefunc_def ) );
173- void fill_qiodevice_filefunc OF (( zlib_filefunc_def * pzlib_filefunc_def ) );
179+ void fill_qiodevice64_filefunc ( zlib_filefunc64_def * pzlib_filefunc_def );
180+ void fill_qiodevice_filefunc ( zlib_filefunc_def * pzlib_filefunc_def );
174181
175182/* now internal definition, only for zip.c and unzip.h */
176183typedef struct zlib_filefunc64_32_def_s
@@ -179,6 +186,7 @@ typedef struct zlib_filefunc64_32_def_s
179186 open_file_func zopen32_file ;
180187 tell_file_func ztell32_file ;
181188 seek_file_func zseek32_file ;
189+ close_file_func zfakeclose_file ; // for no-auto-close flag
182190} zlib_filefunc64_32_def ;
183191
184192
@@ -187,14 +195,14 @@ typedef struct zlib_filefunc64_32_def_s
187195//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
188196//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
189197#define ZCLOSE64 (filefunc ,filestream ) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
190- #define ZFAKECLOSE64 (filefunc ,filestream ) ((*((filefunc).zfile_func64.zfakeclose_file)) ((filefunc).zfile_func64.opaque,filestream))
198+ #define ZFAKECLOSE64 (filefunc ,filestream ) ((*((filefunc).zfile_func64.zfakeclose_file)) ((filefunc).zfile_func64.opaque,filestream))
191199#define ZERROR64 (filefunc ,filestream ) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
192200
193- voidpf call_zopen64 OF (( const zlib_filefunc64_32_def * pfilefunc ,voidpf file ,int mode ) );
194- int call_zseek64 OF (( const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream , ZPOS64_T offset , int origin ) );
195- ZPOS64_T call_ztell64 OF (( const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream ) );
201+ voidpf call_zopen64 ( const zlib_filefunc64_32_def * pfilefunc ,voidpf file ,int mode );
202+ long call_zseek64 ( const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream , ZPOS64_T offset , int origin );
203+ ZPOS64_T call_ztell64 ( const zlib_filefunc64_32_def * pfilefunc ,voidpf filestream );
196204
197- void fill_zlib_filefunc64_32_def_from_filefunc32 (zlib_filefunc64_32_def * p_filefunc64_32 ,const zlib_filefunc_def * p_filefunc32 );
205+ void fill_zlib_filefunc64_32_def_from_filefunc32 (zlib_filefunc64_32_def * p_filefunc64_32 ,const zlib_filefunc_def * p_filefunc32 );
198206
199207#define ZOPEN64 (filefunc ,filename ,mode ) (call_zopen64((&(filefunc)),(filename),(mode)))
200208#define ZTELL64 (filefunc ,filestream ) (call_ztell64((&(filefunc)),(filestream)))
0 commit comments