;---------- ---------- ---------- ---------- ---------- ; 作成者のURL ---> http://www.setsuki.com/ ;---------- ---------- ---------- ---------- ---------- ; ; -lh0- 無圧縮 ; -lh1- スライド辞書法( 4KB, 最大一致長 60B)+動的ハフマン法 ; -lh2- スライド辞書法( 8KB, 最大一致長256B)+動的ハフマン法 ; -lh3- スライド辞書法( 8KB, 最大一致長256B)+静的ハフマン法 ; -lh4- スライド辞書法( 4KB, 最大一致長256B)+静的ハフマン法 ; -lh5- スライド辞書法( 8KB, 最大一致長256B)+静的ハフマン法 ; -lh6- スライド辞書法(32KB, 最大一致長256B)+静的ハフマン法 ; -lh7- スライド辞書法(32KB, 最大一致長256B)+静的ハフマン法 ; ; -lz4- 無圧縮 ; -lz5- スライド辞書法( 4KB, 最大一致長 17B) ; -lzs- スライド辞書法( 2KB, 最大一致長 17B) ; ; ※スライド辞書法(LZ77法) ; ;---------- ---------- ---------- ---------- ---------- #ifdef __hsp30__ #ifndef __USER32__ #define global __USER32__ #uselib "USER32.DLL" #func global EnableWindow "EnableWindow" sptr,sptr #endif #endif ;---------- ---------- ---------- ---------- ---------- #module ;---------- ---------- ---------- ---------- ---------- #deffunc listview int v1, int v2, int v3 ;ExStyle 下位16ビットは標準のスタイル a = v3>>16 ;#define WS_CHILD 0x40000000 ;#define WS_VISIBLE 0x10000000 ;#define WS_CLIPCHILDREN 0x02000000 ;#define LVS_NOSORTHEADER 0x00008000 b = v3&$ffff | $52008000 winobj "SysListView32", "", $200, b, v1, v2 handle_of_list=objinfo(stat,2) ;#define LVM_FIRST 0x1000 ;#define LVM_SETEXTENDEDLISTVIEWSTYLE (LVM_FIRST + 54) if a : sendmsg handle_of_list, $1036, 0, a stt = handle_of_list return ;---------- ---------- ---------- ---------- ---------- #deffunc listaddcl int v1, str s2, int v3, int v4 ;文字列を取得 sdim str2, strlen(s2)+1 : str2=s2 ;横幅のサイズ prm3=v3 : if prm3=0 : prm3=100 ;#define LVM_INSERTCOLUMNA 4123 a = 15, v4, prm3, varptr(str2), 0, v1 sendmsg handle_of_list, 4123, a. 5, varptr(a) return ;---------- ---------- ---------- ---------- ---------- #deffunc listdel int v1 ;#define LVM_DELETEITEM 4104 ;#define LVM_DELETEALLITEMS 4105 ;v1=-1で全て消去 if v1=-1 { sendmsg handle_of_list, 4105, v1, 0 } else { sendmsg handle_of_list, 4104, v1, 0 } return ;---------- ---------- ---------- ---------- ---------- #deffunc listadd int v1, str s2, int v3, int v4, int v5 ;文字列を取得 sdim str2, strlen(s2)+1 : str2=s2 lvi=9,v1,v3,v5,0,varptr(str2) if v3 { ;#define LVM_SETITEMA 4102 m=4102 } else { ;サブアイテム追加じゃないとき lvi+=6 lvi.7=v4,v6 ;#define LVM_INSERTITEMA 4103 m=4103 } sendmsg handle_of_list, m, 0, varptr(lvi) return ;---------- ---------- ---------- ---------- ---------- #deffunc listget var v1, int v2, int v3, int v4, int v5 if v3>=5 { if v3=5 { ;mask, iItem, iSubItem, ?, ?, pszText, cchTextMax lvi=5 ,v2, v5, 0, 0, varptr(v1), v4, 0, 0 ;バッファのサイズを省略時 if v4=0 : lvi.6=64 ;#define LVM_GETITEMA 4101 ;#define LVM_SETITEMA 4102 m=4101 : if v4<0 : lvi=1 : m+ ;再設定 sendmsg handle_of_list, m, 0, varptr(lvi) stt=lvi.8 ;lParam } else { ;mask, iItem lvi=4, v2, 0, 0, 0, 0, 0, 0, 0 m=4101 : if v4 : lvi.8=v1 : m+ ;再設定 sendmsg handle_of_list, m, 0, varptr(lvi) v1=lvi.8 ;lParam stt=0 } } else { a=0,$100,$200,$400,$800 ;#define LVM_GETNEXTITEM 4108 sendmsg handle_of_list, 4108, v2, a.v3+v4 v1=stat stt=0 } return ;---------- ---------- ---------- ---------- ---------- #global #module ;---------- ---------- ---------- ---------- ---------- ; ファイルから num バイトを読み込み (モジュール) ;---------- ---------- ---------- ---------- ---------- #defcfunc fpeek str file, int i, int num ans=0 : bload file, ans, num, i return ans ;---------- ---------- ---------- ---------- ---------- ; デスクトップの場所を取得 ;---------- ---------- ---------- ---------- ---------- #deffunc get_desk var desk mref stt,64 os=getpath( sysinfo(0), 16) ans=instr(os, 0, "win") : if ans=-1 : stt=-1 : return ans=instr(os, 0, "95") if ans=-1 : ans=instr(os, 0, "98") if ans=-1 : ans=instr(os, 0, "9x") if ans=-1 { desk = "C:\\Documents and Settings\\"+ sysinfo(1) +"\\デスクトップ" } else { desk = "C:\\windows\\デスクトップ" } stt=0 return ;---------- ---------- ---------- ---------- ---------- #global ;---------- ---------- ---------- ---------- ---------- #define winx ginfo_winx #define winy ginfo_winy #define dispx ginfo_dispx #define dispy ginfo_dispy #define open_btn 1 //オブジェクトの使用可、不可 #define objgrays(%1) \ EnableWindow objinfo(3,2), %1 : \ EnableWindow objinfo(4,2), %1 //オブジェクトの文字列を取得 #define WM_GETTEXT $D ;---------- ---------- ---------- ---------- ---------- sdim off ,65535 ;圧縮ファイルのoffset sdim box ,65535 ;情報表示 sdim file,1024 ;ファイル名 sdim desk,1024 ;デスクトップ sdim get ,1024 ;一時的s get_desk desk ;デスクトップの場所を取得 ;---------- ---------- ---------- ---------- ---------- screen 0,500,400,0,(dispx-500)/2,(dispy-460)/2 objmode 1,1 : a=winx-64 pos 0, 0 : objsize a : input file pos a, 0 : objsize 64 : button "開く",*open pos 0, 28 : objsize a : listview a,90,13 : l_id=stat : listaddcl 0,"ファイル名",400 pos a, 64 : objsize 64 : button "表示",*view pos a, 90 : objsize 64 : button "解凍",*extract objmode 0,1 pos 0,124 : mesbox box,winx,winy-124,5 : m_id=stat ;---------- ---------- ---------- ---------- ---------- ;ファイルを開く/初期設定 ;---------- ---------- ---------- ---------- ---------- *open //中止のチェックと実行 sendmsg objinfo(open_btn,2),WM_GETTEXT,1024,varptr(get) if instr(get,0,"開く")<0 : goto *open_stop //オブジェクトの使用不可 objgrays 0 //ダイアログを開く dialog "",16 : if stat!1 : goto *open_end file=refstr : exist file //ファイルのチェック if strsize<0 : dialog "ファイルがありません。" : goto *open_end if strsize<1 : dialog "ファイルが空です。" : goto *open_end if getpath(file,18)!".lzh" { dialog "LZH圧縮のファイルではありません。" : goto *open_end } //ファイルを読み込み flen=strsize : objprm 0,file //ファイル名のみ取得 bg=getpath(file,24) : title bg+" ( "+flen+"byte ) 読み込み中" off="" : i=0,0 : listdel -1 //中止ボタンの設定 objprm open_btn,"中止" ;---------- ---------- ---------- ---------- ---------- ;ファイル名&オフセット取得 ;---------- ---------- ---------- ---------- ---------- *open_loop //オフサイズを保存 notesel off : noteadd ""+i //ファイルの一部読み込み sdim buf,256 : c=256 : if i+256>flen : c=flen-i bload file,buf,c,i //ヘッダのレベル level=peek(buf,20) //データサイズ size=lpeek(buf,7) //ヘッダサイズ if level<2 : hsize=peek(buf,0) : size+=hsize+2 if level=2 : hsize=24 : size+=wpeek(buf,0) if level=3 : hsize=28 : size+=wpeek(buf,24) //圧縮法の種類 method=strmid(buf,2,5) //ファイル名の取得 a=peek(buf,21) : dname="" if(level<2)&(a>0){ sdim fname,a+1 : fname=strmid(buf,22,a) } if level>0 { ii=i+hsize : if level<3 : c=2 : else : c=4 repeat 20 bload file,b,c,ii : if b=0 : break bload file,a,1,ii+c if a=1 { sdim fname,b-c //ファイル名 bload file,fname,b-c-1,ii+c+1 } if a=2 { sdim dname,b-c //ディレクトリ名 bload file,dname,b-c-1,ii+c+1 repeat b-c-1 if peek(dname,cnt)=0xFF : poke dname,cnt,'/' loop } ii+=b loop } //ファイル名を一覧に保存 listadd i.1,"("+method+") "+dname+fname, 0, i.1 //次のヘッダ開始位置を設定 i+=size : i.1++ wait 1 : if i+30)&(level<2){ get=getpath(fname,8) : a=strlen(get) if ( instr(fname,0,get) == 0 )&&( a == strlen(fname) ) { poke new,21,a : memcpy new,get,a,22,0 } } if level>0 { ii=hsize : if level<3 : c=2 : else : c=4 repeat 20 if c=2 : b=wpeek(new,ii) : else : b=lpeek(new,ii) if b<1 : break if peek(new,ii+c)=2 { size-=b memcpy new,new,size-ii,ii,ii+b } else { ii+=b } loop } //ファイル名の取得し、保存する bsave desk+"\\"+getpath(fname,1)+".lzh",new,size stop ;---------- ---------- ---------- ---------- ---------- ;ファイルの情報を取得 ;---------- ---------- ---------- ---------- ---------- *view_get //開始位置を取得 listget a,0,,2 : if a<0 : a=0 notesel off : noteget get,a : i=int(get) box="" : notesel box //ファイルの一部読み込み sdim buf,280 : c=280 : if i+280>flen : c=flen-i bload file,buf,c,i //ヘッダのレベル取得 level=peek(buf,20) : noteadd "<基本ヘッダ>" //基本ヘッダ情報(レベル0,1) ;------------------------------ if level<2 { head = peek(buf,0) : noteadd " 基本ヘッダのサイズ     "+head+" bytes" checksum= peek(buf,1) : noteadd " 基本ヘッダのチェックサム  "+checksum method =strmid(buf,2,5) : noteadd " 圧縮法の種類        "+method packed = lpeek(buf,7) : noteadd " 圧縮後のデータサイズ    "+packed+" bytes" original= lpeek(buf,11) : noteadd " 元のファイルサイズ     "+original+" bytes" time = wpeek(buf,15) : noteadd " ファイルの更新時刻     "+time+" (MS-DOS 形式)" date = wpeek(buf,17) : noteadd " ファイルの更新日付     "+date+" (MS-DOS 形式)" attrib = peek(buf,19) : noteadd " ファイル属性        "+attrib+" (MS-DOS 形式)" : noteadd " ヘッダのレベル       "+level len = peek(buf,21) : noteadd " ファイル名の長さ      "+len+" bytes" sdim fname,len+1 : if len>0 : fname=strmid(buf,22,len) : noteadd " ファイル名         "+fname filecrc = wpeek(buf,22+len) : noteadd " ファイルの圧縮前のCRC  "+filecrc ii=0 : i+=24+len //基本ヘッダ情報(レベル2,3) ;------------------------------ } else { head = wpeek(buf,0) : noteadd " 全ヘッダのサイズ      "+head+" bytes" method =strmid(buf,2,5) : noteadd " 圧縮法の種類        "+method packed = lpeek(buf,7) : noteadd " 圧縮後のデータサイズ    "+packed+" bytes" original= lpeek(buf,11) : noteadd " 元のファイルサイズ     "+original+" bytes" time = lpeek(buf,15) : noteadd " ファイルの更新時刻     "+time+" (UNIX 形式) attrib = peek(buf,19) : noteadd " ファイル属性        "+attrib+" (ダミー)" : noteadd " ヘッダのレベル       "+level filecrc = wpeek(buf,22) : noteadd " ファイルの圧縮前のCRC  "+filecrc ii=i+head : i+=23 } //基本ヘッダ情報(OS情報) ;------------------------------ if level>0 { a=fpeek(file,i,1) : i++ wpoke get,0,a : get+=" (不明)" if a='M' : get="M (MS-DOS)" if a='2' : get="2 (OS/2)" if a='9' : get="9 (OS9)" if a='K' : get="K (OS/68K)" if a='3' : get="3 (OS/386)" if a='H' : get="H (HUMAN)" if a='U' : get="U (UNIX)" if a='C' : get="C (CP/M)" if a='F' : get="F (FLEX)" if a='m' : get="m (Mac)" if a='R' : get="R (Runser)" if a='W' : get="W (WindowNT)" if a='w' : get="w (Windows95)" if a='T' : get="T (TownsOS)" if a='X' : get="X (XOSK)" if a==0 : get="0x00 (generic)" noteadd " 書庫を作成したOS識別子  "+get } if level=3 { bload file,head,4,i noteadd " 正しい全ヘッダのサイズ   "+head : i+=4 } //拡張ヘッダ情報 ;------------------------------ if level>0 { if level<3 : c=2 : else : c=4 repeat 20 bload file,exh_size,c,i bload file,exh_kind,1,i+c if exh_size<1 { noteadd "------------------------------" noteadd "<終端ヘッダ>" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" i+=c : break } if exh_kind=0x00 { bload file,exh_crc,2,i+c+1 noteadd "------------------------------" noteadd "<共通ヘッダ>" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " ヘッダのCRC       "+exh_crc if c+3" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " ファイル名         "+fname i+=exh_size : continue } if exh_kind=0x02 { sdim dname,exh_size-c : bload file,dname,exh_size-c-1,i+c+1 repeat exh_size-c-1 if peek(dname,cnt)=0xFF : poke dname,cnt,'\\' loop noteadd "------------------------------" noteadd "<ディレクトリヘッダ>" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " ディレクトリ名       "+dname i+=exh_size : continue } if exh_kind=0x3F { sdim comment,exh_size-c : bload file,comment,exh_size-c-1,i+c+1 noteadd "------------------------------" noteadd "<コメントヘッダ>" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " コメント          "+comment i+=exh_size : continue } if exh_kind=0x40 { noteadd "------------------------------" noteadd "" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " MS−DOSファイル属性  "+fpeek(file,i+c+1,2) i+=exh_size : continue } if exh_kind=0x50 { noteadd "------------------------------" noteadd "" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " 許可属性          "+fpeek(file,i+c+1,2) i+=exh_size : continue } if exh_kind=0x51 { noteadd "------------------------------" noteadd "" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " GID           "+fpeek(file,i+c+1,2) noteadd " UID           "+fpeek(file,i+c+3,2) i+=exh_size : continue } if exh_kind=0x52 { sdim gname,exh_size-c : bload file,gname,exh_size-c-1,i+c+1 noteadd "------------------------------" noteadd "" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " グループ名         "+gname i+=exh_size : continue } if exh_kind=0x53 { sdim uname,exh_size-c : bload file,uname,exh_size-c-1,i+c+1 noteadd "------------------------------" noteadd "" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " ユーザ名          "+uname i+=exh_size : continue } if exh_kind=0x54 { noteadd "------------------------------" noteadd "" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind noteadd " 最終更新日時        "+fpeek(file,i+c+1,2)+" (UNIX 形式)" i+=exh_size : continue } noteadd "------------------------------" noteadd "<不明な拡張ヘッダ>" noteadd " 拡張ヘッダのサイズ     "+exh_size+" bytes" noteadd " 拡張ヘッダの種類      "+exh_kind i+=exh_size loop } if(level=2) : i=ii return ;---------- ---------- ---------- ---------- ---------- ;無圧縮ファイルを展開する ;---------- ---------- ---------- ---------- ---------- *no_comp bload file,new,original,i //表示させる objprm m_id,new //デスクトップに保存 //bsave desk+"\\"+fname,new,original stop ;---------- ---------- ---------- ---------- ---------- ;-lh5-圧縮ファイルを展開する ;---------- ---------- ---------- ---------- ---------- *lh5_comp goto *no_extract stop ;---------- ---------- ---------- ---------- ---------- ;-lh1-圧縮ファイルを展開する ;---------- ---------- ---------- ---------- ---------- *lh1_comp goto *no_extract stop