9,7 → 9,10 |
dd 0 ; parameters |
dd 0 ; path |
|
__DEBUG__ equ 0 |
__DEBUG_LEVEL__ equ 1 |
|
|
BUFFERSIZE equ 4096 |
; useful includes |
include '../macros.inc' |
16,6 → 19,7 |
purge mov,add,sub |
include '../proc32.inc' |
include '../dll.inc' |
include '../debug-fdo.inc' |
|
include '../network.inc' |
|
109,12 → 113,16 |
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 |
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 |
|
mov byte [esi - 1], 0 |
call [con_write_asciiz] |
DEBUGF 1, 'TELNET: resetting cursor \n' |
|
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,8 → 219,10 |
.ip dd 0 |
rb 10 |
|
include_debug_strings ; ALWAYS present in data section |
|
|
|
; import |
align 4 |
@IMPORT: |
233,7 → 240,10 |
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 ? |