#include <net.h>
#include <rtos.h>
#include <stdio.h>
#include <mem.h>
#include <telnetd.h>


void dummythread( DWORD dummy )
{
    teld_str *t;
    BYTE ch;

    do {

        t = teld_listen( 23  );

        teld_write( t, "connected\r\n", 11 );
        do {
            ch = teld_getc( t );

            if ( ch == 255 ) break;
            if ( ch != 0 ) putch( ch );

            if ( kbhit() ) {
                ch = getch();

                /* break on ESC */
                if ( ch == 27 ) exit( 0 );

                teld_write( t, &ch, 1 );
            }
        } while ( 1 );
        teld_close( t );

    } while ( 1 );
}



main()
{
    kdebug = 1;
    rt_init(100);

    sock_init();            /* initialize network */

    cputs("starting... press ESC to exit\r\n");

    rt_newthread( dummythread, 0, 4096, 0, "worker" );
    do {
        /* nothing */
        rt_yield();
    } while ( 1 );
}



