Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7537 → Rev 7538

/programs/fs/unz/unz.asm
43,15 → 43,23
include '../../proc32.inc'
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../dll.inc'
;include '../../debug.inc'
 
 
;include 'include/macros.inc'
;include 'include/proc32.inc'
;include 'include/box_lib.mac'
;include 'include/dll.inc'
include 'debug.inc'
 
version equ '0.65'
version_dword equ 0*10000h + 65
version equ '0.70'
version_dword equ 0*10000h + 70
 
WIN_W = 400
 
SIZE_COPY_BUF = 1024*1024*2
MM_MAX_BLOCKS equ 1024
 
 
virtual at 0
kfar_info_struc:
.lStructSize dd ?
82,15 → 90,19
 
 
 
;-- CODE -------------------------------------------------------------------
 
 
include 'parse.inc'
include 'fs.inc'
include 'file_tree.inc'
include 'memory_manager.inc'
include 'dialogs.inc'
 
;-- CODE -------------------------------------------------------------------
 
 
start:
;dnl
;dpsP params
;dnl
mcall 68, 11
mcall 40, 100111b + 0C0000000h
stdcall dll.Load, IMPORTS
98,8 → 110,6
jnz exit
mov [pathOut],0
 
;stdcall SayErr,strErrorExc
;mcall -1
;----------------------------
;1. find input file, clear
;2. find -o, copy data, clear
115,7 → 125,7
 
.arbeit:
;2.
call getParam2
call getParamOutPath
cmp eax, 2
je errorParsing
 
148,6 → 158,7
call startUnpack
mcall -1
@@:
 
stdcall [OpenDialog_Init],OpenDialog_data
 
;init edit fields --------------
171,7 → 182,10
mov dword[edtUnpPath.size], eax
mov dword[edtUnpPath.pos], eax
 
;--------
; call file_tree_Init
 
 
;main loop --------------------
wm_redraw:
call winRedraw
218,9 → 232,9
 
cmp ah, 2
jne @f
;mcall 51,1,startUnpack,stackUnpack
;mov [bWinChild],1
call startUnpack
mcall 51,1,startUnpack,stackUnpack
mov [bWinChild],1
;call startUnpack
jmp wm_redraw
@@:
 
233,7 → 247,7
jne still
stdcall [edit_box_mouse],edtPack
stdcall [edit_box_mouse],edtUnpPath
 
; stdcall file_tree_Mouse
jmp still
 
exit:
240,6 → 254,8
mcall -1
 
errorParsing:
dph edx
 
dps 'errorParsing'
mcall -1
 
259,7 → 275,7
stdcall [edit_box_draw],edtPack
stdcall [edit_box_draw],edtUnpPath
 
; plain window labels
 
cmp [redInput],0
jne @f
mov ecx,[sc.work_text]
272,8 → 288,6
mov ecx,[sc.work_text]
or ecx,90000000h
mcall 4, <15,37>, , strPath
; text on buttons
mov ecx,[sc.work_button_text]
or ecx,90000000h
if lang eq ru
284,6 → 298,8
mcall 4, <(WIN_W-47),12>, , strDots
mcall 4, <(WIN_W-47),37>, , strDots
 
; call file_tree_Draw
 
mcall 12, 2
ret
endp
388,30 → 404,16
jnz @f
cmp ebx,0 ;;/ ŠŽ‘’›‹œ!!!!
je .errNotFound ;;§­ ç¥­¨¥ ebx ¯®«ã祭® ®¯ëâ­ë¬ ¯ãâñ¬.
cmp ebx,400h ;;ª ª ®­® ¡ã¤¥â à ¡®â âì á ¤à㣨¬¨ ¢¥àá¨ï¬¨
je .errNotSupp ;;¡¨¡«¨®â¥ª¨ - ­¥ ïá­®!
cmp ebx,400h
je .errNotSupp
@@:
mov [hPlugin],eax
 
;get num of all files
; stdcall calcSizeArch,[hPlugin]
; push ebp
; stdcall [aReadFolder], [hPlugin]
; pop ebp
 
 
 
