From 75b6663ce0b91c1f298f21a604d683166a5222a2 Mon Sep 17 00:00:00 2001 From: IgorA Date: Thu, 10 Apr 2025 18:47:13 +0200 Subject: [PATCH] Ftpc: Update (#185) - fix for bugs with buffers 'remote_list_buf', 'buf_buffer2'; - fix stack leak when navigating files; - change sorting of folders and files, clean code; - added option to show|hide log; - icons are taken from @reshare; - added icons to the 'disconnect' and 'search' buttons. Reviewed-on: https://git.kolibrios.org/KolibriOS/kolibrios/pulls/185 Reviewed-by: Max Logaev Co-authored-by: IgorA Co-committed-by: IgorA --- data/Tupfile.lua | 2 - .../libraries/box_lib/trunk/tree_list.asm | 1 + programs/network/ftpc/console.inc | 1 - programs/network/ftpc/ftpc.asm | 39 +- programs/network/ftpc/ftpc_nod.png | Bin 283 -> 0 bytes programs/network/ftpc/ftpc_sys.png | Bin 640 -> 0 bytes programs/network/ftpc/gui.inc | 333 +++++++++++++----- programs/network/ftpc/login_gui.inc | 33 +- programs/network/ftpc/servercommands.inc | 7 +- programs/network/ftpc/usercommands.inc | 20 +- 10 files changed, 308 insertions(+), 128 deletions(-) delete mode 100755 programs/network/ftpc/ftpc_nod.png delete mode 100755 programs/network/ftpc/ftpc_sys.png diff --git a/data/Tupfile.lua b/data/Tupfile.lua index 15a548b9a..66cea9233 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -49,8 +49,6 @@ img_files = { {"MEDIA/IMGF/INVSOL.OBJ", "common/media/ImgF/invSol.obj"}, {"MEDIA/PIXIESKN.PNG", SRC_PROGS .. "/cmm/pixie2/pixieskn.png"}, {"NETWORK/FTPC.INI", SRC_PROGS .. "/network/ftpc/ftpc.ini"}, - {"NETWORK/FTPC_SYS.PNG", SRC_PROGS .. "/network/ftpc/ftpc_sys.png"}, - {"NETWORK/FTPC_NOD.PNG", SRC_PROGS .. "/network/ftpc/ftpc_nod.png"}, {"NETWORK/FTPD.INI", "common/network/ftpd.ini"}, {"NETWORK/KNMAP", "common/network/knmap"}, {"NETWORK/USERS.INI", "common/network/users.ini"}, diff --git a/programs/develop/libraries/box_lib/trunk/tree_list.asm b/programs/develop/libraries/box_lib/trunk/tree_list.asm index 99511353f..f5994d04e 100644 --- a/programs/develop/libraries/box_lib/trunk/tree_list.asm +++ b/programs/develop/libraries/box_lib/trunk/tree_list.asm @@ -170,6 +170,7 @@ proc tl_key uses ebx ecx edi, tlist:dword cmp tl_on_press,0 je @f call tl_on_press + jmp .no_edit @@: cmp ah,byte[ecx+1] ;Space jne @f diff --git a/programs/network/ftpc/console.inc b/programs/network/ftpc/console.inc index e17535cce..d858a8416 100755 --- a/programs/network/ftpc/console.inc +++ b/programs/network/ftpc/console.inc @@ -105,7 +105,6 @@ console: ;////////////////////////////////////////////////////////////////////// mov eax, [esp+36] call write_to_file - @@: popad ret 4 diff --git a/programs/network/ftpc/ftpc.asm b/programs/network/ftpc/ftpc.asm index a77286934..f8b3c185d 100644 --- a/programs/network/ftpc/ftpc.asm +++ b/programs/network/ftpc/ftpc.asm @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2013-2021. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2013-2025. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; ftpc.asm - FTP client for KolibriOS ;; @@ -36,8 +36,8 @@ use32 dd 1 ; header version dd start ; entry point dd i_end ; initialized size - dd mem+0x1000 ; required memory - dd mem+0x1000 ; stack pointer + dd mem ; required memory + dd stacktop ; stack pointer dd buf_cmd ; parameters dd path ; path @@ -83,12 +83,12 @@ start: ;//////////////////////////////////////////////////////////////////////// ;< none ;; ;;================================================================================================;; ; initialize heap for using dynamic blocks - mcall 68, 11 + mcall SF_SYS_MISC, SSF_HEAP_INIT test eax, eax je exit2 ; disable all events except network event - mcall 40, EV_STACK + mcall SF_SET_EVENTS_MASK, EV_STACK ; load libraries stdcall dll.Load, @IMPORT test eax, eax @@ -125,16 +125,16 @@ start: ;//////////////////////////////////////////////////////////////////////// mov [acti_port_stop], ax invoke ini.get_str, path, str_general, str_dir, buf_buffer1, BUFFERSIZE, 0 - mcall 30, 1, buf_buffer1 ; set working directory + mcall SF_CURRENT_FOLDER, SSF_SET_CF, buf_buffer1 ; set working directory ; initialize log file invoke ini.get_str, path, str_general, str_logfile, log_file, 512, 0 - mov [filestruct2.subfn], 2 + mov [filestruct2.subfn], SSF_CREATE_FILE mov [filestruct2.offset], 0 mov [filestruct2.size], 0 mov [filestruct2.ptr], 0 mov [filestruct2.name], log_file - mcall 70, filestruct2 + mcall SF_FILE, filestruct2 ; Usage: ftpc [-cli] [ftp://username:password@server:port/path] @@ -355,7 +355,7 @@ wait_for_servercommand: ;/////////////////////////////////////////////////////// ; receive socket data with timeout .receive: - mcall 26, 9 + mcall SF_SYSTEM_GET, SSF_TIME_COUNT add eax, TIMEOUT*100 mov [timeout], eax .again: @@ -365,11 +365,11 @@ wait_for_servercommand: ;/////////////////////////////////////////////////////// je .closed cmp ebx, EWOULDBLOCK jne .sock_err - mcall 26, 9 + mcall SF_SYSTEM_GET, SSF_TIME_COUNT mov ebx, [timeout] sub ebx, eax jle .timeout - mcall 23 ; Wait for event with timeout + mcall SF_WAIT_EVENT_TIMEOUT ; Wait for event with timeout jmp .again .sock_err: @@ -524,7 +524,7 @@ transfer_queued: ; Error occured, we reached the end of the buffer before [queued] reached 0 mov [queued], 0 - mcall 68, 13, [ptr_fname] ; free buffer + mcall SF_SYS_MISC, SSF_MEM_FREE, [ptr_fname] ; free buffer test eax, eax jz error_heap jmp wait_for_usercommand @@ -535,7 +535,7 @@ transfer_queued: dec [queued] jnz cmd_retr - mcall 68, 13, [ptr_fname] ; free buffer + mcall SF_SYS_MISC, SSF_MEM_FREE, [ptr_fname] ; free buffer test eax, eax jz error_heap jmp cmd_retr @@ -655,12 +655,12 @@ write_to_file: ;//////////////////////////////////////////////////////////////// mov eax, 0 ret @@: - mov [filestruct2.subfn], 3 + mov [filestruct2.subfn], SSF_WRITE_FILE m2m [filestruct2.offset], [logfile_offset] mov [filestruct2.size], ecx mov [filestruct2.ptr], eax mov [filestruct2.name], log_file - mcall 70, filestruct2 + mcall SF_FILE, filestruct2 test eax, eax jz @f mov [logfile_offset], -1 ; disable logging @@ -754,13 +754,13 @@ wait_for_keypress: exit: mcall close, [controlsocket] exit2: - mcall -1 + mcall SF_TERMINATE_PROCESS ; data str_title db 'FTP client for KolibriOS',0 -str_welcome db 'FTP client for KolibriOS v0.16',10 +str_welcome db 'FTP client for KolibriOS v0.18',10 db 10,0 str_srv_addr db 'Please enter ftp server address.',10,0 @@ -971,6 +971,7 @@ param_path rb 1024 param_port rb 6 sc system_colors -rb 1024 - +align 16 +rb 4096 +stacktop: mem: diff --git a/programs/network/ftpc/ftpc_nod.png b/programs/network/ftpc/ftpc_nod.png deleted file mode 100755 index 09c292a01f63c70014da41e3adaaf549ff7742d7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 283 zcmV+$0p$LPP)$(R!T^tkummBq!$Twr?h)O_sHafgbf_xJgurMmF+ z{Q202?(XvK$XxvC!szJmKvbrF0pHE6-Q555MEPY;8 hL6p82M2PRgk0-4o4SKgeg8cvh002ovPDHLkV1g<|jyeDU diff --git a/programs/network/ftpc/ftpc_sys.png b/programs/network/ftpc/ftpc_sys.png deleted file mode 100755 index 8081e4e0175525ea5904f735e40d61078f074d2a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 640 zcmV-`0)PF9P)fc*UXP*70+007IUmVf{Nky#c1q5%E;0Dqr<21f?)=l}r! z0A*!m;?u;RZ#Fm`RGyb7|8`5)K zc|OyqWeE{=yG=`oASGk9qMT-sk~!`Mpq;`%#O;)cA)2?MU5Hs+5FlTPt57B(bEOp{ zzaB+Zm6wWtaoKP!AsY3Ir6q(BF4;iT43!OpZX_xUixU-uN=Y1QEPO@JvtQl63S}0% z%wnZz)o)p04Y(xG2dFPfkDq8Iq5FG%0Pf?XZ~X;KC#C%{>Gd*82-_rMO@M8iWXzro zHYNQeO&Z${1-DmXU2sXoiU@GIAR_U>k+fA ad=l5evNNQLW)k!O0000, <20,555>, 0x34000000+SYS_COL, 0x805080DD, str_title + mcall SF_CREATE_WINDOW, <35,830>, <20,555-160>, 0x34000000+SYS_COL, 0x805080DD, str_title ;------------------------- ; textedit components ;------------------------- - mcall 9, procinfo, -1 + mcall SF_THREAD_INFO, procinfo, -1 mov edi, tedit0 call EvSize movzx ebx,word[procinfo.client_box.width] inc bx - mcall 13, , ted_wnd_t - stdcall [ted_draw], tedit0 + mcall SF_DRAW_RECT, , ted_wnd_t ; draw "disconnect" button - mcall 8, <50,95>, <25,25>, 3, BT_COL + mcall SF_DEFINE_BUTTON, <50,114>, <25,25>, 3, BT_COL + ; icon + mcall SF_PUT_IMAGE_EXT, [icon_buttons], <18, 18>, <54, 29>, 32,, 0 ; string "disconnect" - mcall 4, <50+5,25+5>, 0xb0000000+STR_COL, str_disconnect + mcall SF_DRAW_TEXT, <50+18+10,25+5>, 0xb0000000+STR_COL, str_disconnect + + ; draw "Show|Hide log" button + mcall SF_DEFINE_BUTTON, <50,79>, <326,25>, 10, BT_COL + ; string "Show|Hide log" + cmp [show_log],0 + je @f + stdcall [ted_draw], tedit0 + mov edx, str_hide_log + jmp .end_log_1 + @@: + mov edx, str_show_log + .end_log_1: + mcall SF_DRAW_TEXT, <50+5,326+5>, 0xb0000000+STR_COL + cmp [show_log],0 + je @f ; draw "Copy" button - mcall 8, <50,40>, <326,25>, 4, BT_COL + mcall SF_DEFINE_BUTTON, <129+5,40>, <326,25>, 4, BT_COL ; string "copy" - mcall 4, <50+5,326+5>, 0xb0000000+STR_COL, str_copy + mcall SF_DRAW_TEXT, <129+10,326+5>, 0xb0000000+STR_COL, str_copy + @@: ; draw "Search" button - mcall 8, , <20,25>, 5, BT_COL + mcall SF_DEFINE_BUTTON, , <20,25>, 5, BT_COL + ; icon + mov ebx, [icon_buttons] + add ebx, 18*18*4 + mcall SF_PUT_IMAGE_EXT,, <18, 18>, <730, 24>, 32,, 0 ; string "Search" - mcall 4, , 0xb0000000+STR_COL, str_search + ;mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_search ; draw "LIST" button - mcall 8, , <50,25>, 12, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 12, BT_COL ; string "LIST" - mcall 4, , 0xb0000000+STR_COL, str_list + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_list ; draw "DELE" button - mcall 8, , <50,25>, 7, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 7, BT_COL ; string "DELE" - mcall 4, , 0xb0000000+STR_COL, str_dele + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_dele ; draw "RDIR" button - mcall 8, , <50,25>, 8, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 8, BT_COL ; string "RDIR" - mcall 4, , 0xb0000000+STR_COL, str_rdir + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_rdir ; draw "RMD" button - mcall 8, , <50,25>, 9, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 9, BT_COL ; string "RMD" - mcall 4, , 0xb0000000+STR_COL, str_rmd + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_rmd ; draw "mkd" button - mcall 8, , <80,20>, 6, BT_COL + mcall SF_DEFINE_BUTTON, , <80,20>, 6, BT_COL ; string "mkd" - mcall 4, , 0xb0000000+STR_COL, str_mkd + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_mkd ; draw "cancel" button - ;mcall 8, <555,55>, <308,25>, 10, BT_COL + ;mcall SF_DEFINE_BUTTON, <555,55>, <308,25>, 10, BT_COL ; string "Cancel" - ;mcall 4, <555+5,308+5>, 0xb0000000+STR_COL, str_abort + ;mcall SF_DRAW_TEXT, <555+5,308+5>, 0xb0000000+STR_COL, str_abort ; draw "change volume" button - mcall 8, , <100-20,22>, 11, BT_COL + mcall SF_DEFINE_BUTTON, , <100-20,22>, 11, BT_COL ; string "Change" - mcall 4, , 0xb0000000+STR_COL, str_change + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_change ;-------------------------- ; tree list components @@ -222,12 +254,12 @@ gui: ;////////////////////////////////////////////////////////////////////////// stdcall [edit_box_draw], edit_volume stdcall [edit_box_draw], edit_search - mcall 12,2 + mcall SF_REDRAW, SSF_END_DRAW ret align 16 .mouse: - mcall 37, 1 + mcall SF_MOUSE_GET, SSF_WINDOW_POSITION cmp word[tedit0.wnd.top], ax jg .no_edit @@ -235,7 +267,7 @@ gui: ;////////////////////////////////////////////////////////////////////////// cmp word[tedit0.wnd.left], ax jg .no_edit - mcall 37, 3 + mcall SF_MOUSE_GET, SSF_BUTTON_EXT bt eax, 24 jnc @f @@ -243,12 +275,19 @@ gui: ;////////////////////////////////////////////////////////////////////////// jmp .still @@: + cmp [show_log],0 + je .still stdcall [ted_mouse], tedit0 jmp .still .no_edit: + mov [lbl_after_enter], 0 stdcall [tl_mouse], tree1 stdcall [tl_mouse], tree2 + cmp [lbl_after_enter], 0 + jz @f + jmp [lbl_after_enter] + @@: stdcall [edit_box_mouse], edit_mkd stdcall [edit_box_mouse], edit_volume stdcall [edit_box_mouse], edit_search @@ -256,9 +295,14 @@ gui: ;////////////////////////////////////////////////////////////////////////// align 16 .key: - mcall 2 + mcall SF_GET_KEY + mov [lbl_after_enter], 0 stdcall [tl_key], tree1 stdcall [tl_key], tree2 + cmp [lbl_after_enter], 0 + jz @f + jmp [lbl_after_enter] + @@: stdcall [edit_box_key], edit_mkd stdcall [edit_box_key], edit_volume stdcall [edit_box_key], edit_search @@ -266,13 +310,19 @@ gui: ;////////////////////////////////////////////////////////////////////////// align 16 .button: - mcall 17 + mcall SF_GET_BUTTON cmp ah, 3 jne @f ijmp eax, interface_addr, interface.server_addr jmp .still + @@: + cmp ah, 10 + jne @f + call show_hide_log + jmp .still + @@: cmp ah, 4 jne @f @@ -310,7 +360,7 @@ gui: ;////////////////////////////////////////////////////////////////////////// @@: cmp ah, 1 je .exit - + jmp .still .print: @@ -327,13 +377,15 @@ gui: ;////////////////////////////////////////////////////////////////////////// cmp byte[esi], 0 jne @b stdcall [ted_text_add], tedit0, tedit_buffer, ecx, ebx + cmp [show_log],0 + je .end_log_2 stdcall [ted_draw], tedit0 + .end_log_2: ; write to log file mov eax, [esp+36] sub ecx, 2 ; 0a0d is not included call write_to_file - @@: popad ret 4 @@ -353,13 +405,16 @@ gui: ;////////////////////////////////////////////////////////////////////////// ;< none ;; ;;================================================================================================;; - push edx - push eax + cmp eax, 1 + jl data_loop + push edx eax ; check if any incomplete entry to be parsed cmp byte[remote_list_buf], 0 je .no_backlog + ; find end of remote_list_buf mov edi, remote_list_buf + mov ecx, 1024 ;buffer size mov al, 0 repne scasb ; copy rest of the incomplete entry to remote_list_buf @@ -424,6 +479,8 @@ gui: ;////////////////////////////////////////////////////////////////////////// mov byte[edi], 0 ; add node to tree list + and dword[tree2.style], not 8 + stdcall [tl_cur_next], tree2 cmp word[node_entry2], 'fi' jne @f stdcall [tl_node_add], tree2, 0, node_entry2 @@ -453,9 +510,9 @@ gui: ;////////////////////////////////////////////////////////////////////////// .store_last_entry: ; find index of the last incomplete entry - mov ecx, -1 mov eax, [esp] lea edi, [buf_buffer2+eax-2] + mov ecx, eax mov al, 0x0a std repne scasb @@ -470,9 +527,10 @@ gui: ;////////////////////////////////////////////////////////////////////////// jne @b .done_parsing: + stdcall [tl_cur_beg], tree2 + or dword[tree2.style], 8 call .draw ; to update tree list immediately in case of "auto_list" - pop eax - pop edx + pop eax edx jmp data_loop ; clear tree list and add ".." node before executing "LIST" @@ -494,7 +552,7 @@ gui: ;////////////////////////////////////////////////////////////////////////// ;;================================================================================================;; ; detect abort - mcall 17 + mcall SF_GET_BUTTON cmp ah, 10 je cmd_abor @@ -578,7 +636,8 @@ fun_on_enter: cmp byte[esi], 0 jne @b mov word[edi], 0x000a - jmp cmd_stor + mov [lbl_after_enter], cmd_stor + ret ; Function to call when you press [Enter] @@ -591,7 +650,8 @@ fun_on_enter2: cmp dword[esi], 0x2E2E jne @f mov [auto_list], 1 - jmp cmd_cdup + mov [lbl_after_enter], cmd_cdup + ret @@: cmp word[eax], 'fo' @@ -610,12 +670,14 @@ fun_on_enter2: ; newline in console code cmp word[eax], 'fo' je @f - jmp cmd_retr + mov [lbl_after_enter], cmd_retr + ret @@: stdcall [tl_info_clear], tree2 mov [auto_list], 1 - jmp cmd_cwd + mov [lbl_after_enter], cmd_cwd + ret ;;================================================================================================;; @@ -641,7 +703,7 @@ populate_local_tree_list: ;///////////////////////////////////////////////////// jne @f ; removes last file name from filestruct.name - mcall 30, 2, filestruct.name,1024 ; get absolute path for cwd + mcall SF_CURRENT_FOLDER, SSF_GET_CF, filestruct.name,1024 ; get absolute path for cwd lea edi, [filestruct.name+eax] ; edi = pointer to the tail of file name mov al, '/' mov ecx, -1 @@ -652,15 +714,15 @@ populate_local_tree_list: ;///////////////////////////////////////////////////// mov ecx, filestruct.name @@: - mcall 30, 1, ; set cwd - mcall 30, 2, filestruct.name, 1024 ; get absolute path for cwd + mcall SF_CURRENT_FOLDER, SSF_SET_CF ; set cwd + mcall SF_CURRENT_FOLDER, SSF_GET_CF, filestruct.name, 1024 ; get absolute path for cwd ; clear all nodes in tree list stdcall [tl_info_clear], tree1 mov [filestruct.offset], 0 ; read 32 blocks .outer: - mcall 70, filestruct + mcall SF_FILE, filestruct ;int3 test eax, eax jz @f @@ -746,6 +808,16 @@ EvSize: ret +; +show_hide_log: + mov esi, 555 + xor [show_log],1 + jnz @f + sub esi, 160 + @@: + mcall SF_CHANGE_WINDOW, -1, -1, -1 + ret + ;;================================================================================================;; filter_remote_list: ;/////////////////////////////////////////////////////////////////////////////;; ;;------------------------------------------------------------------------------------------------;; @@ -861,30 +933,133 @@ search: ;/////////////////////////////////////////////////////////////////////// pop edi esi edx ecx ebx ret + +align 4 +proc copy_icon uses ebx ecx esi edi, buf_d:dword, buf_s:dword, ind:dword +;;------------------------------------------------------------------------------------------------;; +;> buf_d = pointer to destination buffer 24-bit +;> buf_s = pointer to source buffer 32-bit (with icons) +;> ind = icon index +;;------------------------------------------------------------------------------------------------;; +;< eax = pointer to destination buffer + icon size +;;------------------------------------------------------------------------------------------------;; + mov edi, [buf_d] + mov ecx, (18+ICON_LEFT_B)*ICON_TOP_B*3 + mov al, 0xff + rep stosb ; make top border + ; copy icon + mov esi, [ind] + imul esi, 18*18*4 + add esi, [buf_s] + mov ebx, 18 + .cycle0: + mov ecx, ICON_LEFT_B*3 + rep stosb ; make left border + mov ecx, 18 + @@: + movsw + movsb + inc esi ; skip transparent byte + loop @b + dec ebx + jnz .cycle0 + mov eax, edi + ret +endp + + +align 4 +proc img_to_gray, buf_rgb:dword, buf_g24:dword, pixels:dword +;;------------------------------------------------------------------------------------------------;; +; function for generating gray icons +;;------------------------------------------------------------------------------------------------;; +;> buf_rgb - buffer with input 24-bit color image +;> buf_g24 - buffer with output 24-bit gray image +;> pixels - number of pixels in the image +;;------------------------------------------------------------------------------------------------;; +pushad + mov esi, [buf_rgb] + mov edi, [buf_g24] + mov ecx, [pixels] + mov ebx, 3 + @@: + movzx eax, byte[esi] + movzx edx, byte[esi+1] + add eax, edx + movzx edx, byte[esi+2] + add eax, edx + xor edx, edx + div ebx + mov ah, al + mov word[edi], ax + mov byte[edi+2], al + add esi, 3 + add edi, 3 + loop @b +popad + ret +endp + + +align 4 +proc copy_icon_w uses ecx esi edi, buf_d:dword, buf_s:dword, ind:dword +;;------------------------------------------------------------------------------------------------;; +;> buf_d = pointer to destination buffer 32-bit +;> buf_s = pointer to source buffer 32-bit (with icons) +;> ind = icon index +;;------------------------------------------------------------------------------------------------;; +;< eax = pointer to destination buffer + icon size +;;------------------------------------------------------------------------------------------------;; + mov edi, [buf_d] + mov ecx, 18*18 + mov esi, [ind] + imul esi, ecx + shl esi, 2 + add esi, [buf_s] + rep movsd + mov eax, edi + + mov ecx, 18*18 + mov edi, [buf_d] + mov esi, [edi] ;copy transparent color + .cycle0: + cmp [edi], esi + jne @f + mov dword[edi], BT_COL + @@: + add edi, 4 + loop .cycle0 + ret +endp + ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;hed db 'FTP Client for KolibriOS',0 str_change db 'Change',0 str_disconnect db 'Disconnect',0 +str_show_log db 'Show log',0 +str_hide_log db 'Hide log',0 str_copy db 'Copy',0 str_mkd db 'MKD',0 str_dele db 'DELE',0 str_rdir db 'RDIR',0 str_rmd db 'RMD',0 str_abort db 'Cancel',0 -str_search db 'Search',0 +;str_search db 'Search',0 str_list db 'LIST',0 str_null db 0 +str_icon_18 db 'ICONS18',0 + ;---------------------- ; tree list elements ;---------------------- -tree1 tree_list 64, 500, tl_list_box_mode, 16, 16, \ - 0xffffff, BT_COL, 0x000000, TLIST1_X, 105, TLIST_SZ-16, 185, 14, 4,\ +tree1 tree_list 64, 500, tl_list_box_mode, 18+ICON_LEFT_B, 18+ICON_TOP_B, \ + 0xffffff, BT_COL, 0x10000000, TLIST1_X, 105, TLIST_SZ-16, 185, 15, 4,\ 0, el_focus, wScr, fun_on_enter -tree2 tree_list 64, 500, tl_list_box_mode, 16, 16, \ - 0xffffff, BT_COL, 0x000000, TLIST2_X, 105, TLIST_SZ-16, 185, 14, 4, \ +tree2 tree_list 64, 500, tl_list_box_mode, 18+ICON_LEFT_B, 18+ICON_TOP_B, \ + 0xffffff, BT_COL, 0x10000000, TLIST2_X, 105, TLIST_SZ-16, 185, 15, 4, \ 0, el_focus, wScr2, fun_on_enter2 ; editbox for mkd @@ -896,7 +1071,7 @@ edit_volume edit_box TLIST_SZ-60, TLIST1_X, 80, 0xffffff, 0x94AECE, 0, \ 0xAABBCC, 0x10000000, 99, root_dir, mouse_dd, 0 ; editbox for search -edit_search edit_box TLIST_SZ-60, TLIST2_X, 22, 0xffffff, 0x94AECE, 0, \ +edit_search edit_box TLIST_SZ-30, TLIST2_X, 22, 0xffffff, 0x94AECE, 0, \ 0xAABBCC, 0x10000000, 99, filter,mouse_dd, 0 ; A subsidiary structure for scrolling diff --git a/programs/network/ftpc/login_gui.inc b/programs/network/ftpc/login_gui.inc index 71c27df6e..388803278 100755 --- a/programs/network/ftpc/login_gui.inc +++ b/programs/network/ftpc/login_gui.inc @@ -27,7 +27,7 @@ login_gui: ;//////////////////////////////////////////////////////////////////// .get_username: ; in case of error when either login_gui.server_addr or ; login_gui.get_username is called, should resize window - mcall 67, WIN_X, WIN_Y, WIN_W, WIN_H ; resize to login gui window size + mcall SF_CHANGE_WINDOW, WIN_X, WIN_Y, WIN_W, WIN_H ; resize to login gui window size .redraw: call .draw @@ -44,22 +44,22 @@ login_gui: ;//////////////////////////////////////////////////////////////////// align 4 .draw: - mcall 12, 1 - mcall 48, 3, sc, 40 + mcall SF_REDRAW, SSF_BEGIN_DRAW + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, 40 edit_boxes_set_sys_color edit_usr,editboxes_end,sc mov edx, 0x34000000 or edx, [sc.work] - mcall 0, , , , 0x805080DD, str_title + mcall SF_CREATE_WINDOW, , , , 0x805080DD, str_title call .draw_editboxes ; draw "connect" button - mcall 8, <162,65>, <150,25>, 2, [sc.work_button] + mcall SF_DEFINE_BUTTON, <162,65>, <150,25>, 2, [sc.work_button] ; draw strings mov ecx, 0x90000000 or ecx, [sc.work_text] - mcall 4, <3, 8>, , gui_str_usr + mcall SF_DRAW_TEXT, <3, 8>, , gui_str_usr mcall , <3,PAD*1+8>, , gui_str_pass mcall , <3,PAD*2+8>, , gui_str_server mcall , <3,PAD*3+8>, , gui_str_port @@ -74,12 +74,12 @@ login_gui: ;//////////////////////////////////////////////////////////////////// mcall mov [str_error_addr], gui_str_null ; reset error string address - mcall 12, 2 + mcall SF_REDRAW, SSF_END_DRAW ret align 4 .still: - mcall 10 ; wait for event + mcall SF_WAIT_EVENT dec eax jz .redraw dec eax @@ -96,7 +96,7 @@ login_gui: ;//////////////////////////////////////////////////////////////////// jmp .still .button: - mcall 17 + mcall SF_GET_BUTTON dec ah jz .exit @@ -107,7 +107,7 @@ login_gui: ;//////////////////////////////////////////////////////////////////// jmp .still .key: - mcall 2 + mcall SF_GET_KEY cmp ah,13 je .connect @@ -122,12 +122,17 @@ login_gui: ;//////////////////////////////////////////////////////////////////// stdcall [edit_box_key], edit_path jmp .still - + .connect: - mcall 67, 35, 20, 830, 555 ; resize to main gui window's coordinates + mov esi, 555 + or [show_log],0 + jnz @f + sub esi, 160 + @@: + mcall SF_CHANGE_WINDOW, 35, 20, 830 ; resize to main gui window's coordinates cmp [param_server_addr], 0 - jne gui.main - + jne gui.main + mov [str_error_addr], gui_str_no_srvr jmp .redraw diff --git a/programs/network/ftpc/servercommands.inc b/programs/network/ftpc/servercommands.inc index d8275a7f1..607b3ec9e 100644 --- a/programs/network/ftpc/servercommands.inc +++ b/programs/network/ftpc/servercommands.inc @@ -190,10 +190,11 @@ data_loop: mov [filestruct.ptr], buf_buffer2 mov [filestruct.size], eax push eax - mcall 70, filestruct + mcall SF_FILE, filestruct test eax, eax jz @f call error_fs + add esp, 4 ; fix stack jmp close_datacon @@: pop eax @@ -204,7 +205,7 @@ data_loop: ; storing, send all data .stor: - mcall 70, filestruct + mcall SF_FILE, filestruct cmp eax, 6 ; end of file je .last_call test eax, eax ; error @@ -244,7 +245,7 @@ data_loop: mov ecx, eax ; eax is size of buffer received inc ecx add ecx, [size_fname] ; added old size to form new required size - mcall 68, 20, , [ptr_fname] ; realloc + mcall SF_SYS_MISC, SSF_MEM_REALLOC, , [ptr_fname] test eax, eax je error_heap mov [ptr_fname], eax ; eax contains the new block now diff --git a/programs/network/ftpc/usercommands.inc b/programs/network/ftpc/usercommands.inc index 2cba28ddc..28d4422a9 100644 --- a/programs/network/ftpc/usercommands.inc +++ b/programs/network/ftpc/usercommands.inc @@ -82,13 +82,13 @@ cmd_retr: mov ecx, 256-5 call set_filename - mov [filestruct.subfn], 2 ; create/rewrite file + mov [filestruct.subfn], SSF_CREATE_FILE ; create/rewrite file mov [filestruct.offset], 0 mov [filestruct.offset+4], 0 mov [filestruct.size], 0 mov [filestruct.ptr], 0 - mcall 70, filestruct + mcall SF_FILE, filestruct test eax, eax jz @f call error_fs @@ -96,7 +96,7 @@ cmd_retr: @@: ; Prepare to write to the file - mov [filestruct.subfn], 3 ; write to file + mov [filestruct.subfn], SSF_WRITE_FILE mov [operation], OPERATION_RETR ; Request the file from server @@ -138,7 +138,7 @@ cmd_stor: mov [operation], OPERATION_STOR ; get file size - mov [filestruct.subfn], 5 + mov [filestruct.subfn], SSF_GET_INFO mov [filestruct.offset], 0 mov [filestruct.offset+4], 0 mov [filestruct.size], 0 @@ -148,12 +148,12 @@ cmd_stor: mov ecx, 256-5 call set_filename - mcall 70, filestruct + mcall SF_FILE, filestruct mov eax, dword[folder_buf+32] ; supports file size upto 4GB mov [file_size], eax - mov [filestruct.subfn], 0 ; read file + mov [filestruct.subfn], SSF_READ_FILE ; mov [filestruct.offset], 0 ; mov [filestruct.offset+4], 0 mov [filestruct.size], BUFFERSIZE @@ -191,12 +191,12 @@ cmd_lcwd: mov byte[esi-1], 0 ; check whether entered path is valid (folder exists) - mov [filestruct2.subfn], 5 + mov [filestruct2.subfn], SSF_GET_INFO mov [filestruct2.offset], 0 mov [filestruct2.size], 0 mov [filestruct2.ptr], folder_buf mov [filestruct2.name], buf_cmd+5 - mcall 70, filestruct2 + mcall SF_FILE, filestruct2 test eax, eax jz @f cmp eax, 2 @@ -205,10 +205,10 @@ cmd_lcwd: jmp wait_for_usercommand @@: - mcall 30, 1, buf_cmd+5 ; set working directory + mcall SF_CURRENT_FOLDER, SSF_SET_CF, buf_cmd+5 ; set working directory .print: - mcall 30, 2, buf_cmd, 256 ; and read it again + mcall SF_CURRENT_FOLDER, SSF_GET_CF, buf_cmd, 256 ; and read it again icall eax, interface_addr, interface.print, str_lcwd, buf_cmd, str_newline jmp wait_for_usercommand