Mercurial > hg > xemacs-beta
comparison src/systty.h @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | 0132846995bd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 /* systty.h - System-dependent definitions for terminals. | |
2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. | |
3 | |
4 This file is part of XEmacs. | |
5 | |
6 XEmacs is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
8 Free Software Foundation; either version 2, or (at your option) any | |
9 later version. | |
10 | |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with XEmacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 Boston, MA 02111-1307, USA. */ | |
20 | |
21 /* Synched up with: FSF 19.30. */ | |
22 | |
23 #ifndef _XEMACS_SYSTTY_H_ | |
24 #define _XEMACS_SYSTTY_H_ | |
25 | |
26 #ifdef HAVE_TERMIOS | |
27 # define HAVE_TCATTR | |
28 #endif | |
29 | |
30 /* If we defined these before and we are about to redefine them, | |
31 prevent alarming warnings. */ | |
32 #ifdef BSD_TERMIOS | |
33 #undef NL0 | |
34 #undef NL1 | |
35 #undef CR0 | |
36 #undef CR1 | |
37 #undef CR2 | |
38 #undef CR3 | |
39 #undef TAB0 | |
40 #undef TAB1 | |
41 #undef TAB2 | |
42 #undef XTABS | |
43 #undef BS0 | |
44 #undef BS1 | |
45 #undef FF0 | |
46 #undef FF1 | |
47 #undef ECHO | |
48 #undef NOFLSH | |
49 #undef TOSTOP | |
50 #undef FLUSHO | |
51 #undef PENDIN | |
52 #endif | |
53 | |
54 /* Include the proper files. */ | |
55 | |
56 /* XEmacs: TERMIOS is mo' better than TERMIO so we use it if it's | |
57 there. Since TERMIO is backward-compatibility stuff if both it | |
58 and TERMIOS exist, it's more likely to be broken. */ | |
59 | |
60 #if defined (HAVE_TERMIOS) | |
61 | |
62 /***** (1) The TERMIOS way (POSIX style) *****/ | |
63 | |
64 # if defined (_AIX) && defined (_I386) | |
65 # include <termios.h> /* termios.h needs to be before termio.h */ | |
66 # include <termio.h> | |
67 # else | |
68 # if !defined (NO_TERMIO) | |
69 # include <termio.h> | |
70 # endif | |
71 # include <termios.h> | |
72 # endif /* _AIX && _I386 */ | |
73 # ifndef INCLUDED_FCNTL | |
74 # define INCLUDED_FCNTL | |
75 # include <fcntl.h> | |
76 # endif | |
77 | |
78 #elif defined (HAVE_TERMIO) | |
79 | |
80 /***** (2) The TERMIO way (system V style) *****/ | |
81 | |
82 # ifdef __DGUX | |
83 # include <sys/ioctl.h> | |
84 # endif | |
85 # ifndef NO_TERMIO | |
86 # include <termio.h> | |
87 # endif /* not NO_TERMIO */ | |
88 # ifndef INCLUDED_FCNTL | |
89 # define INCLUDED_FCNTL | |
90 # include <fcntl.h> | |
91 # endif | |
92 | |
93 #elif defined (DOS_NT) | |
94 | |
95 /***** (3) The MSDOS/NT way *****/ | |
96 | |
97 /* Nothing doing */ | |
98 | |
99 #elif !defined (VMS) | |
100 | |
101 /***** (4) The BSD way *****/ | |
102 | |
103 # ifdef linux /* XEmacs addition -- necessary? */ | |
104 # include <bsd/sgtty.h> | |
105 # else | |
106 # include <sgtty.h> | |
107 # endif | |
108 | |
109 #else /* VMS */ | |
110 | |
111 /***** (5) The VMS way *****/ | |
112 | |
113 # include <descrip.h> | |
114 static struct iosb | |
115 { | |
116 short status; | |
117 short offset; | |
118 short termlen; | |
119 short term; | |
120 } input_iosb; | |
121 | |
122 extern int vms_waiting_for_ast; | |
123 extern int vms_stop_input; | |
124 extern int vms_input_ef; | |
125 extern int vms_timer_ef; | |
126 extern int vms_process_ef; | |
127 extern int vms_input_eflist; | |
128 extern int vms_timer_eflist; | |
129 | |
130 static $DESCRIPTOR (vms_input_dsc, "TT"); | |
131 static int vms_terminator_mask[2] = { 0, 0 }; | |
132 | |
133 static struct sensemode { | |
134 short status; | |
135 unsigned char xmit_baud; | |
136 unsigned char rcv_baud; | |
137 unsigned char crfill; | |
138 unsigned char lffill; | |
139 unsigned char parity; | |
140 unsigned char unused; | |
141 char class; | |
142 char type; | |
143 short scr_wid; | |
144 unsigned long tt_char : 24, scr_len : 8; | |
145 unsigned long tt2_char; | |
146 } sensemode_iosb; | |
147 | |
148 #endif /* VMS */ | |
149 | |
150 /* XEmacs: I don't think we need the following crap. */ | |
151 #ifdef __GNU_LIBRARY__ | |
152 #include <termios.h> | |
153 #endif | |
154 | |
155 /* Formerly there was a conditional that included sys/filio.h if | |
156 USG5_4 was defined, but this is already included in s/usg5-4.h */ | |
157 | |
158 /* Generally useful to include this file: */ | |
159 | |
160 /* But Sun OS has broken include files and doesn't want it included */ | |
161 #if !defined (VMS) && !defined (DOS_NT) && !defined (WIN32) && !defined (SUNOS4) | |
162 # include <sys/ioctl.h> | |
163 #endif | |
164 /* UNIPLUS systems may have FIONREAD. */ | |
165 #ifdef UNIPLUS | |
166 #include <sys.ioctl.h> | |
167 #endif | |
168 | |
169 | |
170 /* ----------------------------------------------------- */ | |
171 /* miscellaneous includes */ | |
172 /* ----------------------------------------------------- */ | |
173 | |
174 #ifdef AIXHFT | |
175 /* Get files for keyboard remapping */ | |
176 #define HFNKEYS 2 | |
177 #include <sys/hft.h> | |
178 #include <sys/devinfo.h> | |
179 #endif | |
180 | |
181 /* XEmacs: We don't support BSD 4.1 any more */ | |
182 | |
183 #ifdef NEED_BSDTTY | |
184 #include <sys/bsdtty.h> | |
185 #endif | |
186 | |
187 /* Include files for PTY's */ | |
188 | |
189 #if defined (HPUX) && defined (HAVE_PTYS) | |
190 #include <sys/ptyio.h> | |
191 #endif | |
192 | |
193 #ifdef AIX | |
194 #include <sys/pty.h> | |
195 #endif /* AIX */ | |
196 | |
197 /* XEmacs: We don't include unistd.h because it's done in lisp.h */ | |
198 | |
199 #ifdef SYSV_PTYS | |
200 # include <sys/types.h> | |
201 # include <sys/tty.h> | |
202 # ifdef titan | |
203 # include <sys/ttyhw.h> | |
204 # include <sys/stream.h> | |
205 # endif | |
206 # ifndef NO_PTY_H | |
207 # include <sys/pty.h> | |
208 # endif | |
209 #endif | |
210 | |
211 /* XEmacs: removed some random if defined (pfa) crap for FASYNC (SIGIO). | |
212 We've cleaned SIGIO up. */ | |
213 | |
214 | |
215 /* ----------------------------------------------------- */ | |
216 /* inhibiting particular features */ | |
217 /* ----------------------------------------------------- */ | |
218 | |
219 | |
220 #ifdef APOLLO | |
221 #undef TIOCSTART | |
222 #endif | |
223 | |
224 #if defined (XENIX) || defined (BROKEN_TIOCGETC) | |
225 #undef TIOCGETC /* Avoid confusing some conditionals that test this. */ | |
226 #endif | |
227 | |
228 /* XEmacs: SIGIO is cleaned up so we remove the crap here that messes | |
229 with it (and FIONREAD and FASYNC, which are related). */ | |
230 | |
231 #ifdef BROKEN_TIOCGWINSZ /* XEmacs addition */ | |
232 #undef TIOCGWINSZ | |
233 #undef TIOCSWINSZ | |
234 #endif | |
235 | |
236 #ifdef BROKEN_O_NONBLOCK /* XEmacs addition */ | |
237 # undef O_NONBLOCK | |
238 #endif /* BROKEN_O_NONBLOCK */ | |
239 | |
240 /* On TERMIOS systems, the tcmumbleattr calls take care of these | |
241 parameters, and it's a bad idea to use them (on AIX, it makes the | |
242 tty hang for a long time). */ | |
243 #if defined (TIOCGLTC) && !defined (HAVE_TERMIOS) | |
244 #define HAVE_LTCHARS | |
245 #endif | |
246 | |
247 #if defined (TIOCGETC) && !defined (HAVE_TERMIOS) | |
248 #define HAVE_TCHARS | |
249 #endif | |
250 | |
251 | |
252 /* ----------------------------------------------------- */ | |
253 /* disabling terminal functions */ | |
254 /* ----------------------------------------------------- */ | |
255 | |
256 /* Try to establish the correct character to disable terminal functions | |
257 in a system-independent manner. Note that USG (at least) define | |
258 _POSIX_VDISABLE as 0! */ | |
259 | |
260 #ifdef _POSIX_VDISABLE | |
261 #define CDISABLE _POSIX_VDISABLE | |
262 #else /* not _POSIX_VDISABLE */ | |
263 #ifdef CDEL | |
264 #undef CDISABLE | |
265 #define CDISABLE CDEL | |
266 #else /* not CDEL */ | |
267 #define CDISABLE 255 | |
268 #endif /* not CDEL */ | |
269 #endif /* not _POSIX_VDISABLE */ | |
270 | |
271 | |
272 /* ----------------------------------------------------- */ | |
273 /* Get the number of characters queued for output */ | |
274 /* ----------------------------------------------------- */ | |
275 | |
276 /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters | |
277 queued for output to the terminal FD in *SIZE, if FD is a tty. | |
278 Returns -1 if there was an error (i.e. FD is not a tty), 0 | |
279 otherwise. */ | |
280 #ifdef TIOCOUTQ | |
281 #define EMACS_OUTQSIZE(fd, size) ioctl (fd, TIOCOUTQ, size) | |
282 #endif | |
283 | |
284 #ifdef HAVE_TERMIO | |
285 #ifdef TCOUTQ | |
286 #undef EMACS_OUTQSIZE | |
287 #define EMACS_OUTQSIZE(fd, size) ioctl (fd, TCOUTQ, size) | |
288 #endif | |
289 #endif | |
290 | |
291 | |
292 /* -------------------------------------------------------------------- */ | |
293 /* Manipulate a terminal's current (foreground) process group */ | |
294 /* -------------------------------------------------------------------- */ | |
295 | |
296 /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current | |
297 controlling process group. | |
298 | |
299 EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's | |
300 current process group. Return -1 if there is an error. | |
301 | |
302 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's | |
303 current process group to *PGID. Return -1 if there is an error. */ | |
304 | |
305 /* HPUX tty process group stuff doesn't work, says the anonymous voice | |
306 from the past. */ | |
307 /* But HPUX people say it does, so I've removed it. --ben */ | |
308 # ifdef TIOCGPGRP | |
309 # define EMACS_HAVE_TTY_PGRP | |
310 # else | |
311 # ifdef HAVE_TERMIOS | |
312 # define EMACS_HAVE_TTY_PGRP | |
313 # endif | |
314 # endif | |
315 | |
316 #ifdef EMACS_HAVE_TTY_PGRP | |
317 | |
318 #if defined (HAVE_TERMIOS) && ! defined (BSD_TERMIOS) | |
319 | |
320 /* Resist the urge to insert needless extra parentheses. */ | |
321 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp (fd)) | |
322 #define EMACS_SET_TTY_PGRP(fd, pgid) tcsetpgrp (fd, *(pgid)) | |
323 | |
324 #elif defined (TIOCSPGRP) | |
325 | |
326 #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid))) | |
327 #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid))) | |
328 | |
329 #endif | |
330 | |
331 #endif /* EMACS_HAVE_TTY_PGRP */ | |
332 | |
333 #ifndef EMACS_GET_TTY_PGRP | |
334 | |
335 /* Just ignore this for now and hope for the best */ | |
336 #define EMACS_GET_TTY_PGRP(fd, pgid) 0 | |
337 #define EMACS_SET_TTY_PGRP(fd, pgif) 0 | |
338 | |
339 #endif | |
340 | |
341 /* XEmacs interim backward-compatibility */ | |
342 #define EMACS_GET_TTY_PROCESS_GROUP EMACS_GET_TTY_PGRP | |
343 #define EMACS_SET_TTY_PROCESS_GROUP EMACS_SET_TTY_PGRP | |
344 | |
345 /* EMACS_GETPGRP (arg) returns the process group of the terminal. */ | |
346 | |
347 /* USG systems have always used the no-arg form of getpgrp(). | |
348 POSIX also calls for this, and thus some newer BSD systems | |
349 have this change. Older BSD systems have an argument. | |
350 It would be nice to autodetect this, but there's unfortunately | |
351 no general way. */ | |
352 | |
353 /* XEmacs backwards-compatibility */ | |
354 #ifdef GETPGRP_NEEDS_ARG | |
355 # undef GETPGRP_NO_ARG | |
356 #else | |
357 # ifdef GETPGRP_NO_ARG | |
358 # undef GETPGRP_NEEDS_ARG | |
359 # endif | |
360 #endif | |
361 | |
362 #if defined (USG) && !defined (GETPGRP_NEEDS_ARG) | |
363 # if !defined (GETPGRP_NO_ARG) | |
364 # define GETPGRP_NO_ARG | |
365 # endif | |
366 #endif | |
367 | |
368 #if defined (GETPGRP_NO_ARG) | |
369 # define EMACS_GETPGRP(x) getpgrp() | |
370 #else | |
371 # define EMACS_GETPGRP(x) getpgrp(x) | |
372 #endif /* !GETPGRP_NO_ARG */ | |
373 | |
374 /* XEmacs backward-compatibility. Is 0 always a reasonable argument? */ | |
375 #define EMACS_GET_PROCESS_GROUP() EMACS_GETPGRP (0) | |
376 | |
377 /* Xemacs addition? */ | |
378 | |
379 /* EMACS_SEPARATE_PROCESS_GROUP () creates a separate process group for the | |
380 running process. */ | |
381 | |
382 /* EMACS_SET_PROCESS_GROUP () sets our process group as specified. */ | |
383 | |
384 /* POSIX calls for setpgid(), so we use it if it's available. | |
385 Otherwise use setpgrp(), in USG or BSD flavor. Note that | |
386 on newer systems, setpgrp() has unwanted effects (e.g. | |
387 creating a new session), so we want to avoid its use | |
388 if possible. | |
389 | |
390 NOTE: On some older systems, we should consider using setpgrp2() | |
391 if it exists. This is sufficiently rare, though, that there | |
392 seems no point in autodetecting it. Currently dgux.h is the | |
393 only place where this has to be munged. */ | |
394 | |
395 #if defined (HAVE_SETPGID) | |
396 # define EMACS_SEPARATE_PROCESS_GROUP() setpgid (0, 0) | |
397 # define EMACS_SET_PROCESS_GROUP(pg) setpgid (0, pg) | |
398 #elif defined (USG) | |
399 # define EMACS_SEPARATE_PROCESS_GROUP() setpgrp () | |
400 /* old (pre-SVR4) USG's don't provide any way to do this. | |
401 No big loss -- it just means that ^Z won't work right | |
402 if we're run from sh. */ | |
403 # define EMACS_SET_PROCESS_GROUP(pg) | |
404 #else | |
405 /* Under NeXTstep, a process group of 0 is not the same as specifying | |
406 your own process ID, so we go ahead and specify it explicitly. */ | |
407 # define EMACS_SEPARATE_PROCESS_GROUP() setpgrp (0, getpid ()) | |
408 # define EMACS_SET_PROCESS_GROUP(pg) setpgrp (0, pg) | |
409 #endif | |
410 | |
411 | |
412 /* --------------------------------------------------------- */ | |
413 /* Manipulate a TTY's input/output processing parameters */ | |
414 /* --------------------------------------------------------- */ | |
415 | |
416 /* struct emacs_tty is a structure used to hold the current tty | |
417 parameters. If the terminal has several structures describing its | |
418 state, for example a struct tchars, a struct sgttyb, a struct | |
419 tchars, a struct ltchars, and a struct pagechars, struct | |
420 emacs_tty should contain an element for each parameter struct | |
421 that Emacs may change. | |
422 | |
423 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the parameters | |
424 of the tty on FD in *P. Return zero if all's well, or -1 if we ran | |
425 into an error we couldn't deal with. | |
426 | |
427 EMACS_SET_TTY (int FD, struct emacs_tty *P, int flushp) | |
428 sets the parameters of the tty on FD according to the contents of | |
429 *P. If flushp is non-zero, we discard queued input to be | |
430 written before making the change. | |
431 Return 0 if all went well, and -1 if anything failed. | |
432 | |
433 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel | |
434 expands tabs to spaces upon output; in that case, there is no | |
435 advantage to using tabs over spaces. */ | |
436 | |
437 | |
438 /* For each tty parameter structure that Emacs might want to save and restore, | |
439 - include an element for it in this structure, and | |
440 - extend the emacs_{get,set}_tty functions in sysdep.c to deal with the | |
441 new members. */ | |
442 | |
443 struct emacs_tty { | |
444 | |
445 /* There is always one of the following elements, so there is no need | |
446 for dummy get and set definitions. */ | |
447 #ifdef HAVE_TCATTR | |
448 struct termios main; | |
449 #else | |
450 #ifdef HAVE_TERMIO | |
451 struct termio main; | |
452 #else | |
453 #ifdef VMS | |
454 struct sensemode main; | |
455 #else | |
456 #ifdef DOS_NT | |
457 int main; | |
458 #else /* not DOS_NT */ | |
459 struct sgttyb main; | |
460 #endif /* not DOS_NT */ | |
461 #endif /* !VMS */ | |
462 #endif | |
463 #endif | |
464 | |
465 /* If we have TERMIOS, we don't need to do this - they're taken care of | |
466 by the tc*attr calls. */ | |
467 #ifndef HAVE_TERMIOS | |
468 #ifdef HAVE_LTCHARS | |
469 struct ltchars ltchars; | |
470 #endif | |
471 | |
472 #ifdef HAVE_TCHARS | |
473 struct tchars tchars; | |
474 int lmode; | |
475 #endif | |
476 #endif | |
477 }; | |
478 | |
479 /* Define EMACS_GET_TTY and EMACS_SET_TTY, | |
480 the macros for reading and setting parts of `struct emacs_tty'. | |
481 | |
482 These got pretty unmanageable (huge macros are hard to debug), and | |
483 finally needed some code which couldn't be done as part of an | |
484 expression, so we moved them out to their own functions in sysdep.c. */ | |
485 #define EMACS_GET_TTY(fd, p) emacs_get_tty (fd, p) | |
486 #define EMACS_SET_TTY(fd, p, waitp) emacs_set_tty (fd, p, waitp) | |
487 | |
488 | |
489 /* --------------------------------------------------------- */ | |
490 /* Define EMACS_TTY_TABS_OK */ | |
491 /* --------------------------------------------------------- */ | |
492 | |
493 #ifdef HAVE_TERMIOS | |
494 | |
495 #ifdef TABDLY | |
496 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) | |
497 #else | |
498 #define EMACS_TTY_TABS_OK(p) 1 | |
499 #endif | |
500 | |
501 #else /* not def HAVE_TERMIOS */ | |
502 #ifdef HAVE_TERMIO | |
503 | |
504 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) | |
505 | |
506 #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ | |
507 #ifdef VMS | |
508 | |
509 #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0) | |
510 | |
511 #else | |
512 | |
513 #ifdef DOS_NT | |
514 #define EMACS_TTY_TABS_OK(p) 0 | |
515 #else /* not DOS_NT */ | |
516 #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS) | |
517 #endif /* not DOS_NT */ | |
518 | |
519 #endif /* not def VMS */ | |
520 #endif /* not def HAVE_TERMIO */ | |
521 #endif /* not def HAVE_TERMIOS */ | |
522 | |
523 #endif /* _XEMACS_SYSTTY_H_ */ |