Document sun change.
[bpt/emacs.git] / src / systty.h
CommitLineData
a04c9535 1/* systty.h - System-dependent definitions for terminals.
d0d6b7c5
JB
2 Copyright (C) 1992 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
2182d459
RS
20#ifdef HAVE_TERMIOS
21#define HAVE_TCATTR
22#endif
d0d6b7c5
JB
23\f
24/* Include the proper files. */
25#ifdef HAVE_TERMIO
26#include <termio.h>
27#include <fcntl.h>
28#else
29#ifdef HAVE_TERMIOS
30#include <termio.h>
31#include <termios.h>
1aaaff21 32#include <fcntl.h>
d0d6b7c5
JB
33#else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
34#ifndef VMS
35#include <sgtty.h>
a04c9535
JB
36#else /* VMS */
37#include <descrip.h>
38static struct iosb
39{
40 short status;
41 short offset;
42 short termlen;
43 short term;
44} input_iosb;
45
46extern int waiting_for_ast;
47extern int stop_input;
210b2b4f 48#if 0 /* VAX C doeasn't understand initializing declarations */
a04c9535
JB
49extern int input_ef = 0;
50extern int timer_ef = 0;
51extern int process_ef = 0;
210b2b4f
JB
52#else
53extern int input_ef;
54extern int timer_ef;
55extern int process_ef;
56#endif
a04c9535
JB
57extern int input_eflist;
58extern int timer_eflist;
59
60static $DESCRIPTOR (input_dsc, "TT");
61static int terminator_mask[2] = { 0, 0 };
62
63static struct sensemode {
64 short status;
65 unsigned char xmit_baud;
66 unsigned char rcv_baud;
67 unsigned char crfill;
68 unsigned char lffill;
69 unsigned char parity;
70 unsigned char unused;
71 char class;
72 char type;
73 short scr_wid;
74 unsigned long tt_char : 24, scr_len : 8;
75 unsigned long tt2_char;
76} sensemode_iosb;
77#endif /* VMS */
d0d6b7c5
JB
78#endif /* not HAVE_TERMIOS */
79#endif /* not HAVE_TERMIO */
80
4746118a
JB
81#ifdef AIX
82/* Get files for keyboard remapping */
83#define HFNKEYS 2
84#include <sys/hft.h>
85#include <sys/devinfo.h>
86#endif
87
88/* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs. */
89#ifdef BSD4_1
90#undef LLITOUT
91#define LLITOUT 0
92#endif /* 4.1 */
93
94#ifdef NEED_BSDTTY
95#include <sys/bsdtty.h>
96#endif
97
98#if defined (HPUX) && defined (HAVE_PTYS)
99#include <sys/ptyio.h>
100#endif
101
102#ifdef AIX
103#include <sys/pty.h>
104#include <unistd.h>
105#endif /* AIX */
106
107#ifdef SYSV_PTYS
108#include <sys/tty.h>
ffd56f97
JB
109#ifdef titan
110#include <sys/ttyhw.h>
111#include <sys/stream.h>
112#endif
372d3c2e 113#ifndef NO_PTY_H
4746118a
JB
114#include <sys/pty.h>
115#endif
372d3c2e 116#endif
4746118a
JB
117
118/* saka@pfu.fujitsu.co.JP writes:
119 FASYNC defined in this file. But, FASYNC don't working.
120 so no problem, because unrequest_sigio only need. */
121#if defined (pfa)
122#include <sys/file.h>
123#endif
124
d0d6b7c5
JB
125\f
126/* Special cases - inhibiting the use of certain features. */
127
128#ifdef APOLLO
129#undef TIOCSTART
130#endif
131
ffd56f97
JB
132#ifdef XENIX
133#undef TIOCGETC /* Avoid confusing some conditionals that test this. */
134#endif
135
d0d6b7c5
JB
136#ifdef BROKEN_TIOCGETC
137#undef TIOCGETC /* Avoid confusing some conditionals that test this. */
138#endif
139
140/* UNIPLUS systems may have FIONREAD. */
141#ifdef UNIPLUS
142#include <sys.ioctl.h>
143#endif
144
145/* Allow m- file to inhibit use of FIONREAD. */
146#ifdef BROKEN_FIONREAD
147#undef FIONREAD
148#undef ASYNC
149#endif
150
151/* Interupt input is not used if there is no FIONREAD. */
152#ifndef FIONREAD
153#undef SIGIO
154#endif
155
156\f
2102829e
RS
157/* Try to establish the correct character to disable terminal functions
158 in a system-independent manner. Note that USG (at least) define
159 _POSIX_VDISABLE as 0! */
160
161#ifdef _POSIX_VDISABLE
162#define CDISABLE _POSIX_VDISABLE
163#else /* not _POSIX_VDISABLE */
164#ifdef CDEL
165#define CDISABLE CDEL
166#else /* not CDEL */
167#define CDISABLE 255
168#endif /* not CDEL */
169#endif /* not _POSIX_VDISABLE */
170\f
d0d6b7c5
JB
171/* Get the number of characters queued for output. */
172
173/* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters
174 queued for output to the terminal FD in *SIZE, if FD is a tty.
175 Returns -1 if there was an error (i.e. FD is not a tty), 0
176 otherwise. */
177#ifdef TIOCOUTQ
178#define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
179#endif
180
181#ifdef HAVE_TERMIO
182#ifdef TCOUTQ
183#undef EMACS_OUTQSIZE
184#define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
185#endif
186#endif
187
188\f
189/* Manipulate a terminal's current process group. */
190
191/* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
192 controlling process group.
193
194 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
195 current process group. Return -1 if there is an error.
196
197 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
198 current process group to *PGID. Return -1 if there is an error. */
199
ffd56f97
JB
200#ifdef HPUX
201/* HPUX tty process group stuff doesn't work, says the anonymous voice
202 from the past. */
203#else
d0d6b7c5
JB
204#ifdef TIOCGPGRP
205#define EMACS_HAVE_TTY_PGRP
206#else
207#ifdef HAVE_TERMIOS
208#define EMACS_HAVE_TTY_PGRP
209#endif
210#endif
ffd56f97 211#endif
d0d6b7c5
JB
212
213#ifdef EMACS_HAVE_TTY_PGRP
214
215#ifdef HAVE_TERMIOS
216
217#define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
218#define EMACS_SET_TTY_PGRP(fd, pgid) (*(pgid) = tcsetpgrp ((fd)))
219
220#else
221#ifdef TIOCSPGRP
222
223#define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
224#define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
225
226#endif
227#endif
228
229#else
230
231/* Just ignore this for now and hope for the best */
232#define EMACS_GET_TTY_PGRP(fd, pgid) 0
ef15f270 233#define EMACS_SET_TTY_PGRP(fd, pgif) 0
d0d6b7c5
JB
234
235#endif
236
237\f
238/* Manipulate a TTY's input/output processing parameters. */
239
240/* struct emacs_tty is a structure used to hold the current tty
241 parameters. If the terminal has several structures describing its
242 state, for example a struct tchars, a struct sgttyb, a struct
243 tchars, a struct ltchars, and a struct pagechars, struct
244 emacs_tty should contain an element for each parameter struct
245 that Emacs may change.
246
247 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the
248 parameters of the tty on FD in *P.
249
250 EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp)
251 sets the parameters of the tty on FD according to the contents of
252 *P. If waitp is non-zero, we wait for all queued output to be
253 written before making the change; otherwise, we forget any queued
254 input and make the change immediately.
255
256 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel
257 expands tabs to spaces upon output; in that case, there is no
258 advantage to using tabs over spaces. */
259
260
d0d6b7c5
JB
261/* For each tty parameter structure that Emacs might want to save and restore,
262 - include an element for it in this structure,
263 - define a pair of numbered macros to get and set it and return
264 true iff the call succeeded,
265 - give alternative definitions for when the component is not implemented
266 which always succeed, and
267 - extend the definition of EMACS_{GET,SET}_TTY_CHARS to include the
268 new macros. */
269
270struct emacs_tty {
271
272/* There is always one of the following elements, so there is no need
273 for dummy get and set definitions. */
2182d459 274#ifdef HAVE_TCATTR
d0d6b7c5
JB
275 struct termios main;
276#else
277#ifdef HAVE_TERMIO
278 struct termio main;
279#else
280#ifdef VMS
281 struct sensemode main;
282#else
283 struct sgttyb main;
284#endif
285#endif
286#endif
2182d459
RS
287#ifdef TIOCGLTC
288 struct ltchars ltchars;
289#endif
290#ifdef TIOCGETC
291 struct tchars tchars;
292 int lmode;
d0d6b7c5 293#endif
2182d459
RS
294};
295\f
296/* Define EMACS_GET_TTY and EMACS_SET_TTY,
c2e4f49a 297 the macros for reading and setting parts of `struct emacs_tty'.
d0d6b7c5 298
c2e4f49a
JB
299 These got pretty unmanageable (huge macros are hard to debug), and
300 finally needed some code which couldn't be done as part of an
301 expression, so we moved them out to their own functions in sysdep.c. */
302#define EMACS_GET_TTY(fd, p) (emacs_get_tty ((fd), (p)))
303#define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
d0d6b7c5 304
2182d459
RS
305\f
306/* Define EMACS_TTY_TABS_OK. */
d0d6b7c5
JB
307
308#ifdef HAVE_TERMIOS
309
310#define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
311
312#else /* not def HAVE_TERMIOS */
313#ifdef HAVE_TERMIO
314
315#define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
316
317#else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
318#ifdef VMS
319
320#define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
321
322#else
323
324#define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
325
326#endif /* not def VMS */
327#endif /* not def HAVE_TERMIO */
328#endif /* not def HAVE_TERMIOS */