Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

infutil.h

00001 /* infutil.h -- types and macros common to blocks and codes
00002  * Copyright (C) 1995-1998 Mark Adler
00003  * For conditions of distribution and use, see copyright notice in zlib.h 
00004  */
00005 
00006 /* WARNING: this file should *not* be used by applications. It is
00007    part of the implementation of the compression library and is
00008    subject to change. Applications should only use zlib.h.
00009  */
00010 
00011 #ifndef _INFUTIL_H
00012 #define _INFUTIL_H
00013 
00014 typedef enum {
00015       TYPE,     /* get type bits (3, including end bit) */
00016       LENS,     /* get lengths for stored */
00017       STORED,   /* processing stored block */
00018       TABLE,    /* get table lengths */
00019       BTREE,    /* get bit lengths tree for a dynamic block */
00020       DTREE,    /* get length, distance trees for a dynamic block */
00021       CODES,    /* processing fixed or dynamic block */
00022       DRY,      /* output remaining window bytes */
00023       DONE,     /* finished last block, done */
00024       BAD}      /* got a data error--stuck here */
00025 inflate_block_mode;
00026 
00027 /* inflate blocks semi-private state */
00028 struct inflate_blocks_state {
00029 
00030   /* mode */
00031   inflate_block_mode  mode;     /* current inflate_block mode */
00032 
00033   /* mode dependent information */
00034   union {
00035     uInt left;          /* if STORED, bytes left to copy */
00036     struct {
00037       uInt table;               /* table lengths (14 bits) */
00038       uInt index;               /* index into blens (or border) */
00039       uIntf *blens;             /* bit lengths of codes */
00040       uInt bb;                  /* bit length tree depth */
00041       inflate_huft *tb;         /* bit length decoding tree */
00042     } trees;            /* if DTREE, decoding info for trees */
00043     struct {
00044       inflate_codes_statef 
00045          *codes;
00046     } decode;           /* if CODES, current state */
00047   } sub;                /* submode */
00048   uInt last;            /* true if this block is the last block */
00049 
00050   /* mode independent information */
00051   uInt bitk;            /* bits in bit buffer */
00052   uLong bitb;           /* bit buffer */
00053   inflate_huft *hufts;  /* single malloc for tree space */
00054   Bytef *window;        /* sliding window */
00055   Bytef *end;           /* one byte after sliding window */
00056   Bytef *read;          /* window read pointer */
00057   Bytef *write;         /* window write pointer */
00058   check_func checkfn;   /* check function */
00059   uLong check;          /* check on output */
00060 
00061 };
00062 
00063 
00064 /* defines for inflate input/output */
00065 /*   update pointers and return */
00066 #define UPDBITS {s->bitb=b;s->bitk=k;}
00067 #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
00068 #define UPDOUT {s->write=q;}
00069 #define UPDATE {UPDBITS UPDIN UPDOUT}
00070 #define LEAVE {UPDATE return inflate_flush(s,z,r);}
00071 /*   get bytes and bits */
00072 #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
00073 #define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
00074 #define NEXTBYTE (n--,*p++)
00075 #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
00076 #define DUMPBITS(j) {b>>=(j);k-=(j);}
00077 /*   output bytes */
00078 #define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
00079 #define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
00080 #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
00081 #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
00082 #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
00083 #define OUTBYTE(a) {*q++=(Byte)(a);m--;}
00084 /*   load local pointers */
00085 #define LOAD {LOADIN LOADOUT}
00086 
00087 /* masks for lower bits (size given to avoid silly warnings with Visual C++) */
00088 extern uInt inflate_mask[17];
00089 
00090 /* copy as much as possible from the sliding window to the output area */
00091 extern int inflate_flush OF((
00092     inflate_blocks_statef *,
00093     z_streamp ,
00094     int));
00095 
00096 struct internal_state      {int dummy;}; /* for buggy compilers */
00097 
00098 #endif

Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by doxygen1.2.15