forked from KolibriOS/kolibrios
FTPc: some more bugfixes, added cwd command
git-svn-id: svn://kolibrios.org@3790 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
75cac16296
commit
0b02e4cfe7
@ -123,18 +123,27 @@ resolve:
|
|||||||
|
|
||||||
invoke con_write_asciiz, str12
|
invoke con_write_asciiz, str12
|
||||||
|
|
||||||
|
mov [offset], 0
|
||||||
|
|
||||||
wait_for_servercommand:
|
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 socket data
|
||||||
|
.receive:
|
||||||
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
||||||
inc eax
|
inc eax
|
||||||
jz socket_error
|
jz socket_error
|
||||||
dec eax
|
dec eax
|
||||||
jz wait_for_servercommand
|
jz wait_for_servercommand
|
||||||
|
|
||||||
; invoke con_write_asciiz, str_dbg2
|
mov [offset], 0
|
||||||
|
|
||||||
; extract commands, copy them to "s" buffer
|
; extract commands, copy them to "s" buffer
|
||||||
lea ecx, [eax + buffer_ptr] ; ecx = end pointer
|
lea ecx, [eax + buffer_ptr] ; ecx = end pointer
|
||||||
@ -151,18 +160,23 @@ wait_for_servercommand:
|
|||||||
stosb
|
stosb
|
||||||
jmp .byteloop
|
jmp .byteloop
|
||||||
.got_command: ; we have a newline check if its a command
|
.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
|
xor al, al
|
||||||
stosb
|
stosb
|
||||||
|
|
||||||
sub edi, s ; length
|
|
||||||
push edi
|
|
||||||
|
|
||||||
invoke con_set_flags, 0x03 ; change color
|
invoke con_set_flags, 0x03 ; change color
|
||||||
invoke con_write_asciiz, s ; print servercommand
|
invoke con_write_asciiz, s ; print servercommand
|
||||||
invoke con_write_asciiz, str4 ; newline
|
invoke con_write_asciiz, str4 ; newline
|
||||||
invoke con_set_flags, 0x07
|
invoke con_set_flags, 0x07
|
||||||
|
|
||||||
pop ecx
|
|
||||||
jmp server_parser ; parse command
|
jmp server_parser ; parse command
|
||||||
|
|
||||||
wait_for_usercommand:
|
wait_for_usercommand:
|
||||||
@ -188,6 +202,9 @@ wait_for_usercommand:
|
|||||||
cmp dword[s], "help"
|
cmp dword[s], "help"
|
||||||
je cmd_help
|
je cmd_help
|
||||||
|
|
||||||
|
cmp dword[s], "cwd "
|
||||||
|
je cmd_cwd
|
||||||
|
|
||||||
invoke con_write_asciiz, str_unknown
|
invoke con_write_asciiz, str_unknown
|
||||||
jmp wait_for_usercommand
|
jmp wait_for_usercommand
|
||||||
|
|
||||||
@ -280,9 +297,6 @@ str_help db "available commands:",10,10
|
|||||||
|
|
||||||
str_open db "opening data socket",10,0
|
str_open db "opening data socket",10,0
|
||||||
|
|
||||||
str_dbg db 'debug',10,0
|
|
||||||
str_dbg2 db 'debug2',10,0
|
|
||||||
|
|
||||||
sockaddr1:
|
sockaddr1:
|
||||||
dw AF_INET4
|
dw AF_INET4
|
||||||
.port dw 0x1500 ; 21
|
.port dw 0x1500 ; 21
|
||||||
@ -326,8 +340,11 @@ i_end:
|
|||||||
active_passive db ?
|
active_passive db ?
|
||||||
socketnum dd ?
|
socketnum dd ?
|
||||||
datasocket dd ?
|
datasocket dd ?
|
||||||
buffer_ptr rb 2*BUFFERSIZE
|
buffer_ptr rb BUFFERSIZE
|
||||||
|
buffer_ptr2 rb BUFFERSIZE
|
||||||
status db ?
|
status db ?
|
||||||
|
offset dd ?
|
||||||
|
size dd ?
|
||||||
|
|
||||||
s rb 1024
|
s rb 1024
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ server_parser:
|
|||||||
cmp dword[s], "220 "
|
cmp dword[s], "220 "
|
||||||
je welcome
|
je welcome
|
||||||
|
|
||||||
cmp dword[s], "226 "
|
; cmp dword[s], "226 "
|
||||||
; je list_ok
|
; je list_ok
|
||||||
|
|
||||||
cmp dword[s], "227 "
|
cmp dword[s], "227 "
|
||||||
@ -20,10 +20,13 @@ server_parser:
|
|||||||
cmp dword[s], "230 "
|
cmp dword[s], "230 "
|
||||||
je login_ok
|
je login_ok
|
||||||
|
|
||||||
|
; cmp dword[s], "250"
|
||||||
|
; je dir_ok
|
||||||
|
|
||||||
cmp dword[s], "331 "
|
cmp dword[s], "331 "
|
||||||
je pass
|
je pass
|
||||||
|
|
||||||
cmp dword[s], "421 "
|
; cmp dword[s], "421 "
|
||||||
; je timeout
|
; je timeout
|
||||||
|
|
||||||
cmp dword[s], "530" ; password incorrect
|
cmp dword[s], "530" ; password incorrect
|
||||||
@ -87,14 +90,14 @@ pasv_ok:
|
|||||||
|
|
||||||
data_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
|
inc eax
|
||||||
jz .fail
|
jz .fail
|
||||||
dec eax
|
dec eax
|
||||||
jz .fail
|
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:
|
.fail:
|
||||||
mcall close, [datasocket]
|
mcall close, [datasocket]
|
||||||
|
@ -15,3 +15,17 @@ cmd_help:
|
|||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
jmp wait_for_usercommand
|
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
|
Loading…
Reference in New Issue
Block a user