comparison zlib/infutil.h @ 10:1040ca591f2e

First entry of Paradise Server 2.9 patch 10 Beta
author darius
date Sat, 06 Dec 1997 04:37:18 +0000
parents
children
comparison
equal deleted inserted replaced
9:331055a97a9d 10:1040ca591f2e
1 /* infutil.h -- types and macros common to blocks and codes
2 * Copyright (C) 1995 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6 /* WARNING: this file should *not* be used by applications. It is
7 part of the implementation of the compression library and is
8 subject to change. Applications should only use zlib.h.
9 */
10
11 /* inflate blocks semi-private state */
12 struct inflate_blocks_state {
13
14 /* mode */
15 enum {
16 TYPE, /* get type bits (3, including end bit) */
17 LENS, /* get lengths for stored */
18 STORED, /* processing stored block */
19 TABLE, /* get table lengths */
20 BTREE, /* get bit lengths tree for a dynamic block */
21 DTREE, /* get length, distance trees for a dynamic block */
22 CODES, /* processing fixed or dynamic block */
23 DRY, /* output remaining window bytes */
24 DONE, /* finished last block, done */
25 BAD} /* got a data error--stuck here */
26 mode; /* current inflate_block mode */
27
28 /* mode dependent information */
29 union {
30 uInt left; /* if STORED, bytes left to copy */
31 struct {
32 uInt table; /* table lengths (14 bits) */
33 uInt index; /* index into blens (or border) */
34 uIntf *blens; /* bit lengths of codes */
35 uInt bb; /* bit length tree depth */
36 inflate_huft *tb; /* bit length decoding tree */
37 } trees; /* if DTREE, decoding info for trees */
38 struct {
39 inflate_huft *tl, *td; /* trees to free */
40 inflate_codes_statef
41 *codes;
42 } decode; /* if CODES, current state */
43 } sub; /* submode */
44 uInt last; /* true if this block is the last block */
45
46 /* mode independent information */
47 uInt bitk; /* bits in bit buffer */
48 uLong bitb; /* bit buffer */
49 Bytef *window; /* sliding window */
50 Bytef *end; /* one byte after sliding window */
51 Bytef *read; /* window read pointer */
52 Bytef *write; /* window write pointer */
53 check_func checkfn; /* check function */
54 uLong check; /* check on output */
55
56 };
57
58
59 /* defines for inflate input/output */
60 /* update pointers and return */
61 #define UPDBITS {s->bitb=b;s->bitk=k;}
62 #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
63 #define UPDOUT {s->write=q;}
64 #define UPDATE {UPDBITS UPDIN UPDOUT}
65 #define LEAVE {UPDATE return inflate_flush(s,z,r);}
66 /* get bytes and bits */
67 #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
68 #define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
69 #define NEXTBYTE (n--,*p++)
70 #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
71 #define DUMPBITS(j) {b>>=(j);k-=(j);}
72 /* output bytes */
73 #define WAVAIL (q<s->read?s->read-q-1:s->end-q)
74 #define LOADOUT {q=s->write;m=WAVAIL;}
75 #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=WAVAIL;}}
76 #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
77 #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
78 #define OUTBYTE(a) {*q++=(Byte)(a);m--;}
79 /* load local pointers */
80 #define LOAD {LOADIN LOADOUT}
81
82 /* masks for lower bits */
83 extern uInt inflate_mask[];
84
85 /* copy as much as possible from the sliding window to the output area */
86 extern int inflate_flush OF((
87 inflate_blocks_statef *,
88 z_stream *,
89 int));
90
91 struct internal_state {int dummy;}; /* for buggy compilers */