00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef _INFUTIL_H
00012 #define _INFUTIL_H
00013 
00014 typedef enum {
00015       TYPE,     
00016       LENS,     
00017       STORED,   
00018       TABLE,    
00019       BTREE,    
00020       DTREE,    
00021       CODES,    
00022       DRY,      
00023       DONE,     
00024       BAD}      
00025 inflate_block_mode;
00026 
00027 
00028 struct inflate_blocks_state {
00029 
00030   
00031   inflate_block_mode  mode;     
00032 
00033   
00034   union {
00035     uInt left;          
00036     struct {
00037       uInt table;               
00038       uInt index;               
00039       uIntf *blens;             
00040       uInt bb;                  
00041       inflate_huft *tb;         
00042     } trees;            
00043     struct {
00044       inflate_codes_statef 
00045          *codes;
00046     } decode;           
00047   } sub;                
00048   uInt last;            
00049 
00050   
00051   uInt bitk;            
00052   uLong bitb;           
00053   inflate_huft *hufts;  
00054   Bytef *window;        
00055   Bytef *end;           
00056   Bytef *read;          
00057   Bytef *write;         
00058   check_func checkfn;   
00059   uLong check;          
00060 
00061 };
00062 
00063 
00064 
00065 
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 
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 
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 
00085 #define LOAD {LOADIN LOADOUT}
00086 
00087 
00088 extern uInt inflate_mask[17];
00089 
00090 
00091 extern int inflate_flush OF((
00092     inflate_blocks_statef *,
00093     z_streamp ,
00094     int));
00095 
00096 struct internal_state      {int dummy;}; 
00097 
00098 #endif