Better SendFTP macro for FTPd

git-svn-id: svn://kolibrios.org@2635 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-04-20 10:02:31 +00:00
parent ea3b5f1721
commit 30a21108d8
2 changed files with 27 additions and 13 deletions

View File

@ -24,18 +24,6 @@ struct thread_data
buffer rb BUFFERSIZE buffer rb BUFFERSIZE
ends ends
macro sendFTP str {
local .string, .length, .label
xor edi, edi
mcall send, [ebp + thread_data.socketnum], .string, .length
jmp @f
.string db str, 13, 10
.length = $ - .string
@@:
}
;------------------------------------------------ ;------------------------------------------------
; parse_cmd ; parse_cmd
; ;
@ -88,6 +76,7 @@ parse_cmd: ; esi must point to command
align 4 align 4
iglobal
commands: ; all commands must be in uppercase commands: ; all commands must be in uppercase
dd 'ABOR', login_first, login_first, login_first, cmdABOR dd 'ABOR', login_first, login_first, login_first, cmdABOR
@ -124,6 +113,7 @@ commands: ; all commands must be in uppercase
dd 'TYPE', login_first, login_first, login_first, cmdTYPE dd 'TYPE', login_first, login_first, login_first, cmdTYPE
dd 'USER', cmdUSER, cmdUSER, cmdUSER, cmdUSER.2 dd 'USER', cmdUSER, cmdUSER, cmdUSER, cmdUSER.2
db 0 ; end marker db 0 ; end marker
endg
align 4 align 4
login_first: login_first:

View File

@ -6,6 +6,8 @@
; GPLv2 ; GPLv2
; ;
DEBUG = 0 ; if set to one, program will run in a single thread
BUFFERSIZE = 8192 BUFFERSIZE = 8192
; using multiple's of 4 ; using multiple's of 4
@ -60,6 +62,18 @@ include '../struct.inc'
include '../libio.inc' include '../libio.inc'
include '../network.inc' include '../network.inc'
macro sendFTP str {
local string, length
xor edi, edi
mcall send, [ebp + thread_data.socketnum], string, length
iglobal
string db str, 13, 10
length = $ - string
\}
}
include 'commands.inc' include 'commands.inc'
start: start:
@ -153,8 +167,12 @@ mainloop:
test eax, eax ; network event? test eax, eax ; network event?
jz .checkconsole jz .checkconsole
if DEBUG
jmp threadstart
else
mcall 51, 1, threadstart, 0 ; Start a new thread for every incoming connection mcall 51, 1, threadstart, 0 ; Start a new thread for every incoming connection
; NOTE: upon initialisation of the thread, stack will not be available! ; NOTE: upon initialisation of the thread, stack will not be available!
end if
jmp mainloop jmp mainloop
.checkconsole: .checkconsole:
@ -195,6 +213,10 @@ threadstart:
je thread_exit je thread_exit
mov [ebp + thread_data.socketnum], eax mov [ebp + thread_data.socketnum], eax
if DEBUG
mcall close, [socketnum] ; close the listening socket
end if
mov [ebp + thread_data.state], STATE_CONNECTED mov [ebp + thread_data.state], STATE_CONNECTED
mov [ebp + thread_data.permissions], 0 mov [ebp + thread_data.permissions], 0
mov [ebp + thread_data.mode], MODE_NOTREADY mov [ebp + thread_data.mode], MODE_NOTREADY
@ -384,7 +406,6 @@ import libini,\
ini.get_int, 'ini_get_int' ini.get_int, 'ini_get_int'
import libio,\ import libio,\
libio.init, 'lib_init',\
file.size, 'file_size',\ file.size, 'file_size',\
file.open, 'file_open',\ file.open, 'file_open',\
file.read, 'file_read',\ file.read, 'file_read',\
@ -394,6 +415,9 @@ import libio,\
file.find.close, 'file_find_close' file.find.close, 'file_find_close'
IncludeIGlobals
i_end: i_end:
diff16 "i_end", 0, $ diff16 "i_end", 0, $