FTPc: some more bugfixes, added cwd command

git-svn-id: svn://kolibrios.org@3790 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-07-09 20:55:18 +00:00
parent 75cac16296
commit 0b02e4cfe7
3 changed files with 51 additions and 17 deletions

View File

@ -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,8 +340,11 @@ 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

View File

@ -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]

View File

@ -15,3 +15,17 @@ cmd_help:
call [con_write_asciiz]
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