Path: blob/main/crypto/heimdal/appl/telnet/telnetd/termstat.c
34879 views
/*1* Copyright (c) 1989, 19932* The Regents of the University of California. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by the University of15* California, Berkeley and its contributors.16* 4. Neither the name of the University nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "telnetd.h"3435RCSID("$Id$");3637/*38* local variables39*/40int def_tspeed = -1, def_rspeed = -1;41#ifdef TIOCSWINSZ42int def_row = 0, def_col = 0;43#endif4445/*46* flowstat47*48* Check for changes to flow control49*/50void51flowstat(void)52{53if (his_state_is_will(TELOPT_LFLOW)) {54if (tty_flowmode() != flowmode) {55flowmode = tty_flowmode();56output_data("%c%c%c%c%c%c",57IAC, SB, TELOPT_LFLOW,58flowmode ? LFLOW_ON : LFLOW_OFF,59IAC, SE);60}61if (tty_restartany() != restartany) {62restartany = tty_restartany();63output_data("%c%c%c%c%c%c",64IAC, SB, TELOPT_LFLOW,65restartany ? LFLOW_RESTART_ANY66: LFLOW_RESTART_XON,67IAC, SE);68}69}70}7172/*73* clientstat74*75* Process linemode related requests from the client.76* Client can request a change to only one of linemode, editmode or slc's77* at a time, and if using kludge linemode, then only linemode may be78* affected.79*/80void81clientstat(int code, int parm1, int parm2)82{83/*84* Get a copy of terminal characteristics.85*/86init_termbuf();8788/*89* Process request from client. code tells what it is.90*/91switch (code) {92case TELOPT_NAWS:93#ifdef TIOCSWINSZ94{95struct winsize ws;9697def_col = parm1;98def_row = parm2;99100/*101* Change window size as requested by client.102*/103104ws.ws_col = parm1;105ws.ws_row = parm2;106ioctl(ourpty, TIOCSWINSZ, (char *)&ws);107}108#endif /* TIOCSWINSZ */109110break;111112case TELOPT_TSPEED:113{114def_tspeed = parm1;115def_rspeed = parm2;116/*117* Change terminal speed as requested by client.118* We set the receive speed first, so that if we can't119* store seperate receive and transmit speeds, the transmit120* speed will take precedence.121*/122tty_rspeed(parm2);123tty_tspeed(parm1);124set_termbuf();125126break;127128} /* end of case TELOPT_TSPEED */129130default:131/* What? */132break;133} /* end of switch */134135netflush();136137}138139140