; push ebp
; stdcall [aOpen], [hPlugin], .str1, O_READ
; pop ebp
;
; push ebp
; stdcall [aSetpos],[hPlugin],0,POSEND
; pop ebp
; add [numbytes],eax
 
 
 
push ebp
stdcall [aSetFolder],[hPlugin], .strRoot,0
pop ebp
;unpack
; void __stdcall GetFiles(HANDLE hPlugin, int NumItems, void* items[], void* addfile, void* adddir);
push ebp
418,9 → 420,10
stdcall [aGetFiles], [hPlugin], -1, 0, myAddFile, myAddDir
pop ebp
 
;jmp @f
; .str1 db '/LICENSE.txt',0
;@@:
jmp @f
.str1 db '/LICENSE.txt',0
.strRoot db '.svn',0
@@:
 
;HANDLE __stdcall open(HANDLE hPlugin, const char* filename, int mode);
;Žâªàëâì ä ©« filename.  à ¬¥âà mode § à¥§¥à¢¨à®¢ ­ ¨ ¢ ⥪ã饩 ¢¥àᨨ kfar ¢á¥£¤  à ¢¥­ 1.
491,183 → 494,125
endp
 
 
allnumbytes dd 0
strBackFold db '../',0
 
proc calcSizeArch hPlugin:dword
locals
bdwk rb 560
num rd 1
endl
;int __stdcall ReadFolder(HANDLE hPlugin, unsigned dirinfo_start,
; unsigned dirinfo_size, void* dirdata);
int3
mov [num],0
; int3
.mainloop:
push ebp
lea eax,[bdwk]
stdcall [aReadFolder], [hPlugin],1,560,eax
stdcall [aReadFolder], [hPlugin],[num],1,eax
pop ebp
 
ret
endp
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
cmp eax,6
je .lastFile
;??????????????????????????????????????????????????????????????????????????????????????????????????
lea ebx,[bdwk+0x20] ;¯®ç¥¬ã «¨¡  ¯¨è¥â ¢ ᬥ饭¨¥ +0x20 - ­¥¨§¥áâ­®
test [ebx],dword 10h
jz @f
;bool __stdcall SetFolder(HANDLE hPlugin, const char* relative_path,
; const char* absolute_path);
 
;SayErr int num_strings, const char* strings[],
; int num_buttons, const char* buttons[]);
push ebp
lea eax,[ebx+40]
dps 'Folder: '
dpsP eax
dnl
stdcall [aSetFolder],[hPlugin], eax,0
 
proc SayErr num_strings:dword, strings:dword,num_buttons:dword, buttons:dword
pushad
cmp [num_strings],1
je @f
m2m [errmess0], strErrorExc
jmp .l1
pop ebp
stdcall calcSizeArch, [hPlugin]
inc [num]
jmp .mainloop
@@:
mov ebx,[strings]
m2m [errmess0], dword [ebx]
.l1:
 
m2m [fsRunNotifyOK.param],[errmess0]
mcall 70,fsRunNotifyOK
lea ebx,[bdwk+0x20]
lea eax,[ebx+40]
dps 'File: '
dpsP eax
dnl
mov eax,[ebx+32]
add [allnumbytes],eax
inc [num]
jmp .mainloop
 
popad
mov eax,1
.lastFile:
; lea ebx,[bdwk+0x20]
; test [ebx],dword 10h
; jz @f
;
; push ebp
; lea eax,[ebx+40]
; stdcall [aSetFolder],[hPlugin], eax,0
; pop ebp
; stdcall calcSizeArch, [hPlugin]
; @@:
 
 
push ebp
stdcall [aSetFolder],[hPlugin], strBackFold,0
pop ebp
ret
endp
 
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; "enter password" dialog for KFar
;password_dlg:
; dd 1 ; use standard dialog colors
; dd -1 ; center window by x
; dd -1 ; center window by y
;.width dd ? ; width (will be filled according to current console width)
; dd 2 ; height
; dd 4, 2 ; border size
; dd aEnterPasswordTitle ; title
; dd ? ; colors (will be set by KFar)
; dd 0 ; used internally by dialog manager, ignored
; dd 0, 0 ; reserved for DlgProc
; dd 2 ; 2 controls
;; the string "enter password"
; dd 1 ; type: static
; dd 1,0 ; upper-left position
;.width1 dd ?,0 ; bottom-right position
; dd aEnterPassword ; data
; dd 0 ; flags
;; editbox for password
; dd 3 ; type: edit
; dd 1,1 ; upper-left position
;.width2 dd ?,0 ; bottom-right position
; dd password_data ; data
; dd 2Ch ; flags
 
