annotate lib/zlib/infutil.h @ 1904:1a1c4040bee4

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