6429 SMB domain join doesn't work with libreSSL
[unleashed.git] / usr / src / lib / libcurses / screen / cbreak.c
blobdce15a57c6c5076e49f30a4f6ccb1898f4a0f584
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #pragma ident "%Z%%M% %I% %E% SMI"
42 /*LINTLIBRARY*/
45 * Routines to deal with setting and resetting modes in the tty driver.
46 * See also setupterm.c in the termlib part.
48 #include <sys/types.h>
49 #include "curses_inc.h"
51 int
52 cbreak(void)
55 * This optimization is here because till SVR3.1 curses did not come up
56 * in cbreak mode and now it does. Therefore, most programs when they
57 * call cbreak won't pay for it since we'll know we're in the right
58 * mode.
61 if (cur_term->_fl_rawmode != 1) {
62 #ifdef SYSV
64 * You might ask why ICRNL has anything to do with cbreak.
65 * The problem is that there are function keys that send
66 * a carriage return (some hp's). Curses cannot virtualize
67 * these function keys if CR is being mapped to a NL. Sooo,
68 * when we start a program up we unmap those but if you are
69 * in nocbreak then we map them back. The reason for that is that
70 * if a getch or getstr is done and you are in nocbreak the tty
71 * driver won't return until it sees a new line and since we've
72 * turned it off any program that has nl() and nocbreak() would
73 * force the user to type a NL. The problem with the function keys
74 * only gets solved if you are in cbreak mode which is OK
75 * since program taking action on a function key is probably
76 * in cbreak because who would expect someone to press a function
77 * key and then return ?????
80 PROGTTYS.c_iflag &= ~ICRNL;
81 PROGTTYS.c_lflag &= ~ICANON;
82 PROGTTYS.c_cc[VMIN] = 1;
83 PROGTTYS.c_cc[VTIME] = 0;
84 #else
85 PROGTTY.sg_flags |= (CBREAK | CRMOD);
86 #endif
88 #ifdef DEBUG
89 #ifdef SYSV
90 if (outf)
91 fprintf(outf, "cbreak(), file %x, flags %x\n",
92 cur_term->Filedes, PROGTTYS.c_lflag);
93 #else
94 if (outf)
95 fprintf(outf, "cbreak(), file %x, flags %x\n",
96 cur_term->Filedes, PROGTTY.sg_flags);
97 #endif
98 #endif
99 cur_term->_fl_rawmode = 1;
100 cur_term->_delay = -1;
101 (void) reset_prog_mode();
102 #ifdef FIONREAD
103 cur_term->timeout = 0;
104 #endif /* FIONREAD */
106 return (OK);