proc rec_calcSize hPlugin:dword
locals
bdwk rb 560
endl
;int __stdcall ReadFolder(HANDLE hPlugin, unsigned dirinfo_start,
; unsigned dirinfo_size, void* dirdata);
;bool __stdcall SetFolder(HANDLE hPlugin, const char* relative_path, const char* absolute_path);
push ebp
lea eax,[bdwk]
stdcall [aReadFolder], [hPlugin],1,560,eax
pop ebp
 
 
proc DialogBox dlgInfo:dword
pushad
mov ebx,[dlgInfo]
mov eax,[ebx+19*4]
mov [forpassword],eax
mov byte[eax], 0
mov [stateDlg], 0
mcall 51,1,threadDialogBox,stackDlg
 
;wait thread...
@@: cmp [stateDlg],0
jne @f
mcall 5,1
jmp @b
@@:
popad
cmp [stateDlg], 1
jne @f
xor eax, eax
ret
@@:
or eax, -1
ret
endp
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
 
proc threadDialogBox
hTrPlugin dd 0
 
mcall 40, 100111b+0C000000h
mov eax,[forpassword]
mov [edtPassword+4*9],eax
xor eax,eax
mov dword[edtPassword.size], eax
mov dword[edtPassword.pos], eax
;eax - file struct for sys70
 
.wm_redraw:
mcall 12, 1
mcall 48, 3, sc, sizeof.system_colors
mov edx, [sc.work]
or edx, 0x33000000
mcall 0, <200,320>, <200,140>, , , title
proc rdFoldforTree
locals
fi rd 0
endl
cmp [hTrPlugin],0
je .exit
push ebx edi esi
 
edit_boxes_set_sys_color edtPack,endEdits,sc
stdcall [edit_box_draw],edtPassword
mov [fi],eax
push ebp
stdcall [aSetFolder],[hTrPlugin], [eax+20],0
mov ebp,[esp]
;hPlug,startBlock,numBlocks,buffer
stdcall [aReadFolder], [hTrPlugin],dword[eax+4],\
dword[eax+12],dword[eax+16]
pop ebp
 
;cmp eax,6
;je .lastFile
 
mov ecx,[sc.work_text]
or ecx,90000000h
mcall 4, <56,12>, , strGetPass
;lea ebx,[bdwk+0x20] ;¯®ç¥¬ã «¨¡  ¯¨è¥â ¢ ᬥ饭¨¥ +0x20 - ­¥¨§¥áâ­®
 
mcall 8, <70,80>,<74,22>,2,[sc.work_button]
mov ecx,[sc.work_button_text]
or ecx,90000000h
mcall 4, <103,79>, , strOk
 
mcall 8, <165,80>,<74,22>,1,[sc.work_button]
mov ecx,[sc.work_button_text]
or ecx,90000000h
mcall 4, <182,79>, , strCancel
 
 
mcall 12, 2
 
.still:
mcall 10
cmp eax, 1
je .wm_redraw
cmp eax, 2
je .wm_key
cmp eax, 3
je .wm_button
cmp eax, 6
je .wm_mouse
 
jmp .still
 
.wm_key:
mcall 2
stdcall [edit_box_key],edtPassword
jmp .still
 
 
.wm_button:
mcall 17
 
cmp ah, 2 ;OK
jne @f
mov [stateDlg],1
jmp .exit
@@:
 
cmp ah, 1 ;Close window or Cancel
jne .still
mov [stateDlg],2
jmp .exit
 
.wm_mouse:
stdcall [edit_box_mouse],edtPassword
 
 
jmp .still
 
pop esi edi ebx
.exit:
mcall -1
ret
endp
 
 
;-- DATA -------------------------------------------------------------------
 
 
679,7 → 624,7
redInput db 0 ;1 - ¯®¤á¢¥â¨âì ªà á­ë¬ ­ ¤¯¨áì
 
