Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/ie/terminal.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1984-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* David Korn <[email protected]> *
18
* Pat Sullivan *
19
* *
20
***********************************************************************/
21
22
/*
23
* terminal interface
24
*/
25
26
#ifndef _TERMINAL_H
27
#define _TERMINAL_H 1
28
#ifdef _hdr_termios
29
# include <termios.h>
30
# ifdef __sgi /* special hack to eliminate ^M problem */
31
# ifndef ECHOCTL
32
# define ECHOCTL ECHOE
33
# endif /* ECHOCTL */
34
# ifndef CNSUSP
35
# define CNSUSP CNSWTCH
36
# endif /* CNSUSP */
37
# endif /* __sgi */
38
#else
39
# ifdef _sys_termios
40
# include <sys/termios.h>
41
# define _hdr_termios
42
# endif /* _sys_termios */
43
#endif /* _hdr_termios */
44
#if !defined(TCSETS) && !defined(TCSANOW)
45
#undef _hdr_termios
46
#undef _sys_termios
47
#endif
48
#ifdef _hdr_termios
49
# ifndef TCSANOW
50
# define TCSANOW TCSETS
51
# define TCSADRAIN TCSETSW
52
# define TCSAFLUSH TCSETSF
53
# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
54
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
55
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
56
# endif /* TCSANOW */
57
/* the following is because of an ultrix bug */
58
# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
59
# define TCSAFLUSH TCSADFLUSH
60
# endif
61
# undef TIOCGETC
62
# undef _hdr_termio
63
# undef _sys_termio
64
# undef _hdr_sgtty
65
# undef _sys_ioctl
66
# undef _sys_bsdtty
67
#else
68
# undef OLDTERMIO
69
#endif /* _hdr_termios */
70
71
#ifdef _hdr_termio
72
# include <termio.h>
73
#else
74
# ifdef _sys_termio
75
# include <sys/termio.h>
76
# define _hdr_termio 1
77
# endif /* _sys_termio */
78
#endif /* _hdr_termio */
79
#if !defined(VEOL2) || !defined(TCGETA)
80
#undef _hdr_termio
81
#undef _sys_termio
82
#endif
83
#ifdef _hdr_termio
84
# define termios termio
85
# undef _hdr_sgtty
86
# undef TIOCGETC
87
# undef _sys_ioctl
88
# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
89
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
90
#endif /* _hdr_termio */
91
92
#ifdef _sys_bsdtty
93
# include <sys/bsdtty.h>
94
#endif /* _sys_bsdtty */
95
96
#ifdef _hdr_sgtty
97
# include <sgtty.h>
98
# ifdef _sys_nttyio
99
# ifndef LPENDIN
100
# include <sys/nttyio.h>
101
# endif /* LPENDIN */
102
# endif /* _sys_nttyio */
103
# define termios sgttyb
104
# undef _sys_ioctl
105
# ifdef TIOCSETN
106
# undef TCSETAW
107
# endif /* TIOCSETN */
108
# ifdef _SELECT_
109
# ifndef included_sys_time
110
# ifdef _sys_time
111
# include <sys/time.h>
112
# endif /* _sys_time */
113
# define included_sys_time
114
# endif /* included_sys_time */
115
extern const int tty_speeds[];
116
# endif /* _SELECT_ */
117
# ifdef TIOCGETP
118
# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
119
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
120
# else
121
# define tcgetattr(fd,tty) gtty(fd, tty)
122
# define tcsetattr(fd,action,tty) stty(fd, tty)
123
# endif /* TIOCGETP */
124
#endif /* _hdr_sgtty */
125
126
#ifndef TCSANOW
127
# ifdef TCSETAW
128
# define TCSANOW TCSETA
129
# ifdef u370
130
/* delays are too long, don't wait for output to drain */
131
# define TCSADRAIN TCSETA
132
# else
133
# define TCSADRAIN TCSETAW
134
# endif /* u370 */
135
# define TCSAFLUSH TCSETAF
136
# else
137
# ifdef TIOCSETN
138
# define TCSANOW TIOCSETN
139
# define TCSADRAIN TIOCSETN
140
# define TCSAFLUSH TIOCSETP
141
# endif /* TIOCSETN */
142
# endif /* TCSETAW */
143
#endif /* TCSANOW */
144
#endif /* _TERMINAL_H */
145
146
#ifndef _hdr_termios
147
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
148
#endif /* _hdr_termios */
149
/* set ECHOCTL if driver can echo control charaters as ^c */
150
#ifdef LCTLECH
151
# ifndef ECHOCTL
152
# define ECHOCTL LCTLECH
153
# endif /* !ECHOCTL */
154
#endif /* LCTLECH */
155
#ifdef LNEW_CTLECH
156
# ifndef ECHOCTL
157
# define ECHOCTL LNEW_CTLECH
158
# endif /* !ECHOCTL */
159
#endif /* LNEW_CTLECH */
160
#ifdef LNEW_PENDIN
161
# ifndef PENDIN
162
# define PENDIN LNEW_PENDIN
163
# endif /* !PENDIN */
164
#endif /* LNEW_PENDIN */
165
#ifndef ECHOCTL
166
# ifndef VEOL2
167
# define RAWONLY 1
168
# endif /* !VEOL2 */
169
#endif /* !ECHOCTL */
170
171
#ifdef _sys_filio
172
# ifndef FIONREAD
173
# include <sys/filio.h>
174
# endif /* FIONREAD */
175
#endif /* _sys_filio */
176
/* set FIORDCHK if you can check for characters in input queue */
177
#ifdef FIONREAD
178
# ifndef FIORDCHK
179
# define FIORDCHK FIONREAD
180
# endif /* !FIORDCHK */
181
#endif /* FIONREAD */
182
183
#ifdef PROTO
184
extern int tty_alt(int);
185
extern void tty_cooked(int);
186
extern int tty_get(int,struct termios*);
187
extern int tty_raw(int);
188
extern int tty_check(int);
189
#else
190
extern int tty_alt();
191
extern void tty_cooked();
192
extern int tty_get();
193
extern int tty_raw();
194
extern int tty_check();
195
#endif /* PROTO */
196
extern int tty_set();
197
198