diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2023-04-14 01:42:03 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2023-04-15 21:17:31 -0700 |
commit | e9d5486e6635141f589e110fd789648aa08e9544 (patch) | |
tree | a78b9ccd92b05af7cd5776b688d9c3eb3a81a40a | |
parent | 5799c14c8526bf1aaa130c021982f831d155b46d (diff) | |
download | zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.gz zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.bz2 zlib-e9d5486e6635141f589e110fd789648aa08e9544.zip |
Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax.
Though the standard has not yet been approved, some high-profile
compilers are now issuing warnings when such definitions are
encountered.
-rw-r--r-- | adler32.c | 32 | ||||
-rw-r--r-- | compress.c | 21 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | crc32.c | 244 | ||||
-rw-r--r-- | deflate.c | 557 | ||||
-rw-r--r-- | deflate.h | 16 | ||||
-rw-r--r-- | gzclose.c | 4 | ||||
-rw-r--r-- | gzguts.h | 18 | ||||
-rw-r--r-- | gzlib.c | 97 | ||||
-rw-r--r-- | gzread.c | 84 | ||||
-rw-r--r-- | gzwrite.c | 82 | ||||
-rw-r--r-- | infback.c | 30 | ||||
-rw-r--r-- | inffast.c | 5 | ||||
-rw-r--r-- | inffast.h | 2 | ||||
-rw-r--r-- | inflate.c | 127 | ||||
-rw-r--r-- | inftrees.c | 11 | ||||
-rw-r--r-- | inftrees.h | 6 | ||||
-rw-r--r-- | test/example.c | 93 | ||||
-rw-r--r-- | test/minigzip.c | 172 | ||||
-rw-r--r-- | trees.c | 526 | ||||
-rw-r--r-- | uncompr.c | 16 | ||||
-rw-r--r-- | zlib.h | 348 | ||||
-rw-r--r-- | zutil.c | 60 | ||||
-rw-r--r-- | zutil.h | 20 |
24 files changed, 931 insertions, 1644 deletions
@@ -7,8 +7,6 @@ | |||
7 | 7 | ||
8 | #include "zutil.h" | 8 | #include "zutil.h" |
9 | 9 | ||
10 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); | ||
11 | |||
12 | #define BASE 65521U /* largest prime smaller than 65536 */ | 10 | #define BASE 65521U /* largest prime smaller than 65536 */ |
13 | #define NMAX 5552 | 11 | #define NMAX 5552 |
14 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ | 12 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
@@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); | |||
60 | #endif | 58 | #endif |
61 | 59 | ||
62 | /* ========================================================================= */ | 60 | /* ========================================================================= */ |
63 | uLong ZEXPORT adler32_z(adler, buf, len) | 61 | uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { |
64 | uLong adler; | ||
65 | const Bytef *buf; | ||
66 | z_size_t len; | ||
67 | { | ||
68 | unsigned long sum2; | 62 | unsigned long sum2; |
69 | unsigned n; | 63 | unsigned n; |
70 | 64 | ||
@@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len) | |||
131 | } | 125 | } |
132 | 126 | ||
133 | /* ========================================================================= */ | 127 | /* ========================================================================= */ |
134 | uLong ZEXPORT adler32(adler, buf, len) | 128 | uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { |
135 | uLong adler; | ||
136 | const Bytef *buf; | ||
137 | uInt len; | ||
138 | { | ||
139 | return adler32_z(adler, buf, len); | 129 | return adler32_z(adler, buf, len); |
140 | } | 130 | } |
141 | 131 | ||
142 | /* ========================================================================= */ | 132 | /* ========================================================================= */ |
143 | local uLong adler32_combine_(adler1, adler2, len2) | 133 | local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { |
144 | uLong adler1; | ||
145 | uLong adler2; | ||
146 | z_off64_t len2; | ||
147 | { | ||
148 | unsigned long sum1; | 134 | unsigned long sum1; |
149 | unsigned long sum2; | 135 | unsigned long sum2; |
150 | unsigned rem; | 136 | unsigned rem; |
@@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2) | |||
169 | } | 155 | } |
170 | 156 | ||
171 | /* ========================================================================= */ | 157 | /* ========================================================================= */ |
172 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) | 158 | uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { |
173 | uLong adler1; | ||
174 | uLong adler2; | ||
175 | z_off_t len2; | ||
176 | { | ||
177 | return adler32_combine_(adler1, adler2, len2); | 159 | return adler32_combine_(adler1, adler2, len2); |
178 | } | 160 | } |
179 | 161 | ||
180 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2) | 162 | uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { |
181 | uLong adler1; | ||
182 | uLong adler2; | ||
183 | z_off64_t len2; | ||
184 | { | ||
185 | return adler32_combine_(adler1, adler2, len2); | 163 | return adler32_combine_(adler1, adler2, len2); |
186 | } | 164 | } |
@@ -19,13 +19,8 @@ | |||
19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, | 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
20 | Z_STREAM_ERROR if the level parameter is invalid. | 20 | Z_STREAM_ERROR if the level parameter is invalid. |
21 | */ | 21 | */ |
22 | int ZEXPORT compress2(dest, destLen, source, sourceLen, level) | 22 | int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, |
23 | Bytef *dest; | 23 | uLong sourceLen, int level) { |
24 | uLongf *destLen; | ||
25 | const Bytef *source; | ||
26 | uLong sourceLen; | ||
27 | int level; | ||
28 | { | ||
29 | z_stream stream; | 24 | z_stream stream; |
30 | int err; | 25 | int err; |
31 | const uInt max = (uInt)-1; | 26 | const uInt max = (uInt)-1; |
@@ -65,12 +60,8 @@ int ZEXPORT compress2(dest, destLen, source, sourceLen, level) | |||
65 | 60 | ||
66 | /* =========================================================================== | 61 | /* =========================================================================== |
67 | */ | 62 | */ |
68 | int ZEXPORT compress(dest, destLen, source, sourceLen) | 63 | int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, |
69 | Bytef *dest; | 64 | uLong sourceLen) { |
70 | uLongf *destLen; | ||
71 | const Bytef *source; | ||
72 | uLong sourceLen; | ||
73 | { | ||
74 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); | 65 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); |
75 | } | 66 | } |
76 | 67 | ||
@@ -78,9 +69,7 @@ int ZEXPORT compress(dest, destLen, source, sourceLen) | |||
78 | If the default memLevel or windowBits for deflateInit() is changed, then | 69 | If the default memLevel or windowBits for deflateInit() is changed, then |
79 | this function needs to be updated. | 70 | this function needs to be updated. |
80 | */ | 71 | */ |
81 | uLong ZEXPORT compressBound(sourceLen) | 72 | uLong ZEXPORT compressBound(uLong sourceLen) { |
82 | uLong sourceLen; | ||
83 | { | ||
84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + | 73 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
85 | (sourceLen >> 25) + 13; | 74 | (sourceLen >> 25) + 13; |
86 | } | 75 | } |
@@ -194,8 +194,8 @@ show $cc -c $test.c | |||
194 | if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then | 194 | if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then |
195 | echo ... using gcc >> configure.log | 195 | echo ... using gcc >> configure.log |
196 | CC="$cc" | 196 | CC="$cc" |
197 | CFLAGS="${CFLAGS--O3} -Wno-deprecated-non-prototype" | 197 | CFLAGS="${CFLAGS--O3}" |
198 | SFLAGS="${CFLAGS--O3} -Wno-deprecated-non-prototype -fPIC" | 198 | SFLAGS="${CFLAGS--O3} -fPIC" |
199 | if test "$ARCHS"; then | 199 | if test "$ARCHS"; then |
200 | CFLAGS="${CFLAGS} ${ARCHS}" | 200 | CFLAGS="${CFLAGS} ${ARCHS}" |
201 | LDFLAGS="${LDFLAGS} ${ARCHS}" | 201 | LDFLAGS="${LDFLAGS} ${ARCHS}" |
@@ -103,19 +103,6 @@ | |||
103 | # define ARMCRC32 | 103 | # define ARMCRC32 |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | /* Local functions. */ | ||
107 | local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); | ||
108 | local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); | ||
109 | |||
110 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) | ||
111 | local z_word_t byte_swap OF((z_word_t word)); | ||
112 | #endif | ||
113 | |||
114 | #if defined(W) && !defined(ARMCRC32) | ||
115 | local z_crc_t crc_word OF((z_word_t data)); | ||
116 | local z_word_t crc_word_big OF((z_word_t data)); | ||
117 | #endif | ||
118 | |||
119 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) | 106 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) |
120 | /* | 107 | /* |
121 | Swap the bytes in a z_word_t to convert between little and big endian. Any | 108 | Swap the bytes in a z_word_t to convert between little and big endian. Any |
@@ -123,9 +110,7 @@ local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); | |||
123 | instruction, if one is available. This assumes that word_t is either 32 bits | 110 | instruction, if one is available. This assumes that word_t is either 32 bits |
124 | or 64 bits. | 111 | or 64 bits. |
125 | */ | 112 | */ |
126 | local z_word_t byte_swap(word) | 113 | local z_word_t byte_swap(z_word_t word) { |
127 | z_word_t word; | ||
128 | { | ||
129 | # if W == 8 | 114 | # if W == 8 |
130 | return | 115 | return |
131 | (word & 0xff00000000000000) >> 56 | | 116 | (word & 0xff00000000000000) >> 56 | |
@@ -146,24 +131,77 @@ local z_word_t byte_swap(word) | |||
146 | } | 131 | } |
147 | #endif | 132 | #endif |
148 | 133 | ||
134 | #ifdef DYNAMIC_CRC_TABLE | ||
135 | /* ========================================================================= | ||
136 | * Table of powers of x for combining CRC-32s, filled in by make_crc_table() | ||
137 | * below. | ||
138 | */ | ||
139 | local z_crc_t FAR x2n_table[32]; | ||
140 | #else | ||
141 | /* ========================================================================= | ||
142 | * Tables for byte-wise and braided CRC-32 calculations, and a table of powers | ||
143 | * of x for combining CRC-32s, all made by make_crc_table(). | ||
144 | */ | ||
145 | # include "crc32.h" | ||
146 | #endif | ||
147 | |||
149 | /* CRC polynomial. */ | 148 | /* CRC polynomial. */ |
150 | #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ | 149 | #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ |
151 | 150 | ||
152 | #ifdef DYNAMIC_CRC_TABLE | 151 | /* |
152 | Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, | ||
153 | reflected. For speed, this requires that a not be zero. | ||
154 | */ | ||
155 | local z_crc_t multmodp(z_crc_t a, z_crc_t b) { | ||
156 | z_crc_t m, p; | ||
157 | |||
158 | m = (z_crc_t)1 << 31; | ||
159 | p = 0; | ||
160 | for (;;) { | ||
161 | if (a & m) { | ||
162 | p ^= b; | ||
163 | if ((a & (m - 1)) == 0) | ||
164 | break; | ||
165 | } | ||
166 | m >>= 1; | ||
167 | b = b & 1 ? (b >> 1) ^ POLY : b >> 1; | ||
168 | } | ||
169 | return p; | ||
170 | } | ||
153 | 171 | ||
172 | /* | ||
173 | Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been | ||
174 | initialized. | ||
175 | */ | ||
176 | local z_crc_t x2nmodp(z_off64_t n, unsigned k) { | ||
177 | z_crc_t p; | ||
178 | |||
179 | p = (z_crc_t)1 << 31; /* x^0 == 1 */ | ||
180 | while (n) { | ||
181 | if (n & 1) | ||
182 | p = multmodp(x2n_table[k & 31], p); | ||
183 | n >>= 1; | ||
184 | k++; | ||
185 | } | ||
186 | return p; | ||
187 | } | ||
188 | |||
189 | #ifdef DYNAMIC_CRC_TABLE | ||
190 | /* ========================================================================= | ||
191 | * Build the tables for byte-wise and braided CRC-32 calculations, and a table | ||
192 | * of powers of x for combining CRC-32s. | ||
193 | */ | ||
154 | local z_crc_t FAR crc_table[256]; | 194 | local z_crc_t FAR crc_table[256]; |
155 | local z_crc_t FAR x2n_table[32]; | ||
156 | local void make_crc_table OF((void)); | ||
157 | #ifdef W | 195 | #ifdef W |
158 | local z_word_t FAR crc_big_table[256]; | 196 | local z_word_t FAR crc_big_table[256]; |
159 | local z_crc_t FAR crc_braid_table[W][256]; | 197 | local z_crc_t FAR crc_braid_table[W][256]; |
160 | local z_word_t FAR crc_braid_big_table[W][256]; | 198 | local z_word_t FAR crc_braid_big_table[W][256]; |
161 | local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); | 199 | local void braid(z_crc_t [][256], z_word_t [][256], int, int); |
162 | #endif | 200 | #endif |
163 | #ifdef MAKECRCH | 201 | #ifdef MAKECRCH |
164 | local void write_table OF((FILE *, const z_crc_t FAR *, int)); | 202 | local void write_table(FILE *, const z_crc_t FAR *, int); |
165 | local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); | 203 | local void write_table32hi(FILE *, const z_word_t FAR *, int); |
166 | local void write_table64 OF((FILE *, const z_word_t FAR *, int)); | 204 | local void write_table64(FILE *, const z_word_t FAR *, int); |
167 | #endif /* MAKECRCH */ | 205 | #endif /* MAKECRCH */ |
168 | 206 | ||
169 | /* | 207 | /* |
@@ -176,7 +214,6 @@ local void make_crc_table OF((void)); | |||
176 | 214 | ||
177 | /* Definition of once functionality. */ | 215 | /* Definition of once functionality. */ |
178 | typedef struct once_s once_t; | 216 | typedef struct once_s once_t; |
179 | local void once OF((once_t *, void (*)(void))); | ||
180 | 217 | ||
181 | /* Check for the availability of atomics. */ | 218 | /* Check for the availability of atomics. */ |
182 | #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ | 219 | #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ |
@@ -196,10 +233,7 @@ struct once_s { | |||
196 | invoke once() at the same time. The state must be a once_t initialized with | 233 | invoke once() at the same time. The state must be a once_t initialized with |
197 | ONCE_INIT. | 234 | ONCE_INIT. |
198 | */ | 235 | */ |
199 | local void once(state, init) | 236 | local void once(once_t *state, void (*init)(void)) { |
200 | once_t *state; | ||
201 | void (*init)(void); | ||
202 | { | ||
203 | if (!atomic_load(&state->done)) { | 237 | if (!atomic_load(&state->done)) { |
204 | if (atomic_flag_test_and_set(&state->begun)) | 238 | if (atomic_flag_test_and_set(&state->begun)) |
205 | while (!atomic_load(&state->done)) | 239 | while (!atomic_load(&state->done)) |
@@ -222,10 +256,7 @@ struct once_s { | |||
222 | 256 | ||
223 | /* Test and set. Alas, not atomic, but tries to minimize the period of | 257 | /* Test and set. Alas, not atomic, but tries to minimize the period of |
224 | vulnerability. */ | 258 | vulnerability. */ |
225 | local int test_and_set OF((int volatile *)); | 259 | local int test_and_set(int volatile *flag) { |
226 | local int test_and_set(flag) | ||
227 | int volatile *flag; | ||
228 | { | ||
229 | int was; | 260 | int was; |
230 | 261 | ||
231 | was = *flag; | 262 | was = *flag; |
@@ -234,10 +265,7 @@ local int test_and_set(flag) | |||
234 | } | 265 | } |
235 | 266 | ||
236 | /* Run the provided init() function once. This is not thread-safe. */ | 267 | /* Run the provided init() function once. This is not thread-safe. */ |
237 | local void once(state, init) | 268 | local void once(once_t *state, void (*init)(void)) { |
238 | once_t *state; | ||
239 | void (*init)(void); | ||
240 | { | ||
241 | if (!state->done) { | 269 | if (!state->done) { |
242 | if (test_and_set(&state->begun)) | 270 | if (test_and_set(&state->begun)) |
243 | while (!state->done) | 271 | while (!state->done) |
@@ -279,8 +307,7 @@ local once_t made = ONCE_INIT; | |||
279 | combinations of CRC register values and incoming bytes. | 307 | combinations of CRC register values and incoming bytes. |
280 | */ | 308 | */ |
281 | 309 | ||
282 | local void make_crc_table() | 310 | local void make_crc_table(void) { |
283 | { | ||
284 | unsigned i, j, n; | 311 | unsigned i, j, n; |
285 | z_crc_t p; | 312 | z_crc_t p; |
286 | 313 | ||
@@ -447,11 +474,7 @@ local void make_crc_table() | |||
447 | Write the 32-bit values in table[0..k-1] to out, five per line in | 474 | Write the 32-bit values in table[0..k-1] to out, five per line in |
448 | hexadecimal separated by commas. | 475 | hexadecimal separated by commas. |
449 | */ | 476 | */ |
450 | local void write_table(out, table, k) | 477 | local void write_table(FILE *out, const z_crc_t FAR *table, int k) { |
451 | FILE *out; | ||
452 | const z_crc_t FAR *table; | ||
453 | int k; | ||
454 | { | ||
455 | int n; | 478 | int n; |
456 | 479 | ||
457 | for (n = 0; n < k; n++) | 480 | for (n = 0; n < k; n++) |
@@ -464,11 +487,7 @@ local void write_table(out, table, k) | |||
464 | Write the high 32-bits of each value in table[0..k-1] to out, five per line | 487 | Write the high 32-bits of each value in table[0..k-1] to out, five per line |
465 | in hexadecimal separated by commas. | 488 | in hexadecimal separated by commas. |
466 | */ | 489 | */ |
467 | local void write_table32hi(out, table, k) | 490 | local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { |
468 | FILE *out; | ||
469 | const z_word_t FAR *table; | ||
470 | int k; | ||
471 | { | ||
472 | int n; | 491 | int n; |
473 | 492 | ||
474 | for (n = 0; n < k; n++) | 493 | for (n = 0; n < k; n++) |
@@ -484,11 +503,7 @@ int k; | |||
484 | bits. If not, then the type cast and format string can be adjusted | 503 | bits. If not, then the type cast and format string can be adjusted |
485 | accordingly. | 504 | accordingly. |
486 | */ | 505 | */ |
487 | local void write_table64(out, table, k) | 506 | local void write_table64(FILE *out, const z_word_t FAR *table, int k) { |
488 | FILE *out; | ||
489 | const z_word_t FAR *table; | ||
490 | int k; | ||
491 | { | ||
492 | int n; | 507 | int n; |
493 | 508 | ||
494 | for (n = 0; n < k; n++) | 509 | for (n = 0; n < k; n++) |
@@ -498,8 +513,7 @@ local void write_table64(out, table, k) | |||
498 | } | 513 | } |
499 | 514 | ||
500 | /* Actually do the deed. */ | 515 | /* Actually do the deed. */ |
501 | int main() | 516 | int main(void) { |
502 | { | ||
503 | make_crc_table(); | 517 | make_crc_table(); |
504 | return 0; | 518 | return 0; |
505 | } | 519 | } |
@@ -511,12 +525,7 @@ int main() | |||
511 | Generate the little and big-endian braid tables for the given n and z_word_t | 525 | Generate the little and big-endian braid tables for the given n and z_word_t |
512 | size w. Each array must have room for w blocks of 256 elements. | 526 | size w. Each array must have room for w blocks of 256 elements. |
513 | */ | 527 | */ |
514 | local void braid(ltl, big, n, w) | 528 | local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { |
515 | z_crc_t ltl[][256]; | ||
516 | z_word_t big[][256]; | ||
517 | int n; | ||
518 | int w; | ||
519 | { | ||
520 | int k; | 529 | int k; |
521 | z_crc_t i, p, q; | 530 | z_crc_t i, p, q; |
522 | for (k = 0; k < w; k++) { | 531 | for (k = 0; k < w; k++) { |
@@ -531,69 +540,13 @@ local void braid(ltl, big, n, w) | |||
531 | } | 540 | } |
532 | #endif | 541 | #endif |
533 | 542 | ||
534 | #else /* !DYNAMIC_CRC_TABLE */ | ||
535 | /* ======================================================================== | ||
536 | * Tables for byte-wise and braided CRC-32 calculations, and a table of powers | ||
537 | * of x for combining CRC-32s, all made by make_crc_table(). | ||
538 | */ | ||
539 | #include "crc32.h" | ||
540 | #endif /* DYNAMIC_CRC_TABLE */ | 543 | #endif /* DYNAMIC_CRC_TABLE */ |
541 | 544 | ||
542 | /* ======================================================================== | ||
543 | * Routines used for CRC calculation. Some are also required for the table | ||
544 | * generation above. | ||
545 | */ | ||
546 | |||
547 | /* | ||
548 | Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, | ||
549 | reflected. For speed, this requires that a not be zero. | ||
550 | */ | ||
551 | local z_crc_t multmodp(a, b) | ||
552 | z_crc_t a; | ||
553 | z_crc_t b; | ||
554 | { | ||
555 | z_crc_t m, p; | ||
556 | |||
557 | m = (z_crc_t)1 << 31; | ||
558 | p = 0; | ||
559 | for (;;) { | ||
560 | if (a & m) { | ||
561 | p ^= b; | ||
562 | if ((a & (m - 1)) == 0) | ||
563 | break; | ||
564 | } | ||
565 | m >>= 1; | ||
566 | b = b & 1 ? (b >> 1) ^ POLY : b >> 1; | ||
567 | } | ||
568 | return p; | ||
569 | } | ||
570 | |||
571 | /* | ||
572 | Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been | ||
573 | initialized. | ||
574 | */ | ||
575 | local z_crc_t x2nmodp(n, k) | ||
576 | z_off64_t n; | ||
577 | unsigned k; | ||
578 | { | ||
579 | z_crc_t p; | ||
580 | |||
581 | p = (z_crc_t)1 << 31; /* x^0 == 1 */ | ||
582 | while (n) { | ||
583 | if (n & 1) | ||
584 | p = multmodp(x2n_table[k & 31], p); | ||
585 | n >>= 1; | ||
586 | k++; | ||
587 | } | ||
588 | return p; | ||
589 | } | ||
590 | |||
591 | /* ========================================================================= | 545 | /* ========================================================================= |
592 | * This function can be used by asm versions of crc32(), and to force the | 546 | * This function can be used by asm versions of crc32(), and to force the |
593 | * generation of the CRC tables in a threaded application. | 547 | * generation of the CRC tables in a threaded application. |
594 | */ | 548 | */ |
595 | const z_crc_t FAR * ZEXPORT get_crc_table() | 549 | const z_crc_t FAR * ZEXPORT get_crc_table(void) { |
596 | { | ||
597 | #ifdef DYNAMIC_CRC_TABLE | 550 | #ifdef DYNAMIC_CRC_TABLE |
598 | once(&made, make_crc_table); | 551 | once(&made, make_crc_table); |
599 | #endif /* DYNAMIC_CRC_TABLE */ | 552 | #endif /* DYNAMIC_CRC_TABLE */ |
@@ -619,11 +572,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table() | |||
619 | #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ | 572 | #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ |
620 | #define Z_BATCH_MIN 800 /* fewest words in a final batch */ | 573 | #define Z_BATCH_MIN 800 /* fewest words in a final batch */ |
621 | 574 | ||
622 | unsigned long ZEXPORT crc32_z(crc, buf, len) | 575 | unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, |
623 | unsigned long crc; | 576 | z_size_t len) { |
624 | const unsigned char FAR *buf; | ||
625 | z_size_t len; | ||
626 | { | ||
627 | z_crc_t val; | 577 | z_crc_t val; |
628 | z_word_t crc1, crc2; | 578 | z_word_t crc1, crc2; |
629 | const z_word_t *word; | 579 | const z_word_t *word; |
@@ -723,18 +673,14 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) | |||
723 | least-significant byte of the word as the first byte of data, without any pre | 673 | least-significant byte of the word as the first byte of data, without any pre |
724 | or post conditioning. This is used to combine the CRCs of each braid. | 674 | or post conditioning. This is used to combine the CRCs of each braid. |
725 | */ | 675 | */ |
726 | local z_crc_t crc_word(data) | 676 | local z_crc_t crc_word(z_word_t data) { |
727 | z_word_t data; | ||
728 | { | ||
729 | int k; | 677 | int k; |
730 | for (k = 0; k < W; k++) | 678 | for (k = 0; k < W; k++) |
731 | data = (data >> 8) ^ crc_table[data & 0xff]; | 679 | data = (data >> 8) ^ crc_table[data & 0xff]; |
732 | return (z_crc_t)data; | 680 | return (z_crc_t)data; |
733 | } | 681 | } |
734 | 682 | ||
735 | local z_word_t crc_word_big(data) | 683 | local z_word_t crc_word_big(z_word_t data) { |
736 | z_word_t data; | ||
737 | { | ||
738 | int k; | 684 | int k; |
739 | for (k = 0; k < W; k++) | 685 | for (k = 0; k < W; k++) |
740 | data = (data << 8) ^ | 686 | data = (data << 8) ^ |
@@ -745,11 +691,8 @@ local z_word_t crc_word_big(data) | |||
745 | #endif | 691 | #endif |
746 | 692 | ||
747 | /* ========================================================================= */ | 693 | /* ========================================================================= */ |
748 | unsigned long ZEXPORT crc32_z(crc, buf, len) | 694 | unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, |
749 | unsigned long crc; | 695 | z_size_t len) { |
750 | const unsigned char FAR *buf; | ||
751 | z_size_t len; | ||
752 | { | ||
753 | /* Return initial CRC, if requested. */ | 696 | /* Return initial CRC, if requested. */ |
754 | if (buf == Z_NULL) return 0; | 697 | if (buf == Z_NULL) return 0; |
755 | 698 | ||
@@ -1069,20 +1012,13 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) | |||
1069 | #endif | 1012 | #endif |
1070 | 1013 | ||
1071 | /* ========================================================================= */ | 1014 | /* ========================================================================= */ |
1072 | unsigned long ZEXPORT crc32(crc, buf, len) | 1015 | unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, |
1073 | unsigned long crc; | 1016 | uInt len) { |
1074 | const unsigned char FAR *buf; | ||
1075 | uInt len; | ||
1076 | { | ||
1077 | return crc32_z(crc, buf, len); | 1017 | return crc32_z(crc, buf, len); |
1078 | } | 1018 | } |
1079 | 1019 | ||
1080 | /* ========================================================================= */ | 1020 | /* ========================================================================= */ |
1081 | uLong ZEXPORT crc32_combine64(crc1, crc2, len2) | 1021 | uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { |
1082 | uLong crc1; | ||
1083 | uLong crc2; | ||
1084 | z_off64_t len2; | ||
1085 | { | ||
1086 | #ifdef DYNAMIC_CRC_TABLE | 1022 | #ifdef DYNAMIC_CRC_TABLE |
1087 | once(&made, make_crc_table); | 1023 | once(&made, make_crc_table); |
1088 | #endif /* DYNAMIC_CRC_TABLE */ | 1024 | #endif /* DYNAMIC_CRC_TABLE */ |
@@ -1090,18 +1026,12 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2) | |||
1090 | } | 1026 | } |
1091 | 1027 | ||
1092 | /* ========================================================================= */ | 1028 | /* ========================================================================= */ |
1093 | uLong ZEXPORT crc32_combine(crc1, crc2, len2) | 1029 | uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { |
1094 | uLong crc1; | ||
1095 | uLong crc2; | ||
1096 | z_off_t len2; | ||
1097 | { | ||
1098 | return crc32_combine64(crc1, crc2, (z_off64_t)len2); | 1030 | return crc32_combine64(crc1, crc2, (z_off64_t)len2); |
1099 | } | 1031 | } |
1100 | 1032 | ||
1101 | /* ========================================================================= */ | 1033 | /* ========================================================================= */ |
1102 | uLong ZEXPORT crc32_combine_gen64(len2) | 1034 | uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { |
1103 | z_off64_t len2; | ||
1104 | { | ||
1105 | #ifdef DYNAMIC_CRC_TABLE | 1035 | #ifdef DYNAMIC_CRC_TABLE |
1106 | once(&made, make_crc_table); | 1036 | once(&made, make_crc_table); |
1107 | #endif /* DYNAMIC_CRC_TABLE */ | 1037 | #endif /* DYNAMIC_CRC_TABLE */ |
@@ -1109,17 +1039,11 @@ uLong ZEXPORT crc32_combine_gen64(len2) | |||
1109 | } | 1039 | } |
1110 | 1040 | ||
1111 | /* ========================================================================= */ | 1041 | /* ========================================================================= */ |
1112 | uLong ZEXPORT crc32_combine_gen(len2) | 1042 | uLong ZEXPORT crc32_combine_gen(z_off_t len2) { |
1113 | z_off_t len2; | ||
1114 | { | ||
1115 | return crc32_combine_gen64((z_off64_t)len2); | 1043 | return crc32_combine_gen64((z_off64_t)len2); |
1116 | } | 1044 | } |
1117 | 1045 | ||
1118 | /* ========================================================================= */ | 1046 | /* ========================================================================= */ |
1119 | uLong ZEXPORT crc32_combine_op(crc1, crc2, op) | 1047 | uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { |
1120 | uLong crc1; | ||
1121 | uLong crc2; | ||
1122 | uLong op; | ||
1123 | { | ||
1124 | return multmodp(op, crc1) ^ (crc2 & 0xffffffff); | 1048 | return multmodp(op, crc1) ^ (crc2 & 0xffffffff); |
1125 | } | 1049 | } |
@@ -60,9 +60,6 @@ const char deflate_copyright[] = | |||
60 | copyright string in the executable of your product. | 60 | copyright string in the executable of your product. |
61 | */ | 61 | */ |
62 | 62 | ||
63 | /* =========================================================================== | ||
64 | * Function prototypes. | ||
65 | */ | ||
66 | typedef enum { | 63 | typedef enum { |
67 | need_more, /* block not completed, need more input or more output */ | 64 | need_more, /* block not completed, need more input or more output */ |
68 | block_done, /* block flush performed */ | 65 | block_done, /* block flush performed */ |
@@ -70,29 +67,16 @@ typedef enum { | |||
70 | finish_done /* finish done, accept no more input or output */ | 67 | finish_done /* finish done, accept no more input or output */ |
71 | } block_state; | 68 | } block_state; |
72 | 69 | ||
73 | typedef block_state (*compress_func) OF((deflate_state *s, int flush)); | 70 | typedef block_state (*compress_func)(deflate_state *s, int flush); |
74 | /* Compression function. Returns the block state after the call. */ | 71 | /* Compression function. Returns the block state after the call. */ |
75 | 72 | ||
76 | local int deflateStateCheck OF((z_streamp strm)); | 73 | local block_state deflate_stored(deflate_state *s, int flush); |
77 | local void slide_hash OF((deflate_state *s)); | 74 | local block_state deflate_fast(deflate_state *s, int flush); |
78 | local void fill_window OF((deflate_state *s)); | ||
79 | local block_state deflate_stored OF((deflate_state *s, int flush)); | ||
80 | local block_state deflate_fast OF((deflate_state *s, int flush)); | ||
81 | #ifndef FASTEST | 75 | #ifndef FASTEST |
82 | local block_state deflate_slow OF((deflate_state *s, int flush)); | 76 | local block_state deflate_slow(deflate_state *s, int flush); |
83 | #endif | ||
84 | local block_state deflate_rle OF((deflate_state *s, int flush)); | ||
85 | local block_state deflate_huff OF((deflate_state *s, int flush)); | ||
86 | local void lm_init OF((deflate_state *s)); | ||
87 | local void putShortMSB OF((deflate_state *s, uInt b)); | ||
88 | local void flush_pending OF((z_streamp strm)); | ||
89 | local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); | ||
90 | local uInt longest_match OF((deflate_state *s, IPos cur_match)); | ||
91 | |||
92 | #ifdef ZLIB_DEBUG | ||
93 | local void check_match OF((deflate_state *s, IPos start, IPos match, | ||
94 | int length)); | ||
95 | #endif | 77 | #endif |
78 | local block_state deflate_rle(deflate_state *s, int flush); | ||
79 | local block_state deflate_huff(deflate_state *s, int flush); | ||
96 | 80 | ||
97 | /* =========================================================================== | 81 | /* =========================================================================== |
98 | * Local data | 82 | * Local data |
@@ -195,9 +179,7 @@ local const config configuration_table[10] = { | |||
195 | * bit values at the expense of memory usage). We slide even when level == 0 to | 179 | * bit values at the expense of memory usage). We slide even when level == 0 to |
196 | * keep the hash table consistent if we switch back to level > 0 later. | 180 | * keep the hash table consistent if we switch back to level > 0 later. |
197 | */ | 181 | */ |
198 | local void slide_hash(s) | 182 | local void slide_hash(deflate_state *s) { |
199 | deflate_state *s; | ||
200 | { | ||
201 | unsigned n, m; | 183 | unsigned n, m; |
202 | Posf *p; | 184 | Posf *p; |
203 | uInt wsize = s->w_size; | 185 | uInt wsize = s->w_size; |
@@ -221,30 +203,177 @@ local void slide_hash(s) | |||
221 | #endif | 203 | #endif |
222 | } | 204 | } |
223 | 205 | ||
206 | /* =========================================================================== | ||
207 | * Read a new buffer from the current input stream, update the adler32 | ||
208 | * and total number of bytes read. All deflate() input goes through | ||
209 | * this function so some applications may wish to modify it to avoid | ||
210 | * allocating a large strm->next_in buffer and copying from it. | ||
211 | * (See also flush_pending()). | ||
212 | */ | ||
213 | local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { | ||
214 | unsigned len = strm->avail_in; | ||
215 | |||
216 | if (len > size) len = size; | ||
217 | if (len == 0) return 0; | ||
218 | |||
219 | strm->avail_in -= len; | ||
220 | |||
221 | zmemcpy(buf, strm->next_in, len); | ||
222 | if (strm->state->wrap == 1) { | ||
223 | strm->adler = adler32(strm->adler, buf, len); | ||
224 | } | ||
225 | #ifdef GZIP | ||
226 | else if (strm->state->wrap == 2) { | ||
227 | strm->adler = crc32(strm->adler, buf, len); | ||
228 | } | ||
229 | #endif | ||
230 | strm->next_in += len; | ||
231 | strm->total_in += len; | ||
232 | |||
233 | return len; | ||
234 | } | ||
235 | |||
236 | /* =========================================================================== | ||
237 | * Fill the window when the lookahead becomes insufficient. | ||
238 | * Updates strstart and lookahead. | ||
239 | * | ||
240 | * IN assertion: lookahead < MIN_LOOKAHEAD | ||
241 | * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD | ||
242 | * At least one byte has been read, or avail_in == 0; reads are | ||
243 | * performed for at least two bytes (required for the zip translate_eol | ||
244 | * option -- not supported here). | ||
245 | */ | ||
246 | local void fill_window(deflate_state *s) { | ||
247 | unsigned n; | ||
248 | unsigned more; /* Amount of free space at the end of the window. */ | ||
249 | uInt wsize = s->w_size; | ||
250 | |||
251 | Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); | ||
252 | |||
253 | do { | ||
254 | more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); | ||
255 | |||
256 | /* Deal with !@#$% 64K limit: */ | ||
257 | if (sizeof(int) <= 2) { | ||
258 | if (more == 0 && s->strstart == 0 && s->lookahead == 0) { | ||
259 | more = wsize; | ||
260 | |||
261 | } else if (more == (unsigned)(-1)) { | ||
262 | /* Very unlikely, but possible on 16 bit machine if | ||
263 | * strstart == 0 && lookahead == 1 (input done a byte at time) | ||
264 | */ | ||
265 | more--; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | /* If the window is almost full and there is insufficient lookahead, | ||
270 | * move the upper half to the lower one to make room in the upper half. | ||
271 | */ | ||
272 | if (s->strstart >= wsize + MAX_DIST(s)) { | ||
273 | |||
274 | zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); | ||
275 | s->match_start -= wsize; | ||
276 | s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ | ||
277 | s->block_start -= (long) wsize; | ||
278 | if (s->insert > s->strstart) | ||
279 | s->insert = s->strstart; | ||
280 | slide_hash(s); | ||
281 | more += wsize; | ||
282 | } | ||
283 | if (s->strm->avail_in == 0) break; | ||
284 | |||
285 | /* If there was no sliding: | ||
286 | * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && | ||
287 | * more == window_size - lookahead - strstart | ||
288 | * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) | ||
289 | * => more >= window_size - 2*WSIZE + 2 | ||
290 | * In the BIG_MEM or MMAP case (not yet supported), | ||
291 | * window_size == input_size + MIN_LOOKAHEAD && | ||
292 | * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. | ||
293 | * Otherwise, window_size == 2*WSIZE so more >= 2. | ||
294 | * If there was sliding, more >= WSIZE. So in all cases, more >= 2. | ||
295 | */ | ||
296 | Assert(more >= 2, "more < 2"); | ||
297 | |||
298 | n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); | ||
299 | s->lookahead += n; | ||
300 | |||
301 | /* Initialize the hash value now that we have some input: */ | ||
302 | if (s->lookahead + s->insert >= MIN_MATCH) { | ||
303 | uInt str = s->strstart - s->insert; | ||
304 | s->ins_h = s->window[str]; | ||
305 | UPDATE_HASH(s, s->ins_h, s->window[str + 1]); | ||
306 | #if MIN_MATCH != 3 | ||
307 | Call UPDATE_HASH() MIN_MATCH-3 more times | ||
308 | #endif | ||
309 | while (s->insert) { | ||
310 | UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); | ||
311 | #ifndef FASTEST | ||
312 | s->prev[str & s->w_mask] = s->head[s->ins_h]; | ||
313 | #endif | ||
314 | s->head[s->ins_h] = (Pos)str; | ||
315 | str++; | ||
316 | s->insert--; | ||
317 | if (s->lookahead + s->insert < MIN_MATCH) | ||
318 | break; | ||
319 | } | ||
320 | } | ||
321 | /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, | ||
322 | * but this is not important since only literal bytes will be emitted. | ||
323 | */ | ||
324 | |||
325 | } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); | ||
326 | |||
327 | /* If the WIN_INIT bytes after the end of the current data have never been | ||
328 | * written, then zero those bytes in order to avoid memory check reports of | ||
329 | * the use of uninitialized (or uninitialised as Julian writes) bytes by | ||
330 | * the longest match routines. Update the high water mark for the next | ||
331 | * time through here. WIN_INIT is set to MAX_MATCH since the longest match | ||
332 | * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. | ||
333 | */ | ||
334 | if (s->high_water < s->window_size) { | ||
335 | ulg curr = s->strstart + (ulg)(s->lookahead); | ||
336 | ulg init; | ||
337 | |||
338 | if (s->high_water < curr) { | ||
339 | /* Previous high water mark below current data -- zero WIN_INIT | ||
340 | * bytes or up to end of window, whichever is less. | ||
341 | */ | ||
342 | init = s->window_size - curr; | ||
343 | if (init > WIN_INIT) | ||
344 | init = WIN_INIT; | ||
345 | zmemzero(s->window + curr, (unsigned)init); | ||
346 | s->high_water = curr + init; | ||
347 | } | ||
348 | else if (s->high_water < (ulg)curr + WIN_INIT) { | ||
349 | /* High water mark at or above current data, but below current data | ||
350 | * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up | ||
351 | * to end of window, whichever is less. | ||
352 | */ | ||
353 | init = (ulg)curr + WIN_INIT - s->high_water; | ||
354 | if (init > s->window_size - s->high_water) | ||
355 | init = s->window_size - s->high_water; | ||
356 | zmemzero(s->window + s->high_water, (unsigned)init); | ||
357 | s->high_water += init; | ||
358 | } | ||
359 | } | ||
360 | |||
361 | Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, | ||
362 | "not enough room for search"); | ||
363 | } | ||
364 | |||
224 | /* ========================================================================= */ | 365 | /* ========================================================================= */ |
225 | int ZEXPORT deflateInit_(strm, level, version, stream_size) | 366 | int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, |
226 | z_streamp strm; | 367 | int stream_size) { |
227 | int level; | ||
228 | const char *version; | ||
229 | int stream_size; | ||
230 | { | ||
231 | return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, | 368 | return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, |
232 | Z_DEFAULT_STRATEGY, version, stream_size); | 369 | Z_DEFAULT_STRATEGY, version, stream_size); |
233 | /* To do: ignore strm->next_in if we use it as window */ | 370 | /* To do: ignore strm->next_in if we use it as window */ |
234 | } | 371 | } |
235 | 372 | ||
236 | /* ========================================================================= */ | 373 | /* ========================================================================= */ |
237 | int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | 374 | int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, |
238 | version, stream_size) | 375 | int windowBits, int memLevel, int strategy, |
239 | z_streamp strm; | 376 | const char *version, int stream_size) { |
240 | int level; | ||
241 | int method; | ||
242 | int windowBits; | ||
243 | int memLevel; | ||
244 | int strategy; | ||
245 | const char *version; | ||
246 | int stream_size; | ||
247 | { | ||
248 | deflate_state *s; | 377 | deflate_state *s; |
249 | int wrap = 1; | 378 | int wrap = 1; |
250 | static const char my_version[] = ZLIB_VERSION; | 379 | static const char my_version[] = ZLIB_VERSION; |
@@ -386,9 +515,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | |||
386 | /* ========================================================================= | 515 | /* ========================================================================= |
387 | * Check for a valid deflate stream state. Return 0 if ok, 1 if not. | 516 | * Check for a valid deflate stream state. Return 0 if ok, 1 if not. |
388 | */ | 517 | */ |
389 | local int deflateStateCheck(strm) | 518 | local int deflateStateCheck(z_streamp strm) { |
390 | z_streamp strm; | ||
391 | { | ||
392 | deflate_state *s; | 519 | deflate_state *s; |
393 | if (strm == Z_NULL || | 520 | if (strm == Z_NULL || |
394 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) | 521 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
@@ -409,11 +536,8 @@ local int deflateStateCheck(strm) | |||
409 | } | 536 | } |
410 | 537 | ||
411 | /* ========================================================================= */ | 538 | /* ========================================================================= */ |
412 | int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) | 539 | int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, |
413 | z_streamp strm; | 540 | uInt dictLength) { |
414 | const Bytef *dictionary; | ||
415 | uInt dictLength; | ||
416 | { | ||
417 | deflate_state *s; | 541 | deflate_state *s; |
418 | uInt str, n; | 542 | uInt str, n; |
419 | int wrap; | 543 | int wrap; |
@@ -478,11 +602,8 @@ int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) | |||
478 | } | 602 | } |
479 | 603 | ||
480 | /* ========================================================================= */ | 604 | /* ========================================================================= */ |
481 | int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) | 605 | int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, |
482 | z_streamp strm; | 606 | uInt *dictLength) { |
483 | Bytef *dictionary; | ||
484 | uInt *dictLength; | ||
485 | { | ||
486 | deflate_state *s; | 607 | deflate_state *s; |
487 | uInt len; | 608 | uInt len; |
488 | 609 | ||
@@ -500,9 +621,7 @@ int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) | |||
500 | } | 621 | } |
501 | 622 | ||
502 | /* ========================================================================= */ | 623 | /* ========================================================================= */ |
503 | int ZEXPORT deflateResetKeep(strm) | 624 | int ZEXPORT deflateResetKeep(z_streamp strm) { |
504 | z_streamp strm; | ||
505 | { | ||
506 | deflate_state *s; | 625 | deflate_state *s; |
507 | 626 | ||
508 | if (deflateStateCheck(strm)) { | 627 | if (deflateStateCheck(strm)) { |
@@ -537,10 +656,32 @@ int ZEXPORT deflateResetKeep(strm) | |||
537 | return Z_OK; | 656 | return Z_OK; |
538 | } | 657 | } |
539 | 658 | ||
659 | /* =========================================================================== | ||
660 | * Initialize the "longest match" routines for a new zlib stream | ||
661 | */ | ||
662 | local void lm_init(deflate_state *s) { | ||
663 | s->window_size = (ulg)2L*s->w_size; | ||
664 | |||
665 | CLEAR_HASH(s); | ||
666 | |||
667 | /* Set the default configuration parameters: | ||
668 | */ | ||
669 | s->max_lazy_match = configuration_table[s->level].max_lazy; | ||
670 | s->good_match = configuration_table[s->level].good_length; | ||
671 | s->nice_match = configuration_table[s->level].nice_length; | ||
672 | s->max_chain_length = configuration_table[s->level].max_chain; | ||
673 | |||
674 | s->strstart = 0; | ||
675 | s->block_start = 0L; | ||
676 | s->lookahead = 0; | ||
677 | s->insert = 0; | ||
678 | s->match_length = s->prev_length = MIN_MATCH-1; | ||
679 | s->match_available = 0; | ||
680 | s->ins_h = 0; | ||
681 | } | ||
682 | |||
540 | /* ========================================================================= */ | 683 | /* ========================================================================= */ |
541 | int ZEXPORT deflateReset(strm) | 684 | int ZEXPORT deflateReset(z_streamp strm) { |
542 | z_streamp strm; | ||
543 | { | ||
544 | int ret; | 685 | int ret; |
545 | 686 | ||
546 | ret = deflateResetKeep(strm); | 687 | ret = deflateResetKeep(strm); |
@@ -550,10 +691,7 @@ int ZEXPORT deflateReset(strm) | |||
550 | } | 691 | } |
551 | 692 | ||
552 | /* ========================================================================= */ | 693 | /* ========================================================================= */ |
553 | int ZEXPORT deflateSetHeader(strm, head) | 694 | int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { |
554 | z_streamp strm; | ||
555 | gz_headerp head; | ||
556 | { | ||
557 | if (deflateStateCheck(strm) || strm->state->wrap != 2) | 695 | if (deflateStateCheck(strm) || strm->state->wrap != 2) |
558 | return Z_STREAM_ERROR; | 696 | return Z_STREAM_ERROR; |
559 | strm->state->gzhead = head; | 697 | strm->state->gzhead = head; |
@@ -561,11 +699,7 @@ int ZEXPORT deflateSetHeader(strm, head) | |||
561 | } | 699 | } |
562 | 700 | ||
563 | /* ========================================================================= */ | 701 | /* ========================================================================= */ |
564 | int ZEXPORT deflatePending(strm, pending, bits) | 702 | int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { |
565 | unsigned *pending; | ||
566 | int *bits; | ||
567 | z_streamp strm; | ||
568 | { | ||
569 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; | 703 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
570 | if (pending != Z_NULL) | 704 | if (pending != Z_NULL) |
571 | *pending = strm->state->pending; | 705 | *pending = strm->state->pending; |
@@ -575,11 +709,7 @@ int ZEXPORT deflatePending(strm, pending, bits) | |||
575 | } | 709 | } |
576 | 710 | ||
577 | /* ========================================================================= */ | 711 | /* ========================================================================= */ |
578 | int ZEXPORT deflatePrime(strm, bits, value) | 712 | int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { |
579 | z_streamp strm; | ||
580 | int bits; | ||
581 | int value; | ||
582 | { | ||
583 | deflate_state *s; | 713 | deflate_state *s; |
584 | int put; | 714 | int put; |
585 | 715 | ||
@@ -602,11 +732,7 @@ int ZEXPORT deflatePrime(strm, bits, value) | |||
602 | } | 732 | } |
603 | 733 | ||
604 | /* ========================================================================= */ | 734 | /* ========================================================================= */ |
605 | int ZEXPORT deflateParams(strm, level, strategy) | 735 | int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { |
606 | z_streamp strm; | ||
607 | int level; | ||
608 | int strategy; | ||
609 | { | ||
610 | deflate_state *s; | 736 | deflate_state *s; |
611 | compress_func func; | 737 | compress_func func; |
612 | 738 | ||
@@ -651,13 +777,8 @@ int ZEXPORT deflateParams(strm, level, strategy) | |||
651 | } | 777 | } |
652 | 778 | ||
653 | /* ========================================================================= */ | 779 | /* ========================================================================= */ |
654 | int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) | 780 | int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, |
655 | z_streamp strm; | 781 | int nice_length, int max_chain) { |
656 | int good_length; | ||
657 | int max_lazy; | ||
658 | int nice_length; | ||
659 | int max_chain; | ||
660 | { | ||
661 | deflate_state *s; | 782 | deflate_state *s; |
662 | 783 | ||
663 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; | 784 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -693,10 +814,7 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) | |||
693 | * | 814 | * |
694 | * Shifts are used to approximate divisions, for speed. | 815 | * Shifts are used to approximate divisions, for speed. |
695 | */ | 816 | */ |
696 | uLong ZEXPORT deflateBound(strm, sourceLen) | 817 | uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { |
697 | z_streamp strm; | ||
698 | uLong sourceLen; | ||
699 | { | ||
700 | deflate_state *s; | 818 | deflate_state *s; |
701 | uLong fixedlen, storelen, wraplen; | 819 | uLong fixedlen, storelen, wraplen; |
702 | 820 | ||
@@ -766,10 +884,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen) | |||
766 | * IN assertion: the stream state is correct and there is enough room in | 884 | * IN assertion: the stream state is correct and there is enough room in |
767 | * pending_buf. | 885 | * pending_buf. |
768 | */ | 886 | */ |
769 | local void putShortMSB(s, b) | 887 | local void putShortMSB(deflate_state *s, uInt b) { |
770 | deflate_state *s; | ||
771 | uInt b; | ||
772 | { | ||
773 | put_byte(s, (Byte)(b >> 8)); | 888 | put_byte(s, (Byte)(b >> 8)); |
774 | put_byte(s, (Byte)(b & 0xff)); | 889 | put_byte(s, (Byte)(b & 0xff)); |
775 | } | 890 | } |
@@ -780,9 +895,7 @@ local void putShortMSB(s, b) | |||
780 | * applications may wish to modify it to avoid allocating a large | 895 | * applications may wish to modify it to avoid allocating a large |
781 | * strm->next_out buffer and copying into it. (See also read_buf()). | 896 | * strm->next_out buffer and copying into it. (See also read_buf()). |
782 | */ | 897 | */ |
783 | local void flush_pending(strm) | 898 | local void flush_pending(z_streamp strm) { |
784 | z_streamp strm; | ||
785 | { | ||
786 | unsigned len; | 899 | unsigned len; |
787 | deflate_state *s = strm->state; | 900 | deflate_state *s = strm->state; |
788 | 901 | ||
@@ -813,10 +926,7 @@ local void flush_pending(strm) | |||
813 | } while (0) | 926 | } while (0) |
814 | 927 | ||
815 | /* ========================================================================= */ | 928 | /* ========================================================================= */ |
816 | int ZEXPORT deflate(strm, flush) | 929 | int ZEXPORT deflate(z_streamp strm, int flush) { |
817 | z_streamp strm; | ||
818 | int flush; | ||
819 | { | ||
820 | int old_flush; /* value of flush param for previous deflate call */ | 930 | int old_flush; /* value of flush param for previous deflate call */ |
821 | deflate_state *s; | 931 | deflate_state *s; |
822 | 932 | ||
@@ -1128,9 +1238,7 @@ int ZEXPORT deflate(strm, flush) | |||
1128 | } | 1238 | } |
1129 | 1239 | ||
1130 | /* ========================================================================= */ | 1240 | /* ========================================================================= */ |
1131 | int ZEXPORT deflateEnd(strm) | 1241 | int ZEXPORT deflateEnd(z_streamp strm) { |
1132 | z_streamp strm; | ||
1133 | { | ||
1134 | int status; | 1242 | int status; |
1135 | 1243 | ||
1136 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; | 1244 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -1154,11 +1262,10 @@ int ZEXPORT deflateEnd(strm) | |||
1154 | * To simplify the source, this is not supported for 16-bit MSDOS (which | 1262 | * To simplify the source, this is not supported for 16-bit MSDOS (which |
1155 | * doesn't have enough memory anyway to duplicate compression states). | 1263 | * doesn't have enough memory anyway to duplicate compression states). |
1156 | */ | 1264 | */ |
1157 | int ZEXPORT deflateCopy(dest, source) | 1265 | int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { |
1158 | z_streamp dest; | ||
1159 | z_streamp source; | ||
1160 | { | ||
1161 | #ifdef MAXSEG_64K | 1266 | #ifdef MAXSEG_64K |
1267 | (void)dest; | ||
1268 | (void)source; | ||
1162 | return Z_STREAM_ERROR; | 1269 | return Z_STREAM_ERROR; |
1163 | #else | 1270 | #else |
1164 | deflate_state *ds; | 1271 | deflate_state *ds; |
@@ -1206,66 +1313,6 @@ int ZEXPORT deflateCopy(dest, source) | |||
1206 | #endif /* MAXSEG_64K */ | 1313 | #endif /* MAXSEG_64K */ |
1207 | } | 1314 | } |
1208 | 1315 | ||
1209 | /* =========================================================================== | ||
1210 | * Read a new buffer from the current input stream, update the adler32 | ||
1211 | * and total number of bytes read. All deflate() input goes through | ||
1212 | * this function so some applications may wish to modify it to avoid | ||
1213 | * allocating a large strm->next_in buffer and copying from it. | ||
1214 | * (See also flush_pending()). | ||
1215 | */ | ||
1216 | local unsigned read_buf(strm, buf, size) | ||
1217 | z_streamp strm; | ||
1218 | Bytef *buf; | ||
1219 | unsigned size; | ||
1220 | { | ||
1221 | unsigned len = strm->avail_in; | ||
1222 | |||
1223 | if (len > size) len = size; | ||
1224 | if (len == 0) return 0; | ||
1225 | |||
1226 | strm->avail_in -= len; | ||
1227 | |||
1228 | zmemcpy(buf, strm->next_in, len); | ||
1229 | if (strm->state->wrap == 1) { | ||
1230 | strm->adler = adler32(strm->adler, buf, len); | ||
1231 | } | ||
1232 | #ifdef GZIP | ||
1233 | else if (strm->state->wrap == 2) { | ||
1234 | strm->adler = crc32(strm->adler, buf, len); | ||
1235 | } | ||
1236 | #endif | ||
1237 | strm->next_in += len; | ||
1238 | strm->total_in += len; | ||
1239 | |||
1240 | return len; | ||
1241 | } | ||
1242 | |||
1243 | /* =========================================================================== | ||
1244 | * Initialize the "longest match" routines for a new zlib stream | ||
1245 | */ | ||
1246 | local void lm_init(s) | ||
1247 | deflate_state *s; | ||
1248 | { | ||
1249 | s->window_size = (ulg)2L*s->w_size; | ||
1250 | |||
1251 | CLEAR_HASH(s); | ||
1252 | |||
1253 | /* Set the default configuration parameters: | ||
1254 | */ | ||
1255 | s->max_lazy_match = configuration_table[s->level].max_lazy; | ||
1256 | s->good_match = configuration_table[s->level].good_length; | ||
1257 | s->nice_match = configuration_table[s->level].nice_length; | ||
1258 | s->max_chain_length = configuration_table[s->level].max_chain; | ||
1259 | |||
1260 | s->strstart = 0; | ||
1261 | s->block_start = 0L; | ||
1262 | s->lookahead = 0; | ||
1263 | s->insert = 0; | ||
1264 | s->match_length = s->prev_length = MIN_MATCH-1; | ||
1265 | s->match_available = 0; | ||
1266 | s->ins_h = 0; | ||
1267 | } | ||
1268 | |||
1269 | #ifndef FASTEST | 1316 | #ifndef FASTEST |
1270 | /* =========================================================================== | 1317 | /* =========================================================================== |
1271 | * Set match_start to the longest match starting at the given string and | 1318 | * Set match_start to the longest match starting at the given string and |
@@ -1276,10 +1323,7 @@ local void lm_init(s) | |||
1276 | * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 | 1323 | * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 |
1277 | * OUT assertion: the match length is not greater than s->lookahead. | 1324 | * OUT assertion: the match length is not greater than s->lookahead. |
1278 | */ | 1325 | */ |
1279 | local uInt longest_match(s, cur_match) | 1326 | local uInt longest_match(deflate_state *s, IPos cur_match) { |
1280 | deflate_state *s; | ||
1281 | IPos cur_match; /* current match */ | ||
1282 | { | ||
1283 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ | 1327 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ |
1284 | register Bytef *scan = s->window + s->strstart; /* current string */ | 1328 | register Bytef *scan = s->window + s->strstart; /* current string */ |
1285 | register Bytef *match; /* matched string */ | 1329 | register Bytef *match; /* matched string */ |
@@ -1427,10 +1471,7 @@ local uInt longest_match(s, cur_match) | |||
1427 | /* --------------------------------------------------------------------------- | 1471 | /* --------------------------------------------------------------------------- |
1428 | * Optimized version for FASTEST only | 1472 | * Optimized version for FASTEST only |
1429 | */ | 1473 | */ |
1430 | local uInt longest_match(s, cur_match) | 1474 | local uInt longest_match(deflate_state *s, IPos cur_match) { |
1431 | deflate_state *s; | ||
1432 | IPos cur_match; /* current match */ | ||
1433 | { | ||
1434 | register Bytef *scan = s->window + s->strstart; /* current string */ | 1475 | register Bytef *scan = s->window + s->strstart; /* current string */ |
1435 | register Bytef *match; /* matched string */ | 1476 | register Bytef *match; /* matched string */ |
1436 | register int len; /* length of current match */ | 1477 | register int len; /* length of current match */ |
@@ -1491,11 +1532,7 @@ local uInt longest_match(s, cur_match) | |||
1491 | /* =========================================================================== | 1532 | /* =========================================================================== |
1492 | * Check that the match at match_start is indeed a match. | 1533 | * Check that the match at match_start is indeed a match. |
1493 | */ | 1534 | */ |
1494 | local void check_match(s, start, match, length) | 1535 | local void check_match(deflate_state *s, IPos start, IPos match, int length) { |
1495 | deflate_state *s; | ||
1496 | IPos start, match; | ||
1497 | int length; | ||
1498 | { | ||
1499 | /* check that the match is indeed a match */ | 1536 | /* check that the match is indeed a match */ |
1500 | if (zmemcmp(s->window + match, | 1537 | if (zmemcmp(s->window + match, |
1501 | s->window + start, length) != EQUAL) { | 1538 | s->window + start, length) != EQUAL) { |
@@ -1516,137 +1553,6 @@ local void check_match(s, start, match, length) | |||
1516 | #endif /* ZLIB_DEBUG */ | 1553 | #endif /* ZLIB_DEBUG */ |
1517 | 1554 | ||
1518 | /* =========================================================================== | 1555 | /* =========================================================================== |
1519 | * Fill the window when the lookahead becomes insufficient. | ||
1520 | * Updates strstart and lookahead. | ||
1521 | * | ||
1522 | * IN assertion: lookahead < MIN_LOOKAHEAD | ||
1523 | * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD | ||
1524 | * At least one byte has been read, or avail_in == 0; reads are | ||
1525 | * performed for at least two bytes (required for the zip translate_eol | ||
1526 | * option -- not supported here). | ||
1527 | */ | ||
1528 | local void fill_window(s) | ||
1529 | deflate_state *s; | ||
1530 | { | ||
1531 | unsigned n; | ||
1532 | unsigned more; /* Amount of free space at the end of the window. */ | ||
1533 | uInt wsize = s->w_size; | ||
1534 | |||
1535 | Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); | ||
1536 | |||
1537 | do { | ||
1538 | more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); | ||
1539 | |||
1540 | /* Deal with !@#$% 64K limit: */ | ||
1541 | if (sizeof(int) <= 2) { | ||
1542 | if (more == 0 && s->strstart == 0 && s->lookahead == 0) { | ||
1543 | more = wsize; | ||
1544 | |||
1545 | } else if (more == (unsigned)(-1)) { | ||
1546 | /* Very unlikely, but possible on 16 bit machine if | ||
1547 | * strstart == 0 && lookahead == 1 (input done a byte at time) | ||
1548 | */ | ||
1549 | more--; | ||
1550 | } | ||
1551 | } | ||
1552 | |||
1553 | /* If the window is almost full and there is insufficient lookahead, | ||
1554 | * move the upper half to the lower one to make room in the upper half. | ||
1555 | */ | ||
1556 | if (s->strstart >= wsize + MAX_DIST(s)) { | ||
1557 | |||
1558 | zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); | ||
1559 | s->match_start -= wsize; | ||
1560 | s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ | ||
1561 | s->block_start -= (long) wsize; | ||
1562 | if (s->insert > s->strstart) | ||
1563 | s->insert = s->strstart; | ||
1564 | slide_hash(s); | ||
1565 | more += wsize; | ||
1566 | } | ||
1567 | if (s->strm->avail_in == 0) break; | ||
1568 | |||
1569 | /* If there was no sliding: | ||
1570 | * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && | ||
1571 | * more == window_size - lookahead - strstart | ||
1572 | * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) | ||
1573 | * => more >= window_size - 2*WSIZE + 2 | ||
1574 | * In the BIG_MEM or MMAP case (not yet supported), | ||
1575 | * window_size == input_size + MIN_LOOKAHEAD && | ||
1576 | * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. | ||
1577 | * Otherwise, window_size == 2*WSIZE so more >= 2. | ||
1578 | * If there was sliding, more >= WSIZE. So in all cases, more >= 2. | ||
1579 | */ | ||
1580 | Assert(more >= 2, "more < 2"); | ||
1581 | |||
1582 | n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); | ||
1583 | s->lookahead += n; | ||
1584 | |||
1585 | /* Initialize the hash value now that we have some input: */ | ||
1586 | if (s->lookahead + s->insert >= MIN_MATCH) { | ||
1587 | uInt str = s->strstart - s->insert; | ||
1588 | s->ins_h = s->window[str]; | ||
1589 | UPDATE_HASH(s, s->ins_h, s->window[str + 1]); | ||
1590 | #if MIN_MATCH != 3 | ||
1591 | Call UPDATE_HASH() MIN_MATCH-3 more times | ||
1592 | #endif | ||
1593 | while (s->insert) { | ||
1594 | UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); | ||
1595 | #ifndef FASTEST | ||
1596 | s->prev[str & s->w_mask] = s->head[s->ins_h]; | ||
1597 | #endif | ||
1598 | s->head[s->ins_h] = (Pos)str; | ||
1599 | str++; | ||
1600 | s->insert--; | ||
1601 | if (s->lookahead + s->insert < MIN_MATCH) | ||
1602 | break; | ||
1603 | } | ||
1604 | } | ||
1605 | /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, | ||
1606 | * but this is not important since only literal bytes will be emitted. | ||
1607 | */ | ||
1608 | |||
1609 | } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); | ||
1610 | |||
1611 | /* If the WIN_INIT bytes after the end of the current data have never been | ||
1612 | * written, then zero those bytes in order to avoid memory check reports of | ||
1613 | * the use of uninitialized (or uninitialised as Julian writes) bytes by | ||
1614 | * the longest match routines. Update the high water mark for the next | ||
1615 | * time through here. WIN_INIT is set to MAX_MATCH since the longest match | ||
1616 | * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. | ||
1617 | */ | ||
1618 | if (s->high_water < s->window_size) { | ||
1619 | ulg curr = s->strstart + (ulg)(s->lookahead); | ||
1620 | ulg init; | ||
1621 | |||
1622 | if (s->high_water < curr) { | ||
1623 | /* Previous high water mark below current data -- zero WIN_INIT | ||
1624 | * bytes or up to end of window, whichever is less. | ||
1625 | */ | ||
1626 | init = s->window_size - curr; | ||
1627 | if (init > WIN_INIT) | ||
1628 | init = WIN_INIT; | ||
1629 | zmemzero(s->window + curr, (unsigned)init); | ||
1630 | s->high_water = curr + init; | ||
1631 | } | ||
1632 | else if (s->high_water < (ulg)curr + WIN_INIT) { | ||
1633 | /* High water mark at or above current data, but below current data | ||
1634 | * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up | ||
1635 | * to end of window, whichever is less. | ||
1636 | */ | ||
1637 | init = (ulg)curr + WIN_INIT - s->high_water; | ||
1638 | if (init > s->window_size - s->high_water) | ||
1639 | init = s->window_size - s->high_water; | ||
1640 | zmemzero(s->window + s->high_water, (unsigned)init); | ||
1641 | s->high_water += init; | ||
1642 | } | ||
1643 | } | ||
1644 | |||
1645 | Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, | ||
1646 | "not enough room for search"); | ||
1647 | } | ||
1648 | |||
1649 | /* =========================================================================== | ||
1650 | * Flush the current block, with given end-of-file flag. | 1556 | * Flush the current block, with given end-of-file flag. |
1651 | * IN assertion: strstart is set to the end of the current match. | 1557 | * IN assertion: strstart is set to the end of the current match. |
1652 | */ | 1558 | */ |
@@ -1688,10 +1594,7 @@ local void fill_window(s) | |||
1688 | * copied. It is most efficient with large input and output buffers, which | 1594 | * copied. It is most efficient with large input and output buffers, which |
1689 | * maximizes the opportunities to have a single copy from next_in to next_out. | 1595 | * maximizes the opportunities to have a single copy from next_in to next_out. |
1690 | */ | 1596 | */ |
1691 | local block_state deflate_stored(s, flush) | 1597 | local block_state deflate_stored(deflate_state *s, int flush) { |
1692 | deflate_state *s; | ||
1693 | int flush; | ||
1694 | { | ||
1695 | /* Smallest worthy block size when not flushing or finishing. By default | 1598 | /* Smallest worthy block size when not flushing or finishing. By default |
1696 | * this is 32K. This can be as small as 507 bytes for memLevel == 1. For | 1599 | * this is 32K. This can be as small as 507 bytes for memLevel == 1. For |
1697 | * large input and output buffers, the stored block size will be larger. | 1600 | * large input and output buffers, the stored block size will be larger. |
@@ -1875,10 +1778,7 @@ local block_state deflate_stored(s, flush) | |||
1875 | * new strings in the dictionary only for unmatched strings or for short | 1778 | * new strings in the dictionary only for unmatched strings or for short |
1876 | * matches. It is used only for the fast compression options. | 1779 | * matches. It is used only for the fast compression options. |
1877 | */ | 1780 | */ |
1878 | local block_state deflate_fast(s, flush) | 1781 | local block_state deflate_fast(deflate_state *s, int flush) { |
1879 | deflate_state *s; | ||
1880 | int flush; | ||
1881 | { | ||
1882 | IPos hash_head; /* head of the hash chain */ | 1782 | IPos hash_head; /* head of the hash chain */ |
1883 | int bflush; /* set if current block must be flushed */ | 1783 | int bflush; /* set if current block must be flushed */ |
1884 | 1784 | ||
@@ -1977,10 +1877,7 @@ local block_state deflate_fast(s, flush) | |||
1977 | * evaluation for matches: a match is finally adopted only if there is | 1877 | * evaluation for matches: a match is finally adopted only if there is |
1978 | * no better match at the next window position. | 1878 | * no better match at the next window position. |
1979 | */ | 1879 | */ |
1980 | local block_state deflate_slow(s, flush) | 1880 | local block_state deflate_slow(deflate_state *s, int flush) { |
1981 | deflate_state *s; | ||
1982 | int flush; | ||
1983 | { | ||
1984 | IPos hash_head; /* head of hash chain */ | 1881 | IPos hash_head; /* head of hash chain */ |
1985 | int bflush; /* set if current block must be flushed */ | 1882 | int bflush; /* set if current block must be flushed */ |
1986 | 1883 | ||
@@ -2108,10 +2005,7 @@ local block_state deflate_slow(s, flush) | |||
2108 | * one. Do not maintain a hash table. (It will be regenerated if this run of | 2005 | * one. Do not maintain a hash table. (It will be regenerated if this run of |
2109 | * deflate switches away from Z_RLE.) | 2006 | * deflate switches away from Z_RLE.) |
2110 | */ | 2007 | */ |
2111 | local block_state deflate_rle(s, flush) | 2008 | local block_state deflate_rle(deflate_state *s, int flush) { |
2112 | deflate_state *s; | ||
2113 | int flush; | ||
2114 | { | ||
2115 | int bflush; /* set if current block must be flushed */ | 2009 | int bflush; /* set if current block must be flushed */ |
2116 | uInt prev; /* byte at distance one to match */ | 2010 | uInt prev; /* byte at distance one to match */ |
2117 | Bytef *scan, *strend; /* scan goes up to strend for length of run */ | 2011 | Bytef *scan, *strend; /* scan goes up to strend for length of run */ |
@@ -2182,10 +2076,7 @@ local block_state deflate_rle(s, flush) | |||
2182 | * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. | 2076 | * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. |
2183 | * (It will be regenerated if this run of deflate switches away from Huffman.) | 2077 | * (It will be regenerated if this run of deflate switches away from Huffman.) |
2184 | */ | 2078 | */ |
2185 | local block_state deflate_huff(s, flush) | 2079 | local block_state deflate_huff(deflate_state *s, int flush) { |
2186 | deflate_state *s; | ||
2187 | int flush; | ||
2188 | { | ||
2189 | int bflush; /* set if current block must be flushed */ | 2080 | int bflush; /* set if current block must be flushed */ |
2190 | 2081 | ||
2191 | for (;;) { | 2082 | for (;;) { |
@@ -291,14 +291,14 @@ typedef struct internal_state { | |||
291 | memory checker errors from longest match routines */ | 291 | memory checker errors from longest match routines */ |
292 | 292 | ||
293 | /* in trees.c */ | 293 | /* in trees.c */ |
294 | void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); | 294 | void ZLIB_INTERNAL _tr_init(deflate_state *s); |
295 | int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); | 295 | int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); |
296 | void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, | 296 | void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, |
297 | ulg stored_len, int last)); | 297 | ulg stored_len, int last); |
298 | void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); | 298 | void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); |
299 | void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); | 299 | void ZLIB_INTERNAL _tr_align(deflate_state *s); |
300 | void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, | 300 | void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, |
301 | ulg stored_len, int last)); | 301 | ulg stored_len, int last); |
302 | 302 | ||
303 | #define d_code(dist) \ | 303 | #define d_code(dist) \ |
304 | ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) | 304 | ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) |
@@ -8,9 +8,7 @@ | |||
8 | /* gzclose() is in a separate file so that it is linked in only if it is used. | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. |
9 | That way the other gzclose functions can be used instead to avoid linking in | 9 | That way the other gzclose functions can be used instead to avoid linking in |
10 | unneeded compression or decompression routines. */ | 10 | unneeded compression or decompression routines. */ |
11 | int ZEXPORT gzclose(file) | 11 | int ZEXPORT gzclose(gzFile file) { |
12 | gzFile file; | ||
13 | { | ||
14 | #ifndef NO_GZCOMPRESS | 12 | #ifndef NO_GZCOMPRESS |
15 | gz_statep state; | 13 | gz_statep state; |
16 | 14 | ||
@@ -119,8 +119,8 @@ | |||
119 | 119 | ||
120 | /* gz* functions always use library allocation functions */ | 120 | /* gz* functions always use library allocation functions */ |
121 | #ifndef STDC | 121 | #ifndef STDC |
122 | extern voidp malloc OF((uInt size)); | 122 | extern voidp malloc(uInt size); |
123 | extern void free OF((voidpf ptr)); | 123 | extern void free(voidpf ptr); |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | /* get errno and strerror definition */ | 126 | /* get errno and strerror definition */ |
@@ -138,10 +138,10 @@ | |||
138 | 138 | ||
139 | /* provide prototypes for these when building zlib without LFS */ | 139 | /* provide prototypes for these when building zlib without LFS */ |
140 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 | 140 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
141 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | 141 | ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
142 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); | 142 | ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); |
143 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); | 143 | ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); |
144 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); | 144 | ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | /* default memLevel */ | 147 | /* default memLevel */ |
@@ -203,9 +203,9 @@ typedef struct { | |||
203 | typedef gz_state FAR *gz_statep; | 203 | typedef gz_state FAR *gz_statep; |
204 | 204 | ||
205 | /* shared functions */ | 205 | /* shared functions */ |
206 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); | 206 | void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); |
207 | #if defined UNDER_CE | 207 | #if defined UNDER_CE |
208 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); | 208 | char ZLIB_INTERNAL *gz_strwinerror(DWORD error); |
209 | #endif | 209 | #endif |
210 | 210 | ||
211 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t | 211 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t |
@@ -214,6 +214,6 @@ char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); | |||
214 | #ifdef INT_MAX | 214 | #ifdef INT_MAX |
215 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) | 215 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) |
216 | #else | 216 | #else |
217 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); | 217 | unsigned ZLIB_INTERNAL gz_intmax(void); |
218 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) | 218 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) |
219 | #endif | 219 | #endif |
@@ -15,10 +15,6 @@ | |||
15 | #endif | 15 | #endif |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | /* Local functions */ | ||
19 | local void gz_reset OF((gz_statep)); | ||
20 | local gzFile gz_open OF((const void *, int, const char *)); | ||
21 | |||
22 | #if defined UNDER_CE | 18 | #if defined UNDER_CE |
23 | 19 | ||
24 | /* Map the Windows error number in ERROR to a locale-dependent error message | 20 | /* Map the Windows error number in ERROR to a locale-dependent error message |
@@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *)); | |||
30 | 26 | ||
31 | The gz_strwinerror function does not change the current setting of | 27 | The gz_strwinerror function does not change the current setting of |
32 | GetLastError. */ | 28 | GetLastError. */ |
33 | char ZLIB_INTERNAL *gz_strwinerror(error) | 29 | char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { |
34 | DWORD error; | ||
35 | { | ||
36 | static char buf[1024]; | 30 | static char buf[1024]; |
37 | 31 | ||
38 | wchar_t *msgbuf; | 32 | wchar_t *msgbuf; |
@@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error) | |||
72 | #endif /* UNDER_CE */ | 66 | #endif /* UNDER_CE */ |
73 | 67 | ||
74 | /* Reset gzip file state */ | 68 | /* Reset gzip file state */ |
75 | local void gz_reset(state) | 69 | local void gz_reset(gz_statep state) { |
76 | gz_statep state; | ||
77 | { | ||
78 | state->x.have = 0; /* no output data available */ | 70 | state->x.have = 0; /* no output data available */ |
79 | if (state->mode == GZ_READ) { /* for reading ... */ | 71 | if (state->mode == GZ_READ) { /* for reading ... */ |
80 | state->eof = 0; /* not at end of file */ | 72 | state->eof = 0; /* not at end of file */ |
@@ -90,11 +82,7 @@ local void gz_reset(state) | |||
90 | } | 82 | } |
91 | 83 | ||
92 | /* Open a gzip file either by name or file descriptor. */ | 84 | /* Open a gzip file either by name or file descriptor. */ |
93 | local gzFile gz_open(path, fd, mode) | 85 | local gzFile gz_open(const void *path, int fd, const char *mode) { |
94 | const void *path; | ||
95 | int fd; | ||
96 | const char *mode; | ||
97 | { | ||
98 | gz_statep state; | 86 | gz_statep state; |
99 | z_size_t len; | 87 | z_size_t len; |
100 | int oflag; | 88 | int oflag; |
@@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode) | |||
269 | } | 257 | } |
270 | 258 | ||
271 | /* -- see zlib.h -- */ | 259 | /* -- see zlib.h -- */ |
272 | gzFile ZEXPORT gzopen(path, mode) | 260 | gzFile ZEXPORT gzopen(const char *path, const char *mode) { |
273 | const char *path; | ||
274 | const char *mode; | ||
275 | { | ||
276 | return gz_open(path, -1, mode); | 261 | return gz_open(path, -1, mode); |
277 | } | 262 | } |
278 | 263 | ||
279 | /* -- see zlib.h -- */ | 264 | /* -- see zlib.h -- */ |
280 | gzFile ZEXPORT gzopen64(path, mode) | 265 | gzFile ZEXPORT gzopen64(const char *path, const char *mode) { |
281 | const char *path; | ||
282 | const char *mode; | ||
283 | { | ||
284 | return gz_open(path, -1, mode); | 266 | return gz_open(path, -1, mode); |
285 | } | 267 | } |
286 | 268 | ||
287 | /* -- see zlib.h -- */ | 269 | /* -- see zlib.h -- */ |
288 | gzFile ZEXPORT gzdopen(fd, mode) | 270 | gzFile ZEXPORT gzdopen(int fd, const char *mode) { |
289 | int fd; | ||
290 | const char *mode; | ||
291 | { | ||
292 | char *path; /* identifier for error messages */ | 271 | char *path; /* identifier for error messages */ |
293 | gzFile gz; | 272 | gzFile gz; |
294 | 273 | ||
@@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode) | |||
306 | 285 | ||
307 | /* -- see zlib.h -- */ | 286 | /* -- see zlib.h -- */ |
308 | #ifdef WIDECHAR | 287 | #ifdef WIDECHAR |
309 | gzFile ZEXPORT gzopen_w(path, mode) | 288 | gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { |
310 | const wchar_t *path; | ||
311 | const char *mode; | ||
312 | { | ||
313 | return gz_open(path, -2, mode); | 289 | return gz_open(path, -2, mode); |
314 | } | 290 | } |
315 | #endif | 291 | #endif |
316 | 292 | ||
317 | /* -- see zlib.h -- */ | 293 | /* -- see zlib.h -- */ |
318 | int ZEXPORT gzbuffer(file, size) | 294 | int ZEXPORT gzbuffer(gzFile file, unsigned size) { |
319 | gzFile file; | ||
320 | unsigned size; | ||
321 | { | ||
322 | gz_statep state; | 295 | gz_statep state; |
323 | 296 | ||
324 | /* get internal structure and check integrity */ | 297 | /* get internal structure and check integrity */ |
@@ -342,9 +315,7 @@ int ZEXPORT gzbuffer(file, size) | |||
342 | } | 315 | } |
343 | 316 | ||
344 | /* -- see zlib.h -- */ | 317 | /* -- see zlib.h -- */ |
345 | int ZEXPORT gzrewind(file) | 318 | int ZEXPORT gzrewind(gzFile file) { |
346 | gzFile file; | ||
347 | { | ||
348 | gz_statep state; | 319 | gz_statep state; |
349 | 320 | ||
350 | /* get internal structure */ | 321 | /* get internal structure */ |
@@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file) | |||
365 | } | 336 | } |
366 | 337 | ||
367 | /* -- see zlib.h -- */ | 338 | /* -- see zlib.h -- */ |
368 | z_off64_t ZEXPORT gzseek64(file, offset, whence) | 339 | z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { |
369 | gzFile file; | ||
370 | z_off64_t offset; | ||
371 | int whence; | ||
372 | { | ||
373 | unsigned n; | 340 | unsigned n; |
374 | z_off64_t ret; | 341 | z_off64_t ret; |
375 | gz_statep state; | 342 | gz_statep state; |
@@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) | |||
442 | } | 409 | } |
443 | 410 | ||
444 | /* -- see zlib.h -- */ | 411 | /* -- see zlib.h -- */ |
445 | z_off_t ZEXPORT gzseek(file, offset, whence) | 412 | z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { |
446 | gzFile file; | ||
447 | z_off_t offset; | ||
448 | int whence; | ||
449 | { | ||
450 | z_off64_t ret; | 413 | z_off64_t ret; |
451 | 414 | ||
452 | ret = gzseek64(file, (z_off64_t)offset, whence); | 415 | ret = gzseek64(file, (z_off64_t)offset, whence); |
@@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence) | |||
454 | } | 417 | } |
455 | 418 | ||
456 | /* -- see zlib.h -- */ | 419 | /* -- see zlib.h -- */ |
457 | z_off64_t ZEXPORT gztell64(file) | 420 | z_off64_t ZEXPORT gztell64(gzFile file) { |
458 | gzFile file; | ||
459 | { | ||
460 | gz_statep state; | 421 | gz_statep state; |
461 | 422 | ||
462 | /* get internal structure and check integrity */ | 423 | /* get internal structure and check integrity */ |
@@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file) | |||
471 | } | 432 | } |
472 | 433 | ||
473 | /* -- see zlib.h -- */ | 434 | /* -- see zlib.h -- */ |
474 | z_off_t ZEXPORT gztell(file) | 435 | z_off_t ZEXPORT gztell(gzFile file) { |
475 | gzFile file; | ||
476 | { | ||
477 | z_off64_t ret; | 436 | z_off64_t ret; |
478 | 437 | ||
479 | ret = gztell64(file); | 438 | ret = gztell64(file); |
@@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file) | |||
481 | } | 440 | } |
482 | 441 | ||
483 | /* -- see zlib.h -- */ | 442 | /* -- see zlib.h -- */ |
484 | z_off64_t ZEXPORT gzoffset64(file) | 443 | z_off64_t ZEXPORT gzoffset64(gzFile file) { |
485 | gzFile file; | ||
486 | { | ||
487 | z_off64_t offset; | 444 | z_off64_t offset; |
488 | gz_statep state; | 445 | gz_statep state; |
489 | 446 | ||
@@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file) | |||
504 | } | 461 | } |
505 | 462 | ||
506 | /* -- see zlib.h -- */ | 463 | /* -- see zlib.h -- */ |
507 | z_off_t ZEXPORT gzoffset(file) | 464 | z_off_t ZEXPORT gzoffset(gzFile file) { |
508 | gzFile file; | ||
509 | { | ||
510 | z_off64_t ret; | 465 | z_off64_t ret; |
511 | 466 | ||
512 | ret = gzoffset64(file); | 467 | ret = gzoffset64(file); |
@@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file) | |||
514 | } | 469 | } |
515 | 470 | ||
516 | /* -- see zlib.h -- */ | 471 | /* -- see zlib.h -- */ |
517 | int ZEXPORT gzeof(file) | 472 | int ZEXPORT gzeof(gzFile file) { |
518 | gzFile file; | ||
519 | { | ||
520 | gz_statep state; | 473 | gz_statep state; |
521 | 474 | ||
522 | /* get internal structure and check integrity */ | 475 | /* get internal structure and check integrity */ |
@@ -531,10 +484,7 @@ int ZEXPORT gzeof(file) | |||
531 | } | 484 | } |
532 | 485 | ||
533 | /* -- see zlib.h -- */ | 486 | /* -- see zlib.h -- */ |
534 | const char * ZEXPORT gzerror(file, errnum) | 487 | const char * ZEXPORT gzerror(gzFile file, int *errnum) { |
535 | gzFile file; | ||
536 | int *errnum; | ||
537 | { | ||
538 | gz_statep state; | 488 | gz_statep state; |
539 | 489 | ||
540 | /* get internal structure and check integrity */ | 490 | /* get internal structure and check integrity */ |
@@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum) | |||
552 | } | 502 | } |
553 | 503 | ||
554 | /* -- see zlib.h -- */ | 504 | /* -- see zlib.h -- */ |
555 | void ZEXPORT gzclearerr(file) | 505 | void ZEXPORT gzclearerr(gzFile file) { |
556 | gzFile file; | ||
557 | { | ||
558 | gz_statep state; | 506 | gz_statep state; |
559 | 507 | ||
560 | /* get internal structure and check integrity */ | 508 | /* get internal structure and check integrity */ |
@@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file) | |||
578 | memory). Simply save the error message as a static string. If there is an | 526 | memory). Simply save the error message as a static string. If there is an |
579 | allocation failure constructing the error message, then convert the error to | 527 | allocation failure constructing the error message, then convert the error to |
580 | out of memory. */ | 528 | out of memory. */ |
581 | void ZLIB_INTERNAL gz_error(state, err, msg) | 529 | void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { |
582 | gz_statep state; | ||
583 | int err; | ||
584 | const char *msg; | ||
585 | { | ||
586 | /* free previously allocated message and clear */ | 530 | /* free previously allocated message and clear */ |
587 | if (state->msg != NULL) { | 531 | if (state->msg != NULL) { |
588 | if (state->err != Z_MEM_ERROR) | 532 | if (state->err != Z_MEM_ERROR) |
@@ -624,8 +568,7 @@ void ZLIB_INTERNAL gz_error(state, err, msg) | |||
624 | available) -- we need to do this to cover cases where 2's complement not | 568 | available) -- we need to do this to cover cases where 2's complement not |
625 | used, since C standard permits 1's complement and sign-bit representations, | 569 | used, since C standard permits 1's complement and sign-bit representations, |
626 | otherwise we could just use ((unsigned)-1) >> 1 */ | 570 | otherwise we could just use ((unsigned)-1) >> 1 */ |
627 | unsigned ZLIB_INTERNAL gz_intmax() | 571 | unsigned ZLIB_INTERNAL gz_intmax(void) { |
628 | { | ||
629 | unsigned p, q; | 572 | unsigned p, q; |
630 | 573 | ||
631 | p = 1; | 574 | p = 1; |
@@ -5,25 +5,12 @@ | |||
5 | 5 | ||
6 | #include "gzguts.h" | 6 | #include "gzguts.h" |
7 | 7 | ||
8 | /* Local functions */ | ||
9 | local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); | ||
10 | local int gz_avail OF((gz_statep)); | ||
11 | local int gz_look OF((gz_statep)); | ||
12 | local int gz_decomp OF((gz_statep)); | ||
13 | local int gz_fetch OF((gz_statep)); | ||
14 | local int gz_skip OF((gz_statep, z_off64_t)); | ||
15 | local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); | ||
16 | |||
17 | /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from | 8 | /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from |
18 | state->fd, and update state->eof, state->err, and state->msg as appropriate. | 9 | state->fd, and update state->eof, state->err, and state->msg as appropriate. |
19 | This function needs to loop on read(), since read() is not guaranteed to | 10 | This function needs to loop on read(), since read() is not guaranteed to |
20 | read the number of bytes requested, depending on the type of descriptor. */ | 11 | read the number of bytes requested, depending on the type of descriptor. */ |
21 | local int gz_load(state, buf, len, have) | 12 | local int gz_load(gz_statep state, unsigned char *buf, unsigned len, |
22 | gz_statep state; | 13 | unsigned *have) { |
23 | unsigned char *buf; | ||
24 | unsigned len; | ||
25 | unsigned *have; | ||
26 | { | ||
27 | int ret; | 14 | int ret; |
28 | unsigned get, max = ((unsigned)-1 >> 2) + 1; | 15 | unsigned get, max = ((unsigned)-1 >> 2) + 1; |
29 | 16 | ||
@@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have) | |||
53 | If strm->avail_in != 0, then the current data is moved to the beginning of | 40 | If strm->avail_in != 0, then the current data is moved to the beginning of |
54 | the input buffer, and then the remainder of the buffer is loaded with the | 41 | the input buffer, and then the remainder of the buffer is loaded with the |
55 | available data from the input file. */ | 42 | available data from the input file. */ |
56 | local int gz_avail(state) | 43 | local int gz_avail(gz_statep state) { |
57 | gz_statep state; | ||
58 | { | ||
59 | unsigned got; | 44 | unsigned got; |
60 | z_streamp strm = &(state->strm); | 45 | z_streamp strm = &(state->strm); |
61 | 46 | ||
@@ -88,9 +73,7 @@ local int gz_avail(state) | |||
88 | case, all further file reads will be directly to either the output buffer or | 73 | case, all further file reads will be directly to either the output buffer or |
89 | a user buffer. If decompressing, the inflate state will be initialized. | 74 | a user buffer. If decompressing, the inflate state will be initialized. |
90 | gz_look() will return 0 on success or -1 on failure. */ | 75 | gz_look() will return 0 on success or -1 on failure. */ |
91 | local int gz_look(state) | 76 | local int gz_look(gz_statep state) { |
92 | gz_statep state; | ||
93 | { | ||
94 | z_streamp strm = &(state->strm); | 77 | z_streamp strm = &(state->strm); |
95 | 78 | ||
96 | /* allocate read buffers and inflate memory */ | 79 | /* allocate read buffers and inflate memory */ |
@@ -170,9 +153,7 @@ local int gz_look(state) | |||
170 | data. If the gzip stream completes, state->how is reset to LOOK to look for | 153 | data. If the gzip stream completes, state->how is reset to LOOK to look for |
171 | the next gzip stream or raw data, once state->x.have is depleted. Returns 0 | 154 | the next gzip stream or raw data, once state->x.have is depleted. Returns 0 |
172 | on success, -1 on failure. */ | 155 | on success, -1 on failure. */ |
173 | local int gz_decomp(state) | 156 | local int gz_decomp(gz_statep state) { |
174 | gz_statep state; | ||
175 | { | ||
176 | int ret = Z_OK; | 157 | int ret = Z_OK; |
177 | unsigned had; | 158 | unsigned had; |
178 | z_streamp strm = &(state->strm); | 159 | z_streamp strm = &(state->strm); |
@@ -224,9 +205,7 @@ local int gz_decomp(state) | |||
224 | looked for to determine whether to copy or decompress. Returns -1 on error, | 205 | looked for to determine whether to copy or decompress. Returns -1 on error, |
225 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the | 206 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the |
226 | end of the input file has been reached and all data has been processed. */ | 207 | end of the input file has been reached and all data has been processed. */ |
227 | local int gz_fetch(state) | 208 | local int gz_fetch(gz_statep state) { |
228 | gz_statep state; | ||
229 | { | ||
230 | z_streamp strm = &(state->strm); | 209 | z_streamp strm = &(state->strm); |
231 | 210 | ||
232 | do { | 211 | do { |
@@ -254,10 +233,7 @@ local int gz_fetch(state) | |||
254 | } | 233 | } |
255 | 234 | ||
256 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ | 235 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
257 | local int gz_skip(state, len) | 236 | local int gz_skip(gz_statep state, z_off64_t len) { |
258 | gz_statep state; | ||
259 | z_off64_t len; | ||
260 | { | ||
261 | unsigned n; | 237 | unsigned n; |
262 | 238 | ||
263 | /* skip over len bytes or reach end-of-file, whichever comes first */ | 239 | /* skip over len bytes or reach end-of-file, whichever comes first */ |
@@ -289,11 +265,7 @@ local int gz_skip(state, len) | |||
289 | input. Return the number of bytes read. If zero is returned, either the | 265 | input. Return the number of bytes read. If zero is returned, either the |
290 | end of file was reached, or there was an error. state->err must be | 266 | end of file was reached, or there was an error. state->err must be |
291 | consulted in that case to determine which. */ | 267 | consulted in that case to determine which. */ |
292 | local z_size_t gz_read(state, buf, len) | 268 | local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { |
293 | gz_statep state; | ||
294 | voidp buf; | ||
295 | z_size_t len; | ||
296 | { | ||
297 | z_size_t got; | 269 | z_size_t got; |
298 | unsigned n; | 270 | unsigned n; |
299 | 271 | ||
@@ -370,11 +342,7 @@ local z_size_t gz_read(state, buf, len) | |||
370 | } | 342 | } |
371 | 343 | ||
372 | /* -- see zlib.h -- */ | 344 | /* -- see zlib.h -- */ |
373 | int ZEXPORT gzread(file, buf, len) | 345 | int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { |
374 | gzFile file; | ||
375 | voidp buf; | ||
376 | unsigned len; | ||
377 | { | ||
378 | gz_statep state; | 346 | gz_statep state; |
379 | 347 | ||
380 | /* get internal structure */ | 348 | /* get internal structure */ |
@@ -406,12 +374,7 @@ int ZEXPORT gzread(file, buf, len) | |||
406 | } | 374 | } |
407 | 375 | ||
408 | /* -- see zlib.h -- */ | 376 | /* -- see zlib.h -- */ |
409 | z_size_t ZEXPORT gzfread(buf, size, nitems, file) | 377 | z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { |
410 | voidp buf; | ||
411 | z_size_t size; | ||
412 | z_size_t nitems; | ||
413 | gzFile file; | ||
414 | { | ||
415 | z_size_t len; | 378 | z_size_t len; |
416 | gz_statep state; | 379 | gz_statep state; |
417 | 380 | ||
@@ -442,9 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) | |||
442 | #else | 405 | #else |
443 | # undef gzgetc | 406 | # undef gzgetc |
444 | #endif | 407 | #endif |
445 | int ZEXPORT gzgetc(file) | 408 | int ZEXPORT gzgetc(gzFile file) { |
446 | gzFile file; | ||
447 | { | ||
448 | unsigned char buf[1]; | 409 | unsigned char buf[1]; |
449 | gz_statep state; | 410 | gz_statep state; |
450 | 411 | ||
@@ -469,17 +430,12 @@ int ZEXPORT gzgetc(file) | |||
469 | return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; | 430 | return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; |
470 | } | 431 | } |
471 | 432 | ||
472 | int ZEXPORT gzgetc_(file) | 433 | int ZEXPORT gzgetc_(gzFile file) { |
473 | gzFile file; | ||
474 | { | ||
475 | return gzgetc(file); | 434 | return gzgetc(file); |
476 | } | 435 | } |
477 | 436 | ||
478 | /* -- see zlib.h -- */ | 437 | /* -- see zlib.h -- */ |
479 | int ZEXPORT gzungetc(c, file) | 438 | int ZEXPORT gzungetc(int c, gzFile file) { |
480 | int c; | ||
481 | gzFile file; | ||
482 | { | ||
483 | gz_statep state; | 439 | gz_statep state; |
484 | 440 | ||
485 | /* get internal structure */ | 441 | /* get internal structure */ |
@@ -536,11 +492,7 @@ int ZEXPORT gzungetc(c, file) | |||
536 | } | 492 | } |
537 | 493 | ||
538 | /* -- see zlib.h -- */ | 494 | /* -- see zlib.h -- */ |
539 | char * ZEXPORT gzgets(file, buf, len) | 495 | char * ZEXPORT gzgets(gzFile file, char *buf, int len) { |
540 | gzFile file; | ||
541 | char *buf; | ||
542 | int len; | ||
543 | { | ||
544 | unsigned left, n; | 496 | unsigned left, n; |
545 | char *str; | 497 | char *str; |
546 | unsigned char *eol; | 498 | unsigned char *eol; |
@@ -600,9 +552,7 @@ char * ZEXPORT gzgets(file, buf, len) | |||
600 | } | 552 | } |
601 | 553 | ||
602 | /* -- see zlib.h -- */ | 554 | /* -- see zlib.h -- */ |
603 | int ZEXPORT gzdirect(file) | 555 | int ZEXPORT gzdirect(gzFile file) { |
604 | gzFile file; | ||
605 | { | ||
606 | gz_statep state; | 556 | gz_statep state; |
607 | 557 | ||
608 | /* get internal structure */ | 558 | /* get internal structure */ |
@@ -620,9 +570,7 @@ int ZEXPORT gzdirect(file) | |||
620 | } | 570 | } |
621 | 571 | ||
622 | /* -- see zlib.h -- */ | 572 | /* -- see zlib.h -- */ |
623 | int ZEXPORT gzclose_r(file) | 573 | int ZEXPORT gzclose_r(gzFile file) { |
624 | gzFile file; | ||
625 | { | ||
626 | int ret, err; | 574 | int ret, err; |
627 | gz_statep state; | 575 | gz_statep state; |
628 | 576 | ||
@@ -5,18 +5,10 @@ | |||
5 | 5 | ||
6 | #include "gzguts.h" | 6 | #include "gzguts.h" |
7 | 7 | ||
8 | /* Local functions */ | ||
9 | local int gz_init OF((gz_statep)); | ||
10 | local int gz_comp OF((gz_statep, int)); | ||
11 | local int gz_zero OF((gz_statep, z_off64_t)); | ||
12 | local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); | ||
13 | |||
14 | /* Initialize state for writing a gzip file. Mark initialization by setting | 8 | /* Initialize state for writing a gzip file. Mark initialization by setting |
15 | state->size to non-zero. Return -1 on a memory allocation failure, or 0 on | 9 | state->size to non-zero. Return -1 on a memory allocation failure, or 0 on |
16 | success. */ | 10 | success. */ |
17 | local int gz_init(state) | 11 | local int gz_init(gz_statep state) { |
18 | gz_statep state; | ||
19 | { | ||
20 | int ret; | 12 | int ret; |
21 | z_streamp strm = &(state->strm); | 13 | z_streamp strm = &(state->strm); |
22 | 14 | ||
@@ -70,10 +62,7 @@ local int gz_init(state) | |||
70 | deflate() flush value. If flush is Z_FINISH, then the deflate() state is | 62 | deflate() flush value. If flush is Z_FINISH, then the deflate() state is |
71 | reset to start a new gzip stream. If gz->direct is true, then simply write | 63 | reset to start a new gzip stream. If gz->direct is true, then simply write |
72 | to the output file without compressing, and ignore flush. */ | 64 | to the output file without compressing, and ignore flush. */ |
73 | local int gz_comp(state, flush) | 65 | local int gz_comp(gz_statep state, int flush) { |
74 | gz_statep state; | ||
75 | int flush; | ||
76 | { | ||
77 | int ret, writ; | 66 | int ret, writ; |
78 | unsigned have, put, max = ((unsigned)-1 >> 2) + 1; | 67 | unsigned have, put, max = ((unsigned)-1 >> 2) + 1; |
79 | z_streamp strm = &(state->strm); | 68 | z_streamp strm = &(state->strm); |
@@ -151,10 +140,7 @@ local int gz_comp(state, flush) | |||
151 | 140 | ||
152 | /* Compress len zeros to output. Return -1 on a write error or memory | 141 | /* Compress len zeros to output. Return -1 on a write error or memory |
153 | allocation failure by gz_comp(), or 0 on success. */ | 142 | allocation failure by gz_comp(), or 0 on success. */ |
154 | local int gz_zero(state, len) | 143 | local int gz_zero(gz_statep state, z_off64_t len) { |
155 | gz_statep state; | ||
156 | z_off64_t len; | ||
157 | { | ||
158 | int first; | 144 | int first; |
159 | unsigned n; | 145 | unsigned n; |
160 | z_streamp strm = &(state->strm); | 146 | z_streamp strm = &(state->strm); |
@@ -184,11 +170,7 @@ local int gz_zero(state, len) | |||
184 | 170 | ||
185 | /* Write len bytes from buf to file. Return the number of bytes written. If | 171 | /* Write len bytes from buf to file. Return the number of bytes written. If |
186 | the returned value is less than len, then there was an error. */ | 172 | the returned value is less than len, then there was an error. */ |
187 | local z_size_t gz_write(state, buf, len) | 173 | local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { |
188 | gz_statep state; | ||
189 | voidpc buf; | ||
190 | z_size_t len; | ||
191 | { | ||
192 | z_size_t put = len; | 174 | z_size_t put = len; |
193 | 175 | ||
194 | /* if len is zero, avoid unnecessary operations */ | 176 | /* if len is zero, avoid unnecessary operations */ |
@@ -252,11 +234,7 @@ local z_size_t gz_write(state, buf, len) | |||
252 | } | 234 | } |
253 | 235 | ||
254 | /* -- see zlib.h -- */ | 236 | /* -- see zlib.h -- */ |
255 | int ZEXPORT gzwrite(file, buf, len) | 237 | int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { |
256 | gzFile file; | ||
257 | voidpc buf; | ||
258 | unsigned len; | ||
259 | { | ||
260 | gz_statep state; | 238 | gz_statep state; |
261 | 239 | ||
262 | /* get internal structure */ | 240 | /* get internal structure */ |
@@ -280,12 +258,8 @@ int ZEXPORT gzwrite(file, buf, len) | |||
280 | } | 258 | } |
281 | 259 | ||
282 | /* -- see zlib.h -- */ | 260 | /* -- see zlib.h -- */ |
283 | z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) | 261 | z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, |
284 | voidpc buf; | 262 | gzFile file) { |
285 | z_size_t size; | ||
286 | z_size_t nitems; | ||
287 | gzFile file; | ||
288 | { | ||
289 | z_size_t len; | 263 | z_size_t len; |
290 | gz_statep state; | 264 | gz_statep state; |
291 | 265 | ||
@@ -310,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) | |||
310 | } | 284 | } |
311 | 285 | ||
312 | /* -- see zlib.h -- */ | 286 | /* -- see zlib.h -- */ |
313 | int ZEXPORT gzputc(file, c) | 287 | int ZEXPORT gzputc(gzFile file, int c) { |
314 | gzFile file; | ||
315 | int c; | ||
316 | { | ||
317 | unsigned have; | 288 | unsigned have; |
318 | unsigned char buf[1]; | 289 | unsigned char buf[1]; |
319 | gz_statep state; | 290 | gz_statep state; |
@@ -358,10 +329,7 @@ int ZEXPORT gzputc(file, c) | |||
358 | } | 329 | } |
359 | 330 | ||
360 | /* -- see zlib.h -- */ | 331 | /* -- see zlib.h -- */ |
361 | int ZEXPORT gzputs(file, s) | 332 | int ZEXPORT gzputs(gzFile file, const char *s) { |
362 | gzFile file; | ||
363 | const char *s; | ||
364 | { | ||
365 | z_size_t len, put; | 333 | z_size_t len, put; |
366 | gz_statep state; | 334 | gz_statep state; |
367 | 335 | ||
@@ -388,8 +356,7 @@ int ZEXPORT gzputs(file, s) | |||
388 | #include <stdarg.h> | 356 | #include <stdarg.h> |
389 | 357 | ||
390 | /* -- see zlib.h -- */ | 358 | /* -- see zlib.h -- */ |
391 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | 359 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { |
392 | { | ||
393 | int len; | 360 | int len; |
394 | unsigned left; | 361 | unsigned left; |
395 | char *next; | 362 | char *next; |
@@ -460,8 +427,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
460 | return len; | 427 | return len; |
461 | } | 428 | } |
462 | 429 | ||
463 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) | 430 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { |
464 | { | ||
465 | va_list va; | 431 | va_list va; |
466 | int ret; | 432 | int ret; |
467 | 433 | ||
@@ -474,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) | |||
474 | #else /* !STDC && !Z_HAVE_STDARG_H */ | 440 | #else /* !STDC && !Z_HAVE_STDARG_H */ |
475 | 441 | ||
476 | /* -- see zlib.h -- */ | 442 | /* -- see zlib.h -- */ |
477 | int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | 443 | int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, |
478 | a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) | 444 | int a4, int a5, int a6, int a7, int a8, int a9, int a10, |
479 | gzFile file; | 445 | int a11, int a12, int a13, int a14, int a15, int a16, |
480 | const char *format; | 446 | int a17, int a18, int a19, int a20) { |
481 | int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | ||
482 | a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; | ||
483 | { | ||
484 | unsigned len, left; | 447 | unsigned len, left; |
485 | char *next; | 448 | char *next; |
486 | gz_statep state; | 449 | gz_statep state; |
@@ -562,10 +525,7 @@ int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | |||
562 | #endif | 525 | #endif |
563 | 526 | ||
564 | /* -- see zlib.h -- */ | 527 | /* -- see zlib.h -- */ |
565 | int ZEXPORT gzflush(file, flush) | 528 | int ZEXPORT gzflush(gzFile file, int flush) { |
566 | gzFile file; | ||
567 | int flush; | ||
568 | { | ||
569 | gz_statep state; | 529 | gz_statep state; |
570 | 530 | ||
571 | /* get internal structure */ | 531 | /* get internal structure */ |
@@ -594,11 +554,7 @@ int ZEXPORT gzflush(file, flush) | |||
594 | } | 554 | } |
595 | 555 | ||
596 | /* -- see zlib.h -- */ | 556 | /* -- see zlib.h -- */ |
597 | int ZEXPORT gzsetparams(file, level, strategy) | 557 | int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { |
598 | gzFile file; | ||
599 | int level; | ||
600 | int strategy; | ||
601 | { | ||
602 | gz_statep state; | 558 | gz_statep state; |
603 | z_streamp strm; | 559 | z_streamp strm; |
604 | 560 | ||
@@ -636,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy) | |||
636 | } | 592 | } |
637 | 593 | ||
638 | /* -- see zlib.h -- */ | 594 | /* -- see zlib.h -- */ |
639 | int ZEXPORT gzclose_w(file) | 595 | int ZEXPORT gzclose_w(gzFile file) { |
640 | gzFile file; | ||
641 | { | ||
642 | int ret = Z_OK; | 596 | int ret = Z_OK; |
643 | gz_statep state; | 597 | gz_statep state; |
644 | 598 | ||
@@ -15,9 +15,6 @@ | |||
15 | #include "inflate.h" | 15 | #include "inflate.h" |
16 | #include "inffast.h" | 16 | #include "inffast.h" |
17 | 17 | ||
18 | /* function prototypes */ | ||
19 | local void fixedtables OF((struct inflate_state FAR *state)); | ||
20 | |||
21 | /* | 18 | /* |
22 | strm provides memory allocation functions in zalloc and zfree, or | 19 | strm provides memory allocation functions in zalloc and zfree, or |
23 | Z_NULL to use the library memory allocation functions. | 20 | Z_NULL to use the library memory allocation functions. |
@@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state)); | |||
25 | windowBits is in the range 8..15, and window is a user-supplied | 22 | windowBits is in the range 8..15, and window is a user-supplied |
26 | window and output buffer that is 2**windowBits bytes. | 23 | window and output buffer that is 2**windowBits bytes. |
27 | */ | 24 | */ |
28 | int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) | 25 | int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, |
29 | z_streamp strm; | 26 | unsigned char FAR *window, const char *version, |
30 | int windowBits; | 27 | int stream_size) { |
31 | unsigned char FAR *window; | ||
32 | const char *version; | ||
33 | int stream_size; | ||
34 | { | ||
35 | struct inflate_state FAR *state; | 28 | struct inflate_state FAR *state; |
36 | 29 | ||
37 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || | 30 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
@@ -80,9 +73,7 @@ int stream_size; | |||
80 | used for threaded applications, since the rewriting of the tables and virgin | 73 | used for threaded applications, since the rewriting of the tables and virgin |
81 | may not be thread-safe. | 74 | may not be thread-safe. |
82 | */ | 75 | */ |
83 | local void fixedtables(state) | 76 | local void fixedtables(struct inflate_state FAR *state) { |
84 | struct inflate_state FAR *state; | ||
85 | { | ||
86 | #ifdef BUILDFIXED | 77 | #ifdef BUILDFIXED |
87 | static int virgin = 1; | 78 | static int virgin = 1; |
88 | static code *lenfix, *distfix; | 79 | static code *lenfix, *distfix; |
@@ -248,13 +239,8 @@ struct inflate_state FAR *state; | |||
248 | inflateBack() can also return Z_STREAM_ERROR if the input parameters | 239 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
249 | are not correct, i.e. strm is Z_NULL or the state was not initialized. | 240 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
250 | */ | 241 | */ |
251 | int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) | 242 | int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, |
252 | z_streamp strm; | 243 | out_func out, void FAR *out_desc) { |
253 | in_func in; | ||
254 | void FAR *in_desc; | ||
255 | out_func out; | ||
256 | void FAR *out_desc; | ||
257 | { | ||
258 | struct inflate_state FAR *state; | 244 | struct inflate_state FAR *state; |
259 | z_const unsigned char FAR *next; /* next input */ | 245 | z_const unsigned char FAR *next; /* next input */ |
260 | unsigned char FAR *put; /* next output */ | 246 | unsigned char FAR *put; /* next output */ |
@@ -632,9 +618,7 @@ void FAR *out_desc; | |||
632 | return ret; | 618 | return ret; |
633 | } | 619 | } |
634 | 620 | ||
635 | int ZEXPORT inflateBackEnd(strm) | 621 | int ZEXPORT inflateBackEnd(z_streamp strm) { |
636 | z_streamp strm; | ||
637 | { | ||
638 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) | 622 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
639 | return Z_STREAM_ERROR; | 623 | return Z_STREAM_ERROR; |
640 | ZFREE(strm, strm->state); | 624 | ZFREE(strm, strm->state); |
@@ -47,10 +47,7 @@ | |||
47 | requires strm->avail_out >= 258 for each loop to avoid checking for | 47 | requires strm->avail_out >= 258 for each loop to avoid checking for |
48 | output space. | 48 | output space. |
49 | */ | 49 | */ |
50 | void ZLIB_INTERNAL inflate_fast(strm, start) | 50 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { |
51 | z_streamp strm; | ||
52 | unsigned start; /* inflate()'s starting value for strm->avail_out */ | ||
53 | { | ||
54 | struct inflate_state FAR *state; | 51 | struct inflate_state FAR *state; |
55 | z_const unsigned char FAR *in; /* local strm->next_in */ | 52 | z_const unsigned char FAR *in; /* local strm->next_in */ |
56 | z_const unsigned char FAR *last; /* have enough input while in < last */ | 53 | z_const unsigned char FAR *last; /* have enough input while in < last */ |
@@ -8,4 +8,4 @@ | |||
8 | subject to change. Applications should only use zlib.h. | 8 | subject to change. Applications should only use zlib.h. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); | 11 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); |
@@ -91,20 +91,7 @@ | |||
91 | # endif | 91 | # endif |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | /* function prototypes */ | 94 | local int inflateStateCheck(z_streamp strm) { |
95 | local int inflateStateCheck OF((z_streamp strm)); | ||
96 | local void fixedtables OF((struct inflate_state FAR *state)); | ||
97 | local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, | ||
98 | unsigned copy)); | ||
99 | #ifdef BUILDFIXED | ||
100 | void makefixed OF((void)); | ||
101 | #endif | ||
102 | local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, | ||
103 | unsigned len)); | ||
104 | |||
105 | local int inflateStateCheck(strm) | ||
106 | z_streamp strm; | ||
107 | { | ||
108 | struct inflate_state FAR *state; | 95 | struct inflate_state FAR *state; |
109 | if (strm == Z_NULL || | 96 | if (strm == Z_NULL || |
110 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) | 97 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
@@ -116,9 +103,7 @@ z_streamp strm; | |||
116 | return 0; | 103 | return 0; |
117 | } | 104 | } |
118 | 105 | ||
119 | int ZEXPORT inflateResetKeep(strm) | 106 | int ZEXPORT inflateResetKeep(z_streamp strm) { |
120 | z_streamp strm; | ||
121 | { | ||
122 | struct inflate_state FAR *state; | 107 | struct inflate_state FAR *state; |
123 | 108 | ||
124 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; | 109 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -142,9 +127,7 @@ z_streamp strm; | |||
142 | return Z_OK; | 127 | return Z_OK; |
143 | } | 128 | } |
144 | 129 | ||
145 | int ZEXPORT inflateReset(strm) | 130 | int ZEXPORT inflateReset(z_streamp strm) { |
146 | z_streamp strm; | ||
147 | { | ||
148 | struct inflate_state FAR *state; | 131 | struct inflate_state FAR *state; |
149 | 132 | ||
150 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; | 133 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -155,10 +138,7 @@ z_streamp strm; | |||
155 | return inflateResetKeep(strm); | 138 | return inflateResetKeep(strm); |
156 | } | 139 | } |
157 | 140 | ||
158 | int ZEXPORT inflateReset2(strm, windowBits) | 141 | int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { |
159 | z_streamp strm; | ||
160 | int windowBits; | ||
161 | { | ||
162 | int wrap; | 142 | int wrap; |
163 | struct inflate_state FAR *state; | 143 | struct inflate_state FAR *state; |
164 | 144 | ||
@@ -195,12 +175,8 @@ int windowBits; | |||
195 | return inflateReset(strm); | 175 | return inflateReset(strm); |
196 | } | 176 | } |
197 | 177 | ||
198 | int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) | 178 | int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, |
199 | z_streamp strm; | 179 | const char *version, int stream_size) { |
200 | int windowBits; | ||
201 | const char *version; | ||
202 | int stream_size; | ||
203 | { | ||
204 | int ret; | 180 | int ret; |
205 | struct inflate_state FAR *state; | 181 | struct inflate_state FAR *state; |
206 | 182 | ||
@@ -239,19 +215,12 @@ int stream_size; | |||
239 | return ret; | 215 | return ret; |
240 | } | 216 | } |
241 | 217 | ||
242 | int ZEXPORT inflateInit_(strm, version, stream_size) | 218 | int ZEXPORT inflateInit_(z_streamp strm, const char *version, |
243 | z_streamp strm; | 219 | int stream_size) { |
244 | const char *version; | ||
245 | int stream_size; | ||
246 | { | ||
247 | return inflateInit2_(strm, DEF_WBITS, version, stream_size); | 220 | return inflateInit2_(strm, DEF_WBITS, version, stream_size); |
248 | } | 221 | } |
249 | 222 | ||
250 | int ZEXPORT inflatePrime(strm, bits, value) | 223 | int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { |
251 | z_streamp strm; | ||
252 | int bits; | ||
253 | int value; | ||
254 | { | ||
255 | struct inflate_state FAR *state; | 224 | struct inflate_state FAR *state; |
256 | 225 | ||
257 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; | 226 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -280,9 +249,7 @@ int value; | |||
280 | used for threaded applications, since the rewriting of the tables and virgin | 249 | used for threaded applications, since the rewriting of the tables and virgin |
281 | may not be thread-safe. | 250 | may not be thread-safe. |
282 | */ | 251 | */ |
283 | local void fixedtables(state) | 252 | local void fixedtables(struct inflate_state FAR *state) { |
284 | struct inflate_state FAR *state; | ||
285 | { | ||
286 | #ifdef BUILDFIXED | 253 | #ifdef BUILDFIXED |
287 | static int virgin = 1; | 254 | static int virgin = 1; |
288 | static code *lenfix, *distfix; | 255 | static code *lenfix, *distfix; |
@@ -344,7 +311,7 @@ struct inflate_state FAR *state; | |||
344 | 311 | ||
345 | a.out > inffixed.h | 312 | a.out > inffixed.h |
346 | */ | 313 | */ |
347 | void makefixed() | 314 | void makefixed(void) |
348 | { | 315 | { |
349 | unsigned low, size; | 316 | unsigned low, size; |
350 | struct inflate_state state; | 317 | struct inflate_state state; |
@@ -398,11 +365,7 @@ void makefixed() | |||
398 | output will fall in the output data, making match copies simpler and faster. | 365 | output will fall in the output data, making match copies simpler and faster. |
399 | The advantage may be dependent on the size of the processor's data caches. | 366 | The advantage may be dependent on the size of the processor's data caches. |
400 | */ | 367 | */ |
401 | local int updatewindow(strm, end, copy) | 368 | local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { |
402 | z_streamp strm; | ||
403 | const Bytef *end; | ||
404 | unsigned copy; | ||
405 | { | ||
406 | struct inflate_state FAR *state; | 369 | struct inflate_state FAR *state; |
407 | unsigned dist; | 370 | unsigned dist; |
408 | 371 | ||
@@ -624,10 +587,7 @@ unsigned copy; | |||
624 | will return Z_BUF_ERROR if it has not reached the end of the stream. | 587 | will return Z_BUF_ERROR if it has not reached the end of the stream. |
625 | */ | 588 | */ |
626 | 589 | ||
627 | int ZEXPORT inflate(strm, flush) | 590 | int ZEXPORT inflate(z_streamp strm, int flush) { |
628 | z_streamp strm; | ||
629 | int flush; | ||
630 | { | ||
631 | struct inflate_state FAR *state; | 591 | struct inflate_state FAR *state; |
632 | z_const unsigned char FAR *next; /* next input */ | 592 | z_const unsigned char FAR *next; /* next input */ |
633 | unsigned char FAR *put; /* next output */ | 593 | unsigned char FAR *put; /* next output */ |
@@ -1303,9 +1263,7 @@ int flush; | |||
1303 | return ret; | 1263 | return ret; |
1304 | } | 1264 | } |
1305 | 1265 | ||
1306 | int ZEXPORT inflateEnd(strm) | 1266 | int ZEXPORT inflateEnd(z_streamp strm) { |
1307 | z_streamp strm; | ||
1308 | { | ||
1309 | struct inflate_state FAR *state; | 1267 | struct inflate_state FAR *state; |
1310 | if (inflateStateCheck(strm)) | 1268 | if (inflateStateCheck(strm)) |
1311 | return Z_STREAM_ERROR; | 1269 | return Z_STREAM_ERROR; |
@@ -1317,11 +1275,8 @@ z_streamp strm; | |||
1317 | return Z_OK; | 1275 | return Z_OK; |
1318 | } | 1276 | } |
1319 | 1277 | ||
1320 | int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) | 1278 | int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, |
1321 | z_streamp strm; | 1279 | uInt *dictLength) { |
1322 | Bytef *dictionary; | ||
1323 | uInt *dictLength; | ||
1324 | { | ||
1325 | struct inflate_state FAR *state; | 1280 | struct inflate_state FAR *state; |
1326 | 1281 | ||
1327 | /* check state */ | 1282 | /* check state */ |
@@ -1340,11 +1295,8 @@ uInt *dictLength; | |||
1340 | return Z_OK; | 1295 | return Z_OK; |
1341 | } | 1296 | } |
1342 | 1297 | ||
1343 | int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) | 1298 | int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, |
1344 | z_streamp strm; | 1299 | uInt dictLength) { |
1345 | const Bytef *dictionary; | ||
1346 | uInt dictLength; | ||
1347 | { | ||
1348 | struct inflate_state FAR *state; | 1300 | struct inflate_state FAR *state; |
1349 | unsigned long dictid; | 1301 | unsigned long dictid; |
1350 | int ret; | 1302 | int ret; |
@@ -1375,10 +1327,7 @@ uInt dictLength; | |||
1375 | return Z_OK; | 1327 | return Z_OK; |
1376 | } | 1328 | } |
1377 | 1329 | ||
1378 | int ZEXPORT inflateGetHeader(strm, head) | 1330 | int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { |
1379 | z_streamp strm; | ||
1380 | gz_headerp head; | ||
1381 | { | ||
1382 | struct inflate_state FAR *state; | 1331 | struct inflate_state FAR *state; |
1383 | 1332 | ||
1384 | /* check state */ | 1333 | /* check state */ |
@@ -1403,11 +1352,8 @@ gz_headerp head; | |||
1403 | called again with more data and the *have state. *have is initialized to | 1352 | called again with more data and the *have state. *have is initialized to |
1404 | zero for the first call. | 1353 | zero for the first call. |
1405 | */ | 1354 | */ |
1406 | local unsigned syncsearch(have, buf, len) | 1355 | local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, |
1407 | unsigned FAR *have; | 1356 | unsigned len) { |
1408 | const unsigned char FAR *buf; | ||
1409 | unsigned len; | ||
1410 | { | ||
1411 | unsigned got; | 1357 | unsigned got; |
1412 | unsigned next; | 1358 | unsigned next; |
1413 | 1359 | ||
@@ -1426,9 +1372,7 @@ unsigned len; | |||
1426 | return next; | 1372 | return next; |
1427 | } | 1373 | } |
1428 | 1374 | ||
1429 | int ZEXPORT inflateSync(strm) | 1375 | int ZEXPORT inflateSync(z_streamp strm) { |
1430 | z_streamp strm; | ||
1431 | { | ||
1432 | unsigned len; /* number of bytes to look at or looked at */ | 1376 | unsigned len; /* number of bytes to look at or looked at */ |
1433 | int flags; /* temporary to save header status */ | 1377 | int flags; /* temporary to save header status */ |
1434 | unsigned long in, out; /* temporary to save total_in and total_out */ | 1378 | unsigned long in, out; /* temporary to save total_in and total_out */ |
@@ -1484,9 +1428,7 @@ z_streamp strm; | |||
1484 | block. When decompressing, PPP checks that at the end of input packet, | 1428 | block. When decompressing, PPP checks that at the end of input packet, |
1485 | inflate is waiting for these length bytes. | 1429 | inflate is waiting for these length bytes. |
1486 | */ | 1430 | */ |
1487 | int ZEXPORT inflateSyncPoint(strm) | 1431 | int ZEXPORT inflateSyncPoint(z_streamp strm) { |
1488 | z_streamp strm; | ||
1489 | { | ||
1490 | struct inflate_state FAR *state; | 1432 | struct inflate_state FAR *state; |
1491 | 1433 | ||
1492 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; | 1434 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -1494,10 +1436,7 @@ z_streamp strm; | |||
1494 | return state->mode == STORED && state->bits == 0; | 1436 | return state->mode == STORED && state->bits == 0; |
1495 | } | 1437 | } |
1496 | 1438 | ||
1497 | int ZEXPORT inflateCopy(dest, source) | 1439 | int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { |
1498 | z_streamp dest; | ||
1499 | z_streamp source; | ||
1500 | { | ||
1501 | struct inflate_state FAR *state; | 1440 | struct inflate_state FAR *state; |
1502 | struct inflate_state FAR *copy; | 1441 | struct inflate_state FAR *copy; |
1503 | unsigned char FAR *window; | 1442 | unsigned char FAR *window; |
@@ -1541,10 +1480,7 @@ z_streamp source; | |||
1541 | return Z_OK; | 1480 | return Z_OK; |
1542 | } | 1481 | } |
1543 | 1482 | ||
1544 | int ZEXPORT inflateUndermine(strm, subvert) | 1483 | int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { |
1545 | z_streamp strm; | ||
1546 | int subvert; | ||
1547 | { | ||
1548 | struct inflate_state FAR *state; | 1484 | struct inflate_state FAR *state; |
1549 | 1485 | ||
1550 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; | 1486 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -1559,10 +1495,7 @@ int subvert; | |||
1559 | #endif | 1495 | #endif |
1560 | } | 1496 | } |
1561 | 1497 | ||
1562 | int ZEXPORT inflateValidate(strm, check) | 1498 | int ZEXPORT inflateValidate(z_streamp strm, int check) { |
1563 | z_streamp strm; | ||
1564 | int check; | ||
1565 | { | ||
1566 | struct inflate_state FAR *state; | 1499 | struct inflate_state FAR *state; |
1567 | 1500 | ||
1568 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; | 1501 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
@@ -1574,9 +1507,7 @@ int check; | |||
1574 | return Z_OK; | 1507 | return Z_OK; |
1575 | } | 1508 | } |
1576 | 1509 | ||
1577 | long ZEXPORT inflateMark(strm) | 1510 | long ZEXPORT inflateMark(z_streamp strm) { |
1578 | z_streamp strm; | ||
1579 | { | ||
1580 | struct inflate_state FAR *state; | 1511 | struct inflate_state FAR *state; |
1581 | 1512 | ||
1582 | if (inflateStateCheck(strm)) | 1513 | if (inflateStateCheck(strm)) |
@@ -1587,9 +1518,7 @@ z_streamp strm; | |||
1587 | (state->mode == MATCH ? state->was - state->length : 0)); | 1518 | (state->mode == MATCH ? state->was - state->length : 0)); |
1588 | } | 1519 | } |
1589 | 1520 | ||
1590 | unsigned long ZEXPORT inflateCodesUsed(strm) | 1521 | unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { |
1591 | z_streamp strm; | ||
1592 | { | ||
1593 | struct inflate_state FAR *state; | 1522 | struct inflate_state FAR *state; |
1594 | if (inflateStateCheck(strm)) return (unsigned long)-1; | 1523 | if (inflateStateCheck(strm)) return (unsigned long)-1; |
1595 | state = (struct inflate_state FAR *)strm->state; | 1524 | state = (struct inflate_state FAR *)strm->state; |
@@ -29,14 +29,9 @@ const char inflate_copyright[] = | |||
29 | table index bits. It will differ if the request is greater than the | 29 | table index bits. It will differ if the request is greater than the |
30 | longest code or if it is less than the shortest code. | 30 | longest code or if it is less than the shortest code. |
31 | */ | 31 | */ |
32 | int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) | 32 | int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, |
33 | codetype type; | 33 | unsigned codes, code FAR * FAR *table, |
34 | unsigned short FAR *lens; | 34 | unsigned FAR *bits, unsigned short FAR *work) { |
35 | unsigned codes; | ||
36 | code FAR * FAR *table; | ||
37 | unsigned FAR *bits; | ||
38 | unsigned short FAR *work; | ||
39 | { | ||
40 | unsigned len; /* a code's length in bits */ | 35 | unsigned len; /* a code's length in bits */ |
41 | unsigned sym; /* index of code symbols */ | 36 | unsigned sym; /* index of code symbols */ |
42 | unsigned min, max; /* minimum and maximum code lengths */ | 37 | unsigned min, max; /* minimum and maximum code lengths */ |
@@ -57,6 +57,6 @@ typedef enum { | |||
57 | DISTS | 57 | DISTS |
58 | } codetype; | 58 | } codetype; |
59 | 59 | ||
60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, | 60 | int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, |
61 | unsigned codes, code FAR * FAR *table, | 61 | unsigned codes, code FAR * FAR *table, |
62 | unsigned FAR *bits, unsigned short FAR *work)); | 62 | unsigned FAR *bits, unsigned short FAR *work); |
diff --git a/test/example.c b/test/example.c index 1470bc8..1c755bc 100644 --- a/test/example.c +++ b/test/example.c | |||
@@ -34,37 +34,14 @@ static z_const char hello[] = "hello, hello!"; | |||
34 | static const char dictionary[] = "hello"; | 34 | static const char dictionary[] = "hello"; |
35 | static uLong dictId; /* Adler32 value of the dictionary */ | 35 | static uLong dictId; /* Adler32 value of the dictionary */ |
36 | 36 | ||
37 | void test_deflate OF((Byte *compr, uLong comprLen)); | ||
38 | void test_inflate OF((Byte *compr, uLong comprLen, | ||
39 | Byte *uncompr, uLong uncomprLen)); | ||
40 | void test_large_deflate OF((Byte *compr, uLong comprLen, | ||
41 | Byte *uncompr, uLong uncomprLen)); | ||
42 | void test_large_inflate OF((Byte *compr, uLong comprLen, | ||
43 | Byte *uncompr, uLong uncomprLen)); | ||
44 | void test_flush OF((Byte *compr, uLong *comprLen)); | ||
45 | void test_sync OF((Byte *compr, uLong comprLen, | ||
46 | Byte *uncompr, uLong uncomprLen)); | ||
47 | void test_dict_deflate OF((Byte *compr, uLong comprLen)); | ||
48 | void test_dict_inflate OF((Byte *compr, uLong comprLen, | ||
49 | Byte *uncompr, uLong uncomprLen)); | ||
50 | int main OF((int argc, char *argv[])); | ||
51 | |||
52 | |||
53 | #ifdef Z_SOLO | 37 | #ifdef Z_SOLO |
54 | 38 | ||
55 | void *myalloc OF((void *, unsigned, unsigned)); | 39 | void *myalloc(void *q, unsigned n, unsigned m) { |
56 | void myfree OF((void *, void *)); | ||
57 | |||
58 | void *myalloc(q, n, m) | ||
59 | void *q; | ||
60 | unsigned n, m; | ||
61 | { | ||
62 | (void)q; | 40 | (void)q; |
63 | return calloc(n, m); | 41 | return calloc(n, m); |
64 | } | 42 | } |
65 | 43 | ||
66 | void myfree(void *q, void *p) | 44 | void myfree(void *q, void *p) { |
67 | { | ||
68 | (void)q; | 45 | (void)q; |
69 | free(p); | 46 | free(p); |
70 | } | 47 | } |
@@ -77,18 +54,11 @@ static free_func zfree = myfree; | |||
77 | static alloc_func zalloc = (alloc_func)0; | 54 | static alloc_func zalloc = (alloc_func)0; |
78 | static free_func zfree = (free_func)0; | 55 | static free_func zfree = (free_func)0; |
79 | 56 | ||
80 | void test_compress OF((Byte *compr, uLong comprLen, | ||
81 | Byte *uncompr, uLong uncomprLen)); | ||
82 | void test_gzio OF((const char *fname, | ||
83 | Byte *uncompr, uLong uncomprLen)); | ||
84 | |||
85 | /* =========================================================================== | 57 | /* =========================================================================== |
86 | * Test compress() and uncompress() | 58 | * Test compress() and uncompress() |
87 | */ | 59 | */ |
88 | void test_compress(compr, comprLen, uncompr, uncomprLen) | 60 | void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, |
89 | Byte *compr, *uncompr; | 61 | uLong uncomprLen) { |
90 | uLong comprLen, uncomprLen; | ||
91 | { | ||
92 | int err; | 62 | int err; |
93 | uLong len = (uLong)strlen(hello)+1; | 63 | uLong len = (uLong)strlen(hello)+1; |
94 | 64 | ||
@@ -111,11 +81,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) | |||
111 | /* =========================================================================== | 81 | /* =========================================================================== |
112 | * Test read/write of .gz files | 82 | * Test read/write of .gz files |
113 | */ | 83 | */ |
114 | void test_gzio(fname, uncompr, uncomprLen) | 84 | void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { |
115 | const char *fname; /* compressed file name */ | ||
116 | Byte *uncompr; | ||
117 | uLong uncomprLen; | ||
118 | { | ||
119 | #ifdef NO_GZCOMPRESS | 85 | #ifdef NO_GZCOMPRESS |
120 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); | 86 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); |
121 | #else | 87 | #else |
@@ -197,10 +163,7 @@ void test_gzio(fname, uncompr, uncomprLen) | |||
197 | /* =========================================================================== | 163 | /* =========================================================================== |
198 | * Test deflate() with small buffers | 164 | * Test deflate() with small buffers |
199 | */ | 165 | */ |
200 | void test_deflate(compr, comprLen) | 166 | void test_deflate(Byte *compr, uLong comprLen) { |
201 | Byte *compr; | ||
202 | uLong comprLen; | ||
203 | { | ||
204 | z_stream c_stream; /* compression stream */ | 167 | z_stream c_stream; /* compression stream */ |
205 | int err; | 168 | int err; |
206 | uLong len = (uLong)strlen(hello)+1; | 169 | uLong len = (uLong)strlen(hello)+1; |
@@ -235,10 +198,8 @@ void test_deflate(compr, comprLen) | |||
235 | /* =========================================================================== | 198 | /* =========================================================================== |
236 | * Test inflate() with small buffers | 199 | * Test inflate() with small buffers |
237 | */ | 200 | */ |
238 | void test_inflate(compr, comprLen, uncompr, uncomprLen) | 201 | void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
239 | Byte *compr, *uncompr; | 202 | uLong uncomprLen) { |
240 | uLong comprLen, uncomprLen; | ||
241 | { | ||
242 | int err; | 203 | int err; |
243 | z_stream d_stream; /* decompression stream */ | 204 | z_stream d_stream; /* decompression stream */ |
244 | 205 | ||
@@ -276,10 +237,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) | |||
276 | /* =========================================================================== | 237 | /* =========================================================================== |
277 | * Test deflate() with large buffers and dynamic change of compression level | 238 | * Test deflate() with large buffers and dynamic change of compression level |
278 | */ | 239 | */ |
279 | void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | 240 | void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, |
280 | Byte *compr, *uncompr; | 241 | uLong uncomprLen) { |
281 | uLong comprLen, uncomprLen; | ||
282 | { | ||
283 | z_stream c_stream; /* compression stream */ | 242 | z_stream c_stream; /* compression stream */ |
284 | int err; | 243 | int err; |
285 | 244 | ||
@@ -331,10 +290,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | |||
331 | /* =========================================================================== | 290 | /* =========================================================================== |
332 | * Test inflate() with large buffers | 291 | * Test inflate() with large buffers |
333 | */ | 292 | */ |
334 | void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | 293 | void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
335 | Byte *compr, *uncompr; | 294 | uLong uncomprLen) { |
336 | uLong comprLen, uncomprLen; | ||
337 | { | ||
338 | int err; | 295 | int err; |
339 | z_stream d_stream; /* decompression stream */ | 296 | z_stream d_stream; /* decompression stream */ |
340 | 297 | ||
@@ -372,10 +329,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | |||
372 | /* =========================================================================== | 329 | /* =========================================================================== |
373 | * Test deflate() with full flush | 330 | * Test deflate() with full flush |
374 | */ | 331 | */ |
375 | void test_flush(compr, comprLen) | 332 | void test_flush(Byte *compr, uLong *comprLen) { |
376 | Byte *compr; | ||
377 | uLong *comprLen; | ||
378 | { | ||
379 | z_stream c_stream; /* compression stream */ | 333 | z_stream c_stream; /* compression stream */ |
380 | int err; | 334 | int err; |
381 | uInt len = (uInt)strlen(hello)+1; | 335 | uInt len = (uInt)strlen(hello)+1; |
@@ -410,10 +364,7 @@ void test_flush(compr, comprLen) | |||
410 | /* =========================================================================== | 364 | /* =========================================================================== |
411 | * Test inflateSync() | 365 | * Test inflateSync() |
412 | */ | 366 | */ |
413 | void test_sync(compr, comprLen, uncompr, uncomprLen) | 367 | void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { |
414 | Byte *compr, *uncompr; | ||
415 | uLong comprLen, uncomprLen; | ||
416 | { | ||
417 | int err; | 368 | int err; |
418 | z_stream d_stream; /* decompression stream */ | 369 | z_stream d_stream; /* decompression stream */ |
419 | 370 | ||
@@ -453,10 +404,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) | |||
453 | /* =========================================================================== | 404 | /* =========================================================================== |
454 | * Test deflate() with preset dictionary | 405 | * Test deflate() with preset dictionary |
455 | */ | 406 | */ |
456 | void test_dict_deflate(compr, comprLen) | 407 | void test_dict_deflate(Byte *compr, uLong comprLen) { |
457 | Byte *compr; | ||
458 | uLong comprLen; | ||
459 | { | ||
460 | z_stream c_stream; /* compression stream */ | 408 | z_stream c_stream; /* compression stream */ |
461 | int err; | 409 | int err; |
462 | 410 | ||
@@ -490,10 +438,8 @@ void test_dict_deflate(compr, comprLen) | |||
490 | /* =========================================================================== | 438 | /* =========================================================================== |
491 | * Test inflate() with a preset dictionary | 439 | * Test inflate() with a preset dictionary |
492 | */ | 440 | */ |
493 | void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | 441 | void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
494 | Byte *compr, *uncompr; | 442 | uLong uncomprLen) { |
495 | uLong comprLen, uncomprLen; | ||
496 | { | ||
497 | int err; | 443 | int err; |
498 | z_stream d_stream; /* decompression stream */ | 444 | z_stream d_stream; /* decompression stream */ |
499 | 445 | ||
@@ -541,10 +487,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | |||
541 | * Usage: example [output.gz [input.gz]] | 487 | * Usage: example [output.gz [input.gz]] |
542 | */ | 488 | */ |
543 | 489 | ||
544 | int main(argc, argv) | 490 | int main(int argc, char *argv[]) { |
545 | int argc; | ||
546 | char *argv[]; | ||
547 | { | ||
548 | Byte *compr, *uncompr; | 491 | Byte *compr, *uncompr; |
549 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ | 492 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ |
550 | uLong uncomprLen = comprLen; | 493 | uLong uncomprLen = comprLen; |
diff --git a/test/minigzip.c b/test/minigzip.c index a649d2b..8a21ddf 100644 --- a/test/minigzip.c +++ b/test/minigzip.c | |||
@@ -59,7 +59,7 @@ | |||
59 | 59 | ||
60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) | 60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) |
61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ | 61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ |
62 | extern int unlink OF((const char *)); | 62 | extern int unlink(const char *); |
63 | #endif | 63 | #endif |
64 | #endif | 64 | #endif |
65 | 65 | ||
@@ -149,20 +149,12 @@ static void pwinerror (s) | |||
149 | # include <unistd.h> /* for unlink() */ | 149 | # include <unistd.h> /* for unlink() */ |
150 | #endif | 150 | #endif |
151 | 151 | ||
152 | void *myalloc OF((void *, unsigned, unsigned)); | 152 | void *myalloc(void *q, unsigned n, unsigned m) { |
153 | void myfree OF((void *, void *)); | ||
154 | |||
155 | void *myalloc(q, n, m) | ||
156 | void *q; | ||
157 | unsigned n, m; | ||
158 | { | ||
159 | (void)q; | 153 | (void)q; |
160 | return calloc(n, m); | 154 | return calloc(n, m); |
161 | } | 155 | } |
162 | 156 | ||
163 | void myfree(q, p) | 157 | void myfree(void *q, void *p) { |
164 | void *q, *p; | ||
165 | { | ||
166 | (void)q; | 158 | (void)q; |
167 | free(p); | 159 | free(p); |
168 | } | 160 | } |
@@ -175,29 +167,7 @@ typedef struct gzFile_s { | |||
175 | z_stream strm; | 167 | z_stream strm; |
176 | } *gzFile; | 168 | } *gzFile; |
177 | 169 | ||
178 | gzFile gzopen OF((const char *, const char *)); | 170 | gzFile gz_open(const char *path, int fd, const char *mode) { |
179 | gzFile gzdopen OF((int, const char *)); | ||
180 | gzFile gz_open OF((const char *, int, const char *)); | ||
181 | |||
182 | gzFile gzopen(path, mode) | ||
183 | const char *path; | ||
184 | const char *mode; | ||
185 | { | ||
186 | return gz_open(path, -1, mode); | ||
187 | } | ||
188 | |||
189 | gzFile gzdopen(fd, mode) | ||
190 | int fd; | ||
191 | const char *mode; | ||
192 | { | ||
193 | return gz_open(NULL, fd, mode); | ||
194 | } | ||
195 | |||
196 | gzFile gz_open(path, fd, mode) | ||
197 | const char *path; | ||
198 | int fd; | ||
199 | const char *mode; | ||
200 | { | ||
201 | gzFile gz; | 171 | gzFile gz; |
202 | int ret; | 172 | int ret; |
203 | 173 | ||
@@ -231,13 +201,15 @@ gzFile gz_open(path, fd, mode) | |||
231 | return gz; | 201 | return gz; |
232 | } | 202 | } |
233 | 203 | ||
234 | int gzwrite OF((gzFile, const void *, unsigned)); | 204 | gzFile gzopen(const char *path, const char *mode) { |
205 | return gz_open(path, -1, mode); | ||
206 | } | ||
235 | 207 | ||
236 | int gzwrite(gz, buf, len) | 208 | gzFile gzdopen(int fd, const char *mode) { |
237 | gzFile gz; | 209 | return gz_open(NULL, fd, mode); |
238 | const void *buf; | 210 | } |
239 | unsigned len; | 211 | |
240 | { | 212 | int gzwrite(gzFile gz, const void *buf, unsigned len) { |
241 | z_stream *strm; | 213 | z_stream *strm; |
242 | unsigned char out[BUFLEN]; | 214 | unsigned char out[BUFLEN]; |
243 | 215 | ||
@@ -255,13 +227,7 @@ int gzwrite(gz, buf, len) | |||
255 | return len; | 227 | return len; |
256 | } | 228 | } |
257 | 229 | ||
258 | int gzread OF((gzFile, void *, unsigned)); | 230 | int gzread(gzFile gz, void *buf, unsigned len) { |
259 | |||
260 | int gzread(gz, buf, len) | ||
261 | gzFile gz; | ||
262 | void *buf; | ||
263 | unsigned len; | ||
264 | { | ||
265 | int ret; | 231 | int ret; |
266 | unsigned got; | 232 | unsigned got; |
267 | unsigned char in[1]; | 233 | unsigned char in[1]; |
@@ -292,11 +258,7 @@ int gzread(gz, buf, len) | |||
292 | return len - strm->avail_out; | 258 | return len - strm->avail_out; |
293 | } | 259 | } |
294 | 260 | ||
295 | int gzclose OF((gzFile)); | 261 | int gzclose(gzFile gz) { |
296 | |||
297 | int gzclose(gz) | ||
298 | gzFile gz; | ||
299 | { | ||
300 | z_stream *strm; | 262 | z_stream *strm; |
301 | unsigned char out[BUFLEN]; | 263 | unsigned char out[BUFLEN]; |
302 | 264 | ||
@@ -321,12 +283,7 @@ int gzclose(gz) | |||
321 | return Z_OK; | 283 | return Z_OK; |
322 | } | 284 | } |
323 | 285 | ||
324 | const char *gzerror OF((gzFile, int *)); | 286 | const char *gzerror(gzFile gz, int *err) { |
325 | |||
326 | const char *gzerror(gz, err) | ||
327 | gzFile gz; | ||
328 | int *err; | ||
329 | { | ||
330 | *err = gz->err; | 287 | *err = gz->err; |
331 | return gz->msg; | 288 | return gz->msg; |
332 | } | 289 | } |
@@ -335,67 +292,20 @@ const char *gzerror(gz, err) | |||
335 | 292 | ||
336 | static char *prog; | 293 | static char *prog; |
337 | 294 | ||
338 | void error OF((const char *msg)); | ||
339 | void gz_compress OF((FILE *in, gzFile out)); | ||
340 | #ifdef USE_MMAP | ||
341 | int gz_compress_mmap OF((FILE *in, gzFile out)); | ||
342 | #endif | ||
343 | void gz_uncompress OF((gzFile in, FILE *out)); | ||
344 | void file_compress OF((char *file, char *mode)); | ||
345 | void file_uncompress OF((char *file)); | ||
346 | int main OF((int argc, char *argv[])); | ||
347 | |||
348 | /* =========================================================================== | 295 | /* =========================================================================== |
349 | * Display error message and exit | 296 | * Display error message and exit |
350 | */ | 297 | */ |
351 | void error(msg) | 298 | void error(const char *msg) { |
352 | const char *msg; | ||
353 | { | ||
354 | fprintf(stderr, "%s: %s\n", prog, msg); | 299 | fprintf(stderr, "%s: %s\n", prog, msg); |
355 | exit(1); | 300 | exit(1); |
356 | } | 301 | } |
357 | 302 | ||
358 | /* =========================================================================== | ||
359 | * Compress input to output then close both files. | ||
360 | */ | ||
361 | |||
362 | void gz_compress(in, out) | ||
363 | FILE *in; | ||
364 | gzFile out; | ||
365 | { | ||
366 | local char buf[BUFLEN]; | ||
367 | int len; | ||
368 | int err; | ||
369 | |||
370 | #ifdef USE_MMAP | ||
371 | /* Try first compressing with mmap. If mmap fails (minigzip used in a | ||
372 | * pipe), use the normal fread loop. | ||
373 | */ | ||
374 | if (gz_compress_mmap(in, out) == Z_OK) return; | ||
375 | #endif | ||
376 | for (;;) { | ||
377 | len = (int)fread(buf, 1, sizeof(buf), in); | ||
378 | if (ferror(in)) { | ||
379 | perror("fread"); | ||
380 | exit(1); | ||
381 | } | ||
382 | if (len == 0) break; | ||
383 | |||
384 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); | ||
385 | } | ||
386 | fclose(in); | ||
387 | if (gzclose(out) != Z_OK) error("failed gzclose"); | ||
388 | } | ||
389 | |||
390 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */ | 303 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */ |
391 | 304 | ||
392 | /* Try compressing the input file at once using mmap. Return Z_OK if | 305 | /* Try compressing the input file at once using mmap. Return Z_OK if |
393 | * if success, Z_ERRNO otherwise. | 306 | * if success, Z_ERRNO otherwise. |
394 | */ | 307 | */ |
395 | int gz_compress_mmap(in, out) | 308 | int gz_compress_mmap(FILE *in, gzFile out) { |
396 | FILE *in; | ||
397 | gzFile out; | ||
398 | { | ||
399 | int len; | 309 | int len; |
400 | int err; | 310 | int err; |
401 | int ifd = fileno(in); | 311 | int ifd = fileno(in); |
@@ -425,12 +335,38 @@ int gz_compress_mmap(in, out) | |||
425 | #endif /* USE_MMAP */ | 335 | #endif /* USE_MMAP */ |
426 | 336 | ||
427 | /* =========================================================================== | 337 | /* =========================================================================== |
338 | * Compress input to output then close both files. | ||
339 | */ | ||
340 | |||
341 | void gz_compress(FILE *in, gzFile out) { | ||
342 | local char buf[BUFLEN]; | ||
343 | int len; | ||
344 | int err; | ||
345 | |||
346 | #ifdef USE_MMAP | ||
347 | /* Try first compressing with mmap. If mmap fails (minigzip used in a | ||
348 | * pipe), use the normal fread loop. | ||
349 | */ | ||
350 | if (gz_compress_mmap(in, out) == Z_OK) return; | ||
351 | #endif | ||
352 | for (;;) { | ||
353 | len = (int)fread(buf, 1, sizeof(buf), in); | ||
354 | if (ferror(in)) { | ||
355 | perror("fread"); | ||
356 | exit(1); | ||
357 | } | ||
358 | if (len == 0) break; | ||
359 | |||
360 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); | ||
361 | } | ||
362 | fclose(in); | ||
363 | if (gzclose(out) != Z_OK) error("failed gzclose"); | ||
364 | } | ||
365 | |||
366 | /* =========================================================================== | ||
428 | * Uncompress input to output then close both files. | 367 | * Uncompress input to output then close both files. |
429 | */ | 368 | */ |
430 | void gz_uncompress(in, out) | 369 | void gz_uncompress(gzFile in, FILE *out) { |
431 | gzFile in; | ||
432 | FILE *out; | ||
433 | { | ||
434 | local char buf[BUFLEN]; | 370 | local char buf[BUFLEN]; |
435 | int len; | 371 | int len; |
436 | int err; | 372 | int err; |
@@ -454,10 +390,7 @@ void gz_uncompress(in, out) | |||
454 | * Compress the given file: create a corresponding .gz file and remove the | 390 | * Compress the given file: create a corresponding .gz file and remove the |
455 | * original. | 391 | * original. |
456 | */ | 392 | */ |
457 | void file_compress(file, mode) | 393 | void file_compress(char *file, char *mode) { |
458 | char *file; | ||
459 | char *mode; | ||
460 | { | ||
461 | local char outfile[MAX_NAME_LEN]; | 394 | local char outfile[MAX_NAME_LEN]; |
462 | FILE *in; | 395 | FILE *in; |
463 | gzFile out; | 396 | gzFile out; |
@@ -493,9 +426,7 @@ void file_compress(file, mode) | |||
493 | /* =========================================================================== | 426 | /* =========================================================================== |
494 | * Uncompress the given file and remove the original. | 427 | * Uncompress the given file and remove the original. |
495 | */ | 428 | */ |
496 | void file_uncompress(file) | 429 | void file_uncompress(char *file) { |
497 | char *file; | ||
498 | { | ||
499 | local char buf[MAX_NAME_LEN]; | 430 | local char buf[MAX_NAME_LEN]; |
500 | char *infile, *outfile; | 431 | char *infile, *outfile; |
501 | FILE *out; | 432 | FILE *out; |
@@ -553,10 +484,7 @@ void file_uncompress(file) | |||
553 | * -1 to -9 : compression level | 484 | * -1 to -9 : compression level |
554 | */ | 485 | */ |
555 | 486 | ||
556 | int main(argc, argv) | 487 | int main(int argc, char *argv[]) { |
557 | int argc; | ||
558 | char *argv[]; | ||
559 | { | ||
560 | int copyout = 0; | 488 | int copyout = 0; |
561 | int uncompr = 0; | 489 | int uncompr = 0; |
562 | gzFile file; | 490 | gzFile file; |
@@ -122,39 +122,116 @@ struct static_tree_desc_s { | |||
122 | int max_length; /* max bit length for the codes */ | 122 | int max_length; /* max bit length for the codes */ |
123 | }; | 123 | }; |
124 | 124 | ||
125 | local const static_tree_desc static_l_desc = | 125 | #ifdef NO_INIT_GLOBAL_POINTERS |
126 | # define TCONST | ||
127 | #else | ||
128 | # define TCONST const | ||
129 | #endif | ||
130 | |||
131 | local TCONST static_tree_desc static_l_desc = | ||
126 | {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; | 132 | {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; |
127 | 133 | ||
128 | local const static_tree_desc static_d_desc = | 134 | local TCONST static_tree_desc static_d_desc = |
129 | {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; | 135 | {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; |
130 | 136 | ||
131 | local const static_tree_desc static_bl_desc = | 137 | local TCONST static_tree_desc static_bl_desc = |
132 | {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; | 138 | {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; |
133 | 139 | ||
134 | /* =========================================================================== | 140 | /* =========================================================================== |
135 | * Local (static) routines in this file. | 141 | * Output a short LSB first on the stream. |
142 | * IN assertion: there is enough room in pendingBuf. | ||
143 | */ | ||
144 | #define put_short(s, w) { \ | ||
145 | put_byte(s, (uch)((w) & 0xff)); \ | ||
146 | put_byte(s, (uch)((ush)(w) >> 8)); \ | ||
147 | } | ||
148 | |||
149 | /* =========================================================================== | ||
150 | * Reverse the first len bits of a code, using straightforward code (a faster | ||
151 | * method would use a table) | ||
152 | * IN assertion: 1 <= len <= 15 | ||
136 | */ | 153 | */ |
154 | local unsigned bi_reverse(unsigned code, int len) { | ||
155 | register unsigned res = 0; | ||
156 | do { | ||
157 | res |= code & 1; | ||
158 | code >>= 1, res <<= 1; | ||
159 | } while (--len > 0); | ||
160 | return res >> 1; | ||
161 | } | ||
137 | 162 | ||
138 | local void tr_static_init OF((void)); | 163 | /* =========================================================================== |
139 | local void init_block OF((deflate_state *s)); | 164 | * Flush the bit buffer, keeping at most 7 bits in it. |
140 | local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); | 165 | */ |
141 | local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); | 166 | local void bi_flush(deflate_state *s) { |
142 | local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); | 167 | if (s->bi_valid == 16) { |
143 | local void build_tree OF((deflate_state *s, tree_desc *desc)); | 168 | put_short(s, s->bi_buf); |
144 | local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); | 169 | s->bi_buf = 0; |
145 | local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); | 170 | s->bi_valid = 0; |
146 | local int build_bl_tree OF((deflate_state *s)); | 171 | } else if (s->bi_valid >= 8) { |
147 | local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, | 172 | put_byte(s, (Byte)s->bi_buf); |
148 | int blcodes)); | 173 | s->bi_buf >>= 8; |
149 | local void compress_block OF((deflate_state *s, const ct_data *ltree, | 174 | s->bi_valid -= 8; |
150 | const ct_data *dtree)); | 175 | } |
151 | local int detect_data_type OF((deflate_state *s)); | 176 | } |
152 | local unsigned bi_reverse OF((unsigned code, int len)); | 177 | |
153 | local void bi_windup OF((deflate_state *s)); | 178 | /* =========================================================================== |
154 | local void bi_flush OF((deflate_state *s)); | 179 | * Flush the bit buffer and align the output on a byte boundary |
180 | */ | ||
181 | local void bi_windup(deflate_state *s) { | ||
182 | if (s->bi_valid > 8) { | ||
183 | put_short(s, s->bi_buf); | ||
184 | } else if (s->bi_valid > 0) { | ||
185 | put_byte(s, (Byte)s->bi_buf); | ||
186 | } | ||
187 | s->bi_buf = 0; | ||
188 | s->bi_valid = 0; | ||
189 | #ifdef ZLIB_DEBUG | ||
190 | s->bits_sent = (s->bits_sent + 7) & ~7; | ||
191 | #endif | ||
192 | } | ||
193 | |||
194 | /* =========================================================================== | ||
195 | * Generate the codes for a given tree and bit counts (which need not be | ||
196 | * optimal). | ||
197 | * IN assertion: the array bl_count contains the bit length statistics for | ||
198 | * the given tree and the field len is set for all tree elements. | ||
199 | * OUT assertion: the field code is set for all tree elements of non | ||
200 | * zero code length. | ||
201 | */ | ||
202 | local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { | ||
203 | ush next_code[MAX_BITS+1]; /* next code value for each bit length */ | ||
204 | unsigned code = 0; /* running code value */ | ||
205 | int bits; /* bit index */ | ||
206 | int n; /* code index */ | ||
207 | |||
208 | /* The distribution counts are first used to generate the code values | ||
209 | * without bit reversal. | ||
210 | */ | ||
211 | for (bits = 1; bits <= MAX_BITS; bits++) { | ||
212 | code = (code + bl_count[bits - 1]) << 1; | ||
213 | next_code[bits] = (ush)code; | ||
214 | } | ||
215 | /* Check that the bit counts in bl_count are consistent. The last code | ||
216 | * must be all ones. | ||
217 | */ | ||
218 | Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, | ||
219 | "inconsistent bit counts"); | ||
220 | Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); | ||
221 | |||
222 | for (n = 0; n <= max_code; n++) { | ||
223 | int len = tree[n].Len; | ||
224 | if (len == 0) continue; | ||
225 | /* Now reverse the bits */ | ||
226 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); | ||
227 | |||
228 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | ||
229 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); | ||
230 | } | ||
231 | } | ||
155 | 232 | ||
156 | #ifdef GEN_TREES_H | 233 | #ifdef GEN_TREES_H |
157 | local void gen_trees_header OF((void)); | 234 | local void gen_trees_header(void); |
158 | #endif | 235 | #endif |
159 | 236 | ||
160 | #ifndef ZLIB_DEBUG | 237 | #ifndef ZLIB_DEBUG |
@@ -168,26 +245,11 @@ local void gen_trees_header OF((void)); | |||
168 | #endif | 245 | #endif |
169 | 246 | ||
170 | /* =========================================================================== | 247 | /* =========================================================================== |
171 | * Output a short LSB first on the stream. | ||
172 | * IN assertion: there is enough room in pendingBuf. | ||
173 | */ | ||
174 | #define put_short(s, w) { \ | ||
175 | put_byte(s, (uch)((w) & 0xff)); \ | ||
176 | put_byte(s, (uch)((ush)(w) >> 8)); \ | ||
177 | } | ||
178 | |||
179 | /* =========================================================================== | ||
180 | * Send a value on a given number of bits. | 248 | * Send a value on a given number of bits. |
181 | * IN assertion: length <= 16 and value fits in length bits. | 249 | * IN assertion: length <= 16 and value fits in length bits. |
182 | */ | 250 | */ |
183 | #ifdef ZLIB_DEBUG | 251 | #ifdef ZLIB_DEBUG |
184 | local void send_bits OF((deflate_state *s, int value, int length)); | 252 | local void send_bits(deflate_state *s, int value, int length) { |
185 | |||
186 | local void send_bits(s, value, length) | ||
187 | deflate_state *s; | ||
188 | int value; /* value to send */ | ||
189 | int length; /* number of bits */ | ||
190 | { | ||
191 | Tracevv((stderr," l %2d v %4x ", length, value)); | 253 | Tracevv((stderr," l %2d v %4x ", length, value)); |
192 | Assert(length > 0 && length <= 15, "invalid length"); | 254 | Assert(length > 0 && length <= 15, "invalid length"); |
193 | s->bits_sent += (ulg)length; | 255 | s->bits_sent += (ulg)length; |
@@ -229,8 +291,7 @@ local void send_bits(s, value, length) | |||
229 | /* =========================================================================== | 291 | /* =========================================================================== |
230 | * Initialize the various 'constant' tables. | 292 | * Initialize the various 'constant' tables. |
231 | */ | 293 | */ |
232 | local void tr_static_init() | 294 | local void tr_static_init(void) { |
233 | { | ||
234 | #if defined(GEN_TREES_H) || !defined(STDC) | 295 | #if defined(GEN_TREES_H) || !defined(STDC) |
235 | static int static_init_done = 0; | 296 | static int static_init_done = 0; |
236 | int n; /* iterates over tree elements */ | 297 | int n; /* iterates over tree elements */ |
@@ -323,8 +384,7 @@ local void tr_static_init() | |||
323 | ((i) == (last)? "\n};\n\n" : \ | 384 | ((i) == (last)? "\n};\n\n" : \ |
324 | ((i) % (width) == (width) - 1 ? ",\n" : ", ")) | 385 | ((i) % (width) == (width) - 1 ? ",\n" : ", ")) |
325 | 386 | ||
326 | void gen_trees_header() | 387 | void gen_trees_header(void) { |
327 | { | ||
328 | FILE *header = fopen("trees.h", "w"); | 388 | FILE *header = fopen("trees.h", "w"); |
329 | int i; | 389 | int i; |
330 | 390 | ||
@@ -374,11 +434,25 @@ void gen_trees_header() | |||
374 | #endif /* GEN_TREES_H */ | 434 | #endif /* GEN_TREES_H */ |
375 | 435 | ||
376 | /* =========================================================================== | 436 | /* =========================================================================== |
437 | * Initialize a new block. | ||
438 | */ | ||
439 | local void init_block(deflate_state *s) { | ||
440 | int n; /* iterates over tree elements */ | ||
441 | |||
442 | /* Initialize the trees. */ | ||
443 | for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; | ||
444 | for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; | ||
445 | for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; | ||
446 | |||
447 | s->dyn_ltree[END_BLOCK].Freq = 1; | ||
448 | s->opt_len = s->static_len = 0L; | ||
449 | s->sym_next = s->matches = 0; | ||
450 | } | ||
451 | |||
452 | /* =========================================================================== | ||
377 | * Initialize the tree data structures for a new zlib stream. | 453 | * Initialize the tree data structures for a new zlib stream. |
378 | */ | 454 | */ |
379 | void ZLIB_INTERNAL _tr_init(s) | 455 | void ZLIB_INTERNAL _tr_init(deflate_state *s) { |
380 | deflate_state *s; | ||
381 | { | ||
382 | tr_static_init(); | 456 | tr_static_init(); |
383 | 457 | ||
384 | s->l_desc.dyn_tree = s->dyn_ltree; | 458 | s->l_desc.dyn_tree = s->dyn_ltree; |
@@ -401,24 +475,6 @@ void ZLIB_INTERNAL _tr_init(s) | |||
401 | init_block(s); | 475 | init_block(s); |
402 | } | 476 | } |
403 | 477 | ||
404 | /* =========================================================================== | ||
405 | * Initialize a new block. | ||
406 | */ | ||
407 | local void init_block(s) | ||
408 | deflate_state *s; | ||
409 | { | ||
410 | int n; /* iterates over tree elements */ | ||
411 | |||
412 | /* Initialize the trees. */ | ||
413 | for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; | ||
414 | for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; | ||
415 | for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; | ||
416 | |||
417 | s->dyn_ltree[END_BLOCK].Freq = 1; | ||
418 | s->opt_len = s->static_len = 0L; | ||
419 | s->sym_next = s->matches = 0; | ||
420 | } | ||
421 | |||
422 | #define SMALLEST 1 | 478 | #define SMALLEST 1 |
423 | /* Index within the heap array of least frequent node in the Huffman tree */ | 479 | /* Index within the heap array of least frequent node in the Huffman tree */ |
424 | 480 | ||
@@ -448,11 +504,7 @@ local void init_block(s) | |||
448 | * when the heap property is re-established (each father smaller than its | 504 | * when the heap property is re-established (each father smaller than its |
449 | * two sons). | 505 | * two sons). |
450 | */ | 506 | */ |
451 | local void pqdownheap(s, tree, k) | 507 | local void pqdownheap(deflate_state *s, ct_data *tree, int k) { |
452 | deflate_state *s; | ||
453 | ct_data *tree; /* the tree to restore */ | ||
454 | int k; /* node to move down */ | ||
455 | { | ||
456 | int v = s->heap[k]; | 508 | int v = s->heap[k]; |
457 | int j = k << 1; /* left son of k */ | 509 | int j = k << 1; /* left son of k */ |
458 | while (j <= s->heap_len) { | 510 | while (j <= s->heap_len) { |
@@ -483,10 +535,7 @@ local void pqdownheap(s, tree, k) | |||
483 | * The length opt_len is updated; static_len is also updated if stree is | 535 | * The length opt_len is updated; static_len is also updated if stree is |
484 | * not null. | 536 | * not null. |
485 | */ | 537 | */ |
486 | local void gen_bitlen(s, desc) | 538 | local void gen_bitlen(deflate_state *s, tree_desc *desc) { |
487 | deflate_state *s; | ||
488 | tree_desc *desc; /* the tree descriptor */ | ||
489 | { | ||
490 | ct_data *tree = desc->dyn_tree; | 539 | ct_data *tree = desc->dyn_tree; |
491 | int max_code = desc->max_code; | 540 | int max_code = desc->max_code; |
492 | const ct_data *stree = desc->stat_desc->static_tree; | 541 | const ct_data *stree = desc->stat_desc->static_tree; |
@@ -561,48 +610,9 @@ local void gen_bitlen(s, desc) | |||
561 | } | 610 | } |
562 | } | 611 | } |
563 | 612 | ||
564 | /* =========================================================================== | 613 | #ifdef DUMP_BL_TREE |
565 | * Generate the codes for a given tree and bit counts (which need not be | 614 | # include <stdio.h> |
566 | * optimal). | 615 | #endif |
567 | * IN assertion: the array bl_count contains the bit length statistics for | ||
568 | * the given tree and the field len is set for all tree elements. | ||
569 | * OUT assertion: the field code is set for all tree elements of non | ||
570 | * zero code length. | ||
571 | */ | ||
572 | local void gen_codes(tree, max_code, bl_count) | ||
573 | ct_data *tree; /* the tree to decorate */ | ||
574 | int max_code; /* largest code with non zero frequency */ | ||
575 | ushf *bl_count; /* number of codes at each bit length */ | ||
576 | { | ||
577 | ush next_code[MAX_BITS+1]; /* next code value for each bit length */ | ||
578 | unsigned code = 0; /* running code value */ | ||
579 | int bits; /* bit index */ | ||
580 | int n; /* code index */ | ||
581 | |||
582 | /* The distribution counts are first used to generate the code values | ||
583 | * without bit reversal. | ||
584 | */ | ||
585 | for (bits = 1; bits <= MAX_BITS; bits++) { | ||
586 | code = (code + bl_count[bits - 1]) << 1; | ||
587 | next_code[bits] = (ush)code; | ||
588 | } | ||
589 | /* Check that the bit counts in bl_count are consistent. The last code | ||
590 | * must be all ones. | ||
591 | */ | ||
592 | Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, | ||
593 | "inconsistent bit counts"); | ||
594 | Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); | ||
595 | |||
596 | for (n = 0; n <= max_code; n++) { | ||
597 | int len = tree[n].Len; | ||
598 | if (len == 0) continue; | ||
599 | /* Now reverse the bits */ | ||
600 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); | ||
601 | |||
602 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | ||
603 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); | ||
604 | } | ||
605 | } | ||
606 | 616 | ||
607 | /* =========================================================================== | 617 | /* =========================================================================== |
608 | * Construct one Huffman tree and assigns the code bit strings and lengths. | 618 | * Construct one Huffman tree and assigns the code bit strings and lengths. |
@@ -612,10 +622,7 @@ local void gen_codes(tree, max_code, bl_count) | |||
612 | * and corresponding code. The length opt_len is updated; static_len is | 622 | * and corresponding code. The length opt_len is updated; static_len is |
613 | * also updated if stree is not null. The field max_code is set. | 623 | * also updated if stree is not null. The field max_code is set. |
614 | */ | 624 | */ |
615 | local void build_tree(s, desc) | 625 | local void build_tree(deflate_state *s, tree_desc *desc) { |
616 | deflate_state *s; | ||
617 | tree_desc *desc; /* the tree descriptor */ | ||
618 | { | ||
619 | ct_data *tree = desc->dyn_tree; | 626 | ct_data *tree = desc->dyn_tree; |
620 | const ct_data *stree = desc->stat_desc->static_tree; | 627 | const ct_data *stree = desc->stat_desc->static_tree; |
621 | int elems = desc->stat_desc->elems; | 628 | int elems = desc->stat_desc->elems; |
@@ -700,11 +707,7 @@ local void build_tree(s, desc) | |||
700 | * Scan a literal or distance tree to determine the frequencies of the codes | 707 | * Scan a literal or distance tree to determine the frequencies of the codes |
701 | * in the bit length tree. | 708 | * in the bit length tree. |
702 | */ | 709 | */ |
703 | local void scan_tree(s, tree, max_code) | 710 | local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { |
704 | deflate_state *s; | ||
705 | ct_data *tree; /* the tree to be scanned */ | ||
706 | int max_code; /* and its largest code of non zero frequency */ | ||
707 | { | ||
708 | int n; /* iterates over all tree elements */ | 711 | int n; /* iterates over all tree elements */ |
709 | int prevlen = -1; /* last emitted length */ | 712 | int prevlen = -1; /* last emitted length */ |
710 | int curlen; /* length of current code */ | 713 | int curlen; /* length of current code */ |
@@ -745,11 +748,7 @@ local void scan_tree(s, tree, max_code) | |||
745 | * Send a literal or distance tree in compressed form, using the codes in | 748 | * Send a literal or distance tree in compressed form, using the codes in |
746 | * bl_tree. | 749 | * bl_tree. |
747 | */ | 750 | */ |
748 | local void send_tree(s, tree, max_code) | 751 | local void send_tree(deflate_state *s, ct_data *tree, int max_code) { |
749 | deflate_state *s; | ||
750 | ct_data *tree; /* the tree to be scanned */ | ||
751 | int max_code; /* and its largest code of non zero frequency */ | ||
752 | { | ||
753 | int n; /* iterates over all tree elements */ | 752 | int n; /* iterates over all tree elements */ |
754 | int prevlen = -1; /* last emitted length */ | 753 | int prevlen = -1; /* last emitted length */ |
755 | int curlen; /* length of current code */ | 754 | int curlen; /* length of current code */ |
@@ -796,9 +795,7 @@ local void send_tree(s, tree, max_code) | |||
796 | * Construct the Huffman tree for the bit lengths and return the index in | 795 | * Construct the Huffman tree for the bit lengths and return the index in |
797 | * bl_order of the last bit length code to send. | 796 | * bl_order of the last bit length code to send. |
798 | */ | 797 | */ |
799 | local int build_bl_tree(s) | 798 | local int build_bl_tree(deflate_state *s) { |
800 | deflate_state *s; | ||
801 | { | ||
802 | int max_blindex; /* index of last bit length code of non zero freq */ | 799 | int max_blindex; /* index of last bit length code of non zero freq */ |
803 | 800 | ||
804 | /* Determine the bit length frequencies for literal and distance trees */ | 801 | /* Determine the bit length frequencies for literal and distance trees */ |
@@ -831,10 +828,8 @@ local int build_bl_tree(s) | |||
831 | * lengths of the bit length codes, the literal tree and the distance tree. | 828 | * lengths of the bit length codes, the literal tree and the distance tree. |
832 | * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. | 829 | * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. |
833 | */ | 830 | */ |
834 | local void send_all_trees(s, lcodes, dcodes, blcodes) | 831 | local void send_all_trees(deflate_state *s, int lcodes, int dcodes, |
835 | deflate_state *s; | 832 | int blcodes) { |
836 | int lcodes, dcodes, blcodes; /* number of codes for each tree */ | ||
837 | { | ||
838 | int rank; /* index in bl_order */ | 833 | int rank; /* index in bl_order */ |
839 | 834 | ||
840 | Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); | 835 | Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); |
@@ -860,12 +855,8 @@ local void send_all_trees(s, lcodes, dcodes, blcodes) | |||
860 | /* =========================================================================== | 855 | /* =========================================================================== |
861 | * Send a stored block | 856 | * Send a stored block |
862 | */ | 857 | */ |
863 | void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | 858 | void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, |
864 | deflate_state *s; | 859 | ulg stored_len, int last) { |
865 | charf *buf; /* input block */ | ||
866 | ulg stored_len; /* length of input block */ | ||
867 | int last; /* one if this is the last block for a file */ | ||
868 | { | ||
869 | send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ | 860 | send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ |
870 | bi_windup(s); /* align on byte boundary */ | 861 | bi_windup(s); /* align on byte boundary */ |
871 | put_short(s, (ush)stored_len); | 862 | put_short(s, (ush)stored_len); |
@@ -884,9 +875,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |||
884 | /* =========================================================================== | 875 | /* =========================================================================== |
885 | * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) | 876 | * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) |
886 | */ | 877 | */ |
887 | void ZLIB_INTERNAL _tr_flush_bits(s) | 878 | void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { |
888 | deflate_state *s; | ||
889 | { | ||
890 | bi_flush(s); | 879 | bi_flush(s); |
891 | } | 880 | } |
892 | 881 | ||
@@ -894,9 +883,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s) | |||
894 | * Send one empty static block to give enough lookahead for inflate. | 883 | * Send one empty static block to give enough lookahead for inflate. |
895 | * This takes 10 bits, of which 7 may remain in the bit buffer. | 884 | * This takes 10 bits, of which 7 may remain in the bit buffer. |
896 | */ | 885 | */ |
897 | void ZLIB_INTERNAL _tr_align(s) | 886 | void ZLIB_INTERNAL _tr_align(deflate_state *s) { |
898 | deflate_state *s; | ||
899 | { | ||
900 | send_bits(s, STATIC_TREES<<1, 3); | 887 | send_bits(s, STATIC_TREES<<1, 3); |
901 | send_code(s, END_BLOCK, static_ltree); | 888 | send_code(s, END_BLOCK, static_ltree); |
902 | #ifdef ZLIB_DEBUG | 889 | #ifdef ZLIB_DEBUG |
@@ -906,15 +893,98 @@ void ZLIB_INTERNAL _tr_align(s) | |||
906 | } | 893 | } |
907 | 894 | ||
908 | /* =========================================================================== | 895 | /* =========================================================================== |
896 | * Send the block data compressed using the given Huffman trees | ||
897 | */ | ||
898 | local void compress_block(deflate_state *s, const ct_data *ltree, | ||
899 | const ct_data *dtree) { | ||
900 | unsigned dist; /* distance of matched string */ | ||
901 | int lc; /* match length or unmatched char (if dist == 0) */ | ||
902 | unsigned sx = 0; /* running index in sym_buf */ | ||
903 | unsigned code; /* the code to send */ | ||
904 | int extra; /* number of extra bits to send */ | ||
905 | |||
906 | if (s->sym_next != 0) do { | ||
907 | dist = s->sym_buf[sx++] & 0xff; | ||
908 | dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; | ||
909 | lc = s->sym_buf[sx++]; | ||
910 | if (dist == 0) { | ||
911 | send_code(s, lc, ltree); /* send a literal byte */ | ||
912 | Tracecv(isgraph(lc), (stderr," '%c' ", lc)); | ||
913 | } else { | ||
914 | /* Here, lc is the match length - MIN_MATCH */ | ||
915 | code = _length_code[lc]; | ||
916 | send_code(s, code + LITERALS + 1, ltree); /* send length code */ | ||
917 | extra = extra_lbits[code]; | ||
918 | if (extra != 0) { | ||
919 | lc -= base_length[code]; | ||
920 | send_bits(s, lc, extra); /* send the extra length bits */ | ||
921 | } | ||
922 | dist--; /* dist is now the match distance - 1 */ | ||
923 | code = d_code(dist); | ||
924 | Assert (code < D_CODES, "bad d_code"); | ||
925 | |||
926 | send_code(s, code, dtree); /* send the distance code */ | ||
927 | extra = extra_dbits[code]; | ||
928 | if (extra != 0) { | ||
929 | dist -= (unsigned)base_dist[code]; | ||
930 | send_bits(s, dist, extra); /* send the extra distance bits */ | ||
931 | } | ||
932 | } /* literal or match pair ? */ | ||
933 | |||
934 | /* Check that the overlay between pending_buf and sym_buf is ok: */ | ||
935 | Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); | ||
936 | |||
937 | } while (sx < s->sym_next); | ||
938 | |||
939 | send_code(s, END_BLOCK, ltree); | ||
940 | } | ||
941 | |||
942 | /* =========================================================================== | ||
943 | * Check if the data type is TEXT or BINARY, using the following algorithm: | ||
944 | * - TEXT if the two conditions below are satisfied: | ||
945 | * a) There are no non-portable control characters belonging to the | ||
946 | * "block list" (0..6, 14..25, 28..31). | ||
947 | * b) There is at least one printable character belonging to the | ||
948 | * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). | ||
949 | * - BINARY otherwise. | ||
950 | * - The following partially-portable control characters form a | ||
951 | * "gray list" that is ignored in this detection algorithm: | ||
952 | * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). | ||
953 | * IN assertion: the fields Freq of dyn_ltree are set. | ||
954 | */ | ||
955 | local int detect_data_type(deflate_state *s) { | ||
956 | /* block_mask is the bit mask of block-listed bytes | ||
957 | * set bits 0..6, 14..25, and 28..31 | ||
958 | * 0xf3ffc07f = binary 11110011111111111100000001111111 | ||
959 | */ | ||
960 | unsigned long block_mask = 0xf3ffc07fUL; | ||
961 | int n; | ||
962 | |||
963 | /* Check for non-textual ("block-listed") bytes. */ | ||
964 | for (n = 0; n <= 31; n++, block_mask >>= 1) | ||
965 | if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) | ||
966 | return Z_BINARY; | ||
967 | |||
968 | /* Check for textual ("allow-listed") bytes. */ | ||
969 | if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 | ||
970 | || s->dyn_ltree[13].Freq != 0) | ||
971 | return Z_TEXT; | ||
972 | for (n = 32; n < LITERALS; n++) | ||
973 | if (s->dyn_ltree[n].Freq != 0) | ||
974 | return Z_TEXT; | ||
975 | |||
976 | /* There are no "block-listed" or "allow-listed" bytes: | ||
977 | * this stream either is empty or has tolerated ("gray-listed") bytes only. | ||
978 | */ | ||
979 | return Z_BINARY; | ||
980 | } | ||
981 | |||
982 | /* =========================================================================== | ||
909 | * Determine the best encoding for the current block: dynamic trees, static | 983 | * Determine the best encoding for the current block: dynamic trees, static |
910 | * trees or store, and write out the encoded block. | 984 | * trees or store, and write out the encoded block. |
911 | */ | 985 | */ |
912 | void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | 986 | void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, |
913 | deflate_state *s; | 987 | ulg stored_len, int last) { |
914 | charf *buf; /* input block, or NULL if too old */ | ||
915 | ulg stored_len; /* length of input block */ | ||
916 | int last; /* one if this is the last block for a file */ | ||
917 | { | ||
918 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ | 988 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ |
919 | int max_blindex = 0; /* index of last bit length code of non zero freq */ | 989 | int max_blindex = 0; /* index of last bit length code of non zero freq */ |
920 | 990 | ||
@@ -1011,11 +1081,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | |||
1011 | * Save the match info and tally the frequency counts. Return true if | 1081 | * Save the match info and tally the frequency counts. Return true if |
1012 | * the current block must be flushed. | 1082 | * the current block must be flushed. |
1013 | */ | 1083 | */ |
1014 | int ZLIB_INTERNAL _tr_tally(s, dist, lc) | 1084 | int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { |
1015 | deflate_state *s; | ||
1016 | unsigned dist; /* distance of matched string */ | ||
1017 | unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ | ||
1018 | { | ||
1019 | s->sym_buf[s->sym_next++] = (uch)dist; | 1085 | s->sym_buf[s->sym_next++] = (uch)dist; |
1020 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); | 1086 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); |
1021 | s->sym_buf[s->sym_next++] = (uch)lc; | 1087 | s->sym_buf[s->sym_next++] = (uch)lc; |
@@ -1035,147 +1101,3 @@ int ZLIB_INTERNAL _tr_tally(s, dist, lc) | |||
1035 | } | 1101 | } |
1036 | return (s->sym_next == s->sym_end); | 1102 | return (s->sym_next == s->sym_end); |
1037 | } | 1103 | } |
1038 | |||
1039 | /* =========================================================================== | ||
1040 | * Send the block data compressed using the given Huffman trees | ||
1041 | */ | ||
1042 | local void compress_block(s, ltree, dtree) | ||
1043 | deflate_state *s; | ||
1044 | const ct_data *ltree; /* literal tree */ | ||
1045 | const ct_data *dtree; /* distance tree */ | ||
1046 | { | ||
1047 | unsigned dist; /* distance of matched string */ | ||
1048 | int lc; /* match length or unmatched char (if dist == 0) */ | ||
1049 | unsigned sx = 0; /* running index in sym_buf */ | ||
1050 | unsigned code; /* the code to send */ | ||
1051 | int extra; /* number of extra bits to send */ | ||
1052 | |||
1053 | if (s->sym_next != 0) do { | ||
1054 | dist = s->sym_buf[sx++] & 0xff; | ||
1055 | dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; | ||
1056 | lc = s->sym_buf[sx++]; | ||
1057 | if (dist == 0) { | ||
1058 | send_code(s, lc, ltree); /* send a literal byte */ | ||
1059 | Tracecv(isgraph(lc), (stderr," '%c' ", lc)); | ||
1060 | } else { | ||
1061 | /* Here, lc is the match length - MIN_MATCH */ | ||
1062 | code = _length_code[lc]; | ||
1063 | send_code(s, code + LITERALS + 1, ltree); /* send length code */ | ||
1064 | extra = extra_lbits[code]; | ||
1065 | if (extra != 0) { | ||
1066 | lc -= base_length[code]; | ||
1067 | send_bits(s, lc, extra); /* send the extra length bits */ | ||
1068 | } | ||
1069 | dist--; /* dist is now the match distance - 1 */ | ||
1070 | code = d_code(dist); | ||
1071 | Assert (code < D_CODES, "bad d_code"); | ||
1072 | |||
1073 | send_code(s, code, dtree); /* send the distance code */ | ||
1074 | extra = extra_dbits[code]; | ||
1075 | if (extra != 0) { | ||
1076 | dist -= (unsigned)base_dist[code]; | ||
1077 | send_bits(s, dist, extra); /* send the extra distance bits */ | ||
1078 | } | ||
1079 | } /* literal or match pair ? */ | ||
1080 | |||
1081 | /* Check that the overlay between pending_buf and sym_buf is ok: */ | ||
1082 | Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); | ||
1083 | |||
1084 | } while (sx < s->sym_next); | ||
1085 | |||
1086 | send_code(s, END_BLOCK, ltree); | ||
1087 | } | ||
1088 | |||
1089 | /* =========================================================================== | ||
1090 | * Check if the data type is TEXT or BINARY, using the following algorithm: | ||
1091 | * - TEXT if the two conditions below are satisfied: | ||
1092 | * a) There are no non-portable control characters belonging to the | ||
1093 | * "block list" (0..6, 14..25, 28..31). | ||
1094 | * b) There is at least one printable character belonging to the | ||
1095 | * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). | ||
1096 | * - BINARY otherwise. | ||
1097 | * - The following partially-portable control characters form a | ||
1098 | * "gray list" that is ignored in this detection algorithm: | ||
1099 | * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). | ||
1100 | * IN assertion: the fields Freq of dyn_ltree are set. | ||
1101 | */ | ||
1102 | local int detect_data_type(s) | ||
1103 | deflate_state *s; | ||
1104 | { | ||
1105 | /* block_mask is the bit mask of block-listed bytes | ||
1106 | * set bits 0..6, 14..25, and 28..31 | ||
1107 | * 0xf3ffc07f = binary 11110011111111111100000001111111 | ||
1108 | */ | ||
1109 | unsigned long block_mask = 0xf3ffc07fUL; | ||
1110 | int n; | ||
1111 | |||
1112 | /* Check for non-textual ("block-listed") bytes. */ | ||
1113 | for (n = 0; n <= 31; n++, block_mask >>= 1) | ||
1114 | if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) | ||
1115 | return Z_BINARY; | ||
1116 | |||
1117 | /* Check for textual ("allow-listed") bytes. */ | ||
1118 | if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 | ||
1119 | || s->dyn_ltree[13].Freq != 0) | ||
1120 | return Z_TEXT; | ||
1121 | for (n = 32; n < LITERALS; n++) | ||
1122 | if (s->dyn_ltree[n].Freq != 0) | ||
1123 | return Z_TEXT; | ||
1124 | |||
1125 | /* There are no "block-listed" or "allow-listed" bytes: | ||
1126 | * this stream either is empty or has tolerated ("gray-listed") bytes only. | ||
1127 | */ | ||
1128 | return Z_BINARY; | ||
1129 | } | ||
1130 | |||
1131 | /* =========================================================================== | ||
1132 | * Reverse the first len bits of a code, using straightforward code (a faster | ||
1133 | * method would use a table) | ||
1134 | * IN assertion: 1 <= len <= 15 | ||
1135 | */ | ||
1136 | local unsigned bi_reverse(code, len) | ||
1137 | unsigned code; /* the value to invert */ | ||
1138 | int len; /* its bit length */ | ||
1139 | { | ||
1140 | register unsigned res = 0; | ||
1141 | do { | ||
1142 | res |= code & 1; | ||
1143 | code >>= 1, res <<= 1; | ||
1144 | } while (--len > 0); | ||
1145 | return res >> 1; | ||
1146 | } | ||
1147 | |||
1148 | /* =========================================================================== | ||
1149 | * Flush the bit buffer, keeping at most 7 bits in it. | ||
1150 | */ | ||
1151 | local void bi_flush(s) | ||
1152 | deflate_state *s; | ||
1153 | { | ||
1154 | if (s->bi_valid == 16) { | ||
1155 | put_short(s, s->bi_buf); | ||
1156 | s->bi_buf = 0; | ||
1157 | s->bi_valid = 0; | ||
1158 | } else if (s->bi_valid >= 8) { | ||
1159 | put_byte(s, (Byte)s->bi_buf); | ||
1160 | s->bi_buf >>= 8; | ||
1161 | s->bi_valid -= 8; | ||
1162 | } | ||
1163 | } | ||
1164 | |||
1165 | /* =========================================================================== | ||
1166 | * Flush the bit buffer and align the output on a byte boundary | ||
1167 | */ | ||
1168 | local void bi_windup(s) | ||
1169 | deflate_state *s; | ||
1170 | { | ||
1171 | if (s->bi_valid > 8) { | ||
1172 | put_short(s, s->bi_buf); | ||
1173 | } else if (s->bi_valid > 0) { | ||
1174 | put_byte(s, (Byte)s->bi_buf); | ||
1175 | } | ||
1176 | s->bi_buf = 0; | ||
1177 | s->bi_valid = 0; | ||
1178 | #ifdef ZLIB_DEBUG | ||
1179 | s->bits_sent = (s->bits_sent + 7) & ~7; | ||
1180 | #endif | ||
1181 | } | ||
@@ -24,12 +24,8 @@ | |||
24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is | 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is |
25 | an incomplete zlib stream. | 25 | an incomplete zlib stream. |
26 | */ | 26 | */ |
27 | int ZEXPORT uncompress2(dest, destLen, source, sourceLen) | 27 | int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, |
28 | Bytef *dest; | 28 | uLong *sourceLen) { |
29 | uLongf *destLen; | ||
30 | const Bytef *source; | ||
31 | uLong *sourceLen; | ||
32 | { | ||
33 | z_stream stream; | 29 | z_stream stream; |
34 | int err; | 30 | int err; |
35 | const uInt max = (uInt)-1; | 31 | const uInt max = (uInt)-1; |
@@ -83,11 +79,7 @@ int ZEXPORT uncompress2(dest, destLen, source, sourceLen) | |||
83 | err; | 79 | err; |
84 | } | 80 | } |
85 | 81 | ||
86 | int ZEXPORT uncompress(dest, destLen, source, sourceLen) | 82 | int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, |
87 | Bytef *dest; | 83 | uLong sourceLen) { |
88 | uLongf *destLen; | ||
89 | const Bytef *source; | ||
90 | uLong sourceLen; | ||
91 | { | ||
92 | return uncompress2(dest, destLen, source, &sourceLen); | 84 | return uncompress2(dest, destLen, source, &sourceLen); |
93 | } | 85 | } |
@@ -78,8 +78,8 @@ extern "C" { | |||
78 | even in the case of corrupted input. | 78 | even in the case of corrupted input. |
79 | */ | 79 | */ |
80 | 80 | ||
81 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); | 81 | typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); |
82 | typedef void (*free_func) OF((voidpf opaque, voidpf address)); | 82 | typedef void (*free_func)(voidpf opaque, voidpf address); |
83 | 83 | ||
84 | struct internal_state; | 84 | struct internal_state; |
85 | 85 | ||
@@ -217,7 +217,7 @@ typedef gz_header FAR *gz_headerp; | |||
217 | 217 | ||
218 | /* basic functions */ | 218 | /* basic functions */ |
219 | 219 | ||
220 | ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | 220 | ZEXTERN const char * ZEXPORT zlibVersion(void); |
221 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. | 221 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. |
222 | If the first character differs, the library code actually used is not | 222 | If the first character differs, the library code actually used is not |
223 | compatible with the zlib.h header file used by the application. This check | 223 | compatible with the zlib.h header file used by the application. This check |
@@ -225,7 +225,7 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | |||
225 | */ | 225 | */ |
226 | 226 | ||
227 | /* | 227 | /* |
228 | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); | 228 | ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); |
229 | 229 | ||
230 | Initializes the internal stream state for compression. The fields | 230 | Initializes the internal stream state for compression. The fields |
231 | zalloc, zfree and opaque must be initialized before by the caller. If | 231 | zalloc, zfree and opaque must be initialized before by the caller. If |
@@ -247,7 +247,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); | |||
247 | */ | 247 | */ |
248 | 248 | ||
249 | 249 | ||
250 | ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | 250 | ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); |
251 | /* | 251 | /* |
252 | deflate compresses as much data as possible, and stops when the input | 252 | deflate compresses as much data as possible, and stops when the input |
253 | buffer becomes empty or the output buffer becomes full. It may introduce | 253 | buffer becomes empty or the output buffer becomes full. It may introduce |
@@ -360,7 +360,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | |||
360 | */ | 360 | */ |
361 | 361 | ||
362 | 362 | ||
363 | ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | 363 | ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); |
364 | /* | 364 | /* |
365 | All dynamically allocated data structures for this stream are freed. | 365 | All dynamically allocated data structures for this stream are freed. |
366 | This function discards any unprocessed input and does not flush any pending | 366 | This function discards any unprocessed input and does not flush any pending |
@@ -375,7 +375,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | |||
375 | 375 | ||
376 | 376 | ||
377 | /* | 377 | /* |
378 | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | 378 | ZEXTERN int ZEXPORT inflateInit(z_streamp strm); |
379 | 379 | ||
380 | Initializes the internal stream state for decompression. The fields | 380 | Initializes the internal stream state for decompression. The fields |
381 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by | 381 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by |
@@ -397,7 +397,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | |||
397 | */ | 397 | */ |
398 | 398 | ||
399 | 399 | ||
400 | ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | 400 | ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); |
401 | /* | 401 | /* |
402 | inflate decompresses as much data as possible, and stops when the input | 402 | inflate decompresses as much data as possible, and stops when the input |
403 | buffer becomes empty or the output buffer becomes full. It may introduce | 403 | buffer becomes empty or the output buffer becomes full. It may introduce |
@@ -517,7 +517,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | |||
517 | */ | 517 | */ |
518 | 518 | ||
519 | 519 | ||
520 | ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | 520 | ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); |
521 | /* | 521 | /* |
522 | All dynamically allocated data structures for this stream are freed. | 522 | All dynamically allocated data structures for this stream are freed. |
523 | This function discards any unprocessed input and does not flush any pending | 523 | This function discards any unprocessed input and does not flush any pending |
@@ -535,12 +535,12 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | |||
535 | */ | 535 | */ |
536 | 536 | ||
537 | /* | 537 | /* |
538 | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | 538 | ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, |
539 | int level, | 539 | int level, |
540 | int method, | 540 | int method, |
541 | int windowBits, | 541 | int windowBits, |
542 | int memLevel, | 542 | int memLevel, |
543 | int strategy)); | 543 | int strategy); |
544 | 544 | ||
545 | This is another version of deflateInit with more compression options. The | 545 | This is another version of deflateInit with more compression options. The |
546 | fields zalloc, zfree and opaque must be initialized before by the caller. | 546 | fields zalloc, zfree and opaque must be initialized before by the caller. |
@@ -607,9 +607,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | |||
607 | compression: this will be done by deflate(). | 607 | compression: this will be done by deflate(). |
608 | */ | 608 | */ |
609 | 609 | ||
610 | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, | 610 | ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, |
611 | const Bytef *dictionary, | 611 | const Bytef *dictionary, |
612 | uInt dictLength)); | 612 | uInt dictLength); |
613 | /* | 613 | /* |
614 | Initializes the compression dictionary from the given byte sequence | 614 | Initializes the compression dictionary from the given byte sequence |
615 | without producing any compressed output. When using the zlib format, this | 615 | without producing any compressed output. When using the zlib format, this |
@@ -651,9 +651,9 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, | |||
651 | not perform any compression: this will be done by deflate(). | 651 | not perform any compression: this will be done by deflate(). |
652 | */ | 652 | */ |
653 | 653 | ||
654 | ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, | 654 | ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, |
655 | Bytef *dictionary, | 655 | Bytef *dictionary, |
656 | uInt *dictLength)); | 656 | uInt *dictLength); |
657 | /* | 657 | /* |
658 | Returns the sliding dictionary being maintained by deflate. dictLength is | 658 | Returns the sliding dictionary being maintained by deflate. dictLength is |
659 | set to the number of bytes in the dictionary, and that many bytes are copied | 659 | set to the number of bytes in the dictionary, and that many bytes are copied |
@@ -673,8 +673,8 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, | |||
673 | stream state is inconsistent. | 673 | stream state is inconsistent. |
674 | */ | 674 | */ |
675 | 675 | ||
676 | ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, | 676 | ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, |
677 | z_streamp source)); | 677 | z_streamp source); |
678 | /* | 678 | /* |
679 | Sets the destination stream as a complete copy of the source stream. | 679 | Sets the destination stream as a complete copy of the source stream. |
680 | 680 | ||
@@ -691,7 +691,7 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, | |||
691 | destination. | 691 | destination. |
692 | */ | 692 | */ |
693 | 693 | ||
694 | ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); | 694 | ZEXTERN int ZEXPORT deflateReset(z_streamp strm); |
695 | /* | 695 | /* |
696 | This function is equivalent to deflateEnd followed by deflateInit, but | 696 | This function is equivalent to deflateEnd followed by deflateInit, but |
697 | does not free and reallocate the internal compression state. The stream | 697 | does not free and reallocate the internal compression state. The stream |
@@ -702,9 +702,9 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); | |||
702 | stream state was inconsistent (such as zalloc or state being Z_NULL). | 702 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
703 | */ | 703 | */ |
704 | 704 | ||
705 | ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, | 705 | ZEXTERN int ZEXPORT deflateParams(z_streamp strm, |
706 | int level, | 706 | int level, |
707 | int strategy)); | 707 | int strategy); |
708 | /* | 708 | /* |
709 | Dynamically update the compression level and compression strategy. The | 709 | Dynamically update the compression level and compression strategy. The |
710 | interpretation of level and strategy is as in deflateInit2(). This can be | 710 | interpretation of level and strategy is as in deflateInit2(). This can be |
@@ -740,11 +740,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, | |||
740 | retried with more output space. | 740 | retried with more output space. |
741 | */ | 741 | */ |
742 | 742 | ||
743 | ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, | 743 | ZEXTERN int ZEXPORT deflateTune(z_streamp strm, |
744 | int good_length, | 744 | int good_length, |
745 | int max_lazy, | 745 | int max_lazy, |
746 | int nice_length, | 746 | int nice_length, |
747 | int max_chain)); | 747 | int max_chain); |
748 | /* | 748 | /* |
749 | Fine tune deflate's internal compression parameters. This should only be | 749 | Fine tune deflate's internal compression parameters. This should only be |
750 | used by someone who understands the algorithm used by zlib's deflate for | 750 | used by someone who understands the algorithm used by zlib's deflate for |
@@ -757,8 +757,8 @@ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, | |||
757 | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. | 757 | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
758 | */ | 758 | */ |
759 | 759 | ||
760 | ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, | 760 | ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, |
761 | uLong sourceLen)); | 761 | uLong sourceLen); |
762 | /* | 762 | /* |
763 | deflateBound() returns an upper bound on the compressed size after | 763 | deflateBound() returns an upper bound on the compressed size after |
764 | deflation of sourceLen bytes. It must be called after deflateInit() or | 764 | deflation of sourceLen bytes. It must be called after deflateInit() or |
@@ -772,9 +772,9 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, | |||
772 | than Z_FINISH or Z_NO_FLUSH are used. | 772 | than Z_FINISH or Z_NO_FLUSH are used. |
773 | */ | 773 | */ |
774 | 774 | ||
775 | ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, | 775 | ZEXTERN int ZEXPORT deflatePending(z_streamp strm, |
776 | unsigned *pending, | 776 | unsigned *pending, |
777 | int *bits)); | 777 | int *bits); |
778 | /* | 778 | /* |
779 | deflatePending() returns the number of bytes and bits of output that have | 779 | deflatePending() returns the number of bytes and bits of output that have |
780 | been generated, but not yet provided in the available output. The bytes not | 780 | been generated, but not yet provided in the available output. The bytes not |
@@ -787,9 +787,9 @@ ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, | |||
787 | stream state was inconsistent. | 787 | stream state was inconsistent. |
788 | */ | 788 | */ |
789 | 789 | ||
790 | ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, | 790 | ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, |
791 | int bits, | 791 | int bits, |
792 | int value)); | 792 | int value); |
793 | /* | 793 | /* |
794 | deflatePrime() inserts bits in the deflate output stream. The intent | 794 | deflatePrime() inserts bits in the deflate output stream. The intent |
795 | is that this function is used to start off the deflate output with the bits | 795 | is that this function is used to start off the deflate output with the bits |
@@ -804,8 +804,8 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, | |||
804 | source stream state was inconsistent. | 804 | source stream state was inconsistent. |
805 | */ | 805 | */ |
806 | 806 | ||
807 | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, | 807 | ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, |
808 | gz_headerp head)); | 808 | gz_headerp head); |
809 | /* | 809 | /* |
810 | deflateSetHeader() provides gzip header information for when a gzip | 810 | deflateSetHeader() provides gzip header information for when a gzip |
811 | stream is requested by deflateInit2(). deflateSetHeader() may be called | 811 | stream is requested by deflateInit2(). deflateSetHeader() may be called |
@@ -829,8 +829,8 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, | |||
829 | */ | 829 | */ |
830 | 830 | ||
831 | /* | 831 | /* |
832 | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | 832 | ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, |
833 | int windowBits)); | 833 | int windowBits); |
834 | 834 | ||
835 | This is another version of inflateInit with an extra parameter. The | 835 | This is another version of inflateInit with an extra parameter. The |
836 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized | 836 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized |
@@ -883,9 +883,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |||
883 | deferred until inflate() is called. | 883 | deferred until inflate() is called. |
884 | */ | 884 | */ |
885 | 885 | ||
886 | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | 886 | ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, |
887 | const Bytef *dictionary, | 887 | const Bytef *dictionary, |
888 | uInt dictLength)); | 888 | uInt dictLength); |
889 | /* | 889 | /* |
890 | Initializes the decompression dictionary from the given uncompressed byte | 890 | Initializes the decompression dictionary from the given uncompressed byte |
891 | sequence. This function must be called immediately after a call of inflate, | 891 | sequence. This function must be called immediately after a call of inflate, |
@@ -906,9 +906,9 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | |||
906 | inflate(). | 906 | inflate(). |
907 | */ | 907 | */ |
908 | 908 | ||
909 | ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, | 909 | ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, |
910 | Bytef *dictionary, | 910 | Bytef *dictionary, |
911 | uInt *dictLength)); | 911 | uInt *dictLength); |
912 | /* | 912 | /* |
913 | Returns the sliding dictionary being maintained by inflate. dictLength is | 913 | Returns the sliding dictionary being maintained by inflate. dictLength is |
914 | set to the number of bytes in the dictionary, and that many bytes are copied | 914 | set to the number of bytes in the dictionary, and that many bytes are copied |
@@ -921,7 +921,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, | |||
921 | stream state is inconsistent. | 921 | stream state is inconsistent. |
922 | */ | 922 | */ |
923 | 923 | ||
924 | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | 924 | ZEXTERN int ZEXPORT inflateSync(z_streamp strm); |
925 | /* | 925 | /* |
926 | Skips invalid compressed data until a possible full flush point (see above | 926 | Skips invalid compressed data until a possible full flush point (see above |
927 | for the description of deflate with Z_FULL_FLUSH) can be found, or until all | 927 | for the description of deflate with Z_FULL_FLUSH) can be found, or until all |
@@ -940,8 +940,8 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | |||
940 | input each time, until success or end of the input data. | 940 | input each time, until success or end of the input data. |
941 | */ | 941 | */ |
942 | 942 | ||
943 | ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, | 943 | ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, |
944 | z_streamp source)); | 944 | z_streamp source); |
945 | /* | 945 | /* |
946 | Sets the destination stream as a complete copy of the source stream. | 946 | Sets the destination stream as a complete copy of the source stream. |
947 | 947 | ||
@@ -956,7 +956,7 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, | |||
956 | destination. | 956 | destination. |
957 | */ | 957 | */ |
958 | 958 | ||
959 | ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); | 959 | ZEXTERN int ZEXPORT inflateReset(z_streamp strm); |
960 | /* | 960 | /* |
961 | This function is equivalent to inflateEnd followed by inflateInit, | 961 | This function is equivalent to inflateEnd followed by inflateInit, |
962 | but does not free and reallocate the internal decompression state. The | 962 | but does not free and reallocate the internal decompression state. The |
@@ -966,8 +966,8 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); | |||
966 | stream state was inconsistent (such as zalloc or state being Z_NULL). | 966 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
967 | */ | 967 | */ |
968 | 968 | ||
969 | ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, | 969 | ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, |
970 | int windowBits)); | 970 | int windowBits); |
971 | /* | 971 | /* |
972 | This function is the same as inflateReset, but it also permits changing | 972 | This function is the same as inflateReset, but it also permits changing |
973 | the wrap and window size requests. The windowBits parameter is interpreted | 973 | the wrap and window size requests. The windowBits parameter is interpreted |
@@ -980,9 +980,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, | |||
980 | the windowBits parameter is invalid. | 980 | the windowBits parameter is invalid. |
981 | */ | 981 | */ |
982 | 982 | ||
983 | ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, | 983 | ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, |
984 | int bits, | 984 | int bits, |
985 | int value)); | 985 | int value); |
986 | /* | 986 | /* |
987 | This function inserts bits in the inflate input stream. The intent is | 987 | This function inserts bits in the inflate input stream. The intent is |
988 | that this function is used to start inflating at a bit position in the | 988 | that this function is used to start inflating at a bit position in the |
@@ -1001,7 +1001,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, | |||
1001 | stream state was inconsistent. | 1001 | stream state was inconsistent. |
1002 | */ | 1002 | */ |
1003 | 1003 | ||
1004 | ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); | 1004 | ZEXTERN long ZEXPORT inflateMark(z_streamp strm); |
1005 | /* | 1005 | /* |
1006 | This function returns two values, one in the lower 16 bits of the return | 1006 | This function returns two values, one in the lower 16 bits of the return |
1007 | value, and the other in the remaining upper bits, obtained by shifting the | 1007 | value, and the other in the remaining upper bits, obtained by shifting the |
@@ -1029,8 +1029,8 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); | |||
1029 | source stream state was inconsistent. | 1029 | source stream state was inconsistent. |
1030 | */ | 1030 | */ |
1031 | 1031 | ||
1032 | ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, | 1032 | ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, |
1033 | gz_headerp head)); | 1033 | gz_headerp head); |
1034 | /* | 1034 | /* |
1035 | inflateGetHeader() requests that gzip header information be stored in the | 1035 | inflateGetHeader() requests that gzip header information be stored in the |
1036 | provided gz_header structure. inflateGetHeader() may be called after | 1036 | provided gz_header structure. inflateGetHeader() may be called after |
@@ -1070,8 +1070,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, | |||
1070 | */ | 1070 | */ |
1071 | 1071 | ||
1072 | /* | 1072 | /* |
1073 | ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, | 1073 | ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, |
1074 | unsigned char FAR *window)); | 1074 | unsigned char FAR *window); |
1075 | 1075 | ||
1076 | Initialize the internal stream state for decompression using inflateBack() | 1076 | Initialize the internal stream state for decompression using inflateBack() |
1077 | calls. The fields zalloc, zfree and opaque in strm must be initialized | 1077 | calls. The fields zalloc, zfree and opaque in strm must be initialized |
@@ -1091,13 +1091,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, | |||
1091 | the version of the header file. | 1091 | the version of the header file. |
1092 | */ | 1092 | */ |
1093 | 1093 | ||
1094 | typedef unsigned (*in_func) OF((void FAR *, | 1094 | typedef unsigned (*in_func)(void FAR *, |
1095 | z_const unsigned char FAR * FAR *)); | 1095 | z_const unsigned char FAR * FAR *); |
1096 | typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); | 1096 | typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); |
1097 | 1097 | ||
1098 | ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, | 1098 | ZEXTERN int ZEXPORT inflateBack(z_streamp strm, |
1099 | in_func in, void FAR *in_desc, | 1099 | in_func in, void FAR *in_desc, |
1100 | out_func out, void FAR *out_desc)); | 1100 | out_func out, void FAR *out_desc); |
1101 | /* | 1101 | /* |
1102 | inflateBack() does a raw inflate with a single call using a call-back | 1102 | inflateBack() does a raw inflate with a single call using a call-back |
1103 | interface for input and output. This is potentially more efficient than | 1103 | interface for input and output. This is potentially more efficient than |
@@ -1165,7 +1165,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, | |||
1165 | cannot return Z_OK. | 1165 | cannot return Z_OK. |
1166 | */ | 1166 | */ |
1167 | 1167 | ||
1168 | ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); | 1168 | ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); |
1169 | /* | 1169 | /* |
1170 | All memory allocated by inflateBackInit() is freed. | 1170 | All memory allocated by inflateBackInit() is freed. |
1171 | 1171 | ||
@@ -1173,7 +1173,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); | |||
1173 | state was inconsistent. | 1173 | state was inconsistent. |
1174 | */ | 1174 | */ |
1175 | 1175 | ||
1176 | ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | 1176 | ZEXTERN uLong ZEXPORT zlibCompileFlags(void); |
1177 | /* Return flags indicating compile-time options. | 1177 | /* Return flags indicating compile-time options. |
1178 | 1178 | ||
1179 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: | 1179 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: |
@@ -1226,8 +1226,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | |||
1226 | you need special options. | 1226 | you need special options. |
1227 | */ | 1227 | */ |
1228 | 1228 | ||
1229 | ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, | 1229 | ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, |
1230 | const Bytef *source, uLong sourceLen)); | 1230 | const Bytef *source, uLong sourceLen); |
1231 | /* | 1231 | /* |
1232 | Compresses the source buffer into the destination buffer. sourceLen is | 1232 | Compresses the source buffer into the destination buffer. sourceLen is |
1233 | the byte length of the source buffer. Upon entry, destLen is the total size | 1233 | the byte length of the source buffer. Upon entry, destLen is the total size |
@@ -1241,9 +1241,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, | |||
1241 | buffer. | 1241 | buffer. |
1242 | */ | 1242 | */ |
1243 | 1243 | ||
1244 | ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, | 1244 | ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, |
1245 | const Bytef *source, uLong sourceLen, | 1245 | const Bytef *source, uLong sourceLen, |
1246 | int level)); | 1246 | int level); |
1247 | /* | 1247 | /* |
1248 | Compresses the source buffer into the destination buffer. The level | 1248 | Compresses the source buffer into the destination buffer. The level |
1249 | parameter has the same meaning as in deflateInit. sourceLen is the byte | 1249 | parameter has the same meaning as in deflateInit. sourceLen is the byte |
@@ -1257,15 +1257,15 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, | |||
1257 | Z_STREAM_ERROR if the level parameter is invalid. | 1257 | Z_STREAM_ERROR if the level parameter is invalid. |
1258 | */ | 1258 | */ |
1259 | 1259 | ||
1260 | ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); | 1260 | ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); |
1261 | /* | 1261 | /* |
1262 | compressBound() returns an upper bound on the compressed size after | 1262 | compressBound() returns an upper bound on the compressed size after |
1263 | compress() or compress2() on sourceLen bytes. It would be used before a | 1263 | compress() or compress2() on sourceLen bytes. It would be used before a |
1264 | compress() or compress2() call to allocate the destination buffer. | 1264 | compress() or compress2() call to allocate the destination buffer. |
1265 | */ | 1265 | */ |
1266 | 1266 | ||
1267 | ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, | 1267 | ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, |
1268 | const Bytef *source, uLong sourceLen)); | 1268 | const Bytef *source, uLong sourceLen); |
1269 | /* | 1269 | /* |
1270 | Decompresses the source buffer into the destination buffer. sourceLen is | 1270 | Decompresses the source buffer into the destination buffer. sourceLen is |
1271 | the byte length of the source buffer. Upon entry, destLen is the total size | 1271 | the byte length of the source buffer. Upon entry, destLen is the total size |
@@ -1282,8 +1282,8 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, | |||
1282 | buffer with the uncompressed data up to that point. | 1282 | buffer with the uncompressed data up to that point. |
1283 | */ | 1283 | */ |
1284 | 1284 | ||
1285 | ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, | 1285 | ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, |
1286 | const Bytef *source, uLong *sourceLen)); | 1286 | const Bytef *source, uLong *sourceLen); |
1287 | /* | 1287 | /* |
1288 | Same as uncompress, except that sourceLen is a pointer, where the | 1288 | Same as uncompress, except that sourceLen is a pointer, where the |
1289 | length of the source is *sourceLen. On return, *sourceLen is the number of | 1289 | length of the source is *sourceLen. On return, *sourceLen is the number of |
@@ -1302,7 +1302,7 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, | |||
1302 | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ | 1302 | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ |
1303 | 1303 | ||
1304 | /* | 1304 | /* |
1305 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | 1305 | ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); |
1306 | 1306 | ||
1307 | Open the gzip (.gz) file at path for reading and decompressing, or | 1307 | Open the gzip (.gz) file at path for reading and decompressing, or |
1308 | compressing and writing. The mode parameter is as in fopen ("rb" or "wb") | 1308 | compressing and writing. The mode parameter is as in fopen ("rb" or "wb") |
@@ -1339,7 +1339,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | |||
1339 | file could not be opened. | 1339 | file could not be opened. |
1340 | */ | 1340 | */ |
1341 | 1341 | ||
1342 | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | 1342 | ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); |
1343 | /* | 1343 | /* |
1344 | Associate a gzFile with the file descriptor fd. File descriptors are | 1344 | Associate a gzFile with the file descriptor fd. File descriptors are |
1345 | obtained from calls like open, dup, creat, pipe or fileno (if the file has | 1345 | obtained from calls like open, dup, creat, pipe or fileno (if the file has |
@@ -1362,7 +1362,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | |||
1362 | will not detect if fd is invalid (unless fd is -1). | 1362 | will not detect if fd is invalid (unless fd is -1). |
1363 | */ | 1363 | */ |
1364 | 1364 | ||
1365 | ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | 1365 | ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); |
1366 | /* | 1366 | /* |
1367 | Set the internal buffer size used by this library's functions for file to | 1367 | Set the internal buffer size used by this library's functions for file to |
1368 | size. The default buffer size is 8192 bytes. This function must be called | 1368 | size. The default buffer size is 8192 bytes. This function must be called |
@@ -1378,7 +1378,7 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | |||
1378 | too late. | 1378 | too late. |
1379 | */ | 1379 | */ |
1380 | 1380 | ||
1381 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | 1381 | ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); |
1382 | /* | 1382 | /* |
1383 | Dynamically update the compression level and strategy for file. See the | 1383 | Dynamically update the compression level and strategy for file. See the |
1384 | description of deflateInit2 for the meaning of these parameters. Previously | 1384 | description of deflateInit2 for the meaning of these parameters. Previously |
@@ -1389,7 +1389,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | |||
1389 | or Z_MEM_ERROR if there is a memory allocation error. | 1389 | or Z_MEM_ERROR if there is a memory allocation error. |
1390 | */ | 1390 | */ |
1391 | 1391 | ||
1392 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | 1392 | ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); |
1393 | /* | 1393 | /* |
1394 | Read and decompress up to len uncompressed bytes from file into buf. If | 1394 | Read and decompress up to len uncompressed bytes from file into buf. If |
1395 | the input file is not in gzip format, gzread copies the given number of | 1395 | the input file is not in gzip format, gzread copies the given number of |
@@ -1419,8 +1419,8 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |||
1419 | Z_STREAM_ERROR. | 1419 | Z_STREAM_ERROR. |
1420 | */ | 1420 | */ |
1421 | 1421 | ||
1422 | ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, | 1422 | ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, |
1423 | gzFile file)); | 1423 | gzFile file); |
1424 | /* | 1424 | /* |
1425 | Read and decompress up to nitems items of size size from file into buf, | 1425 | Read and decompress up to nitems items of size size from file into buf, |
1426 | otherwise operating as gzread() does. This duplicates the interface of | 1426 | otherwise operating as gzread() does. This duplicates the interface of |
@@ -1445,14 +1445,14 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, | |||
1445 | file, resetting and retrying on end-of-file, when size is not 1. | 1445 | file, resetting and retrying on end-of-file, when size is not 1. |
1446 | */ | 1446 | */ |
1447 | 1447 | ||
1448 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); | 1448 | ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); |
1449 | /* | 1449 | /* |
1450 | Compress and write the len uncompressed bytes at buf to file. gzwrite | 1450 | Compress and write the len uncompressed bytes at buf to file. gzwrite |
1451 | returns the number of uncompressed bytes written or 0 in case of error. | 1451 | returns the number of uncompressed bytes written or 0 in case of error. |
1452 | */ | 1452 | */ |
1453 | 1453 | ||
1454 | ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, | 1454 | ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, |
1455 | z_size_t nitems, gzFile file)); | 1455 | z_size_t nitems, gzFile file); |
1456 | /* | 1456 | /* |
1457 | Compress and write nitems items of size size from buf to file, duplicating | 1457 | Compress and write nitems items of size size from buf to file, duplicating |
1458 | the interface of stdio's fwrite(), with size_t request and return types. If | 1458 | the interface of stdio's fwrite(), with size_t request and return types. If |
@@ -1465,7 +1465,7 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, | |||
1465 | is returned, and the error state is set to Z_STREAM_ERROR. | 1465 | is returned, and the error state is set to Z_STREAM_ERROR. |
1466 | */ | 1466 | */ |
1467 | 1467 | ||
1468 | ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); | 1468 | ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); |
1469 | /* | 1469 | /* |
1470 | Convert, format, compress, and write the arguments (...) to file under | 1470 | Convert, format, compress, and write the arguments (...) to file under |
1471 | control of the string format, as in fprintf. gzprintf returns the number of | 1471 | control of the string format, as in fprintf. gzprintf returns the number of |
@@ -1480,7 +1480,7 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); | |||
1480 | This can be determined using zlibCompileFlags(). | 1480 | This can be determined using zlibCompileFlags(). |
1481 | */ | 1481 | */ |
1482 | 1482 | ||
1483 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | 1483 | ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); |
1484 | /* | 1484 | /* |
1485 | Compress and write the given null-terminated string s to file, excluding | 1485 | Compress and write the given null-terminated string s to file, excluding |
1486 | the terminating null character. | 1486 | the terminating null character. |
@@ -1488,7 +1488,7 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | |||
1488 | gzputs returns the number of characters written, or -1 in case of error. | 1488 | gzputs returns the number of characters written, or -1 in case of error. |
1489 | */ | 1489 | */ |
1490 | 1490 | ||
1491 | ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); | 1491 | ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); |
1492 | /* | 1492 | /* |
1493 | Read and decompress bytes from file into buf, until len-1 characters are | 1493 | Read and decompress bytes from file into buf, until len-1 characters are |
1494 | read, or until a newline character is read and transferred to buf, or an | 1494 | read, or until a newline character is read and transferred to buf, or an |
@@ -1502,13 +1502,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); | |||
1502 | buf are indeterminate. | 1502 | buf are indeterminate. |
1503 | */ | 1503 | */ |
1504 | 1504 | ||
1505 | ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); | 1505 | ZEXTERN int ZEXPORT gzputc(gzFile file, int c); |
1506 | /* | 1506 | /* |
1507 | Compress and write c, converted to an unsigned char, into file. gzputc | 1507 | Compress and write c, converted to an unsigned char, into file. gzputc |
1508 | returns the value that was written, or -1 in case of error. | 1508 | returns the value that was written, or -1 in case of error. |
1509 | */ | 1509 | */ |
1510 | 1510 | ||
1511 | ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); | 1511 | ZEXTERN int ZEXPORT gzgetc(gzFile file); |
1512 | /* | 1512 | /* |
1513 | Read and decompress one byte from file. gzgetc returns this byte or -1 | 1513 | Read and decompress one byte from file. gzgetc returns this byte or -1 |
1514 | in case of end of file or error. This is implemented as a macro for speed. | 1514 | in case of end of file or error. This is implemented as a macro for speed. |
@@ -1517,7 +1517,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); | |||
1517 | points to has been clobbered or not. | 1517 | points to has been clobbered or not. |
1518 | */ | 1518 | */ |
1519 | 1519 | ||
1520 | ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | 1520 | ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); |
1521 | /* | 1521 | /* |
1522 | Push c back onto the stream for file to be read as the first character on | 1522 | Push c back onto the stream for file to be read as the first character on |
1523 | the next read. At least one character of push-back is always allowed. | 1523 | the next read. At least one character of push-back is always allowed. |
@@ -1529,7 +1529,7 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | |||
1529 | gzseek() or gzrewind(). | 1529 | gzseek() or gzrewind(). |
1530 | */ | 1530 | */ |
1531 | 1531 | ||
1532 | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | 1532 | ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); |
1533 | /* | 1533 | /* |
1534 | Flush all pending output to file. The parameter flush is as in the | 1534 | Flush all pending output to file. The parameter flush is as in the |
1535 | deflate() function. The return value is the zlib error number (see function | 1535 | deflate() function. The return value is the zlib error number (see function |
@@ -1545,8 +1545,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | |||
1545 | */ | 1545 | */ |
1546 | 1546 | ||
1547 | /* | 1547 | /* |
1548 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | 1548 | ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, |
1549 | z_off_t offset, int whence)); | 1549 | z_off_t offset, int whence); |
1550 | 1550 | ||
1551 | Set the starting position to offset relative to whence for the next gzread | 1551 | Set the starting position to offset relative to whence for the next gzread |
1552 | or gzwrite on file. The offset represents a number of bytes in the | 1552 | or gzwrite on file. The offset represents a number of bytes in the |
@@ -1564,7 +1564,7 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | |||
1564 | would be before the current position. | 1564 | would be before the current position. |
1565 | */ | 1565 | */ |
1566 | 1566 | ||
1567 | ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); | 1567 | ZEXTERN int ZEXPORT gzrewind(gzFile file); |
1568 | /* | 1568 | /* |
1569 | Rewind file. This function is supported only for reading. | 1569 | Rewind file. This function is supported only for reading. |
1570 | 1570 | ||
@@ -1572,7 +1572,7 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); | |||
1572 | */ | 1572 | */ |
1573 | 1573 | ||
1574 | /* | 1574 | /* |
1575 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); | 1575 | ZEXTERN z_off_t ZEXPORT gztell(gzFile file); |
1576 | 1576 | ||
1577 | Return the starting position for the next gzread or gzwrite on file. | 1577 | Return the starting position for the next gzread or gzwrite on file. |
1578 | This position represents a number of bytes in the uncompressed data stream, | 1578 | This position represents a number of bytes in the uncompressed data stream, |
@@ -1583,7 +1583,7 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); | |||
1583 | */ | 1583 | */ |
1584 | 1584 | ||
1585 | /* | 1585 | /* |
1586 | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); | 1586 | ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); |
1587 | 1587 | ||
1588 | Return the current compressed (actual) read or write offset of file. This | 1588 | Return the current compressed (actual) read or write offset of file. This |
1589 | offset includes the count of bytes that precede the gzip stream, for example | 1589 | offset includes the count of bytes that precede the gzip stream, for example |
@@ -1592,7 +1592,7 @@ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); | |||
1592 | be used for a progress indicator. On error, gzoffset() returns -1. | 1592 | be used for a progress indicator. On error, gzoffset() returns -1. |
1593 | */ | 1593 | */ |
1594 | 1594 | ||
1595 | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | 1595 | ZEXTERN int ZEXPORT gzeof(gzFile file); |
1596 | /* | 1596 | /* |
1597 | Return true (1) if the end-of-file indicator for file has been set while | 1597 | Return true (1) if the end-of-file indicator for file has been set while |
1598 | reading, false (0) otherwise. Note that the end-of-file indicator is set | 1598 | reading, false (0) otherwise. Note that the end-of-file indicator is set |
@@ -1607,7 +1607,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | |||
1607 | has grown since the previous end of file was detected. | 1607 | has grown since the previous end of file was detected. |
1608 | */ | 1608 | */ |
1609 | 1609 | ||
1610 | ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); | 1610 | ZEXTERN int ZEXPORT gzdirect(gzFile file); |
1611 | /* | 1611 | /* |
1612 | Return true (1) if file is being copied directly while reading, or false | 1612 | Return true (1) if file is being copied directly while reading, or false |
1613 | (0) if file is a gzip stream being decompressed. | 1613 | (0) if file is a gzip stream being decompressed. |
@@ -1628,7 +1628,7 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); | |||
1628 | gzip file reading and decompression, which may not be desired.) | 1628 | gzip file reading and decompression, which may not be desired.) |
1629 | */ | 1629 | */ |
1630 | 1630 | ||
1631 | ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | 1631 | ZEXTERN int ZEXPORT gzclose(gzFile file); |
1632 | /* | 1632 | /* |
1633 | Flush all pending output for file, if necessary, close file and | 1633 | Flush all pending output for file, if necessary, close file and |
1634 | deallocate the (de)compression state. Note that once file is closed, you | 1634 | deallocate the (de)compression state. Note that once file is closed, you |
@@ -1641,8 +1641,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | |||
1641 | last read ended in the middle of a gzip stream, or Z_OK on success. | 1641 | last read ended in the middle of a gzip stream, or Z_OK on success. |
1642 | */ | 1642 | */ |
1643 | 1643 | ||
1644 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); | 1644 | ZEXTERN int ZEXPORT gzclose_r(gzFile file); |
1645 | ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); | 1645 | ZEXTERN int ZEXPORT gzclose_w(gzFile file); |
1646 | /* | 1646 | /* |
1647 | Same as gzclose(), but gzclose_r() is only for use when reading, and | 1647 | Same as gzclose(), but gzclose_r() is only for use when reading, and |
1648 | gzclose_w() is only for use when writing or appending. The advantage to | 1648 | gzclose_w() is only for use when writing or appending. The advantage to |
@@ -1653,7 +1653,7 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); | |||
1653 | zlib library. | 1653 | zlib library. |
1654 | */ | 1654 | */ |
1655 | 1655 | ||
1656 | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | 1656 | ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); |
1657 | /* | 1657 | /* |
1658 | Return the error message for the last error which occurred on file. | 1658 | Return the error message for the last error which occurred on file. |
1659 | errnum is set to zlib error number. If an error occurred in the file system | 1659 | errnum is set to zlib error number. If an error occurred in the file system |
@@ -1669,7 +1669,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | |||
1669 | functions above that do not distinguish those cases in their return values. | 1669 | functions above that do not distinguish those cases in their return values. |
1670 | */ | 1670 | */ |
1671 | 1671 | ||
1672 | ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | 1672 | ZEXTERN void ZEXPORT gzclearerr(gzFile file); |
1673 | /* | 1673 | /* |
1674 | Clear the error and end-of-file flags for file. This is analogous to the | 1674 | Clear the error and end-of-file flags for file. This is analogous to the |
1675 | clearerr() function in stdio. This is useful for continuing to read a gzip | 1675 | clearerr() function in stdio. This is useful for continuing to read a gzip |
@@ -1686,7 +1686,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | |||
1686 | library. | 1686 | library. |
1687 | */ | 1687 | */ |
1688 | 1688 | ||
1689 | ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); | 1689 | ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); |
1690 | /* | 1690 | /* |
1691 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and | 1691 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
1692 | return the updated checksum. An Adler-32 value is in the range of a 32-bit | 1692 | return the updated checksum. An Adler-32 value is in the range of a 32-bit |
@@ -1706,15 +1706,15 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); | |||
1706 | if (adler != original_adler) error(); | 1706 | if (adler != original_adler) error(); |
1707 | */ | 1707 | */ |
1708 | 1708 | ||
1709 | ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, | 1709 | ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, |
1710 | z_size_t len)); | 1710 | z_size_t len); |
1711 | /* | 1711 | /* |
1712 | Same as adler32(), but with a size_t length. | 1712 | Same as adler32(), but with a size_t length. |
1713 | */ | 1713 | */ |
1714 | 1714 | ||
1715 | /* | 1715 | /* |
1716 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, | 1716 | ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, |
1717 | z_off_t len2)); | 1717 | z_off_t len2); |
1718 | 1718 | ||
1719 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 | 1719 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
1720 | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for | 1720 | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for |
@@ -1724,7 +1724,7 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, | |||
1724 | negative, the result has no meaning or utility. | 1724 | negative, the result has no meaning or utility. |
1725 | */ | 1725 | */ |
1726 | 1726 | ||
1727 | ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); | 1727 | ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); |
1728 | /* | 1728 | /* |
1729 | Update a running CRC-32 with the bytes buf[0..len-1] and return the | 1729 | Update a running CRC-32 with the bytes buf[0..len-1] and return the |
1730 | updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. | 1730 | updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. |
@@ -1742,14 +1742,14 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); | |||
1742 | if (crc != original_crc) error(); | 1742 | if (crc != original_crc) error(); |
1743 | */ | 1743 | */ |
1744 | 1744 | ||
1745 | ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, | 1745 | ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, |
1746 | z_size_t len)); | 1746 | z_size_t len); |
1747 | /* | 1747 | /* |
1748 | Same as crc32(), but with a size_t length. | 1748 | Same as crc32(), but with a size_t length. |
1749 | */ | 1749 | */ |
1750 | 1750 | ||
1751 | /* | 1751 | /* |
1752 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); | 1752 | ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); |
1753 | 1753 | ||
1754 | Combine two CRC-32 check values into one. For two sequences of bytes, | 1754 | Combine two CRC-32 check values into one. For two sequences of bytes, |
1755 | seq1 and seq2 with lengths len1 and len2, CRC-32 check values were | 1755 | seq1 and seq2 with lengths len1 and len2, CRC-32 check values were |
@@ -1759,13 +1759,13 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); | |||
1759 | */ | 1759 | */ |
1760 | 1760 | ||
1761 | /* | 1761 | /* |
1762 | ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); | 1762 | ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); |
1763 | 1763 | ||
1764 | Return the operator corresponding to length len2, to be used with | 1764 | Return the operator corresponding to length len2, to be used with |
1765 | crc32_combine_op(). | 1765 | crc32_combine_op(). |
1766 | */ | 1766 | */ |
1767 | 1767 | ||
1768 | ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); | 1768 | ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); |
1769 | /* | 1769 | /* |
1770 | Give the same result as crc32_combine(), using op in place of len2. op is | 1770 | Give the same result as crc32_combine(), using op in place of len2. op is |
1771 | is generated from len2 by crc32_combine_gen(). This will be faster than | 1771 | is generated from len2 by crc32_combine_gen(). This will be faster than |
@@ -1778,20 +1778,20 @@ ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); | |||
1778 | /* deflateInit and inflateInit are macros to allow checking the zlib version | 1778 | /* deflateInit and inflateInit are macros to allow checking the zlib version |
1779 | * and the compiler's view of z_stream: | 1779 | * and the compiler's view of z_stream: |
1780 | */ | 1780 | */ |
1781 | ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, | 1781 | ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, |
1782 | const char *version, int stream_size)); | 1782 | const char *version, int stream_size); |
1783 | ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, | 1783 | ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, |
1784 | const char *version, int stream_size)); | 1784 | const char *version, int stream_size); |
1785 | ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, | 1785 | ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, |
1786 | int windowBits, int memLevel, | 1786 | int windowBits, int memLevel, |
1787 | int strategy, const char *version, | 1787 | int strategy, const char *version, |
1788 | int stream_size)); | 1788 | int stream_size); |
1789 | ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, | 1789 | ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, |
1790 | const char *version, int stream_size)); | 1790 | const char *version, int stream_size); |
1791 | ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | 1791 | ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, |
1792 | unsigned char FAR *window, | 1792 | unsigned char FAR *window, |
1793 | const char *version, | 1793 | const char *version, |
1794 | int stream_size)); | 1794 | int stream_size); |
1795 | #ifdef Z_PREFIX_SET | 1795 | #ifdef Z_PREFIX_SET |
1796 | # define z_deflateInit(strm, level) \ | 1796 | # define z_deflateInit(strm, level) \ |
1797 | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) | 1797 | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) |
@@ -1836,7 +1836,7 @@ struct gzFile_s { | |||
1836 | unsigned char *next; | 1836 | unsigned char *next; |
1837 | z_off64_t pos; | 1837 | z_off64_t pos; |
1838 | }; | 1838 | }; |
1839 | ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ | 1839 | ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ |
1840 | #ifdef Z_PREFIX_SET | 1840 | #ifdef Z_PREFIX_SET |
1841 | # undef z_gzgetc | 1841 | # undef z_gzgetc |
1842 | # define z_gzgetc(g) \ | 1842 | # define z_gzgetc(g) \ |
@@ -1853,13 +1853,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ | |||
1853 | * without large file support, _LFS64_LARGEFILE must also be true | 1853 | * without large file support, _LFS64_LARGEFILE must also be true |
1854 | */ | 1854 | */ |
1855 | #ifdef Z_LARGE64 | 1855 | #ifdef Z_LARGE64 |
1856 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | 1856 | ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
1857 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); | 1857 | ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); |
1858 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); | 1858 | ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); |
1859 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); | 1859 | ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); |
1860 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); | 1860 | ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); |
1861 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); | 1861 | ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); |
1862 | ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); | 1862 | ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); |
1863 | #endif | 1863 | #endif |
1864 | 1864 | ||
1865 | #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) | 1865 | #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) |
@@ -1881,50 +1881,50 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ | |||
1881 | # define crc32_combine_gen crc32_combine_gen64 | 1881 | # define crc32_combine_gen crc32_combine_gen64 |
1882 | # endif | 1882 | # endif |
1883 | # ifndef Z_LARGE64 | 1883 | # ifndef Z_LARGE64 |
1884 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | 1884 | ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
1885 | ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); | 1885 | ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); |
1886 | ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); | 1886 | ZEXTERN z_off_t ZEXPORT gztell64(gzFile); |
1887 | ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); | 1887 | ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); |
1888 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | 1888 | ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); |
1889 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); | 1889 | ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); |
1890 | ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); | 1890 | ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); |
1891 | # endif | 1891 | # endif |
1892 | #else | 1892 | #else |
1893 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); | 1893 | ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); |
1894 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); | 1894 | ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); |
1895 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); | 1895 | ZEXTERN z_off_t ZEXPORT gztell(gzFile); |
1896 | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); | 1896 | ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); |
1897 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | 1897 | ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); |
1898 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | 1898 | ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); |
1899 | ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); | 1899 | ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); |
1900 | #endif | 1900 | #endif |
1901 | 1901 | ||
1902 | #else /* Z_SOLO */ | 1902 | #else /* Z_SOLO */ |
1903 | 1903 | ||
1904 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | 1904 | ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); |
1905 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | 1905 | ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); |
1906 | ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); | 1906 | ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); |
1907 | 1907 | ||
1908 | #endif /* !Z_SOLO */ | 1908 | #endif /* !Z_SOLO */ |
1909 | 1909 | ||
1910 | /* undocumented functions */ | 1910 | /* undocumented functions */ |
1911 | ZEXTERN const char * ZEXPORT zError OF((int)); | 1911 | ZEXTERN const char * ZEXPORT zError(int); |
1912 | ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); | 1912 | ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); |
1913 | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); | 1913 | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); |
1914 | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); | 1914 | ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); |
1915 | ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); | 1915 | ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); |
1916 | ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp)); | 1916 | ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); |
1917 | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); | 1917 | ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); |
1918 | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); | 1918 | ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); |
1919 | #if defined(_WIN32) && !defined(Z_SOLO) | 1919 | #if defined(_WIN32) && !defined(Z_SOLO) |
1920 | ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, | 1920 | ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, |
1921 | const char *mode)); | 1921 | const char *mode); |
1922 | #endif | 1922 | #endif |
1923 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | 1923 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
1924 | # ifndef Z_SOLO | 1924 | # ifndef Z_SOLO |
1925 | ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, | 1925 | ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, |
1926 | const char *format, | 1926 | const char *format, |
1927 | va_list va)); | 1927 | va_list va); |
1928 | # endif | 1928 | # endif |
1929 | #endif | 1929 | #endif |
1930 | 1930 | ||
@@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = { | |||
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | const char * ZEXPORT zlibVersion() | 27 | const char * ZEXPORT zlibVersion(void) { |
28 | { | ||
29 | return ZLIB_VERSION; | 28 | return ZLIB_VERSION; |
30 | } | 29 | } |
31 | 30 | ||
32 | uLong ZEXPORT zlibCompileFlags() | 31 | uLong ZEXPORT zlibCompileFlags(void) { |
33 | { | ||
34 | uLong flags; | 32 | uLong flags; |
35 | 33 | ||
36 | flags = 0; | 34 | flags = 0; |
@@ -121,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags() | |||
121 | # endif | 119 | # endif |
122 | int ZLIB_INTERNAL z_verbose = verbose; | 120 | int ZLIB_INTERNAL z_verbose = verbose; |
123 | 121 | ||
124 | void ZLIB_INTERNAL z_error(m) | 122 | void ZLIB_INTERNAL z_error(char *m) { |
125 | char *m; | ||
126 | { | ||
127 | fprintf(stderr, "%s\n", m); | 123 | fprintf(stderr, "%s\n", m); |
128 | exit(1); | 124 | exit(1); |
129 | } | 125 | } |
@@ -132,9 +128,7 @@ void ZLIB_INTERNAL z_error(m) | |||
132 | /* exported to allow conversion of error code to string for compress() and | 128 | /* exported to allow conversion of error code to string for compress() and |
133 | * uncompress() | 129 | * uncompress() |
134 | */ | 130 | */ |
135 | const char * ZEXPORT zError(err) | 131 | const char * ZEXPORT zError(int err) { |
136 | int err; | ||
137 | { | ||
138 | return ERR_MSG(err); | 132 | return ERR_MSG(err); |
139 | } | 133 | } |
140 | 134 | ||
@@ -148,22 +142,14 @@ const char * ZEXPORT zError(err) | |||
148 | 142 | ||
149 | #ifndef HAVE_MEMCPY | 143 | #ifndef HAVE_MEMCPY |
150 | 144 | ||
151 | void ZLIB_INTERNAL zmemcpy(dest, source, len) | 145 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { |
152 | Bytef* dest; | ||
153 | const Bytef* source; | ||
154 | uInt len; | ||
155 | { | ||
156 | if (len == 0) return; | 146 | if (len == 0) return; |
157 | do { | 147 | do { |
158 | *dest++ = *source++; /* ??? to be unrolled */ | 148 | *dest++ = *source++; /* ??? to be unrolled */ |
159 | } while (--len != 0); | 149 | } while (--len != 0); |
160 | } | 150 | } |
161 | 151 | ||
162 | int ZLIB_INTERNAL zmemcmp(s1, s2, len) | 152 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { |
163 | const Bytef* s1; | ||
164 | const Bytef* s2; | ||
165 | uInt len; | ||
166 | { | ||
167 | uInt j; | 153 | uInt j; |
168 | 154 | ||
169 | for (j = 0; j < len; j++) { | 155 | for (j = 0; j < len; j++) { |
@@ -172,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len) | |||
172 | return 0; | 158 | return 0; |
173 | } | 159 | } |
174 | 160 | ||
175 | void ZLIB_INTERNAL zmemzero(dest, len) | 161 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { |
176 | Bytef* dest; | ||
177 | uInt len; | ||
178 | { | ||
179 | if (len == 0) return; | 162 | if (len == 0) return; |
180 | do { | 163 | do { |
181 | *dest++ = 0; /* ??? to be unrolled */ | 164 | *dest++ = 0; /* ??? to be unrolled */ |
@@ -216,8 +199,7 @@ local ptr_table table[MAX_PTR]; | |||
216 | * a protected system like OS/2. Use Microsoft C instead. | 199 | * a protected system like OS/2. Use Microsoft C instead. |
217 | */ | 200 | */ |
218 | 201 | ||
219 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) | 202 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { |
220 | { | ||
221 | voidpf buf; | 203 | voidpf buf; |
222 | ulg bsize = (ulg)items*size; | 204 | ulg bsize = (ulg)items*size; |
223 | 205 | ||
@@ -242,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) | |||
242 | return buf; | 224 | return buf; |
243 | } | 225 | } |
244 | 226 | ||
245 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | 227 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
246 | { | ||
247 | int n; | 228 | int n; |
248 | 229 | ||
249 | (void)opaque; | 230 | (void)opaque; |
@@ -279,14 +260,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | |||
279 | # define _hfree hfree | 260 | # define _hfree hfree |
280 | #endif | 261 | #endif |
281 | 262 | ||
282 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) | 263 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { |
283 | { | ||
284 | (void)opaque; | 264 | (void)opaque; |
285 | return _halloc((long)items, size); | 265 | return _halloc((long)items, size); |
286 | } | 266 | } |
287 | 267 | ||
288 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | 268 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
289 | { | ||
290 | (void)opaque; | 269 | (void)opaque; |
291 | _hfree(ptr); | 270 | _hfree(ptr); |
292 | } | 271 | } |
@@ -299,25 +278,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | |||
299 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ | 278 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
300 | 279 | ||
301 | #ifndef STDC | 280 | #ifndef STDC |
302 | extern voidp malloc OF((uInt size)); | 281 | extern voidp malloc(uInt size); |
303 | extern voidp calloc OF((uInt items, uInt size)); | 282 | extern voidp calloc(uInt items, uInt size); |
304 | extern void free OF((voidpf ptr)); | 283 | extern void free(voidpf ptr); |
305 | #endif | 284 | #endif |
306 | 285 | ||
307 | voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) | 286 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { |
308 | voidpf opaque; | ||
309 | unsigned items; | ||
310 | unsigned size; | ||
311 | { | ||
312 | (void)opaque; | 287 | (void)opaque; |
313 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : | 288 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
314 | (voidpf)calloc(items, size); | 289 | (voidpf)calloc(items, size); |
315 | } | 290 | } |
316 | 291 | ||
317 | void ZLIB_INTERNAL zcfree(opaque, ptr) | 292 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
318 | voidpf opaque; | ||
319 | voidpf ptr; | ||
320 | { | ||
321 | (void)opaque; | 293 | (void)opaque; |
322 | free(ptr); | 294 | free(ptr); |
323 | } | 295 | } |
@@ -191,9 +191,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
191 | /* provide prototypes for these when building zlib without LFS */ | 191 | /* provide prototypes for these when building zlib without LFS */ |
192 | #if !defined(_WIN32) && \ | 192 | #if !defined(_WIN32) && \ |
193 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) | 193 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
194 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | 194 | ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); |
195 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); | 195 | ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); |
196 | ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); | 196 | ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | /* common defaults */ | 199 | /* common defaults */ |
@@ -232,16 +232,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
232 | # define zmemzero(dest, len) memset(dest, 0, len) | 232 | # define zmemzero(dest, len) memset(dest, 0, len) |
233 | # endif | 233 | # endif |
234 | #else | 234 | #else |
235 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); | 235 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); |
236 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); | 236 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); |
237 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); | 237 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | /* Diagnostic functions */ | 240 | /* Diagnostic functions */ |
241 | #ifdef ZLIB_DEBUG | 241 | #ifdef ZLIB_DEBUG |
242 | # include <stdio.h> | 242 | # include <stdio.h> |
243 | extern int ZLIB_INTERNAL z_verbose; | 243 | extern int ZLIB_INTERNAL z_verbose; |
244 | extern void ZLIB_INTERNAL z_error OF((char *m)); | 244 | extern void ZLIB_INTERNAL z_error(char *m); |
245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} | 245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} | 246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} | 247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
@@ -258,9 +258,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
258 | #endif | 258 | #endif |
259 | 259 | ||
260 | #ifndef Z_SOLO | 260 | #ifndef Z_SOLO |
261 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, | 261 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, |
262 | unsigned size)); | 262 | unsigned size); |
263 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); | 263 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); |
264 | #endif | 264 | #endif |
265 | 265 | ||
266 | #define ZALLOC(strm, items, size) \ | 266 | #define ZALLOC(strm, items, size) \ |