/* vi: set sw=4 ts=4: */
/*
 * gunzip implementation for busybox
 *
 * Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
 *
 * Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
 * based on gzip sources
 *
 * Adjusted further by Erik Andersen <andersee@debian.org> to support
 * files as well as stdin/stdout, and to generally behave itself wrt
 * command line handling.
 *
 * General cleanup to better adhere to the style guide and make use of standard
 * busybox functions by Glenn McGrath <bug1@optushome.com.au>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 *
 * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
 * Copyright (C) 1992-1993 Jean-loup Gailly
 * The unzip code was written and put in the public domain by Mark Adler.
 * Portions of the lzw code are derived from the public domain 'compress'
 * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
 * Ken Turkowski, Dave Mack and Peter Jannesen.
 *
 * See the license_msg below and the file COPYING for the software license.
 * See the file algorithm.doc for the compression algorithms and file formats.
 */

#if 0
static char *license_msg[] = {
	"   Copyright (C) 1992-1993 Jean-loup Gailly",
	"   This program is free software; you can redistribute it and/or modify",
	"   it under the terms of the GNU General Public License as published by",
	"   the Free Software Foundation; either version 2, or (at your option)",
	"   any later version.",
	"",
	"   This program is distributed in the hope that it will be useful,",
	"   but WITHOUT ANY WARRANTY; without even the implied warranty of",
	"   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the",
	"   GNU General Public License for more details.",
	"",
	"   You should have received a copy of the GNU General Public License",
	"   along with this program; if not, write to the Free Software",
	"   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.",
	0
};
#endif

#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "libbb.h"

#ifdef CONFIG_FEATURE_UNCOMPRESS
int uncompress(FILE * in, FILE * out);
#endif

static FILE *in_file, *out_file;

/* these are freed by gz_close */
static unsigned char *window;
static unsigned long *crc_table;

static unsigned long crc;	/* shift register contents */

/* Return codes from gzip */
#define ERROR 1

/*
 * window size--must be a power of two, and
 *  at least 32K for zip's deflate method
 */
#define WSIZE 0x8000

/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
#define BMAX 16	/* maximum bit length of any code (16 for explode) */
#define N_MAX 288	/* maximum number of codes in any set */

static long bytes_out;	/* number of output bytes */
static unsigned long outcnt;	/* bytes in output buffer */

static unsigned hufts;	/* track memory usage */
static unsigned long bb;	/* bit buffer */
static unsigned bk;		/* bits in bit buffer */

typedef struct huft_s {
	unsigned char e;	/* number of extra bits or operation */
	unsigned char b;	/* number of bits in this code or subcode */
	union {
		unsigned short n;	/* literal, length base, or distance base */
		struct huft_s *t;	/* pointer to next level of table */
	} v;
} huft_t;

static const unsigned short mask_bits[] = {
	0x0000,
	0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
	0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};

/* static int error_number = 0; */
/* ========================================================================
 * Signal and error handler.
 */

static void abort_gzip(void)
{
	error_msg("gzip aborted\n");
	exit(ERROR);
}

static void make_crc_table(void)
{
	const unsigned long poly = 0xedb88320;	/* polynomial exclusive-or pattern */
	unsigned short i;	/* counter for all possible eight bit values */

	/* initial shift register value */
	crc = 0xffffffffL;
	crc_table = (unsigned long *) malloc(256 * sizeof(unsigned long));

	/* Compute and print table of CRC's, five per line */
	for (i = 0; i < 256; i++) {
		unsigned long table_entry;	/* crc shift register */
		char k;			/* byte being shifted into crc apparatus */

		table_entry = i;
		/* The idea to initialize the register with the byte instead of
		   * zero was stolen from Haruhiko Okumura's ar002
		 */
		for (k = 8; k; k--) {
			table_entry =
				table_entry & 1 ? (table_entry >> 1) ^ poly : table_entry >>
				1;
		}
		crc_table[i] = table_entry;
	}
}

/* ===========================================================================
 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
 * (Used for the decompressed data only.)
 */
static void flush_window(void)
{
	int n;

	if (outcnt == 0)
		return;

	for (n = 0; n < outcnt; n++) {
		crc = crc_table[((int) crc ^ (window[n])) & 0xff] ^ (crc >> 8);
	}

	if (fwrite(window, 1, outcnt, out_file) != outcnt) {
		error_msg_and_die("Couldnt write");
	}
	bytes_out += (unsigned long) outcnt;
	outcnt = 0;
}