if lang eq ru
title db 'uNZ v0.12 -  á¯ ª®¢é¨ª Zip ¨ 7z',0
title db 'uNZ v0.2 -  á¯ ª®¢é¨ª Zip ¨ 7z',0
strGo db ' á¯ ª®¢ âì',0
strInp db ' €à娢',0
strPath db 'ˆ§¢«¥çì ¢',0
693,7 → 638,7
strNotSupport db "'¥¯®¤¤¥à¦¨¢ ¥¬ë© ä®à¬ â  à娢 ' -E",0
strNotFound db "'” ©« ­¥ ­ ©¤¥­' -E",0
else if lang eq es
title db 'uNZ v0.12 - Desarchivador para Zip y 7z',0
title db 'uNZ v0.2 - Desarchivador para Zip y 7z',0
strGo db 'Desarchivar',0
strInp db 'Archivar',0
strPath db 'Extraer en',0
707,7 → 652,7
strNotSupport db "'El formato del archivo no es soportado' -E",0
strNotFound db "'Archivo no encontrado' -E",0
else
title db 'uNZ v0.12 - Unarchiver of Zip and 7z',0
title db 'uNZ v0.2 - Unarchiver of Zip and 7z',0
strGo db 'Unpack',0
strInp db 'Archive',0
strPath db 'Extract to',0
722,7 → 667,8
strNotFound db "'File not found' -E",0
end if
 
strNull db 0
 
 
strDots db '...',0
 
;--------
764,7 → 710,7
;--------
 
 
iFiles dd 0 ;ª®«¨ç¥á⢮ ¢ë£à㦠¥¬ëå ä ©«®¢
iFiles dd 0 ;ª®«¨ç¥á⢮ à á¯ ª®¢ë¢ ¥¬ëå ä ©«®¢
endPointer dd buffer
 
 
828,13 → 774,15
 
 
edtPack edit_box (WIN_W-100-60),100,10,0FFFFFFh,0xff,0x80ff,0h,0x90000000,\
255, fInp, mouse_dd,0,0,0
255, fInp, 0,0,0,0
edtUnpPath edit_box (WIN_W-100-60),100,35,0FFFFFFh,0xff,0x80ff,0h,0x90000000,\
255, pathOut, mouse_dd,0,0,0
255, pathOut, 0,0,0,0
edtPassword edit_box 200,56,70,0FFFFFFh,0xff,0x80ff,0h,0x90000000,255,\
password, mouse_dd,0,0,0
password, 0,0,0,0
endEdits:
 
 
 
;-------------------------------------------------------------------------------
OpenDialog_data:
.type dd 0 ;0-open, 1-save, 2-select folder
914,25 → 862,24
 
IncludeIGlobals
 
params1 db '-o "/hd0/1/unz/pig" -h "/hd0/1/unz/abc1"',0
;-- UDATA -----------------------------------------------------------------------------
init_end:
align 16
IncludeUGlobals
 
path rb 512
 
;params db 'unz -o "fil epar1" -f "arch1.txt" -f "ar ch2.txt" file1',0
;params db 'unz -o "fil epar1" -f arch1.txt -f "ar ch2.txt" file1',0
;params db '/hd0/1/unz/xboot-1-0-build-14-en-win.zip',0
;rb 4096
 
fInp rb 1024
pathOut rb 1024
pathOut rb 1024 ;¯ãâì, ªã¤  à á¯ ªã¥âáï ¢áñ
files rd 256
password rb 256
 
fZipInfo rb 40
 
mouse_dd rd 1
RBProcInfo rb 1024
temp_dir_pach rb 1024
ODAreaPath rb 1024
954,9 → 901,17
 
bdvkPack rb 560
 
 
 
;------------ memory_manager.inc
align 4
MM_NBlocks rd 1 ;ª®«¨ç¥á⢮ ¢ë¤¥«¥­­ëå ¡«®ª®¢ ¯ ¬ïâ¨
MM_BlocksInfo rd 2*MM_MAX_BLOCKS ;begin,size
 
 
;--------
 
buffer rb 4096 ;for string of file name or extract
buffer rb 4096 ;for string of file name for extract
params rb 4096
 
rb 1024