1/****************************************************************************
2 * Copyright 2018,2020 Thomas E. Dickey                                     *
3 * Copyright 2011-2014,2017 Free Software Foundation, Inc.                  *
4 *                                                                          *
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:                 *
12 *                                                                          *
13 * The above copyright notice and this permission notice shall be included  *
14 * in all copies or substantial portions of the Software.                   *
15 *                                                                          *
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.                               *
23 *                                                                          *
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       *
27 * authorization.                                                           *
28 ****************************************************************************/
29
30/****************************************************************************
31 *  Author: Thomas E. Dickey                        2011                    *
32 ****************************************************************************/
33
34/* $Id: nc_termios.h,v 1.8 2020/08/29 20:53:19 tom Exp $ */
35
36#ifndef NC_TERMIOS_included
37#define NC_TERMIOS_included 1
38
39#include <ncurses_cfg.h>
40
41#if HAVE_TERMIOS_H && HAVE_TCGETATTR
42
43#else /* !HAVE_TERMIOS_H */
44
45#if HAVE_TERMIO_H
46
47/* Add definitions to make termio look like termios.
48 * But ifdef it, since there are some implementations
49 * that try to do this for us in a fake <termio.h>.
50 */
51#ifndef TCSADRAIN
52#define TCSADRAIN TCSETAW
53#endif
54#ifndef TCSAFLUSH
55#define TCSAFLUSH TCSETAF
56#endif
57#ifndef tcsetattr
58#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
59#endif
60#ifndef tcgetattr
61#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)
62#endif
63#ifndef cfgetospeed
64#define cfgetospeed(t) ((t)->c_cflag & CBAUD)
65#endif
66#ifndef TCIFLUSH
67#define TCIFLUSH 0
68#endif
69#ifndef tcflush
70#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
71#endif
72
73#if defined(EXP_WIN32_DRIVER)
74#undef TERMIOS
75#endif
76
77#else /* !HAVE_TERMIO_H */
78
79#if defined(_WIN32) && !defined(EXP_WIN32_DRIVER)
80
81/* lflag bits */
82#define ISIG	0x0001
83#define ICANON	0x0002
84#define ECHO	0x0004
85#define ECHOE	0x0008
86#define ECHOK	0x0010
87#define ECHONL	0x0020
88#define NOFLSH	0x0040
89#define IEXTEN	0x0100
90
91#define VEOF	     4
92#define VERASE	     5
93#define VINTR	     6
94#define VKILL	     7
95#define VMIN	     9
96#define VQUIT	    10
97#define VTIME	    16
98
99/* iflag bits */
100#define IGNBRK	0x00001
101#define BRKINT	0x00002
102#define IGNPAR	0x00004
103#define INPCK	0x00010
104#define ISTRIP	0x00020
105#define INLCR	0x00040
106#define IGNCR	0x00080
107#define ICRNL	0x00100
108#define IXON	0x00400
109#define IXOFF	0x01000
110#define PARMRK	0x10000
111
112/* oflag bits */
113#define OPOST	0x00001
114
115/* cflag bits */
116#define CBAUD	 0x0100f
117#define B0	 0x00000
118#define B50	 0x00001
119#define B75	 0x00002
120#define B110	 0x00003
121#define B134	 0x00004
122#define B150	 0x00005
123#define B200	 0x00006
124#define B300	 0x00007
125#define B600	 0x00008
126#define B1200	 0x00009
127#define B1800	 0x0000a
128#define B2400	 0x0000b
129#define B4800	 0x0000c
130#define B9600	 0x0000d
131
132#define CSIZE	 0x00030
133#define CS8	 0x00030
134#define CSTOPB	 0x00040
135#define CREAD	 0x00080
136#define PARENB	 0x00100
137#define PARODD	 0x00200
138#define HUPCL	 0x00400
139#define CLOCAL	 0x00800
140
141#define TCIFLUSH	0
142#define TCSADRAIN	3
143
144#ifndef cfgetospeed
145#define cfgetospeed(t) ((t)->c_cflag & CBAUD)
146#endif
147
148#ifndef tcsetattr
149#define tcsetattr(fd, opt, arg) _nc_mingw_tcsetattr(fd, opt, arg)
150#endif
151
152#ifndef tcgetattr
153#define tcgetattr(fd, arg) _nc_mingw_tcgetattr(fd, arg)
154#endif
155
156#ifndef tcflush
157#define tcflush(fd, queue) _nc_mingw_tcflush(fd, queue)
158#endif
159
160#undef  ttyname
161#define ttyname(fd) NULL
162
163#endif /* _WIN32 */
164#endif /* HAVE_TERMIO_H */
165
166#endif /* HAVE_TERMIOS_H */
167
168#endif /* NC_TERMIOS_included */
169