Subversion Repositories Kolibri OS

Rev

Rev 7159 | Rev 7162 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;unz - à á¯ ª®¢é¨ª, ¨á¯®«ì§ãî騩 archiver.obj. ®¤¤¥à¦¨¢ ¥â zip ¨ 7z.
  2.  
  3. ;unz [-o output path] [-f file for unpack] [-f ...] [-h] file.zip
  4. ;-h - hide GUI. If params is empty - do exit.
  5.  
  6. ;unz -o /hd0/1/arci -f text1.txt file.zip -unpack in folder only file text1.txt
  7. ;or
  8. ;unz -o "/hd0/1/arci" -f "text1.txt" text2.txt "file.zip" -unpack in folder only file text1.txt and text2.txt
  9.  
  10.  
  11. ;… …€‹ˆ‡Ž‚€Ž
  12. ;unz -n "namezone" "file.zip"  - open packed file, write list files of main folder in namezone
  13. ;namezone:
  14. ;dd 0 - ¥á«¨ ¨¬¥­­®¢ ­ ï §®­  § ­ïâ , â® 1
  15. ;dd cmd - 0 ­¥â ª®¬ ­¤ë
  16. ;         1 ¯®«ãç¨âì ᯨ᮪ ä ©«®¢
  17. ;         2 ¯®«ãç¨âì ä ©«
  18. ;         3 ãáâ ­®¢¨âì ⥪ã訩 ª â «®£ ¢  à娢¥
  19. ;         4 § ¢¥àè¨âì à ¡®âã
  20. ;data - ¤ ­­ë¥, § ¢¨á¨â ®â ª®¬¬ ­¤ë
  21. ; 1 ¯®«ãç¨âì ᯨ᮪ ä ©«®¢
  22. ; input
  23. ;   none
  24. ; output
  25. ;   dd numfiles - ª®«¨ç¥á⢮ ä ©«®¢ ¨ ¯ ¯®ª ¢ ⥪ã饬 ª â «®£¥
  26. ;   strz file1...fileN - ᯨ᮪ áâப, à §¤¥«ñ­­ëå 0
  27. ; 2 ¯®«ãç¨âì ä ©«
  28. ; input
  29. ;   dd num bytes
  30. ;   strz filename (file1.txt of /fold1/file1.txt)
  31. ; output
  32. ;   dd num bytes
  33. ;   data
  34.  
  35. use32
  36. org    0
  37. db     'MENUET01'
  38. dd     1, start, init_end, end_mem, stack_top, params,  0
  39.  
  40.  
  41. include 'lang.inc'
  42. include '../../macros.inc'
  43. include '../../proc32.inc'
  44. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  45. include '../../dll.inc'
  46. include 'debug.inc'
  47.  
  48. version equ '0.65'
  49. version_dword equ 0*10000h + 65
  50.  
  51. WIN_W = 400
  52.  
  53. SIZE_COPY_BUF = 1024*1024*2
  54.  
  55. virtual at 0
  56. kfar_info_struc:
  57. .lStructSize    dd      ?
  58. .kfar_ver       dd      ?
  59. .open           dd      ?
  60. .open2          dd      ?
  61. .read           dd      ?
  62. .write          dd      ?
  63. .seek           dd      ?
  64. .tell           dd      ?
  65. .flush          dd      ?
  66. .filesize       dd      ?
  67. .close          dd      ?
  68. .pgalloc        dd      ?
  69. .pgrealloc      dd      ?
  70. .pgfree         dd      ?
  71. .getfreemem     dd      ?
  72. .pgalloc2       dd      ?
  73. .pgrealloc2     dd      ?
  74. .pgfree2        dd      ?
  75. .menu           dd      ?
  76. .menu_centered_in dd    ?
  77. .DialogBox      dd      ?
  78. .SayErr         dd      ?
  79. .Message        dd      ?
  80. .cur_console_size dd    ?
  81. end virtual
  82.  
  83.  
  84.  
  85.  
  86.  
  87. include 'parse.inc'
  88. include 'fs.inc'
  89.  
  90. ;--  CODE  -------------------------------------------------------------------
  91.  
  92.  
  93. start:
  94.         mcall   68, 11
  95.         mcall   40, 100111b + 0C0000000h
  96.         stdcall dll.Load, IMPORTS
  97.         test    eax, eax
  98.         jnz     exit
  99.         mov     [pathOut],0
  100.  
  101. ;stdcall SayErr,strErrorExc
  102. ;mcall -1
  103. ;----------------------------
  104.         ;1. find input file, clear
  105.         ;2. find -o, copy data, clear
  106.         ;3. find -f, add pointer, copy data, clear
  107.         ;4. find -c, check variable, clear
  108. ;1.
  109.         call    getLastParam
  110.         test    eax, eax
  111.         je      wm_redraw
  112.         dec     eax
  113.         je      .arbeit
  114.         jmp     errorParsing
  115.  
  116. .arbeit:
  117. ;2.
  118.         call    getParam2
  119.         cmp     eax, 2
  120.         je      errorParsing
  121.  
  122. ;3.
  123.  
  124.    @@:
  125.         mov     eax, [iFiles]
  126.         shl     eax, 2
  127.         add     eax, files
  128.         m2m     dword[eax], dword[endPointer]
  129.         stdcall getParam, '-f'
  130.         cmp     eax, 2
  131.         je      errorParsing
  132.         inc     [iFiles]
  133.         cmp     eax, 1
  134.         je      @b
  135.  
  136. ;4.
  137.         mov     edi, params
  138.         mov     ax,'-h'
  139. @@:     cmp     word [edi], ax
  140.         je      .check
  141.         inc     edi
  142.         cmp     edi, params+1024
  143.         je      @f
  144.         cmp     byte[edi],0
  145.         je      @f
  146.         jmp     @b
  147. .check:
  148.         call    startUnpack
  149.         mcall   -1
  150. @@:
  151.         stdcall [OpenDialog_Init],OpenDialog_data
  152.  
  153. ;init edit fields  --------------
  154.         xor     al,al
  155.         mov     edi,fInp
  156.         mov     ecx,1024
  157.         repne   scasb
  158.         inc     ecx
  159.         mov     eax,1024
  160.         sub     eax,ecx
  161.         mov     dword[edtPack.size],eax
  162.         mov     dword[edtPack.pos],eax
  163.  
  164.         xor     al, al
  165.         mov     edi, pathOut
  166.         mov     ecx, 1024
  167.         repne   scasb
  168.         inc     ecx
  169.         mov     eax, 1024
  170.         sub     eax, ecx
  171.         mov     dword[edtUnpPath.size], eax
  172.         mov     dword[edtUnpPath.pos], eax
  173.  
  174.  
  175. ;main loop --------------------
  176. wm_redraw:
  177.         call winRedraw
  178.  
  179. still:
  180.         mcall   10
  181.         cmp     eax, 1
  182.         je      wm_redraw
  183.         cmp     eax, 2
  184.         je      wm_key
  185.         cmp     eax, 3
  186.         je      wm_button
  187.         cmp     eax, 6
  188.         je      wm_mouse
  189.  
  190.         jmp     still
  191.  
  192. wm_key:
  193.         mcall   2
  194.         cmp     [bWinChild],0
  195.         jne     still
  196.  
  197.         stdcall [edit_box_key],edtPack
  198.         stdcall [edit_box_key],edtUnpPath
  199.  
  200.         jmp     still
  201.  
  202.  
  203. wm_button:
  204.         mcall   17
  205.         cmp     [bWinChild],0
  206.         jne     still
  207.  
  208.         cmp     ah, 3
  209.         jne     @f
  210.         call selectInput
  211.         jmp     wm_redraw
  212.     @@:
  213.         cmp     ah, 4
  214.         jne     @f
  215.         call selectOutFold
  216.         jmp     wm_redraw
  217.     @@:
  218.  
  219.         cmp     ah, 2
  220.         jne     @f
  221.         ;mcall   51,1,startUnpack,stackUnpack
  222.         ;mov     [bWinChild],1
  223.         call   startUnpack
  224.         jmp     wm_redraw
  225.     @@:
  226.  
  227.         cmp     ah, 1
  228.         je      exit
  229.         jmp     still
  230.  
  231. wm_mouse:
  232.         cmp     [bWinChild],0
  233.         jne     still
  234.         stdcall [edit_box_mouse],edtPack
  235.         stdcall [edit_box_mouse],edtUnpPath
  236.  
  237.         jmp     still
  238.  
  239. exit:
  240.         mcall   -1
  241.  
  242. errorParsing:
  243.         dps 'errorParsing'
  244.         mcall   -1
  245.  
  246. ;--- functions ------------------------------------------------------------------
  247.  
  248. proc winRedraw
  249.         mcall 12, 1
  250.         mcall 48, 3, sc, sizeof.system_colors
  251.         mov   edx, [sc.work]
  252.         or        edx, 0x34000000
  253.         mcall 0, <200,WIN_W>, <200,130>, , , title
  254.         mcall 8, <100,100>,<65,25>,2,[sc.work_button]
  255.         mcall 8, <(WIN_W-52),33>,<10,20>,3,[sc.work_button]
  256.         mcall 8, <(WIN_W-52),33>,<35,20>,4,[sc.work_button]
  257.  
  258.         edit_boxes_set_sys_color edtPack,endEdits,sc
  259.         stdcall [edit_box_draw],edtPack
  260.         stdcall [edit_box_draw],edtUnpPath
  261.  
  262.         ; plain window labels
  263.         cmp     [redInput],0
  264.         jne     @f
  265.         mov     ecx,[sc.work_text]
  266.         or      ecx,90000000h
  267.         jmp     .l1
  268.       @@:
  269.         mov      ecx,90FF0000h
  270.      .l1:
  271.         mcall 4, <15,16>, , strInp
  272.         mov     ecx,[sc.work_text]
  273.         or      ecx,90000000h
  274.         mcall 4, <15,37>, , strPath
  275.        
  276.         ; text on buttons
  277.         mov     ecx,[sc.work_button_text]
  278.         or      ecx,90000000h
  279. if lang eq ru
  280.         mcall 4, <107,70>, , strGo
  281. else
  282.         mcall 4, <127,70>, , strGo
  283. end if
  284.         mcall 4, <(WIN_W-47),12>, , strDots
  285.         mcall 4, <(WIN_W-47),37>, , strDots    
  286.  
  287.         mcall 12, 2
  288.         ret
  289. endp
  290.  
  291. ;region
  292. selectInput:
  293.         mov     [OpenDialog_data.type],0
  294.         stdcall [OpenDialog_Start],OpenDialog_data
  295.         mov     edi,ODAreaPath
  296.         xor     al,al
  297.         or      ecx,-1
  298.         repne   scasb
  299.         sub     edi,ODAreaPath
  300.         dec     edi
  301.         mov     dword[edtPack+12*4],edi
  302.         mov     ecx,edi
  303.         inc     ecx
  304.         mov     edi,fInp
  305.         mov     esi,ODAreaPath
  306.         rep     movsb
  307.         mov     [redInput],0
  308.         ret
  309. ;endregion
  310.  
  311. ;region
  312. selectOutFold:
  313.         mov     [OpenDialog_data.type],2
  314.         stdcall [OpenDialog_Start],OpenDialog_data
  315.         mov     edi,ODAreaPath
  316.         xor     al,al
  317.         or      ecx,-1
  318.         repne   scasb
  319.         sub     edi,ODAreaPath
  320.         dec     edi
  321.         mov     dword[edtUnpPath+12*4],edi
  322.         mov     ecx,edi
  323.         inc     ecx
  324.         mov     edi,pathOut
  325.         mov     esi,ODAreaPath
  326.         rep     movsb
  327.         ret
  328. ;endregion
  329.  
  330.  
  331. ;-------------------------------------------------------------------------------
  332.  
  333. allfiles dd 0
  334. succfiles dd 0
  335. numbytes dd 0
  336.  
  337. proc startUnpack
  338. locals
  339.   paramUnp      rd 1
  340.   sizeUnpack    rd 1
  341.   hFile rd 1
  342.   hFileZip rd 1
  343.   hPlugin rd 1
  344.   pathFold rb 256
  345. endl
  346. ;if input not corrected
  347.         cmp     [fInp],byte 0
  348.         je      .errNullInp
  349.  
  350.     ;    mcall   68, 24, Exception, 0FFFFFFFFh ;??
  351. ;init plugin
  352.         push    ebp
  353.         stdcall [aPluginLoad],kfar_info
  354.         pop     ebp
  355.  
  356.  
  357. ;set current directory, create folder
  358.         cmp     [pathOut],0
  359.         jne     @f
  360.         lea     eax,[pathFold]
  361.         stdcall cpLastName, fInp, eax
  362.         lea     eax,[pathFold]
  363.         mov     [fsNewDir.path],eax
  364.         mcall   70, fsNewDir
  365.         mov     ecx, [fsNewDir.path]
  366.  
  367.         mcall   30,4,,1
  368.         jmp     .n
  369. @@:
  370.         mcall   30,4,pathOut,1
  371. .n:
  372.  
  373. ;open and read first 1KB
  374.         stdcall open, fInp, O_READ
  375.         mov     [hFileZip], eax
  376.         mcall   70,fsZip
  377.         test    eax,eax
  378.         jnz     .errNotFound
  379.         mcall   70,fsZipRead
  380.  
  381.  
  382. ;open pack
  383.         push    ebp
  384.         stdcall [aOpenFilePlugin],[hFileZip],bdvkPack,filedata_buffer,filedata_buffer_size ,0 ,0 , fInp
  385.         pop     ebp
  386.  
  387.         test    eax,eax
  388.         jnz     @f
  389.         cmp     ebx,0           ;;/ ŠŽ‘’›‹œ!!!!
  390.         je       .errNotFound   ;;§­ ç¥­¨¥ ebx ¯®«ã祭® ®¯ëâ­ë¬ ¯ãâñ¬.
  391.         cmp     ebx,400h        ;;ª ª ®­® ¡ã¤¥â à ¡®â âì á ¤à㣨¬¨ ¢¥àá¨ï¬¨
  392.         je       .errNotSupp    ;;¡¨¡«¨®â¥ª¨ - ­¥ ïá­®!
  393.       @@:
  394.         mov     [hPlugin],eax
  395.  
  396. ;get num of all files
  397. ;        stdcall calcSizeArch,[hPlugin]
  398. ;        push    ebp
  399. ;        stdcall [aReadFolder], [hPlugin]
  400. ;        pop     ebp
  401.  
  402.  
  403.  
  404. ;        push    ebp
  405. ;        stdcall [aOpen], [hPlugin], .str1, O_READ
  406. ;        pop     ebp
  407. ;
  408. ;        push    ebp
  409. ;        stdcall [aSetpos],[hPlugin],0,POSEND
  410. ;        pop     ebp
  411. ;        add     [numbytes],eax
  412.  
  413.  
  414.  
  415. ;unpack
  416. ;       void __stdcall GetFiles(HANDLE hPlugin, int NumItems, void* items[], void* addfile, void* adddir);
  417.         push    ebp
  418.         stdcall [aGetFiles], [hPlugin], -1, 0, myAddFile, myAddDir
  419.         pop     ebp
  420.  
  421. ;jmp @f
  422. ;   .str1 db '/LICENSE.txt',0
  423. ;@@:
  424.  
  425. ;HANDLE __stdcall open(HANDLE hPlugin, const char* filename, int mode);
  426. ;Žâªàëâì ä ©« filename.  à ¬¥âà mode § à¥§¥à¢¨à®¢ ­ ¨ ¢ ⥪ã饩 ¢¥àᨨ kfar ¢á¥£¤  à ¢¥­ 1.
  427.  ;       push    ebp
  428.  ;       stdcall [aOpen], [hPlugin], .str1, O_READ
  429.  ;       pop     ebp
  430.  
  431.  ;       mov     [hFile],eax
  432. ;unsigned __stdcall read(HANDLE hFile, void* buf, unsigned size);
  433. ;—⥭¨¥ size ¡ ©â ¢ ¡ãä¥à buf ¨§ ä ©«  hFile, à ­¥¥ ®âªàë⮣® ç¥à¥§ open.
  434. ;size ªà â¥­ 512 ¡ ©â
  435. ;‚®§¢à é ¥¬®¥ §­ ç¥­¨¥: ç¨á«® ¯à®ç¨â ­­ëå ¡ ©â, -1 ¯à¨ ®è¨¡ª¥.
  436.  ;       push    ebp
  437.  ;       stdcall [aRead], [hFile], copy_buf, SIZE_COPY_BUF
  438.  ;       pop     ebp
  439.  ;
  440. ;        mcall   70, fsWrite
  441. ;void __stdcall close(HANDLE hFile);
  442.         push    ebp
  443.         stdcall [aClose], [hFile]
  444.         mov     [bWinChild],0
  445.         pop     ebp
  446.  
  447.         push    ebp
  448.         stdcall [aClosePlugin], [hPlugin]
  449.         mov     [bWinChild],0
  450.  
  451.         mov     [fsRunNotifyOK.param],strUnpackOk
  452.         mcall   70,fsRunNotifyOK
  453.         pop     ebp
  454.         ret             ;SUCCESS
  455.  
  456.  
  457. .errNotFound:
  458. ;        stdcall SimpleSayErr,strNotFound
  459.         mov     [bWinChild],0
  460.         mov     [fsRunNotifyOK.param],strUnpackFault
  461.         mcall   70,fsRunNotifyOK
  462.         ret
  463.  
  464. .errNotSupp:
  465.         mov     eax,[fsNewDir.path]
  466.         mov     [fsDelDir.path],eax
  467.         mcall   70, fsDelDir
  468.  
  469.         mov     [bWinChild],0
  470.         mov     [fsRunNotifyOK.param],strUnpackFault
  471.         mcall   70,fsRunNotifyOK
  472.         ret
  473.  
  474. .errNullInp:
  475.         mov     [redInput],1
  476.         mov     [bWinChild],0
  477.         ret
  478. endp
  479.  
  480.  
  481. proc Exception param1:dword
  482.         stdcall SimpleSayErr,strErrorExc
  483.         ret
  484. endp
  485.  
  486. proc debugInt3
  487.         dps ' ­¨ª !!!!!!!!!!!!!!!!!!!!!!!!!'
  488.         dnl
  489.         int3
  490.         ret
  491. endp
  492.  
  493.  
  494. proc calcSizeArch hPlugin:dword
  495. locals
  496.   bdwk rb 560
  497. endl
  498. ;int __stdcall ReadFolder(HANDLE hPlugin, unsigned dirinfo_start,
  499. ;        unsigned dirinfo_size, void* dirdata);
  500. int3
  501.         push    ebp
  502.         lea     eax,[bdwk]
  503.         stdcall [aReadFolder], [hPlugin],1,560,eax
  504.         pop     ebp
  505.  
  506.         ret
  507. endp
  508. ;-------------------------------------------------------------------------------
  509. ;-------------------------------------------------------------------------------
  510. ;-------------------------------------------------------------------------------
  511.  
  512. ;SayErr  int num_strings, const char* strings[],
  513. ;                      int num_buttons, const char* buttons[]);
  514.  
  515. proc SayErr num_strings:dword, strings:dword,num_buttons:dword, buttons:dword
  516.         pushad
  517.         cmp     [num_strings],1
  518.         je      @f
  519.         m2m     [errmess0], strErrorExc
  520.         jmp     .l1
  521.        @@:
  522.         mov     ebx,[strings]
  523.         m2m     [errmess0], dword [ebx]
  524.        .l1:
  525.         mcall   51,1,threadSayErr,stackDlg
  526.         popad
  527.         mov     eax,1
  528.         ret
  529. endp
  530.  
  531. proc SimpleSayErr str:dword
  532.         pushad
  533.         m2m     [errmess0],[str]
  534.         mcall   51,1,threadSayErr,stackDlg
  535.         popad
  536.         ret
  537. endp
  538.  
  539.  
  540. proc threadSayErr
  541.         mcall   40, 111b+0C000000h
  542. .wm_redraw:
  543.         mcall 12, 1
  544.         mcall 48, 3, sc, sizeof.system_colors
  545.         mov   edx, [sc.work]
  546.         or        edx, 0x33000000
  547.         mcall 0, <220,WIN_W>, <220,110>, , , title
  548.  
  549.         mov     ecx,[sc.work_text]
  550.         or      ecx,90000000h
  551.         mov     edx,[errmess0]
  552.         mcall 4, <15,11>
  553.  
  554.         mcall 8, <105,100>,<45,25>,1,[sc.work_button]
  555.         mov     ecx,[sc.work_button_text]
  556.         or      ecx,90000000h
  557.         mcall 4, <147,51>, , strOk
  558.  
  559.         mcall 12, 2
  560.  
  561. .still:
  562.         mcall   10
  563.         cmp     eax, 1
  564.         je      .wm_redraw
  565.         cmp     eax, 2
  566.         je      .wm_key
  567.         cmp     eax, 3
  568.         je      .wm_button
  569.         jmp     .still
  570.  
  571. .wm_button:
  572.         mcall   17
  573.  
  574.         cmp     ah, 1
  575.         je      .exit
  576.         jmp     .still
  577.  
  578. .wm_key:
  579.         mcall   2
  580.         jmp     .still
  581. .exit:
  582.         mcall   -1
  583. endp
  584.  
  585. ;-------------------------------------------------------------------------------
  586. ;-------------------------------------------------------------------------------
  587. ;-------------------------------------------------------------------------------
  588.     ; "enter password" dialog for KFar
  589. ;password_dlg:
  590. ;        dd      1       ; use standard dialog colors
  591. ;        dd      -1      ; center window by x
  592. ;        dd      -1      ; center window by y
  593. ;.width  dd      ?       ; width (will be filled according to current console width)
  594. ;        dd      2       ; height
  595. ;        dd      4, 2    ; border size
  596. ;        dd      aEnterPasswordTitle     ; title
  597. ;        dd      ?       ; colors (will be set by KFar)
  598. ;        dd      0       ; used internally by dialog manager, ignored
  599. ;        dd      0, 0    ; reserved for DlgProc
  600. ;        dd      2       ; 2 controls
  601. ;; the string "enter password"
  602. ;        dd      1       ; type: static
  603. ;        dd      1,0     ; upper-left position
  604. ;.width1 dd      ?,0     ; bottom-right position
  605. ;        dd      aEnterPassword  ; data
  606. ;        dd      0       ; flags
  607. ;; editbox for password
  608. ;        dd      3       ; type: edit
  609. ;        dd      1,1     ; upper-left position
  610. ;.width2 dd      ?,0     ; bottom-right position
  611. ;        dd      password_data   ; data
  612. ;        dd      2Ch     ; flags
  613.  
  614.  
  615.  
  616. proc DialogBox dlgInfo:dword
  617.         pushad
  618.         mov     ebx,[dlgInfo]
  619.         mov     eax,[ebx+19*4]
  620.         mov     [forpassword],eax
  621.         mov     byte[eax], 0
  622.         mov     [stateDlg], 0
  623.         mcall   51,1,threadDialogBox,stackDlg
  624.  
  625.         ;wait thread...
  626.     @@: cmp     [stateDlg],0
  627.         jne     @f
  628.         mcall   5,1
  629.         jmp     @b
  630.      @@:
  631.         popad
  632.         cmp     [stateDlg], 1
  633.         jne     @f
  634.         xor     eax, eax
  635.         ret
  636.     @@:
  637.         or      eax, -1
  638.         ret
  639. endp
  640.  
  641. proc threadDialogBox
  642.  
  643.         mcall   40, 100111b+0C000000h
  644.         mov     eax,[forpassword]
  645.         mov     [edtPassword+4*9],eax
  646.         xor     eax,eax
  647.         mov     dword[edtPassword.size], eax
  648.         mov     dword[edtPassword.pos], eax
  649.  
  650. .wm_redraw:
  651.         mcall   12, 1
  652.         mcall   48, 3, sc, sizeof.system_colors
  653.         mov     edx, [sc.work]
  654.         or      edx, 0x33000000
  655.         mcall   0, <200,320>, <200,140>, , , title
  656.  
  657.         edit_boxes_set_sys_color edtPack,endEdits,sc
  658.         stdcall [edit_box_draw],edtPassword
  659.  
  660.  
  661.         mov     ecx,[sc.work_text]
  662.         or      ecx,90000000h
  663.         mcall 4, <56,12>, , strGetPass
  664.  
  665.         mcall 8, <70,80>,<74,22>,2,[sc.work_button]
  666.         mov     ecx,[sc.work_button_text]
  667.         or      ecx,90000000h
  668.         mcall 4, <103,79>, , strOk
  669.  
  670.         mcall 8, <165,80>,<74,22>,1,[sc.work_button]
  671.         mov     ecx,[sc.work_button_text]
  672.         or      ecx,90000000h
  673.         mcall 4, <182,79>, , strCancel
  674.  
  675.  
  676.         mcall 12, 2
  677.  
  678. .still:
  679.         mcall   10
  680.         cmp     eax, 1
  681.         je      .wm_redraw
  682.         cmp     eax, 2
  683.         je      .wm_key
  684.         cmp     eax, 3
  685.         je      .wm_button
  686.         cmp     eax, 6
  687.         je      .wm_mouse
  688.  
  689.         jmp     .still
  690.  
  691. .wm_key:
  692.         mcall   2
  693.         stdcall [edit_box_key],edtPassword
  694.         jmp     .still
  695.  
  696.  
  697. .wm_button:
  698.         mcall   17
  699.  
  700.         cmp     ah, 2           ;OK
  701.         jne     @f
  702.         mov     [stateDlg],1
  703.         jmp     .exit
  704.     @@:
  705.  
  706.         cmp     ah, 1           ;Close window or Cancel
  707.         jne      .still
  708.         mov     [stateDlg],2
  709.         jmp     .exit
  710.  
  711. .wm_mouse:
  712.         stdcall [edit_box_mouse],edtPassword
  713.  
  714.  
  715.         jmp     .still
  716.  
  717. .exit:
  718.         mcall   -1
  719. endp
  720.  
  721.  
  722. ;--  DATA  -------------------------------------------------------------------
  723.  
  724.  
  725.  
  726. sc system_colors
  727.  
  728.  
  729. bWinChild db 0  ;1 - ¤®ç¥à­¥¥ ®ª­® ¥áâì, £« ¢­®¥ ®ª­® ­¥ ¤®«¦­® ॠ£¨à®¢ âì
  730. redInput  db 0  ;1 - ¯®¤á¢¥â¨âì ªà á­ë¬ ­ ¤¯¨áì
  731.  
  732. if lang eq ru
  733.  title db 'uNZ v0.11 -  á¯ ª®¢é¨ª Zip ¨ 7z',0
  734.  strGo db ' á¯ ª®¢ âì',0
  735.  strInp db  '    €à娢',0
  736.  strPath db 'ˆ§¢«¥çì ¢',0
  737.  strError db 'Žè¨¡ª ',0
  738.  strErrorExc db '¥®¯®§­ ­­ ï ®è¨¡ª ',0
  739.  strOk  db 'OK',0
  740.  strGetPass db ' à®«ì',0
  741.  strCancel  db 'Žâ¬¥­ ',0
  742.  strUnpackOk  db "'“ᯥ譮 à á¯ ª®¢ ­®' -O",0
  743.  strUnpackFault  db "'Žè¨¡ª  à á¯ ª®¢ª¨' -E",0
  744.  strNotSupport db "'¥¯®¤¤¥à¦¨¢ ¥¬ë© ä®à¬ â  à娢 ' -E",0
  745.  strNotFound db "'” ©« ­¥ ­ ©¤¥­' -E",0
  746. else
  747.  title db 'uNZ v0.11 - Unarchiver of Zip and 7z',0
  748.  strGo db   'Unpack',0
  749.  strInp db  'Archive',0
  750.  strPath db 'Extract to',0
  751.  strError db 'Error',0
  752.  strErrorExc db 'Unrecognized error',0
  753.  strOk  db 'OK',0
  754.  strGetPass db 'Password',0
  755.  strCancel  db 'Cancel',0
  756.  strUnpackOk  db "'Unpacked successfuly' -O",0
  757.  strUnpackFault  db "'Unpack failed' -E",0
  758.  strNotSupport db "'Archive format is not supported' -E",0
  759.  strNotFound db "'File not found' -E",0
  760. end if
  761.  
  762. strNull db 0
  763. strDots db '...',0
  764.  
  765. ;--------
  766. ; int __stdcall SayErr(int num_strings, const char* strings[],
  767. ;                      int num_buttons, const char* buttons[]);
  768. ; int __stdcall DialogBox(DLGDATA* dlg);
  769.  
  770. forpassword rd 1
  771. stateDlg dd 0 ;0 - in process, 1 - button ok, 2 - button cancel
  772. errmess0 dd strErrorExc
  773.  
  774.  
  775. kfar_info:
  776.         dd      .size
  777.         dd      version_dword
  778.         dd      open
  779.         dd      open2
  780.         dd      read
  781.         dd      -1      ; write: to be implemented
  782.         dd      seek
  783.         dd      tell
  784.         dd      -1      ; flush: to be implemented
  785.         dd      filesize
  786.         dd      close
  787.         dd      xpgalloc
  788.         dd      xpgrealloc
  789.         dd      pgfree
  790.         dd      getfreemem
  791.         dd      debugInt3;libini_alloc
  792.         dd      debugInt3;libini_realloc
  793.         dd      debugInt3;libini_free
  794.         dd      debugInt3;menu
  795.         dd      debugInt3;menu_centered_in
  796.         dd      DialogBox;DialogBox
  797.         dd      SayErr   ;SayErr
  798.         dd      debugInt3;Message
  799.         dd      0       ;cur_width
  800. .size = $ - kfar_info
  801. ;--------
  802.  
  803.  
  804. iFiles dd 0     ;ª®«¨ç¥á⢮ ¢ë£à㦠¥¬ëå ä ©«®¢
  805. endPointer dd buffer
  806.  
  807.  
  808. fsZip:
  809. .cmd    dd 5
  810.         dd 0
  811.         dd 0
  812. .size   dd 0
  813. .buf    dd bdvkPack
  814.         db 0
  815.         dd fInp
  816.  
  817. fsZipRead:
  818. .cmd    dd 0
  819.         dd 0
  820.         dd 0
  821. .size   dd 1024
  822. .buf    dd filedata_buffer
  823.         db 0
  824.         dd fInp
  825.  
  826.  
  827. fsWrite:
  828. .cmd    dd 2    ;2 rewrite, 3 - write
  829. .pos    dd 0
  830. .hpos   dd 0
  831. .size   dd SIZE_COPY_BUF
  832. .buf    dd copy_buf
  833.         db 0
  834. .path   dd 0
  835.  
  836.  
  837. fsNewDir:
  838. .cmd    dd 9
  839.         dd 0
  840.         dd 0
  841.         dd 0
  842.         dd 0
  843.         db 0
  844. .path   dd 0
  845.  
  846. fsDelDir:
  847. .cmd    dd 8
  848.         dd 0
  849.         dd 0
  850.         dd 0
  851.         dd 0
  852.         db 0
  853. .path   dd 0
  854.  
  855.  
  856.  
  857. fsRunNotifyOK:
  858. .cmd    dd 7
  859.         dd 0
  860. .param  dd strUnpackOk
  861. .size   dd 0
  862. .buf    dd 0
  863.         db '/sys/@notify',0
  864.  
  865.  
  866.  
  867. edtPack     edit_box (WIN_W-100-60),100,10,0FFFFFFh,0xff,0x80ff,0h,0x90000000,\
  868.             255, fInp, mouse_dd,0,0,0
  869. edtUnpPath  edit_box (WIN_W-100-60),100,35,0FFFFFFh,0xff,0x80ff,0h,0x90000000,\
  870.             255, pathOut, mouse_dd,0,0,0
  871. edtPassword edit_box 200,56,70,0FFFFFFh,0xff,0x80ff,0h,0x90000000,255,\
  872.                 password, mouse_dd,0,0,0
  873. endEdits:
  874.  
  875. ;-------------------------------------------------------------------------------
  876. OpenDialog_data:
  877. .type                   dd 0    ;0-open, 1-save, 2-select folder
  878. .procinfo               dd RBProcInfo       ;+4
  879. .com_area_name          dd communication_area_name      ;+8
  880. .com_area               dd 0    ;+12
  881. .opendir_pach           dd temp_dir_pach        ;+16
  882. .dir_default_pach       dd communication_area_default_pach      ;+20
  883. .start_path             dd open_dialog_path     ;+24
  884. .draw_window            dd winRedraw               ;+28
  885. .status                 dd 0    ;+32
  886. .openfile_pach          dd ODAreaPath;   ;+36
  887. .filename_area          dd 0;        ;+40
  888. .filter_area            dd Filter
  889. .x:
  890. .x_size                 dw 420 ;+48 ; Window X size
  891. .x_start                dw 100 ;+50 ; Window X position
  892. .y:
  893. .y_size                 dw 320 ;+52 ; Window y size
  894. .y_start                dw 100 ;+54 ; Window Y position
  895.  
  896. communication_area_name:
  897.         db 'FFFFFFFF_open_dialog',0
  898. open_dialog_path:
  899.         db '/sys/File managers/opendial',0
  900.  
  901. communication_area_default_pach:
  902.         db '/sys',0
  903.  
  904. Filter  dd 0
  905.  
  906.  
  907. ; int __stdcall         ReadFolder(HANDLE hPlugin,
  908. ;       unsigned dirinfo_start, unsigned dirinfo_size, void* dirdata);
  909. ; void __stdcall        ClosePlugin(HANDLE hPlugin);
  910. ; bool __stdcall        SetFolder(HANDLE hPlugin,
  911. ;       const char* relative_path, const char* absolute_path);
  912. ; void __stdcall        GetOpenPluginInfo(HANDLE hPlugin, OpenPluginInfo* info);
  913. ; void __stdcall        GetFiles(HANDLE hPlugin, int NumItems, void* items[],
  914. ;       void* addfile, void* adddir);
  915. ;       bool __stdcall addfile(const char* name, void* bdfe_info, HANDLE hFile);
  916. ;       bool __stdcall adddir(const char* name, void* bdfe_info);
  917. ; int __stdcall         getattr(HANDLE hPlugin, const char* filename, void* info);
  918. ; HANDLE __stdcall      open(HANDLE hPlugin, const char* filename, int mode);
  919. ; void __stdcall        setpos(HANDLE hFile, __int64 pos);
  920. ; unsigned __stdcall    read(HANDLE hFile, void* buf, unsigned size);
  921. ; void __stdcall        close(HANDLE hFile);
  922. IMPORTS:
  923. library archiver, 'archiver.obj',\
  924.         box_lib ,'box_lib.obj',\
  925.         proc_lib,'proc_lib.obj'
  926.  
  927. import  archiver,\
  928.         aPluginLoad     ,      'plugin_load',\
  929.         aOpenFilePlugin ,      'OpenFilePlugin',\
  930.         aClosePlugin    ,      'ClosePlugin',\
  931.         aReadFolder     ,      'ReadFolder',\
  932.         aSetFolder      ,      'SetFolder',\
  933.         aGetFiles       ,      'GetFiles',\
  934.         aGetOpenPluginInfo ,   'GetOpenPluginInfo',\
  935.         aGetattr        ,      'getattr',\
  936.         aOpen           ,      'open',\
  937.         aRead           ,      'read',\
  938.         aSetpos         ,      'setpos',\
  939.         aClose          ,      'close',\
  940.         aDeflateUnpack  ,      'deflate_unpack',\
  941.         aDeflateUnpack2 ,      'deflate_unpack2'
  942.  
  943. import  proc_lib,\
  944.         OpenDialog_Init         ,'OpenDialog_init',\
  945.         OpenDialog_Start        ,'OpenDialog_start'
  946. import  box_lib,\
  947.         edit_box_draw           ,'edit_box',\
  948.         edit_box_key            ,'edit_box_key',\
  949.         edit_box_mouse          ,'edit_box_mouse'
  950.  
  951.  
  952. IncludeIGlobals
  953.  
  954. ;--  UDATA  -----------------------------------------------------------------------------
  955. init_end:
  956. align 16
  957. IncludeUGlobals
  958.  
  959.  
  960. ;params db 'unz -o "fil epar1" -f "arch1.txt" -f "ar ch2.txt" file1',0
  961. ;params db 'unz -o "fil epar1" -f arch1.txt -f "ar ch2.txt" file1',0
  962. ;params db '/hd0/1/unz/xboot-1-0-build-14-en-win.zip',0
  963. ;rb 4096
  964.  
  965. fInp    rb 1024
  966. pathOut rb 1024
  967. files   rd 256
  968. password        rb 256
  969.  
  970. fZipInfo         rb 40
  971.  
  972. mouse_dd        rd 1
  973. RBProcInfo      rb 1024
  974. temp_dir_pach   rb 1024
  975. ODAreaPath      rb 1024
  976.  
  977.  
  978.  
  979. ;--------
  980.  
  981. copy_buf rb SIZE_COPY_BUF
  982.  
  983. execdata rb     1024
  984. execdataend:
  985.  
  986. filedata_buffer_size = 1024
  987. filedata_buffer rb      filedata_buffer_size
  988.  
  989. CopyDestEditBuf         rb      12+512+1
  990. .length = $ - CopyDestEditBuf - 13
  991.  
  992. bdvkPack rb 560
  993.  
  994. ;--------
  995.  
  996. buffer  rb 4096 ;for string of file name or extract
  997. params rb 4096
  998.  
  999.         rb 1024
  1000. stackUnpack:
  1001.  
  1002.         rb 1024
  1003. stackDlg:
  1004.  
  1005.         rb 1024
  1006. stack_top:
  1007.  
  1008. end_mem:
  1009.  
  1010.  
  1011.