big ass size savings in zlib mode :)
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1232 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1947c3354a
commit
a85e37e932
10 changed files with 118 additions and 199 deletions
|
@ -11,8 +11,6 @@
|
||||||
#include "infcodes.h"
|
#include "infcodes.h"
|
||||||
#include "infutil.h"
|
#include "infutil.h"
|
||||||
|
|
||||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
|
||||||
|
|
||||||
/* simplify the use of the inflate_huft type with some defines */
|
/* simplify the use of the inflate_huft type with some defines */
|
||||||
#define exop word.what.Exop
|
#define exop word.what.Exop
|
||||||
#define bits word.what.Bits
|
#define bits word.what.Bits
|
||||||
|
@ -21,33 +19,22 @@ local const char 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};
|
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||||
|
|
||||||
|
|
||||||
void inflate_blocks_reset(s, z, c)
|
void inflateReset(z_streamp z)
|
||||||
inflate_blocks_statef *s;
|
|
||||||
z_streamp z;
|
|
||||||
uLongf *c;
|
|
||||||
{
|
{
|
||||||
if (c) *c = s->check;
|
inflate_blocks_statef *s=&z->blocks;
|
||||||
if (s->mode == BTREE || s->mode == DTREE)
|
if (s->mode == BTREE || s->mode == DTREE)
|
||||||
ZFREE(z, s->sub.trees.blens);
|
ZFREE(z, s->sub.trees.blens);
|
||||||
if (s->mode == CODES)
|
if (s->mode == CODES)
|
||||||
inflate_codes_free(s->sub.decode.codes, z);
|
inflate_codes_free(s->sub.decode.codes, z);
|
||||||
s->mode = TYPE;
|
s->mode = TYPE;
|
||||||
s->bitk = 0;
|
s->bitk = s->bitb = 0;
|
||||||
s->bitb = 0;
|
|
||||||
s->read = s->write = s->window;
|
s->read = s->write = s->window;
|
||||||
Tracev((stderr, "inflate: blocks reset\n"));
|
Tracev((stderr, "inflate: blocks reset\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void inflate_blocks_init(z_streamp z,inflate_blocks_statef *s)
|
|
||||||
{
|
|
||||||
s->end = s->window + (1 << DEF_WBITS);
|
|
||||||
s->mode = TYPE;
|
|
||||||
inflate_blocks_reset(s, z, Z_NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int inflate(z_streamp z)
|
int inflate(z_streamp z)
|
||||||
{
|
{
|
||||||
inflate_blocks_statef *s=&z->state->blocks;
|
inflate_blocks_statef *s=&z->blocks;
|
||||||
|
|
||||||
// lousy two bytes saved by doing this
|
// lousy two bytes saved by doing this
|
||||||
struct
|
struct
|
||||||
|
@ -98,8 +85,8 @@ int r=Z_OK;
|
||||||
uInt bl, bd;
|
uInt bl, bd;
|
||||||
inflate_huft *tl, *td;
|
inflate_huft *tl, *td;
|
||||||
|
|
||||||
inflate_trees_fixed(&bl, &bd, &tl, &td, z);
|
inflate_trees_fixed(&bl, &bd, &tl, &td);
|
||||||
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
|
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td);
|
||||||
if (s->sub.decode.codes == Z_NULL)
|
if (s->sub.decode.codes == Z_NULL)
|
||||||
{
|
{
|
||||||
r = Z_MEM_ERROR;
|
r = Z_MEM_ERROR;
|
||||||
|
@ -187,7 +174,7 @@ int r=Z_OK;
|
||||||
s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
|
s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
|
||||||
s->sub.trees.bb = 7;
|
s->sub.trees.bb = 7;
|
||||||
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
|
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
|
||||||
&s->sub.trees.tb, s->hufts, z);
|
&s->sub.trees.tb, s->hufts);
|
||||||
if (t != Z_OK)
|
if (t != Z_OK)
|
||||||
{
|
{
|
||||||
ZFREE(z, s->sub.trees.blens);
|
ZFREE(z, s->sub.trees.blens);
|
||||||
|
@ -253,7 +240,7 @@ int r=Z_OK;
|
||||||
t = s->sub.trees.table;
|
t = s->sub.trees.table;
|
||||||
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
|
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
|
||||||
s->sub.trees.blens, &bl, &bd, &tl, &td,
|
s->sub.trees.blens, &bl, &bd, &tl, &td,
|
||||||
s->hufts, z);
|
s->hufts);
|
||||||
ZFREE(z, s->sub.trees.blens);
|
ZFREE(z, s->sub.trees.blens);
|
||||||
if (t != Z_OK)
|
if (t != Z_OK)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +250,7 @@ int r=Z_OK;
|
||||||
LEAVE
|
LEAVE
|
||||||
}
|
}
|
||||||
Tracev((stderr, "inflate: trees ok\n"));
|
Tracev((stderr, "inflate: trees ok\n"));
|
||||||
if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
|
if ((c = inflate_codes_new(bl, bd, tl, td)) == Z_NULL)
|
||||||
{
|
{
|
||||||
r = Z_MEM_ERROR;
|
r = Z_MEM_ERROR;
|
||||||
LEAVE
|
LEAVE
|
||||||
|
@ -273,8 +260,8 @@ int r=Z_OK;
|
||||||
s->mode = CODES;
|
s->mode = CODES;
|
||||||
case CODES:
|
case CODES:
|
||||||
UPDATE
|
UPDATE
|
||||||
if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
|
if ((r = inflate_codes(z, r)) != Z_STREAM_END)
|
||||||
return inflate_flush(s, z, r);
|
return inflate_flush(z, r);
|
||||||
r = Z_OK;
|
r = Z_OK;
|
||||||
inflate_codes_free(s->sub.decode.codes, z);
|
inflate_codes_free(s->sub.decode.codes, z);
|
||||||
LOAD
|
LOAD
|
||||||
|
@ -304,15 +291,4 @@ int r=Z_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*int inflate_blocks_free(s, z)
|
|
||||||
inflate_blocks_statef *s;
|
|
||||||
z_streamp z;
|
|
||||||
{
|
|
||||||
inflate_blocks_reset(s, z, Z_NULL);
|
|
||||||
ZFREE(z, s);
|
|
||||||
Tracev((stderr, "inflate: blocks freed\n"));
|
|
||||||
return Z_OK;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
|
@ -5,28 +5,3 @@
|
||||||
|
|
||||||
struct inflate_blocks_state;
|
struct inflate_blocks_state;
|
||||||
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
|
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
|
||||||
|
|
||||||
extern inflate_blocks_statef * inflate_blocks_new OF((
|
|
||||||
z_streamp z)); /* window size */
|
|
||||||
|
|
||||||
extern int inflate_blocks OF((
|
|
||||||
inflate_blocks_statef *,
|
|
||||||
z_streamp ,
|
|
||||||
int)); /* initial return code */
|
|
||||||
|
|
||||||
extern void inflate_blocks_reset OF((
|
|
||||||
inflate_blocks_statef *,
|
|
||||||
z_streamp ,
|
|
||||||
uLongf *)); /* check value on output */
|
|
||||||
|
|
||||||
extern int inflate_blocks_free OF((
|
|
||||||
inflate_blocks_statef *,
|
|
||||||
z_streamp));
|
|
||||||
|
|
||||||
extern void inflate_set_dictionary OF((
|
|
||||||
inflate_blocks_statef *s,
|
|
||||||
const Bytef *d, /* dictionary */
|
|
||||||
uInt n)); /* dictionary length */
|
|
||||||
|
|
||||||
extern int inflate_blocks_sync_point OF((
|
|
||||||
inflate_blocks_statef *s));
|
|
||||||
|
|
|
@ -57,16 +57,15 @@ struct inflate_codes_state {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
|
inflate_codes_statef *inflate_codes_new(bl, bd, tl, td)
|
||||||
uInt bl, bd;
|
uInt bl, bd;
|
||||||
inflate_huft *tl;
|
inflate_huft *tl;
|
||||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||||
z_streamp z;
|
|
||||||
{
|
{
|
||||||
inflate_codes_statef *c;
|
inflate_codes_statef *c;
|
||||||
|
|
||||||
if ((c = (inflate_codes_statef *)
|
if ((c = (inflate_codes_statef *)
|
||||||
ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
|
ZALLOC(0,1,sizeof(struct inflate_codes_state))) != Z_NULL)
|
||||||
{
|
{
|
||||||
c->mode = START;
|
c->mode = START;
|
||||||
c->lbits = (Byte)bl;
|
c->lbits = (Byte)bl;
|
||||||
|
@ -79,11 +78,11 @@ z_streamp z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int inflate_codes(s, z, r)
|
int inflate_codes(z, r)
|
||||||
inflate_blocks_statef *s;
|
|
||||||
z_streamp z;
|
z_streamp z;
|
||||||
int r;
|
int r;
|
||||||
{
|
{
|
||||||
|
inflate_blocks_statef *s=&z->blocks;
|
||||||
uInt j; /* temporary storage */
|
uInt j; /* temporary storage */
|
||||||
inflate_huft *t; /* temporary pointer */
|
inflate_huft *t; /* temporary pointer */
|
||||||
uInt e; /* extra bits or operation */
|
uInt e; /* extra bits or operation */
|
||||||
|
@ -236,11 +235,4 @@ int r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void inflate_codes_free(c, z)
|
|
||||||
inflate_codes_statef *c;
|
|
||||||
z_streamp z;
|
|
||||||
{
|
|
||||||
ZFREE(z, c);
|
|
||||||
Tracev((stderr, "inflate: codes free\n"));
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,15 +8,11 @@ typedef struct inflate_codes_state FAR inflate_codes_statef;
|
||||||
|
|
||||||
extern inflate_codes_statef *inflate_codes_new OF((
|
extern inflate_codes_statef *inflate_codes_new OF((
|
||||||
uInt, uInt,
|
uInt, uInt,
|
||||||
inflate_huft *, inflate_huft *,
|
inflate_huft *, inflate_huft *));
|
||||||
z_streamp ));
|
|
||||||
|
|
||||||
extern int inflate_codes OF((
|
extern int inflate_codes OF((
|
||||||
inflate_blocks_statef *,
|
|
||||||
z_streamp ,
|
z_streamp ,
|
||||||
int));
|
int));
|
||||||
|
|
||||||
extern void inflate_codes_free OF((
|
#define inflate_codes_free(z,c) ZFREE(z,c)
|
||||||
inflate_codes_statef *,
|
|
||||||
z_streamp ));
|
|
||||||
|
|
||||||
|
|
|
@ -15,28 +15,12 @@
|
||||||
#include "infcodes.h"
|
#include "infcodes.h"
|
||||||
#include "infutil.h"
|
#include "infutil.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ZEXPORT inflateReset(z_streamp z)
|
|
||||||
{
|
|
||||||
if (z == Z_NULL || z->state == Z_NULL)
|
|
||||||
return Z_STREAM_ERROR;
|
|
||||||
inflate_blocks_reset(&z->state->blocks, z, Z_NULL);
|
|
||||||
return Z_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct internal_state __mstate;
|
|
||||||
|
|
||||||
int ZEXPORT inflateInit(z_streamp z)
|
int ZEXPORT inflateInit(z_streamp z)
|
||||||
{
|
{
|
||||||
void inflate_blocks_init(z_streamp z,struct inflate_blocks_state *s);
|
z->blocks.end = z->blocks.window + (1 << DEF_WBITS);
|
||||||
|
z->blocks.mode = TYPE;
|
||||||
|
|
||||||
z->state=&__mstate;
|
inflateReset(z);
|
||||||
// if ((z->state =
|
|
||||||
// (struct internal_state FAR *) ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
|
|
||||||
//return Z_MEM_ERROR;
|
|
||||||
|
|
||||||
inflate_blocks_init(z,&z->state->blocks);
|
|
||||||
|
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,12 +222,11 @@ uInt *hn) /* working area: values in order of bit length */
|
||||||
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
|
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inflate_trees_bits(c, bb, tb, hp, z)
|
int inflate_trees_bits(c, bb, tb, hp)
|
||||||
uIntf *c; /* 19 code lengths */
|
uIntf *c; /* 19 code lengths */
|
||||||
uIntf *bb; /* bits tree desired/actual depth */
|
uIntf *bb; /* bits tree desired/actual depth */
|
||||||
inflate_huft * FAR *tb; /* bits tree result */
|
inflate_huft * FAR *tb; /* bits tree result */
|
||||||
inflate_huft *hp; /* space for trees */
|
inflate_huft *hp; /* space for trees */
|
||||||
z_streamp z; /* for messages */
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
uInt hn = 0; /* hufts used in space */
|
uInt hn = 0; /* hufts used in space */
|
||||||
|
@ -241,7 +240,7 @@ z_streamp z; /* for messages */
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z)
|
int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp)
|
||||||
uInt nl; /* number of literal/length codes */
|
uInt nl; /* number of literal/length codes */
|
||||||
uInt nd; /* number of distance codes */
|
uInt nd; /* number of distance codes */
|
||||||
uIntf *c; /* that many (total) code lengths */
|
uIntf *c; /* that many (total) code lengths */
|
||||||
|
@ -250,7 +249,6 @@ uIntf *bd; /* distance desired/actual bit depth */
|
||||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||||
inflate_huft * FAR *td; /* distance tree result */
|
inflate_huft * FAR *td; /* distance tree result */
|
||||||
inflate_huft *hp; /* space for trees */
|
inflate_huft *hp; /* space for trees */
|
||||||
z_streamp z; /* for messages */
|
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
uInt hn = 0; /* hufts used in space */
|
uInt hn = 0; /* hufts used in space */
|
||||||
|
@ -285,12 +283,11 @@ local inflate_huft *fixed_tl;
|
||||||
local inflate_huft *fixed_td;
|
local inflate_huft *fixed_td;
|
||||||
|
|
||||||
|
|
||||||
int inflate_trees_fixed(bl, bd, tl, td, z)
|
int inflate_trees_fixed(bl, bd, tl, td)
|
||||||
uIntf *bl; /* literal desired/actual bit depth */
|
uIntf *bl; /* literal desired/actual bit depth */
|
||||||
uIntf *bd; /* distance desired/actual bit depth */
|
uIntf *bd; /* distance desired/actual bit depth */
|
||||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||||
inflate_huft * FAR *td; /* distance tree result */
|
inflate_huft * FAR *td; /* distance tree result */
|
||||||
z_streamp z; /* for memory allocation */
|
|
||||||
{
|
{
|
||||||
/* build fixed tables if not already */
|
/* build fixed tables if not already */
|
||||||
if (!fixed_built)
|
if (!fixed_built)
|
||||||
|
|
|
@ -4,27 +4,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
typedef struct inflate_huft_s FAR inflate_huft;
|
|
||||||
|
|
||||||
struct inflate_huft_s {
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
Byte Exop; /* number of extra bits or operation */
|
|
||||||
Byte Bits; /* number of bits in this code or subcode */
|
|
||||||
} what;
|
|
||||||
} word;
|
|
||||||
unsigned short base; /* literal, length base, distance base,
|
|
||||||
or table offset */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MANY 1440
|
|
||||||
|
|
||||||
extern int inflate_trees_bits OF((
|
extern int inflate_trees_bits OF((
|
||||||
uIntf *,
|
uIntf *,
|
||||||
uIntf *,
|
uIntf *,
|
||||||
inflate_huft * FAR *,
|
inflate_huft * FAR *,
|
||||||
inflate_huft *,
|
inflate_huft *));
|
||||||
z_streamp));
|
|
||||||
|
|
||||||
extern int inflate_trees_dynamic OF((
|
extern int inflate_trees_dynamic OF((
|
||||||
uInt,
|
uInt,
|
||||||
|
@ -34,12 +18,10 @@ extern int inflate_trees_dynamic OF((
|
||||||
uIntf *,
|
uIntf *,
|
||||||
inflate_huft * FAR *,
|
inflate_huft * FAR *,
|
||||||
inflate_huft * FAR *,
|
inflate_huft * FAR *,
|
||||||
inflate_huft *,
|
inflate_huft *));
|
||||||
z_streamp));
|
|
||||||
|
|
||||||
extern int inflate_trees_fixed OF((
|
extern int inflate_trees_fixed OF((
|
||||||
uIntf *,
|
uIntf *,
|
||||||
uIntf *,
|
uIntf *,
|
||||||
inflate_huft * FAR *,
|
inflate_huft * FAR *,
|
||||||
inflate_huft * FAR *,
|
inflate_huft * FAR *));
|
||||||
z_streamp));
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "infcodes.h"
|
#include "infcodes.h"
|
||||||
#include "infutil.h"
|
#include "infutil.h"
|
||||||
|
|
||||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
struct inflate_codes_state;
|
||||||
|
|
||||||
/* And'ing with mask[n] masks the lower n bits */
|
/* And'ing with mask[n] masks the lower n bits */
|
||||||
unsigned short inflate_mask[17] = {
|
unsigned short inflate_mask[17] = {
|
||||||
|
@ -32,18 +32,19 @@ void NSISCALL genrtable()
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int __myleave(inflate_blocks_statef *s, z_streamp z, int r, int b, int k, Bytef *p, int n, Bytef *q)
|
int __myleave(z_streamp z, int r, int b, int k, Bytef *p, int n, Bytef *q)
|
||||||
{
|
{
|
||||||
|
inflate_blocks_statef *s = &z->blocks;
|
||||||
UPDATE
|
UPDATE
|
||||||
return inflate_flush(s,z,r);
|
return inflate_flush(z,r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy as much as possible from the sliding window to the output area */
|
/* copy as much as possible from the sliding window to the output area */
|
||||||
int inflate_flush(s, z, r)
|
int inflate_flush(z, r)
|
||||||
inflate_blocks_statef *s;
|
|
||||||
z_streamp z;
|
z_streamp z;
|
||||||
int r;
|
int r;
|
||||||
{
|
{
|
||||||
|
inflate_blocks_statef *s=&z->blocks;
|
||||||
uInt n;
|
uInt n;
|
||||||
Bytef *p;
|
Bytef *p;
|
||||||
Bytef *q;
|
Bytef *q;
|
||||||
|
|
|
@ -6,53 +6,6 @@
|
||||||
#ifndef _INFUTIL_H
|
#ifndef _INFUTIL_H
|
||||||
#define _INFUTIL_H
|
#define _INFUTIL_H
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
TYPE, /* get type bits (3, including end bit) */
|
|
||||||
LENS, /* get lengths for stored */
|
|
||||||
STORED, /* processing stored block */
|
|
||||||
TABLE, /* get table lengths */
|
|
||||||
BTREE, /* get bit lengths tree for a dynamic block */
|
|
||||||
DTREE, /* get length, distance trees for a dynamic block */
|
|
||||||
CODES, /* processing fixed or dynamic block */
|
|
||||||
DRY, /* output remaining window bytes */
|
|
||||||
DONE, /* finished last block, done */
|
|
||||||
BAD} /* got a data error--stuck here */
|
|
||||||
inflate_block_mode;
|
|
||||||
|
|
||||||
/* inflate blocks semi-private state */
|
|
||||||
struct inflate_blocks_state {
|
|
||||||
|
|
||||||
/* mode */
|
|
||||||
inflate_block_mode mode; /* current inflate_block mode */
|
|
||||||
|
|
||||||
/* mode dependent information */
|
|
||||||
union {
|
|
||||||
uInt left; /* if STORED, bytes left to copy */
|
|
||||||
struct {
|
|
||||||
uInt table; /* table lengths (14 bits) */
|
|
||||||
uInt index; /* index into blens (or border) */
|
|
||||||
uIntf *blens; /* bit lengths of codes */
|
|
||||||
uInt bb; /* bit length tree depth */
|
|
||||||
inflate_huft *tb; /* bit length decoding tree */
|
|
||||||
} trees; /* if DTREE, decoding info for trees */
|
|
||||||
struct {
|
|
||||||
inflate_codes_statef
|
|
||||||
*codes;
|
|
||||||
} decode; /* if CODES, current state */
|
|
||||||
} sub; /* submode */
|
|
||||||
uInt last; /* true if this block is the last block */
|
|
||||||
|
|
||||||
/* mode independent information */
|
|
||||||
uInt bitk; /* bits in bit buffer */
|
|
||||||
uLong bitb; /* bit buffer */
|
|
||||||
inflate_huft hufts[MANY]; /* single malloc for tree space */
|
|
||||||
Bytef window[1 << DEF_WBITS]; /* sliding window */
|
|
||||||
Bytef *end; /* one byte after sliding window */
|
|
||||||
Bytef *read; /* window read pointer */
|
|
||||||
Bytef *write; /* window write pointer */
|
|
||||||
uLong check; /* check on output */
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* defines for inflate input/output */
|
/* defines for inflate input/output */
|
||||||
|
@ -61,8 +14,8 @@ struct inflate_blocks_state {
|
||||||
#define UPDIN {z->avail_in=n;z->next_in=p;}
|
#define UPDIN {z->avail_in=n;z->next_in=p;}
|
||||||
#define UPDOUT {s->write=q;}
|
#define UPDOUT {s->write=q;}
|
||||||
#define UPDATE {UPDBITS UPDIN UPDOUT}
|
#define UPDATE {UPDBITS UPDIN UPDOUT}
|
||||||
#define LEAVE return __myleave(s,z,r,b,k,p,n,q);
|
#define LEAVE return __myleave(z,r,b,k,p,n,q);
|
||||||
extern int __myleave(inflate_blocks_statef *s, z_streamp z, int r, int b, int k, Bytef *p, int n, Bytef *q);
|
extern int __myleave(z_streamp z, int r, int b, int k, Bytef *p, int n, Bytef *q);
|
||||||
|
|
||||||
/* get bytes and bits */
|
/* get bytes and bits */
|
||||||
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
|
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
|
||||||
|
@ -77,7 +30,7 @@ extern int __myleave(inflate_blocks_statef *s, z_streamp z, int r, int b, int k,
|
||||||
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
|
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
|
||||||
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
|
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
|
||||||
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
|
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
|
||||||
#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
|
#define FLUSH {UPDOUT r=inflate_flush(z,r); LOADOUT}
|
||||||
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
|
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
|
||||||
#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
|
#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
|
||||||
/* load local pointers */
|
/* load local pointers */
|
||||||
|
@ -88,23 +41,7 @@ extern unsigned short inflate_mask[17];
|
||||||
|
|
||||||
/* copy as much as possible from the sliding window to the output area */
|
/* copy as much as possible from the sliding window to the output area */
|
||||||
extern int inflate_flush OF((
|
extern int inflate_flush OF((
|
||||||
inflate_blocks_statef *,
|
|
||||||
z_streamp ,
|
z_streamp ,
|
||||||
int));
|
int));
|
||||||
|
|
||||||
struct internal_state {
|
|
||||||
|
|
||||||
/* mode dependent information */
|
|
||||||
union {
|
|
||||||
uInt method; /* if FLAGS, method byte */
|
|
||||||
struct {
|
|
||||||
uLong was; /* computed check value */
|
|
||||||
uLong need; /* stream check value */
|
|
||||||
} check; /* if CHECK, check values to compare */
|
|
||||||
uInt marker; /* if BAD, inflateSync's marker bytes count */
|
|
||||||
} sub; /* submode */
|
|
||||||
|
|
||||||
struct inflate_blocks_state blocks; /* current inflate_blocks state */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,13 +43,87 @@
|
||||||
#define _ZLIB_H
|
#define _ZLIB_H
|
||||||
|
|
||||||
#include "zconf.h"
|
#include "zconf.h"
|
||||||
|
#include "zutil.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef EXEHEAD
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TYPE, /* get type bits (3, including end bit) */
|
||||||
|
LENS, /* get lengths for stored */
|
||||||
|
STORED, /* processing stored block */
|
||||||
|
TABLE, /* get table lengths */
|
||||||
|
BTREE, /* get bit lengths tree for a dynamic block */
|
||||||
|
DTREE, /* get length, distance trees for a dynamic block */
|
||||||
|
CODES, /* processing fixed or dynamic block */
|
||||||
|
DRY, /* output remaining window bytes */
|
||||||
|
DONE, /* finished last block, done */
|
||||||
|
BAD} /* got a data error--stuck here */
|
||||||
|
inflate_block_mode;
|
||||||
|
|
||||||
|
typedef struct inflate_huft_s FAR inflate_huft;
|
||||||
|
|
||||||
|
struct inflate_huft_s {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
Byte Exop; /* number of extra bits or operation */
|
||||||
|
Byte Bits; /* number of bits in this code or subcode */
|
||||||
|
} what;
|
||||||
|
} word;
|
||||||
|
unsigned short base; /* literal, length base, distance base,
|
||||||
|
or table offset */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MANY 1440
|
||||||
|
|
||||||
|
struct inflate_codes_state;
|
||||||
|
typedef struct inflate_codes_state inflate_codes_statef;
|
||||||
|
|
||||||
|
struct inflate_blocks_state {
|
||||||
|
|
||||||
|
/* mode */
|
||||||
|
inflate_block_mode mode; /* current inflate_block mode */
|
||||||
|
|
||||||
|
/* mode dependent information */
|
||||||
|
union {
|
||||||
|
uInt left; /* if STORED, bytes left to copy */
|
||||||
|
struct {
|
||||||
|
uInt table; /* table lengths (14 bits) */
|
||||||
|
uInt index; /* index into blens (or border) */
|
||||||
|
uIntf *blens; /* bit lengths of codes */
|
||||||
|
uInt bb; /* bit length tree depth */
|
||||||
|
inflate_huft *tb; /* bit length decoding tree */
|
||||||
|
} trees; /* if DTREE, decoding info for trees */
|
||||||
|
struct {
|
||||||
|
inflate_codes_statef
|
||||||
|
*codes;
|
||||||
|
} decode; /* if CODES, current state */
|
||||||
|
} sub; /* submode */
|
||||||
|
uInt last; /* true if this block is the last block */
|
||||||
|
|
||||||
|
/* mode independent information */
|
||||||
|
uInt bitk; /* bits in bit buffer */
|
||||||
|
uLong bitb; /* bit buffer */
|
||||||
|
inflate_huft hufts[MANY]; /* single malloc for tree space */
|
||||||
|
Bytef window[1 << MAX_WBITS]; /* sliding window */
|
||||||
|
Bytef *end; /* one byte after sliding window */
|
||||||
|
Bytef *read; /* window read pointer */
|
||||||
|
Bytef *write; /* window write pointer */
|
||||||
|
uLong check; /* check on output */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
struct internal_state;
|
struct internal_state;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct z_stream_s {
|
typedef struct z_stream_s {
|
||||||
Bytef *next_in; /* next input byte */
|
Bytef *next_in; /* next input byte */
|
||||||
|
@ -65,7 +139,12 @@ typedef struct z_stream_s {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// char *msg; /* last error message, NULL if no error */
|
// char *msg; /* last error message, NULL if no error */
|
||||||
struct internal_state FAR *state; /* not visible by applications */
|
//struct internal_state FAR *state; /* not visible by applications */
|
||||||
|
#ifdef EXEHEAD
|
||||||
|
struct inflate_blocks_state blocks; /* current inflate_blocks state */
|
||||||
|
#else
|
||||||
|
struct internal_state *state;
|
||||||
|
#endif
|
||||||
|
|
||||||
} z_stream;
|
} z_stream;
|
||||||
|
|
||||||
|
@ -130,8 +209,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||||
|
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
||||||
int ZEXPORT inflateReset(z_streamp z);
|
|
||||||
|
|
||||||
|
void ZEXPORT inflateReset OF((
|
||||||
|
z_streamp));
|
||||||
|
|
||||||
/* various hacks, don't look :) */
|
/* various hacks, don't look :) */
|
||||||
|
|
||||||
|
@ -146,8 +226,7 @@ ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
||||||
int windowBits, int memLevel,
|
int windowBits, int memLevel,
|
||||||
int strategy, const char *version,
|
int strategy, const char *version,
|
||||||
int stream_size));
|
int stream_size));
|
||||||
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
|
||||||
const char *version, int stream_size));
|
|
||||||
#define deflateInit(strm, level) \
|
#define deflateInit(strm, level) \
|
||||||
deflateInit_((strm), (level), "", sizeof(z_stream))
|
deflateInit_((strm), (level), "", sizeof(z_stream))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue