2 /* $OpenBSD: sshtty.c,v 1.13 2008/05/19 15:45:07 djm Exp $ */
4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
5 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this
10 * software must be clearly marked as such, and if the derived work is
11 * incompatible with the protocol description in the RFC file, it must be
12 * called by a name other than "ssh" or "Secure Shell".
15 * Copyright (c) 2001 Markus Friedl. All rights reserved.
16 * Copyright (c) 2001 Kevin Steves. All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 __RCSID("$NetBSD: sshtty.c,v 1.5 2009/02/16 20:53:55 christos Exp $");
41 #include <sys/types.h>
48 static struct termios _saved_tio
;
49 static int _in_raw_mode
= 0;
54 return _in_raw_mode
? &_saved_tio
: NULL
;
62 if (tcsetattr(fileno(stdin
), TCSADRAIN
, &_saved_tio
) == -1)
73 if (tcgetattr(fileno(stdin
), &tio
) == -1) {
78 tio
.c_iflag
|= IGNPAR
;
79 tio
.c_iflag
&= ~(ISTRIP
| INLCR
| IGNCR
| ICRNL
| IXON
| IXANY
| IXOFF
);
81 tio
.c_iflag
&= ~IUCLC
;
83 tio
.c_lflag
&= ~(ISIG
| ICANON
| ECHO
| ECHOE
| ECHOK
| ECHONL
);
85 tio
.c_lflag
&= ~IEXTEN
;
87 tio
.c_oflag
&= ~OPOST
;
90 if (tcsetattr(fileno(stdin
), TCSADRAIN
, &tio
) == -1)