diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:26:49 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:26:49 -0700 |
commit | d004b047838a7e803818b4973a2e39e0ff8c1fa2 (patch) | |
tree | 9e8c804f78d73152c70d4ff24c6a7531a0d46782 /contrib/minizip/ioapi.h | |
parent | f6194ef39af5864f792412460c354cc339dde7d1 (diff) | |
download | zlib-1.2.3.5.tar.gz zlib-1.2.3.5.tar.bz2 zlib-1.2.3.5.zip |
zlib 1.2.3.5v1.2.3.5
Diffstat (limited to 'contrib/minizip/ioapi.h')
-rw-r--r-- | contrib/minizip/ioapi.h | 175 |
1 files changed, 147 insertions, 28 deletions
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h index 7d457ba..f443d82 100644 --- a/contrib/minizip/ioapi.h +++ b/contrib/minizip/ioapi.h | |||
@@ -1,13 +1,98 @@ | |||
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 | |||
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. (might need to find a better why for this) | ||
14 | Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work 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 compile on windows. | ||
17 | (but you should use iowin32.c for windows instead) | ||
5 | 18 | ||
6 | Copyright (C) 1998-2005 Gilles Vollant | ||
7 | */ | 19 | */ |
8 | 20 | ||
9 | #ifndef _ZLIBIOAPI_H | 21 | #ifndef _ZLIBIOAPI64_H |
10 | #define _ZLIBIOAPI_H | 22 | #define _ZLIBIOAPI64_H |
23 | |||
24 | #ifndef _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 | #include "zlib.h" | ||
46 | |||
47 | #ifdef _MSC_VER | ||
48 | #define fopen64 fopen | ||
49 | #if _MSC_VER >= 1400 | ||
50 | #define ftello64 _ftelli64 | ||
51 | #define fseeko64 _fseeki64 | ||
52 | #else // old MSC | ||
53 | #define ftello64 ftell | ||
54 | #define fseeko64 fseek | ||
55 | #endif | ||
56 | #endif | ||
57 | |||
58 | /* | ||
59 | #ifndef ZPOS64_T | ||
60 | #ifdef _WIN32 | ||
61 | #define ZPOS64_T fpos_t | ||
62 | #else | ||
63 | #include <stdint.h> | ||
64 | #define ZPOS64_T uint64_t | ||
65 | #endif | ||
66 | #endif | ||
67 | */ | ||
68 | |||
69 | #ifdef HAVE_MINIZIP64_CONF_H | ||
70 | #include "mz64conf.h" | ||
71 | #endif | ||
72 | |||
73 | /* a type choosen by DEFINE */ | ||
74 | #ifdef HAVE_64BIT_INT_CUSTOM | ||
75 | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; | ||
76 | #else | ||
77 | #ifdef HAS_STDINT_H | ||
78 | #include "stdint.h" | ||
79 | typedef uint64_t ZPOS64_T; | ||
80 | #else | ||
81 | |||
82 | |||
83 | #if defined(_MSC_VER) || defined(__BORLANDC__) | ||
84 | typedef unsigned __int64 ZPOS64_T; | ||
85 | #else | ||
86 | typedef unsigned long long int ZPOS64_T; | ||
87 | #endif | ||
88 | #endif | ||
89 | #endif | ||
90 | |||
91 | |||
92 | |||
93 | #ifdef __cplusplus | ||
94 | extern "C" { | ||
95 | #endif | ||
11 | 96 | ||
12 | 97 | ||
13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) | 98 | #define ZLIB_FILEFUNC_SEEK_CUR (1) |
@@ -23,26 +108,27 @@ | |||
23 | 108 | ||
24 | 109 | ||
25 | #ifndef ZCALLBACK | 110 | #ifndef ZCALLBACK |
26 | 111 | #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) | |
27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) | 112 | #define ZCALLBACK CALLBACK |
28 | #define ZCALLBACK CALLBACK | 113 | #else |
29 | #else | 114 | #define ZCALLBACK |
30 | #define ZCALLBACK | 115 | #endif |
31 | #endif | ||
32 | #endif | 116 | #endif |
33 | 117 | ||
34 | #ifdef __cplusplus | ||
35 | extern "C" { | ||
36 | #endif | ||
37 | 118 | ||
38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); | ||
39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | ||
40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const 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, uLong 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 | 119 | ||
120 | |||
121 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); | ||
122 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | ||
123 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); | ||
124 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); | ||
125 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); | ||
126 | |||
127 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); | ||
128 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); | ||
129 | |||
130 | |||
131 | /* here is the "old" 32 bits structure structure */ | ||
46 | typedef struct zlib_filefunc_def_s | 132 | typedef struct zlib_filefunc_def_s |
47 | { | 133 | { |
48 | open_file_func zopen_file; | 134 | open_file_func zopen_file; |
@@ -55,21 +141,54 @@ typedef struct zlib_filefunc_def_s | |||
55 | voidpf opaque; | 141 | voidpf opaque; |
56 | } zlib_filefunc_def; | 142 | } zlib_filefunc_def; |
57 | 143 | ||
144 | typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); | ||
145 | typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); | ||
146 | typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); | ||
58 | 147 | ||
148 | typedef struct zlib_filefunc64_def_s | ||
149 | { | ||
150 | open64_file_func zopen64_file; | ||
151 | read_file_func zread_file; | ||
152 | write_file_func zwrite_file; | ||
153 | tell64_file_func ztell64_file; | ||
154 | seek64_file_func zseek64_file; | ||
155 | close_file_func zclose_file; | ||
156 | testerror_file_func zerror_file; | ||
157 | voidpf opaque; | ||
158 | } zlib_filefunc64_def; | ||
59 | 159 | ||
160 | void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); | ||
60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | 161 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); |
61 | 162 | ||
62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) | 163 | /* now internal definition, only for zip.c and unzip.h */ |
63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) | 164 | typedef struct zlib_filefunc64_32_def_s |
64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) | 165 | { |
65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) | 166 | zlib_filefunc64_def zfile_func64; |
66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) | 167 | open_file_func zopen32_file; |
67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) | 168 | tell_file_func ztell32_file; |
169 | seek_file_func zseek32_file; | ||
170 | } zlib_filefunc64_32_def; | ||
171 | |||
172 | |||
173 | #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) | ||
174 | #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) | ||
175 | //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) | ||
176 | //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) | ||
177 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) | ||
178 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) | ||
68 | 179 | ||
180 | voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); | ||
181 | long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); | ||
182 | ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); | ||
183 | |||
184 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); | ||
185 | |||
186 | #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) | ||
187 | #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) | ||
188 | #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) | ||
69 | 189 | ||
70 | #ifdef __cplusplus | 190 | #ifdef __cplusplus |
71 | } | 191 | } |
72 | #endif | 192 | #endif |
73 | 193 | ||
74 | #endif | 194 | #endif |
75 | |||