/*
 * Free the malloc'ed tables built by huft_build(), which makes a linked
 * list of the tables it made, with the links in a dummy first entry of
 * each table. 
 * t: table to free
 */
static int huft_free(huft_t * t)
{
	huft_t *p, *q;

	/* Go through linked list, freeing from the malloced (t[-1]) address. */
	p = t;
	while (p != (huft_t *) NULL) {
		q = (--p)->v.t;
		free((char *) p);
		p = q;
	}
	return 0;
}

typedef unsigned char extra_bits_t;

/* Given a list of code lengths and a maximum table size, make a set of
 * tables to decode that set of codes.  Return zero on success, one if
 * the given code set is incomplete (the tables are still built in this
 * case), two if the input is invalid (all zero length codes or an
 * oversubscribed set of lengths), and three if not enough memory.
 *
 * b:	code lengths in bits (all assumed <= BMAX)
 * n:	number of codes (assumed <= N_MAX)
 * s:	number of simple-valued codes (0..s-1)
 * d:	list of base values for non-simple codes
 * e:	list of extra bits for non-simple codes
 * t:	result: starting table
 * m:	maximum lookup bits, returns actual
 */
static int huft_build(unsigned int *b, const unsigned int n,
					  const unsigned int s, const unsigned short *d,
					  const extra_bits_t * e, huft_t ** t, int *m)
{
	unsigned a;			/* counter for codes of length k */
	unsigned c[BMAX + 1];	/* bit length count table */
	unsigned f;			/* i repeats in table every f entries */
	int g;				/* maximum code length */
	int h;				/* table level */
	register unsigned i;	/* counter, current code */
	register unsigned j;	/* counter */
	register int k;		/* number of bits in current code */
	int l;				/* bits per table (returned in m) */
	register unsigned *p;	/* pointer into c[], b[], or v[] */
	register huft_t *q;	/* points to current table */
	huft_t r;			/* table entry for structure assignment */
	huft_t *u[BMAX];	/* table stack */
	unsigned v[N_MAX];	/* values in order of bit length */
	register int w;		/* bits before this table == (l * h) */
	unsigned x[BMAX + 1];	/* bit offsets, then code stack */
	unsigned *xp;		/* pointer into x */
	int y;				/* number of dummy codes added */
	unsigned z;			/* number of entries in current table */

	/* Generate counts for each bit length */
	memset((void *) (c), 0, sizeof(c));
	p = b;
	i = n;
	do {
		c[*p]++;		/* assume all entries <= BMAX */
		p++;			/* Can't combine with above line (Solaris bug) */
	} while (--i);
	if (c[0] == n) {	/* null input--all zero length codes */
		*t = (huft_t *) NULL;
		*m = 0;
		return 0;
	}

	/* Find minimum and maximum length, bound *m by those */
	l = *m;
	for (j = 1; j <= BMAX; j++)
		if (c[j])
			break;
	k = j;				/* minimum code length */
	if ((unsigned) l < j)
		l = j;
	for (i = BMAX; i; i--)
		if (c[i])
			break;
	g = i;				/* maximum code length */
	if ((unsigned) l > i)
		l = i;
	*m = l;

	/* Adjust last length count to fill out codes, if needed */
	for (y = 1 << j; j < i; j++, y <<= 1)
		if ((y -= c[j]) < 0)
			return 2;	/* bad input: more codes than bits */
	if ((y -= c[i]) < 0)
		return 2;
	c[i] += y;

	/* Generate starting offsets into the value table for each length */
	x[1] = j = 0;
	p = c + 1;
	xp = x + 2;
	while (--i) {		/* note that i == g from above */
		*xp++ = (j += *p++);
	}

	/* Make a table of values in order of bit lengths */
	p = b;
	i = 0;
	do {
		if ((j = *p++) != 0)
			v[x[j]++] = i;
	} while (++i < n);

	/* Generate the Huffman codes and for each, make the table entries */
	x[0] = i = 0;		/* first Huffman code is zero */
	p = v;				/* grab values in bit order */
	h = -1;				/* no tables yet--level -1 */
	w = -l;				/* bits decoded == (l * h) */
	u[0] = (huft_t *) NULL;	/* just to keep compilers happy */
	q = (huft_t *) NULL;	/* ditto */
	z = 0;				/* ditto */

	/* go through the bit lengths (k already is bits in shortest code) */
	for (; k <= g; k++) {
		a = c[k];
		while (a--) {
			/* here i is the Huffman code of length k bits for value *p */
			/* make tables up to required level */
			while (k > w + l) {
				h++;
				w += l;	/* previous table always l bits */

				/* compute minimum size table less than or equal to l bits */
				z = (z = g - w) > (unsigned) l ? l : z;	/* upper limit on table size */
				if ((f = 1 << (j = k - w)) > a + 1) {	/* try a k-w bit table *//* too few codes for k-w bit table */
					f -= a + 1;	/* deduct codes from patterns left */
					xp = c + k;
					while (++j < z) {	/* try smaller tables up to z bits */
						if ((f <<= 1) <= *++xp)
							break;	/* enough codes to use up j bits */
						f -= *xp;	/* else deduct codes from patterns */
					}
				}
				z = 1 << j;	/* table entries for j-bit table */

				/* allocate and link in new table */
				q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));

				hufts += z + 1;	/* track memory usage */
				*t = q + 1;	/* link to list for huft_free() */
				*(t = &(q->v.t)) = NULL;
				u[h] = ++q;	/* table starts after link */

				/* connect to last table, if there is one */
				if (h) {
					x[h] = i;	/* save pattern for backing up */
					r.b = (unsigned char) l;	/* bits to dump before this table */
					r.e = (unsigned char) (16 + j);	/* bits in this table */
					r.v.t = q;	/* pointer to this table */
					j = i >> (w - l);	/* (get around Turbo C bug) */
					u[h - 1][j] = r;	/* connect to last table */
				}
			}

			/* set up table entry in r */
			r.b = (unsigned char) (k - w);
			if (p >= v + n)
				r.e = 99;	/* out of values--invalid code */
			else if (*p < s) {
				r.e = (unsigned char) (*p < 256 ? 16 : 15);	/* 256 is end-of-block code */
				r.v.n = (unsigned short) (*p);	/* simple code is just the value */
				p++;	/* one compiler does not like *p++ */
			} else {
				r.e = (unsigned char) e[*p - s];	/* non-simple--look up in lists */
				r.v.n = d[*p++ - s];
			}

			/* fill code-like entries with r */
			f = 1 << (k - w);
			for (j = i >> w; j < z; j += f)
				q[j] = r;

			/* backwards increment the k-bit code i */
			for (j = 1 << (k - 1); i & j; j >>= 1)
				i ^= j;
			i ^= j;

			/* backup over finished tables */
			while ((i & ((1 << w) - 1)) != x[h]) {
				h--;	/* don't need to update q */
				w -= l;
			}
		}
	}
	/* Return true (1) if we were given an incomplete table */
	return y != 0 && g != 1;
}

