1 /* @(#)termios.h	1.34 11/08/13 Copyright 1984-2011 J. Schilling */
2 /*
3  *	Terminal driver tty mode handling
4  *
5  *	Copyright (c) 1984-2011 J. Schilling
6  */
7 /*
8  * The contents of this file are subject to the terms of the
9  * Common Development and Distribution License, Version 1.0 only
10  * (the "License").  You may not use this file except in compliance
11  * with the License.
12  *
13  * See the file CDDL.Schily.txt in this distribution for details.
14  * A copy of the CDDL is also available via the Internet at
15  * http://www.opensource.org/licenses/cddl1.txt
16  *
17  * When distributing Covered Code, include this CDDL HEADER in each
18  * file and include the License file CDDL.Schily.txt from this distribution.
19  */
20 
21 
22 #ifndef	_SCHILY_TERMIOS_H
23 #define	_SCHILY_TERMIOS_H
24 
25 #ifndef	_SCHILY_MCONFIG_H
26 #include <schily/mconfig.h>
27 #endif
28 
29 #ifndef	_SCHILY_TYPES_H
30 #include <schily/types.h>
31 #endif
32 #ifndef	_SCHILY_UNISTD_H
33 #include <schily/unistd.h>	/* Haiku needs this for _POSIX_VDISABLE */
34 #endif
35 
36 #ifdef	JOS
37 #	include <ttymodes.h>
38 #	include <spfcode.h>
39 #else
40 #ifdef	HAVE_TERMIOS_H
41 #	ifndef	_INCL_TERMIOS_H
42 #	include <termios.h>
43 #	define	_INCL_TERMIOS_H
44 #	endif	/* _INCL_TERMIOS_H */
45 #	ifdef TIOCGETA				/* FreeBSD */
46 #		define	TCGETS	TIOCGETA
47 #		define	TCSETSW	TIOCSETAW
48 #	endif
49 #	ifdef TCGETATTR
50 #		define	TCGETS	TCGETATTR
51 #		define	TCSETSW	TCSETATTRD
52 #	endif
53 #else
54 #	ifdef	HAVE_TERMIO_H
55 #		ifndef	_INCL_TERMIO_H
56 #		include	<termio.h>
57 #		define	_INCL_TERMIO_H
58 #		endif	/* _INCL_TERMIO_H */
59 #		ifndef	TCGETS
60 #		define	termios	termio
61 #		define	TCGETS	TCGETA
62 #		define	TCSETSW	TCSETAW
63 #		endif
64 #	else
65 #		define	USE_V7_TTY
66 #	endif
67 #endif
68 #endif
69 
70 #if !defined(HAVE_TCGETATTR) || !defined(HAVE_TCSETATTR)
71 #	undef	TCSANOW
72 #else
73 #	define	USE_TCSETATTR	/* Use tcsetattr() instead of ioctl()	*/
74 #	define	USE_TERMIOS	/* Termio as classification		*/
75 #endif
76 
77 #ifndef	TCSANOW
78 #	if	!defined(TCGETS) || !defined(TCSETSW)
79 #		define	USE_V7_TTY
80 #	else
81 #		define	USE_TCSETSW	/* Use ioctl()s			*/
82 #		ifndef	USE_TERMIOS
83 #		define	USE_TERMIOS	/* Termio as classification	*/
84 #		endif
85 #	endif
86 #endif
87 
88 #if	defined(USE_V7_TTY) && defined(HAVE_SGTTY_H)
89 #	ifndef	_INCL_SGTTY_H
90 #	include	<sgtty.h>
91 #	define	_INCL_SGTTY_H
92 #	endif
93 #endif
94 
95 #if	defined(USE_V7_TTY)
96 #	ifndef	TIOCGETP
97 #		undef	USE_V7_TTY
98 #		define	USE_NO_TTY_IOCTL	/* A DOS system?	*/
99 #	endif
100 #endif
101 
102 #if	defined(USE_NO_TTY_IOCTL) && defined(HAVE_CONIO_H)
103 #	ifndef	_INCL_CONIO_H
104 #	include <conio.h>
105 #	define	_INCL_CONIO_H
106 #	endif	/* _INCL_CONIO_H */
107 #	define	USE_GETCH			/* A DOS system!	*/
108 #endif
109 
110 
111 #if !defined(_INCL_TERMIOS_H) && !defined(_INCL_TERMIO_H)
112 #	include	<schily/ioctl.h>
113 #endif
114 
115 #ifdef	HAVE_SYS_BSDTTY_H
116 #ifndef	_INCL_SYS_BSDTTY_H
117 #include <sys/bsdtty.h>
118 #define	_INCL_SYS_BSDTTY_H
119 #endif
120 #endif
121 
122 #if	!defined(TIOCGWINSZ) && ! defined(TIOCGSIZE)
123 #	include	<schily/ioctl.h>
124 #endif
125 
126 #ifndef	OXTABS					/* OS/2 EMX */
127 #define	OXTABS	0
128 #endif
129 #ifndef	XTABS
130 #	ifndef	TAB3				/* FreeBSD */
131 #	define	TABDLY	OXTABS
132 #	define	XTABS	OXTABS
133 #	else
134 #	define	XTABS	TAB3
135 #	endif
136 #endif
137 #ifndef	ONLCR					/* OS/2 EMX */
138 #define	ONLCR	0
139 #endif
140 #ifndef	OCRNL					/* FreeBSD */
141 #	define	OCRNL	0
142 #endif
143 #ifndef	ONLRET					/* FreeBSD */
144 #	define	ONLRET	0
145 #endif
146 #ifndef	_POSIX_VDISABLE
147 #	define	_POSIX_VDISABLE	0
148 #endif
149 
150 #endif	/* _SCHILY_TERMIOS_H */
151