OLD | NEW |
1 /* ioapi.h -- IO base function header for compress/uncompress .zip | 1 /* ioapi.h -- IO base function header for compress/uncompress .zip |
2 files using zlib + zip or unzip API | 2 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html
) |
3 | 3 |
4 Version 1.01e, February 12th, 2005 | 4 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.
com/zLibDll/minizip.html ) |
5 | 5 |
6 Copyright (C) 1998-2005 Gilles Vollant | 6 Modifications for Zip64 support |
| 7 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
| 8 |
| 9 For more info read MiniZip_info.txt |
| 10 |
| 11 Changes |
| 12 |
| 13 Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (mi
ght need to find a better why for this) |
| 14 Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would wor
k on linux. |
| 15 More if/def section may be needed to support other platforms |
| 16 Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would c
ompile on windows. |
| 17 (but you should use iowin32.c for windows instead) |
| 18 |
7 */ | 19 */ |
8 | 20 |
9 #ifndef _ZLIBIOAPI_H | 21 #ifndef _ZLIBIOAPI64_H |
10 #define _ZLIBIOAPI_H | 22 #define _ZLIBIOAPI64_H |
| 23 |
| 24 #if (!defined(_WIN32)) && (!defined(WIN32)) |
| 25 |
| 26 // Linux needs this to support file operation on files larger then 4+GB |
| 27 // But might need better if/def to select just the platforms that needs them. |
| 28 |
| 29 #ifndef __USE_FILE_OFFSET64 |
| 30 #define __USE_FILE_OFFSET64 |
| 31 #endif |
| 32 #ifndef __USE_LARGEFILE64 |
| 33 #define __USE_LARGEFILE64 |
| 34 #endif |
| 35 #ifndef _LARGEFILE64_SOURCE |
| 36 #define _LARGEFILE64_SOURCE |
| 37 #endif |
| 38 #ifndef _FILE_OFFSET_BIT |
| 39 #define _FILE_OFFSET_BIT 64 |
| 40 #endif |
| 41 #endif |
| 42 |
| 43 #include <stdio.h> |
| 44 #include <stdlib.h> |
| 45 #if defined(USE_SYSTEM_ZLIB) |
| 46 #include <zlib.h> |
| 47 #else |
| 48 #include "third_party/zlib/zlib.h" |
| 49 #endif |
| 50 |
| 51 #if defined(USE_FILE32API) |
| 52 #define fopen64 fopen |
| 53 #define ftello64 ftell |
| 54 #define fseeko64 fseek |
| 55 #else |
| 56 #ifdef _MSC_VER |
| 57 #define fopen64 fopen |
| 58 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) |
| 59 #define ftello64 _ftelli64 |
| 60 #define fseeko64 _fseeki64 |
| 61 #else // old MSC |
| 62 #define ftello64 ftell |
| 63 #define fseeko64 fseek |
| 64 #endif |
| 65 #endif |
| 66 #endif |
| 67 |
| 68 /* |
| 69 #ifndef ZPOS64_T |
| 70 #ifdef _WIN32 |
| 71 #define ZPOS64_T fpos_t |
| 72 #else |
| 73 #include <stdint.h> |
| 74 #define ZPOS64_T uint64_t |
| 75 #endif |
| 76 #endif |
| 77 */ |
| 78 |
| 79 #ifdef HAVE_MINIZIP64_CONF_H |
| 80 #include "mz64conf.h" |
| 81 #endif |
| 82 |
| 83 /* a type choosen by DEFINE */ |
| 84 #ifdef HAVE_64BIT_INT_CUSTOM |
| 85 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; |
| 86 #else |
| 87 #ifdef HAS_STDINT_H |
| 88 #include "stdint.h" |
| 89 typedef uint64_t ZPOS64_T; |
| 90 #else |
| 91 |
| 92 |
| 93 #if defined(_MSC_VER) || defined(__BORLANDC__) |
| 94 typedef unsigned __int64 ZPOS64_T; |
| 95 #else |
| 96 typedef unsigned long long int ZPOS64_T; |
| 97 #endif |
| 98 #endif |
| 99 #endif |
| 100 |
| 101 |
| 102 |
| 103 #ifdef __cplusplus |
| 104 extern "C" { |
| 105 #endif |
11 | 106 |
12 | 107 |
13 #define ZLIB_FILEFUNC_SEEK_CUR (1) | 108 #define ZLIB_FILEFUNC_SEEK_CUR (1) |
14 #define ZLIB_FILEFUNC_SEEK_END (2) | 109 #define ZLIB_FILEFUNC_SEEK_END (2) |
15 #define ZLIB_FILEFUNC_SEEK_SET (0) | 110 #define ZLIB_FILEFUNC_SEEK_SET (0) |
16 | 111 |
17 #define ZLIB_FILEFUNC_MODE_READ (1) | 112 #define ZLIB_FILEFUNC_MODE_READ (1) |
18 #define ZLIB_FILEFUNC_MODE_WRITE (2) | 113 #define ZLIB_FILEFUNC_MODE_WRITE (2) |
19 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) | 114 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) |
20 | 115 |
21 #define ZLIB_FILEFUNC_MODE_EXISTING (4) | 116 #define ZLIB_FILEFUNC_MODE_EXISTING (4) |
22 #define ZLIB_FILEFUNC_MODE_CREATE (8) | 117 #define ZLIB_FILEFUNC_MODE_CREATE (8) |
23 | 118 |
24 | 119 |
25 #ifndef ZCALLBACK | 120 #ifndef ZCALLBACK |
26 | 121 #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOW
S)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) |
27 #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLB
ACK) && defined (USEWINDOWS_CALLBACK) | 122 #define ZCALLBACK CALLBACK |
28 #define ZCALLBACK CALLBACK | 123 #else |
29 #else | 124 #define ZCALLBACK |
30 #define ZCALLBACK | 125 #endif |
31 #endif | |
32 #endif | 126 #endif |
33 | 127 |
34 #ifdef __cplusplus | |
35 extern "C" { | |
36 #endif | |
37 | 128 |
38 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filena
me, int mode)); | |
39 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, voi
d* buf, uLong size)); | |
40 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, co
nst void* buf, uLong size)); | |
41 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); | |
42 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLo
ng offset, int origin)); | |
43 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); | |
44 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream
)); | |
45 | 129 |
| 130 |
| 131 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char*
filename, int mode)); |
| 132 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stre
am, void* buf, uLong size)); |
| 133 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stre
am, const void* buf, uLong size)); |
| 134 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stre
am)); |
| 135 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stre
am)); |
| 136 |
| 137 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stre
am)); |
| 138 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stre
am, uLong offset, int origin)); |
| 139 |
| 140 |
| 141 /* here is the "old" 32 bits structure structure */ |
46 typedef struct zlib_filefunc_def_s | 142 typedef struct zlib_filefunc_def_s |
47 { | 143 { |
48 open_file_func zopen_file; | 144 open_file_func zopen_file; |
49 read_file_func zread_file; | 145 read_file_func zread_file; |
50 write_file_func zwrite_file; | 146 write_file_func zwrite_file; |
51 tell_file_func ztell_file; | 147 tell_file_func ztell_file; |
52 seek_file_func zseek_file; | 148 seek_file_func zseek_file; |
53 close_file_func zclose_file; | 149 close_file_func zclose_file; |
54 testerror_file_func zerror_file; | 150 testerror_file_func zerror_file; |
55 voidpf opaque; | 151 voidpf opaque; |
56 } zlib_filefunc_def; | 152 } zlib_filefunc_def; |
57 | 153 |
| 154 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stre
am)); |
| 155 typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stre
am, ZPOS64_T offset, int origin)); |
| 156 typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void*
filename, int mode)); |
| 157 |
| 158 typedef struct zlib_filefunc64_def_s |
| 159 { |
| 160 open64_file_func zopen64_file; |
| 161 read_file_func zread_file; |
| 162 write_file_func zwrite_file; |
| 163 tell64_file_func ztell64_file; |
| 164 seek64_file_func zseek64_file; |
| 165 close_file_func zclose_file; |
| 166 testerror_file_func zerror_file; |
| 167 voidpf opaque; |
| 168 } zlib_filefunc64_def; |
| 169 |
| 170 void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); |
| 171 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); |
| 172 |
| 173 /* now internal definition, only for zip.c and unzip.h */ |
| 174 typedef struct zlib_filefunc64_32_def_s |
| 175 { |
| 176 zlib_filefunc64_def zfile_func64; |
| 177 open_file_func zopen32_file; |
| 178 tell_file_func ztell32_file; |
| 179 seek_file_func zseek32_file; |
| 180 } zlib_filefunc64_32_def; |
58 | 181 |
59 | 182 |
60 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | 183 #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zr
ead_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) |
| 184 #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zw
rite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) |
| 185 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file))
((filefunc).opaque,filestream)) |
| 186 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file))
((filefunc).opaque,filestream,pos,mode)) |
| 187 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zc
lose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 188 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.ze
rror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
61 | 189 |
62 #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefun
c).opaque,filestream,buf,size)) | 190 voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filen
ame,int mode)); |
63 #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filef
unc).opaque,filestream,buf,size)) | 191 long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestre
am, ZPOS64_T offset, int origin)); |
64 #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque
,filestream)) | 192 ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestr
eam)); |
65 #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefun
c).opaque,filestream,pos,mode)) | |
66 #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaq
ue,filestream)) | |
67 #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaq
ue,filestream)) | |
68 | 193 |
| 194 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_fi
lefunc64_32,const zlib_filefunc_def* p_filefunc32); |
| 195 |
| 196 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(fil
ename),(mode))) |
| 197 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(fil
estream))) |
| 198 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(fil
estream),(pos),(mode))) |
69 | 199 |
70 #ifdef __cplusplus | 200 #ifdef __cplusplus |
71 } | 201 } |
72 #endif | 202 #endif |
73 | 203 |
74 #endif | 204 #endif |
75 | |
OLD | NEW |