diff --git a/programs/network/ftpc/ftpc.asm b/programs/network/ftpc/ftpc.asm index eedb1263f..3fe2bb9f3 100644 --- a/programs/network/ftpc/ftpc.asm +++ b/programs/network/ftpc/ftpc.asm @@ -123,18 +123,27 @@ resolve: invoke con_write_asciiz, str12 + mov [offset], 0 + wait_for_servercommand: -; invoke con_write_asciiz, str_dbg + cmp [offset], 0 + je .receive + mov esi, [offset] + mov edi, s + mov ecx, [size] + add ecx, esi + jmp .byteloop ; receive socket data + .receive: mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0 inc eax jz socket_error dec eax jz wait_for_servercommand -; invoke con_write_asciiz, str_dbg2 + mov [offset], 0 ; extract commands, copy them to "s" buffer lea ecx, [eax + buffer_ptr] ; ecx = end pointer @@ -151,18 +160,23 @@ wait_for_servercommand: stosb jmp .byteloop .got_command: ; we have a newline check if its a command + cmp esi, ecx + je .no_more_data + mov [offset], esi + sub ecx, esi + mov [size], ecx + jmp .go_cmd + .no_more_data: + mov [offset], 0 + .go_cmd: xor al, al stosb - sub edi, s ; length - push edi - invoke con_set_flags, 0x03 ; change color invoke con_write_asciiz, s ; print servercommand invoke con_write_asciiz, str4 ; newline invoke con_set_flags, 0x07 - pop ecx jmp server_parser ; parse command wait_for_usercommand: @@ -188,6 +202,9 @@ wait_for_usercommand: cmp dword[s], "help" je cmd_help + cmp dword[s], "cwd " + je cmd_cwd + invoke con_write_asciiz, str_unknown jmp wait_for_usercommand @@ -280,9 +297,6 @@ str_help db "available commands:",10,10 str_open db "opening data socket",10,0 -str_dbg db 'debug',10,0 -str_dbg2 db 'debug2',10,0 - sockaddr1: dw AF_INET4 .port dw 0x1500 ; 21 @@ -326,9 +340,12 @@ i_end: active_passive db ? socketnum dd ? datasocket dd ? -buffer_ptr rb 2*BUFFERSIZE +buffer_ptr rb BUFFERSIZE +buffer_ptr2 rb BUFFERSIZE status db ? +offset dd ? +size dd ? -s rb 1024 +s rb 1024 mem: diff --git a/programs/network/ftpc/servercommands.inc b/programs/network/ftpc/servercommands.inc index eb2cc8478..d12f87922 100644 --- a/programs/network/ftpc/servercommands.inc +++ b/programs/network/ftpc/servercommands.inc @@ -11,7 +11,7 @@ server_parser: cmp dword[s], "220 " je welcome - cmp dword[s], "226 " +; cmp dword[s], "226 " ; je list_ok cmp dword[s], "227 " @@ -20,10 +20,13 @@ server_parser: cmp dword[s], "230 " je login_ok +; cmp dword[s], "250" +; je dir_ok + cmp dword[s], "331 " je pass - cmp dword[s], "421 " +; cmp dword[s], "421 " ; je timeout cmp dword[s], "530" ; password incorrect @@ -87,14 +90,14 @@ pasv_ok: data_ok: - mcall recv, [datasocket], buffer_ptr, BUFFERSIZE, MSG_DONTWAIT ; fixme: use other buffer + mcall recv, [datasocket], buffer_ptr2, BUFFERSIZE, MSG_DONTWAIT inc eax jz .fail dec eax jz .fail - mov byte[buffer_ptr + eax], 0 + mov byte[buffer_ptr2 + eax], 0 - invoke con_write_asciiz, buffer_ptr + invoke con_write_asciiz, buffer_ptr2 .fail: mcall close, [datasocket] diff --git a/programs/network/ftpc/usercommands.inc b/programs/network/ftpc/usercommands.inc index db9ffe656..6cd08fd28 100644 --- a/programs/network/ftpc/usercommands.inc +++ b/programs/network/ftpc/usercommands.inc @@ -14,4 +14,18 @@ cmd_help: push str_help call [con_write_asciiz] - jmp wait_for_usercommand \ No newline at end of file + jmp wait_for_usercommand + +cmd_cwd: + + mov dword[s], "CWD " + + mov ecx, 256 + xor al, al + mov edi, s + repne scasb + lea esi, [edi - s - 1] + + mcall send, [socketnum], s, , 0 + + jmp wait_for_servercommand \ No newline at end of file