blob: fdf379b892af5fa669b05ddfb41efde3a5c3c57d [file] [log] [blame]
Chet Ramey8868eda2020-12-06 15:51:17 -05001/* Copyright (C) 1999-2020 Free Software Foundation, Inc. */
Jari Aaltobb706242000-03-17 21:46:59 +00002
3/* This file is part of GNU Bash, the Bourne Again SHell.
4
Jari Aalto31859422009-01-12 13:36:28 +00005 Bash is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
Jari Aaltobb706242000-03-17 21:46:59 +00009
Jari Aalto31859422009-01-12 13:36:28 +000010 Bash is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
Jari Aaltobb706242000-03-17 21:46:59 +000014
Jari Aalto31859422009-01-12 13:36:28 +000015 You should have received a copy of the GNU General Public License
16 along with Bash. If not, see <http://www.gnu.org/licenses/>.
17*/
Jari Aaltobb706242000-03-17 21:46:59 +000018
19/*
20 * shtty.h -- include the correct system-dependent files to manipulate the
21 * tty
22 */
23
24#ifndef __SH_TTY_H_
25#define __SH_TTY_H_
26
27#include "stdc.h"
28
29#if defined (_POSIX_VERSION) && defined (HAVE_TERMIOS_H) && defined (HAVE_TCGETATTR) && !defined (TERMIOS_MISSING)
30# define TERMIOS_TTY_DRIVER
31#else
32# if defined (HAVE_TERMIO_H)
33# define TERMIO_TTY_DRIVER
34# else
35# define NEW_TTY_DRIVER
36# endif
37#endif
38
39/*
40 * The _POSIX_SOURCE define is to avoid multiple symbol definitions
41 * between sys/ioctl.h and termios.h. Ditto for the test against SunOS4
42 * and the undefining of several symbols.
43 */
44
45#ifdef TERMIOS_TTY_DRIVER
46# if (defined (SunOS4) || defined (SunOS5)) && !defined (_POSIX_SOURCE)
47# define _POSIX_SOURCE
48# endif
49# if defined (SunOS4)
50# undef ECHO
51# undef NOFLSH
52# undef TOSTOP
53# endif /* SunOS4 */
54# include <termios.h>
55# define TTYSTRUCT struct termios
56#else
57# ifdef TERMIO_TTY_DRIVER
58# include <termio.h>
59# define TTYSTRUCT struct termio
60# else /* NEW_TTY_DRIVER */
61# include <sgtty.h>
62# define TTYSTRUCT struct sgttyb
63# endif
64#endif
65
66/* Functions imported from lib/sh/shtty.c */
67
68/* Get and set terminal attributes for the file descriptor passed as
69 an argument. */
Chet Ramey8868eda2020-12-06 15:51:17 -050070extern int ttgetattr PARAMS((int, TTYSTRUCT *));
71extern int ttsetattr PARAMS((int, TTYSTRUCT *));
Jari Aaltobb706242000-03-17 21:46:59 +000072
73/* Save and restore the terminal's attributes from static storage. */
Chet Ramey8868eda2020-12-06 15:51:17 -050074extern void ttsave PARAMS((void));
75extern void ttrestore PARAMS((void));
Jari Aaltobb706242000-03-17 21:46:59 +000076
77/* Return the attributes corresponding to the file descriptor (0 or 1)
78 passed as an argument. */
Chet Ramey8868eda2020-12-06 15:51:17 -050079extern TTYSTRUCT *ttattr PARAMS((int));
Jari Aaltobb706242000-03-17 21:46:59 +000080
81/* These functions only operate on the passed TTYSTRUCT; they don't
82 actually change anything with the kernel's current tty settings. */
Chet Ramey8868eda2020-12-06 15:51:17 -050083extern int tt_setonechar PARAMS((TTYSTRUCT *));
84extern int tt_setnoecho PARAMS((TTYSTRUCT *));
85extern int tt_seteightbit PARAMS((TTYSTRUCT *));
86extern int tt_setnocanon PARAMS((TTYSTRUCT *));
87extern int tt_setcbreak PARAMS((TTYSTRUCT *));
Jari Aaltobb706242000-03-17 21:46:59 +000088
89/* These functions are all generally mutually exclusive. If you call
90 more than one (bracketed with calls to ttsave and ttrestore, of
91 course), the right thing will happen, but more system calls will be
92 executed than absolutely necessary. You can do all of this yourself
93 with the other functions; these are only conveniences. */
Jari Aalto31859422009-01-12 13:36:28 +000094
95/* These functions work with a given file descriptor and set terminal
96 attributes */
Chet Ramey8868eda2020-12-06 15:51:17 -050097extern int ttfd_onechar PARAMS((int, TTYSTRUCT *));
98extern int ttfd_noecho PARAMS((int, TTYSTRUCT *));
99extern int ttfd_eightbit PARAMS((int, TTYSTRUCT *));
100extern int ttfd_nocanon PARAMS((int, TTYSTRUCT *));
Jari Aalto31859422009-01-12 13:36:28 +0000101
Chet Ramey8868eda2020-12-06 15:51:17 -0500102extern int ttfd_cbreak PARAMS((int, TTYSTRUCT *));
Jari Aalto31859422009-01-12 13:36:28 +0000103
104/* These functions work with fd 0 and the TTYSTRUCT saved with ttsave () */
Chet Ramey8868eda2020-12-06 15:51:17 -0500105extern int ttonechar PARAMS((void));
106extern int ttnoecho PARAMS((void));
107extern int tteightbit PARAMS((void));
108extern int ttnocanon PARAMS((void));
Jari Aaltobb706242000-03-17 21:46:59 +0000109
Chet Ramey8868eda2020-12-06 15:51:17 -0500110extern int ttcbreak PARAMS((void));
Jari Aaltobb706242000-03-17 21:46:59 +0000111
112#endif