Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2570 → Rev 2571

/kernel/branches/net/applications/ftpd/commands.inc
11,7 → 11,6
 
mov eax, [esi]
and eax, not 0x20202020 ; convert to upper case
; (also convert spaces to null)
mov edi, commands ; list of commands to scan
.scanloop:
cmp eax, [edi]
35,6 → 34,8
 
db 'ABOR'
dd cmdABOR
db 'CDUP'
dd cmdCDUP
db 'CWD', 0
dd cmdCWD
db 'DELE'
76,11 → 77,36
ret
 
align 4
cmdCDUP:
 
cmp byte [work_dir+1], 0
je .done
 
mov ecx, 1024
xor al, al
mov edi, work_dir+1024
repne scasb
std
dec edi
mov al,'/'
scasb
cld
mov byte[edi], 0
 
.done:
mcall send, [socketnum2], str250, str250.length, 0 ; command successful
 
 
ret
 
align 4
cmdCWD: ; Change Working Directory
 
sub ecx, 4
jb .err
add esi, 4
 
.scan:
mov edi, work_dir + 1
 
cmp byte [esi], '/'
94,6 → 120,9
lodsb
cmp al, 0x20
jb .done
cmp al, '.'
je .up
.continue:
stosb
loop .loop
.done:
108,6 → 137,14
 
ret
 
.up:
lodsb
cmp al, '.'
jne .continue
 
call cmdCDUP
jmp .scan
 
.err:
 
ret
125,17 → 162,20
jne @f
mcall connect, [datasocketnum], datasock, datasock.length
cmp eax, -1
je .err
je socketerror
mov [datasocketnum], eax
@@:
 
; Warn the client we're about to send the data
mcall send, [socketnum2], str150, str150.length, 0 ; here it comes..
 
; Create fpath from home_dir and work_dir
call create_path
 
push fpath
call [con_write_asciiz]
push str_newline
call [con_write_asciiz]
 
; Start the search
push FA_READONLY + FA_FOLDER
push FA_ANY
push str_mask
push fpath
call [file.find.first]
220,7 → 260,7
 
; insert a cr lf
.namedone:
mov ax, 0x0d0a
mov ax, 0x0a0d
stosw
 
; check next file
237,9 → 277,8
xor al, al
stosb
 
; print everything on the console
push buffer
call [con_write_asciiz]
; Warn the client we're about to send the data
mcall send, [socketnum2], str150, str150.length, 0 ; here it comes..
 
; and send it to the client
lea esi, [edi - buffer]
258,18 → 297,7
 
ret
 
.err:
pushd 0x0c
call [con_set_flags]
 
push str_err1
call [con_write_asciiz]
 
pushd 0x07
call [con_set_flags]
 
ret
 
align 4
cmdNLST:
 
327,7 → 355,7
stosd
mov al, ')'
stosb
mov ax, 0x0d0a
mov ax, 0x0a0d
stosw
xor al, al
stosb
426,22 → 454,49
align 4
cmdRETR:
 
sub ecx, 5
jb .cannot_open
 
cmp [mode], MODE_ACTIVE
jne @f
push esi
mcall connect, [datasocketnum], datasock, datasock.length
; cmp eax, -1
; je .err
pop esi
cmp eax, -1
je socketerror
mov [datasocketnum], eax
@@:
 
mcall send, [socketnum2], str150, str150.length, 0 ; here it comes..
push esi
call create_path
pop esi
dec edi
add esi, 5
mov ecx, 1024
.loop:
lodsb
cmp al, 0x20
jl .done
stosb
loop .loop
.done:
xor al, al
stosb
 
push fpath
call [con_write_asciiz]
push str_newline
call [con_write_asciiz]
 
push O_READ
push home_dir
push fpath
call [file.open]
; test eax, eax
; jz .cannot_open
test eax, eax
jz .cannot_open
 
mov ebx, eax
push eax
mcall send, [socketnum2], str150, str150.length, 0 ; here it comes..
pop ebx
 
.read_more:
push BUFFERSIZE
448,8 → 503,8
push buffer
push ebx
call [file.read]
; cmp eax, -1
; je .cannot_open
cmp eax, -1
je .cannot_open ; fixme: this is not the correct error
 
push eax
push ebx
457,8 → 512,8
mcall send, [datasocketnum], buffer, , 0
pop ebx
pop ecx
; cmp eax, -1
; je .socketerr
cmp eax, -1
je socketerror
 
cmp ecx, BUFFERSIZE
je .read_more
474,6 → 529,21
 
ret
 
.cannot_open:
 
pushd 0x0c
call [con_set_flags]
 
push str_notfound
call [con_write_asciiz]
 
pushd 0x07
call [con_set_flags]
 
mcall send, [socketnum2], str550, str550.length, 0 ; file not found
 
ret
 
align 4
cmdSTOR:
 
649,10 → 719,25
ret
 
 
align 4
socketerror:
 
pushd 0x0c
call [con_set_flags]
 
push str_sockerr
call [con_write_asciiz]
 
pushd 0x07
call [con_set_flags]
 
mcall send, [socketnum2], str425, str425.length, 0 ; data connection error
 
ret
 
 
 
 
str150 db '150 Here it comes...', 13, 10
.length = $ - str150
str200 db '200 Command OK.', 13, 10
/kernel/branches/net/applications/ftpd/ftpd.asm
6,7 → 6,7
; GPLv2
;
 
BUFFERSIZE = 4096
BUFFERSIZE = 8192
 
STATE_DISCONNECTED = 0
STATE_CONNECTED = 1
228,11 → 228,14
str_logged_in db 'Login ok',10,10,0
str_pass_ok db 'Password ok - Logged in',10,10,0
str_pwd db 'Current directory is "%s"\n',0
str_err1 db 'ERROR: cannot connect to remote socket',10,10,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_newline db 10,0
 
 
str_mask db '*', 0
 
 
298,7 → 301,7
home_dir db '/rd/1/', 0
rb 1024
work_dir rb 1024
fpath rb 2048
fpath rb 1024*3
 
type db ?
mode db ? ; active/passive