From 30a21108d81b5766a24b5ad19a39116f793c8e0b Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Fri, 20 Apr 2012 10:02:31 +0000 Subject: [PATCH] Better SendFTP macro for FTPd git-svn-id: svn://kolibrios.org@2635 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../net/applications/ftpd/commands.inc | 14 ++-------- .../branches/net/applications/ftpd/ftpd.asm | 26 ++++++++++++++++++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/kernel/branches/net/applications/ftpd/commands.inc b/kernel/branches/net/applications/ftpd/commands.inc index fb828c9594..39ed24539c 100644 --- a/kernel/branches/net/applications/ftpd/commands.inc +++ b/kernel/branches/net/applications/ftpd/commands.inc @@ -24,18 +24,6 @@ struct thread_data buffer rb BUFFERSIZE 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 ; @@ -88,6 +76,7 @@ parse_cmd: ; esi must point to command align 4 +iglobal commands: ; all commands must be in uppercase 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 'USER', cmdUSER, cmdUSER, cmdUSER, cmdUSER.2 db 0 ; end marker +endg align 4 login_first: diff --git a/kernel/branches/net/applications/ftpd/ftpd.asm b/kernel/branches/net/applications/ftpd/ftpd.asm index 3142212565..0611d4aa1a 100644 --- a/kernel/branches/net/applications/ftpd/ftpd.asm +++ b/kernel/branches/net/applications/ftpd/ftpd.asm @@ -6,6 +6,8 @@ ; GPLv2 ; +DEBUG = 0 ; if set to one, program will run in a single thread + BUFFERSIZE = 8192 ; using multiple's of 4 @@ -60,6 +62,18 @@ include '../struct.inc' include '../libio.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' start: @@ -153,8 +167,12 @@ mainloop: test eax, eax ; network event? jz .checkconsole +if DEBUG + jmp threadstart +else mcall 51, 1, threadstart, 0 ; Start a new thread for every incoming connection ; NOTE: upon initialisation of the thread, stack will not be available! +end if jmp mainloop .checkconsole: @@ -195,6 +213,10 @@ threadstart: je thread_exit 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.permissions], 0 mov [ebp + thread_data.mode], MODE_NOTREADY @@ -384,7 +406,6 @@ import libini,\ ini.get_int, 'ini_get_int' import libio,\ - libio.init, 'lib_init',\ file.size, 'file_size',\ file.open, 'file_open',\ file.read, 'file_read',\ @@ -394,6 +415,9 @@ import libio,\ file.find.close, 'file_find_close' +IncludeIGlobals + + i_end: diff16 "i_end", 0, $