ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ioapi.h
Go to the documentation of this file.
1 /* ioapi.h -- IO base function header for compress/uncompress .zip
2  part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html
3  )
4 
5  Copyright (C) 1998-2010 Gilles Vollant (minizip) (
6  http://www.winimage.com/zLibDll/minizip.html )
7 
8  Modifications for Zip64 support
9  Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
10 
11  Modified by Sergey A. Tachenov to allow QIODevice API usage.
12 
13  For more info read MiniZip_info.txt
14 
15  Changes
16 
17  Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux.
18  (might need to find a better why for this) Oct-2009 - Change to fseeko64,
19  ftello64 and fopen64 so large files would work on linux. More if/def section
20  may be needed to support other platforms Oct-2009 - Defined fxxxx64 calls to
21  normal fopen/ftell/fseek so they would compile on windows. (but you should
22  use iowin32.c for windows instead)
23 
24 */
25 
26 #ifndef _ZLIBIOAPI64_H
27 #define _ZLIBIOAPI64_H
28 
29 #if (!defined(_WIN32)) && (!defined(WIN32))
30 
31 // Linux needs this to support file operation on files larger then 4+GB
32 // But might need better if/def to select just the platforms that needs them.
33 
34 #ifndef __USE_FILE_OFFSET64
35 #define __USE_FILE_OFFSET64
36 #endif
37 #ifndef __USE_LARGEFILE64
38 #define __USE_LARGEFILE64
39 #endif
40 #ifndef _LARGEFILE64_SOURCE
41 #define _LARGEFILE64_SOURCE
42 #endif
43 #ifndef _FILE_OFFSET_BIT
44 #define _FILE_OFFSET_BIT 64
45 #endif
46 #endif
47 
48 #include <stdio.h>
49 #include <stdlib.h>
50 
51 #include "zlib.h"
52 
53 #if defined(USE_FILE32API)
54 #define fopen64 fopen
55 #define ftello64 ftell
56 #define fseeko64 fseek
57 #else
58 #ifdef _MSC_VER
59 #define fopen64 fopen
60 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
61 #define ftello64 _ftelli64
62 #define fseeko64 _fseeki64
63 #else // old MSC
64 #define ftello64 ftell
65 #define fseeko64 fseek
66 #endif
67 #endif
68 #endif
69 
70 /*
71 #ifndef ZPOS64_T
72  #ifdef _WIN32
73  #define ZPOS64_T fpos_t
74  #else
75  #include <stdint.h>
76  #define ZPOS64_T uint64_t
77  #endif
78 #endif
79 */
80 
81 #ifdef HAVE_MINIZIP64_CONF_H
82 #include "mz64conf.h"
83 #endif
84 
85 /* a type choosen by DEFINE */
86 #ifdef HAVE_64BIT_INT_CUSTOM
87 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
88 #else
89 #ifdef HAS_STDINT_H
90 #include "stdint.h"
91 typedef uint64_t ZPOS64_T;
92 #else
93 
94 #if defined(_MSC_VER) || defined(__BORLANDC__)
95 typedef unsigned __int64 ZPOS64_T;
96 #else
97 typedef unsigned long long int ZPOS64_T;
98 #endif
99 #endif
100 #endif
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
106 #ifndef OF
107 #define OF _Z_OF
108 #endif
109 
110 #define ZLIB_FILEFUNC_SEEK_CUR (1)
111 #define ZLIB_FILEFUNC_SEEK_END (2)
112 #define ZLIB_FILEFUNC_SEEK_SET (0)
113 
114 #define ZLIB_FILEFUNC_MODE_READ (1)
115 #define ZLIB_FILEFUNC_MODE_WRITE (2)
116 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
117 
118 #define ZLIB_FILEFUNC_MODE_EXISTING (4)
119 #define ZLIB_FILEFUNC_MODE_CREATE (8)
120 
121 #ifndef ZCALLBACK
122 #if (defined(WIN32) || defined(_WIN32) || defined(WINDOWS) || \
123  defined(_WINDOWS)) && \
124  defined(CALLBACK) && defined(USEWINDOWS_CALLBACK)
125 #define ZCALLBACK CALLBACK
126 #else
127 #define ZCALLBACK
128 #endif
129 #endif
130 
131 typedef voidpf(ZCALLBACK *open_file_func)
132  OF((voidpf opaque, voidpf file, int mode));
133 typedef uLong(ZCALLBACK *read_file_func)
134  OF((voidpf opaque, voidpf stream, void *buf, uLong size));
135 typedef uLong(ZCALLBACK *write_file_func)
136  OF((voidpf opaque, voidpf stream, const void *buf, uLong size));
137 typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
138 typedef int(ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
139 
140 typedef uLong(ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
141 typedef int(ZCALLBACK *seek_file_func)
142  OF((voidpf opaque, voidpf stream, uLong offset, int origin));
143 
144 /* here is the "old" 32 bits structure structure */
145 typedef struct zlib_filefunc_def_s {
146  open_file_func zopen_file;
147  read_file_func zread_file;
148  write_file_func zwrite_file;
149  tell_file_func ztell_file;
150  seek_file_func zseek_file;
151  close_file_func zclose_file;
152  testerror_file_func zerror_file;
153  voidpf opaque;
155 
156 typedef ZPOS64_T(ZCALLBACK *tell64_file_func)
157  OF((voidpf opaque, voidpf stream));
158 typedef int(ZCALLBACK *seek64_file_func)
159  OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
160 typedef voidpf(ZCALLBACK *open64_file_func)
161  OF((voidpf opaque, voidpf file, int mode));
162 
163 typedef struct zlib_filefunc64_def_s {
164  open64_file_func zopen64_file;
165  read_file_func zread_file;
166  write_file_func zwrite_file;
167  tell64_file_func ztell64_file;
168  seek64_file_func zseek64_file;
169  close_file_func zclose_file;
170  testerror_file_func zerror_file;
171  voidpf opaque;
172  close_file_func zfakeclose_file; // for no-auto-close flag
174 
175 void fill_qiodevice64_filefunc OF((zlib_filefunc64_def * pzlib_filefunc_def));
176 void fill_qiodevice_filefunc OF((zlib_filefunc_def * pzlib_filefunc_def));
177 
178 /* now internal definition, only for zip.c and unzip.h */
179 typedef struct zlib_filefunc64_32_def_s {
181  open_file_func zopen32_file;
182  tell_file_func ztell32_file;
183  seek_file_func zseek32_file;
185 
186 #define ZREAD64(filefunc, filestream, buf, size) \
187  ((*((filefunc).zfile_func64.zread_file))((filefunc).zfile_func64.opaque, \
188  filestream, buf, size))
189 #define ZWRITE64(filefunc, filestream, buf, size) \
190  ((*((filefunc).zfile_func64.zwrite_file))((filefunc).zfile_func64.opaque, \
191  filestream, buf, size))
192 // #define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file))
193 //((filefunc).opaque,filestream)) #define ZSEEK64(filefunc,filestream,pos,mode)
194 //((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
195 #define ZCLOSE64(filefunc, filestream) \
196  ((*((filefunc).zfile_func64.zclose_file))((filefunc).zfile_func64.opaque, \
197  filestream))
198 #define ZFAKECLOSE64(filefunc, filestream) \
199  ((*((filefunc).zfile_func64.zfakeclose_file))( \
200  (filefunc).zfile_func64.opaque, filestream))
201 #define ZERROR64(filefunc, filestream) \
202  ((*((filefunc).zfile_func64.zerror_file))((filefunc).zfile_func64.opaque, \
203  filestream))
204 
205 voidpf call_zopen64 OF((const zlib_filefunc64_32_def *pfilefunc,
206  voidpf file,
207  int mode));
208 int call_zseek64 OF((const zlib_filefunc64_32_def *pfilefunc,
209  voidpf filestream,
211  int origin));
213  voidpf filestream));
214 
216  zlib_filefunc64_32_def *p_filefunc64_32,
217  const zlib_filefunc_def *p_filefunc32);
218 
219 #define ZOPEN64(filefunc, filename, mode) \
220  (call_zopen64((&(filefunc)), (filename), (mode)))
221 #define ZTELL64(filefunc, filestream) \
222  (call_ztell64((&(filefunc)), (filestream)))
223 #define ZSEEK64(filefunc, filestream, pos, mode) \
224  (call_zseek64((&(filefunc)), (filestream), (pos), (mode)))
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
230 #endif
int size
int offset
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
Definition: qioapi.cpp:320
struct zlib_filefunc64_def_s zlib_filefunc64_def
#define OF
Definition: ioapi.h:107
struct zlib_filefunc_def_s zlib_filefunc_def
struct zlib_filefunc64_32_def_s zlib_filefunc64_32_def
#define ZCALLBACK
Definition: ioapi.h:127
unsigned long long int ZPOS64_T
Definition: ioapi.h:97
voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc, voidpf file, int mode)
Definition: qioapi.cpp:41
void fill_qiodevice64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: qioapi.cpp:307
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
Definition: qioapi.cpp:71
void fill_qiodevice_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
Definition: qioapi.cpp:296
int call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, ZPOS64_T offset, int origin)
Definition: qioapi.cpp:53
seek_file_func zseek32_file
Definition: ioapi.h:183
zlib_filefunc64_def zfile_func64
Definition: ioapi.h:180
open_file_func zopen32_file
Definition: ioapi.h:181
tell_file_func ztell32_file
Definition: ioapi.h:182
write_file_func zwrite_file
Definition: ioapi.h:166
open64_file_func zopen64_file
Definition: ioapi.h:164
close_file_func zfakeclose_file
Definition: ioapi.h:172
read_file_func zread_file
Definition: ioapi.h:165
tell64_file_func ztell64_file
Definition: ioapi.h:167
close_file_func zclose_file
Definition: ioapi.h:169
seek64_file_func zseek64_file
Definition: ioapi.h:168
testerror_file_func zerror_file
Definition: ioapi.h:170
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