annotate lib/zlib/infutil.h @ 137:0afe11853c77

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