62 crypt.c
@@ -84,15 +84,15 @@
# endif
# define GLOBAL(g) g
#else /* !ZIP */
# define GLOBAL(g) G.g
# define GLOBAL(g) (*(Uz_Globs *)pG).g
#endif /* ?ZIP */


#ifdef UNZIP
/* char *key = (char *)NULL; moved to globals.h */
# ifndef FUNZIP
local int testp (__GPRO__ const uch *h);
local int testkey (__GPRO__ const uch *h, const char *key);
local int testp (Uz_Globs *pG, const uch *h);
local int testkey (Uz_Globs *pG, const uch *h, const char *key);
# endif
#endif /* UNZIP */

@@ -135,7 +135,7 @@
#ifdef IZ_CRC_BE_OPTIMIZ
local z_uint4 near crycrctab[256];
local z_uint4 near *cry_crctb_p = NULL;
local z_uint4 near *crytab_init OF((__GPRO));
local z_uint4 near *crytab_init OF((Uz_Globs *pG));
# define CRY_CRC_TAB cry_crctb_p
# undef CRC32
# define CRC32(c, b, crctab) (crctab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
@@ -146,8 +146,8 @@
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
int decrypt_byte(__G)
__GDEF
int decrypt_byte(pG)
Uz_Globs *pG;
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
@@ -160,8 +160,8 @@ int decrypt_byte(__G)
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
int update_keys(__G__ c)
__GDEF
int update_keys(pG, c)
Uz_Globs *pG;
int c;
{
GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c, CRY_CRC_TAB);
@@ -180,20 +180,20 @@ int c;
* Initialize the encryption keys and the random header according to
* the given password.
*/
void init_keys(__G__ passwd)
__GDEF
void init_keys(pG, passwd)
Uz_Globs *pG;
const char *passwd; /* password string with which to modify keys */
{
#ifdef IZ_CRC_BE_OPTIMIZ
if (cry_crctb_p == NULL) {
cry_crctb_p = crytab_init(__G);
cry_crctb_p = crytab_init(pG);
}
#endif
GLOBAL(keys[0]) = 305419896L;
GLOBAL(keys[1]) = 591751049L;
GLOBAL(keys[2]) = 878082192L;
while (*passwd != '\0') {
update_keys(__G__ (int)*passwd);
update_keys(pG, (int)*passwd);
passwd++;
}
}
@@ -209,8 +209,8 @@ void init_keys(__G__ passwd)
* crypt-crc32-table.
*/
#ifdef IZ_CRC_BE_OPTIMIZ
local z_uint4 near *crytab_init(__G)
__GDEF
local z_uint4 near *crytab_init(pG)
Uz_Globs *pG;
{
int i;

@@ -450,8 +450,8 @@ unsigned zfwrite(buf, item_size, nb, f)
* Get the password and set up keys for current zipfile member.
* Return PK_ class error.
*/
int decrypt(__G__ passwrd)
__GDEF
int decrypt(pG, passwrd)
Uz_Globs *pG;
const char *passwrd;
{
ush b;
@@ -463,13 +463,13 @@ int decrypt(__G__ passwrd)
/* get header once (turn off "encrypted" flag temporarily so we don't
* try to decrypt the same data twice) */
GLOBAL(pInfo->encrypted) = FALSE;
defer_leftover_input(__G);
defer_leftover_input(pG);
for (n = 0; n < RAND_HEAD_LEN; n++) {
b = NEXTBYTE;
h[n] = (uch)b;
Trace((stdout, " (%02x)", h[n]));
}
undefer_input(__G);
undefer_input(pG);
GLOBAL(pInfo->encrypted) = TRUE;

if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */
@@ -490,7 +490,7 @@ int decrypt(__G__ passwrd)

/* if have key already, test it; else allocate memory for it */
if (GLOBAL(key)) {
if (!testp(__G__ h))
if (!testp(pG, h))
return PK_COOL; /* existing password OK (else prompt for new) */
else if (GLOBAL(nopwd))
return PK_WARN; /* user indicated no more prompting */
@@ -500,7 +500,7 @@ int decrypt(__G__ passwrd)
/* try a few keys */
n = 0;
do {
r = (*G.decr_passwd)((void *)&G, &n, GLOBAL(key), IZ_PWLEN+1,
r = (*(*(Uz_Globs *)pG).decr_passwd)((void *)&(*(Uz_Globs *)pG), &n, GLOBAL(key), IZ_PWLEN+1,
GLOBAL(zipfn), GLOBAL(filename));
if (r == IZ_PW_ERROR) { /* internal error in fetch of PW */
free (GLOBAL(key));
@@ -511,7 +511,7 @@ int decrypt(__G__ passwrd)
*GLOBAL(key) = '\0'; /* We try the NIL password, ... */
n = 0; /* and cancel fetch for this item. */
}
if (!testp(__G__ h))
if (!testp(pG, h))
return PK_COOL;
if (r == IZ_PW_CANCELALL) /* User replied "Skip all" */
GLOBAL(nopwd) = TRUE; /* inhibit any further PW prompt! */
@@ -526,8 +526,8 @@ int decrypt(__G__ passwrd)
/***********************************************************************
* Test the password. Return -1 if bad, 0 if OK.
*/
local int testp(__G__ h)
__GDEF
local int testp(pG, h)
Uz_Globs *pG;
const uch *h;
{
int r;
@@ -542,10 +542,10 @@ local int testp(__G__ h)
if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
return -1;
/* first try, test password translated "standard" charset */
r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key)));
r = testkey(pG, h, STR_TO_CP1(key_translated, GLOBAL(key)));
#else /* !STR_TO_CP1 */
/* first try, test password as supplied on the extractor's host */
r = testkey(__G__ h, GLOBAL(key));
r = testkey(pG, h, GLOBAL(key));
#endif /* ?STR_TO_CP1 */

#ifdef STR_TO_CP2
@@ -556,11 +556,11 @@ local int testp(__G__ h)
return -1;
#endif
/* second try, password translated to alternate ("standard") charset */
r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key)));
r = testkey(pG, h, STR_TO_CP2(key_translated, GLOBAL(key)));
#ifdef STR_TO_CP3
if (r != 0)
/* third try, password translated to another "standard" charset */
r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key)));
r = testkey(pG, h, STR_TO_CP3(key_translated, GLOBAL(key)));
#endif
#ifndef STR_TO_CP1
free(key_translated);
@@ -572,7 +572,7 @@ local int testp(__G__ h)
free(key_translated);
if (r != 0) {
/* last resort, test password as supplied on the extractor's host */
r = testkey(__G__ h, GLOBAL(key));
r = testkey(pG, h, GLOBAL(key));
}
#endif /* STR_TO_CP1 */

@@ -581,8 +581,8 @@ local int testp(__G__ h)
} /* end function testp() */


local int testkey(__G__ h, key)
__GDEF
local int testkey(pG, h, key)
Uz_Globs *pG;
const uch *h; /* decrypted header */
const char *key; /* decryption password to test */

@@ -596,7 +596,7 @@ local int testkey(__G__ h, key)
uch hh[RAND_HEAD_LEN]; /* decrypted header */

/* set keys and save the encrypted header */
init_keys(__G__ key);
init_keys(pG, key);
memcpy(hh, h, RAND_HEAD_LEN);

/* check password */
14 crypt.h
@@ -115,14 +115,14 @@
/* the crc_32_tab array has to be provided externally for the crypt calculus */

/* encode byte c, using temp t. Warning: c must not have side effects. */
#define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c))
#define zencode(c,t) (t=decrypt_byte(pG), update_keys(c), t^(c))

