|
7ef7284…
|
drh
|
1 |
/* ioapi.h -- IO base function header for compress/uncompress .zip |
|
6ea30fb…
|
florian
|
2 |
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html ) |
|
7ef7284…
|
drh
|
3 |
|
|
6ea30fb…
|
florian
|
4 |
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html ) |
|
7ef7284…
|
drh
|
5 |
|
|
7ef7284…
|
drh
|
6 |
Modifications for Zip64 support |
|
6ea30fb…
|
florian
|
7 |
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com ) |
|
7ef7284…
|
drh
|
8 |
|
|
7ef7284…
|
drh
|
9 |
For more info read MiniZip_info.txt |
|
7ef7284…
|
drh
|
10 |
|
|
7ef7284…
|
drh
|
11 |
Changes |
|
7ef7284…
|
drh
|
12 |
|
|
7ef7284…
|
drh
|
13 |
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) |
|
7ef7284…
|
drh
|
14 |
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. |
|
7ef7284…
|
drh
|
15 |
More if/def section may be needed to support other platforms |
|
7ef7284…
|
drh
|
16 |
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. |
|
7ef7284…
|
drh
|
17 |
(but you should use iowin32.c for windows instead) |
|
7ef7284…
|
drh
|
18 |
|
|
7ef7284…
|
drh
|
19 |
*/ |
|
7ef7284…
|
drh
|
20 |
|
|
6ea30fb…
|
florian
|
21 |
#ifndef ZLIBIOAPI64_H |
|
6ea30fb…
|
florian
|
22 |
#define ZLIBIOAPI64_H |
|
7ef7284…
|
drh
|
23 |
|
|
6ea30fb…
|
florian
|
24 |
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!(defined(__ANDROID_API__) || __ANDROID_API__ >= 24)) |
|
7ef7284…
|
drh
|
25 |
|
|
6ea30fb…
|
florian
|
26 |
/* Linux needs this to support file operation on files larger then 4+GB */ |
|
6ea30fb…
|
florian
|
27 |
/* But might need better if/def to select just the platforms that needs them.*/ |
|
7ef7284…
|
drh
|
28 |
|
|
7ef7284…
|
drh
|
29 |
#ifndef __USE_FILE_OFFSET64 |
|
7ef7284…
|
drh
|
30 |
#define __USE_FILE_OFFSET64 |
|
7ef7284…
|
drh
|
31 |
#endif |
|
7ef7284…
|
drh
|
32 |
#ifndef __USE_LARGEFILE64 |
|
7ef7284…
|
drh
|
33 |
#define __USE_LARGEFILE64 |
|
7ef7284…
|
drh
|
34 |
#endif |
|
7ef7284…
|
drh
|
35 |
#ifndef _LARGEFILE64_SOURCE |
|
7ef7284…
|
drh
|
36 |
#define _LARGEFILE64_SOURCE |
|
7ef7284…
|
drh
|
37 |
#endif |
|
7ef7284…
|
drh
|
38 |
#ifndef _FILE_OFFSET_BIT |
|
7ef7284…
|
drh
|
39 |
#define _FILE_OFFSET_BIT 64 |
|
7ef7284…
|
drh
|
40 |
#endif |
|
7ef7284…
|
drh
|
41 |
|
|
7ef7284…
|
drh
|
42 |
#endif |
|
7ef7284…
|
drh
|
43 |
|
|
7ef7284…
|
drh
|
44 |
#include <stdio.h> |
|
7ef7284…
|
drh
|
45 |
#include <stdlib.h> |
|
7ef7284…
|
drh
|
46 |
#include "zlib.h" |
|
7ef7284…
|
drh
|
47 |
|
|
7ef7284…
|
drh
|
48 |
#if defined(USE_FILE32API) |
|
7ef7284…
|
drh
|
49 |
#define fopen64 fopen |
|
7ef7284…
|
drh
|
50 |
#define ftello64 ftell |
|
7ef7284…
|
drh
|
51 |
#define fseeko64 fseek |
|
7ef7284…
|
drh
|
52 |
#else |
|
f1f1d6c…
|
drh
|
53 |
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
|
7ef7284…
|
drh
|
54 |
#define fopen64 fopen |
|
7ef7284…
|
drh
|
55 |
#define ftello64 ftello |
|
7ef7284…
|
drh
|
56 |
#define fseeko64 fseeko |
|
7ef7284…
|
drh
|
57 |
#endif |
|
7ef7284…
|
drh
|
58 |
#ifdef _MSC_VER |
|
7ef7284…
|
drh
|
59 |
#define fopen64 fopen |
|
7ef7284…
|
drh
|
60 |
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) |
|
7ef7284…
|
drh
|
61 |
#define ftello64 _ftelli64 |
|
7ef7284…
|
drh
|
62 |
#define fseeko64 _fseeki64 |
|
7ef7284…
|
drh
|
63 |
#else // old MSC |
|
7ef7284…
|
drh
|
64 |
#define ftello64 ftell |
|
7ef7284…
|
drh
|
65 |
#define fseeko64 fseek |
|
7ef7284…
|
drh
|
66 |
#endif |
|
7ef7284…
|
drh
|
67 |
#endif |
|
7ef7284…
|
drh
|
68 |
#endif |
|
7ef7284…
|
drh
|
69 |
|
|
7ef7284…
|
drh
|
70 |
#ifdef HAVE_MINIZIP64_CONF_H |
|
7ef7284…
|
drh
|
71 |
#include "mz64conf.h" |
|
7ef7284…
|
drh
|
72 |
#endif |
|
7ef7284…
|
drh
|
73 |
|
|
6ea30fb…
|
florian
|
74 |
#include "ints.h" |
|
6ea30fb…
|
florian
|
75 |
typedef ui64_t ZPOS64_T; |
|
7ef7284…
|
drh
|
76 |
|
|
7ef7284…
|
drh
|
77 |
/* Maximum unsigned 32-bit value used as placeholder for zip64 */ |
|
adb9e8e…
|
drh
|
78 |
#ifndef MAXU32 |
|
adb9e8e…
|
drh
|
79 |
#define MAXU32 (0xffffffff) |
|
adb9e8e…
|
drh
|
80 |
#endif |
|
7ef7284…
|
drh
|
81 |
|
|
7ef7284…
|
drh
|
82 |
#ifdef __cplusplus |
|
7ef7284…
|
drh
|
83 |
extern "C" { |
|
7ef7284…
|
drh
|
84 |
#endif |
|
7ef7284…
|
drh
|
85 |
|
|
7ef7284…
|
drh
|
86 |
|
|
7ef7284…
|
drh
|
87 |
#define ZLIB_FILEFUNC_SEEK_CUR (1) |
|
7ef7284…
|
drh
|
88 |
#define ZLIB_FILEFUNC_SEEK_END (2) |
|
7ef7284…
|
drh
|
89 |
#define ZLIB_FILEFUNC_SEEK_SET (0) |
|
7ef7284…
|
drh
|
90 |
|
|
7ef7284…
|
drh
|
91 |
#define ZLIB_FILEFUNC_MODE_READ (1) |
|
7ef7284…
|
drh
|
92 |
#define ZLIB_FILEFUNC_MODE_WRITE (2) |
|
7ef7284…
|
drh
|
93 |
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) |
|
7ef7284…
|
drh
|
94 |
|
|
7ef7284…
|
drh
|
95 |
#define ZLIB_FILEFUNC_MODE_EXISTING (4) |
|
7ef7284…
|
drh
|
96 |
#define ZLIB_FILEFUNC_MODE_CREATE (8) |
|
7ef7284…
|
drh
|
97 |
|
|
7ef7284…
|
drh
|
98 |
|
|
7ef7284…
|
drh
|
99 |
#ifndef ZCALLBACK |
|
7ef7284…
|
drh
|
100 |
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) |
|
7ef7284…
|
drh
|
101 |
#define ZCALLBACK CALLBACK |
|
7ef7284…
|
drh
|
102 |
#else |
|
7ef7284…
|
drh
|
103 |
#define ZCALLBACK |
|
7ef7284…
|
drh
|
104 |
#endif |
|
7ef7284…
|
drh
|
105 |
#endif |
|
7ef7284…
|
drh
|
106 |
|
|
7ef7284…
|
drh
|
107 |
|
|
7ef7284…
|
drh
|
108 |
|
|
7ef7284…
|
drh
|
109 |
|
|
f1f1d6c…
|
drh
|
110 |
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); |
|
f1f1d6c…
|
drh
|
111 |
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); |
|
f1f1d6c…
|
drh
|
112 |
typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size); |
|
f1f1d6c…
|
drh
|
113 |
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); |
|
f1f1d6c…
|
drh
|
114 |
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); |
|
f1f1d6c…
|
drh
|
115 |
|
|
f1f1d6c…
|
drh
|
116 |
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); |
|
f1f1d6c…
|
drh
|
117 |
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); |
|
7ef7284…
|
drh
|
118 |
|
|
7ef7284…
|
drh
|
119 |
|
|
64ce68d…
|
drh
|
120 |
/* here is the "old" 32 bits structure */ |
|
7ef7284…
|
drh
|
121 |
typedef struct zlib_filefunc_def_s |
|
7ef7284…
|
drh
|
122 |
{ |
|
7ef7284…
|
drh
|
123 |
open_file_func zopen_file; |
|
7ef7284…
|
drh
|
124 |
read_file_func zread_file; |
|
7ef7284…
|
drh
|
125 |
write_file_func zwrite_file; |
|
7ef7284…
|
drh
|
126 |
tell_file_func ztell_file; |
|
7ef7284…
|
drh
|
127 |
seek_file_func zseek_file; |
|
7ef7284…
|
drh
|
128 |
close_file_func zclose_file; |
|
7ef7284…
|
drh
|
129 |
testerror_file_func zerror_file; |
|
7ef7284…
|
drh
|
130 |
voidpf opaque; |
|
7ef7284…
|
drh
|
131 |
} zlib_filefunc_def; |
|
7ef7284…
|
drh
|
132 |
|
|
f1f1d6c…
|
drh
|
133 |
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream); |
|
f1f1d6c…
|
drh
|
134 |
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin); |
|
f1f1d6c…
|
drh
|
135 |
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode); |
|
7ef7284…
|
drh
|
136 |
|
|
7ef7284…
|
drh
|
137 |
typedef struct zlib_filefunc64_def_s |
|
7ef7284…
|
drh
|
138 |
{ |
|
7ef7284…
|
drh
|
139 |
open64_file_func zopen64_file; |
|
7ef7284…
|
drh
|
140 |
read_file_func zread_file; |
|
7ef7284…
|
drh
|
141 |
write_file_func zwrite_file; |
|
7ef7284…
|
drh
|
142 |
tell64_file_func ztell64_file; |
|
7ef7284…
|
drh
|
143 |
seek64_file_func zseek64_file; |
|
7ef7284…
|
drh
|
144 |
close_file_func zclose_file; |
|
7ef7284…
|
drh
|
145 |
testerror_file_func zerror_file; |
|
7ef7284…
|
drh
|
146 |
voidpf opaque; |
|
7ef7284…
|
drh
|
147 |
} zlib_filefunc64_def; |
|
7ef7284…
|
drh
|
148 |
|
|
f1f1d6c…
|
drh
|
149 |
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def); |
|
f1f1d6c…
|
drh
|
150 |
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def); |
|
7ef7284…
|
drh
|
151 |
|
|
7ef7284…
|
drh
|
152 |
/* now internal definition, only for zip.c and unzip.h */ |
|
7ef7284…
|
drh
|
153 |
typedef struct zlib_filefunc64_32_def_s |
|
7ef7284…
|
drh
|
154 |
{ |
|
7ef7284…
|
drh
|
155 |
zlib_filefunc64_def zfile_func64; |
|
7ef7284…
|
drh
|
156 |
open_file_func zopen32_file; |
|
7ef7284…
|
drh
|
157 |
tell_file_func ztell32_file; |
|
7ef7284…
|
drh
|
158 |
seek_file_func zseek32_file; |
|
7ef7284…
|
drh
|
159 |
} zlib_filefunc64_32_def; |
|
7ef7284…
|
drh
|
160 |
|
|
7ef7284…
|
drh
|
161 |
|
|
7ef7284…
|
drh
|
162 |
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) |
|
7ef7284…
|
drh
|
163 |
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) |
|
6ea30fb…
|
florian
|
164 |
/*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) */ |
|
6ea30fb…
|
florian
|
165 |
/*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) */ |
|
7ef7284…
|
drh
|
166 |
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
|
7ef7284…
|
drh
|
167 |
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
|
7ef7284…
|
drh
|
168 |
|
|
f1f1d6c…
|
drh
|
169 |
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode); |
|
f1f1d6c…
|
drh
|
170 |
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin); |
|
f1f1d6c…
|
drh
|
171 |
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream); |
|
7ef7284…
|
drh
|
172 |
|
|
f1f1d6c…
|
drh
|
173 |
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); |
|
7ef7284…
|
drh
|
174 |
|
|
7ef7284…
|
drh
|
175 |
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) |
|
7ef7284…
|
drh
|
176 |
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) |
|
7ef7284…
|
drh
|
177 |
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) |
|
7ef7284…
|
drh
|
178 |
|
|
7ef7284…
|
drh
|
179 |
#ifdef __cplusplus |
|
7ef7284…
|
drh
|
180 |
} |
|
7ef7284…
|
drh
|
181 |
#endif |
|
7ef7284…
|
drh
|
182 |
|
|
7ef7284…
|
drh
|
183 |
#endif |