Rev 1896 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1896 | Rev 3926 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* zutil.h -- internal interface and configuration of the compression library |
1 | /* zutil.h -- internal interface and configuration of the compression library |
2 | * Copyright (C) 1995-2010 Jean-loup Gailly. |
2 | * Copyright (C) 1995-2013 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h |
3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ |
4 | */ |
Line 5... | Line 5... | ||
5 | 5 | ||
6 | /* WARNING: this file should *not* be used by applications. It is |
6 | /* WARNING: this file should *not* be used by applications. It is |
Line 11... | Line 11... | ||
11 | /* @(#) $Id$ */ |
11 | /* @(#) $Id$ */ |
Line 12... | Line 12... | ||
12 | 12 | ||
13 | #ifndef ZUTIL_H |
13 | #ifndef ZUTIL_H |
Line 14... | Line 14... | ||
14 | #define ZUTIL_H |
14 | #define ZUTIL_H |
15 | 15 | ||
16 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) |
16 | #ifdef HAVE_HIDDEN |
17 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
17 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
18 | #else |
18 | #else |
Line 19... | Line 19... | ||
19 | # define ZLIB_INTERNAL |
19 | # define ZLIB_INTERNAL |
Line 20... | Line 20... | ||
20 | #endif |
20 | #endif |
21 | 21 | ||
22 | #include "zlib.h" |
22 | #include "zlib.h" |
23 | 23 | ||
24 | #ifdef STDC |
24 | #if defined(STDC) && !defined(Z_SOLO) |
25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
26 | # include |
26 | # include |
Line -... | Line 27... | ||
- | 27 | # endif |
|
- | 28 | # include |
|
- | 29 | # include |
|
- | 30 | #endif |
|
27 | # endif |
31 | |
28 | # include |
32 | #ifdef Z_SOLO |
29 | # include |
33 | typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ |
30 | #endif |
34 | #endif |
Line 38... | Line 42... | ||
38 | typedef uch FAR uchf; |
42 | typedef uch FAR uchf; |
39 | typedef unsigned short ush; |
43 | typedef unsigned short ush; |
40 | typedef ush FAR ushf; |
44 | typedef ush FAR ushf; |
41 | typedef unsigned long ulg; |
45 | typedef unsigned long ulg; |
Line 42... | Line 46... | ||
42 | 46 | ||
43 | extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ |
47 | extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ |
Line 44... | Line 48... | ||
44 | /* (size given to avoid silly warnings with Visual C++) */ |
48 | /* (size given to avoid silly warnings with Visual C++) */ |
Line 45... | Line 49... | ||
45 | 49 | ||
46 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
50 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
47 | 51 | ||
Line 48... | Line 52... | ||
48 | #define ERR_RETURN(strm,err) \ |
52 | #define ERR_RETURN(strm,err) \ |
Line 49... | Line 53... | ||
49 | return (strm->msg = (char*)ERR_MSG(err), (err)) |
53 | return (strm->msg = ERR_MSG(err), (err)) |
Line 76... | Line 80... | ||
76 | 80 | ||
Line 77... | Line 81... | ||
77 | /* target dependencies */ |
81 | /* target dependencies */ |
78 | 82 | ||
- | 83 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
|
79 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
84 | # define OS_CODE 0x00 |
80 | # define OS_CODE 0x00 |
85 | # ifndef Z_SOLO |
81 | # if defined(__TURBOC__) || defined(__BORLANDC__) |
86 | # if defined(__TURBOC__) || defined(__BORLANDC__) |
82 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
87 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
83 | /* Allow compilation with ANSI keywords only enabled */ |
88 | /* Allow compilation with ANSI keywords only enabled */ |
Line 88... | Line 93... | ||
88 | # endif |
93 | # endif |
89 | # else /* MSC or DJGPP */ |
94 | # else /* MSC or DJGPP */ |
90 | # include |
95 | # include |
91 | # endif |
96 | # endif |
92 | #endif |
97 | # endif |
- | 98 | #endif |
|
Line 93... | Line 99... | ||
93 | 99 | ||
94 | #ifdef AMIGA |
100 | #ifdef AMIGA |
95 | # define OS_CODE 0x01 |
101 | # define OS_CODE 0x01 |
Line 105... | Line 111... | ||
105 | # define OS_CODE 0x05 |
111 | # define OS_CODE 0x05 |
106 | #endif |
112 | #endif |
Line 107... | Line 113... | ||
107 | 113 | ||
108 | #ifdef OS2 |
114 | #ifdef OS2 |
109 | # define OS_CODE 0x06 |
115 | # define OS_CODE 0x06 |
110 | # ifdef M_I86 |
116 | # if defined(M_I86) && !defined(Z_SOLO) |
111 | # include |
117 | # include |
112 | # endif |
118 | # endif |
Line 113... | Line 119... | ||
113 | #endif |
119 | #endif |
114 | 120 | ||
- | 121 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
|
115 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
122 | # define OS_CODE 0x07 |
116 | # define OS_CODE 0x07 |
123 | # ifndef Z_SOLO |
117 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
124 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
118 | # include |
125 | # include |
119 | # else |
126 | # else |
120 | # ifndef fdopen |
127 | # ifndef fdopen |
121 | # define fdopen(fd,mode) NULL /* No fdopen() */ |
128 | # define fdopen(fd,mode) NULL /* No fdopen() */ |
122 | # endif |
129 | # endif |
- | 130 | # endif |
|
Line 123... | Line 131... | ||
123 | # endif |
131 | # endif |
124 | #endif |
132 | #endif |
125 | 133 | ||
Line 151... | Line 159... | ||
151 | # else |
159 | # else |
152 | # define fdopen(fd,type) _fdopen(fd,type) |
160 | # define fdopen(fd,type) _fdopen(fd,type) |
153 | # endif |
161 | # endif |
154 | #endif |
162 | #endif |
Line 155... | Line 163... | ||
155 | 163 | ||
156 | #if defined(__BORLANDC__) |
164 | #if defined(__BORLANDC__) && !defined(MSDOS) |
157 | #pragma warn -8004 |
165 | #pragma warn -8004 |
158 | #pragma warn -8008 |
166 | #pragma warn -8008 |
159 | #pragma warn -8066 |
167 | #pragma warn -8066 |
Line 160... | Line 168... | ||
160 | #endif |
168 | #endif |
- | 169 | ||
161 | 170 | /* provide prototypes for these when building zlib without LFS */ |
|
162 | /* provide prototypes for these when building zlib without LFS */ |
171 | #if !defined(_WIN32) && \ |
163 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
172 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
164 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
173 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
Line 165... | Line 174... | ||
165 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
174 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
Line 175... | Line 184... | ||
175 | # define F_OPEN(name, mode) fopen((name), (mode)) |
184 | # define F_OPEN(name, mode) fopen((name), (mode)) |
176 | #endif |
185 | #endif |
Line 177... | Line 186... | ||
177 | 186 | ||
Line 178... | Line -... | ||
178 | /* functions */ |
- | |
179 | - | ||
180 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) |
- | |
181 | # ifndef HAVE_VSNPRINTF |
- | |
182 | # define HAVE_VSNPRINTF |
- | |
183 | # endif |
- | |
184 | #endif |
- | |
185 | #if defined(__CYGWIN__) |
- | |
186 | # ifndef HAVE_VSNPRINTF |
- | |
187 | # define HAVE_VSNPRINTF |
- | |
188 | # endif |
- | |
189 | #endif |
- | |
190 | #ifndef HAVE_VSNPRINTF |
- | |
191 | # ifdef MSDOS |
- | |
192 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), |
- | |
193 | but for now we just assume it doesn't. */ |
- | |
194 | # define NO_vsnprintf |
- | |
195 | # endif |
- | |
196 | # ifdef __TURBOC__ |
- | |
197 | # define NO_vsnprintf |
- | |
198 | # endif |
- | |
199 | # ifdef WIN32 |
187 | /* functions */ |
200 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ |
- | |
201 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) |
- | |
202 | # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) |
- | |
203 | # define vsnprintf _vsnprintf |
- | |
204 | # endif |
- | |
205 | # endif |
- | |
206 | # endif |
- | |
207 | # ifdef __SASC |
- | |
208 | # define NO_vsnprintf |
- | |
209 | # endif |
- | |
210 | #endif |
- | |
211 | #ifdef VMS |
- | |
212 | # define NO_vsnprintf |
- | |
213 | #endif |
- | |
214 | 188 | ||
215 | #if defined(pyr) |
189 | #if defined(pyr) || defined(Z_SOLO) |
216 | # define NO_MEMCPY |
190 | # define NO_MEMCPY |
217 | #endif |
191 | #endif |
218 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
192 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
Line 259... | Line 233... | ||
259 | # define Tracevv(x) |
233 | # define Tracevv(x) |
260 | # define Tracec(c,x) |
234 | # define Tracec(c,x) |
261 | # define Tracecv(c,x) |
235 | # define Tracecv(c,x) |
262 | #endif |
236 | #endif |
Line 263... | Line 237... | ||
263 | 237 | ||
264 | 238 | #ifndef Z_SOLO |
|
265 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, |
239 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, |
266 | unsigned size)); |
240 | unsigned size)); |
- | 241 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); |
|
Line 267... | Line 242... | ||
267 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); |
242 | #endif |
268 | 243 | ||
269 | #define ZALLOC(strm, items, size) \ |
244 | #define ZALLOC(strm, items, size) \ |
270 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
245 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
Line -... | Line 246... | ||
- | 246 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
|
- | 247 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} |
|
- | 248 | ||
- | 249 | /* Reverse the bytes in a 32-bit value */ |
|
271 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
250 | #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ |