xref: /titanic_50/usr/src/lib/libcurses/screen/reset_sh.c (revision 0e42dee69ed771bf604dd1789fca9d77b5bbe302)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #pragma ident	"%Z%%M%	%I%	%E% SMI"
41 
42 /*LINTLIBRARY*/
43 
44 #include	<sys/types.h>
45 #include	<unistd.h>
46 #include	"curses_inc.h"
47 
48 int
49 reset_shell_mode(void)
50 {
51 #ifdef	DIOCSETT
52 	/*
53 	 * Restore any virtual terminal setting.  This must be done
54 	 * before the TIOCSETN because DIOCSETT will clobber flags like xtabs.
55 	 */
56 	cur_term -> old.st_flgs |= TM_SET;
57 	(void) ioctl(cur_term->Filedes, DIOCSETT, &cur_term -> old);
58 #endif	/* DIOCSETT */
59 #ifdef	SYSV
60 	if (_BRS(SHELLTTYS)) {
61 		if (shell_istermios < 0) {
62 			int i;
63 
64 			SHELLTTY.c_lflag = SHELLTTYS.c_lflag;
65 			SHELLTTY.c_oflag = SHELLTTYS.c_oflag;
66 			SHELLTTY.c_iflag = SHELLTTYS.c_iflag;
67 			SHELLTTY.c_cflag = SHELLTTYS.c_cflag;
68 			for (i = 0; i < NCC; i++)
69 				SHELLTTY.c_cc[i] = SHELLTTYS.c_cc[i];
70 			(void) ioctl(cur_term -> Filedes, TCSETAW, &SHELLTTY);
71 		} else
72 			(void) ioctl(cur_term -> Filedes, TCSETSW, &SHELLTTYS);
73 #ifdef	LTILDE
74 		if (cur_term -> newlmode != cur_term -> oldlmode)
75 			(void) ioctl(cur_term -> Filedes, TIOCLSET,
76 			    &cur_term -> oldlmode);
77 #endif	/* LTILDE */
78 	}
79 #else	/* SYSV */
80 	if (_BR(SHELLTTY)) {
81 		(void) ioctl(cur_term -> Filedes, TIOCSETN, &SHELLTTY);
82 #ifdef	LTILDE
83 		if (cur_term -> newlmode != cur_term -> oldlmode)
84 			(void) ioctl(cur_term -> Filedes, TIOCLSET,
85 			    &cur_term -> oldlmode);
86 #endif	/* LTILDE */
87 	}
88 #endif	/* SYSV */
89 	return (OK);
90 }
91