--- /dev/null
+/* infutil.h -- types and macros common to blocks and codes\r
+ * Copyright (C) 1995-2002 Mark Adler\r
+ * For conditions of distribution and use, see copyright notice in zlib.h \r
+ */\r
+\r
+/* WARNING: this file should *not* be used by applications. It is\r
+ part of the implementation of the compression library and is\r
+ subject to change. Applications should only use zlib.h.\r
+ */\r
+\r
+#ifndef _INFUTIL_H\r
+#define _INFUTIL_H\r
+\r
+typedef enum {\r
+ TYPE, /* get type bits (3, including end bit) */\r
+ LENS, /* get lengths for stored */\r
+ STORED, /* processing stored block */\r
+ TABLE, /* get table lengths */\r
+ BTREE, /* get bit lengths tree for a dynamic block */\r
+ DTREE, /* get length, distance trees for a dynamic block */\r
+ CODES, /* processing fixed or dynamic block */\r
+ DRY, /* output remaining window bytes */\r
+ DONE, /* finished last block, done */\r
+ BAD} /* got a data error--stuck here */\r
+inflate_block_mode;\r
+\r
+/* inflate blocks semi-private state */\r
+struct inflate_blocks_state {\r
+\r
+ /* mode */\r
+ inflate_block_mode mode; /* current inflate_block mode */\r
+\r
+ /* mode dependent information */\r
+ union {\r
+ uInt left; /* if STORED, bytes left to copy */\r
+ struct {\r
+ uInt table; /* table lengths (14 bits) */\r
+ uInt index; /* index into blens (or border) */\r
+ uIntf *blens; /* bit lengths of codes */\r
+ uInt bb; /* bit length tree depth */\r
+ inflate_huft *tb; /* bit length decoding tree */\r
+ } trees; /* if DTREE, decoding info for trees */\r
+ struct {\r
+ inflate_codes_statef \r
+ *codes;\r
+ } decode; /* if CODES, current state */\r
+ } sub; /* submode */\r
+ uInt last; /* true if this block is the last block */\r
+\r
+ /* mode independent information */\r
+ uInt bitk; /* bits in bit buffer */\r
+ uLong bitb; /* bit buffer */\r
+ inflate_huft *hufts; /* single malloc for tree space */\r
+ Bytef *window; /* sliding window */\r
+ Bytef *end; /* one byte after sliding window */\r
+ Bytef *read; /* window read pointer */\r
+ Bytef *write; /* window write pointer */\r
+ check_func checkfn; /* check function */\r
+ uLong check; /* check on output */\r
+\r
+};\r
+\r
+\r
+/* defines for inflate input/output */\r
+/* update pointers and return */\r
+#define UPDBITS {s->bitb=b;s->bitk=k;}\r
+#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}\r
+#define UPDOUT {s->write=q;}\r
+#define UPDATE {UPDBITS UPDIN UPDOUT}\r
+#define LEAVE {UPDATE return inflate_flush(s,z,r);}\r
+/* get bytes and bits */\r
+#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}\r
+#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}\r
+#define NEXTBYTE (n--,*p++)\r
+#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}\r
+#define DUMPBITS(j) {b>>=(j);k-=(j);}\r
+/* output bytes */\r
+#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)\r
+#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}\r
+#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}\r
+#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}\r
+#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}\r
+#define OUTBYTE(a) {*q++=(Byte)(a);m--;}\r
+/* load local pointers */\r
+#define LOAD {LOADIN LOADOUT}\r
+\r
+/* masks for lower bits (size given to avoid silly warnings with Visual C++) */\r
+extern uInt inflate_mask[17];\r
+\r
+/* copy as much as possible from the sliding window to the output area */\r
+extern int inflate_flush OF((\r
+ inflate_blocks_statef *,\r
+ z_streamp ,\r
+ int));\r
+\r
+struct internal_state {int dummy;}; /* for buggy compilers */\r
+\r
+#endif\r