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 (c) 1995-2000 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 /* LINTLIBRARY */ 28 29 /* 30 * cbreak.c 31 * 32 * XCurses Library 33 * 34 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 35 * 36 */ 37 38 #if M_RCSID 39 #ifndef lint 40 static char rcsID[] = 41 "$Header: /team/ps/sun_xcurses/archive/local_changes/xcurses/src/lib/" 42 "libxcurses/src/libc/xcurses/rcs/cbreak.c 1.5 1998/06/04 19:55:47 " 43 "cbates Exp $"; 44 #endif 45 #endif 46 47 #include <private.h> 48 49 int 50 cbreak(void) 51 { 52 cur_term->_flags &= ~__TERM_HALF_DELAY; 53 54 PTERMIOS(_prog)->c_cc[VMIN] = 1; 55 PTERMIOS(_prog)->c_cc[VTIME] = 0; 56 PTERMIOS(_prog)->c_lflag &= ~ICANON; 57 58 return (__m_tty_set_prog_mode()); 59 } 60 61 int 62 nocbreak(void) 63 { 64 cur_term->_flags &= ~__TERM_HALF_DELAY; 65 66 /* 67 * On some systems VMIN and VTIME map to VEOF and VEOL, which 68 * means we have to restore them to their original settings. 69 */ 70 PTERMIOS(_prog)->c_cc[VEOF] = PTERMIOS(_shell)->c_cc[VEOF]; 71 PTERMIOS(_prog)->c_cc[VEOL] = PTERMIOS(_shell)->c_cc[VEOL]; 72 PTERMIOS(_prog)->c_lflag |= ICANON; 73 74 return (__m_tty_set_prog_mode()); 75 } 76 77 /* 78 * Set global timeout value, which overrides individual window timeout 79 * values (I think believe X/Open specified this wrong). 80 */ 81 int 82 halfdelay(int tenths) 83 { 84 cur_term->_flags |= __TERM_HALF_DELAY; 85 86 PTERMIOS(_prog)->c_cc[VMIN] = 0; 87 PTERMIOS(_prog)->c_cc[VTIME] = (tenths > 255) ? 255 : (cc_t)tenths; 88 PTERMIOS(_prog)->c_lflag &= ~ICANON; 89 90 return (__m_tty_set_prog_mode()); 91 } 92 93 int 94 raw(void) 95 { 96 cur_term->_flags &= ~__TERM_HALF_DELAY; 97 98 PTERMIOS(_prog)->c_cc[VMIN] = 1; 99 PTERMIOS(_prog)->c_cc[VTIME] = 0; 100 PTERMIOS(_prog)->c_lflag &= ~(ICANON | ISIG); 101 PTERMIOS(_prog)->c_iflag &= ~IXON; 102 103 return (__m_tty_set_prog_mode()); 104 } 105 106 int 107 noraw(void) 108 { 109 cur_term->_flags &= ~__TERM_HALF_DELAY; 110 111 /* 112 * On some systems VMIN and VTIME map to VEOF and VEOL, which 113 * means we have to restore them to their original settings. 114 */ 115 PTERMIOS(_prog)->c_cc[VEOF] = PTERMIOS(_shell)->c_cc[VEOF]; 116 PTERMIOS(_prog)->c_cc[VEOL] = PTERMIOS(_shell)->c_cc[VEOL]; 117 PTERMIOS(_prog)->c_lflag |= ICANON | ISIG; 118 PTERMIOS(_prog)->c_iflag |= IXON; 119 120 return (__m_tty_set_prog_mode()); 121 } 122