#ifndef AFX_LZHDECODER2_H__31F8AA04_3F84_11D4_8D96_8AB5A6462337__INCLUDED_ #define AFX_LZHDECODER2_H__31F8AA04_3F84_11D4_8D96_8AB5A6462337__INCLUDED_ #define MAXMATCH 256 #define THRESHOLD 3 #define NT (16+3) #define TBIT 5 #define CBIT 9 #define NC (255+MAXMATCH+2-THRESHOLD) #define NPT 0x80 #define N_CHAR (256+60-THRESHOLD+1) #define TREESIZE_C (N_CHAR*2) #define TREESIZE_P (128*2) #define TREESIZE (TREESIZE_C+TREESIZE_P) #define ROOT_C 0 #define ROOT_P TREESIZE_C enum lzh_method{ LH0,LH4,LH5,LH6,LH7,UNKNOWN }; class CLzhDecoder2 { public: void Decode( lzh_method mhd,FILE* infile,DWORD insize, FILE* outfile,DWORD outsize ); private: void Unstore(); WORD Decode_C(lzh_method mhd) {switch( mhd ){ case LH4: case LH5: case LH6: case LH7:return decode_c_st1(); }return 0;}; WORD Decode_P(lzh_method mhd) {switch( mhd ){ case LH4: case LH5: case LH6: case LH7:return decode_p_st1(); }return 0;}; private: // 全般的に FILE *in,*out; DWORD cmpsize,orisize; DWORD loc; // lh4-lh7 void make_table(WORD nchar,BYTE* bitlen,WORD tablebits,WORD* table); void read_pt_len(short nn,short nbit,short i_special); void read_c_len(); WORD decode_c_st1(); WORD decode_p_st1(); WORD left[ 2*NC-1 ], right[ 2*NC-1 ]; BYTE c_len[NC], pt_len[NPT]; WORD c_table[4096],pt_table[256]; WORD blocksize; int pbit; int np; // bit単位のread&write void init_getbits(); void fillbuf(BYTE n); WORD getbits(BYTE n); WORD bitbuf;BYTE subbitbuf,bitcount; }; #endif