comparison src/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 uInt *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 inflate_codes_state
39 *codes; /* if CODES, current state */
40 } sub; /* submode */
41 uInt last; /* true if this block is the last block */
42
43 /* mode independent information */
44 uInt bitk; /* bits in bit buffer */
45 uLong bitb; /* bit buffer */
46 Byte *window; /* sliding window */
47 Byte *end; /* one byte after sliding window */
48 Byte *read; /* window read pointer */
49 Byte *write; /* window write pointer */
50 check_func checkfn; /* check function */
51 uLong check; /* check on output */
52
53 };
54
55 /* defines for inflate input/output */
56 /* update pointers and return */
57 #define UPDBITS {s->bitb=b;s->bitk=k;}
58 #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
59 #define UPDOUT {s->write=q;}
60 #define UPDATE {UPDBITS UPDIN UPDOUT}
61 #define LEAVE {UPDATE return inflate_flush(s,z,r);}
62 /* get bytes and bits */
63 #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
64 #define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
65 #define NEXTBYTE (n--,*p++)
66 #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
67 #define DUMPBITS(j) {b>>=(j);k-=(j);}
68 /* output bytes */
69 #define WAVAIL (q<s->read?s->read-q-1:s->end-q)
70 #define LOADOUT {q=s->write;m=WAVAIL;}
71 #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=WAVAIL;}}
72 #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
73 #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
74 #define OUTBYTE(a) {*q++=(Byte)(a);m--;}
75 /* load local pointers */
76 #define LOAD {LOADIN LOADOUT}
77
78 /* masks for lower bits */
79 extern uInt inflate_mask[];
80
81 /* copy as much as possible from the sliding window to the output area */
82 extern int inflate_flush __P((
83 struct inflate_blocks_state *,
84 z_stream *,
85 int));
86
87 struct internal_state {int dummy;}; /* for buggy compilers */