/*
 * inflate (decompress) the codes in a deflated (compressed) block.
 * Return an error code or zero if it all goes ok.
 *
 * tl, td: literal/length and distance decoder tables
 * bl, bd: number of bits decoded by tl[] and td[]
 */
static int inflate_codes(huft_t * tl, huft_t * td, int bl, int bd)
{
	register unsigned long e;	/* table entry flag/number of extra bits */
	unsigned long n, d;	/* length and index for copy */
	unsigned long w;	/* current window position */
	huft_t *t;			/* pointer to table entry */
	unsigned ml, md;	/* masks for bl and bd bits */
	register unsigned long b;	/* bit buffer */
	register unsigned k;	/* number of bits in bit buffer */

	/* make local copies of globals */
	b = bb;				/* initialize bit buffer */
	k = bk;
	w = outcnt;			/* initialize window position */

	/* inflate the coded data */
	ml = mask_bits[bl];	/* precompute masks for speed */
	md = mask_bits[bd];
	for (;;) {			/* do until end of block */
		while (k < (unsigned) bl) {
			b |= ((unsigned long) fgetc(in_file)) << k;
			k += 8;
		}
		if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
			do {
				if (e == 99) {
					return 1;
				}
				b >>= t->b;
				k -= t->b;
				e -= 16;
				while (k < e) {
					b |= ((unsigned long) fgetc(in_file)) << k;
					k += 8;
				}
			} while ((e =
					  (t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
		b >>= t->b;
		k -= t->b;
		if (e == 16) {	/* then it's a literal */
			window[w++] = (unsigned char) t->v.n;
			if (w == WSIZE) {
				outcnt = (w), flush_window();
				w = 0;
			}
		} else {		/* it's an EOB or a length */

			/* exit if end of block */
			if (e == 15) {
				break;
			}

			/* get length of block to copy */
			while (k < e) {
				b |= ((unsigned long) fgetc(in_file)) << k;
				k += 8;
			}
			n = t->v.n + ((unsigned) b & mask_bits[e]);
			b >>= e;
			k -= e;

			/* decode distance of block to copy */
			while (k < (unsigned) bd) {
				b |= ((unsigned long) fgetc(in_file)) << k;
				k += 8;
			}

			if ((e = (t = td + ((unsigned) b & md))->e) > 16)
				do {
					if (e == 99)
						return 1;
					b >>= t->b;
					k -= t->b;
					e -= 16;
					while (k < e) {
						b |= ((unsigned long) fgetc(in_file)) << k;
						k += 8;
					}
				} while ((e =
						  (t =
						   t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
			b >>= t->b;
			k -= t->b;
			while (k < e) {
				b |= ((unsigned long) fgetc(in_file)) << k;
				k += 8;
			}
			d = w - t->v.n - ((unsigned) b & mask_bits[e]);
			b >>= e;
			k -= e;

			/* do the copy */
			do {
				n -= (e =
					  (e =
					   WSIZE - ((d &= WSIZE - 1) > w ? d : w)) > n ? n : e);
#if !defined(NOMEMCPY) && !defined(DEBUG)
				if (w - d >= e) {	/* (this test assumes unsigned comparison) */
					memcpy(window + w, window + d, e);
					w += e;
					d += e;
				} else	/* do it slow to avoid memcpy() overlap */
#endif							/* !NOMEMCPY */
					do {
						window[w++] = window[d++];
					} while (--e);
				if (w == WSIZE) {
					outcnt = (w), flush_window();
					w = 0;
				}
			} while (n);
		}
	}

	/* restore the globals from the locals */
	outcnt = w;			/* restore global window pointer */
	bb = b;				/* restore global bit buffer */
	bk = k;

	/* done */
	return 0;
}

static const unsigned short cplens[] = {	/* Copy lengths for literal codes 257..285 */
	3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
	35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
};

/* note: see note #13 above about the 258 in this list. */
static const extra_bits_t cplext[] = {	/* Extra bits for literal codes 257..285 */
	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, 99, 99
};						/* 99==invalid */
static const unsigned short cpdist[] = {	/* Copy offsets for distance codes 0..29 */
	1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
	257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
	8193, 12289, 16385, 24577
};
static const extra_bits_t cpdext[] = {	/* Extra bits for distance codes */
	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
};

/* Tables for deflate from PKZIP's appnote.txt. */
static const extra_bits_t border[] = {	/* Order of the bit length code lengths */
	16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};

/*
 * decompress an inflated block
 * e: last block flag
 *
 * GLOBAL VARIABLES: bb, kk,
 */
static int inflate_block(int *e)
{
	unsigned t;			/* block type */
	register unsigned long b;	/* bit buffer */
	register unsigned k;	/* number of bits in bit buffer */

	/* make local bit buffer */
	b = bb;
	k = bk;

	/* read in last block bit */
	while (k < 1) {
		b |= ((unsigned long) fgetc(in_file)) << k;
		k += 8;
	}
	*e = (int) b & 1;
	b >>= 1;
	k -= 1;

	/* read in block type */
	while (k < 2) {
		b |= ((unsigned long) fgetc(in_file)) << k;
		k += 8;
	}
	t = (unsigned) b & 3;
	b >>= 2;
	k -= 2;

	/* restore the global bit buffer */
	bb = b;
	bk = k;

	/* inflate that block type */
	switch (t) {
	case 0:			/* Inflate stored */
	{
		unsigned long n;	/* number of bytes in block */
		unsigned long w;	/* current window position */
		register unsigned long b_stored;	/* bit buffer */
		register unsigned long k_stored;	/* number of bits in bit buffer */

		/* make local copies of globals */
		b_stored = bb;	/* initialize bit buffer */
		k_stored = bk;
		w = outcnt;		/* initialize window position */

		/* go to byte boundary */
		n = k_stored & 7;
		b_stored >>= n;
		k_stored -= n;

		/* get the length and its complement */
		while (k_stored < 16) {
			b_stored |= ((unsigned long) fgetc(in_file)) << k_stored;
			k_stored += 8;
		}
		n = ((unsigned) b_stored & 0xffff);
		b_stored >>= 16;
		k_stored -= 16;
		while (k_stored < 16) {
			b_stored |= ((unsigned long) fgetc(in_file)) << k_stored;
			k_stored += 8;
		}
		if (n != (unsigned) ((~b_stored) & 0xffff)) {
			return 1;	/* error in compressed data */
		}
		b_stored >>= 16;
		k_stored -= 16;

		/* read and output the compressed data */
		while (n--) {
			while (k_stored < 8) {
				b_stored |= ((unsigned long) fgetc(in_file)) << k_stored;
				k_stored += 8;
			}
			window[w++] = (unsigned char) b_stored;
			if (w == (unsigned long) WSIZE) {
				outcnt = (w), flush_window();
				w = 0;
			}
			b_stored >>= 8;
			k_stored -= 8;
		}

		/* restore the globals from the locals */
		outcnt = w;		/* restore global window pointer */
		bb = b_stored;	/* restore global bit buffer */
		bk = k_stored;
		return 0;
	}
	case 1:			/* Inflate fixed 
						   * decompress an inflated type 1 (fixed Huffman codes) block.  We should
						   * either replace this with a custom decoder, or at least precompute the
						   * Huffman tables.
						 */
	{
		int i;			/* temporary variable */
		huft_t *tl;		/* literal/length code table */
		huft_t *td;		/* distance code table */
		int bl;			/* lookup bits for tl */
		int bd;			/* lookup bits for td */
		unsigned int l[288];	/* length list for huft_build */

		/* set up literal table */
		for (i = 0; i < 144; i++) {
			l[i] = 8;
		}
		for (; i < 256; i++) {
			l[i] = 9;
		}
		for (; i < 280; i++) {
			l[i] = 7;
		}
		for (; i < 288; i++) {	/* make a complete, but wrong code set */
			l[i] = 8;
		}
		bl = 7;
		if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) {
			return i;
		}

		/* set up distance table */
		for (i = 0; i < 30; i++) {	/* make an incomplete code set */
			l[i] = 5;
		}
		bd = 5;
		if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) {
			huft_free(tl);
			return i;
		}

		/* decompress until an end-of-block code */
		if (inflate_codes(tl, td, bl, bd))
			return 1;

		/* free the decoding tables, return */
		huft_free(tl);
		huft_free(td);
		return 0;
	}
	case 2:			/* Inflate dynamic */
	{
		const int dbits = 6;	/* bits in base distance lookup table */
		const int lbits = 9;	/* bits in base literal/length lookup table */

		int i;			/* temporary variables */
		unsigned j;
		unsigned l;		/* last length */
		unsigned m;		/* mask for bit lengths table */
		unsigned n;		/* number of lengths to get */
		huft_t *tl;		/* literal/length code table */
		huft_t *td;		/* distance code table */
		int bl;			/* lookup bits for tl */
		int bd;			/* lookup bits for td */
		unsigned nb;	/* number of bit length codes */
		unsigned nl;	/* number of literal/length codes */
		unsigned nd;	/* number of distance codes */

		unsigned ll[286 + 30];	/* literal/length and distance code lengths */
		register unsigned long b_dynamic;	/* bit buffer */
		register unsigned k_dynamic;	/* number of bits in bit buffer */

		/* make local bit buffer */
		b_dynamic = bb;
		k_dynamic = bk;

		/* read in table lengths */
		while (k_dynamic < 5) {
			b_dynamic |= ((unsigned long) fgetc(in_file)) << k_dynamic;
			k_dynamic += 8;
		}
		nl = 257 + ((unsigned) b_dynamic & 0x1f);	/* number of literal/length codes */
		b_dynamic >>= 5;
		k_dynamic -= 5;
		while (k_dynamic < 5) {
			b_dynamic |= ((unsigned long) fgetc(in_file)) << k_dynamic;
			k_dynamic += 8;
		}
		nd = 1 + ((unsigned) b_dynamic & 0x1f);	/* number of distance codes */
		b_dynamic >>= 5;
		k_dynamic -= 5;
		while (k_dynamic < 4) {
			b_dynamic |= ((unsigned long) fgetc(in_file)) << k_dynamic;
			k_dynamic += 8;
		}
		nb = 4 + ((unsigned) b_dynamic & 0xf);	/* number of bit length codes */
		b_dynamic >>= 4;
		k_dynamic -= 4;
		if (nl > 286 || nd > 30) {
			return 1;	/* bad lengths */
		}

		/* read in bit-length-code lengths */
		for (j = 0; j < nb; j++) {
			while (k_dynamic < 3) {
				b_dynamic |= ((unsigned long) fgetc(in_file)) << k_dynamic;
				k_dynamic += 8;
			}
			ll[border[j]] = (unsigned) b_dynamic & 7;
			b_dynamic >>= 3;
			k_dynamic -= 3;
		}
		for (; j < 19; j++) {
			ll[border[j]] = 0;
		}

		/* build decoding table for trees--single level, 7 bit lookup */
		bl = 7;
		if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) {
			if (i == 1) {
				huft_free(tl);
			}
			return i;	/* incomplete code set */
		}

		/* read in literal and distance code lengths */
		n = nl + nd;
		m = mask_bits[bl];
		i = l = 0;
		while ((unsigned) i < n) {
			while (k_dynamic < (unsigned) bl) {
				b_dynamic |= ((unsigned long) fgetc(in_file)) << k_dynamic;
				k_dynamic += 8;
			}
			j = (td = tl + ((unsigned) b_dynamic & m))->b;
			b_dynamic >>= j;
			k_dynamic -= j;
			j = td->v.n;
			if (j < 16) {	/* length of code in bits (0..15) */
				ll[i++] = l = j;	/* save last length in l */
			} else if (j == 16) {	/* repeat last length 3 to 6 times */
				while (k_dynamic < 2) {
					b_dynamic |=
						((unsigned long) fgetc(in_file)) << k_dynamic;
					k_dynamic += 8;
				}
				j = 3 + ((unsigned) b_dynamic & 3);
				b_dynamic >>= 2;
				k_dynamic -= 2;
				if ((unsigned) i + j > n) {
					return 1;
				}
				while (j--) {
					ll[i++] = l;
				}
			} else if (j == 17) {	/* 3 to 10 zero length codes */
				while (k_dynamic < 3) {
					b_dynamic |=
						((unsigned long) fgetc(in_file)) << k_dynamic;
					k_dynamic += 8;
				}
				j = 3 + ((unsigned) b_dynamic & 7);
				b_dynamic >>= 3;
				k_dynamic -= 3;
				if ((unsigned) i + j > n) {
					return 1;
				}
				while (j--) {
					ll[i++] = 0;
				}
				l = 0;
			} else {	/* j == 18: 11 to 138 zero length codes */
				while (k_dynamic < 7) {
					b_dynamic |=
						((unsigned long) fgetc(in_file)) << k_dynamic;
					k_dynamic += 8;
				}
				j = 11 + ((unsigned) b_dynamic & 0x7f);
				b_dynamic >>= 7;
				k_dynamic -= 7;
				if ((unsigned) i + j > n) {
					return 1;
				}
				while (j--) {
					ll[i++] = 0;
				}
				l = 0;
			}
		}

		/* free decoding table for trees */
		huft_free(tl);

		/* restore the global bit buffer */
		bb = b_dynamic;
		bk = k_dynamic;

		/* build the decoding tables for literal/length and distance codes */
		bl = lbits;
		if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
			if (i == 1) {
				error_msg("Incomplete literal tree");
				huft_free(tl);
			}
			return i;	/* incomplete code set */
		}
		bd = dbits;
		if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) {
			if (i == 1) {
				error_msg("incomplete distance tree");
				huft_free(td);
			}
			huft_free(tl);
			return i;	/* incomplete code set */
		}

		/* decompress until an end-of-block code */
		if (inflate_codes(tl, td, bl, bd))
			return 1;

		/* free the decoding tables, return */
		huft_free(tl);
		huft_free(td);
		return 0;
	}
	default:
		/* bad block type */
		return 2;
	}
}

/*
 * decompress an inflated entry
 *
 * GLOBAL VARIABLES: outcnt, bk, bb, hufts, inptr
 */
extern int inflate(FILE * in, FILE * out)
{
	int e;				/* last block flag */
	int r;				/* result code */
	unsigned h = 0;		/* maximum struct huft's malloc'ed */

	/* initialize window, bit buffer */
	outcnt = 0;
	bk = 0;
	bb = 0;

	in_file = in;
	out_file = out;

	/* Allocate all global buffers (for DYN_ALLOC option) */
	window = xmalloc((size_t) (((2L * WSIZE) + 1L) * sizeof(unsigned char)));
	bytes_out = 0L;

	/* Create the crc table */
	make_crc_table();

	/* decompress until the last block */
	do {
		hufts = 0;
		if ((r = inflate_block(&e)) != 0) {
			return r;
		}
		if (hufts > h) {
			h = hufts;
		}
	} while (!e);

	/* Undo too much lookahead. The next read will be byte aligned so we
	 * can discard unused bits in the last meaningful byte.
	 */
	while (bk >= 8) {
		bk -= 8;
		ungetc((bb << bk), in_file);
	}

	/* flush out window */
	flush_window();
	free(window);
	free(crc_table);

	/* return success */
	return 0;
}

/* ===========================================================================
 * Unzip in to out.  This routine works on gzip files only.
 *
 * IN assertions: the buffer inbuf contains already the beginning of
 *   the compressed data, from offsets inptr to insize-1 included.
 *   The magic header has already been checked. The output buffer is cleared.
 * in, out: input and output file descriptors
 */
extern int unzip(FILE * l_in_file, FILE * l_out_file)
{
	unsigned char buf[8];	/* extended local header */
	unsigned char flags;	/* compression flags */
	typedef void (*sig_type) (int);
	unsigned short i;
	unsigned char magic[2];

	if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
		(void) signal(SIGINT, (sig_type) abort_gzip);
	}
#ifdef SIGHUP
	if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
		(void) signal(SIGHUP, (sig_type) abort_gzip);
	}
