1 /****************************************************************************
2 * Copyright 2020 Thomas E. Dickey *
3 * Copyright 1998-2009,2010 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
32 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
33 * and: Thomas E. Dickey 2002 *
34 * and: Juergen Pfeifer 2009 *
35 ****************************************************************************/
40 * Misc. low-level routines:
45 * The baudrate() and delay_output() functions could logically live here,
46 * but are in other modules to reduce the static-link size of programs
47 * that use only these facilities.
50 #include <curses.priv.h>
52 MODULE_ID("$Id: lib_kernel.c,v 1.33 2020/09/05 21:37:57 tom Exp $")
58 #if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
59 value = _POSIX_VDISABLE;
61 #if defined(_PC_VDISABLE)
63 value = (int) fpathconf(0, _PC_VDISABLE);
68 #elif defined(VDISABLE)
78 * Return erase character as given in cur_term->Ottyb.
83 NCURSES_SP_NAME(erasechar) (NCURSES_SP_DCL0)
86 TERMINAL *termp = TerminalOf(SP_PARM);
88 T((T_CALLED("erasechar(%p)"), (void *) SP_PARM));
92 result = termp->Ottyb.c_cc[VERASE];
93 if (result == _nc_vdisable())
95 #elif defined(EXP_WIN32_DRIVER)
98 result = termp->Ottyb.sg_erase;
101 returnChar((char) result);
108 return NCURSES_SP_NAME(erasechar) (CURRENT_SCREEN);
115 * Return kill character as given in cur_term->Ottyb.
120 NCURSES_SP_NAME(killchar) (NCURSES_SP_DCL0)
123 TERMINAL *termp = TerminalOf(SP_PARM);
125 T((T_CALLED("killchar(%p)"), (void *) SP_PARM));
129 result = termp->Ottyb.c_cc[VKILL];
130 if (result == _nc_vdisable())
132 #elif defined(EXP_WIN32_DRIVER)
135 result = termp->Ottyb.sg_kill;
138 returnChar((char) result);
145 return NCURSES_SP_NAME(killchar) (CURRENT_SCREEN);
152 * Flush any input on cur_term->Filedes
157 NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0)
159 TERMINAL *termp = TerminalOf(SP_PARM);
161 T((T_CALLED("flushinp(%p)"), (void *) SP_PARM));
165 tcflush(termp->Filedes, TCIFLUSH);
169 #if defined(EXP_WIN32_DRIVER)
170 _nc_console_flush(_nc_console_fd2handle(termp->Filedes));
172 ioctl(termp->Filedes, TIOCFLUSH, 0);
178 SP_PARM->_fifohead = -1;
179 SP_PARM->_fifotail = 0;
180 SP_PARM->_fifopeek = 0;
191 return NCURSES_SP_NAME(flushinp) (CURRENT_SCREEN);