forked from KolibriOS/kolibrios
Some cosmetic changes in FTPd (net branch)
git-svn-id: svn://kolibrios.org@2585 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
953b8091f9
commit
70caf20c58
@ -81,10 +81,10 @@ commands: ; all commands must be in uppercase
|
||||
dd cmdPASS
|
||||
db 'PASV'
|
||||
dd cmdPASV
|
||||
db 'PWD', 0
|
||||
dd cmdPWD
|
||||
db 'PORT'
|
||||
dd cmdPORT
|
||||
db 'PWD', 0
|
||||
dd cmdPWD
|
||||
db 'QUIT'
|
||||
dd cmdQUIT
|
||||
db 'RETR'
|
||||
@ -97,8 +97,6 @@ commands: ; all commands must be in uppercase
|
||||
dd cmdTYPE
|
||||
db 'USER'
|
||||
dd cmdUSER
|
||||
db 'XPWD'
|
||||
dd cmdPWD
|
||||
db 0 ; end marker
|
||||
|
||||
|
||||
@ -112,24 +110,34 @@ cmdABOR:
|
||||
align 4
|
||||
cmdCDUP:
|
||||
|
||||
cmp byte [edx + thread_data.work_dir+1], 0
|
||||
cmp byte [edx + thread_data.work_dir+1], 0 ; are we in "/" ?
|
||||
je .done
|
||||
|
||||
mov ecx, 1024
|
||||
xor al, al
|
||||
lea edi, [edx + thread_data.work_dir+1024]
|
||||
lea edi, [edx + thread_data.work_dir]
|
||||
repne scasb
|
||||
std
|
||||
dec edi
|
||||
dec edi
|
||||
dec edi
|
||||
mov al,'/'
|
||||
scasb
|
||||
repne scasb
|
||||
cld
|
||||
mov byte[edi], 0
|
||||
mov byte[edi+1], 0
|
||||
|
||||
.done:
|
||||
; Print the new working dir on the console
|
||||
lea eax, [edx + thread_data.work_dir]
|
||||
push eax
|
||||
call [con_write_asciiz]
|
||||
push str_newline
|
||||
call [con_write_asciiz]
|
||||
|
||||
mcall send, [edx + thread_data.socketnum], str250, str250.length, 0 ; command successful
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
cmdCWD: ; Change Working Directory
|
||||
|
||||
@ -174,6 +182,13 @@ cmdCWD: ; Change Working Directory
|
||||
@@:
|
||||
mov byte [edi], 0
|
||||
|
||||
; Print the new working dir on the console
|
||||
lea eax, [edx + thread_data.work_dir]
|
||||
push eax
|
||||
call [con_write_asciiz]
|
||||
push str_newline
|
||||
call [con_write_asciiz]
|
||||
|
||||
mcall send, [edx + thread_data.socketnum], str250, str250.length, 0
|
||||
|
||||
ret
|
||||
@ -198,6 +213,7 @@ cmdDELE:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
cmdLIST:
|
||||
|
||||
@ -344,11 +360,7 @@ cmdLIST:
|
||||
; close the data socket..
|
||||
mov edx, [esp+4] ; thread_data pointer
|
||||
mcall close, [edx + thread_data.datasocketnum]
|
||||
|
||||
cmp [edx + thread_data.mode], MODE_PASSIVE_OK
|
||||
jne @f
|
||||
mov [edx + thread_data.mode], MODE_NOTREADY
|
||||
@@:
|
||||
|
||||
; And send "transfer ok" on the base connection
|
||||
mcall send, [edx + thread_data.socketnum], str226, str226.length, 0
|
||||
@ -448,6 +460,7 @@ cmdPASV:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
cmdPWD: ; Print Working Directory
|
||||
|
||||
@ -471,14 +484,20 @@ cmdPWD: ; Print Working Directory
|
||||
sub esi, edx
|
||||
mov ecx, [edx + thread_data.socketnum]
|
||||
lea edx, [edx + thread_data.buffer]
|
||||
mcall send, , , , 0
|
||||
xor edi, edi
|
||||
mcall send
|
||||
|
||||
; push work_dir
|
||||
; push str_pwd
|
||||
; call [con_printf]
|
||||
mov edx, [esp+4]
|
||||
; Print the new working dir on the console
|
||||
lea eax, [edx + thread_data.work_dir]
|
||||
push eax
|
||||
call [con_write_asciiz]
|
||||
push str_newline
|
||||
call [con_write_asciiz]
|
||||
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
cmdPORT:
|
||||
|
||||
@ -620,11 +639,7 @@ cmdRETR:
|
||||
je .read_more
|
||||
|
||||
mcall close, [edx + thread_data.datasocketnum]
|
||||
|
||||
cmp [edx + thread_data.mode], MODE_PASSIVE_OK
|
||||
jne @f
|
||||
mov [edx + thread_data.mode], MODE_PASSIVE_WAIT
|
||||
@@:
|
||||
mov [edx + thread_data.mode], MODE_NOTREADY
|
||||
|
||||
mcall send, [edx + thread_data.socketnum], str226, str226.length, 0 ; transfer ok
|
||||
|
||||
@ -684,7 +699,6 @@ cmdTYPE:
|
||||
mov [edx + thread_data.type], TYPE_EBDIC
|
||||
|
||||
.subtype:
|
||||
|
||||
cmp ecx, 8
|
||||
jb .non_print
|
||||
|
||||
@ -733,21 +747,21 @@ cmdTYPE:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
cmdUSER:
|
||||
|
||||
; TODO: check user and set home directory (and permissions)
|
||||
|
||||
mcall send, [edx + thread_data.socketnum], str331, str331.length, 0
|
||||
mov edx, [esp+4] ; thread_data pointer
|
||||
mov [edx + thread_data.state], STATE_LOGIN
|
||||
|
||||
mov byte [edx + thread_data.work_dir], "/"
|
||||
mov byte [edx + thread_data.work_dir+1], 0
|
||||
mov word [edx + thread_data.home_dir], "/" ; "/", 0
|
||||
mov word [edx + thread_data.work_dir], "/" ; "/", 0
|
||||
|
||||
push str_logged_in
|
||||
call [con_write_asciiz]
|
||||
|
||||
mcall send, [edx + thread_data.socketnum], str331, str331.length, 0 ; Now send me the password!
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ start:
|
||||
|
||||
; find path to main settings file
|
||||
mov edi, path ; Calculate the length of zero-terminated string
|
||||
xor al , al
|
||||
xor al, al
|
||||
mov ecx, 1024
|
||||
repne scasb
|
||||
dec edi
|
||||
@ -101,9 +101,9 @@ start:
|
||||
push str2
|
||||
call [con_write_asciiz]
|
||||
|
||||
;; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes,
|
||||
;; cmp eax, -1
|
||||
;; je opt_err
|
||||
; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes,
|
||||
; cmp eax, -1
|
||||
; je opt_err
|
||||
|
||||
mcall bind, [socketnum], sockaddr1, sockaddr1.length
|
||||
cmp eax, -1
|
||||
@ -132,6 +132,7 @@ mainloop:
|
||||
; NOTE: upon initialisation of the thread, stack will not be available!
|
||||
jmp mainloop
|
||||
|
||||
diff16 "threadstart", 0, $
|
||||
threadstart:
|
||||
mcall 68, 12, sizeof.thread_data ; allocate the thread data struct
|
||||
cmp eax, -1
|
||||
@ -142,8 +143,12 @@ threadstart:
|
||||
|
||||
mcall 40, 1 shl 7 ; we only want network events for this thread
|
||||
|
||||
pushd 0x03
|
||||
call [con_set_flags]
|
||||
push str8
|
||||
call [con_write_asciiz] ; print on the console that we have created the new thread successfully
|
||||
pushd 0x07
|
||||
call [con_set_flags]
|
||||
|
||||
mcall accept, [socketnum], sockaddr1, sockaddr1.length ; time to accept the awaiting connection..
|
||||
cmp eax, -1
|
||||
@ -187,8 +192,10 @@ threadloop:
|
||||
mov edx, [esp+4] ; pointer to thread_data
|
||||
mov byte [edx + thread_data.buffer + eax], 0 ; append received data with a 0 byte
|
||||
|
||||
pushd 0x0a ; print received data to console (in green color)
|
||||
pushd 0x02 ; print received data to console (in green color)
|
||||
call [con_set_flags]
|
||||
push str_newline
|
||||
call [con_write_asciiz]
|
||||
lea eax, [edx + thread_data.buffer]
|
||||
push eax
|
||||
call [con_write_asciiz]
|
||||
@ -244,22 +251,22 @@ thread_exit:
|
||||
title db 'KolibriOS FTP daemon 0.1', 0
|
||||
str1 db 'Starting FTP daemon on port %u', 0
|
||||
str2 db '.', 0
|
||||
str2b db ' OK!',10,10,0
|
||||
str3 db 'Listen error',10,10,0
|
||||
str4 db 'Bind error',10,10,0
|
||||
str2b db ' OK!',10,0
|
||||
str3 db 'Listen error',10,0
|
||||
str4 db 'Bind error',10,0
|
||||
;str5 db 'Setsockopt error.',10,10,0
|
||||
str6 db 'Could not open socket',10,10,0
|
||||
str6 db 'Could not open socket',10,0
|
||||
str7 db 'Got data!',10,10,0
|
||||
str8 db 10,'New thread created!',10,10,0
|
||||
str_bye db 10,'Closing thread!',10,10,0
|
||||
str8 db 10,'New thread created!',10,0
|
||||
str_bye db 10,'Closing thread!',10,0
|
||||
|
||||
str_logged_in db 'Login ok',10,10,0
|
||||
str_pass_ok db 'Password ok - Logged in',10,10,0
|
||||
str_logged_in db 'Login ok',10,0
|
||||
str_pass_ok db 'Password ok - Logged in',10,0
|
||||
str_pwd db 'Current directory is "%s"\n',0
|
||||
str_err2 db 'ERROR: cannot open directory',10,10,0
|
||||
str_datasock db 'Passive data socket connected!',10,10,0
|
||||
str_notfound db 'ERROR: file not found',10,10,0
|
||||
str_sockerr db 'ERROR: socket error',10,10,0
|
||||
str_err2 db 'ERROR: cannot open directory',10,0
|
||||
str_datasock db 'Passive data socket connected!',10,0
|
||||
str_notfound db 'ERROR: file not found',10,0
|
||||
str_sockerr db 'ERROR: socket error',10,0
|
||||
|
||||
str_newline db 10, 0
|
||||
str_mask db '*', 0
|
||||
|
Loading…
Reference in New Issue
Block a user