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 RJaCGH.orig/src/adler32.c RJaCGH/src/adler32.c
10 --- RJaCGH.orig/src/adler32.c 2009-03-04 12:51:20.000000000 +0100
11 +++ RJaCGH/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
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(adler, buf, len)
77 - /* split Adler-32 into component sums */
78 - sum2 = (adler >> 16) & 0xffff;
81 - /* in case user likes doing a byte at a time, keep it fast */
89 - return adler | (sum2 << 16);
92 - /* initial Adler-32 value (deferred check for len == 1 speed) */
96 - /* in case short lengths are provided, keep it somewhat fast */
104 - MOD4(sum2); /* only added so many BASE's */
105 - return adler | (sum2 << 16);
108 - /* do length NMAX blocks -- requires just one modulo operation */
109 - while (len >= NMAX) {
111 - n = NMAX / 16; /* NMAX is divisible by 16 */
113 - DO16(buf); /* 16 sums unrolled */
120 - /* do remaining bytes (less than NMAX, still just one modulo) */
121 - if (len) { /* avoid modulos if none remaining */
122 - while (len >= 16) {
135 - /* return recombined sums */
136 - return adler | (sum2 << 16);
139 -/* ========================================================================= */
140 -uLong ZEXPORT adler32_combine(adler1, adler2, len2)
145 - unsigned long sum1;
146 - unsigned long sum2;
149 - /* the derivation of this formula is left as an exercise for the reader */
150 - rem = (unsigned)(len2 % BASE);
151 - sum1 = adler1 & 0xffff;
154 - sum1 += (adler2 & 0xffff) + BASE - 1;
155 - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
156 - if (sum1 > BASE) sum1 -= BASE;
157 - if (sum1 > BASE) sum1 -= BASE;
158 - if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
159 - if (sum2 > BASE) sum2 -= BASE;
160 - return sum1 | (sum2 << 16);
162 diff -ruN RJaCGH.orig/src/compress.c RJaCGH/src/compress.c
163 --- RJaCGH.orig/src/compress.c 2009-03-04 12:51:20.000000000 +0100
164 +++ RJaCGH/src/compress.c 1970-01-01 01:00:00.000000000 +0100
166 -/* compress.c -- compress a memory buffer
167 - * Copyright (C) 1995-2003 Jean-loup Gailly.
168 - * For conditions of distribution and use, see copyright notice in zlib.h
173 -#define ZLIB_INTERNAL
176 -/* ===========================================================================
177 - Compresses the source buffer into the destination buffer. The level
178 - parameter has the same meaning as in deflateInit. sourceLen is the byte
179 - length of the source buffer. Upon entry, destLen is the total size of the
180 - destination buffer, which must be at least 0.1% larger than sourceLen plus
181 - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
183 - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
184 - memory, Z_BUF_ERROR if there was not enough room in the output buffer,
185 - Z_STREAM_ERROR if the level parameter is invalid.
187 -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
190 - const Bytef *source;
197 - stream.next_in = (Bytef*)source;
198 - stream.avail_in = (uInt)sourceLen;
200 - /* Check for source > 64K on 16-bit machine: */
201 - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
203 - stream.next_out = dest;
204 - stream.avail_out = (uInt)*destLen;
205 - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
207 - stream.zalloc = (alloc_func)0;
208 - stream.zfree = (free_func)0;
209 - stream.opaque = (voidpf)0;
211 - err = deflateInit(&stream, level);
212 - if (err != Z_OK) return err;
214 - err = deflate(&stream, Z_FINISH);
215 - if (err != Z_STREAM_END) {
216 - deflateEnd(&stream);
217 - return err == Z_OK ? Z_BUF_ERROR : err;
219 - *destLen = stream.total_out;
221 - err = deflateEnd(&stream);
225 -/* ===========================================================================
227 -int ZEXPORT compress (dest, destLen, source, sourceLen)
230 - const Bytef *source;
233 - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
236 -/* ===========================================================================
237 - If the default memLevel or windowBits for deflateInit() is changed, then
238 - this function needs to be updated.
240 -uLong ZEXPORT compressBound (sourceLen)
243 - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
245 diff -ruN RJaCGH.orig/src/crc32.c RJaCGH/src/crc32.c
246 --- RJaCGH.orig/src/crc32.c 2009-03-04 12:51:20.000000000 +0100
247 +++ RJaCGH/src/crc32.c 1970-01-01 01:00:00.000000000 +0100
249 -/* crc32.c -- compute the CRC-32 of a data stream
250 - * Copyright (C) 1995-2005 Mark Adler
251 - * For conditions of distribution and use, see copyright notice in zlib.h
253 - * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
254 - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
255 - * tables for updating the shift register in one step with three exclusive-ors
256 - * instead of four steps with four exclusive-ors. This results in about a
257 - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
263 - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
264 - protection on the static variables used to control the first-use generation
265 - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
266 - first call get_crc_table() to initialize the tables before allowing more than
267 - one thread to use crc32().
272 -# ifndef DYNAMIC_CRC_TABLE
273 -# define DYNAMIC_CRC_TABLE
274 -# endif /* !DYNAMIC_CRC_TABLE */
275 -#endif /* MAKECRCH */
277 -#include "zutil.h" /* for STDC and FAR definitions */
279 -#define local static
281 -/* Find a four-byte integer type for crc32_little() and crc32_big(). */
283 -# ifdef STDC /* need ANSI C limits.h to determine sizes */
284 -# include <limits.h>
286 -# if (UINT_MAX == 0xffffffffUL)
287 - typedef unsigned int u4;
289 -# if (ULONG_MAX == 0xffffffffUL)
290 - typedef unsigned long u4;
292 -# if (USHRT_MAX == 0xffffffffUL)
293 - typedef unsigned short u4;
295 -# undef BYFOUR /* can't find a four-byte integer type! */
300 -#endif /* !NOBYFOUR */
302 -/* Definitions for doing the crc four data bytes at a time. */
304 -# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
305 - (((w)&0xff00)<<8)+(((w)&0xff)<<24))
306 - local unsigned long crc32_little OF((unsigned long,
307 - const unsigned char FAR *, unsigned));
308 - local unsigned long crc32_big OF((unsigned long,
309 - const unsigned char FAR *, unsigned));
315 -/* Local functions for crc concatenation */
316 -local unsigned long gf2_matrix_times OF((unsigned long *mat,
317 - unsigned long vec));
318 -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
320 -#ifdef DYNAMIC_CRC_TABLE
322 -local volatile int crc_table_empty = 1;
323 -local unsigned long FAR crc_table[TBLS][256];
324 -local void make_crc_table OF((void));
326 - local void write_table OF((FILE *, const unsigned long FAR *));
327 -#endif /* MAKECRCH */
329 - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
330 - 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.
332 - Polynomials over GF(2) are represented in binary, one bit per coefficient,
333 - with the lowest powers in the most significant bit. Then adding polynomials
334 - is just exclusive-or, and multiplying a polynomial by x is a right shift by
335 - one. If we call the above polynomial p, and represent a byte as the
336 - polynomial q, also with the lowest power in the most significant bit (so the
337 - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
338 - where a mod b means the remainder after dividing a by b.
340 - This calculation is done using the shift-register method of multiplying and
341 - taking the remainder. The register is initialized to zero, and for each
342 - incoming bit, x^32 is added mod p to the register if the bit is a one (where
343 - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
344 - x (which is shifting right by one and adding x^32 mod p if the bit shifted
345 - out is a one). We start with the highest power (least significant bit) of
346 - q and repeat for all eight bits of q.
348 - The first table is simply the CRC of all possible eight bit values. This is
349 - all the information needed to generate CRCs on data a byte at a time for all
350 - combinations of CRC register values and incoming bytes. The remaining tables
351 - allow for word-at-a-time CRC calculation for both big-endian and little-
352 - endian machines, where a word is four bytes.
354 -local void make_crc_table()
358 - unsigned long poly; /* polynomial exclusive-or pattern */
359 - /* terms of polynomial defining this crc (except x^32): */
360 - static volatile int first = 1; /* flag to limit concurrent making */
361 - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
363 - /* See if another task is already doing this (not thread-safe, but better
364 - than nothing -- significantly reduces duration of vulnerability in
365 - case the advice about DYNAMIC_CRC_TABLE is ignored) */
369 - /* make exclusive-or pattern from polynomial (0xedb88320UL) */
371 - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
372 - poly |= 1UL << (31 - p[n]);
374 - /* generate a crc for every 8-bit value */
375 - for (n = 0; n < 256; n++) {
376 - c = (unsigned long)n;
377 - for (k = 0; k < 8; k++)
378 - c = c & 1 ? poly ^ (c >> 1) : c >> 1;
379 - crc_table[0][n] = c;
383 - /* generate crc for each value followed by one, two, and three zeros,
384 - and then the byte reversal of those as well as the first table */
385 - for (n = 0; n < 256; n++) {
386 - c = crc_table[0][n];
387 - crc_table[4][n] = REV(c);
388 - for (k = 1; k < 4; k++) {
389 - c = crc_table[0][c & 0xff] ^ (c >> 8);
390 - crc_table[k][n] = c;
391 - crc_table[k + 4][n] = REV(c);
396 - crc_table_empty = 0;
398 - else { /* not first */
399 - /* wait for the other guy to finish (not efficient, but rare) */
400 - while (crc_table_empty)
405 - /* write out CRC tables to crc32.h */
409 - out = fopen("crc32.h", "w");
410 - if (out == NULL) return;
411 - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
412 - fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
413 - fprintf(out, "local const unsigned long FAR ");
414 - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
415 - write_table(out, crc_table[0]);
417 - fprintf(out, "#ifdef BYFOUR\n");
418 - for (k = 1; k < 8; k++) {
419 - fprintf(out, " },\n {\n");
420 - write_table(out, crc_table[k]);
422 - fprintf(out, "#endif\n");
423 -# endif /* BYFOUR */
424 - fprintf(out, " }\n};\n");
427 -#endif /* MAKECRCH */
431 -local void write_table(out, table)
433 - const unsigned long FAR *table;
437 - for (n = 0; n < 256; n++)
438 - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
439 - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
441 -#endif /* MAKECRCH */
443 -#else /* !DYNAMIC_CRC_TABLE */
444 -/* ========================================================================
445 - * Tables of CRC-32s of all single-byte values, made by make_crc_table().
448 -#endif /* DYNAMIC_CRC_TABLE */
450 -/* =========================================================================
451 - * This function can be used by asm versions of crc32()
453 -const unsigned long FAR * ZEXPORT get_crc_table()
455 -#ifdef DYNAMIC_CRC_TABLE
456 - if (crc_table_empty)
458 -#endif /* DYNAMIC_CRC_TABLE */
459 - return (const unsigned long FAR *)crc_table;
462 -/* ========================================================================= */
463 -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
464 -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
466 -/* ========================================================================= */
467 -unsigned long ZEXPORT crc32(crc, buf, len)
469 - const unsigned char FAR *buf;
472 - if (buf == Z_NULL) return 0UL;
474 -#ifdef DYNAMIC_CRC_TABLE
475 - if (crc_table_empty)
477 -#endif /* DYNAMIC_CRC_TABLE */
480 - if (sizeof(void *) == sizeof(ptrdiff_t)) {
484 - if (*((unsigned char *)(&endian)))
485 - return crc32_little(crc, buf, len);
487 - return crc32_big(crc, buf, len);
490 - crc = crc ^ 0xffffffffUL;
498 - return crc ^ 0xffffffffUL;
503 -/* ========================================================================= */
504 -#define DOLIT4 c ^= *buf4++; \
505 - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
506 - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
507 -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
509 -/* ========================================================================= */
510 -local unsigned long crc32_little(crc, buf, len)
512 - const unsigned char FAR *buf;
516 - register const u4 FAR *buf4;
520 - while (len && ((ptrdiff_t)buf & 3)) {
521 - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
525 - buf4 = (const u4 FAR *)(const void FAR *)buf;
526 - while (len >= 32) {
534 - buf = (const unsigned char FAR *)buf4;
537 - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
540 - return (unsigned long)c;
543 -/* ========================================================================= */
544 -#define DOBIG4 c ^= *++buf4; \
545 - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
546 - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
547 -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
549 -/* ========================================================================= */
550 -local unsigned long crc32_big(crc, buf, len)
552 - const unsigned char FAR *buf;
556 - register const u4 FAR *buf4;
560 - while (len && ((ptrdiff_t)buf & 3)) {
561 - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
565 - buf4 = (const u4 FAR *)(const void FAR *)buf;
567 - while (len >= 32) {
576 - buf = (const unsigned char FAR *)buf4;
579 - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
582 - return (unsigned long)(REV(c));
587 -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
589 -/* ========================================================================= */
590 -local unsigned long gf2_matrix_times(mat, vec)
591 - unsigned long *mat;
606 -/* ========================================================================= */
607 -local void gf2_matrix_square(square, mat)
608 - unsigned long *square;
609 - unsigned long *mat;
613 - for (n = 0; n < GF2_DIM; n++)
614 - square[n] = gf2_matrix_times(mat, mat[n]);
617 -/* ========================================================================= */
618 -uLong ZEXPORT crc32_combine(crc1, crc2, len2)
625 - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
626 - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
628 - /* degenerate case */
632 - /* put operator for one zero bit in odd */
633 - odd[0] = 0xedb88320L; /* CRC-32 polynomial */
635 - for (n = 1; n < GF2_DIM; n++) {
640 - /* put operator for two zero bits in even */
641 - gf2_matrix_square(even, odd);
643 - /* put operator for four zero bits in odd */
644 - gf2_matrix_square(odd, even);
646 - /* apply len2 zeros to crc1 (first square will put the operator for one
647 - zero byte, eight zero bits, in even) */
649 - /* apply zeros operator for this bit of len2 */
650 - gf2_matrix_square(even, odd);
652 - crc1 = gf2_matrix_times(even, crc1);
655 - /* if no more bits set, then done */
659 - /* another iteration of the loop with odd and even swapped */
660 - gf2_matrix_square(odd, even);
662 - crc1 = gf2_matrix_times(odd, crc1);
665 - /* if no more bits set, then done */
666 - } while (len2 != 0);
668 - /* return combined crc */
672 diff -ruN RJaCGH.orig/src/crc32.h RJaCGH/src/crc32.h
673 --- RJaCGH.orig/src/crc32.h 2009-03-04 12:51:20.000000000 +0100
674 +++ RJaCGH/src/crc32.h 1970-01-01 01:00:00.000000000 +0100
676 -/* crc32.h -- tables for rapid CRC calculation
677 - * Generated automatically by crc32.c
680 -local const unsigned long FAR crc_table[TBLS][256] =
683 - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
684 - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
685 - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
686 - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
687 - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
688 - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
689 - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
690 - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
691 - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
692 - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
693 - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
694 - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
695 - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
696 - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
697 - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
698 - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
699 - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
700 - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
701 - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
702 - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
703 - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
704 - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
705 - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
706 - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
707 - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
708 - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
709 - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
710 - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
711 - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
712 - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
713 - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
714 - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
715 - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
716 - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
717 - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
718 - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
719 - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
720 - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
721 - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
722 - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
723 - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
724 - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
725 - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
726 - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
727 - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
728 - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
729 - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
730 - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
731 - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
732 - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
733 - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
738 - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
739 - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
740 - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
741 - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
742 - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
743 - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
744 - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
745 - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
746 - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
747 - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
748 - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
749 - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
750 - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
751 - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
752 - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
753 - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
754 - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
755 - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
756 - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
757 - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
758 - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
759 - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
760 - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
761 - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
762 - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
763 - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
764 - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
765 - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
766 - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
767 - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
768 - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
769 - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
770 - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
771 - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
772 - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
773 - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
774 - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
775 - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
776 - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
777 - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
778 - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
779 - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
780 - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
781 - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
782 - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
783 - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
784 - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
785 - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
786 - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
787 - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
788 - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
792 - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
793 - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
794 - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
795 - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
796 - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
797 - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
798 - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
799 - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
800 - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
801 - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
802 - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
803 - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
804 - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
805 - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
806 - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
807 - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
808 - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
809 - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
810 - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
811 - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
812 - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
813 - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
814 - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
815 - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
816 - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
817 - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
818 - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
819 - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
820 - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
821 - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
822 - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
823 - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
824 - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
825 - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
826 - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
827 - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
828 - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
829 - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
830 - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
831 - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
832 - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
833 - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
834 - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
835 - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
836 - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
837 - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
838 - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
839 - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
840 - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
841 - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
842 - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
846 - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
847 - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
848 - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
849 - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
850 - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
851 - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
852 - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
853 - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
854 - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
855 - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
856 - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
857 - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
858 - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
859 - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
860 - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
861 - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
862 - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
863 - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
864 - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
865 - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
866 - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
867 - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
868 - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
869 - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
870 - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
871 - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
872 - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
873 - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
874 - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
875 - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
876 - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
877 - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
878 - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
879 - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
880 - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
881 - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
882 - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
883 - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
884 - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
885 - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
886 - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
887 - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
888 - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
889 - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
890 - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
891 - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
892 - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
893 - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
894 - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
895 - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
896 - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
900 - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
901 - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
902 - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
903 - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
904 - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
905 - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
906 - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
907 - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
908 - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
909 - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
910 - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
911 - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
912 - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
913 - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
914 - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
915 - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
916 - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
917 - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
918 - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
919 - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
920 - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
921 - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
922 - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
923 - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
924 - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
925 - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
926 - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
927 - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
928 - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
929 - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
930 - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
931 - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
932 - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
933 - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
934 - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
935 - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
936 - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
937 - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
938 - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
939 - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
940 - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
941 - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
942 - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
943 - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
944 - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
945 - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
946 - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
947 - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
948 - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
949 - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
950 - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
954 - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
955 - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
956 - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
957 - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
958 - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
959 - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
960 - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
961 - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
962 - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
963 - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
964 - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
965 - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
966 - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
967 - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
968 - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
969 - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
970 - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
971 - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
972 - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
973 - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
974 - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
975 - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
976 - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
977 - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
978 - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
979 - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
980 - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
981 - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
982 - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
983 - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
984 - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
985 - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
986 - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
987 - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
988 - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
989 - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
990 - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
991 - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
992 - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
993 - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
994 - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
995 - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
996 - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
997 - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
998 - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
999 - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
1000 - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
1001 - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
1002 - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
1003 - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
1004 - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
1008 - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
1009 - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
1010 - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
1011 - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
1012 - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
1013 - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
1014 - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
1015 - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
1016 - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
1017 - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
1018 - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
1019 - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
1020 - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
1021 - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
1022 - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
1023 - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
1024 - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
1025 - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
1026 - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
1027 - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
1028 - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
1029 - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
1030 - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
1031 - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
1032 - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
1033 - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
1034 - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
1035 - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
1036 - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
1037 - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
1038 - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
1039 - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
1040 - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
1041 - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
1042 - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
1043 - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
1044 - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
1045 - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
1046 - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
1047 - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
1048 - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
1049 - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
1050 - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
1051 - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
1052 - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
1053 - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
1054 - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
1055 - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
1056 - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
1057 - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
1058 - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
1062 - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
1063 - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
1064 - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
1065 - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
1066 - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
1067 - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
1068 - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
1069 - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
1070 - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
1071 - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
1072 - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
1073 - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
1074 - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
1075 - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
1076 - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
1077 - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
1078 - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
1079 - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
1080 - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
1081 - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
1082 - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
1083 - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
1084 - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
1085 - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
1086 - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
1087 - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
1088 - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
1089 - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
1090 - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
1091 - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
1092 - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
1093 - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
1094 - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
1095 - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
1096 - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
1097 - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
1098 - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
1099 - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
1100 - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
1101 - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
1102 - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
1103 - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
1104 - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
1105 - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
1106 - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
1107 - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
1108 - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
1109 - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
1110 - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
1111 - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
1112 - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
1117 diff -ruN RJaCGH.orig/src/deflate.c RJaCGH/src/deflate.c
1118 --- RJaCGH.orig/src/deflate.c 2009-03-04 12:51:20.000000000 +0100
1119 +++ RJaCGH/src/deflate.c 1970-01-01 01:00:00.000000000 +0100
1121 -/* deflate.c -- compress data using the deflation algorithm
1122 - * Copyright (C) 1995-2005 Jean-loup Gailly.
1123 - * For conditions of distribution and use, see copyright notice in zlib.h
1129 - * The "deflation" process depends on being able to identify portions
1130 - * of the input text which are identical to earlier input (within a
1131 - * sliding window trailing behind the input currently being processed).
1133 - * The most straightforward technique turns out to be the fastest for
1134 - * most input files: try all possible matches and select the longest.
1135 - * The key feature of this algorithm is that insertions into the string
1136 - * dictionary are very simple and thus fast, and deletions are avoided
1137 - * completely. Insertions are performed at each input character, whereas
1138 - * string matches are performed only when the previous match ends. So it
1139 - * is preferable to spend more time in matches to allow very fast string
1140 - * insertions and avoid deletions. The matching algorithm for small
1141 - * strings is inspired from that of Rabin & Karp. A brute force approach
1142 - * is used to find longer strings when a small match has been found.
1143 - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
1144 - * (by Leonid Broukhis).
1145 - * A previous version of this file used a more sophisticated algorithm
1146 - * (by Fiala and Greene) which is guaranteed to run in linear amortized
1147 - * time, but has a larger average cost, uses more memory and is patented.
1148 - * However the F&G algorithm may be faster for some highly redundant
1149 - * files if the parameter max_chain_length (described below) is too large.
1151 - * ACKNOWLEDGEMENTS
1153 - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
1154 - * I found it in 'freeze' written by Leonid Broukhis.
1155 - * Thanks to many people for bug reports and testing.
1159 - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
1160 - * Available in http://www.ietf.org/rfc/rfc1951.txt
1162 - * A description of the Rabin and Karp algorithm is given in the book
1163 - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
1165 - * Fiala,E.R., and Greene,D.H.
1166 - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
1172 -#include "deflate.h"
1174 -const char deflate_copyright[] =
1175 - " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
1177 - If you use the zlib library in a product, an acknowledgment is welcome
1178 - in the documentation of your product. If for some reason you cannot
1179 - include such an acknowledgment, I would appreciate that you keep this
1180 - copyright string in the executable of your product.
1183 -/* ===========================================================================
1184 - * Function prototypes.
1187 - need_more, /* block not completed, need more input or more output */
1188 - block_done, /* block flush performed */
1189 - finish_started, /* finish started, need only more output at next deflate */
1190 - finish_done /* finish done, accept no more input or output */
1193 -typedef block_state (*compress_func) OF((deflate_state *s, int flush));
1194 -/* Compression function. Returns the block state after the call. */
1196 -local void fill_window OF((deflate_state *s));
1197 -local block_state deflate_stored OF((deflate_state *s, int flush));
1198 -local block_state deflate_fast OF((deflate_state *s, int flush));
1200 -local block_state deflate_slow OF((deflate_state *s, int flush));
1202 -local void lm_init OF((deflate_state *s));
1203 -local void putShortMSB OF((deflate_state *s, uInt b));
1204 -local void flush_pending OF((z_streamp strm));
1205 -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
1208 - void match_init OF((void)); /* asm code initialization */
1209 - uInt longest_match OF((deflate_state *s, IPos cur_match));
1211 -local uInt longest_match OF((deflate_state *s, IPos cur_match));
1214 -local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
1217 -local void check_match OF((deflate_state *s, IPos start, IPos match,
1221 -/* ===========================================================================
1226 -/* Tail of hash chains */
1229 -# define TOO_FAR 4096
1231 -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
1233 -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
1234 -/* Minimum amount of lookahead, except at the end of the input file.
1235 - * See deflate.c for comments about the MIN_MATCH+1.
1238 -/* Values for max_lazy_match, good_match and max_chain_length, depending on
1239 - * the desired pack level (0..9). The values given below have been tuned to
1240 - * exclude worst case performance for pathological files. Better values may be
1241 - * found for specific files.
1243 -typedef struct config_s {
1244 - ush good_length; /* reduce lazy search above this match length */
1245 - ush max_lazy; /* do not perform lazy search above this match length */
1246 - ush nice_length; /* quit search above this match length */
1248 - compress_func func;
1252 -local const config configuration_table[2] = {
1253 -/* good lazy nice chain */
1254 -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
1255 -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
1257 -local const config configuration_table[10] = {
1258 -/* good lazy nice chain */
1259 -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
1260 -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
1261 -/* 2 */ {4, 5, 16, 8, deflate_fast},
1262 -/* 3 */ {4, 6, 32, 32, deflate_fast},
1264 -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
1265 -/* 5 */ {8, 16, 32, 32, deflate_slow},
1266 -/* 6 */ {8, 16, 128, 128, deflate_slow},
1267 -/* 7 */ {8, 32, 128, 256, deflate_slow},
1268 -/* 8 */ {32, 128, 258, 1024, deflate_slow},
1269 -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
1272 -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
1273 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
1278 -/* result of memcmp for equal strings */
1280 -#ifndef NO_DUMMY_DECL
1281 -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
1284 -/* ===========================================================================
1285 - * Update a hash value with the given input byte
1286 - * IN assertion: all calls to to UPDATE_HASH are made with consecutive
1287 - * input characters, so that a running hash key can be computed from the
1288 - * previous key instead of complete recalculation each time.
1290 -#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
1293 -/* ===========================================================================
1294 - * Insert string str in the dictionary and set match_head to the previous head
1295 - * of the hash chain (the most recent string with same hash key). Return
1296 - * the previous length of the hash chain.
1297 - * If this file is compiled with -DFASTEST, the compression level is forced
1298 - * to 1, and no hash chains are maintained.
1299 - * IN assertion: all calls to to INSERT_STRING are made with consecutive
1300 - * input characters and the first MIN_MATCH bytes of str are valid
1301 - * (except for the last MIN_MATCH-1 bytes of the input file).
1304 -#define INSERT_STRING(s, str, match_head) \
1305 - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
1306 - match_head = s->head[s->ins_h], \
1307 - s->head[s->ins_h] = (Pos)(str))
1309 -#define INSERT_STRING(s, str, match_head) \
1310 - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
1311 - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
1312 - s->head[s->ins_h] = (Pos)(str))
1315 -/* ===========================================================================
1316 - * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
1317 - * prev[] will be initialized on the fly.
1319 -#define CLEAR_HASH(s) \
1320 - s->head[s->hash_size-1] = NIL; \
1321 - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
1323 -/* ========================================================================= */
1324 -int ZEXPORT deflateInit_(strm, level, version, stream_size)
1327 - const char *version;
1330 - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
1331 - Z_DEFAULT_STRATEGY, version, stream_size);
1332 - /* To do: ignore strm->next_in if we use it as window */
1335 -/* ========================================================================= */
1336 -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
1337 - version, stream_size)
1344 - const char *version;
1349 - static const char my_version[] = ZLIB_VERSION;
1352 - /* We overlay pending_buf and d_buf+l_buf. This works since the average
1353 - * output size for (length,distance) codes is <= 24 bits.
1356 - if (version == Z_NULL || version[0] != my_version[0] ||
1357 - stream_size != sizeof(z_stream)) {
1358 - return Z_VERSION_ERROR;
1360 - if (strm == Z_NULL) return Z_STREAM_ERROR;
1362 - strm->msg = Z_NULL;
1363 - if (strm->zalloc == (alloc_func)0) {
1364 - strm->zalloc = zcalloc;
1365 - strm->opaque = (voidpf)0;
1367 - if (strm->zfree == (free_func)0) strm->zfree = zcfree;
1370 - if (level != 0) level = 1;
1372 - if (level == Z_DEFAULT_COMPRESSION) level = 6;
1375 - if (windowBits < 0) { /* suppress zlib wrapper */
1377 - windowBits = -windowBits;
1380 - else if (windowBits > 15) {
1381 - wrap = 2; /* write gzip wrapper instead */
1385 - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
1386 - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
1387 - strategy < 0 || strategy > Z_FIXED) {
1388 - return Z_STREAM_ERROR;
1390 - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
1391 - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
1392 - if (s == Z_NULL) return Z_MEM_ERROR;
1393 - strm->state = (struct internal_state FAR *)s;
1397 - s->gzhead = Z_NULL;
1398 - s->w_bits = windowBits;
1399 - s->w_size = 1 << s->w_bits;
1400 - s->w_mask = s->w_size - 1;
1402 - s->hash_bits = memLevel + 7;
1403 - s->hash_size = 1 << s->hash_bits;
1404 - s->hash_mask = s->hash_size - 1;
1405 - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
1407 - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
1408 - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
1409 - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
1411 - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
1413 - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
1414 - s->pending_buf = (uchf *) overlay;
1415 - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
1417 - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
1418 - s->pending_buf == Z_NULL) {
1419 - s->status = FINISH_STATE;
1420 - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
1421 - deflateEnd (strm);
1422 - return Z_MEM_ERROR;
1424 - s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
1425 - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
1428 - s->strategy = strategy;
1429 - s->method = (Byte)method;
1431 - return deflateReset(strm);
1434 -/* ========================================================================= */
1435 -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
1437 - const Bytef *dictionary;
1441 - uInt length = dictLength;
1443 - IPos hash_head = 0;
1445 - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
1446 - strm->state->wrap == 2 ||
1447 - (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
1448 - return Z_STREAM_ERROR;
1452 - strm->adler = adler32(strm->adler, dictionary, dictLength);
1454 - if (length < MIN_MATCH) return Z_OK;
1455 - if (length > MAX_DIST(s)) {
1456 - length = MAX_DIST(s);
1457 - dictionary += dictLength - length; /* use the tail of the dictionary */
1459 - zmemcpy(s->window, dictionary, length);
1460 - s->strstart = length;
1461 - s->block_start = (long)length;
1463 - /* Insert all strings in the hash table (except for the last two bytes).
1464 - * s->lookahead stays null, so s->ins_h will be recomputed at the next
1465 - * call of fill_window.
1467 - s->ins_h = s->window[0];
1468 - UPDATE_HASH(s, s->ins_h, s->window[1]);
1469 - for (n = 0; n <= length - MIN_MATCH; n++) {
1470 - INSERT_STRING(s, n, hash_head);
1472 - if (hash_head) hash_head = 0; /* to make compiler happy */
1476 -/* ========================================================================= */
1477 -int ZEXPORT deflateReset (strm)
1482 - if (strm == Z_NULL || strm->state == Z_NULL ||
1483 - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
1484 - return Z_STREAM_ERROR;
1487 - strm->total_in = strm->total_out = 0;
1488 - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
1489 - strm->data_type = Z_UNKNOWN;
1491 - s = (deflate_state *)strm->state;
1493 - s->pending_out = s->pending_buf;
1495 - if (s->wrap < 0) {
1496 - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
1498 - s->status = s->wrap ? INIT_STATE : BUSY_STATE;
1501 - s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
1503 - adler32(0L, Z_NULL, 0);
1504 - s->last_flush = Z_NO_FLUSH;
1512 -/* ========================================================================= */
1513 -int ZEXPORT deflateSetHeader (strm, head)
1517 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1518 - if (strm->state->wrap != 2) return Z_STREAM_ERROR;
1519 - strm->state->gzhead = head;
1523 -/* ========================================================================= */
1524 -int ZEXPORT deflatePrime (strm, bits, value)
1529 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1530 - strm->state->bi_valid = bits;
1531 - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
1535 -/* ========================================================================= */
1536 -int ZEXPORT deflateParams(strm, level, strategy)
1542 - compress_func func;
1545 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1549 - if (level != 0) level = 1;
1551 - if (level == Z_DEFAULT_COMPRESSION) level = 6;
1553 - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
1554 - return Z_STREAM_ERROR;
1556 - func = configuration_table[s->level].func;
1558 - if (func != configuration_table[level].func && strm->total_in != 0) {
1559 - /* Flush the last buffer: */
1560 - err = deflate(strm, Z_PARTIAL_FLUSH);
1562 - if (s->level != level) {
1564 - s->max_lazy_match = configuration_table[level].max_lazy;
1565 - s->good_match = configuration_table[level].good_length;
1566 - s->nice_match = configuration_table[level].nice_length;
1567 - s->max_chain_length = configuration_table[level].max_chain;
1569 - s->strategy = strategy;
1573 -/* ========================================================================= */
1574 -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
1583 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1585 - s->good_match = good_length;
1586 - s->max_lazy_match = max_lazy;
1587 - s->nice_match = nice_length;
1588 - s->max_chain_length = max_chain;
1592 -/* =========================================================================
1593 - * For the default windowBits of 15 and memLevel of 8, this function returns
1594 - * a close to exact, as well as small, upper bound on the compressed size.
1595 - * They are coded as constants here for a reason--if the #define's are
1596 - * changed, then this function needs to be changed as well. The return
1597 - * value for 15 and 8 only works for those exact settings.
1599 - * For any setting other than those defaults for windowBits and memLevel,
1600 - * the value returned is a conservative worst case for the maximum expansion
1601 - * resulting from using fixed blocks instead of stored blocks, which deflate
1602 - * can emit on compressed data for some combinations of the parameters.
1604 - * This function could be more sophisticated to provide closer upper bounds
1605 - * for every combination of windowBits and memLevel, as well as wrap.
1606 - * But even the conservative upper bound of about 14% expansion does not
1607 - * seem onerous for output buffer allocation.
1609 -uLong ZEXPORT deflateBound(strm, sourceLen)
1616 - /* conservative upper bound */
1617 - destLen = sourceLen +
1618 - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
1620 - /* if can't get parameters, return conservative bound */
1621 - if (strm == Z_NULL || strm->state == Z_NULL)
1624 - /* if not default parameters, return conservative bound */
1626 - if (s->w_bits != 15 || s->hash_bits != 8 + 7)
1629 - /* default settings: return tight bound for that case */
1630 - return compressBound(sourceLen);
1633 -/* =========================================================================
1634 - * Put a short in the pending buffer. The 16-bit value is put in MSB order.
1635 - * IN assertion: the stream state is correct and there is enough room in
1638 -local void putShortMSB (s, b)
1642 - put_byte(s, (Byte)(b >> 8));
1643 - put_byte(s, (Byte)(b & 0xff));
1646 -/* =========================================================================
1647 - * Flush as much pending output as possible. All deflate() output goes
1648 - * through this function so some applications may wish to modify it
1649 - * to avoid allocating a large strm->next_out buffer and copying into it.
1650 - * (See also read_buf()).
1652 -local void flush_pending(strm)
1655 - unsigned len = strm->state->pending;
1657 - if (len > strm->avail_out) len = strm->avail_out;
1658 - if (len == 0) return;
1660 - zmemcpy(strm->next_out, strm->state->pending_out, len);
1661 - strm->next_out += len;
1662 - strm->state->pending_out += len;
1663 - strm->total_out += len;
1664 - strm->avail_out -= len;
1665 - strm->state->pending -= len;
1666 - if (strm->state->pending == 0) {
1667 - strm->state->pending_out = strm->state->pending_buf;
1671 -/* ========================================================================= */
1672 -int ZEXPORT deflate (strm, flush)
1676 - int old_flush; /* value of flush param for previous deflate call */
1679 - if (strm == Z_NULL || strm->state == Z_NULL ||
1680 - flush > Z_FINISH || flush < 0) {
1681 - return Z_STREAM_ERROR;
1685 - if (strm->next_out == Z_NULL ||
1686 - (strm->next_in == Z_NULL && strm->avail_in != 0) ||
1687 - (s->status == FINISH_STATE && flush != Z_FINISH)) {
1688 - ERR_RETURN(strm, Z_STREAM_ERROR);
1690 - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
1692 - s->strm = strm; /* just in case */
1693 - old_flush = s->last_flush;
1694 - s->last_flush = flush;
1696 - /* Write the header */
1697 - if (s->status == INIT_STATE) {
1699 - if (s->wrap == 2) {
1700 - strm->adler = crc32(0L, Z_NULL, 0);
1704 - if (s->gzhead == NULL) {
1710 - put_byte(s, s->level == 9 ? 2 :
1711 - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
1713 - put_byte(s, OS_CODE);
1714 - s->status = BUSY_STATE;
1717 - put_byte(s, (s->gzhead->text ? 1 : 0) +
1718 - (s->gzhead->hcrc ? 2 : 0) +
1719 - (s->gzhead->extra == Z_NULL ? 0 : 4) +
1720 - (s->gzhead->name == Z_NULL ? 0 : 8) +
1721 - (s->gzhead->comment == Z_NULL ? 0 : 16)
1723 - put_byte(s, (Byte)(s->gzhead->time & 0xff));
1724 - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
1725 - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
1726 - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
1727 - put_byte(s, s->level == 9 ? 2 :
1728 - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
1730 - put_byte(s, s->gzhead->os & 0xff);
1731 - if (s->gzhead->extra != NULL) {
1732 - put_byte(s, s->gzhead->extra_len & 0xff);
1733 - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
1735 - if (s->gzhead->hcrc)
1736 - strm->adler = crc32(strm->adler, s->pending_buf,
1739 - s->status = EXTRA_STATE;
1745 - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
1748 - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
1750 - else if (s->level < 6)
1752 - else if (s->level == 6)
1756 - header |= (level_flags << 6);
1757 - if (s->strstart != 0) header |= PRESET_DICT;
1758 - header += 31 - (header % 31);
1760 - s->status = BUSY_STATE;
1761 - putShortMSB(s, header);
1763 - /* Save the adler32 of the preset dictionary: */
1764 - if (s->strstart != 0) {
1765 - putShortMSB(s, (uInt)(strm->adler >> 16));
1766 - putShortMSB(s, (uInt)(strm->adler & 0xffff));
1768 - strm->adler = adler32(0L, Z_NULL, 0);
1772 - if (s->status == EXTRA_STATE) {
1773 - if (s->gzhead->extra != NULL) {
1774 - uInt beg = s->pending; /* start of bytes to update crc */
1776 - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
1777 - if (s->pending == s->pending_buf_size) {
1778 - if (s->gzhead->hcrc && s->pending > beg)
1779 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1780 - s->pending - beg);
1781 - flush_pending(strm);
1783 - if (s->pending == s->pending_buf_size)
1786 - put_byte(s, s->gzhead->extra[s->gzindex]);
1789 - if (s->gzhead->hcrc && s->pending > beg)
1790 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1791 - s->pending - beg);
1792 - if (s->gzindex == s->gzhead->extra_len) {
1794 - s->status = NAME_STATE;
1798 - s->status = NAME_STATE;
1800 - if (s->status == NAME_STATE) {
1801 - if (s->gzhead->name != NULL) {
1802 - uInt beg = s->pending; /* start of bytes to update crc */
1806 - if (s->pending == s->pending_buf_size) {
1807 - if (s->gzhead->hcrc && s->pending > beg)
1808 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1809 - s->pending - beg);
1810 - flush_pending(strm);
1812 - if (s->pending == s->pending_buf_size) {
1817 - val = s->gzhead->name[s->gzindex++];
1819 - } while (val != 0);
1820 - if (s->gzhead->hcrc && s->pending > beg)
1821 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1822 - s->pending - beg);
1825 - s->status = COMMENT_STATE;
1829 - s->status = COMMENT_STATE;
1831 - if (s->status == COMMENT_STATE) {
1832 - if (s->gzhead->comment != NULL) {
1833 - uInt beg = s->pending; /* start of bytes to update crc */
1837 - if (s->pending == s->pending_buf_size) {
1838 - if (s->gzhead->hcrc && s->pending > beg)
1839 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1840 - s->pending - beg);
1841 - flush_pending(strm);
1843 - if (s->pending == s->pending_buf_size) {
1848 - val = s->gzhead->comment[s->gzindex++];
1850 - } while (val != 0);
1851 - if (s->gzhead->hcrc && s->pending > beg)
1852 - strm->adler = crc32(strm->adler, s->pending_buf + beg,
1853 - s->pending - beg);
1855 - s->status = HCRC_STATE;
1858 - s->status = HCRC_STATE;
1860 - if (s->status == HCRC_STATE) {
1861 - if (s->gzhead->hcrc) {
1862 - if (s->pending + 2 > s->pending_buf_size)
1863 - flush_pending(strm);
1864 - if (s->pending + 2 <= s->pending_buf_size) {
1865 - put_byte(s, (Byte)(strm->adler & 0xff));
1866 - put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1867 - strm->adler = crc32(0L, Z_NULL, 0);
1868 - s->status = BUSY_STATE;
1872 - s->status = BUSY_STATE;
1876 - /* Flush as much pending output as possible */
1877 - if (s->pending != 0) {
1878 - flush_pending(strm);
1879 - if (strm->avail_out == 0) {
1880 - /* Since avail_out is 0, deflate will be called again with
1881 - * more output space, but possibly with both pending and
1882 - * avail_in equal to zero. There won't be anything to do,
1883 - * but this is not an error situation so make sure we
1884 - * return OK instead of BUF_ERROR at next call of deflate:
1886 - s->last_flush = -1;
1890 - /* Make sure there is something to do and avoid duplicate consecutive
1891 - * flushes. For repeated and useless calls with Z_FINISH, we keep
1892 - * returning Z_STREAM_END instead of Z_BUF_ERROR.
1894 - } else if (strm->avail_in == 0 && flush <= old_flush &&
1895 - flush != Z_FINISH) {
1896 - ERR_RETURN(strm, Z_BUF_ERROR);
1899 - /* User must not provide more input after the first FINISH: */
1900 - if (s->status == FINISH_STATE && strm->avail_in != 0) {
1901 - ERR_RETURN(strm, Z_BUF_ERROR);
1904 - /* Start a new block or continue the current one.
1906 - if (strm->avail_in != 0 || s->lookahead != 0 ||
1907 - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1908 - block_state bstate;
1910 - bstate = (*(configuration_table[s->level].func))(s, flush);
1912 - if (bstate == finish_started || bstate == finish_done) {
1913 - s->status = FINISH_STATE;
1915 - if (bstate == need_more || bstate == finish_started) {
1916 - if (strm->avail_out == 0) {
1917 - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
1920 - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1921 - * of deflate should use the same flush parameter to make sure
1922 - * that the flush is complete. So we don't have to output an
1923 - * empty block here, this will be done at next call. This also
1924 - * ensures that for a very small output buffer, we emit at most
1925 - * one empty block.
1928 - if (bstate == block_done) {
1929 - if (flush == Z_PARTIAL_FLUSH) {
1931 - } else { /* FULL_FLUSH or SYNC_FLUSH */
1932 - _tr_stored_block(s, (char*)0, 0L, 0);
1933 - /* For a full flush, this empty block will be recognized
1934 - * as a special marker by inflate_sync().
1936 - if (flush == Z_FULL_FLUSH) {
1937 - CLEAR_HASH(s); /* forget history */
1940 - flush_pending(strm);
1941 - if (strm->avail_out == 0) {
1942 - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1947 - Assert(strm->avail_out > 0, "bug2");
1949 - if (flush != Z_FINISH) return Z_OK;
1950 - if (s->wrap <= 0) return Z_STREAM_END;
1952 - /* Write the trailer */
1954 - if (s->wrap == 2) {
1955 - put_byte(s, (Byte)(strm->adler & 0xff));
1956 - put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1957 - put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
1958 - put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
1959 - put_byte(s, (Byte)(strm->total_in & 0xff));
1960 - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
1961 - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
1962 - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
1967 - putShortMSB(s, (uInt)(strm->adler >> 16));
1968 - putShortMSB(s, (uInt)(strm->adler & 0xffff));
1970 - flush_pending(strm);
1971 - /* If avail_out is zero, the application will call deflate again
1972 - * to flush the rest.
1974 - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1975 - return s->pending != 0 ? Z_OK : Z_STREAM_END;
1978 -/* ========================================================================= */
1979 -int ZEXPORT deflateEnd (strm)
1984 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1986 - status = strm->state->status;
1987 - if (status != INIT_STATE &&
1988 - status != EXTRA_STATE &&
1989 - status != NAME_STATE &&
1990 - status != COMMENT_STATE &&
1991 - status != HCRC_STATE &&
1992 - status != BUSY_STATE &&
1993 - status != FINISH_STATE) {
1994 - return Z_STREAM_ERROR;
1997 - /* Deallocate in reverse order of allocations: */
1998 - TRY_FREE(strm, strm->state->pending_buf);
1999 - TRY_FREE(strm, strm->state->head);
2000 - TRY_FREE(strm, strm->state->prev);
2001 - TRY_FREE(strm, strm->state->window);
2003 - ZFREE(strm, strm->state);
2004 - strm->state = Z_NULL;
2006 - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
2009 -/* =========================================================================
2010 - * Copy the source state to the destination state.
2011 - * To simplify the source, this is not supported for 16-bit MSDOS (which
2012 - * doesn't have enough memory anyway to duplicate compression states).
2014 -int ZEXPORT deflateCopy (dest, source)
2019 - return Z_STREAM_ERROR;
2021 - deflate_state *ds;
2022 - deflate_state *ss;
2026 - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
2027 - return Z_STREAM_ERROR;
2030 - ss = source->state;
2032 - zmemcpy(dest, source, sizeof(z_stream));
2034 - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
2035 - if (ds == Z_NULL) return Z_MEM_ERROR;
2036 - dest->state = (struct internal_state FAR *) ds;
2037 - zmemcpy(ds, ss, sizeof(deflate_state));
2040 - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
2041 - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
2042 - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
2043 - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
2044 - ds->pending_buf = (uchf *) overlay;
2046 - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
2047 - ds->pending_buf == Z_NULL) {
2048 - deflateEnd (dest);
2049 - return Z_MEM_ERROR;
2051 - /* following zmemcpy do not work for 16-bit MSDOS */
2052 - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
2053 - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
2054 - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
2055 - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
2057 - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
2058 - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
2059 - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
2061 - ds->l_desc.dyn_tree = ds->dyn_ltree;
2062 - ds->d_desc.dyn_tree = ds->dyn_dtree;
2063 - ds->bl_desc.dyn_tree = ds->bl_tree;
2066 -#endif /* MAXSEG_64K */
2069 -/* ===========================================================================
2070 - * Read a new buffer from the current input stream, update the adler32
2071 - * and total number of bytes read. All deflate() input goes through
2072 - * this function so some applications may wish to modify it to avoid
2073 - * allocating a large strm->next_in buffer and copying from it.
2074 - * (See also flush_pending()).
2076 -local int read_buf(strm, buf, size)
2081 - unsigned len = strm->avail_in;
2083 - if (len > size) len = size;
2084 - if (len == 0) return 0;
2086 - strm->avail_in -= len;
2088 - if (strm->state->wrap == 1) {
2089 - strm->adler = adler32(strm->adler, strm->next_in, len);
2092 - else if (strm->state->wrap == 2) {
2093 - strm->adler = crc32(strm->adler, strm->next_in, len);
2096 - zmemcpy(buf, strm->next_in, len);
2097 - strm->next_in += len;
2098 - strm->total_in += len;
2103 -/* ===========================================================================
2104 - * Initialize the "longest match" routines for a new zlib stream
2106 -local void lm_init (s)
2109 - s->window_size = (ulg)2L*s->w_size;
2113 - /* Set the default configuration parameters:
2115 - s->max_lazy_match = configuration_table[s->level].max_lazy;
2116 - s->good_match = configuration_table[s->level].good_length;
2117 - s->nice_match = configuration_table[s->level].nice_length;
2118 - s->max_chain_length = configuration_table[s->level].max_chain;
2121 - s->block_start = 0L;
2123 - s->match_length = s->prev_length = MIN_MATCH-1;
2124 - s->match_available = 0;
2128 - match_init(); /* initialize the asm code */
2134 -/* ===========================================================================
2135 - * Set match_start to the longest match starting at the given string and
2136 - * return its length. Matches shorter or equal to prev_length are discarded,
2137 - * in which case the result is equal to prev_length and match_start is
2139 - * IN assertions: cur_match is the head of the hash chain for the current
2140 - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
2141 - * OUT assertion: the match length is not greater than s->lookahead.
2144 -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
2145 - * match.S. The code will be functionally equivalent.
2147 -local uInt longest_match(s, cur_match)
2149 - IPos cur_match; /* current match */
2151 - unsigned chain_length = s->max_chain_length;/* max hash chain length */
2152 - register Bytef *scan = s->window + s->strstart; /* current string */
2153 - register Bytef *match; /* matched string */
2154 - register int len; /* length of current match */
2155 - int best_len = s->prev_length; /* best match length so far */
2156 - int nice_match = s->nice_match; /* stop if match long enough */
2157 - IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
2158 - s->strstart - (IPos)MAX_DIST(s) : NIL;
2159 - /* Stop when cur_match becomes <= limit. To simplify the code,
2160 - * we prevent matches with the string of window index 0.
2162 - Posf *prev = s->prev;
2163 - uInt wmask = s->w_mask;
2165 -#ifdef UNALIGNED_OK
2166 - /* Compare two bytes at a time. Note: this is not always beneficial.
2167 - * Try with and without -DUNALIGNED_OK to check.
2169 - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
2170 - register ush scan_start = *(ushf*)scan;
2171 - register ush scan_end = *(ushf*)(scan+best_len-1);
2173 - register Bytef *strend = s->window + s->strstart + MAX_MATCH;
2174 - register Byte scan_end1 = scan[best_len-1];
2175 - register Byte scan_end = scan[best_len];
2178 - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
2179 - * It is easy to get rid of this optimization if necessary.
2181 - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
2183 - /* Do not waste too much time if we already have a good match: */
2184 - if (s->prev_length >= s->good_match) {
2185 - chain_length >>= 2;
2187 - /* Do not look for matches beyond the end of the input. This is necessary
2188 - * to make deflate deterministic.
2190 - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
2192 - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
2195 - Assert(cur_match < s->strstart, "no future");
2196 - match = s->window + cur_match;
2198 - /* Skip to next match if the match length cannot increase
2199 - * or if the match length is less than 2. Note that the checks below
2200 - * for insufficient lookahead only occur occasionally for performance
2201 - * reasons. Therefore uninitialized memory will be accessed, and
2202 - * conditional jumps will be made that depend on those values.
2203 - * However the length of the match is limited to the lookahead, so
2204 - * the output of deflate is not affected by the uninitialized values.
2206 -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
2207 - /* This code assumes sizeof(unsigned short) == 2. Do not use
2208 - * UNALIGNED_OK if your compiler uses a different size.
2210 - if (*(ushf*)(match+best_len-1) != scan_end ||
2211 - *(ushf*)match != scan_start) continue;
2213 - /* It is not necessary to compare scan[2] and match[2] since they are
2214 - * always equal when the other bytes match, given that the hash keys
2215 - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
2216 - * strstart+3, +5, ... up to strstart+257. We check for insufficient
2217 - * lookahead only every 4th comparison; the 128th check will be made
2218 - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
2219 - * necessary to put more guard bytes at the end of the window, or
2220 - * to check more often for insufficient lookahead.
2222 - Assert(scan[2] == match[2], "scan[2]?");
2225 - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2226 - *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2227 - *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2228 - *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
2230 - /* The funny "do {}" generates better code on most compilers */
2232 - /* Here, scan <= window+strstart+257 */
2233 - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2234 - if (*scan == *match) scan++;
2236 - len = (MAX_MATCH - 1) - (int)(strend-scan);
2237 - scan = strend - (MAX_MATCH-1);
2239 -#else /* UNALIGNED_OK */
2241 - if (match[best_len] != scan_end ||
2242 - match[best_len-1] != scan_end1 ||
2243 - *match != *scan ||
2244 - *++match != scan[1]) continue;
2246 - /* The check at best_len-1 can be removed because it will be made
2247 - * again later. (This heuristic is not always a win.)
2248 - * It is not necessary to compare scan[2] and match[2] since they
2249 - * are always equal when the other bytes match, given that
2250 - * the hash keys are equal and that HASH_BITS >= 8.
2252 - scan += 2, match++;
2253 - Assert(*scan == *match, "match[2]?");
2255 - /* We check for insufficient lookahead only every 8th comparison;
2256 - * the 256th check will be made at strstart+258.
2259 - } while (*++scan == *++match && *++scan == *++match &&
2260 - *++scan == *++match && *++scan == *++match &&
2261 - *++scan == *++match && *++scan == *++match &&
2262 - *++scan == *++match && *++scan == *++match &&
2265 - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2267 - len = MAX_MATCH - (int)(strend - scan);
2268 - scan = strend - MAX_MATCH;
2270 -#endif /* UNALIGNED_OK */
2272 - if (len > best_len) {
2273 - s->match_start = cur_match;
2275 - if (len >= nice_match) break;
2276 -#ifdef UNALIGNED_OK
2277 - scan_end = *(ushf*)(scan+best_len-1);
2279 - scan_end1 = scan[best_len-1];
2280 - scan_end = scan[best_len];
2283 - } while ((cur_match = prev[cur_match & wmask]) > limit
2284 - && --chain_length != 0);
2286 - if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
2287 - return s->lookahead;
2290 -#endif /* FASTEST */
2292 -/* ---------------------------------------------------------------------------
2293 - * Optimized version for level == 1 or strategy == Z_RLE only
2295 -local uInt longest_match_fast(s, cur_match)
2297 - IPos cur_match; /* current match */
2299 - register Bytef *scan = s->window + s->strstart; /* current string */
2300 - register Bytef *match; /* matched string */
2301 - register int len; /* length of current match */
2302 - register Bytef *strend = s->window + s->strstart + MAX_MATCH;
2304 - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
2305 - * It is easy to get rid of this optimization if necessary.
2307 - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
2309 - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
2311 - Assert(cur_match < s->strstart, "no future");
2313 - match = s->window + cur_match;
2315 - /* Return failure if the match length is less than 2:
2317 - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
2319 - /* The check at best_len-1 can be removed because it will be made
2320 - * again later. (This heuristic is not always a win.)
2321 - * It is not necessary to compare scan[2] and match[2] since they
2322 - * are always equal when the other bytes match, given that
2323 - * the hash keys are equal and that HASH_BITS >= 8.
2325 - scan += 2, match += 2;
2326 - Assert(*scan == *match, "match[2]?");
2328 - /* We check for insufficient lookahead only every 8th comparison;
2329 - * the 256th check will be made at strstart+258.
2332 - } while (*++scan == *++match && *++scan == *++match &&
2333 - *++scan == *++match && *++scan == *++match &&
2334 - *++scan == *++match && *++scan == *++match &&
2335 - *++scan == *++match && *++scan == *++match &&
2338 - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2340 - len = MAX_MATCH - (int)(strend - scan);
2342 - if (len < MIN_MATCH) return MIN_MATCH - 1;
2344 - s->match_start = cur_match;
2345 - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
2349 -/* ===========================================================================
2350 - * Check that the match at match_start is indeed a match.
2352 -local void check_match(s, start, match, length)
2354 - IPos start, match;
2357 - /* check that the match is indeed a match */
2358 - if (zmemcmp(s->window + match,
2359 - s->window + start, length) != EQUAL) {
2360 - fprintf(stderr, " start %u, match %u, length %d\n",
2361 - start, match, length);
2363 - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
2364 - } while (--length != 0);
2365 - z_error("invalid match");
2367 - if (z_verbose > 1) {
2368 - fprintf(stderr,"\\[%d,%d]", start-match, length);
2369 - do { putc(s->window[start++], stderr); } while (--length != 0);
2373 -# define check_match(s, start, match, length)
2376 -/* ===========================================================================
2377 - * Fill the window when the lookahead becomes insufficient.
2378 - * Updates strstart and lookahead.
2380 - * IN assertion: lookahead < MIN_LOOKAHEAD
2381 - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
2382 - * At least one byte has been read, or avail_in == 0; reads are
2383 - * performed for at least two bytes (required for the zip translate_eol
2384 - * option -- not supported here).
2386 -local void fill_window(s)
2389 - register unsigned n, m;
2391 - unsigned more; /* Amount of free space at the end of the window. */
2392 - uInt wsize = s->w_size;
2395 - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
2397 - /* Deal with !@#$% 64K limit: */
2398 - if (sizeof(int) <= 2) {
2399 - if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
2402 - } else if (more == (unsigned)(-1)) {
2403 - /* Very unlikely, but possible on 16 bit machine if
2404 - * strstart == 0 && lookahead == 1 (input done a byte at time)
2410 - /* If the window is almost full and there is insufficient lookahead,
2411 - * move the upper half to the lower one to make room in the upper half.
2413 - if (s->strstart >= wsize+MAX_DIST(s)) {
2415 - zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
2416 - s->match_start -= wsize;
2417 - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
2418 - s->block_start -= (long) wsize;
2420 - /* Slide the hash table (could be avoided with 32 bit values
2421 - at the expense of memory usage). We slide even when level == 0
2422 - to keep the hash table consistent if we switch back to level > 0
2423 - later. (Using level 0 permanently is not an optimal usage of
2424 - zlib, so we don't care about this pathological case.)
2426 - /* %%% avoid this when Z_RLE */
2431 - *p = (Pos)(m >= wsize ? m-wsize : NIL);
2439 - *p = (Pos)(m >= wsize ? m-wsize : NIL);
2440 - /* If n is not on any hash chain, prev[n] is garbage but
2441 - * its value will never be used.
2447 - if (s->strm->avail_in == 0) return;
2449 - /* If there was no sliding:
2450 - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
2451 - * more == window_size - lookahead - strstart
2452 - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
2453 - * => more >= window_size - 2*WSIZE + 2
2454 - * In the BIG_MEM or MMAP case (not yet supported),
2455 - * window_size == input_size + MIN_LOOKAHEAD &&
2456 - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
2457 - * Otherwise, window_size == 2*WSIZE so more >= 2.
2458 - * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
2460 - Assert(more >= 2, "more < 2");
2462 - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
2463 - s->lookahead += n;
2465 - /* Initialize the hash value now that we have some input: */
2466 - if (s->lookahead >= MIN_MATCH) {
2467 - s->ins_h = s->window[s->strstart];
2468 - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
2470 - Call UPDATE_HASH() MIN_MATCH-3 more times
2473 - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
2474 - * but this is not important since only literal bytes will be emitted.
2477 - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
2480 -/* ===========================================================================
2481 - * Flush the current block, with given end-of-file flag.
2482 - * IN assertion: strstart is set to the end of the current match.
2484 -#define FLUSH_BLOCK_ONLY(s, eof) { \
2485 - _tr_flush_block(s, (s->block_start >= 0L ? \
2486 - (charf *)&s->window[(unsigned)s->block_start] : \
2487 - (charf *)Z_NULL), \
2488 - (ulg)((long)s->strstart - s->block_start), \
2490 - s->block_start = s->strstart; \
2491 - flush_pending(s->strm); \
2492 - Tracev((stderr,"[FLUSH]")); \
2495 -/* Same but force premature exit if necessary. */
2496 -#define FLUSH_BLOCK(s, eof) { \
2497 - FLUSH_BLOCK_ONLY(s, eof); \
2498 - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
2501 -/* ===========================================================================
2502 - * Copy without compression as much as possible from the input stream, return
2503 - * the current block state.
2504 - * This function does not insert new strings in the dictionary since
2505 - * uncompressible data is probably not useful. This function is used
2506 - * only for the level=0 compression option.
2507 - * NOTE: this function should be optimized to avoid extra copying from
2508 - * window to pending_buf.
2510 -local block_state deflate_stored(s, flush)
2514 - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
2515 - * to pending_buf_size, and each stored block has a 5 byte header:
2517 - ulg max_block_size = 0xffff;
2520 - if (max_block_size > s->pending_buf_size - 5) {
2521 - max_block_size = s->pending_buf_size - 5;
2524 - /* Copy as much as possible from input to output: */
2526 - /* Fill the window as much as possible: */
2527 - if (s->lookahead <= 1) {
2529 - Assert(s->strstart < s->w_size+MAX_DIST(s) ||
2530 - s->block_start >= (long)s->w_size, "slide too late");
2533 - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
2535 - if (s->lookahead == 0) break; /* flush the current block */
2537 - Assert(s->block_start >= 0L, "block gone");
2539 - s->strstart += s->lookahead;
2542 - /* Emit a stored block if pending_buf will be full: */
2543 - max_start = s->block_start + max_block_size;
2544 - if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
2545 - /* strstart == 0 is possible when wraparound on 16-bit machine */
2546 - s->lookahead = (uInt)(s->strstart - max_start);
2547 - s->strstart = (uInt)max_start;
2548 - FLUSH_BLOCK(s, 0);
2550 - /* Flush if we may have to slide, otherwise block_start may become
2551 - * negative and the data will be gone:
2553 - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
2554 - FLUSH_BLOCK(s, 0);
2557 - FLUSH_BLOCK(s, flush == Z_FINISH);
2558 - return flush == Z_FINISH ? finish_done : block_done;
2561 -/* ===========================================================================
2562 - * Compress as much as possible from the input stream, return the current
2564 - * This function does not perform lazy evaluation of matches and inserts
2565 - * new strings in the dictionary only for unmatched strings or for short
2566 - * matches. It is used only for the fast compression options.
2568 -local block_state deflate_fast(s, flush)
2572 - IPos hash_head = NIL; /* head of the hash chain */
2573 - int bflush; /* set if current block must be flushed */
2576 - /* Make sure that we always have enough lookahead, except
2577 - * at the end of the input file. We need MAX_MATCH bytes
2578 - * for the next match, plus MIN_MATCH bytes to insert the
2579 - * string following the next match.
2581 - if (s->lookahead < MIN_LOOKAHEAD) {
2583 - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
2586 - if (s->lookahead == 0) break; /* flush the current block */
2589 - /* Insert the string window[strstart .. strstart+2] in the
2590 - * dictionary, and set hash_head to the head of the hash chain:
2592 - if (s->lookahead >= MIN_MATCH) {
2593 - INSERT_STRING(s, s->strstart, hash_head);
2596 - /* Find the longest match, discarding those <= prev_length.
2597 - * At this point we have always match_length < MIN_MATCH
2599 - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
2600 - /* To simplify the code, we prevent matches with the string
2601 - * of window index 0 (in particular we have to avoid a match
2602 - * of the string with itself at the start of the input file).
2605 - if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
2606 - (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
2607 - s->match_length = longest_match_fast (s, hash_head);
2610 - if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
2611 - s->match_length = longest_match (s, hash_head);
2612 - } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
2613 - s->match_length = longest_match_fast (s, hash_head);
2616 - /* longest_match() or longest_match_fast() sets match_start */
2618 - if (s->match_length >= MIN_MATCH) {
2619 - check_match(s, s->strstart, s->match_start, s->match_length);
2621 - _tr_tally_dist(s, s->strstart - s->match_start,
2622 - s->match_length - MIN_MATCH, bflush);
2624 - s->lookahead -= s->match_length;
2626 - /* Insert new strings in the hash table only if the match length
2627 - * is not too large. This saves time but degrades compression.
2630 - if (s->match_length <= s->max_insert_length &&
2631 - s->lookahead >= MIN_MATCH) {
2632 - s->match_length--; /* string at strstart already in table */
2635 - INSERT_STRING(s, s->strstart, hash_head);
2636 - /* strstart never exceeds WSIZE-MAX_MATCH, so there are
2637 - * always MIN_MATCH bytes ahead.
2639 - } while (--s->match_length != 0);
2644 - s->strstart += s->match_length;
2645 - s->match_length = 0;
2646 - s->ins_h = s->window[s->strstart];
2647 - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
2649 - Call UPDATE_HASH() MIN_MATCH-3 more times
2651 - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
2652 - * matter since it will be recomputed at next deflate call.
2656 - /* No match, output a literal byte */
2657 - Tracevv((stderr,"%c", s->window[s->strstart]));
2658 - _tr_tally_lit (s, s->window[s->strstart], bflush);
2662 - if (bflush) FLUSH_BLOCK(s, 0);
2664 - FLUSH_BLOCK(s, flush == Z_FINISH);
2665 - return flush == Z_FINISH ? finish_done : block_done;
2669 -/* ===========================================================================
2670 - * Same as above, but achieves better compression. We use a lazy
2671 - * evaluation for matches: a match is finally adopted only if there is
2672 - * no better match at the next window position.
2674 -local block_state deflate_slow(s, 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(s, flush)
2807 - int bflush; /* set if current block must be flushed */
2808 - uInt run; /* length of run */
2809 - uInt max; /* maximum length of run */
2810 - uInt prev; /* byte at distance one to match */
2811 - Bytef *scan; /* scan for end of run */
2814 - /* Make sure that we always have enough lookahead, except
2815 - * at the end of the input file. We need MAX_MATCH bytes
2816 - * for the longest encodable run.
2818 - if (s->lookahead < MAX_MATCH) {
2820 - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
2823 - if (s->lookahead == 0) break; /* flush the current block */
2826 - /* See how many times the previous byte repeats */
2828 - if (s->strstart > 0) { /* if there is a previous byte, that is */
2829 - max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
2830 - scan = s->window + s->strstart - 1;
2833 - if (*scan++ != prev)
2835 - } while (++run < max);
2838 - /* Emit match if have run of MIN_MATCH or longer, else emit literal */
2839 - if (run >= MIN_MATCH) {
2840 - check_match(s, s->strstart, s->strstart - 1, run);
2841 - _tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
2842 - s->lookahead -= run;
2843 - s->strstart += run;
2845 - /* No match, output a literal byte */
2846 - Tracevv((stderr,"%c", s->window[s->strstart]));
2847 - _tr_tally_lit (s, s->window[s->strstart], bflush);
2851 - if (bflush) FLUSH_BLOCK(s, 0);
2853 - FLUSH_BLOCK(s, flush == Z_FINISH);
2854 - return flush == Z_FINISH ? finish_done : block_done;
2857 diff -ruN RJaCGH.orig/src/deflate.h RJaCGH/src/deflate.h
2858 --- RJaCGH.orig/src/deflate.h 2009-03-04 12:51:20.000000000 +0100
2859 +++ RJaCGH/src/deflate.h 1970-01-01 01:00:00.000000000 +0100
2861 -/* deflate.h -- internal compression state
2862 - * Copyright (C) 1995-2004 Jean-loup Gailly
2863 - * For conditions of distribution and use, see copyright notice in zlib.h
2866 -/* WARNING: this file should *not* be used by applications. It is
2867 - part of the implementation of the compression library and is
2868 - subject to change. Applications should only use zlib.h.
2878 -/* define NO_GZIP when compiling if you want to disable gzip header and
2879 - trailer creation by deflate(). NO_GZIP would be used to avoid linking in
2880 - the crc code when it is not needed. For shared libraries, gzip encoding
2881 - should be left enabled. */
2886 -/* ===========================================================================
2887 - * Internal compression state.
2890 -#define LENGTH_CODES 29
2891 -/* number of length codes, not counting the special END_BLOCK code */
2893 -#define LITERALS 256
2894 -/* number of literal bytes 0..255 */
2896 -#define L_CODES (LITERALS+1+LENGTH_CODES)
2897 -/* number of Literal or Length codes, including the END_BLOCK code */
2900 -/* number of distance codes */
2902 -#define BL_CODES 19
2903 -/* number of codes used to transfer the bit lengths */
2905 -#define HEAP_SIZE (2*L_CODES+1)
2906 -/* maximum heap size */
2908 -#define MAX_BITS 15
2909 -/* All codes must not exceed MAX_BITS bits */
2911 -#define INIT_STATE 42
2912 -#define EXTRA_STATE 69
2913 -#define NAME_STATE 73
2914 -#define COMMENT_STATE 91
2915 -#define HCRC_STATE 103
2916 -#define BUSY_STATE 113
2917 -#define FINISH_STATE 666
2918 -/* Stream status */
2921 -/* Data structure describing a single value and its code string. */
2922 -typedef struct ct_data_s {
2924 - ush freq; /* frequency count */
2925 - ush code; /* bit string */
2928 - ush dad; /* father node in Huffman tree */
2929 - ush len; /* length of bit string */
2933 -#define Freq fc.freq
2934 -#define Code fc.code
2938 -typedef struct static_tree_desc_s static_tree_desc;
2940 -typedef struct tree_desc_s {
2941 - ct_data *dyn_tree; /* the dynamic tree */
2942 - int max_code; /* largest code with non zero frequency */
2943 - static_tree_desc *stat_desc; /* the corresponding static tree */
2947 -typedef Pos FAR Posf;
2948 -typedef unsigned IPos;
2950 -/* A Pos is an index in the character window. We use short instead of int to
2951 - * save space in the various tables. IPos is used only for parameter passing.
2954 -typedef struct internal_state {
2955 - z_streamp strm; /* pointer back to this zlib stream */
2956 - int status; /* as the name implies */
2957 - Bytef *pending_buf; /* output still pending */
2958 - ulg pending_buf_size; /* size of pending_buf */
2959 - Bytef *pending_out; /* next pending byte to output to the stream */
2960 - uInt pending; /* nb of bytes in the pending buffer */
2961 - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
2962 - gz_headerp gzhead; /* gzip header information to write */
2963 - uInt gzindex; /* where in extra, name, or comment */
2964 - Byte method; /* STORED (for zip only) or DEFLATED */
2965 - int last_flush; /* value of flush param for previous deflate call */
2967 - /* used by deflate.c: */
2969 - uInt w_size; /* LZ77 window size (32K by default) */
2970 - uInt w_bits; /* log2(w_size) (8..16) */
2971 - uInt w_mask; /* w_size - 1 */
2974 - /* Sliding window. Input bytes are read into the second half of the window,
2975 - * and move to the first half later to keep a dictionary of at least wSize
2976 - * bytes. With this organization, matches are limited to a distance of
2977 - * wSize-MAX_MATCH bytes, but this ensures that IO is always
2978 - * performed with a length multiple of the block size. Also, it limits
2979 - * the window size to 64K, which is quite useful on MSDOS.
2980 - * To do: use the user input buffer as sliding window.
2984 - /* Actual size of window: 2*wSize, except when the user input buffer
2985 - * is directly used as sliding window.
2989 - /* Link to older string with same hash index. To limit the size of this
2990 - * array to 64K, this link is maintained only for the last 32K strings.
2991 - * An index in this array is thus a window index modulo 32K.
2994 - Posf *head; /* Heads of the hash chains or NIL. */
2996 - uInt ins_h; /* hash index of string to be inserted */
2997 - uInt hash_size; /* number of elements in hash table */
2998 - uInt hash_bits; /* log2(hash_size) */
2999 - uInt hash_mask; /* hash_size-1 */
3002 - /* Number of bits by which ins_h must be shifted at each input
3003 - * step. It must be such that after MIN_MATCH steps, the oldest
3004 - * byte no longer takes part in the hash key, that is:
3005 - * hash_shift * MIN_MATCH >= hash_bits
3009 - /* Window position at the beginning of the current output block. Gets
3010 - * negative when the window is moved backwards.
3013 - uInt match_length; /* length of best match */
3014 - IPos prev_match; /* previous match */
3015 - int match_available; /* set if previous match exists */
3016 - uInt strstart; /* start of string to insert */
3017 - uInt match_start; /* start of matching string */
3018 - uInt lookahead; /* number of valid bytes ahead in window */
3021 - /* Length of the best match at previous step. Matches not greater than this
3022 - * are discarded. This is used in the lazy match evaluation.
3025 - uInt max_chain_length;
3026 - /* To speed up deflation, hash chains are never searched beyond this
3027 - * length. A higher limit improves compression ratio but degrades the
3031 - uInt max_lazy_match;
3032 - /* Attempt to find a better match only when the current match is strictly
3033 - * smaller than this value. This mechanism is used only for compression
3036 -# define max_insert_length max_lazy_match
3037 - /* Insert new strings in the hash table only if the match length is not
3038 - * greater than this length. This saves time but degrades compression.
3039 - * max_insert_length is used only for compression levels <= 3.
3042 - int level; /* compression level (1..9) */
3043 - int strategy; /* favor or force Huffman coding*/
3046 - /* Use a faster search when the previous match is longer than this */
3048 - int nice_match; /* Stop searching when current match exceeds this */
3050 - /* used by trees.c: */
3051 - /* Didn't use ct_data typedef below to supress compiler warning */
3052 - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
3053 - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
3054 - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
3056 - struct tree_desc_s l_desc; /* desc. for literal tree */
3057 - struct tree_desc_s d_desc; /* desc. for distance tree */
3058 - struct tree_desc_s bl_desc; /* desc. for bit length tree */
3060 - ush bl_count[MAX_BITS+1];
3061 - /* number of codes at each bit length for an optimal tree */
3063 - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
3064 - int heap_len; /* number of elements in the heap */
3065 - int heap_max; /* element of largest frequency */
3066 - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
3067 - * The same heap array is used to build all trees.
3070 - uch depth[2*L_CODES+1];
3071 - /* Depth of each subtree used as tie breaker for trees of equal frequency
3074 - uchf *l_buf; /* buffer for literals or lengths */
3077 - /* Size of match buffer for literals/lengths. There are 4 reasons for
3078 - * limiting lit_bufsize to 64K:
3079 - * - frequencies can be kept in 16 bit counters
3080 - * - if compression is not successful for the first block, all input
3081 - * data is still in the window so we can still emit a stored block even
3082 - * when input comes from standard input. (This can also be done for
3083 - * all blocks if lit_bufsize is not greater than 32K.)
3084 - * - if compression is not successful for a file smaller than 64K, we can
3085 - * even emit a stored file instead of a stored block (saving 5 bytes).
3086 - * This is applicable only for zip (not gzip or zlib).
3087 - * - creating new Huffman trees less frequently may not provide fast
3088 - * adaptation to changes in the input data statistics. (Take for
3089 - * example a binary file with poorly compressible code followed by
3090 - * a highly compressible string table.) Smaller buffer sizes give
3091 - * fast adaptation but have of course the overhead of transmitting
3092 - * trees more frequently.
3093 - * - I can't count above 4
3096 - uInt last_lit; /* running index in l_buf */
3099 - /* Buffer for distances. To simplify the code, d_buf and l_buf have
3100 - * the same number of elements. To use different lengths, an extra flag
3101 - * array would be necessary.
3104 - ulg opt_len; /* bit length of current block with optimal trees */
3105 - ulg static_len; /* bit length of current block with static trees */
3106 - uInt matches; /* number of string matches in current block */
3107 - int last_eob_len; /* bit length of EOB code for last block */
3110 - ulg compressed_len; /* total bit length of compressed file mod 2^32 */
3111 - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
3115 - /* Output buffer. bits are inserted starting at the bottom (least
3116 - * significant bits).
3119 - /* Number of valid bits in bi_buf. All bits above the last valid bit
3120 - * are always zero.
3123 -} FAR deflate_state;
3125 -/* Output a byte on the stream.
3126 - * IN assertion: there is enough room in pending_buf.
3128 -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
3131 -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
3132 -/* Minimum amount of lookahead, except at the end of the input file.
3133 - * See deflate.c for comments about the MIN_MATCH+1.
3136 -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
3137 -/* In order to simplify the code, particularly on 16 bit machines, match
3138 - * distances are limited to MAX_DIST instead of WSIZE.
3142 -void _tr_init OF((deflate_state *s));
3143 -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
3144 -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
3146 -void _tr_align OF((deflate_state *s));
3147 -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
3150 -#define d_code(dist) \
3151 - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
3152 -/* Mapping from a distance to a distance code. dist is the distance - 1 and
3153 - * must not have side effects. _dist_code[256] and _dist_code[257] are never
3158 -/* Inline versions of _tr_tally for speed: */
3160 -#if defined(GEN_TREES_H) || !defined(STDC)
3161 - extern uch _length_code[];
3162 - extern uch _dist_code[];
3164 - extern const uch _length_code[];
3165 - extern const uch _dist_code[];
3168 -# define _tr_tally_lit(s, c, flush) \
3170 - s->d_buf[s->last_lit] = 0; \
3171 - s->l_buf[s->last_lit++] = cc; \
3172 - s->dyn_ltree[cc].Freq++; \
3173 - flush = (s->last_lit == s->lit_bufsize-1); \
3175 -# define _tr_tally_dist(s, distance, length, flush) \
3176 - { uch len = (length); \
3177 - ush dist = (distance); \
3178 - s->d_buf[s->last_lit] = dist; \
3179 - s->l_buf[s->last_lit++] = len; \
3181 - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
3182 - s->dyn_dtree[d_code(dist)].Freq++; \
3183 - flush = (s->last_lit == s->lit_bufsize-1); \
3186 -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
3187 -# define _tr_tally_dist(s, distance, length, flush) \
3188 - flush = _tr_tally(s, distance, length)
3191 -#endif /* DEFLATE_H */
3192 diff -ruN RJaCGH.orig/src/gzio.c RJaCGH/src/gzio.c
3193 --- RJaCGH.orig/src/gzio.c 2009-03-04 12:51:20.000000000 +0100
3194 +++ RJaCGH/src/gzio.c 1970-01-01 01:00:00.000000000 +0100
3196 -/* gzio.c -- IO on .gz files
3197 - * Copyright (C) 1995-2005 Jean-loup Gailly.
3198 - * For conditions of distribution and use, see copyright notice in zlib.h
3200 - * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
3209 -#ifdef NO_DEFLATE /* for compatibility with old definition */
3210 -# define NO_GZCOMPRESS
3213 -#ifndef NO_DUMMY_DECL
3214 -struct internal_state {int dummy;}; /* for buggy compilers */
3219 -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
3221 -# define Z_BUFSIZE 16384
3224 -#ifndef Z_PRINTF_BUFSIZE
3225 -# define Z_PRINTF_BUFSIZE 4096
3229 -# pragma map (fdopen , "\174\174FDOPEN")
3230 - FILE *fdopen(int, const char *);
3234 -extern voidp malloc OF((uInt size));
3235 -extern void free OF((voidpf ptr));
3238 -#define ALLOC(size) malloc(size)
3239 -#define TRYFREE(p) {if (p) free(p);}
3241 -static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
3243 -/* gzip flag byte */
3244 -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
3245 -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
3246 -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
3247 -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
3248 -#define COMMENT 0x10 /* bit 4 set: file comment present */
3249 -#define RESERVED 0xE0 /* bits 5..7: reserved */
3251 -typedef struct gz_stream {
3253 - int z_err; /* error code for last stream operation */
3254 - int z_eof; /* set if end of input file */
3255 - FILE *file; /* .gz file */
3256 - Byte *inbuf; /* input buffer */
3257 - Byte *outbuf; /* output buffer */
3258 - uLong crc; /* crc32 of uncompressed data */
3259 - char *msg; /* error message */
3260 - char *path; /* path name for debugging only */
3261 - int transparent; /* 1 if input file is not a .gz file */
3262 - char mode; /* 'w' or 'r' */
3263 - z_off_t start; /* start of compressed data in file (header skipped) */
3264 - z_off_t in; /* bytes into deflate or inflate */
3265 - z_off_t out; /* bytes out of deflate or inflate */
3266 - int back; /* one character push-back */
3267 - int last; /* true if push-back is last character */
3271 -local gzFile gz_open OF((const char *path, const char *mode, int fd));
3272 -local int do_flush OF((gzFile file, int flush));
3273 -local int get_byte OF((gz_stream *s));
3274 -local void check_header OF((gz_stream *s));
3275 -local int destroy OF((gz_stream *s));
3276 -local void putLong OF((FILE *file, uLong x));
3277 -local uLong getLong OF((gz_stream *s));
3279 -/* ===========================================================================
3280 - Opens a gzip (.gz) file for reading or writing. The mode parameter
3281 - is as in fopen ("rb" or "wb"). The file is given either by file descriptor
3282 - or path name (if fd == -1).
3283 - gz_open returns NULL if the file could not be opened or if there was
3284 - insufficient memory to allocate the (de)compression state; errno
3285 - can be checked to distinguish the two cases (if errno is zero, the
3286 - zlib error is Z_MEM_ERROR).
3288 -local gzFile gz_open (path, mode, fd)
3294 - int level = Z_DEFAULT_COMPRESSION; /* compression level */
3295 - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
3296 - char *p = (char*)mode;
3298 - char fmode[80]; /* copy of mode, without the compression level */
3301 - if (!path || !mode) return Z_NULL;
3303 - s = (gz_stream *)ALLOC(sizeof(gz_stream));
3304 - if (!s) return Z_NULL;
3306 - s->stream.zalloc = (alloc_func)0;
3307 - s->stream.zfree = (free_func)0;
3308 - s->stream.opaque = (voidpf)0;
3309 - s->stream.next_in = s->inbuf = Z_NULL;
3310 - s->stream.next_out = s->outbuf = Z_NULL;
3311 - s->stream.avail_in = s->stream.avail_out = 0;
3318 - s->crc = crc32(0L, Z_NULL, 0);
3320 - s->transparent = 0;
3322 - s->path = (char*)ALLOC(strlen(path)+1);
3323 - if (s->path == NULL) {
3324 - return destroy(s), (gzFile)Z_NULL;
3326 - strcpy(s->path, path); /* do this early for debugging */
3330 - if (*p == 'r') s->mode = 'r';
3331 - if (*p == 'w' || *p == 'a') s->mode = 'w';
3332 - if (*p >= '0' && *p <= '9') {
3334 - } else if (*p == 'f') {
3335 - strategy = Z_FILTERED;
3336 - } else if (*p == 'h') {
3337 - strategy = Z_HUFFMAN_ONLY;
3338 - } else if (*p == 'R') {
3341 - *m++ = *p; /* copy the mode */
3343 - } while (*p++ && m != fmode + sizeof(fmode));
3344 - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
3346 - if (s->mode == 'w') {
3347 -#ifdef NO_GZCOMPRESS
3348 - err = Z_STREAM_ERROR;
3350 - err = deflateInit2(&(s->stream), level,
3351 - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
3352 - /* windowBits is passed < 0 to suppress zlib header */
3354 - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
3356 - if (err != Z_OK || s->outbuf == Z_NULL) {
3357 - return destroy(s), (gzFile)Z_NULL;
3360 - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
3362 - err = inflateInit2(&(s->stream), -MAX_WBITS);
3363 - /* windowBits is passed < 0 to tell that there is no zlib header.
3364 - * Note that in this case inflate *requires* an extra "dummy" byte
3365 - * after the compressed stream in order to complete decompression and
3366 - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
3367 - * present after the compressed stream.
3369 - if (err != Z_OK || s->inbuf == Z_NULL) {
3370 - return destroy(s), (gzFile)Z_NULL;
3373 - s->stream.avail_out = Z_BUFSIZE;
3376 - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
3378 - if (s->file == NULL) {
3379 - return destroy(s), (gzFile)Z_NULL;
3381 - if (s->mode == 'w') {
3382 - /* Write a very simple .gz header:
3384 - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
3385 - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
3387 - /* We use 10L instead of ftell(s->file) to because ftell causes an
3388 - * fflush on some systems. This version of the library doesn't use
3389 - * start anyway in write mode, so this initialization is not
3393 - check_header(s); /* skip the .gz header */
3394 - s->start = ftell(s->file) - s->stream.avail_in;
3400 -/* ===========================================================================
3401 - Opens a gzip (.gz) file for reading or writing.
3403 -gzFile ZEXPORT gzopen (path, mode)
3407 - return gz_open (path, mode, -1);
3410 -/* ===========================================================================
3411 - Associate a gzFile with the file descriptor fd. fd is not dup'ed here
3412 - to mimic the behavio(u)r of fdopen.
3414 -gzFile ZEXPORT gzdopen (fd, mode)
3418 - char name[46]; /* allow for up to 128-bit integers */
3420 - if (fd < 0) return (gzFile)Z_NULL;
3421 - sprintf(name, "<fd:%d>", fd); /* for debugging */
3423 - return gz_open (name, mode, fd);
3426 -/* ===========================================================================
3427 - * Update the compression level and strategy
3429 -int ZEXPORT gzsetparams (file, level, strategy)
3434 - gz_stream *s = (gz_stream*)file;
3436 - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3438 - /* Make room to allow flushing */
3439 - if (s->stream.avail_out == 0) {
3441 - s->stream.next_out = s->outbuf;
3442 - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
3443 - s->z_err = Z_ERRNO;
3445 - s->stream.avail_out = Z_BUFSIZE;
3448 - return deflateParams (&(s->stream), level, strategy);
3451 -/* ===========================================================================
3452 - Read a byte from a gz_stream; update next_in and avail_in. Return EOF
3454 - IN assertion: the stream s has been sucessfully opened for reading.
3456 -local int get_byte(s)
3459 - if (s->z_eof) return EOF;
3460 - if (s->stream.avail_in == 0) {
3462 - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
3463 - if (s->stream.avail_in == 0) {
3465 - if (ferror(s->file)) s->z_err = Z_ERRNO;
3468 - s->stream.next_in = s->inbuf;
3470 - s->stream.avail_in--;
3471 - return *(s->stream.next_in)++;
3474 -/* ===========================================================================
3475 - Check the gzip header of a gz_stream opened for reading. Set the stream
3476 - mode to transparent if the gzip magic header is not present; set s->err
3477 - to Z_DATA_ERROR if the magic header is present but the rest of the header
3479 - IN assertion: the stream s has already been created sucessfully;
3480 - s->stream.avail_in is zero for the first time, but may be non-zero
3481 - for concatenated .gz files.
3483 -local void check_header(s)
3486 - int method; /* method byte */
3487 - int flags; /* flags byte */
3491 - /* Assure two bytes in the buffer so we can peek ahead -- handle case
3492 - where first byte of header is at the end of the buffer after the last
3494 - len = s->stream.avail_in;
3496 - if (len) s->inbuf[0] = s->stream.next_in[0];
3498 - len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
3499 - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
3500 - s->stream.avail_in += len;
3501 - s->stream.next_in = s->inbuf;
3502 - if (s->stream.avail_in < 2) {
3503 - s->transparent = s->stream.avail_in;
3508 - /* Peek ahead to check the gzip magic header */
3509 - if (s->stream.next_in[0] != gz_magic[0] ||
3510 - s->stream.next_in[1] != gz_magic[1]) {
3511 - s->transparent = 1;
3514 - s->stream.avail_in -= 2;
3515 - s->stream.next_in += 2;
3517 - /* Check the rest of the gzip header */
3518 - method = get_byte(s);
3519 - flags = get_byte(s);
3520 - if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
3521 - s->z_err = Z_DATA_ERROR;
3525 - /* Discard time, xflags and OS code: */
3526 - for (len = 0; len < 6; len++) (void)get_byte(s);
3528 - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
3529 - len = (uInt)get_byte(s);
3530 - len += ((uInt)get_byte(s))<<8;
3531 - /* len is garbage if EOF but the loop below will quit anyway */
3532 - while (len-- != 0 && get_byte(s) != EOF) ;
3534 - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
3535 - while ((c = get_byte(s)) != 0 && c != EOF) ;
3537 - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
3538 - while ((c = get_byte(s)) != 0 && c != EOF) ;
3540 - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
3541 - for (len = 0; len < 2; len++) (void)get_byte(s);
3543 - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
3546 - /* ===========================================================================
3547 - * Cleanup then free the given gz_stream. Return a zlib error code.
3548 - Try freeing in the reverse order of allocations.
3550 -local int destroy (s)
3555 - if (!s) return Z_STREAM_ERROR;
3559 - if (s->stream.state != NULL) {
3560 - if (s->mode == 'w') {
3561 -#ifdef NO_GZCOMPRESS
3562 - err = Z_STREAM_ERROR;
3564 - err = deflateEnd(&(s->stream));
3566 - } else if (s->mode == 'r') {
3567 - err = inflateEnd(&(s->stream));
3570 - if (s->file != NULL && fclose(s->file)) {
3572 - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
3576 - if (s->z_err < 0) err = s->z_err;
3578 - TRYFREE(s->inbuf);
3579 - TRYFREE(s->outbuf);
3585 -/* ===========================================================================
3586 - Reads the given number of uncompressed bytes from the compressed file.
3587 - gzread returns the number of bytes actually read (0 for end of file).
3589 -int ZEXPORT gzread (file, buf, len)
3594 - gz_stream *s = (gz_stream*)file;
3595 - Bytef *start = (Bytef*)buf; /* starting point for crc computation */
3596 - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
3598 - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
3600 - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
3601 - if (s->z_err == Z_STREAM_END) return 0; /* EOF */
3603 - next_out = (Byte*)buf;
3604 - s->stream.next_out = (Bytef*)buf;
3605 - s->stream.avail_out = len;
3607 - if (s->stream.avail_out && s->back != EOF) {
3608 - *next_out++ = s->back;
3609 - s->stream.next_out++;
3610 - s->stream.avail_out--;
3615 - s->z_err = Z_STREAM_END;
3620 - while (s->stream.avail_out != 0) {
3622 - if (s->transparent) {
3623 - /* Copy first the lookahead bytes: */
3624 - uInt n = s->stream.avail_in;
3625 - if (n > s->stream.avail_out) n = s->stream.avail_out;
3627 - zmemcpy(s->stream.next_out, s->stream.next_in, n);
3629 - s->stream.next_out = next_out;
3630 - s->stream.next_in += n;
3631 - s->stream.avail_out -= n;
3632 - s->stream.avail_in -= n;
3634 - if (s->stream.avail_out > 0) {
3635 - s->stream.avail_out -=
3636 - (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
3638 - len -= s->stream.avail_out;
3641 - if (len == 0) s->z_eof = 1;
3644 - if (s->stream.avail_in == 0 && !s->z_eof) {
3647 - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
3648 - if (s->stream.avail_in == 0) {
3650 - if (ferror(s->file)) {
3651 - s->z_err = Z_ERRNO;
3655 - s->stream.next_in = s->inbuf;
3657 - s->in += s->stream.avail_in;
3658 - s->out += s->stream.avail_out;
3659 - s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
3660 - s->in -= s->stream.avail_in;
3661 - s->out -= s->stream.avail_out;
3663 - if (s->z_err == Z_STREAM_END) {
3664 - /* Check CRC and original size */
3665 - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
3666 - start = s->stream.next_out;
3668 - if (getLong(s) != s->crc) {
3669 - s->z_err = Z_DATA_ERROR;
3672 - /* The uncompressed length returned by above getlong() may be
3673 - * different from s->out in case of concatenated .gz files.
3674 - * Check for such files:
3677 - if (s->z_err == Z_OK) {
3678 - inflateReset(&(s->stream));
3679 - s->crc = crc32(0L, Z_NULL, 0);
3683 - if (s->z_err != Z_OK || s->z_eof) break;
3685 - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
3687 - if (len == s->stream.avail_out &&
3688 - (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
3690 - return (int)(len - s->stream.avail_out);
3694 -/* ===========================================================================
3695 - Reads one byte from the compressed file. gzgetc returns this byte
3696 - or -1 in case of end of file or error.
3698 -int ZEXPORT gzgetc(file)
3703 - return gzread(file, &c, 1) == 1 ? c : -1;
3707 -/* ===========================================================================
3708 - Push one byte back onto the stream.
3710 -int ZEXPORT gzungetc(c, file)
3714 - gz_stream *s = (gz_stream*)file;
3716 - if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
3719 - s->last = (s->z_err == Z_STREAM_END);
3720 - if (s->last) s->z_err = Z_OK;
3726 -/* ===========================================================================
3727 - Reads bytes from the compressed file until len-1 characters are
3728 - read, or a newline character is read and transferred to buf, or an
3729 - end-of-file condition is encountered. The string is then terminated
3730 - with a null character.
3731 - gzgets returns buf, or Z_NULL in case of error.
3733 - The current implementation is not optimized at all.
3735 -char * ZEXPORT gzgets(file, buf, len)
3741 - if (buf == Z_NULL || len <= 0) return Z_NULL;
3743 - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
3745 - return b == buf && len > 0 ? Z_NULL : b;
3749 -#ifndef NO_GZCOMPRESS
3750 -/* ===========================================================================
3751 - Writes the given number of uncompressed bytes into the compressed file.
3752 - gzwrite returns the number of bytes actually written (0 in case of error).
3754 -int ZEXPORT gzwrite (file, buf, len)
3759 - gz_stream *s = (gz_stream*)file;
3761 - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3763 - s->stream.next_in = (Bytef*)buf;
3764 - s->stream.avail_in = len;
3766 - while (s->stream.avail_in != 0) {
3768 - if (s->stream.avail_out == 0) {
3770 - s->stream.next_out = s->outbuf;
3771 - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
3772 - s->z_err = Z_ERRNO;
3775 - s->stream.avail_out = Z_BUFSIZE;
3777 - s->in += s->stream.avail_in;
3778 - s->out += s->stream.avail_out;
3779 - s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
3780 - s->in -= s->stream.avail_in;
3781 - s->out -= s->stream.avail_out;
3782 - if (s->z_err != Z_OK) break;
3784 - s->crc = crc32(s->crc, (const Bytef *)buf, len);
3786 - 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);
3869 -/* ===========================================================================
3870 - Writes c, converted to an unsigned char, into the compressed file.
3871 - gzputc returns the value that was written, or -1 in case of error.
3873 -int ZEXPORT gzputc(file, c)
3877 - unsigned char cc = (unsigned char) c; /* required for big endian systems */
3879 - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
3883 -/* ===========================================================================
3884 - Writes the given null-terminated string to the compressed file, excluding
3885 - the terminating null character.
3886 - gzputs returns the number of characters written, or -1 in case of error.
3888 -int ZEXPORT gzputs(file, s)
3892 - return gzwrite(file, (char*)s, (unsigned)strlen(s));
3896 -/* ===========================================================================
3897 - Flushes all pending output into the compressed file. The parameter
3898 - flush is as in the deflate() function.
3900 -local int do_flush (file, flush)
3906 - gz_stream *s = (gz_stream*)file;
3908 - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3910 - s->stream.avail_in = 0; /* should be zero already anyway */
3913 - len = Z_BUFSIZE - s->stream.avail_out;
3916 - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
3917 - s->z_err = Z_ERRNO;
3920 - s->stream.next_out = s->outbuf;
3921 - s->stream.avail_out = Z_BUFSIZE;
3924 - s->out += s->stream.avail_out;
3925 - s->z_err = deflate(&(s->stream), flush);
3926 - s->out -= s->stream.avail_out;
3928 - /* Ignore the second of two consecutive flushes: */
3929 - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
3931 - /* deflate has finished flushing only when it hasn't used up
3932 - * all the available space in the output buffer:
3934 - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
3936 - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
3938 - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
3941 -int ZEXPORT gzflush (file, flush)
3945 - gz_stream *s = (gz_stream*)file;
3946 - int err = do_flush (file, flush);
3948 - if (err) return err;
3950 - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
3952 -#endif /* NO_GZCOMPRESS */
3954 -/* ===========================================================================
3955 - Sets the starting position for the next gzread or gzwrite on the given
3956 - compressed file. The offset represents a number of bytes in the
3957 - gzseek returns the resulting offset location as measured in bytes from
3958 - the beginning of the uncompressed stream, or -1 in case of error.
3959 - SEEK_END is not implemented, returns error.
3960 - In this version of the library, gzseek can be extremely slow.
3962 -z_off_t ZEXPORT gzseek (file, offset, whence)
3967 - gz_stream *s = (gz_stream*)file;
3969 - if (s == NULL || whence == SEEK_END ||
3970 - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
3974 - if (s->mode == 'w') {
3975 -#ifdef NO_GZCOMPRESS
3978 - if (whence == SEEK_SET) {
3981 - if (offset < 0) return -1L;
3983 - /* At this point, offset is the number of zero bytes to write. */
3984 - if (s->inbuf == Z_NULL) {
3985 - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
3986 - if (s->inbuf == Z_NULL) return -1L;
3987 - zmemzero(s->inbuf, Z_BUFSIZE);
3989 - while (offset > 0) {
3990 - uInt size = Z_BUFSIZE;
3991 - if (offset < Z_BUFSIZE) size = (uInt)offset;
3993 - size = gzwrite(file, s->inbuf, size);
3994 - if (size == 0) return -1L;
4001 - /* Rest of function is for reading only */
4003 - /* compute absolute position */
4004 - if (whence == SEEK_CUR) {
4007 - if (offset < 0) return -1L;
4009 - if (s->transparent) {
4010 - /* map to fseek */
4012 - s->stream.avail_in = 0;
4013 - s->stream.next_in = s->inbuf;
4014 - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
4016 - s->in = s->out = offset;
4020 - /* For a negative seek, rewind and use positive seek */
4021 - if (offset >= s->out) {
4023 - } else if (gzrewind(file) < 0) {
4026 - /* offset is now the number of bytes to skip. */
4028 - if (offset != 0 && s->outbuf == Z_NULL) {
4029 - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
4030 - if (s->outbuf == Z_NULL) return -1L;
4032 - if (offset && s->back != EOF) {
4036 - if (s->last) s->z_err = Z_STREAM_END;
4038 - while (offset > 0) {
4039 - int size = Z_BUFSIZE;
4040 - if (offset < Z_BUFSIZE) size = (int)offset;
4042 - size = gzread(file, s->outbuf, (uInt)size);
4043 - if (size <= 0) return -1L;
4049 -/* ===========================================================================
4050 - Rewinds input file.
4052 -int ZEXPORT gzrewind (file)
4055 - gz_stream *s = (gz_stream*)file;
4057 - if (s == NULL || s->mode != 'r') return -1;
4062 - s->stream.avail_in = 0;
4063 - s->stream.next_in = s->inbuf;
4064 - s->crc = crc32(0L, Z_NULL, 0);
4065 - if (!s->transparent) (void)inflateReset(&s->stream);
4068 - return fseek(s->file, s->start, SEEK_SET);
4071 -/* ===========================================================================
4072 - Returns the starting position for the next gzread or gzwrite on the
4073 - given compressed file. This position represents a number of bytes in the
4074 - uncompressed data stream.
4076 -z_off_t ZEXPORT gztell (file)
4079 - return gzseek(file, 0L, SEEK_CUR);
4082 -/* ===========================================================================
4083 - Returns 1 when EOF has previously been detected reading the given
4084 - input stream, otherwise zero.
4086 -int ZEXPORT gzeof (file)
4089 - gz_stream *s = (gz_stream*)file;
4091 - /* With concatenated compressed files that can have embedded
4092 - * crc trailers, z_eof is no longer the only/best indicator of EOF
4093 - * on a gz_stream. Handle end-of-stream error explicitly here.
4095 - if (s == NULL || s->mode != 'r') return 0;
4096 - if (s->z_eof) return 1;
4097 - return s->z_err == Z_STREAM_END;
4100 -/* ===========================================================================
4101 - Returns 1 if reading and doing so transparently, otherwise zero.
4103 -int ZEXPORT gzdirect (file)
4106 - gz_stream *s = (gz_stream*)file;
4108 - if (s == NULL || s->mode != 'r') return 0;
4109 - return s->transparent;
4112 -/* ===========================================================================
4113 - Outputs a long in LSB order to the given file
4115 -local void putLong (file, x)
4120 - for (n = 0; n < 4; n++) {
4121 - fputc((int)(x & 0xff), file);
4126 -/* ===========================================================================
4127 - Reads a long in LSB order from the given gz_stream. Sets z_err in case
4130 -local uLong getLong (s)
4133 - uLong x = (uLong)get_byte(s);
4136 - x += ((uLong)get_byte(s))<<8;
4137 - x += ((uLong)get_byte(s))<<16;
4139 - if (c == EOF) s->z_err = Z_DATA_ERROR;
4140 - x += ((uLong)c)<<24;
4144 -/* ===========================================================================
4145 - Flushes all pending output if necessary, closes the compressed file
4146 - and deallocates all the (de)compression state.
4148 -int ZEXPORT gzclose (file)
4151 - gz_stream *s = (gz_stream*)file;
4153 - if (s == NULL) return Z_STREAM_ERROR;
4155 - if (s->mode == 'w') {
4156 -#ifdef NO_GZCOMPRESS
4157 - return Z_STREAM_ERROR;
4159 - if (do_flush (file, Z_FINISH) != Z_OK)
4160 - return destroy((gz_stream*)file);
4162 - putLong (s->file, s->crc);
4163 - putLong (s->file, (uLong)(s->in & 0xffffffff));
4166 - return destroy((gz_stream*)file);
4170 -# define zstrerror(errnum) strerror(errnum)
4172 -# define zstrerror(errnum) ""
4175 -/* ===========================================================================
4176 - Returns the error message for the last error which occurred on the
4177 - given compressed file. errnum is set to zlib error number. If an
4178 - error occurred in the file system and not in the compression library,
4179 - errnum is set to Z_ERRNO and the application may consult errno
4180 - to get the exact error code.
4182 -const char * ZEXPORT gzerror (file, errnum)
4187 - gz_stream *s = (gz_stream*)file;
4190 - *errnum = Z_STREAM_ERROR;
4191 - return (const char*)ERR_MSG(Z_STREAM_ERROR);
4193 - *errnum = s->z_err;
4194 - if (*errnum == Z_OK) return (const char*)"";
4196 - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
4198 - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
4201 - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
4202 - if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
4203 - strcpy(s->msg, s->path);
4204 - strcat(s->msg, ": ");
4205 - strcat(s->msg, m);
4206 - return (const char*)s->msg;
4209 -/* ===========================================================================
4210 - Clear the error and end-of-file flags, and do the same for the real file.
4212 -void ZEXPORT gzclearerr (file)
4215 - gz_stream *s = (gz_stream*)file;
4217 - if (s == NULL) return;
4218 - if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
4220 - clearerr(s->file);
4222 diff -ruN RJaCGH.orig/src/infback.c RJaCGH/src/infback.c
4223 --- RJaCGH.orig/src/infback.c 2009-03-04 12:51:20.000000000 +0100
4224 +++ RJaCGH/src/infback.c 1970-01-01 01:00:00.000000000 +0100
4226 -/* infback.c -- inflate using a call-back interface
4227 - * Copyright (C) 1995-2005 Mark Adler
4228 - * For conditions of distribution and use, see copyright notice in zlib.h
4232 - This code is largely copied from inflate.c. Normally either infback.o or
4233 - inflate.o would be linked into an application--not both. The interface
4234 - with inffast.c is retained so that optimized assembler-coded versions of
4235 - inflate_fast() can be used with either inflate.c or infback.c.
4239 -#include "inftrees.h"
4240 -#include "inflate.h"
4241 -#include "inffast.h"
4243 -/* function prototypes */
4244 -local void fixedtables OF((struct inflate_state FAR *state));
4247 - strm provides memory allocation functions in zalloc and zfree, or
4248 - Z_NULL to use the library memory allocation functions.
4250 - windowBits is in the range 8..15, and window is a user-supplied
4251 - window and output buffer that is 2**windowBits bytes.
4253 -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
4256 -unsigned char FAR *window;
4257 -const char *version;
4260 - struct inflate_state FAR *state;
4262 - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
4263 - stream_size != (int)(sizeof(z_stream)))
4264 - return Z_VERSION_ERROR;
4265 - if (strm == Z_NULL || window == Z_NULL ||
4266 - windowBits < 8 || windowBits > 15)
4267 - return Z_STREAM_ERROR;
4268 - strm->msg = Z_NULL; /* in case we return an error */
4269 - if (strm->zalloc == (alloc_func)0) {
4270 - strm->zalloc = zcalloc;
4271 - strm->opaque = (voidpf)0;
4273 - if (strm->zfree == (free_func)0) strm->zfree = zcfree;
4274 - state = (struct inflate_state FAR *)ZALLOC(strm, 1,
4275 - sizeof(struct inflate_state));
4276 - if (state == Z_NULL) return Z_MEM_ERROR;
4277 - Tracev((stderr, "inflate: allocated\n"));
4278 - strm->state = (struct internal_state FAR *)state;
4279 - state->dmax = 32768U;
4280 - state->wbits = windowBits;
4281 - state->wsize = 1U << windowBits;
4282 - state->window = window;
4289 - Return state with length and distance decoding tables and index sizes set to
4290 - fixed code decoding. Normally this returns fixed tables from inffixed.h.
4291 - If BUILDFIXED is defined, then instead this routine builds the tables the
4292 - first time it's called, and returns those tables the first time and
4293 - thereafter. This reduces the size of the code by about 2K bytes, in
4294 - exchange for a little execution time. However, BUILDFIXED should not be
4295 - used for threaded applications, since the rewriting of the tables and virgin
4296 - may not be thread-safe.
4298 -local void fixedtables(state)
4299 -struct inflate_state FAR *state;
4302 - static int virgin = 1;
4303 - static code *lenfix, *distfix;
4304 - static code fixed[544];
4306 - /* build fixed huffman tables if first call (may not be thread safe) */
4308 - unsigned sym, bits;
4309 - static code *next;
4311 - /* literal/length table */
4313 - while (sym < 144) state->lens[sym++] = 8;
4314 - while (sym < 256) state->lens[sym++] = 9;
4315 - while (sym < 280) state->lens[sym++] = 7;
4316 - while (sym < 288) state->lens[sym++] = 8;
4320 - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
4322 - /* distance table */
4324 - while (sym < 32) state->lens[sym++] = 5;
4327 - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
4329 - /* do this just once */
4332 -#else /* !BUILDFIXED */
4333 -# include "inffixed.h"
4334 -#endif /* BUILDFIXED */
4335 - state->lencode = lenfix;
4336 - state->lenbits = 9;
4337 - state->distcode = distfix;
4338 - state->distbits = 5;
4341 -/* Macros for inflateBack(): */
4343 -/* Load returned state from inflate_fast() */
4346 - put = strm->next_out; \
4347 - left = strm->avail_out; \
4348 - next = strm->next_in; \
4349 - have = strm->avail_in; \
4350 - hold = state->hold; \
4351 - bits = state->bits; \
4354 -/* Set state from registers for inflate_fast() */
4355 -#define RESTORE() \
4357 - strm->next_out = put; \
4358 - strm->avail_out = left; \
4359 - strm->next_in = next; \
4360 - strm->avail_in = have; \
4361 - state->hold = hold; \
4362 - state->bits = bits; \
4365 -/* Clear the input bit accumulator */
4366 -#define INITBITS() \
4372 -/* Assure that some input is available. If input is requested, but denied,
4373 - then return a Z_BUF_ERROR from inflateBack(). */
4376 - if (have == 0) { \
4377 - have = in(in_desc, &next); \
4378 - if (have == 0) { \
4380 - ret = Z_BUF_ERROR; \
4386 -/* Get a byte of input into the bit accumulator, or return from inflateBack()
4387 - with an error if there is no input available. */
4388 -#define PULLBYTE() \
4392 - hold += (unsigned long)(*next++) << bits; \
4396 -/* Assure that there are at least n bits in the bit accumulator. If there is
4397 - not enough available input to do that, then return from inflateBack() with
4399 -#define NEEDBITS(n) \
4401 - while (bits < (unsigned)(n)) \
4405 -/* Return the low n bits of the bit accumulator (n < 16) */
4407 - ((unsigned)hold & ((1U << (n)) - 1))
4409 -/* Remove n bits from the bit accumulator */
4410 -#define DROPBITS(n) \
4413 - bits -= (unsigned)(n); \
4416 -/* Remove zero to seven bits as needed to go to a byte boundary */
4417 -#define BYTEBITS() \
4419 - hold >>= bits & 7; \
4420 - bits -= bits & 7; \
4423 -/* Assure that some output space is available, by writing out the window
4424 - if it's full. If the write fails, return from inflateBack() with a
4428 - if (left == 0) { \
4429 - put = state->window; \
4430 - left = state->wsize; \
4431 - state->whave = left; \
4432 - if (out(out_desc, put, left)) { \
4433 - ret = Z_BUF_ERROR; \
4440 - strm provides the memory allocation functions and window buffer on input,
4441 - and provides information on the unused input on return. For Z_DATA_ERROR
4442 - returns, strm will also provide an error message.
4444 - in() and out() are the call-back input and output functions. When
4445 - inflateBack() needs more input, it calls in(). When inflateBack() has
4446 - filled the window with output, or when it completes with data in the
4447 - window, it calls out() to write out the data. The application must not
4448 - change the provided input until in() is called again or inflateBack()
4449 - returns. The application must not change the window/output buffer until
4450 - inflateBack() returns.
4452 - in() and out() are called with a descriptor parameter provided in the
4453 - inflateBack() call. This parameter can be a structure that provides the
4454 - information required to do the read or write, as well as accumulated
4455 - information on the input and output such as totals and check values.
4457 - in() should return zero on failure. out() should return non-zero on
4458 - failure. If either in() or out() fails, than inflateBack() returns a
4459 - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
4460 - was in() or out() that caused in the error. Otherwise, inflateBack()
4461 - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
4462 - error, or Z_MEM_ERROR if it could not allocate memory for the state.
4463 - inflateBack() can also return Z_STREAM_ERROR if the input parameters
4464 - are not correct, i.e. strm is Z_NULL or the state was not initialized.
4466 -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
4471 -void FAR *out_desc;
4473 - struct inflate_state FAR *state;
4474 - unsigned char FAR *next; /* next input */
4475 - unsigned char FAR *put; /* next output */
4476 - unsigned have, left; /* available input and output */
4477 - unsigned long hold; /* bit buffer */
4478 - unsigned bits; /* bits in bit buffer */
4479 - unsigned copy; /* number of stored or match bytes to copy */
4480 - unsigned char FAR *from; /* where to copy match bytes from */
4481 - code this; /* current decoding table entry */
4482 - code last; /* parent table entry */
4483 - unsigned len; /* length to copy for repeats, bits to drop */
4484 - int ret; /* return code */
4485 - static const unsigned short order[19] = /* permutation of code lengths */
4486 - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
4488 - /* Check that the strm exists and that the state was initialized */
4489 - if (strm == Z_NULL || strm->state == Z_NULL)
4490 - return Z_STREAM_ERROR;
4491 - state = (struct inflate_state FAR *)strm->state;
4493 - /* Reset the state */
4494 - strm->msg = Z_NULL;
4495 - state->mode = TYPE;
4498 - next = strm->next_in;
4499 - have = next != Z_NULL ? strm->avail_in : 0;
4502 - put = state->window;
4503 - left = state->wsize;
4505 - /* Inflate until end of block marked as last */
4507 - switch (state->mode) {
4509 - /* determine and dispatch block type */
4510 - if (state->last) {
4512 - state->mode = DONE;
4516 - state->last = BITS(1);
4518 - switch (BITS(2)) {
4519 - case 0: /* stored block */
4520 - Tracev((stderr, "inflate: stored block%s\n",
4521 - state->last ? " (last)" : ""));
4522 - state->mode = STORED;
4524 - case 1: /* fixed block */
4525 - fixedtables(state);
4526 - Tracev((stderr, "inflate: fixed codes block%s\n",
4527 - state->last ? " (last)" : ""));
4528 - state->mode = LEN; /* decode codes */
4530 - case 2: /* dynamic block */
4531 - Tracev((stderr, "inflate: dynamic codes block%s\n",
4532 - state->last ? " (last)" : ""));
4533 - state->mode = TABLE;
4536 - strm->msg = (char *)"invalid block type";
4537 - state->mode = BAD;
4543 - /* get and verify stored block length */
4544 - BYTEBITS(); /* go to byte boundary */
4546 - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
4547 - strm->msg = (char *)"invalid stored block lengths";
4548 - state->mode = BAD;
4551 - state->length = (unsigned)hold & 0xffff;
4552 - Tracev((stderr, "inflate: stored length %u\n",
4556 - /* copy stored block from input to output */
4557 - while (state->length != 0) {
4558 - copy = state->length;
4561 - if (copy > have) copy = have;
4562 - if (copy > left) copy = left;
4563 - zmemcpy(put, next, copy);
4568 - state->length -= copy;
4570 - Tracev((stderr, "inflate: stored end\n"));
4571 - state->mode = TYPE;
4575 - /* get dynamic table entries descriptor */
4577 - state->nlen = BITS(5) + 257;
4579 - state->ndist = BITS(5) + 1;
4581 - state->ncode = BITS(4) + 4;
4583 -#ifndef PKZIP_BUG_WORKAROUND
4584 - if (state->nlen > 286 || state->ndist > 30) {
4585 - strm->msg = (char *)"too many length or distance symbols";
4586 - state->mode = BAD;
4590 - Tracev((stderr, "inflate: table sizes ok\n"));
4592 - /* get code length code lengths (not a typo) */
4594 - while (state->have < state->ncode) {
4596 - state->lens[order[state->have++]] = (unsigned short)BITS(3);
4599 - while (state->have < 19)
4600 - state->lens[order[state->have++]] = 0;
4601 - state->next = state->codes;
4602 - state->lencode = (code const FAR *)(state->next);
4603 - state->lenbits = 7;
4604 - ret = inflate_table(CODES, state->lens, 19, &(state->next),
4605 - &(state->lenbits), state->work);
4607 - strm->msg = (char *)"invalid code lengths set";
4608 - state->mode = BAD;
4611 - Tracev((stderr, "inflate: code lengths ok\n"));
4613 - /* get length and distance code code lengths */
4615 - while (state->have < state->nlen + state->ndist) {
4617 - this = state->lencode[BITS(state->lenbits)];
4618 - if ((unsigned)(this.bits) <= bits) break;
4621 - if (this.val < 16) {
4622 - NEEDBITS(this.bits);
4623 - DROPBITS(this.bits);
4624 - state->lens[state->have++] = this.val;
4627 - if (this.val == 16) {
4628 - NEEDBITS(this.bits + 2);
4629 - DROPBITS(this.bits);
4630 - if (state->have == 0) {
4631 - strm->msg = (char *)"invalid bit length repeat";
4632 - state->mode = BAD;
4635 - len = (unsigned)(state->lens[state->have - 1]);
4636 - copy = 3 + BITS(2);
4639 - else if (this.val == 17) {
4640 - NEEDBITS(this.bits + 3);
4641 - DROPBITS(this.bits);
4643 - copy = 3 + BITS(3);
4647 - NEEDBITS(this.bits + 7);
4648 - DROPBITS(this.bits);
4650 - copy = 11 + BITS(7);
4653 - if (state->have + copy > state->nlen + state->ndist) {
4654 - strm->msg = (char *)"invalid bit length repeat";
4655 - state->mode = BAD;
4659 - state->lens[state->have++] = (unsigned short)len;
4663 - /* handle error breaks in while */
4664 - if (state->mode == BAD) break;
4666 - /* build code tables */
4667 - state->next = state->codes;
4668 - state->lencode = (code const FAR *)(state->next);
4669 - state->lenbits = 9;
4670 - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
4671 - &(state->lenbits), state->work);
4673 - strm->msg = (char *)"invalid literal/lengths set";
4674 - state->mode = BAD;
4677 - state->distcode = (code const FAR *)(state->next);
4678 - state->distbits = 6;
4679 - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
4680 - &(state->next), &(state->distbits), state->work);
4682 - strm->msg = (char *)"invalid distances set";
4683 - state->mode = BAD;
4686 - Tracev((stderr, "inflate: codes ok\n"));
4687 - state->mode = LEN;
4690 - /* use inflate_fast() if we have enough input and output */
4691 - if (have >= 6 && left >= 258) {
4693 - if (state->whave < state->wsize)
4694 - state->whave = state->wsize - left;
4695 - inflate_fast(strm, state->wsize);
4700 - /* get a literal, length, or end-of-block code */
4702 - this = state->lencode[BITS(state->lenbits)];
4703 - if ((unsigned)(this.bits) <= bits) break;
4706 - if (this.op && (this.op & 0xf0) == 0) {
4709 - this = state->lencode[last.val +
4710 - (BITS(last.bits + last.op) >> last.bits)];
4711 - if ((unsigned)(last.bits + this.bits) <= bits) break;
4714 - DROPBITS(last.bits);
4716 - DROPBITS(this.bits);
4717 - state->length = (unsigned)this.val;
4719 - /* process literal */
4720 - if (this.op == 0) {
4721 - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
4722 - "inflate: literal '%c'\n" :
4723 - "inflate: literal 0x%02x\n", this.val));
4725 - *put++ = (unsigned char)(state->length);
4727 - state->mode = LEN;
4731 - /* process end of block */
4732 - if (this.op & 32) {
4733 - Tracevv((stderr, "inflate: end of block\n"));
4734 - state->mode = TYPE;
4738 - /* invalid code */
4739 - if (this.op & 64) {
4740 - strm->msg = (char *)"invalid literal/length code";
4741 - state->mode = BAD;
4745 - /* length code -- get extra bits, if any */
4746 - state->extra = (unsigned)(this.op) & 15;
4747 - if (state->extra != 0) {
4748 - NEEDBITS(state->extra);
4749 - state->length += BITS(state->extra);
4750 - DROPBITS(state->extra);
4752 - Tracevv((stderr, "inflate: length %u\n", state->length));
4754 - /* get distance code */
4756 - this = state->distcode[BITS(state->distbits)];
4757 - if ((unsigned)(this.bits) <= bits) break;
4760 - if ((this.op & 0xf0) == 0) {
4763 - this = state->distcode[last.val +
4764 - (BITS(last.bits + last.op) >> last.bits)];
4765 - if ((unsigned)(last.bits + this.bits) <= bits) break;
4768 - DROPBITS(last.bits);
4770 - DROPBITS(this.bits);
4771 - if (this.op & 64) {
4772 - strm->msg = (char *)"invalid distance code";
4773 - state->mode = BAD;
4776 - state->offset = (unsigned)this.val;
4778 - /* get distance extra bits, if any */
4779 - state->extra = (unsigned)(this.op) & 15;
4780 - if (state->extra != 0) {
4781 - NEEDBITS(state->extra);
4782 - state->offset += BITS(state->extra);
4783 - DROPBITS(state->extra);
4785 - if (state->offset > state->wsize - (state->whave < state->wsize ?
4787 - strm->msg = (char *)"invalid distance too far back";
4788 - state->mode = BAD;
4791 - Tracevv((stderr, "inflate: distance %u\n", state->offset));
4793 - /* copy match from window to output */
4796 - copy = state->wsize - state->offset;
4797 - if (copy < left) {
4798 - from = put + copy;
4799 - copy = left - copy;
4802 - from = put - state->offset;
4805 - if (copy > state->length) copy = state->length;
4806 - state->length -= copy;
4811 - } while (state->length != 0);
4815 - /* inflate stream terminated properly -- write leftover output */
4816 - ret = Z_STREAM_END;
4817 - if (left < state->wsize) {
4818 - if (out(out_desc, state->window, state->wsize - left))
4819 - ret = Z_BUF_ERROR;
4824 - ret = Z_DATA_ERROR;
4827 - default: /* can't happen, but makes compilers happy */
4828 - ret = Z_STREAM_ERROR;
4832 - /* Return unused input */
4834 - strm->next_in = next;
4835 - strm->avail_in = have;
4839 -int ZEXPORT inflateBackEnd(strm)
4842 - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
4843 - return Z_STREAM_ERROR;
4844 - ZFREE(strm, strm->state);
4845 - strm->state = Z_NULL;
4846 - Tracev((stderr, "inflate: end\n"));
4849 diff -ruN RJaCGH.orig/src/inffast.c RJaCGH/src/inffast.c
4850 --- RJaCGH.orig/src/inffast.c 2009-03-04 12:51:20.000000000 +0100
4851 +++ RJaCGH/src/inffast.c 1970-01-01 01:00:00.000000000 +0100
4853 -/* inffast.c -- fast decoding
4854 - * Copyright (C) 1995-2004 Mark Adler
4855 - * For conditions of distribution and use, see copyright notice in zlib.h
4859 -#include "inftrees.h"
4860 -#include "inflate.h"
4861 -#include "inffast.h"
4865 -/* Allow machine dependent optimization for post-increment or pre-increment.
4866 - Based on testing to date,
4867 - Pre-increment preferred for:
4868 - - PowerPC G3 (Adler)
4869 - - MIPS R5000 (Randers-Pehrson)
4870 - Post-increment preferred for:
4872 - No measurable difference:
4873 - - Pentium III (Anderson)
4878 -# define PUP(a) *(a)++
4881 -# define PUP(a) *++(a)
4885 - Decode literal, length, and distance codes and write out the resulting
4886 - literal and match bytes until either not enough input or output is
4887 - available, an end-of-block is encountered, or a data error is encountered.
4888 - When large enough input and output buffers are supplied to inflate(), for
4889 - example, a 16K input buffer and a 64K output buffer, more than 95% of the
4890 - inflate execution time is spent in this routine.
4892 - Entry assumptions:
4894 - state->mode == LEN
4895 - strm->avail_in >= 6
4896 - strm->avail_out >= 258
4897 - start >= strm->avail_out
4900 - On return, state->mode is one of:
4902 - LEN -- ran out of enough output space or enough available input
4903 - TYPE -- reached end of block code, inflate() to interpret next block
4904 - BAD -- error in block data
4908 - - The maximum input bits used by a length/distance pair is 15 bits for the
4909 - length code, 5 bits for the length extra, 15 bits for the distance code,
4910 - and 13 bits for the distance extra. This totals 48 bits, or six bytes.
4911 - Therefore if strm->avail_in >= 6, then there is enough input to avoid
4912 - checking for available input while decoding.
4914 - - The maximum bytes that a single length/distance pair can output is 258
4915 - bytes, which is the maximum length that can be coded. inflate_fast()
4916 - requires strm->avail_out >= 258 for each loop to avoid checking for
4919 -void inflate_fast(strm, start)
4921 -unsigned start; /* inflate()'s starting value for strm->avail_out */
4923 - struct inflate_state FAR *state;
4924 - unsigned char FAR *in; /* local strm->next_in */
4925 - unsigned char FAR *last; /* while in < last, enough input available */
4926 - unsigned char FAR *out; /* local strm->next_out */
4927 - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
4928 - unsigned char FAR *end; /* while out < end, enough space available */
4929 -#ifdef INFLATE_STRICT
4930 - unsigned dmax; /* maximum distance from zlib header */
4932 - unsigned wsize; /* window size or zero if not using window */
4933 - unsigned whave; /* valid bytes in the window */
4934 - unsigned write; /* window write index */
4935 - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
4936 - unsigned long hold; /* local strm->hold */
4937 - unsigned bits; /* local strm->bits */
4938 - code const FAR *lcode; /* local strm->lencode */
4939 - code const FAR *dcode; /* local strm->distcode */
4940 - unsigned lmask; /* mask for first level of length codes */
4941 - unsigned dmask; /* mask for first level of distance codes */
4942 - code this; /* retrieved table entry */
4943 - unsigned op; /* code bits, operation, extra bits, or */
4944 - /* window position, window bytes to copy */
4945 - unsigned len; /* match length, unused bytes */
4946 - unsigned dist; /* match distance */
4947 - unsigned char FAR *from; /* where to copy match from */
4949 - /* copy state to local variables */
4950 - state = (struct inflate_state FAR *)strm->state;
4951 - in = strm->next_in - OFF;
4952 - last = in + (strm->avail_in - 5);
4953 - out = strm->next_out - OFF;
4954 - beg = out - (start - strm->avail_out);
4955 - end = out + (strm->avail_out - 257);
4956 -#ifdef INFLATE_STRICT
4957 - dmax = state->dmax;
4959 - wsize = state->wsize;
4960 - whave = state->whave;
4961 - write = state->write;
4962 - window = state->window;
4963 - hold = state->hold;
4964 - bits = state->bits;
4965 - lcode = state->lencode;
4966 - dcode = state->distcode;
4967 - lmask = (1U << state->lenbits) - 1;
4968 - dmask = (1U << state->distbits) - 1;
4970 - /* decode literals and length/distances until end-of-block or not enough
4971 - input data or output space */
4974 - hold += (unsigned long)(PUP(in)) << bits;
4976 - hold += (unsigned long)(PUP(in)) << bits;
4979 - this = lcode[hold & lmask];
4981 - op = (unsigned)(this.bits);
4984 - op = (unsigned)(this.op);
4985 - if (op == 0) { /* literal */
4986 - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
4987 - "inflate: literal '%c'\n" :
4988 - "inflate: literal 0x%02x\n", this.val));
4989 - PUP(out) = (unsigned char)(this.val);
4991 - else if (op & 16) { /* length base */
4992 - len = (unsigned)(this.val);
4993 - op &= 15; /* number of extra bits */
4996 - hold += (unsigned long)(PUP(in)) << bits;
4999 - len += (unsigned)hold & ((1U << op) - 1);
5003 - Tracevv((stderr, "inflate: length %u\n", len));
5005 - hold += (unsigned long)(PUP(in)) << bits;
5007 - hold += (unsigned long)(PUP(in)) << bits;
5010 - this = dcode[hold & dmask];
5012 - op = (unsigned)(this.bits);
5015 - op = (unsigned)(this.op);
5016 - if (op & 16) { /* distance base */
5017 - dist = (unsigned)(this.val);
5018 - op &= 15; /* number of extra bits */
5020 - hold += (unsigned long)(PUP(in)) << bits;
5023 - hold += (unsigned long)(PUP(in)) << bits;
5027 - dist += (unsigned)hold & ((1U << op) - 1);
5028 -#ifdef INFLATE_STRICT
5029 - if (dist > dmax) {
5030 - strm->msg = (char *)"invalid distance too far back";
5031 - state->mode = BAD;
5037 - Tracevv((stderr, "inflate: distance %u\n", dist));
5038 - op = (unsigned)(out - beg); /* max distance in output */
5039 - if (dist > op) { /* see if copy from window */
5040 - op = dist - op; /* distance back in window */
5042 - strm->msg = (char *)"invalid distance too far back";
5043 - state->mode = BAD;
5046 - from = window - OFF;
5047 - if (write == 0) { /* very common case */
5048 - from += wsize - op;
5049 - if (op < len) { /* some from window */
5052 - PUP(out) = PUP(from);
5054 - from = out - dist; /* rest from output */
5057 - else if (write < op) { /* wrap around window */
5058 - from += wsize + write - op;
5060 - if (op < len) { /* some from end of window */
5063 - PUP(out) = PUP(from);
5065 - from = window - OFF;
5066 - if (write < len) { /* some from start of window */
5070 - PUP(out) = PUP(from);
5072 - from = out - dist; /* rest from output */
5076 - else { /* contiguous in window */
5077 - from += write - op;
5078 - if (op < len) { /* some from window */
5081 - PUP(out) = PUP(from);
5083 - from = out - dist; /* rest from output */
5087 - PUP(out) = PUP(from);
5088 - PUP(out) = PUP(from);
5089 - PUP(out) = PUP(from);
5093 - PUP(out) = PUP(from);
5095 - PUP(out) = PUP(from);
5099 - from = out - dist; /* copy direct from output */
5100 - do { /* minimum length is three */
5101 - PUP(out) = PUP(from);
5102 - PUP(out) = PUP(from);
5103 - PUP(out) = PUP(from);
5105 - } while (len > 2);
5107 - PUP(out) = PUP(from);
5109 - PUP(out) = PUP(from);
5113 - else if ((op & 64) == 0) { /* 2nd level distance code */
5114 - this = dcode[this.val + (hold & ((1U << op) - 1))];
5118 - strm->msg = (char *)"invalid distance code";
5119 - state->mode = BAD;
5123 - else if ((op & 64) == 0) { /* 2nd level length code */
5124 - this = lcode[this.val + (hold & ((1U << op) - 1))];
5127 - else if (op & 32) { /* end-of-block */
5128 - Tracevv((stderr, "inflate: end of block\n"));
5129 - state->mode = TYPE;
5133 - strm->msg = (char *)"invalid literal/length code";
5134 - state->mode = BAD;
5137 - } while (in < last && out < end);
5139 - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
5143 - hold &= (1U << bits) - 1;
5145 - /* update state and return */
5146 - strm->next_in = in + OFF;
5147 - strm->next_out = out + OFF;
5148 - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
5149 - strm->avail_out = (unsigned)(out < end ?
5150 - 257 + (end - out) : 257 - (out - end));
5151 - state->hold = hold;
5152 - state->bits = bits;
5157 - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
5158 - - Using bit fields for code structure
5159 - - Different op definition to avoid & for extra bits (do & for table bits)
5160 - - Three separate decoding do-loops for direct, window, and write == 0
5161 - - Special case for distance > 1 copies to do overlapped load and store copy
5162 - - Explicit branch predictions (based on measured branch probabilities)
5163 - - Deferring match copy and interspersed it with decoding subsequent codes
5164 - - Swapping literal/length else
5165 - - Swapping window/direct else
5166 - - Larger unrolled copy loops (three is about right)
5167 - - Moving len -= 3 statement into middle of loop
5170 -#endif /* !ASMINF */
5171 diff -ruN RJaCGH.orig/src/inffast.h RJaCGH/src/inffast.h
5172 --- RJaCGH.orig/src/inffast.h 2009-03-04 12:51:20.000000000 +0100
5173 +++ RJaCGH/src/inffast.h 1970-01-01 01:00:00.000000000 +0100
5175 -/* inffast.h -- header to use inffast.c
5176 - * Copyright (C) 1995-2003 Mark Adler
5177 - * For conditions of distribution and use, see copyright notice in zlib.h
5180 -/* WARNING: this file should *not* be used by applications. It is
5181 - part of the implementation of the compression library and is
5182 - subject to change. Applications should only use zlib.h.
5185 -void inflate_fast OF((z_streamp strm, unsigned start));
5186 diff -ruN RJaCGH.orig/src/inffixed.h RJaCGH/src/inffixed.h
5187 --- RJaCGH.orig/src/inffixed.h 2009-03-04 12:51:20.000000000 +0100
5188 +++ RJaCGH/src/inffixed.h 1970-01-01 01:00:00.000000000 +0100
5190 - /* inffixed.h -- table for decoding fixed codes
5191 - * Generated automatically by makefixed().
5194 - /* WARNING: this file should *not* be used by applications. It
5195 - is part of the implementation of the compression library and
5196 - is subject to change. Applications should only use zlib.h.
5199 - static const code lenfix[512] = {
5200 - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
5201 - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
5202 - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
5203 - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
5204 - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
5205 - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
5206 - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
5207 - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
5208 - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
5209 - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
5210 - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
5211 - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
5212 - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
5213 - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
5214 - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
5215 - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
5216 - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
5217 - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
5218 - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
5219 - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
5220 - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
5221 - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
5222 - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
5223 - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
5224 - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
5225 - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
5226 - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
5227 - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
5228 - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
5229 - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
5230 - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
5231 - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
5232 - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
5233 - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
5234 - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
5235 - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
5236 - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
5237 - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
5238 - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
5239 - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
5240 - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
5241 - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
5242 - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
5243 - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
5244 - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
5245 - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
5246 - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
5247 - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
5248 - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
5249 - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
5250 - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
5251 - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
5252 - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
5253 - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
5254 - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
5255 - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
5256 - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
5257 - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
5258 - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
5259 - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
5260 - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
5261 - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
5262 - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
5263 - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
5264 - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
5265 - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
5266 - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
5267 - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
5268 - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
5269 - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
5270 - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
5271 - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
5272 - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
5276 - static const code distfix[32] = {
5277 - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
5278 - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
5279 - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
5280 - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
5281 - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
5282 - {22,5,193},{64,5,0}
5284 diff -ruN RJaCGH.orig/src/inflate.c RJaCGH/src/inflate.c
5285 --- RJaCGH.orig/src/inflate.c 2009-03-04 12:51:20.000000000 +0100
5286 +++ RJaCGH/src/inflate.c 1970-01-01 01:00:00.000000000 +0100
5288 -/* inflate.c -- zlib decompression
5289 - * Copyright (C) 1995-2005 Mark Adler
5290 - * For conditions of distribution and use, see copyright notice in zlib.h
5296 - * 1.2.beta0 24 Nov 2002
5297 - * - First version -- complete rewrite of inflate to simplify code, avoid
5298 - * creation of window when not needed, minimize use of window when it is
5299 - * needed, make inffast.c even faster, implement gzip decoding, and to
5300 - * improve code readability and style over the previous zlib inflate code
5302 - * 1.2.beta1 25 Nov 2002
5303 - * - Use pointers for available input and output checking in inffast.c
5304 - * - Remove input and output counters in inffast.c
5305 - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
5306 - * - Remove unnecessary second byte pull from length extra in inffast.c
5307 - * - Unroll direct copy to three copies per loop in inffast.c
5309 - * 1.2.beta2 4 Dec 2002
5310 - * - Change external routine names to reduce potential conflicts
5311 - * - Correct filename to inffixed.h for fixed tables in inflate.c
5312 - * - Make hbuf[] unsigned char to match parameter type in inflate.c
5313 - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
5314 - * to avoid negation problem on Alphas (64 bit) in inflate.c
5316 - * 1.2.beta3 22 Dec 2002
5317 - * - Add comments on state->bits assertion in inffast.c
5318 - * - Add comments on op field in inftrees.h
5319 - * - Fix bug in reuse of allocated window after inflateReset()
5320 - * - Remove bit fields--back to byte structure for speed
5321 - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
5322 - * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
5323 - * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
5324 - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
5325 - * - Use local copies of stream next and avail values, as well as local bit
5326 - * buffer and bit count in inflate()--for speed when inflate_fast() not used
5328 - * 1.2.beta4 1 Jan 2003
5329 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
5330 - * - Move a comment on output buffer sizes from inffast.c to inflate.c
5331 - * - Add comments in inffast.c to introduce the inflate_fast() routine
5332 - * - Rearrange window copies in inflate_fast() for speed and simplification
5333 - * - Unroll last copy for window match in inflate_fast()
5334 - * - Use local copies of window variables in inflate_fast() for speed
5335 - * - Pull out common write == 0 case for speed in inflate_fast()
5336 - * - Make op and len in inflate_fast() unsigned for consistency
5337 - * - Add FAR to lcode and dcode declarations in inflate_fast()
5338 - * - Simplified bad distance check in inflate_fast()
5339 - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
5340 - * source file infback.c to provide a call-back interface to inflate for
5341 - * programs like gzip and unzip -- uses window as output buffer to avoid
5344 - * 1.2.beta5 1 Jan 2003
5345 - * - Improved inflateBack() interface to allow the caller to provide initial
5347 - * - Fixed stored blocks bug in inflateBack()
5349 - * 1.2.beta6 4 Jan 2003
5350 - * - Added comments in inffast.c on effectiveness of POSTINC
5351 - * - Typecasting all around to reduce compiler warnings
5352 - * - Changed loops from while (1) or do {} while (1) to for (;;), again to
5353 - * make compilers happy
5354 - * - Changed type of window in inflateBackInit() to unsigned char *
5356 - * 1.2.beta7 27 Jan 2003
5357 - * - Changed many types to unsigned or unsigned short to avoid warnings
5358 - * - Added inflateCopy() function
5360 - * 1.2.0 9 Mar 2003
5361 - * - Changed inflateBack() interface to provide separate opaque descriptors
5362 - * for the in() and out() functions
5363 - * - Changed inflateBack() argument and in_func typedef to swap the length
5364 - * and buffer address return values for the input function
5365 - * - Check next_in and next_out for Z_NULL on entry to inflate()
5367 - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
5371 -#include "inftrees.h"
5372 -#include "inflate.h"
5373 -#include "inffast.h"
5376 -# ifndef BUILDFIXED
5377 -# define BUILDFIXED
5381 -/* function prototypes */
5382 -local void fixedtables OF((struct inflate_state FAR *state));
5383 -local int updatewindow OF((z_streamp strm, unsigned out));
5385 - void makefixed OF((void));
5387 -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
5390 -int ZEXPORT inflateReset(strm)
5393 - struct inflate_state FAR *state;
5395 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
5396 - state = (struct inflate_state FAR *)strm->state;
5397 - strm->total_in = strm->total_out = state->total = 0;
5398 - strm->msg = Z_NULL;
5399 - strm->adler = 1; /* to support ill-conceived Java test suite */
5400 - state->mode = HEAD;
5402 - state->havedict = 0;
5403 - state->dmax = 32768U;
5404 - state->head = Z_NULL;
5410 - state->lencode = state->distcode = state->next = state->codes;
5411 - Tracev((stderr, "inflate: reset\n"));
5415 -int ZEXPORT inflatePrime(strm, bits, value)
5420 - struct inflate_state FAR *state;
5422 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
5423 - state = (struct inflate_state FAR *)strm->state;
5424 - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
5425 - value &= (1L << bits) - 1;
5426 - state->hold += value << state->bits;
5427 - state->bits += bits;
5431 -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
5434 -const char *version;
5437 - struct inflate_state FAR *state;
5439 - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
5440 - stream_size != (int)(sizeof(z_stream)))
5441 - return Z_VERSION_ERROR;
5442 - if (strm == Z_NULL) return Z_STREAM_ERROR;
5443 - strm->msg = Z_NULL; /* in case we return an error */
5444 - if (strm->zalloc == (alloc_func)0) {
5445 - strm->zalloc = zcalloc;
5446 - strm->opaque = (voidpf)0;
5448 - if (strm->zfree == (free_func)0) strm->zfree = zcfree;
5449 - state = (struct inflate_state FAR *)
5450 - ZALLOC(strm, 1, sizeof(struct inflate_state));
5451 - if (state == Z_NULL) return Z_MEM_ERROR;
5452 - Tracev((stderr, "inflate: allocated\n"));
5453 - strm->state = (struct internal_state FAR *)state;
5454 - if (windowBits < 0) {
5456 - windowBits = -windowBits;
5459 - state->wrap = (windowBits >> 4) + 1;
5461 - if (windowBits < 48) windowBits &= 15;
5464 - if (windowBits < 8 || windowBits > 15) {
5465 - ZFREE(strm, state);
5466 - strm->state = Z_NULL;
5467 - return Z_STREAM_ERROR;
5469 - state->wbits = (unsigned)windowBits;
5470 - state->window = Z_NULL;
5471 - return inflateReset(strm);
5474 -int ZEXPORT inflateInit_(strm, version, stream_size)
5476 -const char *version;
5479 - return inflateInit2_(strm, DEF_WBITS, version, stream_size);
5483 - Return state with length and distance decoding tables and index sizes set to
5484 - fixed code decoding. Normally this returns fixed tables from inffixed.h.
5485 - If BUILDFIXED is defined, then instead this routine builds the tables the
5486 - first time it's called, and returns those tables the first time and
5487 - thereafter. This reduces the size of the code by about 2K bytes, in
5488 - exchange for a little execution time. However, BUILDFIXED should not be
5489 - used for threaded applications, since the rewriting of the tables and virgin
5490 - may not be thread-safe.
5492 -local void fixedtables(state)
5493 -struct inflate_state FAR *state;
5496 - static int virgin = 1;
5497 - static code *lenfix, *distfix;
5498 - static code fixed[544];
5500 - /* build fixed huffman tables if first call (may not be thread safe) */
5502 - unsigned sym, bits;
5503 - static code *next;
5505 - /* literal/length table */
5507 - while (sym < 144) state->lens[sym++] = 8;
5508 - while (sym < 256) state->lens[sym++] = 9;
5509 - while (sym < 280) state->lens[sym++] = 7;
5510 - while (sym < 288) state->lens[sym++] = 8;
5514 - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
5516 - /* distance table */
5518 - while (sym < 32) state->lens[sym++] = 5;
5521 - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
5523 - /* do this just once */
5526 -#else /* !BUILDFIXED */
5527 -# include "inffixed.h"
5528 -#endif /* BUILDFIXED */
5529 - state->lencode = lenfix;
5530 - state->lenbits = 9;
5531 - state->distcode = distfix;
5532 - state->distbits = 5;
5539 - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
5540 - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
5541 - those tables to stdout, which would be piped to inffixed.h. A small program
5542 - can simply call makefixed to do this:
5544 - void makefixed(void);
5552 - Then that can be linked with zlib built with MAKEFIXED defined and run:
5554 - a.out > inffixed.h
5558 - unsigned low, size;
5559 - struct inflate_state state;
5561 - fixedtables(&state);
5562 - puts(" /* inffixed.h -- table for decoding fixed codes");
5563 - puts(" * Generated automatically by makefixed().");
5566 - puts(" /* WARNING: this file should *not* be used by applications.");
5567 - puts(" It is part of the implementation of this library and is");
5568 - puts(" subject to change. Applications should only use zlib.h.");
5572 - printf(" static const code lenfix[%u] = {", size);
5575 - if ((low % 7) == 0) printf("\n ");
5576 - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
5577 - state.lencode[low].val);
5578 - if (++low == size) break;
5583 - printf("\n static const code distfix[%u] = {", size);
5586 - if ((low % 6) == 0) printf("\n ");
5587 - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
5588 - state.distcode[low].val);
5589 - if (++low == size) break;
5594 -#endif /* MAKEFIXED */
5597 - Update the window with the last wsize (normally 32K) bytes written before
5598 - returning. If window does not exist yet, create it. This is only called
5599 - when a window is already in use, or when output has been written during this
5600 - inflate call, but the end of the deflate stream has not been reached yet.
5601 - It is also called to create a window for dictionary data when a dictionary
5604 - Providing output buffers larger than 32K to inflate() should provide a speed
5605 - advantage, since only the last 32K of output is copied to the sliding window
5606 - upon return from inflate(), and since all distances after the first 32K of
5607 - output will fall in the output data, making match copies simpler and faster.
5608 - The advantage may be dependent on the size of the processor's data caches.
5610 -local int updatewindow(strm, out)
5614 - struct inflate_state FAR *state;
5615 - unsigned copy, dist;
5617 - state = (struct inflate_state FAR *)strm->state;
5619 - /* if it hasn't been done already, allocate space for the window */
5620 - if (state->window == Z_NULL) {
5621 - state->window = (unsigned char FAR *)
5622 - ZALLOC(strm, 1U << state->wbits,
5623 - sizeof(unsigned char));
5624 - if (state->window == Z_NULL) return 1;
5627 - /* if window not in use yet, initialize */
5628 - if (state->wsize == 0) {
5629 - state->wsize = 1U << state->wbits;
5634 - /* copy state->wsize or less output bytes into the circular window */
5635 - copy = out - strm->avail_out;
5636 - if (copy >= state->wsize) {
5637 - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
5639 - state->whave = state->wsize;
5642 - dist = state->wsize - state->write;
5643 - if (dist > copy) dist = copy;
5644 - zmemcpy(state->window + state->write, strm->next_out - copy, dist);
5647 - zmemcpy(state->window, strm->next_out - copy, copy);
5648 - state->write = copy;
5649 - state->whave = state->wsize;
5652 - state->write += dist;
5653 - if (state->write == state->wsize) state->write = 0;
5654 - if (state->whave < state->wsize) state->whave += dist;
5660 -/* Macros for inflate(): */
5662 -/* check function to use adler32() for zlib or crc32() for gzip */
5664 -# define UPDATE(check, buf, len) \
5665 - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
5667 -# define UPDATE(check, buf, len) adler32(check, buf, len)
5670 -/* check macros for header crc */
5672 -# define CRC2(check, word) \
5674 - hbuf[0] = (unsigned char)(word); \
5675 - hbuf[1] = (unsigned char)((word) >> 8); \
5676 - check = crc32(check, hbuf, 2); \
5679 -# define CRC4(check, word) \
5681 - hbuf[0] = (unsigned char)(word); \
5682 - hbuf[1] = (unsigned char)((word) >> 8); \
5683 - hbuf[2] = (unsigned char)((word) >> 16); \
5684 - hbuf[3] = (unsigned char)((word) >> 24); \
5685 - check = crc32(check, hbuf, 4); \
5689 -/* Load registers with state in inflate() for speed */
5692 - put = strm->next_out; \
5693 - left = strm->avail_out; \
5694 - next = strm->next_in; \
5695 - have = strm->avail_in; \
5696 - hold = state->hold; \
5697 - bits = state->bits; \
5700 -/* Restore state from registers in inflate() */
5701 -#define RESTORE() \
5703 - strm->next_out = put; \
5704 - strm->avail_out = left; \
5705 - strm->next_in = next; \
5706 - strm->avail_in = have; \
5707 - state->hold = hold; \
5708 - state->bits = bits; \
5711 -/* Clear the input bit accumulator */
5712 -#define INITBITS() \
5718 -/* Get a byte of input into the bit accumulator, or return from inflate()
5719 - if there is no input available. */
5720 -#define PULLBYTE() \
5722 - if (have == 0) goto inf_leave; \
5724 - hold += (unsigned long)(*next++) << bits; \
5728 -/* Assure that there are at least n bits in the bit accumulator. If there is
5729 - not enough available input to do that, then return from inflate(). */
5730 -#define NEEDBITS(n) \
5732 - while (bits < (unsigned)(n)) \
5736 -/* Return the low n bits of the bit accumulator (n < 16) */
5738 - ((unsigned)hold & ((1U << (n)) - 1))
5740 -/* Remove n bits from the bit accumulator */
5741 -#define DROPBITS(n) \
5744 - bits -= (unsigned)(n); \
5747 -/* Remove zero to seven bits as needed to go to a byte boundary */
5748 -#define BYTEBITS() \
5750 - hold >>= bits & 7; \
5751 - bits -= bits & 7; \
5754 -/* Reverse the bytes in a 32-bit value */
5755 -#define REVERSE(q) \
5756 - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
5757 - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
5760 - inflate() uses a state machine to process as much input data and generate as
5761 - much output data as possible before returning. The state machine is
5762 - structured roughly as follows:
5764 - for (;;) switch (state) {
5767 - if (not enough input data or output space to make progress)
5769 - ... make progress ...
5775 - so when inflate() is called again, the same case is attempted again, and
5776 - if the appropriate resources are provided, the machine proceeds to the
5777 - next state. The NEEDBITS() macro is usually the way the state evaluates
5778 - whether it can proceed or should return. NEEDBITS() does the return if
5779 - the requested bits are not available. The typical use of the BITS macros
5783 - ... do something with BITS(n) ...
5786 - where NEEDBITS(n) either returns from inflate() if there isn't enough
5787 - input left to load n bits into the accumulator, or it continues. BITS(n)
5788 - gives the low n bits in the accumulator. When done, DROPBITS(n) drops
5789 - the low n bits off the accumulator. INITBITS() clears the accumulator
5790 - and sets the number of available bits to zero. BYTEBITS() discards just
5791 - enough bits to put the accumulator on a byte boundary. After BYTEBITS()
5792 - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
5794 - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
5795 - if there is no input available. The decoding of variable length codes uses
5796 - PULLBYTE() directly in order to pull just enough bytes to decode the next
5797 - code, and no more.
5799 - Some states loop until they get enough input, making sure that enough
5800 - state information is maintained to continue the loop where it left off
5801 - if NEEDBITS() returns in the loop. For example, want, need, and keep
5802 - would all have to actually be part of the saved state in case NEEDBITS()
5806 - while (want < need) {
5808 - keep[want++] = BITS(n);
5814 - As shown above, if the next state is also the next case, then the break
5817 - A state may also return if there is not enough output space available to
5818 - complete that state. Those states are copying stored data, writing a
5819 - literal byte, and copying a matching string.
5821 - When returning, a "goto inf_leave" is used to update the total counters,
5822 - update the check value, and determine whether any progress has been made
5823 - during that inflate() call in order to return the proper return code.
5824 - Progress is defined as a change in either strm->avail_in or strm->avail_out.
5825 - When there is a window, goto inf_leave will update the window with the last
5826 - output written. If a goto inf_leave occurs in the middle of decompression
5827 - and there is no window currently, goto inf_leave will create one and copy
5828 - output to the window for the next call of inflate().
5830 - In this implementation, the flush parameter of inflate() only affects the
5831 - return code (per zlib.h). inflate() always writes as much as possible to
5832 - strm->next_out, given the space available and the provided input--the effect
5833 - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
5834 - the allocation of and copying into a sliding window until necessary, which
5835 - provides the effect documented in zlib.h for Z_FINISH when the entire input
5836 - stream available. So the only thing the flush parameter actually does is:
5837 - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
5838 - will return Z_BUF_ERROR if it has not reached the end of the stream.
5841 -int ZEXPORT inflate(strm, flush)
5845 - struct inflate_state FAR *state;
5846 - unsigned char FAR *next; /* next input */
5847 - unsigned char FAR *put; /* next output */
5848 - unsigned have, left; /* available input and output */
5849 - unsigned long hold; /* bit buffer */
5850 - unsigned bits; /* bits in bit buffer */
5851 - unsigned in, out; /* save starting available input and output */
5852 - unsigned copy; /* number of stored or match bytes to copy */
5853 - unsigned char FAR *from; /* where to copy match bytes from */
5854 - code this; /* current decoding table entry */
5855 - code last; /* parent table entry */
5856 - unsigned len; /* length to copy for repeats, bits to drop */
5857 - int ret; /* return code */
5859 - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
5861 - static const unsigned short order[19] = /* permutation of code lengths */
5862 - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
5864 - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
5865 - (strm->next_in == Z_NULL && strm->avail_in != 0))
5866 - return Z_STREAM_ERROR;
5868 - state = (struct inflate_state FAR *)strm->state;
5869 - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
5875 - switch (state->mode) {
5877 - if (state->wrap == 0) {
5878 - state->mode = TYPEDO;
5883 - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
5884 - state->check = crc32(0L, Z_NULL, 0);
5885 - CRC2(state->check, hold);
5887 - state->mode = FLAGS;
5890 - state->flags = 0; /* expect zlib header */
5891 - if (state->head != Z_NULL)
5892 - state->head->done = -1;
5893 - if (!(state->wrap & 1) || /* check if zlib header allowed */
5897 - ((BITS(8) << 8) + (hold >> 8)) % 31) {
5898 - strm->msg = (char *)"incorrect header check";
5899 - state->mode = BAD;
5902 - if (BITS(4) != Z_DEFLATED) {
5903 - strm->msg = (char *)"unknown compression method";
5904 - state->mode = BAD;
5908 - len = BITS(4) + 8;
5909 - if (len > state->wbits) {
5910 - strm->msg = (char *)"invalid window size";
5911 - state->mode = BAD;
5914 - state->dmax = 1U << len;
5915 - Tracev((stderr, "inflate: zlib header ok\n"));
5916 - strm->adler = state->check = adler32(0L, Z_NULL, 0);
5917 - state->mode = hold & 0x200 ? DICTID : TYPE;
5923 - state->flags = (int)(hold);
5924 - if ((state->flags & 0xff) != Z_DEFLATED) {
5925 - strm->msg = (char *)"unknown compression method";
5926 - state->mode = BAD;
5929 - if (state->flags & 0xe000) {
5930 - strm->msg = (char *)"unknown header flags set";
5931 - state->mode = BAD;
5934 - if (state->head != Z_NULL)
5935 - state->head->text = (int)((hold >> 8) & 1);
5936 - if (state->flags & 0x0200) CRC2(state->check, hold);
5938 - state->mode = TIME;
5941 - if (state->head != Z_NULL)
5942 - state->head->time = hold;
5943 - if (state->flags & 0x0200) CRC4(state->check, hold);
5948 - if (state->head != Z_NULL) {
5949 - state->head->xflags = (int)(hold & 0xff);
5950 - state->head->os = (int)(hold >> 8);
5952 - if (state->flags & 0x0200) CRC2(state->check, hold);
5954 - state->mode = EXLEN;
5956 - if (state->flags & 0x0400) {
5958 - state->length = (unsigned)(hold);
5959 - if (state->head != Z_NULL)
5960 - state->head->extra_len = (unsigned)hold;
5961 - if (state->flags & 0x0200) CRC2(state->check, hold);
5964 - else if (state->head != Z_NULL)
5965 - state->head->extra = Z_NULL;
5966 - state->mode = EXTRA;
5968 - if (state->flags & 0x0400) {
5969 - copy = state->length;
5970 - if (copy > have) copy = have;
5972 - if (state->head != Z_NULL &&
5973 - state->head->extra != Z_NULL) {
5974 - len = state->head->extra_len - state->length;
5975 - zmemcpy(state->head->extra + len, next,
5976 - len + copy > state->head->extra_max ?
5977 - state->head->extra_max - len : copy);
5979 - if (state->flags & 0x0200)
5980 - state->check = crc32(state->check, next, copy);
5983 - state->length -= copy;
5985 - if (state->length) goto inf_leave;
5987 - state->length = 0;
5988 - state->mode = NAME;
5990 - if (state->flags & 0x0800) {
5991 - if (have == 0) goto inf_leave;
5994 - len = (unsigned)(next[copy++]);
5995 - if (state->head != Z_NULL &&
5996 - state->head->name != Z_NULL &&
5997 - state->length < state->head->name_max)
5998 - state->head->name[state->length++] = len;
5999 - } while (len && copy < have);
6000 - if (state->flags & 0x0200)
6001 - state->check = crc32(state->check, next, copy);
6004 - if (len) goto inf_leave;
6006 - else if (state->head != Z_NULL)
6007 - state->head->name = Z_NULL;
6008 - state->length = 0;
6009 - state->mode = COMMENT;
6011 - if (state->flags & 0x1000) {
6012 - if (have == 0) goto inf_leave;
6015 - len = (unsigned)(next[copy++]);
6016 - if (state->head != Z_NULL &&
6017 - state->head->comment != Z_NULL &&
6018 - state->length < state->head->comm_max)
6019 - state->head->comment[state->length++] = len;
6020 - } while (len && copy < have);
6021 - if (state->flags & 0x0200)
6022 - state->check = crc32(state->check, next, copy);
6025 - if (len) goto inf_leave;
6027 - else if (state->head != Z_NULL)
6028 - state->head->comment = Z_NULL;
6029 - state->mode = HCRC;
6031 - if (state->flags & 0x0200) {
6033 - if (hold != (state->check & 0xffff)) {
6034 - strm->msg = (char *)"header crc mismatch";
6035 - state->mode = BAD;
6040 - if (state->head != Z_NULL) {
6041 - state->head->hcrc = (int)((state->flags >> 9) & 1);
6042 - state->head->done = 1;
6044 - strm->adler = state->check = crc32(0L, Z_NULL, 0);
6045 - state->mode = TYPE;
6050 - strm->adler = state->check = REVERSE(hold);
6052 - state->mode = DICT;
6054 - if (state->havedict == 0) {
6056 - return Z_NEED_DICT;
6058 - strm->adler = state->check = adler32(0L, Z_NULL, 0);
6059 - state->mode = TYPE;
6061 - if (flush == Z_BLOCK) goto inf_leave;
6063 - if (state->last) {
6065 - state->mode = CHECK;
6069 - state->last = BITS(1);
6071 - switch (BITS(2)) {
6072 - case 0: /* stored block */
6073 - Tracev((stderr, "inflate: stored block%s\n",
6074 - state->last ? " (last)" : ""));
6075 - state->mode = STORED;
6077 - case 1: /* fixed block */
6078 - fixedtables(state);
6079 - Tracev((stderr, "inflate: fixed codes block%s\n",
6080 - state->last ? " (last)" : ""));
6081 - state->mode = LEN; /* decode codes */
6083 - case 2: /* dynamic block */
6084 - Tracev((stderr, "inflate: dynamic codes block%s\n",
6085 - state->last ? " (last)" : ""));
6086 - state->mode = TABLE;
6089 - strm->msg = (char *)"invalid block type";
6090 - state->mode = BAD;
6095 - BYTEBITS(); /* go to byte boundary */
6097 - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
6098 - strm->msg = (char *)"invalid stored block lengths";
6099 - state->mode = BAD;
6102 - state->length = (unsigned)hold & 0xffff;
6103 - Tracev((stderr, "inflate: stored length %u\n",
6106 - state->mode = COPY;
6108 - copy = state->length;
6110 - if (copy > have) copy = have;
6111 - if (copy > left) copy = left;
6112 - if (copy == 0) goto inf_leave;
6113 - zmemcpy(put, next, copy);
6118 - state->length -= copy;
6121 - Tracev((stderr, "inflate: stored end\n"));
6122 - state->mode = TYPE;
6126 - state->nlen = BITS(5) + 257;
6128 - state->ndist = BITS(5) + 1;
6130 - state->ncode = BITS(4) + 4;
6132 -#ifndef PKZIP_BUG_WORKAROUND
6133 - if (state->nlen > 286 || state->ndist > 30) {
6134 - strm->msg = (char *)"too many length or distance symbols";
6135 - state->mode = BAD;
6139 - Tracev((stderr, "inflate: table sizes ok\n"));
6141 - state->mode = LENLENS;
6143 - while (state->have < state->ncode) {
6145 - state->lens[order[state->have++]] = (unsigned short)BITS(3);
6148 - while (state->have < 19)
6149 - state->lens[order[state->have++]] = 0;
6150 - state->next = state->codes;
6151 - state->lencode = (code const FAR *)(state->next);
6152 - state->lenbits = 7;
6153 - ret = inflate_table(CODES, state->lens, 19, &(state->next),
6154 - &(state->lenbits), state->work);
6156 - strm->msg = (char *)"invalid code lengths set";
6157 - state->mode = BAD;
6160 - Tracev((stderr, "inflate: code lengths ok\n"));
6162 - state->mode = CODELENS;
6164 - while (state->have < state->nlen + state->ndist) {
6166 - this = state->lencode[BITS(state->lenbits)];
6167 - if ((unsigned)(this.bits) <= bits) break;
6170 - if (this.val < 16) {
6171 - NEEDBITS(this.bits);
6172 - DROPBITS(this.bits);
6173 - state->lens[state->have++] = this.val;
6176 - if (this.val == 16) {
6177 - NEEDBITS(this.bits + 2);
6178 - DROPBITS(this.bits);
6179 - if (state->have == 0) {
6180 - strm->msg = (char *)"invalid bit length repeat";
6181 - state->mode = BAD;
6184 - len = state->lens[state->have - 1];
6185 - copy = 3 + BITS(2);
6188 - else if (this.val == 17) {
6189 - NEEDBITS(this.bits + 3);
6190 - DROPBITS(this.bits);
6192 - copy = 3 + BITS(3);
6196 - NEEDBITS(this.bits + 7);
6197 - DROPBITS(this.bits);
6199 - copy = 11 + BITS(7);
6202 - if (state->have + copy > state->nlen + state->ndist) {
6203 - strm->msg = (char *)"invalid bit length repeat";
6204 - state->mode = BAD;
6208 - state->lens[state->have++] = (unsigned short)len;
6212 - /* handle error breaks in while */
6213 - if (state->mode == BAD) break;
6215 - /* build code tables */
6216 - state->next = state->codes;
6217 - state->lencode = (code const FAR *)(state->next);
6218 - state->lenbits = 9;
6219 - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
6220 - &(state->lenbits), state->work);
6222 - strm->msg = (char *)"invalid literal/lengths set";
6223 - state->mode = BAD;
6226 - state->distcode = (code const FAR *)(state->next);
6227 - state->distbits = 6;
6228 - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
6229 - &(state->next), &(state->distbits), state->work);
6231 - strm->msg = (char *)"invalid distances set";
6232 - state->mode = BAD;
6235 - Tracev((stderr, "inflate: codes ok\n"));
6236 - state->mode = LEN;
6238 - if (have >= 6 && left >= 258) {
6240 - inflate_fast(strm, out);
6245 - this = state->lencode[BITS(state->lenbits)];
6246 - if ((unsigned)(this.bits) <= bits) break;
6249 - if (this.op && (this.op & 0xf0) == 0) {
6252 - this = state->lencode[last.val +
6253 - (BITS(last.bits + last.op) >> last.bits)];
6254 - if ((unsigned)(last.bits + this.bits) <= bits) break;
6257 - DROPBITS(last.bits);
6259 - DROPBITS(this.bits);
6260 - state->length = (unsigned)this.val;
6261 - if ((int)(this.op) == 0) {
6262 - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
6263 - "inflate: literal '%c'\n" :
6264 - "inflate: literal 0x%02x\n", this.val));
6265 - state->mode = LIT;
6268 - if (this.op & 32) {
6269 - Tracevv((stderr, "inflate: end of block\n"));
6270 - state->mode = TYPE;
6273 - if (this.op & 64) {
6274 - strm->msg = (char *)"invalid literal/length code";
6275 - state->mode = BAD;
6278 - state->extra = (unsigned)(this.op) & 15;
6279 - state->mode = LENEXT;
6281 - if (state->extra) {
6282 - NEEDBITS(state->extra);
6283 - state->length += BITS(state->extra);
6284 - DROPBITS(state->extra);
6286 - Tracevv((stderr, "inflate: length %u\n", state->length));
6287 - state->mode = DIST;
6290 - this = state->distcode[BITS(state->distbits)];
6291 - if ((unsigned)(this.bits) <= bits) break;
6294 - if ((this.op & 0xf0) == 0) {
6297 - this = state->distcode[last.val +
6298 - (BITS(last.bits + last.op) >> last.bits)];
6299 - if ((unsigned)(last.bits + this.bits) <= bits) break;
6302 - DROPBITS(last.bits);
6304 - DROPBITS(this.bits);
6305 - if (this.op & 64) {
6306 - strm->msg = (char *)"invalid distance code";
6307 - state->mode = BAD;
6310 - state->offset = (unsigned)this.val;
6311 - state->extra = (unsigned)(this.op) & 15;
6312 - state->mode = DISTEXT;
6314 - if (state->extra) {
6315 - NEEDBITS(state->extra);
6316 - state->offset += BITS(state->extra);
6317 - DROPBITS(state->extra);
6319 -#ifdef INFLATE_STRICT
6320 - if (state->offset > state->dmax) {
6321 - strm->msg = (char *)"invalid distance too far back";
6322 - state->mode = BAD;
6326 - if (state->offset > state->whave + out - left) {
6327 - strm->msg = (char *)"invalid distance too far back";
6328 - state->mode = BAD;
6331 - Tracevv((stderr, "inflate: distance %u\n", state->offset));
6332 - state->mode = MATCH;
6334 - if (left == 0) goto inf_leave;
6335 - copy = out - left;
6336 - if (state->offset > copy) { /* copy from window */
6337 - copy = state->offset - copy;
6338 - if (copy > state->write) {
6339 - copy -= state->write;
6340 - from = state->window + (state->wsize - copy);
6343 - from = state->window + (state->write - copy);
6344 - if (copy > state->length) copy = state->length;
6346 - else { /* copy from output */
6347 - from = put - state->offset;
6348 - copy = state->length;
6350 - if (copy > left) copy = left;
6352 - state->length -= copy;
6356 - if (state->length == 0) state->mode = LEN;
6359 - if (left == 0) goto inf_leave;
6360 - *put++ = (unsigned char)(state->length);
6362 - state->mode = LEN;
6365 - if (state->wrap) {
6368 - strm->total_out += out;
6369 - state->total += out;
6371 - strm->adler = state->check =
6372 - UPDATE(state->check, put - out, out);
6376 - state->flags ? hold :
6378 - REVERSE(hold)) != state->check) {
6379 - strm->msg = (char *)"incorrect data check";
6380 - state->mode = BAD;
6384 - Tracev((stderr, "inflate: check matches trailer\n"));
6387 - state->mode = LENGTH;
6389 - if (state->wrap && state->flags) {
6391 - if (hold != (state->total & 0xffffffffUL)) {
6392 - strm->msg = (char *)"incorrect length check";
6393 - state->mode = BAD;
6397 - Tracev((stderr, "inflate: length matches trailer\n"));
6400 - state->mode = DONE;
6402 - ret = Z_STREAM_END;
6405 - ret = Z_DATA_ERROR;
6408 - return Z_MEM_ERROR;
6411 - return Z_STREAM_ERROR;
6415 - Return from inflate(), updating the total counts and the check value.
6416 - If there was no progress during the inflate() call, return a buffer
6417 - error. Call updatewindow() to create and/or update the window state.
6418 - Note: a memory error from inflate() is non-recoverable.
6422 - if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
6423 - if (updatewindow(strm, out)) {
6424 - state->mode = MEM;
6425 - return Z_MEM_ERROR;
6427 - in -= strm->avail_in;
6428 - out -= strm->avail_out;
6429 - strm->total_in += in;
6430 - strm->total_out += out;
6431 - state->total += out;
6432 - if (state->wrap && out)
6433 - strm->adler = state->check =
6434 - UPDATE(state->check, strm->next_out - out, out);
6435 - strm->data_type = state->bits + (state->last ? 64 : 0) +
6436 - (state->mode == TYPE ? 128 : 0);
6437 - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
6438 - ret = Z_BUF_ERROR;
6442 -int ZEXPORT inflateEnd(strm)
6445 - struct inflate_state FAR *state;
6446 - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
6447 - return Z_STREAM_ERROR;
6448 - state = (struct inflate_state FAR *)strm->state;
6449 - if (state->window != Z_NULL) ZFREE(strm, state->window);
6450 - ZFREE(strm, strm->state);
6451 - strm->state = Z_NULL;
6452 - Tracev((stderr, "inflate: end\n"));
6456 -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
6458 -const Bytef *dictionary;
6461 - struct inflate_state FAR *state;
6465 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6466 - state = (struct inflate_state FAR *)strm->state;
6467 - if (state->wrap != 0 && state->mode != DICT)
6468 - return Z_STREAM_ERROR;
6470 - /* check for correct dictionary id */
6471 - if (state->mode == DICT) {
6472 - id = adler32(0L, Z_NULL, 0);
6473 - id = adler32(id, dictionary, dictLength);
6474 - if (id != state->check)
6475 - return Z_DATA_ERROR;
6478 - /* copy dictionary to window */
6479 - if (updatewindow(strm, strm->avail_out)) {
6480 - state->mode = MEM;
6481 - return Z_MEM_ERROR;
6483 - if (dictLength > state->wsize) {
6484 - zmemcpy(state->window, dictionary + dictLength - state->wsize,
6486 - state->whave = state->wsize;
6489 - zmemcpy(state->window + state->wsize - dictLength, dictionary,
6491 - state->whave = dictLength;
6493 - state->havedict = 1;
6494 - Tracev((stderr, "inflate: dictionary set\n"));
6498 -int ZEXPORT inflateGetHeader(strm, head)
6502 - struct inflate_state FAR *state;
6505 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6506 - state = (struct inflate_state FAR *)strm->state;
6507 - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
6509 - /* save header structure */
6510 - state->head = head;
6516 - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
6517 - or when out of input. When called, *have is the number of pattern bytes
6518 - found in order so far, in 0..3. On return *have is updated to the new
6519 - state. If on return *have equals four, then the pattern was found and the
6520 - return value is how many bytes were read including the last byte of the
6521 - pattern. If *have is less than four, then the pattern has not been found
6522 - yet and the return value is len. In the latter case, syncsearch() can be
6523 - called again with more data and the *have state. *have is initialized to
6524 - zero for the first call.
6526 -local unsigned syncsearch(have, buf, len)
6527 -unsigned FAR *have;
6528 -unsigned char FAR *buf;
6536 - while (next < len && got < 4) {
6537 - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
6539 - else if (buf[next])
6549 -int ZEXPORT inflateSync(strm)
6552 - unsigned len; /* number of bytes to look at or looked at */
6553 - unsigned long in, out; /* temporary to save total_in and total_out */
6554 - unsigned char buf[4]; /* to restore bit buffer to byte string */
6555 - struct inflate_state FAR *state;
6557 - /* check parameters */
6558 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6559 - state = (struct inflate_state FAR *)strm->state;
6560 - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
6562 - /* if first time, start search in bit buffer */
6563 - if (state->mode != SYNC) {
6564 - state->mode = SYNC;
6565 - state->hold <<= state->bits & 7;
6566 - state->bits -= state->bits & 7;
6568 - while (state->bits >= 8) {
6569 - buf[len++] = (unsigned char)(state->hold);
6570 - state->hold >>= 8;
6574 - syncsearch(&(state->have), buf, len);
6577 - /* search available input */
6578 - len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
6579 - strm->avail_in -= len;
6580 - strm->next_in += len;
6581 - strm->total_in += len;
6583 - /* return no joy or set up to restart inflate() on a new block */
6584 - if (state->have != 4) return Z_DATA_ERROR;
6585 - in = strm->total_in; out = strm->total_out;
6586 - inflateReset(strm);
6587 - strm->total_in = in; strm->total_out = out;
6588 - state->mode = TYPE;
6593 - Returns true if inflate is currently at the end of a block generated by
6594 - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
6595 - implementation to provide an additional safety check. PPP uses
6596 - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
6597 - block. When decompressing, PPP checks that at the end of input packet,
6598 - inflate is waiting for these length bytes.
6600 -int ZEXPORT inflateSyncPoint(strm)
6603 - struct inflate_state FAR *state;
6605 - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
6606 - state = (struct inflate_state FAR *)strm->state;
6607 - return state->mode == STORED && state->bits == 0;
6610 -int ZEXPORT inflateCopy(dest, source)
6614 - struct inflate_state FAR *state;
6615 - struct inflate_state FAR *copy;
6616 - unsigned char FAR *window;
6620 - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
6621 - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
6622 - return Z_STREAM_ERROR;
6623 - state = (struct inflate_state FAR *)source->state;
6625 - /* allocate space */
6626 - copy = (struct inflate_state FAR *)
6627 - ZALLOC(source, 1, sizeof(struct inflate_state));
6628 - if (copy == Z_NULL) return Z_MEM_ERROR;
6630 - if (state->window != Z_NULL) {
6631 - window = (unsigned char FAR *)
6632 - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
6633 - if (window == Z_NULL) {
6634 - ZFREE(source, copy);
6635 - return Z_MEM_ERROR;
6640 - zmemcpy(dest, source, sizeof(z_stream));
6641 - zmemcpy(copy, state, sizeof(struct inflate_state));
6642 - if (state->lencode >= state->codes &&
6643 - state->lencode <= state->codes + ENOUGH - 1) {
6644 - copy->lencode = copy->codes + (state->lencode - state->codes);
6645 - copy->distcode = copy->codes + (state->distcode - state->codes);
6647 - copy->next = copy->codes + (state->next - state->codes);
6648 - if (window != Z_NULL) {
6649 - wsize = 1U << state->wbits;
6650 - zmemcpy(window, state->window, wsize);
6652 - copy->window = window;
6653 - dest->state = (struct internal_state FAR *)copy;
6656 diff -ruN RJaCGH.orig/src/inflate.h RJaCGH/src/inflate.h
6657 --- RJaCGH.orig/src/inflate.h 2009-03-04 12:51:20.000000000 +0100
6658 +++ RJaCGH/src/inflate.h 1970-01-01 01:00:00.000000000 +0100
6660 -/* inflate.h -- internal inflate state definition
6661 - * Copyright (C) 1995-2004 Mark Adler
6662 - * For conditions of distribution and use, see copyright notice in zlib.h
6665 -/* WARNING: this file should *not* be used by applications. It is
6666 - part of the implementation of the compression library and is
6667 - subject to change. Applications should only use zlib.h.
6670 -/* define NO_GZIP when compiling if you want to disable gzip header and
6671 - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
6672 - the crc code when it is not needed. For shared libraries, gzip decoding
6673 - should be left enabled. */
6678 -/* Possible inflate modes between inflate() calls */
6680 - HEAD, /* i: waiting for magic header */
6681 - FLAGS, /* i: waiting for method and flags (gzip) */
6682 - TIME, /* i: waiting for modification time (gzip) */
6683 - OS, /* i: waiting for extra flags and operating system (gzip) */
6684 - EXLEN, /* i: waiting for extra length (gzip) */
6685 - EXTRA, /* i: waiting for extra bytes (gzip) */
6686 - NAME, /* i: waiting for end of file name (gzip) */
6687 - COMMENT, /* i: waiting for end of comment (gzip) */
6688 - HCRC, /* i: waiting for header crc (gzip) */
6689 - DICTID, /* i: waiting for dictionary check value */
6690 - DICT, /* waiting for inflateSetDictionary() call */
6691 - TYPE, /* i: waiting for type bits, including last-flag bit */
6692 - TYPEDO, /* i: same, but skip check to exit inflate on new block */
6693 - STORED, /* i: waiting for stored size (length and complement) */
6694 - COPY, /* i/o: waiting for input or output to copy stored block */
6695 - TABLE, /* i: waiting for dynamic block table lengths */
6696 - LENLENS, /* i: waiting for code length code lengths */
6697 - CODELENS, /* i: waiting for length/lit and distance code lengths */
6698 - LEN, /* i: waiting for length/lit code */
6699 - LENEXT, /* i: waiting for length extra bits */
6700 - DIST, /* i: waiting for distance code */
6701 - DISTEXT, /* i: waiting for distance extra bits */
6702 - MATCH, /* o: waiting for output space to copy string */
6703 - LIT, /* o: waiting for output space to write literal */
6704 - CHECK, /* i: waiting for 32-bit check value */
6705 - LENGTH, /* i: waiting for 32-bit length (gzip) */
6706 - DONE, /* finished check, done -- remain here until reset */
6707 - BAD, /* got a data error -- remain here until reset */
6708 - MEM, /* got an inflate() memory error -- remain here until reset */
6709 - SYNC /* looking for synchronization bytes to restart inflate() */
6713 - State transitions between above modes -
6715 - (most modes can go to the BAD or MEM mode -- not shown for clarity)
6718 - HEAD -> (gzip) or (zlib)
6719 - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
6720 - NAME -> COMMENT -> HCRC -> TYPE
6721 - (zlib) -> DICTID or TYPE
6722 - DICTID -> DICT -> TYPE
6723 - Read deflate blocks:
6724 - TYPE -> STORED or TABLE or LEN or CHECK
6725 - STORED -> COPY -> TYPE
6726 - TABLE -> LENLENS -> CODELENS -> LEN
6727 - Read deflate codes:
6728 - LEN -> LENEXT or LIT or TYPE
6729 - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
6732 - CHECK -> LENGTH -> DONE
6735 -/* state maintained between inflate() calls. Approximately 7K bytes. */
6736 -struct inflate_state {
6737 - inflate_mode mode; /* current inflate mode */
6738 - int last; /* true if processing last block */
6739 - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
6740 - int havedict; /* true if dictionary provided */
6741 - int flags; /* gzip header method and flags (0 if zlib) */
6742 - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
6743 - unsigned long check; /* protected copy of check value */
6744 - unsigned long total; /* protected copy of output count */
6745 - gz_headerp head; /* where to save gzip header information */
6746 - /* sliding window */
6747 - unsigned wbits; /* log base 2 of requested window size */
6748 - unsigned wsize; /* window size or zero if not using window */
6749 - unsigned whave; /* valid bytes in the window */
6750 - unsigned write; /* window write index */
6751 - unsigned char FAR *window; /* allocated sliding window, if needed */
6752 - /* bit accumulator */
6753 - unsigned long hold; /* input bit accumulator */
6754 - unsigned bits; /* number of bits in "in" */
6755 - /* for string and stored block copying */
6756 - unsigned length; /* literal or length of data to copy */
6757 - unsigned offset; /* distance back to copy string from */
6758 - /* for table and code decoding */
6759 - unsigned extra; /* extra bits needed */
6760 - /* fixed and dynamic code tables */
6761 - code const FAR *lencode; /* starting table for length/literal codes */
6762 - code const FAR *distcode; /* starting table for distance codes */
6763 - unsigned lenbits; /* index bits for lencode */
6764 - unsigned distbits; /* index bits for distcode */
6765 - /* dynamic table building */
6766 - unsigned ncode; /* number of code length code lengths */
6767 - unsigned nlen; /* number of length code lengths */
6768 - unsigned ndist; /* number of distance code lengths */
6769 - unsigned have; /* number of code lengths in lens[] */
6770 - code FAR *next; /* next available space in codes[] */
6771 - unsigned short lens[320]; /* temporary storage for code lengths */
6772 - unsigned short work[288]; /* work area for code table building */
6773 - code codes[ENOUGH]; /* space for code tables */
6775 diff -ruN RJaCGH.orig/src/inftrees.c RJaCGH/src/inftrees.c
6776 --- RJaCGH.orig/src/inftrees.c 2009-03-04 12:51:20.000000000 +0100
6777 +++ RJaCGH/src/inftrees.c 1970-01-01 01:00:00.000000000 +0100
6779 -/* inftrees.c -- generate Huffman trees for efficient decoding
6780 - * Copyright (C) 1995-2005 Mark Adler
6781 - * For conditions of distribution and use, see copyright notice in zlib.h
6785 -#include "inftrees.h"
6789 -const char inflate_copyright[] =
6790 - " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
6792 - If you use the zlib library in a product, an acknowledgment is welcome
6793 - in the documentation of your product. If for some reason you cannot
6794 - include such an acknowledgment, I would appreciate that you keep this
6795 - copyright string in the executable of your product.
6799 - Build a set of tables to decode the provided canonical Huffman code.
6800 - The code lengths are lens[0..codes-1]. The result starts at *table,
6801 - whose indices are 0..2^bits-1. work is a writable array of at least
6802 - lens shorts, which is used as a work area. type is the type of code
6803 - to be generated, CODES, LENS, or DISTS. On return, zero is success,
6804 - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
6805 - on return points to the next available entry's address. bits is the
6806 - requested root table index bits, and on return it is the actual root
6807 - table index bits. It will differ if the request is greater than the
6808 - longest code or if it is less than the shortest code.
6810 -int inflate_table(type, lens, codes, table, bits, work)
6812 -unsigned short FAR *lens;
6814 -code FAR * FAR *table;
6815 -unsigned FAR *bits;
6816 -unsigned short FAR *work;
6818 - unsigned len; /* a code's length in bits */
6819 - unsigned sym; /* index of code symbols */
6820 - unsigned min, max; /* minimum and maximum code lengths */
6821 - unsigned root; /* number of index bits for root table */
6822 - unsigned curr; /* number of index bits for current table */
6823 - unsigned drop; /* code bits to drop for sub-table */
6824 - int left; /* number of prefix codes available */
6825 - unsigned used; /* code entries in table used */
6826 - unsigned huff; /* Huffman code */
6827 - unsigned incr; /* for incrementing code, index */
6828 - unsigned fill; /* index for replicating entries */
6829 - unsigned low; /* low bits for current root entry */
6830 - unsigned mask; /* mask for low root bits */
6831 - code this; /* table entry for duplication */
6832 - code FAR *next; /* next available space in table */
6833 - const unsigned short FAR *base; /* base value table to use */
6834 - const unsigned short FAR *extra; /* extra bits table to use */
6835 - int end; /* use base and extra for symbol > end */
6836 - unsigned short count[MAXBITS+1]; /* number of codes of each length */
6837 - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
6838 - static const unsigned short lbase[31] = { /* Length codes 257..285 base */
6839 - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
6840 - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
6841 - static const unsigned short lext[31] = { /* Length codes 257..285 extra */
6842 - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
6843 - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
6844 - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
6845 - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
6846 - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
6847 - 8193, 12289, 16385, 24577, 0, 0};
6848 - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
6849 - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
6850 - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
6851 - 28, 28, 29, 29, 64, 64};
6854 - Process a set of code lengths to create a canonical Huffman code. The
6855 - code lengths are lens[0..codes-1]. Each length corresponds to the
6856 - symbols 0..codes-1. The Huffman code is generated by first sorting the
6857 - symbols by length from short to long, and retaining the symbol order
6858 - for codes with equal lengths. Then the code starts with all zero bits
6859 - for the first code of the shortest length, and the codes are integer
6860 - increments for the same length, and zeros are appended as the length
6861 - increases. For the deflate format, these bits are stored backwards
6862 - from their more natural integer increment ordering, and so when the
6863 - decoding tables are built in the large loop below, the integer codes
6864 - are incremented backwards.
6866 - This routine assumes, but does not check, that all of the entries in
6867 - lens[] are in the range 0..MAXBITS. The caller must assure this.
6868 - 1..MAXBITS is interpreted as that code length. zero means that that
6869 - symbol does not occur in this code.
6871 - The codes are sorted by computing a count of codes for each length,
6872 - creating from that a table of starting indices for each length in the
6873 - sorted table, and then entering the symbols in order in the sorted
6874 - table. The sorted table is work[], with that space being provided by
6877 - The length counts are used for other purposes as well, i.e. finding
6878 - the minimum and maximum length codes, determining if there are any
6879 - codes at all, checking for a valid set of lengths, and looking ahead
6880 - at length counts to determine sub-table sizes when building the
6884 - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
6885 - for (len = 0; len <= MAXBITS; len++)
6887 - for (sym = 0; sym < codes; sym++)
6888 - count[lens[sym]]++;
6890 - /* bound code lengths, force root to be within code lengths */
6892 - for (max = MAXBITS; max >= 1; max--)
6893 - if (count[max] != 0) break;
6894 - if (root > max) root = max;
6895 - if (max == 0) { /* no symbols to code at all */
6896 - this.op = (unsigned char)64; /* invalid code marker */
6897 - this.bits = (unsigned char)1;
6898 - this.val = (unsigned short)0;
6899 - *(*table)++ = this; /* make a table to force an error */
6900 - *(*table)++ = this;
6902 - return 0; /* no symbols, but wait for decoding to report error */
6904 - for (min = 1; min <= MAXBITS; min++)
6905 - if (count[min] != 0) break;
6906 - if (root < min) root = min;
6908 - /* check for an over-subscribed or incomplete set of lengths */
6910 - for (len = 1; len <= MAXBITS; len++) {
6912 - left -= count[len];
6913 - if (left < 0) return -1; /* over-subscribed */
6915 - if (left > 0 && (type == CODES || max != 1))
6916 - return -1; /* incomplete set */
6918 - /* generate offsets into symbol table for each length for sorting */
6920 - for (len = 1; len < MAXBITS; len++)
6921 - offs[len + 1] = offs[len] + count[len];
6923 - /* sort symbols by length, by symbol order within each length */
6924 - for (sym = 0; sym < codes; sym++)
6925 - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
6928 - Create and fill in decoding tables. In this loop, the table being
6929 - filled is at next and has curr index bits. The code being used is huff
6930 - with length len. That code is converted to an index by dropping drop
6931 - bits off of the bottom. For codes where len is less than drop + curr,
6932 - those top drop + curr - len bits are incremented through all values to
6933 - fill the table with replicated entries.
6935 - root is the number of index bits for the root table. When len exceeds
6936 - root, sub-tables are created pointed to by the root entry with an index
6937 - of the low root bits of huff. This is saved in low to check for when a
6938 - new sub-table should be started. drop is zero when the root table is
6939 - being filled, and drop is root when sub-tables are being filled.
6941 - When a new sub-table is needed, it is necessary to look ahead in the
6942 - code lengths to determine what size sub-table is needed. The length
6943 - counts are used for this, and so count[] is decremented as codes are
6944 - entered in the tables.
6946 - used keeps track of how many table entries have been allocated from the
6947 - provided *table space. It is checked when a LENS table is being made
6948 - against the space in *table, ENOUGH, minus the maximum space needed by
6949 - the worst case distance code, MAXD. This should never happen, but the
6950 - sufficiency of ENOUGH has not been proven exhaustively, hence the check.
6951 - This assumes that when type == LENS, bits == 9.
6953 - sym increments through all symbols, and the loop terminates when
6954 - all codes of length max, i.e. all codes, have been processed. This
6955 - routine permits incomplete codes, so another loop after this one fills
6956 - in the rest of the decoding tables with invalid code markers.
6959 - /* set up for code type */
6962 - base = extra = work; /* dummy value--not used */
6972 - default: /* DISTS */
6978 - /* initialize state for loop */
6979 - huff = 0; /* starting code */
6980 - sym = 0; /* starting code symbol */
6981 - len = min; /* starting code length */
6982 - next = *table; /* current table to fill in */
6983 - curr = root; /* current table index bits */
6984 - drop = 0; /* current bits to drop from code for index */
6985 - low = (unsigned)(-1); /* trigger new sub-table when len > root */
6986 - used = 1U << root; /* use root table entries */
6987 - mask = used - 1; /* mask for comparing low */
6989 - /* check available table space */
6990 - if (type == LENS && used >= ENOUGH - MAXD)
6993 - /* process all codes and make table entries */
6995 - /* create table entry */
6996 - this.bits = (unsigned char)(len - drop);
6997 - if ((int)(work[sym]) < end) {
6998 - this.op = (unsigned char)0;
6999 - this.val = work[sym];
7001 - else if ((int)(work[sym]) > end) {
7002 - this.op = (unsigned char)(extra[work[sym]]);
7003 - this.val = base[work[sym]];
7006 - this.op = (unsigned char)(32 + 64); /* end of block */
7010 - /* replicate for those indices with low len bits equal to huff */
7011 - incr = 1U << (len - drop);
7012 - fill = 1U << curr;
7013 - min = fill; /* save offset to next table */
7016 - next[(huff >> drop) + fill] = this;
7017 - } while (fill != 0);
7019 - /* backwards increment the len-bit code huff */
7020 - incr = 1U << (len - 1);
7021 - while (huff & incr)
7030 - /* go to next symbol, update count, len */
7032 - if (--(count[len]) == 0) {
7033 - if (len == max) break;
7034 - len = lens[work[sym]];
7037 - /* create new sub-table if needed */
7038 - if (len > root && (huff & mask) != low) {
7039 - /* if first time, transition to sub-tables */
7043 - /* increment past last table */
7044 - next += min; /* here min is 1 << curr */
7046 - /* determine length of next table */
7047 - curr = len - drop;
7048 - left = (int)(1 << curr);
7049 - while (curr + drop < max) {
7050 - left -= count[curr + drop];
7051 - if (left <= 0) break;
7056 - /* check for enough space */
7057 - used += 1U << curr;
7058 - if (type == LENS && used >= ENOUGH - MAXD)
7061 - /* point entry in root table to sub-table */
7062 - low = huff & mask;
7063 - (*table)[low].op = (unsigned char)curr;
7064 - (*table)[low].bits = (unsigned char)root;
7065 - (*table)[low].val = (unsigned short)(next - *table);
7070 - Fill in rest of table for incomplete codes. This loop is similar to the
7071 - loop above in incrementing huff for table indices. It is assumed that
7072 - len is equal to curr + drop, so there is no loop needed to increment
7073 - through high index bits. When the current sub-table is filled, the loop
7074 - drops back to the root table to fill in any remaining entries there.
7076 - this.op = (unsigned char)64; /* invalid code marker */
7077 - this.bits = (unsigned char)(len - drop);
7078 - this.val = (unsigned short)0;
7079 - while (huff != 0) {
7080 - /* when done with sub-table, drop back to root table */
7081 - if (drop != 0 && (huff & mask) != low) {
7085 - this.bits = (unsigned char)len;
7088 - /* put invalid code marker in table */
7089 - next[huff >> drop] = this;
7091 - /* backwards increment the len-bit code huff */
7092 - incr = 1U << (len - 1);
7093 - while (huff & incr)
7103 - /* set return parameters */
7108 diff -ruN RJaCGH.orig/src/inftrees.h RJaCGH/src/inftrees.h
7109 --- RJaCGH.orig/src/inftrees.h 2009-03-04 12:51:20.000000000 +0100
7110 +++ RJaCGH/src/inftrees.h 1970-01-01 01:00:00.000000000 +0100
7112 -/* inftrees.h -- header to use inftrees.c
7113 - * Copyright (C) 1995-2005 Mark Adler
7114 - * For conditions of distribution and use, see copyright notice in zlib.h
7117 -/* WARNING: this file should *not* be used by applications. It is
7118 - part of the implementation of the compression library and is
7119 - subject to change. Applications should only use zlib.h.
7122 -/* Structure for decoding tables. Each entry provides either the
7123 - information needed to do the operation requested by the code that
7124 - indexed that table entry, or it provides a pointer to another
7125 - table that indexes more bits of the code. op indicates whether
7126 - the entry is a pointer to another table, a literal, a length or
7127 - distance, an end-of-block, or an invalid code. For a table
7128 - pointer, the low four bits of op is the number of index bits of
7129 - that table. For a length or distance, the low four bits of op
7130 - is the number of extra bits to get after the code. bits is
7131 - the number of bits in this code or part of the code to drop off
7132 - of the bit buffer. val is the actual byte to output in the case
7133 - of a literal, the base length or distance, or the offset from
7134 - the current table to the next table. Each entry is four bytes. */
7136 - unsigned char op; /* operation, extra bits, table bits */
7137 - unsigned char bits; /* bits in this part of the code */
7138 - unsigned short val; /* offset in table or code value */
7141 -/* op values as set by inflate_table():
7142 - 00000000 - literal
7143 - 0000tttt - table link, tttt != 0 is the number of table index bits
7144 - 0001eeee - length or distance, eeee is the number of extra bits
7145 - 01100000 - end of block
7146 - 01000000 - invalid code
7149 -/* Maximum size of dynamic tree. The maximum found in a long but non-
7150 - exhaustive search was 1444 code structures (852 for length/literals
7151 - and 592 for distances, the latter actually the result of an
7152 - exhaustive search). The true maximum is not known, but the value
7153 - below is more than safe. */
7154 -#define ENOUGH 2048
7157 -/* Type of code to build for inftable() */
7164 -extern int inflate_table OF((codetype type, unsigned short FAR *lens,
7165 - unsigned codes, code FAR * FAR *table,
7166 - unsigned FAR *bits, unsigned short FAR *work));
7167 diff -ruN RJaCGH.orig/src/Makevars RJaCGH/src/Makevars
7168 --- RJaCGH.orig/src/Makevars 1970-01-01 01:00:00.000000000 +0100
7169 +++ RJaCGH/src/Makevars 2009-05-17 21:17:23.000000000 +0200
7172 \ No newline at end of file
7173 diff -ruN RJaCGH.orig/src/trees.c RJaCGH/src/trees.c
7174 --- RJaCGH.orig/src/trees.c 2009-03-04 12:51:20.000000000 +0100
7175 +++ RJaCGH/src/trees.c 1970-01-01 01:00:00.000000000 +0100
7177 -/* trees.c -- output deflated data using Huffman coding
7178 - * Copyright (C) 1995-2005 Jean-loup Gailly
7179 - * For conditions of distribution and use, see copyright notice in zlib.h
7185 - * The "deflation" process uses several Huffman trees. The more
7186 - * common source values are represented by shorter bit sequences.
7188 - * Each code tree is stored in a compressed form which is itself
7189 - * a Huffman encoding of the lengths of all the code strings (in
7190 - * ascending order by source values). The actual code strings are
7191 - * reconstructed from the lengths in the inflate process, as described
7192 - * in the deflate specification.
7196 - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
7197 - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
7199 - * Storer, James A.
7200 - * Data Compression: Methods and Theory, pp. 49-50.
7201 - * Computer Science Press, 1988. ISBN 0-7167-8156-5.
7204 - * Algorithms, p290.
7205 - * Addison-Wesley, 1983. ISBN 0-201-06672-6.
7210 -/* #define GEN_TREES_H */
7212 -#include "deflate.h"
7215 -# include <ctype.h>
7218 -/* ===========================================================================
7222 -#define MAX_BL_BITS 7
7223 -/* Bit length codes must not exceed MAX_BL_BITS bits */
7225 -#define END_BLOCK 256
7226 -/* end of block literal code */
7229 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */
7231 -#define REPZ_3_10 17
7232 -/* repeat a zero length 3-10 times (3 bits of repeat count) */
7234 -#define REPZ_11_138 18
7235 -/* repeat a zero length 11-138 times (7 bits of repeat count) */
7237 -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
7238 - = {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};
7240 -local const int extra_dbits[D_CODES] /* extra bits for each distance code */
7241 - = {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};
7243 -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
7244 - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
7246 -local const uch bl_order[BL_CODES]
7247 - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
7248 -/* The lengths of the bit length codes are sent in order of decreasing
7249 - * probability, to avoid transmitting the lengths for unused bit length codes.
7252 -#define Buf_size (8 * 2*sizeof(char))
7253 -/* Number of bits used within bi_buf. (bi_buf might be implemented on
7254 - * more than 16 bits on some systems.)
7257 -/* ===========================================================================
7258 - * Local data. These are initialized only once.
7261 -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
7263 -#if defined(GEN_TREES_H) || !defined(STDC)
7264 -/* non ANSI compilers may not accept trees.h */
7266 -local ct_data static_ltree[L_CODES+2];
7267 -/* The static literal tree. Since the bit lengths are imposed, there is no
7268 - * need for the L_CODES extra codes used during heap construction. However
7269 - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
7273 -local ct_data static_dtree[D_CODES];
7274 -/* The static distance tree. (Actually a trivial tree since all codes use
7278 -uch _dist_code[DIST_CODE_LEN];
7279 -/* Distance codes. The first 256 values correspond to the distances
7280 - * 3 .. 258, the last 256 values correspond to the top 8 bits of
7281 - * the 15 bit distances.
7284 -uch _length_code[MAX_MATCH-MIN_MATCH+1];
7285 -/* length code for each normalized match length (0 == MIN_MATCH) */
7287 -local int base_length[LENGTH_CODES];
7288 -/* First normalized length for each code (0 = MIN_MATCH) */
7290 -local int base_dist[D_CODES];
7291 -/* First normalized distance for each code (0 = distance of 1) */
7294 -# include "trees.h"
7295 -#endif /* GEN_TREES_H */
7297 -struct static_tree_desc_s {
7298 - const ct_data *static_tree; /* static tree or NULL */
7299 - const intf *extra_bits; /* extra bits for each code or NULL */
7300 - int extra_base; /* base index for extra_bits */
7301 - int elems; /* max number of elements in the tree */
7302 - int max_length; /* max bit length for the codes */
7305 -local static_tree_desc static_l_desc =
7306 -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
7308 -local static_tree_desc static_d_desc =
7309 -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
7311 -local static_tree_desc static_bl_desc =
7312 -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
7314 -/* ===========================================================================
7315 - * Local (static) routines in this file.
7318 -local void tr_static_init OF((void));
7319 -local void init_block OF((deflate_state *s));
7320 -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
7321 -local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
7322 -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
7323 -local void build_tree OF((deflate_state *s, tree_desc *desc));
7324 -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
7325 -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
7326 -local int build_bl_tree OF((deflate_state *s));
7327 -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
7329 -local void compress_block OF((deflate_state *s, ct_data *ltree,
7331 -local void set_data_type OF((deflate_state *s));
7332 -local unsigned bi_reverse OF((unsigned value, int length));
7333 -local void bi_windup OF((deflate_state *s));
7334 -local void bi_flush OF((deflate_state *s));
7335 -local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
7339 -local void gen_trees_header OF((void));
7343 -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
7344 - /* Send a code of the given tree. c and tree must not have side effects */
7347 -# define send_code(s, c, tree) \
7348 - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
7349 - send_bits(s, tree[c].Code, tree[c].Len); }
7352 -/* ===========================================================================
7353 - * Output a short LSB first on the stream.
7354 - * IN assertion: there is enough room in pendingBuf.
7356 -#define put_short(s, w) { \
7357 - put_byte(s, (uch)((w) & 0xff)); \
7358 - put_byte(s, (uch)((ush)(w) >> 8)); \
7361 -/* ===========================================================================
7362 - * Send a value on a given number of bits.
7363 - * IN assertion: length <= 16 and value fits in length bits.
7366 -local void send_bits OF((deflate_state *s, int value, int length));
7368 -local void send_bits(s, value, length)
7370 - int value; /* value to send */
7371 - int length; /* number of bits */
7373 - Tracevv((stderr," l %2d v %4x ", length, value));
7374 - Assert(length > 0 && length <= 15, "invalid length");
7375 - s->bits_sent += (ulg)length;
7377 - /* If not enough room in bi_buf, use (valid) bits from bi_buf and
7378 - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
7379 - * unused bits in value.
7381 - if (s->bi_valid > (int)Buf_size - length) {
7382 - s->bi_buf |= (value << s->bi_valid);
7383 - put_short(s, s->bi_buf);
7384 - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
7385 - s->bi_valid += length - Buf_size;
7387 - s->bi_buf |= value << s->bi_valid;
7388 - s->bi_valid += length;
7393 -#define send_bits(s, value, length) \
7394 -{ int len = length;\
7395 - if (s->bi_valid > (int)Buf_size - len) {\
7397 - s->bi_buf |= (val << s->bi_valid);\
7398 - put_short(s, s->bi_buf);\
7399 - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
7400 - s->bi_valid += len - Buf_size;\
7402 - s->bi_buf |= (value) << s->bi_valid;\
7403 - s->bi_valid += len;\
7409 -/* the arguments must not have side effects */
7411 -/* ===========================================================================
7412 - * Initialize the various 'constant' tables.
7414 -local void tr_static_init()
7416 -#if defined(GEN_TREES_H) || !defined(STDC)
7417 - static int static_init_done = 0;
7418 - int n; /* iterates over tree elements */
7419 - int bits; /* bit counter */
7420 - int length; /* length value */
7421 - int code; /* code value */
7422 - int dist; /* distance index */
7423 - ush bl_count[MAX_BITS+1];
7424 - /* number of codes at each bit length for an optimal tree */
7426 - if (static_init_done) return;
7428 - /* For some embedded targets, global variables are not initialized: */
7429 - static_l_desc.static_tree = static_ltree;
7430 - static_l_desc.extra_bits = extra_lbits;
7431 - static_d_desc.static_tree = static_dtree;
7432 - static_d_desc.extra_bits = extra_dbits;
7433 - static_bl_desc.extra_bits = extra_blbits;
7435 - /* Initialize the mapping length (0..255) -> length code (0..28) */
7437 - for (code = 0; code < LENGTH_CODES-1; code++) {
7438 - base_length[code] = length;
7439 - for (n = 0; n < (1<<extra_lbits[code]); n++) {
7440 - _length_code[length++] = (uch)code;
7443 - Assert (length == 256, "tr_static_init: length != 256");
7444 - /* Note that the length 255 (match length 258) can be represented
7445 - * in two different ways: code 284 + 5 bits or code 285, so we
7446 - * overwrite length_code[255] to use the best encoding:
7448 - _length_code[length-1] = (uch)code;
7450 - /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
7452 - for (code = 0 ; code < 16; code++) {
7453 - base_dist[code] = dist;
7454 - for (n = 0; n < (1<<extra_dbits[code]); n++) {
7455 - _dist_code[dist++] = (uch)code;
7458 - Assert (dist == 256, "tr_static_init: dist != 256");
7459 - dist >>= 7; /* from now on, all distances are divided by 128 */
7460 - for ( ; code < D_CODES; code++) {
7461 - base_dist[code] = dist << 7;
7462 - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
7463 - _dist_code[256 + dist++] = (uch)code;
7466 - Assert (dist == 256, "tr_static_init: 256+dist != 512");
7468 - /* Construct the codes of the static literal tree */
7469 - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
7471 - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
7472 - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
7473 - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
7474 - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
7475 - /* Codes 286 and 287 do not exist, but we must include them in the
7476 - * tree construction to get a canonical Huffman tree (longest code
7479 - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
7481 - /* The static distance tree is trivial: */
7482 - for (n = 0; n < D_CODES; n++) {
7483 - static_dtree[n].Len = 5;
7484 - static_dtree[n].Code = bi_reverse((unsigned)n, 5);
7486 - static_init_done = 1;
7488 -# ifdef GEN_TREES_H
7489 - gen_trees_header();
7491 -#endif /* defined(GEN_TREES_H) || !defined(STDC) */
7494 -/* ===========================================================================
7495 - * Genererate the file trees.h describing the static trees.
7499 -# include <stdio.h>
7502 -# define SEPARATOR(i, last, width) \
7503 - ((i) == (last)? "\n};\n\n" : \
7504 - ((i) % (width) == (width)-1 ? ",\n" : ", "))
7506 -void gen_trees_header()
7508 - FILE *header = fopen("trees.h", "w");
7511 - Assert (header != NULL, "Can't open trees.h");
7513 - "/* header created automatically with -DGEN_TREES_H */\n\n");
7515 - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
7516 - for (i = 0; i < L_CODES+2; i++) {
7517 - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
7518 - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
7521 - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
7522 - for (i = 0; i < D_CODES; i++) {
7523 - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
7524 - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
7527 - fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
7528 - for (i = 0; i < DIST_CODE_LEN; i++) {
7529 - fprintf(header, "%2u%s", _dist_code[i],
7530 - SEPARATOR(i, DIST_CODE_LEN-1, 20));
7533 - fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
7534 - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
7535 - fprintf(header, "%2u%s", _length_code[i],
7536 - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
7539 - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
7540 - for (i = 0; i < LENGTH_CODES; i++) {
7541 - fprintf(header, "%1u%s", base_length[i],
7542 - SEPARATOR(i, LENGTH_CODES-1, 20));
7545 - fprintf(header, "local const int base_dist[D_CODES] = {\n");
7546 - for (i = 0; i < D_CODES; i++) {
7547 - fprintf(header, "%5u%s", base_dist[i],
7548 - SEPARATOR(i, D_CODES-1, 10));
7553 -#endif /* GEN_TREES_H */
7555 -/* ===========================================================================
7556 - * Initialize the tree data structures for a new zlib stream.
7563 - s->l_desc.dyn_tree = s->dyn_ltree;
7564 - s->l_desc.stat_desc = &static_l_desc;
7566 - s->d_desc.dyn_tree = s->dyn_dtree;
7567 - s->d_desc.stat_desc = &static_d_desc;
7569 - s->bl_desc.dyn_tree = s->bl_tree;
7570 - s->bl_desc.stat_desc = &static_bl_desc;
7574 - s->last_eob_len = 8; /* enough lookahead for inflate */
7576 - s->compressed_len = 0L;
7577 - s->bits_sent = 0L;
7580 - /* Initialize the first block of the first file: */
7584 -/* ===========================================================================
7585 - * Initialize a new block.
7587 -local void init_block(s)
7590 - int n; /* iterates over tree elements */
7592 - /* Initialize the trees. */
7593 - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
7594 - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
7595 - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
7597 - s->dyn_ltree[END_BLOCK].Freq = 1;
7598 - s->opt_len = s->static_len = 0L;
7599 - s->last_lit = s->matches = 0;
7603 -/* Index within the heap array of least frequent node in the Huffman tree */
7606 -/* ===========================================================================
7607 - * Remove the smallest element from the heap and recreate the heap with
7608 - * one less element. Updates heap and heap_len.
7610 -#define pqremove(s, tree, top) \
7612 - top = s->heap[SMALLEST]; \
7613 - s->heap[SMALLEST] = s->heap[s->heap_len--]; \
7614 - pqdownheap(s, tree, SMALLEST); \
7617 -/* ===========================================================================
7618 - * Compares to subtrees, using the tree depth as tie breaker when
7619 - * the subtrees have equal frequency. This minimizes the worst case length.
7621 -#define smaller(tree, n, m, depth) \
7622 - (tree[n].Freq < tree[m].Freq || \
7623 - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
7625 -/* ===========================================================================
7626 - * Restore the heap property by moving down the tree starting at node k,
7627 - * exchanging a node with the smallest of its two sons if necessary, stopping
7628 - * when the heap property is re-established (each father smaller than its
7631 -local void pqdownheap(s, tree, k)
7633 - ct_data *tree; /* the tree to restore */
7634 - int k; /* node to move down */
7636 - int v = s->heap[k];
7637 - int j = k << 1; /* left son of k */
7638 - while (j <= s->heap_len) {
7639 - /* Set j to the smallest of the two sons: */
7640 - if (j < s->heap_len &&
7641 - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
7644 - /* Exit if v is smaller than both sons */
7645 - if (smaller(tree, v, s->heap[j], s->depth)) break;
7647 - /* Exchange v with the smallest son */
7648 - s->heap[k] = s->heap[j]; k = j;
7650 - /* And continue down the tree, setting j to the left son of k */
7656 -/* ===========================================================================
7657 - * Compute the optimal bit lengths for a tree and update the total bit length
7658 - * for the current block.
7659 - * IN assertion: the fields freq and dad are set, heap[heap_max] and
7660 - * above are the tree nodes sorted by increasing frequency.
7661 - * OUT assertions: the field len is set to the optimal bit length, the
7662 - * array bl_count contains the frequencies for each bit length.
7663 - * The length opt_len is updated; static_len is also updated if stree is
7666 -local void gen_bitlen(s, desc)
7668 - tree_desc *desc; /* the tree descriptor */
7670 - ct_data *tree = desc->dyn_tree;
7671 - int max_code = desc->max_code;
7672 - const ct_data *stree = desc->stat_desc->static_tree;
7673 - const intf *extra = desc->stat_desc->extra_bits;
7674 - int base = desc->stat_desc->extra_base;
7675 - int max_length = desc->stat_desc->max_length;
7676 - int h; /* heap index */
7677 - int n, m; /* iterate over the tree elements */
7678 - int bits; /* bit length */
7679 - int xbits; /* extra bits */
7680 - ush f; /* frequency */
7681 - int overflow = 0; /* number of elements with bit length too large */
7683 - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
7685 - /* In a first pass, compute the optimal bit lengths (which may
7686 - * overflow in the case of the bit length tree).
7688 - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
7690 - for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
7692 - bits = tree[tree[n].Dad].Len + 1;
7693 - if (bits > max_length) bits = max_length, overflow++;
7694 - tree[n].Len = (ush)bits;
7695 - /* We overwrite tree[n].Dad which is no longer needed */
7697 - if (n > max_code) continue; /* not a leaf node */
7699 - s->bl_count[bits]++;
7701 - if (n >= base) xbits = extra[n-base];
7703 - s->opt_len += (ulg)f * (bits + xbits);
7704 - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
7706 - if (overflow == 0) return;
7708 - Trace((stderr,"\nbit length overflow\n"));
7709 - /* This happens for example on obj2 and pic of the Calgary corpus */
7711 - /* Find the first bit length which could increase: */
7713 - bits = max_length-1;
7714 - while (s->bl_count[bits] == 0) bits--;
7715 - s->bl_count[bits]--; /* move one leaf down the tree */
7716 - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
7717 - s->bl_count[max_length]--;
7718 - /* The brother of the overflow item also moves one step up,
7719 - * but this does not affect bl_count[max_length]
7722 - } while (overflow > 0);
7724 - /* Now recompute all bit lengths, scanning in increasing frequency.
7725 - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
7726 - * lengths instead of fixing only the wrong ones. This idea is taken
7727 - * from 'ar' written by Haruhiko Okumura.)
7729 - for (bits = max_length; bits != 0; bits--) {
7730 - n = s->bl_count[bits];
7733 - if (m > max_code) continue;
7734 - if ((unsigned) tree[m].Len != (unsigned) bits) {
7735 - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
7736 - s->opt_len += ((long)bits - (long)tree[m].Len)
7737 - *(long)tree[m].Freq;
7738 - tree[m].Len = (ush)bits;
7745 -/* ===========================================================================
7746 - * Generate the codes for a given tree and bit counts (which need not be
7748 - * IN assertion: the array bl_count contains the bit length statistics for
7749 - * the given tree and the field len is set for all tree elements.
7750 - * OUT assertion: the field code is set for all tree elements of non
7751 - * zero code length.
7753 -local void gen_codes (tree, max_code, bl_count)
7754 - ct_data *tree; /* the tree to decorate */
7755 - int max_code; /* largest code with non zero frequency */
7756 - ushf *bl_count; /* number of codes at each bit length */
7758 - ush next_code[MAX_BITS+1]; /* next code value for each bit length */
7759 - ush code = 0; /* running code value */
7760 - int bits; /* bit index */
7761 - int n; /* code index */
7763 - /* The distribution counts are first used to generate the code values
7764 - * without bit reversal.
7766 - for (bits = 1; bits <= MAX_BITS; bits++) {
7767 - next_code[bits] = code = (code + bl_count[bits-1]) << 1;
7769 - /* Check that the bit counts in bl_count are consistent. The last code
7770 - * must be all ones.
7772 - Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
7773 - "inconsistent bit counts");
7774 - Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
7776 - for (n = 0; n <= max_code; n++) {
7777 - int len = tree[n].Len;
7778 - if (len == 0) continue;
7779 - /* Now reverse the bits */
7780 - tree[n].Code = bi_reverse(next_code[len]++, len);
7782 - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
7783 - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
7787 -/* ===========================================================================
7788 - * Construct one Huffman tree and assigns the code bit strings and lengths.
7789 - * Update the total bit length for the current block.
7790 - * IN assertion: the field freq is set for all tree elements.
7791 - * OUT assertions: the fields len and code are set to the optimal bit length
7792 - * and corresponding code. The length opt_len is updated; static_len is
7793 - * also updated if stree is not null. The field max_code is set.
7795 -local void build_tree(s, desc)
7797 - tree_desc *desc; /* the tree descriptor */
7799 - ct_data *tree = desc->dyn_tree;
7800 - const ct_data *stree = desc->stat_desc->static_tree;
7801 - int elems = desc->stat_desc->elems;
7802 - int n, m; /* iterate over heap elements */
7803 - int max_code = -1; /* largest code with non zero frequency */
7804 - int node; /* new node being created */
7806 - /* Construct the initial heap, with least frequent element in
7807 - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
7808 - * heap[0] is not used.
7810 - s->heap_len = 0, s->heap_max = HEAP_SIZE;
7812 - for (n = 0; n < elems; n++) {
7813 - if (tree[n].Freq != 0) {
7814 - s->heap[++(s->heap_len)] = max_code = n;
7821 - /* The pkzip format requires that at least one distance code exists,
7822 - * and that at least one bit should be sent even if there is only one
7823 - * possible code. So to avoid special checks later on we force at least
7824 - * two codes of non zero frequency.
7826 - while (s->heap_len < 2) {
7827 - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
7828 - tree[node].Freq = 1;
7829 - s->depth[node] = 0;
7830 - s->opt_len--; if (stree) s->static_len -= stree[node].Len;
7831 - /* node is 0 or 1 so it does not have extra bits */
7833 - desc->max_code = max_code;
7835 - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
7836 - * establish sub-heaps of increasing lengths:
7838 - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
7840 - /* Construct the Huffman tree by repeatedly combining the least two
7843 - node = elems; /* next internal node of the tree */
7845 - pqremove(s, tree, n); /* n = node of least frequency */
7846 - m = s->heap[SMALLEST]; /* m = node of next least frequency */
7848 - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
7849 - s->heap[--(s->heap_max)] = m;
7851 - /* Create a new node father of n and m */
7852 - tree[node].Freq = tree[n].Freq + tree[m].Freq;
7853 - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
7854 - s->depth[n] : s->depth[m]) + 1);
7855 - tree[n].Dad = tree[m].Dad = (ush)node;
7856 -#ifdef DUMP_BL_TREE
7857 - if (tree == s->bl_tree) {
7858 - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
7859 - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
7862 - /* and insert the new node in the heap */
7863 - s->heap[SMALLEST] = node++;
7864 - pqdownheap(s, tree, SMALLEST);
7866 - } while (s->heap_len >= 2);
7868 - s->heap[--(s->heap_max)] = s->heap[SMALLEST];
7870 - /* At this point, the fields freq and dad are set. We can now
7871 - * generate the bit lengths.
7873 - gen_bitlen(s, (tree_desc *)desc);
7875 - /* The field len is now set, we can generate the bit codes */
7876 - gen_codes ((ct_data *)tree, max_code, s->bl_count);
7879 -/* ===========================================================================
7880 - * Scan a literal or distance tree to determine the frequencies of the codes
7881 - * in the bit length tree.
7883 -local void scan_tree (s, tree, max_code)
7885 - ct_data *tree; /* the tree to be scanned */
7886 - int max_code; /* and its largest code of non zero frequency */
7888 - int n; /* iterates over all tree elements */
7889 - int prevlen = -1; /* last emitted length */
7890 - int curlen; /* length of current code */
7891 - int nextlen = tree[0].Len; /* length of next code */
7892 - int count = 0; /* repeat count of the current code */
7893 - int max_count = 7; /* max repeat count */
7894 - int min_count = 4; /* min repeat count */
7896 - if (nextlen == 0) max_count = 138, min_count = 3;
7897 - tree[max_code+1].Len = (ush)0xffff; /* guard */
7899 - for (n = 0; n <= max_code; n++) {
7900 - curlen = nextlen; nextlen = tree[n+1].Len;
7901 - if (++count < max_count && curlen == nextlen) {
7903 - } else if (count < min_count) {
7904 - s->bl_tree[curlen].Freq += count;
7905 - } else if (curlen != 0) {
7906 - if (curlen != prevlen) s->bl_tree[curlen].Freq++;
7907 - s->bl_tree[REP_3_6].Freq++;
7908 - } else if (count <= 10) {
7909 - s->bl_tree[REPZ_3_10].Freq++;
7911 - s->bl_tree[REPZ_11_138].Freq++;
7913 - count = 0; prevlen = curlen;
7914 - if (nextlen == 0) {
7915 - max_count = 138, min_count = 3;
7916 - } else if (curlen == nextlen) {
7917 - max_count = 6, min_count = 3;
7919 - max_count = 7, min_count = 4;
7924 -/* ===========================================================================
7925 - * Send a literal or distance tree in compressed form, using the codes in
7928 -local void send_tree (s, tree, max_code)
7930 - ct_data *tree; /* the tree to be scanned */
7931 - int max_code; /* and its largest code of non zero frequency */
7933 - int n; /* iterates over all tree elements */
7934 - int prevlen = -1; /* last emitted length */
7935 - int curlen; /* length of current code */
7936 - int nextlen = tree[0].Len; /* length of next code */
7937 - int count = 0; /* repeat count of the current code */
7938 - int max_count = 7; /* max repeat count */
7939 - int min_count = 4; /* min repeat count */
7941 - /* tree[max_code+1].Len = -1; */ /* guard already set */
7942 - if (nextlen == 0) max_count = 138, min_count = 3;
7944 - for (n = 0; n <= max_code; n++) {
7945 - curlen = nextlen; nextlen = tree[n+1].Len;
7946 - if (++count < max_count && curlen == nextlen) {
7948 - } else if (count < min_count) {
7949 - do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
7951 - } else if (curlen != 0) {
7952 - if (curlen != prevlen) {
7953 - send_code(s, curlen, s->bl_tree); count--;
7955 - Assert(count >= 3 && count <= 6, " 3_6?");
7956 - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
7958 - } else if (count <= 10) {
7959 - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
7962 - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
7964 - count = 0; prevlen = curlen;
7965 - if (nextlen == 0) {
7966 - max_count = 138, min_count = 3;
7967 - } else if (curlen == nextlen) {
7968 - max_count = 6, min_count = 3;
7970 - max_count = 7, min_count = 4;
7975 -/* ===========================================================================
7976 - * Construct the Huffman tree for the bit lengths and return the index in
7977 - * bl_order of the last bit length code to send.
7979 -local int build_bl_tree(s)
7982 - int max_blindex; /* index of last bit length code of non zero freq */
7984 - /* Determine the bit length frequencies for literal and distance trees */
7985 - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
7986 - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
7988 - /* Build the bit length tree: */
7989 - build_tree(s, (tree_desc *)(&(s->bl_desc)));
7990 - /* opt_len now includes the length of the tree representations, except
7991 - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
7994 - /* Determine the number of bit length codes to send. The pkzip format
7995 - * requires that at least 4 bit length codes be sent. (appnote.txt says
7996 - * 3 but the actual value used is 4.)
7998 - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
7999 - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
8001 - /* Update opt_len to include the bit length tree and counts */
8002 - s->opt_len += 3*(max_blindex+1) + 5+5+4;
8003 - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
8004 - s->opt_len, s->static_len));
8006 - return max_blindex;
8009 -/* ===========================================================================
8010 - * Send the header for a block using dynamic Huffman trees: the counts, the
8011 - * lengths of the bit length codes, the literal tree and the distance tree.
8012 - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
8014 -local void send_all_trees(s, lcodes, dcodes, blcodes)
8016 - int lcodes, dcodes, blcodes; /* number of codes for each tree */
8018 - int rank; /* index in bl_order */
8020 - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
8021 - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
8022 - "too many codes");
8023 - Tracev((stderr, "\nbl counts: "));
8024 - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
8025 - send_bits(s, dcodes-1, 5);
8026 - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
8027 - for (rank = 0; rank < blcodes; rank++) {
8028 - Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
8029 - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
8031 - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
8033 - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
8034 - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
8036 - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
8037 - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
8040 -/* ===========================================================================
8041 - * Send a stored block
8043 -void _tr_stored_block(s, buf, stored_len, eof)
8045 - charf *buf; /* input block */
8046 - ulg stored_len; /* length of input block */
8047 - int eof; /* true if this is the last block for a file */
8049 - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
8051 - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
8052 - s->compressed_len += (stored_len + 4) << 3;
8054 - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
8057 -/* ===========================================================================
8058 - * Send one empty static block to give enough lookahead for inflate.
8059 - * This takes 10 bits, of which 7 may remain in the bit buffer.
8060 - * The current inflate code requires 9 bits of lookahead. If the
8061 - * last two codes for the previous block (real code plus EOB) were coded
8062 - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
8063 - * the last real code. In this case we send two empty static blocks instead
8064 - * of one. (There are no problems if the previous block is stored or fixed.)
8065 - * To simplify the code, we assume the worst case of last real code encoded
8066 - * on one bit only.
8071 - send_bits(s, STATIC_TREES<<1, 3);
8072 - send_code(s, END_BLOCK, static_ltree);
8074 - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
8077 - /* Of the 10 bits for the empty block, we have already sent
8078 - * (10 - bi_valid) bits. The lookahead for the last real code (before
8079 - * the EOB of the previous block) was thus at least one plus the length
8080 - * of the EOB plus what we have just sent of the empty static block.
8082 - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
8083 - send_bits(s, STATIC_TREES<<1, 3);
8084 - send_code(s, END_BLOCK, static_ltree);
8086 - s->compressed_len += 10L;
8090 - s->last_eob_len = 7;
8093 -/* ===========================================================================
8094 - * Determine the best encoding for the current block: dynamic trees, static
8095 - * trees or store, and output the encoded block to the zip file.
8097 -void _tr_flush_block(s, buf, stored_len, eof)
8099 - charf *buf; /* input block, or NULL if too old */
8100 - ulg stored_len; /* length of input block */
8101 - int eof; /* true if this is the last block for a file */
8103 - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
8104 - int max_blindex = 0; /* index of last bit length code of non zero freq */
8106 - /* Build the Huffman trees unless a stored block is forced */
8107 - if (s->level > 0) {
8109 - /* Check if the file is binary or text */
8110 - if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
8113 - /* Construct the literal and distance trees */
8114 - build_tree(s, (tree_desc *)(&(s->l_desc)));
8115 - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
8118 - build_tree(s, (tree_desc *)(&(s->d_desc)));
8119 - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
8121 - /* At this point, opt_len and static_len are the total bit lengths of
8122 - * the compressed block data, excluding the tree representations.
8125 - /* Build the bit length tree for the above two trees, and get the index
8126 - * in bl_order of the last bit length code to send.
8128 - max_blindex = build_bl_tree(s);
8130 - /* Determine the best encoding. Compute the block lengths in bytes. */
8131 - opt_lenb = (s->opt_len+3+7)>>3;
8132 - static_lenb = (s->static_len+3+7)>>3;
8134 - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
8135 - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
8138 - if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
8141 - Assert(buf != (char*)0, "lost buf");
8142 - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
8145 -#ifdef FORCE_STORED
8146 - if (buf != (char*)0) { /* force stored block */
8148 - if (stored_len+4 <= opt_lenb && buf != (char*)0) {
8149 - /* 4: two words for the lengths */
8151 - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
8152 - * Otherwise we can't have processed more than WSIZE input bytes since
8153 - * the last block flush, because compression would have been
8154 - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
8155 - * transform a block into a stored block.
8157 - _tr_stored_block(s, buf, stored_len, eof);
8159 -#ifdef FORCE_STATIC
8160 - } else if (static_lenb >= 0) { /* force static trees */
8162 - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
8164 - send_bits(s, (STATIC_TREES<<1)+eof, 3);
8165 - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
8167 - s->compressed_len += 3 + s->static_len;
8170 - send_bits(s, (DYN_TREES<<1)+eof, 3);
8171 - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
8173 - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
8175 - s->compressed_len += 3 + s->opt_len;
8178 - Assert (s->compressed_len == s->bits_sent, "bad compressed size");
8179 - /* The above check is made mod 2^32, for files larger than 512 MB
8180 - * and uLong implemented on 32 bits.
8187 - s->compressed_len += 7; /* align on byte boundary */
8190 - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
8191 - s->compressed_len-7*eof));
8194 -/* ===========================================================================
8195 - * Save the match info and tally the frequency counts. Return true if
8196 - * the current block must be flushed.
8198 -int _tr_tally (s, dist, lc)
8200 - unsigned dist; /* distance of matched string */
8201 - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
8203 - s->d_buf[s->last_lit] = (ush)dist;
8204 - s->l_buf[s->last_lit++] = (uch)lc;
8206 - /* lc is the unmatched char */
8207 - s->dyn_ltree[lc].Freq++;
8210 - /* Here, lc is the match length - MIN_MATCH */
8211 - dist--; /* dist = match distance - 1 */
8212 - Assert((ush)dist < (ush)MAX_DIST(s) &&
8213 - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
8214 - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
8216 - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
8217 - s->dyn_dtree[d_code(dist)].Freq++;
8220 -#ifdef TRUNCATE_BLOCK
8221 - /* Try to guess if it is profitable to stop the current block here */
8222 - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
8223 - /* Compute an upper bound for the compressed length */
8224 - ulg out_length = (ulg)s->last_lit*8L;
8225 - ulg in_length = (ulg)((long)s->strstart - s->block_start);
8227 - for (dcode = 0; dcode < D_CODES; dcode++) {
8228 - out_length += (ulg)s->dyn_dtree[dcode].Freq *
8229 - (5L+extra_dbits[dcode]);
8232 - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
8233 - s->last_lit, in_length, out_length,
8234 - 100L - out_length*100L/in_length));
8235 - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
8238 - return (s->last_lit == s->lit_bufsize-1);
8239 - /* We avoid equality with lit_bufsize because of wraparound at 64K
8240 - * on 16 bit machines and because stored blocks are restricted to
8245 -/* ===========================================================================
8246 - * Send the block data compressed using the given Huffman trees
8248 -local void compress_block(s, ltree, dtree)
8250 - ct_data *ltree; /* literal tree */
8251 - ct_data *dtree; /* distance tree */
8253 - unsigned dist; /* distance of matched string */
8254 - int lc; /* match length or unmatched char (if dist == 0) */
8255 - unsigned lx = 0; /* running index in l_buf */
8256 - unsigned code; /* the code to send */
8257 - int extra; /* number of extra bits to send */
8259 - if (s->last_lit != 0) do {
8260 - dist = s->d_buf[lx];
8261 - lc = s->l_buf[lx++];
8263 - send_code(s, lc, ltree); /* send a literal byte */
8264 - Tracecv(isgraph(lc), (stderr," '%c' ", lc));
8266 - /* Here, lc is the match length - MIN_MATCH */
8267 - code = _length_code[lc];
8268 - send_code(s, code+LITERALS+1, ltree); /* send the length code */
8269 - extra = extra_lbits[code];
8271 - lc -= base_length[code];
8272 - send_bits(s, lc, extra); /* send the extra length bits */
8274 - dist--; /* dist is now the match distance - 1 */
8275 - code = d_code(dist);
8276 - Assert (code < D_CODES, "bad d_code");
8278 - send_code(s, code, dtree); /* send the distance code */
8279 - extra = extra_dbits[code];
8281 - dist -= base_dist[code];
8282 - send_bits(s, dist, extra); /* send the extra distance bits */
8284 - } /* literal or match pair ? */
8286 - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
8287 - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
8288 - "pendingBuf overflow");
8290 - } while (lx < s->last_lit);
8292 - send_code(s, END_BLOCK, ltree);
8293 - s->last_eob_len = ltree[END_BLOCK].Len;
8296 -/* ===========================================================================
8297 - * Set the data type to BINARY or TEXT, using a crude approximation:
8298 - * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
8299 - * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
8300 - * IN assertion: the fields Freq of dyn_ltree are set.
8302 -local void set_data_type(s)
8307 - for (n = 0; n < 9; n++)
8308 - if (s->dyn_ltree[n].Freq != 0)
8311 - for (n = 14; n < 32; n++)
8312 - if (s->dyn_ltree[n].Freq != 0)
8314 - s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
8317 -/* ===========================================================================
8318 - * Reverse the first len bits of a code, using straightforward code (a faster
8319 - * method would use a table)
8320 - * IN assertion: 1 <= len <= 15
8322 -local unsigned bi_reverse(code, len)
8323 - unsigned code; /* the value to invert */
8324 - int len; /* its bit length */
8326 - register unsigned res = 0;
8329 - code >>= 1, res <<= 1;
8330 - } while (--len > 0);
8334 -/* ===========================================================================
8335 - * Flush the bit buffer, keeping at most 7 bits in it.
8337 -local void bi_flush(s)
8340 - if (s->bi_valid == 16) {
8341 - put_short(s, s->bi_buf);
8344 - } else if (s->bi_valid >= 8) {
8345 - put_byte(s, (Byte)s->bi_buf);
8351 -/* ===========================================================================
8352 - * Flush the bit buffer and align the output on a byte boundary
8354 -local void bi_windup(s)
8357 - if (s->bi_valid > 8) {
8358 - put_short(s, s->bi_buf);
8359 - } else if (s->bi_valid > 0) {
8360 - put_byte(s, (Byte)s->bi_buf);
8365 - s->bits_sent = (s->bits_sent+7) & ~7;
8369 -/* ===========================================================================
8370 - * Copy a stored block, storing first the length and its
8371 - * one's complement if requested.
8373 -local void copy_block(s, buf, len, header)
8375 - charf *buf; /* the input data */
8376 - unsigned len; /* its length */
8377 - int header; /* true if block header must be written */
8379 - bi_windup(s); /* align on byte boundary */
8380 - s->last_eob_len = 8; /* enough lookahead for inflate */
8383 - put_short(s, (ush)len);
8384 - put_short(s, (ush)~len);
8386 - s->bits_sent += 2*16;
8390 - s->bits_sent += (ulg)len<<3;
8393 - put_byte(s, *buf++);
8396 diff -ruN RJaCGH.orig/src/trees.h RJaCGH/src/trees.h
8397 --- RJaCGH.orig/src/trees.h 2009-03-04 12:51:20.000000000 +0100
8398 +++ RJaCGH/src/trees.h 1970-01-01 01:00:00.000000000 +0100
8400 -/* header created automatically with -DGEN_TREES_H */
8402 -local const ct_data static_ltree[L_CODES+2] = {
8403 -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
8404 -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
8405 -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
8406 -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
8407 -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
8408 -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
8409 -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
8410 -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
8411 -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
8412 -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
8413 -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
8414 -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
8415 -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
8416 -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
8417 -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
8418 -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
8419 -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
8420 -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
8421 -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
8422 -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
8423 -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
8424 -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
8425 -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
8426 -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
8427 -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
8428 -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
8429 -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
8430 -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
8431 -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
8432 -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
8433 -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
8434 -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
8435 -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
8436 -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
8437 -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
8438 -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
8439 -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
8440 -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
8441 -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
8442 -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
8443 -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
8444 -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
8445 -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
8446 -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
8447 -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
8448 -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
8449 -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
8450 -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
8451 -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
8452 -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
8453 -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
8454 -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
8455 -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
8456 -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
8457 -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
8458 -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
8459 -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
8460 -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
8463 -local const ct_data static_dtree[D_CODES] = {
8464 -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
8465 -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
8466 -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
8467 -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
8468 -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
8469 -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
8472 -const uch _dist_code[DIST_CODE_LEN] = {
8473 - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
8474 - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
8475 -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
8476 -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
8477 -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
8478 -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
8479 -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8480 -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8481 -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
8482 -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
8483 -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
8484 -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
8485 -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
8486 -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
8487 -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8488 -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
8489 -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
8490 -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
8491 -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
8492 -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
8493 -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
8494 -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
8495 -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
8496 -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
8497 -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
8498 -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
8501 -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
8502 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
8503 -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
8504 -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
8505 -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
8506 -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
8507 -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
8508 -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8509 -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
8510 -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
8511 -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
8512 -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
8513 -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
8514 -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
8517 -local const int base_length[LENGTH_CODES] = {
8518 -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
8519 -64, 80, 96, 112, 128, 160, 192, 224, 0
8522 -local const int base_dist[D_CODES] = {
8523 - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
8524 - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
8525 - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
8528 diff -ruN RJaCGH.orig/src/uncompr.c RJaCGH/src/uncompr.c
8529 --- RJaCGH.orig/src/uncompr.c 2009-03-04 12:51:20.000000000 +0100
8530 +++ RJaCGH/src/uncompr.c 1970-01-01 01:00:00.000000000 +0100
8532 -/* uncompr.c -- decompress a memory buffer
8533 - * Copyright (C) 1995-2003 Jean-loup Gailly.
8534 - * For conditions of distribution and use, see copyright notice in zlib.h
8539 -#define ZLIB_INTERNAL
8542 -/* ===========================================================================
8543 - Decompresses the source buffer into the destination buffer. sourceLen is
8544 - the byte length of the source buffer. Upon entry, destLen is the total
8545 - size of the destination buffer, which must be large enough to hold the
8546 - entire uncompressed data. (The size of the uncompressed data must have
8547 - been saved previously by the compressor and transmitted to the decompressor
8548 - by some mechanism outside the scope of this compression library.)
8549 - Upon exit, destLen is the actual size of the compressed buffer.
8550 - This function can be used to decompress a whole file at once if the
8551 - input file is mmap'ed.
8553 - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
8554 - enough memory, Z_BUF_ERROR if there was not enough room in the output
8555 - buffer, or Z_DATA_ERROR if the input data was corrupted.
8557 -int ZEXPORT uncompress (dest, destLen, source, sourceLen)
8560 - const Bytef *source;
8566 - stream.next_in = (Bytef*)source;
8567 - stream.avail_in = (uInt)sourceLen;
8568 - /* Check for source > 64K on 16-bit machine: */
8569 - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
8571 - stream.next_out = dest;
8572 - stream.avail_out = (uInt)*destLen;
8573 - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
8575 - stream.zalloc = (alloc_func)0;
8576 - stream.zfree = (free_func)0;
8578 - err = inflateInit(&stream);
8579 - if (err != Z_OK) return err;
8581 - err = inflate(&stream, Z_FINISH);
8582 - if (err != Z_STREAM_END) {
8583 - inflateEnd(&stream);
8584 - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
8585 - return Z_DATA_ERROR;
8588 - *destLen = stream.total_out;
8590 - err = inflateEnd(&stream);
8593 diff -ruN RJaCGH.orig/src/zconf.h RJaCGH/src/zconf.h
8594 --- RJaCGH.orig/src/zconf.h 2009-03-04 12:51:20.000000000 +0100
8595 +++ RJaCGH/src/zconf.h 1970-01-01 01:00:00.000000000 +0100
8597 -/* zconf.h -- configuration of the zlib compression library
8598 - * Copyright (C) 1995-2005 Jean-loup Gailly.
8599 - * For conditions of distribution and use, see copyright notice in zlib.h
8608 - * If you *really* need a unique prefix for all types and library functions,
8609 - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
8612 -# define deflateInit_ z_deflateInit_
8613 -# define deflate z_deflate
8614 -# define deflateEnd z_deflateEnd
8615 -# define inflateInit_ z_inflateInit_
8616 -# define inflate z_inflate
8617 -# define inflateEnd z_inflateEnd
8618 -# define deflateInit2_ z_deflateInit2_
8619 -# define deflateSetDictionary z_deflateSetDictionary
8620 -# define deflateCopy z_deflateCopy
8621 -# define deflateReset z_deflateReset
8622 -# define deflateParams z_deflateParams
8623 -# define deflateBound z_deflateBound
8624 -# define deflatePrime z_deflatePrime
8625 -# define inflateInit2_ z_inflateInit2_
8626 -# define inflateSetDictionary z_inflateSetDictionary
8627 -# define inflateSync z_inflateSync
8628 -# define inflateSyncPoint z_inflateSyncPoint
8629 -# define inflateCopy z_inflateCopy
8630 -# define inflateReset z_inflateReset
8631 -# define inflateBack z_inflateBack
8632 -# define inflateBackEnd z_inflateBackEnd
8633 -# define compress z_compress
8634 -# define compress2 z_compress2
8635 -# define compressBound z_compressBound
8636 -# define uncompress z_uncompress
8637 -# define adler32 z_adler32
8638 -# define crc32 z_crc32
8639 -# define get_crc_table z_get_crc_table
8640 -# define zError z_zError
8642 -# define alloc_func z_alloc_func
8643 -# define free_func z_free_func
8644 -# define in_func z_in_func
8645 -# define out_func z_out_func
8646 -# define Byte z_Byte
8647 -# define uInt z_uInt
8648 -# define uLong z_uLong
8649 -# define Bytef z_Bytef
8650 -# define charf z_charf
8651 -# define intf z_intf
8652 -# define uIntf z_uIntf
8653 -# define uLongf z_uLongf
8654 -# define voidpf z_voidpf
8655 -# define voidp z_voidp
8658 -#if defined(__MSDOS__) && !defined(MSDOS)
8661 -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
8664 -#if defined(_WINDOWS) && !defined(WINDOWS)
8667 -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
8672 -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
8673 -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
8681 - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
8682 - * than 64k bytes at a time (needed on systems with 16-bit int).
8685 -# define MAXSEG_64K
8688 -# define UNALIGNED_OK
8691 -#ifdef __STDC_VERSION__
8695 -# if __STDC_VERSION__ >= 199901L
8701 -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
8704 -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
8707 -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
8710 -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
8714 -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
8719 -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
8720 -# define const /* note: need a more gentle solution here */
8724 -/* Some Mac compilers merge all .h files incorrectly: */
8725 -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
8726 -# define NO_DUMMY_DECL
8729 -/* Maximum value for memLevel in deflateInit2 */
8730 -#ifndef MAX_MEM_LEVEL
8732 -# define MAX_MEM_LEVEL 8
8734 -# define MAX_MEM_LEVEL 9
8738 -/* Maximum value for windowBits in deflateInit2 and inflateInit2.
8739 - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
8740 - * created by gzip. (Files created by minigzip can still be extracted by
8744 -# define MAX_WBITS 15 /* 32K LZ77 window */
8747 -/* The memory requirements for deflate are (in bytes):
8748 - (1 << (windowBits+2)) + (1 << (memLevel+9))
8749 - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
8750 - plus a few kilobytes for small objects. For example, if you want to reduce
8751 - the default memory requirements from 256K to 128K, compile with
8752 - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
8753 - Of course this will generally degrade compression (there's no free lunch).
8755 - The memory requirements for inflate are (in bytes) 1 << windowBits
8756 - that is, 32K for windowBits=15 (default value) plus a few kilobytes
8757 - for small objects.
8760 - /* Type declarations */
8762 -#ifndef OF /* function prototypes */
8764 -# define OF(args) args
8766 -# define OF(args) ()
8770 -/* The following definitions for FAR are needed only for MSDOS mixed
8771 - * model programming (small or medium model with some far allocations).
8772 - * This was tested only with MSC; for other MSDOS compilers you may have
8773 - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
8774 - * just define FAR to be empty.
8777 -# if defined(M_I86SM) || defined(M_I86MM)
8778 - /* MSC small or medium model */
8779 -# define SMALL_MEDIUM
8786 -# if (defined(__SMALL__) || defined(__MEDIUM__))
8787 - /* Turbo C small or medium model */
8788 -# define SMALL_MEDIUM
8789 -# ifdef __BORLANDC__
8797 -#if defined(WINDOWS) || defined(WIN32)
8798 - /* If building or using zlib as a DLL, define ZLIB_DLL.
8799 - * This is not mandatory, but it offers a little performance increase.
8802 -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
8803 -# ifdef ZLIB_INTERNAL
8804 -# define ZEXTERN extern __declspec(dllexport)
8806 -# define ZEXTERN extern __declspec(dllimport)
8809 -# endif /* ZLIB_DLL */
8810 - /* If building or using zlib with the WINAPI/WINAPIV calling convention,
8811 - * define ZLIB_WINAPI.
8812 - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
8814 -# ifdef ZLIB_WINAPI
8818 -# include <windows.h>
8819 - /* No need for _export, use ZLIB.DEF instead. */
8820 - /* For complete Windows compatibility, use WINAPI, not __stdcall. */
8821 -# define ZEXPORT WINAPI
8823 -# define ZEXPORTVA WINAPIV
8825 -# define ZEXPORTVA FAR CDECL
8830 -#if defined (__BEOS__)
8832 -# ifdef ZLIB_INTERNAL
8833 -# define ZEXPORT __declspec(dllexport)
8834 -# define ZEXPORTVA __declspec(dllexport)
8836 -# define ZEXPORT __declspec(dllimport)
8837 -# define ZEXPORTVA __declspec(dllimport)
8843 -# define ZEXTERN extern
8856 -#if !defined(__MACTYPES__)
8857 -typedef unsigned char Byte; /* 8 bits */
8859 -typedef unsigned int uInt; /* 16 bits or more */
8860 -typedef unsigned long uLong; /* 32 bits or more */
8862 -#ifdef SMALL_MEDIUM
8863 - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
8864 -# define Bytef Byte FAR
8866 - typedef Byte FAR Bytef;
8868 -typedef char FAR charf;
8869 -typedef int FAR intf;
8870 -typedef uInt FAR uIntf;
8871 -typedef uLong FAR uLongf;
8874 - typedef void const *voidpc;
8875 - typedef void FAR *voidpf;
8876 - typedef void *voidp;
8878 - typedef Byte const *voidpc;
8879 - typedef Byte FAR *voidpf;
8880 - typedef Byte *voidp;
8883 -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
8884 -# include <sys/types.h> /* for off_t */
8885 -# include <unistd.h> /* for SEEK_* and off_t */
8887 -# include <unixio.h> /* for off_t */
8889 -# define z_off_t off_t
8892 -# define SEEK_SET 0 /* Seek from beginning of file. */
8893 -# define SEEK_CUR 1 /* Seek from current position. */
8894 -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
8897 -# define z_off_t long
8900 -#if defined(__OS400__)
8901 -# define NO_vsnprintf
8904 -#if defined(__MVS__)
8905 -# define NO_vsnprintf
8911 -/* MVS linker does not support external names larger than 8 bytes */
8912 -#if defined(__MVS__)
8913 -# pragma map(deflateInit_,"DEIN")
8914 -# pragma map(deflateInit2_,"DEIN2")
8915 -# pragma map(deflateEnd,"DEEND")
8916 -# pragma map(deflateBound,"DEBND")
8917 -# pragma map(inflateInit_,"ININ")
8918 -# pragma map(inflateInit2_,"ININ2")
8919 -# pragma map(inflateEnd,"INEND")
8920 -# pragma map(inflateSync,"INSY")
8921 -# pragma map(inflateSetDictionary,"INSEDI")
8922 -# pragma map(compressBound,"CMBND")
8923 -# pragma map(inflate_table,"INTABL")
8924 -# pragma map(inflate_fast,"INFA")
8925 -# pragma map(inflate_copyright,"INCOPY")
8928 -#endif /* ZCONF_H */
8929 diff -ruN RJaCGH.orig/src/zconf.in.h RJaCGH/src/zconf.in.h
8930 --- RJaCGH.orig/src/zconf.in.h 2009-03-04 12:51:20.000000000 +0100
8931 +++ RJaCGH/src/zconf.in.h 1970-01-01 01:00:00.000000000 +0100
8933 -/* zconf.h -- configuration of the zlib compression library
8934 - * Copyright (C) 1995-2005 Jean-loup Gailly.
8935 - * For conditions of distribution and use, see copyright notice in zlib.h
8944 - * If you *really* need a unique prefix for all types and library functions,
8945 - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
8948 -# define deflateInit_ z_deflateInit_
8949 -# define deflate z_deflate
8950 -# define deflateEnd z_deflateEnd
8951 -# define inflateInit_ z_inflateInit_
8952 -# define inflate z_inflate
8953 -# define inflateEnd z_inflateEnd
8954 -# define deflateInit2_ z_deflateInit2_
8955 -# define deflateSetDictionary z_deflateSetDictionary
8956 -# define deflateCopy z_deflateCopy
8957 -# define deflateReset z_deflateReset
8958 -# define deflateParams z_deflateParams
8959 -# define deflateBound z_deflateBound
8960 -# define deflatePrime z_deflatePrime
8961 -# define inflateInit2_ z_inflateInit2_
8962 -# define inflateSetDictionary z_inflateSetDictionary
8963 -# define inflateSync z_inflateSync
8964 -# define inflateSyncPoint z_inflateSyncPoint
8965 -# define inflateCopy z_inflateCopy
8966 -# define inflateReset z_inflateReset
8967 -# define inflateBack z_inflateBack
8968 -# define inflateBackEnd z_inflateBackEnd
8969 -# define compress z_compress
8970 -# define compress2 z_compress2
8971 -# define compressBound z_compressBound
8972 -# define uncompress z_uncompress
8973 -# define adler32 z_adler32
8974 -# define crc32 z_crc32
8975 -# define get_crc_table z_get_crc_table
8976 -# define zError z_zError
8978 -# define alloc_func z_alloc_func
8979 -# define free_func z_free_func
8980 -# define in_func z_in_func
8981 -# define out_func z_out_func
8982 -# define Byte z_Byte
8983 -# define uInt z_uInt
8984 -# define uLong z_uLong
8985 -# define Bytef z_Bytef
8986 -# define charf z_charf
8987 -# define intf z_intf
8988 -# define uIntf z_uIntf
8989 -# define uLongf z_uLongf
8990 -# define voidpf z_voidpf
8991 -# define voidp z_voidp
8994 -#if defined(__MSDOS__) && !defined(MSDOS)
8997 -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
9000 -#if defined(_WINDOWS) && !defined(WINDOWS)
9003 -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
9008 -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
9009 -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
9017 - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
9018 - * than 64k bytes at a time (needed on systems with 16-bit int).
9021 -# define MAXSEG_64K
9024 -# define UNALIGNED_OK
9027 -#ifdef __STDC_VERSION__
9031 -# if __STDC_VERSION__ >= 199901L
9037 -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
9040 -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
9043 -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
9046 -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
9050 -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
9055 -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
9056 -# define const /* note: need a more gentle solution here */
9060 -/* Some Mac compilers merge all .h files incorrectly: */
9061 -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
9062 -# define NO_DUMMY_DECL
9065 -/* Maximum value for memLevel in deflateInit2 */
9066 -#ifndef MAX_MEM_LEVEL
9068 -# define MAX_MEM_LEVEL 8
9070 -# define MAX_MEM_LEVEL 9
9074 -/* Maximum value for windowBits in deflateInit2 and inflateInit2.
9075 - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
9076 - * created by gzip. (Files created by minigzip can still be extracted by
9080 -# define MAX_WBITS 15 /* 32K LZ77 window */
9083 -/* The memory requirements for deflate are (in bytes):
9084 - (1 << (windowBits+2)) + (1 << (memLevel+9))
9085 - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
9086 - plus a few kilobytes for small objects. For example, if you want to reduce
9087 - the default memory requirements from 256K to 128K, compile with
9088 - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
9089 - Of course this will generally degrade compression (there's no free lunch).
9091 - The memory requirements for inflate are (in bytes) 1 << windowBits
9092 - that is, 32K for windowBits=15 (default value) plus a few kilobytes
9093 - for small objects.
9096 - /* Type declarations */
9098 -#ifndef OF /* function prototypes */
9100 -# define OF(args) args
9102 -# define OF(args) ()
9106 -/* The following definitions for FAR are needed only for MSDOS mixed
9107 - * model programming (small or medium model with some far allocations).
9108 - * This was tested only with MSC; for other MSDOS compilers you may have
9109 - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
9110 - * just define FAR to be empty.
9113 -# if defined(M_I86SM) || defined(M_I86MM)
9114 - /* MSC small or medium model */
9115 -# define SMALL_MEDIUM
9122 -# if (defined(__SMALL__) || defined(__MEDIUM__))
9123 - /* Turbo C small or medium model */
9124 -# define SMALL_MEDIUM
9125 -# ifdef __BORLANDC__
9133 -#if defined(WINDOWS) || defined(WIN32)
9134 - /* If building or using zlib as a DLL, define ZLIB_DLL.
9135 - * This is not mandatory, but it offers a little performance increase.
9138 -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
9139 -# ifdef ZLIB_INTERNAL
9140 -# define ZEXTERN extern __declspec(dllexport)
9142 -# define ZEXTERN extern __declspec(dllimport)
9145 -# endif /* ZLIB_DLL */
9146 - /* If building or using zlib with the WINAPI/WINAPIV calling convention,
9147 - * define ZLIB_WINAPI.
9148 - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
9150 -# ifdef ZLIB_WINAPI
9154 -# include <windows.h>
9155 - /* No need for _export, use ZLIB.DEF instead. */
9156 - /* For complete Windows compatibility, use WINAPI, not __stdcall. */
9157 -# define ZEXPORT WINAPI
9159 -# define ZEXPORTVA WINAPIV
9161 -# define ZEXPORTVA FAR CDECL
9166 -#if defined (__BEOS__)
9168 -# ifdef ZLIB_INTERNAL
9169 -# define ZEXPORT __declspec(dllexport)
9170 -# define ZEXPORTVA __declspec(dllexport)
9172 -# define ZEXPORT __declspec(dllimport)
9173 -# define ZEXPORTVA __declspec(dllimport)
9179 -# define ZEXTERN extern
9192 -#if !defined(__MACTYPES__)
9193 -typedef unsigned char Byte; /* 8 bits */
9195 -typedef unsigned int uInt; /* 16 bits or more */
9196 -typedef unsigned long uLong; /* 32 bits or more */
9198 -#ifdef SMALL_MEDIUM
9199 - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
9200 -# define Bytef Byte FAR
9202 - typedef Byte FAR Bytef;
9204 -typedef char FAR charf;
9205 -typedef int FAR intf;
9206 -typedef uInt FAR uIntf;
9207 -typedef uLong FAR uLongf;
9210 - typedef void const *voidpc;
9211 - typedef void FAR *voidpf;
9212 - typedef void *voidp;
9214 - typedef Byte const *voidpc;
9215 - typedef Byte FAR *voidpf;
9216 - typedef Byte *voidp;
9219 -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
9220 -# include <sys/types.h> /* for off_t */
9221 -# include <unistd.h> /* for SEEK_* and off_t */
9223 -# include <unixio.h> /* for off_t */
9225 -# define z_off_t off_t
9228 -# define SEEK_SET 0 /* Seek from beginning of file. */
9229 -# define SEEK_CUR 1 /* Seek from current position. */
9230 -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
9233 -# define z_off_t long
9236 -#if defined(__OS400__)
9237 -# define NO_vsnprintf
9240 -#if defined(__MVS__)
9241 -# define NO_vsnprintf
9247 -/* MVS linker does not support external names larger than 8 bytes */
9248 -#if defined(__MVS__)
9249 -# pragma map(deflateInit_,"DEIN")
9250 -# pragma map(deflateInit2_,"DEIN2")
9251 -# pragma map(deflateEnd,"DEEND")
9252 -# pragma map(deflateBound,"DEBND")
9253 -# pragma map(inflateInit_,"ININ")
9254 -# pragma map(inflateInit2_,"ININ2")
9255 -# pragma map(inflateEnd,"INEND")
9256 -# pragma map(inflateSync,"INSY")
9257 -# pragma map(inflateSetDictionary,"INSEDI")
9258 -# pragma map(compressBound,"CMBND")
9259 -# pragma map(inflate_table,"INTABL")
9260 -# pragma map(inflate_fast,"INFA")
9261 -# pragma map(inflate_copyright,"INCOPY")
9264 -#endif /* ZCONF_H */
9265 diff -ruN RJaCGH.orig/src/zlib.h RJaCGH/src/zlib.h
9266 --- RJaCGH.orig/src/zlib.h 2009-03-04 12:51:20.000000000 +0100
9267 +++ RJaCGH/src/zlib.h 1970-01-01 01:00:00.000000000 +0100
9269 -/* zlib.h -- interface of the 'zlib' general purpose compression library
9270 - version 1.2.3, July 18th, 2005
9272 - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
9274 - This software is provided 'as-is', without any express or implied
9275 - warranty. In no event will the authors be held liable for any damages
9276 - arising from the use of this software.
9278 - Permission is granted to anyone to use this software for any purpose,
9279 - including commercial applications, and to alter it and redistribute it
9280 - freely, subject to the following restrictions:
9282 - 1. The origin of this software must not be misrepresented; you must not
9283 - claim that you wrote the original software. If you use this software
9284 - in a product, an acknowledgment in the product documentation would be
9285 - appreciated but is not required.
9286 - 2. Altered source versions must be plainly marked as such, and must not be
9287 - misrepresented as being the original software.
9288 - 3. This notice may not be removed or altered from any source distribution.
9290 - Jean-loup Gailly Mark Adler
9291 - jloup@gzip.org madler@alumni.caltech.edu
9294 - The data format used by the zlib library is described by RFCs (Request for
9295 - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
9296 - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
9308 -#define ZLIB_VERSION "1.2.3"
9309 -#define ZLIB_VERNUM 0x1230
9312 - The 'zlib' compression library provides in-memory compression and
9313 - decompression functions, including integrity checks of the uncompressed
9314 - data. This version of the library supports only one compression method
9315 - (deflation) but other algorithms will be added later and will have the same
9318 - Compression can be done in a single step if the buffers are large
9319 - enough (for example if an input file is mmap'ed), or can be done by
9320 - repeated calls of the compression function. In the latter case, the
9321 - application must provide more input and/or consume the output
9322 - (providing more output space) before each call.
9324 - The compressed data format used by default by the in-memory functions is
9325 - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
9326 - around a deflate stream, which is itself documented in RFC 1951.
9328 - The library also supports reading and writing files in gzip (.gz) format
9329 - with an interface similar to that of stdio using the functions that start
9330 - with "gz". The gzip format is different from the zlib format. gzip is a
9331 - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
9333 - This library can optionally read and write gzip streams in memory as well.
9335 - The zlib format was designed to be compact and fast for use in memory
9336 - and on communications channels. The gzip format was designed for single-
9337 - file compression on file systems, has a larger header than zlib to maintain
9338 - directory information, and uses a different, slower check method than zlib.
9340 - The library does not install any signal handler. The decoder checks
9341 - the consistency of the compressed data, so the library should never
9342 - crash even in case of corrupted input.
9345 -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
9346 -typedef void (*free_func) OF((voidpf opaque, voidpf address));
9348 -struct internal_state;
9350 -typedef struct z_stream_s {
9351 - Bytef *next_in; /* next input byte */
9352 - uInt avail_in; /* number of bytes available at next_in */
9353 - uLong total_in; /* total nb of input bytes read so far */
9355 - Bytef *next_out; /* next output byte should be put there */
9356 - uInt avail_out; /* remaining free space at next_out */
9357 - uLong total_out; /* total nb of bytes output so far */
9359 - char *msg; /* last error message, NULL if no error */
9360 - struct internal_state FAR *state; /* not visible by applications */
9362 - alloc_func zalloc; /* used to allocate the internal state */
9363 - free_func zfree; /* used to free the internal state */
9364 - voidpf opaque; /* private data object passed to zalloc and zfree */
9366 - int data_type; /* best guess about the data type: binary or text */
9367 - uLong adler; /* adler32 value of the uncompressed data */
9368 - uLong reserved; /* reserved for future use */
9371 -typedef z_stream FAR *z_streamp;
9374 - gzip header information passed to and from zlib routines. See RFC 1952
9375 - for more details on the meanings of these fields.
9377 -typedef struct gz_header_s {
9378 - int text; /* true if compressed data believed to be text */
9379 - uLong time; /* modification time */
9380 - int xflags; /* extra flags (not used when writing a gzip file) */
9381 - int os; /* operating system */
9382 - Bytef *extra; /* pointer to extra field or Z_NULL if none */
9383 - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
9384 - uInt extra_max; /* space at extra (only when reading header) */
9385 - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
9386 - uInt name_max; /* space at name (only when reading header) */
9387 - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
9388 - uInt comm_max; /* space at comment (only when reading header) */
9389 - int hcrc; /* true if there was or will be a header crc */
9390 - int done; /* true when done reading gzip header (not used
9391 - when writing a gzip file) */
9394 -typedef gz_header FAR *gz_headerp;
9397 - The application must update next_in and avail_in when avail_in has
9398 - dropped to zero. It must update next_out and avail_out when avail_out
9399 - has dropped to zero. The application must initialize zalloc, zfree and
9400 - opaque before calling the init function. All other fields are set by the
9401 - compression library and must not be updated by the application.
9403 - The opaque value provided by the application will be passed as the first
9404 - parameter for calls of zalloc and zfree. This can be useful for custom
9405 - memory management. The compression library attaches no meaning to the
9408 - zalloc must return Z_NULL if there is not enough memory for the object.
9409 - If zlib is used in a multi-threaded application, zalloc and zfree must be
9412 - On 16-bit systems, the functions zalloc and zfree must be able to allocate
9413 - exactly 65536 bytes, but will not be required to allocate more than this
9414 - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
9415 - pointers returned by zalloc for objects of exactly 65536 bytes *must*
9416 - have their offset normalized to zero. The default allocation function
9417 - provided by this library ensures this (see zutil.c). To reduce memory
9418 - requirements and avoid any allocation of 64K objects, at the expense of
9419 - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
9421 - The fields total_in and total_out can be used for statistics or
9422 - progress reports. After compression, total_in holds the total size of
9423 - the uncompressed data and may be saved for use in the decompressor
9424 - (particularly if the decompressor wants to decompress everything in
9430 -#define Z_NO_FLUSH 0
9431 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
9432 -#define Z_SYNC_FLUSH 2
9433 -#define Z_FULL_FLUSH 3
9436 -/* Allowed flush values; see deflate() and inflate() below for details */
9439 -#define Z_STREAM_END 1
9440 -#define Z_NEED_DICT 2
9441 -#define Z_ERRNO (-1)
9442 -#define Z_STREAM_ERROR (-2)
9443 -#define Z_DATA_ERROR (-3)
9444 -#define Z_MEM_ERROR (-4)
9445 -#define Z_BUF_ERROR (-5)
9446 -#define Z_VERSION_ERROR (-6)
9447 -/* Return codes for the compression/decompression functions. Negative
9448 - * values are errors, positive values are used for special but normal events.
9451 -#define Z_NO_COMPRESSION 0
9452 -#define Z_BEST_SPEED 1
9453 -#define Z_BEST_COMPRESSION 9
9454 -#define Z_DEFAULT_COMPRESSION (-1)
9455 -/* compression levels */
9457 -#define Z_FILTERED 1
9458 -#define Z_HUFFMAN_ONLY 2
9461 -#define Z_DEFAULT_STRATEGY 0
9462 -/* compression strategy; see deflateInit2() below for details */
9466 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
9467 -#define Z_UNKNOWN 2
9468 -/* Possible values of the data_type field (though see inflate()) */
9470 -#define Z_DEFLATED 8
9471 -/* The deflate compression method (the only one supported in this version) */
9473 -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
9475 -#define zlib_version zlibVersion()
9476 -/* for compatibility with versions < 1.0.2 */
9478 - /* basic functions */
9480 -ZEXTERN const char * ZEXPORT zlibVersion OF((void));
9481 -/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
9482 - If the first character differs, the library code actually used is
9483 - not compatible with the zlib.h header file used by the application.
9484 - This check is automatically made by deflateInit and inflateInit.
9488 -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
9490 - Initializes the internal stream state for compression. The fields
9491 - zalloc, zfree and opaque must be initialized before by the caller.
9492 - If zalloc and zfree are set to Z_NULL, deflateInit updates them to
9493 - use default allocation functions.
9495 - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
9496 - 1 gives best speed, 9 gives best compression, 0 gives no compression at
9497 - all (the input data is simply copied a block at a time).
9498 - Z_DEFAULT_COMPRESSION requests a default compromise between speed and
9499 - compression (currently equivalent to level 6).
9501 - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
9502 - enough memory, Z_STREAM_ERROR if level is not a valid compression level,
9503 - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
9504 - with the version assumed by the caller (ZLIB_VERSION).
9505 - msg is set to null if there is no error message. deflateInit does not
9506 - perform any compression: this will be done by deflate().
9510 -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
9512 - deflate compresses as much data as possible, and stops when the input
9513 - buffer becomes empty or the output buffer becomes full. It may introduce some
9514 - output latency (reading input without producing any output) except when
9517 - The detailed semantics are as follows. deflate performs one or both of the
9518 - following actions:
9520 - - Compress more input starting at next_in and update next_in and avail_in
9521 - accordingly. If not all input can be processed (because there is not
9522 - enough room in the output buffer), next_in and avail_in are updated and
9523 - processing will resume at this point for the next call of deflate().
9525 - - Provide more output starting at next_out and update next_out and avail_out
9526 - accordingly. This action is forced if the parameter flush is non zero.
9527 - Forcing flush frequently degrades the compression ratio, so this parameter
9528 - should be set only when necessary (in interactive applications).
9529 - Some output may be provided even if flush is not set.
9531 - Before the call of deflate(), the application should ensure that at least
9532 - one of the actions is possible, by providing more input and/or consuming
9533 - more output, and updating avail_in or avail_out accordingly; avail_out
9534 - should never be zero before the call. The application can consume the
9535 - compressed output when it wants, for example when the output buffer is full
9536 - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
9537 - and with zero avail_out, it must be called again after making room in the
9538 - output buffer because there might be more output pending.
9540 - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
9541 - decide how much data to accumualte before producing output, in order to
9542 - maximize compression.
9544 - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
9545 - flushed to the output buffer and the output is aligned on a byte boundary, so
9546 - that the decompressor can get all input data available so far. (In particular
9547 - avail_in is zero after the call if enough output space has been provided
9548 - before the call.) Flushing may degrade compression for some compression
9549 - algorithms and so it should be used only when necessary.
9551 - If flush is set to Z_FULL_FLUSH, all output is flushed as with
9552 - Z_SYNC_FLUSH, and the compression state is reset so that decompression can
9553 - restart from this point if previous compressed data has been damaged or if
9554 - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
9557 - If deflate returns with avail_out == 0, this function must be called again
9558 - with the same value of the flush parameter and more output space (updated
9559 - avail_out), until the flush is complete (deflate returns with non-zero
9560 - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
9561 - avail_out is greater than six to avoid repeated flush markers due to
9562 - avail_out == 0 on return.
9564 - If the parameter flush is set to Z_FINISH, pending input is processed,
9565 - pending output is flushed and deflate returns with Z_STREAM_END if there
9566 - was enough output space; if deflate returns with Z_OK, this function must be
9567 - called again with Z_FINISH and more output space (updated avail_out) but no
9568 - more input data, until it returns with Z_STREAM_END or an error. After
9569 - deflate has returned Z_STREAM_END, the only possible operations on the
9570 - stream are deflateReset or deflateEnd.
9572 - Z_FINISH can be used immediately after deflateInit if all the compression
9573 - is to be done in a single step. In this case, avail_out must be at least
9574 - the value returned by deflateBound (see below). If deflate does not return
9575 - Z_STREAM_END, then it must be called again as described above.
9577 - deflate() sets strm->adler to the adler32 checksum of all input read
9578 - so far (that is, total_in bytes).
9580 - deflate() may update strm->data_type if it can make a good guess about
9581 - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
9582 - binary. This field is only for information purposes and does not affect
9583 - the compression algorithm in any manner.
9585 - deflate() returns Z_OK if some progress has been made (more input
9586 - processed or more output produced), Z_STREAM_END if all input has been
9587 - consumed and all output has been produced (only when flush is set to
9588 - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
9589 - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
9590 - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
9591 - fatal, and deflate() can be called again with more input and more output
9592 - space to continue compressing.
9596 -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
9598 - All dynamically allocated data structures for this stream are freed.
9599 - This function discards any unprocessed input and does not flush any
9602 - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
9603 - stream state was inconsistent, Z_DATA_ERROR if the stream was freed
9604 - prematurely (some input or output was discarded). In the error case,
9605 - msg may be set but then points to a static string (which must not be
9611 -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
9613 - Initializes the internal stream state for decompression. The fields
9614 - next_in, avail_in, zalloc, zfree and opaque must be initialized before by
9615 - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
9616 - value depends on the compression method), inflateInit determines the
9617 - compression method from the zlib header and allocates all data structures
9618 - accordingly; otherwise the allocation will be deferred to the first call of
9619 - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
9620 - use default allocation functions.
9622 - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
9623 - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
9624 - version assumed by the caller. msg is set to null if there is no error
9625 - message. inflateInit does not perform any decompression apart from reading
9626 - the zlib header if present: this will be done by inflate(). (So next_in and
9627 - avail_in may be modified, but next_out and avail_out are unchanged.)
9631 -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
9633 - inflate decompresses as much data as possible, and stops when the input
9634 - buffer becomes empty or the output buffer becomes full. It may introduce
9635 - some output latency (reading input without producing any output) except when
9638 - The detailed semantics are as follows. inflate performs one or both of the
9639 - following actions:
9641 - - Decompress more input starting at next_in and update next_in and avail_in
9642 - accordingly. If not all input can be processed (because there is not
9643 - enough room in the output buffer), next_in is updated and processing
9644 - will resume at this point for the next call of inflate().
9646 - - Provide more output starting at next_out and update next_out and avail_out
9647 - accordingly. inflate() provides as much output as possible, until there
9648 - is no more input data or no more space in the output buffer (see below
9649 - about the flush parameter).
9651 - Before the call of inflate(), the application should ensure that at least
9652 - one of the actions is possible, by providing more input and/or consuming
9653 - more output, and updating the next_* and avail_* values accordingly.
9654 - The application can consume the uncompressed output when it wants, for
9655 - example when the output buffer is full (avail_out == 0), or after each
9656 - call of inflate(). If inflate returns Z_OK and with zero avail_out, it
9657 - must be called again after making room in the output buffer because there
9658 - might be more output pending.
9660 - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
9661 - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
9662 - output as possible to the output buffer. Z_BLOCK requests that inflate() stop
9663 - if and when it gets to the next deflate block boundary. When decoding the
9664 - zlib or gzip format, this will cause inflate() to return immediately after
9665 - the header and before the first block. When doing a raw inflate, inflate()
9666 - will go ahead and process the first block, and will return when it gets to
9667 - the end of that block, or when it runs out of data.
9669 - The Z_BLOCK option assists in appending to or combining deflate streams.
9670 - Also to assist in this, on return inflate() will set strm->data_type to the
9671 - number of unused bits in the last byte taken from strm->next_in, plus 64
9672 - if inflate() is currently decoding the last block in the deflate stream,
9673 - plus 128 if inflate() returned immediately after decoding an end-of-block
9674 - code or decoding the complete header up to just before the first byte of the
9675 - deflate stream. The end-of-block will not be indicated until all of the
9676 - uncompressed data from that block has been written to strm->next_out. The
9677 - number of unused bits may in general be greater than seven, except when
9678 - bit 7 of data_type is set, in which case the number of unused bits will be
9681 - inflate() should normally be called until it returns Z_STREAM_END or an
9682 - error. However if all decompression is to be performed in a single step
9683 - (a single call of inflate), the parameter flush should be set to
9684 - Z_FINISH. In this case all pending input is processed and all pending
9685 - output is flushed; avail_out must be large enough to hold all the
9686 - uncompressed data. (The size of the uncompressed data may have been saved
9687 - by the compressor for this purpose.) The next operation on this stream must
9688 - be inflateEnd to deallocate the decompression state. The use of Z_FINISH
9689 - is never required, but can be used to inform inflate that a faster approach
9690 - may be used for the single inflate() call.
9692 - In this implementation, inflate() always flushes as much output as
9693 - possible to the output buffer, and always uses the faster approach on the
9694 - first call. So the only effect of the flush parameter in this implementation
9695 - is on the return value of inflate(), as noted below, or when it returns early
9696 - because Z_BLOCK is used.
9698 - If a preset dictionary is needed after this call (see inflateSetDictionary
9699 - below), inflate sets strm->adler to the adler32 checksum of the dictionary
9700 - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
9701 - strm->adler to the adler32 checksum of all output produced so far (that is,
9702 - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
9703 - below. At the end of the stream, inflate() checks that its computed adler32
9704 - checksum is equal to that saved by the compressor and returns Z_STREAM_END
9705 - only if the checksum is correct.
9707 - inflate() will decompress and check either zlib-wrapped or gzip-wrapped
9708 - deflate data. The header type is detected automatically. Any information
9709 - contained in the gzip header is not retained, so applications that need that
9710 - information should instead use raw inflate, see inflateInit2() below, or
9711 - inflateBack() and perform their own processing of the gzip header and
9714 - inflate() returns Z_OK if some progress has been made (more input processed
9715 - or more output produced), Z_STREAM_END if the end of the compressed data has
9716 - been reached and all uncompressed output has been produced, Z_NEED_DICT if a
9717 - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
9718 - corrupted (input stream not conforming to the zlib format or incorrect check
9719 - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
9720 - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
9721 - Z_BUF_ERROR if no progress is possible or if there was not enough room in the
9722 - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
9723 - inflate() can be called again with more input and more output space to
9724 - continue decompressing. If Z_DATA_ERROR is returned, the application may then
9725 - call inflateSync() to look for a good compression block if a partial recovery
9726 - of the data is desired.
9730 -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
9732 - All dynamically allocated data structures for this stream are freed.
9733 - This function discards any unprocessed input and does not flush any
9736 - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
9737 - was inconsistent. In the error case, msg may be set but then points to a
9738 - static string (which must not be deallocated).
9741 - /* Advanced functions */
9744 - The following functions are needed only in some special applications.
9748 -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
9755 - This is another version of deflateInit with more compression options. The
9756 - fields next_in, zalloc, zfree and opaque must be initialized before by
9759 - The method parameter is the compression method. It must be Z_DEFLATED in
9760 - this version of the library.
9762 - The windowBits parameter is the base two logarithm of the window size
9763 - (the size of the history buffer). It should be in the range 8..15 for this
9764 - version of the library. Larger values of this parameter result in better
9765 - compression at the expense of memory usage. The default value is 15 if
9766 - deflateInit is used instead.
9768 - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
9769 - determines the window size. deflate() will then generate raw deflate data
9770 - with no zlib header or trailer, and will not compute an adler32 check value.
9772 - windowBits can also be greater than 15 for optional gzip encoding. Add
9773 - 16 to windowBits to write a simple gzip header and trailer around the
9774 - compressed data instead of a zlib wrapper. The gzip header will have no
9775 - file name, no extra data, no comment, no modification time (set to zero),
9776 - no header crc, and the operating system will be set to 255 (unknown). If a
9777 - gzip stream is being written, strm->adler is a crc32 instead of an adler32.
9779 - The memLevel parameter specifies how much memory should be allocated
9780 - for the internal compression state. memLevel=1 uses minimum memory but
9781 - is slow and reduces compression ratio; memLevel=9 uses maximum memory
9782 - for optimal speed. The default value is 8. See zconf.h for total memory
9783 - usage as a function of windowBits and memLevel.
9785 - The strategy parameter is used to tune the compression algorithm. Use the
9786 - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
9787 - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
9788 - string match), or Z_RLE to limit match distances to one (run-length
9789 - encoding). Filtered data consists mostly of small values with a somewhat
9790 - random distribution. In this case, the compression algorithm is tuned to
9791 - compress them better. The effect of Z_FILTERED is to force more Huffman
9792 - coding and less string matching; it is somewhat intermediate between
9793 - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
9794 - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
9795 - parameter only affects the compression ratio but not the correctness of the
9796 - compressed output even if it is not set appropriately. Z_FIXED prevents the
9797 - use of dynamic Huffman codes, allowing for a simpler decoder for special
9800 - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
9801 - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
9802 - method). msg is set to null if there is no error message. deflateInit2 does
9803 - not perform any compression: this will be done by deflate().
9806 -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
9807 - const Bytef *dictionary,
9808 - uInt dictLength));
9810 - Initializes the compression dictionary from the given byte sequence
9811 - without producing any compressed output. This function must be called
9812 - immediately after deflateInit, deflateInit2 or deflateReset, before any
9813 - call of deflate. The compressor and decompressor must use exactly the same
9814 - dictionary (see inflateSetDictionary).
9816 - The dictionary should consist of strings (byte sequences) that are likely
9817 - to be encountered later in the data to be compressed, with the most commonly
9818 - used strings preferably put towards the end of the dictionary. Using a
9819 - dictionary is most useful when the data to be compressed is short and can be
9820 - predicted with good accuracy; the data can then be compressed better than
9821 - with the default empty dictionary.
9823 - Depending on the size of the compression data structures selected by
9824 - deflateInit or deflateInit2, a part of the dictionary may in effect be
9825 - discarded, for example if the dictionary is larger than the window size in
9826 - deflate or deflate2. Thus the strings most likely to be useful should be
9827 - put at the end of the dictionary, not at the front. In addition, the
9828 - current implementation of deflate will use at most the window size minus
9829 - 262 bytes of the provided dictionary.
9831 - Upon return of this function, strm->adler is set to the adler32 value
9832 - of the dictionary; the decompressor may later use this value to determine
9833 - which dictionary has been used by the compressor. (The adler32 value
9834 - applies to the whole dictionary even if only a subset of the dictionary is
9835 - actually used by the compressor.) If a raw deflate was requested, then the
9836 - adler32 value is not computed and strm->adler is not set.
9838 - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
9839 - parameter is invalid (such as NULL dictionary) or the stream state is
9840 - inconsistent (for example if deflate has already been called for this stream
9841 - or if the compression method is bsort). deflateSetDictionary does not
9842 - perform any compression: this will be done by deflate().
9845 -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
9846 - z_streamp source));
9848 - Sets the destination stream as a complete copy of the source stream.
9850 - This function can be useful when several compression strategies will be
9851 - tried, for example when there are several ways of pre-processing the input
9852 - data with a filter. The streams that will be discarded should then be freed
9853 - by calling deflateEnd. Note that deflateCopy duplicates the internal
9854 - compression state which can be quite large, so this strategy is slow and
9855 - can consume lots of memory.
9857 - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
9858 - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
9859 - (such as zalloc being NULL). msg is left unchanged in both source and
9863 -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
9865 - This function is equivalent to deflateEnd followed by deflateInit,
9866 - but does not free and reallocate all the internal compression state.
9867 - The stream will keep the same compression level and any other attributes
9868 - that may have been set by deflateInit2.
9870 - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
9871 - stream state was inconsistent (such as zalloc or state being NULL).
9874 -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
9878 - Dynamically update the compression level and compression strategy. The
9879 - interpretation of level and strategy is as in deflateInit2. This can be
9880 - used to switch between compression and straight copy of the input data, or
9881 - to switch to a different kind of input data requiring a different
9882 - strategy. If the compression level is changed, the input available so far
9883 - is compressed with the old level (and may be flushed); the new level will
9884 - take effect only at the next call of deflate().
9886 - Before the call of deflateParams, the stream state must be set as for
9887 - a call of deflate(), since the currently available input may have to
9888 - be compressed and flushed. In particular, strm->avail_out must be non-zero.
9890 - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
9891 - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
9892 - if strm->avail_out was zero.
9895 -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
9901 - Fine tune deflate's internal compression parameters. This should only be
9902 - used by someone who understands the algorithm used by zlib's deflate for
9903 - searching for the best matching string, and even then only by the most
9904 - fanatic optimizer trying to squeeze out the last compressed bit for their
9905 - specific input data. Read the deflate.c source code for the meaning of the
9906 - max_lazy, good_length, nice_length, and max_chain parameters.
9908 - deflateTune() can be called after deflateInit() or deflateInit2(), and
9909 - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
9912 -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
9913 - uLong sourceLen));
9915 - deflateBound() returns an upper bound on the compressed size after
9916 - deflation of sourceLen bytes. It must be called after deflateInit()
9917 - or deflateInit2(). This would be used to allocate an output buffer
9918 - for deflation in a single pass, and so would be called before deflate().
9921 -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
9925 - deflatePrime() inserts bits in the deflate output stream. The intent
9926 - is that this function is used to start off the deflate output with the
9927 - bits leftover from a previous deflate stream when appending to it. As such,
9928 - this function can only be used for raw deflate, and must be used before the
9929 - first deflate() call after a deflateInit2() or deflateReset(). bits must be
9930 - less than or equal to 16, and that many of the least significant bits of
9931 - value will be inserted in the output.
9933 - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
9934 - stream state was inconsistent.
9937 -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
9938 - gz_headerp head));
9940 - deflateSetHeader() provides gzip header information for when a gzip
9941 - stream is requested by deflateInit2(). deflateSetHeader() may be called
9942 - after deflateInit2() or deflateReset() and before the first call of
9943 - deflate(). The text, time, os, extra field, name, and comment information
9944 - in the provided gz_header structure are written to the gzip header (xflag is
9945 - ignored -- the extra flags are set according to the compression level). The
9946 - caller must assure that, if not Z_NULL, name and comment are terminated with
9947 - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
9948 - available there. If hcrc is true, a gzip header crc is included. Note that
9949 - the current versions of the command-line version of gzip (up through version
9950 - 1.3.x) do not support header crc's, and will report that it is a "multi-part
9951 - gzip file" and give up.
9953 - If deflateSetHeader is not used, the default gzip header has text false,
9954 - the time set to zero, and os set to 255, with no extra, name, or comment
9955 - fields. The gzip header is returned to the default state by deflateReset().
9957 - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
9958 - stream state was inconsistent.
9962 -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
9965 - This is another version of inflateInit with an extra parameter. The
9966 - fields next_in, avail_in, zalloc, zfree and opaque must be initialized
9967 - before by the caller.
9969 - The windowBits parameter is the base two logarithm of the maximum window
9970 - size (the size of the history buffer). It should be in the range 8..15 for
9971 - this version of the library. The default value is 15 if inflateInit is used
9972 - instead. windowBits must be greater than or equal to the windowBits value
9973 - provided to deflateInit2() while compressing, or it must be equal to 15 if
9974 - deflateInit2() was not used. If a compressed stream with a larger window
9975 - size is given as input, inflate() will return with the error code
9976 - Z_DATA_ERROR instead of trying to allocate a larger window.
9978 - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
9979 - determines the window size. inflate() will then process raw deflate data,
9980 - not looking for a zlib or gzip header, not generating a check value, and not
9981 - looking for any check values for comparison at the end of the stream. This
9982 - is for use with other formats that use the deflate compressed data format
9983 - such as zip. Those formats provide their own check values. If a custom
9984 - format is developed using the raw deflate format for compressed data, it is
9985 - recommended that a check value such as an adler32 or a crc32 be applied to
9986 - the uncompressed data as is done in the zlib, gzip, and zip formats. For
9987 - most applications, the zlib format should be used as is. Note that comments
9988 - above on the use in deflateInit2() applies to the magnitude of windowBits.
9990 - windowBits can also be greater than 15 for optional gzip decoding. Add
9991 - 32 to windowBits to enable zlib and gzip decoding with automatic header
9992 - detection, or add 16 to decode only the gzip format (the zlib format will
9993 - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
9994 - a crc32 instead of an adler32.
9996 - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
9997 - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
9998 - is set to null if there is no error message. inflateInit2 does not perform
9999 - any decompression apart from reading the zlib header if present: this will
10000 - be done by inflate(). (So next_in and avail_in may be modified, but next_out
10001 - and avail_out are unchanged.)
10004 -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
10005 - const Bytef *dictionary,
10006 - uInt dictLength));
10008 - Initializes the decompression dictionary from the given uncompressed byte
10009 - sequence. This function must be called immediately after a call of inflate,
10010 - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
10011 - can be determined from the adler32 value returned by that call of inflate.
10012 - The compressor and decompressor must use exactly the same dictionary (see
10013 - deflateSetDictionary). For raw inflate, this function can be called
10014 - immediately after inflateInit2() or inflateReset() and before any call of
10015 - inflate() to set the dictionary. The application must insure that the
10016 - dictionary that was used for compression is provided.
10018 - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
10019 - parameter is invalid (such as NULL dictionary) or the stream state is
10020 - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
10021 - expected one (incorrect adler32 value). inflateSetDictionary does not
10022 - perform any decompression: this will be done by subsequent calls of
10026 -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
10028 - Skips invalid compressed data until a full flush point (see above the
10029 - description of deflate with Z_FULL_FLUSH) can be found, or until all
10030 - available input is skipped. No output is provided.
10032 - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
10033 - if no more input was provided, Z_DATA_ERROR if no flush point has been found,
10034 - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
10035 - case, the application may save the current current value of total_in which
10036 - indicates where valid compressed data was found. In the error case, the
10037 - application may repeatedly call inflateSync, providing more input each time,
10038 - until success or end of the input data.
10041 -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
10042 - z_streamp source));
10044 - Sets the destination stream as a complete copy of the source stream.
10046 - This function can be useful when randomly accessing a large stream. The
10047 - first pass through the stream can periodically record the inflate state,
10048 - allowing restarting inflate at those points when randomly accessing the
10051 - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
10052 - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
10053 - (such as zalloc being NULL). msg is left unchanged in both source and
10057 -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
10059 - This function is equivalent to inflateEnd followed by inflateInit,
10060 - but does not free and reallocate all the internal decompression state.
10061 - The stream will keep attributes that may have been set by inflateInit2.
10063 - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
10064 - stream state was inconsistent (such as zalloc or state being NULL).
10067 -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
10071 - This function inserts bits in the inflate input stream. The intent is
10072 - that this function is used to start inflating at a bit position in the
10073 - middle of a byte. The provided bits will be used before any bytes are used
10074 - from next_in. This function should only be used with raw inflate, and
10075 - should be used before the first inflate() call after inflateInit2() or
10076 - inflateReset(). bits must be less than or equal to 16, and that many of the
10077 - least significant bits of value will be inserted in the input.
10079 - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
10080 - stream state was inconsistent.
10083 -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
10084 - gz_headerp head));
10086 - inflateGetHeader() requests that gzip header information be stored in the
10087 - provided gz_header structure. inflateGetHeader() may be called after
10088 - inflateInit2() or inflateReset(), and before the first call of inflate().
10089 - As inflate() processes the gzip stream, head->done is zero until the header
10090 - is completed, at which time head->done is set to one. If a zlib stream is
10091 - being decoded, then head->done is set to -1 to indicate that there will be
10092 - no gzip header information forthcoming. Note that Z_BLOCK can be used to
10093 - force inflate() to return immediately after header processing is complete
10094 - and before any actual data is decompressed.
10096 - The text, time, xflags, and os fields are filled in with the gzip header
10097 - contents. hcrc is set to true if there is a header CRC. (The header CRC
10098 - was valid if done is set to one.) If extra is not Z_NULL, then extra_max
10099 - contains the maximum number of bytes to write to extra. Once done is true,
10100 - extra_len contains the actual extra field length, and extra contains the
10101 - extra field, or that field truncated if extra_max is less than extra_len.
10102 - If name is not Z_NULL, then up to name_max characters are written there,
10103 - terminated with a zero unless the length is greater than name_max. If
10104 - comment is not Z_NULL, then up to comm_max characters are written there,
10105 - terminated with a zero unless the length is greater than comm_max. When
10106 - any of extra, name, or comment are not Z_NULL and the respective field is
10107 - not present in the header, then that field is set to Z_NULL to signal its
10108 - absence. This allows the use of deflateSetHeader() with the returned
10109 - structure to duplicate the header. However if those fields are set to
10110 - allocated memory, then the application will need to save those pointers
10111 - elsewhere so that they can be eventually freed.
10113 - If inflateGetHeader is not used, then the header information is simply
10114 - discarded. The header is always checked for validity, including the header
10115 - CRC if present. inflateReset() will reset the process to discard the header
10116 - information. The application would need to call inflateGetHeader() again to
10117 - retrieve the header from the next gzip stream.
10119 - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
10120 - stream state was inconsistent.
10124 -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
10125 - unsigned char FAR *window));
10127 - Initialize the internal stream state for decompression using inflateBack()
10128 - calls. The fields zalloc, zfree and opaque in strm must be initialized
10129 - before the call. If zalloc and zfree are Z_NULL, then the default library-
10130 - derived memory allocation routines are used. windowBits is the base two
10131 - logarithm of the window size, in the range 8..15. window is a caller
10132 - supplied buffer of that size. Except for special applications where it is
10133 - assured that deflate was used with small window sizes, windowBits must be 15
10134 - and a 32K byte window must be supplied to be able to decompress general
10137 - See inflateBack() for the usage of these routines.
10139 - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
10140 - the paramaters are invalid, Z_MEM_ERROR if the internal state could not
10141 - be allocated, or Z_VERSION_ERROR if the version of the library does not
10142 - match the version of the header file.
10145 -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
10146 -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
10148 -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
10149 - in_func in, void FAR *in_desc,
10150 - out_func out, void FAR *out_desc));
10152 - inflateBack() does a raw inflate with a single call using a call-back
10153 - interface for input and output. This is more efficient than inflate() for
10154 - file i/o applications in that it avoids copying between the output and the
10155 - sliding window by simply making the window itself the output buffer. This
10156 - function trusts the application to not change the output buffer passed by
10157 - the output function, at least until inflateBack() returns.
10159 - inflateBackInit() must be called first to allocate the internal state
10160 - and to initialize the state with the user-provided window buffer.
10161 - inflateBack() may then be used multiple times to inflate a complete, raw
10162 - deflate stream with each call. inflateBackEnd() is then called to free
10163 - the allocated state.
10165 - A raw deflate stream is one with no zlib or gzip header or trailer.
10166 - This routine would normally be used in a utility that reads zip or gzip
10167 - files and writes out uncompressed files. The utility would decode the
10168 - header and process the trailer on its own, hence this routine expects
10169 - only the raw deflate stream to decompress. This is different from the
10170 - normal behavior of inflate(), which expects either a zlib or gzip header and
10171 - trailer around the deflate stream.
10173 - inflateBack() uses two subroutines supplied by the caller that are then
10174 - called by inflateBack() for input and output. inflateBack() calls those
10175 - routines until it reads a complete deflate stream and writes out all of the
10176 - uncompressed data, or until it encounters an error. The function's
10177 - parameters and return types are defined above in the in_func and out_func
10178 - typedefs. inflateBack() will call in(in_desc, &buf) which should return the
10179 - number of bytes of provided input, and a pointer to that input in buf. If
10180 - there is no input available, in() must return zero--buf is ignored in that
10181 - case--and inflateBack() will return a buffer error. inflateBack() will call
10182 - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
10183 - should return zero on success, or non-zero on failure. If out() returns
10184 - non-zero, inflateBack() will return with an error. Neither in() nor out()
10185 - are permitted to change the contents of the window provided to
10186 - inflateBackInit(), which is also the buffer that out() uses to write from.
10187 - The length written by out() will be at most the window size. Any non-zero
10188 - amount of input may be provided by in().
10190 - For convenience, inflateBack() can be provided input on the first call by
10191 - setting strm->next_in and strm->avail_in. If that input is exhausted, then
10192 - in() will be called. Therefore strm->next_in must be initialized before
10193 - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
10194 - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
10195 - must also be initialized, and then if strm->avail_in is not zero, input will
10196 - initially be taken from strm->next_in[0 .. strm->avail_in - 1].
10198 - The in_desc and out_desc parameters of inflateBack() is passed as the
10199 - first parameter of in() and out() respectively when they are called. These
10200 - descriptors can be optionally used to pass any information that the caller-
10201 - supplied in() and out() functions need to do their job.
10203 - On return, inflateBack() will set strm->next_in and strm->avail_in to
10204 - pass back any unused input that was provided by the last in() call. The
10205 - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
10206 - if in() or out() returned an error, Z_DATA_ERROR if there was a format
10207 - error in the deflate stream (in which case strm->msg is set to indicate the
10208 - nature of the error), or Z_STREAM_ERROR if the stream was not properly
10209 - initialized. In the case of Z_BUF_ERROR, an input or output error can be
10210 - distinguished using strm->next_in which will be Z_NULL only if in() returned
10211 - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
10212 - out() returning non-zero. (in() will always be called before out(), so
10213 - strm->next_in is assured to be defined if out() returns non-zero.) Note
10214 - that inflateBack() cannot return Z_OK.
10217 -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
10219 - All memory allocated by inflateBackInit() is freed.
10221 - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
10222 - state was inconsistent.
10225 -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
10226 -/* Return flags indicating compile-time options.
10228 - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
10229 - 1.0: size of uInt
10230 - 3.2: size of uLong
10231 - 5.4: size of voidpf (pointer)
10232 - 7.6: size of z_off_t
10234 - Compiler, assembler, and debug options:
10236 - 9: ASMV or ASMINF -- use ASM code
10237 - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
10240 - One-time table building (smaller code, but not thread-safe if true):
10241 - 12: BUILDFIXED -- build static block decoding tables when needed
10242 - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
10243 - 14,15: 0 (reserved)
10245 - Library content (indicates missing functionality):
10246 - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
10247 - deflate code when not needed)
10248 - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
10249 - and decode gzip streams (to avoid linking crc code)
10250 - 18-19: 0 (reserved)
10252 - Operation variations (changes in library functionality):
10253 - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
10254 - 21: FASTEST -- deflate algorithm with only one, lowest compression level
10255 - 22,23: 0 (reserved)
10257 - The sprintf variant used by gzprintf (zero is best):
10258 - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
10259 - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
10260 - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
10263 - 27-31: 0 (reserved)
10267 - /* utility functions */
10270 - The following utility functions are implemented on top of the
10271 - basic stream-oriented functions. To simplify the interface, some
10272 - default options are assumed (compression level and memory usage,
10273 - standard memory allocation functions). The source code of these
10274 - utility functions can easily be modified if you need special options.
10277 -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
10278 - const Bytef *source, uLong sourceLen));
10280 - Compresses the source buffer into the destination buffer. sourceLen is
10281 - the byte length of the source buffer. Upon entry, destLen is the total
10282 - size of the destination buffer, which must be at least the value returned
10283 - by compressBound(sourceLen). Upon exit, destLen is the actual size of the
10284 - compressed buffer.
10285 - This function can be used to compress a whole file at once if the
10286 - input file is mmap'ed.
10287 - compress returns Z_OK if success, Z_MEM_ERROR if there was not
10288 - enough memory, Z_BUF_ERROR if there was not enough room in the output
10292 -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
10293 - const Bytef *source, uLong sourceLen,
10296 - Compresses the source buffer into the destination buffer. The level
10297 - parameter has the same meaning as in deflateInit. sourceLen is the byte
10298 - length of the source buffer. Upon entry, destLen is the total size of the
10299 - destination buffer, which must be at least the value returned by
10300 - compressBound(sourceLen). Upon exit, destLen is the actual size of the
10301 - compressed buffer.
10303 - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
10304 - memory, Z_BUF_ERROR if there was not enough room in the output buffer,
10305 - Z_STREAM_ERROR if the level parameter is invalid.
10308 -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
10310 - compressBound() returns an upper bound on the compressed size after
10311 - compress() or compress2() on sourceLen bytes. It would be used before
10312 - a compress() or compress2() call to allocate the destination buffer.
10315 -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
10316 - const Bytef *source, uLong sourceLen));
10318 - Decompresses the source buffer into the destination buffer. sourceLen is
10319 - the byte length of the source buffer. Upon entry, destLen is the total
10320 - size of the destination buffer, which must be large enough to hold the
10321 - entire uncompressed data. (The size of the uncompressed data must have
10322 - been saved previously by the compressor and transmitted to the decompressor
10323 - by some mechanism outside the scope of this compression library.)
10324 - Upon exit, destLen is the actual size of the compressed buffer.
10325 - This function can be used to decompress a whole file at once if the
10326 - input file is mmap'ed.
10328 - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
10329 - enough memory, Z_BUF_ERROR if there was not enough room in the output
10330 - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
10334 -typedef voidp gzFile;
10336 -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
10338 - Opens a gzip (.gz) file for reading or writing. The mode parameter
10339 - is as in fopen ("rb" or "wb") but can also include a compression level
10340 - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
10341 - Huffman only compression as in "wb1h", or 'R' for run-length encoding
10342 - as in "wb1R". (See the description of deflateInit2 for more information
10343 - about the strategy parameter.)
10345 - gzopen can be used to read a file which is not in gzip format; in this
10346 - case gzread will directly read from the file without decompression.
10348 - gzopen returns NULL if the file could not be opened or if there was
10349 - insufficient memory to allocate the (de)compression state; errno
10350 - can be checked to distinguish the two cases (if errno is zero, the
10351 - zlib error is Z_MEM_ERROR). */
10353 -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
10355 - gzdopen() associates a gzFile with the file descriptor fd. File
10356 - descriptors are obtained from calls like open, dup, creat, pipe or
10357 - fileno (in the file has been previously opened with fopen).
10358 - The mode parameter is as in gzopen.
10359 - The next call of gzclose on the returned gzFile will also close the
10360 - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
10361 - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
10362 - gzdopen returns NULL if there was insufficient memory to allocate
10363 - the (de)compression state.
10366 -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
10368 - Dynamically update the compression level or strategy. See the description
10369 - of deflateInit2 for the meaning of these parameters.
10370 - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
10371 - opened for writing.
10374 -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
10376 - Reads the given number of uncompressed bytes from the compressed file.
10377 - If the input file was not in gzip format, gzread copies the given number
10378 - of bytes into the buffer.
10379 - gzread returns the number of uncompressed bytes actually read (0 for
10380 - end of file, -1 for error). */
10382 -ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
10383 - voidpc buf, unsigned len));
10385 - Writes the given number of uncompressed bytes into the compressed file.
10386 - gzwrite returns the number of uncompressed bytes actually written
10387 - (0 in case of error).
10390 -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
10392 - Converts, formats, and writes the args to the compressed file under
10393 - control of the format string, as in fprintf. gzprintf returns the number of
10394 - uncompressed bytes actually written (0 in case of error). The number of
10395 - uncompressed bytes written is limited to 4095. The caller should assure that
10396 - this limit is not exceeded. If it is exceeded, then gzprintf() will return
10397 - return an error (0) with nothing written. In this case, there may also be a
10398 - buffer overflow with unpredictable consequences, which is possible only if
10399 - zlib was compiled with the insecure functions sprintf() or vsprintf()
10400 - because the secure snprintf() or vsnprintf() functions were not available.
10403 -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
10405 - Writes the given null-terminated string to the compressed file, excluding
10406 - the terminating null character.
10407 - gzputs returns the number of characters written, or -1 in case of error.
10410 -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
10412 - Reads bytes from the compressed file until len-1 characters are read, or
10413 - a newline character is read and transferred to buf, or an end-of-file
10414 - condition is encountered. The string is then terminated with a null
10416 - gzgets returns buf, or Z_NULL in case of error.
10419 -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
10421 - Writes c, converted to an unsigned char, into the compressed file.
10422 - gzputc returns the value that was written, or -1 in case of error.
10425 -ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
10427 - Reads one byte from the compressed file. gzgetc returns this byte
10428 - or -1 in case of end of file or error.
10431 -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
10433 - Push one character back onto the stream to be read again later.
10434 - Only one character of push-back is allowed. gzungetc() returns the
10435 - character pushed, or -1 on failure. gzungetc() will fail if a
10436 - character has been pushed but not read yet, or if c is -1. The pushed
10437 - character will be discarded if the stream is repositioned with gzseek()
10441 -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
10443 - Flushes all pending output into the compressed file. The parameter
10444 - flush is as in the deflate() function. The return value is the zlib
10445 - error number (see function gzerror below). gzflush returns Z_OK if
10446 - the flush parameter is Z_FINISH and all output could be flushed.
10447 - gzflush should be called only when strictly necessary because it can
10448 - degrade compression.
10451 -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
10452 - z_off_t offset, int whence));
10454 - Sets the starting position for the next gzread or gzwrite on the
10455 - given compressed file. The offset represents a number of bytes in the
10456 - uncompressed data stream. The whence parameter is defined as in lseek(2);
10457 - the value SEEK_END is not supported.
10458 - If the file is opened for reading, this function is emulated but can be
10459 - extremely slow. If the file is opened for writing, only forward seeks are
10460 - supported; gzseek then compresses a sequence of zeroes up to the new
10461 - starting position.
10463 - gzseek returns the resulting offset location as measured in bytes from
10464 - the beginning of the uncompressed stream, or -1 in case of error, in
10465 - particular if the file is opened for writing and the new starting position
10466 - would be before the current position.
10469 -ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
10471 - Rewinds the given file. This function is supported only for reading.
10473 - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
10476 -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
10478 - Returns the starting position for the next gzread or gzwrite on the
10479 - given compressed file. This position represents a number of bytes in the
10480 - uncompressed data stream.
10482 - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
10485 -ZEXTERN int ZEXPORT gzeof OF((gzFile file));
10487 - Returns 1 when EOF has previously been detected reading the given
10488 - input stream, otherwise zero.
10491 -ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
10493 - Returns 1 if file is being read directly without decompression, otherwise
10497 -ZEXTERN int ZEXPORT gzclose OF((gzFile file));
10499 - Flushes all pending output if necessary, closes the compressed file
10500 - and deallocates all the (de)compression state. The return value is the zlib
10501 - error number (see function gzerror below).
10504 -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
10506 - Returns the error message for the last error which occurred on the
10507 - given compressed file. errnum is set to zlib error number. If an
10508 - error occurred in the file system and not in the compression library,
10509 - errnum is set to Z_ERRNO and the application may consult errno
10510 - to get the exact error code.
10513 -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
10515 - Clears the error and end-of-file flags for file. This is analogous to the
10516 - clearerr() function in stdio. This is useful for continuing to read a gzip
10517 - file that is being written concurrently.
10520 - /* checksum functions */
10523 - These functions are not related to compression but are exported
10524 - anyway because they might be useful in applications using the
10525 - compression library.
10528 -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
10530 - Update a running Adler-32 checksum with the bytes buf[0..len-1] and
10531 - return the updated checksum. If buf is NULL, this function returns
10532 - the required initial value for the checksum.
10533 - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
10534 - much faster. Usage example:
10536 - uLong adler = adler32(0L, Z_NULL, 0);
10538 - while (read_buffer(buffer, length) != EOF) {
10539 - adler = adler32(adler, buffer, length);
10541 - if (adler != original_adler) error();
10544 -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
10547 - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
10548 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
10549 - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
10550 - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
10553 -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
10555 - Update a running CRC-32 with the bytes buf[0..len-1] and return the
10556 - updated CRC-32. If buf is NULL, this function returns the required initial
10557 - value for the for the crc. Pre- and post-conditioning (one's complement) is
10558 - performed within this function so it shouldn't be done by the application.
10561 - uLong crc = crc32(0L, Z_NULL, 0);
10563 - while (read_buffer(buffer, length) != EOF) {
10564 - crc = crc32(crc, buffer, length);
10566 - if (crc != original_crc) error();
10569 -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
10572 - Combine two CRC-32 check values into one. For two sequences of bytes,
10573 - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
10574 - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
10575 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
10580 - /* various hacks, don't look :) */
10582 -/* deflateInit and inflateInit are macros to allow checking the zlib version
10583 - * and the compiler's view of z_stream:
10585 -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
10586 - const char *version, int stream_size));
10587 -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
10588 - const char *version, int stream_size));
10589 -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
10590 - int windowBits, int memLevel,
10591 - int strategy, const char *version,
10592 - int stream_size));
10593 -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
10594 - const char *version, int stream_size));
10595 -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
10596 - unsigned char FAR *window,
10597 - const char *version,
10598 - int stream_size));
10599 -#define deflateInit(strm, level) \
10600 - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
10601 -#define inflateInit(strm) \
10602 - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
10603 -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
10604 - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
10605 - (strategy), ZLIB_VERSION, sizeof(z_stream))
10606 -#define inflateInit2(strm, windowBits) \
10607 - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
10608 -#define inflateBackInit(strm, windowBits, window) \
10609 - inflateBackInit_((strm), (windowBits), (window), \
10610 - ZLIB_VERSION, sizeof(z_stream))
10613 -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
10614 - struct internal_state {int dummy;}; /* hack for buggy compilers */
10617 -ZEXTERN const char * ZEXPORT zError OF((int));
10618 -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
10619 -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
10621 -#ifdef __cplusplus
10625 -#endif /* ZLIB_H */
10626 diff -ruN RJaCGH.orig/src/zutil.c RJaCGH/src/zutil.c
10627 --- RJaCGH.orig/src/zutil.c 2009-03-04 12:51:20.000000000 +0100
10628 +++ RJaCGH/src/zutil.c 1970-01-01 01:00:00.000000000 +0100
10630 -/* zutil.c -- target dependent utility functions for the compression library
10631 - * Copyright (C) 1995-2005 Jean-loup Gailly.
10632 - * For conditions of distribution and use, see copyright notice in zlib.h
10637 -#include "zutil.h"
10639 -#ifndef NO_DUMMY_DECL
10640 -struct internal_state {int dummy;}; /* for buggy compilers */
10643 -const char * const z_errmsg[10] = {
10644 -"need dictionary", /* Z_NEED_DICT 2 */
10645 -"stream end", /* Z_STREAM_END 1 */
10647 -"file error", /* Z_ERRNO (-1) */
10648 -"stream error", /* Z_STREAM_ERROR (-2) */
10649 -"data error", /* Z_DATA_ERROR (-3) */
10650 -"insufficient memory", /* Z_MEM_ERROR (-4) */
10651 -"buffer error", /* Z_BUF_ERROR (-5) */
10652 -"incompatible version",/* Z_VERSION_ERROR (-6) */
10656 -const char * ZEXPORT zlibVersion()
10658 - return ZLIB_VERSION;
10661 -uLong ZEXPORT zlibCompileFlags()
10666 - switch (sizeof(uInt)) {
10668 - case 4: flags += 1; break;
10669 - case 8: flags += 2; break;
10670 - default: flags += 3;
10672 - switch (sizeof(uLong)) {
10674 - case 4: flags += 1 << 2; break;
10675 - case 8: flags += 2 << 2; break;
10676 - default: flags += 3 << 2;
10678 - switch (sizeof(voidpf)) {
10680 - case 4: flags += 1 << 4; break;
10681 - case 8: flags += 2 << 4; break;
10682 - default: flags += 3 << 4;
10684 - switch (sizeof(z_off_t)) {
10686 - case 4: flags += 1 << 6; break;
10687 - case 8: flags += 2 << 6; break;
10688 - default: flags += 3 << 6;
10693 -#if defined(ASMV) || defined(ASMINF)
10696 -#ifdef ZLIB_WINAPI
10697 - flags += 1 << 10;
10700 - flags += 1 << 12;
10702 -#ifdef DYNAMIC_CRC_TABLE
10703 - flags += 1 << 13;
10705 -#ifdef NO_GZCOMPRESS
10706 - flags += 1L << 16;
10709 - flags += 1L << 17;
10711 -#ifdef PKZIP_BUG_WORKAROUND
10712 - flags += 1L << 20;
10715 - flags += 1L << 21;
10718 -# ifdef NO_vsnprintf
10719 - flags += 1L << 25;
10720 -# ifdef HAS_vsprintf_void
10721 - flags += 1L << 26;
10724 -# ifdef HAS_vsnprintf_void
10725 - flags += 1L << 26;
10729 - flags += 1L << 24;
10730 -# ifdef NO_snprintf
10731 - flags += 1L << 25;
10732 -# ifdef HAS_sprintf_void
10733 - flags += 1L << 26;
10736 -# ifdef HAS_snprintf_void
10737 - flags += 1L << 26;
10747 -# define verbose 0
10749 -int z_verbose = verbose;
10754 - fprintf(stderr, "%s\n", m);
10759 -/* exported to allow conversion of error code to string for compress() and
10762 -const char * ZEXPORT zError(err)
10765 - return ERR_MSG(err);
10768 -#if defined(_WIN32_WCE)
10769 - /* The Microsoft C Run-Time Library for Windows CE doesn't have
10770 - * errno. We define it as a global variable to simplify porting.
10771 - * Its value is always 0 and should not be used.
10776 -#ifndef HAVE_MEMCPY
10778 -void zmemcpy(dest, source, len)
10780 - const Bytef* source;
10783 - if (len == 0) return;
10785 - *dest++ = *source++; /* ??? to be unrolled */
10786 - } while (--len != 0);
10789 -int zmemcmp(s1, s2, len)
10796 - for (j = 0; j < len; j++) {
10797 - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
10802 -void zmemzero(dest, len)
10806 - if (len == 0) return;
10808 - *dest++ = 0; /* ??? to be unrolled */
10809 - } while (--len != 0);
10817 -/* Turbo C in 16-bit mode */
10819 -# define MY_ZCALLOC
10821 -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
10822 - * and farmalloc(64K) returns a pointer with an offset of 8, so we
10823 - * must fix the pointer. Warning: the pointer must be put back to its
10824 - * original form in order to free it, use zcfree().
10827 -#define MAX_PTR 10
10828 -/* 10*64K = 640K */
10830 -local int next_ptr = 0;
10832 -typedef struct ptr_table_s {
10837 -local ptr_table table[MAX_PTR];
10838 -/* This table is used to remember the original form of pointers
10839 - * to large buffers (64K). Such pointers are normalized with a zero offset.
10840 - * Since MSDOS is not a preemptive multitasking OS, this table is not
10841 - * protected from concurrent access. This hack doesn't work anyway on
10842 - * a protected system like OS/2. Use Microsoft C instead.
10845 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10847 - voidpf buf = opaque; /* just to make some compilers happy */
10848 - ulg bsize = (ulg)items*size;
10850 - /* If we allocate less than 65520 bytes, we assume that farmalloc
10851 - * will return a usable pointer which doesn't have to be normalized.
10853 - if (bsize < 65520L) {
10854 - buf = farmalloc(bsize);
10855 - if (*(ush*)&buf != 0) return buf;
10857 - buf = farmalloc(bsize + 16L);
10859 - if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
10860 - table[next_ptr].org_ptr = buf;
10862 - /* Normalize the pointer to seg:0 */
10863 - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
10865 - table[next_ptr++].new_ptr = buf;
10869 -void zcfree (voidpf opaque, voidpf ptr)
10872 - if (*(ush*)&ptr != 0) { /* object < 64K */
10876 - /* Find the original pointer */
10877 - for (n = 0; n < next_ptr; n++) {
10878 - if (ptr != table[n].new_ptr) continue;
10880 - farfree(table[n].org_ptr);
10881 - while (++n < next_ptr) {
10882 - table[n-1] = table[n];
10887 - ptr = opaque; /* just to make some compilers happy */
10888 - Assert(0, "zcfree: ptr not found");
10891 -#endif /* __TURBOC__ */
10895 -/* Microsoft C in 16-bit mode */
10897 -# define MY_ZCALLOC
10899 -#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
10900 -# define _halloc halloc
10901 -# define _hfree hfree
10904 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10906 - if (opaque) opaque = 0; /* to make compiler happy */
10907 - return _halloc((long)items, size);
10910 -void zcfree (voidpf opaque, voidpf ptr)
10912 - if (opaque) opaque = 0; /* to make compiler happy */
10916 -#endif /* M_I86 */
10918 -#endif /* SYS16BIT */
10921 -#ifndef MY_ZCALLOC /* Any system without a special alloc function */
10924 -extern voidp malloc OF((uInt size));
10925 -extern voidp calloc OF((uInt items, uInt size));
10926 -extern void free OF((voidpf ptr));
10929 -voidpf zcalloc (opaque, items, size)
10934 - if (opaque) items += size - size; /* make compiler happy */
10935 - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
10936 - (voidpf)calloc(items, size);
10939 -void zcfree (opaque, ptr)
10944 - if (opaque) return; /* make compiler happy */
10947 -#endif /* MY_ZCALLOC */
10948 diff -ruN RJaCGH.orig/src/zutil.h RJaCGH/src/zutil.h
10949 --- RJaCGH.orig/src/zutil.h 2009-03-04 12:51:20.000000000 +0100
10950 +++ RJaCGH/src/zutil.h 1970-01-01 01:00:00.000000000 +0100
10952 -/* zutil.h -- internal interface and configuration of the compression library
10953 - * Copyright (C) 1995-2005 Jean-loup Gailly.
10954 - * For conditions of distribution and use, see copyright notice in zlib.h
10957 -/* WARNING: this file should *not* be used by applications. It is
10958 - part of the implementation of the compression library and is
10959 - subject to change. Applications should only use zlib.h.
10967 -#define ZLIB_INTERNAL
10971 -# ifndef _WIN32_WCE
10972 -# include <stddef.h>
10974 -# include <string.h>
10975 -# include <stdlib.h>
10978 -# ifdef _WIN32_WCE
10979 - /* The Microsoft C Run-Time Library for Windows CE doesn't have
10980 - * errno. We define it as a global variable to simplify porting.
10981 - * Its value is always 0 and should not be used. We rename it to
10982 - * avoid conflict with other libraries that use the same workaround.
10984 -# define errno z_errno
10986 - extern int errno;
10988 -# ifndef _WIN32_WCE
10989 -# include <errno.h>
10994 -# define local static
10996 -/* compile with -Dlocal if your debugger can't find static symbols */
10998 -typedef unsigned char uch;
10999 -typedef uch FAR uchf;
11000 -typedef unsigned short ush;
11001 -typedef ush FAR ushf;
11002 -typedef unsigned long ulg;
11004 -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
11005 -/* (size given to avoid silly warnings with Visual C++) */
11007 -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
11009 -#define ERR_RETURN(strm,err) \
11010 - return (strm->msg = (char*)ERR_MSG(err), (err))
11011 -/* To be used only when the state is known to be valid */
11013 - /* common constants */
11016 -# define DEF_WBITS MAX_WBITS
11018 -/* default windowBits for decompression. MAX_WBITS is for compression only */
11020 -#if MAX_MEM_LEVEL >= 8
11021 -# define DEF_MEM_LEVEL 8
11023 -# define DEF_MEM_LEVEL MAX_MEM_LEVEL
11025 -/* default memLevel */
11027 -#define STORED_BLOCK 0
11028 -#define STATIC_TREES 1
11029 -#define DYN_TREES 2
11030 -/* The three kinds of block type */
11032 -#define MIN_MATCH 3
11033 -#define MAX_MATCH 258
11034 -/* The minimum and maximum match lengths */
11036 -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
11038 - /* target dependencies */
11040 -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
11041 -# define OS_CODE 0x00
11042 -# if defined(__TURBOC__) || defined(__BORLANDC__)
11043 -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
11044 - /* Allow compilation with ANSI keywords only enabled */
11045 - void _Cdecl farfree( void *block );
11046 - void *_Cdecl farmalloc( unsigned long nbytes );
11048 -# include <alloc.h>
11050 -# else /* MSC or DJGPP */
11051 -# include <malloc.h>
11056 -# define OS_CODE 0x01
11059 -#if defined(VAXC) || defined(VMS)
11060 -# define OS_CODE 0x02
11061 -# define F_OPEN(name, mode) \
11062 - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
11065 -#if defined(ATARI) || defined(atarist)
11066 -# define OS_CODE 0x05
11070 -# define OS_CODE 0x06
11072 - #include <malloc.h>
11076 -#if defined(MACOS) || defined(TARGET_OS_MAC)
11077 -# define OS_CODE 0x07
11078 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
11079 -# include <unix.h> /* for fdopen */
11082 -# define fdopen(fd,mode) NULL /* No fdopen() */
11088 -# define OS_CODE 0x0a
11092 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
11093 -# define OS_CODE 0x0b
11097 -#ifdef __50SERIES /* Prime/PRIMOS */
11098 -# define OS_CODE 0x0f
11101 -#if defined(_BEOS_) || defined(RISCOS)
11102 -# define fdopen(fd,mode) NULL /* No fdopen() */
11105 -#if (defined(_MSC_VER) && (_MSC_VER > 600))
11106 -# if defined(_WIN32_WCE)
11107 -# define fdopen(fd,mode) NULL /* No fdopen() */
11108 -# ifndef _PTRDIFF_T_DEFINED
11109 - typedef int ptrdiff_t;
11110 -# define _PTRDIFF_T_DEFINED
11113 -# define fdopen(fd,type) _fdopen(fd,type)
11117 - /* common defaults */
11120 -# define OS_CODE 0x03 /* assume Unix */
11124 -# define F_OPEN(name, mode) fopen((name), (mode))
11129 -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
11130 -# ifndef HAVE_VSNPRINTF
11131 -# define HAVE_VSNPRINTF
11134 -#if defined(__CYGWIN__)
11135 -# ifndef HAVE_VSNPRINTF
11136 -# define HAVE_VSNPRINTF
11139 -#ifndef HAVE_VSNPRINTF
11141 - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
11142 - but for now we just assume it doesn't. */
11143 -# define NO_vsnprintf
11145 -# ifdef __TURBOC__
11146 -# define NO_vsnprintf
11149 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
11150 -# if !defined(vsnprintf) && !defined(NO_vsnprintf)
11151 -# define vsnprintf _vsnprintf
11155 -# define NO_vsnprintf
11159 -# define NO_vsnprintf
11163 -# define NO_MEMCPY
11165 -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
11166 - /* Use our own functions for small and medium model with MSC <= 5.0.
11167 - * You may have to use the same strategy for Borland C (untested).
11168 - * The __SC__ check is for Symantec.
11170 -# define NO_MEMCPY
11172 -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
11173 -# define HAVE_MEMCPY
11175 -#ifdef HAVE_MEMCPY
11176 -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
11177 -# define zmemcpy _fmemcpy
11178 -# define zmemcmp _fmemcmp
11179 -# define zmemzero(dest, len) _fmemset(dest, 0, len)
11181 -# define zmemcpy memcpy
11182 -# define zmemcmp memcmp
11183 -# define zmemzero(dest, len) memset(dest, 0, len)
11186 - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
11187 - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
11188 - extern void zmemzero OF((Bytef* dest, uInt len));
11191 -/* Diagnostic functions */
11193 -# include <stdio.h>
11194 - extern int z_verbose;
11195 - extern void z_error OF((char *m));
11196 -# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
11197 -# define Trace(x) {if (z_verbose>=0) fprintf x ;}
11198 -# define Tracev(x) {if (z_verbose>0) fprintf x ;}
11199 -# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
11200 -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
11201 -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
11203 -# define Assert(cond,msg)
11205 -# define Tracev(x)
11206 -# define Tracevv(x)
11207 -# define Tracec(c,x)
11208 -# define Tracecv(c,x)
11212 -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
11213 -void zcfree OF((voidpf opaque, voidpf ptr));
11215 -#define ZALLOC(strm, items, size) \
11216 - (*((strm)->zalloc))((strm)->opaque, (items), (size))
11217 -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
11218 -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
11220 -#endif /* ZUTIL_H */