/* decode byte c in place */
#define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G))
#define zdecode(c) update_keys(pG, c ^= decrypt_byte(pG))

int decrypt_byte (__GPRO);
int update_keys (__GPRO__ int c);
void init_keys (__GPRO__ const char *passwd);
int decrypt_byte (Uz_Globs *pG);
int update_keys (Uz_Globs *pG, int c);
void init_keys (Uz_Globs *pG, const char *passwd);

#ifdef ZIP
void crypthead OF((const char *, ulg, FILE *));
@@ -136,7 +136,7 @@ void init_keys (__GPRO__ const char *passwd);
#endif /* ZIP */

#if (defined(UNZIP) && !defined(FUNZIP))
int decrypt (__GPRO__ const char *passwrd);
int decrypt (Uz_Globs *pG, const char *passwrd);
#endif

#ifdef FUNZIP
@@ -145,7 +145,7 @@ void init_keys (__GPRO__ const char *passwd);
# undef NEXTBYTE
# endif
# define NEXTBYTE \
(encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in))
(encrypted? update_keys(pG, getc((*(Uz_Globs *)pG).in)^decrypt_byte(pG)) : getc((*(Uz_Globs *)pG).in))
#endif /* FUNZIP */

#else /* !CRYPT */
104 explode.c
@@ -35,18 +35,18 @@
the 32K window size for specialized
applications.
c6 31 May 92 M. Adler added typecasts to eliminate some warnings
c7 27 Jun 92 G. Roelofs added more typecasts.
c8 17 Oct 92 G. Roelofs changed ULONG/UWORD/byte to ulg/ush/uch.
c7 27 Jun 92 (*(Uz_Globs *)pG). Roelofs added more typecasts.
c8 17 Oct 92 (*(Uz_Globs *)pG). Roelofs changed ULONG/UWORD/byte to ulg/ush/uch.
c9 19 Jul 93 J. Bush added more typecasts (to return values);
made l[256] array static for Amiga.
c10 8 Oct 93 G. Roelofs added used_csize for diagnostics; added
c10 8 Oct 93 (*(Uz_Globs *)pG). Roelofs added used_csize for diagnostics; added
buf and unshrink arguments to flush();
undef'd various macros at end for Turbo C;
removed NEXTBYTE macro (now in unzip.h)
and bytebuf variable (not used); changed
memset() to memzero().
c11 9 Jan 94 M. Adler fixed incorrect used_csize calculation.
c12 9 Apr 94 G. Roelofs fixed split comments on preprocessor lines
c12 9 Apr 94 (*(Uz_Globs *)pG). Roelofs fixed split comments on preprocessor lines
to avoid bug in Encore compiler.
c13 25 Aug 94 M. Adler fixed distance-length comment (orig c9 fix)
c14 22 Nov 95 S. Maxwell removed unnecessary "static" on auto array
@@ -122,7 +122,7 @@
#endif /* at least 8K for zip's implode method */

#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
# define wszimpl (unsigned)(G._wsize)
# define wszimpl (unsigned)((*(Uz_Globs *)pG)._wsize)
#else
# if defined(USE_DEFLATE64) && defined(INT_16BIT)
# define wszimpl (unsigned)(WSIZE>>1)
@@ -132,13 +132,13 @@
#endif

