Fixed Telnet for net branch.

Not the most elegant sollution but at least it works now!

git-svn-id: svn://kolibrios.org@2539 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-04-02 12:06:31 +00:00
parent 38b226fb8d
commit f28853c51d

View File

@ -9,6 +9,9 @@ use32
dd 0 ; parameters dd 0 ; parameters
dd 0 ; path dd 0 ; path
__DEBUG__ equ 0
__DEBUG_LEVEL__ equ 1
BUFFERSIZE equ 4096 BUFFERSIZE equ 4096
; useful includes ; useful includes
@ -16,6 +19,7 @@ include '../macros.inc'
purge mov,add,sub purge mov,add,sub
include '../proc32.inc' include '../proc32.inc'
include '../dll.inc' include '../dll.inc'
include '../debug-fdo.inc'
include '../network.inc' include '../network.inc'
@ -109,12 +113,16 @@ main:
mcall 18, 3 mcall 18, 3
mainloop: mainloop:
DEBUGF 1, 'TELNET: Waiting for events\n'
mcall 10 mcall 10
DEBUGF 1, 'TELNET: EVENT %x !\n', eax
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0 mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
cmp eax, -1 cmp eax, -1
je mainloop je mainloop
DEBUGF 1, 'TELNET: got %u bytes of data !\n', eax
mov esi, buffer_ptr mov esi, buffer_ptr
lea edi, [esi + eax] lea edi, [esi + eax]
mov byte [edi], 0 mov byte [edi], 0
@ -128,53 +136,50 @@ mainloop:
jmp .scan_cmd jmp .scan_cmd
.no_cmd: .no_cmd:
push esi
cmp esi, buffer_ptr cmp esi, buffer_ptr
je .print_it je .print_loop
push edi DEBUGF 1, 'TELNET: sending data\n'
mov edx, buffer_ptr
push esi edi
sub esi, buffer_ptr sub esi, buffer_ptr
xor edi, edi mcall send, [socketnum], buffer_ptr, , 0
mcall send, [socketnum] pop edi esi
pop edi
.print_it: .print_loop:
mov esi, [esp] DEBUGF 1, 'TELNET: printloop\n'
@@:
cmp esi, edi cmp esi, edi
jge .last_print jae mainloop
cmp byte [esi], 0x1b ; escape character cmp byte [esi], 0x1b ; escape character
jne .print_byte
mov byte [esi], 0
inc esi inc esi
jne @f
cmp word [esi], 0x485b ; move cursor to beginning cmp word [esi], 0x485b ; move cursor to beginning
jne @f jne @f
inc esi
inc esi
DEBUGF 1, 'TELNET: resetting cursor \n'
mov byte [esi - 1], 0
call [con_write_asciiz]
push 0 push 0
push 0 push 0
call [con_set_cursor_pos] call [con_set_cursor_pos]
jmp .print_loop
inc esi
inc esi
push esi
jmp @r
.last_print:
call [con_write_asciiz]
jmp mainloop
; write newline and continue main loop
push str4
@@: @@:
call [con_write_asciiz] inc esi
jmp main jmp .print_loop
.print_byte:
push dword 1
push esi ; next string to print
inc esi
call [con_write_string]
jmp .print_loop
fail: fail:
push str5 push str5
jmp @b jmp @b
@ -214,6 +219,8 @@ sockaddr1:
.ip dd 0 .ip dd 0
rb 10 rb 10
include_debug_strings ; ALWAYS present in data section
; import ; import
@ -233,7 +240,10 @@ import console, \
con_gets, 'con_gets',\ con_gets, 'con_gets',\
con_cls, 'con_cls',\ con_cls, 'con_cls',\
con_getch2, 'con_getch2',\ con_getch2, 'con_getch2',\
con_set_cursor_pos, 'con_set_cursor_pos' con_set_cursor_pos, 'con_set_cursor_pos',\
con_write_string, 'con_write_string'
i_end: i_end:
socketnum dd ? socketnum dd ?