xref: /original-bsd/libexec/telnetd/termstat.c (revision 17cc352b)
186530481Sborman /*
286530481Sborman  * Copyright (c) 1989 Regents of the University of California.
386530481Sborman  * All rights reserved.
486530481Sborman  *
586530481Sborman  * Redistribution and use in source and binary forms are permitted
686530481Sborman  * provided that the above copyright notice and this paragraph are
786530481Sborman  * duplicated in all such forms and that any documentation,
886530481Sborman  * advertising materials, and other materials related to such
986530481Sborman  * distribution and use acknowledge that the software was developed
1086530481Sborman  * by the University of California, Berkeley.  The name of the
1186530481Sborman  * University may not be used to endorse or promote products derived
1286530481Sborman  * from this software without specific prior written permission.
1386530481Sborman  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1486530481Sborman  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1586530481Sborman  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1686530481Sborman  */
1786530481Sborman 
1886530481Sborman #ifndef lint
19*17cc352bSborman static char sccsid[] = "@(#)termstat.c	5.4 (Berkeley) 02/28/90";
2086530481Sborman #endif /* not lint */
2186530481Sborman 
2286530481Sborman #include "telnetd.h"
2386530481Sborman 
2486530481Sborman /*
2586530481Sborman  * local variables
2686530481Sborman  */
2786530481Sborman #ifdef	LINEMODE
2886530481Sborman static int _terminit = 0;
2986530481Sborman static int def_tspeed = -1, def_rspeed = -1;
3086530481Sborman #ifdef	TIOCSWINSZ
3186530481Sborman static int def_row = 0, def_col = 0;
3286530481Sborman #endif
3386530481Sborman #endif	LINEMODE
3486530481Sborman 
35*17cc352bSborman #if	defined(CRAY2) && defined(UNICOS5)
3686530481Sborman int	newmap = 1;	/* nonzero if \n maps to ^M^J */
3786530481Sborman #endif
3886530481Sborman 
3986530481Sborman #ifdef	LINEMODE
4086530481Sborman /*
4186530481Sborman  * localstat
4286530481Sborman  *
4386530481Sborman  * This function handles all management of linemode.
4486530481Sborman  *
4586530481Sborman  * Linemode allows the client to do the local editing of data
4686530481Sborman  * and send only complete lines to the server.  Linemode state is
4786530481Sborman  * based on the state of the pty driver.  If the pty is set for
4886530481Sborman  * external processing, then we can use linemode.  Further, if we
4986530481Sborman  * can use real linemode, then we can look at the edit control bits
5086530481Sborman  * in the pty to determine what editing the client should do.
5186530481Sborman  *
5286530481Sborman  * Linemode support uses the following state flags to keep track of
5386530481Sborman  * current and desired linemode state.
5486530481Sborman  *	alwayslinemode : true if -l was specified on the telnetd
5586530481Sborman  * 	command line.  It means to have linemode on as much as
5686530481Sborman  *	possible.
5786530481Sborman  *
5886530481Sborman  * 	lmodetype: signifies whether the client can
5986530481Sborman  *	handle real linemode, or if use of kludgeomatic linemode
6086530481Sborman  *	is preferred.  It will be set to one of the following:
6186530481Sborman  *		REAL_LINEMODE : use linemode option
6286530481Sborman  *		KLUDGE_LINEMODE : use kludge linemode
6386530481Sborman  *		NO_LINEMODE : client is ignorant of linemode
6486530481Sborman  *
6586530481Sborman  *	linemode, uselinemode : linemode is true if linemode
6686530481Sborman  *	is currently on, uselinemode is the state that we wish
6786530481Sborman  *	to be in.  If another function wishes to turn linemode
6886530481Sborman  *	on or off, it sets or clears uselinemode.
6986530481Sborman  *
7086530481Sborman  *	editmode, useeditmode : like linemode/uselinemode, but
7186530481Sborman  *	these contain the edit mode states (edit and trapsig).
7286530481Sborman  *
7386530481Sborman  * The state variables correspond to some of the state information
7486530481Sborman  * in the pty.
7586530481Sborman  *	linemode:
7686530481Sborman  *		In real linemode, this corresponds to whether the pty
7786530481Sborman  *		expects external processing of incoming data.
7886530481Sborman  *		In kludge linemode, this more closely corresponds to the
7986530481Sborman  *		whether normal processing is on or not.  (ICANON in
8086530481Sborman  *		system V, or COOKED mode in BSD.)
8186530481Sborman  *		If the -l option was specified (alwayslinemode), then
8286530481Sborman  *		an attempt is made to force external processing on at
8386530481Sborman  *		all times.
8486530481Sborman  *
8586530481Sborman  * The following heuristics are applied to determine linemode
8686530481Sborman  * handling within the server.
8786530481Sborman  *	1) Early on in starting up the server, an attempt is made
8886530481Sborman  *	   to negotiate the linemode option.  If this succeeds
8986530481Sborman  *	   then lmodetype is set to REAL_LINEMODE and all linemode
9086530481Sborman  *	   processing occurs in the context of the linemode option.
9186530481Sborman  *	2) If the attempt to negotiate the linemode option failed,
9286530481Sborman  *	   then we try to use kludge linemode.  We test for this
9386530481Sborman  *	   capability by sending "do Timing Mark".  If a positive
9486530481Sborman  *	   response comes back, then we assume that the client
9586530481Sborman  *	   understands kludge linemode (ech!) and the
9686530481Sborman  *	   lmodetype flag is set to KLUDGE_LINEMODE.
9786530481Sborman  *	3) Otherwise, linemode is not supported at all and
9886530481Sborman  *	   lmodetype remains set to NO_LINEMODE (which happens
9986530481Sborman  *	   to be 0 for convenience).
10086530481Sborman  *	4) At any time a command arrives that implies a higher
10186530481Sborman  *	   state of linemode support in the client, we move to that
10286530481Sborman  *	   linemode support.
10386530481Sborman  *
10486530481Sborman  * A short explanation of kludge linemode is in order here.
10586530481Sborman  *	1) The heuristic to determine support for kludge linemode
10686530481Sborman  *	   is to send a do timing mark.  We assume that a client
10786530481Sborman  *	   that supports timing marks also supports kludge linemode.
10886530481Sborman  *	   A risky proposition at best.
10986530481Sborman  *	2) Further negotiation of linemode is done by changing the
11086530481Sborman  *	   the server's state regarding SGA.  If server will SGA,
11186530481Sborman  *	   then linemode is off, if server won't SGA, then linemode
11286530481Sborman  *	   is on.
11386530481Sborman  */
11486530481Sborman localstat()
11586530481Sborman {
11686530481Sborman 	void netflush();
11786530481Sborman 
118*17cc352bSborman #ifdef	defined(CRAY2) && defined(UNICOS5)
11986530481Sborman 	/*
12086530481Sborman 	 * Keep track of that ol' CR/NL mapping while we're in the
12186530481Sborman 	 * neighborhood.
12286530481Sborman 	 */
12386530481Sborman 	newmap = tty_isnewmap();
124*17cc352bSborman #endif	defined(CRAY2) && defined(UNICOS5)
12586530481Sborman 
12686530481Sborman 	/*
12786530481Sborman 	 * Check for state of BINARY options.
12886530481Sborman 	 */
12986530481Sborman 	if (tty_isbinaryin()) {
13086530481Sborman 		if (hiswants[TELOPT_BINARY] == OPT_NO)
131a09b88c8Sborman 			send_do(TELOPT_BINARY, 1);
13286530481Sborman 	} else {
13386530481Sborman 		if (hiswants[TELOPT_BINARY] == OPT_YES)
134a09b88c8Sborman 			send_dont(TELOPT_BINARY, 1);
13586530481Sborman 	}
13686530481Sborman 
13786530481Sborman 	if (tty_isbinaryout()) {
13886530481Sborman 		if (mywants[TELOPT_BINARY] == OPT_NO)
139a09b88c8Sborman 			send_will(TELOPT_BINARY, 1);
14086530481Sborman 	} else {
14186530481Sborman 		if (mywants[TELOPT_BINARY] == OPT_YES)
142a09b88c8Sborman 			send_wont(TELOPT_BINARY, 1);
14386530481Sborman 	}
14486530481Sborman 
14586530481Sborman 	/*
14686530481Sborman 	 * Check for changes to flow control if client supports it.
14786530481Sborman 	 */
14886530481Sborman 	if (hisopts[TELOPT_LFLOW] == OPT_YES) {
14986530481Sborman 		if (tty_flowmode() != flowmode) {
15086530481Sborman 			flowmode = tty_flowmode();
15186530481Sborman 			(void) sprintf(nfrontp, "%c%c%c%c%c%c", IAC, SB,
15286530481Sborman 				TELOPT_LFLOW, flowmode, IAC, SE);
15386530481Sborman 			nfrontp += 6;
15486530481Sborman 		}
15586530481Sborman 	}
15686530481Sborman 
15786530481Sborman 	/*
15886530481Sborman 	 * Check linemode on/off state
15986530481Sborman 	 */
16086530481Sborman 	uselinemode = tty_linemode();
16186530481Sborman 
16286530481Sborman 	/*
16386530481Sborman 	 * If alwayslinemode is on, and pty is changing to turn it off, then
16486530481Sborman 	 * force linemode back on.
16586530481Sborman 	 */
16686530481Sborman 	if (alwayslinemode && linemode && !uselinemode) {
16786530481Sborman 		uselinemode = 1;
16886530481Sborman 		tty_setlinemode(uselinemode);
16986530481Sborman 	}
17086530481Sborman 
17186530481Sborman # ifdef	KLUDGELINEMODE
17286530481Sborman 	/*
17386530481Sborman 	 * If using kludge linemode and linemode is desired, it can't
17486530481Sborman 	 * be done if normal line editing is not available on the
17586530481Sborman 	 * pty.  This becomes the test for linemode on/off when
17686530481Sborman 	 * using kludge linemode.
17786530481Sborman 	 */
178*17cc352bSborman 	if (lmodetype == KLUDGE_LINEMODE && uselinemode && tty_israw()) {
17986530481Sborman 		uselinemode = 0;
180*17cc352bSborman 		tty_setlinemode(uselinemode);
181*17cc352bSborman 	}
18286530481Sborman # endif	/* KLUDGELINEMODE */
18386530481Sborman 
18486530481Sborman 	/*
18586530481Sborman 	 * Do echo mode handling as soon as we know what the
18686530481Sborman 	 * linemode is going to be.
18786530481Sborman 	 * If the pty has echo turned off, then tell the client that
18886530481Sborman 	 * the server will echo.  If echo is on, then the server
18986530481Sborman 	 * will echo if in character mode, but in linemode the
19086530481Sborman 	 * client should do local echoing.  The state machine will
19186530481Sborman 	 * not send anything if it is unnecessary, so don't worry
19286530481Sborman 	 * about that here.
19386530481Sborman 	 */
19486530481Sborman 	if (tty_isecho() && uselinemode)
195a09b88c8Sborman 		send_wont(TELOPT_ECHO, 1);
19686530481Sborman 	else
197a09b88c8Sborman 		send_will(TELOPT_ECHO, 1);
19886530481Sborman 
19986530481Sborman 	/*
20086530481Sborman 	 * If linemode is being turned off, send appropriate
20186530481Sborman 	 * command and then we're all done.
20286530481Sborman 	 */
20386530481Sborman 	 if (!uselinemode && linemode) {
20486530481Sborman # ifdef	KLUDGELINEMODE
20586530481Sborman 		if (lmodetype == REAL_LINEMODE)
20686530481Sborman # endif	/* KLUDGELINEMODE */
207a09b88c8Sborman 			send_dont(TELOPT_LINEMODE, 1);
20886530481Sborman # ifdef	KLUDGELINEMODE
20986530481Sborman 		else if (lmodetype == KLUDGE_LINEMODE)
210e2235ae6Sborman 			send_will(TELOPT_SGA, 1);
21186530481Sborman # endif	/* KLUDGELINEMODE */
21286530481Sborman 		linemode = uselinemode;
21386530481Sborman 		goto done;
21486530481Sborman 	}
21586530481Sborman 
21686530481Sborman # ifdef	KLUDGELINEMODE
21786530481Sborman 	/*
21886530481Sborman 	 * If using real linemode check edit modes for possible later use.
21986530481Sborman 	 */
22086530481Sborman 	if (lmodetype == REAL_LINEMODE) {
22186530481Sborman # endif	/* KLUDGELINEMODE */
22286530481Sborman 		useeditmode = 0;
22386530481Sborman 		if (tty_isediting())
22486530481Sborman 			useeditmode |= MODE_EDIT;
22586530481Sborman 		if (tty_istrapsig())
22686530481Sborman 			useeditmode |= MODE_TRAPSIG;
22786530481Sborman # ifdef	KLUDGELINEMODE
22886530481Sborman 	}
22986530481Sborman # endif	/* KLUDGELINEMODE */
23086530481Sborman 
23186530481Sborman 	/*
23286530481Sborman 	 * Negotiate linemode on if pty state has changed to turn it on.
23386530481Sborman 	 * Send appropriate command and send along edit mode, then all done.
23486530481Sborman 	 */
23586530481Sborman 	if (uselinemode && !linemode) {
23686530481Sborman # ifdef	KLUDGELINEMODE
23786530481Sborman 		if (lmodetype == KLUDGE_LINEMODE) {
238a09b88c8Sborman 			send_wont(TELOPT_SGA, 1);
23986530481Sborman 		} else if (lmodetype == REAL_LINEMODE) {
24086530481Sborman # endif	/* KLUDGELINEMODE */
241a09b88c8Sborman 			send_do(TELOPT_LINEMODE, 1);
24286530481Sborman 			/* send along edit modes */
24386530481Sborman 			(void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC, SB,
24486530481Sborman 				TELOPT_LINEMODE, LM_MODE, useeditmode,
24586530481Sborman 				IAC, SE);
24686530481Sborman 			nfrontp += 7;
24786530481Sborman 			editmode = useeditmode;
24886530481Sborman # ifdef	KLUDGELINEMODE
24986530481Sborman 		}
25086530481Sborman # endif	/* KLUDGELINEMODE */
25186530481Sborman 		linemode = uselinemode;
25286530481Sborman 		goto done;
25386530481Sborman 	}
25486530481Sborman 
25586530481Sborman # ifdef	KLUDGELINEMODE
25686530481Sborman 	/*
25786530481Sborman 	 * None of what follows is of any value if not using
25886530481Sborman 	 * real linemode.
25986530481Sborman 	 */
26086530481Sborman 	if (lmodetype < REAL_LINEMODE)
26186530481Sborman 		goto done;
26286530481Sborman # endif	/* KLUDGELINEMODE */
26386530481Sborman 
26486530481Sborman 	if (linemode) {
26586530481Sborman 		/*
26686530481Sborman 		 * If edit mode changed, send edit mode.
26786530481Sborman 		 */
26886530481Sborman 		 if (useeditmode != editmode) {
26986530481Sborman 			/*
27086530481Sborman 			 * Send along appropriate edit mode mask.
27186530481Sborman 			 */
27286530481Sborman 			(void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC, SB,
27386530481Sborman 				TELOPT_LINEMODE, LM_MODE, useeditmode,
27486530481Sborman 				IAC, SE);
27586530481Sborman 			nfrontp += 7;
27686530481Sborman 			editmode = useeditmode;
27786530481Sborman 		}
27886530481Sborman 
27986530481Sborman 
28086530481Sborman 		/*
28186530481Sborman 		 * Check for changes to special characters in use.
28286530481Sborman 		 */
28386530481Sborman 		start_slc(0);
28486530481Sborman 		check_slc();
28586530481Sborman 		end_slc(0);
28686530481Sborman 	}
28786530481Sborman 
28886530481Sborman done:
28986530481Sborman 	/*
29086530481Sborman 	 * Some things should be deferred until after the pty state has
29186530481Sborman 	 * been set by the local process.  Do those things that have been
29286530481Sborman 	 * deferred now.  This only happens once.
29386530481Sborman 	 */
29486530481Sborman 	if (_terminit == 0) {
29586530481Sborman 		_terminit = 1;
29686530481Sborman 		defer_terminit();
29786530481Sborman 	}
29886530481Sborman 
29986530481Sborman 	netflush();
30086530481Sborman 	set_termbuf();
30186530481Sborman 	return;
30286530481Sborman 
30386530481Sborman }  /* end of localstat */
30486530481Sborman #endif	/* LINEMODE */
30586530481Sborman 
30686530481Sborman 
30786530481Sborman /*
30886530481Sborman  * clientstat
30986530481Sborman  *
31086530481Sborman  * Process linemode related requests from the client.
31186530481Sborman  * Client can request a change to only one of linemode, editmode or slc's
31286530481Sborman  * at a time, and if using kludge linemode, then only linemode may be
31386530481Sborman  * affected.
31486530481Sborman  */
31586530481Sborman clientstat(code, parm1, parm2)
31686530481Sborman register int code, parm1, parm2;
31786530481Sborman {
31886530481Sborman 	void netflush();
31986530481Sborman 
32086530481Sborman 	/*
32186530481Sborman 	 * Get a copy of terminal characteristics.
32286530481Sborman 	 */
32386530481Sborman 	init_termbuf();
32486530481Sborman 
32586530481Sborman 	/*
32686530481Sborman 	 * Process request from client. code tells what it is.
32786530481Sborman 	 */
32886530481Sborman 	switch (code) {
32986530481Sborman #ifdef	LINEMODE
33086530481Sborman 	case TELOPT_LINEMODE:
33186530481Sborman 		/*
33286530481Sborman 		 * Don't do anything unless client is asking us to change
33386530481Sborman 		 * modes.
33486530481Sborman 		 */
33586530481Sborman 		uselinemode = (parm1 == WILL);
33686530481Sborman 		if (uselinemode != linemode) {
33786530481Sborman # ifdef	KLUDGELINEMODE
33886530481Sborman 			/*
33986530481Sborman 			 * If using kludge linemode, make sure that
34086530481Sborman 			 * we can do what the client asks.
34186530481Sborman 			 * We can not turn off linemode if alwayslinemode
342a09b88c8Sborman 			 * and the ICANON bit is set.
34386530481Sborman 			 */
34486530481Sborman 			if (lmodetype == KLUDGE_LINEMODE) {
345a09b88c8Sborman 				if (alwayslinemode && tty_isediting()) {
34686530481Sborman 					uselinemode = 1;
34786530481Sborman 				}
34886530481Sborman 			}
34986530481Sborman 
35086530481Sborman 			/*
35186530481Sborman 			 * Quit now if we can't do it.
35286530481Sborman 			 */
35386530481Sborman 			if (uselinemode == linemode)
35486530481Sborman 				return;
35586530481Sborman 
35686530481Sborman 			/*
35786530481Sborman 			 * If using real linemode and linemode is being
35886530481Sborman 			 * turned on, send along the edit mode mask.
35986530481Sborman 			 */
36086530481Sborman 			if (lmodetype == REAL_LINEMODE && uselinemode)
36186530481Sborman # else	/* KLUDGELINEMODE */
36286530481Sborman 			if (uselinemode)
36386530481Sborman # endif	/* KLUDGELINEMODE */
36486530481Sborman 			{
36586530481Sborman 				useeditmode = 0;
36686530481Sborman 				if (tty_isediting())
36786530481Sborman 					useeditmode |= MODE_EDIT;
36886530481Sborman 				if (tty_istrapsig)
36986530481Sborman 					useeditmode |= MODE_TRAPSIG;
37086530481Sborman 				(void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC,
37186530481Sborman 					SB, TELOPT_LINEMODE, LM_MODE,
37286530481Sborman 							useeditmode, IAC, SE);
37386530481Sborman 				nfrontp += 7;
37486530481Sborman 				editmode = useeditmode;
37586530481Sborman 			}
37686530481Sborman 
37786530481Sborman 
37886530481Sborman 			tty_setlinemode(uselinemode);
37986530481Sborman 
38086530481Sborman 			linemode = uselinemode;
38186530481Sborman 
38286530481Sborman 		}
38386530481Sborman 		break;
38486530481Sborman 
38586530481Sborman 	case LM_MODE:
38686530481Sborman 	    {
38786530481Sborman 		register int mode, sig, ack;
38886530481Sborman 
38986530481Sborman 		/*
39086530481Sborman 		 * Client has sent along a mode mask.  If it agrees with
39186530481Sborman 		 * what we are currently doing, ignore it; if not, it could
39286530481Sborman 		 * be viewed as a request to change.  Note that the server
39386530481Sborman 		 * will change to the modes in an ack if it is different from
39486530481Sborman 		 * what we currently have, but we will not ack the ack.
39586530481Sborman 		 */
39686530481Sborman 		 useeditmode &= MODE_MASK;
39786530481Sborman 		 ack = (useeditmode & MODE_ACK);
39886530481Sborman 		 useeditmode &= ~MODE_ACK;
39986530481Sborman 
40086530481Sborman 		 if (useeditmode != editmode) {
40186530481Sborman 			mode = (useeditmode & MODE_EDIT);
40286530481Sborman 			sig = (useeditmode & MODE_TRAPSIG);
40386530481Sborman 
40486530481Sborman 			if (mode != (editmode & LM_MODE)) {
40586530481Sborman 				tty_setedit(mode);
40686530481Sborman 			}
40786530481Sborman 			if (sig != (editmode & MODE_TRAPSIG)) {
40886530481Sborman 				tty_setsig(sig);
40986530481Sborman 			}
41086530481Sborman 
41186530481Sborman 			set_termbuf();
41286530481Sborman 
41386530481Sborman  			if (!ack) {
41486530481Sborman  				(void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC,
41586530481Sborman 					SB, TELOPT_LINEMODE, LM_MODE,
41686530481Sborman  					useeditmode|MODE_ACK,
41786530481Sborman  					IAC, SE);
41886530481Sborman  				nfrontp += 7;
41986530481Sborman  			}
42086530481Sborman 
42186530481Sborman 			editmode = useeditmode;
42286530481Sborman 		}
42386530481Sborman 
42486530481Sborman 		break;
42586530481Sborman 
42686530481Sborman 	    }  /* end of case LM_MODE */
42786530481Sborman #endif	/* LINEMODE */
42886530481Sborman 
42986530481Sborman 	case TELOPT_NAWS:
43086530481Sborman #ifdef	TIOCSWINSZ
43186530481Sborman 	    {
43286530481Sborman 		struct winsize ws;
43386530481Sborman 
43486530481Sborman #ifdef	LINEMODE
43586530481Sborman 		/*
43686530481Sborman 		 * Defer changing window size until after terminal is
43786530481Sborman 		 * initialized.
43886530481Sborman 		 */
43986530481Sborman 		if (terminit() == 0) {
44086530481Sborman 			def_col = parm1;
441*17cc352bSborman 			def_row = parm2;
44286530481Sborman 			return;
44386530481Sborman 		}
44486530481Sborman #endif	/* LINEMODE */
44586530481Sborman 
44686530481Sborman 		/*
44786530481Sborman 		 * Change window size as requested by client.
44886530481Sborman 		 */
44986530481Sborman 
45086530481Sborman 		ws.ws_col = parm1;
45186530481Sborman 		ws.ws_row = parm2;
45286530481Sborman 		(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
45386530481Sborman 	    }
45486530481Sborman #endif	/* TIOCSWINSZ */
45586530481Sborman 
45686530481Sborman 		break;
45786530481Sborman 
45886530481Sborman 	case TELOPT_TSPEED:
45986530481Sborman 	    {
46086530481Sborman #ifdef	LINEMODE
46186530481Sborman 		/*
46286530481Sborman 		 * Defer changing the terminal speed.
46386530481Sborman 		 */
46486530481Sborman 		if (terminit() == 0) {
46586530481Sborman 			def_tspeed = parm1;
46686530481Sborman 			def_rspeed = parm2;
46786530481Sborman 			return;
46886530481Sborman 		}
46986530481Sborman #endif	/* LINEMODE */
47086530481Sborman 		/*
47186530481Sborman 		 * Change terminal speed as requested by client.
47286530481Sborman 		 */
47386530481Sborman 		tty_tspeed(parm1);
47486530481Sborman 		tty_rspeed(parm2);
47586530481Sborman 		set_termbuf();
47686530481Sborman 
47786530481Sborman 		break;
47886530481Sborman 
47986530481Sborman 	    }  /* end of case TELOPT_TSPEED */
48086530481Sborman 
48186530481Sborman 	default:
48286530481Sborman 		/* What? */
48386530481Sborman 		break;
48486530481Sborman 	}  /* end of switch */
48586530481Sborman 
486*17cc352bSborman #if	defined(CRAY2) && defined(UNICOS5)
48786530481Sborman 	/*
48886530481Sborman 	 * Just in case of the likely event that we changed the pty state.
48986530481Sborman 	 */
49086530481Sborman 	rcv_ioctl();
491*17cc352bSborman #endif	/* defined(CRAY2) && defined(UNICOS5) */
49286530481Sborman 
49386530481Sborman 	netflush();
49486530481Sborman 
49586530481Sborman }  /* end of clientstat */
49686530481Sborman 
497*17cc352bSborman #if	defined(CRAY2) && defined(UNICOS5)
49886530481Sborman termstat()
49986530481Sborman {
50086530481Sborman 	needtermstat = 1;
50186530481Sborman }
50286530481Sborman 
50386530481Sborman _termstat()
50486530481Sborman {
50586530481Sborman 	needtermstat = 0;
50686530481Sborman 	init_termbuf();
50786530481Sborman 	localstat();
50886530481Sborman 	rcv_ioctl();
50986530481Sborman }
510*17cc352bSborman #endif	/* defined(CRAY2) && defined(UNICOS5) */
51186530481Sborman 
51286530481Sborman #ifdef	LINEMODE
51386530481Sborman /*
51486530481Sborman  * defer_terminit
51586530481Sborman  *
51686530481Sborman  * Some things should not be done until after the login process has started
51786530481Sborman  * and all the pty modes are set to what they are supposed to be.  This
51886530481Sborman  * function is called when the pty state has been processed for the first time.
51986530481Sborman  * It calls other functions that do things that were deferred in each module.
52086530481Sborman  */
52186530481Sborman defer_terminit()
52286530481Sborman {
52386530481Sborman 
52486530481Sborman 	/*
52586530481Sborman 	 * local stuff that got deferred.
52686530481Sborman 	 */
52786530481Sborman 	if (def_tspeed != -1) {
52886530481Sborman 		clientstat(TELOPT_TSPEED, def_tspeed, def_rspeed);
52986530481Sborman 		def_tspeed = def_rspeed = 0;
53086530481Sborman 	}
53186530481Sborman 
53286530481Sborman #ifdef	TIOCSWINSZ
53386530481Sborman 	if (def_col || def_row) {
53486530481Sborman 		struct winsize ws;
53586530481Sborman 
53686530481Sborman 		ws.ws_col = def_col;
53786530481Sborman 		ws.ws_row = def_row;
53886530481Sborman 		(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
53986530481Sborman 	}
54086530481Sborman #endif
54186530481Sborman 
54286530481Sborman 	/*
54386530481Sborman 	 * The only other module that currently defers anything.
54486530481Sborman 	 */
54586530481Sborman 	deferslc();
54686530481Sborman 
54786530481Sborman }  /* end of defer_terminit */
54886530481Sborman 
54986530481Sborman /*
55086530481Sborman  * terminit
55186530481Sborman  *
55286530481Sborman  * Returns true if the pty state has been processed yet.
55386530481Sborman  */
55486530481Sborman int terminit()
55586530481Sborman {
55686530481Sborman 	return _terminit;
55786530481Sborman 
55886530481Sborman }  /* end of terminit */
55986530481Sborman #endif	/* LINEMODE */
560