Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2891 → Rev 2892

/kernel/branches/net/applications/ftpd/commands.inc
279,6 → 279,54
ret
 
 
align 4
open_datasock:
 
cmp [ebp + thread_data.mode], MODE_PASSIVE_OK
je .start
 
; If we are in active mode, it's time to open a data socket..
cmp [ebp + thread_data.mode], MODE_ACTIVE
jne .not_active
mov ecx, [ebp + thread_data.datasocketnum]
lea edx, [ebp + thread_data.datasock]
mov esi, sizeof.thread_data.datasock
mcall connect
cmp eax, -1
jne .start
 
.socketerror:
add esp, 4
jmp socketerror
 
; If we are still in passive_wait, it's time we accept an incomming call..
.not_active:
cmp [ebp + thread_data.mode], MODE_PASSIVE_WAIT
jne .socketerror
 
.try_now:
mov ecx, [ebp + thread_data.passivesocknum]
lea edx, [ebp + thread_data.datasock]
mov esi, sizeof.thread_data.datasock
mcall accept
cmp eax, -1
jne .pasv_ok
mov [ebp + thread_data.mode], MODE_PASSIVE_FAILED ; assume that we will fail
mcall 23, 200
mcall accept
cmp eax, -1
je .socketerror
.pasv_ok:
mov [ebp + thread_data.datasocketnum], eax
mov [ebp + thread_data.mode], MODE_PASSIVE_OK
mcall close ; [ebp + thread_data.passivesocknum]
mov [ebp + thread_data.passivesocknum], -1
invoke con_write_asciiz, str_datasock
 
.start:
ret
 
 
;------------------------------------------------
; "ABOR"
;
425,44 → 473,8
test [ebp + thread_data.permissions], PERMISSION_EXEC
jz permission_denied
 
cmp [ebp + thread_data.mode], MODE_PASSIVE_OK
je .start
call open_datasock
 
; If we are in active mode, it's time to open a data socket..
cmp [ebp + thread_data.mode], MODE_ACTIVE
jne .not_active
mov ecx, [ebp + thread_data.datasocketnum]
lea edx, [ebp + thread_data.datasock]
mov esi, sizeof.thread_data.datasock
mcall connect
cmp eax, -1
je socketerror
jmp .start
 
; If we are still in passive_wait, it's time we accept an incomming call..
.not_active:
cmp [ebp + thread_data.mode], MODE_PASSIVE_WAIT
jne socketerror
.try_now:
mov ecx, [ebp + thread_data.passivesocknum]
lea edx, [ebp + thread_data.datasock]
mov esi, sizeof.thread_data.datasock
mcall accept
cmp eax, -1
jne .pasv_ok
mov [ebp + thread_data.mode], MODE_PASSIVE_FAILED ; assume that we will fail
mcall 23, 200
mcall accept
cmp eax, -1
je socketerror
.pasv_ok:
mov [ebp + thread_data.datasocketnum], eax
mov [ebp + thread_data.mode], MODE_PASSIVE_OK
mcall close ; [ebp + thread_data.passivesocknum]
mov [ebp + thread_data.passivesocknum], -1
invoke con_write_asciiz, str_datasock
 
.start:
; Create fpath from home_dir and work_dir
call create_path
 
687,10 → 699,10
align 4
cmdPASV:
 
cmp [ebp + thread_data.passivesocknum], -1
je @f
mcall close, [ebp + thread_data.passivesocknum] ; if there is still a socket open, close it
@@:
; cmp [ebp + thread_data.passivesocknum], -1
; je @f
; mcall close, [ebp + thread_data.passivesocknum] ; if there is still a socket open, close it
; @@:
 
; Open a new TCP socket
mcall socket, AF_INET4, SOCK_STREAM, 0
886,49 → 898,11
sub ecx, 5
jb .cannot_open
 
cmp [ebp + thread_data.mode], MODE_PASSIVE_OK
je .start
call open_datasock
 
; If we are in active mode, it's time to open a data socket..
cmp [ebp + thread_data.mode], MODE_ACTIVE
jne .not_active
mov ecx, [ebp + thread_data.datasocketnum]
lea edx, [ebp + thread_data.datasock]
mov esi, sizeof.thread_data.datasock
mcall connect
cmp eax, -1
je socketerror
jmp .start
 
; If we are still in passive_wait, it's time we accept an incomming call..
.not_active:
cmp [ebp + thread_data.mode], MODE_PASSIVE_WAIT
jne socketerror
mov [ebp + thread_data.mode], MODE_PASSIVE_FAILED ; assume that we will fail
.try_now:
mov ecx, [ebp + thread_data.passivesocknum]
lea edx, [ebp + thread_data.datasock]
mov esi, sizeof.thread_data.datasock
mcall accept
cmp eax, -1
jne .pasv_ok
mcall 23, 200
mcall accept
cmp eax, -1
je socketerror
.pasv_ok:
mov [ebp + thread_data.datasocketnum], eax
mov [ebp + thread_data.mode], MODE_PASSIVE_OK
mcall close ; [ebp + thread_data.passivesocknum]
mov [ebp + thread_data.passivesocknum], -1
invoke con_write_asciiz, str_datasock
 
.start:
call create_path
dec edi
add esi, 5
 
lea esi, [ebp + thread_data.buffer] ; FIXME
lea esi, [ebp + thread_data.buffer + 5]
mov ecx, 1024
.loop:
lodsb
961,6 → 935,8
cmp eax, -1
je .cannot_open ; FIXME: this is not the correct error
 
invoke con_write_asciiz, str2
 
push eax ebx
mov esi, eax
mov ecx, [ebp + thread_data.datasocketnum]
979,6 → 955,8
 
invoke file.close, ebx
 
invoke con_write_asciiz, str2b
 
mov [ebp + thread_data.mode], MODE_NOTREADY
mcall close, [ebp + thread_data.datasocketnum]
 
/kernel/branches/net/applications/ftpd/ftpd.asm
1,10 → 1,16
;
; Kolibrios FTP Daemon
;
; hidnplayr@gmail.com
;
; GPLv2
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ftpd.asm - FTP Daemon for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
DEBUG = 0 ; if set to one, program will run in a single thread
 
11,10 → 17,10
BUFFERSIZE = 8192
 
; using multiple's of 4
STATE_CONNECTED = 4*0
STATE_LOGIN = 4*1
STATE_LOGIN_FAIL = 4*2 ; When an invalid username was given
STATE_ACTIVE = 4*3
STATE_CONNECTED = 0*4
STATE_LOGIN = 1*4
STATE_LOGIN_FAIL = 2*4 ; When an invalid username was given
STATE_ACTIVE = 3*4
 
TYPE_UNDEF = 0