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