tty.c revision 1.14 1 1.13 blymn /* $NetBSD: tty.c,v 1.14 2000/04/12 21:36:02 jdc Exp $ */
2 1.7 mikel
3 1.1 mycroft /*-
4 1.6 cgd * Copyright (c) 1992, 1993, 1994
5 1.2 cgd * The Regents of the University of California. All rights reserved.
6 1.1 mycroft *
7 1.1 mycroft * Redistribution and use in source and binary forms, with or without
8 1.1 mycroft * modification, are permitted provided that the following conditions
9 1.1 mycroft * are met:
10 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
11 1.1 mycroft * notice, this list of conditions and the following disclaimer.
12 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
14 1.1 mycroft * documentation and/or other materials provided with the distribution.
15 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
16 1.1 mycroft * must display the following acknowledgement:
17 1.1 mycroft * This product includes software developed by the University of
18 1.1 mycroft * California, Berkeley and its contributors.
19 1.1 mycroft * 4. Neither the name of the University nor the names of its contributors
20 1.1 mycroft * may be used to endorse or promote products derived from this software
21 1.1 mycroft * without specific prior written permission.
22 1.1 mycroft *
23 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 mycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 mycroft * SUCH DAMAGE.
34 1.1 mycroft */
35 1.1 mycroft
36 1.7 mikel #include <sys/cdefs.h>
37 1.1 mycroft #ifndef lint
38 1.7 mikel #if 0
39 1.10 perry static char sccsid[] = "@(#)tty.c 8.6 (Berkeley) 1/10/95";
40 1.7 mikel #else
41 1.13 blymn __RCSID("$NetBSD: tty.c,v 1.14 2000/04/12 21:36:02 jdc Exp $");
42 1.7 mikel #endif
43 1.11 mrg #endif /* not lint */
44 1.11 mrg
45 1.11 mrg #include <sys/types.h>
46 1.1 mycroft
47 1.6 cgd #include <stdlib.h>
48 1.1 mycroft #include <termios.h>
49 1.1 mycroft #include <unistd.h>
50 1.1 mycroft
51 1.6 cgd #include "curses.h"
52 1.14 jdc #include "curses_private.h"
53 1.6 cgd
54 1.2 cgd /*
55 1.2 cgd * In general, curses should leave tty hardware settings alone (speed, parity,
56 1.2 cgd * word size). This is most easily done in BSD by using TCSASOFT on all
57 1.2 cgd * tcsetattr calls. On other systems, it would be better to get and restore
58 1.2 cgd * those attributes at each change, or at least when stopped and restarted.
59 1.2 cgd * See also the comments in getterm().
60 1.2 cgd */
61 1.2 cgd #ifdef TCSASOFT
62 1.11 mrg int __tcaction = 1; /* Ignore hardware settings. */
63 1.2 cgd #else
64 1.11 mrg int __tcaction = 0;
65 1.2 cgd #endif
66 1.2 cgd
67 1.2 cgd struct termios __orig_termios, __baset;
68 1.11 mrg int __endwin;
69 1.2 cgd static struct termios cbreakt, rawt, *curt;
70 1.1 mycroft static int useraw;
71 1.11 mrg static int ovmin = 1;
72 1.11 mrg static int ovtime = 0;
73 1.1 mycroft
74 1.2 cgd #ifndef OXTABS
75 1.2 cgd #ifdef XTABS /* SMI uses XTABS. */
76 1.2 cgd #define OXTABS XTABS
77 1.2 cgd #else
78 1.2 cgd #define OXTABS 0
79 1.2 cgd #endif
80 1.2 cgd #endif
81 1.2 cgd
82 1.1 mycroft /*
83 1.1 mycroft * gettmode --
84 1.1 mycroft * Do terminal type initialization.
85 1.1 mycroft */
86 1.1 mycroft int
87 1.1 mycroft gettmode()
88 1.1 mycroft {
89 1.2 cgd useraw = 0;
90 1.11 mrg
91 1.2 cgd if (tcgetattr(STDIN_FILENO, &__orig_termios))
92 1.2 cgd return (ERR);
93 1.2 cgd
94 1.2 cgd __baset = __orig_termios;
95 1.2 cgd __baset.c_oflag &= ~OXTABS;
96 1.1 mycroft
97 1.11 mrg GT = 0; /* historical. was used before we wired OXTABS
98 1.11 mrg * off */
99 1.2 cgd NONL = (__baset.c_oflag & ONLCR) == 0;
100 1.1 mycroft
101 1.2 cgd /*
102 1.2 cgd * XXX
103 1.2 cgd * System V and SMI systems overload VMIN and VTIME, such that
104 1.2 cgd * VMIN is the same as the VEOF element, and VTIME is the same
105 1.2 cgd * as the VEOL element. This means that, if VEOF was ^D, the
106 1.2 cgd * default VMIN is 4. Majorly stupid.
107 1.2 cgd */
108 1.2 cgd cbreakt = __baset;
109 1.2 cgd cbreakt.c_lflag &= ~ICANON;
110 1.2 cgd cbreakt.c_cc[VMIN] = 1;
111 1.2 cgd cbreakt.c_cc[VTIME] = 0;
112 1.2 cgd
113 1.2 cgd rawt = cbreakt;
114 1.11 mrg rawt.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | INLCR | IGNCR | ICRNL | IXON);
115 1.2 cgd rawt.c_oflag &= ~OPOST;
116 1.11 mrg rawt.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
117 1.2 cgd
118 1.2 cgd /*
119 1.2 cgd * In general, curses should leave hardware-related settings alone.
120 1.2 cgd * This includes parity and word size. Older versions set the tty
121 1.2 cgd * to 8 bits, no parity in raw(), but this is considered to be an
122 1.2 cgd * artifact of the old tty interface. If it's desired to change
123 1.2 cgd * parity and word size, the TCSASOFT bit has to be removed from the
124 1.2 cgd * calls that switch to/from "raw" mode.
125 1.2 cgd */
126 1.2 cgd if (!__tcaction) {
127 1.2 cgd rawt.c_iflag &= ~ISTRIP;
128 1.11 mrg rawt.c_cflag &= ~(CSIZE | PARENB);
129 1.2 cgd rawt.c_cflag |= CS8;
130 1.2 cgd }
131 1.1 mycroft
132 1.2 cgd curt = &__baset;
133 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
134 1.2 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
135 1.1 mycroft }
136 1.1 mycroft
137 1.1 mycroft int
138 1.1 mycroft raw()
139 1.1 mycroft {
140 1.9 phil /* Check if we need to restart ... */
141 1.9 phil if (__endwin) {
142 1.9 phil __endwin = 0;
143 1.9 phil __restartwin();
144 1.9 phil }
145 1.11 mrg
146 1.1 mycroft useraw = __pfast = __rawmode = 1;
147 1.2 cgd curt = &rawt;
148 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
149 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
150 1.1 mycroft }
151 1.1 mycroft
152 1.1 mycroft int
153 1.1 mycroft noraw()
154 1.1 mycroft {
155 1.9 phil /* Check if we need to restart ... */
156 1.9 phil if (__endwin) {
157 1.9 phil __endwin = 0;
158 1.9 phil __restartwin();
159 1.9 phil }
160 1.11 mrg
161 1.1 mycroft useraw = __pfast = __rawmode = 0;
162 1.2 cgd curt = &__baset;
163 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
164 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
165 1.1 mycroft }
166 1.1 mycroft
167 1.1 mycroft int
168 1.1 mycroft cbreak()
169 1.1 mycroft {
170 1.9 phil /* Check if we need to restart ... */
171 1.9 phil if (__endwin) {
172 1.9 phil __endwin = 0;
173 1.9 phil __restartwin();
174 1.9 phil }
175 1.11 mrg
176 1.1 mycroft __rawmode = 1;
177 1.2 cgd curt = useraw ? &rawt : &cbreakt;
178 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
179 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
180 1.1 mycroft }
181 1.1 mycroft
182 1.1 mycroft int
183 1.1 mycroft nocbreak()
184 1.1 mycroft {
185 1.9 phil /* Check if we need to restart ... */
186 1.9 phil if (__endwin) {
187 1.9 phil __endwin = 0;
188 1.9 phil __restartwin();
189 1.9 phil }
190 1.1 mycroft
191 1.1 mycroft __rawmode = 0;
192 1.2 cgd curt = useraw ? &rawt : &__baset;
193 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
194 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
195 1.1 mycroft }
196 1.11 mrg
197 1.11 mrg int
198 1.11 mrg __delay()
199 1.11 mrg {
200 1.11 mrg /* Check if we need to restart ... */
201 1.11 mrg if (__endwin) {
202 1.11 mrg __endwin = 0;
203 1.11 mrg __restartwin();
204 1.11 mrg }
205 1.11 mrg
206 1.11 mrg rawt.c_cc[VMIN] = 1;
207 1.11 mrg rawt.c_cc[VTIME] = 0;
208 1.11 mrg cbreakt.c_cc[VMIN] = 1;
209 1.11 mrg cbreakt.c_cc[VTIME] = 0;
210 1.11 mrg __baset.c_cc[VMIN] = 1;
211 1.11 mrg __baset.c_cc[VTIME] = 0;
212 1.11 mrg
213 1.11 mrg return (tcsetattr(STDIN_FILENO, __tcaction ?
214 1.11 mrg TCSASOFT : TCSANOW, curt) ? ERR : OK);
215 1.11 mrg }
216 1.11 mrg
217 1.11 mrg int
218 1.11 mrg __nodelay()
219 1.11 mrg {
220 1.11 mrg /* Check if we need to restart ... */
221 1.11 mrg if (__endwin) {
222 1.11 mrg __endwin = 0;
223 1.11 mrg __restartwin();
224 1.11 mrg }
225 1.11 mrg
226 1.11 mrg rawt.c_cc[VMIN] = 0;
227 1.11 mrg rawt.c_cc[VTIME] = 0;
228 1.11 mrg cbreakt.c_cc[VMIN] = 0;
229 1.11 mrg cbreakt.c_cc[VTIME] = 0;
230 1.11 mrg __baset.c_cc[VMIN] = 0;
231 1.11 mrg __baset.c_cc[VTIME] = 0;
232 1.11 mrg
233 1.11 mrg return (tcsetattr(STDIN_FILENO, __tcaction ?
234 1.11 mrg TCSASOFT : TCSANOW, curt) ? ERR : OK);
235 1.11 mrg }
236 1.11 mrg
237 1.11 mrg void
238 1.11 mrg __save_termios()
239 1.11 mrg {
240 1.11 mrg /* Check if we need to restart ... */
241 1.11 mrg if (__endwin) {
242 1.11 mrg __endwin = 0;
243 1.11 mrg __restartwin();
244 1.11 mrg }
245 1.11 mrg
246 1.11 mrg ovmin = cbreakt.c_cc[VMIN];
247 1.11 mrg ovtime = cbreakt.c_cc[VTIME];
248 1.11 mrg }
249 1.11 mrg
250 1.11 mrg void
251 1.11 mrg __restore_termios()
252 1.11 mrg {
253 1.11 mrg /* Check if we need to restart ... */
254 1.11 mrg if (__endwin) {
255 1.11 mrg __endwin = 0;
256 1.11 mrg __restartwin();
257 1.11 mrg }
258 1.11 mrg
259 1.11 mrg rawt.c_cc[VMIN] = ovmin;
260 1.11 mrg rawt.c_cc[VTIME] = ovtime;
261 1.11 mrg cbreakt.c_cc[VMIN] = ovmin;
262 1.11 mrg cbreakt.c_cc[VTIME] = ovtime;
263 1.11 mrg __baset.c_cc[VMIN] = ovmin;
264 1.11 mrg __baset.c_cc[VTIME] = ovtime;
265 1.11 mrg }
266 1.11 mrg
267 1.11 mrg int
268 1.11 mrg __timeout(delay)
269 1.11 mrg int delay;
270 1.11 mrg {
271 1.11 mrg /* Check if we need to restart ... */
272 1.11 mrg if (__endwin) {
273 1.11 mrg __endwin = 0;
274 1.11 mrg __restartwin();
275 1.11 mrg }
276 1.11 mrg
277 1.11 mrg ovmin = cbreakt.c_cc[VMIN];
278 1.11 mrg ovtime = cbreakt.c_cc[VTIME];
279 1.11 mrg rawt.c_cc[VMIN] = 0;
280 1.11 mrg rawt.c_cc[VTIME] = delay;
281 1.11 mrg cbreakt.c_cc[VMIN] = 0;
282 1.11 mrg cbreakt.c_cc[VTIME] = delay;
283 1.11 mrg __baset.c_cc[VMIN] = 0;
284 1.11 mrg __baset.c_cc[VTIME] = delay;
285 1.11 mrg
286 1.11 mrg return (tcsetattr(STDIN_FILENO, __tcaction ?
287 1.11 mrg TCSASOFT | TCSANOW : TCSANOW, curt) ? ERR : OK);
288 1.11 mrg }
289 1.11 mrg
290 1.11 mrg int
291 1.11 mrg __notimeout()
292 1.11 mrg {
293 1.11 mrg /* Check if we need to restart ... */
294 1.11 mrg if (__endwin) {
295 1.11 mrg __endwin = 0;
296 1.11 mrg __restartwin();
297 1.11 mrg }
298 1.11 mrg
299 1.11 mrg rawt.c_cc[VMIN] = 1;
300 1.11 mrg rawt.c_cc[VTIME] = 0;
301 1.11 mrg cbreakt.c_cc[VMIN] = 1;
302 1.11 mrg cbreakt.c_cc[VTIME] = 0;
303 1.11 mrg __baset.c_cc[VMIN] = 1;
304 1.11 mrg __baset.c_cc[VTIME] = 0;
305 1.11 mrg
306 1.11 mrg return (tcsetattr(STDIN_FILENO, __tcaction ?
307 1.11 mrg TCSASOFT | TCSANOW : TCSANOW, curt) ? ERR : OK);
308 1.11 mrg }
309 1.11 mrg
310 1.1 mycroft int
311 1.1 mycroft echo()
312 1.1 mycroft {
313 1.9 phil /* Check if we need to restart ... */
314 1.9 phil if (__endwin) {
315 1.9 phil __endwin = 0;
316 1.9 phil __restartwin();
317 1.9 phil }
318 1.9 phil
319 1.1 mycroft rawt.c_lflag |= ECHO;
320 1.2 cgd cbreakt.c_lflag |= ECHO;
321 1.2 cgd __baset.c_lflag |= ECHO;
322 1.11 mrg
323 1.1 mycroft __echoit = 1;
324 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
325 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
326 1.1 mycroft }
327 1.1 mycroft
328 1.1 mycroft int
329 1.1 mycroft noecho()
330 1.1 mycroft {
331 1.9 phil /* Check if we need to restart ... */
332 1.9 phil if (__endwin) {
333 1.9 phil __endwin = 0;
334 1.9 phil __restartwin();
335 1.9 phil }
336 1.9 phil
337 1.1 mycroft rawt.c_lflag &= ~ECHO;
338 1.2 cgd cbreakt.c_lflag &= ~ECHO;
339 1.2 cgd __baset.c_lflag &= ~ECHO;
340 1.12 simonb
341 1.1 mycroft __echoit = 0;
342 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
343 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
344 1.1 mycroft }
345 1.1 mycroft
346 1.1 mycroft int
347 1.1 mycroft nl()
348 1.1 mycroft {
349 1.9 phil /* Check if we need to restart ... */
350 1.9 phil if (__endwin) {
351 1.9 phil __endwin = 0;
352 1.9 phil __restartwin();
353 1.9 phil }
354 1.9 phil
355 1.1 mycroft rawt.c_iflag |= ICRNL;
356 1.1 mycroft rawt.c_oflag |= ONLCR;
357 1.2 cgd cbreakt.c_iflag |= ICRNL;
358 1.2 cgd cbreakt.c_oflag |= ONLCR;
359 1.2 cgd __baset.c_iflag |= ICRNL;
360 1.2 cgd __baset.c_oflag |= ONLCR;
361 1.1 mycroft
362 1.1 mycroft __pfast = __rawmode;
363 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
364 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
365 1.1 mycroft }
366 1.1 mycroft
367 1.1 mycroft int
368 1.1 mycroft nonl()
369 1.1 mycroft {
370 1.9 phil /* Check if we need to restart ... */
371 1.9 phil if (__endwin) {
372 1.9 phil __endwin = 0;
373 1.9 phil __restartwin();
374 1.9 phil }
375 1.9 phil
376 1.1 mycroft rawt.c_iflag &= ~ICRNL;
377 1.1 mycroft rawt.c_oflag &= ~ONLCR;
378 1.2 cgd cbreakt.c_iflag &= ~ICRNL;
379 1.2 cgd cbreakt.c_oflag &= ~ONLCR;
380 1.2 cgd __baset.c_iflag &= ~ICRNL;
381 1.2 cgd __baset.c_oflag &= ~ONLCR;
382 1.1 mycroft
383 1.1 mycroft __pfast = 1;
384 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
385 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
386 1.2 cgd }
387 1.2 cgd
388 1.14 jdc int
389 1.14 jdc intrflush(win, bf) /*ARGSUSED*/
390 1.14 jdc WINDOW *win;
391 1.14 jdc bool bf;
392 1.14 jdc {
393 1.14 jdc /* Check if we need to restart ... */
394 1.14 jdc if (__endwin) {
395 1.14 jdc __endwin = 0;
396 1.14 jdc __restartwin();
397 1.14 jdc }
398 1.14 jdc
399 1.14 jdc if (bf) {
400 1.14 jdc rawt.c_lflag &= ~NOFLSH;
401 1.14 jdc cbreakt.c_lflag &= ~NOFLSH;
402 1.14 jdc __baset.c_lflag &= ~NOFLSH;
403 1.14 jdc } else {
404 1.14 jdc rawt.c_lflag |= NOFLSH;
405 1.14 jdc cbreakt.c_lflag |= NOFLSH;
406 1.14 jdc __baset.c_lflag |= NOFLSH;
407 1.14 jdc }
408 1.14 jdc
409 1.14 jdc __pfast = 1;
410 1.14 jdc return (tcsetattr(STDIN_FILENO, __tcaction ?
411 1.14 jdc TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
412 1.14 jdc }
413 1.14 jdc
414 1.2 cgd void
415 1.2 cgd __startwin()
416 1.2 cgd {
417 1.6 cgd static char *stdbuf;
418 1.6 cgd static size_t len;
419 1.6 cgd
420 1.11 mrg (void) fflush(stdout);
421 1.6 cgd
422 1.6 cgd /*
423 1.6 cgd * Some C libraries default to a 1K buffer when talking to a tty.
424 1.6 cgd * With a larger screen, especially across a network, we'd like
425 1.6 cgd * to get it to all flush in a single write. Make it twice as big
426 1.6 cgd * as just the characters (so that we have room for cursor motions
427 1.11 mrg * and attribute information) but no more than 8K.
428 1.6 cgd */
429 1.6 cgd if (stdbuf == NULL) {
430 1.6 cgd if ((len = LINES * COLS * 2) > 8192)
431 1.6 cgd len = 8192;
432 1.6 cgd if ((stdbuf = malloc(len)) == NULL)
433 1.6 cgd len = 0;
434 1.6 cgd }
435 1.11 mrg (void) setvbuf(stdout, stdbuf, _IOFBF, len);
436 1.2 cgd
437 1.2 cgd tputs(TI, 0, __cputchar);
438 1.2 cgd tputs(VS, 0, __cputchar);
439 1.11 mrg tputs(KS, 0, __cputchar);
440 1.1 mycroft }
441 1.1 mycroft
442 1.1 mycroft int
443 1.1 mycroft endwin()
444 1.1 mycroft {
445 1.8 phil __endwin = 1;
446 1.8 phil return __stopwin();
447 1.11 mrg }
448 1.11 mrg
449 1.13 blymn bool
450 1.11 mrg isendwin()
451 1.11 mrg {
452 1.13 blymn return (__endwin ? TRUE : FALSE);
453 1.11 mrg }
454 1.11 mrg
455 1.11 mrg int
456 1.11 mrg flushinp()
457 1.11 mrg {
458 1.13 blymn (void) fpurge(stdin);
459 1.11 mrg return (OK);
460 1.14 jdc }
461 1.14 jdc
462 1.14 jdc int
463 1.14 jdc def_shell_mode()
464 1.14 jdc {
465 1.14 jdc return (tcgetattr(STDIN_FILENO, &__orig_termios) ? ERR : OK);
466 1.14 jdc }
467 1.14 jdc
468 1.14 jdc int
469 1.14 jdc reset_shell_mode()
470 1.14 jdc {
471 1.14 jdc return (tcsetattr(STDIN_FILENO, __tcaction ?
472 1.14 jdc TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios) ? ERR : OK);
473 1.1 mycroft }
474 1.1 mycroft
475 1.1 mycroft /*
476 1.1 mycroft * The following routines, savetty and resetty are completely useless and
477 1.1 mycroft * are left in only as stubs. If people actually use them they will almost
478 1.1 mycroft * certainly screw up the state of the world.
479 1.1 mycroft */
480 1.1 mycroft static struct termios savedtty;
481 1.1 mycroft int
482 1.1 mycroft savetty()
483 1.1 mycroft {
484 1.6 cgd return (tcgetattr(STDIN_FILENO, &savedtty) ? ERR : OK);
485 1.1 mycroft }
486 1.1 mycroft
487 1.1 mycroft int
488 1.1 mycroft resetty()
489 1.1 mycroft {
490 1.2 cgd return (tcsetattr(STDIN_FILENO, __tcaction ?
491 1.6 cgd TCSASOFT | TCSADRAIN : TCSADRAIN, &savedtty) ? ERR : OK);
492 1.1 mycroft }
493