1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 01_remove_zlib_src.dpatch by <edd@xmcorsairs.wu-wien.ac.at>
4 ## All lines beginning with `## DP:' are a description of the patch.
9 diff -ruN seqinr.orig/src/adler32.c seqinr/src/adler32.c
10 --- seqinr.orig/src/adler32.c 2007-04-19 11:40:19.000000000 +0200
11 +++ seqinr/src/adler32.c 1970-01-01 01:00:00.000000000 +0100
13 -/* adler32.c -- compute the Adler-32 checksum of a data stream
14 - * Copyright (C) 1995-2004 Mark Adler
15 - * For conditions of distribution and use, see copyright notice in zlib.h
18 -/* @(#) $Id: adler32.c,v 1.1.2.1 2007-04-19 09:40:17 penel Exp $ */
20 -#define ZLIB_INTERNAL
23 -#define BASE 65521UL /* largest prime smaller than 65536 */
25 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
27 -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
28 -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
29 -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
30 -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
31 -#define DO16(buf) DO8(buf,0); DO8(buf,8);
33 -/* use NO_DIVIDE if your processor does not do division in hardware */
37 - if (a >= (BASE << 16)) a -= (BASE << 16); \
38 - if (a >= (BASE << 15)) a -= (BASE << 15); \
39 - if (a >= (BASE << 14)) a -= (BASE << 14); \
40 - if (a >= (BASE << 13)) a -= (BASE << 13); \
41 - if (a >= (BASE << 12)) a -= (BASE << 12); \
42 - if (a >= (BASE << 11)) a -= (BASE << 11); \
43 - if (a >= (BASE << 10)) a -= (BASE << 10); \
44 - if (a >= (BASE << 9)) a -= (BASE << 9); \
45 - if (a >= (BASE << 8)) a -= (BASE << 8); \
46 - if (a >= (BASE << 7)) a -= (BASE << 7); \
47 - if (a >= (BASE << 6)) a -= (BASE << 6); \
48 - if (a >= (BASE << 5)) a -= (BASE << 5); \
49 - if (a >= (BASE << 4)) a -= (BASE << 4); \
50 - if (a >= (BASE << 3)) a -= (BASE << 3); \
51 - if (a >= (BASE << 2)) a -= (BASE << 2); \
52 - if (a >= (BASE << 1)) a -= (BASE << 1); \
53 - if (a >= BASE) a -= BASE; \
57 - if (a >= (BASE << 4)) a -= (BASE << 4); \
58 - if (a >= (BASE << 3)) a -= (BASE << 3); \
59 - if (a >= (BASE << 2)) a -= (BASE << 2); \
60 - if (a >= (BASE << 1)) a -= (BASE << 1); \
61 - if (a >= BASE) a -= BASE; \
64 -# define MOD(a) a %= BASE
65 -# define MOD4(a) a %= BASE
68 -/* ========================================================================= */
69 -uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
79 - /* split Adler-32 into component sums */
80 - sum2 = (adler >> 16) & 0xffff;
83 - /* in case user likes doing a byte at a time, keep it fast */
91 - return adler | (sum2 << 16);
94 - /* initial Adler-32 value (deferred check for len == 1 speed) */
98 - /* in case short lengths are provided, keep it somewhat fast */
106 - MOD4(sum2); /* only added so many BASE's */
107 - return adler | (sum2 << 16);
110 - /* do length NMAX blocks -- requires just one modulo operation */
111 - while (len >= NMAX) {
113 - n = NMAX / 16; /* NMAX is divisible by 16 */
115 - DO16(buf); /* 16 sums unrolled */
122 - /* do remaining bytes (less than NMAX, still just one modulo) */
123 - if (len) { /* avoid modulos if none remaining */
124 - while (len >= 16) {
137 - /* return recombined sums */
138 - return adler | (sum2 << 16);
141 -/* ========================================================================= */
142 -uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2)
149 - unsigned long sum1;
150 - unsigned long sum2;
153 - /* the derivation of this formula is left as an exercise for the reader */
154 - rem = (unsigned)(len2 % BASE);
155 - sum1 = adler1 & 0xffff;
158 - sum1 += (adler2 & 0xffff) + BASE - 1;
159 - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
160 - if (sum1 > BASE) sum1 -= BASE;
161 - if (sum1 > BASE) sum1 -= BASE;
162 - if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
163 - if (sum2 > BASE) sum2 -= BASE;
164 - return sum1 | (sum2 << 16);
166 diff -ruN seqinr.orig/src/compress.c seqinr/src/compress.c
167 --- seqinr.orig/src/compress.c 2007-04-19 11:40:19.000000000 +0200
168 +++ seqinr/src/compress.c 1970-01-01 01:00:00.000000000 +0100
170 -/* compress.c -- compress a memory buffer
171 - * Copyright (C) 1995-2003 Jean-loup Gailly.
172 - * For conditions of distribution and use, see copyright notice in zlib.h
175 -/* @(#) $Id: compress.c,v 1.1.2.1 2007-04-19 09:40:17 penel Exp $ */
177 -#define ZLIB_INTERNAL
180 -/* ===========================================================================
181 - Compresses the source buffer into the destination buffer. The level
182 - parameter has the same meaning as in deflateInit. sourceLen is the byte
183 - length of the source buffer. Upon entry, destLen is the total size of the
184 - destination buffer, which must be at least 0.1% larger than sourceLen plus
185 - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
187 - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
188 - memory, Z_BUF_ERROR if there was not enough room in the output buffer,
189 - Z_STREAM_ERROR if the level parameter is invalid.
191 -int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source,
192 - uLong sourceLen, int level)
196 - const Bytef *source;
204 - stream.next_in = (Bytef*)source;
205 - stream.avail_in = (uInt)sourceLen;
207 - /* Check for source > 64K on 16-bit machine: */
208 - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
210 - stream.next_out = dest;
211 - stream.avail_out = (uInt)*destLen;
212 - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
214 - stream.zalloc = (alloc_func)0;
215 - stream.zfree = (free_func)0;
216 - stream.opaque = (voidpf)0;
218 - err = deflateInit(&stream, level);
219 - if (err != Z_OK) return err;
221 - err = deflate(&stream, Z_FINISH);
222 - if (err != Z_STREAM_END) {
223 - deflateEnd(&stream);
224 - return err == Z_OK ? Z_BUF_ERROR : err;
226 - *destLen = stream.total_out;
228 - err = deflateEnd(&stream);
232 -/* ===========================================================================
234 -int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
238 - const Bytef *source;
242 - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
245 -/* ===========================================================================
246 - If the default memLevel or windowBits for deflateInit() is changed, then
247 - this function needs to be updated.
249 -uLong ZEXPORT compressBound (uLong sourceLen)
250 -/* uLong sourceLen; */
252 - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
254 diff -ruN seqinr.orig/src/crc32.c seqinr/src/crc32.c
255 --- seqinr.orig/src/crc32.c 2007-04-19 11:40:19.000000000 +0200
256 +++ seqinr/src/crc32.c 1970-01-01 01:00:00.000000000 +0100
258 -/* crc32.c -- compute the CRC-32 of a data stream
259 - * Copyright (C) 1995-2005 Mark Adler
260 - * For conditions of distribution and use, see copyright notice in zlib.h
262 - * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
263 - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
264 - * tables for updating the shift register in one step with three exclusive-ors
265 - * instead of four steps with four exclusive-ors. This results in about a
266 - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
269 -/* @(#) $Id: crc32.c,v 1.1.2.1 2007-04-19 09:40:17 penel Exp $ */
272 - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
273 - protection on the static variables used to control the first-use generation
274 - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
275 - first call get_crc_table() to initialize the tables before allowing more than
276 - one thread to use crc32().
281 -# ifndef DYNAMIC_CRC_TABLE
282 -# define DYNAMIC_CRC_TABLE
283 -# endif /* !DYNAMIC_CRC_TABLE */
284 -#endif /* MAKECRCH */
286 -#include "zutil.h" /* for STDC and FAR definitions */
288 -#define local static
290 -/* Find a four-byte integer type for crc32_little() and crc32_big(). */
292 -# ifdef STDC /* need ANSI C limits.h to determine sizes */
293 -# include <limits.h>
295 -# if (UINT_MAX == 0xffffffffUL)
296 - typedef unsigned int u4;
298 -# if (ULONG_MAX == 0xffffffffUL)
299 - typedef unsigned long u4;
301 -# if (USHRT_MAX == 0xffffffffUL)
302 - typedef unsigned short u4;
304 -# undef BYFOUR /* can't find a four-byte integer type! */
309 -#endif /* !NOBYFOUR */
311 -/* Definitions for doing the crc four data bytes at a time. */
313 -# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
314 - (((w)&0xff00)<<8)+(((w)&0xff)<<24))
315 - local unsigned long crc32_little OF((unsigned long,
316 - const unsigned char FAR *, unsigned));
317 - local unsigned long crc32_big OF((unsigned long,
318 - const unsigned char FAR *, unsigned));
324 -/* Local functions for crc concatenation */
325 -local unsigned long gf2_matrix_times OF((unsigned long *mat,
326 - unsigned long vec));
327 -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
329 -#ifdef DYNAMIC_CRC_TABLE
331 -local volatile int crc_table_empty = 1;
332 -local unsigned long FAR crc_table[TBLS][256];
333 -local void make_crc_table OF((void));
335 - local void write_table OF((FILE *, const unsigned long FAR *));
336 -#endif /* MAKECRCH */
338 - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
339 - 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.
341 - Polynomials over GF(2) are represented in binary, one bit per coefficient,
342 - with the lowest powers in the most significant bit. Then adding polynomials
343 - is just exclusive-or, and multiplying a polynomial by x is a right shift by
344 - one. If we call the above polynomial p, and represent a byte as the
345 - polynomial q, also with the lowest power in the most significant bit (so the
346 - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
347 - where a mod b means the remainder after dividing a by b.
349 - This calculation is done using the shift-register method of multiplying and
350 - taking the remainder. The register is initialized to zero, and for each
351 - incoming bit, x^32 is added mod p to the register if the bit is a one (where
352 - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
353 - x (which is shifting right by one and adding x^32 mod p if the bit shifted
354 - out is a one). We start with the highest power (least significant bit) of
355 - q and repeat for all eight bits of q.
357 - The first table is simply the CRC of all possible eight bit values. This is
358 - all the information needed to generate CRCs on data a byte at a time for all
359 - combinations of CRC register values and incoming bytes. The remaining tables
360 - allow for word-at-a-time CRC calculation for both big-endian and little-
361 - endian machines, where a word is four bytes.
363 -local void make_crc_table()
367 - unsigned long poly; /* polynomial exclusive-or pattern */
368 - /* terms of polynomial defining this crc (except x^32): */
369 - static volatile int first = 1; /* flag to limit concurrent making */
370 - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
372 - /* See if another task is already doing this (not thread-safe, but better
373 - than nothing -- significantly reduces duration of vulnerability in
374 - case the advice about DYNAMIC_CRC_TABLE is ignored) */
378 - /* make exclusive-or pattern from polynomial (0xedb88320UL) */
380 - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
381 - poly |= 1UL << (31 - p[n]);
383 - /* generate a crc for every 8-bit value */
384 - for (n = 0; n < 256; n++) {
385 - c = (unsigned long)n;
386 - for (k = 0; k < 8; k++)
387 - c = c & 1 ? poly ^ (c >> 1) : c >> 1;
388 - crc_table[0][n] = c;
392 - /* generate crc for each value followed by one, two, and three zeros,
393 - and then the byte reversal of those as well as the first table */
394 - for (n = 0; n < 256; n++) {
395 - c = crc_table[0][n];
396 - crc_table[4][n] = REV(c);
397 - for (k = 1; k < 4; k++) {
398 - c = crc_table[0][c & 0xff] ^ (c >> 8);
399 - crc_table[k][n] = c;
400 - crc_table[k + 4][n] = REV(c);
405 - crc_table_empty = 0;
407 - else { /* not first */
408 - /* wait for the other guy to finish (not efficient, but rare) */
409 - while (crc_table_empty)
414 - /* write out CRC tables to crc32.h */
418 - out = fopen("crc32.h", "w");
419 - if (out == NULL) return;
420 - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
421 - fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
422 - fprintf(out, "local const unsigned long FAR ");
423 - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
424 - write_table(out, crc_table[0]);
426 - fprintf(out, "#ifdef BYFOUR\n");
427 - for (k = 1; k < 8; k++) {
428 - fprintf(out, " },\n {\n");
429 - write_table(out, crc_table[k]);
431 - fprintf(out, "#endif\n");
432 -# endif /* BYFOUR */
433 - fprintf(out, " }\n};\n");
436 -#endif /* MAKECRCH */
440 -local void write_table(out, table)
442 - const unsigned long FAR *table;
446 - for (n = 0; n < 256; n++)
447 - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
448 - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
450 -#endif /* MAKECRCH */
452 -#else /* !DYNAMIC_CRC_TABLE */
453 -/* ========================================================================
454 - * Tables of CRC-32s of all single-byte values, made by make_crc_table().
457 -#endif /* DYNAMIC_CRC_TABLE */
459 -/* =========================================================================
460 - * This function can be used by asm versions of crc32()
462 -const unsigned long FAR * ZEXPORT get_crc_table()
464 -#ifdef DYNAMIC_CRC_TABLE
465 - if (crc_table_empty)
467 -#endif /* DYNAMIC_CRC_TABLE */
468 - return (const unsigned long FAR *)crc_table;
471 -/* ========================================================================= */
472 -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
473 -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
475 -/* ========================================================================= */
476 -unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
480 - const unsigned char FAR *buf;
484 - if (buf == Z_NULL) return 0UL;
486 -#ifdef DYNAMIC_CRC_TABLE
487 - if (crc_table_empty)
489 -#endif /* DYNAMIC_CRC_TABLE */
492 - if (sizeof(void *) == sizeof(ptrdiff_t)) {
496 - if (*((unsigned char *)(&endian)))
497 - return crc32_little(crc, buf, len);
499 - return crc32_big(crc, buf, len);
502 - crc = crc ^ 0xffffffffUL;
510 - return crc ^ 0xffffffffUL;
515 -/* ========================================================================= */
516 -#define DOLIT4 c ^= *buf4++; \
517 - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
518 - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
519 -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
521 -/* ========================================================================= */
522 -local unsigned long crc32_little(unsigned long crc, const unsigned char FAR *buf, unsigned len)
525 - const unsigned char FAR *buf;
530 - register const u4 FAR *buf4;
534 - while (len && ((ptrdiff_t)buf & 3)) {
535 - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
539 - buf4 = (const u4 FAR *)(const void FAR *)buf;
540 - while (len >= 32) {
548 - buf = (const unsigned char FAR *)buf4;
551 - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
554 - return (unsigned long)c;
557 -/* ========================================================================= */
558 -#define DOBIG4 c ^= *++buf4; \
559 - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
560 - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
561 -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
563 -/* ========================================================================= */
564 -local unsigned long crc32_big(unsigned long crc,
565 - const unsigned char FAR *buf, unsigned len)
568 - const unsigned char FAR *buf;
573 - register const u4 FAR *buf4;
577 - while (len && ((ptrdiff_t)buf & 3)) {
578 - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
582 - buf4 = (const u4 FAR *)(const void FAR *)buf;
584 - while (len >= 32) {
593 - buf = (const unsigned char FAR *)buf4;
596 - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
599 - return (unsigned long)(REV(c));
604 -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
606 -/* ========================================================================= */
607 -local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec)
609 - unsigned long *mat;
625 -/* ========================================================================= */
626 -local void gf2_matrix_square(unsigned long *square, unsigned long *mat)
628 - unsigned long *square;
629 - unsigned long *mat;
634 - for (n = 0; n < GF2_DIM; n++)
635 - square[n] = gf2_matrix_times(mat, mat[n]);
638 -/* ========================================================================= */
639 -uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
648 - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
649 - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
651 - /* degenerate case */
655 - /* put operator for one zero bit in odd */
656 - odd[0] = 0xedb88320L; /* CRC-32 polynomial */
658 - for (n = 1; n < GF2_DIM; n++) {
663 - /* put operator for two zero bits in even */
664 - gf2_matrix_square(even, odd);
666 - /* put operator for four zero bits in odd */
667 - gf2_matrix_square(odd, even);
669 - /* apply len2 zeros to crc1 (first square will put the operator for one
670 - zero byte, eight zero bits, in even) */
672 - /* apply zeros operator for this bit of len2 */
673 - gf2_matrix_square(even, odd);
675 - crc1 = gf2_matrix_times(even, crc1);
678 - /* if no more bits set, then done */
682 - /* another iteration of the loop with odd and even swapped */
683 - gf2_matrix_square(odd, even);
685 - crc1 = gf2_matrix_times(odd, crc1);
688 - /* if no more bits set, then done */
689 - } while (len2 != 0);
691 - /* return combined crc */
695 diff -ruN seqinr.orig/src/crc32.h seqinr/src/crc32.h
696 --- seqinr.orig/src/crc32.h 2007-04-19 11:40:19.000000000 +0200
697 +++ seqinr/src/crc32.h 1970-01-01 01:00:00.000000000 +0100
699 -/* crc32.h -- tables for rapid CRC calculation
700 - * Generated automatically by crc32.c
703 -local const unsigned long FAR crc_table[TBLS][256] =
706 - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
707 - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
708 - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
709 - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
710 - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
711 - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
712 - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
713 - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
714 - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
715 - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
716 - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
717 - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
718 - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
719 - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
720 - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
721 - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
722 - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
723 - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
724 - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
725 - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
726 - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
727 - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
728 - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
729 - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
730 - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
731 - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
732 - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
733 - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
734 - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
735 - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
736 - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
737 - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
738 - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
739 - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
740 - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
741 - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
742 - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
743 - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
744 - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
745 - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
746 - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
747 - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
748 - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
749 - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
750 - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
751 - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
752 - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
753 - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
754 - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
755 - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
756 - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
761 - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
762 - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
763 - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
764 - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
765 - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
766 - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
767 - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
768 - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
769 - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
770 - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
771 - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
772 - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
773 - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
774 - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
775 - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
776 - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
777 - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
778 - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
779 - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
780 - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
781 - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
782 - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
783 - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
784 - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
785 - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
786 - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
787 - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
788 - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
789 - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
790 - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
791 - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
792 - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
793 - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
794 - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
795 - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
796 - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
797 - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
798 - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
799 - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
800 - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
801 - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
802 - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
803 - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
804 - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
805 - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
806 - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
807 - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
808 - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
809 - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
810 - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
811 - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
815 - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
816 - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
817 - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
818 - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
819 - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
820 - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
821 - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
822 - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
823 - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
824 - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
825 - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
826 - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
827 - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
828 - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
829 - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
830 - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
831 - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
832 - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
833 - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
834 - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
835 - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
836 - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
837 - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
838 - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
839 - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
840 - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
841 - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
842 - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
843 - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
844 - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
845 - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
846 - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
847 - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
848 - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
849 - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
850 - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
851 - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
852 - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
853 - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
854 - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
855 - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
856 - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
857 - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
858 - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
859 - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
860 - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
861 - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
862 - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
863 - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
864 - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
865 - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
869 - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
870 - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
871 - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
872 - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
873 - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
874 - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
875 - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
876 - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
877 - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
878 - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
879 - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
880 - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
881 - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
882 - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
883 - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
884 - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
885 - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
886 - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
887 - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
888 - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
889 - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
890 - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
891 - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
892 - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
893 - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
894 - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
895 - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
896 - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
897 - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
898 - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
899 - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
900 - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
901 - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
902 - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
903 - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
904 - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
905 - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
906 - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
907 - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
908 - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
909 - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
910 - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
911 - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
912 - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
913 - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
914 - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
915 - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
916 - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
917 - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
918 - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
919 - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
923 - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
924 - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
925 - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
926 - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
927 - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
928 - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
929 - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
930 - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
931 - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
932 - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
933 - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
934 - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
935 - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
936 - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
937 - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
938 - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
939 - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
940 - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
941 - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
942 - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
943 - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
944 - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
945 - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
946 - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
947 - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
948 - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
949 - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
950 - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
951 - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
952 - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
953 - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
954 - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
955 - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
956 - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
957 - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
958 - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
959 - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
960 - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
961 - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
962 - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
963 - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
964 - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
965 - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
966 - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
967 - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
968 - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
969 - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
970 - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
971 - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
972 - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
973 - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
977 - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
978 - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
979 - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
980 - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
981 - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
982 - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
983 - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
984 - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
985 - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
986 - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
987 - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
988 - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
989 - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
990 - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
991 - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
992 - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
993 - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
994 - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
995 - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
996 - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
997 - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
998 - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
999 - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
1000 - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
1001 - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
1002 - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
1003 - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
1004 - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
1005 - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
1006 - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
1007 - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
1008 - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
1009 - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
1010 - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
1011 - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
1012 - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
1013 - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
1014 - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
1015 - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
1016 - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
1017 - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
1018 - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
1019 - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
1020 - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
1021 - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
1022 - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
1023 - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
1024 - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
1025 - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
1026 - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
1027 - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
1031 - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
1032 - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
1033 - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
1034 - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
1035 - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
1036 - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
1037 - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
1038 - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
1039 - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
1040 - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
1041 - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
1042 - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
1043 - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
1044 - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
1045 - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
1046 - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
1047 - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
1048 - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
1049 - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
1050 - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
1051 - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
1052 - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
1053 - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
1054 - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
1055 - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
1056 - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
1057 - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
1058 - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
1059 - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
1060 - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
1061 - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
1062 - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
1063 - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
1064 - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
1065 - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
1066 - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
1067 - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
1068 - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
1069 - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
1070 - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
1071 - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
1072 - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
1073 - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
1074 - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
1075 - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
1076 - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
1077 - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
1078 - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
1079 - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
1080 - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
1081 - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
1085 - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
1086 - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
1087 - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
1088 - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
1089 - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
1090 - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
1091 - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
1092 - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
1093 - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
1094 - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
1095 - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
1096 - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
1097 - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
1098 - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
1099 - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
1100 - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
1101 - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
1102 - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
1103 - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
1104 - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
1105 - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
1106 - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
1107 - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
1108 - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
1109 - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
1110 - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
1111 - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
1112 - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
1113 - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
1114 - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
1115 - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
1116 - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
1117 - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
1118 - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
1119 - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
1120 - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
1121 - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
1122 - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
1123 - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
1124 - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
1125 - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
1126 - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
1127 - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
1128 - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
1129 - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
1130 - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
1131 - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
1132 - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
1133 - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
1134 - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
1135 - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
1140 diff -ruN seqinr.orig/src/deflate.c seqinr/src/deflate.c
1141 --- seqinr.orig/src/deflate.c 2007-04-19 11:40:19.000000000 +0200
1142 +++ seqinr/src/deflate.c 1970-01-01 01:00:00.000000000 +0100
1144 -/* deflate.c -- compress data using the deflation algorithm
1145 - * Copyright (C) 1995-2005 Jean-loup Gailly.
1146 - * For conditions of distribution and use, see copyright notice in zlib.h
1152 - * The "deflation" process depends on being able to identify portions
1153 - * of the input text which are identical to earlier input (within a
1154 - * sliding window trailing behind the input currently being processed).
1156 - * The most straightforward technique turns out to be the fastest for
1157 - * most input files: try all possible matches and select the longest.
1158 - * The key feature of this algorithm is that insertions into the string
1159 - * dictionary are very simple and thus fast, and deletions are avoided
1160 - * completely. Insertions are performed at each input character, whereas
1161 - * string matches are performed only when the previous match ends. So it
1162 - * is preferable to spend more time in matches to allow very fast string
1163 - * insertions and avoid deletions. The matching algorithm for small
1164 - * strings is inspired from that of Rabin & Karp. A brute force approach
1165 - * is used to find longer strings when a small match has been found.
1166 - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
1167 - * (by Leonid Broukhis).
1168 - * A previous version of this file used a more sophisticated algorithm
1169 - * (by Fiala and Greene) which is guaranteed to run in linear amortized
1170 - * time, but has a larger average cost, uses more memory and is patented.
1171 - * However the F&G algorithm may be faster for some highly redundant
1172 - * files if the parameter max_chain_length (described below) is too large.
1174 - * ACKNOWLEDGEMENTS
1176 - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
1177 - * I found it in 'freeze' written by Leonid Broukhis.
1178 - * Thanks to many people for bug reports and testing.
1182 - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
1183 - * Available in http://www.ietf.org/rfc/rfc1951.txt
1185 - * A description of the Rabin and Karp algorithm is given in the book
1186 - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
1188 - * Fiala,E.R., and Greene,D.H.
1189 - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
1193 -/* @(#) $Id: deflate.c,v 1.1.2.1 2007-04-19 09:40:17 penel Exp $ */
1195 -#include "deflate.h"
1197 -const char deflate_copyright[] =
1198 - " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
1200 - If you use the zlib library in a product, an acknowledgment is welcome
1201 - in the documentation of your product. If for some reason you cannot
1202 - include such an acknowledgment, I would appreciate that you keep this
1203 - copyright string in the executable of your product.
1206 -/* ===========================================================================
1207 - * Function prototypes.
1210 - need_more, /* block not completed, need more input or more output */
1211 - block_done, /* block flush performed */
1212 - finish_started, /* finish started, need only more output at next deflate */
1213 - finish_done /* finish done, accept no more input or output */
1216 -typedef block_state (*compress_func) OF((deflate_state *s, int flush));
1217 -/* Compression function. Returns the block state after the call. */
1219 -local void fill_window OF((deflate_state *s));
1220 -local block_state deflate_stored OF((deflate_state *s, int flush));
1221 -local block_state deflate_fast OF((deflate_state *s, int flush));
1223 -local block_state deflate_slow OF((deflate_state *s, int flush));
1225 -local void lm_init OF((deflate_state *s));
1226 -local void putShortMSB OF((deflate_state *s, uInt b));
1227 -local void flush_pending OF((z_streamp strm));
1228 -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
1231 - void match_init OF((void)); /* asm code initialization */
1232 - uInt longest_match OF((deflate_state *s, IPos cur_match));
1234 -local uInt longest_match OF((deflate_state *s, IPos cur_match));
1237 -local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
1240 -local void check_match OF((deflate_state *s, IPos start, IPos match,
1244 -/* ===========================================================================
1249 -/* Tail of hash chains */
1252 -# define TOO_FAR 4096
1254 -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
1256 -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
1257 -/* Minimum amount of lookahead, except at the end of the input file.
1258 - * See deflate.c for comments about the MIN_MATCH+1.
1261 -/* Values for max_lazy_match, good_match and max_chain_length, depending on
1262 - * the desired pack level (0..9). The values given below have been tuned to
1263 - * exclude worst case performance for pathological files. Better values may be
1264 - * found for specific files.
1266 -typedef struct config_s {
1267 - ush good_length; /* reduce lazy search above this match length */
1268 - ush max_lazy; /* do not perform lazy search above this match length */
1269 - ush nice_length; /* quit search above this match length */
1271 - compress_func func;
1275 -local const config configuration_table[2] = {
1276 -/* good lazy nice chain */
1277 -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
1278 -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
1280 -local const config configuration_table[10] = {
1281 -/* good lazy nice chain */
1282 -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
1283 -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
1284 -/* 2 */ {4, 5, 16, 8, deflate_fast},
1285 -/* 3 */ {4, 6, 32, 32, deflate_fast},
1287 -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
1288 -/* 5 */ {8, 16, 32, 32, deflate_slow},
1289 -/* 6 */ {8, 16, 128, 128, deflate_slow},
1290 -/* 7 */ {8, 32, 128, 256, deflate_slow},
1291 -/* 8 */ {32, 128, 258, 1024, deflate_slow},
1292 -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
1295 -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
1296 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
1301 -/* result of memcmp for equal strings */
1303 -#ifndef NO_DUMMY_DECL
1304 -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
1307 -/* ===========================================================================
1308 - * Update a hash value with the given input byte
1309 - * IN assertion: all calls to to UPDATE_HASH are made with consecutive
1310 - * input characters, so that a running hash key can be computed from the
1311 - * previous key instead of complete recalculation each time.
1313 -#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
1316 -/* ===========================================================================
1317 - * Insert string str in the dictionary and set match_head to the previous head
1318 - * of the hash chain (the most recent string with same hash key). Return
1319 - * the previous length of the hash chain.
1320 - * If this file is compiled with -DFASTEST, the compression level is forced
1321 - * to 1, and no hash chains are maintained.
1322 - * IN assertion: all calls to to INSERT_STRING are made with consecutive
1323 - * input characters and the first MIN_MATCH bytes of str are valid
1324 - * (except for the last MIN_MATCH-1 bytes of the input file).
1327 -#define INSERT_STRING(s, str, match_head) \
1328 - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
1329 - match_head = s->head[s->ins_h], \
1330 - s->head[s->ins_h] = (Pos)(str))
1332 -#define INSERT_STRING(s, str, match_head) \
1333 - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
1334 - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
1335 - s->head[s->ins_h] = (Pos)(str))
1338 -/* ===========================================================================
1339 - * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
1340 - * prev[] will be initialized on the fly.
1342 -#define CLEAR_HASH(s) \
1343 - s->head[s->hash_size-1] = NIL; \
1344 - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
1346 -/* ========================================================================= */
1347 -int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version,
1352 - const char *version;
1356 - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
1357 - Z_DEFAULT_STRATEGY, version, stream_size);
1358 - /* To do: ignore strm->next_in if we use it as window */
1361 -/* ========================================================================= */
1362 -int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
1363 - int windowBits, int memLevel, int strategy,
1364 - const char *version, int stream_size)
1372 - const char *version;
1378 - static const char my_version[] = ZLIB_VERSION;
1381 - /* We overlay pending_buf and d_buf+l_buf. This works since the average
1382 - * output size for (length,distance) codes is <= 24 bits.
1385 - if (version == Z_NULL || version[0] != my_version[0] ||
1386 - stream_size != sizeof(z_stream)) {
1387 - return Z_VERSION_ERROR;
1389 - if (strm == Z_NULL) return Z_STREAM_ERROR;
1391 - strm->msg = Z_NULL;
1392 - if (strm->zalloc == (alloc_func)0) {
1393 - strm->zalloc = zcalloc;
1394 - strm->opaque = (voidpf)0;
1396 - if (strm->zfree == (free_func)0) strm->zfree = zcfree;
1399 - if (level != 0) level = 1;
1401 - if (level == Z_DEFAULT_COMPRESSION) level = 6;
1404 - if (windowBits < 0) { /* suppress zlib wrapper */
1406 - windowBits = -windowBits;
1409 - else if (windowBits > 15) {
1410 - wrap = 2; /* write gzip wrapper instead */
1414 - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
1415 - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
1416 - strategy < 0 || strategy > Z_FIXED) {
1417 - return Z_STREAM_ERROR;
1419 - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
1420 - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
1421 - if (s == Z_NULL) return Z_MEM_ERROR;
1422 - strm->state = (struct internal_state FAR *)s;
1426 - s->gzhead = Z_NULL;
1427 - s->w_bits = windowBits;
1428 - s->w_size = 1 << s->w_bits;
1429 - s->w_mask = s->w_size - 1;
1431 - s->hash_bits = memLevel + 7;
1432 - s->hash_size = 1 << s->hash_bits;
1433 - s->hash_mask = s->hash_size - 1;
1434 - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
1436 - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
1437 - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
1438 - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
1440 - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
1442 - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
1443 - s->pending_buf = (uchf *) overlay;
1444 - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
1446 - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
1447 - s->pending_buf == Z_NULL) {
1448 - s->status = FINISH_STATE;
1449 - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
1450 - deflateEnd (strm);
1451 - return Z_MEM_ERROR;
1453 - s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
1454 - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
1457 - s->strategy = strategy;
1458 - s->method = (Byte)method;
1460 - return deflateReset(strm);
1463 -/* ========================================================================= */
1464 -int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary,
1468 - const Bytef *dictionary;
1473 - uInt length = dictLength;
1475 - IPos hash_head = 0;
1477 - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
1478 - strm->state->wrap == 2 ||
1479 - (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
1480 - return Z_STREAM_ERROR;
1484 - strm->adler = adler32(strm->adler, dictionary, dictLength);
1486 - if (length < MIN_MATCH) return Z_OK;
1487 - if (length > MAX_DIST(s)) {
1488 - length = MAX_DIST(s);
1489 - dictionary += dictLength - length; /* use the tail of the dictionary */
1491 - zmemcpy(s->window, dictionary, length);
1492 - s->strstart = length;
1493 - s->block_start = (long)length;
1495 - /* Insert all strings in the hash table (except for the last two bytes).
1496 - * s->lookahead stays null, so s->ins_h will be recomputed at the next
1497 - * call of fill_window.
1499 - s->ins_h = s->window[0];
1500 - UPDATE_HASH(s, s->ins_h, s->window[1]);
1501 - for (n = 0; n <= length - MIN_MATCH; n++) {
1502 - INSERT_STRING(s, n, hash_head);
1504 - if (hash_head) hash_head = 0; /* to make compiler happy */
1508 -/* ========================================================================= */
1509 -int ZEXPORT deflateReset (z_streamp strm)
1510 -/* z_streamp strm; */
1514 - if (strm == Z_NULL || strm->state == Z_NULL ||
1515 - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
1516 - return Z_STREAM_ERROR;
1519 - strm->total_in = strm->total_out = 0;
1520 - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
1521 - strm->data_type = Z_UNKNOWN;
1523 - s = (deflate_state *)strm->state;
1525 - s->pending_out = s->pending_buf;
1527 - if (s->wrap < 0) {
1528 - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
1530 - s->status = s->wrap ? INIT_STATE : BUSY_STATE;
1533 - s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
1535 - adler32(0L, Z_NULL, 0);
1536 - s->last_flush = Z_NO_FLUSH;
1544 -/* ========================================================================= */
1545 -int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
1551 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1552 - if (strm->state->wrap != 2) return Z_STREAM_ERROR;
1553 - strm->state->gzhead = head;
1557 -/* ========================================================================= */
1558 -int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
1560 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1561 - strm->state->bi_valid = bits;
1562 - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
1566 -/* ========================================================================= */
1567 -int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
1570 - compress_func func;
1573 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1577 - if (level != 0) level = 1;
1579 - if (level == Z_DEFAULT_COMPRESSION) level = 6;
1581 - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
1582 - return Z_STREAM_ERROR;
1584 - func = configuration_table[s->level].func;
1586 - if (func != configuration_table[level].func && strm->total_in != 0) {
1587 - /* Flush the last buffer: */
1588 - err = deflate(strm, Z_PARTIAL_FLUSH);
1590 - if (s->level != level) {
1592 - s->max_lazy_match = configuration_table[level].max_lazy;
1593 - s->good_match = configuration_table[level].good_length;
1594 - s->nice_match = configuration_table[level].nice_length;
1595 - s->max_chain_length = configuration_table[level].max_chain;
1597 - s->strategy = strategy;
1601 -/* ========================================================================= */
1602 -int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
1603 - int nice_length, int max_chain)
1607 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1609 - s->good_match = good_length;
1610 - s->max_lazy_match = max_lazy;
1611 - s->nice_match = nice_length;
1612 - s->max_chain_length = max_chain;
1616 -/* =========================================================================
1617 - * For the default windowBits of 15 and memLevel of 8, this function returns
1618 - * a close to exact, as well as small, upper bound on the compressed size.
1619 - * They are coded as constants here for a reason--if the #define's are
1620 - * changed, then this function needs to be changed as well. The return
1621 - * value for 15 and 8 only works for those exact settings.
1623 - * For any setting other than those defaults for windowBits and memLevel,
1624 - * the value returned is a conservative worst case for the maximum expansion
1625 - * resulting from using fixed blocks instead of stored blocks, which deflate
1626 - * can emit on compressed data for some combinations of the parameters.
1628 - * This function could be more sophisticated to provide closer upper bounds
1629 - * for every combination of windowBits and memLevel, as well as wrap.
1630 - * But even the conservative upper bound of about 14% expansion does not
1631 - * seem onerous for output buffer allocation.
1633 -uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
1638 - /* conservative upper bound */
1639 - destLen = sourceLen +
1640 - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
1642 - /* if can't get parameters, return conservative bound */
1643 - if (strm == Z_NULL || strm->state == Z_NULL)
1646 - /* if not default parameters, return conservative bound */
1648 - if (s->w_bits != 15 || s->hash_bits != 8 + 7)
1651 - /* default settings: return tight bound for that case */
1652 - return compressBound(sourceLen);
1655 -/* =========================================================================
1656 - * Put a short in the pending buffer. The 16-bit value is put in MSB order.
1657 - * IN assertion: the stream state is correct and there is enough room in
1660 -local void putShortMSB (deflate_state *s, uInt b)
1662 - put_byte(s, (Byte)(b >> 8));
1663 - put_byte(s, (Byte)(b & 0xff));
1666 -/* =========================================================================
1667 - * Flush as much pending output as possible. All deflate() output goes
1668 - * through this function so some applications may wish to modify it
1669 - * to avoid allocating a large strm->next_out buffer and copying into it.
1670 - * (See also read_buf()).
1672 -local void flush_pending(z_streamp strm)
1674 - unsigned len = strm->state->pending;
1676 - if (len > strm->avail_out) len = strm->avail_out;
1677 - if (len == 0) return;
1679 - zmemcpy(strm->next_out, strm->state->pending_out, len);
1680 - strm->next_out += len;
1681 - strm->state->pending_out += len;
1682 - strm->total_out += len;
1683 - strm->avail_out -= len;
1684 - strm->state->pending -= len;
1685 - if (strm->state->pending == 0) {
1686 - strm->state->pending_out = strm->state->pending_buf;
1690 -/* ========================================================================= */
1691 -int ZEXPORT deflate (z_streamp strm, int flush)
1693 - int old_flush; /* value of flush param for previous deflate call */
1696 - if (strm == Z_NULL || strm->state == Z_NULL ||
1697 - flush > Z_FINISH || flush < 0) {
1698 - return Z_STREAM_ERROR;
1702 - if (strm->next_out == Z_NULL ||
1703 - (strm->next_in == Z_NULL && strm->avail_in != 0) ||
1704 - (s->status == FINISH_STATE && flush != Z_FINISH)) {
1705 - ERR_RETURN(strm, Z_STREAM_ERROR);
1707 - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
1709 - s->strm = strm; /* just in case */
1710 - old_flush = s->last_flush;
1711 - s->last_flush = flush;
1713 - /* Write the header */
1714 - if (s->status == INIT_STATE) {
1716 - if (s->wrap == 2) {
1717 - strm->adler = crc32(0L, Z_NULL, 0);
1721 - if (s->gzhead == NULL) {
1727 - put_byte(s, s->level == 9 ? 2 :
1728 - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
1730 - put_byte(s, OS_CODE);
1731 - s->status = BUSY_STATE;
1734 - put_byte(s, (s->gzhead->text ? 1 : 0) +
1735 - (s->gzhead->hcrc ? 2 : 0) +
1736 - (s->gzhead->extra == Z_NULL ? 0 : 4) +
1737 - (s->gzhead->name == Z_NULL ? 0 : 8) +
1738 - (s->gzhead->comment == Z_NULL ? 0 : 16)
1740 - put_byte(s, (Byte)(s->gzhead->time & 0xff));
1741 - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
1742 - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
1743 - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
1744 - put_byte(s, s->level == 9 ? 2 :
1745 - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
1747 - put_byte(s, s->gzhead->os & 0xff);
1748 - if (s->gzhead->extra != NULL) {
1749 - put_byte(s, s->gzhead->extra_len & 0xff);
1750 - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
1752 - if (s->gzhead->hcrc)
1753 - strm->adler = crc32(strm->adler, s->pending_buf,
1756 - s->status = EXTRA_STATE;
1762 - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
1765 - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
1767 - else if (s->level < 6)
1769 - else if (s->level == 6)
1773 - header |= (level_flags << 6);
1774 - if (s->strstart != 0) header |= PRESET_DICT;
1775 - header += 31 - (header % 31);
1777 - s->status = BUSY_STATE;
1778 - putShortMSB(s, header);
1780 - /* Save the adler32 of the preset dictionary: */
1781 - if (s->strstart != 0) {
1782 - putShortMSB(s, (uInt)(strm->adler >> 16));
1783 - putShortMSB(s, (uInt)(strm->adler & 0xffff));
1785 - strm->adler = adler32(0L, Z_NULL, 0);
1789 - if (s->status == EXTRA_STATE) {
1790 - if (s->gzhead->extra != NULL) {
1791 - uInt beg = s->pending; /* start of bytes to update crc */
1793 - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
1794 - if (s->pending == s->pending_buf_size) {
1795 - if (s->gzhead->hcrc && s->pending > beg)
1796 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1797 - s->pending - beg);
1798 - flush_pending(strm);
1800 - if (s->pending == s->pending_buf_size)
1803 - put_byte(s, s->gzhead->extra[s->gzindex]);
1806 - if (s->gzhead->hcrc && s->pending > beg)
1807 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1808 - s->pending - beg);
1809 - if (s->gzindex == s->gzhead->extra_len) {
1811 - s->status = NAME_STATE;
1815 - s->status = NAME_STATE;
1817 - if (s->status == NAME_STATE) {
1818 - if (s->gzhead->name != NULL) {
1819 - uInt beg = s->pending; /* start of bytes to update crc */
1823 - if (s->pending == s->pending_buf_size) {
1824 - if (s->gzhead->hcrc && s->pending > beg)
1825 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1826 - s->pending - beg);
1827 - flush_pending(strm);
1829 - if (s->pending == s->pending_buf_size) {
1834 - val = s->gzhead->name[s->gzindex++];
1836 - } while (val != 0);
1837 - if (s->gzhead->hcrc && s->pending > beg)
1838 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1839 - s->pending - beg);
1842 - s->status = COMMENT_STATE;
1846 - s->status = COMMENT_STATE;
1848 - if (s->status == COMMENT_STATE) {
1849 - if (s->gzhead->comment != NULL) {
1850 - uInt beg = s->pending; /* start of bytes to update crc */
1854 - if (s->pending == s->pending_buf_size) {
1855 - if (s->gzhead->hcrc && s->pending > beg)
1856 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1857 - s->pending - beg);
1858 - flush_pending(strm);
1860 - if (s->pending == s->pending_buf_size) {
1865 - val = s->gzhead->comment[s->gzindex++];
1867 - } while (val != 0);
1868 - if (s->gzhead->hcrc && s->pending > beg)
1869 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1870 - s->pending - beg);
1872 - s->status = HCRC_STATE;
1875 - s->status = HCRC_STATE;
1877 - if (s->status == HCRC_STATE) {
1878 - if (s->gzhead->hcrc) {
1879 - if (s->pending + 2 > s->pending_buf_size)
1880 - flush_pending(strm);
1881 - if (s->pending + 2 <= s->pending_buf_size) {
1882 - put_byte(s, (Byte)(strm->adler & 0xff));
1883 - put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1884 - strm->adler = crc32(0L, Z_NULL, 0);
1885 - s->status = BUSY_STATE;
1889 - s->status = BUSY_STATE;
1893 - /* Flush as much pending output as possible */
1894 - if (s->pending != 0) {
1895 - flush_pending(strm);
1896 - if (strm->avail_out == 0) {
1897 - /* Since avail_out is 0, deflate will be called again with
1898 - * more output space, but possibly with both pending and
1899 - * avail_in equal to zero. There won't be anything to do,
1900 - * but this is not an error situation so make sure we
1901 - * return OK instead of BUF_ERROR at next call of deflate:
1903 - s->last_flush = -1;
1907 - /* Make sure there is something to do and avoid duplicate consecutive
1908 - * flushes. For repeated and useless calls with Z_FINISH, we keep
1909 - * returning Z_STREAM_END instead of Z_BUF_ERROR.
1911 - } else if (strm->avail_in == 0 && flush <= old_flush &&
1912 - flush != Z_FINISH) {
1913 - ERR_RETURN(strm, Z_BUF_ERROR);
1916 - /* User must not provide more input after the first FINISH: */
1917 - if (s->status == FINISH_STATE && strm->avail_in != 0) {
1918 - ERR_RETURN(strm, Z_BUF_ERROR);
1921 - /* Start a new block or continue the current one.
1923 - if (strm->avail_in != 0 || s->lookahead != 0 ||
1924 - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1925 - block_state bstate;
1927 - bstate = (*(configuration_table[s->level].func))(s, flush);
1929 - if (bstate == finish_started || bstate == finish_done) {
1930 - s->status = FINISH_STATE;
1932 - if (bstate == need_more || bstate == finish_started) {
1933 - if (strm->avail_out == 0) {
1934 - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
1937 - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1938 - * of deflate should use the same flush parameter to make sure
1939 - * that the flush is complete. So we don't have to output an
1940 - * empty block here, this will be done at next call. This also
1941 - * ensures that for a very small output buffer, we emit at most
1942 - * one empty block.
1945 - if (bstate == block_done) {
1946 - if (flush == Z_PARTIAL_FLUSH) {
1948 - } else { /* FULL_FLUSH or SYNC_FLUSH */
1949 - _tr_stored_block(s, (char*)0, 0L, 0);
1950 - /* For a full flush, this empty block will be recognized
1951 - * as a special marker by inflate_sync().
1953 - if (flush == Z_FULL_FLUSH) {
1954 - CLEAR_HASH(s); /* forget history */
1957 - flush_pending(strm);
1958 - if (strm->avail_out == 0) {
1959 - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1964 - Assert(strm->avail_out > 0, "bug2");
1966 - if (flush != Z_FINISH) return Z_OK;
1967 - if (s->wrap <= 0) return Z_STREAM_END;
1969 - /* Write the trailer */
1971 - if (s->wrap == 2) {
1972 - put_byte(s, (Byte)(strm->adler & 0xff));
1973 - put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1974 - put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
1975 - put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
1976 - put_byte(s, (Byte)(strm->total_in & 0xff));
1977 - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
1978 - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
1979 - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
1984 - putShortMSB(s, (uInt)(strm->adler >> 16));
1985 - putShortMSB(s, (uInt)(strm->adler & 0xffff));
1987 - flush_pending(strm);
1988 - /* If avail_out is zero, the application will call deflate again
1989 - * to flush the rest.
1991 - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1992 - return s->pending != 0 ? Z_OK : Z_STREAM_END;
1995 -/* ========================================================================= */
1996 -int ZEXPORT deflateEnd (z_streamp strm)
2000 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
2002 - status = strm->state->status;
2003 - if (status != INIT_STATE &&
2004 - status != EXTRA_STATE &&
2005 - status != NAME_STATE &&
2006 - status != COMMENT_STATE &&
2007 - status != HCRC_STATE &&
2008 - status != BUSY_STATE &&
2009 - status != FINISH_STATE) {
2010 - return Z_STREAM_ERROR;
2013 - /* Deallocate in reverse order of allocations: */
2014 - TRY_FREE(strm, strm->state->pending_buf);
2015 - TRY_FREE(strm, strm->state->head);
2016 - TRY_FREE(strm, strm->state->prev);
2017 - TRY_FREE(strm, strm->state->window);
2019 - ZFREE(strm, strm->state);
2020 - strm->state = Z_NULL;
2022 - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
2025 -/* =========================================================================
2026 - * Copy the source state to the destination state.
2027 - * To simplify the source, this is not supported for 16-bit MSDOS (which
2028 - * doesn't have enough memory anyway to duplicate compression states).
2030 -int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
2033 - return Z_STREAM_ERROR;
2035 - deflate_state *ds;
2036 - deflate_state *ss;
2040 - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
2041 - return Z_STREAM_ERROR;
2044 - ss = source->state;
2046 - zmemcpy(dest, source, sizeof(z_stream));
2048 - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
2049 - if (ds == Z_NULL) return Z_MEM_ERROR;
2050 - dest->state = (struct internal_state FAR *) ds;
2051 - zmemcpy(ds, ss, sizeof(deflate_state));
2054 - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
2055 - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
2056 - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
2057 - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
2058 - ds->pending_buf = (uchf *) overlay;
2060 - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
2061 - ds->pending_buf == Z_NULL) {
2062 - deflateEnd (dest);
2063 - return Z_MEM_ERROR;
2065 - /* following zmemcpy do not work for 16-bit MSDOS */
2066 - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
2067 - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
2068 - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
2069 - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
2071 - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
2072 - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
2073 - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
2075 - ds->l_desc.dyn_tree = ds->dyn_ltree;
2076 - ds->d_desc.dyn_tree = ds->dyn_dtree;
2077 - ds->bl_desc.dyn_tree = ds->bl_tree;
2080 -#endif /* MAXSEG_64K */
2083 -/* ===========================================================================
2084 - * Read a new buffer from the current input stream, update the adler32
2085 - * and total number of bytes read. All deflate() input goes through
2086 - * this function so some applications may wish to modify it to avoid
2087 - * allocating a large strm->next_in buffer and copying from it.
2088 - * (See also flush_pending()).
2090 -local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
2092 - unsigned len = strm->avail_in;
2094 - if (len > size) len = size;
2095 - if (len == 0) return 0;
2097 - strm->avail_in -= len;
2099 - if (strm->state->wrap == 1) {
2100 - strm->adler = adler32(strm->adler, strm->next_in, len);
2103 - else if (strm->state->wrap == 2) {
2104 - strm->adler = crc32(strm->adler, strm->next_in, len);
2107 - zmemcpy(buf, strm->next_in, len);
2108 - strm->next_in += len;
2109 - strm->total_in += len;
2114 -/* ===========================================================================
2115 - * Initialize the "longest match" routines for a new zlib stream
2117 -local void lm_init (deflate_state *s)
2119 - s->window_size = (ulg)2L*s->w_size;
2123 - /* Set the default configuration parameters:
2125 - s->max_lazy_match = configuration_table[s->level].max_lazy;
2126 - s->good_match = configuration_table[s->level].good_length;
2127 - s->nice_match = configuration_table[s->level].nice_length;
2128 - s->max_chain_length = configuration_table[s->level].max_chain;
2131 - s->block_start = 0L;
2133 - s->match_length = s->prev_length = MIN_MATCH-1;
2134 - s->match_available = 0;
2138 - match_init(); /* initialize the asm code */
2144 -/* ===========================================================================
2145 - * Set match_start to the longest match starting at the given string and
2146 - * return its length. Matches shorter or equal to prev_length are discarded,
2147 - * in which case the result is equal to prev_length and match_start is
2149 - * IN assertions: cur_match is the head of the hash chain for the current
2150 - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
2151 - * OUT assertion: the match length is not greater than s->lookahead.
2154 -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
2155 - * match.S. The code will be functionally equivalent.
2157 -local uInt longest_match(deflate_state *s, IPos cur_match)
2158 - /* cur_match current match */
2160 - unsigned chain_length = s->max_chain_length;/* max hash chain length */
2161 - register Bytef *scan = s->window + s->strstart; /* current string */
2162 - register Bytef *match; /* matched string */
2163 - register int len; /* length of current match */
2164 - int best_len = s->prev_length; /* best match length so far */
2165 - int nice_match = s->nice_match; /* stop if match long enough */
2166 - IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
2167 - s->strstart - (IPos)MAX_DIST(s) : NIL;
2168 - /* Stop when cur_match becomes <= limit. To simplify the code,
2169 - * we prevent matches with the string of window index 0.
2171 - Posf *prev = s->prev;
2172 - uInt wmask = s->w_mask;
2174 -#ifdef UNALIGNED_OK
2175 - /* Compare two bytes at a time. Note: this is not always beneficial.
2176 - * Try with and without -DUNALIGNED_OK to check.
2178 - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
2179 - register ush scan_start = *(ushf*)scan;
2180 - register ush scan_end = *(ushf*)(scan+best_len-1);
2182 - register Bytef *strend = s->window + s->strstart + MAX_MATCH;
2183 - register Byte scan_end1 = scan[best_len-1];
2184 - register Byte scan_end = scan[best_len];
2187 - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
2188 - * It is easy to get rid of this optimization if necessary.
2190 - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
2192 - /* Do not waste too much time if we already have a good match: */
2193 - if (s->prev_length >= s->good_match) {
2194 - chain_length >>= 2;
2196 - /* Do not look for matches beyond the end of the input. This is necessary
2197 - * to make deflate deterministic.
2199 - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
2201 - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
2204 - Assert(cur_match < s->strstart, "no future");
2205 - match = s->window + cur_match;
2207 - /* Skip to next match if the match length cannot increase
2208 - * or if the match length is less than 2. Note that the checks below
2209 - * for insufficient lookahead only occur occasionally for performance
2210 - * reasons. Therefore uninitialized memory will be accessed, and
2211 - * conditional jumps will be made that depend on those values.
2212 - * However the length of the match is limited to the lookahead, so
2213 - * the output of deflate is not affected by the uninitialized values.
2215 -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
2216 - /* This code assumes sizeof(unsigned short) == 2. Do not use
2217 - * UNALIGNED_OK if your compiler uses a different size.
2219 - if (*(ushf*)(match+best_len-1) != scan_end ||
2220 - *(ushf*)match != scan_start) continue;
2222 - /* It is not necessary to compare scan[2] and match[2] since they are
2223 - * always equal when the other bytes match, given that the hash keys
2224 - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
2225 - * strstart+3, +5, ... up to strstart+257. We check for insufficient
2226 - * lookahead only every 4th comparison; the 128th check will be made
2227 - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
2228 - * necessary to put more guard bytes at the end of the window, or
2229 - * to check more often for insufficient lookahead.
2231 - Assert(scan[2] == match[2], "scan[2]?");
2234 - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2235 - *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2236 - *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2237 - *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2239 - /* The funny "do {}" generates better code on most compilers */
2241 - /* Here, scan <= window+strstart+257 */
2242 - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2243 - if (*scan == *match) scan++;
2245 - len = (MAX_MATCH - 1) - (int)(strend-scan);
2246 - scan = strend - (MAX_MATCH-1);
2248 -#else /* UNALIGNED_OK */
2250 - if (match[best_len] != scan_end ||
2251 - match[best_len-1] != scan_end1 ||
2252 - *match != *scan ||
2253 - *++match != scan[1]) continue;
2255 - /* The check at best_len-1 can be removed because it will be made
2256 - * again later. (This heuristic is not always a win.)
2257 - * It is not necessary to compare scan[2] and match[2] since they
2258 - * are always equal when the other bytes match, given that
2259 - * the hash keys are equal and that HASH_BITS >= 8.
2261 - scan += 2, match++;
2262 - Assert(*scan == *match, "match[2]?");
2264 - /* We check for insufficient lookahead only every 8th comparison;
2265 - * the 256th check will be made at strstart+258.
2268 - } while (*++scan == *++match && *++scan == *++match &&
2269 - *++scan == *++match && *++scan == *++match &&
2270 - *++scan == *++match && *++scan == *++match &&
2271 - *++scan == *++match && *++scan == *++match &&
2274 - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2276 - len = MAX_MATCH - (int)(strend - scan);
2277 - scan = strend - MAX_MATCH;
2279 -#endif /* UNALIGNED_OK */
2281 - if (len > best_len) {
2282 - s->match_start = cur_match;
2284 - if (len >= nice_match) break;
2285 -#ifdef UNALIGNED_OK
2286 - scan_end = *(ushf*)(scan+best_len-1);
2288 - scan_end1 = scan[best_len-1];
2289 - scan_end = scan[best_len];
2292 - } while ((cur_match = prev[cur_match & wmask]) > limit
2293 - && --chain_length != 0);
2295 - if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
2296 - return s->lookahead;
2299 -#endif /* FASTEST */
2301 -/* ---------------------------------------------------------------------------
2302 - * Optimized version for level == 1 or strategy == Z_RLE only
2304 -local uInt longest_match_fast(deflate_state *s, IPos cur_match)
2306 - register Bytef *scan = s->window + s->strstart; /* current string */
2307 - register Bytef *match; /* matched string */
2308 - register int len; /* length of current match */
2309 - register Bytef *strend = s->window + s->strstart + MAX_MATCH;
2311 - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
2312 - * It is easy to get rid of this optimization if necessary.
2314 - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
2316 - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
2318 - Assert(cur_match < s->strstart, "no future");
2320 - match = s->window + cur_match;
2322 - /* Return failure if the match length is less than 2:
2324 - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
2326 - /* The check at best_len-1 can be removed because it will be made
2327 - * again later. (This heuristic is not always a win.)
2328 - * It is not necessary to compare scan[2] and match[2] since they
2329 - * are always equal when the other bytes match, given that
2330 - * the hash keys are equal and that HASH_BITS >= 8.
2332 - scan += 2, match += 2;
2333 - Assert(*scan == *match, "match[2]?");
2335 - /* We check for insufficient lookahead only every 8th comparison;
2336 - * the 256th check will be made at strstart+258.
2339 - } while (*++scan == *++match && *++scan == *++match &&
2340 - *++scan == *++match && *++scan == *++match &&
2341 - *++scan == *++match && *++scan == *++match &&
2342 - *++scan == *++match && *++scan == *++match &&
2345 - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2347 - len = MAX_MATCH - (int)(strend - scan);
2349 - if (len < MIN_MATCH) return MIN_MATCH - 1;
2351 - s->match_start = cur_match;
2352 - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
2356 -/* ===========================================================================
2357 - * Check that the match at match_start is indeed a match.
2359 -local void check_match(s, start, match, length)
2361 - IPos start, match;
2364 - /* check that the match is indeed a match */
2365 - if (zmemcmp(s->window + match,
2366 - s->window + start, length) != EQUAL) {
2367 - fprintf(stderr, " start %u, match %u, length %d\n",
2368 - start, match, length);
2370 - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
2371 - } while (--length != 0);
2372 - z_error("invalid match");
2374 - if (z_verbose > 1) {
2375 - fprintf(stderr,"\\[%d,%d]", start-match, length);
2376 - do { putc(s->window[start++], stderr); } while (--length != 0);
2380 -# define check_match(s, start, match, length)
2383 -/* ===========================================================================
2384 - * Fill the window when the lookahead becomes insufficient.
2385 - * Updates strstart and lookahead.
2387 - * IN assertion: lookahead < MIN_LOOKAHEAD
2388 - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
2389 - * At least one byte has been read, or avail_in == 0; reads are
2390 - * performed for at least two bytes (required for the zip translate_eol
2391 - * option -- not supported here).
2393 -local void fill_window(deflate_state *s)
2395 - register unsigned n, m;
2397 - unsigned more; /* Amount of free space at the end of the window. */
2398 - uInt wsize = s->w_size;
2401 - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
2403 - /* Deal with !@#$% 64K limit: */
2404 - if (sizeof(int) <= 2) {
2405 - if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
2408 - } else if (more == (unsigned)(-1)) {
2409 - /* Very unlikely, but possible on 16 bit machine if
2410 - * strstart == 0 && lookahead == 1 (input done a byte at time)
2416 - /* If the window is almost full and there is insufficient lookahead,
2417 - * move the upper half to the lower one to make room in the upper half.
2419 - if (s->strstart >= wsize+MAX_DIST(s)) {
2421 - zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
2422 - s->match_start -= wsize;
2423 - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
2424 - s->block_start -= (long) wsize;
2426 - /* Slide the hash table (could be avoided with 32 bit values
2427 - at the expense of memory usage). We slide even when level == 0
2428 - to keep the hash table consistent if we switch back to level > 0
2429 - later. (Using level 0 permanently is not an optimal usage of
2430 - zlib, so we don't care about this pathological case.)
2432 - /* %%% avoid this when Z_RLE */
2437 - *p = (Pos)(m >= wsize ? m-wsize : NIL);
2445 - *p = (Pos)(m >= wsize ? m-wsize : NIL);
2446 - /* If n is not on any hash chain, prev[n] is garbage but
2447 - * its value will never be used.
2453 - if (s->strm->avail_in == 0) return;
2455 - /* If there was no sliding:
2456 - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
2457 - * more == window_size - lookahead - strstart
2458 - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
2459 - * => more >= window_size - 2*WSIZE + 2
2460 - * In the BIG_MEM or MMAP case (not yet supported),
2461 - * window_size == input_size + MIN_LOOKAHEAD &&
2462 - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
2463 - * Otherwise, window_size == 2*WSIZE so more >= 2.
2464 - * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
2466 - Assert(more >= 2, "more < 2");
2468 - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
2469 - s->lookahead += n;
2471 - /* Initialize the hash value now that we have some input: */
2472 - if (s->lookahead >= MIN_MATCH) {
2473 - s->ins_h = s->window[s->strstart];
2474 - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
2476 - Call UPDATE_HASH() MIN_MATCH-3 more times
2479 - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
2480 - * but this is not important since only literal bytes will be emitted.
2483 - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
2486 -/* ===========================================================================
2487 - * Flush the current block, with given end-of-file flag.
2488 - * IN assertion: strstart is set to the end of the current match.
2490 -#define FLUSH_BLOCK_ONLY(s, eof) { \
2491 - _tr_flush_block(s, (s->block_start >= 0L ? \
2492 - (charf *)&s->window[(unsigned)s->block_start] : \
2493 - (charf *)Z_NULL), \
2494 - (ulg)((long)s->strstart - s->block_start), \
2496 - s->block_start = s->strstart; \
2497 - flush_pending(s->strm); \
2498 - Tracev((stderr,"[FLUSH]")); \
2501 -/* Same but force premature exit if necessary. */
2502 -#define FLUSH_BLOCK(s, eof) { \
2503 - FLUSH_BLOCK_ONLY(s, eof); \
2504 - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
2507 -/* ===========================================================================
2508 - * Copy without compression as much as possible from the input stream, return
2509 - * the current block state.
2510 - * This function does not insert new strings in the dictionary since
2511 - * uncompressible data is probably not useful. This function is used
2512 - * only for the level=0 compression option.
2513 - * NOTE: this function should be optimized to avoid extra copying from
2514 - * window to pending_buf.
2516 -local block_state deflate_stored(deflate_state *s, int flush)
2518 - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
2519 - * to pending_buf_size, and each stored block has a 5 byte header:
2521 - ulg max_block_size = 0xffff;
2524 - if (max_block_size > s->pending_buf_size - 5) {
2525 - max_block_size = s->pending_buf_size - 5;
2528 - /* Copy as much as possible from input to output: */
2530 - /* Fill the window as much as possible: */
2531 - if (s->lookahead <= 1) {
2533 - Assert(s->strstart < s->w_size+MAX_DIST(s) ||
2534 - s->block_start >= (long)s->w_size, "slide too late");
2537 - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
2539 - if (s->lookahead == 0) break; /* flush the current block */
2541 - Assert(s->block_start >= 0L, "block gone");
2543 - s->strstart += s->lookahead;
2546 - /* Emit a stored block if pending_buf will be full: */
2547 - max_start = s->block_start + max_block_size;
2548 - if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
2549 - /* strstart == 0 is possible when wraparound on 16-bit machine */
2550 - s->lookahead = (uInt)(s->strstart - max_start);
2551 - s->strstart = (uInt)max_start;
2552 - FLUSH_BLOCK(s, 0);
2554 - /* Flush if we may have to slide, otherwise block_start may become
2555 - * negative and the data will be gone:
2557 - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
2558 - FLUSH_BLOCK(s, 0);
2561 - FLUSH_BLOCK(s, flush == Z_FINISH);
2562 - return flush == Z_FINISH ? finish_done : block_done;
2565 -/* ===========================================================================
2566 - * Compress as much as possible from the input stream, return the current
2568 - * This function does not perform lazy evaluation of matches and inserts
2569 - * new strings in the dictionary only for unmatched strings or for short
2570 - * matches. It is used only for the fast compression options.
2572 -local block_state deflate_fast(deflate_state *s, int flush)
2574 - IPos hash_head = NIL; /* head of the hash chain */
2575 - int bflush; /* set if current block must be flushed */
2578 - /* Make sure that we always have enough lookahead, except
2579 - * at the end of the input file. We need MAX_MATCH bytes
2580 - * for the next match, plus MIN_MATCH bytes to insert the
2581 - * string following the next match.
2583 - if (s->lookahead < MIN_LOOKAHEAD) {
2585 - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
2588 - if (s->lookahead == 0) break; /* flush the current block */
2591 - /* Insert the string window[strstart .. strstart+2] in the
2592 - * dictionary, and set hash_head to the head of the hash chain:
2594 - if (s->lookahead >= MIN_MATCH) {
2595 - INSERT_STRING(s, s->strstart, hash_head);
2598 - /* Find the longest match, discarding those <= prev_length.
2599 - * At this point we have always match_length < MIN_MATCH
2601 - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
2602 - /* To simplify the code, we prevent matches with the string
2603 - * of window index 0 (in particular we have to avoid a match
2604 - * of the string with itself at the start of the input file).
2607 - if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
2608 - (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
2609 - s->match_length = longest_match_fast (s, hash_head);
2612 - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
2613 - s->match_length = longest_match (s, hash_head);
2614 - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
2615 - s->match_length = longest_match_fast (s, hash_head);
2618 - /* longest_match() or longest_match_fast() sets match_start */
2620 - if (s->match_length >= MIN_MATCH) {
2621 - check_match(s, s->strstart, s->match_start, s->match_length);
2623 - _tr_tally_dist(s, s->strstart - s->match_start,
2624 - s->match_length - MIN_MATCH, bflush);
2626 - s->lookahead -= s->match_length;
2628 - /* Insert new strings in the hash table only if the match length
2629 - * is not too large. This saves time but degrades compression.
2632 - if (s->match_length <= s->max_insert_length &&
2633 - s->lookahead >= MIN_MATCH) {
2634 - s->match_length--; /* string at strstart already in table */
2637 - INSERT_STRING(s, s->strstart, hash_head);
2638 - /* strstart never exceeds WSIZE-MAX_MATCH, so there are
2639 - * always MIN_MATCH bytes ahead.
2641 - } while (--s->match_length != 0);
2646 - s->strstart += s->match_length;
2647 - s->match_length = 0;
2648 - s->ins_h = s->window[s->strstart];
2649 - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
2651 - Call UPDATE_HASH() MIN_MATCH-3 more times
2653 - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
2654 - * matter since it will be recomputed at next deflate call.
2658 - /* No match, output a literal byte */
2659 - Tracevv((stderr,"%c", s->window[s->strstart]));
2660 - _tr_tally_lit (s, s->window[s->strstart], bflush);
2664 - if (bflush) FLUSH_BLOCK(s, 0);
2666 - FLUSH_BLOCK(s, flush == Z_FINISH);
2667 - return flush == Z_FINISH ? finish_done : block_done;
2671 -/* ===========================================================================
2672 - * Same as above, but achieves better compression. We use a lazy
2673 - * evaluation for matches: a match is finally adopted only if there is
2674 - * no better match at the next window position.
2676 -local block_state deflate_slow(deflate_state *s, int flush)
2678 - IPos hash_head = NIL; /* head of hash chain */
2679 - int bflush; /* set if current block must be flushed */
2681 - /* Process the input block. */
2683 - /* Make sure that we always have enough lookahead, except
2684 - * at the end of the input file. We need MAX_MATCH bytes
2685 - * for the next match, plus MIN_MATCH bytes to insert the
2686 - * string following the next match.
2688 - if (s->lookahead < MIN_LOOKAHEAD) {
2690 - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
2693 - if (s->lookahead == 0) break; /* flush the current block */
2696 - /* Insert the string window[strstart .. strstart+2] in the
2697 - * dictionary, and set hash_head to the head of the hash chain:
2699 - if (s->lookahead >= MIN_MATCH) {
2700 - INSERT_STRING(s, s->strstart, hash_head);
2703 - /* Find the longest match, discarding those <= prev_length.
2705 - s->prev_length = s->match_length, s->prev_match = s->match_start;
2706 - s->match_length = MIN_MATCH-1;
2708 - if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
2709 - s->strstart - hash_head <= MAX_DIST(s)) {
2710 - /* To simplify the code, we prevent matches with the string
2711 - * of window index 0 (in particular we have to avoid a match
2712 - * of the string with itself at the start of the input file).
2714 - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
2715 - s->match_length = longest_match (s, hash_head);
2716 - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
2717 - s->match_length = longest_match_fast (s, hash_head);
2719 - /* longest_match() or longest_match_fast() sets match_start */
2721 - if (s->match_length <= 5 && (s->strategy == Z_FILTERED
2722 -#if TOO_FAR <= 32767
2723 - || (s->match_length == MIN_MATCH &&
2724 - s->strstart - s->match_start > TOO_FAR)
2728 - /* If prev_match is also MIN_MATCH, match_start is garbage
2729 - * but we will ignore the current match anyway.
2731 - s->match_length = MIN_MATCH-1;
2734 - /* If there was a match at the previous step and the current
2735 - * match is not better, output the previous match:
2737 - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
2738 - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
2739 - /* Do not insert strings in hash table beyond this. */
2741 - check_match(s, s->strstart-1, s->prev_match, s->prev_length);
2743 - _tr_tally_dist(s, s->strstart -1 - s->prev_match,
2744 - s->prev_length - MIN_MATCH, bflush);
2746 - /* Insert in hash table all strings up to the end of the match.
2747 - * strstart-1 and strstart are already inserted. If there is not
2748 - * enough lookahead, the last two strings are not inserted in
2751 - s->lookahead -= s->prev_length-1;
2752 - s->prev_length -= 2;
2754 - if (++s->strstart <= max_insert) {
2755 - INSERT_STRING(s, s->strstart, hash_head);
2757 - } while (--s->prev_length != 0);
2758 - s->match_available = 0;
2759 - s->match_length = MIN_MATCH-1;
2762 - if (bflush) FLUSH_BLOCK(s, 0);
2764 - } else if (s->match_available) {
2765 - /* If there was no match at the previous position, output a
2766 - * single literal. If there was a match but the current match
2767 - * is longer, truncate the previous match to a single literal.
2769 - Tracevv((stderr,"%c", s->window[s->strstart-1]));
2770 - _tr_tally_lit(s, s->window[s->strstart-1], bflush);
2772 - FLUSH_BLOCK_ONLY(s, 0);
2776 - if (s->strm->avail_out == 0) return need_more;
2778 - /* There is no previous match to compare with, wait for
2779 - * the next step to decide.
2781 - s->match_available = 1;
2786 - Assert (flush != Z_NO_FLUSH, "no flush?");
2787 - if (s->match_available) {
2788 - Tracevv((stderr,"%c", s->window[s->strstart-1]));
2789 - _tr_tally_lit(s, s->window[s->strstart-1], bflush);
2790 - s->match_available = 0;
2792 - FLUSH_BLOCK(s, flush == Z_FINISH);
2793 - return flush == Z_FINISH ? finish_done : block_done;
2795 -#endif /* FASTEST */
2798 -/* ===========================================================================
2799 - * For Z_RLE, simply look for runs of bytes, generate matches only of distance
2800 - * one. Do not maintain a hash table. (It will be regenerated if this run of
2801 - * deflate switches away from Z_RLE.)
2803 -local block_state deflate_rle(deflate_state *s, int flush)
2805 - int bflush; /* set if current block must be flushed */
2806 - uInt run; /* length of run */
2807 - uInt max; /* maximum length of run */
2808 - uInt prev; /* byte at distance one to match */
2809 - Bytef *scan; /* scan for end of run */
2812 - /* Make sure that we always have enough lookahead, except
2813 - * at the end of the input file. We need MAX_MATCH bytes
2814 - * for the longest encodable run.
2816 - if (s->lookahead < MAX_MATCH) {
2818 - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
2821 - if (s->lookahead == 0) break; /* flush the current block */
2824 - /* See how many times the previous byte repeats */
2826 - if (s->strstart > 0) { /* if there is a previous byte, that is */
2827 - max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
2828 - scan = s->window + s->strstart - 1;
2831 - if (*scan++ != prev)
2833 - } while (++run < max);
2836 - /* Emit match if have run of MIN_MATCH or longer, else emit literal */
2837 - if (run >= MIN_MATCH) {
2838 - check_match(s, s->strstart, s->strstart - 1, run);
2839 - _tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
2840 - s->lookahead -= run;
2841 - s->strstart += run;
2843 - /* No match, output a literal byte */
2844 - Tracevv((stderr,"%c", s->window[s->strstart]));
2845 - _tr_tally_lit (s, s->window[s->strstart], bflush);
2849 - if (bflush) FLUSH_BLOCK(s, 0);
2851 - FLUSH_BLOCK(s, flush == Z_FINISH);
2852 - return flush == Z_FINISH ? finish_done : block_done;
2855 diff -ruN seqinr.orig/src/deflate.h seqinr/src/deflate.h
2856 --- seqinr.orig/src/deflate.h 2007-04-19 11:40:19.000000000 +0200
2857 +++ seqinr/src/deflate.h 1970-01-01 01:00:00.000000000 +0100
2859 -/* deflate.h -- internal compression state
2860 - * Copyright (C) 1995-2004 Jean-loup Gailly
2861 - * For conditions of distribution and use, see copyright notice in zlib.h
2864 -/* WARNING: this file should *not* be used by applications. It is
2865 - part of the implementation of the compression library and is
2866 - subject to change. Applications should only use zlib.h.
2869 -/* @(#) $Id: deflate.h,v 1.1.2.1 2007-04-19 09:40:18 penel Exp $ */
2876 -/* define NO_GZIP when compiling if you want to disable gzip header and
2877 - trailer creation by deflate(). NO_GZIP would be used to avoid linking in
2878 - the crc code when it is not needed. For shared libraries, gzip encoding
2879 - should be left enabled. */
2884 -/* ===========================================================================
2885 - * Internal compression state.
2888 -#define LENGTH_CODES 29
2889 -/* number of length codes, not counting the special END_BLOCK code */
2891 -#define LITERALS 256
2892 -/* number of literal bytes 0..255 */
2894 -#define L_CODES (LITERALS+1+LENGTH_CODES)
2895 -/* number of Literal or Length codes, including the END_BLOCK code */
2898 -/* number of distance codes */
2900 -#define BL_CODES 19
2901 -/* number of codes used to transfer the bit lengths */
2903 -#define HEAP_SIZE (2*L_CODES+1)
2904 -/* maximum heap size */
2906 -#define MAX_BITS 15
2907 -/* All codes must not exceed MAX_BITS bits */
2909 -#define INIT_STATE 42
2910 -#define EXTRA_STATE 69
2911 -#define NAME_STATE 73
2912 -#define COMMENT_STATE 91
2913 -#define HCRC_STATE 103
2914 -#define BUSY_STATE 113
2915 -#define FINISH_STATE 666
2916 -/* Stream status */
2919 -/* Data structure describing a single value and its code string. */
2920 -typedef struct ct_data_s {
2922 - ush freq; /* frequency count */
2923 - ush code; /* bit string */
2926 - ush dad; /* father node in Huffman tree */
2927 - ush len; /* length of bit string */
2931 -#define Freq fc.freq
2932 -#define Code fc.code
2936 -typedef struct static_tree_desc_s static_tree_desc;
2938 -typedef struct tree_desc_s {
2939 - ct_data *dyn_tree; /* the dynamic tree */
2940 - int max_code; /* largest code with non zero frequency */
2941 - static_tree_desc *stat_desc; /* the corresponding static tree */
2945 -typedef Pos FAR Posf;
2946 -typedef unsigned IPos;
2948 -/* A Pos is an index in the character window. We use short instead of int to
2949 - * save space in the various tables. IPos is used only for parameter passing.
2952 -typedef struct internal_state {
2953 - z_streamp strm; /* pointer back to this zlib stream */
2954 - int status; /* as the name implies */
2955 - Bytef *pending_buf; /* output still pending */
2956 - ulg pending_buf_size; /* size of pending_buf */
2957 - Bytef *pending_out; /* next pending byte to output to the stream */
2958 - uInt pending; /* nb of bytes in the pending buffer */
2959 - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
2960 - gz_headerp gzhead; /* gzip header information to write */
2961 - uInt gzindex; /* where in extra, name, or comment */
2962 - Byte method; /* STORED (for zip only) or DEFLATED */
2963 - int last_flush; /* value of flush param for previous deflate call */
2965 - /* used by deflate.c: */
2967 - uInt w_size; /* LZ77 window size (32K by default) */
2968 - uInt w_bits; /* log2(w_size) (8..16) */
2969 - uInt w_mask; /* w_size - 1 */
2972 - /* Sliding window. Input bytes are read into the second half of the window,
2973 - * and move to the first half later to keep a dictionary of at least wSize
2974 - * bytes. With this organization, matches are limited to a distance of
2975 - * wSize-MAX_MATCH bytes, but this ensures that IO is always
2976 - * performed with a length multiple of the block size. Also, it limits
2977 - * the window size to 64K, which is quite useful on MSDOS.
2978 - * To do: use the user input buffer as sliding window.
2982 - /* Actual size of window: 2*wSize, except when the user input buffer
2983 - * is directly used as sliding window.
2987 - /* Link to older string with same hash index. To limit the size of this
2988 - * array to 64K, this link is maintained only for the last 32K strings.
2989 - * An index in this array is thus a window index modulo 32K.
2992 - Posf *head; /* Heads of the hash chains or NIL. */
2994 - uInt ins_h; /* hash index of string to be inserted */
2995 - uInt hash_size; /* number of elements in hash table */
2996 - uInt hash_bits; /* log2(hash_size) */
2997 - uInt hash_mask; /* hash_size-1 */
3000 - /* Number of bits by which ins_h must be shifted at each input
3001 - * step. It must be such that after MIN_MATCH steps, the oldest
3002 - * byte no longer takes part in the hash key, that is:
3003 - * hash_shift * MIN_MATCH >= hash_bits
3007 - /* Window position at the beginning of the current output block. Gets
3008 - * negative when the window is moved backwards.
3011 - uInt match_length; /* length of best match */
3012 - IPos prev_match; /* previous match */
3013 - int match_available; /* set if previous match exists */
3014 - uInt strstart; /* start of string to insert */
3015 - uInt match_start; /* start of matching string */
3016 - uInt lookahead; /* number of valid bytes ahead in window */
3019 - /* Length of the best match at previous step. Matches not greater than this
3020 - * are discarded. This is used in the lazy match evaluation.
3023 - uInt max_chain_length;
3024 - /* To speed up deflation, hash chains are never searched beyond this
3025 - * length. A higher limit improves compression ratio but degrades the
3029 - uInt max_lazy_match;
3030 - /* Attempt to find a better match only when the current match is strictly
3031 - * smaller than this value. This mechanism is used only for compression
3034 -# define max_insert_length max_lazy_match
3035 - /* Insert new strings in the hash table only if the match length is not
3036 - * greater than this length. This saves time but degrades compression.
3037 - * max_insert_length is used only for compression levels <= 3.
3040 - int level; /* compression level (1..9) */
3041 - int strategy; /* favor or force Huffman coding*/
3044 - /* Use a faster search when the previous match is longer than this */
3046 - int nice_match; /* Stop searching when current match exceeds this */
3048 - /* used by trees.c: */
3049 - /* Didn't use ct_data typedef below to supress compiler warning */
3050 - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
3051 - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
3052 - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
3054 - struct tree_desc_s l_desc; /* desc. for literal tree */
3055 - struct tree_desc_s d_desc; /* desc. for distance tree */
3056 - struct tree_desc_s bl_desc; /* desc. for bit length tree */
3058 - ush bl_count[MAX_BITS+1];
3059 - /* number of codes at each bit length for an optimal tree */
3061 - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
3062 - int heap_len; /* number of elements in the heap */
3063 - int heap_max; /* element of largest frequency */
3064 - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
3065 - * The same heap array is used to build all trees.
3068 - uch depth[2*L_CODES+1];
3069 - /* Depth of each subtree used as tie breaker for trees of equal frequency
3072 - uchf *l_buf; /* buffer for literals or lengths */
3075 - /* Size of match buffer for literals/lengths. There are 4 reasons for
3076 - * limiting lit_bufsize to 64K:
3077 - * - frequencies can be kept in 16 bit counters
3078 - * - if compression is not successful for the first block, all input
3079 - * data is still in the window so we can still emit a stored block even
3080 - * when input comes from standard input. (This can also be done for
3081 - * all blocks if lit_bufsize is not greater than 32K.)
3082 - * - if compression is not successful for a file smaller than 64K, we can
3083 - * even emit a stored file instead of a stored block (saving 5 bytes).
3084 - * This is applicable only for zip (not gzip or zlib).
3085 - * - creating new Huffman trees less frequently may not provide fast
3086 - * adaptation to changes in the input data statistics. (Take for
3087 - * example a binary file with poorly compressible code followed by
3088 - * a highly compressible string table.) Smaller buffer sizes give
3089 - * fast adaptation but have of course the overhead of transmitting
3090 - * trees more frequently.
3091 - * - I can't count above 4
3094 - uInt last_lit; /* running index in l_buf */
3097 - /* Buffer for distances. To simplify the code, d_buf and l_buf have
3098 - * the same number of elements. To use different lengths, an extra flag
3099 - * array would be necessary.
3102 - ulg opt_len; /* bit length of current block with optimal trees */
3103 - ulg static_len; /* bit length of current block with static trees */
3104 - uInt matches; /* number of string matches in current block */
3105 - int last_eob_len; /* bit length of EOB code for last block */
3108 - ulg compressed_len; /* total bit length of compressed file mod 2^32 */
3109 - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
3113 - /* Output buffer. bits are inserted starting at the bottom (least
3114 - * significant bits).
3117 - /* Number of valid bits in bi_buf. All bits above the last valid bit
3118 - * are always zero.
3121 -} FAR deflate_state;
3123 -/* Output a byte on the stream.
3124 - * IN assertion: there is enough room in pending_buf.
3126 -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
3129 -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
3130 -/* Minimum amount of lookahead, except at the end of the input file.
3131 - * See deflate.c for comments about the MIN_MATCH+1.
3134 -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
3135 -/* In order to simplify the code, particularly on 16 bit machines, match
3136 - * distances are limited to MAX_DIST instead of WSIZE.
3140 -void _tr_init OF((deflate_state *s));
3141 -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
3142 -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
3144 -void _tr_align OF((deflate_state *s));
3145 -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
3148 -#define d_code(dist) \
3149 - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
3150 -/* Mapping from a distance to a distance code. dist is the distance - 1 and
3151 - * must not have side effects. _dist_code[256] and _dist_code[257] are never
3156 -/* Inline versions of _tr_tally for speed: */
3158 -#if defined(GEN_TREES_H) || !defined(STDC)
3159 - extern uch _length_code[];
3160 - extern uch _dist_code[];
3162 - extern const uch _length_code[];
3163 - extern const uch _dist_code[];
3166 -# define _tr_tally_lit(s, c, flush) \
3168 - s->d_buf[s->last_lit] = 0; \
3169 - s->l_buf[s->last_lit++] = cc; \
3170 - s->dyn_ltree[cc].Freq++; \
3171 - flush = (s->last_lit == s->lit_bufsize-1); \
3173 -# define _tr_tally_dist(s, distance, length, flush) \
3174 - { uch len = (length); \
3175 - ush dist = (distance); \
3176 - s->d_buf[s->last_lit] = dist; \
3177 - s->l_buf[s->last_lit++] = len; \
3179 - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
3180 - s->dyn_dtree[d_code(dist)].Freq++; \
3181 - flush = (s->last_lit == s->lit_bufsize-1); \
3184 -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
3185 -# define _tr_tally_dist(s, distance, length, flush) \
3186 - flush = _tr_tally(s, distance, length)
3189 -#endif /* DEFLATE_H */
3190 diff -ruN seqinr.orig/src/gzio.c seqinr/src/gzio.c
3191 --- seqinr.orig/src/gzio.c 2007-04-19 11:40:19.000000000 +0200
3192 +++ seqinr/src/gzio.c 1970-01-01 01:00:00.000000000 +0100
3194 -/* gzio.c -- IO on .gz files
3195 - * Copyright (C) 1995-2005 Jean-loup Gailly.
3196 - * For conditions of distribution and use, see copyright notice in zlib.h
3198 - * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
3201 -/* @(#) $Id: gzio.c,v 1.1.2.1 2007-04-19 09:40:18 penel Exp $ */
3203 -#ifdef HAVE_CONFIG_H
3204 -#include <config.h>
3209 -/***Supprime #if !defined(fdopen) && !defined(HAVE_FDOPEN)
3211 -static FILE *fdopen(int fildes, const char *mode)
3220 -#if defined(HAVE_OFF_T) && defined(HAVE_SEEKO)
3221 -#define f_seek fseeko
3222 -#define f_tell ftello
3225 -#define f_seek fseeko64
3226 -#define f_tell ftello64
3228 -#define f_seek fseek
3229 -#define f_tell ftell
3233 -#ifdef NO_DEFLATE /* for compatibility with old definition */
3234 -# define NO_GZCOMPRESS
3237 -#ifndef NO_DUMMY_DECL
3238 -struct internal_state {int dummy;}; /* for buggy compilers */
3243 -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
3245 -# define Z_BUFSIZE 16384
3248 -#ifndef Z_PRINTF_BUFSIZE
3249 -# define Z_PRINTF_BUFSIZE 4096
3253 -# pragma map (fdopen , "\174\174FDOPEN")
3254 - FILE *fdopen(int, const char *);
3258 -extern voidp malloc OF((uInt size));
3259 -extern void free OF((voidpf ptr));
3262 -#define ALLOC(size) malloc(size)
3263 -#define TRYFREE(p) {if (p) free(p);}
3265 -static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
3267 -/* gzip flag byte */
3268 -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
3269 -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
3270 -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
3271 -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
3272 -#define COMMENT 0x10 /* bit 4 set: file comment present */
3273 -#define RESERVED 0xE0 /* bits 5..7: reserved */
3275 -typedef struct gz_stream {
3277 - int z_err; /* error code for last stream operation */
3278 - int z_eof; /* set if end of input file */
3279 - FILE *file; /* .gz file */
3280 - Byte *inbuf; /* input buffer */
3281 - Byte *outbuf; /* output buffer */
3282 - uLong crc; /* crc32 of uncompressed data */
3283 - char *msg; /* error message */
3284 - char *path; /* path name for debugging only */
3285 - int transparent; /* 1 if input file is not a .gz file */
3286 - char mode; /* 'w' or 'r' */
3287 - z_off_t start; /* start of compressed data in file (header skipped) */
3288 - z_off_t in; /* bytes into deflate or inflate */
3289 - z_off_t out; /* bytes out of deflate or inflate */
3290 - int back; /* one character push-back */
3291 - int last; /* true if push-back is last character */
3295 -local gzFile gz_open OF((const char *path, const char *mode, int fd));
3296 -local int do_flush OF((gzFile file, int flush));
3297 -local int get_byte OF((gz_stream *s));
3298 -local void check_header OF((gz_stream *s));
3299 -local int destroy OF((gz_stream *s));
3300 -local void putLong OF((FILE *file, uLong x));
3301 -local uLong getLong OF((gz_stream *s));
3303 -/* ===========================================================================
3304 - Opens a gzip (.gz) file for reading or writing. The mode parameter
3305 - is as in fopen ("rb" or "wb"). The file is given either by file descriptor
3306 - or path name (if fd == -1).
3307 - gz_open returns NULL if the file could not be opened or if there was
3308 - insufficient memory to allocate the (de)compression state; errno
3309 - can be checked to distinguish the two cases (if errno is zero, the
3310 - zlib error is Z_MEM_ERROR).
3312 -local gzFile gz_open (const char *path, const char *mode, int fd)
3315 - int level = Z_DEFAULT_COMPRESSION; /* compression level */
3316 - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
3317 - char *p = (char*)mode;
3319 - char fmode[80]; /* copy of mode, without the compression level */
3322 - if (!path || !mode) return Z_NULL;
3324 - s = (gz_stream *)ALLOC(sizeof(gz_stream));
3325 - if (!s) return Z_NULL;
3327 - s->stream.zalloc = (alloc_func)0;
3328 - s->stream.zfree = (free_func)0;
3329 - s->stream.opaque = (voidpf)0;
3330 - s->stream.next_in = s->inbuf = Z_NULL;
3331 - s->stream.next_out = s->outbuf = Z_NULL;
3332 - s->stream.avail_in = s->stream.avail_out = 0;
3339 - s->crc = crc32(0L, Z_NULL, 0);
3341 - s->transparent = 0;
3343 - s->path = (char*)ALLOC(strlen(path)+1);
3344 - if (s->path == NULL) {
3345 - return destroy(s), (gzFile)Z_NULL;
3347 - strcpy(s->path, path); /* do this early for debugging */
3351 - if (*p == 'r') s->mode = 'r';
3352 - if (*p == 'w' || *p == 'a') s->mode = 'w';
3353 - if (*p >= '0' && *p <= '9') {
3355 - } else if (*p == 'f') {
3356 - strategy = Z_FILTERED;
3357 - } else if (*p == 'h') {
3358 - strategy = Z_HUFFMAN_ONLY;
3359 - } else if (*p == 'R') {
3362 - *m++ = *p; /* copy the mode */
3364 - } while (*p++ && m != fmode + sizeof(fmode));
3365 - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
3367 - if (s->mode == 'w') {
3368 -#ifdef NO_GZCOMPRESS
3369 - err = Z_STREAM_ERROR;
3371 - err = deflateInit2(&(s->stream), level,
3372 - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
3373 - /* windowBits is passed < 0 to suppress zlib header */
3375 - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
3377 - if (err != Z_OK || s->outbuf == Z_NULL) {
3378 - return destroy(s), (gzFile)Z_NULL;
3381 - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
3383 - err = inflateInit2(&(s->stream), -MAX_WBITS);
3384 - /* windowBits is passed < 0 to tell that there is no zlib header.
3385 - * Note that in this case inflate *requires* an extra "dummy" byte
3386 - * after the compressed stream in order to complete decompression and
3387 - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
3388 - * present after the compressed stream.
3390 - if (err != Z_OK || s->inbuf == Z_NULL) {
3391 - return destroy(s), (gzFile)Z_NULL;
3394 - s->stream.avail_out = Z_BUFSIZE;
3397 - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
3399 - if (s->file == NULL) {
3400 - return destroy(s), (gzFile)Z_NULL;
3402 - if (s->mode == 'w') {
3403 - /* Write a very simple .gz header:
3405 - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
3406 - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
3408 - /* We use 10L instead of ftell(s->file) to because ftell causes an
3409 - * fflush on some systems. This version of the library doesn't use
3410 - * start anyway in write mode, so this initialization is not
3414 - check_header(s); /* skip the .gz header */
3415 - s->start = f_tell(s->file) - s->stream.avail_in;
3421 -/* ===========================================================================
3422 - Opens a gzip (.gz) file for reading or writing.
3424 -gzFile ZEXPORT gzopen (const char *path, const char *mode)
3426 - return gz_open (path, mode, -1);
3429 -/* ===========================================================================
3430 - Associate a gzFile with the file descriptor fd. fd is not dup'ed here
3431 - to mimic the behavio(u)r of fdopen.
3433 -gzFile ZEXPORT gzdopen (int fd, const char *mode)
3435 - char name[46]; /* allow for up to 128-bit integers */
3437 - if (fd < 0) return (gzFile)Z_NULL;
3438 - sprintf(name, "<fd:%d>", fd); /* for debugging */
3440 - return gz_open (name, mode, fd);
3443 -/* ===========================================================================
3444 - * Update the compression level and strategy
3446 -int ZEXPORT gzsetparams (gzFile file, int level, int strategy)
3448 - gz_stream *s = (gz_stream*)file;
3450 - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3452 - /* Make room to allow flushing */
3453 - if (s->stream.avail_out == 0) {
3455 - s->stream.next_out = s->outbuf;
3456 - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
3457 - s->z_err = Z_ERRNO;
3459 - s->stream.avail_out = Z_BUFSIZE;
3462 - return deflateParams (&(s->stream), level, strategy);
3465 -/* ===========================================================================
3466 - Read a byte from a gz_stream; update next_in and avail_in. Return EOF
3468 - IN assertion: the stream s has been sucessfully opened for reading.
3470 -local int get_byte(gz_stream *s)
3472 - if (s->z_eof) return EOF;
3473 - if (s->stream.avail_in == 0) {
3475 - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
3476 - if (s->stream.avail_in == 0) {
3478 - if (ferror(s->file)) s->z_err = Z_ERRNO;
3481 - s->stream.next_in = s->inbuf;
3483 - s->stream.avail_in--;
3484 - return *(s->stream.next_in)++;
3487 -/* ===========================================================================
3488 - Check the gzip header of a gz_stream opened for reading. Set the stream
3489 - mode to transparent if the gzip magic header is not present; set s->err
3490 - to Z_DATA_ERROR if the magic header is present but the rest of the header
3492 - IN assertion: the stream s has already been created sucessfully;
3493 - s->stream.avail_in is zero for the first time, but may be non-zero
3494 - for concatenated .gz files.
3496 -local void check_header(gz_stream *s)
3498 - int method; /* method byte */
3499 - int flags; /* flags byte */
3503 - /* Assure two bytes in the buffer so we can peek ahead -- handle case
3504 - where first byte of header is at the end of the buffer after the last
3506 - len = s->stream.avail_in;
3508 - if (len) s->inbuf[0] = s->stream.next_in[0];
3510 - len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
3511 - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
3512 - s->stream.avail_in += len;
3513 - s->stream.next_in = s->inbuf;
3514 - if (s->stream.avail_in < 2) {
3515 - s->transparent = s->stream.avail_in;
3520 - /* Peek ahead to check the gzip magic header */
3521 - if (s->stream.next_in[0] != gz_magic[0] ||
3522 - s->stream.next_in[1] != gz_magic[1]) {
3523 - s->transparent = 1;
3526 - s->stream.avail_in -= 2;
3527 - s->stream.next_in += 2;
3529 - /* Check the rest of the gzip header */
3530 - method = get_byte(s);
3531 - flags = get_byte(s);
3532 - if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
3533 - s->z_err = Z_DATA_ERROR;
3537 - /* Discard time, xflags and OS code: */
3538 - for (len = 0; len < 6; len++) (void)get_byte(s);
3540 - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
3541 - len = (uInt)get_byte(s);
3542 - len += ((uInt)get_byte(s))<<8;
3543 - /* len is garbage if EOF but the loop below will quit anyway */
3544 - while (len-- != 0 && get_byte(s) != EOF) ;
3546 - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
3547 - while ((c = get_byte(s)) != 0 && c != EOF) ;
3549 - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
3550 - while ((c = get_byte(s)) != 0 && c != EOF) ;
3552 - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
3553 - for (len = 0; len < 2; len++) (void)get_byte(s);
3555 - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
3558 - /* ===========================================================================
3559 - * Cleanup then free the given gz_stream. Return a zlib error code.
3560 - Try freeing in the reverse order of allocations.
3562 -local int destroy (gz_stream *s)
3566 - if (!s) return Z_STREAM_ERROR;
3570 - if (s->stream.state != NULL) {
3571 - if (s->mode == 'w') {
3572 -#ifdef NO_GZCOMPRESS
3573 - err = Z_STREAM_ERROR;
3575 - err = deflateEnd(&(s->stream));
3577 - } else if (s->mode == 'r') {
3578 - err = inflateEnd(&(s->stream));
3581 - if (s->file != NULL && fclose(s->file)) {
3583 - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
3587 - if (s->z_err < 0) err = s->z_err;
3589 - TRYFREE(s->inbuf);
3590 - TRYFREE(s->outbuf);
3596 -/* ===========================================================================
3597 - Reads the given number of uncompressed bytes from the compressed file.
3598 - gzread returns the number of bytes actually read (0 for end of file).
3600 -int ZEXPORT gzread (gzFile file, voidp buf, unsigned len)
3602 - gz_stream *s = (gz_stream*)file;
3603 - Bytef *start = (Bytef*)buf; /* starting point for crc computation */
3604 - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
3606 - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
3608 - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
3609 - if (s->z_err == Z_STREAM_END) return 0; /* EOF */
3611 - next_out = (Byte*)buf;
3612 - s->stream.next_out = (Bytef*)buf;
3613 - s->stream.avail_out = len;
3615 - if (s->stream.avail_out && s->back != EOF) {
3616 - *next_out++ = s->back;
3617 - s->stream.next_out++;
3618 - s->stream.avail_out--;
3623 - s->z_err = Z_STREAM_END;
3628 - while (s->stream.avail_out != 0) {
3630 - if (s->transparent) {
3631 - /* Copy first the lookahead bytes: */
3632 - uInt n = s->stream.avail_in;
3633 - if (n > s->stream.avail_out) n = s->stream.avail_out;
3635 - zmemcpy(s->stream.next_out, s->stream.next_in, n);
3637 - s->stream.next_out = next_out;
3638 - s->stream.next_in += n;
3639 - s->stream.avail_out -= n;
3640 - s->stream.avail_in -= n;
3642 - if (s->stream.avail_out > 0) {
3643 - s->stream.avail_out -=
3644 - (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
3646 - len -= s->stream.avail_out;
3649 - if (len == 0) s->z_eof = 1;
3652 - if (s->stream.avail_in == 0 && !s->z_eof) {
3655 - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
3656 - if (s->stream.avail_in == 0) {
3658 - if (ferror(s->file)) {
3659 - s->z_err = Z_ERRNO;
3663 - s->stream.next_in = s->inbuf;
3665 - s->in += s->stream.avail_in;
3666 - s->out += s->stream.avail_out;
3667 - s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
3668 - s->in -= s->stream.avail_in;
3669 - s->out -= s->stream.avail_out;
3671 - if (s->z_err == Z_STREAM_END) {
3672 - /* Check CRC and original size */
3673 - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
3674 - start = s->stream.next_out;
3676 - if (getLong(s) != s->crc) {
3677 - s->z_err = Z_DATA_ERROR;
3680 - /* The uncompressed length returned by above getlong() may be
3681 - * different from s->out in case of concatenated .gz files.
3682 - * Check for such files:
3685 - if (s->z_err == Z_OK) {
3686 - inflateReset(&(s->stream));
3687 - s->crc = crc32(0L, Z_NULL, 0);
3691 - if (s->z_err != Z_OK || s->z_eof) break;
3693 - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
3695 - if (len == s->stream.avail_out &&
3696 - (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
3698 - return (int)(len - s->stream.avail_out);
3702 -/* ===========================================================================
3703 - Reads one byte from the compressed file. gzgetc returns this byte
3704 - or -1 in case of end of file or error.
3706 -int ZEXPORT gzgetc(gzFile file)
3710 - return gzread(file, &c, 1) == 1 ? c : -1;
3714 -/* ===========================================================================
3715 - Push one byte back onto the stream.
3717 -int ZEXPORT gzungetc(int c, gzFile file)
3719 - gz_stream *s = (gz_stream*)file;
3721 - if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
3724 - s->last = (s->z_err == Z_STREAM_END);
3725 - if (s->last) s->z_err = Z_OK;
3731 -/* ===========================================================================
3732 - Reads bytes from the compressed file until len-1 characters are
3733 - read, or a newline character is read and transferred to buf, or an
3734 - end-of-file condition is encountered. The string is then terminated
3735 - with a null character.
3736 - gzgets returns buf, or Z_NULL in case of error.
3738 - The current implementation is not optimized at all.
3740 -char * ZEXPORT gzgets(gzFile file, char *buf, int len)
3743 - if (buf == Z_NULL || len <= 0) return Z_NULL;
3745 - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
3747 - return b == buf && len > 0 ? Z_NULL : b;
3751 -#ifndef NO_GZCOMPRESS
3752 -/* ===========================================================================
3753 - Writes the given number of uncompressed bytes into the compressed file.
3754 - gzwrite returns the number of bytes actually written (0 in case of error).
3756 -int ZEXPORT gzwrite (gzFile file, voidpc buf, unsigned len)
3758 - gz_stream *s = (gz_stream*)file;
3760 - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3762 - s->stream.next_in = (Bytef*)buf;
3763 - s->stream.avail_in = len;
3765 - while (s->stream.avail_in != 0) {
3767 - if (s->stream.avail_out == 0) {
3769 - s->stream.next_out = s->outbuf;
3770 - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
3771 - s->z_err = Z_ERRNO;
3774 - s->stream.avail_out = Z_BUFSIZE;
3776 - s->in += s->stream.avail_in;
3777 - s->out += s->stream.avail_out;
3778 - s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
3779 - s->in -= s->stream.avail_in;
3780 - s->out -= s->stream.avail_out;
3781 - if (s->z_err != Z_OK) break;
3783 - s->crc = crc32(s->crc, (const Bytef *)buf, len);
3785 - return (int)(len - s->stream.avail_in);
3790 -/* ===========================================================================
3791 - Converts, formats, and writes the args to the compressed file under
3792 - control of the format string, as in fprintf. gzprintf returns the number of
3793 - uncompressed bytes actually written (0 in case of error).
3796 -#include <stdarg.h>
3798 -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
3800 - char buf[Z_PRINTF_BUFSIZE];
3804 - buf[sizeof(buf) - 1] = 0;
3805 - va_start(va, format);
3806 -#ifdef NO_vsnprintf
3807 -# ifdef HAS_vsprintf_void
3808 - (void)vsprintf(buf, format, va);
3810 - for (len = 0; len < sizeof(buf); len++)
3811 - if (buf[len] == 0) break;
3813 - len = vsprintf(buf, format, va);
3817 -# ifdef HAS_vsnprintf_void
3818 - (void)vsnprintf(buf, sizeof(buf), format, va);
3820 - len = strlen(buf);
3822 - len = vsnprintf(buf, sizeof(buf), format, va);
3826 - if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
3828 - return gzwrite(file, buf, (unsigned)len);
3830 -#else /* not ANSI C */
3832 -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
3833 - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
3835 - const char *format;
3836 - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
3837 - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
3839 - char buf[Z_PRINTF_BUFSIZE];
3842 - buf[sizeof(buf) - 1] = 0;
3844 -# ifdef HAS_sprintf_void
3845 - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
3846 - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
3847 - for (len = 0; len < sizeof(buf); len++)
3848 - if (buf[len] == 0) break;
3850 - len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
3851 - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
3854 -# ifdef HAS_snprintf_void
3855 - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
3856 - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
3857 - len = strlen(buf);
3859 - len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
3860 - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
3863 - if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
3865 - return gzwrite(file, buf, len);
3868 -#endif /* UNUSED */
3870 -/* ===========================================================================
3871 - Writes c, converted to an unsigned char, into the compressed file.
3872 - gzputc returns the value that was written, or -1 in case of error.
3874 -int ZEXPORT gzputc(gzFile file, int c)
3876 - unsigned char cc = (unsigned char) c; /* required for big endian systems */
3878 - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
3882 -/* ===========================================================================
3883 - Writes the given null-terminated string to the compressed file, excluding
3884 - the terminating null character.
3885 - gzputs returns the number of characters written, or -1 in case of error.
3887 -int ZEXPORT gzputs(gzFile file, const char *s)
3889 - return gzwrite(file, (char*)s, (unsigned)strlen(s));
3893 -/* ===========================================================================
3894 - Flushes all pending output into the compressed file. The parameter
3895 - flush is as in the deflate() function.
3897 -local int do_flush (gzFile file, int flush)
3901 - gz_stream *s = (gz_stream*)file;
3903 - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3905 - s->stream.avail_in = 0; /* should be zero already anyway */
3908 - len = Z_BUFSIZE - s->stream.avail_out;
3911 - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
3912 - s->z_err = Z_ERRNO;
3915 - s->stream.next_out = s->outbuf;
3916 - s->stream.avail_out = Z_BUFSIZE;
3919 - s->out += s->stream.avail_out;
3920 - s->z_err = deflate(&(s->stream), flush);
3921 - s->out -= s->stream.avail_out;
3923 - /* Ignore the second of two consecutive flushes: */
3924 - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
3926 - /* deflate has finished flushing only when it hasn't used up
3927 - * all the available space in the output buffer:
3929 - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
3931 - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
3933 - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
3936 -int ZEXPORT gzflush (gzFile file, int flush)
3938 - gz_stream *s = (gz_stream*)file;
3939 - int err = do_flush (file, flush);
3941 - if (err) return err;
3943 - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
3945 -#endif /* NO_GZCOMPRESS */
3947 -/* ===========================================================================
3948 - Sets the starting position for the next gzread or gzwrite on the given
3949 - compressed file. The offset represents a number of bytes in the
3950 - gzseek returns the resulting offset location as measured in bytes from
3951 - the beginning of the uncompressed stream, or -1 in case of error.
3952 - SEEK_END is not implemented, returns error.
3953 - In this version of the library, gzseek can be extremely slow.
3955 -z_off_t ZEXPORT gzseek (gzFile file, z_off_t offset, int whence)
3957 - gz_stream *s = (gz_stream*)file;
3959 - if (s == NULL || whence == SEEK_END ||
3960 - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
3964 - if (s->mode == 'w') {
3965 -#ifdef NO_GZCOMPRESS
3968 - if (whence == SEEK_SET) {
3971 - if (offset < 0) return -1L;
3973 - /* At this point, offset is the number of zero bytes to write. */
3974 - if (s->inbuf == Z_NULL) {
3975 - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
3976 - if (s->inbuf == Z_NULL) return -1L;
3977 - zmemzero(s->inbuf, Z_BUFSIZE);
3979 - while (offset > 0) {
3980 - uInt size = Z_BUFSIZE;
3981 - if (offset < Z_BUFSIZE) size = (uInt)offset;
3983 - size = gzwrite(file, s->inbuf, size);
3984 - if (size == 0) return -1L;
3991 - /* Rest of function is for reading only */
3993 - /* compute absolute position */
3994 - if (whence == SEEK_CUR) {
3997 - if (offset < 0) return -1L;
3999 - if (s->transparent) {
4000 - /* map to fseek */
4002 - s->stream.avail_in = 0;
4003 - s->stream.next_in = s->inbuf;
4004 - if (f_seek(s->file, offset, SEEK_SET) < 0) return -1L;
4006 - s->in = s->out = offset;
4010 - /* For a negative seek, rewind and use positive seek */
4011 - if (offset >= s->out) {
4013 - } else if (gzrewind(file) < 0) {
4016 - /* offset is now the number of bytes to skip. */
4018 - if (offset != 0 && s->outbuf == Z_NULL) {
4019 - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
4020 - if (s->outbuf == Z_NULL) return -1L;
4022 - if (offset && s->back != EOF) {
4026 - if (s->last) s->z_err = Z_STREAM_END;
4028 - while (offset > 0) {
4029 - int size = Z_BUFSIZE;
4030 - if (offset < Z_BUFSIZE) size = (int)offset;
4032 - size = gzread(file, s->outbuf, (uInt)size);
4033 - if (size <= 0) return -1L;
4039 -/* ===========================================================================
4040 - Rewinds input file.
4042 -int ZEXPORT gzrewind (gzFile file)
4044 - gz_stream *s = (gz_stream*)file;
4046 - if (s == NULL || s->mode != 'r') return -1;
4051 - s->stream.avail_in = 0;
4052 - s->stream.next_in = s->inbuf;
4053 - s->crc = crc32(0L, Z_NULL, 0);
4054 - if (!s->transparent) (void)inflateReset(&s->stream);
4057 - return f_seek(s->file, s->start, SEEK_SET);
4060 -/* ===========================================================================
4061 - Returns the starting position for the next gzread or gzwrite on the
4062 - given compressed file. This position represents a number of bytes in the
4063 - uncompressed data stream.
4065 -z_off_t ZEXPORT gztell (gzFile file)
4067 - return gzseek(file, 0L, SEEK_CUR);
4070 -/* ===========================================================================
4071 - Returns 1 when EOF has previously been detected reading the given
4072 - input stream, otherwise zero.
4074 -int ZEXPORT gzeof (gzFile file)
4076 - gz_stream *s = (gz_stream*)file;
4078 - /* With concatenated compressed files that can have embedded
4079 - * crc trailers, z_eof is no longer the only/best indicator of EOF
4080 - * on a gz_stream. Handle end-of-stream error explicitly here.
4082 - if (s == NULL || s->mode != 'r') return 0;
4083 - if (s->z_eof) return 1;
4084 - return s->z_err == Z_STREAM_END;
4087 -/* ===========================================================================
4088 - Returns 1 if reading and doing so transparently, otherwise zero.
4090 -int ZEXPORT gzdirect (gzFile file)
4092 - gz_stream *s = (gz_stream*)file;
4094 - if (s == NULL || s->mode != 'r') return 0;
4095 - return s->transparent;
4098 -/* ===========================================================================
4099 - Outputs a long in LSB order to the given file
4101 -local void putLong (FILE *file, uLong x)
4104 - for (n = 0; n < 4; n++) {
4105 - fputc((int)(x & 0xff), file);
4110 -/* ===========================================================================
4111 - Reads a long in LSB order from the given gz_stream. Sets z_err in case
4114 -local uLong getLong (gz_stream *s)
4116 - uLong x = (uLong)get_byte(s);
4119 - x += ((uLong)get_byte(s))<<8;
4120 - x += ((uLong)get_byte(s))<<16;
4122 - if (c == EOF) s->z_err = Z_DATA_ERROR;
4123 - x += ((uLong)c)<<24;
4127 -/* ===========================================================================
4128 - Flushes all pending output if necessary, closes the compressed file
4129 - and deallocates all the (de)compression state.
4131 -int ZEXPORT gzclose (gzFile file)
4133 - gz_stream *s = (gz_stream*)file;
4135 - if (s == NULL) return Z_STREAM_ERROR;
4137 - if (s->mode == 'w') {
4138 -#ifdef NO_GZCOMPRESS
4139 - return Z_STREAM_ERROR;
4141 - if (do_flush (file, Z_FINISH) != Z_OK)
4142 - return destroy((gz_stream*)file);
4144 - putLong (s->file, s->crc);
4145 - putLong (s->file, (uLong)(s->in & 0xffffffff));
4148 - return destroy((gz_stream*)file);
4152 -# define zstrerror(errnum) strerror(errnum)
4154 -# define zstrerror(errnum) ""
4157 -/* ===========================================================================
4158 - Returns the error message for the last error which occurred on the
4159 - given compressed file. errnum is set to zlib error number. If an
4160 - error occurred in the file system and not in the compression library,
4161 - errnum is set to Z_ERRNO and the application may consult errno
4162 - to get the exact error code.
4164 -const char * ZEXPORT gzerror (gzFile file, int *errnum)
4167 - gz_stream *s = (gz_stream*)file;
4170 - *errnum = Z_STREAM_ERROR;
4171 - return (const char*)ERR_MSG(Z_STREAM_ERROR);
4173 - *errnum = s->z_err;
4174 - if (*errnum == Z_OK) return (const char*)"";
4176 - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
4178 - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
4181 - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
4182 - if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
4183 - strcpy(s->msg, s->path);
4184 - strcat(s->msg, ": ");
4185 - strcat(s->msg, m);
4186 - return (const char*)s->msg;
4189 -/* ===========================================================================
4190 - Clear the error and end-of-file flags, and do the same for the real file.
4192 -void ZEXPORT gzclearerr (gzFile file)
4194 - gz_stream *s = (gz_stream*)file;
4196 - if (s == NULL) return;
4197 - if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
4199 - clearerr(s->file);
4201 diff -ruN seqinr.orig/src/infback.c seqinr/src/infback.c
4202 --- seqinr.orig/src/infback.c 2007-04-19 11:40:19.000000000 +0200
4203 +++ seqinr/src/infback.c 1970-01-01 01:00:00.000000000 +0100
4205 -/* infback.c -- inflate using a call-back interface
4206 - * Copyright (C) 1995-2005 Mark Adler
4207 - * For conditions of distribution and use, see copyright notice in zlib.h
4211 - This code is largely copied from inflate.c. Normally either infback.o or
4212 - inflate.o would be linked into an application--not both. The interface
4213 - with inffast.c is retained so that optimized assembler-coded versions of
4214 - inflate_fast() can be used with either inflate.c or infback.c.
4218 -#include "inftrees.h"
4219 -#include "inflate.h"
4220 -#include "inffast.h"
4222 -/* function prototypes */
4223 -local void fixedtables OF((struct inflate_state FAR *state));
4226 - strm provides memory allocation functions in zalloc and zfree, or
4227 - Z_NULL to use the library memory allocation functions.
4229 - windowBits is in the range 8..15, and window is a user-supplied
4230 - window and output buffer that is 2**windowBits bytes.
4232 -int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
4233 - unsigned char *window, const char *version,
4238 -unsigned char FAR *window;
4239 -const char *version;
4243 - struct inflate_state FAR *state;
4245 - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
4246 - stream_size != (int)(sizeof(z_stream)))
4247 - return Z_VERSION_ERROR;
4248 - if (strm == Z_NULL || window == Z_NULL ||
4249 - windowBits < 8 || windowBits > 15)
4250 - return Z_STREAM_ERROR;
4251 - strm->msg = Z_NULL; /* in case we return an error */
4252 - if (strm->zalloc == (alloc_func)0) {
4253 - strm->zalloc = zcalloc;
4254 - strm->opaque = (voidpf)0;
4256 - if (strm->zfree == (free_func)0) strm->zfree = zcfree;
4257 - state = (struct inflate_state FAR *)ZALLOC(strm, 1,
4258 - sizeof(struct inflate_state));
4259 - if (state == Z_NULL) return Z_MEM_ERROR;
4260 - Tracev((stderr, "inflate: allocated\n"));
4261 - strm->state = (struct internal_state FAR *)state;
4262 - state->dmax = 32768U;
4263 - state->wbits = windowBits;
4264 - state->wsize = 1U << windowBits;
4265 - state->window = window;
4272 - Return state with length and distance decoding tables and index sizes set to
4273 - fixed code decoding. Normally this returns fixed tables from inffixed.h.
4274 - If BUILDFIXED is defined, then instead this routine builds the tables the
4275 - first time it's called, and returns those tables the first time and
4276 - thereafter. This reduces the size of the code by about 2K bytes, in
4277 - exchange for a little execution time. However, BUILDFIXED should not be
4278 - used for threaded applications, since the rewriting of the tables and virgin
4279 - may not be thread-safe.
4281 -local void fixedtables(struct inflate_state FAR * state)
4284 - static int virgin = 1;
4285 - static code *lenfix, *distfix;
4286 - static code fixed[544];
4288 - /* build fixed huffman tables if first call (may not be thread safe) */
4290 - unsigned sym, bits;
4291 - static code *next;
4293 - /* literal/length table */
4295 - while (sym < 144) state->lens[sym++] = 8;
4296 - while (sym < 256) state->lens[sym++] = 9;
4297 - while (sym < 280) state->lens[sym++] = 7;
4298 - while (sym < 288) state->lens[sym++] = 8;
4302 - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
4304 - /* distance table */
4306 - while (sym < 32) state->lens[sym++] = 5;
4309 - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
4311 - /* do this just once */
4314 -#else /* !BUILDFIXED */
4315 -# include "inffixed.h"
4316 -#endif /* BUILDFIXED */
4317 - state->lencode = lenfix;
4318 - state->lenbits = 9;
4319 - state->distcode = distfix;
4320 - state->distbits = 5;
4323 -/* Macros for inflateBack(): */
4325 -/* Load returned state from inflate_fast() */
4328 - put = strm->next_out; \
4329 - left = strm->avail_out; \
4330 - next = strm->next_in; \
4331 - have = strm->avail_in; \
4332 - hold = state->hold; \
4333 - bits = state->bits; \
4336 -/* Set state from registers for inflate_fast() */
4337 -#define RESTORE() \
4339 - strm->next_out = put; \
4340 - strm->avail_out = left; \
4341 - strm->next_in = next; \
4342 - strm->avail_in = have; \
4343 - state->hold = hold; \
4344 - state->bits = bits; \
4347 -/* Clear the input bit accumulator */
4348 -#define INITBITS() \
4354 -/* Assure that some input is available. If input is requested, but denied,
4355 - then return a Z_BUF_ERROR from inflateBack(). */
4358 - if (have == 0) { \
4359 - have = in(in_desc, &next); \
4360 - if (have == 0) { \
4362 - ret = Z_BUF_ERROR; \
4368 -/* Get a byte of input into the bit accumulator, or return from inflateBack()
4369 - with an error if there is no input available. */
4370 -#define PULLBYTE() \
4374 - hold += (unsigned long)(*next++) << bits; \
4378 -/* Assure that there are at least n bits in the bit accumulator. If there is
4379 - not enough available input to do that, then return from inflateBack() with
4381 -#define NEEDBITS(n) \
4383 - while (bits < (unsigned)(n)) \
4387 -/* Return the low n bits of the bit accumulator (n < 16) */
4389 - ((unsigned)hold & ((1U << (n)) - 1))
4391 -/* Remove n bits from the bit accumulator */
4392 -#define DROPBITS(n) \
4395 - bits -= (unsigned)(n); \
4398 -/* Remove zero to seven bits as needed to go to a byte boundary */
4399 -#define BYTEBITS() \
4401 - hold >>= bits & 7; \
4402 - bits -= bits & 7; \
4405 -/* Assure that some output space is available, by writing out the window
4406 - if it's full. If the write fails, return from inflateBack() with a
4410 - if (left == 0) { \
4411 - put = state->window; \
4412 - left = state->wsize; \
4413 - state->whave = left; \
4414 - if (out(out_desc, put, left)) { \
4415 - ret = Z_BUF_ERROR; \
4422 - strm provides the memory allocation functions and window buffer on input,
4423 - and provides information on the unused input on return. For Z_DATA_ERROR
4424 - returns, strm will also provide an error message.
4426 - in() and out() are the call-back input and output functions. When
4427 - inflateBack() needs more input, it calls in(). When inflateBack() has
4428 - filled the window with output, or when it completes with data in the
4429 - window, it calls out() to write out the data. The application must not
4430 - change the provided input until in() is called again or inflateBack()
4431 - returns. The application must not change the window/output buffer until
4432 - inflateBack() returns.
4434 - in() and out() are called with a descriptor parameter provided in the
4435 - inflateBack() call. This parameter can be a structure that provides the
4436 - information required to do the read or write, as well as accumulated
4437 - information on the input and output such as totals and check values.
4439 - in() should return zero on failure. out() should return non-zero on
4440 - failure. If either in() or out() fails, than inflateBack() returns a
4441 - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
4442 - was in() or out() that caused in the error. Otherwise, inflateBack()
4443 - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
4444 - error, or Z_MEM_ERROR if it could not allocate memory for the state.
4445 - inflateBack() can also return Z_STREAM_ERROR if the input parameters
4446 - are not correct, i.e. strm is Z_NULL or the state was not initialized.
4448 -int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
4449 - out_func out, void FAR *out_desc)
4455 -void FAR *out_desc;
4458 - struct inflate_state FAR *state;
4459 - unsigned char FAR *next; /* next input */
4460 - unsigned char FAR *put; /* next output */
4461 - unsigned have, left; /* available input and output */
4462 - unsigned long hold; /* bit buffer */
4463 - unsigned bits; /* bits in bit buffer */
4464 - unsigned copy; /* number of stored or match bytes to copy */
4465 - unsigned char FAR *from; /* where to copy match bytes from */
4466 - code This; /* current decoding table entry */
4467 - code last; /* parent table entry */
4468 - unsigned len; /* length to copy for repeats, bits to drop */
4469 - int ret; /* return code */
4470 - static const unsigned short order[19] = /* permutation of code lengths */
4471 - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
4473 - /* Check that the strm exists and that the state was initialized */
4474 - if (strm == Z_NULL || strm->state == Z_NULL)
4475 - return Z_STREAM_ERROR;
4476 - state = (struct inflate_state FAR *)strm->state;
4478 - /* Reset the state */
4479 - strm->msg = Z_NULL;
4480 - state->mode = TYPE;
4483 - next = strm->next_in;
4484 - have = next != Z_NULL ? strm->avail_in : 0;
4487 - put = state->window;
4488 - left = state->wsize;
4490 - /* Inflate until end of block marked as last */
4492 - switch (state->mode) {
4494 - /* determine and dispatch block type */
4495 - if (state->last) {
4497 - state->mode = DONE;
4501 - state->last = BITS(1);
4503 - switch (BITS(2)) {
4504 - case 0: /* stored block */
4505 - Tracev((stderr, "inflate: stored block%s\n",
4506 - state->last ? " (last)" : ""));
4507 - state->mode = STORED;
4509 - case 1: /* fixed block */
4510 - fixedtables(state);
4511 - Tracev((stderr, "inflate: fixed codes block%s\n",
4512 - state->last ? " (last)" : ""));
4513 - state->mode = LEN; /* decode codes */
4515 - case 2: /* dynamic block */
4516 - Tracev((stderr, "inflate: dynamic codes block%s\n",
4517 - state->last ? " (last)" : ""));
4518 - state->mode = TABLE;
4521 - strm->msg = (char *)"invalid block type";
4522 - state->mode = BAD;
4528 - /* get and verify stored block length */
4529 - BYTEBITS(); /* go to byte boundary */
4531 - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
4532 - strm->msg = (char *)"invalid stored block lengths";
4533 - state->mode = BAD;
4536 - state->length = (unsigned)hold & 0xffff;
4537 - Tracev((stderr, "inflate: stored length %u\n",
4541 - /* copy stored block from input to output */
4542 - while (state->length != 0) {
4543 - copy = state->length;
4546 - if (copy > have) copy = have;
4547 - if (copy > left) copy = left;
4548 - zmemcpy(put, next, copy);
4553 - state->length -= copy;
4555 - Tracev((stderr, "inflate: stored end\n"));
4556 - state->mode = TYPE;
4560 - /* get dynamic table entries descriptor */
4562 - state->nlen = BITS(5) + 257;
4564 - state->ndist = BITS(5) + 1;
4566 - state->ncode = BITS(4) + 4;
4568 -#ifndef PKZIP_BUG_WORKAROUND
4569 - if (state->nlen > 286 || state->ndist > 30) {
4570 - strm->msg = (char *)"too many length or distance symbols";
4571 - state->mode = BAD;
4575 - Tracev((stderr, "inflate: table sizes ok\n"));
4577 - /* get code length code lengths (not a typo) */
4579 - while (state->have < state->ncode) {
4581 - state->lens[order[state->have++]] = (unsigned short)BITS(3);
4584 - while (state->have < 19)
4585 - state->lens[order[state->have++]] = 0;
4586 - state->next = state->codes;
4587 - state->lencode = (code const FAR *)(state->next);
4588 - state->lenbits = 7;
4589 - ret = inflate_table(CODES, state->lens, 19, &(state->next),
4590 - &(state->lenbits), state->work);
4592 - strm->msg = (char *)"invalid code lengths set";
4593 - state->mode = BAD;
4596 - Tracev((stderr, "inflate: code lengths ok\n"));
4598 - /* get length and distance code code lengths */
4600 - while (state->have < state->nlen + state->ndist) {
4602 - This = state->lencode[BITS(state->lenbits)];
4603 - if ((unsigned)(This.bits) <= bits) break;
4606 - if (This.val < 16) {
4607 - NEEDBITS(This.bits);
4608 - DROPBITS(This.bits);
4609 - state->lens[state->have++] = This.val;
4612 - if (This.val == 16) {
4613 - NEEDBITS(This.bits + 2);
4614 - DROPBITS(This.bits);
4615 - if (state->have == 0) {
4616 - strm->msg = (char *)"invalid bit length repeat";
4617 - state->mode = BAD;
4620 - len = (unsigned)(state->lens[state->have - 1]);
4621 - copy = 3 + BITS(2);
4624 - else if (This.val == 17) {
4625 - NEEDBITS(This.bits + 3);
4626 - DROPBITS(This.bits);
4628 - copy = 3 + BITS(3);
4632 - NEEDBITS(This.bits + 7);
4633 - DROPBITS(This.bits);
4635 - copy = 11 + BITS(7);
4638 - if (state->have + copy > state->nlen + state->ndist) {
4639 - strm->msg = (char *)"invalid bit length repeat";
4640 - state->mode = BAD;
4644 - state->lens[state->have++] = (unsigned short)len;
4648 - /* handle error breaks in while */
4649 - if (state->mode == BAD) break;
4651 - /* build code tables */
4652 - state->next = state->codes;
4653 - state->lencode = (code const FAR *)(state->next);
4654 - state->lenbits = 9;
4655 - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
4656 - &(state->lenbits), state->work);
4658 - strm->msg = (char *)"invalid literal/lengths set";
4659 - state->mode = BAD;
4662 - state->distcode = (code const FAR *)(state->next);
4663 - state->distbits = 6;
4664 - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
4665 - &(state->next), &(state->distbits), state->work);
4667 - strm->msg = (char *)"invalid distances set";
4668 - state->mode = BAD;
4671 - Tracev((stderr, "inflate: codes ok\n"));
4672 - state->mode = LEN;
4675 - /* use inflate_fast() if we have enough input and output */
4676 - if (have >= 6 && left >= 258) {
4678 - if (state->whave < state->wsize)
4679 - state->whave = state->wsize - left;
4680 - inflate_fast(strm, state->wsize);
4685 - /* get a literal, length, or end-of-block code */
4687 - This = state->lencode[BITS(state->lenbits)];
4688 - if ((unsigned)(This.bits) <= bits) break;
4691 - if (This.op && (This.op & 0xf0) == 0) {
4694 - This = state->lencode[last.val +
4695 - (BITS(last.bits + last.op) >> last.bits)];
4696 - if ((unsigned)(last.bits + This.bits) <= bits) break;
4699 - DROPBITS(last.bits);
4701 - DROPBITS(This.bits);
4702 - state->length = (unsigned)This.val;
4704 - /* process literal */
4705 - if (This.op == 0) {
4706 - Tracevv((stderr, This.val >= 0x20 && This.val < 0x7f ?
4707 - "inflate: literal '%c'\n" :
4708 - "inflate: literal 0x%02x\n", This.val));
4710 - *put++ = (unsigned char)(state->length);
4712 - state->mode = LEN;
4716 - /* process end of block */
4717 - if (This.op & 32) {
4718 - Tracevv((stderr, "inflate: end of block\n"));
4719 - state->mode = TYPE;
4723 - /* invalid code */
4724 - if (This.op & 64) {
4725 - strm->msg = (char *)"invalid literal/length code";
4726 - state->mode = BAD;
4730 - /* length code -- get extra bits, if any */
4731 - state->extra = (unsigned)(This.op) & 15;
4732 - if (state->extra != 0) {
4733 - NEEDBITS(state->extra);
4734 - state->length += BITS(state->extra);
4735 - DROPBITS(state->extra);
4737 - Tracevv((stderr, "inflate: length %u\n", state->length));
4739 - /* get distance code */
4741 - This = state->distcode[BITS(state->distbits)];
4742 - if ((unsigned)(This.bits) <= bits) break;
4745 - if ((This.op & 0xf0) == 0) {
4748 - This = state->distcode[last.val +
4749 - (BITS(last.bits + last.op) >> last.bits)];
4750 - if ((unsigned)(last.bits + This.bits) <= bits) break;
4753 - DROPBITS(last.bits);
4755 - DROPBITS(This.bits);
4756 - if (This.op & 64) {
4757 - strm->msg = (char *)"invalid distance code";
4758 - state->mode = BAD;
4761 - state->offset = (unsigned)This.val;
4763 - /* get distance extra bits, if any */
4764 - state->extra = (unsigned)(This.op) & 15;
4765 - if (state->extra != 0) {
4766 - NEEDBITS(state->extra);
4767 - state->offset += BITS(state->extra);
4768 - DROPBITS(state->extra);
4770 - if (state->offset > state->wsize - (state->whave < state->wsize ?
4772 - strm->msg = (char *)"invalid distance too far back";
4773 - state->mode = BAD;
4776 - Tracevv((stderr, "inflate: distance %u\n", state->offset));
4778 - /* copy match from window to output */
4781 - copy = state->wsize - state->offset;
4782 - if (copy < left) {
4783 - from = put + copy;
4784 - copy = left - copy;
4787 - from = put - state->offset;
4790 - if (copy > state->length) copy = state->length;
4791 - state->length -= copy;
4796 - } while (state->length != 0);
4800 - /* inflate stream terminated properly -- write leftover output */
4801 - ret = Z_STREAM_END;
4802 - if (left < state->wsize) {
4803 - if (out(out_desc, state->window, state->wsize - left))
4804 - ret = Z_BUF_ERROR;
4809 - ret = Z_DATA_ERROR;
4812 - default: /* can't happen, but makes compilers happy */
4813 - ret = Z_STREAM_ERROR;
4817 - /* Return unused input */
4819 - strm->next_in = next;
4820 - strm->avail_in = have;
4824 -int ZEXPORT inflateBackEnd(z_streamp strm)
4826 - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
4827 - return Z_STREAM_ERROR;
4828 - ZFREE(strm, strm->state);
4829 - strm->state = Z_NULL;
4830 - Tracev((stderr, "inflate: end\n"));
4833 diff -ruN seqinr.orig/src/inffast.c seqinr/src/inffast.c
4834 --- seqinr.orig/src/inffast.c 2007-04-19 11:40:19.000000000 +0200
4835 +++ seqinr/src/inffast.c 1970-01-01 01:00:00.000000000 +0100
4837 -/* inffast.c -- fast decoding
4838 - * Copyright (C) 1995-2004 Mark Adler
4839 - * For conditions of distribution and use, see copyright notice in zlib.h
4843 -#include "inftrees.h"
4844 -#include "inflate.h"
4845 -#include "inffast.h"
4849 -/* Allow machine dependent optimization for post-increment or pre-increment.
4850 - Based on testing to date,
4851 - Pre-increment preferred for:
4852 - - PowerPC G3 (Adler)
4853 - - MIPS R5000 (Randers-Pehrson)
4854 - Post-increment preferred for:
4856 - No measurable difference:
4857 - - Pentium III (Anderson)
4862 -# define PUP(a) *(a)++
4865 -# define PUP(a) *++(a)
4869 - Decode literal, length, and distance codes and write out the resulting
4870 - literal and match bytes until either not enough input or output is
4871 - available, an end-of-block is encountered, or a data error is encountered.
4872 - When large enough input and output buffers are supplied to inflate(), for
4873 - example, a 16K input buffer and a 64K output buffer, more than 95% of the
4874 - inflate execution time is spent in this routine.
4876 - Entry assumptions:
4878 - state->mode == LEN
4879 - strm->avail_in >= 6
4880 - strm->avail_out >= 258
4881 - start >= strm->avail_out
4884 - On return, state->mode is one of:
4886 - LEN -- ran out of enough output space or enough available input
4887 - TYPE -- reached end of block code, inflate() to interpret next block
4888 - BAD -- error in block data
4892 - - The maximum input bits used by a length/distance pair is 15 bits for the
4893 - length code, 5 bits for the length extra, 15 bits for the distance code,
4894 - and 13 bits for the distance extra. This totals 48 bits, or six bytes.
4895 - Therefore if strm->avail_in >= 6, then there is enough input to avoid
4896 - checking for available input while decoding.
4898 - - The maximum bytes that a single length/distance pair can output is 258
4899 - bytes, which is the maximum length that can be coded. inflate_fast()
4900 - requires strm->avail_out >= 258 for each loop to avoid checking for
4903 -void inflate_fast(z_streamp strm, unsigned start)
4906 -unsigned start; /* inflate()'s starting value for strm->avail_out */
4909 - struct inflate_state FAR *state;
4910 - unsigned char FAR *in; /* local strm->next_in */
4911 - unsigned char FAR *last; /* while in < last, enough input available */
4912 - unsigned char FAR *out; /* local strm->next_out */
4913 - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
4914 - unsigned char FAR *end; /* while out < end, enough space available */
4915 -#ifdef INFLATE_STRICT
4916 - unsigned dmax; /* maximum distance from zlib header */
4918 - unsigned wsize; /* window size or zero if not using window */
4919 - unsigned whave; /* valid bytes in the window */
4920 - unsigned write; /* window write index */
4921 - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
4922 - unsigned long hold; /* local strm->hold */
4923 - unsigned bits; /* local strm->bits */
4924 - code const FAR *lcode; /* local strm->lencode */
4925 - code const FAR *dcode; /* local strm->distcode */
4926 - unsigned lmask; /* mask for first level of length codes */
4927 - unsigned dmask; /* mask for first level of distance codes */
4928 - code This; /* retrieved table entry */
4929 - unsigned op; /* code bits, operation, extra bits, or */
4930 - /* window position, window bytes to copy */
4931 - unsigned len; /* match length, unused bytes */
4932 - unsigned dist; /* match distance */
4933 - unsigned char FAR *from; /* where to copy match from */
4935 - /* copy state to local variables */
4936 - state = (struct inflate_state FAR *)strm->state;
4937 - in = strm->next_in - OFF;
4938 - last = in + (strm->avail_in - 5);
4939 - out = strm->next_out - OFF;
4940 - beg = out - (start - strm->avail_out);
4941 - end = out + (strm->avail_out - 257);
4942 -#ifdef INFLATE_STRICT
4943 - dmax = state->dmax;
4945 - wsize = state->wsize;
4946 - whave = state->whave;
4947 - write = state->write;
4948 - window = state->window;
4949 - hold = state->hold;
4950 - bits = state->bits;
4951 - lcode = state->lencode;
4952 - dcode = state->distcode;
4953 - lmask = (1U << state->lenbits) - 1;
4954 - dmask = (1U << state->distbits) - 1;
4956 - /* decode literals and length/distances until end-of-block or not enough
4957 - input data or output space */
4960 - hold += (unsigned long)(PUP(in)) << bits;
4962 - hold += (unsigned long)(PUP(in)) << bits;
4965 - This = lcode[hold & lmask];
4967 - op = (unsigned)(This.bits);
4970 - op = (unsigned)(This.op);
4971 - if (op == 0) { /* literal */
4972 - Tracevv((stderr, This.val >= 0x20 && This.val < 0x7f ?
4973 - "inflate: literal '%c'\n" :
4974 - "inflate: literal 0x%02x\n", This.val));
4975 - PUP(out) = (unsigned char)(This.val);
4977 - else if (op & 16) { /* length base */
4978 - len = (unsigned)(This.val);
4979 - op &= 15; /* number of extra bits */
4982 - hold += (unsigned long)(PUP(in)) << bits;
4985 - len += (unsigned)hold & ((1U << op) - 1);
4989 - Tracevv((stderr, "inflate: length %u\n", len));
4991 - hold += (unsigned long)(PUP(in)) << bits;
4993 - hold += (unsigned long)(PUP(in)) << bits;
4996 - This = dcode[hold & dmask];
4998 - op = (unsigned)(This.bits);
5001 - op = (unsigned)(This.op);
5002 - if (op & 16) { /* distance base */
5003 - dist = (unsigned)(This.val);
5004 - op &= 15; /* number of extra bits */
5006 - hold += (unsigned long)(PUP(in)) << bits;
5009 - hold += (unsigned long)(PUP(in)) << bits;
5013 - dist += (unsigned)hold & ((1U << op) - 1);
5014 -#ifdef INFLATE_STRICT
5015 - if (dist > dmax) {
5016 - strm->msg = (char *)"invalid distance too far back";
5017 - state->mode = BAD;
5023 - Tracevv((stderr, "inflate: distance %u\n", dist));
5024 - op = (unsigned)(out - beg); /* max distance in output */
5025 - if (dist > op) { /* see if copy from window */
5026 - op = dist - op; /* distance back in window */
5028 - strm->msg = (char *)"invalid distance too far back";
5029 - state->mode = BAD;
5032 - from = window - OFF;
5033 - if (write == 0) { /* very common case */
5034 - from += wsize - op;
5035 - if (op < len) { /* some from window */
5038 - PUP(out) = PUP(from);
5040 - from = out - dist; /* rest from output */
5043 - else if (write < op) { /* wrap around window */
5044 - from += wsize + write - op;
5046 - if (op < len) { /* some from end of window */
5049 - PUP(out) = PUP(from);
5051 - from = window - OFF;
5052 - if (write < len) { /* some from start of window */
5056 - PUP(out) = PUP(from);
5058 - from = out - dist; /* rest from output */
5062 - else { /* contiguous in window */
5063 - from += write - op;
5064 - if (op < len) { /* some from window */
5067 - PUP(out) = PUP(from);
5069 - from = out - dist; /* rest from output */
5073 - PUP(out) = PUP(from);
5074 - PUP(out) = PUP(from);
5075 - PUP(out) = PUP(from);
5079 - PUP(out) = PUP(from);
5081 - PUP(out) = PUP(from);
5085 - from = out - dist; /* copy direct from output */
5086 - do { /* minimum length is three */
5087 - PUP(out) = PUP(from);
5088 - PUP(out) = PUP(from);
5089 - PUP(out) = PUP(from);
5091 - } while (len > 2);
5093 - PUP(out) = PUP(from);
5095 - PUP(out) = PUP(from);
5099 - else if ((op & 64) == 0) { /* 2nd level distance code */
5100 - This = dcode[This.val + (hold & ((1U << op) - 1))];
5104 - strm->msg = (char *)"invalid distance code";
5105 - state->mode = BAD;
5109 - else if ((op & 64) == 0) { /* 2nd level length code */
5110 - This = lcode[This.val + (hold & ((1U << op) - 1))];
5113 - else if (op & 32) { /* end-of-block */
5114 - Tracevv((stderr, "inflate: end of block\n"));
5115 - state->mode = TYPE;
5119 - strm->msg = (char *)"invalid literal/length code";
5120 - state->mode = BAD;
5123 - } while (in < last && out < end);
5125 - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
5129 - hold &= (1U << bits) - 1;
5131 - /* update state and return */
5132 - strm->next_in = in + OFF;
5133 - strm->next_out = out + OFF;
5134 - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
5135 - strm->avail_out = (unsigned)(out < end ?
5136 - 257 + (end - out) : 257 - (out - end));
5137 - state->hold = hold;
5138 - state->bits = bits;
5143 - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
5144 - - Using bit fields for code structure
5145 - - Different op definition to avoid & for extra bits (do & for table bits)
5146 - - Three separate decoding do-loops for direct, window, and write == 0
5147 - - Special case for distance > 1 copies to do overlapped load and store copy
5148 - - Explicit branch predictions (based on measured branch probabilities)
5149 - - Deferring match copy and interspersed it with decoding subsequent codes
5150 - - Swapping literal/length else
5151 - - Swapping window/direct else
5152 - - Larger unrolled copy loops (three is about right)
5153 - - Moving len -= 3 statement into middle of loop
5156 -#endif /* !ASMINF */
5157 diff -ruN seqinr.orig/src/inffast.h seqinr/src/inffast.h
5158 --- seqinr.orig/src/inffast.h 2007-04-19 11:40:19.000000000 +0200
5159 +++ seqinr/src/inffast.h 1970-01-01 01:00:00.000000000 +0100
5161 -/* inffast.h -- header to use inffast.c
5162 - * Copyright (C) 1995-2003 Mark Adler
5163 - * For conditions of distribution and use, see copyright notice in zlib.h
5166 -/* WARNING: this file should *not* be used by applications. It is
5167 - part of the implementation of the compression library and is
5168 - subject to change. Applications should only use zlib.h.
5171 -void inflate_fast OF((z_streamp strm, unsigned start));
5172 diff -ruN seqinr.orig/src/inffixed.h seqinr/src/inffixed.h
5173 --- seqinr.orig/src/inffixed.h 2007-04-19 11:40:19.000000000 +0200
5174 +++ seqinr/src/inffixed.h 1970-01-01 01:00:00.000000000 +0100
5176 - /* inffixed.h -- table for decoding fixed codes
5177 - * Generated automatically by makefixed().
5180 - /* WARNING: this file should *not* be used by applications. It
5181 - is part of the implementation of the compression library and
5182 - is subject to change. Applications should only use zlib.h.
5185 - static const code lenfix[512] = {
5186 - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
5187 - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
5188 - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
5189 - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
5190 - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
5191 - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
5192 - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
5193 - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
5194 - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
5195 - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
5196 - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
5197 - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
5198 - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
5199 - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
5200 - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
5201 - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
5202 - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
5203 - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
5204 - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
5205 - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
5206 - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
5207 - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
5208 - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
5209 - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
5210 - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
5211 - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
5212 - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
5213 - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
5214 - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
5215 - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
5216 - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
5217 - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
5218 - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
5219 - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
5220 - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
5221 - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
5222 - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
5223 - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
5224 - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
5225 - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
5226 - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
5227 - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
5228 - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
5229 - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
5230 - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
5231 - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
5232 - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
5233 - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
5234 - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
5235 - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
5236 - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
5237 - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
5238 - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
5239 - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
5240 - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
5241 - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
5242 - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
5243 - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
5244 - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
5245 - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
5246 - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
5247 - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
5248 - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
5249 - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
5250 - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
5251 - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
5252 - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
5253 - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
5254 - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
5255 - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
5256 - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
5257 - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
5258 - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
5262 - static const code distfix[32] = {
5263 - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
5264 - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
5265 - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
5266 - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
5267 - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
5268 - {22,5,193},{64,5,0}
5270 diff -ruN seqinr.orig/src/inflate.c seqinr/src/inflate.c
5271 --- seqinr.orig/src/inflate.c 2007-04-19 11:40:19.000000000 +0200
5272 +++ seqinr/src/inflate.c 1970-01-01 01:00:00.000000000 +0100
5274 -/* inflate.c -- zlib decompression
5275 - * Copyright (C) 1995-2005 Mark Adler
5276 - * For conditions of distribution and use, see copyright notice in zlib.h
5282 - * 1.2.beta0 24 Nov 2002
5283 - * - First version -- complete rewrite of inflate to simplify code, avoid
5284 - * creation of window when not needed, minimize use of window when it is
5285 - * needed, make inffast.c even faster, implement gzip decoding, and to
5286 - * improve code readability and style over the previous zlib inflate code
5288 - * 1.2.beta1 25 Nov 2002
5289 - * - Use pointers for available input and output checking in inffast.c
5290 - * - Remove input and output counters in inffast.c
5291 - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
5292 - * - Remove unnecessary second byte pull from length extra in inffast.c
5293 - * - Unroll direct copy to three copies per loop in inffast.c
5295 - * 1.2.beta2 4 Dec 2002
5296 - * - Change external routine names to reduce potential conflicts
5297 - * - Correct filename to inffixed.h for fixed tables in inflate.c
5298 - * - Make hbuf[] unsigned char to match parameter type in inflate.c
5299 - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
5300 - * to avoid negation problem on Alphas (64 bit) in inflate.c
5302 - * 1.2.beta3 22 Dec 2002
5303 - * - Add comments on state->bits assertion in inffast.c
5304 - * - Add comments on op field in inftrees.h
5305 - * - Fix bug in reuse of allocated window after inflateReset()
5306 - * - Remove bit fields--back to byte structure for speed
5307 - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
5308 - * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
5309 - * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
5310 - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
5311 - * - Use local copies of stream next and avail values, as well as local bit
5312 - * buffer and bit count in inflate()--for speed when inflate_fast() not used
5314 - * 1.2.beta4 1 Jan 2003
5315 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
5316 - * - Move a comment on output buffer sizes from inffast.c to inflate.c
5317 - * - Add comments in inffast.c to introduce the inflate_fast() routine
5318 - * - Rearrange window copies in inflate_fast() for speed and simplification
5319 - * - Unroll last copy for window match in inflate_fast()
5320 - * - Use local copies of window variables in inflate_fast() for speed
5321 - * - Pull out common write == 0 case for speed in inflate_fast()
5322 - * - Make op and len in inflate_fast() unsigned for consistency
5323 - * - Add FAR to lcode and dcode declarations in inflate_fast()
5324 - * - Simplified bad distance check in inflate_fast()
5325 - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
5326 - * source file infback.c to provide a call-back interface to inflate for
5327 - * programs like gzip and unzip -- uses window as output buffer to avoid
5330 - * 1.2.beta5 1 Jan 2003
5331 - * - Improved inflateBack() interface to allow the caller to provide initial
5333 - * - Fixed stored blocks bug in inflateBack()
5335 - * 1.2.beta6 4 Jan 2003
5336 - * - Added comments in inffast.c on effectiveness of POSTINC
5337 - * - Typecasting all around to reduce compiler warnings
5338 - * - Changed loops from while (1) or do {} while (1) to for (;;), again to
5339 - * make compilers happy
5340 - * - Changed type of window in inflateBackInit() to unsigned char *
5342 - * 1.2.beta7 27 Jan 2003
5343 - * - Changed many types to unsigned or unsigned short to avoid warnings
5344 - * - Added inflateCopy() function
5346 - * 1.2.0 9 Mar 2003
5347 - * - Changed inflateBack() interface to provide separate opaque descriptors
5348 - * for the in() and out() functions
5349 - * - Changed inflateBack() argument and in_func typedef to swap the length
5350 - * and buffer address return values for the input function
5351 - * - Check next_in and next_out for Z_NULL on entry to inflate()
5353 - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
5357 -#include "inftrees.h"
5358 -#include "inflate.h"
5359 -#include "inffast.h"
5363 -# ifndef BUILDFIXED
5364 -# define BUILDFIXED
5368 -/* function prototypes */
5369 -local void fixedtables OF((struct inflate_state FAR *state));
5370 -local int updatewindow OF((z_streamp strm, unsigned out));
5372 - void makefixed OF((void));
5374 -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
5377 -int ZEXPORT inflateReset(z_streamp strm)
5379 - struct inflate_state FAR *state;
5381 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
5382 - state = (struct inflate_state FAR *)strm->state;
5383 - strm->total_in = strm->total_out = state->total = 0;
5384 - strm->msg = Z_NULL;
5385 - strm->adler = 1; /* to support ill-conceived Java test suite */
5386 - state->mode = HEAD;
5388 - state->havedict = 0;
5389 - state->dmax = 32768U;
5390 - state->head = Z_NULL;
5396 - state->lencode = state->distcode = state->next = state->codes;
5397 - Tracev((stderr, "inflate: reset\n"));
5401 -int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
5403 - struct inflate_state FAR *state;
5405 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
5406 - state = (struct inflate_state FAR *)strm->state;
5407 - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
5408 - value &= (1L << bits) - 1;
5409 - state->hold += value << state->bits;
5410 - state->bits += bits;
5414 -int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version,
5417 - struct inflate_state FAR *state;
5419 - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
5420 - stream_size != (int)(sizeof(z_stream)))
5421 - return Z_VERSION_ERROR;
5422 - if (strm == Z_NULL) return Z_STREAM_ERROR;
5423 - strm->msg = Z_NULL; /* in case we return an error */
5424 - if (strm->zalloc == (alloc_func)0) {
5425 - strm->zalloc = zcalloc;
5426 - strm->opaque = (voidpf)0;
5428 - if (strm->zfree == (free_func)0) strm->zfree = zcfree;
5429 - state = (struct inflate_state FAR *)
5430 - ZALLOC(strm, 1, sizeof(struct inflate_state));
5431 - if (state == Z_NULL) return Z_MEM_ERROR;
5432 - Tracev((stderr, "inflate: allocated\n"));
5433 - strm->state = (struct internal_state FAR *)state;
5434 - if (windowBits < 0) {
5436 - windowBits = -windowBits;
5439 - state->wrap = (windowBits >> 4) + 1;
5441 - if (windowBits < 48) windowBits &= 15;
5444 - if (windowBits < 8 || windowBits > 15) {
5445 - ZFREE(strm, state);
5446 - strm->state = Z_NULL;
5447 - return Z_STREAM_ERROR;
5449 - state->wbits = (unsigned)windowBits;
5450 - state->window = Z_NULL;
5451 - return inflateReset(strm);
5454 -int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
5456 - return inflateInit2_(strm, DEF_WBITS, version, stream_size);
5460 - Return state with length and distance decoding tables and index sizes set to
5461 - fixed code decoding. Normally this returns fixed tables from inffixed.h.
5462 - If BUILDFIXED is defined, then instead this routine builds the tables the
5463 - first time it's called, and returns those tables the first time and
5464 - thereafter. This reduces the size of the code by about 2K bytes, in
5465 - exchange for a little execution time. However, BUILDFIXED should not be
5466 - used for threaded applications, since the rewriting of the tables and virgin
5467 - may not be thread-safe.
5469 -local void fixedtables(struct inflate_state FAR *state)
5472 - static int virgin = 1;
5473 - static code *lenfix, *distfix;
5474 - static code fixed[544];
5476 - /* build fixed huffman tables if first call (may not be thread safe) */
5478 - unsigned sym, bits;
5479 - static code *next;
5481 - /* literal/length table */
5483 - while (sym < 144) state->lens[sym++] = 8;
5484 - while (sym < 256) state->lens[sym++] = 9;
5485 - while (sym < 280) state->lens[sym++] = 7;
5486 - while (sym < 288) state->lens[sym++] = 8;
5490 - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
5492 - /* distance table */
5494 - while (sym < 32) state->lens[sym++] = 5;
5497 - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
5499 - /* do this just once */
5502 -#else /* !BUILDFIXED */
5503 -# include "inffixed.h"
5504 -#endif /* BUILDFIXED */
5505 - state->lencode = lenfix;
5506 - state->lenbits = 9;
5507 - state->distcode = distfix;
5508 - state->distbits = 5;
5515 - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
5516 - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
5517 - those tables to stdout, which would be piped to inffixed.h. A small program
5518 - can simply call makefixed to do this:
5520 - void makefixed(void);
5528 - Then that can be linked with zlib built with MAKEFIXED defined and run:
5530 - a.out > inffixed.h
5534 - unsigned low, size;
5535 - struct inflate_state state;
5537 - fixedtables(&state);
5538 - puts(" /* inffixed.h -- table for decoding fixed codes");
5539 - puts(" * Generated automatically by makefixed().");
5542 - puts(" /* WARNING: this file should *not* be used by applications.");
5543 - puts(" It is part of the implementation of this library and is");
5544 - puts(" subject to change. Applications should only use zlib.h.");
5548 - printf(" static const code lenfix[%u] = {", size);
5551 - if ((low % 7) == 0) printf("\n ");
5552 - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
5553 - state.lencode[low].val);
5554 - if (++low == size) break;
5559 - printf("\n static const code distfix[%u] = {", size);
5562 - if ((low % 6) == 0) printf("\n ");
5563 - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
5564 - state.distcode[low].val);
5565 - if (++low == size) break;
5570 -#endif /* MAKEFIXED */
5573 - Update the window with the last wsize (normally 32K) bytes written before
5574 - returning. If window does not exist yet, create it. This is only called
5575 - when a window is already in use, or when output has been written during this
5576 - inflate call, but the end of the deflate stream has not been reached yet.
5577 - It is also called to create a window for dictionary data when a dictionary
5580 - Providing output buffers larger than 32K to inflate() should provide a speed
5581 - advantage, since only the last 32K of output is copied to the sliding window
5582 - upon return from inflate(), and since all distances after the first 32K of
5583 - output will fall in the output data, making match copies simpler and faster.
5584 - The advantage may be dependent on the size of the processor's data caches.
5586 -local int updatewindow(z_streamp strm, unsigned out)
5588 - struct inflate_state FAR *state;
5589 - unsigned copy, dist;
5591 - state = (struct inflate_state FAR *)strm->state;
5593 - /* if it hasn't been done already, allocate space for the window */
5594 - if (state->window == Z_NULL) {
5595 - state->window = (unsigned char FAR *)
5596 - ZALLOC(strm, 1U << state->wbits,
5597 - sizeof(unsigned char));
5598 - if (state->window == Z_NULL) return 1;
5601 - /* if window not in use yet, initialize */
5602 - if (state->wsize == 0) {
5603 - state->wsize = 1U << state->wbits;
5608 - /* copy state->wsize or less output bytes into the circular window */
5609 - copy = out - strm->avail_out;
5610 - if (copy >= state->wsize) {
5611 - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
5613 - state->whave = state->wsize;
5616 - dist = state->wsize - state->write;
5617 - if (dist > copy) dist = copy;
5618 - zmemcpy(state->window + state->write, strm->next_out - copy, dist);
5621 - zmemcpy(state->window, strm->next_out - copy, copy);
5622 - state->write = copy;
5623 - state->whave = state->wsize;
5626 - state->write += dist;
5627 - if (state->write == state->wsize) state->write = 0;
5628 - if (state->whave < state->wsize) state->whave += dist;
5634 -/* Macros for inflate(): */
5636 -/* check function to use adler32() for zlib or crc32() for gzip */
5638 -# define UPDATE(check, buf, len) \
5639 - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
5641 -# define UPDATE(check, buf, len) adler32(check, buf, len)
5644 -/* check macros for header crc */
5646 -# define CRC2(check, word) \
5648 - hbuf[0] = (unsigned char)(word); \
5649 - hbuf[1] = (unsigned char)((word) >> 8); \
5650 - check = crc32(check, hbuf, 2); \
5653 -# define CRC4(check, word) \
5655 - hbuf[0] = (unsigned char)(word); \
5656 - hbuf[1] = (unsigned char)((word) >> 8); \
5657 - hbuf[2] = (unsigned char)((word) >> 16); \
5658 - hbuf[3] = (unsigned char)((word) >> 24); \
5659 - check = crc32(check, hbuf, 4); \
5663 -/* Load registers with state in inflate() for speed */
5666 - put = strm->next_out; \
5667 - left = strm->avail_out; \
5668 - next = strm->next_in; \
5669 - have = strm->avail_in; \
5670 - hold = state->hold; \
5671 - bits = state->bits; \
5674 -/* Restore state from registers in inflate() */
5675 -#define RESTORE() \
5677 - strm->next_out = put; \
5678 - strm->avail_out = left; \
5679 - strm->next_in = next; \
5680 - strm->avail_in = have; \
5681 - state->hold = hold; \
5682 - state->bits = bits; \
5685 -/* Clear the input bit accumulator */
5686 -#define INITBITS() \
5692 -/* Get a byte of input into the bit accumulator, or return from inflate()
5693 - if there is no input available. */
5694 -#define PULLBYTE() \
5696 - if (have == 0) goto inf_leave; \
5698 - hold += (unsigned long)(*next++) << bits; \
5702 -/* Assure that there are at least n bits in the bit accumulator. If there is
5703 - not enough available input to do that, then return from inflate(). */
5704 -#define NEEDBITS(n) \
5706 - while (bits < (unsigned)(n)) \
5710 -/* Return the low n bits of the bit accumulator (n < 16) */
5712 - ((unsigned)hold & ((1U << (n)) - 1))
5714 -/* Remove n bits from the bit accumulator */
5715 -#define DROPBITS(n) \
5718 - bits -= (unsigned)(n); \
5721 -/* Remove zero to seven bits as needed to go to a byte boundary */
5722 -#define BYTEBITS() \
5724 - hold >>= bits & 7; \
5725 - bits -= bits & 7; \
5728 -/* Reverse the bytes in a 32-bit value */
5729 -#define REVERSE(q) \
5730 - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
5731 - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
5734 - inflate() uses a state machine to process as much input data and generate as
5735 - much output data as possible before returning. The state machine is
5736 - structured roughly as follows:
5738 - for (;;) switch (state) {
5741 - if (not enough input data or output space to make progress)
5743 - ... make progress ...
5749 - so when inflate() is called again, the same case is attempted again, and
5750 - if the appropriate resources are provided, the machine proceeds to the
5751 - next state. The NEEDBITS() macro is usually the way the state evaluates
5752 - whether it can proceed or should return. NEEDBITS() does the return if
5753 - the requested bits are not available. The typical use of the BITS macros
5757 - ... do something with BITS(n) ...
5760 - where NEEDBITS(n) either returns from inflate() if there isn't enough
5761 - input left to load n bits into the accumulator, or it continues. BITS(n)
5762 - gives the low n bits in the accumulator. When done, DROPBITS(n) drops
5763 - the low n bits off the accumulator. INITBITS() clears the accumulator
5764 - and sets the number of available bits to zero. BYTEBITS() discards just
5765 - enough bits to put the accumulator on a byte boundary. After BYTEBITS()
5766 - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
5768 - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
5769 - if there is no input available. The decoding of variable length codes uses
5770 - PULLBYTE() directly in order to pull just enough bytes to decode the next
5771 - code, and no more.
5773 - Some states loop until they get enough input, making sure that enough
5774 - state information is maintained to continue the loop where it left off
5775 - if NEEDBITS() returns in the loop. For example, want, need, and keep
5776 - would all have to actually be part of the saved state in case NEEDBITS()
5780 - while (want < need) {
5782 - keep[want++] = BITS(n);
5788 - As shown above, if the next state is also the next case, then the break
5791 - A state may also return if there is not enough output space available to
5792 - complete that state. Those states are copying stored data, writing a
5793 - literal byte, and copying a matching string.
5795 - When returning, a "goto inf_leave" is used to update the total counters,
5796 - update the check value, and determine whether any progress has been made
5797 - during that inflate() call in order to return the proper return code.
5798 - Progress is defined as a change in either strm->avail_in or strm->avail_out.
5799 - When there is a window, goto inf_leave will update the window with the last
5800 - output written. If a goto inf_leave occurs in the middle of decompression
5801 - and there is no window currently, goto inf_leave will create one and copy
5802 - output to the window for the next call of inflate().
5804 - In this implementation, the flush parameter of inflate() only affects the
5805 - return code (per zlib.h). inflate() always writes as much as possible to
5806 - strm->next_out, given the space available and the provided input--the effect
5807 - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
5808 - the allocation of and copying into a sliding window until necessary, which
5809 - provides the effect documented in zlib.h for Z_FINISH when the entire input
5810 - stream available. So the only thing the flush parameter actually does is:
5811 - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
5812 - will return Z_BUF_ERROR if it has not reached the end of the stream.
5815 -int ZEXPORT inflate(z_streamp strm, int flush)
5817 - struct inflate_state FAR *state;
5818 - unsigned char FAR *next; /* next input */
5819 - unsigned char FAR *put; /* next output */
5820 - unsigned have, left; /* available input and output */
5821 - unsigned long hold; /* bit buffer */
5822 - unsigned bits; /* bits in bit buffer */
5823 - unsigned in, out; /* save starting available input and output */
5824 - unsigned copy; /* number of stored or match bytes to copy */
5825 - unsigned char FAR *from; /* where to copy match bytes from */
5826 - code This; /* current decoding table entry */
5827 - code last; /* parent table entry */
5828 - unsigned len; /* length to copy for repeats, bits to drop */
5829 - int ret; /* return code */
5831 - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
5833 - static const unsigned short order[19] = /* permutation of code lengths */
5834 - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
5836 - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
5837 - (strm->next_in == Z_NULL && strm->avail_in != 0))
5838 - return Z_STREAM_ERROR;
5840 - state = (struct inflate_state FAR *)strm->state;
5841 - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
5847 - switch (state->mode) {
5849 - if (state->wrap == 0) {
5850 - state->mode = TYPEDO;
5855 - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
5856 - state->check = crc32(0L, Z_NULL, 0);
5857 - CRC2(state->check, hold);
5859 - state->mode = FLAGS;
5862 - state->flags = 0; /* expect zlib header */
5863 - if (state->head != Z_NULL)
5864 - state->head->done = -1;
5865 - if (!(state->wrap & 1) || /* check if zlib header allowed */
5869 - ((BITS(8) << 8) + (hold >> 8)) % 31) {
5870 - strm->msg = (char *)"incorrect header check";
5871 - state->mode = BAD;
5874 - if (BITS(4) != Z_DEFLATED) {
5875 - strm->msg = (char *)"unknown compression method";
5876 - state->mode = BAD;
5880 - len = BITS(4) + 8;
5881 - if (len > state->wbits) {
5882 - strm->msg = (char *)"invalid window size";
5883 - state->mode = BAD;
5886 - state->dmax = 1U << len;
5887 - Tracev((stderr, "inflate: zlib header ok\n"));
5888 - strm->adler = state->check = adler32(0L, Z_NULL, 0);
5889 - state->mode = hold & 0x200 ? DICTID : TYPE;
5895 - state->flags = (int)(hold);
5896 - if ((state->flags & 0xff) != Z_DEFLATED) {
5897 - strm->msg = (char *)"unknown compression method";
5898 - state->mode = BAD;
5901 - if (state->flags & 0xe000) {
5902 - strm->msg = (char *)"unknown header flags set";
5903 - state->mode = BAD;
5906 - if (state->head != Z_NULL)
5907 - state->head->text = (int)((hold >> 8) & 1);
5908 - if (state->flags & 0x0200) CRC2(state->check, hold);
5910 - state->mode = TIME;
5913 - if (state->head != Z_NULL)
5914 - state->head->time = hold;
5915 - if (state->flags & 0x0200) CRC4(state->check, hold);
5920 - if (state->head != Z_NULL) {
5921 - state->head->xflags = (int)(hold & 0xff);
5922 - state->head->os = (int)(hold >> 8);
5924 - if (state->flags & 0x0200) CRC2(state->check, hold);
5926 - state->mode = EXLEN;
5928 - if (state->flags & 0x0400) {
5930 - state->length = (unsigned)(hold);
5931 - if (state->head != Z_NULL)
5932 - state->head->extra_len = (unsigned)hold;
5933 - if (state->flags & 0x0200) CRC2(state->check, hold);
5936 - else if (state->head != Z_NULL)
5937 - state->head->extra = Z_NULL;
5938 - state->mode = EXTRA;
5940 - if (state->flags & 0x0400) {
5941 - copy = state->length;
5942 - if (copy > have) copy = have;
5944 - if (state->head != Z_NULL &&
5945 - state->head->extra != Z_NULL) {
5946 - len = state->head->extra_len - state->length;
5947 - zmemcpy(state->head->extra + len, next,
5948 - len + copy > state->head->extra_max ?
5949 - state->head->extra_max - len : copy);
5951 - if (state->flags & 0x0200)
5952 - state->check = crc32(state->check, next, copy);
5955 - state->length -= copy;
5957 - if (state->length) goto inf_leave;
5959 - state->length = 0;
5960 - state->mode = NAME;
5962 - if (state->flags & 0x0800) {
5963 - if (have == 0) goto inf_leave;
5966 - len = (unsigned)(next[copy++]);
5967 - if (state->head != Z_NULL &&
5968 - state->head->name != Z_NULL &&
5969 - state->length < state->head->name_max)
5970 - state->head->name[state->length++] = len;
5971 - } while (len && copy < have);
5972 - if (state->flags & 0x0200)
5973 - state->check = crc32(state->check, next, copy);
5976 - if (len) goto inf_leave;
5978 - else if (state->head != Z_NULL)
5979 - state->head->name = Z_NULL;
5980 - state->length = 0;
5981 - state->mode = COMMENT;
5983 - if (state->flags & 0x1000) {
5984 - if (have == 0) goto inf_leave;
5987 - len = (unsigned)(next[copy++]);
5988 - if (state->head != Z_NULL &&
5989 - state->head->comment != Z_NULL &&
5990 - state->length < state->head->comm_max)
5991 - state->head->comment[state->length++] = len;
5992 - } while (len && copy < have);
5993 - if (state->flags & 0x0200)
5994 - state->check = crc32(state->check, next, copy);
5997 - if (len) goto inf_leave;
5999 - else if (state->head != Z_NULL)
6000 - state->head->comment = Z_NULL;
6001 - state->mode = HCRC;
6003 - if (state->flags & 0x0200) {
6005 - if (hold != (state->check & 0xffff)) {
6006 - strm->msg = (char *)"header crc mismatch";
6007 - state->mode = BAD;
6012 - if (state->head != Z_NULL) {
6013 - state->head->hcrc = (int)((state->flags >> 9) & 1);
6014 - state->head->done = 1;
6016 - strm->adler = state->check = crc32(0L, Z_NULL, 0);
6017 - state->mode = TYPE;
6022 - strm->adler = state->check = REVERSE(hold);
6024 - state->mode = DICT;
6026 - if (state->havedict == 0) {
6028 - return Z_NEED_DICT;
6030 - strm->adler = state->check = adler32(0L, Z_NULL, 0);
6031 - state->mode = TYPE;
6033 - if (flush == Z_BLOCK) goto inf_leave;
6035 - if (state->last) {
6037 - state->mode = CHECK;
6041 - state->last = BITS(1);
6043 - switch (BITS(2)) {
6044 - case 0: /* stored block */
6045 - Tracev((stderr, "inflate: stored block%s\n",
6046 - state->last ? " (last)" : ""));
6047 - state->mode = STORED;
6049 - case 1: /* fixed block */
6050 - fixedtables(state);
6051 - Tracev((stderr, "inflate: fixed codes block%s\n",
6052 - state->last ? " (last)" : ""));
6053 - state->mode = LEN; /* decode codes */
6055 - case 2: /* dynamic block */
6056 - Tracev((stderr, "inflate: dynamic codes block%s\n",
6057 - state->last ? " (last)" : ""));
6058 - state->mode = TABLE;
6061 - strm->msg = (char *)"invalid block type";
6062 - state->mode = BAD;
6067 - BYTEBITS(); /* go to byte boundary */
6069 - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
6070 - strm->msg = (char *)"invalid stored block lengths";
6071 - state->mode = BAD;
6074 - state->length = (unsigned)hold & 0xffff;
6075 - Tracev((stderr, "inflate: stored length %u\n",
6078 - state->mode = COPY;
6080 - copy = state->length;
6082 - if (copy > have) copy = have;
6083 - if (copy > left) copy = left;
6084 - if (copy == 0) goto inf_leave;
6085 - zmemcpy(put, next, copy);
6090 - state->length -= copy;
6093 - Tracev((stderr, "inflate: stored end\n"));
6094 - state->mode = TYPE;
6098 - state->nlen = BITS(5) + 257;
6100 - state->ndist = BITS(5) + 1;
6102 - state->ncode = BITS(4) + 4;
6104 -#ifndef PKZIP_BUG_WORKAROUND
6105 - if (state->nlen > 286 || state->ndist > 30) {
6106 - strm->msg = (char *)"too many length or distance symbols";
6107 - state->mode = BAD;
6111 - Tracev((stderr, "inflate: table sizes ok\n"));
6113 - state->mode = LENLENS;
6115 - while (state->have < state->ncode) {
6117 - state->lens[order[state->have++]] = (unsigned short)BITS(3);
6120 - while (state->have < 19)
6121 - state->lens[order[state->have++]] = 0;
6122 - state->next = state->codes;
6123 - state->lencode = (code const FAR *)(state->next);
6124 - state->lenbits = 7;
6125 - ret = inflate_table(CODES, state->lens, 19, &(state->next),
6126 - &(state->lenbits), state->work);
6128 - strm->msg = (char *)"invalid code lengths set";
6129 - state->mode = BAD;
6132 - Tracev((stderr, "inflate: code lengths ok\n"));
6134 - state->mode = CODELENS;
6136 - while (state->have < state->nlen + state->ndist) {
6138 - This = state->lencode[BITS(state->lenbits)];
6139 - if ((unsigned)(This.bits) <= bits) break;
6142 - if (This.val < 16) {
6143 - NEEDBITS(This.bits);
6144 - DROPBITS(This.bits);
6145 - state->lens[state->have++] = This.val;
6148 - if (This.val == 16) {
6149 - NEEDBITS(This.bits + 2);
6150 - DROPBITS(This.bits);
6151 - if (state->have == 0) {
6152 - strm->msg = (char *)"invalid bit length repeat";
6153 - state->mode = BAD;
6156 - len = state->lens[state->have - 1];
6157 - copy = 3 + BITS(2);
6160 - else if (This.val == 17) {
6161 - NEEDBITS(This.bits + 3);
6162 - DROPBITS(This.bits);
6164 - copy = 3 + BITS(3);
6168 - NEEDBITS(This.bits + 7);
6169 - DROPBITS(This.bits);
6171 - copy = 11 + BITS(7);
6174 - if (state->have + copy > state->nlen + state->ndist) {
6175 - strm->msg = (char *)"invalid bit length repeat";
6176 - state->mode = BAD;
6180 - state->lens[state->have++] = (unsigned short)len;
6184 - /* handle error breaks in while */
6185 - if (state->mode == BAD) break;
6187 - /* build code tables */
6188 - state->next = state->codes;
6189 - state->lencode = (code const FAR *)(state->next);
6190 - state->lenbits = 9;
6191 - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
6192 - &(state->lenbits), state->work);
6194 - strm->msg = (char *)"invalid literal/lengths set";
6195 - state->mode = BAD;
6198 - state->distcode = (code const FAR *)(state->next);
6199 - state->distbits = 6;
6200 - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
6201 - &(state->next), &(state->distbits), state->work);
6203 - strm->msg = (char *)"invalid distances set";
6204 - state->mode = BAD;
6207 - Tracev((stderr, "inflate: codes ok\n"));
6208 - state->mode = LEN;
6210 - if (have >= 6 && left >= 258) {
6212 - inflate_fast(strm, out);
6217 - This = state->lencode[BITS(state->lenbits)];
6218 - if ((unsigned)(This.bits) <= bits) break;
6221 - if (This.op && (This.op & 0xf0) == 0) {
6224 - This = state->lencode[last.val +
6225 - (BITS(last.bits + last.op) >> last.bits)];
6226 - if ((unsigned)(last.bits + This.bits) <= bits) break;
6229 - DROPBITS(last.bits);
6231 - DROPBITS(This.bits);
6232 - state->length = (unsigned)This.val;
6233 - if ((int)(This.op) == 0) {
6234 - Tracevv((stderr, This.val >= 0x20 && This.val < 0x7f ?
6235 - "inflate: literal '%c'\n" :
6236 - "inflate: literal 0x%02x\n", This.val));
6237 - state->mode = LIT;
6240 - if (This.op & 32) {
6241 - Tracevv((stderr, "inflate: end of block\n"));
6242 - state->mode = TYPE;
6245 - if (This.op & 64) {
6246 - strm->msg = (char *)"invalid literal/length code";
6247 - state->mode = BAD;
6250 - state->extra = (unsigned)(This.op) & 15;
6251 - state->mode = LENEXT;
6253 - if (state->extra) {
6254 - NEEDBITS(state->extra);
6255 - state->length += BITS(state->extra);
6256 - DROPBITS(state->extra);
6258 - Tracevv((stderr, "inflate: length %u\n", state->length));
6259 - state->mode = DIST;
6262 - This = state->distcode[BITS(state->distbits)];
6263 - if ((unsigned)(This.bits) <= bits) break;
6266 - if ((This.op & 0xf0) == 0) {
6269 - This = state->distcode[last.val +
6270 - (BITS(last.bits + last.op) >> last.bits)];
6271 - if ((unsigned)(last.bits + This.bits) <= bits) break;
6274 - DROPBITS(last.bits);
6276 - DROPBITS(This.bits);
6277 - if (This.op & 64) {
6278 - strm->msg = (char *)"invalid distance code";
6279 - state->mode = BAD;
6282 - state->offset = (unsigned)This.val;
6283 - state->extra = (unsigned)(This.op) & 15;
6284 - state->mode = DISTEXT;
6286 - if (state->extra) {
6287 - NEEDBITS(state->extra);
6288 - state->offset += BITS(state->extra);
6289 - DROPBITS(state->extra);
6291 -#ifdef INFLATE_STRICT
6292 - if (state->offset > state->dmax) {
6293 - strm->msg = (char *)"invalid distance too far back";
6294 - state->mode = BAD;
6298 - if (state->offset > state->whave + out - left) {
6299 - strm->msg = (char *)"invalid distance too far back";
6300 - state->mode = BAD;
6303 - Tracevv((stderr, "inflate: distance %u\n", state->offset));
6304 - state->mode = MATCH;
6306 - if (left == 0) goto inf_leave;
6307 - copy = out - left;
6308 - if (state->offset > copy) { /* copy from window */
6309 - copy = state->offset - copy;
6310 - if (copy > state->write) {
6311 - copy -= state->write;
6312 - from = state->window + (state->wsize - copy);
6315 - from = state->window + (state->write - copy);
6316 - if (copy > state->length) copy = state->length;
6318 - else { /* copy from output */
6319 - from = put - state->offset;
6320 - copy = state->length;
6322 - if (copy > left) copy = left;
6324 - state->length -= copy;
6328 - if (state->length == 0) state->mode = LEN;
6331 - if (left == 0) goto inf_leave;
6332 - *put++ = (unsigned char)(state->length);
6334 - state->mode = LEN;
6337 - if (state->wrap) {
6340 - strm->total_out += out;
6341 - state->total += out;
6343 - strm->adler = state->check =
6344 - UPDATE(state->check, put - out, out);
6348 - state->flags ? hold :
6350 - REVERSE(hold)) != state->check) {
6351 - strm->msg = (char *)"incorrect data check";
6352 - state->mode = BAD;
6356 - Tracev((stderr, "inflate: check matches trailer\n"));
6359 - state->mode = LENGTH;
6361 - if (state->wrap && state->flags) {
6363 - if (hold != (state->total & 0xffffffffUL)) {
6364 - strm->msg = (char *)"incorrect length check";
6365 - state->mode = BAD;
6369 - Tracev((stderr, "inflate: length matches trailer\n"));
6372 - state->mode = DONE;
6374 - ret = Z_STREAM_END;
6377 - ret = Z_DATA_ERROR;
6380 - return Z_MEM_ERROR;
6383 - return Z_STREAM_ERROR;
6387 - Return from inflate(), updating the total counts and the check value.
6388 - If there was no progress during the inflate() call, return a buffer
6389 - error. Call updatewindow() to create and/or update the window state.
6390 - Note: a memory error from inflate() is non-recoverable.
6394 - if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
6395 - if (updatewindow(strm, out)) {
6396 - state->mode = MEM;
6397 - return Z_MEM_ERROR;
6399 - in -= strm->avail_in;
6400 - out -= strm->avail_out;
6401 - strm->total_in += in;
6402 - strm->total_out += out;
6403 - state->total += out;
6404 - if (state->wrap && out)
6405 - strm->adler = state->check =
6406 - UPDATE(state->check, strm->next_out - out, out);
6407 - strm->data_type = state->bits + (state->last ? 64 : 0) +
6408 - (state->mode == TYPE ? 128 : 0);
6409 - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
6410 - ret = Z_BUF_ERROR;
6414 -int ZEXPORT inflateEnd(z_streamp strm)
6416 - struct inflate_state FAR *state;
6417 - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
6418 - return Z_STREAM_ERROR;
6419 - state = (struct inflate_state FAR *)strm->state;
6420 - if (state->window != Z_NULL) ZFREE(strm, state->window);
6421 - ZFREE(strm, strm->state);
6422 - strm->state = Z_NULL;
6423 - Tracev((stderr, "inflate: end\n"));
6427 -int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
6429 - struct inflate_state FAR *state;
6433 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6434 - state = (struct inflate_state FAR *)strm->state;
6435 - if (state->wrap != 0 && state->mode != DICT)
6436 - return Z_STREAM_ERROR;
6438 - /* check for correct dictionary id */
6439 - if (state->mode == DICT) {
6440 - id = adler32(0L, Z_NULL, 0);
6441 - id = adler32(id, dictionary, dictLength);
6442 - if (id != state->check)
6443 - return Z_DATA_ERROR;
6446 - /* copy dictionary to window */
6447 - if (updatewindow(strm, strm->avail_out)) {
6448 - state->mode = MEM;
6449 - return Z_MEM_ERROR;
6451 - if (dictLength > state->wsize) {
6452 - zmemcpy(state->window, dictionary + dictLength - state->wsize,
6454 - state->whave = state->wsize;
6457 - zmemcpy(state->window + state->wsize - dictLength, dictionary,
6459 - state->whave = dictLength;
6461 - state->havedict = 1;
6462 - Tracev((stderr, "inflate: dictionary set\n"));
6466 -int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
6468 - struct inflate_state FAR *state;
6471 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6472 - state = (struct inflate_state FAR *)strm->state;
6473 - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
6475 - /* save header structure */
6476 - state->head = head;
6482 - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
6483 - or when out of input. When called, *have is the number of pattern bytes
6484 - found in order so far, in 0..3. On return *have is updated to the new
6485 - state. If on return *have equals four, then the pattern was found and the
6486 - return value is how many bytes were read including the last byte of the
6487 - pattern. If *have is less than four, then the pattern has not been found
6488 - yet and the return value is len. In the latter case, syncsearch() can be
6489 - called again with more data and the *have state. *have is initialized to
6490 - zero for the first call.
6492 -local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf, unsigned len)
6499 - while (next < len && got < 4) {
6500 - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
6502 - else if (buf[next])
6512 -int ZEXPORT inflateSync(z_streamp strm)
6514 - unsigned len; /* number of bytes to look at or looked at */
6515 - unsigned long in, out; /* temporary to save total_in and total_out */
6516 - unsigned char buf[4]; /* to restore bit buffer to byte string */
6517 - struct inflate_state FAR *state;
6519 - /* check parameters */
6520 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6521 - state = (struct inflate_state FAR *)strm->state;
6522 - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
6524 - /* if first time, start search in bit buffer */
6525 - if (state->mode != SYNC) {
6526 - state->mode = SYNC;
6527 - state->hold <<= state->bits & 7;
6528 - state->bits -= state->bits & 7;
6530 - while (state->bits >= 8) {
6531 - buf[len++] = (unsigned char)(state->hold);
6532 - state->hold >>= 8;
6536 - syncsearch(&(state->have), buf, len);
6539 - /* search available input */
6540 - len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
6541 - strm->avail_in -= len;
6542 - strm->next_in += len;
6543 - strm->total_in += len;
6545 - /* return no joy or set up to restart inflate() on a new block */
6546 - if (state->have != 4) return Z_DATA_ERROR;
6547 - in = strm->total_in; out = strm->total_out;
6548 - inflateReset(strm);
6549 - strm->total_in = in; strm->total_out = out;
6550 - state->mode = TYPE;
6555 - Returns true if inflate is currently at the end of a block generated by
6556 - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
6557 - implementation to provide an additional safety check. PPP uses
6558 - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
6559 - block. When decompressing, PPP checks that at the end of input packet,
6560 - inflate is waiting for these length bytes.
6562 -int ZEXPORT inflateSyncPoint(z_streamp strm)
6564 - struct inflate_state FAR *state;
6566 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6567 - state = (struct inflate_state FAR *)strm->state;
6568 - return state->mode == STORED && state->bits == 0;
6571 -int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
6573 - struct inflate_state FAR *state;
6574 - struct inflate_state FAR *copy;
6575 - unsigned char FAR *window;
6579 - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
6580 - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
6581 - return Z_STREAM_ERROR;
6582 - state = (struct inflate_state FAR *)source->state;
6584 - /* allocate space */
6585 - copy = (struct inflate_state FAR *)
6586 - ZALLOC(source, 1, sizeof(struct inflate_state));
6587 - if (copy == Z_NULL) return Z_MEM_ERROR;
6589 - if (state->window != Z_NULL) {
6590 - window = (unsigned char FAR *)
6591 - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
6592 - if (window == Z_NULL) {
6593 - ZFREE(source, copy);
6594 - return Z_MEM_ERROR;
6599 - zmemcpy(dest, source, sizeof(z_stream));
6600 - zmemcpy(copy, state, sizeof(struct inflate_state));
6601 - if (state->lencode >= state->codes &&
6602 - state->lencode <= state->codes + ENOUGH - 1) {
6603 - copy->lencode = copy->codes + (state->lencode - state->codes);
6604 - copy->distcode = copy->codes + (state->distcode - state->codes);
6606 - copy->next = copy->codes + (state->next - state->codes);
6607 - if (window != Z_NULL) {
6608 - wsize = 1U << state->wbits;
6609 - zmemcpy(window, state->window, wsize);
6611 - copy->window = window;
6612 - dest->state = (struct internal_state FAR *)copy;
6615 diff -ruN seqinr.orig/src/inflate.h seqinr/src/inflate.h
6616 --- seqinr.orig/src/inflate.h 2007-04-19 11:40:19.000000000 +0200
6617 +++ seqinr/src/inflate.h 1970-01-01 01:00:00.000000000 +0100
6619 -/* inflate.h -- internal inflate state definition
6620 - * Copyright (C) 1995-2004 Mark Adler
6621 - * For conditions of distribution and use, see copyright notice in zlib.h
6624 -/* WARNING: this file should *not* be used by applications. It is
6625 - part of the implementation of the compression library and is
6626 - subject to change. Applications should only use zlib.h.
6629 -/* define NO_GZIP when compiling if you want to disable gzip header and
6630 - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
6631 - the crc code when it is not needed. For shared libraries, gzip decoding
6632 - should be left enabled. */
6637 -/* Possible inflate modes between inflate() calls */
6639 - HEAD, /* i: waiting for magic header */
6640 - FLAGS, /* i: waiting for method and flags (gzip) */
6641 - TIME, /* i: waiting for modification time (gzip) */
6642 - OS, /* i: waiting for extra flags and operating system (gzip) */
6643 - EXLEN, /* i: waiting for extra length (gzip) */
6644 - EXTRA, /* i: waiting for extra bytes (gzip) */
6645 - NAME, /* i: waiting for end of file name (gzip) */
6646 - COMMENT, /* i: waiting for end of comment (gzip) */
6647 - HCRC, /* i: waiting for header crc (gzip) */
6648 - DICTID, /* i: waiting for dictionary check value */
6649 - DICT, /* waiting for inflateSetDictionary() call */
6650 - TYPE, /* i: waiting for type bits, including last-flag bit */
6651 - TYPEDO, /* i: same, but skip check to exit inflate on new block */
6652 - STORED, /* i: waiting for stored size (length and complement) */
6653 - COPY, /* i/o: waiting for input or output to copy stored block */
6654 - TABLE, /* i: waiting for dynamic block table lengths */
6655 - LENLENS, /* i: waiting for code length code lengths */
6656 - CODELENS, /* i: waiting for length/lit and distance code lengths */
6657 - LEN, /* i: waiting for length/lit code */
6658 - LENEXT, /* i: waiting for length extra bits */
6659 - DIST, /* i: waiting for distance code */
6660 - DISTEXT, /* i: waiting for distance extra bits */
6661 - MATCH, /* o: waiting for output space to copy string */
6662 - LIT, /* o: waiting for output space to write literal */
6663 - CHECK, /* i: waiting for 32-bit check value */
6664 - LENGTH, /* i: waiting for 32-bit length (gzip) */
6665 - DONE, /* finished check, done -- remain here until reset */
6666 - BAD, /* got a data error -- remain here until reset */
6667 - MEM, /* got an inflate() memory error -- remain here until reset */
6668 - SYNC /* looking for synchronization bytes to restart inflate() */
6672 - State transitions between above modes -
6674 - (most modes can go to the BAD or MEM mode -- not shown for clarity)
6677 - HEAD -> (gzip) or (zlib)
6678 - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
6679 - NAME -> COMMENT -> HCRC -> TYPE
6680 - (zlib) -> DICTID or TYPE
6681 - DICTID -> DICT -> TYPE
6682 - Read deflate blocks:
6683 - TYPE -> STORED or TABLE or LEN or CHECK
6684 - STORED -> COPY -> TYPE
6685 - TABLE -> LENLENS -> CODELENS -> LEN
6686 - Read deflate codes:
6687 - LEN -> LENEXT or LIT or TYPE
6688 - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
6691 - CHECK -> LENGTH -> DONE
6694 -/* state maintained between inflate() calls. Approximately 7K bytes. */
6695 -struct inflate_state {
6696 - inflate_mode mode; /* current inflate mode */
6697 - int last; /* true if processing last block */
6698 - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
6699 - int havedict; /* true if dictionary provided */
6700 - int flags; /* gzip header method and flags (0 if zlib) */
6701 - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
6702 - unsigned long check; /* protected copy of check value */
6703 - unsigned long total; /* protected copy of output count */
6704 - gz_headerp head; /* where to save gzip header information */
6705 - /* sliding window */
6706 - unsigned wbits; /* log base 2 of requested window size */
6707 - unsigned wsize; /* window size or zero if not using window */
6708 - unsigned whave; /* valid bytes in the window */
6709 - unsigned write; /* window write index */
6710 - unsigned char FAR *window; /* allocated sliding window, if needed */
6711 - /* bit accumulator */
6712 - unsigned long hold; /* input bit accumulator */
6713 - unsigned bits; /* number of bits in "in" */
6714 - /* for string and stored block copying */
6715 - unsigned length; /* literal or length of data to copy */
6716 - unsigned offset; /* distance back to copy string from */
6717 - /* for table and code decoding */
6718 - unsigned extra; /* extra bits needed */
6719 - /* fixed and dynamic code tables */
6720 - code const FAR *lencode; /* starting table for length/literal codes */
6721 - code const FAR *distcode; /* starting table for distance codes */
6722 - unsigned lenbits; /* index bits for lencode */
6723 - unsigned distbits; /* index bits for distcode */
6724 - /* dynamic table building */
6725 - unsigned ncode; /* number of code length code lengths */
6726 - unsigned nlen; /* number of length code lengths */
6727 - unsigned ndist; /* number of distance code lengths */
6728 - unsigned have; /* number of code lengths in lens[] */
6729 - code FAR *next; /* next available space in codes[] */
6730 - unsigned short lens[320]; /* temporary storage for code lengths */
6731 - unsigned short work[288]; /* work area for code table building */
6732 - code codes[ENOUGH]; /* space for code tables */
6734 diff -ruN seqinr.orig/src/inftrees.c seqinr/src/inftrees.c
6735 --- seqinr.orig/src/inftrees.c 2007-04-19 11:40:19.000000000 +0200
6736 +++ seqinr/src/inftrees.c 1970-01-01 01:00:00.000000000 +0100
6738 -/* inftrees.c -- generate Huffman trees for efficient decoding
6739 - * Copyright (C) 1995-2005 Mark Adler
6740 - * For conditions of distribution and use, see copyright notice in zlib.h
6744 -#include "inftrees.h"
6748 -const char inflate_copyright[] =
6749 - " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
6751 - If you use the zlib library in a product, an acknowledgment is welcome
6752 - in the documentation of your product. If for some reason you cannot
6753 - include such an acknowledgment, I would appreciate that you keep this
6754 - copyright string in the executable of your product.
6758 - Build a set of tables to decode the provided canonical Huffman code.
6759 - The code lengths are lens[0..codes-1]. The result starts at *table,
6760 - whose indices are 0..2^bits-1. work is a writable array of at least
6761 - lens shorts, which is used as a work area. type is the type of code
6762 - to be generated, CODES, LENS, or DISTS. On return, zero is success,
6763 - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
6764 - on return points to the next available entry's address. bits is the
6765 - requested root table index bits, and on return it is the actual root
6766 - table index bits. It will differ if the request is greater than the
6767 - longest code or if it is less than the shortest code.
6769 -int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes,
6770 - code FAR * FAR * table, unsigned FAR *bits,
6771 - unsigned short FAR *work)
6774 -unsigned short FAR *lens;
6776 -code FAR * FAR *table;
6777 -unsigned FAR *bits;
6778 -unsigned short FAR *work;
6781 - unsigned len; /* a code's length in bits */
6782 - unsigned sym; /* index of code symbols */
6783 - unsigned min, max; /* minimum and maximum code lengths */
6784 - unsigned root; /* number of index bits for root table */
6785 - unsigned curr; /* number of index bits for current table */
6786 - unsigned drop; /* code bits to drop for sub-table */
6787 - int left; /* number of prefix codes available */
6788 - unsigned used; /* code entries in table used */
6789 - unsigned huff; /* Huffman code */
6790 - unsigned incr; /* for incrementing code, index */
6791 - unsigned fill; /* index for replicating entries */
6792 - unsigned low; /* low bits for current root entry */
6793 - unsigned mask; /* mask for low root bits */
6794 - code This; /* table entry for duplication */
6795 - code FAR *next; /* next available space in table */
6796 - const unsigned short FAR *base; /* base value table to use */
6797 - const unsigned short FAR *extra; /* extra bits table to use */
6798 - int end; /* use base and extra for symbol > end */
6799 - unsigned short count[MAXBITS+1]; /* number of codes of each length */
6800 - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
6801 - static const unsigned short lbase[31] = { /* Length codes 257..285 base */
6802 - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
6803 - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
6804 - static const unsigned short lext[31] = { /* Length codes 257..285 extra */
6805 - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
6806 - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
6807 - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
6808 - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
6809 - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
6810 - 8193, 12289, 16385, 24577, 0, 0};
6811 - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
6812 - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
6813 - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
6814 - 28, 28, 29, 29, 64, 64};
6817 - Process a set of code lengths to create a canonical Huffman code. The
6818 - code lengths are lens[0..codes-1]. Each length corresponds to the
6819 - symbols 0..codes-1. The Huffman code is generated by first sorting the
6820 - symbols by length from short to long, and retaining the symbol order
6821 - for codes with equal lengths. Then the code starts with all zero bits
6822 - for the first code of the shortest length, and the codes are integer
6823 - increments for the same length, and zeros are appended as the length
6824 - increases. For the deflate format, these bits are stored backwards
6825 - from their more natural integer increment ordering, and so when the
6826 - decoding tables are built in the large loop below, the integer codes
6827 - are incremented backwards.
6829 - This routine assumes, but does not check, that all of the entries in
6830 - lens[] are in the range 0..MAXBITS. The caller must assure this.
6831 - 1..MAXBITS is interpreted as that code length. zero means that that
6832 - symbol does not occur in this code.
6834 - The codes are sorted by computing a count of codes for each length,
6835 - creating from that a table of starting indices for each length in the
6836 - sorted table, and then entering the symbols in order in the sorted
6837 - table. The sorted table is work[], with that space being provided by
6840 - The length counts are used for other purposes as well, i.e. finding
6841 - the minimum and maximum length codes, determining if there are any
6842 - codes at all, checking for a valid set of lengths, and looking ahead
6843 - at length counts to determine sub-table sizes when building the
6847 - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
6848 - for (len = 0; len <= MAXBITS; len++)
6850 - for (sym = 0; sym < codes; sym++)
6851 - count[lens[sym]]++;
6853 - /* bound code lengths, force root to be within code lengths */
6855 - for (max = MAXBITS; max >= 1; max--)
6856 - if (count[max] != 0) break;
6857 - if (root > max) root = max;
6858 - if (max == 0) { /* no symbols to code at all */
6859 - This.op = (unsigned char)64; /* invalid code marker */
6860 - This.bits = (unsigned char)1;
6861 - This.val = (unsigned short)0;
6862 - *(*table)++ = This; /* make a table to force an error */
6863 - *(*table)++ = This;
6865 - return 0; /* no symbols, but wait for decoding to report error */
6867 - for (min = 1; min <= MAXBITS; min++)
6868 - if (count[min] != 0) break;
6869 - if (root < min) root = min;
6871 - /* check for an over-subscribed or incomplete set of lengths */
6873 - for (len = 1; len <= MAXBITS; len++) {
6875 - left -= count[len];
6876 - if (left < 0) return -1; /* over-subscribed */
6878 - if (left > 0 && (type == CODES || max != 1))
6879 - return -1; /* incomplete set */
6881 - /* generate offsets into symbol table for each length for sorting */
6883 - for (len = 1; len < MAXBITS; len++)
6884 - offs[len + 1] = offs[len] + count[len];
6886 - /* sort symbols by length, by symbol order within each length */
6887 - for (sym = 0; sym < codes; sym++)
6888 - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
6891 - Create and fill in decoding tables. In this loop, the table being
6892 - filled is at next and has curr index bits. The code being used is huff
6893 - with length len. That code is converted to an index by dropping drop
6894 - bits off of the bottom. For codes where len is less than drop + curr,
6895 - those top drop + curr - len bits are incremented through all values to
6896 - fill the table with replicated entries.
6898 - root is the number of index bits for the root table. When len exceeds
6899 - root, sub-tables are created pointed to by the root entry with an index
6900 - of the low root bits of huff. This is saved in low to check for when a
6901 - new sub-table should be started. drop is zero when the root table is
6902 - being filled, and drop is root when sub-tables are being filled.
6904 - When a new sub-table is needed, it is necessary to look ahead in the
6905 - code lengths to determine what size sub-table is needed. The length
6906 - counts are used for this, and so count[] is decremented as codes are
6907 - entered in the tables.
6909 - used keeps track of how many table entries have been allocated from the
6910 - provided *table space. It is checked when a LENS table is being made
6911 - against the space in *table, ENOUGH, minus the maximum space needed by
6912 - the worst case distance code, MAXD. This should never happen, but the
6913 - sufficiency of ENOUGH has not been proven exhaustively, hence the check.
6914 - This assumes that when type == LENS, bits == 9.
6916 - sym increments through all symbols, and the loop terminates when
6917 - all codes of length max, i.e. all codes, have been processed. This
6918 - routine permits incomplete codes, so another loop after this one fills
6919 - in the rest of the decoding tables with invalid code markers.
6922 - /* set up for code type */
6925 - base = extra = work; /* dummy value--not used */
6935 - default: /* DISTS */
6941 - /* initialize state for loop */
6942 - huff = 0; /* starting code */
6943 - sym = 0; /* starting code symbol */
6944 - len = min; /* starting code length */
6945 - next = *table; /* current table to fill in */
6946 - curr = root; /* current table index bits */
6947 - drop = 0; /* current bits to drop from code for index */
6948 - low = (unsigned)(-1); /* trigger new sub-table when len > root */
6949 - used = 1U << root; /* use root table entries */
6950 - mask = used - 1; /* mask for comparing low */
6952 - /* check available table space */
6953 - if (type == LENS && used >= ENOUGH - MAXD)
6956 - /* process all codes and make table entries */
6958 - /* create table entry */
6959 - This.bits = (unsigned char)(len - drop);
6960 - if ((int)(work[sym]) < end) {
6961 - This.op = (unsigned char)0;
6962 - This.val = work[sym];
6964 - else if ((int)(work[sym]) > end) {
6965 - This.op = (unsigned char)(extra[work[sym]]);
6966 - This.val = base[work[sym]];
6969 - This.op = (unsigned char)(32 + 64); /* end of block */
6973 - /* replicate for those indices with low len bits equal to huff */
6974 - incr = 1U << (len - drop);
6975 - fill = 1U << curr;
6976 - min = fill; /* save offset to next table */
6979 - next[(huff >> drop) + fill] = This;
6980 - } while (fill != 0);
6982 - /* backwards increment the len-bit code huff */
6983 - incr = 1U << (len - 1);
6984 - while (huff & incr)
6993 - /* go to next symbol, update count, len */
6995 - if (--(count[len]) == 0) {
6996 - if (len == max) break;
6997 - len = lens[work[sym]];
7000 - /* create new sub-table if needed */
7001 - if (len > root && (huff & mask) != low) {
7002 - /* if first time, transition to sub-tables */
7006 - /* increment past last table */
7007 - next += min; /* here min is 1 << curr */
7009 - /* determine length of next table */
7010 - curr = len - drop;
7011 - left = (int)(1 << curr);
7012 - while (curr + drop < max) {
7013 - left -= count[curr + drop];
7014 - if (left <= 0) break;
7019 - /* check for enough space */
7020 - used += 1U << curr;
7021 - if (type == LENS && used >= ENOUGH - MAXD)
7024 - /* point entry in root table to sub-table */
7025 - low = huff & mask;
7026 - (*table)[low].op = (unsigned char)curr;
7027 - (*table)[low].bits = (unsigned char)root;
7028 - (*table)[low].val = (unsigned short)(next - *table);
7033 - Fill in rest of table for incomplete codes. This loop is similar to the
7034 - loop above in incrementing huff for table indices. It is assumed that
7035 - len is equal to curr + drop, so there is no loop needed to increment
7036 - through high index bits. When the current sub-table is filled, the loop
7037 - drops back to the root table to fill in any remaining entries there.
7039 - This.op = (unsigned char)64; /* invalid code marker */
7040 - This.bits = (unsigned char)(len - drop);
7041 - This.val = (unsigned short)0;
7042 - while (huff != 0) {
7043 - /* when done with sub-table, drop back to root table */
7044 - if (drop != 0 && (huff & mask) != low) {
7048 - This.bits = (unsigned char)len;
7051 - /* put invalid code marker in table */
7052 - next[huff >> drop] = This;
7054 - /* backwards increment the len-bit code huff */
7055 - incr = 1U << (len - 1);
7056 - while (huff & incr)
7066 - /* set return parameters */
7071 diff -ruN seqinr.orig/src/inftrees.h seqinr/src/inftrees.h
7072 --- seqinr.orig/src/inftrees.h 2007-04-19 11:40:19.000000000 +0200
7073 +++ seqinr/src/inftrees.h 1970-01-01 01:00:00.000000000 +0100
7075 -/* inftrees.h -- header to use inftrees.c
7076 - * Copyright (C) 1995-2005 Mark Adler
7077 - * For conditions of distribution and use, see copyright notice in zlib.h
7080 -/* WARNING: this file should *not* be used by applications. It is
7081 - part of the implementation of the compression library and is
7082 - subject to change. Applications should only use zlib.h.
7085 -/* Structure for decoding tables. Each entry provides either the
7086 - information needed to do the operation requested by the code that
7087 - indexed that table entry, or it provides a pointer to another
7088 - table that indexes more bits of the code. op indicates whether
7089 - the entry is a pointer to another table, a literal, a length or
7090 - distance, an end-of-block, or an invalid code. For a table
7091 - pointer, the low four bits of op is the number of index bits of
7092 - that table. For a length or distance, the low four bits of op
7093 - is the number of extra bits to get after the code. bits is
7094 - the number of bits in this code or part of the code to drop off
7095 - of the bit buffer. val is the actual byte to output in the case
7096 - of a literal, the base length or distance, or the offset from
7097 - the current table to the next table. Each entry is four bytes. */
7099 - unsigned char op; /* operation, extra bits, table bits */
7100 - unsigned char bits; /* bits in this part of the code */
7101 - unsigned short val; /* offset in table or code value */
7104 -/* op values as set by inflate_table():
7105 - 00000000 - literal
7106 - 0000tttt - table link, tttt != 0 is the number of table index bits
7107 - 0001eeee - length or distance, eeee is the number of extra bits
7108 - 01100000 - end of block
7109 - 01000000 - invalid code
7112 -/* Maximum size of dynamic tree. The maximum found in a long but non-
7113 - exhaustive search was 1444 code structures (852 for length/literals
7114 - and 592 for distances, the latter actually the result of an
7115 - exhaustive search). The true maximum is not known, but the value
7116 - below is more than safe. */
7117 -#define ENOUGH 2048
7120 -/* Type of code to build for inftable() */
7127 -extern int inflate_table OF((codetype type, unsigned short FAR *lens,
7128 - unsigned codes, code FAR * FAR *table,
7129 - unsigned FAR *bits, unsigned short FAR *work));
7130 diff -ruN seqinr.orig/src/Makevars seqinr/src/Makevars
7131 --- seqinr.orig/src/Makevars 2007-04-19 14:23:37.000000000 +0200
7132 +++ seqinr/src/Makevars 2009-05-17 21:38:04.000000000 +0200
7134 PKG_CFLAGS = -DUSE_TYPE_CHECKING_STRICT
7136 diff -ruN seqinr.orig/src/trees.c seqinr/src/trees.c
7137 --- seqinr.orig/src/trees.c 2007-04-19 11:40:19.000000000 +0200
7138 +++ seqinr/src/trees.c 1970-01-01 01:00:00.000000000 +0100
7140 -/* trees.c -- output deflated data using Huffman coding
7141 - * Copyright (C) 1995-2005 Jean-loup Gailly
7142 - * For conditions of distribution and use, see copyright notice in zlib.h
7148 - * The "deflation" process uses several Huffman trees. The more
7149 - * common source values are represented by shorter bit sequences.
7151 - * Each code tree is stored in a compressed form which is itself
7152 - * a Huffman encoding of the lengths of all the code strings (in
7153 - * ascending order by source values). The actual code strings are
7154 - * reconstructed from the lengths in the inflate process, as described
7155 - * in the deflate specification.
7159 - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
7160 - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
7162 - * Storer, James A.
7163 - * Data Compression: Methods and Theory, pp. 49-50.
7164 - * Computer Science Press, 1988. ISBN 0-7167-8156-5.
7167 - * Algorithms, p290.
7168 - * Addison-Wesley, 1983. ISBN 0-201-06672-6.
7171 -/* @(#) $Id: trees.c,v 1.1.2.1 2007-04-19 09:40:18 penel Exp $ */
7173 -/* #define GEN_TREES_H */
7175 -#include "deflate.h"
7178 -# include <ctype.h>
7181 -/* ===========================================================================
7185 -#define MAX_BL_BITS 7
7186 -/* Bit length codes must not exceed MAX_BL_BITS bits */
7188 -#define END_BLOCK 256
7189 -/* end of block literal code */
7192 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */
7194 -#define REPZ_3_10 17
7195 -/* repeat a zero length 3-10 times (3 bits of repeat count) */
7197 -#define REPZ_11_138 18
7198 -/* repeat a zero length 11-138 times (7 bits of repeat count) */
7200 -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
7201 - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
7203 -local const int extra_dbits[D_CODES] /* extra bits for each distance code */
7204 - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
7206 -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
7207 - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
7209 -local const uch bl_order[BL_CODES]
7210 - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
7211 -/* The lengths of the bit length codes are sent in order of decreasing
7212 - * probability, to avoid transmitting the lengths for unused bit length codes.
7215 -#define Buf_size (8 * 2*sizeof(char))
7216 -/* Number of bits used within bi_buf. (bi_buf might be implemented on
7217 - * more than 16 bits on some systems.)
7220 -/* ===========================================================================
7221 - * Local data. These are initialized only once.
7224 -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
7226 -#if defined(GEN_TREES_H) || !defined(STDC)
7227 -/* non ANSI compilers may not accept trees.h */
7229 -local ct_data static_ltree[L_CODES+2];
7230 -/* The static literal tree. Since the bit lengths are imposed, there is no
7231 - * need for the L_CODES extra codes used during heap construction. However
7232 - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
7236 -local ct_data static_dtree[D_CODES];
7237 -/* The static distance tree. (Actually a trivial tree since all codes use
7241 -uch _dist_code[DIST_CODE_LEN];
7242 -/* Distance codes. The first 256 values correspond to the distances
7243 - * 3 .. 258, the last 256 values correspond to the top 8 bits of
7244 - * the 15 bit distances.
7247 -uch _length_code[MAX_MATCH-MIN_MATCH+1];
7248 -/* length code for each normalized match length (0 == MIN_MATCH) */
7250 -local int base_length[LENGTH_CODES];
7251 -/* First normalized length for each code (0 = MIN_MATCH) */
7253 -local int base_dist[D_CODES];
7254 -/* First normalized distance for each code (0 = distance of 1) */
7257 -# include "trees.h"
7258 -#endif /* GEN_TREES_H */
7260 -struct static_tree_desc_s {
7261 - const ct_data *static_tree; /* static tree or NULL */
7262 - const intf *extra_bits; /* extra bits for each code or NULL */
7263 - int extra_base; /* base index for extra_bits */
7264 - int elems; /* max number of elements in the tree */
7265 - int max_length; /* max bit length for the codes */
7268 -local static_tree_desc static_l_desc =
7269 -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
7271 -local static_tree_desc static_d_desc =
7272 -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
7274 -local static_tree_desc static_bl_desc =
7275 -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
7277 -/* ===========================================================================
7278 - * Local (static) routines in this file.
7281 -local void tr_static_init OF((void));
7282 -local void init_block OF((deflate_state *s));
7283 -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
7284 -local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
7285 -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
7286 -local void build_tree OF((deflate_state *s, tree_desc *desc));
7287 -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
7288 -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
7289 -local int build_bl_tree OF((deflate_state *s));
7290 -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
7292 -local void compress_block OF((deflate_state *s, ct_data *ltree,
7294 -local void set_data_type OF((deflate_state *s));
7295 -local unsigned bi_reverse OF((unsigned value, int length));
7296 -local void bi_windup OF((deflate_state *s));
7297 -local void bi_flush OF((deflate_state *s));
7298 -local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
7302 -local void gen_trees_header OF((void));
7306 -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
7307 - /* Send a code of the given tree. c and tree must not have side effects */
7310 -# define send_code(s, c, tree) \
7311 - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
7312 - send_bits(s, tree[c].Code, tree[c].Len); }
7315 -/* ===========================================================================
7316 - * Output a short LSB first on the stream.
7317 - * IN assertion: there is enough room in pendingBuf.
7319 -#define put_short(s, w) { \
7320 - put_byte(s, (uch)((w) & 0xff)); \
7321 - put_byte(s, (uch)((ush)(w) >> 8)); \
7324 -/* ===========================================================================
7325 - * Send a value on a given number of bits.
7326 - * IN assertion: length <= 16 and value fits in length bits.
7329 -local void send_bits OF((deflate_state *s, int value, int length));
7331 -local void send_bits(s, value, length)
7333 - int value; /* value to send */
7334 - int length; /* number of bits */
7336 - Tracevv((stderr," l %2d v %4x ", length, value));
7337 - Assert(length > 0 && length <= 15, "invalid length");
7338 - s->bits_sent += (ulg)length;
7340 - /* If not enough room in bi_buf, use (valid) bits from bi_buf and
7341 - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
7342 - * unused bits in value.
7344 - if (s->bi_valid > (int)Buf_size - length) {
7345 - s->bi_buf |= (value << s->bi_valid);
7346 - put_short(s, s->bi_buf);
7347 - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
7348 - s->bi_valid += length - Buf_size;
7350 - s->bi_buf |= value << s->bi_valid;
7351 - s->bi_valid += length;
7356 -#define send_bits(s, value, length) \
7357 -{ int len = length;\
7358 - if (s->bi_valid > (int)Buf_size - len) {\
7360 - s->bi_buf |= (val << s->bi_valid);\
7361 - put_short(s, s->bi_buf);\
7362 - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
7363 - s->bi_valid += len - Buf_size;\
7365 - s->bi_buf |= (value) << s->bi_valid;\
7366 - s->bi_valid += len;\
7372 -/* the arguments must not have side effects */
7374 -/* ===========================================================================
7375 - * Initialize the various 'constant' tables.
7377 -local void tr_static_init()
7379 -#if defined(GEN_TREES_H) || !defined(STDC)
7380 - static int static_init_done = 0;
7381 - int n; /* iterates over tree elements */
7382 - int bits; /* bit counter */
7383 - int length; /* length value */
7384 - int code; /* code value */
7385 - int dist; /* distance index */
7386 - ush bl_count[MAX_BITS+1];
7387 - /* number of codes at each bit length for an optimal tree */
7389 - if (static_init_done) return;
7391 - /* For some embedded targets, global variables are not initialized: */
7392 - static_l_desc.static_tree = static_ltree;
7393 - static_l_desc.extra_bits = extra_lbits;
7394 - static_d_desc.static_tree = static_dtree;
7395 - static_d_desc.extra_bits = extra_dbits;
7396 - static_bl_desc.extra_bits = extra_blbits;
7398 - /* Initialize the mapping length (0..255) -> length code (0..28) */
7400 - for (code = 0; code < LENGTH_CODES-1; code++) {
7401 - base_length[code] = length;
7402 - for (n = 0; n < (1<<extra_lbits[code]); n++) {
7403 - _length_code[length++] = (uch)code;
7406 - Assert (length == 256, "tr_static_init: length != 256");
7407 - /* Note that the length 255 (match length 258) can be represented
7408 - * in two different ways: code 284 + 5 bits or code 285, so we
7409 - * overwrite length_code[255] to use the best encoding:
7411 - _length_code[length-1] = (uch)code;
7413 - /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
7415 - for (code = 0 ; code < 16; code++) {
7416 - base_dist[code] = dist;
7417 - for (n = 0; n < (1<<extra_dbits[code]); n++) {
7418 - _dist_code[dist++] = (uch)code;
7421 - Assert (dist == 256, "tr_static_init: dist != 256");
7422 - dist >>= 7; /* from now on, all distances are divided by 128 */
7423 - for ( ; code < D_CODES; code++) {
7424 - base_dist[code] = dist << 7;
7425 - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
7426 - _dist_code[256 + dist++] = (uch)code;
7429 - Assert (dist == 256, "tr_static_init: 256+dist != 512");
7431 - /* Construct the codes of the static literal tree */
7432 - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
7434 - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
7435 - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
7436 - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
7437 - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
7438 - /* Codes 286 and 287 do not exist, but we must include them in the
7439 - * tree construction to get a canonical Huffman tree (longest code
7442 - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
7444 - /* The static distance tree is trivial: */
7445 - for (n = 0; n < D_CODES; n++) {
7446 - static_dtree[n].Len = 5;
7447 - static_dtree[n].Code = bi_reverse((unsigned)n, 5);
7449 - static_init_done = 1;
7451 -# ifdef GEN_TREES_H
7452 - gen_trees_header();
7454 -#endif /* defined(GEN_TREES_H) || !defined(STDC) */
7457 -/* ===========================================================================
7458 - * Genererate the file trees.h describing the static trees.
7462 -# include <stdio.h>
7465 -# define SEPARATOR(i, last, width) \
7466 - ((i) == (last)? "\n};\n\n" : \
7467 - ((i) % (width) == (width)-1 ? ",\n" : ", "))
7469 -void gen_trees_header()
7471 - FILE *header = fopen("trees.h", "w");
7474 - Assert (header != NULL, "Can't open trees.h");
7476 - "/* header created automatically with -DGEN_TREES_H */\n\n");
7478 - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
7479 - for (i = 0; i < L_CODES+2; i++) {
7480 - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
7481 - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
7484 - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
7485 - for (i = 0; i < D_CODES; i++) {
7486 - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
7487 - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
7490 - fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
7491 - for (i = 0; i < DIST_CODE_LEN; i++) {
7492 - fprintf(header, "%2u%s", _dist_code[i],
7493 - SEPARATOR(i, DIST_CODE_LEN-1, 20));
7496 - fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
7497 - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
7498 - fprintf(header, "%2u%s", _length_code[i],
7499 - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
7502 - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
7503 - for (i = 0; i < LENGTH_CODES; i++) {
7504 - fprintf(header, "%1u%s", base_length[i],
7505 - SEPARATOR(i, LENGTH_CODES-1, 20));
7508 - fprintf(header, "local const int base_dist[D_CODES] = {\n");
7509 - for (i = 0; i < D_CODES; i++) {
7510 - fprintf(header, "%5u%s", base_dist[i],
7511 - SEPARATOR(i, D_CODES-1, 10));
7516 -#endif /* GEN_TREES_H */
7518 -/* ===========================================================================
7519 - * Initialize the tree data structures for a new zlib stream.
7521 -void _tr_init(deflate_state *s)
7528 - s->l_desc.dyn_tree = s->dyn_ltree;
7529 - s->l_desc.stat_desc = &static_l_desc;
7531 - s->d_desc.dyn_tree = s->dyn_dtree;
7532 - s->d_desc.stat_desc = &static_d_desc;
7534 - s->bl_desc.dyn_tree = s->bl_tree;
7535 - s->bl_desc.stat_desc = &static_bl_desc;
7539 - s->last_eob_len = 8; /* enough lookahead for inflate */
7541 - s->compressed_len = 0L;
7542 - s->bits_sent = 0L;
7545 - /* Initialize the first block of the first file: */
7549 -/* ===========================================================================
7550 - * Initialize a new block.
7552 -local void init_block(deflate_state *s)
7553 -/* deflate_state *s;*/
7555 - int n; /* iterates over tree elements */
7557 - /* Initialize the trees. */
7558 - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
7559 - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
7560 - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
7562 - s->dyn_ltree[END_BLOCK].Freq = 1;
7563 - s->opt_len = s->static_len = 0L;
7564 - s->last_lit = s->matches = 0;
7568 -/* Index within the heap array of least frequent node in the Huffman tree */
7571 -/* ===========================================================================
7572 - * Remove the smallest element from the heap and recreate the heap with
7573 - * one less element. Updates heap and heap_len.
7575 -#define pqremove(s, tree, top) \
7577 - top = s->heap[SMALLEST]; \
7578 - s->heap[SMALLEST] = s->heap[s->heap_len--]; \
7579 - pqdownheap(s, tree, SMALLEST); \
7582 -/* ===========================================================================
7583 - * Compares to subtrees, using the tree depth as tie breaker when
7584 - * the subtrees have equal frequency. This minimizes the worst case length.
7586 -#define smaller(tree, n, m, depth) \
7587 - (tree[n].Freq < tree[m].Freq || \
7588 - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
7590 -/* ===========================================================================
7591 - * Restore the heap property by moving down the tree starting at node k,
7592 - * exchanging a node with the smallest of its two sons if necessary, stopping
7593 - * when the heap property is re-established (each father smaller than its
7596 -local void pqdownheap(deflate_state *s, ct_data *tree, int k)
7599 - ct_data *tree; /* the tree to restore */
7600 - int k; /* node to move down */
7603 - int v = s->heap[k];
7604 - int j = k << 1; /* left son of k */
7605 - while (j <= s->heap_len) {
7606 - /* Set j to the smallest of the two sons: */
7607 - if (j < s->heap_len &&
7608 - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
7611 - /* Exit if v is smaller than both sons */
7612 - if (smaller(tree, v, s->heap[j], s->depth)) break;
7614 - /* Exchange v with the smallest son */
7615 - s->heap[k] = s->heap[j]; k = j;
7617 - /* And continue down the tree, setting j to the left son of k */
7623 -/* ===========================================================================
7624 - * Compute the optimal bit lengths for a tree and update the total bit length
7625 - * for the current block.
7626 - * IN assertion: the fields freq and dad are set, heap[heap_max] and
7627 - * above are the tree nodes sorted by increasing frequency.
7628 - * OUT assertions: the field len is set to the optimal bit length, the
7629 - * array bl_count contains the frequencies for each bit length.
7630 - * The length opt_len is updated; static_len is also updated if stree is
7633 -local void gen_bitlen(deflate_state *s, tree_desc *desc)
7636 - tree_desc *desc; /* the tree descriptor */
7639 - ct_data *tree = desc->dyn_tree;
7640 - int max_code = desc->max_code;
7641 - const ct_data *stree = desc->stat_desc->static_tree;
7642 - const intf *extra = desc->stat_desc->extra_bits;
7643 - int base = desc->stat_desc->extra_base;
7644 - int max_length = desc->stat_desc->max_length;
7645 - int h; /* heap index */
7646 - int n, m; /* iterate over the tree elements */
7647 - int bits; /* bit length */
7648 - int xbits; /* extra bits */
7649 - ush f; /* frequency */
7650 - int overflow = 0; /* number of elements with bit length too large */
7652 - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
7654 - /* In a first pass, compute the optimal bit lengths (which may
7655 - * overflow in the case of the bit length tree).
7657 - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
7659 - for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
7661 - bits = tree[tree[n].Dad].Len + 1;
7662 - if (bits > max_length) bits = max_length, overflow++;
7663 - tree[n].Len = (ush)bits;
7664 - /* We overwrite tree[n].Dad which is no longer needed */
7666 - if (n > max_code) continue; /* not a leaf node */
7668 - s->bl_count[bits]++;
7670 - if (n >= base) xbits = extra[n-base];
7672 - s->opt_len += (ulg)f * (bits + xbits);
7673 - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
7675 - if (overflow == 0) return;
7677 - Trace((stderr,"\nbit length overflow\n"));
7678 - /* This happens for example on obj2 and pic of the Calgary corpus */
7680 - /* Find the first bit length which could increase: */
7682 - bits = max_length-1;
7683 - while (s->bl_count[bits] == 0) bits--;
7684 - s->bl_count[bits]--; /* move one leaf down the tree */
7685 - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
7686 - s->bl_count[max_length]--;
7687 - /* The brother of the overflow item also moves one step up,
7688 - * but this does not affect bl_count[max_length]
7691 - } while (overflow > 0);
7693 - /* Now recompute all bit lengths, scanning in increasing frequency.
7694 - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
7695 - * lengths instead of fixing only the wrong ones. This idea is taken
7696 - * from 'ar' written by Haruhiko Okumura.)
7698 - for (bits = max_length; bits != 0; bits--) {
7699 - n = s->bl_count[bits];
7702 - if (m > max_code) continue;
7703 - if ((unsigned) tree[m].Len != (unsigned) bits) {
7704 - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
7705 - s->opt_len += ((long)bits - (long)tree[m].Len)
7706 - *(long)tree[m].Freq;
7707 - tree[m].Len = (ush)bits;
7714 -/* ===========================================================================
7715 - * Generate the codes for a given tree and bit counts (which need not be
7717 - * IN assertion: the array bl_count contains the bit length statistics for
7718 - * the given tree and the field len is set for all tree elements.
7719 - * OUT assertion: the field code is set for all tree elements of non
7720 - * zero code length.
7722 -local void gen_codes (ct_data *tree, int max_code, ushf *bl_count)
7724 - ct_data *tree; /* the tree to decorate */
7725 - int max_code; /* largest code with non zero frequency */
7726 - ushf *bl_count; /* number of codes at each bit length */
7729 - ush next_code[MAX_BITS+1]; /* next code value for each bit length */
7730 - ush code = 0; /* running code value */
7731 - int bits; /* bit index */
7732 - int n; /* code index */
7734 - /* The distribution counts are first used to generate the code values
7735 - * without bit reversal.
7737 - for (bits = 1; bits <= MAX_BITS; bits++) {
7738 - next_code[bits] = code = (code + bl_count[bits-1]) << 1;
7740 - /* Check that the bit counts in bl_count are consistent. The last code
7741 - * must be all ones.
7743 - Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
7744 - "inconsistent bit counts");
7745 - Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
7747 - for (n = 0; n <= max_code; n++) {
7748 - int len = tree[n].Len;
7749 - if (len == 0) continue;
7750 - /* Now reverse the bits */
7751 - tree[n].Code = bi_reverse(next_code[len]++, len);
7753 - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
7754 - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
7758 -/* ===========================================================================
7759 - * Construct one Huffman tree and assigns the code bit strings and lengths.
7760 - * Update the total bit length for the current block.
7761 - * IN assertion: the field freq is set for all tree elements.
7762 - * OUT assertions: the fields len and code are set to the optimal bit length
7763 - * and corresponding code. The length opt_len is updated; static_len is
7764 - * also updated if stree is not null. The field max_code is set.
7766 -local void build_tree(deflate_state *s, tree_desc *desc)
7769 - tree_desc *desc; /* the tree descriptor */
7772 - ct_data *tree = desc->dyn_tree;
7773 - const ct_data *stree = desc->stat_desc->static_tree;
7774 - int elems = desc->stat_desc->elems;
7775 - int n, m; /* iterate over heap elements */
7776 - int max_code = -1; /* largest code with non zero frequency */
7777 - int node; /* new node being created */
7779 - /* Construct the initial heap, with least frequent element in
7780 - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
7781 - * heap[0] is not used.
7783 - s->heap_len = 0, s->heap_max = HEAP_SIZE;
7785 - for (n = 0; n < elems; n++) {
7786 - if (tree[n].Freq != 0) {
7787 - s->heap[++(s->heap_len)] = max_code = n;
7794 - /* The pkzip format requires that at least one distance code exists,
7795 - * and that at least one bit should be sent even if there is only one
7796 - * possible code. So to avoid special checks later on we force at least
7797 - * two codes of non zero frequency.
7799 - while (s->heap_len < 2) {
7800 - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
7801 - tree[node].Freq = 1;
7802 - s->depth[node] = 0;
7803 - s->opt_len--; if (stree) s->static_len -= stree[node].Len;
7804 - /* node is 0 or 1 so it does not have extra bits */
7806 - desc->max_code = max_code;
7808 - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
7809 - * establish sub-heaps of increasing lengths:
7811 - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
7813 - /* Construct the Huffman tree by repeatedly combining the least two
7816 - node = elems; /* next internal node of the tree */
7818 - pqremove(s, tree, n); /* n = node of least frequency */
7819 - m = s->heap[SMALLEST]; /* m = node of next least frequency */
7821 - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
7822 - s->heap[--(s->heap_max)] = m;
7824 - /* Create a new node father of n and m */
7825 - tree[node].Freq = tree[n].Freq + tree[m].Freq;
7826 - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
7827 - s->depth[n] : s->depth[m]) + 1);
7828 - tree[n].Dad = tree[m].Dad = (ush)node;
7829 -#ifdef DUMP_BL_TREE
7830 - if (tree == s->bl_tree) {
7831 - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
7832 - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
7835 - /* and insert the new node in the heap */
7836 - s->heap[SMALLEST] = node++;
7837 - pqdownheap(s, tree, SMALLEST);
7839 - } while (s->heap_len >= 2);
7841 - s->heap[--(s->heap_max)] = s->heap[SMALLEST];
7843 - /* At this point, the fields freq and dad are set. We can now
7844 - * generate the bit lengths.
7846 - gen_bitlen(s, (tree_desc *)desc);
7848 - /* The field len is now set, we can generate the bit codes */
7849 - gen_codes ((ct_data *)tree, max_code, s->bl_count);
7852 -/* ===========================================================================
7853 - * Scan a literal or distance tree to determine the frequencies of the codes
7854 - * in the bit length tree.
7856 -local void scan_tree (deflate_state *s, ct_data *tree, int max_code)
7859 - ct_data *tree; /* the tree to be scanned */
7860 - int max_code; /* and its largest code of non zero frequency */
7863 - int n; /* iterates over all tree elements */
7864 - int prevlen = -1; /* last emitted length */
7865 - int curlen; /* length of current code */
7866 - int nextlen = tree[0].Len; /* length of next code */
7867 - int count = 0; /* repeat count of the current code */
7868 - int max_count = 7; /* max repeat count */
7869 - int min_count = 4; /* min repeat count */
7871 - if (nextlen == 0) max_count = 138, min_count = 3;
7872 - tree[max_code+1].Len = (ush)0xffff; /* guard */
7874 - for (n = 0; n <= max_code; n++) {
7875 - curlen = nextlen; nextlen = tree[n+1].Len;
7876 - if (++count < max_count && curlen == nextlen) {
7878 - } else if (count < min_count) {
7879 - s->bl_tree[curlen].Freq += count;
7880 - } else if (curlen != 0) {
7881 - if (curlen != prevlen) s->bl_tree[curlen].Freq++;
7882 - s->bl_tree[REP_3_6].Freq++;
7883 - } else if (count <= 10) {
7884 - s->bl_tree[REPZ_3_10].Freq++;
7886 - s->bl_tree[REPZ_11_138].Freq++;
7888 - count = 0; prevlen = curlen;
7889 - if (nextlen == 0) {
7890 - max_count = 138, min_count = 3;
7891 - } else if (curlen == nextlen) {
7892 - max_count = 6, min_count = 3;
7894 - max_count = 7, min_count = 4;
7899 -/* ===========================================================================
7900 - * Send a literal or distance tree in compressed form, using the codes in
7903 -local void send_tree (deflate_state *s, ct_data *tree, int max_code)
7906 - ct_data *tree; /* the tree to be scanned */
7907 - int max_code; /* and its largest code of non zero frequency */
7910 - int n; /* iterates over all tree elements */
7911 - int prevlen = -1; /* last emitted length */
7912 - int curlen; /* length of current code */
7913 - int nextlen = tree[0].Len; /* length of next code */
7914 - int count = 0; /* repeat count of the current code */
7915 - int max_count = 7; /* max repeat count */
7916 - int min_count = 4; /* min repeat count */
7918 - /* tree[max_code+1].Len = -1; */ /* guard already set */
7919 - if (nextlen == 0) max_count = 138, min_count = 3;
7921 - for (n = 0; n <= max_code; n++) {
7922 - curlen = nextlen; nextlen = tree[n+1].Len;
7923 - if (++count < max_count && curlen == nextlen) {
7925 - } else if (count < min_count) {
7926 - do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
7928 - } else if (curlen != 0) {
7929 - if (curlen != prevlen) {
7930 - send_code(s, curlen, s->bl_tree); count--;
7932 - Assert(count >= 3 && count <= 6, " 3_6?");
7933 - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
7935 - } else if (count <= 10) {
7936 - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
7939 - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
7941 - count = 0; prevlen = curlen;
7942 - if (nextlen == 0) {
7943 - max_count = 138, min_count = 3;
7944 - } else if (curlen == nextlen) {
7945 - max_count = 6, min_count = 3;
7947 - max_count = 7, min_count = 4;
7952 -/* ===========================================================================
7953 - * Construct the Huffman tree for the bit lengths and return the index in
7954 - * bl_order of the last bit length code to send.
7956 -local int build_bl_tree(deflate_state *s)
7961 - int max_blindex; /* index of last bit length code of non zero freq */
7963 - /* Determine the bit length frequencies for literal and distance trees */
7964 - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
7965 - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
7967 - /* Build the bit length tree: */
7968 - build_tree(s, (tree_desc *)(&(s->bl_desc)));
7969 - /* opt_len now includes the length of the tree representations, except
7970 - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
7973 - /* Determine the number of bit length codes to send. The pkzip format
7974 - * requires that at least 4 bit length codes be sent. (appnote.txt says
7975 - * 3 but the actual value used is 4.)
7977 - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
7978 - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
7980 - /* Update opt_len to include the bit length tree and counts */
7981 - s->opt_len += 3*(max_blindex+1) + 5+5+4;
7982 - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
7983 - s->opt_len, s->static_len));
7985 - return max_blindex;
7988 -/* ===========================================================================
7989 - * Send the header for a block using dynamic Huffman trees: the counts, the
7990 - * lengths of the bit length codes, the literal tree and the distance tree.
7991 - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
7993 -local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
7996 - int lcodes, dcodes, blcodes; /* number of codes for each tree */
7999 - int rank; /* index in bl_order */
8001 - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
8002 - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
8003 - "too many codes");
8004 - Tracev((stderr, "\nbl counts: "));
8005 - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
8006 - send_bits(s, dcodes-1, 5);
8007 - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
8008 - for (rank = 0; rank < blcodes; rank++) {
8009 - Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
8010 - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
8012 - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
8014 - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
8015 - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
8017 - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
8018 - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
8021 -/* ===========================================================================
8022 - * Send a stored block
8024 -void _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
8027 - charf *buf; /* input block */
8028 - ulg stored_len; /* length of input block */
8029 - int eof; /* true if this is the last block for a file */
8032 - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
8034 - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
8035 - s->compressed_len += (stored_len + 4) << 3;
8037 - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
8040 -/* ===========================================================================
8041 - * Send one empty static block to give enough lookahead for inflate.
8042 - * This takes 10 bits, of which 7 may remain in the bit buffer.
8043 - * The current inflate code requires 9 bits of lookahead. If the
8044 - * last two codes for the previous block (real code plus EOB) were coded
8045 - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
8046 - * the last real code. In this case we send two empty static blocks instead
8047 - * of one. (There are no problems if the previous block is stored or fixed.)
8048 - * To simplify the code, we assume the worst case of last real code encoded
8049 - * on one bit only.
8051 -void _tr_align(deflate_state *s)
8052 -/* deflate_state *s; */
8054 - send_bits(s, STATIC_TREES<<1, 3);
8055 - send_code(s, END_BLOCK, static_ltree);
8057 - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
8060 - /* Of the 10 bits for the empty block, we have already sent
8061 - * (10 - bi_valid) bits. The lookahead for the last real code (before
8062 - * the EOB of the previous block) was thus at least one plus the length
8063 - * of the EOB plus what we have just sent of the empty static block.
8065 - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
8066 - send_bits(s, STATIC_TREES<<1, 3);
8067 - send_code(s, END_BLOCK, static_ltree);
8069 - s->compressed_len += 10L;
8073 - s->last_eob_len = 7;
8076 -/* ===========================================================================
8077 - * Determine the best encoding for the current block: dynamic trees, static
8078 - * trees or store, and output the encoded block to the zip file.
8080 -void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
8083 - charf *buf; /* input block, or NULL if too old */
8084 - ulg stored_len; /* length of input block */
8085 - int eof; /* true if this is the last block for a file */
8088 - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
8089 - int max_blindex = 0; /* index of last bit length code of non zero freq */
8091 - /* Build the Huffman trees unless a stored block is forced */
8092 - if (s->level > 0) {
8094 - /* Check if the file is binary or text */
8095 - if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
8098 - /* Construct the literal and distance trees */
8099 - build_tree(s, (tree_desc *)(&(s->l_desc)));
8100 - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
8103 - build_tree(s, (tree_desc *)(&(s->d_desc)));
8104 - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
8106 - /* At this point, opt_len and static_len are the total bit lengths of
8107 - * the compressed block data, excluding the tree representations.
8110 - /* Build the bit length tree for the above two trees, and get the index
8111 - * in bl_order of the last bit length code to send.
8113 - max_blindex = build_bl_tree(s);
8115 - /* Determine the best encoding. Compute the block lengths in bytes. */
8116 - opt_lenb = (s->opt_len+3+7)>>3;
8117 - static_lenb = (s->static_len+3+7)>>3;
8119 - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
8120 - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
8123 - if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
8126 - Assert(buf != (char*)0, "lost buf");
8127 - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
8130 -#ifdef FORCE_STORED
8131 - if (buf != (char*)0) { /* force stored block */
8133 - if (stored_len+4 <= opt_lenb && buf != (char*)0) {
8134 - /* 4: two words for the lengths */
8136 - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
8137 - * Otherwise we can't have processed more than WSIZE input bytes since
8138 - * the last block flush, because compression would have been
8139 - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
8140 - * transform a block into a stored block.
8142 - _tr_stored_block(s, buf, stored_len, eof);
8144 -#ifdef FORCE_STATIC
8145 - } else if (static_lenb >= 0) { /* force static trees */
8147 - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
8149 - send_bits(s, (STATIC_TREES<<1)+eof, 3);
8150 - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
8152 - s->compressed_len += 3 + s->static_len;
8155 - send_bits(s, (DYN_TREES<<1)+eof, 3);
8156 - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
8158 - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
8160 - s->compressed_len += 3 + s->opt_len;
8163 - Assert (s->compressed_len == s->bits_sent, "bad compressed size");
8164 - /* The above check is made mod 2^32, for files larger than 512 MB
8165 - * and uLong implemented on 32 bits.
8172 - s->compressed_len += 7; /* align on byte boundary */
8175 - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
8176 - s->compressed_len-7*eof));
8179 -/* ===========================================================================
8180 - * Save the match info and tally the frequency counts. Return true if
8181 - * the current block must be flushed.
8183 -int _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
8186 - unsigned dist; /* distance of matched string */
8187 - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
8190 - s->d_buf[s->last_lit] = (ush)dist;
8191 - s->l_buf[s->last_lit++] = (uch)lc;
8193 - /* lc is the unmatched char */
8194 - s->dyn_ltree[lc].Freq++;
8197 - /* Here, lc is the match length - MIN_MATCH */
8198 - dist--; /* dist = match distance - 1 */
8199 - Assert((ush)dist < (ush)MAX_DIST(s) &&
8200 - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
8201 - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
8203 - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
8204 - s->dyn_dtree[d_code(dist)].Freq++;
8207 -#ifdef TRUNCATE_BLOCK
8208 - /* Try to guess if it is profitable to stop the current block here */
8209 - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
8210 - /* Compute an upper bound for the compressed length */
8211 - ulg out_length = (ulg)s->last_lit*8L;
8212 - ulg in_length = (ulg)((long)s->strstart - s->block_start);
8214 - for (dcode = 0; dcode < D_CODES; dcode++) {
8215 - out_length += (ulg)s->dyn_dtree[dcode].Freq *
8216 - (5L+extra_dbits[dcode]);
8219 - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
8220 - s->last_lit, in_length, out_length,
8221 - 100L - out_length*100L/in_length));
8222 - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
8225 - return (s->last_lit == s->lit_bufsize-1);
8226 - /* We avoid equality with lit_bufsize because of wraparound at 64K
8227 - * on 16 bit machines and because stored blocks are restricted to
8232 -/* ===========================================================================
8233 - * Send the block data compressed using the given Huffman trees
8235 -local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree)
8238 - ct_data *ltree; /* literal tree */
8239 - ct_data *dtree; /* distance tree */
8242 - unsigned dist; /* distance of matched string */
8243 - int lc; /* match length or unmatched char (if dist == 0) */
8244 - unsigned lx = 0; /* running index in l_buf */
8245 - unsigned code; /* the code to send */
8246 - int extra; /* number of extra bits to send */
8248 - if (s->last_lit != 0) do {
8249 - dist = s->d_buf[lx];
8250 - lc = s->l_buf[lx++];
8252 - send_code(s, lc, ltree); /* send a literal byte */
8253 - Tracecv(isgraph(lc), (stderr," '%c' ", lc));
8255 - /* Here, lc is the match length - MIN_MATCH */
8256 - code = _length_code[lc];
8257 - send_code(s, code+LITERALS+1, ltree); /* send the length code */
8258 - extra = extra_lbits[code];
8260 - lc -= base_length[code];
8261 - send_bits(s, lc, extra); /* send the extra length bits */
8263 - dist--; /* dist is now the match distance - 1 */
8264 - code = d_code(dist);
8265 - Assert (code < D_CODES, "bad d_code");
8267 - send_code(s, code, dtree); /* send the distance code */
8268 - extra = extra_dbits[code];
8270 - dist -= base_dist[code];
8271 - send_bits(s, dist, extra); /* send the extra distance bits */
8273 - } /* literal or match pair ? */
8275 - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
8276 - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
8277 - "pendingBuf overflow");
8279 - } while (lx < s->last_lit);
8281 - send_code(s, END_BLOCK, ltree);
8282 - s->last_eob_len = ltree[END_BLOCK].Len;
8285 -/* ===========================================================================
8286 - * Set the data type to BINARY or TEXT, using a crude approximation:
8287 - * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
8288 - * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
8289 - * IN assertion: the fields Freq of dyn_ltree are set.
8291 -local void set_data_type(deflate_state *s)
8292 -/* deflate_state *s; */
8296 - for (n = 0; n < 9; n++)
8297 - if (s->dyn_ltree[n].Freq != 0)
8300 - for (n = 14; n < 32; n++)
8301 - if (s->dyn_ltree[n].Freq != 0)
8303 - s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
8306 -/* ===========================================================================
8307 - * Reverse the first len bits of a code, using straightforward code (a faster
8308 - * method would use a table)
8309 - * IN assertion: 1 <= len <= 15
8311 -local unsigned bi_reverse(unsigned code, int len)
8313 - unsigned code; /* the value to invert */
8314 - int len; /* its bit length */
8317 - register unsigned res = 0;
8320 - code >>= 1, res <<= 1;
8321 - } while (--len > 0);
8325 -/* ===========================================================================
8326 - * Flush the bit buffer, keeping at most 7 bits in it.
8328 -local void bi_flush(deflate_state *s)
8329 -/* deflate_state *s; */
8331 - if (s->bi_valid == 16) {
8332 - put_short(s, s->bi_buf);
8335 - } else if (s->bi_valid >= 8) {
8336 - put_byte(s, (Byte)s->bi_buf);
8342 -/* ===========================================================================
8343 - * Flush the bit buffer and align the output on a byte boundary
8345 -local void bi_windup(deflate_state *s)
8346 -/* deflate_state *s; */
8348 - if (s->bi_valid > 8) {
8349 - put_short(s, s->bi_buf);
8350 - } else if (s->bi_valid > 0) {
8351 - put_byte(s, (Byte)s->bi_buf);
8356 - s->bits_sent = (s->bits_sent+7) & ~7;
8360 -/* ===========================================================================
8361 - * Copy a stored block, storing first the length and its
8362 - * one's complement if requested.
8364 -local void copy_block(deflate_state *s, charf *buf, unsigned len, int header)
8367 - charf *buf; /* the input data */
8368 - unsigned len; /* its length */
8369 - int header; /* true if block header must be written */
8372 - bi_windup(s); /* align on byte boundary */
8373 - s->last_eob_len = 8; /* enough lookahead for inflate */
8376 - put_short(s, (ush)len);
8377 - put_short(s, (ush)~len);
8379 - s->bits_sent += 2*16;
8383 - s->bits_sent += (ulg)len<<3;
8386 - put_byte(s, *buf++);
8389 diff -ruN seqinr.orig/src/trees.h seqinr/src/trees.h
8390 --- seqinr.orig/src/trees.h 2007-04-19 11:40:19.000000000 +0200
8391 +++ seqinr/src/trees.h 1970-01-01 01:00:00.000000000 +0100
8393 -/* header created automatically with -DGEN_TREES_H */
8395 -local const ct_data static_ltree[L_CODES+2] = {
8396 -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
8397 -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
8398 -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
8399 -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
8400 -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
8401 -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
8402 -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
8403 -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
8404 -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
8405 -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
8406 -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
8407 -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
8408 -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
8409 -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
8410 -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
8411 -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
8412 -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
8413 -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
8414 -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
8415 -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
8416 -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
8417 -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
8418 -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
8419 -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
8420 -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
8421 -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
8422 -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
8423 -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
8424 -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
8425 -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
8426 -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
8427 -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
8428 -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
8429 -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
8430 -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
8431 -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
8432 -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
8433 -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
8434 -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
8435 -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
8436 -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
8437 -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
8438 -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
8439 -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
8440 -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
8441 -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
8442 -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
8443 -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
8444 -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
8445 -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
8446 -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
8447 -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
8448 -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
8449 -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
8450 -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
8451 -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
8452 -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
8453 -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
8456 -local const ct_data static_dtree[D_CODES] = {
8457 -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
8458 -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
8459 -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
8460 -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
8461 -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
8462 -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
8465 -const uch _dist_code[DIST_CODE_LEN] = {
8466 - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
8467 - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
8468 -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
8469 -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
8470 -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
8471 -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
8472 -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8473 -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8474 -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8475 -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
8476 -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
8477 -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
8478 -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
8479 -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
8480 -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8481 -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
8482 -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
8483 -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
8484 -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
8485 -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
8486 -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
8487 -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
8488 -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
8489 -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
8490 -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
8491 -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
8494 -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
8495 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
8496 -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
8497 -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
8498 -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
8499 -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
8500 -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
8501 -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8502 -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8503 -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
8504 -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
8505 -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
8506 -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
8507 -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
8510 -local const int base_length[LENGTH_CODES] = {
8511 -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
8512 -64, 80, 96, 112, 128, 160, 192, 224, 0
8515 -local const int base_dist[D_CODES] = {
8516 - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
8517 - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
8518 - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
8521 diff -ruN seqinr.orig/src/uncompr.c seqinr/src/uncompr.c
8522 --- seqinr.orig/src/uncompr.c 2007-04-19 11:40:19.000000000 +0200
8523 +++ seqinr/src/uncompr.c 1970-01-01 01:00:00.000000000 +0100
8525 -/* uncompr.c -- decompress a memory buffer
8526 - * Copyright (C) 1995-2003 Jean-loup Gailly.
8527 - * For conditions of distribution and use, see copyright notice in zlib.h
8530 -/* @(#) $Id: uncompr.c,v 1.1.2.1 2007-04-19 09:40:18 penel Exp $ */
8532 -#define ZLIB_INTERNAL
8535 -/* ===========================================================================
8536 - Decompresses the source buffer into the destination buffer. sourceLen is
8537 - the byte length of the source buffer. Upon entry, destLen is the total
8538 - size of the destination buffer, which must be large enough to hold the
8539 - entire uncompressed data. (The size of the uncompressed data must have
8540 - been saved previously by the compressor and transmitted to the decompressor
8541 - by some mechanism outside the scope of this compression library.)
8542 - Upon exit, destLen is the actual size of the compressed buffer.
8543 - This function can be used to decompress a whole file at once if the
8544 - input file is mmap'ed.
8546 - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
8547 - enough memory, Z_BUF_ERROR if there was not enough room in the output
8548 - buffer, or Z_DATA_ERROR if the input data was corrupted.
8550 -int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
8554 - const Bytef *source;
8561 - stream.next_in = (Bytef*)source;
8562 - stream.avail_in = (uInt)sourceLen;
8563 - /* Check for source > 64K on 16-bit machine: */
8564 - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
8566 - stream.next_out = dest;
8567 - stream.avail_out = (uInt)*destLen;
8568 - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
8570 - stream.zalloc = (alloc_func)0;
8571 - stream.zfree = (free_func)0;
8573 - err = inflateInit(&stream);
8574 - if (err != Z_OK) return err;
8576 - err = inflate(&stream, Z_FINISH);
8577 - if (err != Z_STREAM_END) {
8578 - inflateEnd(&stream);
8579 - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
8580 - return Z_DATA_ERROR;
8583 - *destLen = stream.total_out;
8585 - err = inflateEnd(&stream);
8588 diff -ruN seqinr.orig/src/zconf.h seqinr/src/zconf.h
8589 --- seqinr.orig/src/zconf.h 2007-04-19 11:40:19.000000000 +0200
8590 +++ seqinr/src/zconf.h 1970-01-01 01:00:00.000000000 +0100
8592 -/* zconf.h -- configuration of the zlib compression library
8593 - * Copyright (C) 1995-2005 Jean-loup Gailly.
8594 - * For conditions of distribution and use, see copyright notice in zlib.h
8597 -/* @(#) $Id: zconf.h,v 1.1.2.1 2007-04-19 09:40:19 penel Exp $ */
8602 -#ifdef HAVE_CONFIG_H
8603 -#include <config.h>
8606 - * If you *really* need a unique prefix for all types and library functions,
8607 - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
8610 -# define deflateInit_ z_deflateInit_
8611 -# define deflate z_deflate
8612 -# define deflateEnd z_deflateEnd
8613 -# define inflateInit_ z_inflateInit_
8614 -# define inflate z_inflate
8615 -# define inflateEnd z_inflateEnd
8616 -# define deflateInit2_ z_deflateInit2_
8617 -# define deflateSetDictionary z_deflateSetDictionary
8618 -# define deflateCopy z_deflateCopy
8619 -# define deflateReset z_deflateReset
8620 -# define deflateParams z_deflateParams
8621 -# define deflateBound z_deflateBound
8622 -# define deflatePrime z_deflatePrime
8623 -# define inflateInit2_ z_inflateInit2_
8624 -# define inflateSetDictionary z_inflateSetDictionary
8625 -# define inflateSync z_inflateSync
8626 -# define inflateSyncPoint z_inflateSyncPoint
8627 -# define inflateCopy z_inflateCopy
8628 -# define inflateReset z_inflateReset
8629 -# define inflateBack z_inflateBack
8630 -# define inflateBackEnd z_inflateBackEnd
8631 -# define compress z_compress
8632 -# define compress2 z_compress2
8633 -# define compressBound z_compressBound
8634 -# define uncompress z_uncompress
8635 -# define adler32 z_adler32
8636 -# define crc32 z_crc32
8637 -# define get_crc_table z_get_crc_table
8638 -# define zError z_zError
8640 -# define alloc_func z_alloc_func
8641 -# define free_func z_free_func
8642 -# define in_func z_in_func
8643 -# define out_func z_out_func
8644 -# define Byte z_Byte
8645 -# define uInt z_uInt
8646 -# define uLong z_uLong
8647 -# define Bytef z_Bytef
8648 -# define charf z_charf
8649 -# define intf z_intf
8650 -# define uIntf z_uIntf
8651 -# define uLongf z_uLongf
8652 -# define voidpf z_voidpf
8653 -# define voidp z_voidp
8656 -#if defined(__MSDOS__) && !defined(MSDOS)
8659 -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
8662 -#if defined(_WINDOWS) && !defined(WINDOWS)
8665 -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
8670 -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
8671 -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
8679 - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
8680 - * than 64k bytes at a time (needed on systems with 16-bit int).
8683 -# define MAXSEG_64K
8686 -# define UNALIGNED_OK
8689 -#ifdef __STDC_VERSION__
8693 -# if __STDC_VERSION__ >= 199901L
8699 -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
8702 -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
8705 -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
8708 -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
8712 -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
8717 -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
8718 -# define const /* note: need a more gentle solution here */
8722 -/* Some Mac compilers merge all .h files incorrectly: */
8723 -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
8724 -# define NO_DUMMY_DECL
8727 -/* Maximum value for memLevel in deflateInit2 */
8728 -#ifndef MAX_MEM_LEVEL
8730 -# define MAX_MEM_LEVEL 8
8732 -# define MAX_MEM_LEVEL 9
8736 -/* Maximum value for windowBits in deflateInit2 and inflateInit2.
8737 - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
8738 - * created by gzip. (Files created by minigzip can still be extracted by
8742 -# define MAX_WBITS 15 /* 32K LZ77 window */
8745 -/* The memory requirements for deflate are (in bytes):
8746 - (1 << (windowBits+2)) + (1 << (memLevel+9))
8747 - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
8748 - plus a few kilobytes for small objects. For example, if you want to reduce
8749 - the default memory requirements from 256K to 128K, compile with
8750 - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
8751 - Of course this will generally degrade compression (there's no free lunch).
8753 - The memory requirements for inflate are (in bytes) 1 << windowBits
8754 - that is, 32K for windowBits=15 (default value) plus a few kilobytes
8755 - for small objects.
8758 - /* Type declarations */
8760 -#ifndef OF /* function prototypes */
8762 -# define OF(args) args
8764 -# define OF(args) ()
8768 -/* The following definitions for FAR are needed only for MSDOS mixed
8769 - * model programming (small or medium model with some far allocations).
8770 - * This was tested only with MSC; for other MSDOS compilers you may have
8771 - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
8772 - * just define FAR to be empty.
8775 -# if defined(M_I86SM) || defined(M_I86MM)
8776 - /* MSC small or medium model */
8777 -# define SMALL_MEDIUM
8784 -# if (defined(__SMALL__) || defined(__MEDIUM__))
8785 - /* Turbo C small or medium model */
8786 -# define SMALL_MEDIUM
8787 -# ifdef __BORLANDC__
8795 -#if defined(WINDOWS) || defined(WIN32)
8796 - /* If building or using zlib as a DLL, define ZLIB_DLL.
8797 - * This is not mandatory, but it offers a little performance increase.
8800 -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
8801 -# ifdef ZLIB_INTERNAL
8802 -# define ZEXTERN extern __declspec(dllexport)
8804 -# define ZEXTERN extern __declspec(dllimport)
8807 -# endif /* ZLIB_DLL */
8808 - /* If building or using zlib with the WINAPI/WINAPIV calling convention,
8809 - * define ZLIB_WINAPI.
8810 - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
8812 -# ifdef ZLIB_WINAPI
8816 -# include <windows.h>
8817 - /* No need for _export, use ZLIB.DEF instead. */
8818 - /* For complete Windows compatibility, use WINAPI, not __stdcall. */
8819 -# define ZEXPORT WINAPI
8821 -# define ZEXPORTVA WINAPIV
8823 -# define ZEXPORTVA FAR CDECL
8828 -#if defined (__BEOS__)
8830 -# ifdef ZLIB_INTERNAL
8831 -# define ZEXPORT __declspec(dllexport)
8832 -# define ZEXPORTVA __declspec(dllexport)
8834 -# define ZEXPORT __declspec(dllimport)
8835 -# define ZEXPORTVA __declspec(dllimport)
8841 -# define ZEXTERN extern
8854 -#if !defined(__MACTYPES__)
8855 -typedef unsigned char Byte; /* 8 bits */
8857 -typedef unsigned int uInt; /* 16 bits or more */
8858 -typedef unsigned long uLong; /* 32 bits or more */
8860 -#ifdef SMALL_MEDIUM
8861 - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
8862 -# define Bytef Byte FAR
8864 - typedef Byte FAR Bytef;
8866 -typedef char FAR charf;
8867 -typedef int FAR intf;
8868 -typedef uInt FAR uIntf;
8869 -typedef uLong FAR uLongf;
8872 - typedef void const *voidpc;
8873 - typedef void FAR *voidpf;
8874 - typedef void *voidp;
8876 - typedef Byte const *voidpc;
8877 - typedef Byte FAR *voidpf;
8878 - typedef Byte *voidp;
8881 -#ifdef HAVE_UNISTD_H /* HAVE_UNISTD_H -- this line is updated by ./configure */
8882 -# include <sys/types.h> /* for off_t */
8883 -# include <unistd.h> /* for SEEK_* and off_t */
8885 -# include <unixio.h> /* for off_t */
8887 -# define z_off_t off_t
8890 -# define SEEK_SET 0 /* Seek from beginning of file. */
8891 -# define SEEK_CUR 1 /* Seek from current position. */
8892 -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
8895 -# define z_off_t long
8898 -#if defined(__OS400__)
8899 -# define NO_vsnprintf
8902 -#if defined(__MVS__)
8903 -# define NO_vsnprintf
8909 -/* MVS linker does not support external names larger than 8 bytes */
8910 -#if defined(__MVS__)
8911 -# pragma map(deflateInit_,"DEIN")
8912 -# pragma map(deflateInit2_,"DEIN2")
8913 -# pragma map(deflateEnd,"DEEND")
8914 -# pragma map(deflateBound,"DEBND")
8915 -# pragma map(inflateInit_,"ININ")
8916 -# pragma map(inflateInit2_,"ININ2")
8917 -# pragma map(inflateEnd,"INEND")
8918 -# pragma map(inflateSync,"INSY")
8919 -# pragma map(inflateSetDictionary,"INSEDI")
8920 -# pragma map(compressBound,"CMBND")
8921 -# pragma map(inflate_table,"INTABL")
8922 -# pragma map(inflate_fast,"INFA")
8923 -# pragma map(inflate_copyright,"INCOPY")
8926 -#endif /* ZCONF_H */
8927 diff -ruN seqinr.orig/src/zlib.h seqinr/src/zlib.h
8928 --- seqinr.orig/src/zlib.h 2007-04-19 11:40:19.000000000 +0200
8929 +++ seqinr/src/zlib.h 1970-01-01 01:00:00.000000000 +0100
8931 -/* zlib.h -- interface of the 'zlib' general purpose compression library
8932 - version 1.2.3, July 18th, 2005
8934 - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
8936 - This software is provided 'as-is', without any express or implied
8937 - warranty. In no event will the authors be held liable for any damages
8938 - arising from the use of this software.
8940 - Permission is granted to anyone to use this software for any purpose,
8941 - including commercial applications, and to alter it and redistribute it
8942 - freely, subject to the following restrictions:
8944 - 1. The origin of this software must not be misrepresented; you must not
8945 - claim that you wrote the original software. If you use this software
8946 - in a product, an acknowledgment in the product documentation would be
8947 - appreciated but is not required.
8948 - 2. Altered source versions must be plainly marked as such, and must not be
8949 - misrepresented as being the original software.
8950 - 3. This notice may not be removed or altered from any source distribution.
8952 - Jean-loup Gailly Mark Adler
8953 - jloup@gzip.org madler@alumni.caltech.edu
8956 - The data format used by the zlib library is described by RFCs (Request for
8957 - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
8958 - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
8970 -#define ZLIB_VERSION "1.2.3"
8971 -#define ZLIB_VERNUM 0x1230
8974 - The 'zlib' compression library provides in-memory compression and
8975 - decompression functions, including integrity checks of the uncompressed
8976 - data. This version of the library supports only one compression method
8977 - (deflation) but other algorithms will be added later and will have the same
8980 - Compression can be done in a single step if the buffers are large
8981 - enough (for example if an input file is mmap'ed), or can be done by
8982 - repeated calls of the compression function. In the latter case, the
8983 - application must provide more input and/or consume the output
8984 - (providing more output space) before each call.
8986 - The compressed data format used by default by the in-memory functions is
8987 - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
8988 - around a deflate stream, which is itself documented in RFC 1951.
8990 - The library also supports reading and writing files in gzip (.gz) format
8991 - with an interface similar to that of stdio using the functions that start
8992 - with "gz". The gzip format is different from the zlib format. gzip is a
8993 - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
8995 - This library can optionally read and write gzip streams in memory as well.
8997 - The zlib format was designed to be compact and fast for use in memory
8998 - and on communications channels. The gzip format was designed for single-
8999 - file compression on file systems, has a larger header than zlib to maintain
9000 - directory information, and uses a different, slower check method than zlib.
9002 - The library does not install any signal handler. The decoder checks
9003 - the consistency of the compressed data, so the library should never
9004 - crash even in case of corrupted input.
9007 -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
9008 -typedef void (*free_func) OF((voidpf opaque, voidpf address));
9010 -struct internal_state;
9012 -typedef struct z_stream_s {
9013 - Bytef *next_in; /* next input byte */
9014 - uInt avail_in; /* number of bytes available at next_in */
9015 - uLong total_in; /* total nb of input bytes read so far */
9017 - Bytef *next_out; /* next output byte should be put there */
9018 - uInt avail_out; /* remaining free space at next_out */
9019 - uLong total_out; /* total nb of bytes output so far */
9021 - char *msg; /* last error message, NULL if no error */
9022 - struct internal_state FAR *state; /* not visible by applications */
9024 - alloc_func zalloc; /* used to allocate the internal state */
9025 - free_func zfree; /* used to free the internal state */
9026 - voidpf opaque; /* private data object passed to zalloc and zfree */
9028 - int data_type; /* best guess about the data type: binary or text */
9029 - uLong adler; /* adler32 value of the uncompressed data */
9030 - uLong reserved; /* reserved for future use */
9033 -typedef z_stream FAR *z_streamp;
9036 - gzip header information passed to and from zlib routines. See RFC 1952
9037 - for more details on the meanings of these fields.
9039 -typedef struct gz_header_s {
9040 - int text; /* true if compressed data believed to be text */
9041 - uLong time; /* modification time */
9042 - int xflags; /* extra flags (not used when writing a gzip file) */
9043 - int os; /* operating system */
9044 - Bytef *extra; /* pointer to extra field or Z_NULL if none */
9045 - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
9046 - uInt extra_max; /* space at extra (only when reading header) */
9047 - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
9048 - uInt name_max; /* space at name (only when reading header) */
9049 - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
9050 - uInt comm_max; /* space at comment (only when reading header) */
9051 - int hcrc; /* true if there was or will be a header crc */
9052 - int done; /* true when done reading gzip header (not used
9053 - when writing a gzip file) */
9056 -typedef gz_header FAR *gz_headerp;
9059 - The application must update next_in and avail_in when avail_in has
9060 - dropped to zero. It must update next_out and avail_out when avail_out
9061 - has dropped to zero. The application must initialize zalloc, zfree and
9062 - opaque before calling the init function. All other fields are set by the
9063 - compression library and must not be updated by the application.
9065 - The opaque value provided by the application will be passed as the first
9066 - parameter for calls of zalloc and zfree. This can be useful for custom
9067 - memory management. The compression library attaches no meaning to the
9070 - zalloc must return Z_NULL if there is not enough memory for the object.
9071 - If zlib is used in a multi-threaded application, zalloc and zfree must be
9074 - On 16-bit systems, the functions zalloc and zfree must be able to allocate
9075 - exactly 65536 bytes, but will not be required to allocate more than this
9076 - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
9077 - pointers returned by zalloc for objects of exactly 65536 bytes *must*
9078 - have their offset normalized to zero. The default allocation function
9079 - provided by this library ensures this (see zutil.c). To reduce memory
9080 - requirements and avoid any allocation of 64K objects, at the expense of
9081 - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
9083 - The fields total_in and total_out can be used for statistics or
9084 - progress reports. After compression, total_in holds the total size of
9085 - the uncompressed data and may be saved for use in the decompressor
9086 - (particularly if the decompressor wants to decompress everything in
9092 -#define Z_NO_FLUSH 0
9093 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
9094 -#define Z_SYNC_FLUSH 2
9095 -#define Z_FULL_FLUSH 3
9098 -/* Allowed flush values; see deflate() and inflate() below for details */
9101 -#define Z_STREAM_END 1
9102 -#define Z_NEED_DICT 2
9103 -#define Z_ERRNO (-1)
9104 -#define Z_STREAM_ERROR (-2)
9105 -#define Z_DATA_ERROR (-3)
9106 -#define Z_MEM_ERROR (-4)
9107 -#define Z_BUF_ERROR (-5)
9108 -#define Z_VERSION_ERROR (-6)
9109 -/* Return codes for the compression/decompression functions. Negative
9110 - * values are errors, positive values are used for special but normal events.
9113 -#define Z_NO_COMPRESSION 0
9114 -#define Z_BEST_SPEED 1
9115 -#define Z_BEST_COMPRESSION 9
9116 -#define Z_DEFAULT_COMPRESSION (-1)
9117 -/* compression levels */
9119 -#define Z_FILTERED 1
9120 -#define Z_HUFFMAN_ONLY 2
9123 -#define Z_DEFAULT_STRATEGY 0
9124 -/* compression strategy; see deflateInit2() below for details */
9128 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
9129 -#define Z_UNKNOWN 2
9130 -/* Possible values of the data_type field (though see inflate()) */
9132 -#define Z_DEFLATED 8
9133 -/* The deflate compression method (the only one supported in this version) */
9135 -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
9137 -#define zlib_version zlibVersion()
9138 -/* for compatibility with versions < 1.0.2 */
9140 - /* basic functions */
9142 -ZEXTERN const char * ZEXPORT zlibVersion OF((void));
9143 -/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
9144 - If the first character differs, the library code actually used is
9145 - not compatible with the zlib.h header file used by the application.
9146 - This check is automatically made by deflateInit and inflateInit.
9150 -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
9152 - Initializes the internal stream state for compression. The fields
9153 - zalloc, zfree and opaque must be initialized before by the caller.
9154 - If zalloc and zfree are set to Z_NULL, deflateInit updates them to
9155 - use default allocation functions.
9157 - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
9158 - 1 gives best speed, 9 gives best compression, 0 gives no compression at
9159 - all (the input data is simply copied a block at a time).
9160 - Z_DEFAULT_COMPRESSION requests a default compromise between speed and
9161 - compression (currently equivalent to level 6).
9163 - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
9164 - enough memory, Z_STREAM_ERROR if level is not a valid compression level,
9165 - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
9166 - with the version assumed by the caller (ZLIB_VERSION).
9167 - msg is set to null if there is no error message. deflateInit does not
9168 - perform any compression: this will be done by deflate().
9172 -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
9174 - deflate compresses as much data as possible, and stops when the input
9175 - buffer becomes empty or the output buffer becomes full. It may introduce some
9176 - output latency (reading input without producing any output) except when
9179 - The detailed semantics are as follows. deflate performs one or both of the
9180 - following actions:
9182 - - Compress more input starting at next_in and update next_in and avail_in
9183 - accordingly. If not all input can be processed (because there is not
9184 - enough room in the output buffer), next_in and avail_in are updated and
9185 - processing will resume at this point for the next call of deflate().
9187 - - Provide more output starting at next_out and update next_out and avail_out
9188 - accordingly. This action is forced if the parameter flush is non zero.
9189 - Forcing flush frequently degrades the compression ratio, so this parameter
9190 - should be set only when necessary (in interactive applications).
9191 - Some output may be provided even if flush is not set.
9193 - Before the call of deflate(), the application should ensure that at least
9194 - one of the actions is possible, by providing more input and/or consuming
9195 - more output, and updating avail_in or avail_out accordingly; avail_out
9196 - should never be zero before the call. The application can consume the
9197 - compressed output when it wants, for example when the output buffer is full
9198 - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
9199 - and with zero avail_out, it must be called again after making room in the
9200 - output buffer because there might be more output pending.
9202 - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
9203 - decide how much data to accumualte before producing output, in order to
9204 - maximize compression.
9206 - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
9207 - flushed to the output buffer and the output is aligned on a byte boundary, so
9208 - that the decompressor can get all input data available so far. (In particular
9209 - avail_in is zero after the call if enough output space has been provided
9210 - before the call.) Flushing may degrade compression for some compression
9211 - algorithms and so it should be used only when necessary.
9213 - If flush is set to Z_FULL_FLUSH, all output is flushed as with
9214 - Z_SYNC_FLUSH, and the compression state is reset so that decompression can
9215 - restart from this point if previous compressed data has been damaged or if
9216 - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
9219 - If deflate returns with avail_out == 0, this function must be called again
9220 - with the same value of the flush parameter and more output space (updated
9221 - avail_out), until the flush is complete (deflate returns with non-zero
9222 - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
9223 - avail_out is greater than six to avoid repeated flush markers due to
9224 - avail_out == 0 on return.
9226 - If the parameter flush is set to Z_FINISH, pending input is processed,
9227 - pending output is flushed and deflate returns with Z_STREAM_END if there
9228 - was enough output space; if deflate returns with Z_OK, this function must be
9229 - called again with Z_FINISH and more output space (updated avail_out) but no
9230 - more input data, until it returns with Z_STREAM_END or an error. After
9231 - deflate has returned Z_STREAM_END, the only possible operations on the
9232 - stream are deflateReset or deflateEnd.
9234 - Z_FINISH can be used immediately after deflateInit if all the compression
9235 - is to be done in a single step. In this case, avail_out must be at least
9236 - the value returned by deflateBound (see below). If deflate does not return
9237 - Z_STREAM_END, then it must be called again as described above.
9239 - deflate() sets strm->adler to the adler32 checksum of all input read
9240 - so far (that is, total_in bytes).
9242 - deflate() may update strm->data_type if it can make a good guess about
9243 - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
9244 - binary. This field is only for information purposes and does not affect
9245 - the compression algorithm in any manner.
9247 - deflate() returns Z_OK if some progress has been made (more input
9248 - processed or more output produced), Z_STREAM_END if all input has been
9249 - consumed and all output has been produced (only when flush is set to
9250 - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
9251 - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
9252 - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
9253 - fatal, and deflate() can be called again with more input and more output
9254 - space to continue compressing.
9258 -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
9260 - All dynamically allocated data structures for this stream are freed.
9261 - This function discards any unprocessed input and does not flush any
9264 - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
9265 - stream state was inconsistent, Z_DATA_ERROR if the stream was freed
9266 - prematurely (some input or output was discarded). In the error case,
9267 - msg may be set but then points to a static string (which must not be
9273 -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
9275 - Initializes the internal stream state for decompression. The fields
9276 - next_in, avail_in, zalloc, zfree and opaque must be initialized before by
9277 - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
9278 - value depends on the compression method), inflateInit determines the
9279 - compression method from the zlib header and allocates all data structures
9280 - accordingly; otherwise the allocation will be deferred to the first call of
9281 - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
9282 - use default allocation functions.
9284 - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
9285 - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
9286 - version assumed by the caller. msg is set to null if there is no error
9287 - message. inflateInit does not perform any decompression apart from reading
9288 - the zlib header if present: this will be done by inflate(). (So next_in and
9289 - avail_in may be modified, but next_out and avail_out are unchanged.)
9293 -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
9295 - inflate decompresses as much data as possible, and stops when the input
9296 - buffer becomes empty or the output buffer becomes full. It may introduce
9297 - some output latency (reading input without producing any output) except when
9300 - The detailed semantics are as follows. inflate performs one or both of the
9301 - following actions:
9303 - - Decompress more input starting at next_in and update next_in and avail_in
9304 - accordingly. If not all input can be processed (because there is not
9305 - enough room in the output buffer), next_in is updated and processing
9306 - will resume at this point for the next call of inflate().
9308 - - Provide more output starting at next_out and update next_out and avail_out
9309 - accordingly. inflate() provides as much output as possible, until there
9310 - is no more input data or no more space in the output buffer (see below
9311 - about the flush parameter).
9313 - Before the call of inflate(), the application should ensure that at least
9314 - one of the actions is possible, by providing more input and/or consuming
9315 - more output, and updating the next_* and avail_* values accordingly.
9316 - The application can consume the uncompressed output when it wants, for
9317 - example when the output buffer is full (avail_out == 0), or after each
9318 - call of inflate(). If inflate returns Z_OK and with zero avail_out, it
9319 - must be called again after making room in the output buffer because there
9320 - might be more output pending.
9322 - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
9323 - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
9324 - output as possible to the output buffer. Z_BLOCK requests that inflate() stop
9325 - if and when it gets to the next deflate block boundary. When decoding the
9326 - zlib or gzip format, this will cause inflate() to return immediately after
9327 - the header and before the first block. When doing a raw inflate, inflate()
9328 - will go ahead and process the first block, and will return when it gets to
9329 - the end of that block, or when it runs out of data.
9331 - The Z_BLOCK option assists in appending to or combining deflate streams.
9332 - Also to assist in this, on return inflate() will set strm->data_type to the
9333 - number of unused bits in the last byte taken from strm->next_in, plus 64
9334 - if inflate() is currently decoding the last block in the deflate stream,
9335 - plus 128 if inflate() returned immediately after decoding an end-of-block
9336 - code or decoding the complete header up to just before the first byte of the
9337 - deflate stream. The end-of-block will not be indicated until all of the
9338 - uncompressed data from that block has been written to strm->next_out. The
9339 - number of unused bits may in general be greater than seven, except when
9340 - bit 7 of data_type is set, in which case the number of unused bits will be
9343 - inflate() should normally be called until it returns Z_STREAM_END or an
9344 - error. However if all decompression is to be performed in a single step
9345 - (a single call of inflate), the parameter flush should be set to
9346 - Z_FINISH. In this case all pending input is processed and all pending
9347 - output is flushed; avail_out must be large enough to hold all the
9348 - uncompressed data. (The size of the uncompressed data may have been saved
9349 - by the compressor for this purpose.) The next operation on this stream must
9350 - be inflateEnd to deallocate the decompression state. The use of Z_FINISH
9351 - is never required, but can be used to inform inflate that a faster approach
9352 - may be used for the single inflate() call.
9354 - In this implementation, inflate() always flushes as much output as
9355 - possible to the output buffer, and always uses the faster approach on the
9356 - first call. So the only effect of the flush parameter in this implementation
9357 - is on the return value of inflate(), as noted below, or when it returns early
9358 - because Z_BLOCK is used.
9360 - If a preset dictionary is needed after this call (see inflateSetDictionary
9361 - below), inflate sets strm->adler to the adler32 checksum of the dictionary
9362 - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
9363 - strm->adler to the adler32 checksum of all output produced so far (that is,
9364 - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
9365 - below. At the end of the stream, inflate() checks that its computed adler32
9366 - checksum is equal to that saved by the compressor and returns Z_STREAM_END
9367 - only if the checksum is correct.
9369 - inflate() will decompress and check either zlib-wrapped or gzip-wrapped
9370 - deflate data. The header type is detected automatically. Any information
9371 - contained in the gzip header is not retained, so applications that need that
9372 - information should instead use raw inflate, see inflateInit2() below, or
9373 - inflateBack() and perform their own processing of the gzip header and
9376 - inflate() returns Z_OK if some progress has been made (more input processed
9377 - or more output produced), Z_STREAM_END if the end of the compressed data has
9378 - been reached and all uncompressed output has been produced, Z_NEED_DICT if a
9379 - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
9380 - corrupted (input stream not conforming to the zlib format or incorrect check
9381 - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
9382 - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
9383 - Z_BUF_ERROR if no progress is possible or if there was not enough room in the
9384 - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
9385 - inflate() can be called again with more input and more output space to
9386 - continue decompressing. If Z_DATA_ERROR is returned, the application may then
9387 - call inflateSync() to look for a good compression block if a partial recovery
9388 - of the data is desired.
9392 -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
9394 - All dynamically allocated data structures for this stream are freed.
9395 - This function discards any unprocessed input and does not flush any
9398 - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
9399 - was inconsistent. In the error case, msg may be set but then points to a
9400 - static string (which must not be deallocated).
9403 - /* Advanced functions */
9406 - The following functions are needed only in some special applications.
9410 -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
9417 - This is another version of deflateInit with more compression options. The
9418 - fields next_in, zalloc, zfree and opaque must be initialized before by
9421 - The method parameter is the compression method. It must be Z_DEFLATED in
9422 - this version of the library.
9424 - The windowBits parameter is the base two logarithm of the window size
9425 - (the size of the history buffer). It should be in the range 8..15 for this
9426 - version of the library. Larger values of this parameter result in better
9427 - compression at the expense of memory usage. The default value is 15 if
9428 - deflateInit is used instead.
9430 - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
9431 - determines the window size. deflate() will then generate raw deflate data
9432 - with no zlib header or trailer, and will not compute an adler32 check value.
9434 - windowBits can also be greater than 15 for optional gzip encoding. Add
9435 - 16 to windowBits to write a simple gzip header and trailer around the
9436 - compressed data instead of a zlib wrapper. The gzip header will have no
9437 - file name, no extra data, no comment, no modification time (set to zero),
9438 - no header crc, and the operating system will be set to 255 (unknown). If a
9439 - gzip stream is being written, strm->adler is a crc32 instead of an adler32.
9441 - The memLevel parameter specifies how much memory should be allocated
9442 - for the internal compression state. memLevel=1 uses minimum memory but
9443 - is slow and reduces compression ratio; memLevel=9 uses maximum memory
9444 - for optimal speed. The default value is 8. See zconf.h for total memory
9445 - usage as a function of windowBits and memLevel.
9447 - The strategy parameter is used to tune the compression algorithm. Use the
9448 - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
9449 - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
9450 - string match), or Z_RLE to limit match distances to one (run-length
9451 - encoding). Filtered data consists mostly of small values with a somewhat
9452 - random distribution. In this case, the compression algorithm is tuned to
9453 - compress them better. The effect of Z_FILTERED is to force more Huffman
9454 - coding and less string matching; it is somewhat intermediate between
9455 - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
9456 - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
9457 - parameter only affects the compression ratio but not the correctness of the
9458 - compressed output even if it is not set appropriately. Z_FIXED prevents the
9459 - use of dynamic Huffman codes, allowing for a simpler decoder for special
9462 - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
9463 - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
9464 - method). msg is set to null if there is no error message. deflateInit2 does
9465 - not perform any compression: this will be done by deflate().
9468 -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
9469 - const Bytef *dictionary,
9470 - uInt dictLength));
9472 - Initializes the compression dictionary from the given byte sequence
9473 - without producing any compressed output. This function must be called
9474 - immediately after deflateInit, deflateInit2 or deflateReset, before any
9475 - call of deflate. The compressor and decompressor must use exactly the same
9476 - dictionary (see inflateSetDictionary).
9478 - The dictionary should consist of strings (byte sequences) that are likely
9479 - to be encountered later in the data to be compressed, with the most commonly
9480 - used strings preferably put towards the end of the dictionary. Using a
9481 - dictionary is most useful when the data to be compressed is short and can be
9482 - predicted with good accuracy; the data can then be compressed better than
9483 - with the default empty dictionary.
9485 - Depending on the size of the compression data structures selected by
9486 - deflateInit or deflateInit2, a part of the dictionary may in effect be
9487 - discarded, for example if the dictionary is larger than the window size in
9488 - deflate or deflate2. Thus the strings most likely to be useful should be
9489 - put at the end of the dictionary, not at the front. In addition, the
9490 - current implementation of deflate will use at most the window size minus
9491 - 262 bytes of the provided dictionary.
9493 - Upon return of this function, strm->adler is set to the adler32 value
9494 - of the dictionary; the decompressor may later use this value to determine
9495 - which dictionary has been used by the compressor. (The adler32 value
9496 - applies to the whole dictionary even if only a subset of the dictionary is
9497 - actually used by the compressor.) If a raw deflate was requested, then the
9498 - adler32 value is not computed and strm->adler is not set.
9500 - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
9501 - parameter is invalid (such as NULL dictionary) or the stream state is
9502 - inconsistent (for example if deflate has already been called for this stream
9503 - or if the compression method is bsort). deflateSetDictionary does not
9504 - perform any compression: this will be done by deflate().
9507 -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
9508 - z_streamp source));
9510 - Sets the destination stream as a complete copy of the source stream.
9512 - This function can be useful when several compression strategies will be
9513 - tried, for example when there are several ways of pre-processing the input
9514 - data with a filter. The streams that will be discarded should then be freed
9515 - by calling deflateEnd. Note that deflateCopy duplicates the internal
9516 - compression state which can be quite large, so this strategy is slow and
9517 - can consume lots of memory.
9519 - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
9520 - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
9521 - (such as zalloc being NULL). msg is left unchanged in both source and
9525 -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
9527 - This function is equivalent to deflateEnd followed by deflateInit,
9528 - but does not free and reallocate all the internal compression state.
9529 - The stream will keep the same compression level and any other attributes
9530 - that may have been set by deflateInit2.
9532 - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
9533 - stream state was inconsistent (such as zalloc or state being NULL).
9536 -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
9540 - Dynamically update the compression level and compression strategy. The
9541 - interpretation of level and strategy is as in deflateInit2. This can be
9542 - used to switch between compression and straight copy of the input data, or
9543 - to switch to a different kind of input data requiring a different
9544 - strategy. If the compression level is changed, the input available so far
9545 - is compressed with the old level (and may be flushed); the new level will
9546 - take effect only at the next call of deflate().
9548 - Before the call of deflateParams, the stream state must be set as for
9549 - a call of deflate(), since the currently available input may have to
9550 - be compressed and flushed. In particular, strm->avail_out must be non-zero.
9552 - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
9553 - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
9554 - if strm->avail_out was zero.
9557 -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
9563 - Fine tune deflate's internal compression parameters. This should only be
9564 - used by someone who understands the algorithm used by zlib's deflate for
9565 - searching for the best matching string, and even then only by the most
9566 - fanatic optimizer trying to squeeze out the last compressed bit for their
9567 - specific input data. Read the deflate.c source code for the meaning of the
9568 - max_lazy, good_length, nice_length, and max_chain parameters.
9570 - deflateTune() can be called after deflateInit() or deflateInit2(), and
9571 - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
9574 -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
9575 - uLong sourceLen));
9577 - deflateBound() returns an upper bound on the compressed size after
9578 - deflation of sourceLen bytes. It must be called after deflateInit()
9579 - or deflateInit2(). This would be used to allocate an output buffer
9580 - for deflation in a single pass, and so would be called before deflate().
9583 -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
9587 - deflatePrime() inserts bits in the deflate output stream. The intent
9588 - is that this function is used to start off the deflate output with the
9589 - bits leftover from a previous deflate stream when appending to it. As such,
9590 - this function can only be used for raw deflate, and must be used before the
9591 - first deflate() call after a deflateInit2() or deflateReset(). bits must be
9592 - less than or equal to 16, and that many of the least significant bits of
9593 - value will be inserted in the output.
9595 - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
9596 - stream state was inconsistent.
9599 -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
9600 - gz_headerp head));
9602 - deflateSetHeader() provides gzip header information for when a gzip
9603 - stream is requested by deflateInit2(). deflateSetHeader() may be called
9604 - after deflateInit2() or deflateReset() and before the first call of
9605 - deflate(). The text, time, os, extra field, name, and comment information
9606 - in the provided gz_header structure are written to the gzip header (xflag is
9607 - ignored -- the extra flags are set according to the compression level). The
9608 - caller must assure that, if not Z_NULL, name and comment are terminated with
9609 - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
9610 - available there. If hcrc is true, a gzip header crc is included. Note that
9611 - the current versions of the command-line version of gzip (up through version
9612 - 1.3.x) do not support header crc's, and will report that it is a "multi-part
9613 - gzip file" and give up.
9615 - If deflateSetHeader is not used, the default gzip header has text false,
9616 - the time set to zero, and os set to 255, with no extra, name, or comment
9617 - fields. The gzip header is returned to the default state by deflateReset().
9619 - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
9620 - stream state was inconsistent.
9624 -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
9627 - This is another version of inflateInit with an extra parameter. The
9628 - fields next_in, avail_in, zalloc, zfree and opaque must be initialized
9629 - before by the caller.
9631 - The windowBits parameter is the base two logarithm of the maximum window
9632 - size (the size of the history buffer). It should be in the range 8..15 for
9633 - this version of the library. The default value is 15 if inflateInit is used
9634 - instead. windowBits must be greater than or equal to the windowBits value
9635 - provided to deflateInit2() while compressing, or it must be equal to 15 if
9636 - deflateInit2() was not used. If a compressed stream with a larger window
9637 - size is given as input, inflate() will return with the error code
9638 - Z_DATA_ERROR instead of trying to allocate a larger window.
9640 - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
9641 - determines the window size. inflate() will then process raw deflate data,
9642 - not looking for a zlib or gzip header, not generating a check value, and not
9643 - looking for any check values for comparison at the end of the stream. This
9644 - is for use with other formats that use the deflate compressed data format
9645 - such as zip. Those formats provide their own check values. If a custom
9646 - format is developed using the raw deflate format for compressed data, it is
9647 - recommended that a check value such as an adler32 or a crc32 be applied to
9648 - the uncompressed data as is done in the zlib, gzip, and zip formats. For
9649 - most applications, the zlib format should be used as is. Note that comments
9650 - above on the use in deflateInit2() applies to the magnitude of windowBits.
9652 - windowBits can also be greater than 15 for optional gzip decoding. Add
9653 - 32 to windowBits to enable zlib and gzip decoding with automatic header
9654 - detection, or add 16 to decode only the gzip format (the zlib format will
9655 - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
9656 - a crc32 instead of an adler32.
9658 - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
9659 - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
9660 - is set to null if there is no error message. inflateInit2 does not perform
9661 - any decompression apart from reading the zlib header if present: this will
9662 - be done by inflate(). (So next_in and avail_in may be modified, but next_out
9663 - and avail_out are unchanged.)
9666 -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
9667 - const Bytef *dictionary,
9668 - uInt dictLength));
9670 - Initializes the decompression dictionary from the given uncompressed byte
9671 - sequence. This function must be called immediately after a call of inflate,
9672 - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
9673 - can be determined from the adler32 value returned by that call of inflate.
9674 - The compressor and decompressor must use exactly the same dictionary (see
9675 - deflateSetDictionary). For raw inflate, this function can be called
9676 - immediately after inflateInit2() or inflateReset() and before any call of
9677 - inflate() to set the dictionary. The application must insure that the
9678 - dictionary that was used for compression is provided.
9680 - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
9681 - parameter is invalid (such as NULL dictionary) or the stream state is
9682 - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
9683 - expected one (incorrect adler32 value). inflateSetDictionary does not
9684 - perform any decompression: this will be done by subsequent calls of
9688 -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
9690 - Skips invalid compressed data until a full flush point (see above the
9691 - description of deflate with Z_FULL_FLUSH) can be found, or until all
9692 - available input is skipped. No output is provided.
9694 - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
9695 - if no more input was provided, Z_DATA_ERROR if no flush point has been found,
9696 - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
9697 - case, the application may save the current current value of total_in which
9698 - indicates where valid compressed data was found. In the error case, the
9699 - application may repeatedly call inflateSync, providing more input each time,
9700 - until success or end of the input data.
9703 -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
9704 - z_streamp source));
9706 - Sets the destination stream as a complete copy of the source stream.
9708 - This function can be useful when randomly accessing a large stream. The
9709 - first pass through the stream can periodically record the inflate state,
9710 - allowing restarting inflate at those points when randomly accessing the
9713 - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
9714 - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
9715 - (such as zalloc being NULL). msg is left unchanged in both source and
9719 -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
9721 - This function is equivalent to inflateEnd followed by inflateInit,
9722 - but does not free and reallocate all the internal decompression state.
9723 - The stream will keep attributes that may have been set by inflateInit2.
9725 - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
9726 - stream state was inconsistent (such as zalloc or state being NULL).
9729 -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
9733 - This function inserts bits in the inflate input stream. The intent is
9734 - that this function is used to start inflating at a bit position in the
9735 - middle of a byte. The provided bits will be used before any bytes are used
9736 - from next_in. This function should only be used with raw inflate, and
9737 - should be used before the first inflate() call after inflateInit2() or
9738 - inflateReset(). bits must be less than or equal to 16, and that many of the
9739 - least significant bits of value will be inserted in the input.
9741 - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
9742 - stream state was inconsistent.
9745 -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
9746 - gz_headerp head));
9748 - inflateGetHeader() requests that gzip header information be stored in the
9749 - provided gz_header structure. inflateGetHeader() may be called after
9750 - inflateInit2() or inflateReset(), and before the first call of inflate().
9751 - As inflate() processes the gzip stream, head->done is zero until the header
9752 - is completed, at which time head->done is set to one. If a zlib stream is
9753 - being decoded, then head->done is set to -1 to indicate that there will be
9754 - no gzip header information forthcoming. Note that Z_BLOCK can be used to
9755 - force inflate() to return immediately after header processing is complete
9756 - and before any actual data is decompressed.
9758 - The text, time, xflags, and os fields are filled in with the gzip header
9759 - contents. hcrc is set to true if there is a header CRC. (The header CRC
9760 - was valid if done is set to one.) If extra is not Z_NULL, then extra_max
9761 - contains the maximum number of bytes to write to extra. Once done is true,
9762 - extra_len contains the actual extra field length, and extra contains the
9763 - extra field, or that field truncated if extra_max is less than extra_len.
9764 - If name is not Z_NULL, then up to name_max characters are written there,
9765 - terminated with a zero unless the length is greater than name_max. If
9766 - comment is not Z_NULL, then up to comm_max characters are written there,
9767 - terminated with a zero unless the length is greater than comm_max. When
9768 - any of extra, name, or comment are not Z_NULL and the respective field is
9769 - not present in the header, then that field is set to Z_NULL to signal its
9770 - absence. This allows the use of deflateSetHeader() with the returned
9771 - structure to duplicate the header. However if those fields are set to
9772 - allocated memory, then the application will need to save those pointers
9773 - elsewhere so that they can be eventually freed.
9775 - If inflateGetHeader is not used, then the header information is simply
9776 - discarded. The header is always checked for validity, including the header
9777 - CRC if present. inflateReset() will reset the process to discard the header
9778 - information. The application would need to call inflateGetHeader() again to
9779 - retrieve the header from the next gzip stream.
9781 - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
9782 - stream state was inconsistent.
9786 -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
9787 - unsigned char FAR *window));
9789 - Initialize the internal stream state for decompression using inflateBack()
9790 - calls. The fields zalloc, zfree and opaque in strm must be initialized
9791 - before the call. If zalloc and zfree are Z_NULL, then the default library-
9792 - derived memory allocation routines are used. windowBits is the base two
9793 - logarithm of the window size, in the range 8..15. window is a caller
9794 - supplied buffer of that size. Except for special applications where it is
9795 - assured that deflate was used with small window sizes, windowBits must be 15
9796 - and a 32K byte window must be supplied to be able to decompress general
9799 - See inflateBack() for the usage of these routines.
9801 - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
9802 - the paramaters are invalid, Z_MEM_ERROR if the internal state could not
9803 - be allocated, or Z_VERSION_ERROR if the version of the library does not
9804 - match the version of the header file.
9807 -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
9808 -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
9810 -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
9811 - in_func in, void FAR *in_desc,
9812 - out_func out, void FAR *out_desc));
9814 - inflateBack() does a raw inflate with a single call using a call-back
9815 - interface for input and output. This is more efficient than inflate() for
9816 - file i/o applications in that it avoids copying between the output and the
9817 - sliding window by simply making the window itself the output buffer. This
9818 - function trusts the application to not change the output buffer passed by
9819 - the output function, at least until inflateBack() returns.
9821 - inflateBackInit() must be called first to allocate the internal state
9822 - and to initialize the state with the user-provided window buffer.
9823 - inflateBack() may then be used multiple times to inflate a complete, raw
9824 - deflate stream with each call. inflateBackEnd() is then called to free
9825 - the allocated state.
9827 - A raw deflate stream is one with no zlib or gzip header or trailer.
9828 - This routine would normally be used in a utility that reads zip or gzip
9829 - files and writes out uncompressed files. The utility would decode the
9830 - header and process the trailer on its own, hence this routine expects
9831 - only the raw deflate stream to decompress. This is different from the
9832 - normal behavior of inflate(), which expects either a zlib or gzip header and
9833 - trailer around the deflate stream.
9835 - inflateBack() uses two subroutines supplied by the caller that are then
9836 - called by inflateBack() for input and output. inflateBack() calls those
9837 - routines until it reads a complete deflate stream and writes out all of the
9838 - uncompressed data, or until it encounters an error. The function's
9839 - parameters and return types are defined above in the in_func and out_func
9840 - typedefs. inflateBack() will call in(in_desc, &buf) which should return the
9841 - number of bytes of provided input, and a pointer to that input in buf. If
9842 - there is no input available, in() must return zero--buf is ignored in that
9843 - case--and inflateBack() will return a buffer error. inflateBack() will call
9844 - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
9845 - should return zero on success, or non-zero on failure. If out() returns
9846 - non-zero, inflateBack() will return with an error. Neither in() nor out()
9847 - are permitted to change the contents of the window provided to
9848 - inflateBackInit(), which is also the buffer that out() uses to write from.
9849 - The length written by out() will be at most the window size. Any non-zero
9850 - amount of input may be provided by in().
9852 - For convenience, inflateBack() can be provided input on the first call by
9853 - setting strm->next_in and strm->avail_in. If that input is exhausted, then
9854 - in() will be called. Therefore strm->next_in must be initialized before
9855 - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
9856 - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
9857 - must also be initialized, and then if strm->avail_in is not zero, input will
9858 - initially be taken from strm->next_in[0 .. strm->avail_in - 1].
9860 - The in_desc and out_desc parameters of inflateBack() is passed as the
9861 - first parameter of in() and out() respectively when they are called. These
9862 - descriptors can be optionally used to pass any information that the caller-
9863 - supplied in() and out() functions need to do their job.
9865 - On return, inflateBack() will set strm->next_in and strm->avail_in to
9866 - pass back any unused input that was provided by the last in() call. The
9867 - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
9868 - if in() or out() returned an error, Z_DATA_ERROR if there was a format
9869 - error in the deflate stream (in which case strm->msg is set to indicate the
9870 - nature of the error), or Z_STREAM_ERROR if the stream was not properly
9871 - initialized. In the case of Z_BUF_ERROR, an input or output error can be
9872 - distinguished using strm->next_in which will be Z_NULL only if in() returned
9873 - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
9874 - out() returning non-zero. (in() will always be called before out(), so
9875 - strm->next_in is assured to be defined if out() returns non-zero.) Note
9876 - that inflateBack() cannot return Z_OK.
9879 -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
9881 - All memory allocated by inflateBackInit() is freed.
9883 - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
9884 - state was inconsistent.
9887 -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
9888 -/* Return flags indicating compile-time options.
9890 - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
9892 - 3.2: size of uLong
9893 - 5.4: size of voidpf (pointer)
9894 - 7.6: size of z_off_t
9896 - Compiler, assembler, and debug options:
9898 - 9: ASMV or ASMINF -- use ASM code
9899 - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
9902 - One-time table building (smaller code, but not thread-safe if true):
9903 - 12: BUILDFIXED -- build static block decoding tables when needed
9904 - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
9905 - 14,15: 0 (reserved)
9907 - Library content (indicates missing functionality):
9908 - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
9909 - deflate code when not needed)
9910 - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
9911 - and decode gzip streams (to avoid linking crc code)
9912 - 18-19: 0 (reserved)
9914 - Operation variations (changes in library functionality):
9915 - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
9916 - 21: FASTEST -- deflate algorithm with only one, lowest compression level
9917 - 22,23: 0 (reserved)
9919 - The sprintf variant used by gzprintf (zero is best):
9920 - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
9921 - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
9922 - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
9925 - 27-31: 0 (reserved)
9929 - /* utility functions */
9932 - The following utility functions are implemented on top of the
9933 - basic stream-oriented functions. To simplify the interface, some
9934 - default options are assumed (compression level and memory usage,
9935 - standard memory allocation functions). The source code of these
9936 - utility functions can easily be modified if you need special options.
9939 -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
9940 - const Bytef *source, uLong sourceLen));
9942 - Compresses the source buffer into the destination buffer. sourceLen is
9943 - the byte length of the source buffer. Upon entry, destLen is the total
9944 - size of the destination buffer, which must be at least the value returned
9945 - by compressBound(sourceLen). Upon exit, destLen is the actual size of the
9946 - compressed buffer.
9947 - This function can be used to compress a whole file at once if the
9948 - input file is mmap'ed.
9949 - compress returns Z_OK if success, Z_MEM_ERROR if there was not
9950 - enough memory, Z_BUF_ERROR if there was not enough room in the output
9954 -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
9955 - const Bytef *source, uLong sourceLen,
9958 - Compresses the source buffer into the destination buffer. The level
9959 - parameter has the same meaning as in deflateInit. sourceLen is the byte
9960 - length of the source buffer. Upon entry, destLen is the total size of the
9961 - destination buffer, which must be at least the value returned by
9962 - compressBound(sourceLen). Upon exit, destLen is the actual size of the
9963 - compressed buffer.
9965 - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
9966 - memory, Z_BUF_ERROR if there was not enough room in the output buffer,
9967 - Z_STREAM_ERROR if the level parameter is invalid.
9970 -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
9972 - compressBound() returns an upper bound on the compressed size after
9973 - compress() or compress2() on sourceLen bytes. It would be used before
9974 - a compress() or compress2() call to allocate the destination buffer.
9977 -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
9978 - const Bytef *source, uLong sourceLen));
9980 - Decompresses the source buffer into the destination buffer. sourceLen is
9981 - the byte length of the source buffer. Upon entry, destLen is the total
9982 - size of the destination buffer, which must be large enough to hold the
9983 - entire uncompressed data. (The size of the uncompressed data must have
9984 - been saved previously by the compressor and transmitted to the decompressor
9985 - by some mechanism outside the scope of this compression library.)
9986 - Upon exit, destLen is the actual size of the compressed buffer.
9987 - This function can be used to decompress a whole file at once if the
9988 - input file is mmap'ed.
9990 - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
9991 - enough memory, Z_BUF_ERROR if there was not enough room in the output
9992 - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
9996 -typedef voidp gzFile;
9998 -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
10000 - Opens a gzip (.gz) file for reading or writing. The mode parameter
10001 - is as in fopen ("rb" or "wb") but can also include a compression level
10002 - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
10003 - Huffman only compression as in "wb1h", or 'R' for run-length encoding
10004 - as in "wb1R". (See the description of deflateInit2 for more information
10005 - about the strategy parameter.)
10007 - gzopen can be used to read a file which is not in gzip format; in this
10008 - case gzread will directly read from the file without decompression.
10010 - gzopen returns NULL if the file could not be opened or if there was
10011 - insufficient memory to allocate the (de)compression state; errno
10012 - can be checked to distinguish the two cases (if errno is zero, the
10013 - zlib error is Z_MEM_ERROR). */
10015 -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
10017 - gzdopen() associates a gzFile with the file descriptor fd. File
10018 - descriptors are obtained from calls like open, dup, creat, pipe or
10019 - fileno (in the file has been previously opened with fopen).
10020 - The mode parameter is as in gzopen.
10021 - The next call of gzclose on the returned gzFile will also close the
10022 - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
10023 - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
10024 - gzdopen returns NULL if there was insufficient memory to allocate
10025 - the (de)compression state.
10028 -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
10030 - Dynamically update the compression level or strategy. See the description
10031 - of deflateInit2 for the meaning of these parameters.
10032 - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
10033 - opened for writing.
10036 -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
10038 - Reads the given number of uncompressed bytes from the compressed file.
10039 - If the input file was not in gzip format, gzread copies the given number
10040 - of bytes into the buffer.
10041 - gzread returns the number of uncompressed bytes actually read (0 for
10042 - end of file, -1 for error). */
10044 -ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
10045 - voidpc buf, unsigned len));
10047 - Writes the given number of uncompressed bytes into the compressed file.
10048 - gzwrite returns the number of uncompressed bytes actually written
10049 - (0 in case of error).
10052 -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
10054 - Converts, formats, and writes the args to the compressed file under
10055 - control of the format string, as in fprintf. gzprintf returns the number of
10056 - uncompressed bytes actually written (0 in case of error). The number of
10057 - uncompressed bytes written is limited to 4095. The caller should assure that
10058 - this limit is not exceeded. If it is exceeded, then gzprintf() will return
10059 - return an error (0) with nothing written. In this case, there may also be a
10060 - buffer overflow with unpredictable consequences, which is possible only if
10061 - zlib was compiled with the insecure functions sprintf() or vsprintf()
10062 - because the secure snprintf() or vsnprintf() functions were not available.
10065 -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
10067 - Writes the given null-terminated string to the compressed file, excluding
10068 - the terminating null character.
10069 - gzputs returns the number of characters written, or -1 in case of error.
10072 -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
10074 - Reads bytes from the compressed file until len-1 characters are read, or
10075 - a newline character is read and transferred to buf, or an end-of-file
10076 - condition is encountered. The string is then terminated with a null
10078 - gzgets returns buf, or Z_NULL in case of error.
10081 -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
10083 - Writes c, converted to an unsigned char, into the compressed file.
10084 - gzputc returns the value that was written, or -1 in case of error.
10087 -ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
10089 - Reads one byte from the compressed file. gzgetc returns this byte
10090 - or -1 in case of end of file or error.
10093 -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
10095 - Push one character back onto the stream to be read again later.
10096 - Only one character of push-back is allowed. gzungetc() returns the
10097 - character pushed, or -1 on failure. gzungetc() will fail if a
10098 - character has been pushed but not read yet, or if c is -1. The pushed
10099 - character will be discarded if the stream is repositioned with gzseek()
10103 -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
10105 - Flushes all pending output into the compressed file. The parameter
10106 - flush is as in the deflate() function. The return value is the zlib
10107 - error number (see function gzerror below). gzflush returns Z_OK if
10108 - the flush parameter is Z_FINISH and all output could be flushed.
10109 - gzflush should be called only when strictly necessary because it can
10110 - degrade compression.
10113 -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
10114 - z_off_t offset, int whence));
10116 - Sets the starting position for the next gzread or gzwrite on the
10117 - given compressed file. The offset represents a number of bytes in the
10118 - uncompressed data stream. The whence parameter is defined as in lseek(2);
10119 - the value SEEK_END is not supported.
10120 - If the file is opened for reading, this function is emulated but can be
10121 - extremely slow. If the file is opened for writing, only forward seeks are
10122 - supported; gzseek then compresses a sequence of zeroes up to the new
10123 - starting position.
10125 - gzseek returns the resulting offset location as measured in bytes from
10126 - the beginning of the uncompressed stream, or -1 in case of error, in
10127 - particular if the file is opened for writing and the new starting position
10128 - would be before the current position.
10131 -ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
10133 - Rewinds the given file. This function is supported only for reading.
10135 - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
10138 -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
10140 - Returns the starting position for the next gzread or gzwrite on the
10141 - given compressed file. This position represents a number of bytes in the
10142 - uncompressed data stream.
10144 - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
10147 -ZEXTERN int ZEXPORT gzeof OF((gzFile file));
10149 - Returns 1 when EOF has previously been detected reading the given
10150 - input stream, otherwise zero.
10153 -ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
10155 - Returns 1 if file is being read directly without decompression, otherwise
10159 -ZEXTERN int ZEXPORT gzclose OF((gzFile file));
10161 - Flushes all pending output if necessary, closes the compressed file
10162 - and deallocates all the (de)compression state. The return value is the zlib
10163 - error number (see function gzerror below).
10166 -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
10168 - Returns the error message for the last error which occurred on the
10169 - given compressed file. errnum is set to zlib error number. If an
10170 - error occurred in the file system and not in the compression library,
10171 - errnum is set to Z_ERRNO and the application may consult errno
10172 - to get the exact error code.
10175 -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
10177 - Clears the error and end-of-file flags for file. This is analogous to the
10178 - clearerr() function in stdio. This is useful for continuing to read a gzip
10179 - file that is being written concurrently.
10182 - /* checksum functions */
10185 - These functions are not related to compression but are exported
10186 - anyway because they might be useful in applications using the
10187 - compression library.
10190 -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
10192 - Update a running Adler-32 checksum with the bytes buf[0..len-1] and
10193 - return the updated checksum. If buf is NULL, this function returns
10194 - the required initial value for the checksum.
10195 - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
10196 - much faster. Usage example:
10198 - uLong adler = adler32(0L, Z_NULL, 0);
10200 - while (read_buffer(buffer, length) != EOF) {
10201 - adler = adler32(adler, buffer, length);
10203 - if (adler != original_adler) error();
10206 -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
10209 - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
10210 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
10211 - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
10212 - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
10215 -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
10217 - Update a running CRC-32 with the bytes buf[0..len-1] and return the
10218 - updated CRC-32. If buf is NULL, this function returns the required initial
10219 - value for the for the crc. Pre- and post-conditioning (one's complement) is
10220 - performed within this function so it shouldn't be done by the application.
10223 - uLong crc = crc32(0L, Z_NULL, 0);
10225 - while (read_buffer(buffer, length) != EOF) {
10226 - crc = crc32(crc, buffer, length);
10228 - if (crc != original_crc) error();
10231 -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
10234 - Combine two CRC-32 check values into one. For two sequences of bytes,
10235 - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
10236 - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
10237 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
10242 - /* various hacks, don't look :) */
10244 -/* deflateInit and inflateInit are macros to allow checking the zlib version
10245 - * and the compiler's view of z_stream:
10247 -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
10248 - const char *version, int stream_size));
10249 -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
10250 - const char *version, int stream_size));
10251 -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
10252 - int windowBits, int memLevel,
10253 - int strategy, const char *version,
10254 - int stream_size));
10255 -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
10256 - const char *version, int stream_size));
10257 -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
10258 - unsigned char FAR *window,
10259 - const char *version,
10260 - int stream_size));
10261 -#define deflateInit(strm, level) \
10262 - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
10263 -#define inflateInit(strm) \
10264 - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
10265 -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
10266 - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
10267 - (strategy), ZLIB_VERSION, sizeof(z_stream))
10268 -#define inflateInit2(strm, windowBits) \
10269 - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
10270 -#define inflateBackInit(strm, windowBits, window) \
10271 - inflateBackInit_((strm), (windowBits), (window), \
10272 - ZLIB_VERSION, sizeof(z_stream))
10275 -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
10276 - struct internal_state {int dummy;}; /* hack for buggy compilers */
10279 -ZEXTERN const char * ZEXPORT zError OF((int));
10280 -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
10281 -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
10283 -#ifdef __cplusplus
10287 -#endif /* ZLIB_H */
10288 diff -ruN seqinr.orig/src/zsockr.c seqinr/src/zsockr.c
10289 --- seqinr.orig/src/zsockr.c 2007-04-19 11:40:19.000000000 +0200
10290 +++ seqinr/src/zsockr.c 1970-01-01 01:00:00.000000000 +0100
10292 -/* functions to handle zlib-compressed data read from socket
10301 -#include <unistd.h>
10302 -#include <stdlib.h>
10303 -#include <stdio.h>
10304 -#include <string.h>
10306 -#include <winsock.h>
10308 -#include <sys/select.h>
10312 -/* included functions */
10313 -void *prepare_sock_gz_r(int sockr);
10314 -int z_getc_R(void *v);
10315 -char *z_gets(void *v, char *line, size_t len);
10316 -char *z_read_sock(void *v);
10317 -int close_sock_gz_r(void *v);
10321 -#define ZBSIZE 100000
10324 - char z_buffer[ZBSIZE]; /* compressed input buffer */
10325 - char text_buffer[4 * ZBSIZE]; /* decompressed buffer */
10326 - char *pos, *endbuf;
10336 -void *prepare_sock_gz_r(int sockr)
10340 -static sock_gz_r s_big;
10343 -if(big == NULL) return NULL;
10344 -big->stream.next_in = Z_NULL;
10345 -big->stream.avail_in = 0;
10346 -big->stream.avail_out = 0;
10347 -big->stream.zalloc = Z_NULL;
10348 -big->stream.zfree = Z_NULL;
10349 -big->stream.opaque = NULL;
10350 -big->pos = big->text_buffer;
10351 -big->endbuf = big->pos;
10353 -big->fd = (SOCKET)sockr;
10357 -err = inflateInit(&big->stream);
10358 -return err == Z_OK ? (void *)big : NULL;
10362 -int z_getc_R(void *v)
10365 -sock_gz_r *big = (sock_gz_r *)v;
10372 -if(big->pos < big->endbuf) {
10373 - return *(big->pos++);
10375 -zs = &(big->stream);
10376 -zs->next_out = (Bytef *)big->text_buffer;
10377 -zs->avail_out = sizeof(big->text_buffer);
10378 -big->pos = (char *)zs->next_out;
10380 - if(zs->avail_in == 0) {
10383 - lu = recv( big->fd , big->z_buffer, ZBSIZE, 0 );
10386 - FD_ZERO(&readfds);
10387 - FD_SET(big->fd, &readfds);
10388 - err = select(big->fd + 1, &readfds, NULL, NULL, NULL);
10390 - lu = read( big->fd , big->z_buffer, ZBSIZE );
10394 - if(lu == -1) return EOF;
10395 - zs->next_in = (Bytef *)big->z_buffer;
10396 - zs->avail_in = lu;
10398 - q = inflate(zs, Z_NO_FLUSH);
10399 - if(q == Z_STREAM_END) break;
10404 -while ( (char *)zs->next_out == big->pos);
10405 -big->endbuf = (char *)zs->next_out;
10406 -if(big->pos < big->endbuf) return *(big->pos++);
10412 -char *z_gets(void *v, char *line, size_t len)
10419 - c = z_getc_R( v );
10421 - if(p == line) return NULL;
10425 - if(c == '\n') break;
10433 -char *z_read_sock(void *v)
10435 -static char line[500];
10439 -p = z_gets(v, line, sizeof(line));
10440 -if(p == NULL) return NULL;
10442 -if(l > 0 && line[l-1] == '\n') line[l-1] = 0;
10447 -int close_sock_gz_r(void *v)
10449 -sock_gz_r *big = (sock_gz_r *)v;
10452 -val = inflateEnd(&(big->stream));
10456 -void *prepare_sock_gz_r(int sockr) {
10461 diff -ruN seqinr.orig/src/zutil.c seqinr/src/zutil.c
10462 --- seqinr.orig/src/zutil.c 2007-04-19 11:40:19.000000000 +0200
10463 +++ seqinr/src/zutil.c 1970-01-01 01:00:00.000000000 +0100
10465 -/* zutil.c -- target dependent utility functions for the compression library
10466 - * Copyright (C) 1995-2005 Jean-loup Gailly.
10467 - * For conditions of distribution and use, see copyright notice in zlib.h
10470 -/* @(#) $Id: zutil.c,v 1.1.2.1 2007-04-19 09:40:19 penel Exp $ */
10472 -#include "zutil.h"
10474 -#ifndef NO_DUMMY_DECL
10475 -struct internal_state {int dummy;}; /* for buggy compilers */
10478 -const char * const z_errmsg[10] = {
10479 -"need dictionary", /* Z_NEED_DICT 2 */
10480 -"stream end", /* Z_STREAM_END 1 */
10482 -"file error", /* Z_ERRNO (-1) */
10483 -"stream error", /* Z_STREAM_ERROR (-2) */
10484 -"data error", /* Z_DATA_ERROR (-3) */
10485 -"insufficient memory", /* Z_MEM_ERROR (-4) */
10486 -"buffer error", /* Z_BUF_ERROR (-5) */
10487 -"incompatible version",/* Z_VERSION_ERROR (-6) */
10491 -const char * ZEXPORT zlibVersion()
10493 - return ZLIB_VERSION;
10496 -uLong ZEXPORT zlibCompileFlags()
10501 - switch (sizeof(uInt)) {
10503 - case 4: flags += 1; break;
10504 - case 8: flags += 2; break;
10505 - default: flags += 3;
10507 - switch (sizeof(uLong)) {
10509 - case 4: flags += 1 << 2; break;
10510 - case 8: flags += 2 << 2; break;
10511 - default: flags += 3 << 2;
10513 - switch (sizeof(voidpf)) {
10515 - case 4: flags += 1 << 4; break;
10516 - case 8: flags += 2 << 4; break;
10517 - default: flags += 3 << 4;
10519 - switch (sizeof(z_off_t)) {
10521 - case 4: flags += 1 << 6; break;
10522 - case 8: flags += 2 << 6; break;
10523 - default: flags += 3 << 6;
10528 -#if defined(ASMV) || defined(ASMINF)
10531 -#ifdef ZLIB_WINAPI
10532 - flags += 1 << 10;
10535 - flags += 1 << 12;
10537 -#ifdef DYNAMIC_CRC_TABLE
10538 - flags += 1 << 13;
10540 -#ifdef NO_GZCOMPRESS
10541 - flags += 1L << 16;
10544 - flags += 1L << 17;
10546 -#ifdef PKZIP_BUG_WORKAROUND
10547 - flags += 1L << 20;
10550 - flags += 1L << 21;
10553 -# ifdef NO_vsnprintf
10554 - flags += 1L << 25;
10555 -# ifdef HAS_vsprintf_void
10556 - flags += 1L << 26;
10559 -# ifdef HAS_vsnprintf_void
10560 - flags += 1L << 26;
10564 - flags += 1L << 24;
10565 -# ifdef NO_snprintf
10566 - flags += 1L << 25;
10567 -# ifdef HAS_sprintf_void
10568 - flags += 1L << 26;
10571 -# ifdef HAS_snprintf_void
10572 - flags += 1L << 26;
10582 -# define verbose 0
10584 -int z_verbose = verbose;
10589 - fprintf(stderr, "%s\n", m);
10594 -/* exported to allow conversion of error code to string for compress() and
10597 -const char * ZEXPORT zError(int err)
10600 - return ERR_MSG(err);
10603 -#if defined(_WIN32_WCE)
10604 - /* The Microsoft C Run-Time Library for Windows CE doesn't have
10605 - * errno. We define it as a global variable to simplify porting.
10606 - * Its value is always 0 and should not be used.
10611 -#ifndef HAVE_MEMCPY
10613 -void zmemcpy(dest, source, len)
10615 - const Bytef* source;
10618 - if (len == 0) return;
10620 - *dest++ = *source++; /* ??? to be unrolled */
10621 - } while (--len != 0);
10624 -int zmemcmp(s1, s2, len)
10631 - for (j = 0; j < len; j++) {
10632 - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
10637 -void zmemzero(dest, len)
10641 - if (len == 0) return;
10643 - *dest++ = 0; /* ??? to be unrolled */
10644 - } while (--len != 0);
10652 -/* Turbo C in 16-bit mode */
10654 -# define MY_ZCALLOC
10656 -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
10657 - * and farmalloc(64K) returns a pointer with an offset of 8, so we
10658 - * must fix the pointer. Warning: the pointer must be put back to its
10659 - * original form in order to free it, use zcfree().
10662 -#define MAX_PTR 10
10663 -/* 10*64K = 640K */
10665 -local int next_ptr = 0;
10667 -typedef struct ptr_table_s {
10672 -local ptr_table table[MAX_PTR];
10673 -/* This table is used to remember the original form of pointers
10674 - * to large buffers (64K). Such pointers are normalized with a zero offset.
10675 - * Since MSDOS is not a preemptive multitasking OS, this table is not
10676 - * protected from concurrent access. This hack doesn't work anyway on
10677 - * a protected system like OS/2. Use Microsoft C instead.
10680 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10682 - voidpf buf = opaque; /* just to make some compilers happy */
10683 - ulg bsize = (ulg)items*size;
10685 - /* If we allocate less than 65520 bytes, we assume that farmalloc
10686 - * will return a usable pointer which doesn't have to be normalized.
10688 - if (bsize < 65520L) {
10689 - buf = farmalloc(bsize);
10690 - if (*(ush*)&buf != 0) return buf;
10692 - buf = farmalloc(bsize + 16L);
10694 - if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
10695 - table[next_ptr].org_ptr = buf;
10697 - /* Normalize the pointer to seg:0 */
10698 - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
10700 - table[next_ptr++].new_ptr = buf;
10704 -void zcfree (voidpf opaque, voidpf ptr)
10707 - if (*(ush*)&ptr != 0) { /* object < 64K */
10711 - /* Find the original pointer */
10712 - for (n = 0; n < next_ptr; n++) {
10713 - if (ptr != table[n].new_ptr) continue;
10715 - farfree(table[n].org_ptr);
10716 - while (++n < next_ptr) {
10717 - table[n-1] = table[n];
10722 - ptr = opaque; /* just to make some compilers happy */
10723 - Assert(0, "zcfree: ptr not found");
10726 -#endif /* __TURBOC__ */
10730 -/* Microsoft C in 16-bit mode */
10732 -# define MY_ZCALLOC
10734 -#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
10735 -# define _halloc halloc
10736 -# define _hfree hfree
10739 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10741 - if (opaque) opaque = 0; /* to make compiler happy */
10742 - return _halloc((long)items, size);
10745 -void zcfree (voidpf opaque, voidpf ptr)
10747 - if (opaque) opaque = 0; /* to make compiler happy */
10751 -#endif /* M_I86 */
10753 -#endif /* SYS16BIT */
10756 -#ifndef MY_ZCALLOC /* Any system without a special alloc function */
10759 -extern voidp malloc OF((uInt size));
10760 -extern voidp calloc OF((uInt items, uInt size));
10761 -extern void free OF((voidpf ptr));
10764 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10771 - if (opaque) items += size - size; /* make compiler happy */
10772 - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
10773 - (voidpf)calloc(items, size);
10776 -void zcfree (voidpf opaque, voidpf ptr)
10783 - if (opaque) return; /* make compiler happy */
10786 -#endif /* MY_ZCALLOC */
10787 diff -ruN seqinr.orig/src/zutil.h seqinr/src/zutil.h
10788 --- seqinr.orig/src/zutil.h 2007-04-19 11:40:19.000000000 +0200
10789 +++ seqinr/src/zutil.h 1970-01-01 01:00:00.000000000 +0100
10791 -/* zutil.h -- internal interface and configuration of the compression library
10792 - * Copyright (C) 1995-2005 Jean-loup Gailly.
10793 - * For conditions of distribution and use, see copyright notice in zlib.h
10796 -/* WARNING: this file should *not* be used by applications. It is
10797 - part of the implementation of the compression library and is
10798 - subject to change. Applications should only use zlib.h.
10801 -/* @(#) $Id: zutil.h,v 1.1.2.1 2007-04-19 09:40:19 penel Exp $ */
10806 -#define ZLIB_INTERNAL
10810 -# ifndef _WIN32_WCE
10811 -# include <stddef.h>
10813 -# include <string.h>
10814 -# include <stdlib.h>
10817 -# ifdef _WIN32_WCE
10818 - /* The Microsoft C Run-Time Library for Windows CE doesn't have
10819 - * errno. We define it as a global variable to simplify porting.
10820 - * Its value is always 0 and should not be used. We rename it to
10821 - * avoid conflict with other libraries that use the same workaround.
10823 -# define errno z_errno
10825 - extern int errno;
10827 -# ifndef _WIN32_WCE
10828 -# include <errno.h>
10833 -# define local static
10835 -/* compile with -Dlocal if your debugger can't find static symbols */
10837 -typedef unsigned char uch;
10838 -typedef uch FAR uchf;
10839 -typedef unsigned short ush;
10840 -typedef ush FAR ushf;
10841 -typedef unsigned long ulg;
10843 -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
10844 -/* (size given to avoid silly warnings with Visual C++) */
10846 -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
10848 -#define ERR_RETURN(strm,err) \
10849 - return (strm->msg = (char*)ERR_MSG(err), (err))
10850 -/* To be used only when the state is known to be valid */
10852 - /* common constants */
10855 -# define DEF_WBITS MAX_WBITS
10857 -/* default windowBits for decompression. MAX_WBITS is for compression only */
10859 -#if MAX_MEM_LEVEL >= 8
10860 -# define DEF_MEM_LEVEL 8
10862 -# define DEF_MEM_LEVEL MAX_MEM_LEVEL
10864 -/* default memLevel */
10866 -#define STORED_BLOCK 0
10867 -#define STATIC_TREES 1
10868 -#define DYN_TREES 2
10869 -/* The three kinds of block type */
10871 -#define MIN_MATCH 3
10872 -#define MAX_MATCH 258
10873 -/* The minimum and maximum match lengths */
10875 -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
10877 - /* target dependencies */
10879 -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
10880 -# define OS_CODE 0x00
10881 -# if defined(__TURBOC__) || defined(__BORLANDC__)
10882 -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
10883 - /* Allow compilation with ANSI keywords only enabled */
10884 - void _Cdecl farfree( void *block );
10885 - void *_Cdecl farmalloc( unsigned long nbytes );
10887 -# include <alloc.h>
10889 -# else /* MSC or DJGPP */
10890 -# include <malloc.h>
10895 -# define OS_CODE 0x01
10898 -#if defined(VAXC) || defined(VMS)
10899 -# define OS_CODE 0x02
10900 -# define F_OPEN(name, mode) \
10901 - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
10904 -#if defined(ATARI) || defined(atarist)
10905 -# define OS_CODE 0x05
10909 -# define OS_CODE 0x06
10911 - #include <malloc.h>
10915 -#if defined(MACOS) || defined(TARGET_OS_MAC)
10916 -# define OS_CODE 0x07
10917 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
10918 -# include <unix.h> /* for fdopen */
10921 -# define fdopen(fd,mode) NULL /* No fdopen() */
10927 -# define OS_CODE 0x0a
10931 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
10932 -# define OS_CODE 0x0b
10936 -#ifdef __50SERIES /* Prime/PRIMOS */
10937 -# define OS_CODE 0x0f
10940 -#if defined(_BEOS_) || defined(RISCOS)
10941 -# define fdopen(fd,mode) NULL /* No fdopen() */
10944 -#if (defined(_MSC_VER) && (_MSC_VER > 600))
10945 -# if defined(_WIN32_WCE)
10946 -# define fdopen(fd,mode) NULL /* No fdopen() */
10947 -# ifndef _PTRDIFF_T_DEFINED
10948 - typedef int ptrdiff_t;
10949 -# define _PTRDIFF_T_DEFINED
10952 -# define fdopen(fd,type) _fdopen(fd,type)
10956 - /* common defaults */
10959 -# define OS_CODE 0x03 /* assume Unix */
10963 -# define F_OPEN(name, mode) fopen((name), (mode))
10968 -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
10969 -# ifndef HAVE_VSNPRINTF
10970 -# define HAVE_VSNPRINTF
10973 -#if defined(__CYGWIN__)
10974 -# ifndef HAVE_VSNPRINTF
10975 -# define HAVE_VSNPRINTF
10978 -#ifndef HAVE_VSNPRINTF
10980 - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
10981 - but for now we just assume it doesn't. */
10982 -# define NO_vsnprintf
10984 -# ifdef __TURBOC__
10985 -# define NO_vsnprintf
10988 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
10989 -# if !defined(vsnprintf) && !defined(NO_vsnprintf)
10990 -# define vsnprintf _vsnprintf
10994 -# define NO_vsnprintf
10998 -# define NO_vsnprintf
11002 -# define NO_MEMCPY
11004 -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
11005 - /* Use our own functions for small and medium model with MSC <= 5.0.
11006 - * You may have to use the same strategy for Borland C (untested).
11007 - * The __SC__ check is for Symantec.
11009 -# define NO_MEMCPY
11011 -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
11012 -# define HAVE_MEMCPY
11014 -#ifdef HAVE_MEMCPY
11015 -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
11016 -# define zmemcpy _fmemcpy
11017 -# define zmemcmp _fmemcmp
11018 -# define zmemzero(dest, len) _fmemset(dest, 0, len)
11020 -# define zmemcpy memcpy
11021 -# define zmemcmp memcmp
11022 -# define zmemzero(dest, len) memset(dest, 0, len)
11025 - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
11026 - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
11027 - extern void zmemzero OF((Bytef* dest, uInt len));
11030 -/* Diagnostic functions */
11032 -# include <stdio.h>
11033 - extern int z_verbose;
11034 - extern void z_error OF((char *m));
11035 -# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
11036 -# define Trace(x) {if (z_verbose>=0) fprintf x ;}
11037 -# define Tracev(x) {if (z_verbose>0) fprintf x ;}
11038 -# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
11039 -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
11040 -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
11042 -# define Assert(cond,msg)
11044 -# define Tracev(x)
11045 -# define Tracevv(x)
11046 -# define Tracec(c,x)
11047 -# define Tracecv(c,x)
11051 -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
11052 -void zcfree OF((voidpf opaque, voidpf ptr));
11054 -#define ZALLOC(strm, items, size) \
11055 - (*((strm)->zalloc))((strm)->opaque, (items), (size))
11056 -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
11057 -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
11059 -#endif /* ZUTIL_H */