/* routines here */
static int get_tree (__GPRO__ unsigned *l, unsigned n);
static int explode_lit (__GPRO__ struct huft *tb, struct huft *tl,
static int get_tree (Uz_Globs *pG, unsigned *l, unsigned n);
static int explode_lit (Uz_Globs *pG, struct huft *tb, struct huft *tl,
struct huft *td, unsigned bb, unsigned bl,
unsigned bd, unsigned bdl);
static int explode_nolit (__GPRO__ struct huft *tl, struct huft *td,
static int explode_nolit (Uz_Globs *pG, struct huft *tl, struct huft *td,
unsigned bl, unsigned bd, unsigned bdl);
int explode (__GPRO);
int explode (Uz_Globs *pG);


/* The implode algorithm uses a sliding 4K or 8K byte window on the
@@ -219,8 +219,8 @@ static const ush cpdist8[] =
}


static int get_tree(__G__ l, n)
__GDEF
static int get_tree(pG, l, n)
Uz_Globs *pG;
unsigned *l; /* bit lengths */
unsigned n; /* number expected */
/* Get the bit lengths for a code representation from the compressed
@@ -250,8 +250,8 @@ unsigned n; /* number expected */



static int explode_lit(__G__ tb, tl, td, bb, bl, bd, bdl)
__GDEF
static int explode_lit(pG, tb, tl, td, bb, bl, bd, bdl)
Uz_Globs *pG;
struct huft *tb, *tl, *td; /* literal, length, and distance tables */
unsigned bb, bl, bd; /* number of bits decoded by those */
unsigned bdl; /* number of distance low bits */
@@ -278,7 +278,7 @@ unsigned bdl; /* number of distance low bits */
ml = mask_bits[bl];
md = mask_bits[bd];
mdl = mask_bits[bdl];
s = G.lrec.ucsize;
s = (*(Uz_Globs *)pG).lrec.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
@@ -290,7 +290,7 @@ unsigned bdl; /* number of distance low bits */
redirSlide[w++] = (uch)t->v.n;
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
if ((retval = flush(pG, redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
@@ -316,7 +316,7 @@ unsigned bdl; /* number of distance low bits */
s = (s > (zusz_t)n ? s - (zusz_t)n : 0);
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
if ((*(Uz_Globs *)pG).redirect_slide) {
/* &= w/ wszimpl not needed and wrong if redirect */
if (d >= wszimpl)
return 1;
@@ -347,7 +347,7 @@ unsigned bdl; /* number of distance low bits */
} while (--e);
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
if ((retval = flush(pG, redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
@@ -356,20 +356,20 @@ unsigned bdl; /* number of distance low bits */
}

/* flush out redirSlide */
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
if ((retval = flush(pG, redirSlide, (ulg)w, 0)) != 0)
return retval;
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
if ((*(Uz_Globs *)pG).csize + (*(Uz_Globs *)pG).incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
(*(Uz_Globs *)pG).used_csize = (*(Uz_Globs *)pG).lrec.csize - (*(Uz_Globs *)pG).csize - (*(Uz_Globs *)pG).incnt - (k >> 3);
return 5;
}
return 0;
}



static int explode_nolit(__G__ tl, td, bl, bd, bdl)
__GDEF
static int explode_nolit(pG, tl, td, bl, bd, bdl)
Uz_Globs *pG;
struct huft *tl, *td; /* length and distance decoder tables */
unsigned bl, bd; /* number of bits decoded by tl[] and td[] */
unsigned bdl; /* number of distance low bits */
@@ -395,7 +395,7 @@ unsigned bdl; /* number of distance low bits */
ml = mask_bits[bl]; /* precompute masks for speed */
md = mask_bits[bd];
mdl = mask_bits[bdl];
s = G.lrec.ucsize;
s = (*(Uz_Globs *)pG).lrec.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
@@ -407,7 +407,7 @@ unsigned bdl; /* number of distance low bits */
redirSlide[w++] = (uch)b;
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
if ((retval = flush(pG, redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
@@ -434,7 +434,7 @@ unsigned bdl; /* number of distance low bits */
s = (s > (zusz_t)n ? s - (zusz_t)n : 0);
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
if ((*(Uz_Globs *)pG).redirect_slide) {
/* &= w/ wszimpl not needed and wrong if redirect */
if (d >= wszimpl)
return 1;
@@ -465,7 +465,7 @@ unsigned bdl; /* number of distance low bits */
} while (--e);
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
if ((retval = flush(pG, redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
@@ -474,20 +474,20 @@ unsigned bdl; /* number of distance low bits */
}

/* flush out redirSlide */
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
if ((retval = flush(pG, redirSlide, (ulg)w, 0)) != 0)
return retval;
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
if ((*(Uz_Globs *)pG).csize + (*(Uz_Globs *)pG).incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
(*(Uz_Globs *)pG).used_csize = (*(Uz_Globs *)pG).lrec.csize - (*(Uz_Globs *)pG).csize - (*(Uz_Globs *)pG).incnt - (k >> 3);
return 5;
}
return 0;
}



int explode(__G)
__GDEF
int explode(pG)
Uz_Globs *pG;
/* Explode an imploded compressed stream. Based on the general purpose
bit flag, decide on coded or uncoded literals, and an 8K or 4K sliding
window. Construct the literal (if any), length, and distance codes and
@@ -508,19 +508,19 @@ int explode(__G)
unsigned l[256]; /* bit lengths for codes */

#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide)
if ((*(Uz_Globs *)pG).redirect_slide)
/* For 16-bit systems, it has already been checked at DLL entrance that
* the buffer size in G.redirect_size does not exceed unsigned range.
* the buffer size in (*(Uz_Globs *)pG).redirect_size does not exceed unsigned range.
*/
G._wsize = G.redirect_size, redirSlide = G.redirect_buffer;
(*(Uz_Globs *)pG)._wsize = (*(Uz_Globs *)pG).redirect_size, redirSlide = (*(Uz_Globs *)pG).redirect_buffer;
else
#if defined(USE_DEFLATE64) && defined(INT_16BIT)
/* For systems using 16-bit ints, reduce the used buffer size below
* the limit of "unsigned int" numbers range.
*/
G._wsize = WSIZE>>1, redirSlide = slide;
(*(Uz_Globs *)pG)._wsize = WSIZE>>1, redirSlide = slide;
#else /* !(USE_DEFLATE64 && INT_16BIT) */
G._wsize = WSIZE, redirSlide = slide;
(*(Uz_Globs *)pG)._wsize = WSIZE, redirSlide = slide;
#endif /* !(USE_DEFLATE64 && INT_16BIT) */
#endif /* DLL && !NO_SLIDE_REDIR */

@@ -530,29 +530,29 @@ int explode(__G)
7, 7, and 9 worked best over a very wide range of sizes, except that
bd = 8 worked marginally better for large compressed sizes. */
bl = 7;
bd = (G.csize + G.incnt) > 200000L ? 8 : 7;
bd = ((*(Uz_Globs *)pG).csize + (*(Uz_Globs *)pG).incnt) > 200000L ? 8 : 7;

#ifdef DEBUG
G.hufts = 0; /* initialize huft's malloc'ed */
(*(Uz_Globs *)pG).hufts = 0; /* initialize huft's malloc'ed */
#endif

if (G.lrec.general_purpose_bit_flag & 4)
if ((*(Uz_Globs *)pG).lrec.general_purpose_bit_flag & 4)
/* With literal tree--minimum match length is 3 */
{
bb = 9; /* base table size for literals */
if ((r = get_tree(__G__ l, 256)) != 0)
if ((r = get_tree(pG, l, 256)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 256, 256, NULL, NULL, &tb, &bb)) != 0)
if ((r = huft_build(pG, l, 256, 256, NULL, NULL, &tb, &bb)) != 0)
{
if (r == 1)
huft_free(tb);
return (int)r;
}
if ((r = get_tree(__G__ l, 64)) != 0) {
if ((r = get_tree(pG, l, 64)) != 0) {
huft_free(tb);
return (int)r;
}
if ((r = huft_build(__G__ l, 64, 0, cplen3, extra, &tl, &bl)) != 0)
if ((r = huft_build(pG, l, 64, 0, cplen3, extra, &tl, &bl)) != 0)
{
if (r == 1)
huft_free(tl);
@@ -564,30 +564,30 @@ int explode(__G)
/* No literal tree--minimum match length is 2 */
{
tb = (struct huft *)NULL;
if ((r = get_tree(__G__ l, 64)) != 0)
if ((r = get_tree(pG, l, 64)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 64, 0, cplen2, extra, &tl, &bl)) != 0)
if ((r = huft_build(pG, l, 64, 0, cplen2, extra, &tl, &bl)) != 0)
{
if (r == 1)
huft_free(tl);
return (int)r;
}
}

if ((r = get_tree(__G__ l, 64)) != 0) {
if ((r = get_tree(pG, l, 64)) != 0) {
huft_free(tl);
if (tb != (struct huft *)NULL) huft_free(tb);
return (int)r;
}
if (G.lrec.general_purpose_bit_flag & 2) /* true if 8K */
if ((*(Uz_Globs *)pG).lrec.general_purpose_bit_flag & 2) /* true if 8K */
{
bdl = 7;
r = huft_build(__G__ l, 64, 0, cpdist8, extra, &td, &bd);
r = huft_build(pG, l, 64, 0, cpdist8, extra, &td, &bd);
}
else /* else 4K */
{
bdl = 6;
r = huft_build(__G__ l, 64, 0, cpdist4, extra, &td, &bd);
r = huft_build(pG, l, 64, 0, cpdist4, extra, &td, &bd);
}
if (r != 0)
{
@@ -599,15 +599,15 @@ int explode(__G)
}

if (tb != NULL) {
r = explode_lit(__G__ tb, tl, td, bb, bl, bd, bdl);
r = explode_lit(pG, tb, tl, td, bb, bl, bd, bdl);
huft_free(tb);
} else {
r = explode_nolit(__G__ tl, td, bl, bd, bdl);
r = explode_nolit(pG, tl, td, bl, bd, bdl);
}

huft_free(td);
huft_free(tl);
Trace((stderr, "<%u > ", G.hufts));
Trace((stderr, "<%u > ", (*(Uz_Globs *)pG).hufts));
return (int)r;
}

826 extract.c

Large diffs are not rendered by default.

644 fileio.c

Large diffs are not rendered by default.

122 funzip.c
@@ -33,62 +33,62 @@
entries, added more help.
1.3 16 Aug 92 M. Adler removed redundant #define's, added
decryption.
1.4 27 Aug 92 G. Roelofs added exit(0).
1.4 27 Aug 92 (*(Uz_Globs *)pG). Roelofs added exit(0).
1.5 1 Sep 92 K. U. Rommel changed read/write modes for OS/2.
1.6 6 Sep 92 G. Roelofs modified to use dummy crypt.c and
1.6 6 Sep 92 (*(Uz_Globs *)pG). Roelofs modified to use dummy crypt.c and
crypt.h instead of -DCRYPT.
1.7 23 Sep 92 G. Roelofs changed to use DOS_OS2; included
1.7 23 Sep 92 (*(Uz_Globs *)pG). Roelofs changed to use DOS_OS2; included
crypt.c under MS-DOS.
1.8 9 Oct 92 M. Adler improved inflation error msgs.
1.9 17 Oct 92 G. Roelofs changed ULONG/UWORD/byte to ulg/ush/uch;
1.9 17 Oct 92 (*(Uz_Globs *)pG). Roelofs changed ULONG/UWORD/byte to ulg/ush/uch;
renamed inflate_entry() to inflate();
adapted to use new, in-place zdecode.
2.0 22 Oct 92 M. Adler allow filename argument, prompt for
passwords and don't echo, still allow
command-line password entry, but as an
option.
2.1 23 Oct 92 J-l. Gailly fixed crypt/store bug,
G. Roelofs removed crypt.c under MS-DOS, fixed
(*(Uz_Globs *)pG). Roelofs removed crypt.c under MS-DOS, fixed
decryption check to compare single byte.
2.2 28 Oct 92 G. Roelofs removed declaration of key.
2.2 28 Oct 92 (*(Uz_Globs *)pG). Roelofs removed declaration of key.
2.3 14 Dec 92 M. Adler replaced fseek (fails on stdin for SCO
Unix V.3.2.4). added quietflg for
inflate.c.
3.0 11 May 93 M. Adler added gzip support
3.1 9 Jul 93 K. U. Rommel fixed OS/2 pipe bug (PIPE_ERROR)
3.2 4 Sep 93 G. Roelofs moved crc_32_tab[] to tables.h; used FOPx
3.2 4 Sep 93 (*(Uz_Globs *)pG). Roelofs moved crc_32_tab[] to tables.h; used FOPx
from unzip.h; nuked OUTB macro and outbuf;
replaced flush(); inlined FlushOutput();
renamed decrypt to encrypted
3.3 29 Sep 93 G. Roelofs replaced ReadByte() with NEXTBYTE macro;
3.3 29 Sep 93 (*(Uz_Globs *)pG). Roelofs replaced ReadByte() with NEXTBYTE macro;
revised (restored?) flush(); added FUNZIP
3.4 21 Oct 93 G. Roelofs renamed quietflg to qflag; changed outcnt,
3.4 21 Oct 93 (*(Uz_Globs *)pG). Roelofs renamed quietflg to qflag; changed outcnt,
H. Gessau second updcrc() arg and flush() arg to ulg;
added inflate_free(); added "g =" to null
getc(in) to avoid compiler warnings
3.5 31 Oct 93 H. Gessau changed DOS_OS2 to DOS_NT_OS2
3.6 6 Dec 93 H. Gessau added "near" to mask_bits[]
3.7 9 Dec 93 G. Roelofs added extent typecasts to fwrite() checks
3.7 9 Dec 93 (*(Uz_Globs *)pG). Roelofs added extent typecasts to fwrite() checks
3.8 28 Jan 94 GRR/JlG initialized g variable in main() for gcc
3.81 22 Feb 94 M. Hanning-Lee corrected usage message
3.82 27 Feb 94 G. Roelofs added some typecasts to avoid warnings
3.83 22 Jul 94 G. Roelofs changed fprintf to macro for DLLs
3.82 27 Feb 94 (*(Uz_Globs *)pG). Roelofs added some typecasts to avoid warnings
3.83 22 Jul 94 (*(Uz_Globs *)pG). Roelofs changed fprintf to macro for DLLs
- 2 Aug 94 - public release with UnZip 5.11
- 28 Aug 94 - public release with UnZip 5.12
3.84 1 Oct 94 K. U. Rommel changes for Metaware High C
3.85 29 Oct 94 G. Roelofs changed fprintf macro to Info
3.85 29 Oct 94 (*(Uz_Globs *)pG). Roelofs changed fprintf macro to Info
3.86 7 May 95 K. Davis RISCOS patches;
P. Kienitz Amiga patches
3.87 12 Aug 95 G. Roelofs inflate_free(), DESTROYGLOBALS fixes
3.87 12 Aug 95 (*(Uz_Globs *)pG). Roelofs inflate_free(), DESTROYGLOBALS fixes
3.88 4 Sep 95 C. Spieler reordered macro to work around MSC 5.1 bug
3.89 22 Nov 95 PK/CS ifdef'd out updcrc() for ASM_CRC
3.9 17 Dec 95 G. Roelofs modified for USE_ZLIB (new fillinbuf())
3.9 17 Dec 95 (*(Uz_Globs *)pG). Roelofs modified for USE_ZLIB (new fillinbuf())
- 30 Apr 96 - public release with UnZip 5.2
3.91 17 Aug 96 G. Roelofs main() -> return int (Peter Seebach)
3.92 13 Apr 97 G. Roelofs minor cosmetic fixes to messages
3.91 17 Aug 96 (*(Uz_Globs *)pG). Roelofs main() -> return int (Peter Seebach)
3.92 13 Apr 97 (*(Uz_Globs *)pG). Roelofs minor cosmetic fixes to messages
- 22 Apr 97 - public release with UnZip 5.3
- 31 May 97 - public release with UnZip 5.31
3.93 20 Sep 97 G. Roelofs minor cosmetic fixes to messages
3.93 20 Sep 97 (*(Uz_Globs *)pG). Roelofs minor cosmetic fixes to messages
- 3 Nov 97 - public release with UnZip 5.32
- 28 Nov 98 - public release with UnZip 5.4
- 16 Apr 00 - public release with UnZip 5.41
@@ -179,34 +179,34 @@ static int partflush OF((uch *rawbuf, unsigned w));
int main OF((int, char **));

/* Globals */
FILE *out; /* output file (*in moved to G struct) */
FILE *out; /* output file (*in moved to (*(Uz_Globs *)pG) struct) */
ulg outsiz; /* total bytes written to out */
int encrypted; /* flag to turn on decryption */


#ifdef USE_ZLIB

int fillinbuf(__G)
__GDEF
int fillinbuf(pG)
Uz_Globs *pG;
/* Fill input buffer for pull-model inflate() in zlib. Return the number of
* bytes in inbuf. */
{
/* GRR: check return value from fread(): same as read()? check errno? */
if ((G.incnt = fread((char *)G.inbuf, 1, INBUFSIZ, G.in)) <= 0)
if (((*(Uz_Globs *)pG).incnt = fread((char *)(*(Uz_Globs *)pG).inbuf, 1, INBUFSIZ, (*(Uz_Globs *)pG).in)) <= 0)
return 0;
G.inptr = G.inbuf;
(*(Uz_Globs *)pG).inptr = (*(Uz_Globs *)pG).inbuf;

#if CRYPT
if (encrypted) {
uch *p;
int n;

for (n = G.incnt, p = G.inptr; n--; p++)
for (n = (*(Uz_Globs *)pG).incnt, p = (*(Uz_Globs *)pG).inptr; n--; p++)
zdecode(*p);
}
#endif /* CRYPT */

return G.incnt;
return (*(Uz_Globs *)pG).incnt;

}

@@ -266,7 +266,7 @@ int main(int argc, char **argv)
*/
# define UZ_SLIDE_CHUNK (sizeof(shrint)+sizeof(uch)+sizeof(uch))
# define UZ_NUMOF_CHUNKS (unsigned)( (WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK )
G.area.Slide = (uch *)zcalloc(UZ_NUMOF_CHUNKS, UZ_SLIDE_CHUNK);
(*(Uz_Globs *)pG).area.Slide = (uch *)zcalloc(UZ_NUMOF_CHUNKS, UZ_SLIDE_CHUNK);
# undef UZ_SLIDE_CHUNK
# undef UZ_NUMOF_CHUNKS
#endif
@@ -289,7 +289,7 @@ int main(int argc, char **argv)
/* prepare to be a binary filter */
if (argc)
{
if ((G.in = fopen(*argv, FOPR)) == (FILE *)NULL)
if (((*(Uz_Globs *)pG).in = fopen(*argv, FOPR)) == (FILE *)NULL)
err(2, "cannot find input file");
}
else
@@ -303,9 +303,9 @@ int main(int argc, char **argv)
#endif /* DOS_FLX_NLM_OS2_W32 */

#ifdef RISCOS
G.in = stdin;
(*(Uz_Globs *)pG).in = stdin;
#else
if ((G.in = fdopen(0, FOPR)) == (FILE *)NULL)
if (((*(Uz_Globs *)pG).in = fdopen(0, FOPR)) == (FILE *)NULL)
err(2, "cannot find stdin");
#endif
}
@@ -326,10 +326,10 @@ int main(int argc, char **argv)
#endif

/* read local header, check validity, and skip name and extra fields */
n = getc(G.in); n |= getc(G.in) << 8;
n = getc((*(Uz_Globs *)pG).in); n |= getc((*(Uz_Globs *)pG).in) << 8;
if (n == ZIPMAG)
{
if (fread((char *)h, 1, LOCHDR, G.in) != LOCHDR || SH(h) != LOCREM)
if (fread((char *)h, 1, LOCHDR, (*(Uz_Globs *)pG).in) != LOCHDR || SH(h) != LOCREM)
err(3, "invalid zipfile");
switch (method = SH(h + LOCHOW)) {
case STORED:
@@ -342,28 +342,28 @@ int main(int argc, char **argv)
err(3, "first entry not deflated or stored--cannot unpack");
break;
}
for (n = SH(h + LOCFIL); n--; ) g = getc(G.in);
for (n = SH(h + LOCEXT); n--; ) g = getc(G.in);
for (n = SH(h + LOCFIL); n--; ) g = getc((*(Uz_Globs *)pG).in);
for (n = SH(h + LOCEXT); n--; ) g = getc((*(Uz_Globs *)pG).in);
g = 0;
encrypted = h[LOCFLG] & CRPFLG;
}
else if (n == GZPMAG)
{
if (fread((char *)h, 1, GZPHDR, G.in) != GZPHDR)
if (fread((char *)h, 1, GZPHDR, (*(Uz_Globs *)pG).in) != GZPHDR)
err(3, "invalid gzip file");
if ((method = h[GZPHOW]) != DEFLATED && method != ENHDEFLATED)
err(3, "gzip file not deflated");
if (h[GZPFLG] & GZPMUL)
err(3, "cannot handle multi-part gzip files");
if (h[GZPFLG] & GZPISX)
{
n = getc(G.in); n |= getc(G.in) << 8;
while (n--) g = getc(G.in);
n = getc((*(Uz_Globs *)pG).in); n |= getc((*(Uz_Globs *)pG).in) << 8;
while (n--) g = getc((*(Uz_Globs *)pG).in);
}
if (h[GZPFLG] & GZPISF)
while ((g = getc(G.in)) != 0 && g != EOF) ;
while ((g = getc((*(Uz_Globs *)pG).in)) != 0 && g != EOF) ;
if (h[GZPFLG] & GZPISC)
while ((g = getc(G.in)) != 0 && g != EOF) ;
while ((g = getc((*(Uz_Globs *)pG).in)) != 0 && g != EOF) ;
g = 1;
encrypted = h[GZPFLG] & GZPISE;
}
@@ -396,10 +396,10 @@ int main(int argc, char **argv)
#endif /* ?CRYPT */

/* prepare output buffer and crc */
G.outptr = slide;
G.outcnt = 0L;
(*(Uz_Globs *)pG).outptr = slide;
(*(Uz_Globs *)pG).outcnt = 0L;
outsiz = 0L;
G.crc32val = CRCVAL_INITIAL;
(*(Uz_Globs *)pG).crc32val = CRCVAL_INITIAL;

/* decompress */
if (g || h[LOCHOW])
@@ -408,16 +408,16 @@ int main(int argc, char **argv)

#ifdef USE_ZLIB
/* need to allocate and prepare input buffer */
if ((G.inbuf = (uch *)malloc(INBUFSIZ)) == (uch *)NULL)
if (((*(Uz_Globs *)pG).inbuf = (uch *)malloc(INBUFSIZ)) == (uch *)NULL)
err(1, "out of memory");
#endif /* USE_ZLIB */
if ((r = UZinflate(__G__ (method == ENHDEFLATED))) != 0) {
if ((r = UZinflate(pG, (method == ENHDEFLATED))) != 0) {
if (r == 3)
err(1, "out of memory");
else
err(4, "invalid compressed data--format violated");
}
inflate_free(__G);
inflate_free(pG);
}
else
{ /* stored entry */
@@ -433,57 +433,57 @@ int main(int argc, char **argv)
err(4, "invalid compressed data--length mismatch");
}
while (n--) {
ush c = getc(G.in);
ush c = getc((*(Uz_Globs *)pG).in);
#if CRYPT
if (encrypted)
zdecode(c);
#endif
*G.outptr++ = (uch)c;
*(*(Uz_Globs *)pG).outptr++ = (uch)c;
#if (defined(USE_DEFLATE64) && defined(__16BIT__))
if (++G.outcnt == (WSIZE>>1)) /* do FlushOutput() */
if (++(*(Uz_Globs *)pG).outcnt == (WSIZE>>1)) /* do FlushOutput() */
#else
if (++G.outcnt == WSIZE) /* do FlushOutput() */
if (++(*(Uz_Globs *)pG).outcnt == WSIZE) /* do FlushOutput() */
#endif
{
G.crc32val = crc32(G.crc32val, slide, (extent)G.outcnt);
if (fwrite((char *)slide, 1,(extent)G.outcnt,out) != (extent)G.outcnt
(*(Uz_Globs *)pG).crc32val = crc32((*(Uz_Globs *)pG).crc32val, slide, (extent)(*(Uz_Globs *)pG).outcnt);
if (fwrite((char *)slide, 1,(extent)(*(Uz_Globs *)pG).outcnt,out) != (extent)(*(Uz_Globs *)pG).outcnt
&& !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += G.outcnt;
G.outptr = slide;
G.outcnt = 0L;
outsiz += (*(Uz_Globs *)pG).outcnt;
(*(Uz_Globs *)pG).outptr = slide;
(*(Uz_Globs *)pG).outcnt = 0L;
}
}
}
if (G.outcnt) /* flush one last time; no need to reset G.outptr/outcnt */
if ((*(Uz_Globs *)pG).outcnt) /* flush one last time; no need to reset (*(Uz_Globs *)pG).outptr/outcnt */
{
G.crc32val = crc32(G.crc32val, slide, (extent)G.outcnt);
if (fwrite((char *)slide, 1,(extent)G.outcnt,out) != (extent)G.outcnt
(*(Uz_Globs *)pG).crc32val = crc32((*(Uz_Globs *)pG).crc32val, slide, (extent)(*(Uz_Globs *)pG).outcnt);
if (fwrite((char *)slide, 1,(extent)(*(Uz_Globs *)pG).outcnt,out) != (extent)(*(Uz_Globs *)pG).outcnt
&& !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += G.outcnt;
outsiz += (*(Uz_Globs *)pG).outcnt;
}
fflush(out);

/* if extended header, get it */
if (g)
{
if (fread((char *)h + LOCCRC, 1, 8, G.in) != 8)
if (fread((char *)h + LOCCRC, 1, 8, (*(Uz_Globs *)pG).in) != 8)
err(3, "gzip file ended prematurely");
}
else
if ((h[LOCFLG] & EXTFLG) &&
fread((char *)h + LOCCRC - 4, 1, EXTHDR, G.in) != EXTHDR)
fread((char *)h + LOCCRC - 4, 1, EXTHDR, (*(Uz_Globs *)pG).in) != EXTHDR)
err(3, "zipfile ended prematurely");

/* validate decompression */
if (LG(h + LOCCRC) != G.crc32val)
if (LG(h + LOCCRC) != (*(Uz_Globs *)pG).crc32val)
err(4, "invalid compressed data--crc error");
if (LG((g ? (h + LOCSIZ) : (h + LOCLEN))) != outsiz)
err(4, "invalid compressed data--length error");

/* check if there are more entries */
if (!g && fread((char *)h, 1, 4, G.in) == 4 && LG(h) == LOCSIG)
if (!g && fread((char *)h, 1, 4, (*(Uz_Globs *)pG).in) == 4 && LG(h) == LOCSIG)
Info(slide, 1, ((char *)slide,
"funzip warning: zipfile has more than one entry--rest ignored\n"));

@@ -60,21 +60,21 @@ int main(argc, argv)
printf(out_format, "h_v_t", (ulg)&t->v.t - (ulg)t);
printf(out_format, "SIZEOF_huft", (ulg)sizeof(struct huft));

printf(out_format, "bb", (ulg)&G.bb - (ulg)&G);
printf(out_format, "bk", (ulg)&G.bk - (ulg)&G);
printf(out_format, "wp", (ulg)&G.wp - (ulg)&G);
printf(out_format, "bb", (ulg)&(*(Uz_Globs *)pG).bb - (ulg)&(*(Uz_Globs *)pG));
printf(out_format, "bk", (ulg)&(*(Uz_Globs *)pG).bk - (ulg)&(*(Uz_Globs *)pG));
printf(out_format, "wp", (ulg)&(*(Uz_Globs *)pG).wp - (ulg)&(*(Uz_Globs *)pG));
#ifdef FUNZIP
printf(out_format, "in", (ulg)&G.in - (ulg)&G);
printf(out_format, "in", (ulg)&(*(Uz_Globs *)pG).in - (ulg)&(*(Uz_Globs *)pG));
#else
printf(out_format, "incnt", (ulg)&G.incnt - (ulg)&G);
printf(out_format, "inptr", (ulg)&G.inptr - (ulg)&G);
printf(out_format, "csize", (ulg)&G.csize - (ulg)&G);
printf(out_format, "mem_mode", (ulg)&G.mem_mode - (ulg)&G);
printf(out_format, "incnt", (ulg)&(*(Uz_Globs *)pG).incnt - (ulg)&(*(Uz_Globs *)pG));
printf(out_format, "inptr", (ulg)&(*(Uz_Globs *)pG).inptr - (ulg)&(*(Uz_Globs *)pG));
printf(out_format, "csize", (ulg)&(*(Uz_Globs *)pG).csize - (ulg)&(*(Uz_Globs *)pG));
printf(out_format, "mem_mode", (ulg)&(*(Uz_Globs *)pG).mem_mode - (ulg)&(*(Uz_Globs *)pG));
#endif
printf(out_format, "redirslide", (ulg)&redirSlide - (ulg)&G);
printf(out_format, "redirslide", (ulg)&redirSlide - (ulg)&(*(Uz_Globs *)pG));
printf(out_format, "SIZEOF_slide", (ulg)sizeof(redirSlide));
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
printf(out_format, "_wsize", (ulg)&G._wsize - (ulg)&G);
printf(out_format, "_wsize", (ulg)&(*(Uz_Globs *)pG)._wsize - (ulg)&(*(Uz_Globs *)pG));
#endif /* DLL && !NO_SLIDE_REDIR */
printf(out_format, "CRYPT", (ulg)CRYPT);
#ifdef FUNZIP
@@ -39,7 +39,7 @@ const char *fnames[2] = {"*", NULL}; /* default filenames vector */


#ifndef REENTRANT
Uz_Globs G;
Uz_Globs (*(Uz_Globs *)pG);
#else /* REENTRANT */

# ifndef USETHREADID
@@ -66,12 +66,12 @@ const char *fnames[2] = {"*", NULL}; /* default filenames vector */
"error: global pointer in table does not match pointer passed as\
parameter\n";

static void registerGlobalPointer OF((__GPRO));
static void registerGlobalPointer OF((Uz_Globs *pG));



static void registerGlobalPointer(__G)
__GDEF
static void registerGlobalPointer(pG)
Uz_Globs *pG;
{
int scan=0;
ulg tid = GetThreadId();
@@ -93,8 +93,8 @@ static void registerGlobalPointer(__G)



void deregisterGlobalPointer(__G)
__GDEF
void deregisterGlobalPointer(pG)
Uz_Globs *pG;
{
int scan=0;
ulg tid = GetThreadId();
@@ -165,46 +165,46 @@ Uz_Globs *globalsCtor()
return (Uz_Globs *)NULL;
#endif /* REENTRANT */

/* for REENTRANT version, G is defined as (*pG) */
/* for REENTRANT version, (*(Uz_Globs *)pG) is defined as (*pG) */

memzero(&G, sizeof(Uz_Globs));
memzero(&(*(Uz_Globs *)pG), sizeof(Uz_Globs));

#ifndef FUNZIP

uO.lflag=(-1);
G.wildzipfn = "";
G.pfnames = (char **)fnames;
G.pxnames = (char **)&fnames[1];
G.pInfo = G.info;
G.sol = TRUE; /* at start of line */

G.message = UzpMessagePrnt;
G.input = UzpInput; /* not used by anyone at the moment... */
(*(Uz_Globs *)pG).wildzipfn = "";
(*(Uz_Globs *)pG).pfnames = (char **)fnames;
(*(Uz_Globs *)pG).pxnames = (char **)&fnames[1];
(*(Uz_Globs *)pG).pInfo = (*(Uz_Globs *)pG).info;
(*(Uz_Globs *)pG).sol = TRUE; /* at start of line */

(*(Uz_Globs *)pG).message = UzpMessagePrnt;
(*(Uz_Globs *)pG).input = UzpInput; /* not used by anyone at the moment... */
#if defined(WINDLL) || defined(MACOS)
G.mpause = NULL; /* has scrollbars: no need for pausing */
(*(Uz_Globs *)pG).mpause = NULL; /* has scrollbars: no need for pausing */
#else
G.mpause = UzpMorePause;
(*(Uz_Globs *)pG).mpause = UzpMorePause;
#endif
G.decr_passwd = UzpPassword;
(*(Uz_Globs *)pG).decr_passwd = UzpPassword;
#endif /* !FUNZIP */

#if (!defined(DOS_FLX_H68_NLM_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
G.echofd = -1;
(*(Uz_Globs *)pG).echofd = -1;
#endif /* !(MACOS || ATARI || VMS) */
#endif /* !(DOS_FLX_H68_NLM_OS2_W32 || AMIGA || RISCOS) */

#ifdef SYSTEM_SPECIFIC_CTOR
SYSTEM_SPECIFIC_CTOR(__G);
SYSTEM_SPECIFIC_CTOR(pG);
#endif

#ifdef REENTRANT
#ifdef USETHREADID
registerGlobalPointer(__G);
registerGlobalPointer(pG);
#else
GG = &G;
GG = &(*(Uz_Globs *)pG);
#endif /* ?USETHREADID */
#endif /* REENTRANT */

return &G;
return &(*(Uz_Globs *)pG);
}
@@ -38,7 +38,7 @@
USING VARIABLES FROM THE STRUCTURE
----------------------------------
All global variables must now be prefixed with `G.' which is either a
All global variables must now be prefixed with `(*(Uz_Globs *)pG).' which is either a
global struct (in which case it should be the only global variable) or
a macro for the value of a local pointer variable that is passed from
function to function. Yes, this is a pain. But it's the only way to
@@ -67,41 +67,41 @@
To support this new global struct, all functions must now conditionally
pass the globals pointer (pG) to each other. This is supported by 5 macros:
__GPRO, __GPRO__, __G, __G__ and __GDEF. A function that needs no other
Uz_Globs *pG, Uz_Globs *pG,, pG, pG, and Uz_Globs *pG;. A function that needs no other
parameters would look like this:
int extract_or_test_files(__G)
__GDEF
int extract_or_test_files(pG)
Uz_Globs *pG;
{
... stuff ...
}
A function with other parameters would look like:
int memextract(__G__ tgt, tgtsize, src, srcsize)
__GDEF
int memextract(pG, tgt, tgtsize, src, srcsize)
Uz_Globs *pG;
uch *tgt, *src;
ulg tgtsize, srcsize;
{
... stuff ...
}
In the Function Prototypes section of unzpriv.h, you should use __GPRO and
__GPRO__ instead:
In the Function Prototypes section of unzpriv.h, you should use Uz_Globs *pG and
Uz_Globs *pG, instead:
int uz_opts OF((__GPRO__ int *pargc, char ***pargv));
int process_zipfiles OF((__GPRO));
int uz_opts OF((Uz_Globs *pG, int *pargc, char ***pargv));
int process_zipfiles OF((Uz_Globs *pG));
Note that there is NO comma after __G__ or __GPRO__ and no semi-colon after
__GDEF. I wish there was another way but I don't think there is.
Note that there is NO comma after pG, or Uz_Globs *pG, and no semi-colon after
Uz_Globs *pG;. I wish there was another way but I don't think there is.
TESTING THE CODE
-----------------
Whether your platform requires reentrancy or not, you should always try
building with REENTRANT defined if any functions have been added. It is
pretty easy to forget a __G__ or a __GDEF and this mistake will only show
pretty easy to forget a pG, or a Uz_Globs *pG; and this mistake will only show
up if REENTRANT is defined. All platforms should run with REENTRANT
defined. Platforms that can't take advantage of it will just be paying
a performance penalty needlessly.
@@ -359,7 +359,7 @@ typedef struct Globals {
/***************************************************************************/


#define CRC_32_TAB G.crc_32_tab
#define CRC_32_TAB (*(Uz_Globs *)pG).crc_32_tab


Uz_Globs *globalsCtor ();
@@ -375,15 +375,9 @@ extern char end_central64_sig[4];
extern char end_centloc64_sig[4];
/* extern char extd_local_sig[4]; NOT USED YET */

# define G (*(Uz_Globs *)pG)
# define __G pG
# define __G__ pG,
# define __GPRO Uz_Globs *pG
# define __GPRO__ Uz_Globs *pG,
# define __GDEF Uz_Globs *pG;
# ifdef USETHREADID
extern int lastScan;
void deregisterGlobalPointer OF((__GPRO));
void deregisterGlobalPointer OF((Uz_Globs *pG));
Uz_Globs *getGlobalPointer OF((void));
# define GETGLOBALS() Uz_Globs *pG = getGlobalPointer()
# define DESTROYGLOBALS() do {free_G_buffers(pG); \
@@ -395,4 +389,4 @@ extern char end_centloc64_sig[4];
# endif /* ?USETHREADID */
# define CONSTRUCTGLOBALS() Uz_Globs *pG = globalsCtor()

#define uO G.UzO
#define uO (*(Uz_Globs *)pG).UzO
396 inflate.c

Large diffs are not rendered by default.

@@ -26,9 +26,9 @@
---- --------- -------------- ------------------------------------
c14 12 Mar 93 M. Adler made inflate.c standalone with the
introduction of inflate.h.
c14d 28 Aug 93 G. Roelofs replaced flush/FlushOutput with new version
c14e 29 Sep 93 G. Roelofs moved everything into unzip.h; added crypt.h
c14f 23 Nov 95 G. Roelofs added UNZIP_INTERNAL to accommodate newly
c14d 28 Aug 93 (*(Uz_Globs *)pG). Roelofs replaced flush/FlushOutput with new version
c14e 29 Sep 93 (*(Uz_Globs *)pG). Roelofs moved everything into unzip.h; added crypt.h
c14f 23 Nov 95 (*(Uz_Globs *)pG). Roelofs added UNZIP_INTERNAL to accommodate newly
split unzip.h
*/

216 list.c

Large diffs are not rendered by default.

728 process.c

Large diffs are not rendered by default.

30 ttyio.c
@@ -47,7 +47,7 @@
# endif
# define GLOBAL(g) g
#else
# define GLOBAL(g) G.g
# define GLOBAL(g) (*(Uz_Globs *)pG).g
#endif

#ifdef _POSIX_VERSION
@@ -191,8 +191,8 @@
/*
* Turn echo off for file descriptor f. Assumes that f is a tty device.
*/
void Echoff(__G__ f)
__GDEF
void Echoff(pG, f)
Uz_Globs *pG;
int f; /* file descriptor for which to turn echo off */
{
struct sgttyb sg; /* tty device structure */
@@ -206,8 +206,8 @@ void Echoff(__G__ f)
/*
* Turn echo back on for file descriptor echofd.
*/
void Echon(__G)
__GDEF
void Echon(pG)
Uz_Globs *pG;
{
struct sgttyb sg; /* tty device structure */

@@ -324,8 +324,8 @@ int screensize(tt_rows, tt_cols)
/*
* Get a character from the given file descriptor without echo or newline.
*/
int zgetch(__G__ f)
__GDEF
int zgetch(pG, f)
Uz_Globs *pG;
int f; /* file descriptor from which to read */
{
#if (defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS))
@@ -369,8 +369,8 @@ int zgetch(__G__ f)
#ifndef VMS /* VMS supplies its own variant of getch() */


int zgetch(__G__ f)
__GDEF
int zgetch(pG, f)
Uz_Globs *pG;
int f; /* file descriptor from which to read (must be open already) */
{
char c, c2;
@@ -435,8 +435,8 @@ int zgetch(__G__ f)
/* This is the getp() function for all systems (with TTY type user interface)
* that supply a working `non-echo' getch() function for "raw" console input.
*/
char *getp(__G__ m, p, n)
__GDEF
char *getp(pG, m, p, n)
Uz_Globs *pG;
const char *m; /* prompt for password */
char *p; /* return value: line input */
int n; /* bytes available in p[] */
@@ -487,8 +487,8 @@ char *getp(__G__ m, p, n)
# endif
#endif

char *getp(__G__ m, p, n)
__GDEF
char *getp(pG, m, p, n)
Uz_Globs *pG;
const char *m; /* prompt for password */
char *p; /* return value: line input */
int n; /* bytes available in p[] */
@@ -540,8 +540,8 @@ char *getp(__G__ m, p, n)

#if (defined(VMS) || defined(CMS_MVS))

char *getp(__G__ m, p, n)
__GDEF
char *getp(pG, m, p, n)
Uz_Globs *pG;
const char *m; /* prompt for password */
char *p; /* return value: line input */
int n; /* bytes available in p[] */
26 ttyio.h
@@ -21,18 +21,6 @@
* Non-echo keyboard/console input support is needed and enabled.
*/

#ifndef __G /* UnZip only, for now (DLL stuff) */
# define __G
# define __G__
# define __GDEF
# define __GPRO void
# define __GPRO__
#endif

#ifndef const /* UnZip only (until have configure script like Zip) */
# define const const
#endif

#if (defined(MSDOS) || defined(OS2) || defined(WIN32))
# ifndef DOS_OS2_W32
# define DOS_OS2_W32
@@ -191,10 +179,10 @@
* Echon() for suppressing and (re)enabling console input echo.
*/
#ifndef echoff
# define echoff(f) Echoff(__G__ f)
# define echon() Echon(__G)
void Echoff (__GPRO__ int f);
void Echon (__GPRO);
# define echoff(f) Echoff(pG, f)
# define echon() Echon(pG)
void Echoff (Uz_Globs *pG, int f);
void Echon (Uz_Globs *pG);
#endif

/* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
@@ -204,13 +192,13 @@
# endif
# ifndef FGETCH
/* default for all systems where no getch()-like function is available */
int zgetch (__GPRO__ int f);
# define FGETCH(f) zgetch(__G__ f)
int zgetch (Uz_Globs *pG, int f);
# define FGETCH(f) zgetch(pG, f)
# endif
#endif /* UNZIP && !FUNZIP */

#if (CRYPT && !defined(WINDLL))
char *getp (__GPRO__ const char *m, char *p, int n);
char *getp (Uz_Globs *pG, const char *m, char *p, int n);
#endif

#else /* !(CRYPT || (UNZIP && !FUNZIP)) */

Large diffs are not rendered by default.

@@ -72,7 +72,7 @@

#ifndef LZW_CLEAN

static void partial_clear (__GPRO__ int lastcodeused);
static void partial_clear (Uz_Globs *pG, int lastcodeused);

#ifdef DEBUG
# define OUTDBG(c) \
@@ -88,17 +88,17 @@ static void partial_clear (__GPRO__ int lastcodeused);
#define FREE_CODE HSIZE /* 0x2000 (code is unused or was cleared) */
#define HAS_CHILD (HSIZE << 1) /* 0x4000 (code has a child--do not clear) */

#define parent G.area.shrink.Parent
#define Value G.area.shrink.value /* "value" conflicts with Pyramid ioctl.h */
#define stack G.area.shrink.Stack
#define parent (*(Uz_Globs *)pG).area.shrink.Parent
#define Value (*(Uz_Globs *)pG).area.shrink.value /* "value" conflicts with Pyramid ioctl.h */
#define stack (*(Uz_Globs *)pG).area.shrink.Stack


/***********************/
/* Function unshrink() */
/***********************/

int unshrink(__G)
__GDEF
int unshrink(pG)
Uz_Globs *pG;
{
uch *stacktop = stack + (HSIZE - 1);
register uch *newstr;
@@ -112,9 +112,9 @@ int unshrink(__G)
* are redirected to a large memory buffer, realbuf will point to the
* new location while outbuf will remain pointing to the malloc'd
* memory buffer. */
uch *realbuf = G.outbuf;
uch *realbuf = (*(Uz_Globs *)pG).outbuf;
#else
# define realbuf G.outbuf
# define realbuf (*(Uz_Globs *)pG).outbuf
#endif


@@ -128,8 +128,8 @@ int unshrink(__G)
#ifndef SMALL_MEM
/* non-memory-limited machines: allocate second (large) buffer for
* textmode conversion in flush(), but only if needed */
if (G.pInfo->textmode && !G.outbuf2 &&
(G.outbuf2 = (uch *)malloc(TRANSBUFSIZ)) == (uch *)NULL)
if ((*(Uz_Globs *)pG).pInfo->textmode && !(*(Uz_Globs *)pG).outbuf2 &&
((*(Uz_Globs *)pG).outbuf2 = (uch *)malloc(TRANSBUFSIZ)) == (uch *)NULL)
return PK_MEM3;
#endif
#endif /* !VMS */
@@ -142,42 +142,42 @@ int unshrink(__G)
parent[code] = FREE_CODE;

#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) { /* use normal outbuf unless we're a DLL routine */
realbuf = G.redirect_buffer;
outbufsiz = (unsigned)G.redirect_size;
if ((*(Uz_Globs *)pG).redirect_slide) { /* use normal outbuf unless we're a DLL routine */
realbuf = (*(Uz_Globs *)pG).redirect_buffer;
outbufsiz = (unsigned)(*(Uz_Globs *)pG).redirect_size;
} else
#endif
#ifdef DLL
if (G.pInfo->textmode && !G.redirect_data)
if ((*(Uz_Globs *)pG).pInfo->textmode && !(*(Uz_Globs *)pG).redirect_data)
#else
if (G.pInfo->textmode)
if ((*(Uz_Globs *)pG).pInfo->textmode)
#endif
outbufsiz = RAWBUFSIZ;
else
outbufsiz = OUTBUFSIZ;
G.outptr = realbuf;
G.outcnt = 0L;
(*(Uz_Globs *)pG).outptr = realbuf;
(*(Uz_Globs *)pG).outcnt = 0L;

/*---------------------------------------------------------------------------
Get and output first code, then loop over remaining ones.
---------------------------------------------------------------------------*/

READBITS(codesize, oldcode)
if (G.zipeof)
if ((*(Uz_Globs *)pG).zipeof)
return PK_OK;

finalval = (uch)oldcode;
OUTDBG(finalval)
*G.outptr++ = finalval;
++G.outcnt;
*(*(Uz_Globs *)pG).outptr++ = finalval;
++(*(Uz_Globs *)pG).outcnt;

while (TRUE) {
READBITS(codesize, code)
if (G.zipeof)
if ((*(Uz_Globs *)pG).zipeof)
break;
if (code == BOGUSCODE) { /* possible to have consecutive escapes? */
READBITS(codesize, code)
if (G.zipeof)
if ((*(Uz_Globs *)pG).zipeof)
break;
if (code == 1) {
++codesize;
@@ -186,7 +186,7 @@ int unshrink(__G)
} else if (code == 2) {
Trace((stderr, " (partial clear code)\n"));
/* clear leafs (nodes with no children) */
partial_clear(__G__ lastfreecode);
partial_clear(pG, lastfreecode);
Trace((stderr, " (done with partial clear)\n"));
lastfreecode = BOGUSCODE; /* reset start of free-node search */
}
@@ -242,17 +242,17 @@ int unshrink(__G)
register uch *p;

for (p = newstr; p < newstr+len; ++p) {
*G.outptr++ = *p;
*(*(Uz_Globs *)pG).outptr++ = *p;
OUTDBG(*p)
if (++G.outcnt == outbufsiz) {
Trace((stderr, "doing flush(), outcnt = %lu\n", G.outcnt));
if ((error = flush(__G__ realbuf, G.outcnt, TRUE)) != 0) {
if (++(*(Uz_Globs *)pG).outcnt == outbufsiz) {
Trace((stderr, "doing flush(), outcnt = %lu\n", (*(Uz_Globs *)pG).outcnt));
if ((error = flush(pG, realbuf, (*(Uz_Globs *)pG).outcnt, TRUE)) != 0) {
Trace((stderr, "unshrink: flush() error (%d)\n",
error));
return error;
}
G.outptr = realbuf;
G.outcnt = 0L;
(*(Uz_Globs *)pG).outptr = realbuf;
(*(Uz_Globs *)pG).outcnt = 0L;
Trace((stderr, "done with flush()\n"));
}
}
@@ -283,9 +283,9 @@ int unshrink(__G)
Flush any remaining data and return to sender...
---------------------------------------------------------------------------*/

if (G.outcnt > 0L) {
Trace((stderr, "doing final flush(), outcnt = %lu\n", G.outcnt));
if ((error = flush(__G__ realbuf, G.outcnt, TRUE)) != 0) {
if ((*(Uz_Globs *)pG).outcnt > 0L) {
Trace((stderr, "doing final flush(), outcnt = %lu\n", (*(Uz_Globs *)pG).outcnt));
if ((error = flush(pG, realbuf, (*(Uz_Globs *)pG).outcnt, TRUE)) != 0) {
Trace((stderr, "unshrink: flush() error (%d)\n", error));
return error;
}
@@ -304,8 +304,8 @@ int unshrink(__G)
/* Function partial_clear() */ /* no longer recursive... */
/****************************/

static void partial_clear(__G__ lastcodeused)
__GDEF
static void partial_clear(pG, lastcodeused)
Uz_Globs *pG;
int lastcodeused;
{
register shrint code;
188 unzip.c

Large diffs are not rendered by default.

158 unzpriv.h

Large diffs are not rendered by default.

Large diffs are not rendered by default.

376 zipinfo.c

Large diffs are not rendered by default.