]> git.donarmstrong.com Git - cran2deb.git/blob - tags/pre-dual/inst/etc/patches/RJaCGH/01_remove_zlib.patch
reprepro version before the massacre
[cran2deb.git] / tags / pre-dual / inst / etc / patches / RJaCGH / 01_remove_zlib.patch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 01_remove_zlib_src.dpatch by  <edd@xmcorsairs.wu-wien.ac.at>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Remove zlib
6
7 @DPATCH@
8
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
12 @@ -1,149 +0,0 @@
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
16 - */
17 -
18 -/* @(#) $Id$ */
19 -
20 -#define ZLIB_INTERNAL
21 -#include "zlib.h"
22 -
23 -#define BASE 65521UL    /* largest prime smaller than 65536 */
24 -#define NMAX 5552
25 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
26 -
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);
32 -
33 -/* use NO_DIVIDE if your processor does not do division in hardware */
34 -#ifdef NO_DIVIDE
35 -#  define MOD(a) \
36 -    do { \
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; \
54 -    } while (0)
55 -#  define MOD4(a) \
56 -    do { \
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; \
62 -    } while (0)
63 -#else
64 -#  define MOD(a) a %= BASE
65 -#  define MOD4(a) a %= BASE
66 -#endif
67 -
68 -/* ========================================================================= */
69 -uLong ZEXPORT adler32(adler, buf, len)
70 -    uLong adler;
71 -    const Bytef *buf;
72 -    uInt len;
73 -{
74 -    unsigned long sum2;
75 -    unsigned n;
76 -
77 -    /* split Adler-32 into component sums */
78 -    sum2 = (adler >> 16) & 0xffff;
79 -    adler &= 0xffff;
80 -
81 -    /* in case user likes doing a byte at a time, keep it fast */
82 -    if (len == 1) {
83 -        adler += buf[0];
84 -        if (adler >= BASE)
85 -            adler -= BASE;
86 -        sum2 += adler;
87 -        if (sum2 >= BASE)
88 -            sum2 -= BASE;
89 -        return adler | (sum2 << 16);
90 -    }
91 -
92 -    /* initial Adler-32 value (deferred check for len == 1 speed) */
93 -    if (buf == Z_NULL)
94 -        return 1L;
95 -
96 -    /* in case short lengths are provided, keep it somewhat fast */
97 -    if (len < 16) {
98 -        while (len--) {
99 -            adler += *buf++;
100 -            sum2 += adler;
101 -        }
102 -        if (adler >= BASE)
103 -            adler -= BASE;
104 -        MOD4(sum2);             /* only added so many BASE's */
105 -        return adler | (sum2 << 16);
106 -    }
107 -
108 -    /* do length NMAX blocks -- requires just one modulo operation */
109 -    while (len >= NMAX) {
110 -        len -= NMAX;
111 -        n = NMAX / 16;          /* NMAX is divisible by 16 */
112 -        do {
113 -            DO16(buf);          /* 16 sums unrolled */
114 -            buf += 16;
115 -        } while (--n);
116 -        MOD(adler);
117 -        MOD(sum2);
118 -    }
119 -
120 -    /* do remaining bytes (less than NMAX, still just one modulo) */
121 -    if (len) {                  /* avoid modulos if none remaining */
122 -        while (len >= 16) {
123 -            len -= 16;
124 -            DO16(buf);
125 -            buf += 16;
126 -        }
127 -        while (len--) {
128 -            adler += *buf++;
129 -            sum2 += adler;
130 -        }
131 -        MOD(adler);
132 -        MOD(sum2);
133 -    }
134 -
135 -    /* return recombined sums */
136 -    return adler | (sum2 << 16);
137 -}
138 -
139 -/* ========================================================================= */
140 -uLong ZEXPORT adler32_combine(adler1, adler2, len2)
141 -    uLong adler1;
142 -    uLong adler2;
143 -    z_off_t len2;
144 -{
145 -    unsigned long sum1;
146 -    unsigned long sum2;
147 -    unsigned rem;
148 -
149 -    /* the derivation of this formula is left as an exercise for the reader */
150 -    rem = (unsigned)(len2 % BASE);
151 -    sum1 = adler1 & 0xffff;
152 -    sum2 = rem * sum1;
153 -    MOD(sum2);
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);
161 -}
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
165 @@ -1,79 +0,0 @@
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
169 - */
170 -
171 -/* @(#) $Id$ */
172 -
173 -#define ZLIB_INTERNAL
174 -#include "zlib.h"
175 -
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.
182 -
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.
186 -*/
187 -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
188 -    Bytef *dest;
189 -    uLongf *destLen;
190 -    const Bytef *source;
191 -    uLong sourceLen;
192 -    int level;
193 -{
194 -    z_stream stream;
195 -    int err;
196 -
197 -    stream.next_in = (Bytef*)source;
198 -    stream.avail_in = (uInt)sourceLen;
199 -#ifdef MAXSEG_64K
200 -    /* Check for source > 64K on 16-bit machine: */
201 -    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
202 -#endif
203 -    stream.next_out = dest;
204 -    stream.avail_out = (uInt)*destLen;
205 -    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
206 -
207 -    stream.zalloc = (alloc_func)0;
208 -    stream.zfree = (free_func)0;
209 -    stream.opaque = (voidpf)0;
210 -
211 -    err = deflateInit(&stream, level);
212 -    if (err != Z_OK) return err;
213 -
214 -    err = deflate(&stream, Z_FINISH);
215 -    if (err != Z_STREAM_END) {
216 -        deflateEnd(&stream);
217 -        return err == Z_OK ? Z_BUF_ERROR : err;
218 -    }
219 -    *destLen = stream.total_out;
220 -
221 -    err = deflateEnd(&stream);
222 -    return err;
223 -}
224 -
225 -/* ===========================================================================
226 - */
227 -int ZEXPORT compress (dest, destLen, source, sourceLen)
228 -    Bytef *dest;
229 -    uLongf *destLen;
230 -    const Bytef *source;
231 -    uLong sourceLen;
232 -{
233 -    return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
234 -}
235 -
236 -/* ===========================================================================
237 -     If the default memLevel or windowBits for deflateInit() is changed, then
238 -   this function needs to be updated.
239 - */
240 -uLong ZEXPORT compressBound (sourceLen)
241 -    uLong sourceLen;
242 -{
243 -    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
244 -}
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
248 @@ -1,423 +0,0 @@
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
252 - *
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.
258 - */
259 -
260 -/* @(#) $Id$ */
261 -
262 -/*
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().
268 - */
269 -
270 -#ifdef MAKECRCH
271 -#  include <stdio.h>
272 -#  ifndef DYNAMIC_CRC_TABLE
273 -#    define DYNAMIC_CRC_TABLE
274 -#  endif /* !DYNAMIC_CRC_TABLE */
275 -#endif /* MAKECRCH */
276 -
277 -#include "zutil.h"      /* for STDC and FAR definitions */
278 -
279 -#define local static
280 -
281 -/* Find a four-byte integer type for crc32_little() and crc32_big(). */
282 -#ifndef NOBYFOUR
283 -#  ifdef STDC           /* need ANSI C limits.h to determine sizes */
284 -#    include <limits.h>
285 -#    define BYFOUR
286 -#    if (UINT_MAX == 0xffffffffUL)
287 -       typedef unsigned int u4;
288 -#    else
289 -#      if (ULONG_MAX == 0xffffffffUL)
290 -         typedef unsigned long u4;
291 -#      else
292 -#        if (USHRT_MAX == 0xffffffffUL)
293 -           typedef unsigned short u4;
294 -#        else
295 -#          undef BYFOUR     /* can't find a four-byte integer type! */
296 -#        endif
297 -#      endif
298 -#    endif
299 -#  endif /* STDC */
300 -#endif /* !NOBYFOUR */
301 -
302 -/* Definitions for doing the crc four data bytes at a time. */
303 -#ifdef BYFOUR
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));
310 -#  define TBLS 8
311 -#else
312 -#  define TBLS 1
313 -#endif /* BYFOUR */
314 -
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));
319 -
320 -#ifdef DYNAMIC_CRC_TABLE
321 -
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));
325 -#ifdef MAKECRCH
326 -   local void write_table OF((FILE *, const unsigned long FAR *));
327 -#endif /* MAKECRCH */
328 -/*
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.
331 -
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.
339 -
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.
347 -
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.
353 -*/
354 -local void make_crc_table()
355 -{
356 -    unsigned long c;
357 -    int n, k;
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};
362 -
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) */
366 -    if (first) {
367 -        first = 0;
368 -
369 -        /* make exclusive-or pattern from polynomial (0xedb88320UL) */
370 -        poly = 0UL;
371 -        for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
372 -            poly |= 1UL << (31 - p[n]);
373 -
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;
380 -        }
381 -
382 -#ifdef BYFOUR
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);
392 -            }
393 -        }
394 -#endif /* BYFOUR */
395 -
396 -        crc_table_empty = 0;
397 -    }
398 -    else {      /* not first */
399 -        /* wait for the other guy to finish (not efficient, but rare) */
400 -        while (crc_table_empty)
401 -            ;
402 -    }
403 -
404 -#ifdef MAKECRCH
405 -    /* write out CRC tables to crc32.h */
406 -    {
407 -        FILE *out;
408 -
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]);
416 -#  ifdef BYFOUR
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]);
421 -        }
422 -        fprintf(out, "#endif\n");
423 -#  endif /* BYFOUR */
424 -        fprintf(out, "  }\n};\n");
425 -        fclose(out);
426 -    }
427 -#endif /* MAKECRCH */
428 -}
429 -
430 -#ifdef MAKECRCH
431 -local void write_table(out, table)
432 -    FILE *out;
433 -    const unsigned long FAR *table;
434 -{
435 -    int n;
436 -
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" : ", "));
440 -}
441 -#endif /* MAKECRCH */
442 -
443 -#else /* !DYNAMIC_CRC_TABLE */
444 -/* ========================================================================
445 - * Tables of CRC-32s of all single-byte values, made by make_crc_table().
446 - */
447 -#include "crc32.h"
448 -#endif /* DYNAMIC_CRC_TABLE */
449 -
450 -/* =========================================================================
451 - * This function can be used by asm versions of crc32()
452 - */
453 -const unsigned long FAR * ZEXPORT get_crc_table()
454 -{
455 -#ifdef DYNAMIC_CRC_TABLE
456 -    if (crc_table_empty)
457 -        make_crc_table();
458 -#endif /* DYNAMIC_CRC_TABLE */
459 -    return (const unsigned long FAR *)crc_table;
460 -}
461 -
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
465 -
466 -/* ========================================================================= */
467 -unsigned long ZEXPORT crc32(crc, buf, len)
468 -    unsigned long crc;
469 -    const unsigned char FAR *buf;
470 -    unsigned len;
471 -{
472 -    if (buf == Z_NULL) return 0UL;
473 -
474 -#ifdef DYNAMIC_CRC_TABLE
475 -    if (crc_table_empty)
476 -        make_crc_table();
477 -#endif /* DYNAMIC_CRC_TABLE */
478 -
479 -#ifdef BYFOUR
480 -    if (sizeof(void *) == sizeof(ptrdiff_t)) {
481 -        u4 endian;
482 -
483 -        endian = 1;
484 -        if (*((unsigned char *)(&endian)))
485 -            return crc32_little(crc, buf, len);
486 -        else
487 -            return crc32_big(crc, buf, len);
488 -    }
489 -#endif /* BYFOUR */
490 -    crc = crc ^ 0xffffffffUL;
491 -    while (len >= 8) {
492 -        DO8;
493 -        len -= 8;
494 -    }
495 -    if (len) do {
496 -        DO1;
497 -    } while (--len);
498 -    return crc ^ 0xffffffffUL;
499 -}
500 -
501 -#ifdef BYFOUR
502 -
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
508 -
509 -/* ========================================================================= */
510 -local unsigned long crc32_little(crc, buf, len)
511 -    unsigned long crc;
512 -    const unsigned char FAR *buf;
513 -    unsigned len;
514 -{
515 -    register u4 c;
516 -    register const u4 FAR *buf4;
517 -
518 -    c = (u4)crc;
519 -    c = ~c;
520 -    while (len && ((ptrdiff_t)buf & 3)) {
521 -        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
522 -        len--;
523 -    }
524 -
525 -    buf4 = (const u4 FAR *)(const void FAR *)buf;
526 -    while (len >= 32) {
527 -        DOLIT32;
528 -        len -= 32;
529 -    }
530 -    while (len >= 4) {
531 -        DOLIT4;
532 -        len -= 4;
533 -    }
534 -    buf = (const unsigned char FAR *)buf4;
535 -
536 -    if (len) do {
537 -        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
538 -    } while (--len);
539 -    c = ~c;
540 -    return (unsigned long)c;
541 -}
542 -
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
548 -
549 -/* ========================================================================= */
550 -local unsigned long crc32_big(crc, buf, len)
551 -    unsigned long crc;
552 -    const unsigned char FAR *buf;
553 -    unsigned len;
554 -{
555 -    register u4 c;
556 -    register const u4 FAR *buf4;
557 -
558 -    c = REV((u4)crc);
559 -    c = ~c;
560 -    while (len && ((ptrdiff_t)buf & 3)) {
561 -        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
562 -        len--;
563 -    }
564 -
565 -    buf4 = (const u4 FAR *)(const void FAR *)buf;
566 -    buf4--;
567 -    while (len >= 32) {
568 -        DOBIG32;
569 -        len -= 32;
570 -    }
571 -    while (len >= 4) {
572 -        DOBIG4;
573 -        len -= 4;
574 -    }
575 -    buf4++;
576 -    buf = (const unsigned char FAR *)buf4;
577 -
578 -    if (len) do {
579 -        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
580 -    } while (--len);
581 -    c = ~c;
582 -    return (unsigned long)(REV(c));
583 -}
584 -
585 -#endif /* BYFOUR */
586 -
587 -#define GF2_DIM 32      /* dimension of GF(2) vectors (length of CRC) */
588 -
589 -/* ========================================================================= */
590 -local unsigned long gf2_matrix_times(mat, vec)
591 -    unsigned long *mat;
592 -    unsigned long vec;
593 -{
594 -    unsigned long sum;
595 -
596 -    sum = 0;
597 -    while (vec) {
598 -        if (vec & 1)
599 -            sum ^= *mat;
600 -        vec >>= 1;
601 -        mat++;
602 -    }
603 -    return sum;
604 -}
605 -
606 -/* ========================================================================= */
607 -local void gf2_matrix_square(square, mat)
608 -    unsigned long *square;
609 -    unsigned long *mat;
610 -{
611 -    int n;
612 -
613 -    for (n = 0; n < GF2_DIM; n++)
614 -        square[n] = gf2_matrix_times(mat, mat[n]);
615 -}
616 -
617 -/* ========================================================================= */
618 -uLong ZEXPORT crc32_combine(crc1, crc2, len2)
619 -    uLong crc1;
620 -    uLong crc2;
621 -    z_off_t len2;
622 -{
623 -    int n;
624 -    unsigned long row;
625 -    unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */
626 -    unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */
627 -
628 -    /* degenerate case */
629 -    if (len2 == 0)
630 -        return crc1;
631 -
632 -    /* put operator for one zero bit in odd */
633 -    odd[0] = 0xedb88320L;           /* CRC-32 polynomial */
634 -    row = 1;
635 -    for (n = 1; n < GF2_DIM; n++) {
636 -        odd[n] = row;
637 -        row <<= 1;
638 -    }
639 -
640 -    /* put operator for two zero bits in even */
641 -    gf2_matrix_square(even, odd);
642 -
643 -    /* put operator for four zero bits in odd */
644 -    gf2_matrix_square(odd, even);
645 -
646 -    /* apply len2 zeros to crc1 (first square will put the operator for one
647 -       zero byte, eight zero bits, in even) */
648 -    do {
649 -        /* apply zeros operator for this bit of len2 */
650 -        gf2_matrix_square(even, odd);
651 -        if (len2 & 1)
652 -            crc1 = gf2_matrix_times(even, crc1);
653 -        len2 >>= 1;
654 -
655 -        /* if no more bits set, then done */
656 -        if (len2 == 0)
657 -            break;
658 -
659 -        /* another iteration of the loop with odd and even swapped */
660 -        gf2_matrix_square(odd, even);
661 -        if (len2 & 1)
662 -            crc1 = gf2_matrix_times(odd, crc1);
663 -        len2 >>= 1;
664 -
665 -        /* if no more bits set, then done */
666 -    } while (len2 != 0);
667 -
668 -    /* return combined crc */
669 -    crc1 ^= crc2;
670 -    return crc1;
671 -}
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
675 @@ -1,441 +0,0 @@
676 -/* crc32.h -- tables for rapid CRC calculation
677 - * Generated automatically by crc32.c
678 - */
679 -
680 -local const unsigned long FAR crc_table[TBLS][256] =
681 -{
682 -  {
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,
734 -    0x2d02ef8dUL
735 -#ifdef BYFOUR
736 -  },
737 -  {
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,
789 -    0x9324fd72UL
790 -  },
791 -  {
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,
843 -    0xbe9834edUL
844 -  },
845 -  {
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,
897 -    0xde0506f1UL
898 -  },
899 -  {
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,
951 -    0x8def022dUL
952 -  },
953 -  {
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,
1005 -    0x72fd2493UL
1006 -  },
1007 -  {
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,
1059 -    0xed3498beUL
1060 -  },
1061 -  {
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,
1113 -    0xf10605deUL
1114 -#endif
1115 -  }
1116 -};
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
1120 @@ -1,1736 +0,0 @@
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
1124 - */
1125 -
1126 -/*
1127 - *  ALGORITHM
1128 - *
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).
1132 - *
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.
1150 - *
1151 - *  ACKNOWLEDGEMENTS
1152 - *
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.
1156 - *
1157 - *  REFERENCES
1158 - *
1159 - *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
1160 - *      Available in http://www.ietf.org/rfc/rfc1951.txt
1161 - *
1162 - *      A description of the Rabin and Karp algorithm is given in the book
1163 - *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
1164 - *
1165 - *      Fiala,E.R., and Greene,D.H.
1166 - *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
1167 - *
1168 - */
1169 -
1170 -/* @(#) $Id$ */
1171 -
1172 -#include "deflate.h"
1173 -
1174 -const char deflate_copyright[] =
1175 -   " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
1176 -/*
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.
1181 - */
1182 -
1183 -/* ===========================================================================
1184 - *  Function prototypes.
1185 - */
1186 -typedef enum {
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 */
1191 -} block_state;
1192 -
1193 -typedef block_state (*compress_func) OF((deflate_state *s, int flush));
1194 -/* Compression function. Returns the block state after the call. */
1195 -
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));
1199 -#ifndef FASTEST
1200 -local block_state deflate_slow   OF((deflate_state *s, int flush));
1201 -#endif
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));
1206 -#ifndef FASTEST
1207 -#ifdef ASMV
1208 -      void match_init OF((void)); /* asm code initialization */
1209 -      uInt longest_match  OF((deflate_state *s, IPos cur_match));
1210 -#else
1211 -local uInt longest_match  OF((deflate_state *s, IPos cur_match));
1212 -#endif
1213 -#endif
1214 -local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
1215 -
1216 -#ifdef DEBUG
1217 -local  void check_match OF((deflate_state *s, IPos start, IPos match,
1218 -                            int length));
1219 -#endif
1220 -
1221 -/* ===========================================================================
1222 - * Local data
1223 - */
1224 -
1225 -#define NIL 0
1226 -/* Tail of hash chains */
1227 -
1228 -#ifndef TOO_FAR
1229 -#  define TOO_FAR 4096
1230 -#endif
1231 -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
1232 -
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.
1236 - */
1237 -
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.
1242 - */
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 */
1247 -   ush max_chain;
1248 -   compress_func func;
1249 -} config;
1250 -
1251 -#ifdef FASTEST
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 */
1256 -#else
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},
1263 -
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 */
1270 -#endif
1271 -
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
1274 - * meaning.
1275 - */
1276 -
1277 -#define EQUAL 0
1278 -/* result of memcmp for equal strings */
1279 -
1280 -#ifndef NO_DUMMY_DECL
1281 -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
1282 -#endif
1283 -
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.
1289 - */
1290 -#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
1291 -
1292 -
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).
1302 - */
1303 -#ifdef FASTEST
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))
1308 -#else
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))
1313 -#endif
1314 -
1315 -/* ===========================================================================
1316 - * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
1317 - * prev[] will be initialized on the fly.
1318 - */
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));
1322 -
1323 -/* ========================================================================= */
1324 -int ZEXPORT deflateInit_(strm, level, version, stream_size)
1325 -    z_streamp strm;
1326 -    int level;
1327 -    const char *version;
1328 -    int stream_size;
1329 -{
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 */
1333 -}
1334 -
1335 -/* ========================================================================= */
1336 -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
1337 -                  version, stream_size)
1338 -    z_streamp strm;
1339 -    int  level;
1340 -    int  method;
1341 -    int  windowBits;
1342 -    int  memLevel;
1343 -    int  strategy;
1344 -    const char *version;
1345 -    int stream_size;
1346 -{
1347 -    deflate_state *s;
1348 -    int wrap = 1;
1349 -    static const char my_version[] = ZLIB_VERSION;
1350 -
1351 -    ushf *overlay;
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.
1354 -     */
1355 -
1356 -    if (version == Z_NULL || version[0] != my_version[0] ||
1357 -        stream_size != sizeof(z_stream)) {
1358 -        return Z_VERSION_ERROR;
1359 -    }
1360 -    if (strm == Z_NULL) return Z_STREAM_ERROR;
1361 -
1362 -    strm->msg = Z_NULL;
1363 -    if (strm->zalloc == (alloc_func)0) {
1364 -        strm->zalloc = zcalloc;
1365 -        strm->opaque = (voidpf)0;
1366 -    }
1367 -    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
1368 -
1369 -#ifdef FASTEST
1370 -    if (level != 0) level = 1;
1371 -#else
1372 -    if (level == Z_DEFAULT_COMPRESSION) level = 6;
1373 -#endif
1374 -
1375 -    if (windowBits < 0) { /* suppress zlib wrapper */
1376 -        wrap = 0;
1377 -        windowBits = -windowBits;
1378 -    }
1379 -#ifdef GZIP
1380 -    else if (windowBits > 15) {
1381 -        wrap = 2;       /* write gzip wrapper instead */
1382 -        windowBits -= 16;
1383 -    }
1384 -#endif
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;
1389 -    }
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;
1394 -    s->strm = strm;
1395 -
1396 -    s->wrap = wrap;
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;
1401 -
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);
1406 -
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));
1410 -
1411 -    s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
1412 -
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);
1416 -
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;
1423 -    }
1424 -    s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
1425 -    s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
1426 -
1427 -    s->level = level;
1428 -    s->strategy = strategy;
1429 -    s->method = (Byte)method;
1430 -
1431 -    return deflateReset(strm);
1432 -}
1433 -
1434 -/* ========================================================================= */
1435 -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
1436 -    z_streamp strm;
1437 -    const Bytef *dictionary;
1438 -    uInt  dictLength;
1439 -{
1440 -    deflate_state *s;
1441 -    uInt length = dictLength;
1442 -    uInt n;
1443 -    IPos hash_head = 0;
1444 -
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;
1449 -
1450 -    s = strm->state;
1451 -    if (s->wrap)
1452 -        strm->adler = adler32(strm->adler, dictionary, dictLength);
1453 -
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 */
1458 -    }
1459 -    zmemcpy(s->window, dictionary, length);
1460 -    s->strstart = length;
1461 -    s->block_start = (long)length;
1462 -
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.
1466 -     */
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);
1471 -    }
1472 -    if (hash_head) hash_head = 0;  /* to make compiler happy */
1473 -    return Z_OK;
1474 -}
1475 -
1476 -/* ========================================================================= */
1477 -int ZEXPORT deflateReset (strm)
1478 -    z_streamp strm;
1479 -{
1480 -    deflate_state *s;
1481 -
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;
1485 -    }
1486 -
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;
1490 -
1491 -    s = (deflate_state *)strm->state;
1492 -    s->pending = 0;
1493 -    s->pending_out = s->pending_buf;
1494 -
1495 -    if (s->wrap < 0) {
1496 -        s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
1497 -    }
1498 -    s->status = s->wrap ? INIT_STATE : BUSY_STATE;
1499 -    strm->adler =
1500 -#ifdef GZIP
1501 -        s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
1502 -#endif
1503 -        adler32(0L, Z_NULL, 0);
1504 -    s->last_flush = Z_NO_FLUSH;
1505 -
1506 -    _tr_init(s);
1507 -    lm_init(s);
1508 -
1509 -    return Z_OK;
1510 -}
1511 -
1512 -/* ========================================================================= */
1513 -int ZEXPORT deflateSetHeader (strm, head)
1514 -    z_streamp strm;
1515 -    gz_headerp head;
1516 -{
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;
1520 -    return Z_OK;
1521 -}
1522 -
1523 -/* ========================================================================= */
1524 -int ZEXPORT deflatePrime (strm, bits, value)
1525 -    z_streamp strm;
1526 -    int bits;
1527 -    int value;
1528 -{
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));
1532 -    return Z_OK;
1533 -}
1534 -
1535 -/* ========================================================================= */
1536 -int ZEXPORT deflateParams(strm, level, strategy)
1537 -    z_streamp strm;
1538 -    int level;
1539 -    int strategy;
1540 -{
1541 -    deflate_state *s;
1542 -    compress_func func;
1543 -    int err = Z_OK;
1544 -
1545 -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1546 -    s = strm->state;
1547 -
1548 -#ifdef FASTEST
1549 -    if (level != 0) level = 1;
1550 -#else
1551 -    if (level == Z_DEFAULT_COMPRESSION) level = 6;
1552 -#endif
1553 -    if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
1554 -        return Z_STREAM_ERROR;
1555 -    }
1556 -    func = configuration_table[s->level].func;
1557 -
1558 -    if (func != configuration_table[level].func && strm->total_in != 0) {
1559 -        /* Flush the last buffer: */
1560 -        err = deflate(strm, Z_PARTIAL_FLUSH);
1561 -    }
1562 -    if (s->level != level) {
1563 -        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;
1568 -    }
1569 -    s->strategy = strategy;
1570 -    return err;
1571 -}
1572 -
1573 -/* ========================================================================= */
1574 -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
1575 -    z_streamp strm;
1576 -    int good_length;
1577 -    int max_lazy;
1578 -    int nice_length;
1579 -    int max_chain;
1580 -{
1581 -    deflate_state *s;
1582 -
1583 -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1584 -    s = strm->state;
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;
1589 -    return Z_OK;
1590 -}
1591 -
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.
1598 - *
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.
1603 - *
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.
1608 - */
1609 -uLong ZEXPORT deflateBound(strm, sourceLen)
1610 -    z_streamp strm;
1611 -    uLong sourceLen;
1612 -{
1613 -    deflate_state *s;
1614 -    uLong destLen;
1615 -
1616 -    /* conservative upper bound */
1617 -    destLen = sourceLen +
1618 -              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
1619 -
1620 -    /* if can't get parameters, return conservative bound */
1621 -    if (strm == Z_NULL || strm->state == Z_NULL)
1622 -        return destLen;
1623 -
1624 -    /* if not default parameters, return conservative bound */
1625 -    s = strm->state;
1626 -    if (s->w_bits != 15 || s->hash_bits != 8 + 7)
1627 -        return destLen;
1628 -
1629 -    /* default settings: return tight bound for that case */
1630 -    return compressBound(sourceLen);
1631 -}
1632 -
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
1636 - * pending_buf.
1637 - */
1638 -local void putShortMSB (s, b)
1639 -    deflate_state *s;
1640 -    uInt b;
1641 -{
1642 -    put_byte(s, (Byte)(b >> 8));
1643 -    put_byte(s, (Byte)(b & 0xff));
1644 -}
1645 -
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()).
1651 - */
1652 -local void flush_pending(strm)
1653 -    z_streamp strm;
1654 -{
1655 -    unsigned len = strm->state->pending;
1656 -
1657 -    if (len > strm->avail_out) len = strm->avail_out;
1658 -    if (len == 0) return;
1659 -
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;
1668 -    }
1669 -}
1670 -
1671 -/* ========================================================================= */
1672 -int ZEXPORT deflate (strm, flush)
1673 -    z_streamp strm;
1674 -    int flush;
1675 -{
1676 -    int old_flush; /* value of flush param for previous deflate call */
1677 -    deflate_state *s;
1678 -
1679 -    if (strm == Z_NULL || strm->state == Z_NULL ||
1680 -        flush > Z_FINISH || flush < 0) {
1681 -        return Z_STREAM_ERROR;
1682 -    }
1683 -    s = strm->state;
1684 -
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);
1689 -    }
1690 -    if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
1691 -
1692 -    s->strm = strm; /* just in case */
1693 -    old_flush = s->last_flush;
1694 -    s->last_flush = flush;
1695 -
1696 -    /* Write the header */
1697 -    if (s->status == INIT_STATE) {
1698 -#ifdef GZIP
1699 -        if (s->wrap == 2) {
1700 -            strm->adler = crc32(0L, Z_NULL, 0);
1701 -            put_byte(s, 31);
1702 -            put_byte(s, 139);
1703 -            put_byte(s, 8);
1704 -            if (s->gzhead == NULL) {
1705 -                put_byte(s, 0);
1706 -                put_byte(s, 0);
1707 -                put_byte(s, 0);
1708 -                put_byte(s, 0);
1709 -                put_byte(s, 0);
1710 -                put_byte(s, s->level == 9 ? 2 :
1711 -                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
1712 -                             4 : 0));
1713 -                put_byte(s, OS_CODE);
1714 -                s->status = BUSY_STATE;
1715 -            }
1716 -            else {
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)
1722 -                        );
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 ?
1729 -                             4 : 0));
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);
1734 -                }
1735 -                if (s->gzhead->hcrc)
1736 -                    strm->adler = crc32(strm->adler, s->pending_buf,
1737 -                                        s->pending);
1738 -                s->gzindex = 0;
1739 -                s->status = EXTRA_STATE;
1740 -            }
1741 -        }
1742 -        else
1743 -#endif
1744 -        {
1745 -            uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
1746 -            uInt level_flags;
1747 -
1748 -            if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
1749 -                level_flags = 0;
1750 -            else if (s->level < 6)
1751 -                level_flags = 1;
1752 -            else if (s->level == 6)
1753 -                level_flags = 2;
1754 -            else
1755 -                level_flags = 3;
1756 -            header |= (level_flags << 6);
1757 -            if (s->strstart != 0) header |= PRESET_DICT;
1758 -            header += 31 - (header % 31);
1759 -
1760 -            s->status = BUSY_STATE;
1761 -            putShortMSB(s, header);
1762 -
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));
1767 -            }
1768 -            strm->adler = adler32(0L, Z_NULL, 0);
1769 -        }
1770 -    }
1771 -#ifdef GZIP
1772 -    if (s->status == EXTRA_STATE) {
1773 -        if (s->gzhead->extra != NULL) {
1774 -            uInt beg = s->pending;  /* start of bytes to update crc */
1775 -
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);
1782 -                    beg = s->pending;
1783 -                    if (s->pending == s->pending_buf_size)
1784 -                        break;
1785 -                }
1786 -                put_byte(s, s->gzhead->extra[s->gzindex]);
1787 -                s->gzindex++;
1788 -            }
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) {
1793 -                s->gzindex = 0;
1794 -                s->status = NAME_STATE;
1795 -            }
1796 -        }
1797 -        else
1798 -            s->status = NAME_STATE;
1799 -    }
1800 -    if (s->status == NAME_STATE) {
1801 -        if (s->gzhead->name != NULL) {
1802 -            uInt beg = s->pending;  /* start of bytes to update crc */
1803 -            int val;
1804 -
1805 -            do {
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);
1811 -                    beg = s->pending;
1812 -                    if (s->pending == s->pending_buf_size) {
1813 -                        val = 1;
1814 -                        break;
1815 -                    }
1816 -                }
1817 -                val = s->gzhead->name[s->gzindex++];
1818 -                put_byte(s, val);
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);
1823 -            if (val == 0) {
1824 -                s->gzindex = 0;
1825 -                s->status = COMMENT_STATE;
1826 -            }
1827 -        }
1828 -        else
1829 -            s->status = COMMENT_STATE;
1830 -    }
1831 -    if (s->status == COMMENT_STATE) {
1832 -        if (s->gzhead->comment != NULL) {
1833 -            uInt beg = s->pending;  /* start of bytes to update crc */
1834 -            int val;
1835 -
1836 -            do {
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);
1842 -                    beg = s->pending;
1843 -                    if (s->pending == s->pending_buf_size) {
1844 -                        val = 1;
1845 -                        break;
1846 -                    }
1847 -                }
1848 -                val = s->gzhead->comment[s->gzindex++];
1849 -                put_byte(s, val);
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);
1854 -            if (val == 0)
1855 -                s->status = HCRC_STATE;
1856 -        }
1857 -        else
1858 -            s->status = HCRC_STATE;
1859 -    }
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;
1869 -            }
1870 -        }
1871 -        else
1872 -            s->status = BUSY_STATE;
1873 -    }
1874 -#endif
1875 -
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:
1885 -             */
1886 -            s->last_flush = -1;
1887 -            return Z_OK;
1888 -        }
1889 -
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.
1893 -     */
1894 -    } else if (strm->avail_in == 0 && flush <= old_flush &&
1895 -               flush != Z_FINISH) {
1896 -        ERR_RETURN(strm, Z_BUF_ERROR);
1897 -    }
1898 -
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);
1902 -    }
1903 -
1904 -    /* Start a new block or continue the current one.
1905 -     */
1906 -    if (strm->avail_in != 0 || s->lookahead != 0 ||
1907 -        (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1908 -        block_state bstate;
1909 -
1910 -        bstate = (*(configuration_table[s->level].func))(s, flush);
1911 -
1912 -        if (bstate == finish_started || bstate == finish_done) {
1913 -            s->status = FINISH_STATE;
1914 -        }
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 */
1918 -            }
1919 -            return Z_OK;
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.
1926 -             */
1927 -        }
1928 -        if (bstate == block_done) {
1929 -            if (flush == Z_PARTIAL_FLUSH) {
1930 -                _tr_align(s);
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().
1935 -                 */
1936 -                if (flush == Z_FULL_FLUSH) {
1937 -                    CLEAR_HASH(s);             /* forget history */
1938 -                }
1939 -            }
1940 -            flush_pending(strm);
1941 -            if (strm->avail_out == 0) {
1942 -              s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1943 -              return Z_OK;
1944 -            }
1945 -        }
1946 -    }
1947 -    Assert(strm->avail_out > 0, "bug2");
1948 -
1949 -    if (flush != Z_FINISH) return Z_OK;
1950 -    if (s->wrap <= 0) return Z_STREAM_END;
1951 -
1952 -    /* Write the trailer */
1953 -#ifdef GZIP
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));
1963 -    }
1964 -    else
1965 -#endif
1966 -    {
1967 -        putShortMSB(s, (uInt)(strm->adler >> 16));
1968 -        putShortMSB(s, (uInt)(strm->adler & 0xffff));
1969 -    }
1970 -    flush_pending(strm);
1971 -    /* If avail_out is zero, the application will call deflate again
1972 -     * to flush the rest.
1973 -     */
1974 -    if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1975 -    return s->pending != 0 ? Z_OK : Z_STREAM_END;
1976 -}
1977 -
1978 -/* ========================================================================= */
1979 -int ZEXPORT deflateEnd (strm)
1980 -    z_streamp strm;
1981 -{
1982 -    int status;
1983 -
1984 -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1985 -
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;
1995 -    }
1996 -
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);
2002 -
2003 -    ZFREE(strm, strm->state);
2004 -    strm->state = Z_NULL;
2005 -
2006 -    return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
2007 -}
2008 -
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).
2013 - */
2014 -int ZEXPORT deflateCopy (dest, source)
2015 -    z_streamp dest;
2016 -    z_streamp source;
2017 -{
2018 -#ifdef MAXSEG_64K
2019 -    return Z_STREAM_ERROR;
2020 -#else
2021 -    deflate_state *ds;
2022 -    deflate_state *ss;
2023 -    ushf *overlay;
2024 -
2025 -
2026 -    if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
2027 -        return Z_STREAM_ERROR;
2028 -    }
2029 -
2030 -    ss = source->state;
2031 -
2032 -    zmemcpy(dest, source, sizeof(z_stream));
2033 -
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));
2038 -    ds->strm = dest;
2039 -
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;
2045 -
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;
2050 -    }
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);
2056 -
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;
2060 -
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;
2064 -
2065 -    return Z_OK;
2066 -#endif /* MAXSEG_64K */
2067 -}
2068 -
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()).
2075 - */
2076 -local int read_buf(strm, buf, size)
2077 -    z_streamp strm;
2078 -    Bytef *buf;
2079 -    unsigned size;
2080 -{
2081 -    unsigned len = strm->avail_in;
2082 -
2083 -    if (len > size) len = size;
2084 -    if (len == 0) return 0;
2085 -
2086 -    strm->avail_in  -= len;
2087 -
2088 -    if (strm->state->wrap == 1) {
2089 -        strm->adler = adler32(strm->adler, strm->next_in, len);
2090 -    }
2091 -#ifdef GZIP
2092 -    else if (strm->state->wrap == 2) {
2093 -        strm->adler = crc32(strm->adler, strm->next_in, len);
2094 -    }
2095 -#endif
2096 -    zmemcpy(buf, strm->next_in, len);
2097 -    strm->next_in  += len;
2098 -    strm->total_in += len;
2099 -
2100 -    return (int)len;
2101 -}
2102 -
2103 -/* ===========================================================================
2104 - * Initialize the "longest match" routines for a new zlib stream
2105 - */
2106 -local void lm_init (s)
2107 -    deflate_state *s;
2108 -{
2109 -    s->window_size = (ulg)2L*s->w_size;
2110 -
2111 -    CLEAR_HASH(s);
2112 -
2113 -    /* Set the default configuration parameters:
2114 -     */
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;
2119 -
2120 -    s->strstart = 0;
2121 -    s->block_start = 0L;
2122 -    s->lookahead = 0;
2123 -    s->match_length = s->prev_length = MIN_MATCH-1;
2124 -    s->match_available = 0;
2125 -    s->ins_h = 0;
2126 -#ifndef FASTEST
2127 -#ifdef ASMV
2128 -    match_init(); /* initialize the asm code */
2129 -#endif
2130 -#endif
2131 -}
2132 -
2133 -#ifndef FASTEST
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
2138 - * garbage.
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.
2142 - */
2143 -#ifndef ASMV
2144 -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
2145 - * match.S. The code will be functionally equivalent.
2146 - */
2147 -local uInt longest_match(s, cur_match)
2148 -    deflate_state *s;
2149 -    IPos cur_match;                             /* current match */
2150 -{
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.
2161 -     */
2162 -    Posf *prev = s->prev;
2163 -    uInt wmask = s->w_mask;
2164 -
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.
2168 -     */
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);
2172 -#else
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];
2176 -#endif
2177 -
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.
2180 -     */
2181 -    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
2182 -
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;
2186 -    }
2187 -    /* Do not look for matches beyond the end of the input. This is necessary
2188 -     * to make deflate deterministic.
2189 -     */
2190 -    if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
2191 -
2192 -    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
2193 -
2194 -    do {
2195 -        Assert(cur_match < s->strstart, "no future");
2196 -        match = s->window + cur_match;
2197 -
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.
2205 -         */
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.
2209 -         */
2210 -        if (*(ushf*)(match+best_len-1) != scan_end ||
2211 -            *(ushf*)match != scan_start) continue;
2212 -
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.
2221 -         */
2222 -        Assert(scan[2] == match[2], "scan[2]?");
2223 -        scan++, match++;
2224 -        do {
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) &&
2229 -                 scan < strend);
2230 -        /* The funny "do {}" generates better code on most compilers */
2231 -
2232 -        /* Here, scan <= window+strstart+257 */
2233 -        Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2234 -        if (*scan == *match) scan++;
2235 -
2236 -        len = (MAX_MATCH - 1) - (int)(strend-scan);
2237 -        scan = strend - (MAX_MATCH-1);
2238 -
2239 -#else /* UNALIGNED_OK */
2240 -
2241 -        if (match[best_len]   != scan_end  ||
2242 -            match[best_len-1] != scan_end1 ||
2243 -            *match            != *scan     ||
2244 -            *++match          != scan[1])      continue;
2245 -
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.
2251 -         */
2252 -        scan += 2, match++;
2253 -        Assert(*scan == *match, "match[2]?");
2254 -
2255 -        /* We check for insufficient lookahead only every 8th comparison;
2256 -         * the 256th check will be made at strstart+258.
2257 -         */
2258 -        do {
2259 -        } while (*++scan == *++match && *++scan == *++match &&
2260 -                 *++scan == *++match && *++scan == *++match &&
2261 -                 *++scan == *++match && *++scan == *++match &&
2262 -                 *++scan == *++match && *++scan == *++match &&
2263 -                 scan < strend);
2264 -
2265 -        Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2266 -
2267 -        len = MAX_MATCH - (int)(strend - scan);
2268 -        scan = strend - MAX_MATCH;
2269 -
2270 -#endif /* UNALIGNED_OK */
2271 -
2272 -        if (len > best_len) {
2273 -            s->match_start = cur_match;
2274 -            best_len = len;
2275 -            if (len >= nice_match) break;
2276 -#ifdef UNALIGNED_OK
2277 -            scan_end = *(ushf*)(scan+best_len-1);
2278 -#else
2279 -            scan_end1  = scan[best_len-1];
2280 -            scan_end   = scan[best_len];
2281 -#endif
2282 -        }
2283 -    } while ((cur_match = prev[cur_match & wmask]) > limit
2284 -             && --chain_length != 0);
2285 -
2286 -    if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
2287 -    return s->lookahead;
2288 -}
2289 -#endif /* ASMV */
2290 -#endif /* FASTEST */
2291 -
2292 -/* ---------------------------------------------------------------------------
2293 - * Optimized version for level == 1 or strategy == Z_RLE only
2294 - */
2295 -local uInt longest_match_fast(s, cur_match)
2296 -    deflate_state *s;
2297 -    IPos cur_match;                             /* current match */
2298 -{
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;
2303 -
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.
2306 -     */
2307 -    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
2308 -
2309 -    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
2310 -
2311 -    Assert(cur_match < s->strstart, "no future");
2312 -
2313 -    match = s->window + cur_match;
2314 -
2315 -    /* Return failure if the match length is less than 2:
2316 -     */
2317 -    if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
2318 -
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.
2324 -     */
2325 -    scan += 2, match += 2;
2326 -    Assert(*scan == *match, "match[2]?");
2327 -
2328 -    /* We check for insufficient lookahead only every 8th comparison;
2329 -     * the 256th check will be made at strstart+258.
2330 -     */
2331 -    do {
2332 -    } while (*++scan == *++match && *++scan == *++match &&
2333 -             *++scan == *++match && *++scan == *++match &&
2334 -             *++scan == *++match && *++scan == *++match &&
2335 -             *++scan == *++match && *++scan == *++match &&
2336 -             scan < strend);
2337 -
2338 -    Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
2339 -
2340 -    len = MAX_MATCH - (int)(strend - scan);
2341 -
2342 -    if (len < MIN_MATCH) return MIN_MATCH - 1;
2343 -
2344 -    s->match_start = cur_match;
2345 -    return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
2346 -}
2347 -
2348 -#ifdef DEBUG
2349 -/* ===========================================================================
2350 - * Check that the match at match_start is indeed a match.
2351 - */
2352 -local void check_match(s, start, match, length)
2353 -    deflate_state *s;
2354 -    IPos start, match;
2355 -    int length;
2356 -{
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);
2362 -        do {
2363 -            fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
2364 -        } while (--length != 0);
2365 -        z_error("invalid match");
2366 -    }
2367 -    if (z_verbose > 1) {
2368 -        fprintf(stderr,"\\[%d,%d]", start-match, length);
2369 -        do { putc(s->window[start++], stderr); } while (--length != 0);
2370 -    }
2371 -}
2372 -#else
2373 -#  define check_match(s, start, match, length)
2374 -#endif /* DEBUG */
2375 -
2376 -/* ===========================================================================
2377 - * Fill the window when the lookahead becomes insufficient.
2378 - * Updates strstart and lookahead.
2379 - *
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).
2385 - */
2386 -local void fill_window(s)
2387 -    deflate_state *s;
2388 -{
2389 -    register unsigned n, m;
2390 -    register Posf *p;
2391 -    unsigned more;    /* Amount of free space at the end of the window. */
2392 -    uInt wsize = s->w_size;
2393 -
2394 -    do {
2395 -        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
2396 -
2397 -        /* Deal with !@#$% 64K limit: */
2398 -        if (sizeof(int) <= 2) {
2399 -            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
2400 -                more = wsize;
2401 -
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)
2405 -                 */
2406 -                more--;
2407 -            }
2408 -        }
2409 -
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.
2412 -         */
2413 -        if (s->strstart >= wsize+MAX_DIST(s)) {
2414 -
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;
2419 -
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.)
2425 -             */
2426 -            /* %%% avoid this when Z_RLE */
2427 -            n = s->hash_size;
2428 -            p = &s->head[n];
2429 -            do {
2430 -                m = *--p;
2431 -                *p = (Pos)(m >= wsize ? m-wsize : NIL);
2432 -            } while (--n);
2433 -
2434 -            n = wsize;
2435 -#ifndef FASTEST
2436 -            p = &s->prev[n];
2437 -            do {
2438 -                m = *--p;
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.
2442 -                 */
2443 -            } while (--n);
2444 -#endif
2445 -            more += wsize;
2446 -        }
2447 -        if (s->strm->avail_in == 0) return;
2448 -
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.
2459 -         */
2460 -        Assert(more >= 2, "more < 2");
2461 -
2462 -        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
2463 -        s->lookahead += n;
2464 -
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]);
2469 -#if MIN_MATCH != 3
2470 -            Call UPDATE_HASH() MIN_MATCH-3 more times
2471 -#endif
2472 -        }
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.
2475 -         */
2476 -
2477 -    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
2478 -}
2479 -
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.
2483 - */
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), \
2489 -                (eof)); \
2490 -   s->block_start = s->strstart; \
2491 -   flush_pending(s->strm); \
2492 -   Tracev((stderr,"[FLUSH]")); \
2493 -}
2494 -
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; \
2499 -}
2500 -
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.
2509 - */
2510 -local block_state deflate_stored(s, flush)
2511 -    deflate_state *s;
2512 -    int flush;
2513 -{
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:
2516 -     */
2517 -    ulg max_block_size = 0xffff;
2518 -    ulg max_start;
2519 -
2520 -    if (max_block_size > s->pending_buf_size - 5) {
2521 -        max_block_size = s->pending_buf_size - 5;
2522 -    }
2523 -
2524 -    /* Copy as much as possible from input to output: */
2525 -    for (;;) {
2526 -        /* Fill the window as much as possible: */
2527 -        if (s->lookahead <= 1) {
2528 -
2529 -            Assert(s->strstart < s->w_size+MAX_DIST(s) ||
2530 -                   s->block_start >= (long)s->w_size, "slide too late");
2531 -
2532 -            fill_window(s);
2533 -            if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
2534 -
2535 -            if (s->lookahead == 0) break; /* flush the current block */
2536 -        }
2537 -        Assert(s->block_start >= 0L, "block gone");
2538 -
2539 -        s->strstart += s->lookahead;
2540 -        s->lookahead = 0;
2541 -
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);
2549 -        }
2550 -        /* Flush if we may have to slide, otherwise block_start may become
2551 -         * negative and the data will be gone:
2552 -         */
2553 -        if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
2554 -            FLUSH_BLOCK(s, 0);
2555 -        }
2556 -    }
2557 -    FLUSH_BLOCK(s, flush == Z_FINISH);
2558 -    return flush == Z_FINISH ? finish_done : block_done;
2559 -}
2560 -
2561 -/* ===========================================================================
2562 - * Compress as much as possible from the input stream, return the current
2563 - * block state.
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.
2567 - */
2568 -local block_state deflate_fast(s, flush)
2569 -    deflate_state *s;
2570 -    int flush;
2571 -{
2572 -    IPos hash_head = NIL; /* head of the hash chain */
2573 -    int bflush;           /* set if current block must be flushed */
2574 -
2575 -    for (;;) {
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.
2580 -         */
2581 -        if (s->lookahead < MIN_LOOKAHEAD) {
2582 -            fill_window(s);
2583 -            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
2584 -                return need_more;
2585 -            }
2586 -            if (s->lookahead == 0) break; /* flush the current block */
2587 -        }
2588 -
2589 -        /* Insert the string window[strstart .. strstart+2] in the
2590 -         * dictionary, and set hash_head to the head of the hash chain:
2591 -         */
2592 -        if (s->lookahead >= MIN_MATCH) {
2593 -            INSERT_STRING(s, s->strstart, hash_head);
2594 -        }
2595 -
2596 -        /* Find the longest match, discarding those <= prev_length.
2597 -         * At this point we have always match_length < MIN_MATCH
2598 -         */
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).
2603 -             */
2604 -#ifdef FASTEST
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);
2608 -            }
2609 -#else
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);
2614 -            }
2615 -#endif
2616 -            /* longest_match() or longest_match_fast() sets match_start */
2617 -        }
2618 -        if (s->match_length >= MIN_MATCH) {
2619 -            check_match(s, s->strstart, s->match_start, s->match_length);
2620 -
2621 -            _tr_tally_dist(s, s->strstart - s->match_start,
2622 -                           s->match_length - MIN_MATCH, bflush);
2623 -
2624 -            s->lookahead -= s->match_length;
2625 -
2626 -            /* Insert new strings in the hash table only if the match length
2627 -             * is not too large. This saves time but degrades compression.
2628 -             */
2629 -#ifndef FASTEST
2630 -            if (s->match_length <= s->max_insert_length &&
2631 -                s->lookahead >= MIN_MATCH) {
2632 -                s->match_length--; /* string at strstart already in table */
2633 -                do {
2634 -                    s->strstart++;
2635 -                    INSERT_STRING(s, s->strstart, hash_head);
2636 -                    /* strstart never exceeds WSIZE-MAX_MATCH, so there are
2637 -                     * always MIN_MATCH bytes ahead.
2638 -                     */
2639 -                } while (--s->match_length != 0);
2640 -                s->strstart++;
2641 -            } else
2642 -#endif
2643 -            {
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]);
2648 -#if MIN_MATCH != 3
2649 -                Call UPDATE_HASH() MIN_MATCH-3 more times
2650 -#endif
2651 -                /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
2652 -                 * matter since it will be recomputed at next deflate call.
2653 -                 */
2654 -            }
2655 -        } else {
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);
2659 -            s->lookahead--;
2660 -            s->strstart++;
2661 -        }
2662 -        if (bflush) FLUSH_BLOCK(s, 0);
2663 -    }
2664 -    FLUSH_BLOCK(s, flush == Z_FINISH);
2665 -    return flush == Z_FINISH ? finish_done : block_done;
2666 -}
2667 -
2668 -#ifndef FASTEST
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.
2673 - */
2674 -local block_state deflate_slow(s, flush)
2675 -    deflate_state *s;
2676 -    int flush;
2677 -{
2678 -    IPos hash_head = NIL;    /* head of hash chain */
2679 -    int bflush;              /* set if current block must be flushed */
2680 -
2681 -    /* Process the input block. */
2682 -    for (;;) {
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.
2687 -         */
2688 -        if (s->lookahead < MIN_LOOKAHEAD) {
2689 -            fill_window(s);
2690 -            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
2691 -                return need_more;
2692 -            }
2693 -            if (s->lookahead == 0) break; /* flush the current block */
2694 -        }
2695 -
2696 -        /* Insert the string window[strstart .. strstart+2] in the
2697 -         * dictionary, and set hash_head to the head of the hash chain:
2698 -         */
2699 -        if (s->lookahead >= MIN_MATCH) {
2700 -            INSERT_STRING(s, s->strstart, hash_head);
2701 -        }
2702 -
2703 -        /* Find the longest match, discarding those <= prev_length.
2704 -         */
2705 -        s->prev_length = s->match_length, s->prev_match = s->match_start;
2706 -        s->match_length = MIN_MATCH-1;
2707 -
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).
2713 -             */
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);
2718 -            }
2719 -            /* longest_match() or longest_match_fast() sets match_start */
2720 -
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)
2725 -#endif
2726 -                )) {
2727 -
2728 -                /* If prev_match is also MIN_MATCH, match_start is garbage
2729 -                 * but we will ignore the current match anyway.
2730 -                 */
2731 -                s->match_length = MIN_MATCH-1;
2732 -            }
2733 -        }
2734 -        /* If there was a match at the previous step and the current
2735 -         * match is not better, output the previous match:
2736 -         */
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. */
2740 -
2741 -            check_match(s, s->strstart-1, s->prev_match, s->prev_length);
2742 -
2743 -            _tr_tally_dist(s, s->strstart -1 - s->prev_match,
2744 -                           s->prev_length - MIN_MATCH, bflush);
2745 -
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
2749 -             * the hash table.
2750 -             */
2751 -            s->lookahead -= s->prev_length-1;
2752 -            s->prev_length -= 2;
2753 -            do {
2754 -                if (++s->strstart <= max_insert) {
2755 -                    INSERT_STRING(s, s->strstart, hash_head);
2756 -                }
2757 -            } while (--s->prev_length != 0);
2758 -            s->match_available = 0;
2759 -            s->match_length = MIN_MATCH-1;
2760 -            s->strstart++;
2761 -
2762 -            if (bflush) FLUSH_BLOCK(s, 0);
2763 -
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.
2768 -             */
2769 -            Tracevv((stderr,"%c", s->window[s->strstart-1]));
2770 -            _tr_tally_lit(s, s->window[s->strstart-1], bflush);
2771 -            if (bflush) {
2772 -                FLUSH_BLOCK_ONLY(s, 0);
2773 -            }
2774 -            s->strstart++;
2775 -            s->lookahead--;
2776 -            if (s->strm->avail_out == 0) return need_more;
2777 -        } else {
2778 -            /* There is no previous match to compare with, wait for
2779 -             * the next step to decide.
2780 -             */
2781 -            s->match_available = 1;
2782 -            s->strstart++;
2783 -            s->lookahead--;
2784 -        }
2785 -    }
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;
2791 -    }
2792 -    FLUSH_BLOCK(s, flush == Z_FINISH);
2793 -    return flush == Z_FINISH ? finish_done : block_done;
2794 -}
2795 -#endif /* FASTEST */
2796 -
2797 -#if 0
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.)
2802 - */
2803 -local block_state deflate_rle(s, flush)
2804 -    deflate_state *s;
2805 -    int flush;
2806 -{
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 */
2812 -
2813 -    for (;;) {
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.
2817 -         */
2818 -        if (s->lookahead < MAX_MATCH) {
2819 -            fill_window(s);
2820 -            if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
2821 -                return need_more;
2822 -            }
2823 -            if (s->lookahead == 0) break; /* flush the current block */
2824 -        }
2825 -
2826 -        /* See how many times the previous byte repeats */
2827 -        run = 0;
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;
2831 -            prev = *scan++;
2832 -            do {
2833 -                if (*scan++ != prev)
2834 -                    break;
2835 -            } while (++run < max);
2836 -        }
2837 -
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;
2844 -        } else {
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);
2848 -            s->lookahead--;
2849 -            s->strstart++;
2850 -        }
2851 -        if (bflush) FLUSH_BLOCK(s, 0);
2852 -    }
2853 -    FLUSH_BLOCK(s, flush == Z_FINISH);
2854 -    return flush == Z_FINISH ? finish_done : block_done;
2855 -}
2856 -#endif
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
2860 @@ -1,331 +0,0 @@
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
2864 - */
2865 -
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.
2869 - */
2870 -
2871 -/* @(#) $Id$ */
2872 -
2873 -#ifndef DEFLATE_H
2874 -#define DEFLATE_H
2875 -
2876 -#include "zutil.h"
2877 -
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. */
2882 -#ifndef NO_GZIP
2883 -#  define GZIP
2884 -#endif
2885 -
2886 -/* ===========================================================================
2887 - * Internal compression state.
2888 - */
2889 -
2890 -#define LENGTH_CODES 29
2891 -/* number of length codes, not counting the special END_BLOCK code */
2892 -
2893 -#define LITERALS  256
2894 -/* number of literal bytes 0..255 */
2895 -
2896 -#define L_CODES (LITERALS+1+LENGTH_CODES)
2897 -/* number of Literal or Length codes, including the END_BLOCK code */
2898 -
2899 -#define D_CODES   30
2900 -/* number of distance codes */
2901 -
2902 -#define BL_CODES  19
2903 -/* number of codes used to transfer the bit lengths */
2904 -
2905 -#define HEAP_SIZE (2*L_CODES+1)
2906 -/* maximum heap size */
2907 -
2908 -#define MAX_BITS 15
2909 -/* All codes must not exceed MAX_BITS bits */
2910 -
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 */
2919 -
2920 -
2921 -/* Data structure describing a single value and its code string. */
2922 -typedef struct ct_data_s {
2923 -    union {
2924 -        ush  freq;       /* frequency count */
2925 -        ush  code;       /* bit string */
2926 -    } fc;
2927 -    union {
2928 -        ush  dad;        /* father node in Huffman tree */
2929 -        ush  len;        /* length of bit string */
2930 -    } dl;
2931 -} FAR ct_data;
2932 -
2933 -#define Freq fc.freq
2934 -#define Code fc.code
2935 -#define Dad  dl.dad
2936 -#define Len  dl.len
2937 -
2938 -typedef struct static_tree_desc_s  static_tree_desc;
2939 -
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 */
2944 -} FAR tree_desc;
2945 -
2946 -typedef ush Pos;
2947 -typedef Pos FAR Posf;
2948 -typedef unsigned IPos;
2949 -
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.
2952 - */
2953 -
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 */
2966 -
2967 -                /* used by deflate.c: */
2968 -
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 */
2972 -
2973 -    Bytef *window;
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.
2981 -     */
2982 -
2983 -    ulg window_size;
2984 -    /* Actual size of window: 2*wSize, except when the user input buffer
2985 -     * is directly used as sliding window.
2986 -     */
2987 -
2988 -    Posf *prev;
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.
2992 -     */
2993 -
2994 -    Posf *head; /* Heads of the hash chains or NIL. */
2995 -
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 */
3000 -
3001 -    uInt  hash_shift;
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
3006 -     */
3007 -
3008 -    long block_start;
3009 -    /* Window position at the beginning of the current output block. Gets
3010 -     * negative when the window is moved backwards.
3011 -     */
3012 -
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 */
3019 -
3020 -    uInt prev_length;
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.
3023 -     */
3024 -
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
3028 -     * speed.
3029 -     */
3030 -
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
3034 -     * levels >= 4.
3035 -     */
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.
3040 -     */
3041 -
3042 -    int level;    /* compression level (1..9) */
3043 -    int strategy; /* favor or force Huffman coding*/
3044 -
3045 -    uInt good_match;
3046 -    /* Use a faster search when the previous match is longer than this */
3047 -
3048 -    int nice_match; /* Stop searching when current match exceeds this */
3049 -
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 */
3055 -
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 */
3059 -
3060 -    ush bl_count[MAX_BITS+1];
3061 -    /* number of codes at each bit length for an optimal tree */
3062 -
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.
3068 -     */
3069 -
3070 -    uch depth[2*L_CODES+1];
3071 -    /* Depth of each subtree used as tie breaker for trees of equal frequency
3072 -     */
3073 -
3074 -    uchf *l_buf;          /* buffer for literals or lengths */
3075 -
3076 -    uInt  lit_bufsize;
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
3094 -     */
3095 -
3096 -    uInt last_lit;      /* running index in l_buf */
3097 -
3098 -    ushf *d_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.
3102 -     */
3103 -
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 */
3108 -
3109 -#ifdef DEBUG
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 */
3112 -#endif
3113 -
3114 -    ush bi_buf;
3115 -    /* Output buffer. bits are inserted starting at the bottom (least
3116 -     * significant bits).
3117 -     */
3118 -    int bi_valid;
3119 -    /* Number of valid bits in bi_buf.  All bits above the last valid bit
3120 -     * are always zero.
3121 -     */
3122 -
3123 -} FAR deflate_state;
3124 -
3125 -/* Output a byte on the stream.
3126 - * IN assertion: there is enough room in pending_buf.
3127 - */
3128 -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
3129 -
3130 -
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.
3134 - */
3135 -
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.
3139 - */
3140 -
3141 -        /* in trees.c */
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,
3145 -                          int eof));
3146 -void _tr_align        OF((deflate_state *s));
3147 -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
3148 -                          int eof));
3149 -
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
3154 - * used.
3155 - */
3156 -
3157 -#ifndef DEBUG
3158 -/* Inline versions of _tr_tally for speed: */
3159 -
3160 -#if defined(GEN_TREES_H) || !defined(STDC)
3161 -  extern uch _length_code[];
3162 -  extern uch _dist_code[];
3163 -#else
3164 -  extern const uch _length_code[];
3165 -  extern const uch _dist_code[];
3166 -#endif
3167 -
3168 -# define _tr_tally_lit(s, c, flush) \
3169 -  { uch cc = (c); \
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); \
3174 -   }
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; \
3180 -    dist--; \
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); \
3184 -  }
3185 -#else
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)
3189 -#endif
3190 -
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
3195 @@ -1,1026 +0,0 @@
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
3199 - *
3200 - * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
3201 - */
3202 -
3203 -/* @(#) $Id$ */
3204 -
3205 -#include <stdio.h>
3206 -
3207 -#include "zutil.h"
3208 -
3209 -#ifdef NO_DEFLATE       /* for compatibility with old definition */
3210 -#  define NO_GZCOMPRESS
3211 -#endif
3212 -
3213 -#ifndef NO_DUMMY_DECL
3214 -struct internal_state {int dummy;}; /* for buggy compilers */
3215 -#endif
3216 -
3217 -#ifndef Z_BUFSIZE
3218 -#  ifdef MAXSEG_64K
3219 -#    define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
3220 -#  else
3221 -#    define Z_BUFSIZE 16384
3222 -#  endif
3223 -#endif
3224 -#ifndef Z_PRINTF_BUFSIZE
3225 -#  define Z_PRINTF_BUFSIZE 4096
3226 -#endif
3227 -
3228 -#ifdef __MVS__
3229 -#  pragma map (fdopen , "\174\174FDOPEN")
3230 -   FILE *fdopen(int, const char *);
3231 -#endif
3232 -
3233 -#ifndef STDC
3234 -extern voidp  malloc OF((uInt size));
3235 -extern void   free   OF((voidpf ptr));
3236 -#endif
3237 -
3238 -#define ALLOC(size) malloc(size)
3239 -#define TRYFREE(p) {if (p) free(p);}
3240 -
3241 -static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
3242 -
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 */
3250 -
3251 -typedef struct gz_stream {
3252 -    z_stream 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 */
3268 -} gz_stream;
3269 -
3270 -
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));
3278 -
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).
3287 -*/
3288 -local gzFile gz_open (path, mode, fd)
3289 -    const char *path;
3290 -    const char *mode;
3291 -    int  fd;
3292 -{
3293 -    int err;
3294 -    int level = Z_DEFAULT_COMPRESSION; /* compression level */
3295 -    int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
3296 -    char *p = (char*)mode;
3297 -    gz_stream *s;
3298 -    char fmode[80]; /* copy of mode, without the compression level */
3299 -    char *m = fmode;
3300 -
3301 -    if (!path || !mode) return Z_NULL;
3302 -
3303 -    s = (gz_stream *)ALLOC(sizeof(gz_stream));
3304 -    if (!s) return Z_NULL;
3305 -
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;
3312 -    s->file = NULL;
3313 -    s->z_err = Z_OK;
3314 -    s->z_eof = 0;
3315 -    s->in = 0;
3316 -    s->out = 0;
3317 -    s->back = EOF;
3318 -    s->crc = crc32(0L, Z_NULL, 0);
3319 -    s->msg = NULL;
3320 -    s->transparent = 0;
3321 -
3322 -    s->path = (char*)ALLOC(strlen(path)+1);
3323 -    if (s->path == NULL) {
3324 -        return destroy(s), (gzFile)Z_NULL;
3325 -    }
3326 -    strcpy(s->path, path); /* do this early for debugging */
3327 -
3328 -    s->mode = '\0';
3329 -    do {
3330 -        if (*p == 'r') s->mode = 'r';
3331 -        if (*p == 'w' || *p == 'a') s->mode = 'w';
3332 -        if (*p >= '0' && *p <= '9') {
3333 -            level = *p - '0';
3334 -        } else if (*p == 'f') {
3335 -          strategy = Z_FILTERED;
3336 -        } else if (*p == 'h') {
3337 -          strategy = Z_HUFFMAN_ONLY;
3338 -        } else if (*p == 'R') {
3339 -          strategy = Z_RLE;
3340 -        } else {
3341 -            *m++ = *p; /* copy the mode */
3342 -        }
3343 -    } while (*p++ && m != fmode + sizeof(fmode));
3344 -    if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
3345 -
3346 -    if (s->mode == 'w') {
3347 -#ifdef NO_GZCOMPRESS
3348 -        err = Z_STREAM_ERROR;
3349 -#else
3350 -        err = deflateInit2(&(s->stream), level,
3351 -                           Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
3352 -        /* windowBits is passed < 0 to suppress zlib header */
3353 -
3354 -        s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
3355 -#endif
3356 -        if (err != Z_OK || s->outbuf == Z_NULL) {
3357 -            return destroy(s), (gzFile)Z_NULL;
3358 -        }
3359 -    } else {
3360 -        s->stream.next_in  = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
3361 -
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.
3368 -         */
3369 -        if (err != Z_OK || s->inbuf == Z_NULL) {
3370 -            return destroy(s), (gzFile)Z_NULL;
3371 -        }
3372 -    }
3373 -    s->stream.avail_out = Z_BUFSIZE;
3374 -
3375 -    errno = 0;
3376 -    s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
3377 -
3378 -    if (s->file == NULL) {
3379 -        return destroy(s), (gzFile)Z_NULL;
3380 -    }
3381 -    if (s->mode == 'w') {
3382 -        /* Write a very simple .gz header:
3383 -         */
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);
3386 -        s->start = 10L;
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
3390 -         * necessary.
3391 -         */
3392 -    } else {
3393 -        check_header(s); /* skip the .gz header */
3394 -        s->start = ftell(s->file) - s->stream.avail_in;
3395 -    }
3396 -
3397 -    return (gzFile)s;
3398 -}
3399 -
3400 -/* ===========================================================================
3401 -     Opens a gzip (.gz) file for reading or writing.
3402 -*/
3403 -gzFile ZEXPORT gzopen (path, mode)
3404 -    const char *path;
3405 -    const char *mode;
3406 -{
3407 -    return gz_open (path, mode, -1);
3408 -}
3409 -
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.
3413 -*/
3414 -gzFile ZEXPORT gzdopen (fd, mode)
3415 -    int fd;
3416 -    const char *mode;
3417 -{
3418 -    char name[46];      /* allow for up to 128-bit integers */
3419 -
3420 -    if (fd < 0) return (gzFile)Z_NULL;
3421 -    sprintf(name, "<fd:%d>", fd); /* for debugging */
3422 -
3423 -    return gz_open (name, mode, fd);
3424 -}
3425 -
3426 -/* ===========================================================================
3427 - * Update the compression level and strategy
3428 - */
3429 -int ZEXPORT gzsetparams (file, level, strategy)
3430 -    gzFile file;
3431 -    int level;
3432 -    int strategy;
3433 -{
3434 -    gz_stream *s = (gz_stream*)file;
3435 -
3436 -    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3437 -
3438 -    /* Make room to allow flushing */
3439 -    if (s->stream.avail_out == 0) {
3440 -
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;
3444 -        }
3445 -        s->stream.avail_out = Z_BUFSIZE;
3446 -    }
3447 -
3448 -    return deflateParams (&(s->stream), level, strategy);
3449 -}
3450 -
3451 -/* ===========================================================================
3452 -     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
3453 -   for end of file.
3454 -   IN assertion: the stream s has been sucessfully opened for reading.
3455 -*/
3456 -local int get_byte(s)
3457 -    gz_stream *s;
3458 -{
3459 -    if (s->z_eof) return EOF;
3460 -    if (s->stream.avail_in == 0) {
3461 -        errno = 0;
3462 -        s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
3463 -        if (s->stream.avail_in == 0) {
3464 -            s->z_eof = 1;
3465 -            if (ferror(s->file)) s->z_err = Z_ERRNO;
3466 -            return EOF;
3467 -        }
3468 -        s->stream.next_in = s->inbuf;
3469 -    }
3470 -    s->stream.avail_in--;
3471 -    return *(s->stream.next_in)++;
3472 -}
3473 -
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
3478 -    is incorrect.
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.
3482 -*/
3483 -local void check_header(s)
3484 -    gz_stream *s;
3485 -{
3486 -    int method; /* method byte */
3487 -    int flags;  /* flags byte */
3488 -    uInt len;
3489 -    int c;
3490 -
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
3493 -       gzip segment */
3494 -    len = s->stream.avail_in;
3495 -    if (len < 2) {
3496 -        if (len) s->inbuf[0] = s->stream.next_in[0];
3497 -        errno = 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;
3504 -            return;
3505 -        }
3506 -    }
3507 -
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;
3512 -        return;
3513 -    }
3514 -    s->stream.avail_in -= 2;
3515 -    s->stream.next_in += 2;
3516 -
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;
3522 -        return;
3523 -    }
3524 -
3525 -    /* Discard time, xflags and OS code: */
3526 -    for (len = 0; len < 6; len++) (void)get_byte(s);
3527 -
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) ;
3533 -    }
3534 -    if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
3535 -        while ((c = get_byte(s)) != 0 && c != EOF) ;
3536 -    }
3537 -    if ((flags & COMMENT) != 0) {   /* skip the .gz file comment */
3538 -        while ((c = get_byte(s)) != 0 && c != EOF) ;
3539 -    }
3540 -    if ((flags & HEAD_CRC) != 0) {  /* skip the header crc */
3541 -        for (len = 0; len < 2; len++) (void)get_byte(s);
3542 -    }
3543 -    s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
3544 -}
3545 -
3546 - /* ===========================================================================
3547 - * Cleanup then free the given gz_stream. Return a zlib error code.
3548 -   Try freeing in the reverse order of allocations.
3549 - */
3550 -local int destroy (s)
3551 -    gz_stream *s;
3552 -{
3553 -    int err = Z_OK;
3554 -
3555 -    if (!s) return Z_STREAM_ERROR;
3556 -
3557 -    TRYFREE(s->msg);
3558 -
3559 -    if (s->stream.state != NULL) {
3560 -        if (s->mode == 'w') {
3561 -#ifdef NO_GZCOMPRESS
3562 -            err = Z_STREAM_ERROR;
3563 -#else
3564 -            err = deflateEnd(&(s->stream));
3565 -#endif
3566 -        } else if (s->mode == 'r') {
3567 -            err = inflateEnd(&(s->stream));
3568 -        }
3569 -    }
3570 -    if (s->file != NULL && fclose(s->file)) {
3571 -#ifdef ESPIPE
3572 -        if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
3573 -#endif
3574 -            err = Z_ERRNO;
3575 -    }
3576 -    if (s->z_err < 0) err = s->z_err;
3577 -
3578 -    TRYFREE(s->inbuf);
3579 -    TRYFREE(s->outbuf);
3580 -    TRYFREE(s->path);
3581 -    TRYFREE(s);
3582 -    return err;
3583 -}
3584 -
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).
3588 -*/
3589 -int ZEXPORT gzread (file, buf, len)
3590 -    gzFile file;
3591 -    voidp buf;
3592 -    unsigned len;
3593 -{
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) */
3597 -
3598 -    if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
3599 -
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 */
3602 -
3603 -    next_out = (Byte*)buf;
3604 -    s->stream.next_out = (Bytef*)buf;
3605 -    s->stream.avail_out = len;
3606 -
3607 -    if (s->stream.avail_out && s->back != EOF) {
3608 -        *next_out++ = s->back;
3609 -        s->stream.next_out++;
3610 -        s->stream.avail_out--;
3611 -        s->back = EOF;
3612 -        s->out++;
3613 -        start++;
3614 -        if (s->last) {
3615 -            s->z_err = Z_STREAM_END;
3616 -            return 1;
3617 -        }
3618 -    }
3619 -
3620 -    while (s->stream.avail_out != 0) {
3621 -
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;
3626 -            if (n > 0) {
3627 -                zmemcpy(s->stream.next_out, s->stream.next_in, n);
3628 -                next_out += 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;
3633 -            }
3634 -            if (s->stream.avail_out > 0) {
3635 -                s->stream.avail_out -=
3636 -                    (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
3637 -            }
3638 -            len -= s->stream.avail_out;
3639 -            s->in  += len;
3640 -            s->out += len;
3641 -            if (len == 0) s->z_eof = 1;
3642 -            return (int)len;
3643 -        }
3644 -        if (s->stream.avail_in == 0 && !s->z_eof) {
3645 -
3646 -            errno = 0;
3647 -            s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
3648 -            if (s->stream.avail_in == 0) {
3649 -                s->z_eof = 1;
3650 -                if (ferror(s->file)) {
3651 -                    s->z_err = Z_ERRNO;
3652 -                    break;
3653 -                }
3654 -            }
3655 -            s->stream.next_in = s->inbuf;
3656 -        }
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;
3662 -
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;
3667 -
3668 -            if (getLong(s) != s->crc) {
3669 -                s->z_err = Z_DATA_ERROR;
3670 -            } else {
3671 -                (void)getLong(s);
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:
3675 -                 */
3676 -                check_header(s);
3677 -                if (s->z_err == Z_OK) {
3678 -                    inflateReset(&(s->stream));
3679 -                    s->crc = crc32(0L, Z_NULL, 0);
3680 -                }
3681 -            }
3682 -        }
3683 -        if (s->z_err != Z_OK || s->z_eof) break;
3684 -    }
3685 -    s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
3686 -
3687 -    if (len == s->stream.avail_out &&
3688 -        (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
3689 -        return -1;
3690 -    return (int)(len - s->stream.avail_out);
3691 -}
3692 -
3693 -
3694 -/* ===========================================================================
3695 -      Reads one byte from the compressed file. gzgetc returns this byte
3696 -   or -1 in case of end of file or error.
3697 -*/
3698 -int ZEXPORT gzgetc(file)
3699 -    gzFile file;
3700 -{
3701 -    unsigned char c;
3702 -
3703 -    return gzread(file, &c, 1) == 1 ? c : -1;
3704 -}
3705 -
3706 -
3707 -/* ===========================================================================
3708 -      Push one byte back onto the stream.
3709 -*/
3710 -int ZEXPORT gzungetc(c, file)
3711 -    int c;
3712 -    gzFile file;
3713 -{
3714 -    gz_stream *s = (gz_stream*)file;
3715 -
3716 -    if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
3717 -    s->back = c;
3718 -    s->out--;
3719 -    s->last = (s->z_err == Z_STREAM_END);
3720 -    if (s->last) s->z_err = Z_OK;
3721 -    s->z_eof = 0;
3722 -    return c;
3723 -}
3724 -
3725 -
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.
3732 -
3733 -      The current implementation is not optimized at all.
3734 -*/
3735 -char * ZEXPORT gzgets(file, buf, len)
3736 -    gzFile file;
3737 -    char *buf;
3738 -    int len;
3739 -{
3740 -    char *b = buf;
3741 -    if (buf == Z_NULL || len <= 0) return Z_NULL;
3742 -
3743 -    while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
3744 -    *buf = '\0';
3745 -    return b == buf && len > 0 ? Z_NULL : b;
3746 -}
3747 -
3748 -
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).
3753 -*/
3754 -int ZEXPORT gzwrite (file, buf, len)
3755 -    gzFile file;
3756 -    voidpc buf;
3757 -    unsigned len;
3758 -{
3759 -    gz_stream *s = (gz_stream*)file;
3760 -
3761 -    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3762 -
3763 -    s->stream.next_in = (Bytef*)buf;
3764 -    s->stream.avail_in = len;
3765 -
3766 -    while (s->stream.avail_in != 0) {
3767 -
3768 -        if (s->stream.avail_out == 0) {
3769 -
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;
3773 -                break;
3774 -            }
3775 -            s->stream.avail_out = Z_BUFSIZE;
3776 -        }
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;
3783 -    }
3784 -    s->crc = crc32(s->crc, (const Bytef *)buf, len);
3785 -
3786 -    return (int)(len - s->stream.avail_in);
3787 -}
3788 -
3789 -
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).
3794 -*/
3795 -#ifdef STDC
3796 -#include <stdarg.h>
3797 -
3798 -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
3799 -{
3800 -    char buf[Z_PRINTF_BUFSIZE];
3801 -    va_list va;
3802 -    int len;
3803 -
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);
3809 -    va_end(va);
3810 -    for (len = 0; len < sizeof(buf); len++)
3811 -        if (buf[len] == 0) break;
3812 -#  else
3813 -    len = vsprintf(buf, format, va);
3814 -    va_end(va);
3815 -#  endif
3816 -#else
3817 -#  ifdef HAS_vsnprintf_void
3818 -    (void)vsnprintf(buf, sizeof(buf), format, va);
3819 -    va_end(va);
3820 -    len = strlen(buf);
3821 -#  else
3822 -    len = vsnprintf(buf, sizeof(buf), format, va);
3823 -    va_end(va);
3824 -#  endif
3825 -#endif
3826 -    if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
3827 -        return 0;
3828 -    return gzwrite(file, buf, (unsigned)len);
3829 -}
3830 -#else /* not ANSI C */
3831 -
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)
3834 -    gzFile file;
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;
3838 -{
3839 -    char buf[Z_PRINTF_BUFSIZE];
3840 -    int len;
3841 -
3842 -    buf[sizeof(buf) - 1] = 0;
3843 -#ifdef NO_snprintf
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;
3849 -#  else
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);
3852 -#  endif
3853 -#else
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);
3858 -#  else
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);
3861 -#  endif
3862 -#endif
3863 -    if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
3864 -        return 0;
3865 -    return gzwrite(file, buf, len);
3866 -}
3867 -#endif
3868 -
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.
3872 -*/
3873 -int ZEXPORT gzputc(file, c)
3874 -    gzFile file;
3875 -    int c;
3876 -{
3877 -    unsigned char cc = (unsigned char) c; /* required for big endian systems */
3878 -
3879 -    return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
3880 -}
3881 -
3882 -
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.
3887 -*/
3888 -int ZEXPORT gzputs(file, s)
3889 -    gzFile file;
3890 -    const char *s;
3891 -{
3892 -    return gzwrite(file, (char*)s, (unsigned)strlen(s));
3893 -}
3894 -
3895 -
3896 -/* ===========================================================================
3897 -     Flushes all pending output into the compressed file. The parameter
3898 -   flush is as in the deflate() function.
3899 -*/
3900 -local int do_flush (file, flush)
3901 -    gzFile file;
3902 -    int flush;
3903 -{
3904 -    uInt len;
3905 -    int done = 0;
3906 -    gz_stream *s = (gz_stream*)file;
3907 -
3908 -    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
3909 -
3910 -    s->stream.avail_in = 0; /* should be zero already anyway */
3911 -
3912 -    for (;;) {
3913 -        len = Z_BUFSIZE - s->stream.avail_out;
3914 -
3915 -        if (len != 0) {
3916 -            if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
3917 -                s->z_err = Z_ERRNO;
3918 -                return Z_ERRNO;
3919 -            }
3920 -            s->stream.next_out = s->outbuf;
3921 -            s->stream.avail_out = Z_BUFSIZE;
3922 -        }
3923 -        if (done) break;
3924 -        s->out += s->stream.avail_out;
3925 -        s->z_err = deflate(&(s->stream), flush);
3926 -        s->out -= s->stream.avail_out;
3927 -
3928 -        /* Ignore the second of two consecutive flushes: */
3929 -        if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
3930 -
3931 -        /* deflate has finished flushing only when it hasn't used up
3932 -         * all the available space in the output buffer:
3933 -         */
3934 -        done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
3935 -
3936 -        if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
3937 -    }
3938 -    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
3939 -}
3940 -
3941 -int ZEXPORT gzflush (file, flush)
3942 -     gzFile file;
3943 -     int flush;
3944 -{
3945 -    gz_stream *s = (gz_stream*)file;
3946 -    int err = do_flush (file, flush);
3947 -
3948 -    if (err) return err;
3949 -    fflush(s->file);
3950 -    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
3951 -}
3952 -#endif /* NO_GZCOMPRESS */
3953 -
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.
3961 -*/
3962 -z_off_t ZEXPORT gzseek (file, offset, whence)
3963 -    gzFile file;
3964 -    z_off_t offset;
3965 -    int whence;
3966 -{
3967 -    gz_stream *s = (gz_stream*)file;
3968 -
3969 -    if (s == NULL || whence == SEEK_END ||
3970 -        s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
3971 -        return -1L;
3972 -    }
3973 -
3974 -    if (s->mode == 'w') {
3975 -#ifdef NO_GZCOMPRESS
3976 -        return -1L;
3977 -#else
3978 -        if (whence == SEEK_SET) {
3979 -            offset -= s->in;
3980 -        }
3981 -        if (offset < 0) return -1L;
3982 -
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);
3988 -        }
3989 -        while (offset > 0)  {
3990 -            uInt size = Z_BUFSIZE;
3991 -            if (offset < Z_BUFSIZE) size = (uInt)offset;
3992 -
3993 -            size = gzwrite(file, s->inbuf, size);
3994 -            if (size == 0) return -1L;
3995 -
3996 -            offset -= size;
3997 -        }
3998 -        return s->in;
3999 -#endif
4000 -    }
4001 -    /* Rest of function is for reading only */
4002 -
4003 -    /* compute absolute position */
4004 -    if (whence == SEEK_CUR) {
4005 -        offset += s->out;
4006 -    }
4007 -    if (offset < 0) return -1L;
4008 -
4009 -    if (s->transparent) {
4010 -        /* map to fseek */
4011 -        s->back = EOF;
4012 -        s->stream.avail_in = 0;
4013 -        s->stream.next_in = s->inbuf;
4014 -        if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
4015 -
4016 -        s->in = s->out = offset;
4017 -        return offset;
4018 -    }
4019 -
4020 -    /* For a negative seek, rewind and use positive seek */
4021 -    if (offset >= s->out) {
4022 -        offset -= s->out;
4023 -    } else if (gzrewind(file) < 0) {
4024 -        return -1L;
4025 -    }
4026 -    /* offset is now the number of bytes to skip. */
4027 -
4028 -    if (offset != 0 && s->outbuf == Z_NULL) {
4029 -        s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
4030 -        if (s->outbuf == Z_NULL) return -1L;
4031 -    }
4032 -    if (offset && s->back != EOF) {
4033 -        s->back = EOF;
4034 -        s->out++;
4035 -        offset--;
4036 -        if (s->last) s->z_err = Z_STREAM_END;
4037 -    }
4038 -    while (offset > 0)  {
4039 -        int size = Z_BUFSIZE;
4040 -        if (offset < Z_BUFSIZE) size = (int)offset;
4041 -
4042 -        size = gzread(file, s->outbuf, (uInt)size);
4043 -        if (size <= 0) return -1L;
4044 -        offset -= size;
4045 -    }
4046 -    return s->out;
4047 -}
4048 -
4049 -/* ===========================================================================
4050 -     Rewinds input file.
4051 -*/
4052 -int ZEXPORT gzrewind (file)
4053 -    gzFile file;
4054 -{
4055 -    gz_stream *s = (gz_stream*)file;
4056 -
4057 -    if (s == NULL || s->mode != 'r') return -1;
4058 -
4059 -    s->z_err = Z_OK;
4060 -    s->z_eof = 0;
4061 -    s->back = EOF;
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);
4066 -    s->in = 0;
4067 -    s->out = 0;
4068 -    return fseek(s->file, s->start, SEEK_SET);
4069 -}
4070 -
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.
4075 -*/
4076 -z_off_t ZEXPORT gztell (file)
4077 -    gzFile file;
4078 -{
4079 -    return gzseek(file, 0L, SEEK_CUR);
4080 -}
4081 -
4082 -/* ===========================================================================
4083 -     Returns 1 when EOF has previously been detected reading the given
4084 -   input stream, otherwise zero.
4085 -*/
4086 -int ZEXPORT gzeof (file)
4087 -    gzFile file;
4088 -{
4089 -    gz_stream *s = (gz_stream*)file;
4090 -
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.
4094 -     */
4095 -    if (s == NULL || s->mode != 'r') return 0;
4096 -    if (s->z_eof) return 1;
4097 -    return s->z_err == Z_STREAM_END;
4098 -}
4099 -
4100 -/* ===========================================================================
4101 -     Returns 1 if reading and doing so transparently, otherwise zero.
4102 -*/
4103 -int ZEXPORT gzdirect (file)
4104 -    gzFile file;
4105 -{
4106 -    gz_stream *s = (gz_stream*)file;
4107 -
4108 -    if (s == NULL || s->mode != 'r') return 0;
4109 -    return s->transparent;
4110 -}
4111 -
4112 -/* ===========================================================================
4113 -   Outputs a long in LSB order to the given file
4114 -*/
4115 -local void putLong (file, x)
4116 -    FILE *file;
4117 -    uLong x;
4118 -{
4119 -    int n;
4120 -    for (n = 0; n < 4; n++) {
4121 -        fputc((int)(x & 0xff), file);
4122 -        x >>= 8;
4123 -    }
4124 -}
4125 -
4126 -/* ===========================================================================
4127 -   Reads a long in LSB order from the given gz_stream. Sets z_err in case
4128 -   of error.
4129 -*/
4130 -local uLong getLong (s)
4131 -    gz_stream *s;
4132 -{
4133 -    uLong x = (uLong)get_byte(s);
4134 -    int c;
4135 -
4136 -    x += ((uLong)get_byte(s))<<8;
4137 -    x += ((uLong)get_byte(s))<<16;
4138 -    c = get_byte(s);
4139 -    if (c == EOF) s->z_err = Z_DATA_ERROR;
4140 -    x += ((uLong)c)<<24;
4141 -    return x;
4142 -}
4143 -
4144 -/* ===========================================================================
4145 -     Flushes all pending output if necessary, closes the compressed file
4146 -   and deallocates all the (de)compression state.
4147 -*/
4148 -int ZEXPORT gzclose (file)
4149 -    gzFile file;
4150 -{
4151 -    gz_stream *s = (gz_stream*)file;
4152 -
4153 -    if (s == NULL) return Z_STREAM_ERROR;
4154 -
4155 -    if (s->mode == 'w') {
4156 -#ifdef NO_GZCOMPRESS
4157 -        return Z_STREAM_ERROR;
4158 -#else
4159 -        if (do_flush (file, Z_FINISH) != Z_OK)
4160 -            return destroy((gz_stream*)file);
4161 -
4162 -        putLong (s->file, s->crc);
4163 -        putLong (s->file, (uLong)(s->in & 0xffffffff));
4164 -#endif
4165 -    }
4166 -    return destroy((gz_stream*)file);
4167 -}
4168 -
4169 -#ifdef STDC
4170 -#  define zstrerror(errnum) strerror(errnum)
4171 -#else
4172 -#  define zstrerror(errnum) ""
4173 -#endif
4174 -
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.
4181 -*/
4182 -const char * ZEXPORT gzerror (file, errnum)
4183 -    gzFile file;
4184 -    int *errnum;
4185 -{
4186 -    char *m;
4187 -    gz_stream *s = (gz_stream*)file;
4188 -
4189 -    if (s == NULL) {
4190 -        *errnum = Z_STREAM_ERROR;
4191 -        return (const char*)ERR_MSG(Z_STREAM_ERROR);
4192 -    }
4193 -    *errnum = s->z_err;
4194 -    if (*errnum == Z_OK) return (const char*)"";
4195 -
4196 -    m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
4197 -
4198 -    if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
4199 -
4200 -    TRYFREE(s->msg);
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;
4207 -}
4208 -
4209 -/* ===========================================================================
4210 -     Clear the error and end-of-file flags, and do the same for the real file.
4211 -*/
4212 -void ZEXPORT gzclearerr (file)
4213 -    gzFile file;
4214 -{
4215 -    gz_stream *s = (gz_stream*)file;
4216 -
4217 -    if (s == NULL) return;
4218 -    if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
4219 -    s->z_eof = 0;
4220 -    clearerr(s->file);
4221 -}
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
4225 @@ -1,623 +0,0 @@
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
4229 - */
4230 -
4231 -/*
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.
4236 - */
4237 -
4238 -#include "zutil.h"
4239 -#include "inftrees.h"
4240 -#include "inflate.h"
4241 -#include "inffast.h"
4242 -
4243 -/* function prototypes */
4244 -local void fixedtables OF((struct inflate_state FAR *state));
4245 -
4246 -/*
4247 -   strm provides memory allocation functions in zalloc and zfree, or
4248 -   Z_NULL to use the library memory allocation functions.
4249 -
4250 -   windowBits is in the range 8..15, and window is a user-supplied
4251 -   window and output buffer that is 2**windowBits bytes.
4252 - */
4253 -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
4254 -z_streamp strm;
4255 -int windowBits;
4256 -unsigned char FAR *window;
4257 -const char *version;
4258 -int stream_size;
4259 -{
4260 -    struct inflate_state FAR *state;
4261 -
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;
4272 -    }
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;
4283 -    state->write = 0;
4284 -    state->whave = 0;
4285 -    return Z_OK;
4286 -}
4287 -
4288 -/*
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.
4297 - */
4298 -local void fixedtables(state)
4299 -struct inflate_state FAR *state;
4300 -{
4301 -#ifdef BUILDFIXED
4302 -    static int virgin = 1;
4303 -    static code *lenfix, *distfix;
4304 -    static code fixed[544];
4305 -
4306 -    /* build fixed huffman tables if first call (may not be thread safe) */
4307 -    if (virgin) {
4308 -        unsigned sym, bits;
4309 -        static code *next;
4310 -
4311 -        /* literal/length table */
4312 -        sym = 0;
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;
4317 -        next = fixed;
4318 -        lenfix = next;
4319 -        bits = 9;
4320 -        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
4321 -
4322 -        /* distance table */
4323 -        sym = 0;
4324 -        while (sym < 32) state->lens[sym++] = 5;
4325 -        distfix = next;
4326 -        bits = 5;
4327 -        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
4328 -
4329 -        /* do this just once */
4330 -        virgin = 0;
4331 -    }
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;
4339 -}
4340 -
4341 -/* Macros for inflateBack(): */
4342 -
4343 -/* Load returned state from inflate_fast() */
4344 -#define LOAD() \
4345 -    do { \
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; \
4352 -    } while (0)
4353 -
4354 -/* Set state from registers for inflate_fast() */
4355 -#define RESTORE() \
4356 -    do { \
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; \
4363 -    } while (0)
4364 -
4365 -/* Clear the input bit accumulator */
4366 -#define INITBITS() \
4367 -    do { \
4368 -        hold = 0; \
4369 -        bits = 0; \
4370 -    } while (0)
4371 -
4372 -/* Assure that some input is available.  If input is requested, but denied,
4373 -   then return a Z_BUF_ERROR from inflateBack(). */
4374 -#define PULL() \
4375 -    do { \
4376 -        if (have == 0) { \
4377 -            have = in(in_desc, &next); \
4378 -            if (have == 0) { \
4379 -                next = Z_NULL; \
4380 -                ret = Z_BUF_ERROR; \
4381 -                goto inf_leave; \
4382 -            } \
4383 -        } \
4384 -    } while (0)
4385 -
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() \
4389 -    do { \
4390 -        PULL(); \
4391 -        have--; \
4392 -        hold += (unsigned long)(*next++) << bits; \
4393 -        bits += 8; \
4394 -    } while (0)
4395 -
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
4398 -   an error. */
4399 -#define NEEDBITS(n) \
4400 -    do { \
4401 -        while (bits < (unsigned)(n)) \
4402 -            PULLBYTE(); \
4403 -    } while (0)
4404 -
4405 -/* Return the low n bits of the bit accumulator (n < 16) */
4406 -#define BITS(n) \
4407 -    ((unsigned)hold & ((1U << (n)) - 1))
4408 -
4409 -/* Remove n bits from the bit accumulator */
4410 -#define DROPBITS(n) \
4411 -    do { \
4412 -        hold >>= (n); \
4413 -        bits -= (unsigned)(n); \
4414 -    } while (0)
4415 -
4416 -/* Remove zero to seven bits as needed to go to a byte boundary */
4417 -#define BYTEBITS() \
4418 -    do { \
4419 -        hold >>= bits & 7; \
4420 -        bits -= bits & 7; \
4421 -    } while (0)
4422 -
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
4425 -   Z_BUF_ERROR. */
4426 -#define ROOM() \
4427 -    do { \
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; \
4434 -                goto inf_leave; \
4435 -            } \
4436 -        } \
4437 -    } while (0)
4438 -
4439 -/*
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.
4443 -
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.
4451 -
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.
4456 -
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.
4465 - */
4466 -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
4467 -z_streamp strm;
4468 -in_func in;
4469 -void FAR *in_desc;
4470 -out_func out;
4471 -void FAR *out_desc;
4472 -{
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};
4487 -
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;
4492 -
4493 -    /* Reset the state */
4494 -    strm->msg = Z_NULL;
4495 -    state->mode = TYPE;
4496 -    state->last = 0;
4497 -    state->whave = 0;
4498 -    next = strm->next_in;
4499 -    have = next != Z_NULL ? strm->avail_in : 0;
4500 -    hold = 0;
4501 -    bits = 0;
4502 -    put = state->window;
4503 -    left = state->wsize;
4504 -
4505 -    /* Inflate until end of block marked as last */
4506 -    for (;;)
4507 -        switch (state->mode) {
4508 -        case TYPE:
4509 -            /* determine and dispatch block type */
4510 -            if (state->last) {
4511 -                BYTEBITS();
4512 -                state->mode = DONE;
4513 -                break;
4514 -            }
4515 -            NEEDBITS(3);
4516 -            state->last = BITS(1);
4517 -            DROPBITS(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;
4523 -                break;
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 */
4529 -                break;
4530 -            case 2:                             /* dynamic block */
4531 -                Tracev((stderr, "inflate:     dynamic codes block%s\n",
4532 -                        state->last ? " (last)" : ""));
4533 -                state->mode = TABLE;
4534 -                break;
4535 -            case 3:
4536 -                strm->msg = (char *)"invalid block type";
4537 -                state->mode = BAD;
4538 -            }
4539 -            DROPBITS(2);
4540 -            break;
4541 -
4542 -        case STORED:
4543 -            /* get and verify stored block length */
4544 -            BYTEBITS();                         /* go to byte boundary */
4545 -            NEEDBITS(32);
4546 -            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
4547 -                strm->msg = (char *)"invalid stored block lengths";
4548 -                state->mode = BAD;
4549 -                break;
4550 -            }
4551 -            state->length = (unsigned)hold & 0xffff;
4552 -            Tracev((stderr, "inflate:       stored length %u\n",
4553 -                    state->length));
4554 -            INITBITS();
4555 -
4556 -            /* copy stored block from input to output */
4557 -            while (state->length != 0) {
4558 -                copy = state->length;
4559 -                PULL();
4560 -                ROOM();
4561 -                if (copy > have) copy = have;
4562 -                if (copy > left) copy = left;
4563 -                zmemcpy(put, next, copy);
4564 -                have -= copy;
4565 -                next += copy;
4566 -                left -= copy;
4567 -                put += copy;
4568 -                state->length -= copy;
4569 -            }
4570 -            Tracev((stderr, "inflate:       stored end\n"));
4571 -            state->mode = TYPE;
4572 -            break;
4573 -
4574 -        case TABLE:
4575 -            /* get dynamic table entries descriptor */
4576 -            NEEDBITS(14);
4577 -            state->nlen = BITS(5) + 257;
4578 -            DROPBITS(5);
4579 -            state->ndist = BITS(5) + 1;
4580 -            DROPBITS(5);
4581 -            state->ncode = BITS(4) + 4;
4582 -            DROPBITS(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;
4587 -                break;
4588 -            }
4589 -#endif
4590 -            Tracev((stderr, "inflate:       table sizes ok\n"));
4591 -
4592 -            /* get code length code lengths (not a typo) */
4593 -            state->have = 0;
4594 -            while (state->have < state->ncode) {
4595 -                NEEDBITS(3);
4596 -                state->lens[order[state->have++]] = (unsigned short)BITS(3);
4597 -                DROPBITS(3);
4598 -            }
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);
4606 -            if (ret) {
4607 -                strm->msg = (char *)"invalid code lengths set";
4608 -                state->mode = BAD;
4609 -                break;
4610 -            }
4611 -            Tracev((stderr, "inflate:       code lengths ok\n"));
4612 -
4613 -            /* get length and distance code code lengths */
4614 -            state->have = 0;
4615 -            while (state->have < state->nlen + state->ndist) {
4616 -                for (;;) {
4617 -                    this = state->lencode[BITS(state->lenbits)];
4618 -                    if ((unsigned)(this.bits) <= bits) break;
4619 -                    PULLBYTE();
4620 -                }
4621 -                if (this.val < 16) {
4622 -                    NEEDBITS(this.bits);
4623 -                    DROPBITS(this.bits);
4624 -                    state->lens[state->have++] = this.val;
4625 -                }
4626 -                else {
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;
4633 -                            break;
4634 -                        }
4635 -                        len = (unsigned)(state->lens[state->have - 1]);
4636 -                        copy = 3 + BITS(2);
4637 -                        DROPBITS(2);
4638 -                    }
4639 -                    else if (this.val == 17) {
4640 -                        NEEDBITS(this.bits + 3);
4641 -                        DROPBITS(this.bits);
4642 -                        len = 0;
4643 -                        copy = 3 + BITS(3);
4644 -                        DROPBITS(3);
4645 -                    }
4646 -                    else {
4647 -                        NEEDBITS(this.bits + 7);
4648 -                        DROPBITS(this.bits);
4649 -                        len = 0;
4650 -                        copy = 11 + BITS(7);
4651 -                        DROPBITS(7);
4652 -                    }
4653 -                    if (state->have + copy > state->nlen + state->ndist) {
4654 -                        strm->msg = (char *)"invalid bit length repeat";
4655 -                        state->mode = BAD;
4656 -                        break;
4657 -                    }
4658 -                    while (copy--)
4659 -                        state->lens[state->have++] = (unsigned short)len;
4660 -                }
4661 -            }
4662 -
4663 -            /* handle error breaks in while */
4664 -            if (state->mode == BAD) break;
4665 -
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);
4672 -            if (ret) {
4673 -                strm->msg = (char *)"invalid literal/lengths set";
4674 -                state->mode = BAD;
4675 -                break;
4676 -            }
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);
4681 -            if (ret) {
4682 -                strm->msg = (char *)"invalid distances set";
4683 -                state->mode = BAD;
4684 -                break;
4685 -            }
4686 -            Tracev((stderr, "inflate:       codes ok\n"));
4687 -            state->mode = LEN;
4688 -
4689 -        case LEN:
4690 -            /* use inflate_fast() if we have enough input and output */
4691 -            if (have >= 6 && left >= 258) {
4692 -                RESTORE();
4693 -                if (state->whave < state->wsize)
4694 -                    state->whave = state->wsize - left;
4695 -                inflate_fast(strm, state->wsize);
4696 -                LOAD();
4697 -                break;
4698 -            }
4699 -
4700 -            /* get a literal, length, or end-of-block code */
4701 -            for (;;) {
4702 -                this = state->lencode[BITS(state->lenbits)];
4703 -                if ((unsigned)(this.bits) <= bits) break;
4704 -                PULLBYTE();
4705 -            }
4706 -            if (this.op && (this.op & 0xf0) == 0) {
4707 -                last = this;
4708 -                for (;;) {
4709 -                    this = state->lencode[last.val +
4710 -                            (BITS(last.bits + last.op) >> last.bits)];
4711 -                    if ((unsigned)(last.bits + this.bits) <= bits) break;
4712 -                    PULLBYTE();
4713 -                }
4714 -                DROPBITS(last.bits);
4715 -            }
4716 -            DROPBITS(this.bits);
4717 -            state->length = (unsigned)this.val;
4718 -
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));
4724 -                ROOM();
4725 -                *put++ = (unsigned char)(state->length);
4726 -                left--;
4727 -                state->mode = LEN;
4728 -                break;
4729 -            }
4730 -
4731 -            /* process end of block */
4732 -            if (this.op & 32) {
4733 -                Tracevv((stderr, "inflate:         end of block\n"));
4734 -                state->mode = TYPE;
4735 -                break;
4736 -            }
4737 -
4738 -            /* invalid code */
4739 -            if (this.op & 64) {
4740 -                strm->msg = (char *)"invalid literal/length code";
4741 -                state->mode = BAD;
4742 -                break;
4743 -            }
4744 -
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);
4751 -            }
4752 -            Tracevv((stderr, "inflate:         length %u\n", state->length));
4753 -
4754 -            /* get distance code */
4755 -            for (;;) {
4756 -                this = state->distcode[BITS(state->distbits)];
4757 -                if ((unsigned)(this.bits) <= bits) break;
4758 -                PULLBYTE();
4759 -            }
4760 -            if ((this.op & 0xf0) == 0) {
4761 -                last = this;
4762 -                for (;;) {
4763 -                    this = state->distcode[last.val +
4764 -                            (BITS(last.bits + last.op) >> last.bits)];
4765 -                    if ((unsigned)(last.bits + this.bits) <= bits) break;
4766 -                    PULLBYTE();
4767 -                }
4768 -                DROPBITS(last.bits);
4769 -            }
4770 -            DROPBITS(this.bits);
4771 -            if (this.op & 64) {
4772 -                strm->msg = (char *)"invalid distance code";
4773 -                state->mode = BAD;
4774 -                break;
4775 -            }
4776 -            state->offset = (unsigned)this.val;
4777 -
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);
4784 -            }
4785 -            if (state->offset > state->wsize - (state->whave < state->wsize ?
4786 -                                                left : 0)) {
4787 -                strm->msg = (char *)"invalid distance too far back";
4788 -                state->mode = BAD;
4789 -                break;
4790 -            }
4791 -            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
4792 -
4793 -            /* copy match from window to output */
4794 -            do {
4795 -                ROOM();
4796 -                copy = state->wsize - state->offset;
4797 -                if (copy < left) {
4798 -                    from = put + copy;
4799 -                    copy = left - copy;
4800 -                }
4801 -                else {
4802 -                    from = put - state->offset;
4803 -                    copy = left;
4804 -                }
4805 -                if (copy > state->length) copy = state->length;
4806 -                state->length -= copy;
4807 -                left -= copy;
4808 -                do {
4809 -                    *put++ = *from++;
4810 -                } while (--copy);
4811 -            } while (state->length != 0);
4812 -            break;
4813 -
4814 -        case DONE:
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;
4820 -            }
4821 -            goto inf_leave;
4822 -
4823 -        case BAD:
4824 -            ret = Z_DATA_ERROR;
4825 -            goto inf_leave;
4826 -
4827 -        default:                /* can't happen, but makes compilers happy */
4828 -            ret = Z_STREAM_ERROR;
4829 -            goto inf_leave;
4830 -        }
4831 -
4832 -    /* Return unused input */
4833 -  inf_leave:
4834 -    strm->next_in = next;
4835 -    strm->avail_in = have;
4836 -    return ret;
4837 -}
4838 -
4839 -int ZEXPORT inflateBackEnd(strm)
4840 -z_streamp strm;
4841 -{
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"));
4847 -    return Z_OK;
4848 -}
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
4852 @@ -1,318 +0,0 @@
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
4856 - */
4857 -
4858 -#include "zutil.h"
4859 -#include "inftrees.h"
4860 -#include "inflate.h"
4861 -#include "inffast.h"
4862 -
4863 -#ifndef ASMINF
4864 -
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:
4871 -   - none
4872 -   No measurable difference:
4873 -   - Pentium III (Anderson)
4874 -   - M68060 (Nikl)
4875 - */
4876 -#ifdef POSTINC
4877 -#  define OFF 0
4878 -#  define PUP(a) *(a)++
4879 -#else
4880 -#  define OFF 1
4881 -#  define PUP(a) *++(a)
4882 -#endif
4883 -
4884 -/*
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.
4891 -
4892 -   Entry assumptions:
4893 -
4894 -        state->mode == LEN
4895 -        strm->avail_in >= 6
4896 -        strm->avail_out >= 258
4897 -        start >= strm->avail_out
4898 -        state->bits < 8
4899 -
4900 -   On return, state->mode is one of:
4901 -
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
4905 -
4906 -   Notes:
4907 -
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.
4913 -
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
4917 -      output space.
4918 - */
4919 -void inflate_fast(strm, start)
4920 -z_streamp strm;
4921 -unsigned start;         /* inflate()'s starting value for strm->avail_out */
4922 -{
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 */
4931 -#endif
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 */
4948 -
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;
4958 -#endif
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;
4969 -
4970 -    /* decode literals and length/distances until end-of-block or not enough
4971 -       input data or output space */
4972 -    do {
4973 -        if (bits < 15) {
4974 -            hold += (unsigned long)(PUP(in)) << bits;
4975 -            bits += 8;
4976 -            hold += (unsigned long)(PUP(in)) << bits;
4977 -            bits += 8;
4978 -        }
4979 -        this = lcode[hold & lmask];
4980 -      dolen:
4981 -        op = (unsigned)(this.bits);
4982 -        hold >>= op;
4983 -        bits -= op;
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);
4990 -        }
4991 -        else if (op & 16) {                     /* length base */
4992 -            len = (unsigned)(this.val);
4993 -            op &= 15;                           /* number of extra bits */
4994 -            if (op) {
4995 -                if (bits < op) {
4996 -                    hold += (unsigned long)(PUP(in)) << bits;
4997 -                    bits += 8;
4998 -                }
4999 -                len += (unsigned)hold & ((1U << op) - 1);
5000 -                hold >>= op;
5001 -                bits -= op;
5002 -            }
5003 -            Tracevv((stderr, "inflate:         length %u\n", len));
5004 -            if (bits < 15) {
5005 -                hold += (unsigned long)(PUP(in)) << bits;
5006 -                bits += 8;
5007 -                hold += (unsigned long)(PUP(in)) << bits;
5008 -                bits += 8;
5009 -            }
5010 -            this = dcode[hold & dmask];
5011 -          dodist:
5012 -            op = (unsigned)(this.bits);
5013 -            hold >>= op;
5014 -            bits -= op;
5015 -            op = (unsigned)(this.op);
5016 -            if (op & 16) {                      /* distance base */
5017 -                dist = (unsigned)(this.val);
5018 -                op &= 15;                       /* number of extra bits */
5019 -                if (bits < op) {
5020 -                    hold += (unsigned long)(PUP(in)) << bits;
5021 -                    bits += 8;
5022 -                    if (bits < op) {
5023 -                        hold += (unsigned long)(PUP(in)) << bits;
5024 -                        bits += 8;
5025 -                    }
5026 -                }
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;
5032 -                    break;
5033 -                }
5034 -#endif
5035 -                hold >>= op;
5036 -                bits -= op;
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 */
5041 -                    if (op > whave) {
5042 -                        strm->msg = (char *)"invalid distance too far back";
5043 -                        state->mode = BAD;
5044 -                        break;
5045 -                    }
5046 -                    from = window - OFF;
5047 -                    if (write == 0) {           /* very common case */
5048 -                        from += wsize - op;
5049 -                        if (op < len) {         /* some from window */
5050 -                            len -= op;
5051 -                            do {
5052 -                                PUP(out) = PUP(from);
5053 -                            } while (--op);
5054 -                            from = out - dist;  /* rest from output */
5055 -                        }
5056 -                    }
5057 -                    else if (write < op) {      /* wrap around window */
5058 -                        from += wsize + write - op;
5059 -                        op -= write;
5060 -                        if (op < len) {         /* some from end of window */
5061 -                            len -= op;
5062 -                            do {
5063 -                                PUP(out) = PUP(from);
5064 -                            } while (--op);
5065 -                            from = window - OFF;
5066 -                            if (write < len) {  /* some from start of window */
5067 -                                op = write;
5068 -                                len -= op;
5069 -                                do {
5070 -                                    PUP(out) = PUP(from);
5071 -                                } while (--op);
5072 -                                from = out - dist;      /* rest from output */
5073 -                            }
5074 -                        }
5075 -                    }
5076 -                    else {                      /* contiguous in window */
5077 -                        from += write - op;
5078 -                        if (op < len) {         /* some from window */
5079 -                            len -= op;
5080 -                            do {
5081 -                                PUP(out) = PUP(from);
5082 -                            } while (--op);
5083 -                            from = out - dist;  /* rest from output */
5084 -                        }
5085 -                    }
5086 -                    while (len > 2) {
5087 -                        PUP(out) = PUP(from);
5088 -                        PUP(out) = PUP(from);
5089 -                        PUP(out) = PUP(from);
5090 -                        len -= 3;
5091 -                    }
5092 -                    if (len) {
5093 -                        PUP(out) = PUP(from);
5094 -                        if (len > 1)
5095 -                            PUP(out) = PUP(from);
5096 -                    }
5097 -                }
5098 -                else {
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);
5104 -                        len -= 3;
5105 -                    } while (len > 2);
5106 -                    if (len) {
5107 -                        PUP(out) = PUP(from);
5108 -                        if (len > 1)
5109 -                            PUP(out) = PUP(from);
5110 -                    }
5111 -                }
5112 -            }
5113 -            else if ((op & 64) == 0) {          /* 2nd level distance code */
5114 -                this = dcode[this.val + (hold & ((1U << op) - 1))];
5115 -                goto dodist;
5116 -            }
5117 -            else {
5118 -                strm->msg = (char *)"invalid distance code";
5119 -                state->mode = BAD;
5120 -                break;
5121 -            }
5122 -        }
5123 -        else if ((op & 64) == 0) {              /* 2nd level length code */
5124 -            this = lcode[this.val + (hold & ((1U << op) - 1))];
5125 -            goto dolen;
5126 -        }
5127 -        else if (op & 32) {                     /* end-of-block */
5128 -            Tracevv((stderr, "inflate:         end of block\n"));
5129 -            state->mode = TYPE;
5130 -            break;
5131 -        }
5132 -        else {
5133 -            strm->msg = (char *)"invalid literal/length code";
5134 -            state->mode = BAD;
5135 -            break;
5136 -        }
5137 -    } while (in < last && out < end);
5138 -
5139 -    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
5140 -    len = bits >> 3;
5141 -    in -= len;
5142 -    bits -= len << 3;
5143 -    hold &= (1U << bits) - 1;
5144 -
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;
5153 -    return;
5154 -}
5155 -
5156 -/*
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
5168 - */
5169 -
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
5174 @@ -1,11 +0,0 @@
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
5178 - */
5179 -
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.
5183 - */
5184 -
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
5189 @@ -1,94 +0,0 @@
5190 -    /* inffixed.h -- table for decoding fixed codes
5191 -     * Generated automatically by makefixed().
5192 -     */
5193 -
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.
5197 -     */
5198 -
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},
5273 -        {0,9,255}
5274 -    };
5275 -
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}
5283 -    };
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
5287 @@ -1,1368 +0,0 @@
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
5291 - */
5292 -
5293 -/*
5294 - * Change history:
5295 - *
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
5301 - *
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
5308 - *
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
5315 - *
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
5327 - *
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
5342 - *   window copying
5343 - *
5344 - * 1.2.beta5    1 Jan 2003
5345 - * - Improved inflateBack() interface to allow the caller to provide initial
5346 - *   input in strm.
5347 - * - Fixed stored blocks bug in inflateBack()
5348 - *
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 *
5355 - *
5356 - * 1.2.beta7    27 Jan 2003
5357 - * - Changed many types to unsigned or unsigned short to avoid warnings
5358 - * - Added inflateCopy() function
5359 - *
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()
5366 - *
5367 - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
5368 - */
5369 -
5370 -#include "zutil.h"
5371 -#include "inftrees.h"
5372 -#include "inflate.h"
5373 -#include "inffast.h"
5374 -
5375 -#ifdef MAKEFIXED
5376 -#  ifndef BUILDFIXED
5377 -#    define BUILDFIXED
5378 -#  endif
5379 -#endif
5380 -
5381 -/* function prototypes */
5382 -local void fixedtables OF((struct inflate_state FAR *state));
5383 -local int updatewindow OF((z_streamp strm, unsigned out));
5384 -#ifdef BUILDFIXED
5385 -   void makefixed OF((void));
5386 -#endif
5387 -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
5388 -                              unsigned len));
5389 -
5390 -int ZEXPORT inflateReset(strm)
5391 -z_streamp strm;
5392 -{
5393 -    struct inflate_state FAR *state;
5394 -
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;
5401 -    state->last = 0;
5402 -    state->havedict = 0;
5403 -    state->dmax = 32768U;
5404 -    state->head = Z_NULL;
5405 -    state->wsize = 0;
5406 -    state->whave = 0;
5407 -    state->write = 0;
5408 -    state->hold = 0;
5409 -    state->bits = 0;
5410 -    state->lencode = state->distcode = state->next = state->codes;
5411 -    Tracev((stderr, "inflate: reset\n"));
5412 -    return Z_OK;
5413 -}
5414 -
5415 -int ZEXPORT inflatePrime(strm, bits, value)
5416 -z_streamp strm;
5417 -int bits;
5418 -int value;
5419 -{
5420 -    struct inflate_state FAR *state;
5421 -
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;
5428 -    return Z_OK;
5429 -}
5430 -
5431 -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
5432 -z_streamp strm;
5433 -int windowBits;
5434 -const char *version;
5435 -int stream_size;
5436 -{
5437 -    struct inflate_state FAR *state;
5438 -
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;
5447 -    }
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) {
5455 -        state->wrap = 0;
5456 -        windowBits = -windowBits;
5457 -    }
5458 -    else {
5459 -        state->wrap = (windowBits >> 4) + 1;
5460 -#ifdef GUNZIP
5461 -        if (windowBits < 48) windowBits &= 15;
5462 -#endif
5463 -    }
5464 -    if (windowBits < 8 || windowBits > 15) {
5465 -        ZFREE(strm, state);
5466 -        strm->state = Z_NULL;
5467 -        return Z_STREAM_ERROR;
5468 -    }
5469 -    state->wbits = (unsigned)windowBits;
5470 -    state->window = Z_NULL;
5471 -    return inflateReset(strm);
5472 -}
5473 -
5474 -int ZEXPORT inflateInit_(strm, version, stream_size)
5475 -z_streamp strm;
5476 -const char *version;
5477 -int stream_size;
5478 -{
5479 -    return inflateInit2_(strm, DEF_WBITS, version, stream_size);
5480 -}
5481 -
5482 -/*
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.
5491 - */
5492 -local void fixedtables(state)
5493 -struct inflate_state FAR *state;
5494 -{
5495 -#ifdef BUILDFIXED
5496 -    static int virgin = 1;
5497 -    static code *lenfix, *distfix;
5498 -    static code fixed[544];
5499 -
5500 -    /* build fixed huffman tables if first call (may not be thread safe) */
5501 -    if (virgin) {
5502 -        unsigned sym, bits;
5503 -        static code *next;
5504 -
5505 -        /* literal/length table */
5506 -        sym = 0;
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;
5511 -        next = fixed;
5512 -        lenfix = next;
5513 -        bits = 9;
5514 -        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
5515 -
5516 -        /* distance table */
5517 -        sym = 0;
5518 -        while (sym < 32) state->lens[sym++] = 5;
5519 -        distfix = next;
5520 -        bits = 5;
5521 -        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
5522 -
5523 -        /* do this just once */
5524 -        virgin = 0;
5525 -    }
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;
5533 -}
5534 -
5535 -#ifdef MAKEFIXED
5536 -#include <stdio.h>
5537 -
5538 -/*
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:
5543 -
5544 -    void makefixed(void);
5545 -
5546 -    int main(void)
5547 -    {
5548 -        makefixed();
5549 -        return 0;
5550 -    }
5551 -
5552 -   Then that can be linked with zlib built with MAKEFIXED defined and run:
5553 -
5554 -    a.out > inffixed.h
5555 - */
5556 -void makefixed()
5557 -{
5558 -    unsigned low, size;
5559 -    struct inflate_state state;
5560 -
5561 -    fixedtables(&state);
5562 -    puts("    /* inffixed.h -- table for decoding fixed codes");
5563 -    puts("     * Generated automatically by makefixed().");
5564 -    puts("     */");
5565 -    puts("");
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.");
5569 -    puts("     */");
5570 -    puts("");
5571 -    size = 1U << 9;
5572 -    printf("    static const code lenfix[%u] = {", size);
5573 -    low = 0;
5574 -    for (;;) {
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;
5579 -        putchar(',');
5580 -    }
5581 -    puts("\n    };");
5582 -    size = 1U << 5;
5583 -    printf("\n    static const code distfix[%u] = {", size);
5584 -    low = 0;
5585 -    for (;;) {
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;
5590 -        putchar(',');
5591 -    }
5592 -    puts("\n    };");
5593 -}
5594 -#endif /* MAKEFIXED */
5595 -
5596 -/*
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
5602 -   is loaded.
5603 -
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.
5609 - */
5610 -local int updatewindow(strm, out)
5611 -z_streamp strm;
5612 -unsigned out;
5613 -{
5614 -    struct inflate_state FAR *state;
5615 -    unsigned copy, dist;
5616 -
5617 -    state = (struct inflate_state FAR *)strm->state;
5618 -
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;
5625 -    }
5626 -
5627 -    /* if window not in use yet, initialize */
5628 -    if (state->wsize == 0) {
5629 -        state->wsize = 1U << state->wbits;
5630 -        state->write = 0;
5631 -        state->whave = 0;
5632 -    }
5633 -
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);
5638 -        state->write = 0;
5639 -        state->whave = state->wsize;
5640 -    }
5641 -    else {
5642 -        dist = state->wsize - state->write;
5643 -        if (dist > copy) dist = copy;
5644 -        zmemcpy(state->window + state->write, strm->next_out - copy, dist);
5645 -        copy -= dist;
5646 -        if (copy) {
5647 -            zmemcpy(state->window, strm->next_out - copy, copy);
5648 -            state->write = copy;
5649 -            state->whave = state->wsize;
5650 -        }
5651 -        else {
5652 -            state->write += dist;
5653 -            if (state->write == state->wsize) state->write = 0;
5654 -            if (state->whave < state->wsize) state->whave += dist;
5655 -        }
5656 -    }
5657 -    return 0;
5658 -}
5659 -
5660 -/* Macros for inflate(): */
5661 -
5662 -/* check function to use adler32() for zlib or crc32() for gzip */
5663 -#ifdef GUNZIP
5664 -#  define UPDATE(check, buf, len) \
5665 -    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
5666 -#else
5667 -#  define UPDATE(check, buf, len) adler32(check, buf, len)
5668 -#endif
5669 -
5670 -/* check macros for header crc */
5671 -#ifdef GUNZIP
5672 -#  define CRC2(check, word) \
5673 -    do { \
5674 -        hbuf[0] = (unsigned char)(word); \
5675 -        hbuf[1] = (unsigned char)((word) >> 8); \
5676 -        check = crc32(check, hbuf, 2); \
5677 -    } while (0)
5678 -
5679 -#  define CRC4(check, word) \
5680 -    do { \
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); \
5686 -    } while (0)
5687 -#endif
5688 -
5689 -/* Load registers with state in inflate() for speed */
5690 -#define LOAD() \
5691 -    do { \
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; \
5698 -    } while (0)
5699 -
5700 -/* Restore state from registers in inflate() */
5701 -#define RESTORE() \
5702 -    do { \
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; \
5709 -    } while (0)
5710 -
5711 -/* Clear the input bit accumulator */
5712 -#define INITBITS() \
5713 -    do { \
5714 -        hold = 0; \
5715 -        bits = 0; \
5716 -    } while (0)
5717 -
5718 -/* Get a byte of input into the bit accumulator, or return from inflate()
5719 -   if there is no input available. */
5720 -#define PULLBYTE() \
5721 -    do { \
5722 -        if (have == 0) goto inf_leave; \
5723 -        have--; \
5724 -        hold += (unsigned long)(*next++) << bits; \
5725 -        bits += 8; \
5726 -    } while (0)
5727 -
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) \
5731 -    do { \
5732 -        while (bits < (unsigned)(n)) \
5733 -            PULLBYTE(); \
5734 -    } while (0)
5735 -
5736 -/* Return the low n bits of the bit accumulator (n < 16) */
5737 -#define BITS(n) \
5738 -    ((unsigned)hold & ((1U << (n)) - 1))
5739 -
5740 -/* Remove n bits from the bit accumulator */
5741 -#define DROPBITS(n) \
5742 -    do { \
5743 -        hold >>= (n); \
5744 -        bits -= (unsigned)(n); \
5745 -    } while (0)
5746 -
5747 -/* Remove zero to seven bits as needed to go to a byte boundary */
5748 -#define BYTEBITS() \
5749 -    do { \
5750 -        hold >>= bits & 7; \
5751 -        bits -= bits & 7; \
5752 -    } while (0)
5753 -
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))
5758 -
5759 -/*
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:
5763 -
5764 -    for (;;) switch (state) {
5765 -    ...
5766 -    case STATEn:
5767 -        if (not enough input data or output space to make progress)
5768 -            return;
5769 -        ... make progress ...
5770 -        state = STATEm;
5771 -        break;
5772 -    ...
5773 -    }
5774 -
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
5780 -   is:
5781 -
5782 -        NEEDBITS(n);
5783 -        ... do something with BITS(n) ...
5784 -        DROPBITS(n);
5785 -
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.
5793 -
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.
5798 -
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()
5803 -   returns:
5804 -
5805 -    case STATEw:
5806 -        while (want < need) {
5807 -            NEEDBITS(n);
5808 -            keep[want++] = BITS(n);
5809 -            DROPBITS(n);
5810 -        }
5811 -        state = STATEx;
5812 -    case STATEx:
5813 -
5814 -   As shown above, if the next state is also the next case, then the break
5815 -   is omitted.
5816 -
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.
5820 -
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().
5829 -
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.
5839 - */
5840 -
5841 -int ZEXPORT inflate(strm, flush)
5842 -z_streamp strm;
5843 -int flush;
5844 -{
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 */
5858 -#ifdef GUNZIP
5859 -    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
5860 -#endif
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};
5863 -
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;
5867 -
5868 -    state = (struct inflate_state FAR *)strm->state;
5869 -    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
5870 -    LOAD();
5871 -    in = have;
5872 -    out = left;
5873 -    ret = Z_OK;
5874 -    for (;;)
5875 -        switch (state->mode) {
5876 -        case HEAD:
5877 -            if (state->wrap == 0) {
5878 -                state->mode = TYPEDO;
5879 -                break;
5880 -            }
5881 -            NEEDBITS(16);
5882 -#ifdef GUNZIP
5883 -            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
5884 -                state->check = crc32(0L, Z_NULL, 0);
5885 -                CRC2(state->check, hold);
5886 -                INITBITS();
5887 -                state->mode = FLAGS;
5888 -                break;
5889 -            }
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 */
5894 -#else
5895 -            if (
5896 -#endif
5897 -                ((BITS(8) << 8) + (hold >> 8)) % 31) {
5898 -                strm->msg = (char *)"incorrect header check";
5899 -                state->mode = BAD;
5900 -                break;
5901 -            }
5902 -            if (BITS(4) != Z_DEFLATED) {
5903 -                strm->msg = (char *)"unknown compression method";
5904 -                state->mode = BAD;
5905 -                break;
5906 -            }
5907 -            DROPBITS(4);
5908 -            len = BITS(4) + 8;
5909 -            if (len > state->wbits) {
5910 -                strm->msg = (char *)"invalid window size";
5911 -                state->mode = BAD;
5912 -                break;
5913 -            }
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;
5918 -            INITBITS();
5919 -            break;
5920 -#ifdef GUNZIP
5921 -        case FLAGS:
5922 -            NEEDBITS(16);
5923 -            state->flags = (int)(hold);
5924 -            if ((state->flags & 0xff) != Z_DEFLATED) {
5925 -                strm->msg = (char *)"unknown compression method";
5926 -                state->mode = BAD;
5927 -                break;
5928 -            }
5929 -            if (state->flags & 0xe000) {
5930 -                strm->msg = (char *)"unknown header flags set";
5931 -                state->mode = BAD;
5932 -                break;
5933 -            }
5934 -            if (state->head != Z_NULL)
5935 -                state->head->text = (int)((hold >> 8) & 1);
5936 -            if (state->flags & 0x0200) CRC2(state->check, hold);
5937 -            INITBITS();
5938 -            state->mode = TIME;
5939 -        case TIME:
5940 -            NEEDBITS(32);
5941 -            if (state->head != Z_NULL)
5942 -                state->head->time = hold;
5943 -            if (state->flags & 0x0200) CRC4(state->check, hold);
5944 -            INITBITS();
5945 -            state->mode = OS;
5946 -        case OS:
5947 -            NEEDBITS(16);
5948 -            if (state->head != Z_NULL) {
5949 -                state->head->xflags = (int)(hold & 0xff);
5950 -                state->head->os = (int)(hold >> 8);
5951 -            }
5952 -            if (state->flags & 0x0200) CRC2(state->check, hold);
5953 -            INITBITS();
5954 -            state->mode = EXLEN;
5955 -        case EXLEN:
5956 -            if (state->flags & 0x0400) {
5957 -                NEEDBITS(16);
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);
5962 -                INITBITS();
5963 -            }
5964 -            else if (state->head != Z_NULL)
5965 -                state->head->extra = Z_NULL;
5966 -            state->mode = EXTRA;
5967 -        case EXTRA:
5968 -            if (state->flags & 0x0400) {
5969 -                copy = state->length;
5970 -                if (copy > have) copy = have;
5971 -                if (copy) {
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);
5978 -                    }
5979 -                    if (state->flags & 0x0200)
5980 -                        state->check = crc32(state->check, next, copy);
5981 -                    have -= copy;
5982 -                    next += copy;
5983 -                    state->length -= copy;
5984 -                }
5985 -                if (state->length) goto inf_leave;
5986 -            }
5987 -            state->length = 0;
5988 -            state->mode = NAME;
5989 -        case NAME:
5990 -            if (state->flags & 0x0800) {
5991 -                if (have == 0) goto inf_leave;
5992 -                copy = 0;
5993 -                do {
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);
6002 -                have -= copy;
6003 -                next += copy;
6004 -                if (len) goto inf_leave;
6005 -            }
6006 -            else if (state->head != Z_NULL)
6007 -                state->head->name = Z_NULL;
6008 -            state->length = 0;
6009 -            state->mode = COMMENT;
6010 -        case COMMENT:
6011 -            if (state->flags & 0x1000) {
6012 -                if (have == 0) goto inf_leave;
6013 -                copy = 0;
6014 -                do {
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);
6023 -                have -= copy;
6024 -                next += copy;
6025 -                if (len) goto inf_leave;
6026 -            }
6027 -            else if (state->head != Z_NULL)
6028 -                state->head->comment = Z_NULL;
6029 -            state->mode = HCRC;
6030 -        case HCRC:
6031 -            if (state->flags & 0x0200) {
6032 -                NEEDBITS(16);
6033 -                if (hold != (state->check & 0xffff)) {
6034 -                    strm->msg = (char *)"header crc mismatch";
6035 -                    state->mode = BAD;
6036 -                    break;
6037 -                }
6038 -                INITBITS();
6039 -            }
6040 -            if (state->head != Z_NULL) {
6041 -                state->head->hcrc = (int)((state->flags >> 9) & 1);
6042 -                state->head->done = 1;
6043 -            }
6044 -            strm->adler = state->check = crc32(0L, Z_NULL, 0);
6045 -            state->mode = TYPE;
6046 -            break;
6047 -#endif
6048 -        case DICTID:
6049 -            NEEDBITS(32);
6050 -            strm->adler = state->check = REVERSE(hold);
6051 -            INITBITS();
6052 -            state->mode = DICT;
6053 -        case DICT:
6054 -            if (state->havedict == 0) {
6055 -                RESTORE();
6056 -                return Z_NEED_DICT;
6057 -            }
6058 -            strm->adler = state->check = adler32(0L, Z_NULL, 0);
6059 -            state->mode = TYPE;
6060 -        case TYPE:
6061 -            if (flush == Z_BLOCK) goto inf_leave;
6062 -        case TYPEDO:
6063 -            if (state->last) {
6064 -                BYTEBITS();
6065 -                state->mode = CHECK;
6066 -                break;
6067 -            }
6068 -            NEEDBITS(3);
6069 -            state->last = BITS(1);
6070 -            DROPBITS(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;
6076 -                break;
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 */
6082 -                break;
6083 -            case 2:                             /* dynamic block */
6084 -                Tracev((stderr, "inflate:     dynamic codes block%s\n",
6085 -                        state->last ? " (last)" : ""));
6086 -                state->mode = TABLE;
6087 -                break;
6088 -            case 3:
6089 -                strm->msg = (char *)"invalid block type";
6090 -                state->mode = BAD;
6091 -            }
6092 -            DROPBITS(2);
6093 -            break;
6094 -        case STORED:
6095 -            BYTEBITS();                         /* go to byte boundary */
6096 -            NEEDBITS(32);
6097 -            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
6098 -                strm->msg = (char *)"invalid stored block lengths";
6099 -                state->mode = BAD;
6100 -                break;
6101 -            }
6102 -            state->length = (unsigned)hold & 0xffff;
6103 -            Tracev((stderr, "inflate:       stored length %u\n",
6104 -                    state->length));
6105 -            INITBITS();
6106 -            state->mode = COPY;
6107 -        case COPY:
6108 -            copy = state->length;
6109 -            if (copy) {
6110 -                if (copy > have) copy = have;
6111 -                if (copy > left) copy = left;
6112 -                if (copy == 0) goto inf_leave;
6113 -                zmemcpy(put, next, copy);
6114 -                have -= copy;
6115 -                next += copy;
6116 -                left -= copy;
6117 -                put += copy;
6118 -                state->length -= copy;
6119 -                break;
6120 -            }
6121 -            Tracev((stderr, "inflate:       stored end\n"));
6122 -            state->mode = TYPE;
6123 -            break;
6124 -        case TABLE:
6125 -            NEEDBITS(14);
6126 -            state->nlen = BITS(5) + 257;
6127 -            DROPBITS(5);
6128 -            state->ndist = BITS(5) + 1;
6129 -            DROPBITS(5);
6130 -            state->ncode = BITS(4) + 4;
6131 -            DROPBITS(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;
6136 -                break;
6137 -            }
6138 -#endif
6139 -            Tracev((stderr, "inflate:       table sizes ok\n"));
6140 -            state->have = 0;
6141 -            state->mode = LENLENS;
6142 -        case LENLENS:
6143 -            while (state->have < state->ncode) {
6144 -                NEEDBITS(3);
6145 -                state->lens[order[state->have++]] = (unsigned short)BITS(3);
6146 -                DROPBITS(3);
6147 -            }
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);
6155 -            if (ret) {
6156 -                strm->msg = (char *)"invalid code lengths set";
6157 -                state->mode = BAD;
6158 -                break;
6159 -            }
6160 -            Tracev((stderr, "inflate:       code lengths ok\n"));
6161 -            state->have = 0;
6162 -            state->mode = CODELENS;
6163 -        case CODELENS:
6164 -            while (state->have < state->nlen + state->ndist) {
6165 -                for (;;) {
6166 -                    this = state->lencode[BITS(state->lenbits)];
6167 -                    if ((unsigned)(this.bits) <= bits) break;
6168 -                    PULLBYTE();
6169 -                }
6170 -                if (this.val < 16) {
6171 -                    NEEDBITS(this.bits);
6172 -                    DROPBITS(this.bits);
6173 -                    state->lens[state->have++] = this.val;
6174 -                }
6175 -                else {
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;
6182 -                            break;
6183 -                        }
6184 -                        len = state->lens[state->have - 1];
6185 -                        copy = 3 + BITS(2);
6186 -                        DROPBITS(2);
6187 -                    }
6188 -                    else if (this.val == 17) {
6189 -                        NEEDBITS(this.bits + 3);
6190 -                        DROPBITS(this.bits);
6191 -                        len = 0;
6192 -                        copy = 3 + BITS(3);
6193 -                        DROPBITS(3);
6194 -                    }
6195 -                    else {
6196 -                        NEEDBITS(this.bits + 7);
6197 -                        DROPBITS(this.bits);
6198 -                        len = 0;
6199 -                        copy = 11 + BITS(7);
6200 -                        DROPBITS(7);
6201 -                    }
6202 -                    if (state->have + copy > state->nlen + state->ndist) {
6203 -                        strm->msg = (char *)"invalid bit length repeat";
6204 -                        state->mode = BAD;
6205 -                        break;
6206 -                    }
6207 -                    while (copy--)
6208 -                        state->lens[state->have++] = (unsigned short)len;
6209 -                }
6210 -            }
6211 -
6212 -            /* handle error breaks in while */
6213 -            if (state->mode == BAD) break;
6214 -
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);
6221 -            if (ret) {
6222 -                strm->msg = (char *)"invalid literal/lengths set";
6223 -                state->mode = BAD;
6224 -                break;
6225 -            }
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);
6230 -            if (ret) {
6231 -                strm->msg = (char *)"invalid distances set";
6232 -                state->mode = BAD;
6233 -                break;
6234 -            }
6235 -            Tracev((stderr, "inflate:       codes ok\n"));
6236 -            state->mode = LEN;
6237 -        case LEN:
6238 -            if (have >= 6 && left >= 258) {
6239 -                RESTORE();
6240 -                inflate_fast(strm, out);
6241 -                LOAD();
6242 -                break;
6243 -            }
6244 -            for (;;) {
6245 -                this = state->lencode[BITS(state->lenbits)];
6246 -                if ((unsigned)(this.bits) <= bits) break;
6247 -                PULLBYTE();
6248 -            }
6249 -            if (this.op && (this.op & 0xf0) == 0) {
6250 -                last = this;
6251 -                for (;;) {
6252 -                    this = state->lencode[last.val +
6253 -                            (BITS(last.bits + last.op) >> last.bits)];
6254 -                    if ((unsigned)(last.bits + this.bits) <= bits) break;
6255 -                    PULLBYTE();
6256 -                }
6257 -                DROPBITS(last.bits);
6258 -            }
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;
6266 -                break;
6267 -            }
6268 -            if (this.op & 32) {
6269 -                Tracevv((stderr, "inflate:         end of block\n"));
6270 -                state->mode = TYPE;
6271 -                break;
6272 -            }
6273 -            if (this.op & 64) {
6274 -                strm->msg = (char *)"invalid literal/length code";
6275 -                state->mode = BAD;
6276 -                break;
6277 -            }
6278 -            state->extra = (unsigned)(this.op) & 15;
6279 -            state->mode = LENEXT;
6280 -        case LENEXT:
6281 -            if (state->extra) {
6282 -                NEEDBITS(state->extra);
6283 -                state->length += BITS(state->extra);
6284 -                DROPBITS(state->extra);
6285 -            }
6286 -            Tracevv((stderr, "inflate:         length %u\n", state->length));
6287 -            state->mode = DIST;
6288 -        case DIST:
6289 -            for (;;) {
6290 -                this = state->distcode[BITS(state->distbits)];
6291 -                if ((unsigned)(this.bits) <= bits) break;
6292 -                PULLBYTE();
6293 -            }
6294 -            if ((this.op & 0xf0) == 0) {
6295 -                last = this;
6296 -                for (;;) {
6297 -                    this = state->distcode[last.val +
6298 -                            (BITS(last.bits + last.op) >> last.bits)];
6299 -                    if ((unsigned)(last.bits + this.bits) <= bits) break;
6300 -                    PULLBYTE();
6301 -                }
6302 -                DROPBITS(last.bits);
6303 -            }
6304 -            DROPBITS(this.bits);
6305 -            if (this.op & 64) {
6306 -                strm->msg = (char *)"invalid distance code";
6307 -                state->mode = BAD;
6308 -                break;
6309 -            }
6310 -            state->offset = (unsigned)this.val;
6311 -            state->extra = (unsigned)(this.op) & 15;
6312 -            state->mode = DISTEXT;
6313 -        case DISTEXT:
6314 -            if (state->extra) {
6315 -                NEEDBITS(state->extra);
6316 -                state->offset += BITS(state->extra);
6317 -                DROPBITS(state->extra);
6318 -            }
6319 -#ifdef INFLATE_STRICT
6320 -            if (state->offset > state->dmax) {
6321 -                strm->msg = (char *)"invalid distance too far back";
6322 -                state->mode = BAD;
6323 -                break;
6324 -            }
6325 -#endif
6326 -            if (state->offset > state->whave + out - left) {
6327 -                strm->msg = (char *)"invalid distance too far back";
6328 -                state->mode = BAD;
6329 -                break;
6330 -            }
6331 -            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
6332 -            state->mode = MATCH;
6333 -        case 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);
6341 -                }
6342 -                else
6343 -                    from = state->window + (state->write - copy);
6344 -                if (copy > state->length) copy = state->length;
6345 -            }
6346 -            else {                              /* copy from output */
6347 -                from = put - state->offset;
6348 -                copy = state->length;
6349 -            }
6350 -            if (copy > left) copy = left;
6351 -            left -= copy;
6352 -            state->length -= copy;
6353 -            do {
6354 -                *put++ = *from++;
6355 -            } while (--copy);
6356 -            if (state->length == 0) state->mode = LEN;
6357 -            break;
6358 -        case LIT:
6359 -            if (left == 0) goto inf_leave;
6360 -            *put++ = (unsigned char)(state->length);
6361 -            left--;
6362 -            state->mode = LEN;
6363 -            break;
6364 -        case CHECK:
6365 -            if (state->wrap) {
6366 -                NEEDBITS(32);
6367 -                out -= left;
6368 -                strm->total_out += out;
6369 -                state->total += out;
6370 -                if (out)
6371 -                    strm->adler = state->check =
6372 -                        UPDATE(state->check, put - out, out);
6373 -                out = left;
6374 -                if ((
6375 -#ifdef GUNZIP
6376 -                     state->flags ? hold :
6377 -#endif
6378 -                     REVERSE(hold)) != state->check) {
6379 -                    strm->msg = (char *)"incorrect data check";
6380 -                    state->mode = BAD;
6381 -                    break;
6382 -                }
6383 -                INITBITS();
6384 -                Tracev((stderr, "inflate:   check matches trailer\n"));
6385 -            }
6386 -#ifdef GUNZIP
6387 -            state->mode = LENGTH;
6388 -        case LENGTH:
6389 -            if (state->wrap && state->flags) {
6390 -                NEEDBITS(32);
6391 -                if (hold != (state->total & 0xffffffffUL)) {
6392 -                    strm->msg = (char *)"incorrect length check";
6393 -                    state->mode = BAD;
6394 -                    break;
6395 -                }
6396 -                INITBITS();
6397 -                Tracev((stderr, "inflate:   length matches trailer\n"));
6398 -            }
6399 -#endif
6400 -            state->mode = DONE;
6401 -        case DONE:
6402 -            ret = Z_STREAM_END;
6403 -            goto inf_leave;
6404 -        case BAD:
6405 -            ret = Z_DATA_ERROR;
6406 -            goto inf_leave;
6407 -        case MEM:
6408 -            return Z_MEM_ERROR;
6409 -        case SYNC:
6410 -        default:
6411 -            return Z_STREAM_ERROR;
6412 -        }
6413 -
6414 -    /*
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.
6419 -     */
6420 -  inf_leave:
6421 -    RESTORE();
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;
6426 -        }
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;
6439 -    return ret;
6440 -}
6441 -
6442 -int ZEXPORT inflateEnd(strm)
6443 -z_streamp strm;
6444 -{
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"));
6453 -    return Z_OK;
6454 -}
6455 -
6456 -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
6457 -z_streamp strm;
6458 -const Bytef *dictionary;
6459 -uInt dictLength;
6460 -{
6461 -    struct inflate_state FAR *state;
6462 -    unsigned long id;
6463 -
6464 -    /* check 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;
6469 -
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;
6476 -    }
6477 -
6478 -    /* copy dictionary to window */
6479 -    if (updatewindow(strm, strm->avail_out)) {
6480 -        state->mode = MEM;
6481 -        return Z_MEM_ERROR;
6482 -    }
6483 -    if (dictLength > state->wsize) {
6484 -        zmemcpy(state->window, dictionary + dictLength - state->wsize,
6485 -                state->wsize);
6486 -        state->whave = state->wsize;
6487 -    }
6488 -    else {
6489 -        zmemcpy(state->window + state->wsize - dictLength, dictionary,
6490 -                dictLength);
6491 -        state->whave = dictLength;
6492 -    }
6493 -    state->havedict = 1;
6494 -    Tracev((stderr, "inflate:   dictionary set\n"));
6495 -    return Z_OK;
6496 -}
6497 -
6498 -int ZEXPORT inflateGetHeader(strm, head)
6499 -z_streamp strm;
6500 -gz_headerp head;
6501 -{
6502 -    struct inflate_state FAR *state;
6503 -
6504 -    /* check 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;
6508 -
6509 -    /* save header structure */
6510 -    state->head = head;
6511 -    head->done = 0;
6512 -    return Z_OK;
6513 -}
6514 -
6515 -/*
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.
6525 - */
6526 -local unsigned syncsearch(have, buf, len)
6527 -unsigned FAR *have;
6528 -unsigned char FAR *buf;
6529 -unsigned len;
6530 -{
6531 -    unsigned got;
6532 -    unsigned next;
6533 -
6534 -    got = *have;
6535 -    next = 0;
6536 -    while (next < len && got < 4) {
6537 -        if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
6538 -            got++;
6539 -        else if (buf[next])
6540 -            got = 0;
6541 -        else
6542 -            got = 4 - got;
6543 -        next++;
6544 -    }
6545 -    *have = got;
6546 -    return next;
6547 -}
6548 -
6549 -int ZEXPORT inflateSync(strm)
6550 -z_streamp strm;
6551 -{
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;
6556 -
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;
6561 -
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;
6567 -        len = 0;
6568 -        while (state->bits >= 8) {
6569 -            buf[len++] = (unsigned char)(state->hold);
6570 -            state->hold >>= 8;
6571 -            state->bits -= 8;
6572 -        }
6573 -        state->have = 0;
6574 -        syncsearch(&(state->have), buf, len);
6575 -    }
6576 -
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;
6582 -
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;
6589 -    return Z_OK;
6590 -}
6591 -
6592 -/*
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.
6599 - */
6600 -int ZEXPORT inflateSyncPoint(strm)
6601 -z_streamp strm;
6602 -{
6603 -    struct inflate_state FAR *state;
6604 -
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;
6608 -}
6609 -
6610 -int ZEXPORT inflateCopy(dest, source)
6611 -z_streamp dest;
6612 -z_streamp source;
6613 -{
6614 -    struct inflate_state FAR *state;
6615 -    struct inflate_state FAR *copy;
6616 -    unsigned char FAR *window;
6617 -    unsigned wsize;
6618 -
6619 -    /* check input */
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;
6624 -
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;
6629 -    window = Z_NULL;
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;
6636 -        }
6637 -    }
6638 -
6639 -    /* copy state */
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);
6646 -    }
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);
6651 -    }
6652 -    copy->window = window;
6653 -    dest->state = (struct internal_state FAR *)copy;
6654 -    return Z_OK;
6655 -}
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
6659 @@ -1,115 +0,0 @@
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
6663 - */
6664 -
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.
6668 - */
6669 -
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. */
6674 -#ifndef NO_GZIP
6675 -#  define GUNZIP
6676 -#endif
6677 -
6678 -/* Possible inflate modes between inflate() calls */
6679 -typedef enum {
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() */
6710 -} inflate_mode;
6711 -
6712 -/*
6713 -    State transitions between above modes -
6714 -
6715 -    (most modes can go to the BAD or MEM mode -- not shown for clarity)
6716 -
6717 -    Process header:
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
6730 -                LIT -> LEN
6731 -    Process trailer:
6732 -        CHECK -> LENGTH -> DONE
6733 - */
6734 -
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 */
6774 -};
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
6778 @@ -1,329 +0,0 @@
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
6782 - */
6783 -
6784 -#include "zutil.h"
6785 -#include "inftrees.h"
6786 -
6787 -#define MAXBITS 15
6788 -
6789 -const char inflate_copyright[] =
6790 -   " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
6791 -/*
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.
6796 - */
6797 -
6798 -/*
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.
6809 - */
6810 -int inflate_table(type, lens, codes, table, bits, work)
6811 -codetype type;
6812 -unsigned short FAR *lens;
6813 -unsigned codes;
6814 -code FAR * FAR *table;
6815 -unsigned FAR *bits;
6816 -unsigned short FAR *work;
6817 -{
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};
6852 -
6853 -    /*
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.
6865 -
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.
6870 -
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
6875 -       the caller.
6876 -
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
6881 -       decoding tables.
6882 -     */
6883 -
6884 -    /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
6885 -    for (len = 0; len <= MAXBITS; len++)
6886 -        count[len] = 0;
6887 -    for (sym = 0; sym < codes; sym++)
6888 -        count[lens[sym]]++;
6889 -
6890 -    /* bound code lengths, force root to be within code lengths */
6891 -    root = *bits;
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;
6901 -        *bits = 1;
6902 -        return 0;     /* no symbols, but wait for decoding to report error */
6903 -    }
6904 -    for (min = 1; min <= MAXBITS; min++)
6905 -        if (count[min] != 0) break;
6906 -    if (root < min) root = min;
6907 -
6908 -    /* check for an over-subscribed or incomplete set of lengths */
6909 -    left = 1;
6910 -    for (len = 1; len <= MAXBITS; len++) {
6911 -        left <<= 1;
6912 -        left -= count[len];
6913 -        if (left < 0) return -1;        /* over-subscribed */
6914 -    }
6915 -    if (left > 0 && (type == CODES || max != 1))
6916 -        return -1;                      /* incomplete set */
6917 -
6918 -    /* generate offsets into symbol table for each length for sorting */
6919 -    offs[1] = 0;
6920 -    for (len = 1; len < MAXBITS; len++)
6921 -        offs[len + 1] = offs[len] + count[len];
6922 -
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;
6926 -
6927 -    /*
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.
6934 -
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.
6940 -
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.
6945 -
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.
6952 -
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.
6957 -     */
6958 -
6959 -    /* set up for code type */
6960 -    switch (type) {
6961 -    case CODES:
6962 -        base = extra = work;    /* dummy value--not used */
6963 -        end = 19;
6964 -        break;
6965 -    case LENS:
6966 -        base = lbase;
6967 -        base -= 257;
6968 -        extra = lext;
6969 -        extra -= 257;
6970 -        end = 256;
6971 -        break;
6972 -    default:            /* DISTS */
6973 -        base = dbase;
6974 -        extra = dext;
6975 -        end = -1;
6976 -    }
6977 -
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 */
6988 -
6989 -    /* check available table space */
6990 -    if (type == LENS && used >= ENOUGH - MAXD)
6991 -        return 1;
6992 -
6993 -    /* process all codes and make table entries */
6994 -    for (;;) {
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];
7000 -        }
7001 -        else if ((int)(work[sym]) > end) {
7002 -            this.op = (unsigned char)(extra[work[sym]]);
7003 -            this.val = base[work[sym]];
7004 -        }
7005 -        else {
7006 -            this.op = (unsigned char)(32 + 64);         /* end of block */
7007 -            this.val = 0;
7008 -        }
7009 -
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 */
7014 -        do {
7015 -            fill -= incr;
7016 -            next[(huff >> drop) + fill] = this;
7017 -        } while (fill != 0);
7018 -
7019 -        /* backwards increment the len-bit code huff */
7020 -        incr = 1U << (len - 1);
7021 -        while (huff & incr)
7022 -            incr >>= 1;
7023 -        if (incr != 0) {
7024 -            huff &= incr - 1;
7025 -            huff += incr;
7026 -        }
7027 -        else
7028 -            huff = 0;
7029 -
7030 -        /* go to next symbol, update count, len */
7031 -        sym++;
7032 -        if (--(count[len]) == 0) {
7033 -            if (len == max) break;
7034 -            len = lens[work[sym]];
7035 -        }
7036 -
7037 -        /* create new sub-table if needed */
7038 -        if (len > root && (huff & mask) != low) {
7039 -            /* if first time, transition to sub-tables */
7040 -            if (drop == 0)
7041 -                drop = root;
7042 -
7043 -            /* increment past last table */
7044 -            next += min;            /* here min is 1 << curr */
7045 -
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;
7052 -                curr++;
7053 -                left <<= 1;
7054 -            }
7055 -
7056 -            /* check for enough space */
7057 -            used += 1U << curr;
7058 -            if (type == LENS && used >= ENOUGH - MAXD)
7059 -                return 1;
7060 -
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);
7066 -        }
7067 -    }
7068 -
7069 -    /*
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.
7075 -     */
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) {
7082 -            drop = 0;
7083 -            len = root;
7084 -            next = *table;
7085 -            this.bits = (unsigned char)len;
7086 -        }
7087 -
7088 -        /* put invalid code marker in table */
7089 -        next[huff >> drop] = this;
7090 -
7091 -        /* backwards increment the len-bit code huff */
7092 -        incr = 1U << (len - 1);
7093 -        while (huff & incr)
7094 -            incr >>= 1;
7095 -        if (incr != 0) {
7096 -            huff &= incr - 1;
7097 -            huff += incr;
7098 -        }
7099 -        else
7100 -            huff = 0;
7101 -    }
7102 -
7103 -    /* set return parameters */
7104 -    *table += used;
7105 -    *bits = root;
7106 -    return 0;
7107 -}
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
7111 @@ -1,55 +0,0 @@
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
7115 - */
7116 -
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.
7120 - */
7121 -
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. */
7135 -typedef struct {
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 */
7139 -} code;
7140 -
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
7147 - */
7148 -
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
7155 -#define MAXD 592
7156 -
7157 -/* Type of code to build for inftable() */
7158 -typedef enum {
7159 -    CODES,
7160 -    LENS,
7161 -    DISTS
7162 -} codetype;
7163 -
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
7170 @@ -0,0 +1 @@
7171 +PKG_LIBS=-lz
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
7176 @@ -1,1219 +0,0 @@
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
7180 - */
7181 -
7182 -/*
7183 - *  ALGORITHM
7184 - *
7185 - *      The "deflation" process uses several Huffman trees. The more
7186 - *      common source values are represented by shorter bit sequences.
7187 - *
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.
7193 - *
7194 - *  REFERENCES
7195 - *
7196 - *      Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
7197 - *      Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
7198 - *
7199 - *      Storer, James A.
7200 - *          Data Compression:  Methods and Theory, pp. 49-50.
7201 - *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.
7202 - *
7203 - *      Sedgewick, R.
7204 - *          Algorithms, p290.
7205 - *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
7206 - */
7207 -
7208 -/* @(#) $Id$ */
7209 -
7210 -/* #define GEN_TREES_H */
7211 -
7212 -#include "deflate.h"
7213 -
7214 -#ifdef DEBUG
7215 -#  include <ctype.h>
7216 -#endif
7217 -
7218 -/* ===========================================================================
7219 - * Constants
7220 - */
7221 -
7222 -#define MAX_BL_BITS 7
7223 -/* Bit length codes must not exceed MAX_BL_BITS bits */
7224 -
7225 -#define END_BLOCK 256
7226 -/* end of block literal code */
7227 -
7228 -#define REP_3_6      16
7229 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */
7230 -
7231 -#define REPZ_3_10    17
7232 -/* repeat a zero length 3-10 times  (3 bits of repeat count) */
7233 -
7234 -#define REPZ_11_138  18
7235 -/* repeat a zero length 11-138 times  (7 bits of repeat count) */
7236 -
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};
7239 -
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};
7242 -
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};
7245 -
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.
7250 - */
7251 -
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.)
7255 - */
7256 -
7257 -/* ===========================================================================
7258 - * Local data. These are initialized only once.
7259 - */
7260 -
7261 -#define DIST_CODE_LEN  512 /* see definition of array dist_code below */
7262 -
7263 -#if defined(GEN_TREES_H) || !defined(STDC)
7264 -/* non ANSI compilers may not accept trees.h */
7265 -
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
7270 - * below).
7271 - */
7272 -
7273 -local ct_data static_dtree[D_CODES];
7274 -/* The static distance tree. (Actually a trivial tree since all codes use
7275 - * 5 bits.)
7276 - */
7277 -
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.
7282 - */
7283 -
7284 -uch _length_code[MAX_MATCH-MIN_MATCH+1];
7285 -/* length code for each normalized match length (0 == MIN_MATCH) */
7286 -
7287 -local int base_length[LENGTH_CODES];
7288 -/* First normalized length for each code (0 = MIN_MATCH) */
7289 -
7290 -local int base_dist[D_CODES];
7291 -/* First normalized distance for each code (0 = distance of 1) */
7292 -
7293 -#else
7294 -#  include "trees.h"
7295 -#endif /* GEN_TREES_H */
7296 -
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 */
7303 -};
7304 -
7305 -local static_tree_desc  static_l_desc =
7306 -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
7307 -
7308 -local static_tree_desc  static_d_desc =
7309 -{static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
7310 -
7311 -local static_tree_desc  static_bl_desc =
7312 -{(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
7313 -
7314 -/* ===========================================================================
7315 - * Local (static) routines in this file.
7316 - */
7317 -
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,
7328 -                              int blcodes));
7329 -local void compress_block OF((deflate_state *s, ct_data *ltree,
7330 -                              ct_data *dtree));
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,
7336 -                              int header));
7337 -
7338 -#ifdef GEN_TREES_H
7339 -local void gen_trees_header OF((void));
7340 -#endif
7341 -
7342 -#ifndef DEBUG
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 */
7345 -
7346 -#else /* DEBUG */
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); }
7350 -#endif
7351 -
7352 -/* ===========================================================================
7353 - * Output a short LSB first on the stream.
7354 - * IN assertion: there is enough room in pendingBuf.
7355 - */
7356 -#define put_short(s, w) { \
7357 -    put_byte(s, (uch)((w) & 0xff)); \
7358 -    put_byte(s, (uch)((ush)(w) >> 8)); \
7359 -}
7360 -
7361 -/* ===========================================================================
7362 - * Send a value on a given number of bits.
7363 - * IN assertion: length <= 16 and value fits in length bits.
7364 - */
7365 -#ifdef DEBUG
7366 -local void send_bits      OF((deflate_state *s, int value, int length));
7367 -
7368 -local void send_bits(s, value, length)
7369 -    deflate_state *s;
7370 -    int value;  /* value to send */
7371 -    int length; /* number of bits */
7372 -{
7373 -    Tracevv((stderr," l %2d v %4x ", length, value));
7374 -    Assert(length > 0 && length <= 15, "invalid length");
7375 -    s->bits_sent += (ulg)length;
7376 -
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.
7380 -     */
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;
7386 -    } else {
7387 -        s->bi_buf |= value << s->bi_valid;
7388 -        s->bi_valid += length;
7389 -    }
7390 -}
7391 -#else /* !DEBUG */
7392 -
7393 -#define send_bits(s, value, length) \
7394 -{ int len = length;\
7395 -  if (s->bi_valid > (int)Buf_size - len) {\
7396 -    int val = value;\
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;\
7401 -  } else {\
7402 -    s->bi_buf |= (value) << s->bi_valid;\
7403 -    s->bi_valid += len;\
7404 -  }\
7405 -}
7406 -#endif /* DEBUG */
7407 -
7408 -
7409 -/* the arguments must not have side effects */
7410 -
7411 -/* ===========================================================================
7412 - * Initialize the various 'constant' tables.
7413 - */
7414 -local void tr_static_init()
7415 -{
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 */
7425 -
7426 -    if (static_init_done) return;
7427 -
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;
7434 -
7435 -    /* Initialize the mapping length (0..255) -> length code (0..28) */
7436 -    length = 0;
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;
7441 -        }
7442 -    }
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:
7447 -     */
7448 -    _length_code[length-1] = (uch)code;
7449 -
7450 -    /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
7451 -    dist = 0;
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;
7456 -        }
7457 -    }
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;
7464 -        }
7465 -    }
7466 -    Assert (dist == 256, "tr_static_init: 256+dist != 512");
7467 -
7468 -    /* Construct the codes of the static literal tree */
7469 -    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
7470 -    n = 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
7477 -     * all ones)
7478 -     */
7479 -    gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
7480 -
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);
7485 -    }
7486 -    static_init_done = 1;
7487 -
7488 -#  ifdef GEN_TREES_H
7489 -    gen_trees_header();
7490 -#  endif
7491 -#endif /* defined(GEN_TREES_H) || !defined(STDC) */
7492 -}
7493 -
7494 -/* ===========================================================================
7495 - * Genererate the file trees.h describing the static trees.
7496 - */
7497 -#ifdef GEN_TREES_H
7498 -#  ifndef DEBUG
7499 -#    include <stdio.h>
7500 -#  endif
7501 -
7502 -#  define SEPARATOR(i, last, width) \
7503 -      ((i) == (last)? "\n};\n\n" :    \
7504 -       ((i) % (width) == (width)-1 ? ",\n" : ", "))
7505 -
7506 -void gen_trees_header()
7507 -{
7508 -    FILE *header = fopen("trees.h", "w");
7509 -    int i;
7510 -
7511 -    Assert (header != NULL, "Can't open trees.h");
7512 -    fprintf(header,
7513 -            "/* header created automatically with -DGEN_TREES_H */\n\n");
7514 -
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));
7519 -    }
7520 -
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));
7525 -    }
7526 -
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));
7531 -    }
7532 -
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));
7537 -    }
7538 -
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));
7543 -    }
7544 -
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));
7549 -    }
7550 -
7551 -    fclose(header);
7552 -}
7553 -#endif /* GEN_TREES_H */
7554 -
7555 -/* ===========================================================================
7556 - * Initialize the tree data structures for a new zlib stream.
7557 - */
7558 -void _tr_init(s)
7559 -    deflate_state *s;
7560 -{
7561 -    tr_static_init();
7562 -
7563 -    s->l_desc.dyn_tree = s->dyn_ltree;
7564 -    s->l_desc.stat_desc = &static_l_desc;
7565 -
7566 -    s->d_desc.dyn_tree = s->dyn_dtree;
7567 -    s->d_desc.stat_desc = &static_d_desc;
7568 -
7569 -    s->bl_desc.dyn_tree = s->bl_tree;
7570 -    s->bl_desc.stat_desc = &static_bl_desc;
7571 -
7572 -    s->bi_buf = 0;
7573 -    s->bi_valid = 0;
7574 -    s->last_eob_len = 8; /* enough lookahead for inflate */
7575 -#ifdef DEBUG
7576 -    s->compressed_len = 0L;
7577 -    s->bits_sent = 0L;
7578 -#endif
7579 -
7580 -    /* Initialize the first block of the first file: */
7581 -    init_block(s);
7582 -}
7583 -
7584 -/* ===========================================================================
7585 - * Initialize a new block.
7586 - */
7587 -local void init_block(s)
7588 -    deflate_state *s;
7589 -{
7590 -    int n; /* iterates over tree elements */
7591 -
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;
7596 -
7597 -    s->dyn_ltree[END_BLOCK].Freq = 1;
7598 -    s->opt_len = s->static_len = 0L;
7599 -    s->last_lit = s->matches = 0;
7600 -}
7601 -
7602 -#define SMALLEST 1
7603 -/* Index within the heap array of least frequent node in the Huffman tree */
7604 -
7605 -
7606 -/* ===========================================================================
7607 - * Remove the smallest element from the heap and recreate the heap with
7608 - * one less element. Updates heap and heap_len.
7609 - */
7610 -#define pqremove(s, tree, top) \
7611 -{\
7612 -    top = s->heap[SMALLEST]; \
7613 -    s->heap[SMALLEST] = s->heap[s->heap_len--]; \
7614 -    pqdownheap(s, tree, SMALLEST); \
7615 -}
7616 -
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.
7620 - */
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]))
7624 -
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
7629 - * two sons).
7630 - */
7631 -local void pqdownheap(s, tree, k)
7632 -    deflate_state *s;
7633 -    ct_data *tree;  /* the tree to restore */
7634 -    int k;               /* node to move down */
7635 -{
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)) {
7642 -            j++;
7643 -        }
7644 -        /* Exit if v is smaller than both sons */
7645 -        if (smaller(tree, v, s->heap[j], s->depth)) break;
7646 -
7647 -        /* Exchange v with the smallest son */
7648 -        s->heap[k] = s->heap[j];  k = j;
7649 -
7650 -        /* And continue down the tree, setting j to the left son of k */
7651 -        j <<= 1;
7652 -    }
7653 -    s->heap[k] = v;
7654 -}
7655 -
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
7664 - *     not null.
7665 - */
7666 -local void gen_bitlen(s, desc)
7667 -    deflate_state *s;
7668 -    tree_desc *desc;    /* the tree descriptor */
7669 -{
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 */
7682 -
7683 -    for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
7684 -
7685 -    /* In a first pass, compute the optimal bit lengths (which may
7686 -     * overflow in the case of the bit length tree).
7687 -     */
7688 -    tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
7689 -
7690 -    for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
7691 -        n = s->heap[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 */
7696 -
7697 -        if (n > max_code) continue; /* not a leaf node */
7698 -
7699 -        s->bl_count[bits]++;
7700 -        xbits = 0;
7701 -        if (n >= base) xbits = extra[n-base];
7702 -        f = tree[n].Freq;
7703 -        s->opt_len += (ulg)f * (bits + xbits);
7704 -        if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
7705 -    }
7706 -    if (overflow == 0) return;
7707 -
7708 -    Trace((stderr,"\nbit length overflow\n"));
7709 -    /* This happens for example on obj2 and pic of the Calgary corpus */
7710 -
7711 -    /* Find the first bit length which could increase: */
7712 -    do {
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]
7720 -         */
7721 -        overflow -= 2;
7722 -    } while (overflow > 0);
7723 -
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.)
7728 -     */
7729 -    for (bits = max_length; bits != 0; bits--) {
7730 -        n = s->bl_count[bits];
7731 -        while (n != 0) {
7732 -            m = s->heap[--h];
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;
7739 -            }
7740 -            n--;
7741 -        }
7742 -    }
7743 -}
7744 -
7745 -/* ===========================================================================
7746 - * Generate the codes for a given tree and bit counts (which need not be
7747 - * optimal).
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.
7752 - */
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 */
7757 -{
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 */
7762 -
7763 -    /* The distribution counts are first used to generate the code values
7764 -     * without bit reversal.
7765 -     */
7766 -    for (bits = 1; bits <= MAX_BITS; bits++) {
7767 -        next_code[bits] = code = (code + bl_count[bits-1]) << 1;
7768 -    }
7769 -    /* Check that the bit counts in bl_count are consistent. The last code
7770 -     * must be all ones.
7771 -     */
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));
7775 -
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);
7781 -
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));
7784 -    }
7785 -}
7786 -
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.
7794 - */
7795 -local void build_tree(s, desc)
7796 -    deflate_state *s;
7797 -    tree_desc *desc; /* the tree descriptor */
7798 -{
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 */
7805 -
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.
7809 -     */
7810 -    s->heap_len = 0, s->heap_max = HEAP_SIZE;
7811 -
7812 -    for (n = 0; n < elems; n++) {
7813 -        if (tree[n].Freq != 0) {
7814 -            s->heap[++(s->heap_len)] = max_code = n;
7815 -            s->depth[n] = 0;
7816 -        } else {
7817 -            tree[n].Len = 0;
7818 -        }
7819 -    }
7820 -
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.
7825 -     */
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 */
7832 -    }
7833 -    desc->max_code = max_code;
7834 -
7835 -    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
7836 -     * establish sub-heaps of increasing lengths:
7837 -     */
7838 -    for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
7839 -
7840 -    /* Construct the Huffman tree by repeatedly combining the least two
7841 -     * frequent nodes.
7842 -     */
7843 -    node = elems;              /* next internal node of the tree */
7844 -    do {
7845 -        pqremove(s, tree, n);  /* n = node of least frequency */
7846 -        m = s->heap[SMALLEST]; /* m = node of next least frequency */
7847 -
7848 -        s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
7849 -        s->heap[--(s->heap_max)] = m;
7850 -
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);
7860 -        }
7861 -#endif
7862 -        /* and insert the new node in the heap */
7863 -        s->heap[SMALLEST] = node++;
7864 -        pqdownheap(s, tree, SMALLEST);
7865 -
7866 -    } while (s->heap_len >= 2);
7867 -
7868 -    s->heap[--(s->heap_max)] = s->heap[SMALLEST];
7869 -
7870 -    /* At this point, the fields freq and dad are set. We can now
7871 -     * generate the bit lengths.
7872 -     */
7873 -    gen_bitlen(s, (tree_desc *)desc);
7874 -
7875 -    /* The field len is now set, we can generate the bit codes */
7876 -    gen_codes ((ct_data *)tree, max_code, s->bl_count);
7877 -}
7878 -
7879 -/* ===========================================================================
7880 - * Scan a literal or distance tree to determine the frequencies of the codes
7881 - * in the bit length tree.
7882 - */
7883 -local void scan_tree (s, tree, max_code)
7884 -    deflate_state *s;
7885 -    ct_data *tree;   /* the tree to be scanned */
7886 -    int max_code;    /* and its largest code of non zero frequency */
7887 -{
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 */
7895 -
7896 -    if (nextlen == 0) max_count = 138, min_count = 3;
7897 -    tree[max_code+1].Len = (ush)0xffff; /* guard */
7898 -
7899 -    for (n = 0; n <= max_code; n++) {
7900 -        curlen = nextlen; nextlen = tree[n+1].Len;
7901 -        if (++count < max_count && curlen == nextlen) {
7902 -            continue;
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++;
7910 -        } else {
7911 -            s->bl_tree[REPZ_11_138].Freq++;
7912 -        }
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;
7918 -        } else {
7919 -            max_count = 7, min_count = 4;
7920 -        }
7921 -    }
7922 -}
7923 -
7924 -/* ===========================================================================
7925 - * Send a literal or distance tree in compressed form, using the codes in
7926 - * bl_tree.
7927 - */
7928 -local void send_tree (s, tree, max_code)
7929 -    deflate_state *s;
7930 -    ct_data *tree; /* the tree to be scanned */
7931 -    int max_code;       /* and its largest code of non zero frequency */
7932 -{
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 */
7940 -
7941 -    /* tree[max_code+1].Len = -1; */  /* guard already set */
7942 -    if (nextlen == 0) max_count = 138, min_count = 3;
7943 -
7944 -    for (n = 0; n <= max_code; n++) {
7945 -        curlen = nextlen; nextlen = tree[n+1].Len;
7946 -        if (++count < max_count && curlen == nextlen) {
7947 -            continue;
7948 -        } else if (count < min_count) {
7949 -            do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
7950 -
7951 -        } else if (curlen != 0) {
7952 -            if (curlen != prevlen) {
7953 -                send_code(s, curlen, s->bl_tree); count--;
7954 -            }
7955 -            Assert(count >= 3 && count <= 6, " 3_6?");
7956 -            send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
7957 -
7958 -        } else if (count <= 10) {
7959 -            send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
7960 -
7961 -        } else {
7962 -            send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
7963 -        }
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;
7969 -        } else {
7970 -            max_count = 7, min_count = 4;
7971 -        }
7972 -    }
7973 -}
7974 -
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.
7978 - */
7979 -local int build_bl_tree(s)
7980 -    deflate_state *s;
7981 -{
7982 -    int max_blindex;  /* index of last bit length code of non zero freq */
7983 -
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);
7987 -
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.
7992 -     */
7993 -
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.)
7997 -     */
7998 -    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
7999 -        if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
8000 -    }
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));
8005 -
8006 -    return max_blindex;
8007 -}
8008 -
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.
8013 - */
8014 -local void send_all_trees(s, lcodes, dcodes, blcodes)
8015 -    deflate_state *s;
8016 -    int lcodes, dcodes, blcodes; /* number of codes for each tree */
8017 -{
8018 -    int rank;                    /* index in bl_order */
8019 -
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);
8030 -    }
8031 -    Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
8032 -
8033 -    send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
8034 -    Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
8035 -
8036 -    send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
8037 -    Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
8038 -}
8039 -
8040 -/* ===========================================================================
8041 - * Send a stored block
8042 - */
8043 -void _tr_stored_block(s, buf, stored_len, eof)
8044 -    deflate_state *s;
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 */
8048 -{
8049 -    send_bits(s, (STORED_BLOCK<<1)+eof, 3);  /* send block type */
8050 -#ifdef DEBUG
8051 -    s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
8052 -    s->compressed_len += (stored_len + 4) << 3;
8053 -#endif
8054 -    copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
8055 -}
8056 -
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.
8067 - */
8068 -void _tr_align(s)
8069 -    deflate_state *s;
8070 -{
8071 -    send_bits(s, STATIC_TREES<<1, 3);
8072 -    send_code(s, END_BLOCK, static_ltree);
8073 -#ifdef DEBUG
8074 -    s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
8075 -#endif
8076 -    bi_flush(s);
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.
8081 -     */
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);
8085 -#ifdef DEBUG
8086 -        s->compressed_len += 10L;
8087 -#endif
8088 -        bi_flush(s);
8089 -    }
8090 -    s->last_eob_len = 7;
8091 -}
8092 -
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.
8096 - */
8097 -void _tr_flush_block(s, buf, stored_len, eof)
8098 -    deflate_state *s;
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 */
8102 -{
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 */
8105 -
8106 -    /* Build the Huffman trees unless a stored block is forced */
8107 -    if (s->level > 0) {
8108 -
8109 -        /* Check if the file is binary or text */
8110 -        if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
8111 -            set_data_type(s);
8112 -
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,
8116 -                s->static_len));
8117 -
8118 -        build_tree(s, (tree_desc *)(&(s->d_desc)));
8119 -        Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
8120 -                s->static_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.
8123 -         */
8124 -
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.
8127 -         */
8128 -        max_blindex = build_bl_tree(s);
8129 -
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;
8133 -
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,
8136 -                s->last_lit));
8137 -
8138 -        if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
8139 -
8140 -    } else {
8141 -        Assert(buf != (char*)0, "lost buf");
8142 -        opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
8143 -    }
8144 -
8145 -#ifdef FORCE_STORED
8146 -    if (buf != (char*)0) { /* force stored block */
8147 -#else
8148 -    if (stored_len+4 <= opt_lenb && buf != (char*)0) {
8149 -                       /* 4: two words for the lengths */
8150 -#endif
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.
8156 -         */
8157 -        _tr_stored_block(s, buf, stored_len, eof);
8158 -
8159 -#ifdef FORCE_STATIC
8160 -    } else if (static_lenb >= 0) { /* force static trees */
8161 -#else
8162 -    } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
8163 -#endif
8164 -        send_bits(s, (STATIC_TREES<<1)+eof, 3);
8165 -        compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
8166 -#ifdef DEBUG
8167 -        s->compressed_len += 3 + s->static_len;
8168 -#endif
8169 -    } else {
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,
8172 -                       max_blindex+1);
8173 -        compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
8174 -#ifdef DEBUG
8175 -        s->compressed_len += 3 + s->opt_len;
8176 -#endif
8177 -    }
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.
8181 -     */
8182 -    init_block(s);
8183 -
8184 -    if (eof) {
8185 -        bi_windup(s);
8186 -#ifdef DEBUG
8187 -        s->compressed_len += 7;  /* align on byte boundary */
8188 -#endif
8189 -    }
8190 -    Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
8191 -           s->compressed_len-7*eof));
8192 -}
8193 -
8194 -/* ===========================================================================
8195 - * Save the match info and tally the frequency counts. Return true if
8196 - * the current block must be flushed.
8197 - */
8198 -int _tr_tally (s, dist, lc)
8199 -    deflate_state *s;
8200 -    unsigned dist;  /* distance of matched string */
8201 -    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
8202 -{
8203 -    s->d_buf[s->last_lit] = (ush)dist;
8204 -    s->l_buf[s->last_lit++] = (uch)lc;
8205 -    if (dist == 0) {
8206 -        /* lc is the unmatched char */
8207 -        s->dyn_ltree[lc].Freq++;
8208 -    } else {
8209 -        s->matches++;
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");
8215 -
8216 -        s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
8217 -        s->dyn_dtree[d_code(dist)].Freq++;
8218 -    }
8219 -
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);
8226 -        int dcode;
8227 -        for (dcode = 0; dcode < D_CODES; dcode++) {
8228 -            out_length += (ulg)s->dyn_dtree[dcode].Freq *
8229 -                (5L+extra_dbits[dcode]);
8230 -        }
8231 -        out_length >>= 3;
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;
8236 -    }
8237 -#endif
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
8241 -     * 64K-1 bytes.
8242 -     */
8243 -}
8244 -
8245 -/* ===========================================================================
8246 - * Send the block data compressed using the given Huffman trees
8247 - */
8248 -local void compress_block(s, ltree, dtree)
8249 -    deflate_state *s;
8250 -    ct_data *ltree; /* literal tree */
8251 -    ct_data *dtree; /* distance tree */
8252 -{
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 */
8258 -
8259 -    if (s->last_lit != 0) do {
8260 -        dist = s->d_buf[lx];
8261 -        lc = s->l_buf[lx++];
8262 -        if (dist == 0) {
8263 -            send_code(s, lc, ltree); /* send a literal byte */
8264 -            Tracecv(isgraph(lc), (stderr," '%c' ", lc));
8265 -        } else {
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];
8270 -            if (extra != 0) {
8271 -                lc -= base_length[code];
8272 -                send_bits(s, lc, extra);       /* send the extra length bits */
8273 -            }
8274 -            dist--; /* dist is now the match distance - 1 */
8275 -            code = d_code(dist);
8276 -            Assert (code < D_CODES, "bad d_code");
8277 -
8278 -            send_code(s, code, dtree);       /* send the distance code */
8279 -            extra = extra_dbits[code];
8280 -            if (extra != 0) {
8281 -                dist -= base_dist[code];
8282 -                send_bits(s, dist, extra);   /* send the extra distance bits */
8283 -            }
8284 -        } /* literal or match pair ? */
8285 -
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");
8289 -
8290 -    } while (lx < s->last_lit);
8291 -
8292 -    send_code(s, END_BLOCK, ltree);
8293 -    s->last_eob_len = ltree[END_BLOCK].Len;
8294 -}
8295 -
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.
8301 - */
8302 -local void set_data_type(s)
8303 -    deflate_state *s;
8304 -{
8305 -    int n;
8306 -
8307 -    for (n = 0; n < 9; n++)
8308 -        if (s->dyn_ltree[n].Freq != 0)
8309 -            break;
8310 -    if (n == 9)
8311 -        for (n = 14; n < 32; n++)
8312 -            if (s->dyn_ltree[n].Freq != 0)
8313 -                break;
8314 -    s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
8315 -}
8316 -
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
8321 - */
8322 -local unsigned bi_reverse(code, len)
8323 -    unsigned code; /* the value to invert */
8324 -    int len;       /* its bit length */
8325 -{
8326 -    register unsigned res = 0;
8327 -    do {
8328 -        res |= code & 1;
8329 -        code >>= 1, res <<= 1;
8330 -    } while (--len > 0);
8331 -    return res >> 1;
8332 -}
8333 -
8334 -/* ===========================================================================
8335 - * Flush the bit buffer, keeping at most 7 bits in it.
8336 - */
8337 -local void bi_flush(s)
8338 -    deflate_state *s;
8339 -{
8340 -    if (s->bi_valid == 16) {
8341 -        put_short(s, s->bi_buf);
8342 -        s->bi_buf = 0;
8343 -        s->bi_valid = 0;
8344 -    } else if (s->bi_valid >= 8) {
8345 -        put_byte(s, (Byte)s->bi_buf);
8346 -        s->bi_buf >>= 8;
8347 -        s->bi_valid -= 8;
8348 -    }
8349 -}
8350 -
8351 -/* ===========================================================================
8352 - * Flush the bit buffer and align the output on a byte boundary
8353 - */
8354 -local void bi_windup(s)
8355 -    deflate_state *s;
8356 -{
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);
8361 -    }
8362 -    s->bi_buf = 0;
8363 -    s->bi_valid = 0;
8364 -#ifdef DEBUG
8365 -    s->bits_sent = (s->bits_sent+7) & ~7;
8366 -#endif
8367 -}
8368 -
8369 -/* ===========================================================================
8370 - * Copy a stored block, storing first the length and its
8371 - * one's complement if requested.
8372 - */
8373 -local void copy_block(s, buf, len, header)
8374 -    deflate_state *s;
8375 -    charf    *buf;    /* the input data */
8376 -    unsigned len;     /* its length */
8377 -    int      header;  /* true if block header must be written */
8378 -{
8379 -    bi_windup(s);        /* align on byte boundary */
8380 -    s->last_eob_len = 8; /* enough lookahead for inflate */
8381 -
8382 -    if (header) {
8383 -        put_short(s, (ush)len);
8384 -        put_short(s, (ush)~len);
8385 -#ifdef DEBUG
8386 -        s->bits_sent += 2*16;
8387 -#endif
8388 -    }
8389 -#ifdef DEBUG
8390 -    s->bits_sent += (ulg)len<<3;
8391 -#endif
8392 -    while (len--) {
8393 -        put_byte(s, *buf++);
8394 -    }
8395 -}
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
8399 @@ -1,128 +0,0 @@
8400 -/* header created automatically with -DGEN_TREES_H */
8401 -
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}}
8461 -};
8462 -
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}}
8470 -};
8471 -
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
8499 -};
8500 -
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
8515 -};
8516 -
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
8520 -};
8521 -
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
8526 -};
8527 -
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
8531 @@ -1,61 +0,0 @@
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
8535 - */
8536 -
8537 -/* @(#) $Id$ */
8538 -
8539 -#define ZLIB_INTERNAL
8540 -#include "zlib.h"
8541 -
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.
8552 -
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.
8556 -*/
8557 -int ZEXPORT uncompress (dest, destLen, source, sourceLen)
8558 -    Bytef *dest;
8559 -    uLongf *destLen;
8560 -    const Bytef *source;
8561 -    uLong sourceLen;
8562 -{
8563 -    z_stream stream;
8564 -    int err;
8565 -
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;
8570 -
8571 -    stream.next_out = dest;
8572 -    stream.avail_out = (uInt)*destLen;
8573 -    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
8574 -
8575 -    stream.zalloc = (alloc_func)0;
8576 -    stream.zfree = (free_func)0;
8577 -
8578 -    err = inflateInit(&stream);
8579 -    if (err != Z_OK) return err;
8580 -
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;
8586 -        return err;
8587 -    }
8588 -    *destLen = stream.total_out;
8589 -
8590 -    err = inflateEnd(&stream);
8591 -    return err;
8592 -}
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
8596 @@ -1,332 +0,0 @@
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
8600 - */
8601 -
8602 -/* @(#) $Id$ */
8603 -
8604 -#ifndef ZCONF_H
8605 -#define ZCONF_H
8606 -
8607 -/*
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.
8610 - */
8611 -#ifdef Z_PREFIX
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
8641 -
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
8656 -#endif
8657 -
8658 -#if defined(__MSDOS__) && !defined(MSDOS)
8659 -#  define MSDOS
8660 -#endif
8661 -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
8662 -#  define OS2
8663 -#endif
8664 -#if defined(_WINDOWS) && !defined(WINDOWS)
8665 -#  define WINDOWS
8666 -#endif
8667 -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
8668 -#  ifndef WIN32
8669 -#    define WIN32
8670 -#  endif
8671 -#endif
8672 -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
8673 -#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
8674 -#    ifndef SYS16BIT
8675 -#      define SYS16BIT
8676 -#    endif
8677 -#  endif
8678 -#endif
8679 -
8680 -/*
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).
8683 - */
8684 -#ifdef SYS16BIT
8685 -#  define MAXSEG_64K
8686 -#endif
8687 -#ifdef MSDOS
8688 -#  define UNALIGNED_OK
8689 -#endif
8690 -
8691 -#ifdef __STDC_VERSION__
8692 -#  ifndef STDC
8693 -#    define STDC
8694 -#  endif
8695 -#  if __STDC_VERSION__ >= 199901L
8696 -#    ifndef STDC99
8697 -#      define STDC99
8698 -#    endif
8699 -#  endif
8700 -#endif
8701 -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
8702 -#  define STDC
8703 -#endif
8704 -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
8705 -#  define STDC
8706 -#endif
8707 -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
8708 -#  define STDC
8709 -#endif
8710 -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
8711 -#  define STDC
8712 -#endif
8713 -
8714 -#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
8715 -#  define STDC
8716 -#endif
8717 -
8718 -#ifndef STDC
8719 -#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
8720 -#    define const       /* note: need a more gentle solution here */
8721 -#  endif
8722 -#endif
8723 -
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
8727 -#endif
8728 -
8729 -/* Maximum value for memLevel in deflateInit2 */
8730 -#ifndef MAX_MEM_LEVEL
8731 -#  ifdef MAXSEG_64K
8732 -#    define MAX_MEM_LEVEL 8
8733 -#  else
8734 -#    define MAX_MEM_LEVEL 9
8735 -#  endif
8736 -#endif
8737 -
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
8741 - * gzip.)
8742 - */
8743 -#ifndef MAX_WBITS
8744 -#  define MAX_WBITS   15 /* 32K LZ77 window */
8745 -#endif
8746 -
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).
8754 -
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.
8758 -*/
8759 -
8760 -                        /* Type declarations */
8761 -
8762 -#ifndef OF /* function prototypes */
8763 -#  ifdef STDC
8764 -#    define OF(args)  args
8765 -#  else
8766 -#    define OF(args)  ()
8767 -#  endif
8768 -#endif
8769 -
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.
8775 - */
8776 -#ifdef SYS16BIT
8777 -#  if defined(M_I86SM) || defined(M_I86MM)
8778 -     /* MSC small or medium model */
8779 -#    define SMALL_MEDIUM
8780 -#    ifdef _MSC_VER
8781 -#      define FAR _far
8782 -#    else
8783 -#      define FAR far
8784 -#    endif
8785 -#  endif
8786 -#  if (defined(__SMALL__) || defined(__MEDIUM__))
8787 -     /* Turbo C small or medium model */
8788 -#    define SMALL_MEDIUM
8789 -#    ifdef __BORLANDC__
8790 -#      define FAR _far
8791 -#    else
8792 -#      define FAR far
8793 -#    endif
8794 -#  endif
8795 -#endif
8796 -
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.
8800 -    */
8801 -#  ifdef ZLIB_DLL
8802 -#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
8803 -#      ifdef ZLIB_INTERNAL
8804 -#        define ZEXTERN extern __declspec(dllexport)
8805 -#      else
8806 -#        define ZEXTERN extern __declspec(dllimport)
8807 -#      endif
8808 -#    endif
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.
8813 -    */
8814 -#  ifdef ZLIB_WINAPI
8815 -#    ifdef FAR
8816 -#      undef FAR
8817 -#    endif
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
8822 -#    ifdef WIN32
8823 -#      define ZEXPORTVA WINAPIV
8824 -#    else
8825 -#      define ZEXPORTVA FAR CDECL
8826 -#    endif
8827 -#  endif
8828 -#endif
8829 -
8830 -#if defined (__BEOS__)
8831 -#  ifdef ZLIB_DLL
8832 -#    ifdef ZLIB_INTERNAL
8833 -#      define ZEXPORT   __declspec(dllexport)
8834 -#      define ZEXPORTVA __declspec(dllexport)
8835 -#    else
8836 -#      define ZEXPORT   __declspec(dllimport)
8837 -#      define ZEXPORTVA __declspec(dllimport)
8838 -#    endif
8839 -#  endif
8840 -#endif
8841 -
8842 -#ifndef ZEXTERN
8843 -#  define ZEXTERN extern
8844 -#endif
8845 -#ifndef ZEXPORT
8846 -#  define ZEXPORT
8847 -#endif
8848 -#ifndef ZEXPORTVA
8849 -#  define ZEXPORTVA
8850 -#endif
8851 -
8852 -#ifndef FAR
8853 -#  define FAR
8854 -#endif
8855 -
8856 -#if !defined(__MACTYPES__)
8857 -typedef unsigned char  Byte;  /* 8 bits */
8858 -#endif
8859 -typedef unsigned int   uInt;  /* 16 bits or more */
8860 -typedef unsigned long  uLong; /* 32 bits or more */
8861 -
8862 -#ifdef SMALL_MEDIUM
8863 -   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
8864 -#  define Bytef Byte FAR
8865 -#else
8866 -   typedef Byte  FAR Bytef;
8867 -#endif
8868 -typedef char  FAR charf;
8869 -typedef int   FAR intf;
8870 -typedef uInt  FAR uIntf;
8871 -typedef uLong FAR uLongf;
8872 -
8873 -#ifdef STDC
8874 -   typedef void const *voidpc;
8875 -   typedef void FAR   *voidpf;
8876 -   typedef void       *voidp;
8877 -#else
8878 -   typedef Byte const *voidpc;
8879 -   typedef Byte FAR   *voidpf;
8880 -   typedef Byte       *voidp;
8881 -#endif
8882 -
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 */
8886 -#  ifdef VMS
8887 -#    include <unixio.h>   /* for off_t */
8888 -#  endif
8889 -#  define z_off_t off_t
8890 -#endif
8891 -#ifndef SEEK_SET
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" */
8895 -#endif
8896 -#ifndef z_off_t
8897 -#  define z_off_t long
8898 -#endif
8899 -
8900 -#if defined(__OS400__)
8901 -#  define NO_vsnprintf
8902 -#endif
8903 -
8904 -#if defined(__MVS__)
8905 -#  define NO_vsnprintf
8906 -#  ifdef FAR
8907 -#    undef FAR
8908 -#  endif
8909 -#endif
8910 -
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")
8926 -#endif
8927 -
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
8932 @@ -1,332 +0,0 @@
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
8936 - */
8937 -
8938 -/* @(#) $Id$ */
8939 -
8940 -#ifndef ZCONF_H
8941 -#define ZCONF_H
8942 -
8943 -/*
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.
8946 - */
8947 -#ifdef Z_PREFIX
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
8977 -
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
8992 -#endif
8993 -
8994 -#if defined(__MSDOS__) && !defined(MSDOS)
8995 -#  define MSDOS
8996 -#endif
8997 -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
8998 -#  define OS2
8999 -#endif
9000 -#if defined(_WINDOWS) && !defined(WINDOWS)
9001 -#  define WINDOWS
9002 -#endif
9003 -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
9004 -#  ifndef WIN32
9005 -#    define WIN32
9006 -#  endif
9007 -#endif
9008 -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
9009 -#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
9010 -#    ifndef SYS16BIT
9011 -#      define SYS16BIT
9012 -#    endif
9013 -#  endif
9014 -#endif
9015 -
9016 -/*
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).
9019 - */
9020 -#ifdef SYS16BIT
9021 -#  define MAXSEG_64K
9022 -#endif
9023 -#ifdef MSDOS
9024 -#  define UNALIGNED_OK
9025 -#endif
9026 -
9027 -#ifdef __STDC_VERSION__
9028 -#  ifndef STDC
9029 -#    define STDC
9030 -#  endif
9031 -#  if __STDC_VERSION__ >= 199901L
9032 -#    ifndef STDC99
9033 -#      define STDC99
9034 -#    endif
9035 -#  endif
9036 -#endif
9037 -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
9038 -#  define STDC
9039 -#endif
9040 -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
9041 -#  define STDC
9042 -#endif
9043 -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
9044 -#  define STDC
9045 -#endif
9046 -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
9047 -#  define STDC
9048 -#endif
9049 -
9050 -#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
9051 -#  define STDC
9052 -#endif
9053 -
9054 -#ifndef STDC
9055 -#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
9056 -#    define const       /* note: need a more gentle solution here */
9057 -#  endif
9058 -#endif
9059 -
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
9063 -#endif
9064 -
9065 -/* Maximum value for memLevel in deflateInit2 */
9066 -#ifndef MAX_MEM_LEVEL
9067 -#  ifdef MAXSEG_64K
9068 -#    define MAX_MEM_LEVEL 8
9069 -#  else
9070 -#    define MAX_MEM_LEVEL 9
9071 -#  endif
9072 -#endif
9073 -
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
9077 - * gzip.)
9078 - */
9079 -#ifndef MAX_WBITS
9080 -#  define MAX_WBITS   15 /* 32K LZ77 window */
9081 -#endif
9082 -
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).
9090 -
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.
9094 -*/
9095 -
9096 -                        /* Type declarations */
9097 -
9098 -#ifndef OF /* function prototypes */
9099 -#  ifdef STDC
9100 -#    define OF(args)  args
9101 -#  else
9102 -#    define OF(args)  ()
9103 -#  endif
9104 -#endif
9105 -
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.
9111 - */
9112 -#ifdef SYS16BIT
9113 -#  if defined(M_I86SM) || defined(M_I86MM)
9114 -     /* MSC small or medium model */
9115 -#    define SMALL_MEDIUM
9116 -#    ifdef _MSC_VER
9117 -#      define FAR _far
9118 -#    else
9119 -#      define FAR far
9120 -#    endif
9121 -#  endif
9122 -#  if (defined(__SMALL__) || defined(__MEDIUM__))
9123 -     /* Turbo C small or medium model */
9124 -#    define SMALL_MEDIUM
9125 -#    ifdef __BORLANDC__
9126 -#      define FAR _far
9127 -#    else
9128 -#      define FAR far
9129 -#    endif
9130 -#  endif
9131 -#endif
9132 -
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.
9136 -    */
9137 -#  ifdef ZLIB_DLL
9138 -#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
9139 -#      ifdef ZLIB_INTERNAL
9140 -#        define ZEXTERN extern __declspec(dllexport)
9141 -#      else
9142 -#        define ZEXTERN extern __declspec(dllimport)
9143 -#      endif
9144 -#    endif
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.
9149 -    */
9150 -#  ifdef ZLIB_WINAPI
9151 -#    ifdef FAR
9152 -#      undef FAR
9153 -#    endif
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
9158 -#    ifdef WIN32
9159 -#      define ZEXPORTVA WINAPIV
9160 -#    else
9161 -#      define ZEXPORTVA FAR CDECL
9162 -#    endif
9163 -#  endif
9164 -#endif
9165 -
9166 -#if defined (__BEOS__)
9167 -#  ifdef ZLIB_DLL
9168 -#    ifdef ZLIB_INTERNAL
9169 -#      define ZEXPORT   __declspec(dllexport)
9170 -#      define ZEXPORTVA __declspec(dllexport)
9171 -#    else
9172 -#      define ZEXPORT   __declspec(dllimport)
9173 -#      define ZEXPORTVA __declspec(dllimport)
9174 -#    endif
9175 -#  endif
9176 -#endif
9177 -
9178 -#ifndef ZEXTERN
9179 -#  define ZEXTERN extern
9180 -#endif
9181 -#ifndef ZEXPORT
9182 -#  define ZEXPORT
9183 -#endif
9184 -#ifndef ZEXPORTVA
9185 -#  define ZEXPORTVA
9186 -#endif
9187 -
9188 -#ifndef FAR
9189 -#  define FAR
9190 -#endif
9191 -
9192 -#if !defined(__MACTYPES__)
9193 -typedef unsigned char  Byte;  /* 8 bits */
9194 -#endif
9195 -typedef unsigned int   uInt;  /* 16 bits or more */
9196 -typedef unsigned long  uLong; /* 32 bits or more */
9197 -
9198 -#ifdef SMALL_MEDIUM
9199 -   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
9200 -#  define Bytef Byte FAR
9201 -#else
9202 -   typedef Byte  FAR Bytef;
9203 -#endif
9204 -typedef char  FAR charf;
9205 -typedef int   FAR intf;
9206 -typedef uInt  FAR uIntf;
9207 -typedef uLong FAR uLongf;
9208 -
9209 -#ifdef STDC
9210 -   typedef void const *voidpc;
9211 -   typedef void FAR   *voidpf;
9212 -   typedef void       *voidp;
9213 -#else
9214 -   typedef Byte const *voidpc;
9215 -   typedef Byte FAR   *voidpf;
9216 -   typedef Byte       *voidp;
9217 -#endif
9218 -
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 */
9222 -#  ifdef VMS
9223 -#    include <unixio.h>   /* for off_t */
9224 -#  endif
9225 -#  define z_off_t off_t
9226 -#endif
9227 -#ifndef SEEK_SET
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" */
9231 -#endif
9232 -#ifndef z_off_t
9233 -#  define z_off_t long
9234 -#endif
9235 -
9236 -#if defined(__OS400__)
9237 -#  define NO_vsnprintf
9238 -#endif
9239 -
9240 -#if defined(__MVS__)
9241 -#  define NO_vsnprintf
9242 -#  ifdef FAR
9243 -#    undef FAR
9244 -#  endif
9245 -#endif
9246 -
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")
9262 -#endif
9263 -
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
9268 @@ -1,1357 +0,0 @@
9269 -/* zlib.h -- interface of the 'zlib' general purpose compression library
9270 -  version 1.2.3, July 18th, 2005
9271 -
9272 -  Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
9273 -
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.
9277 -
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:
9281 -
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.
9289 -
9290 -  Jean-loup Gailly        Mark Adler
9291 -  jloup@gzip.org          madler@alumni.caltech.edu
9292 -
9293 -
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).
9297 -*/
9298 -
9299 -#ifndef ZLIB_H
9300 -#define ZLIB_H
9301 -
9302 -#include "zconf.h"
9303 -
9304 -#ifdef __cplusplus
9305 -extern "C" {
9306 -#endif
9307 -
9308 -#define ZLIB_VERSION "1.2.3"
9309 -#define ZLIB_VERNUM 0x1230
9310 -
9311 -/*
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
9316 -  stream interface.
9317 -
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.
9323 -
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.
9327 -
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.
9332 -
9333 -     This library can optionally read and write gzip streams in memory as well.
9334 -
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.
9339 -
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.
9343 -*/
9344 -
9345 -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
9346 -typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
9347 -
9348 -struct internal_state;
9349 -
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 */
9354 -
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 */
9358 -
9359 -    char     *msg;      /* last error message, NULL if no error */
9360 -    struct internal_state FAR *state; /* not visible by applications */
9361 -
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 */
9365 -
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 */
9369 -} z_stream;
9370 -
9371 -typedef z_stream FAR *z_streamp;
9372 -
9373 -/*
9374 -     gzip header information passed to and from zlib routines.  See RFC 1952
9375 -  for more details on the meanings of these fields.
9376 -*/
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) */
9392 -} gz_header;
9393 -
9394 -typedef gz_header FAR *gz_headerp;
9395 -
9396 -/*
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.
9402 -
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
9406 -   opaque value.
9407 -
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
9410 -   thread safe.
9411 -
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).
9420 -
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
9425 -   a single step).
9426 -*/
9427 -
9428 -                        /* constants */
9429 -
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
9434 -#define Z_FINISH        4
9435 -#define Z_BLOCK         5
9436 -/* Allowed flush values; see deflate() and inflate() below for details */
9437 -
9438 -#define Z_OK            0
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.
9449 - */
9450 -
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 */
9456 -
9457 -#define Z_FILTERED            1
9458 -#define Z_HUFFMAN_ONLY        2
9459 -#define Z_RLE                 3
9460 -#define Z_FIXED               4
9461 -#define Z_DEFAULT_STRATEGY    0
9462 -/* compression strategy; see deflateInit2() below for details */
9463 -
9464 -#define Z_BINARY   0
9465 -#define Z_TEXT     1
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()) */
9469 -
9470 -#define Z_DEFLATED   8
9471 -/* The deflate compression method (the only one supported in this version) */
9472 -
9473 -#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
9474 -
9475 -#define zlib_version zlibVersion()
9476 -/* for compatibility with versions < 1.0.2 */
9477 -
9478 -                        /* basic functions */
9479 -
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.
9485 - */
9486 -
9487 -/*
9488 -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
9489 -
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.
9494 -
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).
9500 -
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().
9507 -*/
9508 -
9509 -
9510 -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
9511 -/*
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
9515 -  forced to flush.
9516 -
9517 -    The detailed semantics are as follows. deflate performs one or both of the
9518 -  following actions:
9519 -
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().
9524 -
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.
9530 -
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.
9539 -
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.
9543 -
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.
9550 -
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
9555 -  compression.
9556 -
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.
9563 -
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.
9571 -
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.
9576 -
9577 -    deflate() sets strm->adler to the adler32 checksum of all input read
9578 -  so far (that is, total_in bytes).
9579 -
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.
9584 -
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.
9593 -*/
9594 -
9595 -
9596 -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
9597 -/*
9598 -     All dynamically allocated data structures for this stream are freed.
9599 -   This function discards any unprocessed input and does not flush any
9600 -   pending output.
9601 -
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
9606 -   deallocated).
9607 -*/
9608 -
9609 -
9610 -/*
9611 -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
9612 -
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.
9621 -
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.)
9628 -*/
9629 -
9630 -
9631 -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
9632 -/*
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
9636 -  forced to flush.
9637 -
9638 -  The detailed semantics are as follows. inflate performs one or both of the
9639 -  following actions:
9640 -
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().
9645 -
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).
9650 -
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.
9659 -
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.
9668 -
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
9679 -  less than eight.
9680 -
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.
9691 -
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.
9697 -
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.
9706 -
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
9712 -  trailer.
9713 -
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.
9727 -*/
9728 -
9729 -
9730 -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
9731 -/*
9732 -     All dynamically allocated data structures for this stream are freed.
9733 -   This function discards any unprocessed input and does not flush any
9734 -   pending output.
9735 -
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).
9739 -*/
9740 -
9741 -                        /* Advanced functions */
9742 -
9743 -/*
9744 -    The following functions are needed only in some special applications.
9745 -*/
9746 -
9747 -/*
9748 -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
9749 -                                     int  level,
9750 -                                     int  method,
9751 -                                     int  windowBits,
9752 -                                     int  memLevel,
9753 -                                     int  strategy));
9754 -
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
9757 -   the caller.
9758 -
9759 -     The method parameter is the compression method. It must be Z_DEFLATED in
9760 -   this version of the library.
9761 -
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.
9767 -
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.
9771 -
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.
9778 -
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.
9784 -
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
9798 -   applications.
9799 -
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().
9804 -*/
9805 -
9806 -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
9807 -                                             const Bytef *dictionary,
9808 -                                             uInt  dictLength));
9809 -/*
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).
9815 -
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.
9822 -
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.
9830 -
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.
9837 -
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().
9843 -*/
9844 -
9845 -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
9846 -                                    z_streamp source));
9847 -/*
9848 -     Sets the destination stream as a complete copy of the source stream.
9849 -
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.
9856 -
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
9860 -   destination.
9861 -*/
9862 -
9863 -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
9864 -/*
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.
9869 -
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).
9872 -*/
9873 -
9874 -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
9875 -                                      int level,
9876 -                                      int strategy));
9877 -/*
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().
9885 -
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.
9889 -
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.
9893 -*/
9894 -
9895 -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
9896 -                                    int good_length,
9897 -                                    int max_lazy,
9898 -                                    int nice_length,
9899 -                                    int max_chain));
9900 -/*
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.
9907 -
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.
9910 - */
9911 -
9912 -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
9913 -                                       uLong sourceLen));
9914 -/*
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().
9919 -*/
9920 -
9921 -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
9922 -                                     int bits,
9923 -                                     int value));
9924 -/*
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.
9932 -
9933 -      deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
9934 -   stream state was inconsistent.
9935 -*/
9936 -
9937 -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
9938 -                                         gz_headerp head));
9939 -/*
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.
9952 -
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().
9956 -
9957 -      deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
9958 -   stream state was inconsistent.
9959 -*/
9960 -
9961 -/*
9962 -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
9963 -                                     int  windowBits));
9964 -
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.
9968 -
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.
9977 -
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.
9989 -
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.
9995 -
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.)
10002 -*/
10003 -
10004 -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
10005 -                                             const Bytef *dictionary,
10006 -                                             uInt  dictLength));
10007 -/*
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.
10017 -
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
10023 -   inflate().
10024 -*/
10025 -
10026 -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
10027 -/*
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.
10031 -
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.
10039 -*/
10040 -
10041 -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
10042 -                                    z_streamp source));
10043 -/*
10044 -     Sets the destination stream as a complete copy of the source stream.
10045 -
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
10049 -   stream.
10050 -
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
10054 -   destination.
10055 -*/
10056 -
10057 -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
10058 -/*
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.
10062 -
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).
10065 -*/
10066 -
10067 -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
10068 -                                     int bits,
10069 -                                     int value));
10070 -/*
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.
10078 -
10079 -      inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
10080 -   stream state was inconsistent.
10081 -*/
10082 -
10083 -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
10084 -                                         gz_headerp head));
10085 -/*
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.
10095 -
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.
10112 -
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.
10118 -
10119 -      inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
10120 -   stream state was inconsistent.
10121 -*/
10122 -
10123 -/*
10124 -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
10125 -                                        unsigned char FAR *window));
10126 -
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
10135 -   deflate streams.
10136 -
10137 -     See inflateBack() for the usage of these routines.
10138 -
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.
10143 -*/
10144 -
10145 -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
10146 -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
10147 -
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));
10151 -/*
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.
10158 -
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.
10164 -
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.
10172 -
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().
10189 -
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].
10197 -
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.
10202 -
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.
10215 -*/
10216 -
10217 -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
10218 -/*
10219 -     All memory allocated by inflateBackInit() is freed.
10220 -
10221 -     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
10222 -   state was inconsistent.
10223 -*/
10224 -
10225 -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
10226 -/* Return flags indicating compile-time options.
10227 -
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
10233 -
10234 -    Compiler, assembler, and debug options:
10235 -     8: DEBUG
10236 -     9: ASMV or ASMINF -- use ASM code
10237 -     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
10238 -     11: 0 (reserved)
10239 -
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)
10244 -
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)
10251 -
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)
10256 -
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
10261 -
10262 -    Remainder:
10263 -     27-31: 0 (reserved)
10264 - */
10265 -
10266 -
10267 -                        /* utility functions */
10268 -
10269 -/*
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.
10275 -*/
10276 -
10277 -ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
10278 -                                 const Bytef *source, uLong sourceLen));
10279 -/*
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
10289 -   buffer.
10290 -*/
10291 -
10292 -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
10293 -                                  const Bytef *source, uLong sourceLen,
10294 -                                  int level));
10295 -/*
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.
10302 -
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.
10306 -*/
10307 -
10308 -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
10309 -/*
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.
10313 -*/
10314 -
10315 -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
10316 -                                   const Bytef *source, uLong sourceLen));
10317 -/*
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.
10327 -
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.
10331 -*/
10332 -
10333 -
10334 -typedef voidp gzFile;
10335 -
10336 -ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
10337 -/*
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.)
10344 -
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.
10347 -
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).  */
10352 -
10353 -ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
10354 -/*
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.
10364 -*/
10365 -
10366 -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
10367 -/*
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.
10372 -*/
10373 -
10374 -ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
10375 -/*
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). */
10381 -
10382 -ZEXTERN int ZEXPORT    gzwrite OF((gzFile file,
10383 -                                   voidpc buf, unsigned len));
10384 -/*
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).
10388 -*/
10389 -
10390 -ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
10391 -/*
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.
10401 -*/
10402 -
10403 -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
10404 -/*
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.
10408 -*/
10409 -
10410 -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
10411 -/*
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
10415 -   character.
10416 -      gzgets returns buf, or Z_NULL in case of error.
10417 -*/
10418 -
10419 -ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
10420 -/*
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.
10423 -*/
10424 -
10425 -ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
10426 -/*
10427 -      Reads one byte from the compressed file. gzgetc returns this byte
10428 -   or -1 in case of end of file or error.
10429 -*/
10430 -
10431 -ZEXTERN int ZEXPORT    gzungetc OF((int c, gzFile file));
10432 -/*
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()
10438 -   or gzrewind().
10439 -*/
10440 -
10441 -ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
10442 -/*
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.
10449 -*/
10450 -
10451 -ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
10452 -                                      z_off_t offset, int whence));
10453 -/*
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.
10462 -
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.
10467 -*/
10468 -
10469 -ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
10470 -/*
10471 -     Rewinds the given file. This function is supported only for reading.
10472 -
10473 -   gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
10474 -*/
10475 -
10476 -ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
10477 -/*
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.
10481 -
10482 -   gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
10483 -*/
10484 -
10485 -ZEXTERN int ZEXPORT gzeof OF((gzFile file));
10486 -/*
10487 -     Returns 1 when EOF has previously been detected reading the given
10488 -   input stream, otherwise zero.
10489 -*/
10490 -
10491 -ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
10492 -/*
10493 -     Returns 1 if file is being read directly without decompression, otherwise
10494 -   zero.
10495 -*/
10496 -
10497 -ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
10498 -/*
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).
10502 -*/
10503 -
10504 -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
10505 -/*
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.
10511 -*/
10512 -
10513 -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
10514 -/*
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.
10518 -*/
10519 -
10520 -                        /* checksum functions */
10521 -
10522 -/*
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.
10526 -*/
10527 -
10528 -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
10529 -/*
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:
10535 -
10536 -     uLong adler = adler32(0L, Z_NULL, 0);
10537 -
10538 -     while (read_buffer(buffer, length) != EOF) {
10539 -       adler = adler32(adler, buffer, length);
10540 -     }
10541 -     if (adler != original_adler) error();
10542 -*/
10543 -
10544 -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
10545 -                                          z_off_t len2));
10546 -/*
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.
10551 -*/
10552 -
10553 -ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
10554 -/*
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.
10559 -   Usage example:
10560 -
10561 -     uLong crc = crc32(0L, Z_NULL, 0);
10562 -
10563 -     while (read_buffer(buffer, length) != EOF) {
10564 -       crc = crc32(crc, buffer, length);
10565 -     }
10566 -     if (crc != original_crc) error();
10567 -*/
10568 -
10569 -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
10570 -
10571 -/*
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
10576 -   len2.
10577 -*/
10578 -
10579 -
10580 -                        /* various hacks, don't look :) */
10581 -
10582 -/* deflateInit and inflateInit are macros to allow checking the zlib version
10583 - * and the compiler's view of z_stream:
10584 - */
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))
10611 -
10612 -
10613 -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
10614 -    struct internal_state {int dummy;}; /* hack for buggy compilers */
10615 -#endif
10616 -
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));
10620 -
10621 -#ifdef __cplusplus
10622 -}
10623 -#endif
10624 -
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
10629 @@ -1,318 +0,0 @@
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
10633 - */
10634 -
10635 -/* @(#) $Id$ */
10636 -
10637 -#include "zutil.h"
10638 -
10639 -#ifndef NO_DUMMY_DECL
10640 -struct internal_state      {int dummy;}; /* for buggy compilers */
10641 -#endif
10642 -
10643 -const char * const z_errmsg[10] = {
10644 -"need dictionary",     /* Z_NEED_DICT       2  */
10645 -"stream end",          /* Z_STREAM_END      1  */
10646 -"",                    /* Z_OK              0  */
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) */
10653 -""};
10654 -
10655 -
10656 -const char * ZEXPORT zlibVersion()
10657 -{
10658 -    return ZLIB_VERSION;
10659 -}
10660 -
10661 -uLong ZEXPORT zlibCompileFlags()
10662 -{
10663 -    uLong flags;
10664 -
10665 -    flags = 0;
10666 -    switch (sizeof(uInt)) {
10667 -    case 2:     break;
10668 -    case 4:     flags += 1;     break;
10669 -    case 8:     flags += 2;     break;
10670 -    default:    flags += 3;
10671 -    }
10672 -    switch (sizeof(uLong)) {
10673 -    case 2:     break;
10674 -    case 4:     flags += 1 << 2;        break;
10675 -    case 8:     flags += 2 << 2;        break;
10676 -    default:    flags += 3 << 2;
10677 -    }
10678 -    switch (sizeof(voidpf)) {
10679 -    case 2:     break;
10680 -    case 4:     flags += 1 << 4;        break;
10681 -    case 8:     flags += 2 << 4;        break;
10682 -    default:    flags += 3 << 4;
10683 -    }
10684 -    switch (sizeof(z_off_t)) {
10685 -    case 2:     break;
10686 -    case 4:     flags += 1 << 6;        break;
10687 -    case 8:     flags += 2 << 6;        break;
10688 -    default:    flags += 3 << 6;
10689 -    }
10690 -#ifdef DEBUG
10691 -    flags += 1 << 8;
10692 -#endif
10693 -#if defined(ASMV) || defined(ASMINF)
10694 -    flags += 1 << 9;
10695 -#endif
10696 -#ifdef ZLIB_WINAPI
10697 -    flags += 1 << 10;
10698 -#endif
10699 -#ifdef BUILDFIXED
10700 -    flags += 1 << 12;
10701 -#endif
10702 -#ifdef DYNAMIC_CRC_TABLE
10703 -    flags += 1 << 13;
10704 -#endif
10705 -#ifdef NO_GZCOMPRESS
10706 -    flags += 1L << 16;
10707 -#endif
10708 -#ifdef NO_GZIP
10709 -    flags += 1L << 17;
10710 -#endif
10711 -#ifdef PKZIP_BUG_WORKAROUND
10712 -    flags += 1L << 20;
10713 -#endif
10714 -#ifdef FASTEST
10715 -    flags += 1L << 21;
10716 -#endif
10717 -#ifdef STDC
10718 -#  ifdef NO_vsnprintf
10719 -        flags += 1L << 25;
10720 -#    ifdef HAS_vsprintf_void
10721 -        flags += 1L << 26;
10722 -#    endif
10723 -#  else
10724 -#    ifdef HAS_vsnprintf_void
10725 -        flags += 1L << 26;
10726 -#    endif
10727 -#  endif
10728 -#else
10729 -        flags += 1L << 24;
10730 -#  ifdef NO_snprintf
10731 -        flags += 1L << 25;
10732 -#    ifdef HAS_sprintf_void
10733 -        flags += 1L << 26;
10734 -#    endif
10735 -#  else
10736 -#    ifdef HAS_snprintf_void
10737 -        flags += 1L << 26;
10738 -#    endif
10739 -#  endif
10740 -#endif
10741 -    return flags;
10742 -}
10743 -
10744 -#ifdef DEBUG
10745 -
10746 -#  ifndef verbose
10747 -#    define verbose 0
10748 -#  endif
10749 -int z_verbose = verbose;
10750 -
10751 -void z_error (m)
10752 -    char *m;
10753 -{
10754 -    fprintf(stderr, "%s\n", m);
10755 -    exit(1);
10756 -}
10757 -#endif
10758 -
10759 -/* exported to allow conversion of error code to string for compress() and
10760 - * uncompress()
10761 - */
10762 -const char * ZEXPORT zError(err)
10763 -    int err;
10764 -{
10765 -    return ERR_MSG(err);
10766 -}
10767 -
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.
10772 -     */
10773 -    int errno = 0;
10774 -#endif
10775 -
10776 -#ifndef HAVE_MEMCPY
10777 -
10778 -void zmemcpy(dest, source, len)
10779 -    Bytef* dest;
10780 -    const Bytef* source;
10781 -    uInt  len;
10782 -{
10783 -    if (len == 0) return;
10784 -    do {
10785 -        *dest++ = *source++; /* ??? to be unrolled */
10786 -    } while (--len != 0);
10787 -}
10788 -
10789 -int zmemcmp(s1, s2, len)
10790 -    const Bytef* s1;
10791 -    const Bytef* s2;
10792 -    uInt  len;
10793 -{
10794 -    uInt j;
10795 -
10796 -    for (j = 0; j < len; j++) {
10797 -        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
10798 -    }
10799 -    return 0;
10800 -}
10801 -
10802 -void zmemzero(dest, len)
10803 -    Bytef* dest;
10804 -    uInt  len;
10805 -{
10806 -    if (len == 0) return;
10807 -    do {
10808 -        *dest++ = 0;  /* ??? to be unrolled */
10809 -    } while (--len != 0);
10810 -}
10811 -#endif
10812 -
10813 -
10814 -#ifdef SYS16BIT
10815 -
10816 -#ifdef __TURBOC__
10817 -/* Turbo C in 16-bit mode */
10818 -
10819 -#  define MY_ZCALLOC
10820 -
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().
10825 - */
10826 -
10827 -#define MAX_PTR 10
10828 -/* 10*64K = 640K */
10829 -
10830 -local int next_ptr = 0;
10831 -
10832 -typedef struct ptr_table_s {
10833 -    voidpf org_ptr;
10834 -    voidpf new_ptr;
10835 -} ptr_table;
10836 -
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.
10843 - */
10844 -
10845 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10846 -{
10847 -    voidpf buf = opaque; /* just to make some compilers happy */
10848 -    ulg bsize = (ulg)items*size;
10849 -
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.
10852 -     */
10853 -    if (bsize < 65520L) {
10854 -        buf = farmalloc(bsize);
10855 -        if (*(ush*)&buf != 0) return buf;
10856 -    } else {
10857 -        buf = farmalloc(bsize + 16L);
10858 -    }
10859 -    if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
10860 -    table[next_ptr].org_ptr = buf;
10861 -
10862 -    /* Normalize the pointer to seg:0 */
10863 -    *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
10864 -    *(ush*)&buf = 0;
10865 -    table[next_ptr++].new_ptr = buf;
10866 -    return buf;
10867 -}
10868 -
10869 -void  zcfree (voidpf opaque, voidpf ptr)
10870 -{
10871 -    int n;
10872 -    if (*(ush*)&ptr != 0) { /* object < 64K */
10873 -        farfree(ptr);
10874 -        return;
10875 -    }
10876 -    /* Find the original pointer */
10877 -    for (n = 0; n < next_ptr; n++) {
10878 -        if (ptr != table[n].new_ptr) continue;
10879 -
10880 -        farfree(table[n].org_ptr);
10881 -        while (++n < next_ptr) {
10882 -            table[n-1] = table[n];
10883 -        }
10884 -        next_ptr--;
10885 -        return;
10886 -    }
10887 -    ptr = opaque; /* just to make some compilers happy */
10888 -    Assert(0, "zcfree: ptr not found");
10889 -}
10890 -
10891 -#endif /* __TURBOC__ */
10892 -
10893 -
10894 -#ifdef M_I86
10895 -/* Microsoft C in 16-bit mode */
10896 -
10897 -#  define MY_ZCALLOC
10898 -
10899 -#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
10900 -#  define _halloc  halloc
10901 -#  define _hfree   hfree
10902 -#endif
10903 -
10904 -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
10905 -{
10906 -    if (opaque) opaque = 0; /* to make compiler happy */
10907 -    return _halloc((long)items, size);
10908 -}
10909 -
10910 -void  zcfree (voidpf opaque, voidpf ptr)
10911 -{
10912 -    if (opaque) opaque = 0; /* to make compiler happy */
10913 -    _hfree(ptr);
10914 -}
10915 -
10916 -#endif /* M_I86 */
10917 -
10918 -#endif /* SYS16BIT */
10919 -
10920 -
10921 -#ifndef MY_ZCALLOC /* Any system without a special alloc function */
10922 -
10923 -#ifndef STDC
10924 -extern voidp  malloc OF((uInt size));
10925 -extern voidp  calloc OF((uInt items, uInt size));
10926 -extern void   free   OF((voidpf ptr));
10927 -#endif
10928 -
10929 -voidpf zcalloc (opaque, items, size)
10930 -    voidpf opaque;
10931 -    unsigned items;
10932 -    unsigned size;
10933 -{
10934 -    if (opaque) items += size - size; /* make compiler happy */
10935 -    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
10936 -                              (voidpf)calloc(items, size);
10937 -}
10938 -
10939 -void  zcfree (opaque, ptr)
10940 -    voidpf opaque;
10941 -    voidpf ptr;
10942 -{
10943 -    free(ptr);
10944 -    if (opaque) return; /* make compiler happy */
10945 -}
10946 -
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
10951 @@ -1,269 +0,0 @@
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
10955 - */
10956 -
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.
10960 - */
10961 -
10962 -/* @(#) $Id$ */
10963 -
10964 -#ifndef ZUTIL_H
10965 -#define ZUTIL_H
10966 -
10967 -#define ZLIB_INTERNAL
10968 -#include "zlib.h"
10969 -
10970 -#ifdef STDC
10971 -#  ifndef _WIN32_WCE
10972 -#    include <stddef.h>
10973 -#  endif
10974 -#  include <string.h>
10975 -#  include <stdlib.h>
10976 -#endif
10977 -#ifdef NO_ERRNO_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.
10983 -       */
10984 -#     define errno z_errno
10985 -#   endif
10986 -    extern int errno;
10987 -#else
10988 -#  ifndef _WIN32_WCE
10989 -#    include <errno.h>
10990 -#  endif
10991 -#endif
10992 -
10993 -#ifndef local
10994 -#  define local static
10995 -#endif
10996 -/* compile with -Dlocal if your debugger can't find static symbols */
10997 -
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;
11003 -
11004 -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
11005 -/* (size given to avoid silly warnings with Visual C++) */
11006 -
11007 -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
11008 -
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 */
11012 -
11013 -        /* common constants */
11014 -
11015 -#ifndef DEF_WBITS
11016 -#  define DEF_WBITS MAX_WBITS
11017 -#endif
11018 -/* default windowBits for decompression. MAX_WBITS is for compression only */
11019 -
11020 -#if MAX_MEM_LEVEL >= 8
11021 -#  define DEF_MEM_LEVEL 8
11022 -#else
11023 -#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
11024 -#endif
11025 -/* default memLevel */
11026 -
11027 -#define STORED_BLOCK 0
11028 -#define STATIC_TREES 1
11029 -#define DYN_TREES    2
11030 -/* The three kinds of block type */
11031 -
11032 -#define MIN_MATCH  3
11033 -#define MAX_MATCH  258
11034 -/* The minimum and maximum match lengths */
11035 -
11036 -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
11037 -
11038 -        /* target dependencies */
11039 -
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 );
11047 -#    else
11048 -#      include <alloc.h>
11049 -#    endif
11050 -#  else /* MSC or DJGPP */
11051 -#    include <malloc.h>
11052 -#  endif
11053 -#endif
11054 -
11055 -#ifdef AMIGA
11056 -#  define OS_CODE  0x01
11057 -#endif
11058 -
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")
11063 -#endif
11064 -
11065 -#if defined(ATARI) || defined(atarist)
11066 -#  define OS_CODE  0x05
11067 -#endif
11068 -
11069 -#ifdef OS2
11070 -#  define OS_CODE  0x06
11071 -#  ifdef M_I86
11072 -     #include <malloc.h>
11073 -#  endif
11074 -#endif
11075 -
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 */
11080 -#  else
11081 -#    ifndef fdopen
11082 -#      define fdopen(fd,mode) NULL /* No fdopen() */
11083 -#    endif
11084 -#  endif
11085 -#endif
11086 -
11087 -#ifdef TOPS20
11088 -#  define OS_CODE  0x0a
11089 -#endif
11090 -
11091 -#ifdef WIN32
11092 -#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
11093 -#    define OS_CODE  0x0b
11094 -#  endif
11095 -#endif
11096 -
11097 -#ifdef __50SERIES /* Prime/PRIMOS */
11098 -#  define OS_CODE  0x0f
11099 -#endif
11100 -
11101 -#if defined(_BEOS_) || defined(RISCOS)
11102 -#  define fdopen(fd,mode) NULL /* No fdopen() */
11103 -#endif
11104 -
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
11111 -#    endif
11112 -#  else
11113 -#    define fdopen(fd,type)  _fdopen(fd,type)
11114 -#  endif
11115 -#endif
11116 -
11117 -        /* common defaults */
11118 -
11119 -#ifndef OS_CODE
11120 -#  define OS_CODE  0x03  /* assume Unix */
11121 -#endif
11122 -
11123 -#ifndef F_OPEN
11124 -#  define F_OPEN(name, mode) fopen((name), (mode))
11125 -#endif
11126 -
11127 -         /* functions */
11128 -
11129 -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
11130 -#  ifndef HAVE_VSNPRINTF
11131 -#    define HAVE_VSNPRINTF
11132 -#  endif
11133 -#endif
11134 -#if defined(__CYGWIN__)
11135 -#  ifndef HAVE_VSNPRINTF
11136 -#    define HAVE_VSNPRINTF
11137 -#  endif
11138 -#endif
11139 -#ifndef HAVE_VSNPRINTF
11140 -#  ifdef MSDOS
11141 -     /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
11142 -        but for now we just assume it doesn't. */
11143 -#    define NO_vsnprintf
11144 -#  endif
11145 -#  ifdef __TURBOC__
11146 -#    define NO_vsnprintf
11147 -#  endif
11148 -#  ifdef WIN32
11149 -     /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
11150 -#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
11151 -#      define vsnprintf _vsnprintf
11152 -#    endif
11153 -#  endif
11154 -#  ifdef __SASC
11155 -#    define NO_vsnprintf
11156 -#  endif
11157 -#endif
11158 -#ifdef VMS
11159 -#  define NO_vsnprintf
11160 -#endif
11161 -
11162 -#if defined(pyr)
11163 -#  define NO_MEMCPY
11164 -#endif
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.
11169 -  */
11170 -#  define NO_MEMCPY
11171 -#endif
11172 -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
11173 -#  define HAVE_MEMCPY
11174 -#endif
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)
11180 -#  else
11181 -#    define zmemcpy memcpy
11182 -#    define zmemcmp memcmp
11183 -#    define zmemzero(dest, len) memset(dest, 0, len)
11184 -#  endif
11185 -#else
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));
11189 -#endif
11190 -
11191 -/* Diagnostic functions */
11192 -#ifdef DEBUG
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 ;}
11202 -#else
11203 -#  define Assert(cond,msg)
11204 -#  define Trace(x)
11205 -#  define Tracev(x)
11206 -#  define Tracevv(x)
11207 -#  define Tracec(c,x)
11208 -#  define Tracecv(c,x)
11209 -#endif
11210 -
11211 -
11212 -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
11213 -void   zcfree  OF((voidpf opaque, voidpf ptr));
11214 -
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);}
11219 -
11220 -#endif /* ZUTIL_H */