#endif

	magic[0] = fgetc(l_in_file);
	magic[1] = fgetc(l_in_file);

#ifdef CONFIG_FEATURE_UNCOMPRESS
	/* Magic header for compress files, 1F 9d = \037\235 */
	if ((magic[0] == 0x1F) && (magic[1] == 0x9d)) {
		return uncompress(l_in_file, l_out_file);
	}
#endif

	/* Magic header for gzip files, 1F 8B = \037\213 */
	if ((magic[0] != 0x1F) || (magic[1] != 0x8b)) {
		error_msg("Invalid gzip magic");
		return EXIT_FAILURE;
	}

	/* Check the compression method */
	if (fgetc(l_in_file) != 8) {
		error_msg("Unknown compression method");
		return (-1);
	}

	flags = (unsigned char) fgetc(l_in_file);

	/* Ignore time stamp(4), extra flags(1), OS type(1) */
	for (i = 0; i < 6; i++) {
		fgetc(l_in_file);
	}

	if (flags & 0x04) {
		/* bit 2 set: extra field present */
		const unsigned short extra =
			fgetc(l_in_file) + (fgetc(l_in_file) << 8);

		for (i = 0; i < extra; i++) {
			fgetc(l_in_file);
		}
	}

	/* Discard original name if any */
	if (flags & 0x08) {
		/* bit 3 set: original file name present */
		while (fgetc(l_in_file) != 0);	/* null */
	}

	/* Discard file comment if any */
	if (flags & 0x10) {
		/* bit 4 set: file comment present */
		while (fgetc(l_in_file) != 0);	/* null */
	}

	/* Decompress */
	if (inflate(l_in_file, l_out_file) != 0) {
		error_msg("invalid compressed data--format violated");
	}

	/* Get the crc and original length
	 * crc32  (see algorithm.doc)
	 * uncompressed input size modulo 2^32
	 */
	fread(buf, 1, 8, l_in_file);

	/* Validate decompression - crc */
	if ((unsigned int) ((buf[0] | (buf[1] << 8)) |
						((buf[2] | (buf[3] << 8)) << 16)) !=
		(crc ^ 0xffffffffL)) {
		error_msg("invalid compressed data--crc error");
	}
	/* Validate decompression - size */
	if (((buf[4] | (buf[5] << 8)) | ((buf[6] | (buf[7] << 8)) << 16)) !=
		(unsigned long) bytes_out) {
		error_msg("invalid compressed data--length error");
	}

	return 0;
}

/*
 * This needs access to global variables window and crc_table, so its not in its own file.
 */
extern void gz_close(int gunzip_pid)
{
	if (kill(gunzip_pid, SIGTERM) == -1) {
		error_msg_and_die
			("***  Couldnt kill old gunzip process *** aborting");
	}

	if (waitpid(gunzip_pid, NULL, 0) == -1) {
		printf("Couldnt wait ?");
	}

	free(window);
	free(crc_table);
}
