diff options
Diffstat (limited to '')
| -rw-r--r-- | infutil.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/infutil.h b/infutil.h new file mode 100644 index 0000000..af07372 --- /dev/null +++ b/infutil.h | |||
| @@ -0,0 +1,86 @@ | |||
| 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 | ERROR} /* 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 | uLong check; /* check on output */ | ||
| 51 | |||
| 52 | }; | ||
| 53 | |||
| 54 | /* defines for inflate input/output */ | ||
| 55 | /* update pointers and return */ | ||
| 56 | #define UPDBITS {s->bitb=b;s->bitk=k;} | ||
| 57 | #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} | ||
| 58 | #define UPDOUT {s->write=q;} | ||
| 59 | #define UPDATE {UPDBITS UPDIN UPDOUT} | ||
| 60 | #define LEAVE {UPDATE return inflate_flush(s,z,r);} | ||
| 61 | /* get bytes and bits */ | ||
| 62 | #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} | ||
| 63 | #define NEEDBYTE {if(n)r=Z_OK;else LEAVE} | ||
| 64 | #define NEXTBYTE (n--,*p++) | ||
| 65 | #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} | ||
| 66 | #define DUMPBITS(j) {b>>=(j);k-=(j);} | ||
| 67 | /* output bytes */ | ||
| 68 | #define WAVAIL (q<s->read?s->read-q-1:s->end-q) | ||
| 69 | #define LOADOUT {q=s->write;m=WAVAIL;} | ||
| 70 | #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=WAVAIL;}} | ||
| 71 | #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} | ||
| 72 | #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} | ||
| 73 | #define OUTBYTE(a) {*q++=(Byte)(a);m--;} | ||
| 74 | /* load local pointers */ | ||
| 75 | #define LOAD {LOADIN LOADOUT} | ||
| 76 | |||
| 77 | /* masks for lower bits */ | ||
| 78 | extern uInt inflate_mask[]; | ||
| 79 | |||
| 80 | /* copy as much as possible from the sliding window to the output area */ | ||
| 81 | extern int inflate_flush __P(( | ||
| 82 | struct inflate_blocks_state *, | ||
| 83 | z_stream *, | ||
| 84 | int)); | ||
| 85 | |||
| 86 | struct internal_state {int dummy;}; /* for buggy compilers */ | ||
