| ... | ... |
@@ -2,8 +2,8 @@ |
| 2 | 2 |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 3 | 3 |
<ImportGroup Label="PropertySheets" /> |
| 4 | 4 |
<PropertyGroup Label="UserMacros"> |
| 5 |
- <zlibRootDir>ZLIBFIXME</zlibRootDir> |
|
| 6 |
- <WinampSDKDir>WINAMPSDKFIXME</WinampSDKDir> |
|
| 5 |
+ <zlibRootDir>$(MSBuildThisFileDirectory)\zlib</zlibRootDir> |
|
| 6 |
+ <WinampSDKDir>$(MSBuildThisFileDirectory)\winamp</WinampSDKDir> |
|
| 7 | 7 |
</PropertyGroup> |
| 8 | 8 |
<PropertyGroup /> |
| 9 | 9 |
<ItemDefinitionGroup /> |
| 0 | 2 |
deleted file mode 100644 |
| ... | ... |
@@ -1,186 +0,0 @@ |
| 1 |
-/* adler32.c -- compute the Adler-32 checksum of a data stream |
|
| 2 |
- * Copyright (C) 1995-2011, 2016 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* @(#) $Id$ */ |
|
| 7 |
- |
|
| 8 |
-#include "zutil.h" |
|
| 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 */ |
|
| 13 |
-#define NMAX 5552 |
|
| 14 |
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
|
| 15 |
- |
|
| 16 |
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
|
| 17 |
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); |
|
| 18 |
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); |
|
| 19 |
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); |
|
| 20 |
-#define DO16(buf) DO8(buf,0); DO8(buf,8); |
|
| 21 |
- |
|
| 22 |
-/* use NO_DIVIDE if your processor does not do division in hardware -- |
|
| 23 |
- try it both ways to see which is faster */ |
|
| 24 |
-#ifdef NO_DIVIDE |
|
| 25 |
-/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 |
|
| 26 |
- (thank you to John Reiser for pointing this out) */ |
|
| 27 |
-# define CHOP(a) \ |
|
| 28 |
- do { \
|
|
| 29 |
- unsigned long tmp = a >> 16; \ |
|
| 30 |
- a &= 0xffffUL; \ |
|
| 31 |
- a += (tmp << 4) - tmp; \ |
|
| 32 |
- } while (0) |
|
| 33 |
-# define MOD28(a) \ |
|
| 34 |
- do { \
|
|
| 35 |
- CHOP(a); \ |
|
| 36 |
- if (a >= BASE) a -= BASE; \ |
|
| 37 |
- } while (0) |
|
| 38 |
-# define MOD(a) \ |
|
| 39 |
- do { \
|
|
| 40 |
- CHOP(a); \ |
|
| 41 |
- MOD28(a); \ |
|
| 42 |
- } while (0) |
|
| 43 |
-# define MOD63(a) \ |
|
| 44 |
- do { /* this assumes a is not negative */ \
|
|
| 45 |
- z_off64_t tmp = a >> 32; \ |
|
| 46 |
- a &= 0xffffffffL; \ |
|
| 47 |
- a += (tmp << 8) - (tmp << 5) + tmp; \ |
|
| 48 |
- tmp = a >> 16; \ |
|
| 49 |
- a &= 0xffffL; \ |
|
| 50 |
- a += (tmp << 4) - tmp; \ |
|
| 51 |
- tmp = a >> 16; \ |
|
| 52 |
- a &= 0xffffL; \ |
|
| 53 |
- a += (tmp << 4) - tmp; \ |
|
| 54 |
- if (a >= BASE) a -= BASE; \ |
|
| 55 |
- } while (0) |
|
| 56 |
-#else |
|
| 57 |
-# define MOD(a) a %= BASE |
|
| 58 |
-# define MOD28(a) a %= BASE |
|
| 59 |
-# define MOD63(a) a %= BASE |
|
| 60 |
-#endif |
|
| 61 |
- |
|
| 62 |
-/* ========================================================================= */ |
|
| 63 |
-uLong ZEXPORT adler32_z(adler, buf, len) |
|
| 64 |
- uLong adler; |
|
| 65 |
- const Bytef *buf; |
|
| 66 |
- z_size_t len; |
|
| 67 |
-{
|
|
| 68 |
- unsigned long sum2; |
|
| 69 |
- unsigned n; |
|
| 70 |
- |
|
| 71 |
- /* split Adler-32 into component sums */ |
|
| 72 |
- sum2 = (adler >> 16) & 0xffff; |
|
| 73 |
- adler &= 0xffff; |
|
| 74 |
- |
|
| 75 |
- /* in case user likes doing a byte at a time, keep it fast */ |
|
| 76 |
- if (len == 1) {
|
|
| 77 |
- adler += buf[0]; |
|
| 78 |
- if (adler >= BASE) |
|
| 79 |
- adler -= BASE; |
|
| 80 |
- sum2 += adler; |
|
| 81 |
- if (sum2 >= BASE) |
|
| 82 |
- sum2 -= BASE; |
|
| 83 |
- return adler | (sum2 << 16); |
|
| 84 |
- } |
|
| 85 |
- |
|
| 86 |
- /* initial Adler-32 value (deferred check for len == 1 speed) */ |
|
| 87 |
- if (buf == Z_NULL) |
|
| 88 |
- return 1L; |
|
| 89 |
- |
|
| 90 |
- /* in case short lengths are provided, keep it somewhat fast */ |
|
| 91 |
- if (len < 16) {
|
|
| 92 |
- while (len--) {
|
|
| 93 |
- adler += *buf++; |
|
| 94 |
- sum2 += adler; |
|
| 95 |
- } |
|
| 96 |
- if (adler >= BASE) |
|
| 97 |
- adler -= BASE; |
|
| 98 |
- MOD28(sum2); /* only added so many BASE's */ |
|
| 99 |
- return adler | (sum2 << 16); |
|
| 100 |
- } |
|
| 101 |
- |
|
| 102 |
- /* do length NMAX blocks -- requires just one modulo operation */ |
|
| 103 |
- while (len >= NMAX) {
|
|
| 104 |
- len -= NMAX; |
|
| 105 |
- n = NMAX / 16; /* NMAX is divisible by 16 */ |
|
| 106 |
- do {
|
|
| 107 |
- DO16(buf); /* 16 sums unrolled */ |
|
| 108 |
- buf += 16; |
|
| 109 |
- } while (--n); |
|
| 110 |
- MOD(adler); |
|
| 111 |
- MOD(sum2); |
|
| 112 |
- } |
|
| 113 |
- |
|
| 114 |
- /* do remaining bytes (less than NMAX, still just one modulo) */ |
|
| 115 |
- if (len) { /* avoid modulos if none remaining */
|
|
| 116 |
- while (len >= 16) {
|
|
| 117 |
- len -= 16; |
|
| 118 |
- DO16(buf); |
|
| 119 |
- buf += 16; |
|
| 120 |
- } |
|
| 121 |
- while (len--) {
|
|
| 122 |
- adler += *buf++; |
|
| 123 |
- sum2 += adler; |
|
| 124 |
- } |
|
| 125 |
- MOD(adler); |
|
| 126 |
- MOD(sum2); |
|
| 127 |
- } |
|
| 128 |
- |
|
| 129 |
- /* return recombined sums */ |
|
| 130 |
- return adler | (sum2 << 16); |
|
| 131 |
-} |
|
| 132 |
- |
|
| 133 |
-/* ========================================================================= */ |
|
| 134 |
-uLong ZEXPORT adler32(adler, buf, len) |
|
| 135 |
- uLong adler; |
|
| 136 |
- const Bytef *buf; |
|
| 137 |
- uInt len; |
|
| 138 |
-{
|
|
| 139 |
- return adler32_z(adler, buf, len); |
|
| 140 |
-} |
|
| 141 |
- |
|
| 142 |
-/* ========================================================================= */ |
|
| 143 |
-local uLong adler32_combine_(adler1, adler2, len2) |
|
| 144 |
- uLong adler1; |
|
| 145 |
- uLong adler2; |
|
| 146 |
- z_off64_t len2; |
|
| 147 |
-{
|
|
| 148 |
- unsigned long sum1; |
|
| 149 |
- unsigned long sum2; |
|
| 150 |
- unsigned rem; |
|
| 151 |
- |
|
| 152 |
- /* for negative len, return invalid adler32 as a clue for debugging */ |
|
| 153 |
- if (len2 < 0) |
|
| 154 |
- return 0xffffffffUL; |
|
| 155 |
- |
|
| 156 |
- /* the derivation of this formula is left as an exercise for the reader */ |
|
| 157 |
- MOD63(len2); /* assumes len2 >= 0 */ |
|
| 158 |
- rem = (unsigned)len2; |
|
| 159 |
- sum1 = adler1 & 0xffff; |
|
| 160 |
- sum2 = rem * sum1; |
|
| 161 |
- MOD(sum2); |
|
| 162 |
- sum1 += (adler2 & 0xffff) + BASE - 1; |
|
| 163 |
- sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; |
|
| 164 |
- if (sum1 >= BASE) sum1 -= BASE; |
|
| 165 |
- if (sum1 >= BASE) sum1 -= BASE; |
|
| 166 |
- if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); |
|
| 167 |
- if (sum2 >= BASE) sum2 -= BASE; |
|
| 168 |
- return sum1 | (sum2 << 16); |
|
| 169 |
-} |
|
| 170 |
- |
|
| 171 |
-/* ========================================================================= */ |
|
| 172 |
-uLong ZEXPORT adler32_combine(adler1, adler2, len2) |
|
| 173 |
- uLong adler1; |
|
| 174 |
- uLong adler2; |
|
| 175 |
- z_off_t len2; |
|
| 176 |
-{
|
|
| 177 |
- return adler32_combine_(adler1, adler2, len2); |
|
| 178 |
-} |
|
| 179 |
- |
|
| 180 |
-uLong ZEXPORT adler32_combine64(adler1, adler2, len2) |
|
| 181 |
- uLong adler1; |
|
| 182 |
- uLong adler2; |
|
| 183 |
- z_off64_t len2; |
|
| 184 |
-{
|
|
| 185 |
- return adler32_combine_(adler1, adler2, len2); |
|
| 186 |
-} |
| 187 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,442 +0,0 @@ |
| 1 |
-/* crc32.c -- compute the CRC-32 of a data stream |
|
| 2 |
- * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- * |
|
| 5 |
- * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster |
|
| 6 |
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing |
|
| 7 |
- * tables for updating the shift register in one step with three exclusive-ors |
|
| 8 |
- * instead of four steps with four exclusive-ors. This results in about a |
|
| 9 |
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. |
|
| 10 |
- */ |
|
| 11 |
- |
|
| 12 |
-/* @(#) $Id$ */ |
|
| 13 |
- |
|
| 14 |
-/* |
|
| 15 |
- Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore |
|
| 16 |
- protection on the static variables used to control the first-use generation |
|
| 17 |
- of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should |
|
| 18 |
- first call get_crc_table() to initialize the tables before allowing more than |
|
| 19 |
- one thread to use crc32(). |
|
| 20 |
- |
|
| 21 |
- DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. |
|
| 22 |
- */ |
|
| 23 |
- |
|
| 24 |
-#ifdef MAKECRCH |
|
| 25 |
-# include <stdio.h> |
|
| 26 |
-# ifndef DYNAMIC_CRC_TABLE |
|
| 27 |
-# define DYNAMIC_CRC_TABLE |
|
| 28 |
-# endif /* !DYNAMIC_CRC_TABLE */ |
|
| 29 |
-#endif /* MAKECRCH */ |
|
| 30 |
- |
|
| 31 |
-#include "zutil.h" /* for STDC and FAR definitions */ |
|
| 32 |
- |
|
| 33 |
-/* Definitions for doing the crc four data bytes at a time. */ |
|
| 34 |
-#if !defined(NOBYFOUR) && defined(Z_U4) |
|
| 35 |
-# define BYFOUR |
|
| 36 |
-#endif |
|
| 37 |
-#ifdef BYFOUR |
|
| 38 |
- local unsigned long crc32_little OF((unsigned long, |
|
| 39 |
- const unsigned char FAR *, z_size_t)); |
|
| 40 |
- local unsigned long crc32_big OF((unsigned long, |
|
| 41 |
- const unsigned char FAR *, z_size_t)); |
|
| 42 |
-# define TBLS 8 |
|
| 43 |
-#else |
|
| 44 |
-# define TBLS 1 |
|
| 45 |
-#endif /* BYFOUR */ |
|
| 46 |
- |
|
| 47 |
-/* Local functions for crc concatenation */ |
|
| 48 |
-local unsigned long gf2_matrix_times OF((unsigned long *mat, |
|
| 49 |
- unsigned long vec)); |
|
| 50 |
-local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); |
|
| 51 |
-local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); |
|
| 52 |
- |
|
| 53 |
- |
|
| 54 |
-#ifdef DYNAMIC_CRC_TABLE |
|
| 55 |
- |
|
| 56 |
-local volatile int crc_table_empty = 1; |
|
| 57 |
-local z_crc_t FAR crc_table[TBLS][256]; |
|
| 58 |
-local void make_crc_table OF((void)); |
|
| 59 |
-#ifdef MAKECRCH |
|
| 60 |
- local void write_table OF((FILE *, const z_crc_t FAR *)); |
|
| 61 |
-#endif /* MAKECRCH */ |
|
| 62 |
-/* |
|
| 63 |
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: |
|
| 64 |
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. |
|
| 65 |
- |
|
| 66 |
- Polynomials over GF(2) are represented in binary, one bit per coefficient, |
|
| 67 |
- with the lowest powers in the most significant bit. Then adding polynomials |
|
| 68 |
- is just exclusive-or, and multiplying a polynomial by x is a right shift by |
|
| 69 |
- one. If we call the above polynomial p, and represent a byte as the |
|
| 70 |
- polynomial q, also with the lowest power in the most significant bit (so the |
|
| 71 |
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, |
|
| 72 |
- where a mod b means the remainder after dividing a by b. |
|
| 73 |
- |
|
| 74 |
- This calculation is done using the shift-register method of multiplying and |
|
| 75 |
- taking the remainder. The register is initialized to zero, and for each |
|
| 76 |
- incoming bit, x^32 is added mod p to the register if the bit is a one (where |
|
| 77 |
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by |
|
| 78 |
- x (which is shifting right by one and adding x^32 mod p if the bit shifted |
|
| 79 |
- out is a one). We start with the highest power (least significant bit) of |
|
| 80 |
- q and repeat for all eight bits of q. |
|
| 81 |
- |
|
| 82 |
- The first table is simply the CRC of all possible eight bit values. This is |
|
| 83 |
- all the information needed to generate CRCs on data a byte at a time for all |
|
| 84 |
- combinations of CRC register values and incoming bytes. The remaining tables |
|
| 85 |
- allow for word-at-a-time CRC calculation for both big-endian and little- |
|
| 86 |
- endian machines, where a word is four bytes. |
|
| 87 |
-*/ |
|
| 88 |
-local void make_crc_table() |
|
| 89 |
-{
|
|
| 90 |
- z_crc_t c; |
|
| 91 |
- int n, k; |
|
| 92 |
- z_crc_t poly; /* polynomial exclusive-or pattern */ |
|
| 93 |
- /* terms of polynomial defining this crc (except x^32): */ |
|
| 94 |
- static volatile int first = 1; /* flag to limit concurrent making */ |
|
| 95 |
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
|
| 96 |
- |
|
| 97 |
- /* See if another task is already doing this (not thread-safe, but better |
|
| 98 |
- than nothing -- significantly reduces duration of vulnerability in |
|
| 99 |
- case the advice about DYNAMIC_CRC_TABLE is ignored) */ |
|
| 100 |
- if (first) {
|
|
| 101 |
- first = 0; |
|
| 102 |
- |
|
| 103 |
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */ |
|
| 104 |
- poly = 0; |
|
| 105 |
- for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) |
|
| 106 |
- poly |= (z_crc_t)1 << (31 - p[n]); |
|
| 107 |
- |
|
| 108 |
- /* generate a crc for every 8-bit value */ |
|
| 109 |
- for (n = 0; n < 256; n++) {
|
|
| 110 |
- c = (z_crc_t)n; |
|
| 111 |
- for (k = 0; k < 8; k++) |
|
| 112 |
- c = c & 1 ? poly ^ (c >> 1) : c >> 1; |
|
| 113 |
- crc_table[0][n] = c; |
|
| 114 |
- } |
|
| 115 |
- |
|
| 116 |
-#ifdef BYFOUR |
|
| 117 |
- /* generate crc for each value followed by one, two, and three zeros, |
|
| 118 |
- and then the byte reversal of those as well as the first table */ |
|
| 119 |
- for (n = 0; n < 256; n++) {
|
|
| 120 |
- c = crc_table[0][n]; |
|
| 121 |
- crc_table[4][n] = ZSWAP32(c); |
|
| 122 |
- for (k = 1; k < 4; k++) {
|
|
| 123 |
- c = crc_table[0][c & 0xff] ^ (c >> 8); |
|
| 124 |
- crc_table[k][n] = c; |
|
| 125 |
- crc_table[k + 4][n] = ZSWAP32(c); |
|
| 126 |
- } |
|
| 127 |
- } |
|
| 128 |
-#endif /* BYFOUR */ |
|
| 129 |
- |
|
| 130 |
- crc_table_empty = 0; |
|
| 131 |
- } |
|
| 132 |
- else { /* not first */
|
|
| 133 |
- /* wait for the other guy to finish (not efficient, but rare) */ |
|
| 134 |
- while (crc_table_empty) |
|
| 135 |
- ; |
|
| 136 |
- } |
|
| 137 |
- |
|
| 138 |
-#ifdef MAKECRCH |
|
| 139 |
- /* write out CRC tables to crc32.h */ |
|
| 140 |
- {
|
|
| 141 |
- FILE *out; |
|
| 142 |
- |
|
| 143 |
- out = fopen("crc32.h", "w");
|
|
| 144 |
- if (out == NULL) return; |
|
| 145 |
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); |
|
| 146 |
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); |
|
| 147 |
- fprintf(out, "local const z_crc_t FAR "); |
|
| 148 |
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
|
|
| 149 |
- write_table(out, crc_table[0]); |
|
| 150 |
-# ifdef BYFOUR |
|
| 151 |
- fprintf(out, "#ifdef BYFOUR\n"); |
|
| 152 |
- for (k = 1; k < 8; k++) {
|
|
| 153 |
- fprintf(out, " },\n {\n");
|
|
| 154 |
- write_table(out, crc_table[k]); |
|
| 155 |
- } |
|
| 156 |
- fprintf(out, "#endif\n"); |
|
| 157 |
-# endif /* BYFOUR */ |
|
| 158 |
- fprintf(out, " }\n};\n"); |
|
| 159 |
- fclose(out); |
|
| 160 |
- } |
|
| 161 |
-#endif /* MAKECRCH */ |
|
| 162 |
-} |
|
| 163 |
- |
|
| 164 |
-#ifdef MAKECRCH |
|
| 165 |
-local void write_table(out, table) |
|
| 166 |
- FILE *out; |
|
| 167 |
- const z_crc_t FAR *table; |
|
| 168 |
-{
|
|
| 169 |
- int n; |
|
| 170 |
- |
|
| 171 |
- for (n = 0; n < 256; n++) |
|
| 172 |
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", |
|
| 173 |
- (unsigned long)(table[n]), |
|
| 174 |
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); |
|
| 175 |
-} |
|
| 176 |
-#endif /* MAKECRCH */ |
|
| 177 |
- |
|
| 178 |
-#else /* !DYNAMIC_CRC_TABLE */ |
|
| 179 |
-/* ======================================================================== |
|
| 180 |
- * Tables of CRC-32s of all single-byte values, made by make_crc_table(). |
|
| 181 |
- */ |
|
| 182 |
-#include "crc32.h" |
|
| 183 |
-#endif /* DYNAMIC_CRC_TABLE */ |
|
| 184 |
- |
|
| 185 |
-/* ========================================================================= |
|
| 186 |
- * This function can be used by asm versions of crc32() |
|
| 187 |
- */ |
|
| 188 |
-const z_crc_t FAR * ZEXPORT get_crc_table() |
|
| 189 |
-{
|
|
| 190 |
-#ifdef DYNAMIC_CRC_TABLE |
|
| 191 |
- if (crc_table_empty) |
|
| 192 |
- make_crc_table(); |
|
| 193 |
-#endif /* DYNAMIC_CRC_TABLE */ |
|
| 194 |
- return (const z_crc_t FAR *)crc_table; |
|
| 195 |
-} |
|
| 196 |
- |
|
| 197 |
-/* ========================================================================= */ |
|
| 198 |
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) |
|
| 199 |
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 |
|
| 200 |
- |
|
| 201 |
-/* ========================================================================= */ |
|
| 202 |
-unsigned long ZEXPORT crc32_z(crc, buf, len) |
|
| 203 |
- unsigned long crc; |
|
| 204 |
- const unsigned char FAR *buf; |
|
| 205 |
- z_size_t len; |
|
| 206 |
-{
|
|
| 207 |
- if (buf == Z_NULL) return 0UL; |
|
| 208 |
- |
|
| 209 |
-#ifdef DYNAMIC_CRC_TABLE |
|
| 210 |
- if (crc_table_empty) |
|
| 211 |
- make_crc_table(); |
|
| 212 |
-#endif /* DYNAMIC_CRC_TABLE */ |
|
| 213 |
- |
|
| 214 |
-#ifdef BYFOUR |
|
| 215 |
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
|
|
| 216 |
- z_crc_t endian; |
|
| 217 |
- |
|
| 218 |
- endian = 1; |
|
| 219 |
- if (*((unsigned char *)(&endian))) |
|
| 220 |
- return crc32_little(crc, buf, len); |
|
| 221 |
- else |
|
| 222 |
- return crc32_big(crc, buf, len); |
|
| 223 |
- } |
|
| 224 |
-#endif /* BYFOUR */ |
|
| 225 |
- crc = crc ^ 0xffffffffUL; |
|
| 226 |
- while (len >= 8) {
|
|
| 227 |
- DO8; |
|
| 228 |
- len -= 8; |
|
| 229 |
- } |
|
| 230 |
- if (len) do {
|
|
| 231 |
- DO1; |
|
| 232 |
- } while (--len); |
|
| 233 |
- return crc ^ 0xffffffffUL; |
|
| 234 |
-} |
|
| 235 |
- |
|
| 236 |
-/* ========================================================================= */ |
|
| 237 |
-unsigned long ZEXPORT crc32(crc, buf, len) |
|
| 238 |
- unsigned long crc; |
|
| 239 |
- const unsigned char FAR *buf; |
|
| 240 |
- uInt len; |
|
| 241 |
-{
|
|
| 242 |
- return crc32_z(crc, buf, len); |
|
| 243 |
-} |
|
| 244 |
- |
|
| 245 |
-#ifdef BYFOUR |
|
| 246 |
- |
|
| 247 |
-/* |
|
| 248 |
- This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit |
|
| 249 |
- integer pointer type. This violates the strict aliasing rule, where a |
|
| 250 |
- compiler can assume, for optimization purposes, that two pointers to |
|
| 251 |
- fundamentally different types won't ever point to the same memory. This can |
|
| 252 |
- manifest as a problem only if one of the pointers is written to. This code |
|
| 253 |
- only reads from those pointers. So long as this code remains isolated in |
|
| 254 |
- this compilation unit, there won't be a problem. For this reason, this code |
|
| 255 |
- should not be copied and pasted into a compilation unit in which other code |
|
| 256 |
- writes to the buffer that is passed to these routines. |
|
| 257 |
- */ |
|
| 258 |
- |
|
| 259 |
-/* ========================================================================= */ |
|
| 260 |
-#define DOLIT4 c ^= *buf4++; \ |
|
| 261 |
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ |
|
| 262 |
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] |
|
| 263 |
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 |
|
| 264 |
- |
|
| 265 |
-/* ========================================================================= */ |
|
| 266 |
-local unsigned long crc32_little(crc, buf, len) |
|
| 267 |
- unsigned long crc; |
|
| 268 |
- const unsigned char FAR *buf; |
|
| 269 |
- z_size_t len; |
|
| 270 |
-{
|
|
| 271 |
- register z_crc_t c; |
|
| 272 |
- register const z_crc_t FAR *buf4; |
|
| 273 |
- |
|
| 274 |
- c = (z_crc_t)crc; |
|
| 275 |
- c = ~c; |
|
| 276 |
- while (len && ((ptrdiff_t)buf & 3)) {
|
|
| 277 |
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); |
|
| 278 |
- len--; |
|
| 279 |
- } |
|
| 280 |
- |
|
| 281 |
- buf4 = (const z_crc_t FAR *)(const void FAR *)buf; |
|
| 282 |
- while (len >= 32) {
|
|
| 283 |
- DOLIT32; |
|
| 284 |
- len -= 32; |
|
| 285 |
- } |
|
| 286 |
- while (len >= 4) {
|
|
| 287 |
- DOLIT4; |
|
| 288 |
- len -= 4; |
|
| 289 |
- } |
|
| 290 |
- buf = (const unsigned char FAR *)buf4; |
|
| 291 |
- |
|
| 292 |
- if (len) do {
|
|
| 293 |
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); |
|
| 294 |
- } while (--len); |
|
| 295 |
- c = ~c; |
|
| 296 |
- return (unsigned long)c; |
|
| 297 |
-} |
|
| 298 |
- |
|
| 299 |
-/* ========================================================================= */ |
|
| 300 |
-#define DOBIG4 c ^= *buf4++; \ |
|
| 301 |
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ |
|
| 302 |
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] |
|
| 303 |
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 |
|
| 304 |
- |
|
| 305 |
-/* ========================================================================= */ |
|
| 306 |
-local unsigned long crc32_big(crc, buf, len) |
|
| 307 |
- unsigned long crc; |
|
| 308 |
- const unsigned char FAR *buf; |
|
| 309 |
- z_size_t len; |
|
| 310 |
-{
|
|
| 311 |
- register z_crc_t c; |
|
| 312 |
- register const z_crc_t FAR *buf4; |
|
| 313 |
- |
|
| 314 |
- c = ZSWAP32((z_crc_t)crc); |
|
| 315 |
- c = ~c; |
|
| 316 |
- while (len && ((ptrdiff_t)buf & 3)) {
|
|
| 317 |
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |
|
| 318 |
- len--; |
|
| 319 |
- } |
|
| 320 |
- |
|
| 321 |
- buf4 = (const z_crc_t FAR *)(const void FAR *)buf; |
|
| 322 |
- while (len >= 32) {
|
|
| 323 |
- DOBIG32; |
|
| 324 |
- len -= 32; |
|
| 325 |
- } |
|
| 326 |
- while (len >= 4) {
|
|
| 327 |
- DOBIG4; |
|
| 328 |
- len -= 4; |
|
| 329 |
- } |
|
| 330 |
- buf = (const unsigned char FAR *)buf4; |
|
| 331 |
- |
|
| 332 |
- if (len) do {
|
|
| 333 |
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |
|
| 334 |
- } while (--len); |
|
| 335 |
- c = ~c; |
|
| 336 |
- return (unsigned long)(ZSWAP32(c)); |
|
| 337 |
-} |
|
| 338 |
- |
|
| 339 |
-#endif /* BYFOUR */ |
|
| 340 |
- |
|
| 341 |
-#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ |
|
| 342 |
- |
|
| 343 |
-/* ========================================================================= */ |
|
| 344 |
-local unsigned long gf2_matrix_times(mat, vec) |
|
| 345 |
- unsigned long *mat; |
|
| 346 |
- unsigned long vec; |
|
| 347 |
-{
|
|
| 348 |
- unsigned long sum; |
|
| 349 |
- |
|
| 350 |
- sum = 0; |
|
| 351 |
- while (vec) {
|
|
| 352 |
- if (vec & 1) |
|
| 353 |
- sum ^= *mat; |
|
| 354 |
- vec >>= 1; |
|
| 355 |
- mat++; |
|
| 356 |
- } |
|
| 357 |
- return sum; |
|
| 358 |
-} |
|
| 359 |
- |
|
| 360 |
-/* ========================================================================= */ |
|
| 361 |
-local void gf2_matrix_square(square, mat) |
|
| 362 |
- unsigned long *square; |
|
| 363 |
- unsigned long *mat; |
|
| 364 |
-{
|
|
| 365 |
- int n; |
|
| 366 |
- |
|
| 367 |
- for (n = 0; n < GF2_DIM; n++) |
|
| 368 |
- square[n] = gf2_matrix_times(mat, mat[n]); |
|
| 369 |
-} |
|
| 370 |
- |
|
| 371 |
-/* ========================================================================= */ |
|
| 372 |
-local uLong crc32_combine_(crc1, crc2, len2) |
|
| 373 |
- uLong crc1; |
|
| 374 |
- uLong crc2; |
|
| 375 |
- z_off64_t len2; |
|
| 376 |
-{
|
|
| 377 |
- int n; |
|
| 378 |
- unsigned long row; |
|
| 379 |
- unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ |
|
| 380 |
- unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ |
|
| 381 |
- |
|
| 382 |
- /* degenerate case (also disallow negative lengths) */ |
|
| 383 |
- if (len2 <= 0) |
|
| 384 |
- return crc1; |
|
| 385 |
- |
|
| 386 |
- /* put operator for one zero bit in odd */ |
|
| 387 |
- odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ |
|
| 388 |
- row = 1; |
|
| 389 |
- for (n = 1; n < GF2_DIM; n++) {
|
|
| 390 |
- odd[n] = row; |
|
| 391 |
- row <<= 1; |
|
| 392 |
- } |
|
| 393 |
- |
|
| 394 |
- /* put operator for two zero bits in even */ |
|
| 395 |
- gf2_matrix_square(even, odd); |
|
| 396 |
- |
|
| 397 |
- /* put operator for four zero bits in odd */ |
|
| 398 |
- gf2_matrix_square(odd, even); |
|
| 399 |
- |
|
| 400 |
- /* apply len2 zeros to crc1 (first square will put the operator for one |
|
| 401 |
- zero byte, eight zero bits, in even) */ |
|
| 402 |
- do {
|
|
| 403 |
- /* apply zeros operator for this bit of len2 */ |
|
| 404 |
- gf2_matrix_square(even, odd); |
|
| 405 |
- if (len2 & 1) |
|
| 406 |
- crc1 = gf2_matrix_times(even, crc1); |
|
| 407 |
- len2 >>= 1; |
|
| 408 |
- |
|
| 409 |
- /* if no more bits set, then done */ |
|
| 410 |
- if (len2 == 0) |
|
| 411 |
- break; |
|
| 412 |
- |
|
| 413 |
- /* another iteration of the loop with odd and even swapped */ |
|
| 414 |
- gf2_matrix_square(odd, even); |
|
| 415 |
- if (len2 & 1) |
|
| 416 |
- crc1 = gf2_matrix_times(odd, crc1); |
|
| 417 |
- len2 >>= 1; |
|
| 418 |
- |
|
| 419 |
- /* if no more bits set, then done */ |
|
| 420 |
- } while (len2 != 0); |
|
| 421 |
- |
|
| 422 |
- /* return combined crc */ |
|
| 423 |
- crc1 ^= crc2; |
|
| 424 |
- return crc1; |
|
| 425 |
-} |
|
| 426 |
- |
|
| 427 |
-/* ========================================================================= */ |
|
| 428 |
-uLong ZEXPORT crc32_combine(crc1, crc2, len2) |
|
| 429 |
- uLong crc1; |
|
| 430 |
- uLong crc2; |
|
| 431 |
- z_off_t len2; |
|
| 432 |
-{
|
|
| 433 |
- return crc32_combine_(crc1, crc2, len2); |
|
| 434 |
-} |
|
| 435 |
- |
|
| 436 |
-uLong ZEXPORT crc32_combine64(crc1, crc2, len2) |
|
| 437 |
- uLong crc1; |
|
| 438 |
- uLong crc2; |
|
| 439 |
- z_off64_t len2; |
|
| 440 |
-{
|
|
| 441 |
- return crc32_combine_(crc1, crc2, len2); |
|
| 442 |
-} |
| 443 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,441 +0,0 @@ |
| 1 |
-/* crc32.h -- tables for rapid CRC calculation |
|
| 2 |
- * Generated automatically by crc32.c |
|
| 3 |
- */ |
|
| 4 |
- |
|
| 5 |
-local const z_crc_t FAR crc_table[TBLS][256] = |
|
| 6 |
-{
|
|
| 7 |
- {
|
|
| 8 |
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, |
|
| 9 |
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, |
|
| 10 |
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, |
|
| 11 |
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, |
|
| 12 |
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, |
|
| 13 |
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, |
|
| 14 |
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, |
|
| 15 |
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, |
|
| 16 |
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, |
|
| 17 |
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, |
|
| 18 |
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, |
|
| 19 |
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, |
|
| 20 |
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, |
|
| 21 |
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, |
|
| 22 |
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, |
|
| 23 |
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, |
|
| 24 |
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, |
|
| 25 |
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, |
|
| 26 |
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, |
|
| 27 |
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, |
|
| 28 |
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, |
|
| 29 |
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, |
|
| 30 |
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, |
|
| 31 |
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, |
|
| 32 |
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, |
|
| 33 |
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, |
|
| 34 |
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, |
|
| 35 |
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, |
|
| 36 |
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, |
|
| 37 |
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, |
|
| 38 |
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, |
|
| 39 |
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, |
|
| 40 |
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, |
|
| 41 |
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, |
|
| 42 |
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, |
|
| 43 |
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, |
|
| 44 |
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, |
|
| 45 |
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, |
|
| 46 |
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, |
|
| 47 |
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, |
|
| 48 |
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, |
|
| 49 |
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, |
|
| 50 |
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, |
|
| 51 |
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, |
|
| 52 |
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, |
|
| 53 |
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, |
|
| 54 |
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, |
|
| 55 |
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, |
|
| 56 |
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, |
|
| 57 |
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, |
|
| 58 |
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, |
|
| 59 |
- 0x2d02ef8dUL |
|
| 60 |
-#ifdef BYFOUR |
|
| 61 |
- }, |
|
| 62 |
- {
|
|
| 63 |
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, |
|
| 64 |
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, |
|
| 65 |
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, |
|
| 66 |
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, |
|
| 67 |
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, |
|
| 68 |
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, |
|
| 69 |
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, |
|
| 70 |
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, |
|
| 71 |
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, |
|
| 72 |
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, |
|
| 73 |
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, |
|
| 74 |
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, |
|
| 75 |
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, |
|
| 76 |
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, |
|
| 77 |
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, |
|
| 78 |
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, |
|
| 79 |
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, |
|
| 80 |
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, |
|
| 81 |
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, |
|
| 82 |
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, |
|
| 83 |
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, |
|
| 84 |
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, |
|
| 85 |
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, |
|
| 86 |
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, |
|
| 87 |
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, |
|
| 88 |
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, |
|
| 89 |
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, |
|
| 90 |
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, |
|
| 91 |
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, |
|
| 92 |
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, |
|
| 93 |
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, |
|
| 94 |
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, |
|
| 95 |
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, |
|
| 96 |
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, |
|
| 97 |
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, |
|
| 98 |
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, |
|
| 99 |
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, |
|
| 100 |
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, |
|
| 101 |
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, |
|
| 102 |
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, |
|
| 103 |
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, |
|
| 104 |
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, |
|
| 105 |
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, |
|
| 106 |
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, |
|
| 107 |
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, |
|
| 108 |
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, |
|
| 109 |
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, |
|
| 110 |
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, |
|
| 111 |
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, |
|
| 112 |
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, |
|
| 113 |
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, |
|
| 114 |
- 0x9324fd72UL |
|
| 115 |
- }, |
|
| 116 |
- {
|
|
| 117 |
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, |
|
| 118 |
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, |
|
| 119 |
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, |
|
| 120 |
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, |
|
| 121 |
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, |
|
| 122 |
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, |
|
| 123 |
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, |
|
| 124 |
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, |
|
| 125 |
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, |
|
| 126 |
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, |
|
| 127 |
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, |
|
| 128 |
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, |
|
| 129 |
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, |
|
| 130 |
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, |
|
| 131 |
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, |
|
| 132 |
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, |
|
| 133 |
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, |
|
| 134 |
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, |
|
| 135 |
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, |
|
| 136 |
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, |
|
| 137 |
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, |
|
| 138 |
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, |
|
| 139 |
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, |
|
| 140 |
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, |
|
| 141 |
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, |
|
| 142 |
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, |
|
| 143 |
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, |
|
| 144 |
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, |
|
| 145 |
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, |
|
| 146 |
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, |
|
| 147 |
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, |
|
| 148 |
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, |
|
| 149 |
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, |
|
| 150 |
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, |
|
| 151 |
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, |
|
| 152 |
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, |
|
| 153 |
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, |
|
| 154 |
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, |
|
| 155 |
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, |
|
| 156 |
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, |
|
| 157 |
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, |
|
| 158 |
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, |
|
| 159 |
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, |
|
| 160 |
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, |
|
| 161 |
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, |
|
| 162 |
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, |
|
| 163 |
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, |
|
| 164 |
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, |
|
| 165 |
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, |
|
| 166 |
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, |
|
| 167 |
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, |
|
| 168 |
- 0xbe9834edUL |
|
| 169 |
- }, |
|
| 170 |
- {
|
|
| 171 |
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, |
|
| 172 |
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, |
|
| 173 |
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, |
|
| 174 |
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, |
|
| 175 |
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, |
|
| 176 |
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, |
|
| 177 |
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, |
|
| 178 |
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, |
|
| 179 |
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, |
|
| 180 |
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, |
|
| 181 |
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, |
|
| 182 |
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, |
|
| 183 |
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, |
|
| 184 |
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, |
|
| 185 |
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, |
|
| 186 |
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, |
|
| 187 |
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, |
|
| 188 |
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, |
|
| 189 |
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, |
|
| 190 |
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, |
|
| 191 |
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, |
|
| 192 |
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, |
|
| 193 |
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, |
|
| 194 |
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, |
|
| 195 |
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, |
|
| 196 |
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, |
|
| 197 |
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, |
|
| 198 |
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, |
|
| 199 |
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, |
|
| 200 |
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, |
|
| 201 |
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, |
|
| 202 |
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, |
|
| 203 |
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, |
|
| 204 |
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, |
|
| 205 |
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, |
|
| 206 |
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, |
|
| 207 |
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, |
|
| 208 |
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, |
|
| 209 |
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, |
|
| 210 |
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, |
|
| 211 |
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, |
|
| 212 |
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, |
|
| 213 |
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, |
|
| 214 |
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, |
|
| 215 |
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, |
|
| 216 |
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, |
|
| 217 |
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, |
|
| 218 |
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, |
|
| 219 |
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, |
|
| 220 |
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, |
|
| 221 |
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, |
|
| 222 |
- 0xde0506f1UL |
|
| 223 |
- }, |
|
| 224 |
- {
|
|
| 225 |
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, |
|
| 226 |
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, |
|
| 227 |
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, |
|
| 228 |
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, |
|
| 229 |
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, |
|
| 230 |
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, |
|
| 231 |
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, |
|
| 232 |
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, |
|
| 233 |
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, |
|
| 234 |
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, |
|
| 235 |
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, |
|
| 236 |
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, |
|
| 237 |
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, |
|
| 238 |
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, |
|
| 239 |
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, |
|
| 240 |
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, |
|
| 241 |
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, |
|
| 242 |
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, |
|
| 243 |
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, |
|
| 244 |
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, |
|
| 245 |
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, |
|
| 246 |
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, |
|
| 247 |
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, |
|
| 248 |
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, |
|
| 249 |
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, |
|
| 250 |
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, |
|
| 251 |
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, |
|
| 252 |
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, |
|
| 253 |
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, |
|
| 254 |
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, |
|
| 255 |
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, |
|
| 256 |
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, |
|
| 257 |
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, |
|
| 258 |
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, |
|
| 259 |
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, |
|
| 260 |
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, |
|
| 261 |
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, |
|
| 262 |
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, |
|
| 263 |
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, |
|
| 264 |
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, |
|
| 265 |
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, |
|
| 266 |
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, |
|
| 267 |
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, |
|
| 268 |
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, |
|
| 269 |
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, |
|
| 270 |
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, |
|
| 271 |
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, |
|
| 272 |
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, |
|
| 273 |
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, |
|
| 274 |
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, |
|
| 275 |
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, |
|
| 276 |
- 0x8def022dUL |
|
| 277 |
- }, |
|
| 278 |
- {
|
|
| 279 |
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, |
|
| 280 |
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, |
|
| 281 |
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, |
|
| 282 |
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, |
|
| 283 |
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, |
|
| 284 |
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, |
|
| 285 |
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, |
|
| 286 |
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, |
|
| 287 |
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, |
|
| 288 |
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, |
|
| 289 |
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, |
|
| 290 |
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, |
|
| 291 |
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, |
|
| 292 |
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, |
|
| 293 |
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, |
|
| 294 |
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, |
|
| 295 |
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, |
|
| 296 |
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, |
|
| 297 |
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, |
|
| 298 |
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, |
|
| 299 |
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, |
|
| 300 |
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, |
|
| 301 |
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, |
|
| 302 |
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, |
|
| 303 |
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, |
|
| 304 |
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, |
|
| 305 |
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, |
|
| 306 |
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, |
|
| 307 |
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, |
|
| 308 |
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, |
|
| 309 |
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, |
|
| 310 |
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, |
|
| 311 |
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, |
|
| 312 |
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, |
|
| 313 |
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, |
|
| 314 |
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, |
|
| 315 |
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, |
|
| 316 |
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, |
|
| 317 |
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, |
|
| 318 |
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, |
|
| 319 |
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, |
|
| 320 |
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, |
|
| 321 |
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, |
|
| 322 |
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, |
|
| 323 |
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, |
|
| 324 |
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, |
|
| 325 |
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, |
|
| 326 |
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, |
|
| 327 |
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, |
|
| 328 |
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, |
|
| 329 |
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, |
|
| 330 |
- 0x72fd2493UL |
|
| 331 |
- }, |
|
| 332 |
- {
|
|
| 333 |
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, |
|
| 334 |
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, |
|
| 335 |
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, |
|
| 336 |
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, |
|
| 337 |
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, |
|
| 338 |
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, |
|
| 339 |
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, |
|
| 340 |
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, |
|
| 341 |
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, |
|
| 342 |
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, |
|
| 343 |
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, |
|
| 344 |
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, |
|
| 345 |
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, |
|
| 346 |
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, |
|
| 347 |
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, |
|
| 348 |
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, |
|
| 349 |
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, |
|
| 350 |
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, |
|
| 351 |
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, |
|
| 352 |
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, |
|
| 353 |
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, |
|
| 354 |
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, |
|
| 355 |
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, |
|
| 356 |
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, |
|
| 357 |
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, |
|
| 358 |
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, |
|
| 359 |
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, |
|
| 360 |
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, |
|
| 361 |
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, |
|
| 362 |
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, |
|
| 363 |
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, |
|
| 364 |
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, |
|
| 365 |
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, |
|
| 366 |
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, |
|
| 367 |
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, |
|
| 368 |
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, |
|
| 369 |
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, |
|
| 370 |
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, |
|
| 371 |
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, |
|
| 372 |
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, |
|
| 373 |
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, |
|
| 374 |
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, |
|
| 375 |
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, |
|
| 376 |
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, |
|
| 377 |
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, |
|
| 378 |
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, |
|
| 379 |
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, |
|
| 380 |
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, |
|
| 381 |
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, |
|
| 382 |
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, |
|
| 383 |
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, |
|
| 384 |
- 0xed3498beUL |
|
| 385 |
- }, |
|
| 386 |
- {
|
|
| 387 |
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, |
|
| 388 |
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, |
|
| 389 |
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, |
|
| 390 |
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, |
|
| 391 |
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, |
|
| 392 |
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, |
|
| 393 |
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, |
|
| 394 |
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, |
|
| 395 |
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, |
|
| 396 |
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, |
|
| 397 |
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, |
|
| 398 |
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, |
|
| 399 |
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, |
|
| 400 |
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, |
|
| 401 |
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, |
|
| 402 |
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, |
|
| 403 |
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, |
|
| 404 |
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, |
|
| 405 |
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, |
|
| 406 |
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, |
|
| 407 |
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, |
|
| 408 |
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, |
|
| 409 |
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, |
|
| 410 |
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, |
|
| 411 |
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, |
|
| 412 |
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, |
|
| 413 |
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, |
|
| 414 |
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, |
|
| 415 |
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, |
|
| 416 |
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, |
|
| 417 |
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, |
|
| 418 |
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, |
|
| 419 |
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, |
|
| 420 |
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, |
|
| 421 |
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, |
|
| 422 |
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, |
|
| 423 |
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, |
|
| 424 |
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, |
|
| 425 |
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, |
|
| 426 |
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, |
|
| 427 |
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, |
|
| 428 |
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, |
|
| 429 |
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, |
|
| 430 |
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, |
|
| 431 |
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, |
|
| 432 |
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, |
|
| 433 |
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, |
|
| 434 |
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, |
|
| 435 |
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, |
|
| 436 |
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, |
|
| 437 |
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, |
|
| 438 |
- 0xf10605deUL |
|
| 439 |
-#endif |
|
| 440 |
- } |
|
| 441 |
-}; |
| 442 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,218 +0,0 @@ |
| 1 |
-/* gzguts.h -- zlib internal header definitions for gz* operations |
|
| 2 |
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-#ifdef _LARGEFILE64_SOURCE |
|
| 7 |
-# ifndef _LARGEFILE_SOURCE |
|
| 8 |
-# define _LARGEFILE_SOURCE 1 |
|
| 9 |
-# endif |
|
| 10 |
-# ifdef _FILE_OFFSET_BITS |
|
| 11 |
-# undef _FILE_OFFSET_BITS |
|
| 12 |
-# endif |
|
| 13 |
-#endif |
|
| 14 |
- |
|
| 15 |
-#ifdef HAVE_HIDDEN |
|
| 16 |
-# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
|
| 17 |
-#else |
|
| 18 |
-# define ZLIB_INTERNAL |
|
| 19 |
-#endif |
|
| 20 |
- |
|
| 21 |
-#include <stdio.h> |
|
| 22 |
-#include "zlib.h" |
|
| 23 |
-#ifdef STDC |
|
| 24 |
-# include <string.h> |
|
| 25 |
-# include <stdlib.h> |
|
| 26 |
-# include <limits.h> |
|
| 27 |
-#endif |
|
| 28 |
- |
|
| 29 |
-#ifndef _POSIX_SOURCE |
|
| 30 |
-# define _POSIX_SOURCE |
|
| 31 |
-#endif |
|
| 32 |
-#include <fcntl.h> |
|
| 33 |
- |
|
| 34 |
-#ifdef _WIN32 |
|
| 35 |
-# include <stddef.h> |
|
| 36 |
-#endif |
|
| 37 |
- |
|
| 38 |
-#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) |
|
| 39 |
-# include <io.h> |
|
| 40 |
-#endif |
|
| 41 |
- |
|
| 42 |
-#if defined(_WIN32) || defined(__CYGWIN__) |
|
| 43 |
-# define WIDECHAR |
|
| 44 |
-#endif |
|
| 45 |
- |
|
| 46 |
-#ifdef WINAPI_FAMILY |
|
| 47 |
-# define open _open |
|
| 48 |
-# define read _read |
|
| 49 |
-# define write _write |
|
| 50 |
-# define close _close |
|
| 51 |
-#endif |
|
| 52 |
- |
|
| 53 |
-#ifdef NO_DEFLATE /* for compatibility with old definition */ |
|
| 54 |
-# define NO_GZCOMPRESS |
|
| 55 |
-#endif |
|
| 56 |
- |
|
| 57 |
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) |
|
| 58 |
-# ifndef HAVE_VSNPRINTF |
|
| 59 |
-# define HAVE_VSNPRINTF |
|
| 60 |
-# endif |
|
| 61 |
-#endif |
|
| 62 |
- |
|
| 63 |
-#if defined(__CYGWIN__) |
|
| 64 |
-# ifndef HAVE_VSNPRINTF |
|
| 65 |
-# define HAVE_VSNPRINTF |
|
| 66 |
-# endif |
|
| 67 |
-#endif |
|
| 68 |
- |
|
| 69 |
-#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) |
|
| 70 |
-# ifndef HAVE_VSNPRINTF |
|
| 71 |
-# define HAVE_VSNPRINTF |
|
| 72 |
-# endif |
|
| 73 |
-#endif |
|
| 74 |
- |
|
| 75 |
-#ifndef HAVE_VSNPRINTF |
|
| 76 |
-# ifdef MSDOS |
|
| 77 |
-/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), |
|
| 78 |
- but for now we just assume it doesn't. */ |
|
| 79 |
-# define NO_vsnprintf |
|
| 80 |
-# endif |
|
| 81 |
-# ifdef __TURBOC__ |
|
| 82 |
-# define NO_vsnprintf |
|
| 83 |
-# endif |
|
| 84 |
-# ifdef WIN32 |
|
| 85 |
-/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ |
|
| 86 |
-# if !defined(vsnprintf) && !defined(NO_vsnprintf) |
|
| 87 |
-# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) |
|
| 88 |
-# define vsnprintf _vsnprintf |
|
| 89 |
-# endif |
|
| 90 |
-# endif |
|
| 91 |
-# endif |
|
| 92 |
-# ifdef __SASC |
|
| 93 |
-# define NO_vsnprintf |
|
| 94 |
-# endif |
|
| 95 |
-# ifdef VMS |
|
| 96 |
-# define NO_vsnprintf |
|
| 97 |
-# endif |
|
| 98 |
-# ifdef __OS400__ |
|
| 99 |
-# define NO_vsnprintf |
|
| 100 |
-# endif |
|
| 101 |
-# ifdef __MVS__ |
|
| 102 |
-# define NO_vsnprintf |
|
| 103 |
-# endif |
|
| 104 |
-#endif |
|
| 105 |
- |
|
| 106 |
-/* unlike snprintf (which is required in C99), _snprintf does not guarantee |
|
| 107 |
- null termination of the result -- however this is only used in gzlib.c where |
|
| 108 |
- the result is assured to fit in the space provided */ |
|
| 109 |
-#if defined(_MSC_VER) && _MSC_VER < 1900 |
|
| 110 |
-# define snprintf _snprintf |
|
| 111 |
-#endif |
|
| 112 |
- |
|
| 113 |
-#ifndef local |
|
| 114 |
-# define local static |
|
| 115 |
-#endif |
|
| 116 |
-/* since "static" is used to mean two completely different things in C, we |
|
| 117 |
- define "local" for the non-static meaning of "static", for readability |
|
| 118 |
- (compile with -Dlocal if your debugger can't find static symbols) */ |
|
| 119 |
- |
|
| 120 |
-/* gz* functions always use library allocation functions */ |
|
| 121 |
-#ifndef STDC |
|
| 122 |
- extern voidp malloc OF((uInt size)); |
|
| 123 |
- extern void free OF((voidpf ptr)); |
|
| 124 |
-#endif |
|
| 125 |
- |
|
| 126 |
-/* get errno and strerror definition */ |
|
| 127 |
-#if defined UNDER_CE |
|
| 128 |
-# include <windows.h> |
|
| 129 |
-# define zstrerror() gz_strwinerror((DWORD)GetLastError()) |
|
| 130 |
-#else |
|
| 131 |
-# ifndef NO_STRERROR |
|
| 132 |
-# include <errno.h> |
|
| 133 |
-# define zstrerror() strerror(errno) |
|
| 134 |
-# else |
|
| 135 |
-# define zstrerror() "stdio error (consult errno)" |
|
| 136 |
-# endif |
|
| 137 |
-#endif |
|
| 138 |
- |
|
| 139 |
-/* provide prototypes for these when building zlib without LFS */ |
|
| 140 |
-#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
|
| 141 |
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
|
| 142 |
- ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); |
|
| 143 |
- ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); |
|
| 144 |
- ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); |
|
| 145 |
-#endif |
|
| 146 |
- |
|
| 147 |
-/* default memLevel */ |
|
| 148 |
-#if MAX_MEM_LEVEL >= 8 |
|
| 149 |
-# define DEF_MEM_LEVEL 8 |
|
| 150 |
-#else |
|
| 151 |
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL |
|
| 152 |
-#endif |
|
| 153 |
- |
|
| 154 |
-/* default i/o buffer size -- double this for output when reading (this and |
|
| 155 |
- twice this must be able to fit in an unsigned type) */ |
|
| 156 |
-#define GZBUFSIZE 8192 |
|
| 157 |
- |
|
| 158 |
-/* gzip modes, also provide a little integrity check on the passed structure */ |
|
| 159 |
-#define GZ_NONE 0 |
|
| 160 |
-#define GZ_READ 7247 |
|
| 161 |
-#define GZ_WRITE 31153 |
|
| 162 |
-#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ |
|
| 163 |
- |
|
| 164 |
-/* values for gz_state how */ |
|
| 165 |
-#define LOOK 0 /* look for a gzip header */ |
|
| 166 |
-#define COPY 1 /* copy input directly */ |
|
| 167 |
-#define GZIP 2 /* decompress a gzip stream */ |
|
| 168 |
- |
|
| 169 |
-/* internal gzip file state data structure */ |
|
| 170 |
-typedef struct {
|
|
| 171 |
- /* exposed contents for gzgetc() macro */ |
|
| 172 |
- struct gzFile_s x; /* "x" for exposed */ |
|
| 173 |
- /* x.have: number of bytes available at x.next */ |
|
| 174 |
- /* x.next: next output data to deliver or write */ |
|
| 175 |
- /* x.pos: current position in uncompressed data */ |
|
| 176 |
- /* used for both reading and writing */ |
|
| 177 |
- int mode; /* see gzip modes above */ |
|
| 178 |
- int fd; /* file descriptor */ |
|
| 179 |
- char *path; /* path or fd for error messages */ |
|
| 180 |
- unsigned size; /* buffer size, zero if not allocated yet */ |
|
| 181 |
- unsigned want; /* requested buffer size, default is GZBUFSIZE */ |
|
| 182 |
- unsigned char *in; /* input buffer (double-sized when writing) */ |
|
| 183 |
- unsigned char *out; /* output buffer (double-sized when reading) */ |
|
| 184 |
- int direct; /* 0 if processing gzip, 1 if transparent */ |
|
| 185 |
- /* just for reading */ |
|
| 186 |
- int how; /* 0: get header, 1: copy, 2: decompress */ |
|
| 187 |
- z_off64_t start; /* where the gzip data started, for rewinding */ |
|
| 188 |
- int eof; /* true if end of input file reached */ |
|
| 189 |
- int past; /* true if read requested past end */ |
|
| 190 |
- /* just for writing */ |
|
| 191 |
- int level; /* compression level */ |
|
| 192 |
- int strategy; /* compression strategy */ |
|
| 193 |
- /* seek request */ |
|
| 194 |
- z_off64_t skip; /* amount to skip (already rewound if backwards) */ |
|
| 195 |
- int seek; /* true if seek request pending */ |
|
| 196 |
- /* error information */ |
|
| 197 |
- int err; /* error code */ |
|
| 198 |
- char *msg; /* error message */ |
|
| 199 |
- /* zlib inflate or deflate stream */ |
|
| 200 |
- z_stream strm; /* stream structure in-place (not a pointer) */ |
|
| 201 |
-} gz_state; |
|
| 202 |
-typedef gz_state FAR *gz_statep; |
|
| 203 |
- |
|
| 204 |
-/* shared functions */ |
|
| 205 |
-void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); |
|
| 206 |
-#if defined UNDER_CE |
|
| 207 |
-char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); |
|
| 208 |
-#endif |
|
| 209 |
- |
|
| 210 |
-/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t |
|
| 211 |
- value -- needed when comparing unsigned to z_off64_t, which is signed |
|
| 212 |
- (possible z_off64_t types off_t, off64_t, and long are all signed) */ |
|
| 213 |
-#ifdef INT_MAX |
|
| 214 |
-# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) |
|
| 215 |
-#else |
|
| 216 |
-unsigned ZLIB_INTERNAL gz_intmax OF((void)); |
|
| 217 |
-# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) |
|
| 218 |
-#endif |
| 219 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,323 +0,0 @@ |
| 1 |
-/* inffast.c -- fast decoding |
|
| 2 |
- * Copyright (C) 1995-2017 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-#include "zutil.h" |
|
| 7 |
-#include "inftrees.h" |
|
| 8 |
-#include "inflate.h" |
|
| 9 |
-#include "inffast.h" |
|
| 10 |
- |
|
| 11 |
-#ifdef ASMINF |
|
| 12 |
-# pragma message("Assembler code may have bugs -- use at your own risk")
|
|
| 13 |
-#else |
|
| 14 |
- |
|
| 15 |
-/* |
|
| 16 |
- Decode literal, length, and distance codes and write out the resulting |
|
| 17 |
- literal and match bytes until either not enough input or output is |
|
| 18 |
- available, an end-of-block is encountered, or a data error is encountered. |
|
| 19 |
- When large enough input and output buffers are supplied to inflate(), for |
|
| 20 |
- example, a 16K input buffer and a 64K output buffer, more than 95% of the |
|
| 21 |
- inflate execution time is spent in this routine. |
|
| 22 |
- |
|
| 23 |
- Entry assumptions: |
|
| 24 |
- |
|
| 25 |
- state->mode == LEN |
|
| 26 |
- strm->avail_in >= 6 |
|
| 27 |
- strm->avail_out >= 258 |
|
| 28 |
- start >= strm->avail_out |
|
| 29 |
- state->bits < 8 |
|
| 30 |
- |
|
| 31 |
- On return, state->mode is one of: |
|
| 32 |
- |
|
| 33 |
- LEN -- ran out of enough output space or enough available input |
|
| 34 |
- TYPE -- reached end of block code, inflate() to interpret next block |
|
| 35 |
- BAD -- error in block data |
|
| 36 |
- |
|
| 37 |
- Notes: |
|
| 38 |
- |
|
| 39 |
- - The maximum input bits used by a length/distance pair is 15 bits for the |
|
| 40 |
- length code, 5 bits for the length extra, 15 bits for the distance code, |
|
| 41 |
- and 13 bits for the distance extra. This totals 48 bits, or six bytes. |
|
| 42 |
- Therefore if strm->avail_in >= 6, then there is enough input to avoid |
|
| 43 |
- checking for available input while decoding. |
|
| 44 |
- |
|
| 45 |
- - The maximum bytes that a single length/distance pair can output is 258 |
|
| 46 |
- bytes, which is the maximum length that can be coded. inflate_fast() |
|
| 47 |
- requires strm->avail_out >= 258 for each loop to avoid checking for |
|
| 48 |
- output space. |
|
| 49 |
- */ |
|
| 50 |
-void ZLIB_INTERNAL inflate_fast(strm, start) |
|
| 51 |
-z_streamp strm; |
|
| 52 |
-unsigned start; /* inflate()'s starting value for strm->avail_out */ |
|
| 53 |
-{
|
|
| 54 |
- struct inflate_state FAR *state; |
|
| 55 |
- z_const unsigned char FAR *in; /* local strm->next_in */ |
|
| 56 |
- z_const unsigned char FAR *last; /* have enough input while in < last */ |
|
| 57 |
- unsigned char FAR *out; /* local strm->next_out */ |
|
| 58 |
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
|
| 59 |
- unsigned char FAR *end; /* while out < end, enough space available */ |
|
| 60 |
-#ifdef INFLATE_STRICT |
|
| 61 |
- unsigned dmax; /* maximum distance from zlib header */ |
|
| 62 |
-#endif |
|
| 63 |
- unsigned wsize; /* window size or zero if not using window */ |
|
| 64 |
- unsigned whave; /* valid bytes in the window */ |
|
| 65 |
- unsigned wnext; /* window write index */ |
|
| 66 |
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ |
|
| 67 |
- unsigned long hold; /* local strm->hold */ |
|
| 68 |
- unsigned bits; /* local strm->bits */ |
|
| 69 |
- code const FAR *lcode; /* local strm->lencode */ |
|
| 70 |
- code const FAR *dcode; /* local strm->distcode */ |
|
| 71 |
- unsigned lmask; /* mask for first level of length codes */ |
|
| 72 |
- unsigned dmask; /* mask for first level of distance codes */ |
|
| 73 |
- code here; /* retrieved table entry */ |
|
| 74 |
- unsigned op; /* code bits, operation, extra bits, or */ |
|
| 75 |
- /* window position, window bytes to copy */ |
|
| 76 |
- unsigned len; /* match length, unused bytes */ |
|
| 77 |
- unsigned dist; /* match distance */ |
|
| 78 |
- unsigned char FAR *from; /* where to copy match from */ |
|
| 79 |
- |
|
| 80 |
- /* copy state to local variables */ |
|
| 81 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 82 |
- in = strm->next_in; |
|
| 83 |
- last = in + (strm->avail_in - 5); |
|
| 84 |
- out = strm->next_out; |
|
| 85 |
- beg = out - (start - strm->avail_out); |
|
| 86 |
- end = out + (strm->avail_out - 257); |
|
| 87 |
-#ifdef INFLATE_STRICT |
|
| 88 |
- dmax = state->dmax; |
|
| 89 |
-#endif |
|
| 90 |
- wsize = state->wsize; |
|
| 91 |
- whave = state->whave; |
|
| 92 |
- wnext = state->wnext; |
|
| 93 |
- window = state->window; |
|
| 94 |
- hold = state->hold; |
|
| 95 |
- bits = state->bits; |
|
| 96 |
- lcode = state->lencode; |
|
| 97 |
- dcode = state->distcode; |
|
| 98 |
- lmask = (1U << state->lenbits) - 1; |
|
| 99 |
- dmask = (1U << state->distbits) - 1; |
|
| 100 |
- |
|
| 101 |
- /* decode literals and length/distances until end-of-block or not enough |
|
| 102 |
- input data or output space */ |
|
| 103 |
- do {
|
|
| 104 |
- if (bits < 15) {
|
|
| 105 |
- hold += (unsigned long)(*in++) << bits; |
|
| 106 |
- bits += 8; |
|
| 107 |
- hold += (unsigned long)(*in++) << bits; |
|
| 108 |
- bits += 8; |
|
| 109 |
- } |
|
| 110 |
- here = lcode[hold & lmask]; |
|
| 111 |
- dolen: |
|
| 112 |
- op = (unsigned)(here.bits); |
|
| 113 |
- hold >>= op; |
|
| 114 |
- bits -= op; |
|
| 115 |
- op = (unsigned)(here.op); |
|
| 116 |
- if (op == 0) { /* literal */
|
|
| 117 |
- Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? |
|
| 118 |
- "inflate: literal '%c'\n" : |
|
| 119 |
- "inflate: literal 0x%02x\n", here.val)); |
|
| 120 |
- *out++ = (unsigned char)(here.val); |
|
| 121 |
- } |
|
| 122 |
- else if (op & 16) { /* length base */
|
|
| 123 |
- len = (unsigned)(here.val); |
|
| 124 |
- op &= 15; /* number of extra bits */ |
|
| 125 |
- if (op) {
|
|
| 126 |
- if (bits < op) {
|
|
| 127 |
- hold += (unsigned long)(*in++) << bits; |
|
| 128 |
- bits += 8; |
|
| 129 |
- } |
|
| 130 |
- len += (unsigned)hold & ((1U << op) - 1); |
|
| 131 |
- hold >>= op; |
|
| 132 |
- bits -= op; |
|
| 133 |
- } |
|
| 134 |
- Tracevv((stderr, "inflate: length %u\n", len)); |
|
| 135 |
- if (bits < 15) {
|
|
| 136 |
- hold += (unsigned long)(*in++) << bits; |
|
| 137 |
- bits += 8; |
|
| 138 |
- hold += (unsigned long)(*in++) << bits; |
|
| 139 |
- bits += 8; |
|
| 140 |
- } |
|
| 141 |
- here = dcode[hold & dmask]; |
|
| 142 |
- dodist: |
|
| 143 |
- op = (unsigned)(here.bits); |
|
| 144 |
- hold >>= op; |
|
| 145 |
- bits -= op; |
|
| 146 |
- op = (unsigned)(here.op); |
|
| 147 |
- if (op & 16) { /* distance base */
|
|
| 148 |
- dist = (unsigned)(here.val); |
|
| 149 |
- op &= 15; /* number of extra bits */ |
|
| 150 |
- if (bits < op) {
|
|
| 151 |
- hold += (unsigned long)(*in++) << bits; |
|
| 152 |
- bits += 8; |
|
| 153 |
- if (bits < op) {
|
|
| 154 |
- hold += (unsigned long)(*in++) << bits; |
|
| 155 |
- bits += 8; |
|
| 156 |
- } |
|
| 157 |
- } |
|
| 158 |
- dist += (unsigned)hold & ((1U << op) - 1); |
|
| 159 |
-#ifdef INFLATE_STRICT |
|
| 160 |
- if (dist > dmax) {
|
|
| 161 |
- strm->msg = (char *)"invalid distance too far back"; |
|
| 162 |
- state->mode = BAD; |
|
| 163 |
- break; |
|
| 164 |
- } |
|
| 165 |
-#endif |
|
| 166 |
- hold >>= op; |
|
| 167 |
- bits -= op; |
|
| 168 |
- Tracevv((stderr, "inflate: distance %u\n", dist)); |
|
| 169 |
- op = (unsigned)(out - beg); /* max distance in output */ |
|
| 170 |
- if (dist > op) { /* see if copy from window */
|
|
| 171 |
- op = dist - op; /* distance back in window */ |
|
| 172 |
- if (op > whave) {
|
|
| 173 |
- if (state->sane) {
|
|
| 174 |
- strm->msg = |
|
| 175 |
- (char *)"invalid distance too far back"; |
|
| 176 |
- state->mode = BAD; |
|
| 177 |
- break; |
|
| 178 |
- } |
|
| 179 |
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
|
| 180 |
- if (len <= op - whave) {
|
|
| 181 |
- do {
|
|
| 182 |
- *out++ = 0; |
|
| 183 |
- } while (--len); |
|
| 184 |
- continue; |
|
| 185 |
- } |
|
| 186 |
- len -= op - whave; |
|
| 187 |
- do {
|
|
| 188 |
- *out++ = 0; |
|
| 189 |
- } while (--op > whave); |
|
| 190 |
- if (op == 0) {
|
|
| 191 |
- from = out - dist; |
|
| 192 |
- do {
|
|
| 193 |
- *out++ = *from++; |
|
| 194 |
- } while (--len); |
|
| 195 |
- continue; |
|
| 196 |
- } |
|
| 197 |
-#endif |
|
| 198 |
- } |
|
| 199 |
- from = window; |
|
| 200 |
- if (wnext == 0) { /* very common case */
|
|
| 201 |
- from += wsize - op; |
|
| 202 |
- if (op < len) { /* some from window */
|
|
| 203 |
- len -= op; |
|
| 204 |
- do {
|
|
| 205 |
- *out++ = *from++; |
|
| 206 |
- } while (--op); |
|
| 207 |
- from = out - dist; /* rest from output */ |
|
| 208 |
- } |
|
| 209 |
- } |
|
| 210 |
- else if (wnext < op) { /* wrap around window */
|
|
| 211 |
- from += wsize + wnext - op; |
|
| 212 |
- op -= wnext; |
|
| 213 |
- if (op < len) { /* some from end of window */
|
|
| 214 |
- len -= op; |
|
| 215 |
- do {
|
|
| 216 |
- *out++ = *from++; |
|
| 217 |
- } while (--op); |
|
| 218 |
- from = window; |
|
| 219 |
- if (wnext < len) { /* some from start of window */
|
|
| 220 |
- op = wnext; |
|
| 221 |
- len -= op; |
|
| 222 |
- do {
|
|
| 223 |
- *out++ = *from++; |
|
| 224 |
- } while (--op); |
|
| 225 |
- from = out - dist; /* rest from output */ |
|
| 226 |
- } |
|
| 227 |
- } |
|
| 228 |
- } |
|
| 229 |
- else { /* contiguous in window */
|
|
| 230 |
- from += wnext - op; |
|
| 231 |
- if (op < len) { /* some from window */
|
|
| 232 |
- len -= op; |
|
| 233 |
- do {
|
|
| 234 |
- *out++ = *from++; |
|
| 235 |
- } while (--op); |
|
| 236 |
- from = out - dist; /* rest from output */ |
|
| 237 |
- } |
|
| 238 |
- } |
|
| 239 |
- while (len > 2) {
|
|
| 240 |
- *out++ = *from++; |
|
| 241 |
- *out++ = *from++; |
|
| 242 |
- *out++ = *from++; |
|
| 243 |
- len -= 3; |
|
| 244 |
- } |
|
| 245 |
- if (len) {
|
|
| 246 |
- *out++ = *from++; |
|
| 247 |
- if (len > 1) |
|
| 248 |
- *out++ = *from++; |
|
| 249 |
- } |
|
| 250 |
- } |
|
| 251 |
- else {
|
|
| 252 |
- from = out - dist; /* copy direct from output */ |
|
| 253 |
- do { /* minimum length is three */
|
|
| 254 |
- *out++ = *from++; |
|
| 255 |
- *out++ = *from++; |
|
| 256 |
- *out++ = *from++; |
|
| 257 |
- len -= 3; |
|
| 258 |
- } while (len > 2); |
|
| 259 |
- if (len) {
|
|
| 260 |
- *out++ = *from++; |
|
| 261 |
- if (len > 1) |
|
| 262 |
- *out++ = *from++; |
|
| 263 |
- } |
|
| 264 |
- } |
|
| 265 |
- } |
|
| 266 |
- else if ((op & 64) == 0) { /* 2nd level distance code */
|
|
| 267 |
- here = dcode[here.val + (hold & ((1U << op) - 1))]; |
|
| 268 |
- goto dodist; |
|
| 269 |
- } |
|
| 270 |
- else {
|
|
| 271 |
- strm->msg = (char *)"invalid distance code"; |
|
| 272 |
- state->mode = BAD; |
|
| 273 |
- break; |
|
| 274 |
- } |
|
| 275 |
- } |
|
| 276 |
- else if ((op & 64) == 0) { /* 2nd level length code */
|
|
| 277 |
- here = lcode[here.val + (hold & ((1U << op) - 1))]; |
|
| 278 |
- goto dolen; |
|
| 279 |
- } |
|
| 280 |
- else if (op & 32) { /* end-of-block */
|
|
| 281 |
- Tracevv((stderr, "inflate: end of block\n")); |
|
| 282 |
- state->mode = TYPE; |
|
| 283 |
- break; |
|
| 284 |
- } |
|
| 285 |
- else {
|
|
| 286 |
- strm->msg = (char *)"invalid literal/length code"; |
|
| 287 |
- state->mode = BAD; |
|
| 288 |
- break; |
|
| 289 |
- } |
|
| 290 |
- } while (in < last && out < end); |
|
| 291 |
- |
|
| 292 |
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ |
|
| 293 |
- len = bits >> 3; |
|
| 294 |
- in -= len; |
|
| 295 |
- bits -= len << 3; |
|
| 296 |
- hold &= (1U << bits) - 1; |
|
| 297 |
- |
|
| 298 |
- /* update state and return */ |
|
| 299 |
- strm->next_in = in; |
|
| 300 |
- strm->next_out = out; |
|
| 301 |
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); |
|
| 302 |
- strm->avail_out = (unsigned)(out < end ? |
|
| 303 |
- 257 + (end - out) : 257 - (out - end)); |
|
| 304 |
- state->hold = hold; |
|
| 305 |
- state->bits = bits; |
|
| 306 |
- return; |
|
| 307 |
-} |
|
| 308 |
- |
|
| 309 |
-/* |
|
| 310 |
- inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): |
|
| 311 |
- - Using bit fields for code structure |
|
| 312 |
- - Different op definition to avoid & for extra bits (do & for table bits) |
|
| 313 |
- - Three separate decoding do-loops for direct, window, and wnext == 0 |
|
| 314 |
- - Special case for distance > 1 copies to do overlapped load and store copy |
|
| 315 |
- - Explicit branch predictions (based on measured branch probabilities) |
|
| 316 |
- - Deferring match copy and interspersed it with decoding subsequent codes |
|
| 317 |
- - Swapping literal/length else |
|
| 318 |
- - Swapping window/direct else |
|
| 319 |
- - Larger unrolled copy loops (three is about right) |
|
| 320 |
- - Moving len -= 3 statement into middle of loop |
|
| 321 |
- */ |
|
| 322 |
- |
|
| 323 |
-#endif /* !ASMINF */ |
| 324 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,11 +0,0 @@ |
| 1 |
-/* inffast.h -- header to use inffast.c |
|
| 2 |
- * Copyright (C) 1995-2003, 2010 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* WARNING: this file should *not* be used by applications. It is |
|
| 7 |
- part of the implementation of the compression library and is |
|
| 8 |
- subject to change. Applications should only use zlib.h. |
|
| 9 |
- */ |
|
| 10 |
- |
|
| 11 |
-void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); |
| 12 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,94 +0,0 @@ |
| 1 |
- /* inffixed.h -- table for decoding fixed codes |
|
| 2 |
- * Generated automatically by makefixed(). |
|
| 3 |
- */ |
|
| 4 |
- |
|
| 5 |
- /* WARNING: this file should *not* be used by applications. |
|
| 6 |
- It is part of the implementation of this library and is |
|
| 7 |
- subject to change. Applications should only use zlib.h. |
|
| 8 |
- */ |
|
| 9 |
- |
|
| 10 |
- static const code lenfix[512] = {
|
|
| 11 |
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
|
|
| 12 |
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
|
|
| 13 |
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
|
|
| 14 |
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
|
|
| 15 |
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
|
|
| 16 |
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
|
|
| 17 |
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
|
|
| 18 |
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
|
|
| 19 |
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
|
|
| 20 |
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
|
|
| 21 |
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
|
|
| 22 |
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
|
|
| 23 |
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
|
|
| 24 |
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
|
|
| 25 |
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
|
|
| 26 |
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
|
|
| 27 |
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
|
|
| 28 |
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
|
|
| 29 |
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
|
|
| 30 |
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
|
|
| 31 |
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
|
|
| 32 |
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
|
|
| 33 |
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
|
|
| 34 |
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
|
|
| 35 |
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
|
|
| 36 |
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
|
|
| 37 |
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
|
|
| 38 |
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
|
|
| 39 |
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
|
|
| 40 |
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
|
|
| 41 |
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
|
|
| 42 |
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
|
|
| 43 |
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
|
|
| 44 |
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
|
|
| 45 |
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
|
|
| 46 |
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
|
|
| 47 |
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
|
|
| 48 |
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
|
|
| 49 |
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
|
|
| 50 |
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
|
|
| 51 |
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
|
|
| 52 |
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
|
|
| 53 |
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
|
|
| 54 |
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
|
|
| 55 |
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
|
|
| 56 |
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
|
|
| 57 |
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
|
|
| 58 |
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
|
|
| 59 |
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
|
|
| 60 |
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
|
|
| 61 |
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
|
|
| 62 |
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
|
|
| 63 |
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
|
|
| 64 |
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
|
|
| 65 |
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
|
|
| 66 |
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
|
|
| 67 |
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
|
|
| 68 |
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
|
|
| 69 |
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
|
|
| 70 |
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
|
|
| 71 |
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
|
|
| 72 |
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
|
|
| 73 |
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
|
|
| 74 |
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
|
|
| 75 |
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
|
|
| 76 |
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
|
|
| 77 |
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
|
|
| 78 |
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
|
|
| 79 |
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
|
|
| 80 |
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
|
|
| 81 |
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
|
|
| 82 |
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
|
|
| 83 |
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
|
|
| 84 |
- {0,9,255}
|
|
| 85 |
- }; |
|
| 86 |
- |
|
| 87 |
- static const code distfix[32] = {
|
|
| 88 |
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
|
|
| 89 |
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
|
|
| 90 |
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
|
|
| 91 |
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
|
|
| 92 |
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
|
|
| 93 |
- {22,5,193},{64,5,0}
|
|
| 94 |
- }; |
| 95 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,1561 +0,0 @@ |
| 1 |
-/* inflate.c -- zlib decompression |
|
| 2 |
- * Copyright (C) 1995-2016 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* |
|
| 7 |
- * Change history: |
|
| 8 |
- * |
|
| 9 |
- * 1.2.beta0 24 Nov 2002 |
|
| 10 |
- * - First version -- complete rewrite of inflate to simplify code, avoid |
|
| 11 |
- * creation of window when not needed, minimize use of window when it is |
|
| 12 |
- * needed, make inffast.c even faster, implement gzip decoding, and to |
|
| 13 |
- * improve code readability and style over the previous zlib inflate code |
|
| 14 |
- * |
|
| 15 |
- * 1.2.beta1 25 Nov 2002 |
|
| 16 |
- * - Use pointers for available input and output checking in inffast.c |
|
| 17 |
- * - Remove input and output counters in inffast.c |
|
| 18 |
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 |
|
| 19 |
- * - Remove unnecessary second byte pull from length extra in inffast.c |
|
| 20 |
- * - Unroll direct copy to three copies per loop in inffast.c |
|
| 21 |
- * |
|
| 22 |
- * 1.2.beta2 4 Dec 2002 |
|
| 23 |
- * - Change external routine names to reduce potential conflicts |
|
| 24 |
- * - Correct filename to inffixed.h for fixed tables in inflate.c |
|
| 25 |
- * - Make hbuf[] unsigned char to match parameter type in inflate.c |
|
| 26 |
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) |
|
| 27 |
- * to avoid negation problem on Alphas (64 bit) in inflate.c |
|
| 28 |
- * |
|
| 29 |
- * 1.2.beta3 22 Dec 2002 |
|
| 30 |
- * - Add comments on state->bits assertion in inffast.c |
|
| 31 |
- * - Add comments on op field in inftrees.h |
|
| 32 |
- * - Fix bug in reuse of allocated window after inflateReset() |
|
| 33 |
- * - Remove bit fields--back to byte structure for speed |
|
| 34 |
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths |
|
| 35 |
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased? |
|
| 36 |
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?) |
|
| 37 |
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used |
|
| 38 |
- * - Use local copies of stream next and avail values, as well as local bit |
|
| 39 |
- * buffer and bit count in inflate()--for speed when inflate_fast() not used |
|
| 40 |
- * |
|
| 41 |
- * 1.2.beta4 1 Jan 2003 |
|
| 42 |
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings |
|
| 43 |
- * - Move a comment on output buffer sizes from inffast.c to inflate.c |
|
| 44 |
- * - Add comments in inffast.c to introduce the inflate_fast() routine |
|
| 45 |
- * - Rearrange window copies in inflate_fast() for speed and simplification |
|
| 46 |
- * - Unroll last copy for window match in inflate_fast() |
|
| 47 |
- * - Use local copies of window variables in inflate_fast() for speed |
|
| 48 |
- * - Pull out common wnext == 0 case for speed in inflate_fast() |
|
| 49 |
- * - Make op and len in inflate_fast() unsigned for consistency |
|
| 50 |
- * - Add FAR to lcode and dcode declarations in inflate_fast() |
|
| 51 |
- * - Simplified bad distance check in inflate_fast() |
|
| 52 |
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new |
|
| 53 |
- * source file infback.c to provide a call-back interface to inflate for |
|
| 54 |
- * programs like gzip and unzip -- uses window as output buffer to avoid |
|
| 55 |
- * window copying |
|
| 56 |
- * |
|
| 57 |
- * 1.2.beta5 1 Jan 2003 |
|
| 58 |
- * - Improved inflateBack() interface to allow the caller to provide initial |
|
| 59 |
- * input in strm. |
|
| 60 |
- * - Fixed stored blocks bug in inflateBack() |
|
| 61 |
- * |
|
| 62 |
- * 1.2.beta6 4 Jan 2003 |
|
| 63 |
- * - Added comments in inffast.c on effectiveness of POSTINC |
|
| 64 |
- * - Typecasting all around to reduce compiler warnings |
|
| 65 |
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
|
|
| 66 |
- * make compilers happy |
|
| 67 |
- * - Changed type of window in inflateBackInit() to unsigned char * |
|
| 68 |
- * |
|
| 69 |
- * 1.2.beta7 27 Jan 2003 |
|
| 70 |
- * - Changed many types to unsigned or unsigned short to avoid warnings |
|
| 71 |
- * - Added inflateCopy() function |
|
| 72 |
- * |
|
| 73 |
- * 1.2.0 9 Mar 2003 |
|
| 74 |
- * - Changed inflateBack() interface to provide separate opaque descriptors |
|
| 75 |
- * for the in() and out() functions |
|
| 76 |
- * - Changed inflateBack() argument and in_func typedef to swap the length |
|
| 77 |
- * and buffer address return values for the input function |
|
| 78 |
- * - Check next_in and next_out for Z_NULL on entry to inflate() |
|
| 79 |
- * |
|
| 80 |
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. |
|
| 81 |
- */ |
|
| 82 |
- |
|
| 83 |
-#include "zutil.h" |
|
| 84 |
-#include "inftrees.h" |
|
| 85 |
-#include "inflate.h" |
|
| 86 |
-#include "inffast.h" |
|
| 87 |
- |
|
| 88 |
-#ifdef MAKEFIXED |
|
| 89 |
-# ifndef BUILDFIXED |
|
| 90 |
-# define BUILDFIXED |
|
| 91 |
-# endif |
|
| 92 |
-#endif |
|
| 93 |
- |
|
| 94 |
-/* function prototypes */ |
|
| 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; |
|
| 109 |
- if (strm == Z_NULL || |
|
| 110 |
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
|
| 111 |
- return 1; |
|
| 112 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 113 |
- if (state == Z_NULL || state->strm != strm || |
|
| 114 |
- state->mode < HEAD || state->mode > SYNC) |
|
| 115 |
- return 1; |
|
| 116 |
- return 0; |
|
| 117 |
-} |
|
| 118 |
- |
|
| 119 |
-int ZEXPORT inflateResetKeep(strm) |
|
| 120 |
-z_streamp strm; |
|
| 121 |
-{
|
|
| 122 |
- struct inflate_state FAR *state; |
|
| 123 |
- |
|
| 124 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 125 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 126 |
- strm->total_in = strm->total_out = state->total = 0; |
|
| 127 |
- strm->msg = Z_NULL; |
|
| 128 |
- if (state->wrap) /* to support ill-conceived Java test suite */ |
|
| 129 |
- strm->adler = state->wrap & 1; |
|
| 130 |
- state->mode = HEAD; |
|
| 131 |
- state->last = 0; |
|
| 132 |
- state->havedict = 0; |
|
| 133 |
- state->dmax = 32768U; |
|
| 134 |
- state->head = Z_NULL; |
|
| 135 |
- state->hold = 0; |
|
| 136 |
- state->bits = 0; |
|
| 137 |
- state->lencode = state->distcode = state->next = state->codes; |
|
| 138 |
- state->sane = 1; |
|
| 139 |
- state->back = -1; |
|
| 140 |
- Tracev((stderr, "inflate: reset\n")); |
|
| 141 |
- return Z_OK; |
|
| 142 |
-} |
|
| 143 |
- |
|
| 144 |
-int ZEXPORT inflateReset(strm) |
|
| 145 |
-z_streamp strm; |
|
| 146 |
-{
|
|
| 147 |
- struct inflate_state FAR *state; |
|
| 148 |
- |
|
| 149 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 150 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 151 |
- state->wsize = 0; |
|
| 152 |
- state->whave = 0; |
|
| 153 |
- state->wnext = 0; |
|
| 154 |
- return inflateResetKeep(strm); |
|
| 155 |
-} |
|
| 156 |
- |
|
| 157 |
-int ZEXPORT inflateReset2(strm, windowBits) |
|
| 158 |
-z_streamp strm; |
|
| 159 |
-int windowBits; |
|
| 160 |
-{
|
|
| 161 |
- int wrap; |
|
| 162 |
- struct inflate_state FAR *state; |
|
| 163 |
- |
|
| 164 |
- /* get the state */ |
|
| 165 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 166 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 167 |
- |
|
| 168 |
- /* extract wrap request from windowBits parameter */ |
|
| 169 |
- if (windowBits < 0) {
|
|
| 170 |
- wrap = 0; |
|
| 171 |
- windowBits = -windowBits; |
|
| 172 |
- } |
|
| 173 |
- else {
|
|
| 174 |
- wrap = (windowBits >> 4) + 5; |
|
| 175 |
-#ifdef GUNZIP |
|
| 176 |
- if (windowBits < 48) |
|
| 177 |
- windowBits &= 15; |
|
| 178 |
-#endif |
|
| 179 |
- } |
|
| 180 |
- |
|
| 181 |
- /* set number of window bits, free window if different */ |
|
| 182 |
- if (windowBits && (windowBits < 8 || windowBits > 15)) |
|
| 183 |
- return Z_STREAM_ERROR; |
|
| 184 |
- if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
|
|
| 185 |
- ZFREE(strm, state->window); |
|
| 186 |
- state->window = Z_NULL; |
|
| 187 |
- } |
|
| 188 |
- |
|
| 189 |
- /* update state and reset the rest of it */ |
|
| 190 |
- state->wrap = wrap; |
|
| 191 |
- state->wbits = (unsigned)windowBits; |
|
| 192 |
- return inflateReset(strm); |
|
| 193 |
-} |
|
| 194 |
- |
|
| 195 |
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) |
|
| 196 |
-z_streamp strm; |
|
| 197 |
-int windowBits; |
|
| 198 |
-const char *version; |
|
| 199 |
-int stream_size; |
|
| 200 |
-{
|
|
| 201 |
- int ret; |
|
| 202 |
- struct inflate_state FAR *state; |
|
| 203 |
- |
|
| 204 |
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
|
| 205 |
- stream_size != (int)(sizeof(z_stream))) |
|
| 206 |
- return Z_VERSION_ERROR; |
|
| 207 |
- if (strm == Z_NULL) return Z_STREAM_ERROR; |
|
| 208 |
- strm->msg = Z_NULL; /* in case we return an error */ |
|
| 209 |
- if (strm->zalloc == (alloc_func)0) {
|
|
| 210 |
-#ifdef Z_SOLO |
|
| 211 |
- return Z_STREAM_ERROR; |
|
| 212 |
-#else |
|
| 213 |
- strm->zalloc = zcalloc; |
|
| 214 |
- strm->opaque = (voidpf)0; |
|
| 215 |
-#endif |
|
| 216 |
- } |
|
| 217 |
- if (strm->zfree == (free_func)0) |
|
| 218 |
-#ifdef Z_SOLO |
|
| 219 |
- return Z_STREAM_ERROR; |
|
| 220 |
-#else |
|
| 221 |
- strm->zfree = zcfree; |
|
| 222 |
-#endif |
|
| 223 |
- state = (struct inflate_state FAR *) |
|
| 224 |
- ZALLOC(strm, 1, sizeof(struct inflate_state)); |
|
| 225 |
- if (state == Z_NULL) return Z_MEM_ERROR; |
|
| 226 |
- Tracev((stderr, "inflate: allocated\n")); |
|
| 227 |
- strm->state = (struct internal_state FAR *)state; |
|
| 228 |
- state->strm = strm; |
|
| 229 |
- state->window = Z_NULL; |
|
| 230 |
- state->mode = HEAD; /* to pass state test in inflateReset2() */ |
|
| 231 |
- ret = inflateReset2(strm, windowBits); |
|
| 232 |
- if (ret != Z_OK) {
|
|
| 233 |
- ZFREE(strm, state); |
|
| 234 |
- strm->state = Z_NULL; |
|
| 235 |
- } |
|
| 236 |
- return ret; |
|
| 237 |
-} |
|
| 238 |
- |
|
| 239 |
-int ZEXPORT inflateInit_(strm, version, stream_size) |
|
| 240 |
-z_streamp strm; |
|
| 241 |
-const char *version; |
|
| 242 |
-int stream_size; |
|
| 243 |
-{
|
|
| 244 |
- return inflateInit2_(strm, DEF_WBITS, version, stream_size); |
|
| 245 |
-} |
|
| 246 |
- |
|
| 247 |
-int ZEXPORT inflatePrime(strm, bits, value) |
|
| 248 |
-z_streamp strm; |
|
| 249 |
-int bits; |
|
| 250 |
-int value; |
|
| 251 |
-{
|
|
| 252 |
- struct inflate_state FAR *state; |
|
| 253 |
- |
|
| 254 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 255 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 256 |
- if (bits < 0) {
|
|
| 257 |
- state->hold = 0; |
|
| 258 |
- state->bits = 0; |
|
| 259 |
- return Z_OK; |
|
| 260 |
- } |
|
| 261 |
- if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; |
|
| 262 |
- value &= (1L << bits) - 1; |
|
| 263 |
- state->hold += (unsigned)value << state->bits; |
|
| 264 |
- state->bits += (uInt)bits; |
|
| 265 |
- return Z_OK; |
|
| 266 |
-} |
|
| 267 |
- |
|
| 268 |
-/* |
|
| 269 |
- Return state with length and distance decoding tables and index sizes set to |
|
| 270 |
- fixed code decoding. Normally this returns fixed tables from inffixed.h. |
|
| 271 |
- If BUILDFIXED is defined, then instead this routine builds the tables the |
|
| 272 |
- first time it's called, and returns those tables the first time and |
|
| 273 |
- thereafter. This reduces the size of the code by about 2K bytes, in |
|
| 274 |
- exchange for a little execution time. However, BUILDFIXED should not be |
|
| 275 |
- used for threaded applications, since the rewriting of the tables and virgin |
|
| 276 |
- may not be thread-safe. |
|
| 277 |
- */ |
|
| 278 |
-local void fixedtables(state) |
|
| 279 |
-struct inflate_state FAR *state; |
|
| 280 |
-{
|
|
| 281 |
-#ifdef BUILDFIXED |
|
| 282 |
- static int virgin = 1; |
|
| 283 |
- static code *lenfix, *distfix; |
|
| 284 |
- static code fixed[544]; |
|
| 285 |
- |
|
| 286 |
- /* build fixed huffman tables if first call (may not be thread safe) */ |
|
| 287 |
- if (virgin) {
|
|
| 288 |
- unsigned sym, bits; |
|
| 289 |
- static code *next; |
|
| 290 |
- |
|
| 291 |
- /* literal/length table */ |
|
| 292 |
- sym = 0; |
|
| 293 |
- while (sym < 144) state->lens[sym++] = 8; |
|
| 294 |
- while (sym < 256) state->lens[sym++] = 9; |
|
| 295 |
- while (sym < 280) state->lens[sym++] = 7; |
|
| 296 |
- while (sym < 288) state->lens[sym++] = 8; |
|
| 297 |
- next = fixed; |
|
| 298 |
- lenfix = next; |
|
| 299 |
- bits = 9; |
|
| 300 |
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); |
|
| 301 |
- |
|
| 302 |
- /* distance table */ |
|
| 303 |
- sym = 0; |
|
| 304 |
- while (sym < 32) state->lens[sym++] = 5; |
|
| 305 |
- distfix = next; |
|
| 306 |
- bits = 5; |
|
| 307 |
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); |
|
| 308 |
- |
|
| 309 |
- /* do this just once */ |
|
| 310 |
- virgin = 0; |
|
| 311 |
- } |
|
| 312 |
-#else /* !BUILDFIXED */ |
|
| 313 |
-# include "inffixed.h" |
|
| 314 |
-#endif /* BUILDFIXED */ |
|
| 315 |
- state->lencode = lenfix; |
|
| 316 |
- state->lenbits = 9; |
|
| 317 |
- state->distcode = distfix; |
|
| 318 |
- state->distbits = 5; |
|
| 319 |
-} |
|
| 320 |
- |
|
| 321 |
-#ifdef MAKEFIXED |
|
| 322 |
-#include <stdio.h> |
|
| 323 |
- |
|
| 324 |
-/* |
|
| 325 |
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also |
|
| 326 |
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes |
|
| 327 |
- those tables to stdout, which would be piped to inffixed.h. A small program |
|
| 328 |
- can simply call makefixed to do this: |
|
| 329 |
- |
|
| 330 |
- void makefixed(void); |
|
| 331 |
- |
|
| 332 |
- int main(void) |
|
| 333 |
- {
|
|
| 334 |
- makefixed(); |
|
| 335 |
- return 0; |
|
| 336 |
- } |
|
| 337 |
- |
|
| 338 |
- Then that can be linked with zlib built with MAKEFIXED defined and run: |
|
| 339 |
- |
|
| 340 |
- a.out > inffixed.h |
|
| 341 |
- */ |
|
| 342 |
-void makefixed() |
|
| 343 |
-{
|
|
| 344 |
- unsigned low, size; |
|
| 345 |
- struct inflate_state state; |
|
| 346 |
- |
|
| 347 |
- fixedtables(&state); |
|
| 348 |
- puts(" /* inffixed.h -- table for decoding fixed codes");
|
|
| 349 |
- puts(" * Generated automatically by makefixed().");
|
|
| 350 |
- puts(" */");
|
|
| 351 |
- puts("");
|
|
| 352 |
- puts(" /* WARNING: this file should *not* be used by applications.");
|
|
| 353 |
- puts(" It is part of the implementation of this library and is");
|
|
| 354 |
- puts(" subject to change. Applications should only use zlib.h.");
|
|
| 355 |
- puts(" */");
|
|
| 356 |
- puts("");
|
|
| 357 |
- size = 1U << 9; |
|
| 358 |
- printf(" static const code lenfix[%u] = {", size);
|
|
| 359 |
- low = 0; |
|
| 360 |
- for (;;) {
|
|
| 361 |
- if ((low % 7) == 0) printf("\n ");
|
|
| 362 |
- printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
|
|
| 363 |
- state.lencode[low].bits, state.lencode[low].val); |
|
| 364 |
- if (++low == size) break; |
|
| 365 |
- putchar(',');
|
|
| 366 |
- } |
|
| 367 |
- puts("\n };");
|
|
| 368 |
- size = 1U << 5; |
|
| 369 |
- printf("\n static const code distfix[%u] = {", size);
|
|
| 370 |
- low = 0; |
|
| 371 |
- for (;;) {
|
|
| 372 |
- if ((low % 6) == 0) printf("\n ");
|
|
| 373 |
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
|
|
| 374 |
- state.distcode[low].val); |
|
| 375 |
- if (++low == size) break; |
|
| 376 |
- putchar(',');
|
|
| 377 |
- } |
|
| 378 |
- puts("\n };");
|
|
| 379 |
-} |
|
| 380 |
-#endif /* MAKEFIXED */ |
|
| 381 |
- |
|
| 382 |
-/* |
|
| 383 |
- Update the window with the last wsize (normally 32K) bytes written before |
|
| 384 |
- returning. If window does not exist yet, create it. This is only called |
|
| 385 |
- when a window is already in use, or when output has been written during this |
|
| 386 |
- inflate call, but the end of the deflate stream has not been reached yet. |
|
| 387 |
- It is also called to create a window for dictionary data when a dictionary |
|
| 388 |
- is loaded. |
|
| 389 |
- |
|
| 390 |
- Providing output buffers larger than 32K to inflate() should provide a speed |
|
| 391 |
- advantage, since only the last 32K of output is copied to the sliding window |
|
| 392 |
- upon return from inflate(), and since all distances after the first 32K of |
|
| 393 |
- output will fall in the output data, making match copies simpler and faster. |
|
| 394 |
- The advantage may be dependent on the size of the processor's data caches. |
|
| 395 |
- */ |
|
| 396 |
-local int updatewindow(strm, end, copy) |
|
| 397 |
-z_streamp strm; |
|
| 398 |
-const Bytef *end; |
|
| 399 |
-unsigned copy; |
|
| 400 |
-{
|
|
| 401 |
- struct inflate_state FAR *state; |
|
| 402 |
- unsigned dist; |
|
| 403 |
- |
|
| 404 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 405 |
- |
|
| 406 |
- /* if it hasn't been done already, allocate space for the window */ |
|
| 407 |
- if (state->window == Z_NULL) {
|
|
| 408 |
- state->window = (unsigned char FAR *) |
|
| 409 |
- ZALLOC(strm, 1U << state->wbits, |
|
| 410 |
- sizeof(unsigned char)); |
|
| 411 |
- if (state->window == Z_NULL) return 1; |
|
| 412 |
- } |
|
| 413 |
- |
|
| 414 |
- /* if window not in use yet, initialize */ |
|
| 415 |
- if (state->wsize == 0) {
|
|
| 416 |
- state->wsize = 1U << state->wbits; |
|
| 417 |
- state->wnext = 0; |
|
| 418 |
- state->whave = 0; |
|
| 419 |
- } |
|
| 420 |
- |
|
| 421 |
- /* copy state->wsize or less output bytes into the circular window */ |
|
| 422 |
- if (copy >= state->wsize) {
|
|
| 423 |
- zmemcpy(state->window, end - state->wsize, state->wsize); |
|
| 424 |
- state->wnext = 0; |
|
| 425 |
- state->whave = state->wsize; |
|
| 426 |
- } |
|
| 427 |
- else {
|
|
| 428 |
- dist = state->wsize - state->wnext; |
|
| 429 |
- if (dist > copy) dist = copy; |
|
| 430 |
- zmemcpy(state->window + state->wnext, end - copy, dist); |
|
| 431 |
- copy -= dist; |
|
| 432 |
- if (copy) {
|
|
| 433 |
- zmemcpy(state->window, end - copy, copy); |
|
| 434 |
- state->wnext = copy; |
|
| 435 |
- state->whave = state->wsize; |
|
| 436 |
- } |
|
| 437 |
- else {
|
|
| 438 |
- state->wnext += dist; |
|
| 439 |
- if (state->wnext == state->wsize) state->wnext = 0; |
|
| 440 |
- if (state->whave < state->wsize) state->whave += dist; |
|
| 441 |
- } |
|
| 442 |
- } |
|
| 443 |
- return 0; |
|
| 444 |
-} |
|
| 445 |
- |
|
| 446 |
-/* Macros for inflate(): */ |
|
| 447 |
- |
|
| 448 |
-/* check function to use adler32() for zlib or crc32() for gzip */ |
|
| 449 |
-#ifdef GUNZIP |
|
| 450 |
-# define UPDATE(check, buf, len) \ |
|
| 451 |
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) |
|
| 452 |
-#else |
|
| 453 |
-# define UPDATE(check, buf, len) adler32(check, buf, len) |
|
| 454 |
-#endif |
|
| 455 |
- |
|
| 456 |
-/* check macros for header crc */ |
|
| 457 |
-#ifdef GUNZIP |
|
| 458 |
-# define CRC2(check, word) \ |
|
| 459 |
- do { \
|
|
| 460 |
- hbuf[0] = (unsigned char)(word); \ |
|
| 461 |
- hbuf[1] = (unsigned char)((word) >> 8); \ |
|
| 462 |
- check = crc32(check, hbuf, 2); \ |
|
| 463 |
- } while (0) |
|
| 464 |
- |
|
| 465 |
-# define CRC4(check, word) \ |
|
| 466 |
- do { \
|
|
| 467 |
- hbuf[0] = (unsigned char)(word); \ |
|
| 468 |
- hbuf[1] = (unsigned char)((word) >> 8); \ |
|
| 469 |
- hbuf[2] = (unsigned char)((word) >> 16); \ |
|
| 470 |
- hbuf[3] = (unsigned char)((word) >> 24); \ |
|
| 471 |
- check = crc32(check, hbuf, 4); \ |
|
| 472 |
- } while (0) |
|
| 473 |
-#endif |
|
| 474 |
- |
|
| 475 |
-/* Load registers with state in inflate() for speed */ |
|
| 476 |
-#define LOAD() \ |
|
| 477 |
- do { \
|
|
| 478 |
- put = strm->next_out; \ |
|
| 479 |
- left = strm->avail_out; \ |
|
| 480 |
- next = strm->next_in; \ |
|
| 481 |
- have = strm->avail_in; \ |
|
| 482 |
- hold = state->hold; \ |
|
| 483 |
- bits = state->bits; \ |
|
| 484 |
- } while (0) |
|
| 485 |
- |
|
| 486 |
-/* Restore state from registers in inflate() */ |
|
| 487 |
-#define RESTORE() \ |
|
| 488 |
- do { \
|
|
| 489 |
- strm->next_out = put; \ |
|
| 490 |
- strm->avail_out = left; \ |
|
| 491 |
- strm->next_in = next; \ |
|
| 492 |
- strm->avail_in = have; \ |
|
| 493 |
- state->hold = hold; \ |
|
| 494 |
- state->bits = bits; \ |
|
| 495 |
- } while (0) |
|
| 496 |
- |
|
| 497 |
-/* Clear the input bit accumulator */ |
|
| 498 |
-#define INITBITS() \ |
|
| 499 |
- do { \
|
|
| 500 |
- hold = 0; \ |
|
| 501 |
- bits = 0; \ |
|
| 502 |
- } while (0) |
|
| 503 |
- |
|
| 504 |
-/* Get a byte of input into the bit accumulator, or return from inflate() |
|
| 505 |
- if there is no input available. */ |
|
| 506 |
-#define PULLBYTE() \ |
|
| 507 |
- do { \
|
|
| 508 |
- if (have == 0) goto inf_leave; \ |
|
| 509 |
- have--; \ |
|
| 510 |
- hold += (unsigned long)(*next++) << bits; \ |
|
| 511 |
- bits += 8; \ |
|
| 512 |
- } while (0) |
|
| 513 |
- |
|
| 514 |
-/* Assure that there are at least n bits in the bit accumulator. If there is |
|
| 515 |
- not enough available input to do that, then return from inflate(). */ |
|
| 516 |
-#define NEEDBITS(n) \ |
|
| 517 |
- do { \
|
|
| 518 |
- while (bits < (unsigned)(n)) \ |
|
| 519 |
- PULLBYTE(); \ |
|
| 520 |
- } while (0) |
|
| 521 |
- |
|
| 522 |
-/* Return the low n bits of the bit accumulator (n < 16) */ |
|
| 523 |
-#define BITS(n) \ |
|
| 524 |
- ((unsigned)hold & ((1U << (n)) - 1)) |
|
| 525 |
- |
|
| 526 |
-/* Remove n bits from the bit accumulator */ |
|
| 527 |
-#define DROPBITS(n) \ |
|
| 528 |
- do { \
|
|
| 529 |
- hold >>= (n); \ |
|
| 530 |
- bits -= (unsigned)(n); \ |
|
| 531 |
- } while (0) |
|
| 532 |
- |
|
| 533 |
-/* Remove zero to seven bits as needed to go to a byte boundary */ |
|
| 534 |
-#define BYTEBITS() \ |
|
| 535 |
- do { \
|
|
| 536 |
- hold >>= bits & 7; \ |
|
| 537 |
- bits -= bits & 7; \ |
|
| 538 |
- } while (0) |
|
| 539 |
- |
|
| 540 |
-/* |
|
| 541 |
- inflate() uses a state machine to process as much input data and generate as |
|
| 542 |
- much output data as possible before returning. The state machine is |
|
| 543 |
- structured roughly as follows: |
|
| 544 |
- |
|
| 545 |
- for (;;) switch (state) {
|
|
| 546 |
- ... |
|
| 547 |
- case STATEn: |
|
| 548 |
- if (not enough input data or output space to make progress) |
|
| 549 |
- return; |
|
| 550 |
- ... make progress ... |
|
| 551 |
- state = STATEm; |
|
| 552 |
- break; |
|
| 553 |
- ... |
|
| 554 |
- } |
|
| 555 |
- |
|
| 556 |
- so when inflate() is called again, the same case is attempted again, and |
|
| 557 |
- if the appropriate resources are provided, the machine proceeds to the |
|
| 558 |
- next state. The NEEDBITS() macro is usually the way the state evaluates |
|
| 559 |
- whether it can proceed or should return. NEEDBITS() does the return if |
|
| 560 |
- the requested bits are not available. The typical use of the BITS macros |
|
| 561 |
- is: |
|
| 562 |
- |
|
| 563 |
- NEEDBITS(n); |
|
| 564 |
- ... do something with BITS(n) ... |
|
| 565 |
- DROPBITS(n); |
|
| 566 |
- |
|
| 567 |
- where NEEDBITS(n) either returns from inflate() if there isn't enough |
|
| 568 |
- input left to load n bits into the accumulator, or it continues. BITS(n) |
|
| 569 |
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops |
|
| 570 |
- the low n bits off the accumulator. INITBITS() clears the accumulator |
|
| 571 |
- and sets the number of available bits to zero. BYTEBITS() discards just |
|
| 572 |
- enough bits to put the accumulator on a byte boundary. After BYTEBITS() |
|
| 573 |
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. |
|
| 574 |
- |
|
| 575 |
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return |
|
| 576 |
- if there is no input available. The decoding of variable length codes uses |
|
| 577 |
- PULLBYTE() directly in order to pull just enough bytes to decode the next |
|
| 578 |
- code, and no more. |
|
| 579 |
- |
|
| 580 |
- Some states loop until they get enough input, making sure that enough |
|
| 581 |
- state information is maintained to continue the loop where it left off |
|
| 582 |
- if NEEDBITS() returns in the loop. For example, want, need, and keep |
|
| 583 |
- would all have to actually be part of the saved state in case NEEDBITS() |
|
| 584 |
- returns: |
|
| 585 |
- |
|
| 586 |
- case STATEw: |
|
| 587 |
- while (want < need) {
|
|
| 588 |
- NEEDBITS(n); |
|
| 589 |
- keep[want++] = BITS(n); |
|
| 590 |
- DROPBITS(n); |
|
| 591 |
- } |
|
| 592 |
- state = STATEx; |
|
| 593 |
- case STATEx: |
|
| 594 |
- |
|
| 595 |
- As shown above, if the next state is also the next case, then the break |
|
| 596 |
- is omitted. |
|
| 597 |
- |
|
| 598 |
- A state may also return if there is not enough output space available to |
|
| 599 |
- complete that state. Those states are copying stored data, writing a |
|
| 600 |
- literal byte, and copying a matching string. |
|
| 601 |
- |
|
| 602 |
- When returning, a "goto inf_leave" is used to update the total counters, |
|
| 603 |
- update the check value, and determine whether any progress has been made |
|
| 604 |
- during that inflate() call in order to return the proper return code. |
|
| 605 |
- Progress is defined as a change in either strm->avail_in or strm->avail_out. |
|
| 606 |
- When there is a window, goto inf_leave will update the window with the last |
|
| 607 |
- output written. If a goto inf_leave occurs in the middle of decompression |
|
| 608 |
- and there is no window currently, goto inf_leave will create one and copy |
|
| 609 |
- output to the window for the next call of inflate(). |
|
| 610 |
- |
|
| 611 |
- In this implementation, the flush parameter of inflate() only affects the |
|
| 612 |
- return code (per zlib.h). inflate() always writes as much as possible to |
|
| 613 |
- strm->next_out, given the space available and the provided input--the effect |
|
| 614 |
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers |
|
| 615 |
- the allocation of and copying into a sliding window until necessary, which |
|
| 616 |
- provides the effect documented in zlib.h for Z_FINISH when the entire input |
|
| 617 |
- stream available. So the only thing the flush parameter actually does is: |
|
| 618 |
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it |
|
| 619 |
- will return Z_BUF_ERROR if it has not reached the end of the stream. |
|
| 620 |
- */ |
|
| 621 |
- |
|
| 622 |
-int ZEXPORT inflate(strm, flush) |
|
| 623 |
-z_streamp strm; |
|
| 624 |
-int flush; |
|
| 625 |
-{
|
|
| 626 |
- struct inflate_state FAR *state; |
|
| 627 |
- z_const unsigned char FAR *next; /* next input */ |
|
| 628 |
- unsigned char FAR *put; /* next output */ |
|
| 629 |
- unsigned have, left; /* available input and output */ |
|
| 630 |
- unsigned long hold; /* bit buffer */ |
|
| 631 |
- unsigned bits; /* bits in bit buffer */ |
|
| 632 |
- unsigned in, out; /* save starting available input and output */ |
|
| 633 |
- unsigned copy; /* number of stored or match bytes to copy */ |
|
| 634 |
- unsigned char FAR *from; /* where to copy match bytes from */ |
|
| 635 |
- code here; /* current decoding table entry */ |
|
| 636 |
- code last; /* parent table entry */ |
|
| 637 |
- unsigned len; /* length to copy for repeats, bits to drop */ |
|
| 638 |
- int ret; /* return code */ |
|
| 639 |
-#ifdef GUNZIP |
|
| 640 |
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ |
|
| 641 |
-#endif |
|
| 642 |
- static const unsigned short order[19] = /* permutation of code lengths */ |
|
| 643 |
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
|
| 644 |
- |
|
| 645 |
- if (inflateStateCheck(strm) || strm->next_out == Z_NULL || |
|
| 646 |
- (strm->next_in == Z_NULL && strm->avail_in != 0)) |
|
| 647 |
- return Z_STREAM_ERROR; |
|
| 648 |
- |
|
| 649 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 650 |
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ |
|
| 651 |
- LOAD(); |
|
| 652 |
- in = have; |
|
| 653 |
- out = left; |
|
| 654 |
- ret = Z_OK; |
|
| 655 |
- for (;;) |
|
| 656 |
- switch (state->mode) {
|
|
| 657 |
- case HEAD: |
|
| 658 |
- if (state->wrap == 0) {
|
|
| 659 |
- state->mode = TYPEDO; |
|
| 660 |
- break; |
|
| 661 |
- } |
|
| 662 |
- NEEDBITS(16); |
|
| 663 |
-#ifdef GUNZIP |
|
| 664 |
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
|
|
| 665 |
- if (state->wbits == 0) |
|
| 666 |
- state->wbits = 15; |
|
| 667 |
- state->check = crc32(0L, Z_NULL, 0); |
|
| 668 |
- CRC2(state->check, hold); |
|
| 669 |
- INITBITS(); |
|
| 670 |
- state->mode = FLAGS; |
|
| 671 |
- break; |
|
| 672 |
- } |
|
| 673 |
- state->flags = 0; /* expect zlib header */ |
|
| 674 |
- if (state->head != Z_NULL) |
|
| 675 |
- state->head->done = -1; |
|
| 676 |
- if (!(state->wrap & 1) || /* check if zlib header allowed */ |
|
| 677 |
-#else |
|
| 678 |
- if ( |
|
| 679 |
-#endif |
|
| 680 |
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
|
|
| 681 |
- strm->msg = (char *)"incorrect header check"; |
|
| 682 |
- state->mode = BAD; |
|
| 683 |
- break; |
|
| 684 |
- } |
|
| 685 |
- if (BITS(4) != Z_DEFLATED) {
|
|
| 686 |
- strm->msg = (char *)"unknown compression method"; |
|
| 687 |
- state->mode = BAD; |
|
| 688 |
- break; |
|
| 689 |
- } |
|
| 690 |
- DROPBITS(4); |
|
| 691 |
- len = BITS(4) + 8; |
|
| 692 |
- if (state->wbits == 0) |
|
| 693 |
- state->wbits = len; |
|
| 694 |
- if (len > 15 || len > state->wbits) {
|
|
| 695 |
- strm->msg = (char *)"invalid window size"; |
|
| 696 |
- state->mode = BAD; |
|
| 697 |
- break; |
|
| 698 |
- } |
|
| 699 |
- state->dmax = 1U << len; |
|
| 700 |
- Tracev((stderr, "inflate: zlib header ok\n")); |
|
| 701 |
- strm->adler = state->check = adler32(0L, Z_NULL, 0); |
|
| 702 |
- state->mode = hold & 0x200 ? DICTID : TYPE; |
|
| 703 |
- INITBITS(); |
|
| 704 |
- break; |
|
| 705 |
-#ifdef GUNZIP |
|
| 706 |
- case FLAGS: |
|
| 707 |
- NEEDBITS(16); |
|
| 708 |
- state->flags = (int)(hold); |
|
| 709 |
- if ((state->flags & 0xff) != Z_DEFLATED) {
|
|
| 710 |
- strm->msg = (char *)"unknown compression method"; |
|
| 711 |
- state->mode = BAD; |
|
| 712 |
- break; |
|
| 713 |
- } |
|
| 714 |
- if (state->flags & 0xe000) {
|
|
| 715 |
- strm->msg = (char *)"unknown header flags set"; |
|
| 716 |
- state->mode = BAD; |
|
| 717 |
- break; |
|
| 718 |
- } |
|
| 719 |
- if (state->head != Z_NULL) |
|
| 720 |
- state->head->text = (int)((hold >> 8) & 1); |
|
| 721 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 722 |
- CRC2(state->check, hold); |
|
| 723 |
- INITBITS(); |
|
| 724 |
- state->mode = TIME; |
|
| 725 |
- case TIME: |
|
| 726 |
- NEEDBITS(32); |
|
| 727 |
- if (state->head != Z_NULL) |
|
| 728 |
- state->head->time = hold; |
|
| 729 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 730 |
- CRC4(state->check, hold); |
|
| 731 |
- INITBITS(); |
|
| 732 |
- state->mode = OS; |
|
| 733 |
- case OS: |
|
| 734 |
- NEEDBITS(16); |
|
| 735 |
- if (state->head != Z_NULL) {
|
|
| 736 |
- state->head->xflags = (int)(hold & 0xff); |
|
| 737 |
- state->head->os = (int)(hold >> 8); |
|
| 738 |
- } |
|
| 739 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 740 |
- CRC2(state->check, hold); |
|
| 741 |
- INITBITS(); |
|
| 742 |
- state->mode = EXLEN; |
|
| 743 |
- case EXLEN: |
|
| 744 |
- if (state->flags & 0x0400) {
|
|
| 745 |
- NEEDBITS(16); |
|
| 746 |
- state->length = (unsigned)(hold); |
|
| 747 |
- if (state->head != Z_NULL) |
|
| 748 |
- state->head->extra_len = (unsigned)hold; |
|
| 749 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 750 |
- CRC2(state->check, hold); |
|
| 751 |
- INITBITS(); |
|
| 752 |
- } |
|
| 753 |
- else if (state->head != Z_NULL) |
|
| 754 |
- state->head->extra = Z_NULL; |
|
| 755 |
- state->mode = EXTRA; |
|
| 756 |
- case EXTRA: |
|
| 757 |
- if (state->flags & 0x0400) {
|
|
| 758 |
- copy = state->length; |
|
| 759 |
- if (copy > have) copy = have; |
|
| 760 |
- if (copy) {
|
|
| 761 |
- if (state->head != Z_NULL && |
|
| 762 |
- state->head->extra != Z_NULL) {
|
|
| 763 |
- len = state->head->extra_len - state->length; |
|
| 764 |
- zmemcpy(state->head->extra + len, next, |
|
| 765 |
- len + copy > state->head->extra_max ? |
|
| 766 |
- state->head->extra_max - len : copy); |
|
| 767 |
- } |
|
| 768 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 769 |
- state->check = crc32(state->check, next, copy); |
|
| 770 |
- have -= copy; |
|
| 771 |
- next += copy; |
|
| 772 |
- state->length -= copy; |
|
| 773 |
- } |
|
| 774 |
- if (state->length) goto inf_leave; |
|
| 775 |
- } |
|
| 776 |
- state->length = 0; |
|
| 777 |
- state->mode = NAME; |
|
| 778 |
- case NAME: |
|
| 779 |
- if (state->flags & 0x0800) {
|
|
| 780 |
- if (have == 0) goto inf_leave; |
|
| 781 |
- copy = 0; |
|
| 782 |
- do {
|
|
| 783 |
- len = (unsigned)(next[copy++]); |
|
| 784 |
- if (state->head != Z_NULL && |
|
| 785 |
- state->head->name != Z_NULL && |
|
| 786 |
- state->length < state->head->name_max) |
|
| 787 |
- state->head->name[state->length++] = (Bytef)len; |
|
| 788 |
- } while (len && copy < have); |
|
| 789 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 790 |
- state->check = crc32(state->check, next, copy); |
|
| 791 |
- have -= copy; |
|
| 792 |
- next += copy; |
|
| 793 |
- if (len) goto inf_leave; |
|
| 794 |
- } |
|
| 795 |
- else if (state->head != Z_NULL) |
|
| 796 |
- state->head->name = Z_NULL; |
|
| 797 |
- state->length = 0; |
|
| 798 |
- state->mode = COMMENT; |
|
| 799 |
- case COMMENT: |
|
| 800 |
- if (state->flags & 0x1000) {
|
|
| 801 |
- if (have == 0) goto inf_leave; |
|
| 802 |
- copy = 0; |
|
| 803 |
- do {
|
|
| 804 |
- len = (unsigned)(next[copy++]); |
|
| 805 |
- if (state->head != Z_NULL && |
|
| 806 |
- state->head->comment != Z_NULL && |
|
| 807 |
- state->length < state->head->comm_max) |
|
| 808 |
- state->head->comment[state->length++] = (Bytef)len; |
|
| 809 |
- } while (len && copy < have); |
|
| 810 |
- if ((state->flags & 0x0200) && (state->wrap & 4)) |
|
| 811 |
- state->check = crc32(state->check, next, copy); |
|
| 812 |
- have -= copy; |
|
| 813 |
- next += copy; |
|
| 814 |
- if (len) goto inf_leave; |
|
| 815 |
- } |
|
| 816 |
- else if (state->head != Z_NULL) |
|
| 817 |
- state->head->comment = Z_NULL; |
|
| 818 |
- state->mode = HCRC; |
|
| 819 |
- case HCRC: |
|
| 820 |
- if (state->flags & 0x0200) {
|
|
| 821 |
- NEEDBITS(16); |
|
| 822 |
- if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
|
|
| 823 |
- strm->msg = (char *)"header crc mismatch"; |
|
| 824 |
- state->mode = BAD; |
|
| 825 |
- break; |
|
| 826 |
- } |
|
| 827 |
- INITBITS(); |
|
| 828 |
- } |
|
| 829 |
- if (state->head != Z_NULL) {
|
|
| 830 |
- state->head->hcrc = (int)((state->flags >> 9) & 1); |
|
| 831 |
- state->head->done = 1; |
|
| 832 |
- } |
|
| 833 |
- strm->adler = state->check = crc32(0L, Z_NULL, 0); |
|
| 834 |
- state->mode = TYPE; |
|
| 835 |
- break; |
|
| 836 |
-#endif |
|
| 837 |
- case DICTID: |
|
| 838 |
- NEEDBITS(32); |
|
| 839 |
- strm->adler = state->check = ZSWAP32(hold); |
|
| 840 |
- INITBITS(); |
|
| 841 |
- state->mode = DICT; |
|
| 842 |
- case DICT: |
|
| 843 |
- if (state->havedict == 0) {
|
|
| 844 |
- RESTORE(); |
|
| 845 |
- return Z_NEED_DICT; |
|
| 846 |
- } |
|
| 847 |
- strm->adler = state->check = adler32(0L, Z_NULL, 0); |
|
| 848 |
- state->mode = TYPE; |
|
| 849 |
- case TYPE: |
|
| 850 |
- if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; |
|
| 851 |
- case TYPEDO: |
|
| 852 |
- if (state->last) {
|
|
| 853 |
- BYTEBITS(); |
|
| 854 |
- state->mode = CHECK; |
|
| 855 |
- break; |
|
| 856 |
- } |
|
| 857 |
- NEEDBITS(3); |
|
| 858 |
- state->last = BITS(1); |
|
| 859 |
- DROPBITS(1); |
|
| 860 |
- switch (BITS(2)) {
|
|
| 861 |
- case 0: /* stored block */ |
|
| 862 |
- Tracev((stderr, "inflate: stored block%s\n", |
|
| 863 |
- state->last ? " (last)" : "")); |
|
| 864 |
- state->mode = STORED; |
|
| 865 |
- break; |
|
| 866 |
- case 1: /* fixed block */ |
|
| 867 |
- fixedtables(state); |
|
| 868 |
- Tracev((stderr, "inflate: fixed codes block%s\n", |
|
| 869 |
- state->last ? " (last)" : "")); |
|
| 870 |
- state->mode = LEN_; /* decode codes */ |
|
| 871 |
- if (flush == Z_TREES) {
|
|
| 872 |
- DROPBITS(2); |
|
| 873 |
- goto inf_leave; |
|
| 874 |
- } |
|
| 875 |
- break; |
|
| 876 |
- case 2: /* dynamic block */ |
|
| 877 |
- Tracev((stderr, "inflate: dynamic codes block%s\n", |
|
| 878 |
- state->last ? " (last)" : "")); |
|
| 879 |
- state->mode = TABLE; |
|
| 880 |
- break; |
|
| 881 |
- case 3: |
|
| 882 |
- strm->msg = (char *)"invalid block type"; |
|
| 883 |
- state->mode = BAD; |
|
| 884 |
- } |
|
| 885 |
- DROPBITS(2); |
|
| 886 |
- break; |
|
| 887 |
- case STORED: |
|
| 888 |
- BYTEBITS(); /* go to byte boundary */ |
|
| 889 |
- NEEDBITS(32); |
|
| 890 |
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
|
|
| 891 |
- strm->msg = (char *)"invalid stored block lengths"; |
|
| 892 |
- state->mode = BAD; |
|
| 893 |
- break; |
|
| 894 |
- } |
|
| 895 |
- state->length = (unsigned)hold & 0xffff; |
|
| 896 |
- Tracev((stderr, "inflate: stored length %u\n", |
|
| 897 |
- state->length)); |
|
| 898 |
- INITBITS(); |
|
| 899 |
- state->mode = COPY_; |
|
| 900 |
- if (flush == Z_TREES) goto inf_leave; |
|
| 901 |
- case COPY_: |
|
| 902 |
- state->mode = COPY; |
|
| 903 |
- case COPY: |
|
| 904 |
- copy = state->length; |
|
| 905 |
- if (copy) {
|
|
| 906 |
- if (copy > have) copy = have; |
|
| 907 |
- if (copy > left) copy = left; |
|
| 908 |
- if (copy == 0) goto inf_leave; |
|
| 909 |
- zmemcpy(put, next, copy); |
|
| 910 |
- have -= copy; |
|
| 911 |
- next += copy; |
|
| 912 |
- left -= copy; |
|
| 913 |
- put += copy; |
|
| 914 |
- state->length -= copy; |
|
| 915 |
- break; |
|
| 916 |
- } |
|
| 917 |
- Tracev((stderr, "inflate: stored end\n")); |
|
| 918 |
- state->mode = TYPE; |
|
| 919 |
- break; |
|
| 920 |
- case TABLE: |
|
| 921 |
- NEEDBITS(14); |
|
| 922 |
- state->nlen = BITS(5) + 257; |
|
| 923 |
- DROPBITS(5); |
|
| 924 |
- state->ndist = BITS(5) + 1; |
|
| 925 |
- DROPBITS(5); |
|
| 926 |
- state->ncode = BITS(4) + 4; |
|
| 927 |
- DROPBITS(4); |
|
| 928 |
-#ifndef PKZIP_BUG_WORKAROUND |
|
| 929 |
- if (state->nlen > 286 || state->ndist > 30) {
|
|
| 930 |
- strm->msg = (char *)"too many length or distance symbols"; |
|
| 931 |
- state->mode = BAD; |
|
| 932 |
- break; |
|
| 933 |
- } |
|
| 934 |
-#endif |
|
| 935 |
- Tracev((stderr, "inflate: table sizes ok\n")); |
|
| 936 |
- state->have = 0; |
|
| 937 |
- state->mode = LENLENS; |
|
| 938 |
- case LENLENS: |
|
| 939 |
- while (state->have < state->ncode) {
|
|
| 940 |
- NEEDBITS(3); |
|
| 941 |
- state->lens[order[state->have++]] = (unsigned short)BITS(3); |
|
| 942 |
- DROPBITS(3); |
|
| 943 |
- } |
|
| 944 |
- while (state->have < 19) |
|
| 945 |
- state->lens[order[state->have++]] = 0; |
|
| 946 |
- state->next = state->codes; |
|
| 947 |
- state->lencode = (const code FAR *)(state->next); |
|
| 948 |
- state->lenbits = 7; |
|
| 949 |
- ret = inflate_table(CODES, state->lens, 19, &(state->next), |
|
| 950 |
- &(state->lenbits), state->work); |
|
| 951 |
- if (ret) {
|
|
| 952 |
- strm->msg = (char *)"invalid code lengths set"; |
|
| 953 |
- state->mode = BAD; |
|
| 954 |
- break; |
|
| 955 |
- } |
|
| 956 |
- Tracev((stderr, "inflate: code lengths ok\n")); |
|
| 957 |
- state->have = 0; |
|
| 958 |
- state->mode = CODELENS; |
|
| 959 |
- case CODELENS: |
|
| 960 |
- while (state->have < state->nlen + state->ndist) {
|
|
| 961 |
- for (;;) {
|
|
| 962 |
- here = state->lencode[BITS(state->lenbits)]; |
|
| 963 |
- if ((unsigned)(here.bits) <= bits) break; |
|
| 964 |
- PULLBYTE(); |
|
| 965 |
- } |
|
| 966 |
- if (here.val < 16) {
|
|
| 967 |
- DROPBITS(here.bits); |
|
| 968 |
- state->lens[state->have++] = here.val; |
|
| 969 |
- } |
|
| 970 |
- else {
|
|
| 971 |
- if (here.val == 16) {
|
|
| 972 |
- NEEDBITS(here.bits + 2); |
|
| 973 |
- DROPBITS(here.bits); |
|
| 974 |
- if (state->have == 0) {
|
|
| 975 |
- strm->msg = (char *)"invalid bit length repeat"; |
|
| 976 |
- state->mode = BAD; |
|
| 977 |
- break; |
|
| 978 |
- } |
|
| 979 |
- len = state->lens[state->have - 1]; |
|
| 980 |
- copy = 3 + BITS(2); |
|
| 981 |
- DROPBITS(2); |
|
| 982 |
- } |
|
| 983 |
- else if (here.val == 17) {
|
|
| 984 |
- NEEDBITS(here.bits + 3); |
|
| 985 |
- DROPBITS(here.bits); |
|
| 986 |
- len = 0; |
|
| 987 |
- copy = 3 + BITS(3); |
|
| 988 |
- DROPBITS(3); |
|
| 989 |
- } |
|
| 990 |
- else {
|
|
| 991 |
- NEEDBITS(here.bits + 7); |
|
| 992 |
- DROPBITS(here.bits); |
|
| 993 |
- len = 0; |
|
| 994 |
- copy = 11 + BITS(7); |
|
| 995 |
- DROPBITS(7); |
|
| 996 |
- } |
|
| 997 |
- if (state->have + copy > state->nlen + state->ndist) {
|
|
| 998 |
- strm->msg = (char *)"invalid bit length repeat"; |
|
| 999 |
- state->mode = BAD; |
|
| 1000 |
- break; |
|
| 1001 |
- } |
|
| 1002 |
- while (copy--) |
|
| 1003 |
- state->lens[state->have++] = (unsigned short)len; |
|
| 1004 |
- } |
|
| 1005 |
- } |
|
| 1006 |
- |
|
| 1007 |
- /* handle error breaks in while */ |
|
| 1008 |
- if (state->mode == BAD) break; |
|
| 1009 |
- |
|
| 1010 |
- /* check for end-of-block code (better have one) */ |
|
| 1011 |
- if (state->lens[256] == 0) {
|
|
| 1012 |
- strm->msg = (char *)"invalid code -- missing end-of-block"; |
|
| 1013 |
- state->mode = BAD; |
|
| 1014 |
- break; |
|
| 1015 |
- } |
|
| 1016 |
- |
|
| 1017 |
- /* build code tables -- note: do not change the lenbits or distbits |
|
| 1018 |
- values here (9 and 6) without reading the comments in inftrees.h |
|
| 1019 |
- concerning the ENOUGH constants, which depend on those values */ |
|
| 1020 |
- state->next = state->codes; |
|
| 1021 |
- state->lencode = (const code FAR *)(state->next); |
|
| 1022 |
- state->lenbits = 9; |
|
| 1023 |
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), |
|
| 1024 |
- &(state->lenbits), state->work); |
|
| 1025 |
- if (ret) {
|
|
| 1026 |
- strm->msg = (char *)"invalid literal/lengths set"; |
|
| 1027 |
- state->mode = BAD; |
|
| 1028 |
- break; |
|
| 1029 |
- } |
|
| 1030 |
- state->distcode = (const code FAR *)(state->next); |
|
| 1031 |
- state->distbits = 6; |
|
| 1032 |
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, |
|
| 1033 |
- &(state->next), &(state->distbits), state->work); |
|
| 1034 |
- if (ret) {
|
|
| 1035 |
- strm->msg = (char *)"invalid distances set"; |
|
| 1036 |
- state->mode = BAD; |
|
| 1037 |
- break; |
|
| 1038 |
- } |
|
| 1039 |
- Tracev((stderr, "inflate: codes ok\n")); |
|
| 1040 |
- state->mode = LEN_; |
|
| 1041 |
- if (flush == Z_TREES) goto inf_leave; |
|
| 1042 |
- case LEN_: |
|
| 1043 |
- state->mode = LEN; |
|
| 1044 |
- case LEN: |
|
| 1045 |
- if (have >= 6 && left >= 258) {
|
|
| 1046 |
- RESTORE(); |
|
| 1047 |
- inflate_fast(strm, out); |
|
| 1048 |
- LOAD(); |
|
| 1049 |
- if (state->mode == TYPE) |
|
| 1050 |
- state->back = -1; |
|
| 1051 |
- break; |
|
| 1052 |
- } |
|
| 1053 |
- state->back = 0; |
|
| 1054 |
- for (;;) {
|
|
| 1055 |
- here = state->lencode[BITS(state->lenbits)]; |
|
| 1056 |
- if ((unsigned)(here.bits) <= bits) break; |
|
| 1057 |
- PULLBYTE(); |
|
| 1058 |
- } |
|
| 1059 |
- if (here.op && (here.op & 0xf0) == 0) {
|
|
| 1060 |
- last = here; |
|
| 1061 |
- for (;;) {
|
|
| 1062 |
- here = state->lencode[last.val + |
|
| 1063 |
- (BITS(last.bits + last.op) >> last.bits)]; |
|
| 1064 |
- if ((unsigned)(last.bits + here.bits) <= bits) break; |
|
| 1065 |
- PULLBYTE(); |
|
| 1066 |
- } |
|
| 1067 |
- DROPBITS(last.bits); |
|
| 1068 |
- state->back += last.bits; |
|
| 1069 |
- } |
|
| 1070 |
- DROPBITS(here.bits); |
|
| 1071 |
- state->back += here.bits; |
|
| 1072 |
- state->length = (unsigned)here.val; |
|
| 1073 |
- if ((int)(here.op) == 0) {
|
|
| 1074 |
- Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? |
|
| 1075 |
- "inflate: literal '%c'\n" : |
|
| 1076 |
- "inflate: literal 0x%02x\n", here.val)); |
|
| 1077 |
- state->mode = LIT; |
|
| 1078 |
- break; |
|
| 1079 |
- } |
|
| 1080 |
- if (here.op & 32) {
|
|
| 1081 |
- Tracevv((stderr, "inflate: end of block\n")); |
|
| 1082 |
- state->back = -1; |
|
| 1083 |
- state->mode = TYPE; |
|
| 1084 |
- break; |
|
| 1085 |
- } |
|
| 1086 |
- if (here.op & 64) {
|
|
| 1087 |
- strm->msg = (char *)"invalid literal/length code"; |
|
| 1088 |
- state->mode = BAD; |
|
| 1089 |
- break; |
|
| 1090 |
- } |
|
| 1091 |
- state->extra = (unsigned)(here.op) & 15; |
|
| 1092 |
- state->mode = LENEXT; |
|
| 1093 |
- case LENEXT: |
|
| 1094 |
- if (state->extra) {
|
|
| 1095 |
- NEEDBITS(state->extra); |
|
| 1096 |
- state->length += BITS(state->extra); |
|
| 1097 |
- DROPBITS(state->extra); |
|
| 1098 |
- state->back += state->extra; |
|
| 1099 |
- } |
|
| 1100 |
- Tracevv((stderr, "inflate: length %u\n", state->length)); |
|
| 1101 |
- state->was = state->length; |
|
| 1102 |
- state->mode = DIST; |
|
| 1103 |
- case DIST: |
|
| 1104 |
- for (;;) {
|
|
| 1105 |
- here = state->distcode[BITS(state->distbits)]; |
|
| 1106 |
- if ((unsigned)(here.bits) <= bits) break; |
|
| 1107 |
- PULLBYTE(); |
|
| 1108 |
- } |
|
| 1109 |
- if ((here.op & 0xf0) == 0) {
|
|
| 1110 |
- last = here; |
|
| 1111 |
- for (;;) {
|
|
| 1112 |
- here = state->distcode[last.val + |
|
| 1113 |
- (BITS(last.bits + last.op) >> last.bits)]; |
|
| 1114 |
- if ((unsigned)(last.bits + here.bits) <= bits) break; |
|
| 1115 |
- PULLBYTE(); |
|
| 1116 |
- } |
|
| 1117 |
- DROPBITS(last.bits); |
|
| 1118 |
- state->back += last.bits; |
|
| 1119 |
- } |
|
| 1120 |
- DROPBITS(here.bits); |
|
| 1121 |
- state->back += here.bits; |
|
| 1122 |
- if (here.op & 64) {
|
|
| 1123 |
- strm->msg = (char *)"invalid distance code"; |
|
| 1124 |
- state->mode = BAD; |
|
| 1125 |
- break; |
|
| 1126 |
- } |
|
| 1127 |
- state->offset = (unsigned)here.val; |
|
| 1128 |
- state->extra = (unsigned)(here.op) & 15; |
|
| 1129 |
- state->mode = DISTEXT; |
|
| 1130 |
- case DISTEXT: |
|
| 1131 |
- if (state->extra) {
|
|
| 1132 |
- NEEDBITS(state->extra); |
|
| 1133 |
- state->offset += BITS(state->extra); |
|
| 1134 |
- DROPBITS(state->extra); |
|
| 1135 |
- state->back += state->extra; |
|
| 1136 |
- } |
|
| 1137 |
-#ifdef INFLATE_STRICT |
|
| 1138 |
- if (state->offset > state->dmax) {
|
|
| 1139 |
- strm->msg = (char *)"invalid distance too far back"; |
|
| 1140 |
- state->mode = BAD; |
|
| 1141 |
- break; |
|
| 1142 |
- } |
|
| 1143 |
-#endif |
|
| 1144 |
- Tracevv((stderr, "inflate: distance %u\n", state->offset)); |
|
| 1145 |
- state->mode = MATCH; |
|
| 1146 |
- case MATCH: |
|
| 1147 |
- if (left == 0) goto inf_leave; |
|
| 1148 |
- copy = out - left; |
|
| 1149 |
- if (state->offset > copy) { /* copy from window */
|
|
| 1150 |
- copy = state->offset - copy; |
|
| 1151 |
- if (copy > state->whave) {
|
|
| 1152 |
- if (state->sane) {
|
|
| 1153 |
- strm->msg = (char *)"invalid distance too far back"; |
|
| 1154 |
- state->mode = BAD; |
|
| 1155 |
- break; |
|
| 1156 |
- } |
|
| 1157 |
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
|
| 1158 |
- Trace((stderr, "inflate.c too far\n")); |
|
| 1159 |
- copy -= state->whave; |
|
| 1160 |
- if (copy > state->length) copy = state->length; |
|
| 1161 |
- if (copy > left) copy = left; |
|
| 1162 |
- left -= copy; |
|
| 1163 |
- state->length -= copy; |
|
| 1164 |
- do {
|
|
| 1165 |
- *put++ = 0; |
|
| 1166 |
- } while (--copy); |
|
| 1167 |
- if (state->length == 0) state->mode = LEN; |
|
| 1168 |
- break; |
|
| 1169 |
-#endif |
|
| 1170 |
- } |
|
| 1171 |
- if (copy > state->wnext) {
|
|
| 1172 |
- copy -= state->wnext; |
|
| 1173 |
- from = state->window + (state->wsize - copy); |
|
| 1174 |
- } |
|
| 1175 |
- else |
|
| 1176 |
- from = state->window + (state->wnext - copy); |
|
| 1177 |
- if (copy > state->length) copy = state->length; |
|
| 1178 |
- } |
|
| 1179 |
- else { /* copy from output */
|
|
| 1180 |
- from = put - state->offset; |
|
| 1181 |
- copy = state->length; |
|
| 1182 |
- } |
|
| 1183 |
- if (copy > left) copy = left; |
|
| 1184 |
- left -= copy; |
|
| 1185 |
- state->length -= copy; |
|
| 1186 |
- do {
|
|
| 1187 |
- *put++ = *from++; |
|
| 1188 |
- } while (--copy); |
|
| 1189 |
- if (state->length == 0) state->mode = LEN; |
|
| 1190 |
- break; |
|
| 1191 |
- case LIT: |
|
| 1192 |
- if (left == 0) goto inf_leave; |
|
| 1193 |
- *put++ = (unsigned char)(state->length); |
|
| 1194 |
- left--; |
|
| 1195 |
- state->mode = LEN; |
|
| 1196 |
- break; |
|
| 1197 |
- case CHECK: |
|
| 1198 |
- if (state->wrap) {
|
|
| 1199 |
- NEEDBITS(32); |
|
| 1200 |
- out -= left; |
|
| 1201 |
- strm->total_out += out; |
|
| 1202 |
- state->total += out; |
|
| 1203 |
- if ((state->wrap & 4) && out) |
|
| 1204 |
- strm->adler = state->check = |
|
| 1205 |
- UPDATE(state->check, put - out, out); |
|
| 1206 |
- out = left; |
|
| 1207 |
- if ((state->wrap & 4) && ( |
|
| 1208 |
-#ifdef GUNZIP |
|
| 1209 |
- state->flags ? hold : |
|
| 1210 |
-#endif |
|
| 1211 |
- ZSWAP32(hold)) != state->check) {
|
|
| 1212 |
- strm->msg = (char *)"incorrect data check"; |
|
| 1213 |
- state->mode = BAD; |
|
| 1214 |
- break; |
|
| 1215 |
- } |
|
| 1216 |
- INITBITS(); |
|
| 1217 |
- Tracev((stderr, "inflate: check matches trailer\n")); |
|
| 1218 |
- } |
|
| 1219 |
-#ifdef GUNZIP |
|
| 1220 |
- state->mode = LENGTH; |
|
| 1221 |
- case LENGTH: |
|
| 1222 |
- if (state->wrap && state->flags) {
|
|
| 1223 |
- NEEDBITS(32); |
|
| 1224 |
- if (hold != (state->total & 0xffffffffUL)) {
|
|
| 1225 |
- strm->msg = (char *)"incorrect length check"; |
|
| 1226 |
- state->mode = BAD; |
|
| 1227 |
- break; |
|
| 1228 |
- } |
|
| 1229 |
- INITBITS(); |
|
| 1230 |
- Tracev((stderr, "inflate: length matches trailer\n")); |
|
| 1231 |
- } |
|
| 1232 |
-#endif |
|
| 1233 |
- state->mode = DONE; |
|
| 1234 |
- case DONE: |
|
| 1235 |
- ret = Z_STREAM_END; |
|
| 1236 |
- goto inf_leave; |
|
| 1237 |
- case BAD: |
|
| 1238 |
- ret = Z_DATA_ERROR; |
|
| 1239 |
- goto inf_leave; |
|
| 1240 |
- case MEM: |
|
| 1241 |
- return Z_MEM_ERROR; |
|
| 1242 |
- case SYNC: |
|
| 1243 |
- default: |
|
| 1244 |
- return Z_STREAM_ERROR; |
|
| 1245 |
- } |
|
| 1246 |
- |
|
| 1247 |
- /* |
|
| 1248 |
- Return from inflate(), updating the total counts and the check value. |
|
| 1249 |
- If there was no progress during the inflate() call, return a buffer |
|
| 1250 |
- error. Call updatewindow() to create and/or update the window state. |
|
| 1251 |
- Note: a memory error from inflate() is non-recoverable. |
|
| 1252 |
- */ |
|
| 1253 |
- inf_leave: |
|
| 1254 |
- RESTORE(); |
|
| 1255 |
- if (state->wsize || (out != strm->avail_out && state->mode < BAD && |
|
| 1256 |
- (state->mode < CHECK || flush != Z_FINISH))) |
|
| 1257 |
- if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
|
|
| 1258 |
- state->mode = MEM; |
|
| 1259 |
- return Z_MEM_ERROR; |
|
| 1260 |
- } |
|
| 1261 |
- in -= strm->avail_in; |
|
| 1262 |
- out -= strm->avail_out; |
|
| 1263 |
- strm->total_in += in; |
|
| 1264 |
- strm->total_out += out; |
|
| 1265 |
- state->total += out; |
|
| 1266 |
- if ((state->wrap & 4) && out) |
|
| 1267 |
- strm->adler = state->check = |
|
| 1268 |
- UPDATE(state->check, strm->next_out - out, out); |
|
| 1269 |
- strm->data_type = (int)state->bits + (state->last ? 64 : 0) + |
|
| 1270 |
- (state->mode == TYPE ? 128 : 0) + |
|
| 1271 |
- (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); |
|
| 1272 |
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) |
|
| 1273 |
- ret = Z_BUF_ERROR; |
|
| 1274 |
- return ret; |
|
| 1275 |
-} |
|
| 1276 |
- |
|
| 1277 |
-int ZEXPORT inflateEnd(strm) |
|
| 1278 |
-z_streamp strm; |
|
| 1279 |
-{
|
|
| 1280 |
- struct inflate_state FAR *state; |
|
| 1281 |
- if (inflateStateCheck(strm)) |
|
| 1282 |
- return Z_STREAM_ERROR; |
|
| 1283 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1284 |
- if (state->window != Z_NULL) ZFREE(strm, state->window); |
|
| 1285 |
- ZFREE(strm, strm->state); |
|
| 1286 |
- strm->state = Z_NULL; |
|
| 1287 |
- Tracev((stderr, "inflate: end\n")); |
|
| 1288 |
- return Z_OK; |
|
| 1289 |
-} |
|
| 1290 |
- |
|
| 1291 |
-int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) |
|
| 1292 |
-z_streamp strm; |
|
| 1293 |
-Bytef *dictionary; |
|
| 1294 |
-uInt *dictLength; |
|
| 1295 |
-{
|
|
| 1296 |
- struct inflate_state FAR *state; |
|
| 1297 |
- |
|
| 1298 |
- /* check state */ |
|
| 1299 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1300 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1301 |
- |
|
| 1302 |
- /* copy dictionary */ |
|
| 1303 |
- if (state->whave && dictionary != Z_NULL) {
|
|
| 1304 |
- zmemcpy(dictionary, state->window + state->wnext, |
|
| 1305 |
- state->whave - state->wnext); |
|
| 1306 |
- zmemcpy(dictionary + state->whave - state->wnext, |
|
| 1307 |
- state->window, state->wnext); |
|
| 1308 |
- } |
|
| 1309 |
- if (dictLength != Z_NULL) |
|
| 1310 |
- *dictLength = state->whave; |
|
| 1311 |
- return Z_OK; |
|
| 1312 |
-} |
|
| 1313 |
- |
|
| 1314 |
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) |
|
| 1315 |
-z_streamp strm; |
|
| 1316 |
-const Bytef *dictionary; |
|
| 1317 |
-uInt dictLength; |
|
| 1318 |
-{
|
|
| 1319 |
- struct inflate_state FAR *state; |
|
| 1320 |
- unsigned long dictid; |
|
| 1321 |
- int ret; |
|
| 1322 |
- |
|
| 1323 |
- /* check state */ |
|
| 1324 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1325 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1326 |
- if (state->wrap != 0 && state->mode != DICT) |
|
| 1327 |
- return Z_STREAM_ERROR; |
|
| 1328 |
- |
|
| 1329 |
- /* check for correct dictionary identifier */ |
|
| 1330 |
- if (state->mode == DICT) {
|
|
| 1331 |
- dictid = adler32(0L, Z_NULL, 0); |
|
| 1332 |
- dictid = adler32(dictid, dictionary, dictLength); |
|
| 1333 |
- if (dictid != state->check) |
|
| 1334 |
- return Z_DATA_ERROR; |
|
| 1335 |
- } |
|
| 1336 |
- |
|
| 1337 |
- /* copy dictionary to window using updatewindow(), which will amend the |
|
| 1338 |
- existing dictionary if appropriate */ |
|
| 1339 |
- ret = updatewindow(strm, dictionary + dictLength, dictLength); |
|
| 1340 |
- if (ret) {
|
|
| 1341 |
- state->mode = MEM; |
|
| 1342 |
- return Z_MEM_ERROR; |
|
| 1343 |
- } |
|
| 1344 |
- state->havedict = 1; |
|
| 1345 |
- Tracev((stderr, "inflate: dictionary set\n")); |
|
| 1346 |
- return Z_OK; |
|
| 1347 |
-} |
|
| 1348 |
- |
|
| 1349 |
-int ZEXPORT inflateGetHeader(strm, head) |
|
| 1350 |
-z_streamp strm; |
|
| 1351 |
-gz_headerp head; |
|
| 1352 |
-{
|
|
| 1353 |
- struct inflate_state FAR *state; |
|
| 1354 |
- |
|
| 1355 |
- /* check state */ |
|
| 1356 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1357 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1358 |
- if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; |
|
| 1359 |
- |
|
| 1360 |
- /* save header structure */ |
|
| 1361 |
- state->head = head; |
|
| 1362 |
- head->done = 0; |
|
| 1363 |
- return Z_OK; |
|
| 1364 |
-} |
|
| 1365 |
- |
|
| 1366 |
-/* |
|
| 1367 |
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found |
|
| 1368 |
- or when out of input. When called, *have is the number of pattern bytes |
|
| 1369 |
- found in order so far, in 0..3. On return *have is updated to the new |
|
| 1370 |
- state. If on return *have equals four, then the pattern was found and the |
|
| 1371 |
- return value is how many bytes were read including the last byte of the |
|
| 1372 |
- pattern. If *have is less than four, then the pattern has not been found |
|
| 1373 |
- yet and the return value is len. In the latter case, syncsearch() can be |
|
| 1374 |
- called again with more data and the *have state. *have is initialized to |
|
| 1375 |
- zero for the first call. |
|
| 1376 |
- */ |
|
| 1377 |
-local unsigned syncsearch(have, buf, len) |
|
| 1378 |
-unsigned FAR *have; |
|
| 1379 |
-const unsigned char FAR *buf; |
|
| 1380 |
-unsigned len; |
|
| 1381 |
-{
|
|
| 1382 |
- unsigned got; |
|
| 1383 |
- unsigned next; |
|
| 1384 |
- |
|
| 1385 |
- got = *have; |
|
| 1386 |
- next = 0; |
|
| 1387 |
- while (next < len && got < 4) {
|
|
| 1388 |
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) |
|
| 1389 |
- got++; |
|
| 1390 |
- else if (buf[next]) |
|
| 1391 |
- got = 0; |
|
| 1392 |
- else |
|
| 1393 |
- got = 4 - got; |
|
| 1394 |
- next++; |
|
| 1395 |
- } |
|
| 1396 |
- *have = got; |
|
| 1397 |
- return next; |
|
| 1398 |
-} |
|
| 1399 |
- |
|
| 1400 |
-int ZEXPORT inflateSync(strm) |
|
| 1401 |
-z_streamp strm; |
|
| 1402 |
-{
|
|
| 1403 |
- unsigned len; /* number of bytes to look at or looked at */ |
|
| 1404 |
- unsigned long in, out; /* temporary to save total_in and total_out */ |
|
| 1405 |
- unsigned char buf[4]; /* to restore bit buffer to byte string */ |
|
| 1406 |
- struct inflate_state FAR *state; |
|
| 1407 |
- |
|
| 1408 |
- /* check parameters */ |
|
| 1409 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1410 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1411 |
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; |
|
| 1412 |
- |
|
| 1413 |
- /* if first time, start search in bit buffer */ |
|
| 1414 |
- if (state->mode != SYNC) {
|
|
| 1415 |
- state->mode = SYNC; |
|
| 1416 |
- state->hold <<= state->bits & 7; |
|
| 1417 |
- state->bits -= state->bits & 7; |
|
| 1418 |
- len = 0; |
|
| 1419 |
- while (state->bits >= 8) {
|
|
| 1420 |
- buf[len++] = (unsigned char)(state->hold); |
|
| 1421 |
- state->hold >>= 8; |
|
| 1422 |
- state->bits -= 8; |
|
| 1423 |
- } |
|
| 1424 |
- state->have = 0; |
|
| 1425 |
- syncsearch(&(state->have), buf, len); |
|
| 1426 |
- } |
|
| 1427 |
- |
|
| 1428 |
- /* search available input */ |
|
| 1429 |
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in); |
|
| 1430 |
- strm->avail_in -= len; |
|
| 1431 |
- strm->next_in += len; |
|
| 1432 |
- strm->total_in += len; |
|
| 1433 |
- |
|
| 1434 |
- /* return no joy or set up to restart inflate() on a new block */ |
|
| 1435 |
- if (state->have != 4) return Z_DATA_ERROR; |
|
| 1436 |
- in = strm->total_in; out = strm->total_out; |
|
| 1437 |
- inflateReset(strm); |
|
| 1438 |
- strm->total_in = in; strm->total_out = out; |
|
| 1439 |
- state->mode = TYPE; |
|
| 1440 |
- return Z_OK; |
|
| 1441 |
-} |
|
| 1442 |
- |
|
| 1443 |
-/* |
|
| 1444 |
- Returns true if inflate is currently at the end of a block generated by |
|
| 1445 |
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP |
|
| 1446 |
- implementation to provide an additional safety check. PPP uses |
|
| 1447 |
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored |
|
| 1448 |
- block. When decompressing, PPP checks that at the end of input packet, |
|
| 1449 |
- inflate is waiting for these length bytes. |
|
| 1450 |
- */ |
|
| 1451 |
-int ZEXPORT inflateSyncPoint(strm) |
|
| 1452 |
-z_streamp strm; |
|
| 1453 |
-{
|
|
| 1454 |
- struct inflate_state FAR *state; |
|
| 1455 |
- |
|
| 1456 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1457 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1458 |
- return state->mode == STORED && state->bits == 0; |
|
| 1459 |
-} |
|
| 1460 |
- |
|
| 1461 |
-int ZEXPORT inflateCopy(dest, source) |
|
| 1462 |
-z_streamp dest; |
|
| 1463 |
-z_streamp source; |
|
| 1464 |
-{
|
|
| 1465 |
- struct inflate_state FAR *state; |
|
| 1466 |
- struct inflate_state FAR *copy; |
|
| 1467 |
- unsigned char FAR *window; |
|
| 1468 |
- unsigned wsize; |
|
| 1469 |
- |
|
| 1470 |
- /* check input */ |
|
| 1471 |
- if (inflateStateCheck(source) || dest == Z_NULL) |
|
| 1472 |
- return Z_STREAM_ERROR; |
|
| 1473 |
- state = (struct inflate_state FAR *)source->state; |
|
| 1474 |
- |
|
| 1475 |
- /* allocate space */ |
|
| 1476 |
- copy = (struct inflate_state FAR *) |
|
| 1477 |
- ZALLOC(source, 1, sizeof(struct inflate_state)); |
|
| 1478 |
- if (copy == Z_NULL) return Z_MEM_ERROR; |
|
| 1479 |
- window = Z_NULL; |
|
| 1480 |
- if (state->window != Z_NULL) {
|
|
| 1481 |
- window = (unsigned char FAR *) |
|
| 1482 |
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); |
|
| 1483 |
- if (window == Z_NULL) {
|
|
| 1484 |
- ZFREE(source, copy); |
|
| 1485 |
- return Z_MEM_ERROR; |
|
| 1486 |
- } |
|
| 1487 |
- } |
|
| 1488 |
- |
|
| 1489 |
- /* copy state */ |
|
| 1490 |
- zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); |
|
| 1491 |
- zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); |
|
| 1492 |
- copy->strm = dest; |
|
| 1493 |
- if (state->lencode >= state->codes && |
|
| 1494 |
- state->lencode <= state->codes + ENOUGH - 1) {
|
|
| 1495 |
- copy->lencode = copy->codes + (state->lencode - state->codes); |
|
| 1496 |
- copy->distcode = copy->codes + (state->distcode - state->codes); |
|
| 1497 |
- } |
|
| 1498 |
- copy->next = copy->codes + (state->next - state->codes); |
|
| 1499 |
- if (window != Z_NULL) {
|
|
| 1500 |
- wsize = 1U << state->wbits; |
|
| 1501 |
- zmemcpy(window, state->window, wsize); |
|
| 1502 |
- } |
|
| 1503 |
- copy->window = window; |
|
| 1504 |
- dest->state = (struct internal_state FAR *)copy; |
|
| 1505 |
- return Z_OK; |
|
| 1506 |
-} |
|
| 1507 |
- |
|
| 1508 |
-int ZEXPORT inflateUndermine(strm, subvert) |
|
| 1509 |
-z_streamp strm; |
|
| 1510 |
-int subvert; |
|
| 1511 |
-{
|
|
| 1512 |
- struct inflate_state FAR *state; |
|
| 1513 |
- |
|
| 1514 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1515 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1516 |
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
|
| 1517 |
- state->sane = !subvert; |
|
| 1518 |
- return Z_OK; |
|
| 1519 |
-#else |
|
| 1520 |
- (void)subvert; |
|
| 1521 |
- state->sane = 1; |
|
| 1522 |
- return Z_DATA_ERROR; |
|
| 1523 |
-#endif |
|
| 1524 |
-} |
|
| 1525 |
- |
|
| 1526 |
-int ZEXPORT inflateValidate(strm, check) |
|
| 1527 |
-z_streamp strm; |
|
| 1528 |
-int check; |
|
| 1529 |
-{
|
|
| 1530 |
- struct inflate_state FAR *state; |
|
| 1531 |
- |
|
| 1532 |
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
|
| 1533 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1534 |
- if (check) |
|
| 1535 |
- state->wrap |= 4; |
|
| 1536 |
- else |
|
| 1537 |
- state->wrap &= ~4; |
|
| 1538 |
- return Z_OK; |
|
| 1539 |
-} |
|
| 1540 |
- |
|
| 1541 |
-long ZEXPORT inflateMark(strm) |
|
| 1542 |
-z_streamp strm; |
|
| 1543 |
-{
|
|
| 1544 |
- struct inflate_state FAR *state; |
|
| 1545 |
- |
|
| 1546 |
- if (inflateStateCheck(strm)) |
|
| 1547 |
- return -(1L << 16); |
|
| 1548 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1549 |
- return (long)(((unsigned long)((long)state->back)) << 16) + |
|
| 1550 |
- (state->mode == COPY ? state->length : |
|
| 1551 |
- (state->mode == MATCH ? state->was - state->length : 0)); |
|
| 1552 |
-} |
|
| 1553 |
- |
|
| 1554 |
-unsigned long ZEXPORT inflateCodesUsed(strm) |
|
| 1555 |
-z_streamp strm; |
|
| 1556 |
-{
|
|
| 1557 |
- struct inflate_state FAR *state; |
|
| 1558 |
- if (inflateStateCheck(strm)) return (unsigned long)-1; |
|
| 1559 |
- state = (struct inflate_state FAR *)strm->state; |
|
| 1560 |
- return (unsigned long)(state->next - state->codes); |
|
| 1561 |
-} |
| 1562 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,125 +0,0 @@ |
| 1 |
-/* inflate.h -- internal inflate state definition |
|
| 2 |
- * Copyright (C) 1995-2016 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* WARNING: this file should *not* be used by applications. It is |
|
| 7 |
- part of the implementation of the compression library and is |
|
| 8 |
- subject to change. Applications should only use zlib.h. |
|
| 9 |
- */ |
|
| 10 |
- |
|
| 11 |
-/* define NO_GZIP when compiling if you want to disable gzip header and |
|
| 12 |
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in |
|
| 13 |
- the crc code when it is not needed. For shared libraries, gzip decoding |
|
| 14 |
- should be left enabled. */ |
|
| 15 |
-#ifndef NO_GZIP |
|
| 16 |
-# define GUNZIP |
|
| 17 |
-#endif |
|
| 18 |
- |
|
| 19 |
-/* Possible inflate modes between inflate() calls */ |
|
| 20 |
-typedef enum {
|
|
| 21 |
- HEAD = 16180, /* i: waiting for magic header */ |
|
| 22 |
- FLAGS, /* i: waiting for method and flags (gzip) */ |
|
| 23 |
- TIME, /* i: waiting for modification time (gzip) */ |
|
| 24 |
- OS, /* i: waiting for extra flags and operating system (gzip) */ |
|
| 25 |
- EXLEN, /* i: waiting for extra length (gzip) */ |
|
| 26 |
- EXTRA, /* i: waiting for extra bytes (gzip) */ |
|
| 27 |
- NAME, /* i: waiting for end of file name (gzip) */ |
|
| 28 |
- COMMENT, /* i: waiting for end of comment (gzip) */ |
|
| 29 |
- HCRC, /* i: waiting for header crc (gzip) */ |
|
| 30 |
- DICTID, /* i: waiting for dictionary check value */ |
|
| 31 |
- DICT, /* waiting for inflateSetDictionary() call */ |
|
| 32 |
- TYPE, /* i: waiting for type bits, including last-flag bit */ |
|
| 33 |
- TYPEDO, /* i: same, but skip check to exit inflate on new block */ |
|
| 34 |
- STORED, /* i: waiting for stored size (length and complement) */ |
|
| 35 |
- COPY_, /* i/o: same as COPY below, but only first time in */ |
|
| 36 |
- COPY, /* i/o: waiting for input or output to copy stored block */ |
|
| 37 |
- TABLE, /* i: waiting for dynamic block table lengths */ |
|
| 38 |
- LENLENS, /* i: waiting for code length code lengths */ |
|
| 39 |
- CODELENS, /* i: waiting for length/lit and distance code lengths */ |
|
| 40 |
- LEN_, /* i: same as LEN below, but only first time in */ |
|
| 41 |
- LEN, /* i: waiting for length/lit/eob code */ |
|
| 42 |
- LENEXT, /* i: waiting for length extra bits */ |
|
| 43 |
- DIST, /* i: waiting for distance code */ |
|
| 44 |
- DISTEXT, /* i: waiting for distance extra bits */ |
|
| 45 |
- MATCH, /* o: waiting for output space to copy string */ |
|
| 46 |
- LIT, /* o: waiting for output space to write literal */ |
|
| 47 |
- CHECK, /* i: waiting for 32-bit check value */ |
|
| 48 |
- LENGTH, /* i: waiting for 32-bit length (gzip) */ |
|
| 49 |
- DONE, /* finished check, done -- remain here until reset */ |
|
| 50 |
- BAD, /* got a data error -- remain here until reset */ |
|
| 51 |
- MEM, /* got an inflate() memory error -- remain here until reset */ |
|
| 52 |
- SYNC /* looking for synchronization bytes to restart inflate() */ |
|
| 53 |
-} inflate_mode; |
|
| 54 |
- |
|
| 55 |
-/* |
|
| 56 |
- State transitions between above modes - |
|
| 57 |
- |
|
| 58 |
- (most modes can go to BAD or MEM on error -- not shown for clarity) |
|
| 59 |
- |
|
| 60 |
- Process header: |
|
| 61 |
- HEAD -> (gzip) or (zlib) or (raw) |
|
| 62 |
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> |
|
| 63 |
- HCRC -> TYPE |
|
| 64 |
- (zlib) -> DICTID or TYPE |
|
| 65 |
- DICTID -> DICT -> TYPE |
|
| 66 |
- (raw) -> TYPEDO |
|
| 67 |
- Read deflate blocks: |
|
| 68 |
- TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK |
|
| 69 |
- STORED -> COPY_ -> COPY -> TYPE |
|
| 70 |
- TABLE -> LENLENS -> CODELENS -> LEN_ |
|
| 71 |
- LEN_ -> LEN |
|
| 72 |
- Read deflate codes in fixed or dynamic block: |
|
| 73 |
- LEN -> LENEXT or LIT or TYPE |
|
| 74 |
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN |
|
| 75 |
- LIT -> LEN |
|
| 76 |
- Process trailer: |
|
| 77 |
- CHECK -> LENGTH -> DONE |
|
| 78 |
- */ |
|
| 79 |
- |
|
| 80 |
-/* State maintained between inflate() calls -- approximately 7K bytes, not |
|
| 81 |
- including the allocated sliding window, which is up to 32K bytes. */ |
|
| 82 |
-struct inflate_state {
|
|
| 83 |
- z_streamp strm; /* pointer back to this zlib stream */ |
|
| 84 |
- inflate_mode mode; /* current inflate mode */ |
|
| 85 |
- int last; /* true if processing last block */ |
|
| 86 |
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip, |
|
| 87 |
- bit 2 true to validate check value */ |
|
| 88 |
- int havedict; /* true if dictionary provided */ |
|
| 89 |
- int flags; /* gzip header method and flags (0 if zlib) */ |
|
| 90 |
- unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ |
|
| 91 |
- unsigned long check; /* protected copy of check value */ |
|
| 92 |
- unsigned long total; /* protected copy of output count */ |
|
| 93 |
- gz_headerp head; /* where to save gzip header information */ |
|
| 94 |
- /* sliding window */ |
|
| 95 |
- unsigned wbits; /* log base 2 of requested window size */ |
|
| 96 |
- unsigned wsize; /* window size or zero if not using window */ |
|
| 97 |
- unsigned whave; /* valid bytes in the window */ |
|
| 98 |
- unsigned wnext; /* window write index */ |
|
| 99 |
- unsigned char FAR *window; /* allocated sliding window, if needed */ |
|
| 100 |
- /* bit accumulator */ |
|
| 101 |
- unsigned long hold; /* input bit accumulator */ |
|
| 102 |
- unsigned bits; /* number of bits in "in" */ |
|
| 103 |
- /* for string and stored block copying */ |
|
| 104 |
- unsigned length; /* literal or length of data to copy */ |
|
| 105 |
- unsigned offset; /* distance back to copy string from */ |
|
| 106 |
- /* for table and code decoding */ |
|
| 107 |
- unsigned extra; /* extra bits needed */ |
|
| 108 |
- /* fixed and dynamic code tables */ |
|
| 109 |
- code const FAR *lencode; /* starting table for length/literal codes */ |
|
| 110 |
- code const FAR *distcode; /* starting table for distance codes */ |
|
| 111 |
- unsigned lenbits; /* index bits for lencode */ |
|
| 112 |
- unsigned distbits; /* index bits for distcode */ |
|
| 113 |
- /* dynamic table building */ |
|
| 114 |
- unsigned ncode; /* number of code length code lengths */ |
|
| 115 |
- unsigned nlen; /* number of length code lengths */ |
|
| 116 |
- unsigned ndist; /* number of distance code lengths */ |
|
| 117 |
- unsigned have; /* number of code lengths in lens[] */ |
|
| 118 |
- code FAR *next; /* next available space in codes[] */ |
|
| 119 |
- unsigned short lens[320]; /* temporary storage for code lengths */ |
|
| 120 |
- unsigned short work[288]; /* work area for code table building */ |
|
| 121 |
- code codes[ENOUGH]; /* space for code tables */ |
|
| 122 |
- int sane; /* if false, allow invalid distance too far */ |
|
| 123 |
- int back; /* bits back of last unprocessed length/lit */ |
|
| 124 |
- unsigned was; /* initial length of match */ |
|
| 125 |
-}; |
| 126 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,304 +0,0 @@ |
| 1 |
-/* inftrees.c -- generate Huffman trees for efficient decoding |
|
| 2 |
- * Copyright (C) 1995-2017 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-#include "zutil.h" |
|
| 7 |
-#include "inftrees.h" |
|
| 8 |
- |
|
| 9 |
-#define MAXBITS 15 |
|
| 10 |
- |
|
| 11 |
-const char inflate_copyright[] = |
|
| 12 |
- " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; |
|
| 13 |
-/* |
|
| 14 |
- If you use the zlib library in a product, an acknowledgment is welcome |
|
| 15 |
- in the documentation of your product. If for some reason you cannot |
|
| 16 |
- include such an acknowledgment, I would appreciate that you keep this |
|
| 17 |
- copyright string in the executable of your product. |
|
| 18 |
- */ |
|
| 19 |
- |
|
| 20 |
-/* |
|
| 21 |
- Build a set of tables to decode the provided canonical Huffman code. |
|
| 22 |
- The code lengths are lens[0..codes-1]. The result starts at *table, |
|
| 23 |
- whose indices are 0..2^bits-1. work is a writable array of at least |
|
| 24 |
- lens shorts, which is used as a work area. type is the type of code |
|
| 25 |
- to be generated, CODES, LENS, or DISTS. On return, zero is success, |
|
| 26 |
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table |
|
| 27 |
- on return points to the next available entry's address. bits is the |
|
| 28 |
- requested root table index bits, and on return it is the actual root |
|
| 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. |
|
| 31 |
- */ |
|
| 32 |
-int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) |
|
| 33 |
-codetype type; |
|
| 34 |
-unsigned short FAR *lens; |
|
| 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 */ |
|
| 41 |
- unsigned sym; /* index of code symbols */ |
|
| 42 |
- unsigned min, max; /* minimum and maximum code lengths */ |
|
| 43 |
- unsigned root; /* number of index bits for root table */ |
|
| 44 |
- unsigned curr; /* number of index bits for current table */ |
|
| 45 |
- unsigned drop; /* code bits to drop for sub-table */ |
|
| 46 |
- int left; /* number of prefix codes available */ |
|
| 47 |
- unsigned used; /* code entries in table used */ |
|
| 48 |
- unsigned huff; /* Huffman code */ |
|
| 49 |
- unsigned incr; /* for incrementing code, index */ |
|
| 50 |
- unsigned fill; /* index for replicating entries */ |
|
| 51 |
- unsigned low; /* low bits for current root entry */ |
|
| 52 |
- unsigned mask; /* mask for low root bits */ |
|
| 53 |
- code here; /* table entry for duplication */ |
|
| 54 |
- code FAR *next; /* next available space in table */ |
|
| 55 |
- const unsigned short FAR *base; /* base value table to use */ |
|
| 56 |
- const unsigned short FAR *extra; /* extra bits table to use */ |
|
| 57 |
- unsigned match; /* use base and extra for symbol >= match */ |
|
| 58 |
- unsigned short count[MAXBITS+1]; /* number of codes of each length */ |
|
| 59 |
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ |
|
| 60 |
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
|
| 61 |
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
|
| 62 |
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
|
| 63 |
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
|
| 64 |
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, |
|
| 65 |
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; |
|
| 66 |
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
|
| 67 |
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
|
| 68 |
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
|
| 69 |
- 8193, 12289, 16385, 24577, 0, 0}; |
|
| 70 |
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
|
|
| 71 |
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, |
|
| 72 |
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, |
|
| 73 |
- 28, 28, 29, 29, 64, 64}; |
|
| 74 |
- |
|
| 75 |
- /* |
|
| 76 |
- Process a set of code lengths to create a canonical Huffman code. The |
|
| 77 |
- code lengths are lens[0..codes-1]. Each length corresponds to the |
|
| 78 |
- symbols 0..codes-1. The Huffman code is generated by first sorting the |
|
| 79 |
- symbols by length from short to long, and retaining the symbol order |
|
| 80 |
- for codes with equal lengths. Then the code starts with all zero bits |
|
| 81 |
- for the first code of the shortest length, and the codes are integer |
|
| 82 |
- increments for the same length, and zeros are appended as the length |
|
| 83 |
- increases. For the deflate format, these bits are stored backwards |
|
| 84 |
- from their more natural integer increment ordering, and so when the |
|
| 85 |
- decoding tables are built in the large loop below, the integer codes |
|
| 86 |
- are incremented backwards. |
|
| 87 |
- |
|
| 88 |
- This routine assumes, but does not check, that all of the entries in |
|
| 89 |
- lens[] are in the range 0..MAXBITS. The caller must assure this. |
|
| 90 |
- 1..MAXBITS is interpreted as that code length. zero means that that |
|
| 91 |
- symbol does not occur in this code. |
|
| 92 |
- |
|
| 93 |
- The codes are sorted by computing a count of codes for each length, |
|
| 94 |
- creating from that a table of starting indices for each length in the |
|
| 95 |
- sorted table, and then entering the symbols in order in the sorted |
|
| 96 |
- table. The sorted table is work[], with that space being provided by |
|
| 97 |
- the caller. |
|
| 98 |
- |
|
| 99 |
- The length counts are used for other purposes as well, i.e. finding |
|
| 100 |
- the minimum and maximum length codes, determining if there are any |
|
| 101 |
- codes at all, checking for a valid set of lengths, and looking ahead |
|
| 102 |
- at length counts to determine sub-table sizes when building the |
|
| 103 |
- decoding tables. |
|
| 104 |
- */ |
|
| 105 |
- |
|
| 106 |
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ |
|
| 107 |
- for (len = 0; len <= MAXBITS; len++) |
|
| 108 |
- count[len] = 0; |
|
| 109 |
- for (sym = 0; sym < codes; sym++) |
|
| 110 |
- count[lens[sym]]++; |
|
| 111 |
- |
|
| 112 |
- /* bound code lengths, force root to be within code lengths */ |
|
| 113 |
- root = *bits; |
|
| 114 |
- for (max = MAXBITS; max >= 1; max--) |
|
| 115 |
- if (count[max] != 0) break; |
|
| 116 |
- if (root > max) root = max; |
|
| 117 |
- if (max == 0) { /* no symbols to code at all */
|
|
| 118 |
- here.op = (unsigned char)64; /* invalid code marker */ |
|
| 119 |
- here.bits = (unsigned char)1; |
|
| 120 |
- here.val = (unsigned short)0; |
|
| 121 |
- *(*table)++ = here; /* make a table to force an error */ |
|
| 122 |
- *(*table)++ = here; |
|
| 123 |
- *bits = 1; |
|
| 124 |
- return 0; /* no symbols, but wait for decoding to report error */ |
|
| 125 |
- } |
|
| 126 |
- for (min = 1; min < max; min++) |
|
| 127 |
- if (count[min] != 0) break; |
|
| 128 |
- if (root < min) root = min; |
|
| 129 |
- |
|
| 130 |
- /* check for an over-subscribed or incomplete set of lengths */ |
|
| 131 |
- left = 1; |
|
| 132 |
- for (len = 1; len <= MAXBITS; len++) {
|
|
| 133 |
- left <<= 1; |
|
| 134 |
- left -= count[len]; |
|
| 135 |
- if (left < 0) return -1; /* over-subscribed */ |
|
| 136 |
- } |
|
| 137 |
- if (left > 0 && (type == CODES || max != 1)) |
|
| 138 |
- return -1; /* incomplete set */ |
|
| 139 |
- |
|
| 140 |
- /* generate offsets into symbol table for each length for sorting */ |
|
| 141 |
- offs[1] = 0; |
|
| 142 |
- for (len = 1; len < MAXBITS; len++) |
|
| 143 |
- offs[len + 1] = offs[len] + count[len]; |
|
| 144 |
- |
|
| 145 |
- /* sort symbols by length, by symbol order within each length */ |
|
| 146 |
- for (sym = 0; sym < codes; sym++) |
|
| 147 |
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; |
|
| 148 |
- |
|
| 149 |
- /* |
|
| 150 |
- Create and fill in decoding tables. In this loop, the table being |
|
| 151 |
- filled is at next and has curr index bits. The code being used is huff |
|
| 152 |
- with length len. That code is converted to an index by dropping drop |
|
| 153 |
- bits off of the bottom. For codes where len is less than drop + curr, |
|
| 154 |
- those top drop + curr - len bits are incremented through all values to |
|
| 155 |
- fill the table with replicated entries. |
|
| 156 |
- |
|
| 157 |
- root is the number of index bits for the root table. When len exceeds |
|
| 158 |
- root, sub-tables are created pointed to by the root entry with an index |
|
| 159 |
- of the low root bits of huff. This is saved in low to check for when a |
|
| 160 |
- new sub-table should be started. drop is zero when the root table is |
|
| 161 |
- being filled, and drop is root when sub-tables are being filled. |
|
| 162 |
- |
|
| 163 |
- When a new sub-table is needed, it is necessary to look ahead in the |
|
| 164 |
- code lengths to determine what size sub-table is needed. The length |
|
| 165 |
- counts are used for this, and so count[] is decremented as codes are |
|
| 166 |
- entered in the tables. |
|
| 167 |
- |
|
| 168 |
- used keeps track of how many table entries have been allocated from the |
|
| 169 |
- provided *table space. It is checked for LENS and DIST tables against |
|
| 170 |
- the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in |
|
| 171 |
- the initial root table size constants. See the comments in inftrees.h |
|
| 172 |
- for more information. |
|
| 173 |
- |
|
| 174 |
- sym increments through all symbols, and the loop terminates when |
|
| 175 |
- all codes of length max, i.e. all codes, have been processed. This |
|
| 176 |
- routine permits incomplete codes, so another loop after this one fills |
|
| 177 |
- in the rest of the decoding tables with invalid code markers. |
|
| 178 |
- */ |
|
| 179 |
- |
|
| 180 |
- /* set up for code type */ |
|
| 181 |
- switch (type) {
|
|
| 182 |
- case CODES: |
|
| 183 |
- base = extra = work; /* dummy value--not used */ |
|
| 184 |
- match = 20; |
|
| 185 |
- break; |
|
| 186 |
- case LENS: |
|
| 187 |
- base = lbase; |
|
| 188 |
- extra = lext; |
|
| 189 |
- match = 257; |
|
| 190 |
- break; |
|
| 191 |
- default: /* DISTS */ |
|
| 192 |
- base = dbase; |
|
| 193 |
- extra = dext; |
|
| 194 |
- match = 0; |
|
| 195 |
- } |
|
| 196 |
- |
|
| 197 |
- /* initialize state for loop */ |
|
| 198 |
- huff = 0; /* starting code */ |
|
| 199 |
- sym = 0; /* starting code symbol */ |
|
| 200 |
- len = min; /* starting code length */ |
|
| 201 |
- next = *table; /* current table to fill in */ |
|
| 202 |
- curr = root; /* current table index bits */ |
|
| 203 |
- drop = 0; /* current bits to drop from code for index */ |
|
| 204 |
- low = (unsigned)(-1); /* trigger new sub-table when len > root */ |
|
| 205 |
- used = 1U << root; /* use root table entries */ |
|
| 206 |
- mask = used - 1; /* mask for comparing low */ |
|
| 207 |
- |
|
| 208 |
- /* check available table space */ |
|
| 209 |
- if ((type == LENS && used > ENOUGH_LENS) || |
|
| 210 |
- (type == DISTS && used > ENOUGH_DISTS)) |
|
| 211 |
- return 1; |
|
| 212 |
- |
|
| 213 |
- /* process all codes and make table entries */ |
|
| 214 |
- for (;;) {
|
|
| 215 |
- /* create table entry */ |
|
| 216 |
- here.bits = (unsigned char)(len - drop); |
|
| 217 |
- if (work[sym] + 1U < match) {
|
|
| 218 |
- here.op = (unsigned char)0; |
|
| 219 |
- here.val = work[sym]; |
|
| 220 |
- } |
|
| 221 |
- else if (work[sym] >= match) {
|
|
| 222 |
- here.op = (unsigned char)(extra[work[sym] - match]); |
|
| 223 |
- here.val = base[work[sym] - match]; |
|
| 224 |
- } |
|
| 225 |
- else {
|
|
| 226 |
- here.op = (unsigned char)(32 + 64); /* end of block */ |
|
| 227 |
- here.val = 0; |
|
| 228 |
- } |
|
| 229 |
- |
|
| 230 |
- /* replicate for those indices with low len bits equal to huff */ |
|
| 231 |
- incr = 1U << (len - drop); |
|
| 232 |
- fill = 1U << curr; |
|
| 233 |
- min = fill; /* save offset to next table */ |
|
| 234 |
- do {
|
|
| 235 |
- fill -= incr; |
|
| 236 |
- next[(huff >> drop) + fill] = here; |
|
| 237 |
- } while (fill != 0); |
|
| 238 |
- |
|
| 239 |
- /* backwards increment the len-bit code huff */ |
|
| 240 |
- incr = 1U << (len - 1); |
|
| 241 |
- while (huff & incr) |
|
| 242 |
- incr >>= 1; |
|
| 243 |
- if (incr != 0) {
|
|
| 244 |
- huff &= incr - 1; |
|
| 245 |
- huff += incr; |
|
| 246 |
- } |
|
| 247 |
- else |
|
| 248 |
- huff = 0; |
|
| 249 |
- |
|
| 250 |
- /* go to next symbol, update count, len */ |
|
| 251 |
- sym++; |
|
| 252 |
- if (--(count[len]) == 0) {
|
|
| 253 |
- if (len == max) break; |
|
| 254 |
- len = lens[work[sym]]; |
|
| 255 |
- } |
|
| 256 |
- |
|
| 257 |
- /* create new sub-table if needed */ |
|
| 258 |
- if (len > root && (huff & mask) != low) {
|
|
| 259 |
- /* if first time, transition to sub-tables */ |
|
| 260 |
- if (drop == 0) |
|
| 261 |
- drop = root; |
|
| 262 |
- |
|
| 263 |
- /* increment past last table */ |
|
| 264 |
- next += min; /* here min is 1 << curr */ |
|
| 265 |
- |
|
| 266 |
- /* determine length of next table */ |
|
| 267 |
- curr = len - drop; |
|
| 268 |
- left = (int)(1 << curr); |
|
| 269 |
- while (curr + drop < max) {
|
|
| 270 |
- left -= count[curr + drop]; |
|
| 271 |
- if (left <= 0) break; |
|
| 272 |
- curr++; |
|
| 273 |
- left <<= 1; |
|
| 274 |
- } |
|
| 275 |
- |
|
| 276 |
- /* check for enough space */ |
|
| 277 |
- used += 1U << curr; |
|
| 278 |
- if ((type == LENS && used > ENOUGH_LENS) || |
|
| 279 |
- (type == DISTS && used > ENOUGH_DISTS)) |
|
| 280 |
- return 1; |
|
| 281 |
- |
|
| 282 |
- /* point entry in root table to sub-table */ |
|
| 283 |
- low = huff & mask; |
|
| 284 |
- (*table)[low].op = (unsigned char)curr; |
|
| 285 |
- (*table)[low].bits = (unsigned char)root; |
|
| 286 |
- (*table)[low].val = (unsigned short)(next - *table); |
|
| 287 |
- } |
|
| 288 |
- } |
|
| 289 |
- |
|
| 290 |
- /* fill in remaining table entry if code is incomplete (guaranteed to have |
|
| 291 |
- at most one remaining entry, since if the code is incomplete, the |
|
| 292 |
- maximum code length that was allowed to get this far is one bit) */ |
|
| 293 |
- if (huff != 0) {
|
|
| 294 |
- here.op = (unsigned char)64; /* invalid code marker */ |
|
| 295 |
- here.bits = (unsigned char)(len - drop); |
|
| 296 |
- here.val = (unsigned short)0; |
|
| 297 |
- next[huff] = here; |
|
| 298 |
- } |
|
| 299 |
- |
|
| 300 |
- /* set return parameters */ |
|
| 301 |
- *table += used; |
|
| 302 |
- *bits = root; |
|
| 303 |
- return 0; |
|
| 304 |
-} |
| 305 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,62 +0,0 @@ |
| 1 |
-/* inftrees.h -- header to use inftrees.c |
|
| 2 |
- * Copyright (C) 1995-2005, 2010 Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* WARNING: this file should *not* be used by applications. It is |
|
| 7 |
- part of the implementation of the compression library and is |
|
| 8 |
- subject to change. Applications should only use zlib.h. |
|
| 9 |
- */ |
|
| 10 |
- |
|
| 11 |
-/* Structure for decoding tables. Each entry provides either the |
|
| 12 |
- information needed to do the operation requested by the code that |
|
| 13 |
- indexed that table entry, or it provides a pointer to another |
|
| 14 |
- table that indexes more bits of the code. op indicates whether |
|
| 15 |
- the entry is a pointer to another table, a literal, a length or |
|
| 16 |
- distance, an end-of-block, or an invalid code. For a table |
|
| 17 |
- pointer, the low four bits of op is the number of index bits of |
|
| 18 |
- that table. For a length or distance, the low four bits of op |
|
| 19 |
- is the number of extra bits to get after the code. bits is |
|
| 20 |
- the number of bits in this code or part of the code to drop off |
|
| 21 |
- of the bit buffer. val is the actual byte to output in the case |
|
| 22 |
- of a literal, the base length or distance, or the offset from |
|
| 23 |
- the current table to the next table. Each entry is four bytes. */ |
|
| 24 |
-typedef struct {
|
|
| 25 |
- unsigned char op; /* operation, extra bits, table bits */ |
|
| 26 |
- unsigned char bits; /* bits in this part of the code */ |
|
| 27 |
- unsigned short val; /* offset in table or code value */ |
|
| 28 |
-} code; |
|
| 29 |
- |
|
| 30 |
-/* op values as set by inflate_table(): |
|
| 31 |
- 00000000 - literal |
|
| 32 |
- 0000tttt - table link, tttt != 0 is the number of table index bits |
|
| 33 |
- 0001eeee - length or distance, eeee is the number of extra bits |
|
| 34 |
- 01100000 - end of block |
|
| 35 |
- 01000000 - invalid code |
|
| 36 |
- */ |
|
| 37 |
- |
|
| 38 |
-/* Maximum size of the dynamic table. The maximum number of code structures is |
|
| 39 |
- 1444, which is the sum of 852 for literal/length codes and 592 for distance |
|
| 40 |
- codes. These values were found by exhaustive searches using the program |
|
| 41 |
- examples/enough.c found in the zlib distribtution. The arguments to that |
|
| 42 |
- program are the number of symbols, the initial root table size, and the |
|
| 43 |
- maximum bit length of a code. "enough 286 9 15" for literal/length codes |
|
| 44 |
- returns returns 852, and "enough 30 6 15" for distance codes returns 592. |
|
| 45 |
- The initial root table size (9 or 6) is found in the fifth argument of the |
|
| 46 |
- inflate_table() calls in inflate.c and infback.c. If the root table size is |
|
| 47 |
- changed, then these maximum sizes would be need to be recalculated and |
|
| 48 |
- updated. */ |
|
| 49 |
-#define ENOUGH_LENS 852 |
|
| 50 |
-#define ENOUGH_DISTS 592 |
|
| 51 |
-#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) |
|
| 52 |
- |
|
| 53 |
-/* Type of code to build for inflate_table() */ |
|
| 54 |
-typedef enum {
|
|
| 55 |
- CODES, |
|
| 56 |
- LENS, |
|
| 57 |
- DISTS |
|
| 58 |
-} codetype; |
|
| 59 |
- |
|
| 60 |
-int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, |
|
| 61 |
- unsigned codes, code FAR * FAR *table, |
|
| 62 |
- unsigned FAR *bits, unsigned short FAR *work)); |
| 63 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,93 +0,0 @@ |
| 1 |
-/* uncompr.c -- decompress a memory buffer |
|
| 2 |
- * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* @(#) $Id$ */ |
|
| 7 |
- |
|
| 8 |
-#define ZLIB_INTERNAL |
|
| 9 |
-#include "zlib.h" |
|
| 10 |
- |
|
| 11 |
-/* =========================================================================== |
|
| 12 |
- Decompresses the source buffer into the destination buffer. *sourceLen is |
|
| 13 |
- the byte length of the source buffer. Upon entry, *destLen is the total size |
|
| 14 |
- of the destination buffer, which must be large enough to hold the entire |
|
| 15 |
- uncompressed data. (The size of the uncompressed data must have been saved |
|
| 16 |
- previously by the compressor and transmitted to the decompressor by some |
|
| 17 |
- mechanism outside the scope of this compression library.) Upon exit, |
|
| 18 |
- *destLen is the size of the decompressed data and *sourceLen is the number |
|
| 19 |
- of source bytes consumed. Upon return, source + *sourceLen points to the |
|
| 20 |
- first unused input byte. |
|
| 21 |
- |
|
| 22 |
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|
| 23 |
- memory, Z_BUF_ERROR if there was not enough room in the output buffer, or |
|
| 24 |
- Z_DATA_ERROR if the input data was corrupted, including if the input data is |
|
| 25 |
- an incomplete zlib stream. |
|
| 26 |
-*/ |
|
| 27 |
-int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) |
|
| 28 |
- Bytef *dest; |
|
| 29 |
- uLongf *destLen; |
|
| 30 |
- const Bytef *source; |
|
| 31 |
- uLong *sourceLen; |
|
| 32 |
-{
|
|
| 33 |
- z_stream stream; |
|
| 34 |
- int err; |
|
| 35 |
- const uInt max = (uInt)-1; |
|
| 36 |
- uLong len, left; |
|
| 37 |
- Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ |
|
| 38 |
- |
|
| 39 |
- len = *sourceLen; |
|
| 40 |
- if (*destLen) {
|
|
| 41 |
- left = *destLen; |
|
| 42 |
- *destLen = 0; |
|
| 43 |
- } |
|
| 44 |
- else {
|
|
| 45 |
- left = 1; |
|
| 46 |
- dest = buf; |
|
| 47 |
- } |
|
| 48 |
- |
|
| 49 |
- stream.next_in = (z_const Bytef *)source; |
|
| 50 |
- stream.avail_in = 0; |
|
| 51 |
- stream.zalloc = (alloc_func)0; |
|
| 52 |
- stream.zfree = (free_func)0; |
|
| 53 |
- stream.opaque = (voidpf)0; |
|
| 54 |
- |
|
| 55 |
- err = inflateInit(&stream); |
|
| 56 |
- if (err != Z_OK) return err; |
|
| 57 |
- |
|
| 58 |
- stream.next_out = dest; |
|
| 59 |
- stream.avail_out = 0; |
|
| 60 |
- |
|
| 61 |
- do {
|
|
| 62 |
- if (stream.avail_out == 0) {
|
|
| 63 |
- stream.avail_out = left > (uLong)max ? max : (uInt)left; |
|
| 64 |
- left -= stream.avail_out; |
|
| 65 |
- } |
|
| 66 |
- if (stream.avail_in == 0) {
|
|
| 67 |
- stream.avail_in = len > (uLong)max ? max : (uInt)len; |
|
| 68 |
- len -= stream.avail_in; |
|
| 69 |
- } |
|
| 70 |
- err = inflate(&stream, Z_NO_FLUSH); |
|
| 71 |
- } while (err == Z_OK); |
|
| 72 |
- |
|
| 73 |
- *sourceLen -= len + stream.avail_in; |
|
| 74 |
- if (dest != buf) |
|
| 75 |
- *destLen = stream.total_out; |
|
| 76 |
- else if (stream.total_out && err == Z_BUF_ERROR) |
|
| 77 |
- left = 1; |
|
| 78 |
- |
|
| 79 |
- inflateEnd(&stream); |
|
| 80 |
- return err == Z_STREAM_END ? Z_OK : |
|
| 81 |
- err == Z_NEED_DICT ? Z_DATA_ERROR : |
|
| 82 |
- err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : |
|
| 83 |
- err; |
|
| 84 |
-} |
|
| 85 |
- |
|
| 86 |
-int ZEXPORT uncompress (dest, destLen, source, sourceLen) |
|
| 87 |
- Bytef *dest; |
|
| 88 |
- uLongf *destLen; |
|
| 89 |
- const Bytef *source; |
|
| 90 |
- uLong sourceLen; |
|
| 91 |
-{
|
|
| 92 |
- return uncompress2(dest, destLen, source, &sourceLen); |
|
| 93 |
-} |
| 94 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,534 +0,0 @@ |
| 1 |
-/* zconf.h -- configuration of the zlib compression library |
|
| 2 |
- * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* @(#) $Id$ */ |
|
| 7 |
- |
|
| 8 |
-#ifndef ZCONF_H |
|
| 9 |
-#define ZCONF_H |
|
| 10 |
- |
|
| 11 |
-/* |
|
| 12 |
- * If you *really* need a unique prefix for all types and library functions, |
|
| 13 |
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. |
|
| 14 |
- * Even better than compiling with -DZ_PREFIX would be to use configure to set |
|
| 15 |
- * this permanently in zconf.h using "./configure --zprefix". |
|
| 16 |
- */ |
|
| 17 |
-#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ |
|
| 18 |
-# define Z_PREFIX_SET |
|
| 19 |
- |
|
| 20 |
-/* all linked symbols and init macros */ |
|
| 21 |
-# define _dist_code z__dist_code |
|
| 22 |
-# define _length_code z__length_code |
|
| 23 |
-# define _tr_align z__tr_align |
|
| 24 |
-# define _tr_flush_bits z__tr_flush_bits |
|
| 25 |
-# define _tr_flush_block z__tr_flush_block |
|
| 26 |
-# define _tr_init z__tr_init |
|
| 27 |
-# define _tr_stored_block z__tr_stored_block |
|
| 28 |
-# define _tr_tally z__tr_tally |
|
| 29 |
-# define adler32 z_adler32 |
|
| 30 |
-# define adler32_combine z_adler32_combine |
|
| 31 |
-# define adler32_combine64 z_adler32_combine64 |
|
| 32 |
-# define adler32_z z_adler32_z |
|
| 33 |
-# ifndef Z_SOLO |
|
| 34 |
-# define compress z_compress |
|
| 35 |
-# define compress2 z_compress2 |
|
| 36 |
-# define compressBound z_compressBound |
|
| 37 |
-# endif |
|
| 38 |
-# define crc32 z_crc32 |
|
| 39 |
-# define crc32_combine z_crc32_combine |
|
| 40 |
-# define crc32_combine64 z_crc32_combine64 |
|
| 41 |
-# define crc32_z z_crc32_z |
|
| 42 |
-# define deflate z_deflate |
|
| 43 |
-# define deflateBound z_deflateBound |
|
| 44 |
-# define deflateCopy z_deflateCopy |
|
| 45 |
-# define deflateEnd z_deflateEnd |
|
| 46 |
-# define deflateGetDictionary z_deflateGetDictionary |
|
| 47 |
-# define deflateInit z_deflateInit |
|
| 48 |
-# define deflateInit2 z_deflateInit2 |
|
| 49 |
-# define deflateInit2_ z_deflateInit2_ |
|
| 50 |
-# define deflateInit_ z_deflateInit_ |
|
| 51 |
-# define deflateParams z_deflateParams |
|
| 52 |
-# define deflatePending z_deflatePending |
|
| 53 |
-# define deflatePrime z_deflatePrime |
|
| 54 |
-# define deflateReset z_deflateReset |
|
| 55 |
-# define deflateResetKeep z_deflateResetKeep |
|
| 56 |
-# define deflateSetDictionary z_deflateSetDictionary |
|
| 57 |
-# define deflateSetHeader z_deflateSetHeader |
|
| 58 |
-# define deflateTune z_deflateTune |
|
| 59 |
-# define deflate_copyright z_deflate_copyright |
|
| 60 |
-# define get_crc_table z_get_crc_table |
|
| 61 |
-# ifndef Z_SOLO |
|
| 62 |
-# define gz_error z_gz_error |
|
| 63 |
-# define gz_intmax z_gz_intmax |
|
| 64 |
-# define gz_strwinerror z_gz_strwinerror |
|
| 65 |
-# define gzbuffer z_gzbuffer |
|
| 66 |
-# define gzclearerr z_gzclearerr |
|
| 67 |
-# define gzclose z_gzclose |
|
| 68 |
-# define gzclose_r z_gzclose_r |
|
| 69 |
-# define gzclose_w z_gzclose_w |
|
| 70 |
-# define gzdirect z_gzdirect |
|
| 71 |
-# define gzdopen z_gzdopen |
|
| 72 |
-# define gzeof z_gzeof |
|
| 73 |
-# define gzerror z_gzerror |
|
| 74 |
-# define gzflush z_gzflush |
|
| 75 |
-# define gzfread z_gzfread |
|
| 76 |
-# define gzfwrite z_gzfwrite |
|
| 77 |
-# define gzgetc z_gzgetc |
|
| 78 |
-# define gzgetc_ z_gzgetc_ |
|
| 79 |
-# define gzgets z_gzgets |
|
| 80 |
-# define gzoffset z_gzoffset |
|
| 81 |
-# define gzoffset64 z_gzoffset64 |
|
| 82 |
-# define gzopen z_gzopen |
|
| 83 |
-# define gzopen64 z_gzopen64 |
|
| 84 |
-# ifdef _WIN32 |
|
| 85 |
-# define gzopen_w z_gzopen_w |
|
| 86 |
-# endif |
|
| 87 |
-# define gzprintf z_gzprintf |
|
| 88 |
-# define gzputc z_gzputc |
|
| 89 |
-# define gzputs z_gzputs |
|
| 90 |
-# define gzread z_gzread |
|
| 91 |
-# define gzrewind z_gzrewind |
|
| 92 |
-# define gzseek z_gzseek |
|
| 93 |
-# define gzseek64 z_gzseek64 |
|
| 94 |
-# define gzsetparams z_gzsetparams |
|
| 95 |
-# define gztell z_gztell |
|
| 96 |
-# define gztell64 z_gztell64 |
|
| 97 |
-# define gzungetc z_gzungetc |
|
| 98 |
-# define gzvprintf z_gzvprintf |
|
| 99 |
-# define gzwrite z_gzwrite |
|
| 100 |
-# endif |
|
| 101 |
-# define inflate z_inflate |
|
| 102 |
-# define inflateBack z_inflateBack |
|
| 103 |
-# define inflateBackEnd z_inflateBackEnd |
|
| 104 |
-# define inflateBackInit z_inflateBackInit |
|
| 105 |
-# define inflateBackInit_ z_inflateBackInit_ |
|
| 106 |
-# define inflateCodesUsed z_inflateCodesUsed |
|
| 107 |
-# define inflateCopy z_inflateCopy |
|
| 108 |
-# define inflateEnd z_inflateEnd |
|
| 109 |
-# define inflateGetDictionary z_inflateGetDictionary |
|
| 110 |
-# define inflateGetHeader z_inflateGetHeader |
|
| 111 |
-# define inflateInit z_inflateInit |
|
| 112 |
-# define inflateInit2 z_inflateInit2 |
|
| 113 |
-# define inflateInit2_ z_inflateInit2_ |
|
| 114 |
-# define inflateInit_ z_inflateInit_ |
|
| 115 |
-# define inflateMark z_inflateMark |
|
| 116 |
-# define inflatePrime z_inflatePrime |
|
| 117 |
-# define inflateReset z_inflateReset |
|
| 118 |
-# define inflateReset2 z_inflateReset2 |
|
| 119 |
-# define inflateResetKeep z_inflateResetKeep |
|
| 120 |
-# define inflateSetDictionary z_inflateSetDictionary |
|
| 121 |
-# define inflateSync z_inflateSync |
|
| 122 |
-# define inflateSyncPoint z_inflateSyncPoint |
|
| 123 |
-# define inflateUndermine z_inflateUndermine |
|
| 124 |
-# define inflateValidate z_inflateValidate |
|
| 125 |
-# define inflate_copyright z_inflate_copyright |
|
| 126 |
-# define inflate_fast z_inflate_fast |
|
| 127 |
-# define inflate_table z_inflate_table |
|
| 128 |
-# ifndef Z_SOLO |
|
| 129 |
-# define uncompress z_uncompress |
|
| 130 |
-# define uncompress2 z_uncompress2 |
|
| 131 |
-# endif |
|
| 132 |
-# define zError z_zError |
|
| 133 |
-# ifndef Z_SOLO |
|
| 134 |
-# define zcalloc z_zcalloc |
|
| 135 |
-# define zcfree z_zcfree |
|
| 136 |
-# endif |
|
| 137 |
-# define zlibCompileFlags z_zlibCompileFlags |
|
| 138 |
-# define zlibVersion z_zlibVersion |
|
| 139 |
- |
|
| 140 |
-/* all zlib typedefs in zlib.h and zconf.h */ |
|
| 141 |
-# define Byte z_Byte |
|
| 142 |
-# define Bytef z_Bytef |
|
| 143 |
-# define alloc_func z_alloc_func |
|
| 144 |
-# define charf z_charf |
|
| 145 |
-# define free_func z_free_func |
|
| 146 |
-# ifndef Z_SOLO |
|
| 147 |
-# define gzFile z_gzFile |
|
| 148 |
-# endif |
|
| 149 |
-# define gz_header z_gz_header |
|
| 150 |
-# define gz_headerp z_gz_headerp |
|
| 151 |
-# define in_func z_in_func |
|
| 152 |
-# define intf z_intf |
|
| 153 |
-# define out_func z_out_func |
|
| 154 |
-# define uInt z_uInt |
|
| 155 |
-# define uIntf z_uIntf |
|
| 156 |
-# define uLong z_uLong |
|
| 157 |
-# define uLongf z_uLongf |
|
| 158 |
-# define voidp z_voidp |
|
| 159 |
-# define voidpc z_voidpc |
|
| 160 |
-# define voidpf z_voidpf |
|
| 161 |
- |
|
| 162 |
-/* all zlib structs in zlib.h and zconf.h */ |
|
| 163 |
-# define gz_header_s z_gz_header_s |
|
| 164 |
-# define internal_state z_internal_state |
|
| 165 |
- |
|
| 166 |
-#endif |
|
| 167 |
- |
|
| 168 |
-#if defined(__MSDOS__) && !defined(MSDOS) |
|
| 169 |
-# define MSDOS |
|
| 170 |
-#endif |
|
| 171 |
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) |
|
| 172 |
-# define OS2 |
|
| 173 |
-#endif |
|
| 174 |
-#if defined(_WINDOWS) && !defined(WINDOWS) |
|
| 175 |
-# define WINDOWS |
|
| 176 |
-#endif |
|
| 177 |
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) |
|
| 178 |
-# ifndef WIN32 |
|
| 179 |
-# define WIN32 |
|
| 180 |
-# endif |
|
| 181 |
-#endif |
|
| 182 |
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) |
|
| 183 |
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) |
|
| 184 |
-# ifndef SYS16BIT |
|
| 185 |
-# define SYS16BIT |
|
| 186 |
-# endif |
|
| 187 |
-# endif |
|
| 188 |
-#endif |
|
| 189 |
- |
|
| 190 |
-/* |
|
| 191 |
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more |
|
| 192 |
- * than 64k bytes at a time (needed on systems with 16-bit int). |
|
| 193 |
- */ |
|
| 194 |
-#ifdef SYS16BIT |
|
| 195 |
-# define MAXSEG_64K |
|
| 196 |
-#endif |
|
| 197 |
-#ifdef MSDOS |
|
| 198 |
-# define UNALIGNED_OK |
|
| 199 |
-#endif |
|
| 200 |
- |
|
| 201 |
-#ifdef __STDC_VERSION__ |
|
| 202 |
-# ifndef STDC |
|
| 203 |
-# define STDC |
|
| 204 |
-# endif |
|
| 205 |
-# if __STDC_VERSION__ >= 199901L |
|
| 206 |
-# ifndef STDC99 |
|
| 207 |
-# define STDC99 |
|
| 208 |
-# endif |
|
| 209 |
-# endif |
|
| 210 |
-#endif |
|
| 211 |
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) |
|
| 212 |
-# define STDC |
|
| 213 |
-#endif |
|
| 214 |
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) |
|
| 215 |
-# define STDC |
|
| 216 |
-#endif |
|
| 217 |
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) |
|
| 218 |
-# define STDC |
|
| 219 |
-#endif |
|
| 220 |
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) |
|
| 221 |
-# define STDC |
|
| 222 |
-#endif |
|
| 223 |
- |
|
| 224 |
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ |
|
| 225 |
-# define STDC |
|
| 226 |
-#endif |
|
| 227 |
- |
|
| 228 |
-#ifndef STDC |
|
| 229 |
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ |
|
| 230 |
-# define const /* note: need a more gentle solution here */ |
|
| 231 |
-# endif |
|
| 232 |
-#endif |
|
| 233 |
- |
|
| 234 |
-#if defined(ZLIB_CONST) && !defined(z_const) |
|
| 235 |
-# define z_const const |
|
| 236 |
-#else |
|
| 237 |
-# define z_const |
|
| 238 |
-#endif |
|
| 239 |
- |
|
| 240 |
-#ifdef Z_SOLO |
|
| 241 |
- typedef unsigned long z_size_t; |
|
| 242 |
-#else |
|
| 243 |
-# define z_longlong long long |
|
| 244 |
-# if defined(NO_SIZE_T) |
|
| 245 |
- typedef unsigned NO_SIZE_T z_size_t; |
|
| 246 |
-# elif defined(STDC) |
|
| 247 |
-# include <stddef.h> |
|
| 248 |
- typedef size_t z_size_t; |
|
| 249 |
-# else |
|
| 250 |
- typedef unsigned long z_size_t; |
|
| 251 |
-# endif |
|
| 252 |
-# undef z_longlong |
|
| 253 |
-#endif |
|
| 254 |
- |
|
| 255 |
-/* Maximum value for memLevel in deflateInit2 */ |
|
| 256 |
-#ifndef MAX_MEM_LEVEL |
|
| 257 |
-# ifdef MAXSEG_64K |
|
| 258 |
-# define MAX_MEM_LEVEL 8 |
|
| 259 |
-# else |
|
| 260 |
-# define MAX_MEM_LEVEL 9 |
|
| 261 |
-# endif |
|
| 262 |
-#endif |
|
| 263 |
- |
|
| 264 |
-/* Maximum value for windowBits in deflateInit2 and inflateInit2. |
|
| 265 |
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files |
|
| 266 |
- * created by gzip. (Files created by minigzip can still be extracted by |
|
| 267 |
- * gzip.) |
|
| 268 |
- */ |
|
| 269 |
-#ifndef MAX_WBITS |
|
| 270 |
-# define MAX_WBITS 15 /* 32K LZ77 window */ |
|
| 271 |
-#endif |
|
| 272 |
- |
|
| 273 |
-/* The memory requirements for deflate are (in bytes): |
|
| 274 |
- (1 << (windowBits+2)) + (1 << (memLevel+9)) |
|
| 275 |
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) |
|
| 276 |
- plus a few kilobytes for small objects. For example, if you want to reduce |
|
| 277 |
- the default memory requirements from 256K to 128K, compile with |
|
| 278 |
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" |
|
| 279 |
- Of course this will generally degrade compression (there's no free lunch). |
|
| 280 |
- |
|
| 281 |
- The memory requirements for inflate are (in bytes) 1 << windowBits |
|
| 282 |
- that is, 32K for windowBits=15 (default value) plus about 7 kilobytes |
|
| 283 |
- for small objects. |
|
| 284 |
-*/ |
|
| 285 |
- |
|
| 286 |
- /* Type declarations */ |
|
| 287 |
- |
|
| 288 |
-#ifndef OF /* function prototypes */ |
|
| 289 |
-# ifdef STDC |
|
| 290 |
-# define OF(args) args |
|
| 291 |
-# else |
|
| 292 |
-# define OF(args) () |
|
| 293 |
-# endif |
|
| 294 |
-#endif |
|
| 295 |
- |
|
| 296 |
-#ifndef Z_ARG /* function prototypes for stdarg */ |
|
| 297 |
-# if defined(STDC) || defined(Z_HAVE_STDARG_H) |
|
| 298 |
-# define Z_ARG(args) args |
|
| 299 |
-# else |
|
| 300 |
-# define Z_ARG(args) () |
|
| 301 |
-# endif |
|
| 302 |
-#endif |
|
| 303 |
- |
|
| 304 |
-/* The following definitions for FAR are needed only for MSDOS mixed |
|
| 305 |
- * model programming (small or medium model with some far allocations). |
|
| 306 |
- * This was tested only with MSC; for other MSDOS compilers you may have |
|
| 307 |
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, |
|
| 308 |
- * just define FAR to be empty. |
|
| 309 |
- */ |
|
| 310 |
-#ifdef SYS16BIT |
|
| 311 |
-# if defined(M_I86SM) || defined(M_I86MM) |
|
| 312 |
- /* MSC small or medium model */ |
|
| 313 |
-# define SMALL_MEDIUM |
|
| 314 |
-# ifdef _MSC_VER |
|
| 315 |
-# define FAR _far |
|
| 316 |
-# else |
|
| 317 |
-# define FAR far |
|
| 318 |
-# endif |
|
| 319 |
-# endif |
|
| 320 |
-# if (defined(__SMALL__) || defined(__MEDIUM__)) |
|
| 321 |
- /* Turbo C small or medium model */ |
|
| 322 |
-# define SMALL_MEDIUM |
|
| 323 |
-# ifdef __BORLANDC__ |
|
| 324 |
-# define FAR _far |
|
| 325 |
-# else |
|
| 326 |
-# define FAR far |
|
| 327 |
-# endif |
|
| 328 |
-# endif |
|
| 329 |
-#endif |
|
| 330 |
- |
|
| 331 |
-#if defined(WINDOWS) || defined(WIN32) |
|
| 332 |
- /* If building or using zlib as a DLL, define ZLIB_DLL. |
|
| 333 |
- * This is not mandatory, but it offers a little performance increase. |
|
| 334 |
- */ |
|
| 335 |
-# ifdef ZLIB_DLL |
|
| 336 |
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) |
|
| 337 |
-# ifdef ZLIB_INTERNAL |
|
| 338 |
-# define ZEXTERN extern __declspec(dllexport) |
|
| 339 |
-# else |
|
| 340 |
-# define ZEXTERN extern __declspec(dllimport) |
|
| 341 |
-# endif |
|
| 342 |
-# endif |
|
| 343 |
-# endif /* ZLIB_DLL */ |
|
| 344 |
- /* If building or using zlib with the WINAPI/WINAPIV calling convention, |
|
| 345 |
- * define ZLIB_WINAPI. |
|
| 346 |
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. |
|
| 347 |
- */ |
|
| 348 |
-# ifdef ZLIB_WINAPI |
|
| 349 |
-# ifdef FAR |
|
| 350 |
-# undef FAR |
|
| 351 |
-# endif |
|
| 352 |
-# include <windows.h> |
|
| 353 |
- /* No need for _export, use ZLIB.DEF instead. */ |
|
| 354 |
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */ |
|
| 355 |
-# define ZEXPORT WINAPI |
|
| 356 |
-# ifdef WIN32 |
|
| 357 |
-# define ZEXPORTVA WINAPIV |
|
| 358 |
-# else |
|
| 359 |
-# define ZEXPORTVA FAR CDECL |
|
| 360 |
-# endif |
|
| 361 |
-# endif |
|
| 362 |
-#endif |
|
| 363 |
- |
|
| 364 |
-#if defined (__BEOS__) |
|
| 365 |
-# ifdef ZLIB_DLL |
|
| 366 |
-# ifdef ZLIB_INTERNAL |
|
| 367 |
-# define ZEXPORT __declspec(dllexport) |
|
| 368 |
-# define ZEXPORTVA __declspec(dllexport) |
|
| 369 |
-# else |
|
| 370 |
-# define ZEXPORT __declspec(dllimport) |
|
| 371 |
-# define ZEXPORTVA __declspec(dllimport) |
|
| 372 |
-# endif |
|
| 373 |
-# endif |
|
| 374 |
-#endif |
|
| 375 |
- |
|
| 376 |
-#ifndef ZEXTERN |
|
| 377 |
-# define ZEXTERN extern |
|
| 378 |
-#endif |
|
| 379 |
-#ifndef ZEXPORT |
|
| 380 |
-# define ZEXPORT |
|
| 381 |
-#endif |
|
| 382 |
-#ifndef ZEXPORTVA |
|
| 383 |
-# define ZEXPORTVA |
|
| 384 |
-#endif |
|
| 385 |
- |
|
| 386 |
-#ifndef FAR |
|
| 387 |
-# define FAR |
|
| 388 |
-#endif |
|
| 389 |
- |
|
| 390 |
-#if !defined(__MACTYPES__) |
|
| 391 |
-typedef unsigned char Byte; /* 8 bits */ |
|
| 392 |
-#endif |
|
| 393 |
-typedef unsigned int uInt; /* 16 bits or more */ |
|
| 394 |
-typedef unsigned long uLong; /* 32 bits or more */ |
|
| 395 |
- |
|
| 396 |
-#ifdef SMALL_MEDIUM |
|
| 397 |
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ |
|
| 398 |
-# define Bytef Byte FAR |
|
| 399 |
-#else |
|
| 400 |
- typedef Byte FAR Bytef; |
|
| 401 |
-#endif |
|
| 402 |
-typedef char FAR charf; |
|
| 403 |
-typedef int FAR intf; |
|
| 404 |
-typedef uInt FAR uIntf; |
|
| 405 |
-typedef uLong FAR uLongf; |
|
| 406 |
- |
|
| 407 |
-#ifdef STDC |
|
| 408 |
- typedef void const *voidpc; |
|
| 409 |
- typedef void FAR *voidpf; |
|
| 410 |
- typedef void *voidp; |
|
| 411 |
-#else |
|
| 412 |
- typedef Byte const *voidpc; |
|
| 413 |
- typedef Byte FAR *voidpf; |
|
| 414 |
- typedef Byte *voidp; |
|
| 415 |
-#endif |
|
| 416 |
- |
|
| 417 |
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) |
|
| 418 |
-# include <limits.h> |
|
| 419 |
-# if (UINT_MAX == 0xffffffffUL) |
|
| 420 |
-# define Z_U4 unsigned |
|
| 421 |
-# elif (ULONG_MAX == 0xffffffffUL) |
|
| 422 |
-# define Z_U4 unsigned long |
|
| 423 |
-# elif (USHRT_MAX == 0xffffffffUL) |
|
| 424 |
-# define Z_U4 unsigned short |
|
| 425 |
-# endif |
|
| 426 |
-#endif |
|
| 427 |
- |
|
| 428 |
-#ifdef Z_U4 |
|
| 429 |
- typedef Z_U4 z_crc_t; |
|
| 430 |
-#else |
|
| 431 |
- typedef unsigned long z_crc_t; |
|
| 432 |
-#endif |
|
| 433 |
- |
|
| 434 |
-#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ |
|
| 435 |
-# define Z_HAVE_UNISTD_H |
|
| 436 |
-#endif |
|
| 437 |
- |
|
| 438 |
-#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ |
|
| 439 |
-# define Z_HAVE_STDARG_H |
|
| 440 |
-#endif |
|
| 441 |
- |
|
| 442 |
-#ifdef STDC |
|
| 443 |
-# ifndef Z_SOLO |
|
| 444 |
-# include <sys/types.h> /* for off_t */ |
|
| 445 |
-# endif |
|
| 446 |
-#endif |
|
| 447 |
- |
|
| 448 |
-#if defined(STDC) || defined(Z_HAVE_STDARG_H) |
|
| 449 |
-# ifndef Z_SOLO |
|
| 450 |
-# include <stdarg.h> /* for va_list */ |
|
| 451 |
-# endif |
|
| 452 |
-#endif |
|
| 453 |
- |
|
| 454 |
-#ifdef _WIN32 |
|
| 455 |
-# ifndef Z_SOLO |
|
| 456 |
-# include <stddef.h> /* for wchar_t */ |
|
| 457 |
-# endif |
|
| 458 |
-#endif |
|
| 459 |
- |
|
| 460 |
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and |
|
| 461 |
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even |
|
| 462 |
- * though the former does not conform to the LFS document), but considering |
|
| 463 |
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as |
|
| 464 |
- * equivalently requesting no 64-bit operations |
|
| 465 |
- */ |
|
| 466 |
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 |
|
| 467 |
-# undef _LARGEFILE64_SOURCE |
|
| 468 |
-#endif |
|
| 469 |
- |
|
| 470 |
-#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) |
|
| 471 |
-# define Z_HAVE_UNISTD_H |
|
| 472 |
-#endif |
|
| 473 |
-#ifndef Z_SOLO |
|
| 474 |
-# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) |
|
| 475 |
-# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ |
|
| 476 |
-# ifdef VMS |
|
| 477 |
-# include <unixio.h> /* for off_t */ |
|
| 478 |
-# endif |
|
| 479 |
-# ifndef z_off_t |
|
| 480 |
-# define z_off_t off_t |
|
| 481 |
-# endif |
|
| 482 |
-# endif |
|
| 483 |
-#endif |
|
| 484 |
- |
|
| 485 |
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 |
|
| 486 |
-# define Z_LFS64 |
|
| 487 |
-#endif |
|
| 488 |
- |
|
| 489 |
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) |
|
| 490 |
-# define Z_LARGE64 |
|
| 491 |
-#endif |
|
| 492 |
- |
|
| 493 |
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) |
|
| 494 |
-# define Z_WANT64 |
|
| 495 |
-#endif |
|
| 496 |
- |
|
| 497 |
-#if !defined(SEEK_SET) && !defined(Z_SOLO) |
|
| 498 |
-# define SEEK_SET 0 /* Seek from beginning of file. */ |
|
| 499 |
-# define SEEK_CUR 1 /* Seek from current position. */ |
|
| 500 |
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ |
|
| 501 |
-#endif |
|
| 502 |
- |
|
| 503 |
-#ifndef z_off_t |
|
| 504 |
-# define z_off_t long |
|
| 505 |
-#endif |
|
| 506 |
- |
|
| 507 |
-#if !defined(_WIN32) && defined(Z_LARGE64) |
|
| 508 |
-# define z_off64_t off64_t |
|
| 509 |
-#else |
|
| 510 |
-# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) |
|
| 511 |
-# define z_off64_t __int64 |
|
| 512 |
-# else |
|
| 513 |
-# define z_off64_t z_off_t |
|
| 514 |
-# endif |
|
| 515 |
-#endif |
|
| 516 |
- |
|
| 517 |
-/* MVS linker does not support external names larger than 8 bytes */ |
|
| 518 |
-#if defined(__MVS__) |
|
| 519 |
- #pragma map(deflateInit_,"DEIN") |
|
| 520 |
- #pragma map(deflateInit2_,"DEIN2") |
|
| 521 |
- #pragma map(deflateEnd,"DEEND") |
|
| 522 |
- #pragma map(deflateBound,"DEBND") |
|
| 523 |
- #pragma map(inflateInit_,"ININ") |
|
| 524 |
- #pragma map(inflateInit2_,"ININ2") |
|
| 525 |
- #pragma map(inflateEnd,"INEND") |
|
| 526 |
- #pragma map(inflateSync,"INSY") |
|
| 527 |
- #pragma map(inflateSetDictionary,"INSEDI") |
|
| 528 |
- #pragma map(compressBound,"CMBND") |
|
| 529 |
- #pragma map(inflate_table,"INTABL") |
|
| 530 |
- #pragma map(inflate_fast,"INFA") |
|
| 531 |
- #pragma map(inflate_copyright,"INCOPY") |
|
| 532 |
-#endif |
|
| 533 |
- |
|
| 534 |
-#endif /* ZCONF_H */ |
| 535 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,1912 +0,0 @@ |
| 1 |
-/* zlib.h -- interface of the 'zlib' general purpose compression library |
|
| 2 |
- version 1.2.11, January 15th, 2017 |
|
| 3 |
- |
|
| 4 |
- Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler |
|
| 5 |
- |
|
| 6 |
- This software is provided 'as-is', without any express or implied |
|
| 7 |
- warranty. In no event will the authors be held liable for any damages |
|
| 8 |
- arising from the use of this software. |
|
| 9 |
- |
|
| 10 |
- Permission is granted to anyone to use this software for any purpose, |
|
| 11 |
- including commercial applications, and to alter it and redistribute it |
|
| 12 |
- freely, subject to the following restrictions: |
|
| 13 |
- |
|
| 14 |
- 1. The origin of this software must not be misrepresented; you must not |
|
| 15 |
- claim that you wrote the original software. If you use this software |
|
| 16 |
- in a product, an acknowledgment in the product documentation would be |
|
| 17 |
- appreciated but is not required. |
|
| 18 |
- 2. Altered source versions must be plainly marked as such, and must not be |
|
| 19 |
- misrepresented as being the original software. |
|
| 20 |
- 3. This notice may not be removed or altered from any source distribution. |
|
| 21 |
- |
|
| 22 |
- Jean-loup Gailly Mark Adler |
|
| 23 |
- jloup@gzip.org madler@alumni.caltech.edu |
|
| 24 |
- |
|
| 25 |
- |
|
| 26 |
- The data format used by the zlib library is described by RFCs (Request for |
|
| 27 |
- Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 |
|
| 28 |
- (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). |
|
| 29 |
-*/ |
|
| 30 |
- |
|
| 31 |
-#ifndef ZLIB_H |
|
| 32 |
-#define ZLIB_H |
|
| 33 |
- |
|
| 34 |
-#include "zconf.h" |
|
| 35 |
- |
|
| 36 |
-#ifdef __cplusplus |
|
| 37 |
-extern "C" {
|
|
| 38 |
-#endif |
|
| 39 |
- |
|
| 40 |
-#define ZLIB_VERSION "1.2.11" |
|
| 41 |
-#define ZLIB_VERNUM 0x12b0 |
|
| 42 |
-#define ZLIB_VER_MAJOR 1 |
|
| 43 |
-#define ZLIB_VER_MINOR 2 |
|
| 44 |
-#define ZLIB_VER_REVISION 11 |
|
| 45 |
-#define ZLIB_VER_SUBREVISION 0 |
|
| 46 |
- |
|
| 47 |
-/* |
|
| 48 |
- The 'zlib' compression library provides in-memory compression and |
|
| 49 |
- decompression functions, including integrity checks of the uncompressed data. |
|
| 50 |
- This version of the library supports only one compression method (deflation) |
|
| 51 |
- but other algorithms will be added later and will have the same stream |
|
| 52 |
- interface. |
|
| 53 |
- |
|
| 54 |
- Compression can be done in a single step if the buffers are large enough, |
|
| 55 |
- or can be done by repeated calls of the compression function. In the latter |
|
| 56 |
- case, the application must provide more input and/or consume the output |
|
| 57 |
- (providing more output space) before each call. |
|
| 58 |
- |
|
| 59 |
- The compressed data format used by default by the in-memory functions is |
|
| 60 |
- the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped |
|
| 61 |
- around a deflate stream, which is itself documented in RFC 1951. |
|
| 62 |
- |
|
| 63 |
- The library also supports reading and writing files in gzip (.gz) format |
|
| 64 |
- with an interface similar to that of stdio using the functions that start |
|
| 65 |
- with "gz". The gzip format is different from the zlib format. gzip is a |
|
| 66 |
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. |
|
| 67 |
- |
|
| 68 |
- This library can optionally read and write gzip and raw deflate streams in |
|
| 69 |
- memory as well. |
|
| 70 |
- |
|
| 71 |
- The zlib format was designed to be compact and fast for use in memory |
|
| 72 |
- and on communications channels. The gzip format was designed for single- |
|
| 73 |
- file compression on file systems, has a larger header than zlib to maintain |
|
| 74 |
- directory information, and uses a different, slower check method than zlib. |
|
| 75 |
- |
|
| 76 |
- The library does not install any signal handler. The decoder checks |
|
| 77 |
- the consistency of the compressed data, so the library should never crash |
|
| 78 |
- even in the case of corrupted input. |
|
| 79 |
-*/ |
|
| 80 |
- |
|
| 81 |
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); |
|
| 82 |
-typedef void (*free_func) OF((voidpf opaque, voidpf address)); |
|
| 83 |
- |
|
| 84 |
-struct internal_state; |
|
| 85 |
- |
|
| 86 |
-typedef struct z_stream_s {
|
|
| 87 |
- z_const Bytef *next_in; /* next input byte */ |
|
| 88 |
- uInt avail_in; /* number of bytes available at next_in */ |
|
| 89 |
- uLong total_in; /* total number of input bytes read so far */ |
|
| 90 |
- |
|
| 91 |
- Bytef *next_out; /* next output byte will go here */ |
|
| 92 |
- uInt avail_out; /* remaining free space at next_out */ |
|
| 93 |
- uLong total_out; /* total number of bytes output so far */ |
|
| 94 |
- |
|
| 95 |
- z_const char *msg; /* last error message, NULL if no error */ |
|
| 96 |
- struct internal_state FAR *state; /* not visible by applications */ |
|
| 97 |
- |
|
| 98 |
- alloc_func zalloc; /* used to allocate the internal state */ |
|
| 99 |
- free_func zfree; /* used to free the internal state */ |
|
| 100 |
- voidpf opaque; /* private data object passed to zalloc and zfree */ |
|
| 101 |
- |
|
| 102 |
- int data_type; /* best guess about the data type: binary or text |
|
| 103 |
- for deflate, or the decoding state for inflate */ |
|
| 104 |
- uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ |
|
| 105 |
- uLong reserved; /* reserved for future use */ |
|
| 106 |
-} z_stream; |
|
| 107 |
- |
|
| 108 |
-typedef z_stream FAR *z_streamp; |
|
| 109 |
- |
|
| 110 |
-/* |
|
| 111 |
- gzip header information passed to and from zlib routines. See RFC 1952 |
|
| 112 |
- for more details on the meanings of these fields. |
|
| 113 |
-*/ |
|
| 114 |
-typedef struct gz_header_s {
|
|
| 115 |
- int text; /* true if compressed data believed to be text */ |
|
| 116 |
- uLong time; /* modification time */ |
|
| 117 |
- int xflags; /* extra flags (not used when writing a gzip file) */ |
|
| 118 |
- int os; /* operating system */ |
|
| 119 |
- Bytef *extra; /* pointer to extra field or Z_NULL if none */ |
|
| 120 |
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ |
|
| 121 |
- uInt extra_max; /* space at extra (only when reading header) */ |
|
| 122 |
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ |
|
| 123 |
- uInt name_max; /* space at name (only when reading header) */ |
|
| 124 |
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ |
|
| 125 |
- uInt comm_max; /* space at comment (only when reading header) */ |
|
| 126 |
- int hcrc; /* true if there was or will be a header crc */ |
|
| 127 |
- int done; /* true when done reading gzip header (not used |
|
| 128 |
- when writing a gzip file) */ |
|
| 129 |
-} gz_header; |
|
| 130 |
- |
|
| 131 |
-typedef gz_header FAR *gz_headerp; |
|
| 132 |
- |
|
| 133 |
-/* |
|
| 134 |
- The application must update next_in and avail_in when avail_in has dropped |
|
| 135 |
- to zero. It must update next_out and avail_out when avail_out has dropped |
|
| 136 |
- to zero. The application must initialize zalloc, zfree and opaque before |
|
| 137 |
- calling the init function. All other fields are set by the compression |
|
| 138 |
- library and must not be updated by the application. |
|
| 139 |
- |
|
| 140 |
- The opaque value provided by the application will be passed as the first |
|
| 141 |
- parameter for calls of zalloc and zfree. This can be useful for custom |
|
| 142 |
- memory management. The compression library attaches no meaning to the |
|
| 143 |
- opaque value. |
|
| 144 |
- |
|
| 145 |
- zalloc must return Z_NULL if there is not enough memory for the object. |
|
| 146 |
- If zlib is used in a multi-threaded application, zalloc and zfree must be |
|
| 147 |
- thread safe. In that case, zlib is thread-safe. When zalloc and zfree are |
|
| 148 |
- Z_NULL on entry to the initialization function, they are set to internal |
|
| 149 |
- routines that use the standard library functions malloc() and free(). |
|
| 150 |
- |
|
| 151 |
- On 16-bit systems, the functions zalloc and zfree must be able to allocate |
|
| 152 |
- exactly 65536 bytes, but will not be required to allocate more than this if |
|
| 153 |
- the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers |
|
| 154 |
- returned by zalloc for objects of exactly 65536 bytes *must* have their |
|
| 155 |
- offset normalized to zero. The default allocation function provided by this |
|
| 156 |
- library ensures this (see zutil.c). To reduce memory requirements and avoid |
|
| 157 |
- any allocation of 64K objects, at the expense of compression ratio, compile |
|
| 158 |
- the library with -DMAX_WBITS=14 (see zconf.h). |
|
| 159 |
- |
|
| 160 |
- The fields total_in and total_out can be used for statistics or progress |
|
| 161 |
- reports. After compression, total_in holds the total size of the |
|
| 162 |
- uncompressed data and may be saved for use by the decompressor (particularly |
|
| 163 |
- if the decompressor wants to decompress everything in a single step). |
|
| 164 |
-*/ |
|
| 165 |
- |
|
| 166 |
- /* constants */ |
|
| 167 |
- |
|
| 168 |
-#define Z_NO_FLUSH 0 |
|
| 169 |
-#define Z_PARTIAL_FLUSH 1 |
|
| 170 |
-#define Z_SYNC_FLUSH 2 |
|
| 171 |
-#define Z_FULL_FLUSH 3 |
|
| 172 |
-#define Z_FINISH 4 |
|
| 173 |
-#define Z_BLOCK 5 |
|
| 174 |
-#define Z_TREES 6 |
|
| 175 |
-/* Allowed flush values; see deflate() and inflate() below for details */ |
|
| 176 |
- |
|
| 177 |
-#define Z_OK 0 |
|
| 178 |
-#define Z_STREAM_END 1 |
|
| 179 |
-#define Z_NEED_DICT 2 |
|
| 180 |
-#define Z_ERRNO (-1) |
|
| 181 |
-#define Z_STREAM_ERROR (-2) |
|
| 182 |
-#define Z_DATA_ERROR (-3) |
|
| 183 |
-#define Z_MEM_ERROR (-4) |
|
| 184 |
-#define Z_BUF_ERROR (-5) |
|
| 185 |
-#define Z_VERSION_ERROR (-6) |
|
| 186 |
-/* Return codes for the compression/decompression functions. Negative values |
|
| 187 |
- * are errors, positive values are used for special but normal events. |
|
| 188 |
- */ |
|
| 189 |
- |
|
| 190 |
-#define Z_NO_COMPRESSION 0 |
|
| 191 |
-#define Z_BEST_SPEED 1 |
|
| 192 |
-#define Z_BEST_COMPRESSION 9 |
|
| 193 |
-#define Z_DEFAULT_COMPRESSION (-1) |
|
| 194 |
-/* compression levels */ |
|
| 195 |
- |
|
| 196 |
-#define Z_FILTERED 1 |
|
| 197 |
-#define Z_HUFFMAN_ONLY 2 |
|
| 198 |
-#define Z_RLE 3 |
|
| 199 |
-#define Z_FIXED 4 |
|
| 200 |
-#define Z_DEFAULT_STRATEGY 0 |
|
| 201 |
-/* compression strategy; see deflateInit2() below for details */ |
|
| 202 |
- |
|
| 203 |
-#define Z_BINARY 0 |
|
| 204 |
-#define Z_TEXT 1 |
|
| 205 |
-#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ |
|
| 206 |
-#define Z_UNKNOWN 2 |
|
| 207 |
-/* Possible values of the data_type field for deflate() */ |
|
| 208 |
- |
|
| 209 |
-#define Z_DEFLATED 8 |
|
| 210 |
-/* The deflate compression method (the only one supported in this version) */ |
|
| 211 |
- |
|
| 212 |
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ |
|
| 213 |
- |
|
| 214 |
-#define zlib_version zlibVersion() |
|
| 215 |
-/* for compatibility with versions < 1.0.2 */ |
|
| 216 |
- |
|
| 217 |
- |
|
| 218 |
- /* basic functions */ |
|
| 219 |
- |
|
| 220 |
-ZEXTERN const char * ZEXPORT zlibVersion OF((void)); |
|
| 221 |
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency. |
|
| 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 |
|
| 224 |
- is automatically made by deflateInit and inflateInit. |
|
| 225 |
- */ |
|
| 226 |
- |
|
| 227 |
-/* |
|
| 228 |
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); |
|
| 229 |
- |
|
| 230 |
- Initializes the internal stream state for compression. The fields |
|
| 231 |
- zalloc, zfree and opaque must be initialized before by the caller. If |
|
| 232 |
- zalloc and zfree are set to Z_NULL, deflateInit updates them to use default |
|
| 233 |
- allocation functions. |
|
| 234 |
- |
|
| 235 |
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: |
|
| 236 |
- 1 gives best speed, 9 gives best compression, 0 gives no compression at all |
|
| 237 |
- (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION |
|
| 238 |
- requests a default compromise between speed and compression (currently |
|
| 239 |
- equivalent to level 6). |
|
| 240 |
- |
|
| 241 |
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|
| 242 |
- memory, Z_STREAM_ERROR if level is not a valid compression level, or |
|
| 243 |
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible |
|
| 244 |
- with the version assumed by the caller (ZLIB_VERSION). msg is set to null |
|
| 245 |
- if there is no error message. deflateInit does not perform any compression: |
|
| 246 |
- this will be done by deflate(). |
|
| 247 |
-*/ |
|
| 248 |
- |
|
| 249 |
- |
|
| 250 |
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); |
|
| 251 |
-/* |
|
| 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 |
|
| 254 |
- some output latency (reading input without producing any output) except when |
|
| 255 |
- forced to flush. |
|
| 256 |
- |
|
| 257 |
- The detailed semantics are as follows. deflate performs one or both of the |
|
| 258 |
- following actions: |
|
| 259 |
- |
|
| 260 |
- - Compress more input starting at next_in and update next_in and avail_in |
|
| 261 |
- accordingly. If not all input can be processed (because there is not |
|
| 262 |
- enough room in the output buffer), next_in and avail_in are updated and |
|
| 263 |
- processing will resume at this point for the next call of deflate(). |
|
| 264 |
- |
|
| 265 |
- - Generate more output starting at next_out and update next_out and avail_out |
|
| 266 |
- accordingly. This action is forced if the parameter flush is non zero. |
|
| 267 |
- Forcing flush frequently degrades the compression ratio, so this parameter |
|
| 268 |
- should be set only when necessary. Some output may be provided even if |
|
| 269 |
- flush is zero. |
|
| 270 |
- |
|
| 271 |
- Before the call of deflate(), the application should ensure that at least |
|
| 272 |
- one of the actions is possible, by providing more input and/or consuming more |
|
| 273 |
- output, and updating avail_in or avail_out accordingly; avail_out should |
|
| 274 |
- never be zero before the call. The application can consume the compressed |
|
| 275 |
- output when it wants, for example when the output buffer is full (avail_out |
|
| 276 |
- == 0), or after each call of deflate(). If deflate returns Z_OK and with |
|
| 277 |
- zero avail_out, it must be called again after making room in the output |
|
| 278 |
- buffer because there might be more output pending. See deflatePending(), |
|
| 279 |
- which can be used if desired to determine whether or not there is more ouput |
|
| 280 |
- in that case. |
|
| 281 |
- |
|
| 282 |
- Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to |
|
| 283 |
- decide how much data to accumulate before producing output, in order to |
|
| 284 |
- maximize compression. |
|
| 285 |
- |
|
| 286 |
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is |
|
| 287 |
- flushed to the output buffer and the output is aligned on a byte boundary, so |
|
| 288 |
- that the decompressor can get all input data available so far. (In |
|
| 289 |
- particular avail_in is zero after the call if enough output space has been |
|
| 290 |
- provided before the call.) Flushing may degrade compression for some |
|
| 291 |
- compression algorithms and so it should be used only when necessary. This |
|
| 292 |
- completes the current deflate block and follows it with an empty stored block |
|
| 293 |
- that is three bits plus filler bits to the next byte, followed by four bytes |
|
| 294 |
- (00 00 ff ff). |
|
| 295 |
- |
|
| 296 |
- If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the |
|
| 297 |
- output buffer, but the output is not aligned to a byte boundary. All of the |
|
| 298 |
- input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. |
|
| 299 |
- This completes the current deflate block and follows it with an empty fixed |
|
| 300 |
- codes block that is 10 bits long. This assures that enough bytes are output |
|
| 301 |
- in order for the decompressor to finish the block before the empty fixed |
|
| 302 |
- codes block. |
|
| 303 |
- |
|
| 304 |
- If flush is set to Z_BLOCK, a deflate block is completed and emitted, as |
|
| 305 |
- for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to |
|
| 306 |
- seven bits of the current block are held to be written as the next byte after |
|
| 307 |
- the next deflate block is completed. In this case, the decompressor may not |
|
| 308 |
- be provided enough bits at this point in order to complete decompression of |
|
| 309 |
- the data provided so far to the compressor. It may need to wait for the next |
|
| 310 |
- block to be emitted. This is for advanced applications that need to control |
|
| 311 |
- the emission of deflate blocks. |
|
| 312 |
- |
|
| 313 |
- If flush is set to Z_FULL_FLUSH, all output is flushed as with |
|
| 314 |
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can |
|
| 315 |
- restart from this point if previous compressed data has been damaged or if |
|
| 316 |
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade |
|
| 317 |
- compression. |
|
| 318 |
- |
|
| 319 |
- If deflate returns with avail_out == 0, this function must be called again |
|
| 320 |
- with the same value of the flush parameter and more output space (updated |
|
| 321 |
- avail_out), until the flush is complete (deflate returns with non-zero |
|
| 322 |
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that |
|
| 323 |
- avail_out is greater than six to avoid repeated flush markers due to |
|
| 324 |
- avail_out == 0 on return. |
|
| 325 |
- |
|
| 326 |
- If the parameter flush is set to Z_FINISH, pending input is processed, |
|
| 327 |
- pending output is flushed and deflate returns with Z_STREAM_END if there was |
|
| 328 |
- enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this |
|
| 329 |
- function must be called again with Z_FINISH and more output space (updated |
|
| 330 |
- avail_out) but no more input data, until it returns with Z_STREAM_END or an |
|
| 331 |
- error. After deflate has returned Z_STREAM_END, the only possible operations |
|
| 332 |
- on the stream are deflateReset or deflateEnd. |
|
| 333 |
- |
|
| 334 |
- Z_FINISH can be used in the first deflate call after deflateInit if all the |
|
| 335 |
- compression is to be done in a single step. In order to complete in one |
|
| 336 |
- call, avail_out must be at least the value returned by deflateBound (see |
|
| 337 |
- below). Then deflate is guaranteed to return Z_STREAM_END. If not enough |
|
| 338 |
- output space is provided, deflate will not return Z_STREAM_END, and it must |
|
| 339 |
- be called again as described above. |
|
| 340 |
- |
|
| 341 |
- deflate() sets strm->adler to the Adler-32 checksum of all input read |
|
| 342 |
- so far (that is, total_in bytes). If a gzip stream is being generated, then |
|
| 343 |
- strm->adler will be the CRC-32 checksum of the input read so far. (See |
|
| 344 |
- deflateInit2 below.) |
|
| 345 |
- |
|
| 346 |
- deflate() may update strm->data_type if it can make a good guess about |
|
| 347 |
- the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is |
|
| 348 |
- considered binary. This field is only for information purposes and does not |
|
| 349 |
- affect the compression algorithm in any manner. |
|
| 350 |
- |
|
| 351 |
- deflate() returns Z_OK if some progress has been made (more input |
|
| 352 |
- processed or more output produced), Z_STREAM_END if all input has been |
|
| 353 |
- consumed and all output has been produced (only when flush is set to |
|
| 354 |
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example |
|
| 355 |
- if next_in or next_out was Z_NULL or the state was inadvertently written over |
|
| 356 |
- by the application), or Z_BUF_ERROR if no progress is possible (for example |
|
| 357 |
- avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and |
|
| 358 |
- deflate() can be called again with more input and more output space to |
|
| 359 |
- continue compressing. |
|
| 360 |
-*/ |
|
| 361 |
- |
|
| 362 |
- |
|
| 363 |
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); |
|
| 364 |
-/* |
|
| 365 |
- All dynamically allocated data structures for this stream are freed. |
|
| 366 |
- This function discards any unprocessed input and does not flush any pending |
|
| 367 |
- output. |
|
| 368 |
- |
|
| 369 |
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the |
|
| 370 |
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed |
|
| 371 |
- prematurely (some input or output was discarded). In the error case, msg |
|
| 372 |
- may be set but then points to a static string (which must not be |
|
| 373 |
- deallocated). |
|
| 374 |
-*/ |
|
| 375 |
- |
|
| 376 |
- |
|
| 377 |
-/* |
|
| 378 |
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); |
|
| 379 |
- |
|
| 380 |
- Initializes the internal stream state for decompression. The fields |
|
| 381 |
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by |
|
| 382 |
- the caller. In the current version of inflate, the provided input is not |
|
| 383 |
- read or consumed. The allocation of a sliding window will be deferred to |
|
| 384 |
- the first call of inflate (if the decompression does not complete on the |
|
| 385 |
- first call). If zalloc and zfree are set to Z_NULL, inflateInit updates |
|
| 386 |
- them to use default allocation functions. |
|
| 387 |
- |
|
| 388 |
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|
| 389 |
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the |
|
| 390 |
- version assumed by the caller, or Z_STREAM_ERROR if the parameters are |
|
| 391 |
- invalid, such as a null pointer to the structure. msg is set to null if |
|
| 392 |
- there is no error message. inflateInit does not perform any decompression. |
|
| 393 |
- Actual decompression will be done by inflate(). So next_in, and avail_in, |
|
| 394 |
- next_out, and avail_out are unused and unchanged. The current |
|
| 395 |
- implementation of inflateInit() does not process any header information -- |
|
| 396 |
- that is deferred until inflate() is called. |
|
| 397 |
-*/ |
|
| 398 |
- |
|
| 399 |
- |
|
| 400 |
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); |
|
| 401 |
-/* |
|
| 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 |
|
| 404 |
- some output latency (reading input without producing any output) except when |
|
| 405 |
- forced to flush. |
|
| 406 |
- |
|
| 407 |
- The detailed semantics are as follows. inflate performs one or both of the |
|
| 408 |
- following actions: |
|
| 409 |
- |
|
| 410 |
- - Decompress more input starting at next_in and update next_in and avail_in |
|
| 411 |
- accordingly. If not all input can be processed (because there is not |
|
| 412 |
- enough room in the output buffer), then next_in and avail_in are updated |
|
| 413 |
- accordingly, and processing will resume at this point for the next call of |
|
| 414 |
- inflate(). |
|
| 415 |
- |
|
| 416 |
- - Generate more output starting at next_out and update next_out and avail_out |
|
| 417 |
- accordingly. inflate() provides as much output as possible, until there is |
|
| 418 |
- no more input data or no more space in the output buffer (see below about |
|
| 419 |
- the flush parameter). |
|
| 420 |
- |
|
| 421 |
- Before the call of inflate(), the application should ensure that at least |
|
| 422 |
- one of the actions is possible, by providing more input and/or consuming more |
|
| 423 |
- output, and updating the next_* and avail_* values accordingly. If the |
|
| 424 |
- caller of inflate() does not provide both available input and available |
|
| 425 |
- output space, it is possible that there will be no progress made. The |
|
| 426 |
- application can consume the uncompressed output when it wants, for example |
|
| 427 |
- when the output buffer is full (avail_out == 0), or after each call of |
|
| 428 |
- inflate(). If inflate returns Z_OK and with zero avail_out, it must be |
|
| 429 |
- called again after making room in the output buffer because there might be |
|
| 430 |
- more output pending. |
|
| 431 |
- |
|
| 432 |
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, |
|
| 433 |
- Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much |
|
| 434 |
- output as possible to the output buffer. Z_BLOCK requests that inflate() |
|
| 435 |
- stop if and when it gets to the next deflate block boundary. When decoding |
|
| 436 |
- the zlib or gzip format, this will cause inflate() to return immediately |
|
| 437 |
- after the header and before the first block. When doing a raw inflate, |
|
| 438 |
- inflate() will go ahead and process the first block, and will return when it |
|
| 439 |
- gets to the end of that block, or when it runs out of data. |
|
| 440 |
- |
|
| 441 |
- The Z_BLOCK option assists in appending to or combining deflate streams. |
|
| 442 |
- To assist in this, on return inflate() always sets strm->data_type to the |
|
| 443 |
- number of unused bits in the last byte taken from strm->next_in, plus 64 if |
|
| 444 |
- inflate() is currently decoding the last block in the deflate stream, plus |
|
| 445 |
- 128 if inflate() returned immediately after decoding an end-of-block code or |
|
| 446 |
- decoding the complete header up to just before the first byte of the deflate |
|
| 447 |
- stream. The end-of-block will not be indicated until all of the uncompressed |
|
| 448 |
- data from that block has been written to strm->next_out. The number of |
|
| 449 |
- unused bits may in general be greater than seven, except when bit 7 of |
|
| 450 |
- data_type is set, in which case the number of unused bits will be less than |
|
| 451 |
- eight. data_type is set as noted here every time inflate() returns for all |
|
| 452 |
- flush options, and so can be used to determine the amount of currently |
|
| 453 |
- consumed input in bits. |
|
| 454 |
- |
|
| 455 |
- The Z_TREES option behaves as Z_BLOCK does, but it also returns when the |
|
| 456 |
- end of each deflate block header is reached, before any actual data in that |
|
| 457 |
- block is decoded. This allows the caller to determine the length of the |
|
| 458 |
- deflate block header for later use in random access within a deflate block. |
|
| 459 |
- 256 is added to the value of strm->data_type when inflate() returns |
|
| 460 |
- immediately after reaching the end of the deflate block header. |
|
| 461 |
- |
|
| 462 |
- inflate() should normally be called until it returns Z_STREAM_END or an |
|
| 463 |
- error. However if all decompression is to be performed in a single step (a |
|
| 464 |
- single call of inflate), the parameter flush should be set to Z_FINISH. In |
|
| 465 |
- this case all pending input is processed and all pending output is flushed; |
|
| 466 |
- avail_out must be large enough to hold all of the uncompressed data for the |
|
| 467 |
- operation to complete. (The size of the uncompressed data may have been |
|
| 468 |
- saved by the compressor for this purpose.) The use of Z_FINISH is not |
|
| 469 |
- required to perform an inflation in one step. However it may be used to |
|
| 470 |
- inform inflate that a faster approach can be used for the single inflate() |
|
| 471 |
- call. Z_FINISH also informs inflate to not maintain a sliding window if the |
|
| 472 |
- stream completes, which reduces inflate's memory footprint. If the stream |
|
| 473 |
- does not complete, either because not all of the stream is provided or not |
|
| 474 |
- enough output space is provided, then a sliding window will be allocated and |
|
| 475 |
- inflate() can be called again to continue the operation as if Z_NO_FLUSH had |
|
| 476 |
- been used. |
|
| 477 |
- |
|
| 478 |
- In this implementation, inflate() always flushes as much output as |
|
| 479 |
- possible to the output buffer, and always uses the faster approach on the |
|
| 480 |
- first call. So the effects of the flush parameter in this implementation are |
|
| 481 |
- on the return value of inflate() as noted below, when inflate() returns early |
|
| 482 |
- when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of |
|
| 483 |
- memory for a sliding window when Z_FINISH is used. |
|
| 484 |
- |
|
| 485 |
- If a preset dictionary is needed after this call (see inflateSetDictionary |
|
| 486 |
- below), inflate sets strm->adler to the Adler-32 checksum of the dictionary |
|
| 487 |
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets |
|
| 488 |
- strm->adler to the Adler-32 checksum of all output produced so far (that is, |
|
| 489 |
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described |
|
| 490 |
- below. At the end of the stream, inflate() checks that its computed Adler-32 |
|
| 491 |
- checksum is equal to that saved by the compressor and returns Z_STREAM_END |
|
| 492 |
- only if the checksum is correct. |
|
| 493 |
- |
|
| 494 |
- inflate() can decompress and check either zlib-wrapped or gzip-wrapped |
|
| 495 |
- deflate data. The header type is detected automatically, if requested when |
|
| 496 |
- initializing with inflateInit2(). Any information contained in the gzip |
|
| 497 |
- header is not retained unless inflateGetHeader() is used. When processing |
|
| 498 |
- gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output |
|
| 499 |
- produced so far. The CRC-32 is checked against the gzip trailer, as is the |
|
| 500 |
- uncompressed length, modulo 2^32. |
|
| 501 |
- |
|
| 502 |
- inflate() returns Z_OK if some progress has been made (more input processed |
|
| 503 |
- or more output produced), Z_STREAM_END if the end of the compressed data has |
|
| 504 |
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a |
|
| 505 |
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was |
|
| 506 |
- corrupted (input stream not conforming to the zlib format or incorrect check |
|
| 507 |
- value, in which case strm->msg points to a string with a more specific |
|
| 508 |
- error), Z_STREAM_ERROR if the stream structure was inconsistent (for example |
|
| 509 |
- next_in or next_out was Z_NULL, or the state was inadvertently written over |
|
| 510 |
- by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR |
|
| 511 |
- if no progress was possible or if there was not enough room in the output |
|
| 512 |
- buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and |
|
| 513 |
- inflate() can be called again with more input and more output space to |
|
| 514 |
- continue decompressing. If Z_DATA_ERROR is returned, the application may |
|
| 515 |
- then call inflateSync() to look for a good compression block if a partial |
|
| 516 |
- recovery of the data is to be attempted. |
|
| 517 |
-*/ |
|
| 518 |
- |
|
| 519 |
- |
|
| 520 |
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); |
|
| 521 |
-/* |
|
| 522 |
- All dynamically allocated data structures for this stream are freed. |
|
| 523 |
- This function discards any unprocessed input and does not flush any pending |
|
| 524 |
- output. |
|
| 525 |
- |
|
| 526 |
- inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state |
|
| 527 |
- was inconsistent. |
|
| 528 |
-*/ |
|
| 529 |
- |
|
| 530 |
- |
|
| 531 |
- /* Advanced functions */ |
|
| 532 |
- |
|
| 533 |
-/* |
|
| 534 |
- The following functions are needed only in some special applications. |
|
| 535 |
-*/ |
|
| 536 |
- |
|
| 537 |
-/* |
|
| 538 |
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, |
|
| 539 |
- int level, |
|
| 540 |
- int method, |
|
| 541 |
- int windowBits, |
|
| 542 |
- int memLevel, |
|
| 543 |
- int strategy)); |
|
| 544 |
- |
|
| 545 |
- This is another version of deflateInit with more compression options. The |
|
| 546 |
- fields next_in, zalloc, zfree and opaque must be initialized before by the |
|
| 547 |
- caller. |
|
| 548 |
- |
|
| 549 |
- The method parameter is the compression method. It must be Z_DEFLATED in |
|
| 550 |
- this version of the library. |
|
| 551 |
- |
|
| 552 |
- The windowBits parameter is the base two logarithm of the window size |
|
| 553 |
- (the size of the history buffer). It should be in the range 8..15 for this |
|
| 554 |
- version of the library. Larger values of this parameter result in better |
|
| 555 |
- compression at the expense of memory usage. The default value is 15 if |
|
| 556 |
- deflateInit is used instead. |
|
| 557 |
- |
|
| 558 |
- For the current implementation of deflate(), a windowBits value of 8 (a |
|
| 559 |
- window size of 256 bytes) is not supported. As a result, a request for 8 |
|
| 560 |
- will result in 9 (a 512-byte window). In that case, providing 8 to |
|
| 561 |
- inflateInit2() will result in an error when the zlib header with 9 is |
|
| 562 |
- checked against the initialization of inflate(). The remedy is to not use 8 |
|
| 563 |
- with deflateInit2() with this initialization, or at least in that case use 9 |
|
| 564 |
- with inflateInit2(). |
|
| 565 |
- |
|
| 566 |
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits |
|
| 567 |
- determines the window size. deflate() will then generate raw deflate data |
|
| 568 |
- with no zlib header or trailer, and will not compute a check value. |
|
| 569 |
- |
|
| 570 |
- windowBits can also be greater than 15 for optional gzip encoding. Add |
|
| 571 |
- 16 to windowBits to write a simple gzip header and trailer around the |
|
| 572 |
- compressed data instead of a zlib wrapper. The gzip header will have no |
|
| 573 |
- file name, no extra data, no comment, no modification time (set to zero), no |
|
| 574 |
- header crc, and the operating system will be set to the appropriate value, |
|
| 575 |
- if the operating system was determined at compile time. If a gzip stream is |
|
| 576 |
- being written, strm->adler is a CRC-32 instead of an Adler-32. |
|
| 577 |
- |
|
| 578 |
- For raw deflate or gzip encoding, a request for a 256-byte window is |
|
| 579 |
- rejected as invalid, since only the zlib header provides a means of |
|
| 580 |
- transmitting the window size to the decompressor. |
|
| 581 |
- |
|
| 582 |
- The memLevel parameter specifies how much memory should be allocated |
|
| 583 |
- for the internal compression state. memLevel=1 uses minimum memory but is |
|
| 584 |
- slow and reduces compression ratio; memLevel=9 uses maximum memory for |
|
| 585 |
- optimal speed. The default value is 8. See zconf.h for total memory usage |
|
| 586 |
- as a function of windowBits and memLevel. |
|
| 587 |
- |
|
| 588 |
- The strategy parameter is used to tune the compression algorithm. Use the |
|
| 589 |
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a |
|
| 590 |
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no |
|
| 591 |
- string match), or Z_RLE to limit match distances to one (run-length |
|
| 592 |
- encoding). Filtered data consists mostly of small values with a somewhat |
|
| 593 |
- random distribution. In this case, the compression algorithm is tuned to |
|
| 594 |
- compress them better. The effect of Z_FILTERED is to force more Huffman |
|
| 595 |
- coding and less string matching; it is somewhat intermediate between |
|
| 596 |
- Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as |
|
| 597 |
- fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The |
|
| 598 |
- strategy parameter only affects the compression ratio but not the |
|
| 599 |
- correctness of the compressed output even if it is not set appropriately. |
|
| 600 |
- Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler |
|
| 601 |
- decoder for special applications. |
|
| 602 |
- |
|
| 603 |
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|
| 604 |
- memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid |
|
| 605 |
- method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is |
|
| 606 |
- incompatible with the version assumed by the caller (ZLIB_VERSION). msg is |
|
| 607 |
- set to null if there is no error message. deflateInit2 does not perform any |
|
| 608 |
- compression: this will be done by deflate(). |
|
| 609 |
-*/ |
|
| 610 |
- |
|
| 611 |
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, |
|
| 612 |
- const Bytef *dictionary, |
|
| 613 |
- uInt dictLength)); |
|
| 614 |
-/* |
|
| 615 |
- Initializes the compression dictionary from the given byte sequence |
|
| 616 |
- without producing any compressed output. When using the zlib format, this |
|
| 617 |
- function must be called immediately after deflateInit, deflateInit2 or |
|
| 618 |
- deflateReset, and before any call of deflate. When doing raw deflate, this |
|
| 619 |
- function must be called either before any call of deflate, or immediately |
|
| 620 |
- after the completion of a deflate block, i.e. after all input has been |
|
| 621 |
- consumed and all output has been delivered when using any of the flush |
|
| 622 |
- options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The |
|
| 623 |
- compressor and decompressor must use exactly the same dictionary (see |
|
| 624 |
- inflateSetDictionary). |
|
| 625 |
- |
|
| 626 |
- The dictionary should consist of strings (byte sequences) that are likely |
|
| 627 |
- to be encountered later in the data to be compressed, with the most commonly |
|
| 628 |
- used strings preferably put towards the end of the dictionary. Using a |
|
| 629 |
- dictionary is most useful when the data to be compressed is short and can be |
|
| 630 |
- predicted with good accuracy; the data can then be compressed better than |
|
| 631 |
- with the default empty dictionary. |
|
| 632 |
- |
|
| 633 |
- Depending on the size of the compression data structures selected by |
|
| 634 |
- deflateInit or deflateInit2, a part of the dictionary may in effect be |
|
| 635 |
- discarded, for example if the dictionary is larger than the window size |
|
| 636 |
- provided in deflateInit or deflateInit2. Thus the strings most likely to be |
|
| 637 |
- useful should be put at the end of the dictionary, not at the front. In |
|
| 638 |
- addition, the current implementation of deflate will use at most the window |
|
| 639 |
- size minus 262 bytes of the provided dictionary. |
|
| 640 |
- |
|
| 641 |
- Upon return of this function, strm->adler is set to the Adler-32 value |
|
| 642 |
- of the dictionary; the decompressor may later use this value to determine |
|
| 643 |
- which dictionary has been used by the compressor. (The Adler-32 value |
|
| 644 |
- applies to the whole dictionary even if only a subset of the dictionary is |
|
| 645 |
- actually used by the compressor.) If a raw deflate was requested, then the |
|
| 646 |
- Adler-32 value is not computed and strm->adler is not set. |
|
| 647 |
- |
|
| 648 |
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a |
|
| 649 |
- parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is |
|
| 650 |
- inconsistent (for example if deflate has already been called for this stream |
|
| 651 |
- or if not at a block boundary for raw deflate). deflateSetDictionary does |
|
| 652 |
- not perform any compression: this will be done by deflate(). |
|
| 653 |
-*/ |
|
| 654 |
- |
|
| 655 |
-ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, |
|
| 656 |
- Bytef *dictionary, |
|
| 657 |
- uInt *dictLength)); |
|
| 658 |
-/* |
|
| 659 |
- Returns the sliding dictionary being maintained by deflate. dictLength is |
|
| 660 |
- set to the number of bytes in the dictionary, and that many bytes are copied |
|
| 661 |
- to dictionary. dictionary must have enough space, where 32768 bytes is |
|
| 662 |
- always enough. If deflateGetDictionary() is called with dictionary equal to |
|
| 663 |
- Z_NULL, then only the dictionary length is returned, and nothing is copied. |
|
| 664 |
- Similary, if dictLength is Z_NULL, then it is not set. |
|
| 665 |
- |
|
| 666 |
- deflateGetDictionary() may return a length less than the window size, even |
|
| 667 |
- when more than the window size in input has been provided. It may return up |
|
| 668 |
- to 258 bytes less in that case, due to how zlib's implementation of deflate |
|
| 669 |
- manages the sliding window and lookahead for matches, where matches can be |
|
| 670 |
- up to 258 bytes long. If the application needs the last window-size bytes of |
|
| 671 |
- input, then that would need to be saved by the application outside of zlib. |
|
| 672 |
- |
|
| 673 |
- deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
|
| 674 |
- stream state is inconsistent. |
|
| 675 |
-*/ |
|
| 676 |
- |
|
| 677 |
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, |
|
| 678 |
- z_streamp source)); |
|
| 679 |
-/* |
|
| 680 |
- Sets the destination stream as a complete copy of the source stream. |
|
| 681 |
- |
|
| 682 |
- This function can be useful when several compression strategies will be |
|
| 683 |
- tried, for example when there are several ways of pre-processing the input |
|
| 684 |
- data with a filter. The streams that will be discarded should then be freed |
|
| 685 |
- by calling deflateEnd. Note that deflateCopy duplicates the internal |
|
| 686 |
- compression state which can be quite large, so this strategy is slow and can |
|
| 687 |
- consume lots of memory. |
|
| 688 |
- |
|
| 689 |
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not |
|
| 690 |
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
|
| 691 |
- (such as zalloc being Z_NULL). msg is left unchanged in both source and |
|
| 692 |
- destination. |
|
| 693 |
-*/ |
|
| 694 |
- |
|
| 695 |
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); |
|
| 696 |
-/* |
|
| 697 |
- This function is equivalent to deflateEnd followed by deflateInit, but |
|
| 698 |
- does not free and reallocate the internal compression state. The stream |
|
| 699 |
- will leave the compression level and any other attributes that may have been |
|
| 700 |
- set unchanged. |
|
| 701 |
- |
|
| 702 |
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 703 |
- stream state was inconsistent (such as zalloc or state being Z_NULL). |
|
| 704 |
-*/ |
|
| 705 |
- |
|
| 706 |
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, |
|
| 707 |
- int level, |
|
| 708 |
- int strategy)); |
|
| 709 |
-/* |
|
| 710 |
- Dynamically update the compression level and compression strategy. The |
|
| 711 |
- interpretation of level and strategy is as in deflateInit2(). This can be |
|
| 712 |
- used to switch between compression and straight copy of the input data, or |
|
| 713 |
- to switch to a different kind of input data requiring a different strategy. |
|
| 714 |
- If the compression approach (which is a function of the level) or the |
|
| 715 |
- strategy is changed, and if any input has been consumed in a previous |
|
| 716 |
- deflate() call, then the input available so far is compressed with the old |
|
| 717 |
- level and strategy using deflate(strm, Z_BLOCK). There are three approaches |
|
| 718 |
- for the compression levels 0, 1..3, and 4..9 respectively. The new level |
|
| 719 |
- and strategy will take effect at the next call of deflate(). |
|
| 720 |
- |
|
| 721 |
- If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does |
|
| 722 |
- not have enough output space to complete, then the parameter change will not |
|
| 723 |
- take effect. In this case, deflateParams() can be called again with the |
|
| 724 |
- same parameters and more output space to try again. |
|
| 725 |
- |
|
| 726 |
- In order to assure a change in the parameters on the first try, the |
|
| 727 |
- deflate stream should be flushed using deflate() with Z_BLOCK or other flush |
|
| 728 |
- request until strm.avail_out is not zero, before calling deflateParams(). |
|
| 729 |
- Then no more input data should be provided before the deflateParams() call. |
|
| 730 |
- If this is done, the old level and strategy will be applied to the data |
|
| 731 |
- compressed before deflateParams(), and the new level and strategy will be |
|
| 732 |
- applied to the the data compressed after deflateParams(). |
|
| 733 |
- |
|
| 734 |
- deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream |
|
| 735 |
- state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if |
|
| 736 |
- there was not enough output space to complete the compression of the |
|
| 737 |
- available input data before a change in the strategy or approach. Note that |
|
| 738 |
- in the case of a Z_BUF_ERROR, the parameters are not changed. A return |
|
| 739 |
- value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be |
|
| 740 |
- retried with more output space. |
|
| 741 |
-*/ |
|
| 742 |
- |
|
| 743 |
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, |
|
| 744 |
- int good_length, |
|
| 745 |
- int max_lazy, |
|
| 746 |
- int nice_length, |
|
| 747 |
- int max_chain)); |
|
| 748 |
-/* |
|
| 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 |
|
| 751 |
- searching for the best matching string, and even then only by the most |
|
| 752 |
- fanatic optimizer trying to squeeze out the last compressed bit for their |
|
| 753 |
- specific input data. Read the deflate.c source code for the meaning of the |
|
| 754 |
- max_lazy, good_length, nice_length, and max_chain parameters. |
|
| 755 |
- |
|
| 756 |
- deflateTune() can be called after deflateInit() or deflateInit2(), and |
|
| 757 |
- returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
|
| 758 |
- */ |
|
| 759 |
- |
|
| 760 |
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, |
|
| 761 |
- uLong sourceLen)); |
|
| 762 |
-/* |
|
| 763 |
- deflateBound() returns an upper bound on the compressed size after |
|
| 764 |
- deflation of sourceLen bytes. It must be called after deflateInit() or |
|
| 765 |
- deflateInit2(), and after deflateSetHeader(), if used. This would be used |
|
| 766 |
- to allocate an output buffer for deflation in a single pass, and so would be |
|
| 767 |
- called before deflate(). If that first deflate() call is provided the |
|
| 768 |
- sourceLen input bytes, an output buffer allocated to the size returned by |
|
| 769 |
- deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed |
|
| 770 |
- to return Z_STREAM_END. Note that it is possible for the compressed size to |
|
| 771 |
- be larger than the value returned by deflateBound() if flush options other |
|
| 772 |
- than Z_FINISH or Z_NO_FLUSH are used. |
|
| 773 |
-*/ |
|
| 774 |
- |
|
| 775 |
-ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, |
|
| 776 |
- unsigned *pending, |
|
| 777 |
- int *bits)); |
|
| 778 |
-/* |
|
| 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 |
|
| 781 |
- provided would be due to the available output space having being consumed. |
|
| 782 |
- The number of bits of output not provided are between 0 and 7, where they |
|
| 783 |
- await more bits to join them in order to fill out a full byte. If pending |
|
| 784 |
- or bits are Z_NULL, then those values are not set. |
|
| 785 |
- |
|
| 786 |
- deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 787 |
- stream state was inconsistent. |
|
| 788 |
- */ |
|
| 789 |
- |
|
| 790 |
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, |
|
| 791 |
- int bits, |
|
| 792 |
- int value)); |
|
| 793 |
-/* |
|
| 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 |
|
| 796 |
- leftover from a previous deflate stream when appending to it. As such, this |
|
| 797 |
- function can only be used for raw deflate, and must be used before the first |
|
| 798 |
- deflate() call after a deflateInit2() or deflateReset(). bits must be less |
|
| 799 |
- than or equal to 16, and that many of the least significant bits of value |
|
| 800 |
- will be inserted in the output. |
|
| 801 |
- |
|
| 802 |
- deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough |
|
| 803 |
- room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the |
|
| 804 |
- source stream state was inconsistent. |
|
| 805 |
-*/ |
|
| 806 |
- |
|
| 807 |
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, |
|
| 808 |
- gz_headerp head)); |
|
| 809 |
-/* |
|
| 810 |
- deflateSetHeader() provides gzip header information for when a gzip |
|
| 811 |
- stream is requested by deflateInit2(). deflateSetHeader() may be called |
|
| 812 |
- after deflateInit2() or deflateReset() and before the first call of |
|
| 813 |
- deflate(). The text, time, os, extra field, name, and comment information |
|
| 814 |
- in the provided gz_header structure are written to the gzip header (xflag is |
|
| 815 |
- ignored -- the extra flags are set according to the compression level). The |
|
| 816 |
- caller must assure that, if not Z_NULL, name and comment are terminated with |
|
| 817 |
- a zero byte, and that if extra is not Z_NULL, that extra_len bytes are |
|
| 818 |
- available there. If hcrc is true, a gzip header crc is included. Note that |
|
| 819 |
- the current versions of the command-line version of gzip (up through version |
|
| 820 |
- 1.3.x) do not support header crc's, and will report that it is a "multi-part |
|
| 821 |
- gzip file" and give up. |
|
| 822 |
- |
|
| 823 |
- If deflateSetHeader is not used, the default gzip header has text false, |
|
| 824 |
- the time set to zero, and os set to 255, with no extra, name, or comment |
|
| 825 |
- fields. The gzip header is returned to the default state by deflateReset(). |
|
| 826 |
- |
|
| 827 |
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 828 |
- stream state was inconsistent. |
|
| 829 |
-*/ |
|
| 830 |
- |
|
| 831 |
-/* |
|
| 832 |
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, |
|
| 833 |
- int windowBits)); |
|
| 834 |
- |
|
| 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 |
|
| 837 |
- before by the caller. |
|
| 838 |
- |
|
| 839 |
- The windowBits parameter is the base two logarithm of the maximum window |
|
| 840 |
- size (the size of the history buffer). It should be in the range 8..15 for |
|
| 841 |
- this version of the library. The default value is 15 if inflateInit is used |
|
| 842 |
- instead. windowBits must be greater than or equal to the windowBits value |
|
| 843 |
- provided to deflateInit2() while compressing, or it must be equal to 15 if |
|
| 844 |
- deflateInit2() was not used. If a compressed stream with a larger window |
|
| 845 |
- size is given as input, inflate() will return with the error code |
|
| 846 |
- Z_DATA_ERROR instead of trying to allocate a larger window. |
|
| 847 |
- |
|
| 848 |
- windowBits can also be zero to request that inflate use the window size in |
|
| 849 |
- the zlib header of the compressed stream. |
|
| 850 |
- |
|
| 851 |
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits |
|
| 852 |
- determines the window size. inflate() will then process raw deflate data, |
|
| 853 |
- not looking for a zlib or gzip header, not generating a check value, and not |
|
| 854 |
- looking for any check values for comparison at the end of the stream. This |
|
| 855 |
- is for use with other formats that use the deflate compressed data format |
|
| 856 |
- such as zip. Those formats provide their own check values. If a custom |
|
| 857 |
- format is developed using the raw deflate format for compressed data, it is |
|
| 858 |
- recommended that a check value such as an Adler-32 or a CRC-32 be applied to |
|
| 859 |
- the uncompressed data as is done in the zlib, gzip, and zip formats. For |
|
| 860 |
- most applications, the zlib format should be used as is. Note that comments |
|
| 861 |
- above on the use in deflateInit2() applies to the magnitude of windowBits. |
|
| 862 |
- |
|
| 863 |
- windowBits can also be greater than 15 for optional gzip decoding. Add |
|
| 864 |
- 32 to windowBits to enable zlib and gzip decoding with automatic header |
|
| 865 |
- detection, or add 16 to decode only the gzip format (the zlib format will |
|
| 866 |
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a |
|
| 867 |
- CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see |
|
| 868 |
- below), inflate() will not automatically decode concatenated gzip streams. |
|
| 869 |
- inflate() will return Z_STREAM_END at the end of the gzip stream. The state |
|
| 870 |
- would need to be reset to continue decoding a subsequent gzip stream. |
|
| 871 |
- |
|
| 872 |
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|
| 873 |
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the |
|
| 874 |
- version assumed by the caller, or Z_STREAM_ERROR if the parameters are |
|
| 875 |
- invalid, such as a null pointer to the structure. msg is set to null if |
|
| 876 |
- there is no error message. inflateInit2 does not perform any decompression |
|
| 877 |
- apart from possibly reading the zlib header if present: actual decompression |
|
| 878 |
- will be done by inflate(). (So next_in and avail_in may be modified, but |
|
| 879 |
- next_out and avail_out are unused and unchanged.) The current implementation |
|
| 880 |
- of inflateInit2() does not process any header information -- that is |
|
| 881 |
- deferred until inflate() is called. |
|
| 882 |
-*/ |
|
| 883 |
- |
|
| 884 |
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, |
|
| 885 |
- const Bytef *dictionary, |
|
| 886 |
- uInt dictLength)); |
|
| 887 |
-/* |
|
| 888 |
- Initializes the decompression dictionary from the given uncompressed byte |
|
| 889 |
- sequence. This function must be called immediately after a call of inflate, |
|
| 890 |
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
|
| 891 |
- can be determined from the Adler-32 value returned by that call of inflate. |
|
| 892 |
- The compressor and decompressor must use exactly the same dictionary (see |
|
| 893 |
- deflateSetDictionary). For raw inflate, this function can be called at any |
|
| 894 |
- time to set the dictionary. If the provided dictionary is smaller than the |
|
| 895 |
- window and there is already data in the window, then the provided dictionary |
|
| 896 |
- will amend what's there. The application must insure that the dictionary |
|
| 897 |
- that was used for compression is provided. |
|
| 898 |
- |
|
| 899 |
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a |
|
| 900 |
- parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is |
|
| 901 |
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the |
|
| 902 |
- expected one (incorrect Adler-32 value). inflateSetDictionary does not |
|
| 903 |
- perform any decompression: this will be done by subsequent calls of |
|
| 904 |
- inflate(). |
|
| 905 |
-*/ |
|
| 906 |
- |
|
| 907 |
-ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, |
|
| 908 |
- Bytef *dictionary, |
|
| 909 |
- uInt *dictLength)); |
|
| 910 |
-/* |
|
| 911 |
- Returns the sliding dictionary being maintained by inflate. dictLength is |
|
| 912 |
- set to the number of bytes in the dictionary, and that many bytes are copied |
|
| 913 |
- to dictionary. dictionary must have enough space, where 32768 bytes is |
|
| 914 |
- always enough. If inflateGetDictionary() is called with dictionary equal to |
|
| 915 |
- Z_NULL, then only the dictionary length is returned, and nothing is copied. |
|
| 916 |
- Similary, if dictLength is Z_NULL, then it is not set. |
|
| 917 |
- |
|
| 918 |
- inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
|
| 919 |
- stream state is inconsistent. |
|
| 920 |
-*/ |
|
| 921 |
- |
|
| 922 |
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); |
|
| 923 |
-/* |
|
| 924 |
- Skips invalid compressed data until a possible full flush point (see above |
|
| 925 |
- for the description of deflate with Z_FULL_FLUSH) can be found, or until all |
|
| 926 |
- available input is skipped. No output is provided. |
|
| 927 |
- |
|
| 928 |
- inflateSync searches for a 00 00 FF FF pattern in the compressed data. |
|
| 929 |
- All full flush points have this pattern, but not all occurrences of this |
|
| 930 |
- pattern are full flush points. |
|
| 931 |
- |
|
| 932 |
- inflateSync returns Z_OK if a possible full flush point has been found, |
|
| 933 |
- Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point |
|
| 934 |
- has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. |
|
| 935 |
- In the success case, the application may save the current current value of |
|
| 936 |
- total_in which indicates where valid compressed data was found. In the |
|
| 937 |
- error case, the application may repeatedly call inflateSync, providing more |
|
| 938 |
- input each time, until success or end of the input data. |
|
| 939 |
-*/ |
|
| 940 |
- |
|
| 941 |
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, |
|
| 942 |
- z_streamp source)); |
|
| 943 |
-/* |
|
| 944 |
- Sets the destination stream as a complete copy of the source stream. |
|
| 945 |
- |
|
| 946 |
- This function can be useful when randomly accessing a large stream. The |
|
| 947 |
- first pass through the stream can periodically record the inflate state, |
|
| 948 |
- allowing restarting inflate at those points when randomly accessing the |
|
| 949 |
- stream. |
|
| 950 |
- |
|
| 951 |
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not |
|
| 952 |
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
|
| 953 |
- (such as zalloc being Z_NULL). msg is left unchanged in both source and |
|
| 954 |
- destination. |
|
| 955 |
-*/ |
|
| 956 |
- |
|
| 957 |
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); |
|
| 958 |
-/* |
|
| 959 |
- This function is equivalent to inflateEnd followed by inflateInit, |
|
| 960 |
- but does not free and reallocate the internal decompression state. The |
|
| 961 |
- stream will keep attributes that may have been set by inflateInit2. |
|
| 962 |
- |
|
| 963 |
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 964 |
- stream state was inconsistent (such as zalloc or state being Z_NULL). |
|
| 965 |
-*/ |
|
| 966 |
- |
|
| 967 |
-ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, |
|
| 968 |
- int windowBits)); |
|
| 969 |
-/* |
|
| 970 |
- This function is the same as inflateReset, but it also permits changing |
|
| 971 |
- the wrap and window size requests. The windowBits parameter is interpreted |
|
| 972 |
- the same as it is for inflateInit2. If the window size is changed, then the |
|
| 973 |
- memory allocated for the window is freed, and the window will be reallocated |
|
| 974 |
- by inflate() if needed. |
|
| 975 |
- |
|
| 976 |
- inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 977 |
- stream state was inconsistent (such as zalloc or state being Z_NULL), or if |
|
| 978 |
- the windowBits parameter is invalid. |
|
| 979 |
-*/ |
|
| 980 |
- |
|
| 981 |
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, |
|
| 982 |
- int bits, |
|
| 983 |
- int value)); |
|
| 984 |
-/* |
|
| 985 |
- This function inserts bits in the inflate input stream. The intent is |
|
| 986 |
- that this function is used to start inflating at a bit position in the |
|
| 987 |
- middle of a byte. The provided bits will be used before any bytes are used |
|
| 988 |
- from next_in. This function should only be used with raw inflate, and |
|
| 989 |
- should be used before the first inflate() call after inflateInit2() or |
|
| 990 |
- inflateReset(). bits must be less than or equal to 16, and that many of the |
|
| 991 |
- least significant bits of value will be inserted in the input. |
|
| 992 |
- |
|
| 993 |
- If bits is negative, then the input stream bit buffer is emptied. Then |
|
| 994 |
- inflatePrime() can be called again to put bits in the buffer. This is used |
|
| 995 |
- to clear out bits leftover after feeding inflate a block description prior |
|
| 996 |
- to feeding inflate codes. |
|
| 997 |
- |
|
| 998 |
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 999 |
- stream state was inconsistent. |
|
| 1000 |
-*/ |
|
| 1001 |
- |
|
| 1002 |
-ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); |
|
| 1003 |
-/* |
|
| 1004 |
- This function returns two values, one in the lower 16 bits of the return |
|
| 1005 |
- value, and the other in the remaining upper bits, obtained by shifting the |
|
| 1006 |
- return value down 16 bits. If the upper value is -1 and the lower value is |
|
| 1007 |
- zero, then inflate() is currently decoding information outside of a block. |
|
| 1008 |
- If the upper value is -1 and the lower value is non-zero, then inflate is in |
|
| 1009 |
- the middle of a stored block, with the lower value equaling the number of |
|
| 1010 |
- bytes from the input remaining to copy. If the upper value is not -1, then |
|
| 1011 |
- it is the number of bits back from the current bit position in the input of |
|
| 1012 |
- the code (literal or length/distance pair) currently being processed. In |
|
| 1013 |
- that case the lower value is the number of bytes already emitted for that |
|
| 1014 |
- code. |
|
| 1015 |
- |
|
| 1016 |
- A code is being processed if inflate is waiting for more input to complete |
|
| 1017 |
- decoding of the code, or if it has completed decoding but is waiting for |
|
| 1018 |
- more output space to write the literal or match data. |
|
| 1019 |
- |
|
| 1020 |
- inflateMark() is used to mark locations in the input data for random |
|
| 1021 |
- access, which may be at bit positions, and to note those cases where the |
|
| 1022 |
- output of a code may span boundaries of random access blocks. The current |
|
| 1023 |
- location in the input stream can be determined from avail_in and data_type |
|
| 1024 |
- as noted in the description for the Z_BLOCK flush parameter for inflate. |
|
| 1025 |
- |
|
| 1026 |
- inflateMark returns the value noted above, or -65536 if the provided |
|
| 1027 |
- source stream state was inconsistent. |
|
| 1028 |
-*/ |
|
| 1029 |
- |
|
| 1030 |
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, |
|
| 1031 |
- gz_headerp head)); |
|
| 1032 |
-/* |
|
| 1033 |
- inflateGetHeader() requests that gzip header information be stored in the |
|
| 1034 |
- provided gz_header structure. inflateGetHeader() may be called after |
|
| 1035 |
- inflateInit2() or inflateReset(), and before the first call of inflate(). |
|
| 1036 |
- As inflate() processes the gzip stream, head->done is zero until the header |
|
| 1037 |
- is completed, at which time head->done is set to one. If a zlib stream is |
|
| 1038 |
- being decoded, then head->done is set to -1 to indicate that there will be |
|
| 1039 |
- no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be |
|
| 1040 |
- used to force inflate() to return immediately after header processing is |
|
| 1041 |
- complete and before any actual data is decompressed. |
|
| 1042 |
- |
|
| 1043 |
- The text, time, xflags, and os fields are filled in with the gzip header |
|
| 1044 |
- contents. hcrc is set to true if there is a header CRC. (The header CRC |
|
| 1045 |
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max |
|
| 1046 |
- contains the maximum number of bytes to write to extra. Once done is true, |
|
| 1047 |
- extra_len contains the actual extra field length, and extra contains the |
|
| 1048 |
- extra field, or that field truncated if extra_max is less than extra_len. |
|
| 1049 |
- If name is not Z_NULL, then up to name_max characters are written there, |
|
| 1050 |
- terminated with a zero unless the length is greater than name_max. If |
|
| 1051 |
- comment is not Z_NULL, then up to comm_max characters are written there, |
|
| 1052 |
- terminated with a zero unless the length is greater than comm_max. When any |
|
| 1053 |
- of extra, name, or comment are not Z_NULL and the respective field is not |
|
| 1054 |
- present in the header, then that field is set to Z_NULL to signal its |
|
| 1055 |
- absence. This allows the use of deflateSetHeader() with the returned |
|
| 1056 |
- structure to duplicate the header. However if those fields are set to |
|
| 1057 |
- allocated memory, then the application will need to save those pointers |
|
| 1058 |
- elsewhere so that they can be eventually freed. |
|
| 1059 |
- |
|
| 1060 |
- If inflateGetHeader is not used, then the header information is simply |
|
| 1061 |
- discarded. The header is always checked for validity, including the header |
|
| 1062 |
- CRC if present. inflateReset() will reset the process to discard the header |
|
| 1063 |
- information. The application would need to call inflateGetHeader() again to |
|
| 1064 |
- retrieve the header from the next gzip stream. |
|
| 1065 |
- |
|
| 1066 |
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
|
| 1067 |
- stream state was inconsistent. |
|
| 1068 |
-*/ |
|
| 1069 |
- |
|
| 1070 |
-/* |
|
| 1071 |
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, |
|
| 1072 |
- unsigned char FAR *window)); |
|
| 1073 |
- |
|
| 1074 |
- Initialize the internal stream state for decompression using inflateBack() |
|
| 1075 |
- calls. The fields zalloc, zfree and opaque in strm must be initialized |
|
| 1076 |
- before the call. If zalloc and zfree are Z_NULL, then the default library- |
|
| 1077 |
- derived memory allocation routines are used. windowBits is the base two |
|
| 1078 |
- logarithm of the window size, in the range 8..15. window is a caller |
|
| 1079 |
- supplied buffer of that size. Except for special applications where it is |
|
| 1080 |
- assured that deflate was used with small window sizes, windowBits must be 15 |
|
| 1081 |
- and a 32K byte window must be supplied to be able to decompress general |
|
| 1082 |
- deflate streams. |
|
| 1083 |
- |
|
| 1084 |
- See inflateBack() for the usage of these routines. |
|
| 1085 |
- |
|
| 1086 |
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of |
|
| 1087 |
- the parameters are invalid, Z_MEM_ERROR if the internal state could not be |
|
| 1088 |
- allocated, or Z_VERSION_ERROR if the version of the library does not match |
|
| 1089 |
- the version of the header file. |
|
| 1090 |
-*/ |
|
| 1091 |
- |
|
| 1092 |
-typedef unsigned (*in_func) OF((void FAR *, |
|
| 1093 |
- z_const unsigned char FAR * FAR *)); |
|
| 1094 |
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); |
|
| 1095 |
- |
|
| 1096 |
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, |
|
| 1097 |
- in_func in, void FAR *in_desc, |
|
| 1098 |
- out_func out, void FAR *out_desc)); |
|
| 1099 |
-/* |
|
| 1100 |
- inflateBack() does a raw inflate with a single call using a call-back |
|
| 1101 |
- interface for input and output. This is potentially more efficient than |
|
| 1102 |
- inflate() for file i/o applications, in that it avoids copying between the |
|
| 1103 |
- output and the sliding window by simply making the window itself the output |
|
| 1104 |
- buffer. inflate() can be faster on modern CPUs when used with large |
|
| 1105 |
- buffers. inflateBack() trusts the application to not change the output |
|
| 1106 |
- buffer passed by the output function, at least until inflateBack() returns. |
|
| 1107 |
- |
|
| 1108 |
- inflateBackInit() must be called first to allocate the internal state |
|
| 1109 |
- and to initialize the state with the user-provided window buffer. |
|
| 1110 |
- inflateBack() may then be used multiple times to inflate a complete, raw |
|
| 1111 |
- deflate stream with each call. inflateBackEnd() is then called to free the |
|
| 1112 |
- allocated state. |
|
| 1113 |
- |
|
| 1114 |
- A raw deflate stream is one with no zlib or gzip header or trailer. |
|
| 1115 |
- This routine would normally be used in a utility that reads zip or gzip |
|
| 1116 |
- files and writes out uncompressed files. The utility would decode the |
|
| 1117 |
- header and process the trailer on its own, hence this routine expects only |
|
| 1118 |
- the raw deflate stream to decompress. This is different from the default |
|
| 1119 |
- behavior of inflate(), which expects a zlib header and trailer around the |
|
| 1120 |
- deflate stream. |
|
| 1121 |
- |
|
| 1122 |
- inflateBack() uses two subroutines supplied by the caller that are then |
|
| 1123 |
- called by inflateBack() for input and output. inflateBack() calls those |
|
| 1124 |
- routines until it reads a complete deflate stream and writes out all of the |
|
| 1125 |
- uncompressed data, or until it encounters an error. The function's |
|
| 1126 |
- parameters and return types are defined above in the in_func and out_func |
|
| 1127 |
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the |
|
| 1128 |
- number of bytes of provided input, and a pointer to that input in buf. If |
|
| 1129 |
- there is no input available, in() must return zero -- buf is ignored in that |
|
| 1130 |
- case -- and inflateBack() will return a buffer error. inflateBack() will |
|
| 1131 |
- call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. |
|
| 1132 |
- out() should return zero on success, or non-zero on failure. If out() |
|
| 1133 |
- returns non-zero, inflateBack() will return with an error. Neither in() nor |
|
| 1134 |
- out() are permitted to change the contents of the window provided to |
|
| 1135 |
- inflateBackInit(), which is also the buffer that out() uses to write from. |
|
| 1136 |
- The length written by out() will be at most the window size. Any non-zero |
|
| 1137 |
- amount of input may be provided by in(). |
|
| 1138 |
- |
|
| 1139 |
- For convenience, inflateBack() can be provided input on the first call by |
|
| 1140 |
- setting strm->next_in and strm->avail_in. If that input is exhausted, then |
|
| 1141 |
- in() will be called. Therefore strm->next_in must be initialized before |
|
| 1142 |
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called |
|
| 1143 |
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in |
|
| 1144 |
- must also be initialized, and then if strm->avail_in is not zero, input will |
|
| 1145 |
- initially be taken from strm->next_in[0 .. strm->avail_in - 1]. |
|
| 1146 |
- |
|
| 1147 |
- The in_desc and out_desc parameters of inflateBack() is passed as the |
|
| 1148 |
- first parameter of in() and out() respectively when they are called. These |
|
| 1149 |
- descriptors can be optionally used to pass any information that the caller- |
|
| 1150 |
- supplied in() and out() functions need to do their job. |
|
| 1151 |
- |
|
| 1152 |
- On return, inflateBack() will set strm->next_in and strm->avail_in to |
|
| 1153 |
- pass back any unused input that was provided by the last in() call. The |
|
| 1154 |
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR |
|
| 1155 |
- if in() or out() returned an error, Z_DATA_ERROR if there was a format error |
|
| 1156 |
- in the deflate stream (in which case strm->msg is set to indicate the nature |
|
| 1157 |
- of the error), or Z_STREAM_ERROR if the stream was not properly initialized. |
|
| 1158 |
- In the case of Z_BUF_ERROR, an input or output error can be distinguished |
|
| 1159 |
- using strm->next_in which will be Z_NULL only if in() returned an error. If |
|
| 1160 |
- strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning |
|
| 1161 |
- non-zero. (in() will always be called before out(), so strm->next_in is |
|
| 1162 |
- assured to be defined if out() returns non-zero.) Note that inflateBack() |
|
| 1163 |
- cannot return Z_OK. |
|
| 1164 |
-*/ |
|
| 1165 |
- |
|
| 1166 |
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); |
|
| 1167 |
-/* |
|
| 1168 |
- All memory allocated by inflateBackInit() is freed. |
|
| 1169 |
- |
|
| 1170 |
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream |
|
| 1171 |
- state was inconsistent. |
|
| 1172 |
-*/ |
|
| 1173 |
- |
|
| 1174 |
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); |
|
| 1175 |
-/* Return flags indicating compile-time options. |
|
| 1176 |
- |
|
| 1177 |
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: |
|
| 1178 |
- 1.0: size of uInt |
|
| 1179 |
- 3.2: size of uLong |
|
| 1180 |
- 5.4: size of voidpf (pointer) |
|
| 1181 |
- 7.6: size of z_off_t |
|
| 1182 |
- |
|
| 1183 |
- Compiler, assembler, and debug options: |
|
| 1184 |
- 8: ZLIB_DEBUG |
|
| 1185 |
- 9: ASMV or ASMINF -- use ASM code |
|
| 1186 |
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention |
|
| 1187 |
- 11: 0 (reserved) |
|
| 1188 |
- |
|
| 1189 |
- One-time table building (smaller code, but not thread-safe if true): |
|
| 1190 |
- 12: BUILDFIXED -- build static block decoding tables when needed |
|
| 1191 |
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed |
|
| 1192 |
- 14,15: 0 (reserved) |
|
| 1193 |
- |
|
| 1194 |
- Library content (indicates missing functionality): |
|
| 1195 |
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking |
|
| 1196 |
- deflate code when not needed) |
|
| 1197 |
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect |
|
| 1198 |
- and decode gzip streams (to avoid linking crc code) |
|
| 1199 |
- 18-19: 0 (reserved) |
|
| 1200 |
- |
|
| 1201 |
- Operation variations (changes in library functionality): |
|
| 1202 |
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate |
|
| 1203 |
- 21: FASTEST -- deflate algorithm with only one, lowest compression level |
|
| 1204 |
- 22,23: 0 (reserved) |
|
| 1205 |
- |
|
| 1206 |
- The sprintf variant used by gzprintf (zero is best): |
|
| 1207 |
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format |
|
| 1208 |
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! |
|
| 1209 |
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned |
|
| 1210 |
- |
|
| 1211 |
- Remainder: |
|
| 1212 |
- 27-31: 0 (reserved) |
|
| 1213 |
- */ |
|
| 1214 |
- |
|
| 1215 |
-#ifndef Z_SOLO |
|
| 1216 |
- |
|
| 1217 |
- /* utility functions */ |
|
| 1218 |
- |
|
| 1219 |
-/* |
|
| 1220 |
- The following utility functions are implemented on top of the basic |
|
| 1221 |
- stream-oriented functions. To simplify the interface, some default options |
|
| 1222 |
- are assumed (compression level and memory usage, standard memory allocation |
|
| 1223 |
- functions). The source code of these utility functions can be modified if |
|
| 1224 |
- you need special options. |
|
| 1225 |
-*/ |
|
| 1226 |
- |
|
| 1227 |
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, |
|
| 1228 |
- const Bytef *source, uLong sourceLen)); |
|
| 1229 |
-/* |
|
| 1230 |
- Compresses the source buffer into the destination buffer. sourceLen is |
|
| 1231 |
- the byte length of the source buffer. Upon entry, destLen is the total size |
|
| 1232 |
- of the destination buffer, which must be at least the value returned by |
|
| 1233 |
- compressBound(sourceLen). Upon exit, destLen is the actual size of the |
|
| 1234 |
- compressed data. compress() is equivalent to compress2() with a level |
|
| 1235 |
- parameter of Z_DEFAULT_COMPRESSION. |
|
| 1236 |
- |
|
| 1237 |
- compress returns Z_OK if success, Z_MEM_ERROR if there was not |
|
| 1238 |
- enough memory, Z_BUF_ERROR if there was not enough room in the output |
|
| 1239 |
- buffer. |
|
| 1240 |
-*/ |
|
| 1241 |
- |
|
| 1242 |
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, |
|
| 1243 |
- const Bytef *source, uLong sourceLen, |
|
| 1244 |
- int level)); |
|
| 1245 |
-/* |
|
| 1246 |
- Compresses the source buffer into the destination buffer. The level |
|
| 1247 |
- parameter has the same meaning as in deflateInit. sourceLen is the byte |
|
| 1248 |
- length of the source buffer. Upon entry, destLen is the total size of the |
|
| 1249 |
- destination buffer, which must be at least the value returned by |
|
| 1250 |
- compressBound(sourceLen). Upon exit, destLen is the actual size of the |
|
| 1251 |
- compressed data. |
|
| 1252 |
- |
|
| 1253 |
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|
| 1254 |
- memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
|
| 1255 |
- Z_STREAM_ERROR if the level parameter is invalid. |
|
| 1256 |
-*/ |
|
| 1257 |
- |
|
| 1258 |
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); |
|
| 1259 |
-/* |
|
| 1260 |
- compressBound() returns an upper bound on the compressed size after |
|
| 1261 |
- compress() or compress2() on sourceLen bytes. It would be used before a |
|
| 1262 |
- compress() or compress2() call to allocate the destination buffer. |
|
| 1263 |
-*/ |
|
| 1264 |
- |
|
| 1265 |
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, |
|
| 1266 |
- const Bytef *source, uLong sourceLen)); |
|
| 1267 |
-/* |
|
| 1268 |
- Decompresses the source buffer into the destination buffer. sourceLen is |
|
| 1269 |
- the byte length of the source buffer. Upon entry, destLen is the total size |
|
| 1270 |
- of the destination buffer, which must be large enough to hold the entire |
|
| 1271 |
- uncompressed data. (The size of the uncompressed data must have been saved |
|
| 1272 |
- previously by the compressor and transmitted to the decompressor by some |
|
| 1273 |
- mechanism outside the scope of this compression library.) Upon exit, destLen |
|
| 1274 |
- is the actual size of the uncompressed data. |
|
| 1275 |
- |
|
| 1276 |
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not |
|
| 1277 |
- enough memory, Z_BUF_ERROR if there was not enough room in the output |
|
| 1278 |
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In |
|
| 1279 |
- the case where there is not enough room, uncompress() will fill the output |
|
| 1280 |
- buffer with the uncompressed data up to that point. |
|
| 1281 |
-*/ |
|
| 1282 |
- |
|
| 1283 |
-ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, |
|
| 1284 |
- const Bytef *source, uLong *sourceLen)); |
|
| 1285 |
-/* |
|
| 1286 |
- Same as uncompress, except that sourceLen is a pointer, where the |
|
| 1287 |
- length of the source is *sourceLen. On return, *sourceLen is the number of |
|
| 1288 |
- source bytes consumed. |
|
| 1289 |
-*/ |
|
| 1290 |
- |
|
| 1291 |
- /* gzip file access functions */ |
|
| 1292 |
- |
|
| 1293 |
-/* |
|
| 1294 |
- This library supports reading and writing files in gzip (.gz) format with |
|
| 1295 |
- an interface similar to that of stdio, using the functions that start with |
|
| 1296 |
- "gz". The gzip format is different from the zlib format. gzip is a gzip |
|
| 1297 |
- wrapper, documented in RFC 1952, wrapped around a deflate stream. |
|
| 1298 |
-*/ |
|
| 1299 |
- |
|
| 1300 |
-typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ |
|
| 1301 |
- |
|
| 1302 |
-/* |
|
| 1303 |
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); |
|
| 1304 |
- |
|
| 1305 |
- Opens a gzip (.gz) file for reading or writing. The mode parameter is as |
|
| 1306 |
- in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
|
|
| 1307 |
- a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only |
|
| 1308 |
- compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' |
|
| 1309 |
- for fixed code compression as in "wb9F". (See the description of |
|
| 1310 |
- deflateInit2 for more information about the strategy parameter.) 'T' will |
|
| 1311 |
- request transparent writing or appending with no compression and not using |
|
| 1312 |
- the gzip format. |
|
| 1313 |
- |
|
| 1314 |
- "a" can be used instead of "w" to request that the gzip stream that will |
|
| 1315 |
- be written be appended to the file. "+" will result in an error, since |
|
| 1316 |
- reading and writing to the same gzip file is not supported. The addition of |
|
| 1317 |
- "x" when writing will create the file exclusively, which fails if the file |
|
| 1318 |
- already exists. On systems that support it, the addition of "e" when |
|
| 1319 |
- reading or writing will set the flag to close the file on an execve() call. |
|
| 1320 |
- |
|
| 1321 |
- These functions, as well as gzip, will read and decode a sequence of gzip |
|
| 1322 |
- streams in a file. The append function of gzopen() can be used to create |
|
| 1323 |
- such a file. (Also see gzflush() for another way to do this.) When |
|
| 1324 |
- appending, gzopen does not test whether the file begins with a gzip stream, |
|
| 1325 |
- nor does it look for the end of the gzip streams to begin appending. gzopen |
|
| 1326 |
- will simply append a gzip stream to the existing file. |
|
| 1327 |
- |
|
| 1328 |
- gzopen can be used to read a file which is not in gzip format; in this |
|
| 1329 |
- case gzread will directly read from the file without decompression. When |
|
| 1330 |
- reading, this will be detected automatically by looking for the magic two- |
|
| 1331 |
- byte gzip header. |
|
| 1332 |
- |
|
| 1333 |
- gzopen returns NULL if the file could not be opened, if there was |
|
| 1334 |
- insufficient memory to allocate the gzFile state, or if an invalid mode was |
|
| 1335 |
- specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). |
|
| 1336 |
- errno can be checked to determine if the reason gzopen failed was that the |
|
| 1337 |
- file could not be opened. |
|
| 1338 |
-*/ |
|
| 1339 |
- |
|
| 1340 |
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); |
|
| 1341 |
-/* |
|
| 1342 |
- gzdopen associates a gzFile with the file descriptor fd. File descriptors |
|
| 1343 |
- are obtained from calls like open, dup, creat, pipe or fileno (if the file |
|
| 1344 |
- has been previously opened with fopen). The mode parameter is as in gzopen. |
|
| 1345 |
- |
|
| 1346 |
- The next call of gzclose on the returned gzFile will also close the file |
|
| 1347 |
- descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor |
|
| 1348 |
- fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, |
|
| 1349 |
- mode);. The duplicated descriptor should be saved to avoid a leak, since |
|
| 1350 |
- gzdopen does not close fd if it fails. If you are using fileno() to get the |
|
| 1351 |
- file descriptor from a FILE *, then you will have to use dup() to avoid |
|
| 1352 |
- double-close()ing the file descriptor. Both gzclose() and fclose() will |
|
| 1353 |
- close the associated file descriptor, so they need to have different file |
|
| 1354 |
- descriptors. |
|
| 1355 |
- |
|
| 1356 |
- gzdopen returns NULL if there was insufficient memory to allocate the |
|
| 1357 |
- gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not |
|
| 1358 |
- provided, or '+' was provided), or if fd is -1. The file descriptor is not |
|
| 1359 |
- used until the next gz* read, write, seek, or close operation, so gzdopen |
|
| 1360 |
- will not detect if fd is invalid (unless fd is -1). |
|
| 1361 |
-*/ |
|
| 1362 |
- |
|
| 1363 |
-ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); |
|
| 1364 |
-/* |
|
| 1365 |
- Set the internal buffer size used by this library's functions. The |
|
| 1366 |
- default buffer size is 8192 bytes. This function must be called after |
|
| 1367 |
- gzopen() or gzdopen(), and before any other calls that read or write the |
|
| 1368 |
- file. The buffer memory allocation is always deferred to the first read or |
|
| 1369 |
- write. Three times that size in buffer space is allocated. A larger buffer |
|
| 1370 |
- size of, for example, 64K or 128K bytes will noticeably increase the speed |
|
| 1371 |
- of decompression (reading). |
|
| 1372 |
- |
|
| 1373 |
- The new buffer size also affects the maximum length for gzprintf(). |
|
| 1374 |
- |
|
| 1375 |
- gzbuffer() returns 0 on success, or -1 on failure, such as being called |
|
| 1376 |
- too late. |
|
| 1377 |
-*/ |
|
| 1378 |
- |
|
| 1379 |
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); |
|
| 1380 |
-/* |
|
| 1381 |
- Dynamically update the compression level or strategy. See the description |
|
| 1382 |
- of deflateInit2 for the meaning of these parameters. Previously provided |
|
| 1383 |
- data is flushed before the parameter change. |
|
| 1384 |
- |
|
| 1385 |
- gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not |
|
| 1386 |
- opened for writing, Z_ERRNO if there is an error writing the flushed data, |
|
| 1387 |
- or Z_MEM_ERROR if there is a memory allocation error. |
|
| 1388 |
-*/ |
|
| 1389 |
- |
|
| 1390 |
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
|
| 1391 |
-/* |
|
| 1392 |
- Reads the given number of uncompressed bytes from the compressed file. If |
|
| 1393 |
- the input file is not in gzip format, gzread copies the given number of |
|
| 1394 |
- bytes into the buffer directly from the file. |
|
| 1395 |
- |
|
| 1396 |
- After reaching the end of a gzip stream in the input, gzread will continue |
|
| 1397 |
- to read, looking for another gzip stream. Any number of gzip streams may be |
|
| 1398 |
- concatenated in the input file, and will all be decompressed by gzread(). |
|
| 1399 |
- If something other than a gzip stream is encountered after a gzip stream, |
|
| 1400 |
- that remaining trailing garbage is ignored (and no error is returned). |
|
| 1401 |
- |
|
| 1402 |
- gzread can be used to read a gzip file that is being concurrently written. |
|
| 1403 |
- Upon reaching the end of the input, gzread will return with the available |
|
| 1404 |
- data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then |
|
| 1405 |
- gzclearerr can be used to clear the end of file indicator in order to permit |
|
| 1406 |
- gzread to be tried again. Z_OK indicates that a gzip stream was completed |
|
| 1407 |
- on the last gzread. Z_BUF_ERROR indicates that the input file ended in the |
|
| 1408 |
- middle of a gzip stream. Note that gzread does not return -1 in the event |
|
| 1409 |
- of an incomplete gzip stream. This error is deferred until gzclose(), which |
|
| 1410 |
- will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip |
|
| 1411 |
- stream. Alternatively, gzerror can be used before gzclose to detect this |
|
| 1412 |
- case. |
|
| 1413 |
- |
|
| 1414 |
- gzread returns the number of uncompressed bytes actually read, less than |
|
| 1415 |
- len for end of file, or -1 for error. If len is too large to fit in an int, |
|
| 1416 |
- then nothing is read, -1 is returned, and the error state is set to |
|
| 1417 |
- Z_STREAM_ERROR. |
|
| 1418 |
-*/ |
|
| 1419 |
- |
|
| 1420 |
-ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, |
|
| 1421 |
- gzFile file)); |
|
| 1422 |
-/* |
|
| 1423 |
- Read up to nitems items of size size from file to buf, otherwise operating |
|
| 1424 |
- as gzread() does. This duplicates the interface of stdio's fread(), with |
|
| 1425 |
- size_t request and return types. If the library defines size_t, then |
|
| 1426 |
- z_size_t is identical to size_t. If not, then z_size_t is an unsigned |
|
| 1427 |
- integer type that can contain a pointer. |
|
| 1428 |
- |
|
| 1429 |
- gzfread() returns the number of full items read of size size, or zero if |
|
| 1430 |
- the end of the file was reached and a full item could not be read, or if |
|
| 1431 |
- there was an error. gzerror() must be consulted if zero is returned in |
|
| 1432 |
- order to determine if there was an error. If the multiplication of size and |
|
| 1433 |
- nitems overflows, i.e. the product does not fit in a z_size_t, then nothing |
|
| 1434 |
- is read, zero is returned, and the error state is set to Z_STREAM_ERROR. |
|
| 1435 |
- |
|
| 1436 |
- In the event that the end of file is reached and only a partial item is |
|
| 1437 |
- available at the end, i.e. the remaining uncompressed data length is not a |
|
| 1438 |
- multiple of size, then the final partial item is nevetheless read into buf |
|
| 1439 |
- and the end-of-file flag is set. The length of the partial item read is not |
|
| 1440 |
- provided, but could be inferred from the result of gztell(). This behavior |
|
| 1441 |
- is the same as the behavior of fread() implementations in common libraries, |
|
| 1442 |
- but it prevents the direct use of gzfread() to read a concurrently written |
|
| 1443 |
- file, reseting and retrying on end-of-file, when size is not 1. |
|
| 1444 |
-*/ |
|
| 1445 |
- |
|
| 1446 |
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file, |
|
| 1447 |
- voidpc buf, unsigned len)); |
|
| 1448 |
-/* |
|
| 1449 |
- Writes the given number of uncompressed bytes into the compressed file. |
|
| 1450 |
- gzwrite returns the number of uncompressed bytes written or 0 in case of |
|
| 1451 |
- error. |
|
| 1452 |
-*/ |
|
| 1453 |
- |
|
| 1454 |
-ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, |
|
| 1455 |
- z_size_t nitems, gzFile file)); |
|
| 1456 |
-/* |
|
| 1457 |
- gzfwrite() writes 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 |
|
| 1459 |
- the library defines size_t, then z_size_t is identical to size_t. If not, |
|
| 1460 |
- then z_size_t is an unsigned integer type that can contain a pointer. |
|
| 1461 |
- |
|
| 1462 |
- gzfwrite() returns the number of full items written of size size, or zero |
|
| 1463 |
- if there was an error. If the multiplication of size and nitems overflows, |
|
| 1464 |
- i.e. the product does not fit in a z_size_t, then nothing is written, zero |
|
| 1465 |
- is returned, and the error state is set to Z_STREAM_ERROR. |
|
| 1466 |
-*/ |
|
| 1467 |
- |
|
| 1468 |
-ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); |
|
| 1469 |
-/* |
|
| 1470 |
- Converts, formats, and writes the arguments to the compressed file under |
|
| 1471 |
- control of the format string, as in fprintf. gzprintf returns the number of |
|
| 1472 |
- uncompressed bytes actually written, or a negative zlib error code in case |
|
| 1473 |
- of error. The number of uncompressed bytes written is limited to 8191, or |
|
| 1474 |
- one less than the buffer size given to gzbuffer(). The caller should assure |
|
| 1475 |
- that this limit is not exceeded. If it is exceeded, then gzprintf() will |
|
| 1476 |
- return an error (0) with nothing written. In this case, there may also be a |
|
| 1477 |
- buffer overflow with unpredictable consequences, which is possible only if |
|
| 1478 |
- zlib was compiled with the insecure functions sprintf() or vsprintf() |
|
| 1479 |
- because the secure snprintf() or vsnprintf() functions were not available. |
|
| 1480 |
- This can be determined using zlibCompileFlags(). |
|
| 1481 |
-*/ |
|
| 1482 |
- |
|
| 1483 |
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); |
|
| 1484 |
-/* |
|
| 1485 |
- Writes the given null-terminated string to the compressed file, excluding |
|
| 1486 |
- the terminating null character. |
|
| 1487 |
- |
|
| 1488 |
- gzputs returns the number of characters written, or -1 in case of error. |
|
| 1489 |
-*/ |
|
| 1490 |
- |
|
| 1491 |
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); |
|
| 1492 |
-/* |
|
| 1493 |
- Reads bytes from the compressed file until len-1 characters are read, or a |
|
| 1494 |
- newline character is read and transferred to buf, or an end-of-file |
|
| 1495 |
- condition is encountered. If any characters are read or if len == 1, the |
|
| 1496 |
- string is terminated with a null character. If no characters are read due |
|
| 1497 |
- to an end-of-file or len < 1, then the buffer is left untouched. |
|
| 1498 |
- |
|
| 1499 |
- gzgets returns buf which is a null-terminated string, or it returns NULL |
|
| 1500 |
- for end-of-file or in case of error. If there was an error, the contents at |
|
| 1501 |
- buf are indeterminate. |
|
| 1502 |
-*/ |
|
| 1503 |
- |
|
| 1504 |
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); |
|
| 1505 |
-/* |
|
| 1506 |
- Writes c, converted to an unsigned char, into the compressed file. gzputc |
|
| 1507 |
- returns the value that was written, or -1 in case of error. |
|
| 1508 |
-*/ |
|
| 1509 |
- |
|
| 1510 |
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); |
|
| 1511 |
-/* |
|
| 1512 |
- Reads one byte from the compressed file. gzgetc returns this byte or -1 |
|
| 1513 |
- in case of end of file or error. This is implemented as a macro for speed. |
|
| 1514 |
- As such, it does not do all of the checking the other functions do. I.e. |
|
| 1515 |
- it does not check to see if file is NULL, nor whether the structure file |
|
| 1516 |
- points to has been clobbered or not. |
|
| 1517 |
-*/ |
|
| 1518 |
- |
|
| 1519 |
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); |
|
| 1520 |
-/* |
|
| 1521 |
- Push one character back onto the stream to be read as the first character |
|
| 1522 |
- on the next read. At least one character of push-back is allowed. |
|
| 1523 |
- gzungetc() returns the character pushed, or -1 on failure. gzungetc() will |
|
| 1524 |
- fail if c is -1, and may fail if a character has been pushed but not read |
|
| 1525 |
- yet. If gzungetc is used immediately after gzopen or gzdopen, at least the |
|
| 1526 |
- output buffer size of pushed characters is allowed. (See gzbuffer above.) |
|
| 1527 |
- The pushed character will be discarded if the stream is repositioned with |
|
| 1528 |
- gzseek() or gzrewind(). |
|
| 1529 |
-*/ |
|
| 1530 |
- |
|
| 1531 |
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); |
|
| 1532 |
-/* |
|
| 1533 |
- Flushes all pending output into the compressed file. The parameter flush |
|
| 1534 |
- is as in the deflate() function. The return value is the zlib error number |
|
| 1535 |
- (see function gzerror below). gzflush is only permitted when writing. |
|
| 1536 |
- |
|
| 1537 |
- If the flush parameter is Z_FINISH, the remaining data is written and the |
|
| 1538 |
- gzip stream is completed in the output. If gzwrite() is called again, a new |
|
| 1539 |
- gzip stream will be started in the output. gzread() is able to read such |
|
| 1540 |
- concatenated gzip streams. |
|
| 1541 |
- |
|
| 1542 |
- gzflush should be called only when strictly necessary because it will |
|
| 1543 |
- degrade compression if called too often. |
|
| 1544 |
-*/ |
|
| 1545 |
- |
|
| 1546 |
-/* |
|
| 1547 |
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, |
|
| 1548 |
- z_off_t offset, int whence)); |
|
| 1549 |
- |
|
| 1550 |
- Sets the starting position for the next gzread or gzwrite on the given |
|
| 1551 |
- compressed file. The offset represents a number of bytes in the |
|
| 1552 |
- uncompressed data stream. The whence parameter is defined as in lseek(2); |
|
| 1553 |
- the value SEEK_END is not supported. |
|
| 1554 |
- |
|
| 1555 |
- If the file is opened for reading, this function is emulated but can be |
|
| 1556 |
- extremely slow. If the file is opened for writing, only forward seeks are |
|
| 1557 |
- supported; gzseek then compresses a sequence of zeroes up to the new |
|
| 1558 |
- starting position. |
|
| 1559 |
- |
|
| 1560 |
- gzseek returns the resulting offset location as measured in bytes from |
|
| 1561 |
- the beginning of the uncompressed stream, or -1 in case of error, in |
|
| 1562 |
- particular if the file is opened for writing and the new starting position |
|
| 1563 |
- would be before the current position. |
|
| 1564 |
-*/ |
|
| 1565 |
- |
|
| 1566 |
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); |
|
| 1567 |
-/* |
|
| 1568 |
- Rewinds the given file. This function is supported only for reading. |
|
| 1569 |
- |
|
| 1570 |
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) |
|
| 1571 |
-*/ |
|
| 1572 |
- |
|
| 1573 |
-/* |
|
| 1574 |
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); |
|
| 1575 |
- |
|
| 1576 |
- Returns the starting position for the next gzread or gzwrite on the given |
|
| 1577 |
- compressed file. This position represents a number of bytes in the |
|
| 1578 |
- uncompressed data stream, and is zero when starting, even if appending or |
|
| 1579 |
- reading a gzip stream from the middle of a file using gzdopen(). |
|
| 1580 |
- |
|
| 1581 |
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) |
|
| 1582 |
-*/ |
|
| 1583 |
- |
|
| 1584 |
-/* |
|
| 1585 |
-ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); |
|
| 1586 |
- |
|
| 1587 |
- Returns the current offset in the file being read or written. This offset |
|
| 1588 |
- includes the count of bytes that precede the gzip stream, for example when |
|
| 1589 |
- appending or when using gzdopen() for reading. When reading, the offset |
|
| 1590 |
- does not include as yet unused buffered input. This information can be used |
|
| 1591 |
- for a progress indicator. On error, gzoffset() returns -1. |
|
| 1592 |
-*/ |
|
| 1593 |
- |
|
| 1594 |
-ZEXTERN int ZEXPORT gzeof OF((gzFile file)); |
|
| 1595 |
-/* |
|
| 1596 |
- Returns true (1) if the end-of-file indicator has been set while reading, |
|
| 1597 |
- false (0) otherwise. Note that the end-of-file indicator is set only if the |
|
| 1598 |
- read tried to go past the end of the input, but came up short. Therefore, |
|
| 1599 |
- just like feof(), gzeof() may return false even if there is no more data to |
|
| 1600 |
- read, in the event that the last read request was for the exact number of |
|
| 1601 |
- bytes remaining in the input file. This will happen if the input file size |
|
| 1602 |
- is an exact multiple of the buffer size. |
|
| 1603 |
- |
|
| 1604 |
- If gzeof() returns true, then the read functions will return no more data, |
|
| 1605 |
- unless the end-of-file indicator is reset by gzclearerr() and the input file |
|
| 1606 |
- has grown since the previous end of file was detected. |
|
| 1607 |
-*/ |
|
| 1608 |
- |
|
| 1609 |
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); |
|
| 1610 |
-/* |
|
| 1611 |
- Returns true (1) if file is being copied directly while reading, or false |
|
| 1612 |
- (0) if file is a gzip stream being decompressed. |
|
| 1613 |
- |
|
| 1614 |
- If the input file is empty, gzdirect() will return true, since the input |
|
| 1615 |
- does not contain a gzip stream. |
|
| 1616 |
- |
|
| 1617 |
- If gzdirect() is used immediately after gzopen() or gzdopen() it will |
|
| 1618 |
- cause buffers to be allocated to allow reading the file to determine if it |
|
| 1619 |
- is a gzip file. Therefore if gzbuffer() is used, it should be called before |
|
| 1620 |
- gzdirect(). |
|
| 1621 |
- |
|
| 1622 |
- When writing, gzdirect() returns true (1) if transparent writing was |
|
| 1623 |
- requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
|
|
| 1624 |
- gzdirect() is not needed when writing. Transparent writing must be |
|
| 1625 |
- explicitly requested, so the application already knows the answer. When |
|
| 1626 |
- linking statically, using gzdirect() will include all of the zlib code for |
|
| 1627 |
- gzip file reading and decompression, which may not be desired.) |
|
| 1628 |
-*/ |
|
| 1629 |
- |
|
| 1630 |
-ZEXTERN int ZEXPORT gzclose OF((gzFile file)); |
|
| 1631 |
-/* |
|
| 1632 |
- Flushes all pending output if necessary, closes the compressed file and |
|
| 1633 |
- deallocates the (de)compression state. Note that once file is closed, you |
|
| 1634 |
- cannot call gzerror with file, since its structures have been deallocated. |
|
| 1635 |
- gzclose must not be called more than once on the same file, just as free |
|
| 1636 |
- must not be called more than once on the same allocation. |
|
| 1637 |
- |
|
| 1638 |
- gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a |
|
| 1639 |
- file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the |
|
| 1640 |
- last read ended in the middle of a gzip stream, or Z_OK on success. |
|
| 1641 |
-*/ |
|
| 1642 |
- |
|
| 1643 |
-ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); |
|
| 1644 |
-ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); |
|
| 1645 |
-/* |
|
| 1646 |
- Same as gzclose(), but gzclose_r() is only for use when reading, and |
|
| 1647 |
- gzclose_w() is only for use when writing or appending. The advantage to |
|
| 1648 |
- using these instead of gzclose() is that they avoid linking in zlib |
|
| 1649 |
- compression or decompression code that is not used when only reading or only |
|
| 1650 |
- writing respectively. If gzclose() is used, then both compression and |
|
| 1651 |
- decompression code will be included the application when linking to a static |
|
| 1652 |
- zlib library. |
|
| 1653 |
-*/ |
|
| 1654 |
- |
|
| 1655 |
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); |
|
| 1656 |
-/* |
|
| 1657 |
- Returns the error message for the last error which occurred on the given |
|
| 1658 |
- compressed file. errnum is set to zlib error number. If an error occurred |
|
| 1659 |
- in the file system and not in the compression library, errnum is set to |
|
| 1660 |
- Z_ERRNO and the application may consult errno to get the exact error code. |
|
| 1661 |
- |
|
| 1662 |
- The application must not modify the returned string. Future calls to |
|
| 1663 |
- this function may invalidate the previously returned string. If file is |
|
| 1664 |
- closed, then the string previously returned by gzerror will no longer be |
|
| 1665 |
- available. |
|
| 1666 |
- |
|
| 1667 |
- gzerror() should be used to distinguish errors from end-of-file for those |
|
| 1668 |
- functions above that do not distinguish those cases in their return values. |
|
| 1669 |
-*/ |
|
| 1670 |
- |
|
| 1671 |
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); |
|
| 1672 |
-/* |
|
| 1673 |
- Clears the error and end-of-file flags for file. This is analogous to the |
|
| 1674 |
- clearerr() function in stdio. This is useful for continuing to read a gzip |
|
| 1675 |
- file that is being written concurrently. |
|
| 1676 |
-*/ |
|
| 1677 |
- |
|
| 1678 |
-#endif /* !Z_SOLO */ |
|
| 1679 |
- |
|
| 1680 |
- /* checksum functions */ |
|
| 1681 |
- |
|
| 1682 |
-/* |
|
| 1683 |
- These functions are not related to compression but are exported |
|
| 1684 |
- anyway because they might be useful in applications using the compression |
|
| 1685 |
- library. |
|
| 1686 |
-*/ |
|
| 1687 |
- |
|
| 1688 |
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); |
|
| 1689 |
-/* |
|
| 1690 |
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
|
| 1691 |
- return the updated checksum. If buf is Z_NULL, this function returns the |
|
| 1692 |
- required initial value for the checksum. |
|
| 1693 |
- |
|
| 1694 |
- An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed |
|
| 1695 |
- much faster. |
|
| 1696 |
- |
|
| 1697 |
- Usage example: |
|
| 1698 |
- |
|
| 1699 |
- uLong adler = adler32(0L, Z_NULL, 0); |
|
| 1700 |
- |
|
| 1701 |
- while (read_buffer(buffer, length) != EOF) {
|
|
| 1702 |
- adler = adler32(adler, buffer, length); |
|
| 1703 |
- } |
|
| 1704 |
- if (adler != original_adler) error(); |
|
| 1705 |
-*/ |
|
| 1706 |
- |
|
| 1707 |
-ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, |
|
| 1708 |
- z_size_t len)); |
|
| 1709 |
-/* |
|
| 1710 |
- Same as adler32(), but with a size_t length. |
|
| 1711 |
-*/ |
|
| 1712 |
- |
|
| 1713 |
-/* |
|
| 1714 |
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, |
|
| 1715 |
- z_off_t len2)); |
|
| 1716 |
- |
|
| 1717 |
- Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
|
| 1718 |
- and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for |
|
| 1719 |
- each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of |
|
| 1720 |
- seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note |
|
| 1721 |
- that the z_off_t type (like off_t) is a signed integer. If len2 is |
|
| 1722 |
- negative, the result has no meaning or utility. |
|
| 1723 |
-*/ |
|
| 1724 |
- |
|
| 1725 |
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); |
|
| 1726 |
-/* |
|
| 1727 |
- Update a running CRC-32 with the bytes buf[0..len-1] and return the |
|
| 1728 |
- updated CRC-32. If buf is Z_NULL, this function returns the required |
|
| 1729 |
- initial value for the crc. Pre- and post-conditioning (one's complement) is |
|
| 1730 |
- performed within this function so it shouldn't be done by the application. |
|
| 1731 |
- |
|
| 1732 |
- Usage example: |
|
| 1733 |
- |
|
| 1734 |
- uLong crc = crc32(0L, Z_NULL, 0); |
|
| 1735 |
- |
|
| 1736 |
- while (read_buffer(buffer, length) != EOF) {
|
|
| 1737 |
- crc = crc32(crc, buffer, length); |
|
| 1738 |
- } |
|
| 1739 |
- if (crc != original_crc) error(); |
|
| 1740 |
-*/ |
|
| 1741 |
- |
|
| 1742 |
-ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, |
|
| 1743 |
- z_size_t len)); |
|
| 1744 |
-/* |
|
| 1745 |
- Same as crc32(), but with a size_t length. |
|
| 1746 |
-*/ |
|
| 1747 |
- |
|
| 1748 |
-/* |
|
| 1749 |
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); |
|
| 1750 |
- |
|
| 1751 |
- Combine two CRC-32 check values into one. For two sequences of bytes, |
|
| 1752 |
- seq1 and seq2 with lengths len1 and len2, CRC-32 check values were |
|
| 1753 |
- calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 |
|
| 1754 |
- check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and |
|
| 1755 |
- len2. |
|
| 1756 |
-*/ |
|
| 1757 |
- |
|
| 1758 |
- |
|
| 1759 |
- /* various hacks, don't look :) */ |
|
| 1760 |
- |
|
| 1761 |
-/* deflateInit and inflateInit are macros to allow checking the zlib version |
|
| 1762 |
- * and the compiler's view of z_stream: |
|
| 1763 |
- */ |
|
| 1764 |
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, |
|
| 1765 |
- const char *version, int stream_size)); |
|
| 1766 |
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, |
|
| 1767 |
- const char *version, int stream_size)); |
|
| 1768 |
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, |
|
| 1769 |
- int windowBits, int memLevel, |
|
| 1770 |
- int strategy, const char *version, |
|
| 1771 |
- int stream_size)); |
|
| 1772 |
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, |
|
| 1773 |
- const char *version, int stream_size)); |
|
| 1774 |
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, |
|
| 1775 |
- unsigned char FAR *window, |
|
| 1776 |
- const char *version, |
|
| 1777 |
- int stream_size)); |
|
| 1778 |
-#ifdef Z_PREFIX_SET |
|
| 1779 |
-# define z_deflateInit(strm, level) \ |
|
| 1780 |
- deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1781 |
-# define z_inflateInit(strm) \ |
|
| 1782 |
- inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1783 |
-# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ |
|
| 1784 |
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ |
|
| 1785 |
- (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1786 |
-# define z_inflateInit2(strm, windowBits) \ |
|
| 1787 |
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ |
|
| 1788 |
- (int)sizeof(z_stream)) |
|
| 1789 |
-# define z_inflateBackInit(strm, windowBits, window) \ |
|
| 1790 |
- inflateBackInit_((strm), (windowBits), (window), \ |
|
| 1791 |
- ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1792 |
-#else |
|
| 1793 |
-# define deflateInit(strm, level) \ |
|
| 1794 |
- deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1795 |
-# define inflateInit(strm) \ |
|
| 1796 |
- inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1797 |
-# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ |
|
| 1798 |
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ |
|
| 1799 |
- (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1800 |
-# define inflateInit2(strm, windowBits) \ |
|
| 1801 |
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ |
|
| 1802 |
- (int)sizeof(z_stream)) |
|
| 1803 |
-# define inflateBackInit(strm, windowBits, window) \ |
|
| 1804 |
- inflateBackInit_((strm), (windowBits), (window), \ |
|
| 1805 |
- ZLIB_VERSION, (int)sizeof(z_stream)) |
|
| 1806 |
-#endif |
|
| 1807 |
- |
|
| 1808 |
-#ifndef Z_SOLO |
|
| 1809 |
- |
|
| 1810 |
-/* gzgetc() macro and its supporting function and exposed data structure. Note |
|
| 1811 |
- * that the real internal state is much larger than the exposed structure. |
|
| 1812 |
- * This abbreviated structure exposes just enough for the gzgetc() macro. The |
|
| 1813 |
- * user should not mess with these exposed elements, since their names or |
|
| 1814 |
- * behavior could change in the future, perhaps even capriciously. They can |
|
| 1815 |
- * only be used by the gzgetc() macro. You have been warned. |
|
| 1816 |
- */ |
|
| 1817 |
-struct gzFile_s {
|
|
| 1818 |
- unsigned have; |
|
| 1819 |
- unsigned char *next; |
|
| 1820 |
- z_off64_t pos; |
|
| 1821 |
-}; |
|
| 1822 |
-ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ |
|
| 1823 |
-#ifdef Z_PREFIX_SET |
|
| 1824 |
-# undef z_gzgetc |
|
| 1825 |
-# define z_gzgetc(g) \ |
|
| 1826 |
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) |
|
| 1827 |
-#else |
|
| 1828 |
-# define gzgetc(g) \ |
|
| 1829 |
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) |
|
| 1830 |
-#endif |
|
| 1831 |
- |
|
| 1832 |
-/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or |
|
| 1833 |
- * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if |
|
| 1834 |
- * both are true, the application gets the *64 functions, and the regular |
|
| 1835 |
- * functions are changed to 64 bits) -- in case these are set on systems |
|
| 1836 |
- * without large file support, _LFS64_LARGEFILE must also be true |
|
| 1837 |
- */ |
|
| 1838 |
-#ifdef Z_LARGE64 |
|
| 1839 |
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
|
| 1840 |
- ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); |
|
| 1841 |
- ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); |
|
| 1842 |
- ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); |
|
| 1843 |
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); |
|
| 1844 |
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); |
|
| 1845 |
-#endif |
|
| 1846 |
- |
|
| 1847 |
-#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) |
|
| 1848 |
-# ifdef Z_PREFIX_SET |
|
| 1849 |
-# define z_gzopen z_gzopen64 |
|
| 1850 |
-# define z_gzseek z_gzseek64 |
|
| 1851 |
-# define z_gztell z_gztell64 |
|
| 1852 |
-# define z_gzoffset z_gzoffset64 |
|
| 1853 |
-# define z_adler32_combine z_adler32_combine64 |
|
| 1854 |
-# define z_crc32_combine z_crc32_combine64 |
|
| 1855 |
-# else |
|
| 1856 |
-# define gzopen gzopen64 |
|
| 1857 |
-# define gzseek gzseek64 |
|
| 1858 |
-# define gztell gztell64 |
|
| 1859 |
-# define gzoffset gzoffset64 |
|
| 1860 |
-# define adler32_combine adler32_combine64 |
|
| 1861 |
-# define crc32_combine crc32_combine64 |
|
| 1862 |
-# endif |
|
| 1863 |
-# ifndef Z_LARGE64 |
|
| 1864 |
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
|
| 1865 |
- ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); |
|
| 1866 |
- ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); |
|
| 1867 |
- ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); |
|
| 1868 |
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
|
| 1869 |
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
|
| 1870 |
-# endif |
|
| 1871 |
-#else |
|
| 1872 |
- ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); |
|
| 1873 |
- ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); |
|
| 1874 |
- ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); |
|
| 1875 |
- ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); |
|
| 1876 |
- ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); |
|
| 1877 |
- ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
|
| 1878 |
-#endif |
|
| 1879 |
- |
|
| 1880 |
-#else /* Z_SOLO */ |
|
| 1881 |
- |
|
| 1882 |
- ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); |
|
| 1883 |
- ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
|
| 1884 |
- |
|
| 1885 |
-#endif /* !Z_SOLO */ |
|
| 1886 |
- |
|
| 1887 |
-/* undocumented functions */ |
|
| 1888 |
-ZEXTERN const char * ZEXPORT zError OF((int)); |
|
| 1889 |
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); |
|
| 1890 |
-ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); |
|
| 1891 |
-ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); |
|
| 1892 |
-ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); |
|
| 1893 |
-ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); |
|
| 1894 |
-ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); |
|
| 1895 |
-ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); |
|
| 1896 |
-#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) |
|
| 1897 |
-ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, |
|
| 1898 |
- const char *mode)); |
|
| 1899 |
-#endif |
|
| 1900 |
-#if defined(STDC) || defined(Z_HAVE_STDARG_H) |
|
| 1901 |
-# ifndef Z_SOLO |
|
| 1902 |
-ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, |
|
| 1903 |
- const char *format, |
|
| 1904 |
- va_list va)); |
|
| 1905 |
-# endif |
|
| 1906 |
-#endif |
|
| 1907 |
- |
|
| 1908 |
-#ifdef __cplusplus |
|
| 1909 |
-} |
|
| 1910 |
-#endif |
|
| 1911 |
- |
|
| 1912 |
-#endif /* ZLIB_H */ |
| 1913 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,325 +0,0 @@ |
| 1 |
-/* zutil.c -- target dependent utility functions for the compression library |
|
| 2 |
- * Copyright (C) 1995-2017 Jean-loup Gailly |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* @(#) $Id$ */ |
|
| 7 |
- |
|
| 8 |
-#include "zutil.h" |
|
| 9 |
-#ifndef Z_SOLO |
|
| 10 |
-# include "gzguts.h" |
|
| 11 |
-#endif |
|
| 12 |
- |
|
| 13 |
-z_const char * const z_errmsg[10] = {
|
|
| 14 |
- (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ |
|
| 15 |
- (z_const char *)"stream end", /* Z_STREAM_END 1 */ |
|
| 16 |
- (z_const char *)"", /* Z_OK 0 */ |
|
| 17 |
- (z_const char *)"file error", /* Z_ERRNO (-1) */ |
|
| 18 |
- (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ |
|
| 19 |
- (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ |
|
| 20 |
- (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ |
|
| 21 |
- (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ |
|
| 22 |
- (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ |
|
| 23 |
- (z_const char *)"" |
|
| 24 |
-}; |
|
| 25 |
- |
|
| 26 |
- |
|
| 27 |
-const char * ZEXPORT zlibVersion() |
|
| 28 |
-{
|
|
| 29 |
- return ZLIB_VERSION; |
|
| 30 |
-} |
|
| 31 |
- |
|
| 32 |
-uLong ZEXPORT zlibCompileFlags() |
|
| 33 |
-{
|
|
| 34 |
- uLong flags; |
|
| 35 |
- |
|
| 36 |
- flags = 0; |
|
| 37 |
- switch ((int)(sizeof(uInt))) {
|
|
| 38 |
- case 2: break; |
|
| 39 |
- case 4: flags += 1; break; |
|
| 40 |
- case 8: flags += 2; break; |
|
| 41 |
- default: flags += 3; |
|
| 42 |
- } |
|
| 43 |
- switch ((int)(sizeof(uLong))) {
|
|
| 44 |
- case 2: break; |
|
| 45 |
- case 4: flags += 1 << 2; break; |
|
| 46 |
- case 8: flags += 2 << 2; break; |
|
| 47 |
- default: flags += 3 << 2; |
|
| 48 |
- } |
|
| 49 |
- switch ((int)(sizeof(voidpf))) {
|
|
| 50 |
- case 2: break; |
|
| 51 |
- case 4: flags += 1 << 4; break; |
|
| 52 |
- case 8: flags += 2 << 4; break; |
|
| 53 |
- default: flags += 3 << 4; |
|
| 54 |
- } |
|
| 55 |
- switch ((int)(sizeof(z_off_t))) {
|
|
| 56 |
- case 2: break; |
|
| 57 |
- case 4: flags += 1 << 6; break; |
|
| 58 |
- case 8: flags += 2 << 6; break; |
|
| 59 |
- default: flags += 3 << 6; |
|
| 60 |
- } |
|
| 61 |
-#ifdef ZLIB_DEBUG |
|
| 62 |
- flags += 1 << 8; |
|
| 63 |
-#endif |
|
| 64 |
-#if defined(ASMV) || defined(ASMINF) |
|
| 65 |
- flags += 1 << 9; |
|
| 66 |
-#endif |
|
| 67 |
-#ifdef ZLIB_WINAPI |
|
| 68 |
- flags += 1 << 10; |
|
| 69 |
-#endif |
|
| 70 |
-#ifdef BUILDFIXED |
|
| 71 |
- flags += 1 << 12; |
|
| 72 |
-#endif |
|
| 73 |
-#ifdef DYNAMIC_CRC_TABLE |
|
| 74 |
- flags += 1 << 13; |
|
| 75 |
-#endif |
|
| 76 |
-#ifdef NO_GZCOMPRESS |
|
| 77 |
- flags += 1L << 16; |
|
| 78 |
-#endif |
|
| 79 |
-#ifdef NO_GZIP |
|
| 80 |
- flags += 1L << 17; |
|
| 81 |
-#endif |
|
| 82 |
-#ifdef PKZIP_BUG_WORKAROUND |
|
| 83 |
- flags += 1L << 20; |
|
| 84 |
-#endif |
|
| 85 |
-#ifdef FASTEST |
|
| 86 |
- flags += 1L << 21; |
|
| 87 |
-#endif |
|
| 88 |
-#if defined(STDC) || defined(Z_HAVE_STDARG_H) |
|
| 89 |
-# ifdef NO_vsnprintf |
|
| 90 |
- flags += 1L << 25; |
|
| 91 |
-# ifdef HAS_vsprintf_void |
|
| 92 |
- flags += 1L << 26; |
|
| 93 |
-# endif |
|
| 94 |
-# else |
|
| 95 |
-# ifdef HAS_vsnprintf_void |
|
| 96 |
- flags += 1L << 26; |
|
| 97 |
-# endif |
|
| 98 |
-# endif |
|
| 99 |
-#else |
|
| 100 |
- flags += 1L << 24; |
|
| 101 |
-# ifdef NO_snprintf |
|
| 102 |
- flags += 1L << 25; |
|
| 103 |
-# ifdef HAS_sprintf_void |
|
| 104 |
- flags += 1L << 26; |
|
| 105 |
-# endif |
|
| 106 |
-# else |
|
| 107 |
-# ifdef HAS_snprintf_void |
|
| 108 |
- flags += 1L << 26; |
|
| 109 |
-# endif |
|
| 110 |
-# endif |
|
| 111 |
-#endif |
|
| 112 |
- return flags; |
|
| 113 |
-} |
|
| 114 |
- |
|
| 115 |
-#ifdef ZLIB_DEBUG |
|
| 116 |
-#include <stdlib.h> |
|
| 117 |
-# ifndef verbose |
|
| 118 |
-# define verbose 0 |
|
| 119 |
-# endif |
|
| 120 |
-int ZLIB_INTERNAL z_verbose = verbose; |
|
| 121 |
- |
|
| 122 |
-void ZLIB_INTERNAL z_error (m) |
|
| 123 |
- char *m; |
|
| 124 |
-{
|
|
| 125 |
- fprintf(stderr, "%s\n", m); |
|
| 126 |
- exit(1); |
|
| 127 |
-} |
|
| 128 |
-#endif |
|
| 129 |
- |
|
| 130 |
-/* exported to allow conversion of error code to string for compress() and |
|
| 131 |
- * uncompress() |
|
| 132 |
- */ |
|
| 133 |
-const char * ZEXPORT zError(err) |
|
| 134 |
- int err; |
|
| 135 |
-{
|
|
| 136 |
- return ERR_MSG(err); |
|
| 137 |
-} |
|
| 138 |
- |
|
| 139 |
-#if defined(_WIN32_WCE) |
|
| 140 |
- /* The Microsoft C Run-Time Library for Windows CE doesn't have |
|
| 141 |
- * errno. We define it as a global variable to simplify porting. |
|
| 142 |
- * Its value is always 0 and should not be used. |
|
| 143 |
- */ |
|
| 144 |
- int errno = 0; |
|
| 145 |
-#endif |
|
| 146 |
- |
|
| 147 |
-#ifndef HAVE_MEMCPY |
|
| 148 |
- |
|
| 149 |
-void ZLIB_INTERNAL zmemcpy(dest, source, len) |
|
| 150 |
- Bytef* dest; |
|
| 151 |
- const Bytef* source; |
|
| 152 |
- uInt len; |
|
| 153 |
-{
|
|
| 154 |
- if (len == 0) return; |
|
| 155 |
- do {
|
|
| 156 |
- *dest++ = *source++; /* ??? to be unrolled */ |
|
| 157 |
- } while (--len != 0); |
|
| 158 |
-} |
|
| 159 |
- |
|
| 160 |
-int ZLIB_INTERNAL zmemcmp(s1, s2, len) |
|
| 161 |
- const Bytef* s1; |
|
| 162 |
- const Bytef* s2; |
|
| 163 |
- uInt len; |
|
| 164 |
-{
|
|
| 165 |
- uInt j; |
|
| 166 |
- |
|
| 167 |
- for (j = 0; j < len; j++) {
|
|
| 168 |
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; |
|
| 169 |
- } |
|
| 170 |
- return 0; |
|
| 171 |
-} |
|
| 172 |
- |
|
| 173 |
-void ZLIB_INTERNAL zmemzero(dest, len) |
|
| 174 |
- Bytef* dest; |
|
| 175 |
- uInt len; |
|
| 176 |
-{
|
|
| 177 |
- if (len == 0) return; |
|
| 178 |
- do {
|
|
| 179 |
- *dest++ = 0; /* ??? to be unrolled */ |
|
| 180 |
- } while (--len != 0); |
|
| 181 |
-} |
|
| 182 |
-#endif |
|
| 183 |
- |
|
| 184 |
-#ifndef Z_SOLO |
|
| 185 |
- |
|
| 186 |
-#ifdef SYS16BIT |
|
| 187 |
- |
|
| 188 |
-#ifdef __TURBOC__ |
|
| 189 |
-/* Turbo C in 16-bit mode */ |
|
| 190 |
- |
|
| 191 |
-# define MY_ZCALLOC |
|
| 192 |
- |
|
| 193 |
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes |
|
| 194 |
- * and farmalloc(64K) returns a pointer with an offset of 8, so we |
|
| 195 |
- * must fix the pointer. Warning: the pointer must be put back to its |
|
| 196 |
- * original form in order to free it, use zcfree(). |
|
| 197 |
- */ |
|
| 198 |
- |
|
| 199 |
-#define MAX_PTR 10 |
|
| 200 |
-/* 10*64K = 640K */ |
|
| 201 |
- |
|
| 202 |
-local int next_ptr = 0; |
|
| 203 |
- |
|
| 204 |
-typedef struct ptr_table_s {
|
|
| 205 |
- voidpf org_ptr; |
|
| 206 |
- voidpf new_ptr; |
|
| 207 |
-} ptr_table; |
|
| 208 |
- |
|
| 209 |
-local ptr_table table[MAX_PTR]; |
|
| 210 |
-/* This table is used to remember the original form of pointers |
|
| 211 |
- * to large buffers (64K). Such pointers are normalized with a zero offset. |
|
| 212 |
- * Since MSDOS is not a preemptive multitasking OS, this table is not |
|
| 213 |
- * protected from concurrent access. This hack doesn't work anyway on |
|
| 214 |
- * a protected system like OS/2. Use Microsoft C instead. |
|
| 215 |
- */ |
|
| 216 |
- |
|
| 217 |
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) |
|
| 218 |
-{
|
|
| 219 |
- voidpf buf; |
|
| 220 |
- ulg bsize = (ulg)items*size; |
|
| 221 |
- |
|
| 222 |
- (void)opaque; |
|
| 223 |
- |
|
| 224 |
- /* If we allocate less than 65520 bytes, we assume that farmalloc |
|
| 225 |
- * will return a usable pointer which doesn't have to be normalized. |
|
| 226 |
- */ |
|
| 227 |
- if (bsize < 65520L) {
|
|
| 228 |
- buf = farmalloc(bsize); |
|
| 229 |
- if (*(ush*)&buf != 0) return buf; |
|
| 230 |
- } else {
|
|
| 231 |
- buf = farmalloc(bsize + 16L); |
|
| 232 |
- } |
|
| 233 |
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL; |
|
| 234 |
- table[next_ptr].org_ptr = buf; |
|
| 235 |
- |
|
| 236 |
- /* Normalize the pointer to seg:0 */ |
|
| 237 |
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; |
|
| 238 |
- *(ush*)&buf = 0; |
|
| 239 |
- table[next_ptr++].new_ptr = buf; |
|
| 240 |
- return buf; |
|
| 241 |
-} |
|
| 242 |
- |
|
| 243 |
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) |
|
| 244 |
-{
|
|
| 245 |
- int n; |
|
| 246 |
- |
|
| 247 |
- (void)opaque; |
|
| 248 |
- |
|
| 249 |
- if (*(ush*)&ptr != 0) { /* object < 64K */
|
|
| 250 |
- farfree(ptr); |
|
| 251 |
- return; |
|
| 252 |
- } |
|
| 253 |
- /* Find the original pointer */ |
|
| 254 |
- for (n = 0; n < next_ptr; n++) {
|
|
| 255 |
- if (ptr != table[n].new_ptr) continue; |
|
| 256 |
- |
|
| 257 |
- farfree(table[n].org_ptr); |
|
| 258 |
- while (++n < next_ptr) {
|
|
| 259 |
- table[n-1] = table[n]; |
|
| 260 |
- } |
|
| 261 |
- next_ptr--; |
|
| 262 |
- return; |
|
| 263 |
- } |
|
| 264 |
- Assert(0, "zcfree: ptr not found"); |
|
| 265 |
-} |
|
| 266 |
- |
|
| 267 |
-#endif /* __TURBOC__ */ |
|
| 268 |
- |
|
| 269 |
- |
|
| 270 |
-#ifdef M_I86 |
|
| 271 |
-/* Microsoft C in 16-bit mode */ |
|
| 272 |
- |
|
| 273 |
-# define MY_ZCALLOC |
|
| 274 |
- |
|
| 275 |
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) |
|
| 276 |
-# define _halloc halloc |
|
| 277 |
-# define _hfree hfree |
|
| 278 |
-#endif |
|
| 279 |
- |
|
| 280 |
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) |
|
| 281 |
-{
|
|
| 282 |
- (void)opaque; |
|
| 283 |
- return _halloc((long)items, size); |
|
| 284 |
-} |
|
| 285 |
- |
|
| 286 |
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) |
|
| 287 |
-{
|
|
| 288 |
- (void)opaque; |
|
| 289 |
- _hfree(ptr); |
|
| 290 |
-} |
|
| 291 |
- |
|
| 292 |
-#endif /* M_I86 */ |
|
| 293 |
- |
|
| 294 |
-#endif /* SYS16BIT */ |
|
| 295 |
- |
|
| 296 |
- |
|
| 297 |
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
|
| 298 |
- |
|
| 299 |
-#ifndef STDC |
|
| 300 |
-extern voidp malloc OF((uInt size)); |
|
| 301 |
-extern voidp calloc OF((uInt items, uInt size)); |
|
| 302 |
-extern void free OF((voidpf ptr)); |
|
| 303 |
-#endif |
|
| 304 |
- |
|
| 305 |
-voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) |
|
| 306 |
- voidpf opaque; |
|
| 307 |
- unsigned items; |
|
| 308 |
- unsigned size; |
|
| 309 |
-{
|
|
| 310 |
- (void)opaque; |
|
| 311 |
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
|
| 312 |
- (voidpf)calloc(items, size); |
|
| 313 |
-} |
|
| 314 |
- |
|
| 315 |
-void ZLIB_INTERNAL zcfree (opaque, ptr) |
|
| 316 |
- voidpf opaque; |
|
| 317 |
- voidpf ptr; |
|
| 318 |
-{
|
|
| 319 |
- (void)opaque; |
|
| 320 |
- free(ptr); |
|
| 321 |
-} |
|
| 322 |
- |
|
| 323 |
-#endif /* MY_ZCALLOC */ |
|
| 324 |
- |
|
| 325 |
-#endif /* !Z_SOLO */ |
| 326 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,271 +0,0 @@ |
| 1 |
-/* zutil.h -- internal interface and configuration of the compression library |
|
| 2 |
- * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler |
|
| 3 |
- * For conditions of distribution and use, see copyright notice in zlib.h |
|
| 4 |
- */ |
|
| 5 |
- |
|
| 6 |
-/* WARNING: this file should *not* be used by applications. It is |
|
| 7 |
- part of the implementation of the compression library and is |
|
| 8 |
- subject to change. Applications should only use zlib.h. |
|
| 9 |
- */ |
|
| 10 |
- |
|
| 11 |
-/* @(#) $Id$ */ |
|
| 12 |
- |
|
| 13 |
-#ifndef ZUTIL_H |
|
| 14 |
-#define ZUTIL_H |
|
| 15 |
- |
|
| 16 |
-#ifdef HAVE_HIDDEN |
|
| 17 |
-# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
|
| 18 |
-#else |
|
| 19 |
-# define ZLIB_INTERNAL |
|
| 20 |
-#endif |
|
| 21 |
- |
|
| 22 |
-#include "zlib.h" |
|
| 23 |
- |
|
| 24 |
-#if defined(STDC) && !defined(Z_SOLO) |
|
| 25 |
-# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
|
| 26 |
-# include <stddef.h> |
|
| 27 |
-# endif |
|
| 28 |
-# include <string.h> |
|
| 29 |
-# include <stdlib.h> |
|
| 30 |
-#endif |
|
| 31 |
- |
|
| 32 |
-#ifdef Z_SOLO |
|
| 33 |
- typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ |
|
| 34 |
-#endif |
|
| 35 |
- |
|
| 36 |
-#ifndef local |
|
| 37 |
-# define local static |
|
| 38 |
-#endif |
|
| 39 |
-/* since "static" is used to mean two completely different things in C, we |
|
| 40 |
- define "local" for the non-static meaning of "static", for readability |
|
| 41 |
- (compile with -Dlocal if your debugger can't find static symbols) */ |
|
| 42 |
- |
|
| 43 |
-typedef unsigned char uch; |
|
| 44 |
-typedef uch FAR uchf; |
|
| 45 |
-typedef unsigned short ush; |
|
| 46 |
-typedef ush FAR ushf; |
|
| 47 |
-typedef unsigned long ulg; |
|
| 48 |
- |
|
| 49 |
-extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ |
|
| 50 |
-/* (size given to avoid silly warnings with Visual C++) */ |
|
| 51 |
- |
|
| 52 |
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
|
| 53 |
- |
|
| 54 |
-#define ERR_RETURN(strm,err) \ |
|
| 55 |
- return (strm->msg = ERR_MSG(err), (err)) |
|
| 56 |
-/* To be used only when the state is known to be valid */ |
|
| 57 |
- |
|
| 58 |
- /* common constants */ |
|
| 59 |
- |
|
| 60 |
-#ifndef DEF_WBITS |
|
| 61 |
-# define DEF_WBITS MAX_WBITS |
|
| 62 |
-#endif |
|
| 63 |
-/* default windowBits for decompression. MAX_WBITS is for compression only */ |
|
| 64 |
- |
|
| 65 |
-#if MAX_MEM_LEVEL >= 8 |
|
| 66 |
-# define DEF_MEM_LEVEL 8 |
|
| 67 |
-#else |
|
| 68 |
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL |
|
| 69 |
-#endif |
|
| 70 |
-/* default memLevel */ |
|
| 71 |
- |
|
| 72 |
-#define STORED_BLOCK 0 |
|
| 73 |
-#define STATIC_TREES 1 |
|
| 74 |
-#define DYN_TREES 2 |
|
| 75 |
-/* The three kinds of block type */ |
|
| 76 |
- |
|
| 77 |
-#define MIN_MATCH 3 |
|
| 78 |
-#define MAX_MATCH 258 |
|
| 79 |
-/* The minimum and maximum match lengths */ |
|
| 80 |
- |
|
| 81 |
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ |
|
| 82 |
- |
|
| 83 |
- /* target dependencies */ |
|
| 84 |
- |
|
| 85 |
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
|
| 86 |
-# define OS_CODE 0x00 |
|
| 87 |
-# ifndef Z_SOLO |
|
| 88 |
-# if defined(__TURBOC__) || defined(__BORLANDC__) |
|
| 89 |
-# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
|
| 90 |
- /* Allow compilation with ANSI keywords only enabled */ |
|
| 91 |
- void _Cdecl farfree( void *block ); |
|
| 92 |
- void *_Cdecl farmalloc( unsigned long nbytes ); |
|
| 93 |
-# else |
|
| 94 |
-# include <alloc.h> |
|
| 95 |
-# endif |
|
| 96 |
-# else /* MSC or DJGPP */ |
|
| 97 |
-# include <malloc.h> |
|
| 98 |
-# endif |
|
| 99 |
-# endif |
|
| 100 |
-#endif |
|
| 101 |
- |
|
| 102 |
-#ifdef AMIGA |
|
| 103 |
-# define OS_CODE 1 |
|
| 104 |
-#endif |
|
| 105 |
- |
|
| 106 |
-#if defined(VAXC) || defined(VMS) |
|
| 107 |
-# define OS_CODE 2 |
|
| 108 |
-# define F_OPEN(name, mode) \ |
|
| 109 |
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") |
|
| 110 |
-#endif |
|
| 111 |
- |
|
| 112 |
-#ifdef __370__ |
|
| 113 |
-# if __TARGET_LIB__ < 0x20000000 |
|
| 114 |
-# define OS_CODE 4 |
|
| 115 |
-# elif __TARGET_LIB__ < 0x40000000 |
|
| 116 |
-# define OS_CODE 11 |
|
| 117 |
-# else |
|
| 118 |
-# define OS_CODE 8 |
|
| 119 |
-# endif |
|
| 120 |
-#endif |
|
| 121 |
- |
|
| 122 |
-#if defined(ATARI) || defined(atarist) |
|
| 123 |
-# define OS_CODE 5 |
|
| 124 |
-#endif |
|
| 125 |
- |
|
| 126 |
-#ifdef OS2 |
|
| 127 |
-# define OS_CODE 6 |
|
| 128 |
-# if defined(M_I86) && !defined(Z_SOLO) |
|
| 129 |
-# include <malloc.h> |
|
| 130 |
-# endif |
|
| 131 |
-#endif |
|
| 132 |
- |
|
| 133 |
-#if defined(MACOS) || defined(TARGET_OS_MAC) |
|
| 134 |
-# define OS_CODE 7 |
|
| 135 |
-# ifndef Z_SOLO |
|
| 136 |
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
|
| 137 |
-# include <unix.h> /* for fdopen */ |
|
| 138 |
-# else |
|
| 139 |
-# ifndef fdopen |
|
| 140 |
-# define fdopen(fd,mode) NULL /* No fdopen() */ |
|
| 141 |
-# endif |
|
| 142 |
-# endif |
|
| 143 |
-# endif |
|
| 144 |
-#endif |
|
| 145 |
- |
|
| 146 |
-#ifdef __acorn |
|
| 147 |
-# define OS_CODE 13 |
|
| 148 |
-#endif |
|
| 149 |
- |
|
| 150 |
-#if defined(WIN32) && !defined(__CYGWIN__) |
|
| 151 |
-# define OS_CODE 10 |
|
| 152 |
-#endif |
|
| 153 |
- |
|
| 154 |
-#ifdef _BEOS_ |
|
| 155 |
-# define OS_CODE 16 |
|
| 156 |
-#endif |
|
| 157 |
- |
|
| 158 |
-#ifdef __TOS_OS400__ |
|
| 159 |
-# define OS_CODE 18 |
|
| 160 |
-#endif |
|
| 161 |
- |
|
| 162 |
-#ifdef __APPLE__ |
|
| 163 |
-# define OS_CODE 19 |
|
| 164 |
-#endif |
|
| 165 |
- |
|
| 166 |
-#if defined(_BEOS_) || defined(RISCOS) |
|
| 167 |
-# define fdopen(fd,mode) NULL /* No fdopen() */ |
|
| 168 |
-#endif |
|
| 169 |
- |
|
| 170 |
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX |
|
| 171 |
-# if defined(_WIN32_WCE) |
|
| 172 |
-# define fdopen(fd,mode) NULL /* No fdopen() */ |
|
| 173 |
-# ifndef _PTRDIFF_T_DEFINED |
|
| 174 |
- typedef int ptrdiff_t; |
|
| 175 |
-# define _PTRDIFF_T_DEFINED |
|
| 176 |
-# endif |
|
| 177 |
-# else |
|
| 178 |
-# define fdopen(fd,type) _fdopen(fd,type) |
|
| 179 |
-# endif |
|
| 180 |
-#endif |
|
| 181 |
- |
|
| 182 |
-#if defined(__BORLANDC__) && !defined(MSDOS) |
|
| 183 |
- #pragma warn -8004 |
|
| 184 |
- #pragma warn -8008 |
|
| 185 |
- #pragma warn -8066 |
|
| 186 |
-#endif |
|
| 187 |
- |
|
| 188 |
-/* provide prototypes for these when building zlib without LFS */ |
|
| 189 |
-#if !defined(_WIN32) && \ |
|
| 190 |
- (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
|
| 191 |
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
|
| 192 |
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
|
| 193 |
-#endif |
|
| 194 |
- |
|
| 195 |
- /* common defaults */ |
|
| 196 |
- |
|
| 197 |
-#ifndef OS_CODE |
|
| 198 |
-# define OS_CODE 3 /* assume Unix */ |
|
| 199 |
-#endif |
|
| 200 |
- |
|
| 201 |
-#ifndef F_OPEN |
|
| 202 |
-# define F_OPEN(name, mode) fopen((name), (mode)) |
|
| 203 |
-#endif |
|
| 204 |
- |
|
| 205 |
- /* functions */ |
|
| 206 |
- |
|
| 207 |
-#if defined(pyr) || defined(Z_SOLO) |
|
| 208 |
-# define NO_MEMCPY |
|
| 209 |
-#endif |
|
| 210 |
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
|
| 211 |
- /* Use our own functions for small and medium model with MSC <= 5.0. |
|
| 212 |
- * You may have to use the same strategy for Borland C (untested). |
|
| 213 |
- * The __SC__ check is for Symantec. |
|
| 214 |
- */ |
|
| 215 |
-# define NO_MEMCPY |
|
| 216 |
-#endif |
|
| 217 |
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) |
|
| 218 |
-# define HAVE_MEMCPY |
|
| 219 |
-#endif |
|
| 220 |
-#ifdef HAVE_MEMCPY |
|
| 221 |
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ |
|
| 222 |
-# define zmemcpy _fmemcpy |
|
| 223 |
-# define zmemcmp _fmemcmp |
|
| 224 |
-# define zmemzero(dest, len) _fmemset(dest, 0, len) |
|
| 225 |
-# else |
|
| 226 |
-# define zmemcpy memcpy |
|
| 227 |
-# define zmemcmp memcmp |
|
| 228 |
-# define zmemzero(dest, len) memset(dest, 0, len) |
|
| 229 |
-# endif |
|
| 230 |
-#else |
|
| 231 |
- void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); |
|
| 232 |
- int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); |
|
| 233 |
- void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); |
|
| 234 |
-#endif |
|
| 235 |
- |
|
| 236 |
-/* Diagnostic functions */ |
|
| 237 |
-#ifdef ZLIB_DEBUG |
|
| 238 |
-# include <stdio.h> |
|
| 239 |
- extern int ZLIB_INTERNAL z_verbose; |
|
| 240 |
- extern void ZLIB_INTERNAL z_error OF((char *m)); |
|
| 241 |
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
|
| 242 |
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
|
| 243 |
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
|
| 244 |
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
|
| 245 |
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
|
| 246 |
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
|
| 247 |
-#else |
|
| 248 |
-# define Assert(cond,msg) |
|
| 249 |
-# define Trace(x) |
|
| 250 |
-# define Tracev(x) |
|
| 251 |
-# define Tracevv(x) |
|
| 252 |
-# define Tracec(c,x) |
|
| 253 |
-# define Tracecv(c,x) |
|
| 254 |
-#endif |
|
| 255 |
- |
|
| 256 |
-#ifndef Z_SOLO |
|
| 257 |
- voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, |
|
| 258 |
- unsigned size)); |
|
| 259 |
- void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); |
|
| 260 |
-#endif |
|
| 261 |
- |
|
| 262 |
-#define ZALLOC(strm, items, size) \ |
|
| 263 |
- (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
|
| 264 |
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
|
| 265 |
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
|
| 266 |
- |
|
| 267 |
-/* Reverse the bytes in a 32-bit value */ |
|
| 268 |
-#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ |
|
| 269 |
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) |
|
| 270 |
- |
|
| 271 |
-#endif /* ZUTIL_H */ |