TELNET_D.C
资源名称:ertos.rar [点击查看]
上传用户:sunrenlu
上传日期:2022-06-13
资源大小:1419k
文件大小:2k
源码类别:
操作系统开发
开发平台:
DOS
- #include <dos.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <rtos.h>
- #include <telnetd.h>
- #include <string.h>
- #include <parse.h>
- void hightext( char *s )
- {
- highvideo();
- cputs( s );
- lowvideo();
- }
- void telnet_thread( DWORD dummy )
- {
- teld_str *t;
- BYTE ch;
- char buf[ 128 ];
- char buf2[ 256 ];
- char *substring;
- int i;
- do {
- hightext( "listenning for a connectionrn");
- t = teld_listen( 0 );
- hightext("connection establishedrn");
- hightext("keys you type will be sent to client, Esc to exitrn");
- teld_puts( t, "WelcomernPress keys to send to serverrnESC moves to next sectionrn");
- do {
- ch = teld_getc( t );
- if ( ch == 255 ) break;
- if ( ch == 27 ) break; /* ESC */
- 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_puts(t, "Enter any old password: ");
- if ( teld_getpassword( t, buf, sizeof( buf ), 0 )) {
- teld_puts( t, "You enterred: ");
- teld_puts( t, buf );
- teld_puts( t, "rn");
- }
- do {
- teld_puts(t,"Now enter a text string or 'quit': ");
- if ( teld_gets(t, buf, sizeof( buf ), 0 )) {
- teld_puts( t, "rn Got: ");
- teld_puts( t, buf );
- teld_puts( t, "rn");
- /* show how to parse the string */
- for ( i = 1 ; i < 20 ; ++i ) {
- if ( ( substring = parse_arg( buf, i )) != NULL ) {
- sprintf( buf2, " arg %u : %srn", i, substring );
- teld_puts( t, buf2 );
- kfree( substring );
- }
- }
- } else break;
- } while ( stricmp( buf, "quit"));
- teld_close( t );
- hightext("rnclosed connectionrn");
- } while ( 1 );
- }
- main()
- {
- kdebug = 1;
- rt_init(100);
- sock_init(); /* initialize network */
- cputs("starting...rn");
- rt_newthread( telnet_thread, 0, 4096, 0, "worker" );
- do {
- /* nothing */
- rt_yield();
- } while ( 1 );
- }