Artifact b09630e0fb2982da4dd8fc4027f6068aa42fe5a2
#ifndef AFX_LZHTOOL_H__31F8AA01_3F84_11D4_8D96_8AB5A6462337__INCLUDED_
#define AFX_LZHTOOL_H__31F8AA01_3F84_11D4_8D96_8AB5A6462337__INCLUDED_
// Lzh Archive Extraction ... ( XacRett #39 SubSet )
class CLzhTool
{
public:
//-- 外向きインターフェイス --------------
bool Extract( const char* aname, const char* dll, kiPath& dll_rel_path );
public:
//-- CRC 計算 ---------------------------
static bool crcinit;
static unsigned short crctable[256];
static void init_crc_table(){
if( !crcinit )
for( unsigned short i=0,j,r; i!=256; i++ )
{
r = i;
for( j=0; j!=8; j++ )
{
if( r&1 ) r = ((r>>1)^0xA001);
else r>>=1;
}
crctable[i] = r;
}}
CLzhTool() { init_crc_table(); }
private:
//-- 内部処理
int FindHeader( const char* fname, const BYTE* hdr, DWORD siz );
bool ReadHeader( unsigned char* buf );
WORD crc;
BYTE sum;
void UpdateCRC( BYTE *p,int n )
{while( n-- )crc = crctable[(crc^(*p++))&0xff] ^ (crc >> 8);}
void UpdateSum( BYTE *p,int n )
{while( n-- )sum+=*(p++);}
int fread_crc( BYTE* p,int n)
{n=fread(p,1,n,lzh);if(n==-1)n=0;
UpdateCRC(p,n);UpdateSum(p,n);return n;}
FILE *lzh,*out;
BYTE h_Level; // ヘッダレベル
char h_FileName[MAX_PATH*2]; // ファイル名(パス付き)
char h_Method[6]; // 圧縮法 "-lh5-" など。
DWORD h_CompSize; // 圧縮されたサイズ
DWORD h_OrigSize; // 元のサイズ
WORD h_Attrib; // 属性
DWORD h_Update; // 更新日時(h0,h1:ftime h2:time_t)
};
#endif