1 /****************************************************************************
2  * Copyright (c) 2011,2014 Free Software Foundation, Inc.                   *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28 
29 /****************************************************************************
30  *  Author: Thomas E. Dickey                        2011                    *
31  ****************************************************************************/
32 
33 /* $Id: nc_termios.h,v 1.3 2014/05/03 19:40:10 juergen Exp $ */
34 
35 #ifndef NC_TERMIOS_included
36 #define NC_TERMIOS_included 1
37 
38 #if HAVE_TERMIOS_H && HAVE_TCGETATTR
39 
40 #else /* !HAVE_TERMIOS_H */
41 
42 #if HAVE_TERMIO_H
43 
44 /* Add definitions to make termio look like termios.
45  * But ifdef it, since there are some implementations
46  * that try to do this for us in a fake <termio.h>.
47  */
48 #ifndef TCSADRAIN
49 #define TCSADRAIN TCSETAW
50 #endif
51 #ifndef TCSAFLUSH
52 #define TCSAFLUSH TCSETAF
53 #endif
54 #ifndef tcsetattr
55 #define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
56 #endif
57 #ifndef tcgetattr
58 #define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)
59 #endif
60 #ifndef cfgetospeed
61 #define cfgetospeed(t) ((t)->c_cflag & CBAUD)
62 #endif
63 #ifndef TCIFLUSH
64 #define TCIFLUSH 0
65 #endif
66 #ifndef tcflush
67 #define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
68 #endif
69 
70 #else /* !HAVE_TERMIO_H */
71 
72 #if __MINGW32__
73 
74 /* lflag bits */
75 #define ISIG	0x0001
76 #define ICANON	0x0002
77 #define ECHO	0x0004
78 #define ECHOE	0x0008
79 #define ECHOK	0x0010
80 #define ECHONL	0x0020
81 #define NOFLSH	0x0040
82 #define IEXTEN	0x0100
83 
84 #define VEOF	     4
85 #define VERASE	     5
86 #define VINTR	     6
87 #define VKILL	     7
88 #define VMIN	     9
89 #define VQUIT	    10
90 #define VTIME	    16
91 
92 /* iflag bits */
93 #define IGNBRK	0x00001
94 #define BRKINT	0x00002
95 #define IGNPAR	0x00004
96 #define INPCK	0x00010
97 #define ISTRIP	0x00020
98 #define INLCR	0x00040
99 #define IGNCR	0x00080
100 #define ICRNL	0x00100
101 #define IXON	0x00400
102 #define IXOFF	0x01000
103 #define PARMRK	0x10000
104 
105 /* oflag bits */
106 #define OPOST	0x00001
107 
108 /* cflag bits */
109 #define CBAUD	 0x0100f
110 #define B0	 0x00000
111 #define B50	 0x00001
112 #define B75	 0x00002
113 #define B110	 0x00003
114 #define B134	 0x00004
115 #define B150	 0x00005
116 #define B200	 0x00006
117 #define B300	 0x00007
118 #define B600	 0x00008
119 #define B1200	 0x00009
120 #define B1800	 0x0000a
121 #define B2400	 0x0000b
122 #define B4800	 0x0000c
123 #define B9600	 0x0000d
124 
125 #define CSIZE	 0x00030
126 #define CS8	 0x00030
127 #define CSTOPB	 0x00040
128 #define CREAD	 0x00080
129 #define PARENB	 0x00100
130 #define PARODD	 0x00200
131 #define HUPCL	 0x00400
132 #define CLOCAL	 0x00800
133 
134 #define TCIFLUSH	0
135 #define TCSADRAIN	3
136 
137 #ifndef cfgetospeed
138 #define cfgetospeed(t) ((t)->c_cflag & CBAUD)
139 #endif
140 
141 #ifndef tcsetattr
142 #define tcsetattr(fd, opt, arg) _nc_mingw_tcsetattr(fd, opt, arg)
143 #endif
144 
145 #ifndef tcgetattr
146 #define tcgetattr(fd, arg) _nc_mingw_tcgetattr(fd, arg)
147 #endif
148 
149 #ifndef tcflush
150 #define tcflush(fd, queue) _nc_mingw_tcflush(fd, queue)
151 #endif
152 
153 #undef  ttyname
154 #define ttyname(fd) NULL
155 
156 #endif /* __MINGW32__ */
157 #endif /* HAVE_TERMIO_H */
158 
159 #endif /* HAVE_TERMIOS_H */
160 
161 #endif /* NC_TERMIOS_included */
162