⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 termstat.c

📁 这是关于远程登陆TELNET 的源代码 已经测试过的。
💻 C
📖 第 1 页 / 共 2 页
字号:
# endif	/* KLUDGELINEMODE */	if (linemode && his_state_is_will(TELOPT_LINEMODE)) {		/*		 * If edit mode changed, send edit mode.		 */		 if (useeditmode != editmode) {			/*			 * Send along appropriate edit mode mask.			 */			(void) netoprintf("%c%c%c%c%c%c%c", IAC, SB,				TELOPT_LINEMODE, LM_MODE, useeditmode,				IAC, SE);			editmode = useeditmode;		}									/*		 * Check for changes to special characters in use.		 */		start_slc(0);		check_slc();		(void) end_slc(0);	}done:	if (need_will_echo)		send_will(TELOPT_ECHO, 1);	/*	 * Some things should be deferred until after the pty state has	 * been set by the local process.  Do those things that have been	 * deferred now.  This only happens once.	 */	if (_terminit == 0) {		_terminit = 1;		defer_terminit();	}	netflush();	set_termbuf();	return;}  /* end of localstat */#endif	/* LINEMODE *//* * clientstat * * Process linemode related requests from the client. * Client can request a change to only one of linemode, editmode or slc's * at a time, and if using kludge linemode, then only linemode may be * affected. */void clientstat(register int code, register int parm1, register int parm2){	/*	 * Get a copy of terminal characteristics.	 */	init_termbuf();	/*	 * Process request from client. code tells what it is.	 */	switch (code) {#ifdef	LINEMODE	case TELOPT_LINEMODE:		/*		 * Don't do anything unless client is asking us to change		 * modes.		 */		uselinemode = (parm1 == WILL);		if (uselinemode != linemode) {# ifdef	KLUDGELINEMODE			/*			 * If using kludge linemode, make sure that			 * we can do what the client asks.			 * We can not turn off linemode if alwayslinemode			 * and the ICANON bit is set.			 */			if (lmodetype == KLUDGE_LINEMODE) {				if (alwayslinemode && tty_isediting()) {					uselinemode = 1;				}			}					/*			 * Quit now if we can't do it.			 */			if (uselinemode == linemode)				return;			/*			 * If using real linemode and linemode is being			 * turned on, send along the edit mode mask.			 */			if (lmodetype == REAL_LINEMODE && uselinemode)# else	/* KLUDGELINEMODE */			if (uselinemode)# endif	/* KLUDGELINEMODE */			{				useeditmode = 0;				if (tty_isediting())					useeditmode |= MODE_EDIT;				if (tty_istrapsig)					useeditmode |= MODE_TRAPSIG;				if (tty_issofttab())					useeditmode |= MODE_SOFT_TAB;				if (tty_islitecho())					useeditmode |= MODE_LIT_ECHO;				(void) netoprintf("%c%c%c%c%c%c%c", IAC,					SB, TELOPT_LINEMODE, LM_MODE,							useeditmode, IAC, SE);				editmode = useeditmode;			}			tty_setlinemode(uselinemode);			linemode = uselinemode;		}		break;		case LM_MODE:	    {		register int ack, changed;		/*		 * Client has sent along a mode mask.  If it agrees with		 * what we are currently doing, ignore it; if not, it could		 * be viewed as a request to change.  Note that the server		 * will change to the modes in an ack if it is different from		 * what we currently have, but we will not ack the ack.		 */		 useeditmode &= MODE_MASK;		 ack = (useeditmode & MODE_ACK);		 useeditmode &= ~MODE_ACK;		 if (changed = (useeditmode ^ editmode)) {			/*			 * This check is for a timing problem.  If the			 * state of the tty has changed (due to the user			 * application) we need to process that info			 * before we write in the state contained in the			 * ack!!!  This gets out the new MODE request,			 * and when the ack to that command comes back			 * we'll set it and be in the right mode.			 */			if (ack)				localstat();			if (changed & MODE_EDIT)				tty_setedit(useeditmode & MODE_EDIT);			if (changed & MODE_TRAPSIG)				tty_setsig(useeditmode & MODE_TRAPSIG);			if (changed & MODE_SOFT_TAB)				tty_setsofttab(useeditmode & MODE_SOFT_TAB);			if (changed & MODE_LIT_ECHO)				tty_setlitecho(useeditmode & MODE_LIT_ECHO);			set_termbuf(); 			if (!ack) { 				(void) netoprintf("%c%c%c%c%c%c%c", IAC,					SB, TELOPT_LINEMODE, LM_MODE, 					useeditmode|MODE_ACK, 					IAC, SE); 			} 					editmode = useeditmode;		}		break;	    }  /* end of case LM_MODE */#endif	/* LINEMODE */	case TELOPT_NAWS:#ifdef	TIOCSWINSZ	    {		struct winsize ws;		def_col = parm1;		def_row = parm2;#ifdef	LINEMODE		/*		 * Defer changing window size until after terminal is		 * initialized.		 */		if (terminit() == 0)			return;#endif	/* LINEMODE */		/*		 * Change window size as requested by client.		 */		ws.ws_col = parm1;		ws.ws_row = parm2;		(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);	    }#endif	/* TIOCSWINSZ */				break;		case TELOPT_TSPEED:	    {		def_tspeed = parm1;		def_rspeed = parm2;#ifdef	LINEMODE		/*		 * Defer changing the terminal speed.		 */		if (terminit() == 0)			return;#endif	/* LINEMODE */		/*		 * Change terminal speed as requested by client.		 * We set the receive speed first, so that if we can't		 * store seperate receive and transmit speeds, the transmit		 * speed will take precedence.		 */		tty_rspeed(parm2);		tty_tspeed(parm1);		set_termbuf();		break;	    }  /* end of case TELOPT_TSPEED */	default:		/* What? */		break;	}  /* end of switch */	netflush();}  /* end of clientstat */#ifdef	LINEMODE/* * defer_terminit * * Some things should not be done until after the login process has started * and all the pty modes are set to what they are supposed to be.  This * function is called when the pty state has been processed for the first time.  * It calls other functions that do things that were deferred in each module. */	voiddefer_terminit(){	/*	 * local stuff that got deferred.	 */	if (def_tspeed != -1) {		clientstat(TELOPT_TSPEED, def_tspeed, def_rspeed);		def_tspeed = def_rspeed = 0;	}#ifdef	TIOCSWINSZ	if (def_col || def_row) {		struct winsize ws;		bzero((char *)&ws, sizeof(ws));		ws.ws_col = def_col;		ws.ws_row = def_row;		(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);	}#endif	/*	 * The only other module that currently defers anything.	 */	deferslc();}  /* end of defer_terminit *//* * terminit * * Returns true if the pty state has been processed yet. */	intterminit(){	return _terminit;}  /* end of terminit */#endif	/* LINEMODE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -