Mercurial > emacs
annotate src/sysdep.c @ 43403:fef73ecd984e
(calc-split-manual): Look for calc.texi.
(calc-public-autoloads): Obsolete; remove.
(calc-private-autoloads): Ditto.
(calc-add-autoloads): Ditto.
author | Colin Walters <walters@gnu.org> |
---|---|
date | Mon, 18 Feb 2002 20:06:07 +0000 |
parents | de51098df2fd |
children | 009de2eaf047 1918306a80b1 |
rev | line source |
---|---|
491 | 1 /* Interfaces to system-dependent kernel and library entries. |
35078 | 2 Copyright (C) 1985, 86,87,88,93,94,95, 1999, 2000, 2001 |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
3 Free Software Foundation, Inc. |
491 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
491 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13943
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13943
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
491 | 21 |
42469 | 22 #ifdef HAVE_CONFIG_H |
23 #include <config.h> | |
24 #endif | |
25 | |
491 | 26 #include <signal.h> |
27 #include <setjmp.h> | |
29387
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
28 #ifdef HAVE_UNISTD_H |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
29 #include <unistd.h> |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
30 #endif |
491 | 31 #include "lisp.h" |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
32 /* Including stdlib.h isn't necessarily enough to get srandom |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
33 declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */ |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
34 #ifdef HAVE_RANDOM |
35189 | 35 #if 0 /* It turns out that defining _OSF_SOURCE in osf5-0.h gets |
36 random prototyped as returning `int'. It looks to me as | |
37 though the best way to DTRT is to prefer the rand48 functions | |
38 (per libc.info). -- fx */ | |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
39 extern long int random P_ ((void)); |
35189 | 40 #endif |
35077
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
41 #if 0 /* Don't prototype srandom; it takes an unsigned argument on |
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
42 some systems, and an unsigned long on others, like FreeBSD |
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
43 4.1. */ |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
44 extern void srandom P_ ((unsigned int)); |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
45 #endif |
35077
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
46 #endif |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
47 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
48 #include "blockinput.h" |
491 | 49 #undef NULL |
50 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
51 #ifdef macintosh |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
52 /* It is essential to include stdlib.h so that this file picks up |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
53 the correct definitions of rand, srand, and RAND_MAX. |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
54 Otherwise random numbers will not work correctly. */ |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
55 #include <stdlib.h> |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
56 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
57 #ifndef subprocesses |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
58 /* Nonzero means delete a process right away if it exits (process.c). */ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
59 static int delete_exited_processes; |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
60 #endif |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
61 #endif /* macintosh */ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
62 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
63 #ifdef WINDOWSNT |
27933
ea5807a5d84e
[WINDOWSNT]: Use sys_read and sys_write to ensure correct line-ending
Jason Rumney <jasonr@gnu.org>
parents:
27922
diff
changeset
|
64 #define read sys_read |
ea5807a5d84e
[WINDOWSNT]: Use sys_read and sys_write to ensure correct line-ending
Jason Rumney <jasonr@gnu.org>
parents:
27922
diff
changeset
|
65 #define write sys_write |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
66 #include <windows.h> |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
67 #ifndef NULL |
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
68 #define NULL 0 |
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
69 #endif |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
70 #endif /* not WINDOWSNT */ |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
71 |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
72 /* Does anyone other than VMS need this? */ |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
73 #ifndef fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
74 #define sys_fwrite fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
75 #else |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
76 #undef fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
77 #endif |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
78 |
491 | 79 #include <stdio.h> |
80 #include <sys/types.h> | |
81 #include <sys/stat.h> | |
82 #include <errno.h> | |
83 | |
11624
5c151211d571
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
11391
diff
changeset
|
84 /* Get _POSIX_VDISABLE, if it is available. */ |
5c151211d571
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
11391
diff
changeset
|
85 #ifdef HAVE_UNISTD_H |
5c151211d571
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
11391
diff
changeset
|
86 #include <unistd.h> |
5c151211d571
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
11391
diff
changeset
|
87 #endif |
5c151211d571
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
11391
diff
changeset
|
88 |
29387
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
89 #ifdef HAVE_STDLIB_H |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
90 #include <stdlib.h> |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
91 #endif |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
92 |
29125
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
93 #ifdef HAVE_SETPGID |
29150
0398ec3316c5
(setpgrp): Don't define if USG and BSD_PGRPS are not defined.
Gerd Moellmann <gerd@gnu.org>
parents:
29125
diff
changeset
|
94 #if !defined (USG) || defined (BSD_PGRPS) |
29911
02b0c6c15f1c
Undefine setpgrp before setting it.
Dave Love <fx@gnu.org>
parents:
29812
diff
changeset
|
95 #undef setpgrp |
29125
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
96 #define setpgrp setpgid |
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
97 #endif |
29150
0398ec3316c5
(setpgrp): Don't define if USG and BSD_PGRPS are not defined.
Gerd Moellmann <gerd@gnu.org>
parents:
29125
diff
changeset
|
98 #endif |
29125
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
99 |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
100 /* Get SI_SRPC_DOMAIN, if it is available. */ |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
101 #ifdef HAVE_SYS_SYSTEMINFO_H |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
102 #include <sys/systeminfo.h> |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
103 #endif |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
104 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
105 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
106 #include <dos.h> |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
107 #include "dosfns.h" |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
108 #include "msdos.h" |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
109 #include <sys/param.h> |
14971
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
110 |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
111 #if __DJGPP__ > 1 |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
112 extern int etext; |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
113 extern unsigned start __asm__ ("start"); |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
114 #endif |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
115 #endif |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
116 |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
117 #ifndef USE_CRT_DLL |
25453
61fb4dde8684
Include <stdlib.h> if available. Declare errno only if it is not a macro.
Andreas Schwab <schwab@suse.de>
parents:
25431
diff
changeset
|
118 #ifndef errno |
491 | 119 extern int errno; |
25453
61fb4dde8684
Include <stdlib.h> if available. Declare errno only if it is not a macro.
Andreas Schwab <schwab@suse.de>
parents:
25431
diff
changeset
|
120 #endif |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
121 #endif |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
122 |
5533
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
123 #ifdef VMS |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
124 #include <rms.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
125 #include <ttdef.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
126 #include <tt2def.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
127 #include <iodef.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
128 #include <ssdef.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
129 #include <descrip.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
130 #include <fibdef.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
131 #include <atrdef.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
132 #include <ctype.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
133 #include <string.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
134 #ifdef __GNUC__ |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
135 #include <sys/file.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
136 #else |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
137 #include <file.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
138 #endif |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
139 #undef F_SETFL |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
140 #ifndef RAB$C_BID |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
141 #include <rab.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
142 #endif |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
143 #define MAXIOSIZE (32 * PAGESIZE) /* Don't I/O more than 32 blocks at a time */ |
5533
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
144 #endif /* VMS */ |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
145 |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
146 #ifndef BSD4_1 |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
147 #ifdef BSD_SYSTEM /* avoid writing defined (BSD_SYSTEM) || defined (USG) |
5533
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
148 because the vms compiler doesn't grok `defined' */ |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
149 #include <fcntl.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
150 #endif |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
151 #ifdef USG |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
152 #ifndef USG5 |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
153 #include <fcntl.h> |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
154 #endif |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
155 #endif |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
156 #endif /* not 4.1 bsd */ |
491 | 157 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
158 #ifndef MSDOS |
491 | 159 #include <sys/ioctl.h> |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
160 #endif |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
161 |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
162 #include "systty.h" |
4640 | 163 #include "syswait.h" |
491 | 164 |
165 #ifdef BROKEN_TIOCGWINSZ | |
166 #undef TIOCGWINSZ | |
7559
c786925f32a5
[BROKEN_TIOCGWINSZ]: Undef TIOCSWINSZ too.
Richard M. Stallman <rms@gnu.org>
parents:
7482
diff
changeset
|
167 #undef TIOCSWINSZ |
491 | 168 #endif |
169 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
170 #if defined (USG) || defined (DGUX) |
491 | 171 #include <sys/utsname.h> |
172 #ifndef MEMORY_IN_STRING_H | |
173 #include <memory.h> | |
174 #endif | |
7326
f6e5ef4a73e3
Test ISC4_0 along with TIOCGWINSZ.
Richard M. Stallman <rms@gnu.org>
parents:
6895
diff
changeset
|
175 #if defined (TIOCGWINSZ) || defined (ISC4_0) |
491 | 176 #ifdef NEED_SIOCTL |
177 #include <sys/sioctl.h> | |
178 #endif | |
179 #ifdef NEED_PTEM_H | |
180 #include <sys/stream.h> | |
181 #include <sys/ptem.h> | |
182 #endif | |
7326
f6e5ef4a73e3
Test ISC4_0 along with TIOCGWINSZ.
Richard M. Stallman <rms@gnu.org>
parents:
6895
diff
changeset
|
183 #endif /* TIOCGWINSZ or ISC4_0 */ |
20288 | 184 #endif /* USG or DGUX */ |
491 | 185 |
186 extern int quit_char; | |
187 | |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
188 #include "keyboard.h" |
766 | 189 #include "frame.h" |
491 | 190 #include "window.h" |
191 #include "termhooks.h" | |
192 #include "termchar.h" | |
193 #include "termopts.h" | |
194 #include "dispextern.h" | |
195 #include "process.h" | |
196 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
197 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
198 #include <direct.h> |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
199 /* In process.h which conflicts with the local copy. */ |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
200 #define _P_WAIT 0 |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
201 int _CRTAPI1 _spawnlp (int, const char *, const char *, ...); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
202 int _CRTAPI1 _getpid (void); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
203 #endif |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
204 |
491 | 205 #ifdef NONSYSTEM_DIR_LIBRARY |
206 #include "ndir.h" | |
207 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
208 | |
579 | 209 #include "syssignal.h" |
210 #include "systime.h" | |
9239
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
211 #ifdef HAVE_UTIME_H |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
212 #include <utime.h> |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
213 #endif |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
214 |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
215 #ifndef HAVE_UTIMES |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
216 #ifndef HAVE_STRUCT_UTIMBUF |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
217 /* We want to use utime rather than utimes, but we couldn't find the |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
218 structure declaration. We'll use the traditional one. */ |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
219 struct utimbuf { |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
220 long actime; |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
221 long modtime; |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
222 }; |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
223 #endif |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
224 #endif |
491 | 225 |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
226 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
227 #ifndef LPASS8 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
228 #define LPASS8 0 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
229 #endif |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
230 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
231 #ifdef BSD4_1 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
232 #define LNOFLSH 0100000 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
233 #endif |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
234 |
491 | 235 static int baud_convert[] = |
236 #ifdef BAUD_CONVERT | |
237 BAUD_CONVERT; | |
238 #else | |
239 { | |
240 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, | |
241 1800, 2400, 4800, 9600, 19200, 38400 | |
242 }; | |
243 #endif | |
244 | |
29252
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
245 #ifdef HAVE_SPEED_T |
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
246 #include <termios.h> |
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
247 #else |
19023
f7a3c16c49cb
[HAVE_LIBNCURSES]: Declare ospeed as short, unless NCURSES_OSPEED_T.
Richard M. Stallman <rms@gnu.org>
parents:
18808
diff
changeset
|
248 #if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T) |
f7a3c16c49cb
[HAVE_LIBNCURSES]: Declare ospeed as short, unless NCURSES_OSPEED_T.
Richard M. Stallman <rms@gnu.org>
parents:
18808
diff
changeset
|
249 #else |
41969
e669966d496e
Test GNU_LINUX, not LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
41275
diff
changeset
|
250 #if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX) |
18808 | 251 #include <termios.h> |
16117
16c866efd8b5
[HAVE_TERMIOS_H]: Include termios.h.
Richard M. Stallman <rms@gnu.org>
parents:
16051
diff
changeset
|
252 #endif |
19023
f7a3c16c49cb
[HAVE_LIBNCURSES]: Declare ospeed as short, unless NCURSES_OSPEED_T.
Richard M. Stallman <rms@gnu.org>
parents:
18808
diff
changeset
|
253 #endif |
29252
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
254 #endif |
491 | 255 |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
256 int emacs_ospeed; |
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
257 |
579 | 258 /* The file descriptor for Emacs's input terminal. |
9651
3c2685c4e09d
(input_fd): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
259 Under Unix, this is normally zero except when using X; |
3c2685c4e09d
(input_fd): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
260 under VMS, we place the input channel number here. */ |
3c2685c4e09d
(input_fd): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
261 int input_fd; |
21769
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
262 |
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
263 void croak P_ ((char *)); |
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
264 |
22825
a5d08eacb02b
[AIXHFT] (hft_init, hft_reset): Add declarations.
Richard M. Stallman <rms@gnu.org>
parents:
22336
diff
changeset
|
265 #ifdef AIXHFT |
a5d08eacb02b
[AIXHFT] (hft_init, hft_reset): Add declarations.
Richard M. Stallman <rms@gnu.org>
parents:
22336
diff
changeset
|
266 void hft_init (); |
a5d08eacb02b
[AIXHFT] (hft_init, hft_reset): Add declarations.
Richard M. Stallman <rms@gnu.org>
parents:
22336
diff
changeset
|
267 void hft_reset (); |
a5d08eacb02b
[AIXHFT] (hft_init, hft_reset): Add declarations.
Richard M. Stallman <rms@gnu.org>
parents:
22336
diff
changeset
|
268 #endif |
21769
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
269 |
29812
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
270 /* Temporary used by `sigblock' when defined in terms of signprocmask. */ |
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
271 |
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
272 SIGMASKTYPE sigprocmask_set; |
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
273 |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
274 |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
275 /* Specify a different file descriptor for further input operations. */ |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
276 |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
277 void |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
278 change_input_fd (fd) |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
279 int fd; |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
280 { |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
281 input_fd = fd; |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
282 } |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
283 |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
284 /* Discard pending input on descriptor input_fd. */ |
579 | 285 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
286 void |
491 | 287 discard_tty_input () |
288 { | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
289 #ifndef WINDOWSNT |
579 | 290 struct emacs_tty buf; |
491 | 291 |
292 if (noninteractive) | |
293 return; | |
294 | |
295 /* Discarding input is not safe when the input could contain | |
296 replies from the X server. So don't do it. */ | |
297 if (read_socket_hook) | |
298 return; | |
299 | |
300 #ifdef VMS | |
301 end_kbd_input (); | |
579 | 302 SYS$QIOW (0, input_fd, IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, |
303 &buf.main, 0, 0, terminator_mask, 0, 0); | |
491 | 304 queue_kbd_input (); |
305 #else /* not VMS */ | |
306 #ifdef APOLLO | |
307 { | |
308 int zero = 0; | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
309 ioctl (input_fd, TIOCFLUSH, &zero); |
491 | 310 } |
311 #else /* not Apollo */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
312 #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
313 while (dos_keyread () != -1) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
314 ; |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
315 #else /* not MSDOS */ |
579 | 316 EMACS_GET_TTY (input_fd, &buf); |
317 EMACS_SET_TTY (input_fd, &buf, 0); | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
318 #endif /* not MSDOS */ |
491 | 319 #endif /* not Apollo */ |
320 #endif /* not VMS */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
321 #endif /* not WINDOWSNT */ |
491 | 322 } |
323 | |
324 #ifdef SIGTSTP | |
325 | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
326 /* Arrange for character C to be read as the next input from |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
327 the terminal. */ |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
328 |
21514 | 329 void |
491 | 330 stuff_char (c) |
331 char c; | |
332 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
333 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
334 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
335 |
491 | 336 /* Should perhaps error if in batch mode */ |
337 #ifdef TIOCSTI | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
338 ioctl (input_fd, TIOCSTI, &c); |
491 | 339 #else /* no TIOCSTI */ |
5167
6ac5c999a7cc
(init_baud_rate): Avoid referring to sg uninitialized.
Richard M. Stallman <rms@gnu.org>
parents:
5158
diff
changeset
|
340 error ("Cannot stuff terminal input characters in this version of Unix"); |
491 | 341 #endif /* no TIOCSTI */ |
342 } | |
343 | |
344 #endif /* SIGTSTP */ | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
345 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
346 void |
491 | 347 init_baud_rate () |
348 { | |
349 if (noninteractive) | |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
350 emacs_ospeed = 0; |
491 | 351 else |
352 { | |
18095
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
353 #ifdef INIT_BAUD_RATE |
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
354 INIT_BAUD_RATE (); |
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
355 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
356 #ifdef DOS_NT |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
357 emacs_ospeed = 15; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
358 #else /* not DOS_NT */ |
491 | 359 #ifdef VMS |
579 | 360 struct sensemode sg; |
361 | |
362 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0, | |
491 | 363 &sg.class, 12, 0, 0, 0, 0 ); |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
364 emacs_ospeed = sg.xmit_baud; |
579 | 365 #else /* not VMS */ |
366 #ifdef HAVE_TERMIOS | |
367 struct termios sg; | |
368 | |
5167
6ac5c999a7cc
(init_baud_rate): Avoid referring to sg uninitialized.
Richard M. Stallman <rms@gnu.org>
parents:
5158
diff
changeset
|
369 sg.c_cflag = B9600; |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
370 tcgetattr (input_fd, &sg); |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
371 emacs_ospeed = cfgetospeed (&sg); |
8696
10ec51f5e4b0
(init_baud_rate): Test that getobaud is actually defined.
Richard M. Stallman <rms@gnu.org>
parents:
8690
diff
changeset
|
372 #if defined (USE_GETOBAUD) && defined (getobaud) |
8690
83a8062ca215
(init_baud_rate) [USE_GETOBAUD]: Use getobaud.
Richard M. Stallman <rms@gnu.org>
parents:
8368
diff
changeset
|
373 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
374 if (emacs_ospeed == 0) |
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
375 emacs_ospeed = getobaud (sg.c_cflag); |
8690
83a8062ca215
(init_baud_rate) [USE_GETOBAUD]: Use getobaud.
Richard M. Stallman <rms@gnu.org>
parents:
8368
diff
changeset
|
376 #endif |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
377 #else /* neither VMS nor TERMIOS */ |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
378 #ifdef HAVE_TERMIO |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
379 struct termio sg; |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
380 |
5167
6ac5c999a7cc
(init_baud_rate): Avoid referring to sg uninitialized.
Richard M. Stallman <rms@gnu.org>
parents:
5158
diff
changeset
|
381 sg.c_cflag = B9600; |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
382 #ifdef HAVE_TCATTR |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
383 tcgetattr (input_fd, &sg); |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
384 #else |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
385 ioctl (input_fd, TCGETA, &sg); |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
386 #endif |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
387 emacs_ospeed = sg.c_cflag & CBAUD; |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
388 #else /* neither VMS nor TERMIOS nor TERMIO */ |
579 | 389 struct sgttyb sg; |
390 | |
391 sg.sg_ospeed = B9600; | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
392 if (ioctl (input_fd, TIOCGETP, &sg) < 0) |
3559
a9b886b3f976
(init_baud_rate) [HAVE_TERMIOS]: Use cfgetospeed.
Richard M. Stallman <rms@gnu.org>
parents:
3472
diff
changeset
|
393 abort (); |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
394 emacs_ospeed = sg.sg_ospeed; |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
395 #endif /* not HAVE_TERMIO */ |
579 | 396 #endif /* not HAVE_TERMIOS */ |
491 | 397 #endif /* not VMS */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
398 #endif /* not DOS_NT */ |
18095
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
399 #endif /* not INIT_BAUD_RATE */ |
491 | 400 } |
401 | |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
402 baud_rate = (emacs_ospeed < sizeof baud_convert / sizeof baud_convert[0] |
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
403 ? baud_convert[emacs_ospeed] : 9600); |
491 | 404 if (baud_rate == 0) |
405 baud_rate = 1200; | |
406 } | |
407 | |
408 /*ARGSUSED*/ | |
21514 | 409 void |
491 | 410 set_exclusive_use (fd) |
411 int fd; | |
412 { | |
413 #ifdef FIOCLEX | |
414 ioctl (fd, FIOCLEX, 0); | |
415 #endif | |
416 /* Ok to do nothing if this feature does not exist */ | |
417 } | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
418 |
491 | 419 #ifndef subprocesses |
420 | |
421 wait_without_blocking () | |
422 { | |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
423 #ifdef BSD_SYSTEM |
491 | 424 wait3 (0, WNOHANG | WUNTRACED, 0); |
425 #else | |
426 croak ("wait_without_blocking"); | |
427 #endif | |
428 synch_process_alive = 0; | |
429 } | |
430 | |
431 #endif /* not subprocesses */ | |
432 | |
433 int wait_debugging; /* Set nonzero to make following function work under dbx | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
434 (at least for bsd). */ |
491 | 435 |
436 SIGTYPE | |
437 wait_for_termination_signal () | |
438 {} | |
439 | |
440 /* Wait for subprocess with process id `pid' to terminate and | |
441 make sure it will get eliminated (not remain forever as a zombie) */ | |
442 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
443 void |
491 | 444 wait_for_termination (pid) |
445 int pid; | |
446 { | |
447 while (1) | |
448 { | |
449 #ifdef subprocesses | |
450 #ifdef VMS | |
451 int status; | |
452 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
453 status = SYS$FORCEX (&pid, 0, 0); |
491 | 454 break; |
455 #else /* not VMS */ | |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
456 #if defined (BSD_SYSTEM) || (defined (HPUX) && !defined (HPUX_5)) |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
457 /* Note that kill returns -1 even if the process is just a zombie now. |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
458 But inevitably a SIGCHLD interrupt should be generated |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
459 and child_sig will do wait3 and make the process go away. */ |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
460 /* There is some indication that there is a bug involved with |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
461 termination of subprocesses, perhaps involving a kernel bug too, |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
462 but no idea what it is. Just as a hunch we signal SIGCHLD to see |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
463 if that causes the problem to go away or get worse. */ |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
464 sigsetmask (sigmask (SIGCHLD)); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
465 if (0 > kill (pid, 0)) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
466 { |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
467 sigsetmask (SIGEMPTYMASK); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
468 kill (getpid (), SIGCHLD); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
469 break; |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
470 } |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
471 if (wait_debugging) |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
472 sleep (1); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
473 else |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
474 sigpause (SIGEMPTYMASK); |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
475 #else /* not BSD_SYSTEM, and not HPUX version >= 6 */ |
3334
7900edb84c4f
(wait_for_termination): Delete LINUX conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
3321
diff
changeset
|
476 #if defined (UNIPLUS) |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
477 if (0 > kill (pid, 0)) |
491 | 478 break; |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
479 wait (0); |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
480 #else /* neither BSD_SYSTEM nor UNIPLUS: random sysV */ |
41969
e669966d496e
Test GNU_LINUX, not LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
41275
diff
changeset
|
481 #ifdef POSIX_SIGNALS /* would this work for GNU/Linux as well? */ |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
482 sigblock (sigmask (SIGCHLD)); |
39374
54dd36cef0e2
(wait_for_termination) [POSIX_SIGNALS]: Terminate
Gerd Moellmann <gerd@gnu.org>
parents:
39363
diff
changeset
|
483 errno = 0; |
54dd36cef0e2
(wait_for_termination) [POSIX_SIGNALS]: Terminate
Gerd Moellmann <gerd@gnu.org>
parents:
39363
diff
changeset
|
484 if (kill (pid, 0) == -1 && errno == ESRCH) |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
485 { |
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
486 sigunblock (sigmask (SIGCHLD)); |
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
487 break; |
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
488 } |
39363
50bf161d854c
(wait_for_termination): Add a FIXME comment for the use of non-POSIX
Gerd Moellmann <gerd@gnu.org>
parents:
37219
diff
changeset
|
489 |
50bf161d854c
(wait_for_termination): Add a FIXME comment for the use of non-POSIX
Gerd Moellmann <gerd@gnu.org>
parents:
37219
diff
changeset
|
490 /* FIXME: Since sigpause is not POSIX and its use is deprecated, |
50bf161d854c
(wait_for_termination): Add a FIXME comment for the use of non-POSIX
Gerd Moellmann <gerd@gnu.org>
parents:
37219
diff
changeset
|
491 this should probably be `sigsuspend (&empty_mask)', which is |
50bf161d854c
(wait_for_termination): Add a FIXME comment for the use of non-POSIX
Gerd Moellmann <gerd@gnu.org>
parents:
37219
diff
changeset
|
492 POSIX. I'm not making that change right away because the |
50bf161d854c
(wait_for_termination): Add a FIXME comment for the use of non-POSIX
Gerd Moellmann <gerd@gnu.org>
parents:
37219
diff
changeset
|
493 release is nearing. 2001-09-20 gerd. */ |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
494 sigpause (SIGEMPTYMASK); |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
495 #else /* not POSIX_SIGNALS */ |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
496 #ifdef HAVE_SYSV_SIGPAUSE |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
497 sighold (SIGCHLD); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
498 if (0 > kill (pid, 0)) |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
499 { |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
500 sigrelse (SIGCHLD); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
501 break; |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
502 } |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
503 sigpause (SIGCHLD); |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
504 #else /* not HAVE_SYSV_SIGPAUSE */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
505 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
506 wait (0); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
507 break; |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
508 #else /* not WINDOWSNT */ |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
509 if (0 > kill (pid, 0)) |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
510 break; |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
511 /* Using sleep instead of pause avoids timing error. |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
512 If the inferior dies just before the sleep, |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
513 we lose just one second. */ |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
514 sleep (1); |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
515 #endif /* not WINDOWSNT */ |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
516 #endif /* not HAVE_SYSV_SIGPAUSE */ |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
517 #endif /* not POSIX_SIGNALS */ |
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
518 #endif /* not UNIPLUS */ |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
519 #endif /* not BSD_SYSTEM, and not HPUX version >= 6 */ |
491 | 520 #endif /* not VMS */ |
521 #else /* not subprocesses */ | |
14971
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
522 #if __DJGPP__ > 1 |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
523 break; |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
524 #else /* not __DJGPP__ > 1 */ |
491 | 525 #ifndef BSD4_1 |
526 if (kill (pid, 0) < 0) | |
527 break; | |
528 wait (0); | |
529 #else /* BSD4_1 */ | |
530 int status; | |
531 status = wait (0); | |
532 if (status == pid || status == -1) | |
533 break; | |
534 #endif /* BSD4_1 */ | |
14971
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
535 #endif /* not __DJGPP__ > 1*/ |
491 | 536 #endif /* not subprocesses */ |
537 } | |
538 } | |
539 | |
540 #ifdef subprocesses | |
541 | |
542 /* | |
543 * flush any pending output | |
544 * (may flush input as well; it does not matter the way we use it) | |
545 */ | |
546 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
547 void |
491 | 548 flush_pending_output (channel) |
549 int channel; | |
550 { | |
551 #ifdef HAVE_TERMIOS | |
552 /* If we try this, we get hit with SIGTTIN, because | |
553 the child's tty belongs to the child's pgrp. */ | |
554 #else | |
555 #ifdef TCFLSH | |
556 ioctl (channel, TCFLSH, 1); | |
557 #else | |
558 #ifdef TIOCFLUSH | |
559 int zero = 0; | |
560 /* 3rd arg should be ignored | |
561 but some 4.2 kernels actually want the address of an int | |
562 and nonzero means something different. */ | |
563 ioctl (channel, TIOCFLUSH, &zero); | |
564 #endif | |
565 #endif | |
566 #endif | |
567 } | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
568 |
491 | 569 #ifndef VMS |
570 /* Set up the terminal at the other end of a pseudo-terminal that | |
571 we will be controlling an inferior through. | |
572 It should not echo or do line-editing, since that is done | |
573 in Emacs. No padding needed for insertion into an Emacs buffer. */ | |
574 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
575 void |
491 | 576 child_setup_tty (out) |
577 int out; | |
578 { | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
579 #ifndef DOS_NT |
579 | 580 struct emacs_tty s; |
581 | |
582 EMACS_GET_TTY (out, &s); | |
583 | |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
584 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
579 | 585 s.main.c_oflag |= OPOST; /* Enable output postprocessing */ |
586 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */ | |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
587 #ifdef NLDLY |
579 | 588 s.main.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); |
589 /* No output delays */ | |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
590 #endif |
579 | 591 s.main.c_lflag &= ~ECHO; /* Disable echo */ |
592 s.main.c_lflag |= ISIG; /* Enable signals */ | |
41275 | 593 #if 0 /* This causes bugs in (for instance) telnet to certain sites. */ |
39685
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
594 s.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
595 #ifdef INLCR /* Just being cautious, since I can't check how |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
596 widespread INLCR is--rms. */ |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
597 s.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */ |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
598 #endif |
40932
103ddc9d157a
(child_setup_tty): Don't clear ICRNL or INLCR.
Richard M. Stallman <rms@gnu.org>
parents:
40122
diff
changeset
|
599 #endif |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
600 #ifdef IUCLC |
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
601 s.main.c_iflag &= ~IUCLC; /* Disable downcasing on input. */ |
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
602 #endif |
14390
d16ba81e278a
(child_setup_tty): Turn off ISTRIP to pass 8bit. Turn off TAB3 so
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
603 #ifdef ISTRIP |
d16ba81e278a
(child_setup_tty): Turn off ISTRIP to pass 8bit. Turn off TAB3 so
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
604 s.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ |
d16ba81e278a
(child_setup_tty): Turn off ISTRIP to pass 8bit. Turn off TAB3 so
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
605 #endif |
5972
ccb0f99750e3
(child_setup_tty): Typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5967
diff
changeset
|
606 #ifdef OLCUC |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
607 s.main.c_oflag &= ~OLCUC; /* Disable upcasing on output. */ |
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
608 #endif |
14390
d16ba81e278a
(child_setup_tty): Turn off ISTRIP to pass 8bit. Turn off TAB3 so
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
609 s.main.c_oflag &= ~TAB3; /* Disable tab expansion */ |
4916
83db42883f64
(child_setup_tty): Make the pty handle 8-bit characters.
Richard M. Stallman <rms@gnu.org>
parents:
4772
diff
changeset
|
610 s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */ |
579 | 611 #if 0 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
612 /* Said to be unnecessary: */ |
579 | 613 s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */ |
614 s.main.c_cc[VTIME] = 0; /* wait forever for at least 1 character */ | |
615 #endif | |
616 | |
617 s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */ | |
618 s.main.c_cc[VEOF] = 04; /* insure that EOF is Control-D */ | |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
619 s.main.c_cc[VERASE] = CDISABLE; /* disable erase processing */ |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
620 s.main.c_cc[VKILL] = CDISABLE; /* disable kill processing */ |
579 | 621 |
491 | 622 #ifdef HPUX |
579 | 623 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ |
491 | 624 #endif /* HPUX */ |
579 | 625 |
491 | 626 #ifdef AIX |
627 /* AIX enhanced edit loses NULs, so disable it */ | |
628 #ifndef IBMR2AIX | |
579 | 629 s.main.c_line = 0; |
630 s.main.c_iflag &= ~ASCEDIT; | |
491 | 631 #endif |
632 /* Also, PTY overloads NUL and BREAK. | |
633 don't ignore break, but don't signal either, so it looks like NUL. */ | |
579 | 634 s.main.c_iflag &= ~IGNBRK; |
635 s.main.c_iflag &= ~BRKINT; | |
636 /* QUIT and INTR work better as signals, so disable character forms */ | |
637 s.main.c_cc[VINTR] = 0377; | |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
638 #ifdef SIGNALS_VIA_CHARACTERS |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
639 /* the QUIT and INTR character are used in process_send_signal |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
640 so set them here to something useful. */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
641 if (s.main.c_cc[VQUIT] == 0377) |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
642 s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
643 if (s.main.c_cc[VINTR] == 0377) |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
644 s.main.c_cc[VINTR] = 'C'&037; /* Control-C */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
645 #else /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
646 /* QUIT and INTR work better as signals, so disable character forms */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
647 s.main.c_cc[VQUIT] = 0377; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
648 s.main.c_cc[VINTR] = 0377; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
649 s.main.c_lflag &= ~ISIG; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
650 #endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ |
579 | 651 s.main.c_cc[VEOL] = 0377; |
652 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ | |
491 | 653 #endif /* AIX */ |
654 | |
655 #else /* not HAVE_TERMIO */ | |
579 | 656 |
657 s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE | |
658 | CBREAK | TANDEM); | |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
659 s.main.sg_flags |= LPASS8; |
579 | 660 s.main.sg_erase = 0377; |
661 s.main.sg_kill = 0377; | |
4916
83db42883f64
(child_setup_tty): Make the pty handle 8-bit characters.
Richard M. Stallman <rms@gnu.org>
parents:
4772
diff
changeset
|
662 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */ |
579 | 663 |
491 | 664 #endif /* not HAVE_TERMIO */ |
665 | |
579 | 666 EMACS_SET_TTY (out, &s, 0); |
491 | 667 |
668 #ifdef BSD4_1 | |
669 if (interrupt_input) | |
670 reset_sigio (); | |
671 #endif /* BSD4_1 */ | |
672 #ifdef RTU | |
673 { | |
674 int zero = 0; | |
675 ioctl (out, FIOASYNC, &zero); | |
676 } | |
677 #endif /* RTU */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
678 #endif /* not DOS_NT */ |
491 | 679 } |
680 #endif /* not VMS */ | |
681 | |
682 #endif /* subprocesses */ | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
683 |
491 | 684 /* Record a signal code and the handler for it. */ |
685 struct save_signal | |
686 { | |
687 int code; | |
20348 | 688 SIGTYPE (*handler) P_ ((int)); |
491 | 689 }; |
690 | |
20348 | 691 static void save_signal_handlers P_ ((struct save_signal *)); |
692 static void restore_signal_handlers P_ ((struct save_signal *)); | |
693 | |
491 | 694 /* Suspend the Emacs process; give terminal to its superior. */ |
695 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
696 void |
491 | 697 sys_suspend () |
698 { | |
699 #ifdef VMS | |
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
700 /* "Foster" parentage allows emacs to return to a subprocess that attached |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
701 to the current emacs as a cheaper than starting a whole new process. This |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
702 is set up by KEPTEDITOR.COM. */ |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
703 unsigned long parent_id, foster_parent_id; |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
704 char *fpid_string; |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
705 |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
706 fpid_string = getenv ("EMACS_PARENT_PID"); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
707 if (fpid_string != NULL) |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
708 { |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
709 sscanf (fpid_string, "%x", &foster_parent_id); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
710 if (foster_parent_id != 0) |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
711 parent_id = foster_parent_id; |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
712 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
713 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
714 } |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
715 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
716 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
717 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
718 xfree (fpid_string); /* On VMS, this was malloc'd */ |
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
719 |
491 | 720 if (parent_id && parent_id != 0xffffffff) |
721 { | |
722 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); | |
723 int status = LIB$ATTACH (&parent_id) & 1; | |
724 signal (SIGINT, oldsig); | |
725 return status; | |
726 } | |
727 else | |
728 { | |
729 struct { | |
730 int l; | |
731 char *a; | |
732 } d_prompt; | |
733 d_prompt.l = sizeof ("Emacs: "); /* Our special prompt */ | |
734 d_prompt.a = "Emacs: "; /* Just a reminder */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
735 LIB$SPAWN (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &d_prompt, 0); |
491 | 736 return 1; |
737 } | |
738 return -1; | |
739 #else | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
740 #if defined (SIGTSTP) && !defined (MSDOS) |
491 | 741 |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
742 { |
4958
8d58e388e71b
(sys_suspend): Use EMACS_GETPGRP macro.
Richard M. Stallman <rms@gnu.org>
parents:
4952
diff
changeset
|
743 int pgrp = EMACS_GETPGRP (0); |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
744 EMACS_KILLPG (pgrp, SIGTSTP); |
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
745 } |
491 | 746 |
747 #else /* No SIGTSTP */ | |
748 #ifdef USG_JOBCTRL /* If you don't know what this is don't mess with it */ | |
749 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */ | |
750 kill (getpid (), SIGQUIT); | |
751 | |
752 #else /* No SIGTSTP or USG_JOBCTRL */ | |
753 | |
754 /* On a system where suspending is not implemented, | |
755 instead fork a subshell and let it talk directly to the terminal | |
756 while we wait. */ | |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
757 sys_subshell (); |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
758 |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
759 #endif /* no USG_JOBCTRL */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
760 #endif /* no SIGTSTP */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
761 #endif /* not VMS */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
762 } |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
763 |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
764 /* Fork a subshell. */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
765 |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
766 #ifndef macintosh |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
767 void |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
768 sys_subshell () |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
769 { |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
770 #ifndef VMS |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
771 #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
772 int st; |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
773 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
774 #endif |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
775 int pid; |
491 | 776 struct save_signal saved_handlers[5]; |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
777 Lisp_Object dir; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
778 unsigned char *str = 0; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
779 int len; |
491 | 780 |
781 saved_handlers[0].code = SIGINT; | |
782 saved_handlers[1].code = SIGQUIT; | |
783 saved_handlers[2].code = SIGTERM; | |
784 #ifdef SIGIO | |
785 saved_handlers[3].code = SIGIO; | |
786 saved_handlers[4].code = 0; | |
787 #else | |
788 saved_handlers[3].code = 0; | |
789 #endif | |
790 | |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
791 /* Mentioning current_buffer->buffer would mean including buffer.h, |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
792 which somehow wedges the hp compiler. So instead... */ |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
793 |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
794 dir = intern ("default-directory"); |
9426
4dd2d351ea53
(sys_subshell): Use NILP macro directly, not its expansion. Previous code was
Karl Heuer <kwzh@gnu.org>
parents:
9279
diff
changeset
|
795 if (NILP (Fboundp (dir))) |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
796 goto xyzzy; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
797 dir = Fsymbol_value (dir); |
9110
c0eefdfd11f4
(sys_subshell): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9082
diff
changeset
|
798 if (!STRINGP (dir)) |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
799 goto xyzzy; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
800 |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
801 dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
802 str = (unsigned char *) alloca (XSTRING (dir)->size + 2); |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
803 len = XSTRING (dir)->size; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
804 bcopy (XSTRING (dir)->data, str, len); |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
805 if (str[len - 1] != '/') str[len++] = '/'; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
806 str[len] = 0; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
807 xyzzy: |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
808 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
809 #ifdef DOS_NT |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
810 pid = 0; |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
811 #if __DJGPP__ > 1 |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
812 save_signal_handlers (saved_handlers); |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
813 synch_process_alive = 1; |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
814 #endif /* __DJGPP__ > 1 */ |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
815 #else |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
816 pid = vfork (); |
491 | 817 if (pid == -1) |
818 error ("Can't spawn subshell"); | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
819 #endif |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
820 |
491 | 821 if (pid == 0) |
822 { | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
823 char *sh = 0; |
491 | 824 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
825 #ifdef DOS_NT /* MW, Aug 1993 */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
826 getwd (oldwd); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
827 if (sh == 0) |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
828 sh = (char *) egetenv ("SUSPEND"); /* KFS, 1994-12-14 */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
829 #endif |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
830 if (sh == 0) |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
831 sh = (char *) egetenv ("SHELL"); |
491 | 832 if (sh == 0) |
833 sh = "sh"; | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
834 |
491 | 835 /* Use our buffer's default directory for the subshell. */ |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
836 if (str) |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
837 chdir ((char *) str); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
838 |
491 | 839 #ifdef subprocesses |
840 close_process_descs (); /* Close Emacs's pipes/ptys */ | |
841 #endif | |
1203
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
842 |
7482
8193d122cf6e
(sys_subshell): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7326
diff
changeset
|
843 #ifdef SET_EMACS_PRIORITY |
1203
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
844 { |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
845 extern int emacs_priority; |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
846 |
7482
8193d122cf6e
(sys_subshell): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7326
diff
changeset
|
847 if (emacs_priority < 0) |
1203
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
848 nice (-emacs_priority); |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
849 } |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
850 #endif |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
851 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
852 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
853 st = system (sh); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
854 chdir (oldwd); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
855 #if 0 /* This is also reported if last command executed in subshell failed, KFS */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
856 if (st) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
857 report_file_error ("Can't execute subshell", Fcons (build_string (sh), Qnil)); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
858 #endif |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
859 #else /* not MSDOS */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
860 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
861 /* Waits for process completion */ |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
862 pid = _spawnlp (_P_WAIT, sh, sh, NULL); |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
863 chdir (oldwd); |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
864 if (pid == -1) |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
865 write (1, "Can't execute subshell", 22); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
866 #else /* not WINDOWSNT */ |
491 | 867 execlp (sh, sh, 0); |
868 write (1, "Can't execute subshell", 22); | |
869 _exit (1); | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
870 #endif /* not WINDOWSNT */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
871 #endif /* not MSDOS */ |
491 | 872 } |
873 | |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
874 /* Do this now if we did not do it before. */ |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
875 #if !defined (MSDOS) || __DJGPP__ == 1 |
491 | 876 save_signal_handlers (saved_handlers); |
2939
34492be68ced
* sysdep.c (sys_suspend): Set synch_process_alive, so that
Jim Blandy <jimb@redhat.com>
parents:
2913
diff
changeset
|
877 synch_process_alive = 1; |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
878 #endif |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
879 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
880 #ifndef DOS_NT |
491 | 881 wait_for_termination (pid); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
882 #endif |
491 | 883 restore_signal_handlers (saved_handlers); |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
884 synch_process_alive = 0; |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
885 #endif /* !VMS */ |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
886 } |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
887 #endif /* !macintosh */ |
491 | 888 |
20348 | 889 static void |
491 | 890 save_signal_handlers (saved_handlers) |
891 struct save_signal *saved_handlers; | |
892 { | |
893 while (saved_handlers->code) | |
894 { | |
692 | 895 saved_handlers->handler |
20348 | 896 = (SIGTYPE (*) P_ ((int))) signal (saved_handlers->code, SIG_IGN); |
491 | 897 saved_handlers++; |
898 } | |
899 } | |
900 | |
20348 | 901 static void |
491 | 902 restore_signal_handlers (saved_handlers) |
903 struct save_signal *saved_handlers; | |
904 { | |
905 while (saved_handlers->code) | |
906 { | |
907 signal (saved_handlers->code, saved_handlers->handler); | |
908 saved_handlers++; | |
909 } | |
910 } | |
911 | |
912 #ifdef F_SETFL | |
913 | |
914 int old_fcntl_flags; | |
915 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
916 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
917 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
918 int fd; |
491 | 919 { |
920 #ifdef FASYNC | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
921 old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
922 fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); |
491 | 923 #endif |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
924 interrupts_deferred = 0; |
491 | 925 } |
926 | |
20379
e6db4b8d2834
(reset_sigio): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20367
diff
changeset
|
927 void |
491 | 928 reset_sigio () |
929 { | |
930 unrequest_sigio (); | |
931 } | |
932 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
933 #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ |
491 | 934 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
935 void |
491 | 936 request_sigio () |
937 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
938 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
939 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
940 |
491 | 941 #ifdef SIGWINCH |
638 | 942 sigunblock (sigmask (SIGWINCH)); |
491 | 943 #endif |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
944 fcntl (input_fd, F_SETFL, old_fcntl_flags | FASYNC); |
491 | 945 |
946 interrupts_deferred = 0; | |
947 } | |
948 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
949 void |
491 | 950 unrequest_sigio () |
951 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
952 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
953 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
954 |
491 | 955 #ifdef SIGWINCH |
638 | 956 sigblock (sigmask (SIGWINCH)); |
491 | 957 #endif |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
958 fcntl (input_fd, F_SETFL, old_fcntl_flags); |
491 | 959 interrupts_deferred = 1; |
960 } | |
961 | |
962 #else /* no FASYNC */ | |
963 #ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */ | |
964 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
965 void |
491 | 966 request_sigio () |
967 { | |
968 int on = 1; | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
969 |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
970 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
971 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
972 |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
973 ioctl (input_fd, FIOASYNC, &on); |
491 | 974 interrupts_deferred = 0; |
975 } | |
976 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
977 void |
491 | 978 unrequest_sigio () |
979 { | |
980 int off = 0; | |
981 | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
982 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
983 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
984 |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
985 ioctl (input_fd, FIOASYNC, &off); |
491 | 986 interrupts_deferred = 1; |
987 } | |
988 | |
989 #else /* not FASYNC, not STRIDE */ | |
990 | |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
991 #ifdef _CX_UX |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
992 |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
993 #include <termios.h> |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
994 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
995 void |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
996 request_sigio () |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
997 { |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
998 int on = 1; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
999 sigset_t st; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1000 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1001 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1002 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1003 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1004 sigemptyset (&st); |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1005 sigaddset (&st, SIGIO); |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1006 ioctl (input_fd, FIOASYNC, &on); |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1007 interrupts_deferred = 0; |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1008 sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1009 } |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1010 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1011 void |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1012 unrequest_sigio () |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1013 { |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1014 int off = 0; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1015 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1016 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1017 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1018 |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1019 ioctl (input_fd, FIOASYNC, &off); |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1020 interrupts_deferred = 1; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1021 } |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1022 |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1023 #else /* ! _CX_UX */ |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1024 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1025 void |
491 | 1026 request_sigio () |
1027 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1028 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1029 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1030 |
491 | 1031 croak ("request_sigio"); |
1032 } | |
1033 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1034 void |
491 | 1035 unrequest_sigio () |
1036 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1037 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1038 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1039 |
491 | 1040 croak ("unrequest_sigio"); |
1041 } | |
1042 | |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1043 #endif /* _CX_UX */ |
491 | 1044 #endif /* STRIDE */ |
1045 #endif /* FASYNC */ | |
1046 #endif /* F_SETFL */ | |
1047 | |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1048 /* Saving and restoring the process group of Emacs's terminal. */ |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1049 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1050 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1051 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1052 /* The process group of which Emacs was a member when it initially |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1053 started. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1054 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1055 If Emacs was in its own process group (i.e. inherited_pgroup == |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1056 getpid ()), then we know we're running under a shell with job |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1057 control (Emacs would never be run as part of a pipeline). |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1058 Everything is fine. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1059 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1060 If Emacs was not in its own process group, then we know we're |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1061 running under a shell (or a caller) that doesn't know how to |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1062 separate itself from Emacs (like sh). Emacs must be in its own |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1063 process group in order to receive SIGIO correctly. In this |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1064 situation, we put ourselves in our own pgroup, forcibly set the |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1065 tty's pgroup to our pgroup, and make sure to restore and reinstate |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1066 the tty's pgroup just like any other terminal setting. If |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1067 inherited_group was not the tty's pgroup, then we'll get a |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1068 SIGTTmumble when we try to change the tty's pgroup, and a CONT if |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1069 it goes foreground in the future, which is what should happen. */ |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1070 int inherited_pgroup; |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1071 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1072 /* Split off the foreground process group to Emacs alone. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1073 When we are in the foreground, but not started in our own process |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1074 group, redirect the TTY to point to our own process group. We need |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1075 to be in our own process group to receive SIGIO properly. */ |
21514 | 1076 void |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1077 narrow_foreground_group () |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1078 { |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1079 int me = getpid (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1080 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1081 setpgrp (0, inherited_pgroup); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1082 if (inherited_pgroup != me) |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1083 EMACS_SET_TTY_PGRP (input_fd, &me); |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1084 setpgrp (0, me); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1085 } |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1086 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1087 /* Set the tty to our original foreground group. */ |
21514 | 1088 void |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1089 widen_foreground_group () |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1090 { |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1091 if (inherited_pgroup != getpid ()) |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1092 EMACS_SET_TTY_PGRP (input_fd, &inherited_pgroup); |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1093 setpgrp (0, inherited_pgroup); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1094 } |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1095 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1096 #endif /* BSD_PGRPS */ |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1097 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1098 /* Getting and setting emacs_tty structures. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1099 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1100 /* Set *TC to the parameters associated with the terminal FD. |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1101 Return zero if all's well, or -1 if we ran into an error we |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1102 couldn't deal with. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1103 int |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1104 emacs_get_tty (fd, settings) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1105 int fd; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1106 struct emacs_tty *settings; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1107 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1108 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1109 #ifdef HAVE_TCATTR |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1110 /* We have those nifty POSIX tcmumbleattr functions. */ |
21843
600f19764b68
(emacs_get_tty): Zero out termios structure before
Andreas Schwab <schwab@suse.de>
parents:
21769
diff
changeset
|
1111 bzero (&settings->main, sizeof (settings->main)); |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1112 if (tcgetattr (fd, &settings->main) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1113 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1114 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1115 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1116 #ifdef HAVE_TERMIO |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1117 /* The SYSV-style interface? */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1118 if (ioctl (fd, TCGETA, &settings->main) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1119 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1120 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1121 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1122 #ifdef VMS |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1123 /* Vehemently Monstrous System? :-) */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1124 if (! (SYS$QIOW (0, fd, IO$_SENSEMODE, settings, 0, 0, |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1125 &settings->main.class, 12, 0, 0, 0, 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1126 & 1)) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1127 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1128 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1129 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1130 #ifndef DOS_NT |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1131 /* I give up - I hope you have the BSD ioctls. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1132 if (ioctl (fd, TIOCGETP, &settings->main) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1133 return -1; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1134 #endif /* not DOS_NT */ |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1135 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1136 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1137 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1138 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1139 /* Suivant - Do we have to get struct ltchars data? */ |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1140 #ifdef HAVE_LTCHARS |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1141 if (ioctl (fd, TIOCGLTC, &settings->ltchars) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1142 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1143 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1144 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1145 /* How about a struct tchars and a wordful of lmode bits? */ |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1146 #ifdef HAVE_TCHARS |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1147 if (ioctl (fd, TIOCGETC, &settings->tchars) < 0 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1148 || ioctl (fd, TIOCLGET, &settings->lmode) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1149 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1150 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1151 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1152 /* We have survived the tempest. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1153 return 0; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1154 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1155 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1156 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1157 /* Set the parameters of the tty on FD according to the contents of |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1158 *SETTINGS. If FLUSHP is non-zero, we discard input. |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1159 Return 0 if all went well, and -1 if anything failed. */ |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1160 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1161 int |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1162 emacs_set_tty (fd, settings, flushp) |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1163 int fd; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1164 struct emacs_tty *settings; |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1165 int flushp; |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1166 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1167 /* Set the primary parameters - baud rate, character size, etcetera. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1168 #ifdef HAVE_TCATTR |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1169 int i; |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1170 /* We have those nifty POSIX tcmumbleattr functions. |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1171 William J. Smith <wjs@wiis.wang.com> writes: |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1172 "POSIX 1003.1 defines tcsetattr to return success if it was |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1173 able to perform any of the requested actions, even if some |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1174 of the requested actions could not be performed. |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1175 We must read settings back to ensure tty setup properly. |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1176 AIX requires this to keep tty from hanging occasionally." */ |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1177 /* This make sure that we don't loop indefinitely in here. */ |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1178 for (i = 0 ; i < 10 ; i++) |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1179 if (tcsetattr (fd, flushp ? TCSAFLUSH : TCSADRAIN, &settings->main) < 0) |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1180 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1181 if (errno == EINTR) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1182 continue; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1183 else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1184 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1185 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1186 else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1187 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1188 struct termios new; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1189 |
21843
600f19764b68
(emacs_get_tty): Zero out termios structure before
Andreas Schwab <schwab@suse.de>
parents:
21769
diff
changeset
|
1190 bzero (&new, sizeof (new)); |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1191 /* Get the current settings, and see if they're what we asked for. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1192 tcgetattr (fd, &new); |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1193 /* We cannot use memcmp on the whole structure here because under |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1194 * aix386 the termios structure has some reserved field that may |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1195 * not be filled in. |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1196 */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1197 if ( new.c_iflag == settings->main.c_iflag |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1198 && new.c_oflag == settings->main.c_oflag |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1199 && new.c_cflag == settings->main.c_cflag |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1200 && new.c_lflag == settings->main.c_lflag |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1201 && memcmp (new.c_cc, settings->main.c_cc, NCCS) == 0) |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1202 break; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1203 else |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1204 continue; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1205 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1206 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1207 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1208 #ifdef HAVE_TERMIO |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1209 /* The SYSV-style interface? */ |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1210 if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0) |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1211 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1212 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1213 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1214 #ifdef VMS |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1215 /* Vehemently Monstrous System? :-) */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1216 if (! (SYS$QIOW (0, fd, IO$_SETMODE, &input_iosb, 0, 0, |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1217 &settings->main.class, 12, 0, 0, 0, 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1218 & 1)) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1219 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1220 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1221 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1222 #ifndef DOS_NT |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1223 /* I give up - I hope you have the BSD ioctls. */ |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1224 if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1225 return -1; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1226 #endif /* not DOS_NT */ |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1227 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1228 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1229 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1230 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1231 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1232 /* Suivant - Do we have to get struct ltchars data? */ |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1233 #ifdef HAVE_LTCHARS |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1234 if (ioctl (fd, TIOCSLTC, &settings->ltchars) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1235 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1236 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1237 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1238 /* How about a struct tchars and a wordful of lmode bits? */ |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1239 #ifdef HAVE_TCHARS |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1240 if (ioctl (fd, TIOCSETC, &settings->tchars) < 0 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1241 || ioctl (fd, TIOCLSET, &settings->lmode) < 0) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1242 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1243 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1244 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1245 /* We have survived the tempest. */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1246 return 0; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1247 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1248 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1249 |
579 | 1250 /* The initial tty mode bits */ |
1251 struct emacs_tty old_tty; | |
491 | 1252 |
12070 | 1253 /* 1 if we have been through init_sys_modes. */ |
1254 int term_initted; | |
1255 | |
1256 /* 1 if outer tty status has been recorded. */ | |
1257 int old_tty_valid; | |
491 | 1258 |
579 | 1259 #ifdef BSD4_1 |
1260 /* BSD 4.1 needs to keep track of the lmode bits in order to start | |
1261 sigio. */ | |
1262 int lmode; | |
1263 #endif | |
1264 | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1265 #ifndef F_SETOWN_BUG |
491 | 1266 #ifdef F_SETOWN |
1267 int old_fcntl_owner; | |
1268 #endif /* F_SETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1269 #endif /* F_SETOWN_BUG */ |
491 | 1270 |
1271 /* This may also be defined in stdio, | |
1272 but if so, this does no harm, | |
1273 and using the same name avoids wasting the other one's space. */ | |
1274 | |
23631
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1275 #ifdef nec_ews_svr4 |
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1276 extern char *_sobuf ; |
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1277 #else |
491 | 1278 #if defined (USG) || defined (DGUX) |
1279 unsigned char _sobuf[BUFSIZ+8]; | |
1280 #else | |
1281 char _sobuf[BUFSIZ]; | |
1282 #endif | |
23631
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1283 #endif |
491 | 1284 |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1285 #ifdef HAVE_LTCHARS |
491 | 1286 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; |
1287 #endif | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1288 #ifdef HAVE_TCHARS |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1289 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; |
491 | 1290 #endif |
1291 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1292 void |
491 | 1293 init_sys_modes () |
1294 { | |
579 | 1295 struct emacs_tty tty; |
1296 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1297 #ifdef macintosh |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
1298 /* cus-start.el complains if delete-exited-processes is not defined */ |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1299 #ifndef subprocesses |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1300 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, |
40122
4a487543a226
(delete-exited-processes): Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39685
diff
changeset
|
1301 doc: /* *Non-nil means delete processes immediately when they exit. |
4a487543a226
(delete-exited-processes): Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39685
diff
changeset
|
1302 nil means don't delete them until `list-processes' is run. */); |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1303 delete_exited_processes = 0; |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1304 #endif |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1305 #endif /* not macintosh */ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1306 |
491 | 1307 #ifdef VMS |
1308 #if 0 | |
1309 static int oob_chars[2] = {0, 1 << 7}; /* catch C-g's */ | |
1310 extern int (*interrupt_signal) (); | |
1311 #endif | |
1312 #endif | |
1313 | |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1314 Vtty_erase_char = Qnil; |
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1315 |
491 | 1316 if (noninteractive) |
1317 return; | |
1318 | |
1319 #ifdef VMS | |
1320 if (!input_ef) | |
1321 input_ef = get_kbd_event_flag (); | |
1322 /* LIB$GET_EF (&input_ef); */ | |
1323 SYS$CLREF (input_ef); | |
1324 waiting_for_ast = 0; | |
1325 if (!timer_ef) | |
1326 timer_ef = get_timer_event_flag (); | |
1327 /* LIB$GET_EF (&timer_ef); */ | |
1328 SYS$CLREF (timer_ef); | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1329 #if 0 |
491 | 1330 if (!process_ef) |
1331 { | |
1332 LIB$GET_EF (&process_ef); | |
1333 SYS$CLREF (process_ef); | |
1334 } | |
1335 if (input_ef / 32 != process_ef / 32) | |
1336 croak ("Input and process event flags in different clusters."); | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1337 #endif |
491 | 1338 if (input_ef / 32 != timer_ef / 32) |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1339 croak ("Input and timer event flags in different clusters."); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1340 #if 0 |
491 | 1341 input_eflist = ((unsigned) 1 << (input_ef % 32)) | |
1342 ((unsigned) 1 << (process_ef % 32)); | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1343 #endif |
491 | 1344 timer_eflist = ((unsigned) 1 << (input_ef % 32)) | |
1345 ((unsigned) 1 << (timer_ef % 32)); | |
1346 #ifndef VMS4_4 | |
1347 sys_access_reinit (); | |
1348 #endif | |
1349 #endif /* not VMS */ | |
579 | 1350 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1351 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1352 if (! read_socket_hook && EQ (Vwindow_system, Qnil)) |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1353 narrow_foreground_group (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1354 #endif |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1355 |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
1356 #ifdef HAVE_WINDOW_SYSTEM |
9572 | 1357 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore |
1358 needs the initialization code below. */ | |
491 | 1359 if (!read_socket_hook && EQ (Vwindow_system, Qnil)) |
9572 | 1360 #endif |
491 | 1361 { |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1362 EMACS_GET_TTY (input_fd, &old_tty); |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1363 |
12070 | 1364 old_tty_valid = 1; |
1365 | |
579 | 1366 tty = old_tty; |
491 | 1367 |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
1368 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18604
diff
changeset
|
1369 XSETINT (Vtty_erase_char, old_tty.main.c_cc[VERASE]); |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1370 |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1371 #ifdef DGUX |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1372 /* This allows meta to be sent on 8th bit. */ |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1373 tty.main.c_iflag &= ~INPCK; /* don't check input for parity */ |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1374 #endif |
579 | 1375 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ |
1376 tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ | |
14790
70553c545976
(init_sys_modes): Clear INLCR like ICRNL.
Richard M. Stallman <rms@gnu.org>
parents:
14390
diff
changeset
|
1377 #ifdef INLCR /* I'm just being cautious, |
70553c545976
(init_sys_modes): Clear INLCR like ICRNL.
Richard M. Stallman <rms@gnu.org>
parents:
14390
diff
changeset
|
1378 since I can't check how widespread INLCR is--rms. */ |
70553c545976
(init_sys_modes): Clear INLCR like ICRNL.
Richard M. Stallman <rms@gnu.org>
parents:
14390
diff
changeset
|
1379 tty.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */ |
70553c545976
(init_sys_modes): Clear INLCR like ICRNL.
Richard M. Stallman <rms@gnu.org>
parents:
14390
diff
changeset
|
1380 #endif |
491 | 1381 #ifdef ISTRIP |
579 | 1382 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ |
491 | 1383 #endif |
579 | 1384 tty.main.c_lflag &= ~ECHO; /* Disable echo */ |
1385 tty.main.c_lflag &= ~ICANON; /* Disable erase/kill processing */ | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1386 #ifdef IEXTEN |
5960
ce4b18e394a2
(init_sys_modes): IEXTEN is in c_lflag, not c_iflag.
Richard M. Stallman <rms@gnu.org>
parents:
5954
diff
changeset
|
1387 tty.main.c_lflag &= ~IEXTEN; /* Disable other editing characters. */ |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1388 #endif |
579 | 1389 tty.main.c_lflag |= ISIG; /* Enable signals */ |
491 | 1390 if (flow_control) |
1391 { | |
579 | 1392 tty.main.c_iflag |= IXON; /* Enable start/stop output control */ |
491 | 1393 #ifdef IXANY |
579 | 1394 tty.main.c_iflag &= ~IXANY; |
491 | 1395 #endif /* IXANY */ |
1396 } | |
1397 else | |
579 | 1398 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ |
1399 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL | |
1400 on output */ | |
1401 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ | |
491 | 1402 #ifdef CS8 |
1403 if (meta_key) | |
1404 { | |
579 | 1405 tty.main.c_cflag |= CS8; /* allow 8th bit on input */ |
1406 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ | |
491 | 1407 } |
1408 #endif | |
579 | 1409 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ |
491 | 1410 /* Set up C-g for both SIGQUIT and SIGINT. |
1411 We don't know which we will get, but we handle both alike | |
1412 so which one it really gives us does not matter. */ | |
579 | 1413 tty.main.c_cc[VQUIT] = quit_char; |
1414 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ | |
1415 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */ | |
491 | 1416 #ifdef VSWTCH |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1417 tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use |
579 | 1418 of C-z */ |
491 | 1419 #endif /* VSWTCH */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1420 |
491 | 1421 #if defined (mips) || defined (HAVE_TCATTR) |
1422 #ifdef VSUSP | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1423 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ |
491 | 1424 #endif /* VSUSP */ |
1425 #ifdef V_DSUSP | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1426 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ |
491 | 1427 #endif /* V_DSUSP */ |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1428 #ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */ |
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1429 tty.main.c_cc[VDSUSP] = CDISABLE; |
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1430 #endif /* VDSUSP */ |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1431 #ifdef VLNEXT |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1432 tty.main.c_cc[VLNEXT] = CDISABLE; |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1433 #endif /* VLNEXT */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1434 #ifdef VREPRINT |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1435 tty.main.c_cc[VREPRINT] = CDISABLE; |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1436 #endif /* VREPRINT */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1437 #ifdef VWERASE |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1438 tty.main.c_cc[VWERASE] = CDISABLE; |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1439 #endif /* VWERASE */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1440 #ifdef VDISCARD |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1441 tty.main.c_cc[VDISCARD] = CDISABLE; |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1442 #endif /* VDISCARD */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1443 |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1444 if (flow_control) |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1445 { |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1446 #ifdef VSTART |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1447 tty.main.c_cc[VSTART] = '\021'; |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1448 #endif /* VSTART */ |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1449 #ifdef VSTOP |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1450 tty.main.c_cc[VSTOP] = '\023'; |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1451 #endif /* VSTOP */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1452 } |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1453 else |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1454 { |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1455 #ifdef VSTART |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1456 tty.main.c_cc[VSTART] = CDISABLE; |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1457 #endif /* VSTART */ |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1458 #ifdef VSTOP |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1459 tty.main.c_cc[VSTOP] = CDISABLE; |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1460 #endif /* VSTOP */ |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1461 } |
491 | 1462 #endif /* mips or HAVE_TCATTR */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1463 |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1464 #ifdef SET_LINE_DISCIPLINE |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
1465 /* Need to explicitly request TERMIODISC line discipline or |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1466 Ultrix's termios does not work correctly. */ |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1467 tty.main.c_line = SET_LINE_DISCIPLINE; |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1468 #endif |
491 | 1469 #ifdef AIX |
1470 #ifndef IBMR2AIX | |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1471 /* AIX enhanced edit loses NULs, so disable it. */ |
579 | 1472 tty.main.c_line = 0; |
1473 tty.main.c_iflag &= ~ASCEDIT; | |
491 | 1474 #else |
579 | 1475 tty.main.c_cc[VSTRT] = 255; |
1476 tty.main.c_cc[VSTOP] = 255; | |
1477 tty.main.c_cc[VSUSP] = 255; | |
1478 tty.main.c_cc[VDSUSP] = 255; | |
491 | 1479 #endif /* IBMR2AIX */ |
18232
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1480 if (flow_control) |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1481 { |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1482 #ifdef VSTART |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1483 tty.main.c_cc[VSTART] = '\021'; |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1484 #endif /* VSTART */ |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1485 #ifdef VSTOP |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1486 tty.main.c_cc[VSTOP] = '\023'; |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1487 #endif /* VSTOP */ |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1488 } |
491 | 1489 /* Also, PTY overloads NUL and BREAK. |
1490 don't ignore break, but don't signal either, so it looks like NUL. | |
1491 This really serves a purpose only if running in an XTERM window | |
1492 or via TELNET or the like, but does no harm elsewhere. */ | |
579 | 1493 tty.main.c_iflag &= ~IGNBRK; |
1494 tty.main.c_iflag &= ~BRKINT; | |
491 | 1495 #endif |
1496 #else /* if not HAVE_TERMIO */ | |
1497 #ifdef VMS | |
579 | 1498 tty.main.tt_char |= TT$M_NOECHO; |
491 | 1499 if (meta_key) |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
1500 tty.main.tt_char |= TT$M_EIGHTBIT; |
491 | 1501 if (flow_control) |
579 | 1502 tty.main.tt_char |= TT$M_TTSYNC; |
491 | 1503 else |
579 | 1504 tty.main.tt_char &= ~TT$M_TTSYNC; |
1505 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; | |
491 | 1506 #else /* not VMS (BSD, that is) */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1507 #ifndef DOS_NT |
21532
fff5e42d7b2a
(init_sys_modes): Fix mixing of Lisp_Object and int
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
1508 XSETINT (Vtty_erase_char, tty.main.sg_erase); |
579 | 1509 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); |
491 | 1510 if (meta_key) |
579 | 1511 tty.main.sg_flags |= ANYP; |
1512 tty.main.sg_flags |= interrupt_input ? RAW : CBREAK; | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1513 #endif /* not DOS_NT */ |
491 | 1514 #endif /* not VMS (BSD, that is) */ |
1515 #endif /* not HAVE_TERMIO */ | |
1516 | |
579 | 1517 /* If going to use CBREAK mode, we must request C-g to interrupt |
1518 and turn off start and stop chars, etc. If not going to use | |
1519 CBREAK mode, do this anyway so as to turn off local flow | |
1520 control for user coming over network on 4.2; in this case, | |
1521 only t_stopc and t_startc really matter. */ | |
1522 #ifndef HAVE_TERMIO | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1523 #ifdef HAVE_TCHARS |
579 | 1524 /* Note: if not using CBREAK mode, it makes no difference how we |
1525 set this */ | |
1526 tty.tchars = new_tchars; | |
1527 tty.tchars.t_intrc = quit_char; | |
1528 if (flow_control) | |
1529 { | |
1530 tty.tchars.t_startc = '\021'; | |
1531 tty.tchars.t_stopc = '\023'; | |
1532 } | |
1533 | |
1534 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | old_tty.lmode; | |
3759
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1535 #ifdef ultrix |
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1536 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt |
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1537 anything, and leaving it in breaks the meta key. Go figure. */ |
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1538 tty.lmode &= ~LLITOUT; |
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1539 #endif |
579 | 1540 |
1541 #ifdef BSD4_1 | |
1542 lmode = tty.lmode; | |
1543 #endif | |
1544 | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1545 #endif /* HAVE_TCHARS */ |
579 | 1546 #endif /* not HAVE_TERMIO */ |
1547 | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1548 #ifdef HAVE_LTCHARS |
579 | 1549 tty.ltchars = new_ltchars; |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1550 #endif /* HAVE_LTCHARS */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1551 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ |
9572 | 1552 if (!term_initted) |
1553 internal_terminal_init (); | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1554 dos_ttraw (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1555 #endif |
579 | 1556 |
1557 EMACS_SET_TTY (input_fd, &tty, 0); | |
491 | 1558 |
1559 /* This code added to insure that, if flow-control is not to be used, | |
766 | 1560 we have an unlocked terminal at the start. */ |
579 | 1561 |
491 | 1562 #ifdef TCXONC |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1563 if (!flow_control) ioctl (input_fd, TCXONC, 1); |
491 | 1564 #endif |
1565 #ifndef APOLLO | |
1566 #ifdef TIOCSTART | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1567 if (!flow_control) ioctl (input_fd, TIOCSTART, 0); |
491 | 1568 #endif |
1569 #endif | |
1570 | |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1571 #if defined (HAVE_TERMIOS) || defined (HPUX9) |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
1572 #ifdef TCOON |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1573 if (!flow_control) tcflow (input_fd, TCOON); |
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1574 #endif |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
1575 #endif |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1576 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1577 #ifdef AIXHFT |
491 | 1578 hft_init (); |
1579 #ifdef IBMR2AIX | |
1580 { | |
1581 /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it | |
1582 to be only LF. This is the way that is done. */ | |
1583 struct termio tty; | |
1584 | |
1585 if (ioctl (1, HFTGETID, &tty) != -1) | |
1586 write (1, "\033[20l", 5); | |
1587 } | |
1588 #endif | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1589 #endif /* AIXHFT */ |
491 | 1590 |
1591 #ifdef VMS | |
1592 /* Appears to do nothing when in PASTHRU mode. | |
579 | 1593 SYS$QIOW (0, input_fd, IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, |
491 | 1594 interrupt_signal, oob_chars, 0, 0, 0, 0); |
1595 */ | |
1596 queue_kbd_input (0); | |
1597 #endif /* VMS */ | |
1598 } | |
1599 | |
1600 #ifdef F_SETFL | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1601 #ifndef F_SETOWN_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1602 #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ |
7889
11d254f1f196
(init_sys_modes): Don't set up sigio here if window system.
Richard M. Stallman <rms@gnu.org>
parents:
7878
diff
changeset
|
1603 if (interrupt_input |
11d254f1f196
(init_sys_modes): Don't set up sigio here if window system.
Richard M. Stallman <rms@gnu.org>
parents:
7878
diff
changeset
|
1604 && ! read_socket_hook && EQ (Vwindow_system, Qnil)) |
491 | 1605 { |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1606 old_fcntl_owner = fcntl (input_fd, F_GETOWN, 0); |
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1607 fcntl (input_fd, F_SETOWN, getpid ()); |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1608 init_sigio (input_fd); |
491 | 1609 } |
1610 #endif /* F_GETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1611 #endif /* F_SETOWN_BUG */ |
491 | 1612 #endif /* F_SETFL */ |
1613 | |
1614 #ifdef BSD4_1 | |
1615 if (interrupt_input) | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1616 init_sigio (input_fd); |
491 | 1617 #endif |
1618 | |
1619 #ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ | |
1620 #undef _IOFBF | |
1621 #endif | |
1622 #ifdef _IOFBF | |
1623 /* This symbol is defined on recent USG systems. | |
1624 Someone says without this call USG won't really buffer the file | |
1625 even with a call to setbuf. */ | |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
1626 setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf); |
491 | 1627 #else |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
1628 setbuf (stdout, (char *) _sobuf); |
491 | 1629 #endif |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
1630 #ifdef HAVE_WINDOW_SYSTEM |
13174
d9170c4ec837
(init_sys_modes) [!HAVE_X_WINDOWS (MSDOS)]: Always call set_terminal_modes.
Kim F. Storm <storm@cua.dk>
parents:
12988
diff
changeset
|
1631 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore |
d9170c4ec837
(init_sys_modes) [!HAVE_X_WINDOWS (MSDOS)]: Always call set_terminal_modes.
Kim F. Storm <storm@cua.dk>
parents:
12988
diff
changeset
|
1632 needs the initialization code below. */ |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1633 if (EQ (Vwindow_system, Qnil) |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1634 #ifndef WINDOWSNT |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1635 /* When running in tty mode on NT/Win95, we have a read_socket |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1636 hook, but still need the rest of the initialization code below. */ |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1637 && (! read_socket_hook) |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1638 #endif |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1639 ) |
13174
d9170c4ec837
(init_sys_modes) [!HAVE_X_WINDOWS (MSDOS)]: Always call set_terminal_modes.
Kim F. Storm <storm@cua.dk>
parents:
12988
diff
changeset
|
1640 #endif |
7878
546334ab3974
(init_sys_modes): Don't call set_terminal_modes
Richard M. Stallman <rms@gnu.org>
parents:
7559
diff
changeset
|
1641 set_terminal_modes (); |
546334ab3974
(init_sys_modes): Don't call set_terminal_modes
Richard M. Stallman <rms@gnu.org>
parents:
7559
diff
changeset
|
1642 |
25157
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1643 if (!term_initted |
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1644 && FRAMEP (Vterminal_frame) |
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1645 && FRAME_TERMCAP_P (XFRAME (Vterminal_frame))) |
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1646 init_frame_faces (XFRAME (Vterminal_frame)); |
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1647 |
491 | 1648 if (term_initted && no_redraw_on_reenter) |
1649 { | |
1650 if (display_completed) | |
1651 direct_output_forward_char (0); | |
1652 } | |
1653 else | |
1654 { | |
766 | 1655 frame_garbaged = 1; |
1656 if (FRAMEP (Vterminal_frame)) | |
1657 FRAME_GARBAGED_P (XFRAME (Vterminal_frame)) = 1; | |
491 | 1658 } |
579 | 1659 |
491 | 1660 term_initted = 1; |
1661 } | |
1662 | |
1663 /* Return nonzero if safe to use tabs in output. | |
1664 At the time this is called, init_sys_modes has not been done yet. */ | |
1665 | |
21514 | 1666 int |
491 | 1667 tabs_safe_p () |
1668 { | |
579 | 1669 struct emacs_tty tty; |
1670 | |
1671 EMACS_GET_TTY (input_fd, &tty); | |
1672 return EMACS_TTY_TABS_OK (&tty); | |
491 | 1673 } |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1674 |
491 | 1675 /* Get terminal size from system. |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1676 Store number of lines into *HEIGHTP and width into *WIDTHP. |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1677 We store 0 if there's no valid information. */ |
491 | 1678 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1679 void |
766 | 1680 get_frame_size (widthp, heightp) |
491 | 1681 int *widthp, *heightp; |
1682 { | |
579 | 1683 |
1684 #ifdef TIOCGWINSZ | |
1685 | |
1686 /* BSD-style. */ | |
1687 struct winsize size; | |
1688 | |
1689 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) | |
1690 *widthp = *heightp = 0; | |
1691 else | |
1692 { | |
1693 *widthp = size.ws_col; | |
1694 *heightp = size.ws_row; | |
1695 } | |
1696 | |
1697 #else | |
491 | 1698 #ifdef TIOCGSIZE |
579 | 1699 |
1700 /* SunOS - style. */ | |
1701 struct ttysize size; | |
1702 | |
1703 if (ioctl (input_fd, TIOCGSIZE, &size) == -1) | |
1704 *widthp = *heightp = 0; | |
1705 else | |
1706 { | |
1707 *widthp = size.ts_cols; | |
1708 *heightp = size.ts_lines; | |
1709 } | |
1710 | |
1711 #else | |
491 | 1712 #ifdef VMS |
579 | 1713 |
1714 struct sensemode tty; | |
1715 | |
1716 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, | |
491 | 1717 &tty.class, 12, 0, 0, 0, 0); |
1718 *widthp = tty.scr_wid; | |
1719 *heightp = tty.scr_len; | |
579 | 1720 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1721 #else |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1722 #ifdef MSDOS |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1723 *widthp = ScreenCols (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1724 *heightp = ScreenRows (); |
491 | 1725 #else /* system doesn't know size */ |
1726 *widthp = 0; | |
1727 *heightp = 0; | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1728 #endif |
579 | 1729 |
1730 #endif /* not VMS */ | |
1731 #endif /* not SunOS-style */ | |
1732 #endif /* not BSD-style */ | |
491 | 1733 } |
579 | 1734 |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1735 /* Set the logical window size associated with descriptor FD |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1736 to HEIGHT and WIDTH. This is used mainly with ptys. */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1737 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1738 int |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1739 set_window_size (fd, height, width) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1740 int fd, height, width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1741 { |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1742 #ifdef TIOCSWINSZ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1743 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1744 /* BSD-style. */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1745 struct winsize size; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1746 size.ws_row = height; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1747 size.ws_col = width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1748 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1749 if (ioctl (fd, TIOCSWINSZ, &size) == -1) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1750 return 0; /* error */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1751 else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1752 return 1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1753 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1754 #else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1755 #ifdef TIOCSSIZE |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1756 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1757 /* SunOS - style. */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1758 struct ttysize size; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1759 size.ts_lines = height; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1760 size.ts_cols = width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1761 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1762 if (ioctl (fd, TIOCGSIZE, &size) == -1) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1763 return 0; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1764 else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1765 return 1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1766 #else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1767 return -1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1768 #endif /* not SunOS-style */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1769 #endif /* not BSD-style */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1770 } |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1771 |
491 | 1772 |
579 | 1773 /* Prepare the terminal for exiting Emacs; move the cursor to the |
766 | 1774 bottom of the frame, turn off interrupt-driven I/O, etc. */ |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1775 void |
491 | 1776 reset_sys_modes () |
1777 { | |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1778 struct frame *sf; |
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1779 |
491 | 1780 if (noninteractive) |
1781 { | |
1782 fflush (stdout); | |
1783 return; | |
1784 } | |
1785 if (!term_initted) | |
1786 return; | |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
1787 #ifdef HAVE_WINDOW_SYSTEM |
9572 | 1788 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore |
1789 needs the clean-up code below. */ | |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1790 if (!EQ (Vwindow_system, Qnil) |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1791 #ifndef WINDOWSNT |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1792 /* When running in tty mode on NT/Win95, we have a read_socket |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1793 hook, but still need the rest of the clean-up code below. */ |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1794 || read_socket_hook |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1795 #endif |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1796 ) |
491 | 1797 return; |
9572 | 1798 #endif |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1799 sf = SELECTED_FRAME (); |
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1800 cursor_to (FRAME_HEIGHT (sf) - 1, 0); |
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1801 clear_end_of_line (FRAME_WIDTH (sf)); |
491 | 1802 /* clear_end_of_line may move the cursor */ |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1803 cursor_to (FRAME_HEIGHT (sf) - 1, 0); |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1804 #if defined (IBMR2AIX) && defined (AIXHFT) |
491 | 1805 { |
1806 /* HFT devices normally use ^J as a LF/CR. We forced it to | |
1807 do the LF only. Now, we need to reset it. */ | |
1808 struct termio tty; | |
1809 | |
1810 if (ioctl (1, HFTGETID, &tty) != -1) | |
1811 write (1, "\033[20h", 5); | |
1812 } | |
1813 #endif | |
1814 | |
1815 reset_terminal_modes (); | |
1816 fflush (stdout); | |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
1817 #ifdef BSD_SYSTEM |
491 | 1818 #ifndef BSD4_1 |
1819 /* Avoid possible loss of output when changing terminal modes. */ | |
1820 fsync (fileno (stdout)); | |
1821 #endif | |
1822 #endif | |
579 | 1823 |
491 | 1824 #ifdef F_SETFL |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1825 #ifndef F_SETOWN_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1826 #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ |
491 | 1827 if (interrupt_input) |
1828 { | |
1829 reset_sigio (); | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1830 fcntl (input_fd, F_SETOWN, old_fcntl_owner); |
491 | 1831 } |
1832 #endif /* F_SETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1833 #endif /* F_SETOWN_BUG */ |
6489
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1834 #ifdef O_NDELAY |
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1835 fcntl (input_fd, F_SETFL, fcntl (input_fd, F_GETFL, 0) & ~O_NDELAY); |
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1836 #endif |
491 | 1837 #endif /* F_SETFL */ |
1838 #ifdef BSD4_1 | |
1839 if (interrupt_input) | |
1840 reset_sigio (); | |
1841 #endif /* BSD4_1 */ | |
579 | 1842 |
12070 | 1843 if (old_tty_valid) |
1844 while (EMACS_SET_TTY (input_fd, &old_tty, 0) < 0 && errno == EINTR) | |
1845 ; | |
491 | 1846 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1847 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1848 dos_ttcooked (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1849 #endif |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1850 |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1851 #ifdef SET_LINE_DISCIPLINE |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1852 /* Ultrix's termios *ignores* any line discipline except TERMIODISC. |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1853 A different old line discipline is therefore not restored, yet. |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1854 Restore the old line discipline by hand. */ |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1855 ioctl (0, TIOCSETD, &old_tty.main.c_line); |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1856 #endif |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1857 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1858 #ifdef AIXHFT |
491 | 1859 hft_reset (); |
1860 #endif | |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1861 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1862 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1863 widen_foreground_group (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1864 #endif |
491 | 1865 } |
1866 | |
1867 #ifdef HAVE_PTYS | |
1868 | |
1869 /* Set up the proper status flags for use of a pty. */ | |
1870 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1871 void |
491 | 1872 setup_pty (fd) |
1873 int fd; | |
1874 { | |
1875 /* I'm told that TOICREMOTE does not mean control chars | |
1876 "can't be sent" but rather that they don't have | |
1877 input-editing or signaling effects. | |
1878 That should be good, because we have other ways | |
1879 to do those things in Emacs. | |
1880 However, telnet mode seems not to work on 4.2. | |
1881 So TIOCREMOTE is turned off now. */ | |
1882 | |
1883 /* Under hp-ux, if TIOCREMOTE is turned on, some calls | |
1884 will hang. In particular, the "timeout" feature (which | |
1885 causes a read to return if there is no data available) | |
1886 does this. Also it is known that telnet mode will hang | |
1887 in such a way that Emacs must be stopped (perhaps this | |
1888 is the same problem). | |
1889 | |
1890 If TIOCREMOTE is turned off, then there is a bug in | |
1891 hp-ux which sometimes loses data. Apparently the | |
1892 code which blocks the master process when the internal | |
1893 buffer fills up does not work. Other than this, | |
1894 though, everything else seems to work fine. | |
1895 | |
1896 Since the latter lossage is more benign, we may as well | |
1897 lose that way. -- cph */ | |
1898 #ifdef FIONBIO | |
29033
bad1d68a57e3
(setup_pty): Treat case that UNIX98_PTYS is defined
Gerd Moellmann <gerd@gnu.org>
parents:
27933
diff
changeset
|
1899 #if defined(SYSV_PTYS) || defined(UNIX98_PTYS) |
491 | 1900 { |
1901 int on = 1; | |
1902 ioctl (fd, FIONBIO, &on); | |
1903 } | |
1904 #endif | |
1905 #endif | |
1906 #ifdef IBMRTAIX | |
1907 /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */ | |
1908 /* ignore SIGHUP once we've started a child on a pty. Note that this may */ | |
1909 /* cause EMACS not to die when it should, i.e., when its own controlling */ | |
1910 /* tty goes away. I've complained to the AIX developers, and they may */ | |
1911 /* change this behavior, but I'm not going to hold my breath. */ | |
1912 signal (SIGHUP, SIG_IGN); | |
1913 #endif | |
1914 } | |
1915 #endif /* HAVE_PTYS */ | |
1916 | |
1917 #ifdef VMS | |
1918 | |
1919 /* Assigning an input channel is done at the start of Emacs execution. | |
1920 This is called each time Emacs is resumed, also, but does nothing | |
1921 because input_chain is no longer zero. */ | |
1922 | |
21514 | 1923 void |
491 | 1924 init_vms_input () |
1925 { | |
1926 int status; | |
1927 | |
579 | 1928 if (input_fd == 0) |
491 | 1929 { |
579 | 1930 status = SYS$ASSIGN (&input_dsc, &input_fd, 0, 0); |
491 | 1931 if (! (status & 1)) |
1932 LIB$STOP (status); | |
1933 } | |
1934 } | |
1935 | |
1936 /* Deassigning the input channel is done before exiting. */ | |
1937 | |
21514 | 1938 void |
491 | 1939 stop_vms_input () |
1940 { | |
579 | 1941 return SYS$DASSGN (input_fd); |
491 | 1942 } |
1943 | |
1944 short input_buffer; | |
1945 | |
1946 /* Request reading one character into the keyboard buffer. | |
1947 This is done as soon as the buffer becomes empty. */ | |
1948 | |
21514 | 1949 void |
491 | 1950 queue_kbd_input () |
1951 { | |
1952 int status; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1953 extern kbd_input_ast (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1954 |
491 | 1955 waiting_for_ast = 0; |
1956 stop_input = 0; | |
579 | 1957 status = SYS$QIO (0, input_fd, IO$_READVBLK, |
491 | 1958 &input_iosb, kbd_input_ast, 1, |
1959 &input_buffer, 1, 0, terminator_mask, 0, 0); | |
1960 } | |
1961 | |
1962 int input_count; | |
1963 | |
1964 /* Ast routine that is called when keyboard input comes in | |
1965 in accord with the SYS$QIO above. */ | |
1966 | |
21514 | 1967 void |
491 | 1968 kbd_input_ast () |
1969 { | |
1970 register int c = -1; | |
1971 int old_errno = errno; | |
648 | 1972 extern EMACS_TIME *input_available_clear_time; |
491 | 1973 |
1974 if (waiting_for_ast) | |
1975 SYS$SETEF (input_ef); | |
1976 waiting_for_ast = 0; | |
1977 input_count++; | |
1978 #ifdef ASTDEBUG | |
1979 if (input_count == 25) | |
1980 exit (1); | |
1981 printf ("Ast # %d,", input_count); | |
1982 printf (" iosb = %x, %x, %x, %x", | |
1983 input_iosb.offset, input_iosb.status, input_iosb.termlen, | |
1984 input_iosb.term); | |
1985 #endif | |
1986 if (input_iosb.offset) | |
1987 { | |
1988 c = input_buffer; | |
1989 #ifdef ASTDEBUG | |
1990 printf (", char = 0%o", c); | |
1991 #endif | |
1992 } | |
1993 #ifdef ASTDEBUG | |
1994 printf ("\n"); | |
1995 fflush (stdout); | |
1996 sleep (1); | |
1997 #endif | |
1998 if (! stop_input) | |
1999 queue_kbd_input (); | |
2000 if (c >= 0) | |
2001 { | |
2002 struct input_event e; | |
2003 e.kind = ascii_keystroke; | |
9279
2382e2f3884e
(kbd_input_ast, read_input_waiting): Use new accessor macros instead of
Karl Heuer <kwzh@gnu.org>
parents:
9239
diff
changeset
|
2004 XSETINT (e.code, c); |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
2005 e.frame_or_window = selected_frame; |
491 | 2006 kbd_buffer_store_event (&e); |
2007 } | |
648 | 2008 if (input_available_clear_time) |
2009 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | |
491 | 2010 errno = old_errno; |
2011 } | |
2012 | |
2013 /* Wait until there is something in kbd_buffer. */ | |
2014 | |
21514 | 2015 void |
491 | 2016 wait_for_kbd_input () |
2017 { | |
2018 extern int have_process_input, process_exited; | |
2019 | |
2020 /* If already something, avoid doing system calls. */ | |
2021 if (detect_input_pending ()) | |
2022 { | |
2023 return; | |
2024 } | |
2025 /* Clear a flag, and tell ast routine above to set it. */ | |
2026 SYS$CLREF (input_ef); | |
2027 waiting_for_ast = 1; | |
2028 /* Check for timing error: ast happened while we were doing that. */ | |
2029 if (!detect_input_pending ()) | |
2030 { | |
2031 /* No timing error: wait for flag to be set. */ | |
2032 set_waiting_for_input (0); | |
2033 SYS$WFLOR (input_ef, input_eflist); | |
41163
c8f21aec2f62
(wait_for_kbd_input) [VMS]: Do not call clear_waiting_for_input with
Pavel Janík <Pavel@Janik.cz>
parents:
40932
diff
changeset
|
2034 clear_waiting_for_input (); |
491 | 2035 if (!detect_input_pending ()) |
2036 /* Check for subprocess input availability */ | |
2037 { | |
2038 int dsp = have_process_input || process_exited; | |
2039 | |
2040 SYS$CLREF (process_ef); | |
2041 if (have_process_input) | |
2042 process_command_input (); | |
2043 if (process_exited) | |
2044 process_exit (); | |
2045 if (dsp) | |
2046 { | |
2047 update_mode_lines++; | |
5253
1846f03ac8f3
[VMS] (wait_for_kbd_input): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5189
diff
changeset
|
2048 prepare_menu_bars (); |
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
35189
diff
changeset
|
2049 redisplay_preserve_echo_area (18); |
491 | 2050 } |
2051 } | |
2052 } | |
2053 waiting_for_ast = 0; | |
2054 } | |
2055 | |
2056 /* Get rid of any pending QIO, when we are about to suspend | |
2057 or when we want to throw away pending input. | |
2058 We wait for a positive sign that the AST routine has run | |
2059 and therefore there is no I/O request queued when we return. | |
2060 SYS$SETAST is used to avoid a timing error. */ | |
2061 | |
21514 | 2062 void |
491 | 2063 end_kbd_input () |
2064 { | |
2065 #ifdef ASTDEBUG | |
2066 printf ("At end_kbd_input.\n"); | |
2067 fflush (stdout); | |
2068 sleep (1); | |
2069 #endif | |
2070 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ | |
2071 { | |
579 | 2072 SYS$CANCEL (input_fd); |
491 | 2073 return; |
2074 } | |
2075 | |
2076 SYS$SETAST (0); | |
2077 /* Clear a flag, and tell ast routine above to set it. */ | |
2078 SYS$CLREF (input_ef); | |
2079 waiting_for_ast = 1; | |
2080 stop_input = 1; | |
579 | 2081 SYS$CANCEL (input_fd); |
491 | 2082 SYS$SETAST (1); |
2083 SYS$WAITFR (input_ef); | |
2084 waiting_for_ast = 0; | |
2085 } | |
2086 | |
2087 /* Wait for either input available or time interval expiry. */ | |
2088 | |
21514 | 2089 void |
491 | 2090 input_wait_timeout (timeval) |
2091 int timeval; /* Time to wait, in seconds */ | |
2092 { | |
2093 int time [2]; | |
2094 static int zero = 0; | |
2095 static int large = -10000000; | |
2096 | |
2097 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
2098 | |
2099 /* If already something, avoid doing system calls. */ | |
2100 if (detect_input_pending ()) | |
2101 { | |
2102 return; | |
2103 } | |
2104 /* Clear a flag, and tell ast routine above to set it. */ | |
2105 SYS$CLREF (input_ef); | |
2106 waiting_for_ast = 1; | |
2107 /* Check for timing error: ast happened while we were doing that. */ | |
2108 if (!detect_input_pending ()) | |
2109 { | |
2110 /* No timing error: wait for flag to be set. */ | |
2111 SYS$CANTIM (1, 0); | |
2112 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
2113 SYS$WFLOR (timer_ef, timer_eflist); /* Wait for timer expiry or input */ | |
2114 } | |
2115 waiting_for_ast = 0; | |
2116 } | |
2117 | |
2118 /* The standard `sleep' routine works some other way | |
2119 and it stops working if you have ever quit out of it. | |
2120 This one continues to work. */ | |
2121 | |
2122 sys_sleep (timeval) | |
2123 int timeval; | |
2124 { | |
2125 int time [2]; | |
2126 static int zero = 0; | |
2127 static int large = -10000000; | |
2128 | |
2129 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
2130 | |
2131 SYS$CANTIM (1, 0); | |
2132 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
2133 SYS$WAITFR (timer_ef); /* Wait for timer expiry only */ | |
2134 } | |
2135 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2136 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2137 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2138 int fd; |
491 | 2139 { |
2140 request_sigio (); | |
2141 } | |
2142 | |
2143 reset_sigio () | |
2144 { | |
2145 unrequest_sigio (); | |
2146 } | |
2147 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2148 void |
491 | 2149 request_sigio () |
2150 { | |
2151 croak ("request sigio"); | |
2152 } | |
2153 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2154 void |
491 | 2155 unrequest_sigio () |
2156 { | |
2157 croak ("unrequest sigio"); | |
2158 } | |
2159 | |
2160 #endif /* VMS */ | |
2161 | |
2162 /* Note that VMS compiler won't accept defined (CANNOT_DUMP). */ | |
2163 #ifndef CANNOT_DUMP | |
2164 #define NEED_STARTS | |
2165 #endif | |
2166 | |
2167 #ifndef SYSTEM_MALLOC | |
2168 #ifndef NEED_STARTS | |
2169 #define NEED_STARTS | |
2170 #endif | |
2171 #endif | |
2172 | |
2173 #ifdef NEED_STARTS | |
2174 /* Some systems that cannot dump also cannot implement these. */ | |
2175 | |
2176 /* | |
2177 * Return the address of the start of the text segment prior to | |
2178 * doing an unexec. After unexec the return value is undefined. | |
2179 * See crt0.c for further explanation and _start. | |
2180 * | |
2181 */ | |
2182 | |
27922
db5a4af9fafd
(start_of_text): Don't define this function for NetBSD
Gerd Moellmann <gerd@gnu.org>
parents:
27709
diff
changeset
|
2183 #if !(defined (__NetBSD__) && defined (__ELF__)) |
9039
22e5c594d59d
(start_of_text): Don't test CANNOT_UNEXEC.
Richard M. Stallman <rms@gnu.org>
parents:
9036
diff
changeset
|
2184 #ifndef HAVE_TEXT_START |
491 | 2185 char * |
2186 start_of_text () | |
2187 { | |
2188 #ifdef TEXT_START | |
2189 return ((char *) TEXT_START); | |
2190 #else | |
2191 #ifdef GOULD | |
2192 extern csrt (); | |
2193 return ((char *) csrt); | |
2194 #else /* not GOULD */ | |
2195 extern int _start (); | |
2196 return ((char *) _start); | |
2197 #endif /* GOULD */ | |
2198 #endif /* TEXT_START */ | |
2199 } | |
9039
22e5c594d59d
(start_of_text): Don't test CANNOT_UNEXEC.
Richard M. Stallman <rms@gnu.org>
parents:
9036
diff
changeset
|
2200 #endif /* not HAVE_TEXT_START */ |
27922
db5a4af9fafd
(start_of_text): Don't define this function for NetBSD
Gerd Moellmann <gerd@gnu.org>
parents:
27709
diff
changeset
|
2201 #endif |
491 | 2202 |
2203 /* | |
2204 * Return the address of the start of the data segment prior to | |
2205 * doing an unexec. After unexec the return value is undefined. | |
2206 * See crt0.c for further information and definition of data_start. | |
2207 * | |
2208 * Apparently, on BSD systems this is etext at startup. On | |
2209 * USG systems (swapping) this is highly mmu dependent and | |
2210 * is also dependent on whether or not the program is running | |
2211 * with shared text. Generally there is a (possibly large) | |
2212 * gap between end of text and start of data with shared text. | |
2213 * | |
2214 * On Uniplus+ systems with shared text, data starts at a | |
2215 * fixed address. Each port (from a given oem) is generally | |
2216 * different, and the specific value of the start of data can | |
2217 * be obtained via the UniPlus+ specific "uvar" system call, | |
2218 * however the method outlined in crt0.c seems to be more portable. | |
2219 * | |
2220 * Probably what will have to happen when a USG unexec is available, | |
2221 * at least on UniPlus, is temacs will have to be made unshared so | |
2222 * that text and data are contiguous. Then once loadup is complete, | |
2223 * unexec will produce a shared executable where the data can be | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
2224 * at the normal shared text boundary and the startofdata variable |
491 | 2225 * will be patched by unexec to the correct value. |
2226 * | |
2227 */ | |
2228 | |
2229 char * | |
2230 start_of_data () | |
2231 { | |
2232 #ifdef DATA_START | |
2233 return ((char *) DATA_START); | |
2234 #else | |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2235 #ifdef ORDINARY_LINK |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2236 /* |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2237 * This is a hack. Since we're not linking crt0.c or pre_crt0.c, |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2238 * data_start isn't defined. We take the address of environ, which |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2239 * is known to live at or near the start of the system crt0.c, and |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2240 * we don't sweat the handful of bytes that might lose. |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2241 */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2242 extern char **environ; |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2243 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
2244 return ((char *) &environ); |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2245 #else |
491 | 2246 extern int data_start; |
2247 return ((char *) &data_start); | |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2248 #endif /* ORDINARY_LINK */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2249 #endif /* DATA_START */ |
491 | 2250 } |
2251 #endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ | |
2252 | |
2253 #ifndef CANNOT_DUMP | |
2254 /* Some systems that cannot dump also cannot implement these. */ | |
2255 | |
2256 /* | |
2257 * Return the address of the end of the text segment prior to | |
2258 * doing an unexec. After unexec the return value is undefined. | |
2259 */ | |
2260 | |
2261 char * | |
2262 end_of_text () | |
2263 { | |
2264 #ifdef TEXT_END | |
2265 return ((char *) TEXT_END); | |
2266 #else | |
2267 extern int etext; | |
2268 return ((char *) &etext); | |
2269 #endif | |
2270 } | |
2271 | |
2272 /* | |
2273 * Return the address of the end of the data segment prior to | |
2274 * doing an unexec. After unexec the return value is undefined. | |
2275 */ | |
2276 | |
2277 char * | |
2278 end_of_data () | |
2279 { | |
2280 #ifdef DATA_END | |
2281 return ((char *) DATA_END); | |
2282 #else | |
2283 extern int edata; | |
2284 return ((char *) &edata); | |
2285 #endif | |
2286 } | |
2287 | |
2288 #endif /* not CANNOT_DUMP */ | |
2289 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2290 /* init_system_name sets up the string for the Lisp function |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2291 system-name to return. */ |
491 | 2292 |
2293 #ifdef BSD4_1 | |
2294 #include <whoami.h> | |
2295 #endif | |
2296 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2297 extern Lisp_Object Vsystem_name; |
491 | 2298 |
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2299 #ifndef BSD4_1 |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2300 #ifndef VMS |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2301 #ifdef HAVE_SOCKETS |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2302 #include <sys/socket.h> |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2303 #include <netdb.h> |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2304 #endif /* HAVE_SOCKETS */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2305 #endif /* not VMS */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2306 #endif /* not BSD4_1 */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2307 |
33718
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2308 #ifdef TRY_AGAIN |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2309 #ifndef HAVE_H_ERRNO |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2310 extern int h_errno; |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2311 #endif |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2312 #endif /* TRY_AGAIN */ |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2313 |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2314 void |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2315 init_system_name () |
491 | 2316 { |
2317 #ifdef BSD4_1 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2318 Vsystem_name = build_string (sysname); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2319 #else |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2320 #ifdef VMS |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2321 char *sp, *end; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2322 if ((sp = egetenv ("SYS$NODE")) == 0) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2323 Vsystem_name = build_string ("vax-vms"); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2324 else if ((end = index (sp, ':')) == 0) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2325 Vsystem_name = build_string (sp); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2326 else |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2327 Vsystem_name = make_string (sp, end - sp); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2328 #else |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2329 #ifndef HAVE_GETHOSTNAME |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2330 struct utsname uts; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2331 uname (&uts); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2332 Vsystem_name = build_string (uts.nodename); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2333 #else /* HAVE_GETHOSTNAME */ |
11800
a2f009e1b85b
(init_system_name): Clean up signedness mismatch.
Karl Heuer <kwzh@gnu.org>
parents:
11722
diff
changeset
|
2334 unsigned int hostname_size = 256; |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2335 char *hostname = (char *) alloca (hostname_size); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2336 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2337 /* Try to get the host name; if the buffer is too short, try |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2338 again. Apparently, the only indication gethostname gives of |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2339 whether the buffer was large enough is the presence or absence |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2340 of a '\0' in the string. Eech. */ |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2341 for (;;) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2342 { |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2343 gethostname (hostname, hostname_size - 1); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2344 hostname[hostname_size - 1] = '\0'; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2345 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2346 /* Was the buffer large enough for the '\0'? */ |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2347 if (strlen (hostname) < hostname_size - 1) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2348 break; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2349 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2350 hostname_size <<= 1; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2351 hostname = (char *) alloca (hostname_size); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2352 } |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2353 #ifdef HAVE_SOCKETS |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2354 /* Turn the hostname into the official, fully-qualified hostname. |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2355 Don't do this if we're going to dump; this can confuse system |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2356 libraries on some machines and make the dumped emacs core dump. */ |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2357 #ifndef CANNOT_DUMP |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2358 if (initialized) |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2359 #endif /* not CANNOT_DUMP */ |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2360 if (! index (hostname, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2361 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2362 struct hostent *hp; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2363 int count; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2364 for (count = 0;; count++) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2365 { |
8330
60adc323cfe7
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8285
diff
changeset
|
2366 #ifdef TRY_AGAIN |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2367 h_errno = 0; |
8330
60adc323cfe7
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8285
diff
changeset
|
2368 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2369 hp = gethostbyname (hostname); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
2370 #ifdef TRY_AGAIN |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2371 if (! (hp == 0 && h_errno == TRY_AGAIN)) |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
2372 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2373 break; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2374 if (count >= 5) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2375 break; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2376 Fsleep_for (make_number (1), Qnil); |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2377 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2378 if (hp) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2379 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2380 char *fqdn = (char *) hp->h_name; |
43177
de51098df2fd
(init_system_name): Put unused variable `p' in #if 0.
Pavel Janík <Pavel@Janik.cz>
parents:
42469
diff
changeset
|
2381 #if 0 |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2382 char *p; |
43177
de51098df2fd
(init_system_name): Put unused variable `p' in #if 0.
Pavel Janík <Pavel@Janik.cz>
parents:
42469
diff
changeset
|
2383 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2384 |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2385 if (!index (fqdn, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2386 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2387 /* We still don't have a fully qualified domain name. |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2388 Try to find one in the list of alternate names */ |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2389 char **alias = hp->h_aliases; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2390 while (*alias && !index (*alias, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2391 alias++; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2392 if (*alias) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2393 fqdn = *alias; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2394 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2395 hostname = fqdn; |
6799 | 2396 #if 0 |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2397 /* Convert the host name to lower case. */ |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2398 /* Using ctype.h here would introduce a possible locale |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2399 dependence that is probably wrong for hostnames. */ |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2400 p = hostname; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2401 while (*p) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2402 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2403 if (*p >= 'A' && *p <= 'Z') |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2404 *p += 'a' - 'A'; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2405 p++; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2406 } |
6799 | 2407 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2408 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2409 } |
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2410 #endif /* HAVE_SOCKETS */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2411 /* We used to try using getdomainname here, |
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2412 but NIIBE Yutaka <gniibe@etl.go.jp> says that |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2413 getdomainname gets the NIS/YP domain which often is not the same |
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2414 as in Internet domain name. */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2415 #if 0 /* Turned off because sysinfo is not really likely to return the |
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2416 correct Internet domain. */ |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2417 #if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2418 if (! index (hostname, '.')) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2419 { |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2420 /* The hostname is not fully qualified. Append the domain name. */ |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2421 |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2422 int hostlen = strlen (hostname); |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2423 int domain_size = 256; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2424 |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2425 for (;;) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2426 { |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2427 char *domain = (char *) alloca (domain_size + 1); |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2428 char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1); |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2429 int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size); |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2430 if (sys_domain_size <= 0) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2431 break; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2432 if (domain_size < sys_domain_size) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2433 { |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2434 domain_size = sys_domain_size; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2435 continue; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2436 } |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2437 strcpy (fqdn, hostname); |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2438 if (domain[0] == '.') |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2439 strcpy (fqdn + hostlen, domain); |
19258
cf4b06e6a5ab
(init_system_name): If domain is null, don't add a period.
Richard M. Stallman <rms@gnu.org>
parents:
19198
diff
changeset
|
2440 else if (domain[0] != 0) |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2441 { |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2442 fqdn[hostlen] = '.'; |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2443 strcpy (fqdn + hostlen + 1, domain); |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2444 } |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2445 hostname = fqdn; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2446 break; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2447 } |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2448 } |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2449 #endif /* HAVE_SYSINFO && defined (SI_SRPC_DOMAIN) */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2450 #endif /* 0 */ |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2451 Vsystem_name = build_string (hostname); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2452 #endif /* HAVE_GETHOSTNAME */ |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2453 #endif /* VMS */ |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2454 #endif /* BSD4_1 */ |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2455 { |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2456 unsigned char *p; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2457 for (p = XSTRING (Vsystem_name)->data; *p; p++) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2458 if (*p == ' ' || *p == '\t') |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2459 *p = '-'; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2460 } |
491 | 2461 } |
2462 | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
2463 #ifndef MSDOS |
491 | 2464 #ifndef VMS |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2465 #if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X) |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2466 |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2467 #include "sysselect.h" |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2468 #undef select |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2469 |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2470 #if defined (HAVE_X_WINDOWS) && !defined (HAVE_SELECT) |
491 | 2471 /* Cause explanatory error message at compile time, |
2472 since the select emulation is not good enough for X. */ | |
2473 int *x = &x_windows_lose_if_no_select_system_call; | |
2474 #endif | |
2475 | |
2476 /* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs | |
2477 * Only checks read descriptors. | |
2478 */ | |
2479 /* How long to wait between checking fds in select */ | |
2480 #define SELECT_PAUSE 1 | |
2481 int select_alarmed; | |
2482 | |
2483 /* For longjmp'ing back to read_input_waiting. */ | |
2484 | |
2485 jmp_buf read_alarm_throw; | |
2486 | |
2487 /* Nonzero if the alarm signal should throw back to read_input_waiting. | |
2488 The read_socket_hook function sets this to 1 while it is waiting. */ | |
2489 | |
2490 int read_alarm_should_throw; | |
2491 | |
2492 SIGTYPE | |
2493 select_alarm () | |
2494 { | |
2495 select_alarmed = 1; | |
2496 #ifdef BSD4_1 | |
2497 sigrelse (SIGALRM); | |
2498 #else /* not BSD4_1 */ | |
2499 signal (SIGALRM, SIG_IGN); | |
2500 #endif /* not BSD4_1 */ | |
2501 if (read_alarm_should_throw) | |
2502 longjmp (read_alarm_throw, 1); | |
2503 } | |
2504 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
2505 #ifndef WINDOWSNT |
491 | 2506 /* Only rfds are checked. */ |
2507 int | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2508 sys_select (nfds, rfds, wfds, efds, timeout) |
491 | 2509 int nfds; |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2510 SELECT_TYPE *rfds, *wfds, *efds; |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2511 EMACS_TIME *timeout; |
491 | 2512 { |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2513 int ravail = 0; |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2514 SELECT_TYPE orfds; |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2515 int timeoutval; |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2516 int *local_timeout; |
491 | 2517 extern int proc_buffered_char[]; |
2518 #ifndef subprocesses | |
2519 int process_tick = 0, update_tick = 0; | |
2520 #else | |
2521 extern int process_tick, update_tick; | |
2522 #endif | |
2523 unsigned char buf; | |
2524 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2525 #if defined (HAVE_SELECT) && defined (HAVE_X_WINDOWS) |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2526 /* If we're using X, then the native select will work; we only need the |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2527 emulation for non-X usage. */ |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2528 if (!NILP (Vwindow_system)) |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2529 return select (nfds, rfds, wfds, efds, timeout); |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2530 #endif |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2531 timeoutval = timeout ? EMACS_SECS (*timeout) : 100000; |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2532 local_timeout = &timeoutval; |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2533 FD_ZERO (&orfds); |
491 | 2534 if (rfds) |
2535 { | |
2536 orfds = *rfds; | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2537 FD_ZERO (rfds); |
491 | 2538 } |
2539 if (wfds) | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2540 FD_ZERO (wfds); |
491 | 2541 if (efds) |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2542 FD_ZERO (efds); |
491 | 2543 |
2544 /* If we are looking only for the terminal, with no timeout, | |
2545 just read it and wait -- that's more efficient. */ | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2546 if (*local_timeout == 100000 && process_tick == update_tick |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2547 && FD_ISSET (0, &orfds)) |
491 | 2548 { |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2549 int fd; |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2550 for (fd = 1; fd < nfds; ++fd) |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2551 if (FD_ISSET (fd, &orfds)) |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2552 goto hardway; |
491 | 2553 if (! detect_input_pending ()) |
2554 read_input_waiting (); | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2555 FD_SET (0, rfds); |
491 | 2556 return 1; |
2557 } | |
2558 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2559 hardway: |
491 | 2560 /* Once a second, till the timer expires, check all the flagged read |
2561 * descriptors to see if any input is available. If there is some then | |
2562 * set the corresponding bit in the return copy of rfds. | |
2563 */ | |
2564 while (1) | |
2565 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2566 register int to_check, fd; |
491 | 2567 |
2568 if (rfds) | |
2569 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2570 for (to_check = nfds, fd = 0; --to_check >= 0; fd++) |
491 | 2571 { |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2572 if (FD_ISSET (fd, &orfds)) |
491 | 2573 { |
2574 int avail = 0, status = 0; | |
2575 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2576 if (fd == 0) |
491 | 2577 avail = detect_input_pending (); /* Special keyboard handler */ |
2578 else | |
2579 { | |
2580 #ifdef FIONREAD | |
2581 status = ioctl (fd, FIONREAD, &avail); | |
2582 #else /* no FIONREAD */ | |
2583 /* Hoping it will return -1 if nothing available | |
2584 or 0 if all 0 chars requested are read. */ | |
2585 if (proc_buffered_char[fd] >= 0) | |
2586 avail = 1; | |
2587 else | |
2588 { | |
2589 avail = read (fd, &buf, 1); | |
2590 if (avail > 0) | |
2591 proc_buffered_char[fd] = buf; | |
2592 } | |
2593 #endif /* no FIONREAD */ | |
2594 } | |
2595 if (status >= 0 && avail > 0) | |
2596 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2597 FD_SET (fd, rfds); |
491 | 2598 ravail++; |
2599 } | |
2600 } | |
2601 } | |
2602 } | |
2603 if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick) | |
2604 break; | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2605 |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2606 turn_on_atimers (0); |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2607 signal (SIGALRM, select_alarm); |
491 | 2608 select_alarmed = 0; |
2609 alarm (SELECT_PAUSE); | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2610 |
491 | 2611 /* Wait for a SIGALRM (or maybe a SIGTINT) */ |
2612 while (select_alarmed == 0 && *local_timeout != 0 | |
2613 && process_tick == update_tick) | |
2614 { | |
2615 /* If we are interested in terminal input, | |
2616 wait by reading the terminal. | |
2617 That makes instant wakeup for terminal input at least. */ | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2618 if (FD_ISSET (0, &orfds)) |
491 | 2619 { |
2620 read_input_waiting (); | |
2621 if (detect_input_pending ()) | |
2622 select_alarmed = 1; | |
2623 } | |
2624 else | |
2625 pause (); | |
2626 } | |
2627 (*local_timeout) -= SELECT_PAUSE; | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2628 |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2629 /* Reset the old alarm if there was one. */ |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2630 turn_on_atimers (1); |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2631 |
491 | 2632 if (*local_timeout == 0) /* Stop on timer being cleared */ |
2633 break; | |
2634 } | |
2635 return ravail; | |
2636 } | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
2637 #endif /* not WINDOWSNT */ |
491 | 2638 |
2639 /* Read keyboard input into the standard buffer, | |
2640 waiting for at least one character. */ | |
2641 | |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
2642 /* Make all keyboard buffers much bigger when using a window system. */ |
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
2643 #ifdef HAVE_WINDOW_SYSTEM |
491 | 2644 #define BUFFER_SIZE_FACTOR 16 |
2645 #else | |
2646 #define BUFFER_SIZE_FACTOR 1 | |
2647 #endif | |
2648 | |
21514 | 2649 void |
491 | 2650 read_input_waiting () |
2651 { | |
2652 struct input_event e; | |
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2653 int nread, i; |
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2654 extern int quit_char; |
491 | 2655 |
2656 if (read_socket_hook) | |
2657 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2658 struct input_event buf[256]; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2659 |
491 | 2660 read_alarm_should_throw = 0; |
2661 if (! setjmp (read_alarm_throw)) | |
33217
960181d7eebf
(read_input_waiting): Remove extraneous argument to
Andrew Innes <andrewi@gnu.org>
parents:
32752
diff
changeset
|
2662 nread = (*read_socket_hook) (0, buf, 256, 1); |
491 | 2663 else |
2664 nread = -1; | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2665 |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2666 /* Scan the chars for C-g and store them in kbd_buffer. */ |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2667 for (i = 0; i < nread; i++) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2668 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2669 kbd_buffer_store_event (&buf[i]); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2670 /* Don't look at input that follows a C-g too closely. |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2671 This reduces lossage due to autorepeat on C-g. */ |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2672 if (buf[i].kind == ascii_keystroke |
10946
aa943e2ea495
(read_input_waiting): Fix Lisp_Object vs. int problem.
Karl Heuer <kwzh@gnu.org>
parents:
10528
diff
changeset
|
2673 && buf[i].code == quit_char) |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2674 break; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2675 } |
491 | 2676 } |
2677 else | |
2678 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2679 char buf[3]; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2680 nread = read (fileno (stdin), buf, 1); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2681 |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2682 /* Scan the chars for C-g and store them in kbd_buffer. */ |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2683 e.kind = ascii_keystroke; |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
2684 e.frame_or_window = selected_frame; |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2685 e.modifiers = 0; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2686 for (i = 0; i < nread; i++) |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2687 { |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2688 /* Convert chars > 0177 to meta events if desired. |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2689 We do this under the same conditions that read_avail_input does. */ |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2690 if (read_socket_hook == 0) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2691 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2692 /* If the user says she has a meta key, then believe her. */ |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2693 if (meta_key == 1 && (buf[i] & 0x80)) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2694 e.modifiers = meta_modifier; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2695 if (meta_key != 2) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2696 buf[i] &= ~0x80; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2697 } |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2698 |
9279
2382e2f3884e
(kbd_input_ast, read_input_waiting): Use new accessor macros instead of
Karl Heuer <kwzh@gnu.org>
parents:
9239
diff
changeset
|
2699 XSETINT (e.code, buf[i]); |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2700 kbd_buffer_store_event (&e); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2701 /* Don't look at input that follows a C-g too closely. |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2702 This reduces lossage due to autorepeat on C-g. */ |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2703 if (buf[i] == quit_char) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2704 break; |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2705 } |
491 | 2706 } |
2707 } | |
2708 | |
2709 #endif /* not HAVE_SELECT */ | |
2710 #endif /* not VMS */ | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
2711 #endif /* not MSDOS */ |
491 | 2712 |
2713 #ifdef BSD4_1 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2714 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2715 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2716 int fd; |
491 | 2717 { |
2718 if (noninteractive) | |
2719 return; | |
2720 lmode = LINTRUP | lmode; | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2721 ioctl (fd, TIOCLSET, &lmode); |
491 | 2722 } |
2723 | |
21514 | 2724 void |
491 | 2725 reset_sigio () |
2726 { | |
2727 if (noninteractive) | |
2728 return; | |
2729 lmode = ~LINTRUP & lmode; | |
2730 ioctl (0, TIOCLSET, &lmode); | |
2731 } | |
2732 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2733 void |
491 | 2734 request_sigio () |
2735 { | |
2736 sigrelse (SIGTINT); | |
2737 | |
2738 interrupts_deferred = 0; | |
2739 } | |
2740 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2741 void |
491 | 2742 unrequest_sigio () |
2743 { | |
2744 sighold (SIGTINT); | |
2745 | |
2746 interrupts_deferred = 1; | |
2747 } | |
2748 | |
2749 /* still inside #ifdef BSD4_1 */ | |
2750 #ifdef subprocesses | |
2751 | |
2752 int sigheld; /* Mask of held signals */ | |
2753 | |
21514 | 2754 void |
491 | 2755 sigholdx (signum) |
2756 int signum; | |
2757 { | |
2758 sigheld |= sigbit (signum); | |
2759 sighold (signum); | |
2760 } | |
2761 | |
21514 | 2762 void |
491 | 2763 sigisheld (signum) |
2764 int signum; | |
2765 { | |
2766 sigheld |= sigbit (signum); | |
2767 } | |
2768 | |
21514 | 2769 void |
491 | 2770 sigunhold (signum) |
2771 int signum; | |
2772 { | |
2773 sigheld &= ~sigbit (signum); | |
2774 sigrelse (signum); | |
2775 } | |
2776 | |
21514 | 2777 void |
491 | 2778 sigfree () /* Free all held signals */ |
2779 { | |
2780 int i; | |
2781 for (i = 0; i < NSIG; i++) | |
2782 if (sigheld & sigbit (i)) | |
2783 sigrelse (i); | |
2784 sigheld = 0; | |
2785 } | |
2786 | |
21514 | 2787 int |
491 | 2788 sigbit (i) |
2789 { | |
2790 return 1 << (i - 1); | |
2791 } | |
2792 #endif /* subprocesses */ | |
2793 #endif /* BSD4_1 */ | |
2794 | |
2795 /* POSIX signals support - DJB */ | |
2796 /* Anyone with POSIX signals should have ANSI C declarations */ | |
2797 | |
2798 #ifdef POSIX_SIGNALS | |
2799 | |
20948 | 2800 sigset_t empty_mask, full_mask; |
491 | 2801 |
2802 signal_handler_t | |
2803 sys_signal (int signal_number, signal_handler_t action) | |
2804 { | |
20948 | 2805 struct sigaction new_action, old_action; |
491 | 2806 sigemptyset (&new_action.sa_mask); |
20498
22dd2d861e36
(sys_signal): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
20456
diff
changeset
|
2807 new_action.sa_handler = action; |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2808 #ifdef SA_RESTART |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2809 /* Emacs mostly works better with restartable system services. If this |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2810 * flag exists, we probably want to turn it on here. |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2811 */ |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2812 new_action.sa_flags = SA_RESTART; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2813 #else |
3292
6209d0e98e35
(sys_signal): Use 0, not NULL, to set sa_flags.
Richard M. Stallman <rms@gnu.org>
parents:
3268
diff
changeset
|
2814 new_action.sa_flags = 0; |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2815 #endif |
709 | 2816 sigaction (signal_number, &new_action, &old_action); |
20498
22dd2d861e36
(sys_signal): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
20456
diff
changeset
|
2817 return (old_action.sa_handler); |
491 | 2818 } |
2819 | |
638 | 2820 #ifndef __GNUC__ |
2821 /* If we're compiling with GCC, we don't need this function, since it | |
2822 can be written as a macro. */ | |
2823 sigset_t | |
2824 sys_sigmask (int sig) | |
2825 { | |
2826 sigset_t mask; | |
2827 sigemptyset (&mask); | |
2828 sigaddset (&mask, sig); | |
2829 return mask; | |
2830 } | |
2831 #endif | |
2832 | |
491 | 2833 /* I'd like to have these guys return pointers to the mask storage in here, |
2834 but there'd be trouble if the code was saving multiple masks. I'll be | |
2835 safe and pass the structure. It normally won't be more than 2 bytes | |
2836 anyhow. - DJB */ | |
2837 | |
2838 sigset_t | |
2839 sys_sigblock (sigset_t new_mask) | |
2840 { | |
2841 sigset_t old_mask; | |
2842 sigprocmask (SIG_BLOCK, &new_mask, &old_mask); | |
2843 return (old_mask); | |
2844 } | |
2845 | |
2846 sigset_t | |
2847 sys_sigunblock (sigset_t new_mask) | |
2848 { | |
2849 sigset_t old_mask; | |
2850 sigprocmask (SIG_UNBLOCK, &new_mask, &old_mask); | |
2851 return (old_mask); | |
2852 } | |
2853 | |
2854 sigset_t | |
2855 sys_sigsetmask (sigset_t new_mask) | |
2856 { | |
2857 sigset_t old_mask; | |
2858 sigprocmask (SIG_SETMASK, &new_mask, &old_mask); | |
2859 return (old_mask); | |
2860 } | |
2861 | |
2862 #endif /* POSIX_SIGNALS */ | |
2863 | |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2864 #if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2865 static char *my_sys_siglist[NSIG]; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2866 # ifdef sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2867 # undef sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2868 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2869 # define sys_siglist my_sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2870 #endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2871 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2872 void |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2873 init_signals () |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2874 { |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2875 #ifdef POSIX_SIGNALS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2876 sigemptyset (&empty_mask); |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2877 sigfillset (&full_mask); |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2878 #endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2879 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2880 #if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2881 if (! initialized) |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2882 { |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2883 # ifdef SIGABRT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2884 sys_siglist[SIGABRT] = "Aborted"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2885 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2886 # ifdef SIGAIO |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2887 sys_siglist[SIGAIO] = "LAN I/O interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2888 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2889 # ifdef SIGALRM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2890 sys_siglist[SIGALRM] = "Alarm clock"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2891 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2892 # ifdef SIGBUS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2893 sys_siglist[SIGBUS] = "Bus error"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2894 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2895 # ifdef SIGCLD |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2896 sys_siglist[SIGCLD] = "Child status changed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2897 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2898 # ifdef SIGCHLD |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2899 sys_siglist[SIGCHLD] = "Child status changed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2900 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2901 # ifdef SIGCONT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2902 sys_siglist[SIGCONT] = "Continued"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2903 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2904 # ifdef SIGDANGER |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2905 sys_siglist[SIGDANGER] = "Swap space dangerously low"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2906 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2907 # ifdef SIGDGNOTIFY |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2908 sys_siglist[SIGDGNOTIFY] = "Notification message in queue"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2909 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2910 # ifdef SIGEMT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2911 sys_siglist[SIGEMT] = "Emulation trap"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2912 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2913 # ifdef SIGFPE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2914 sys_siglist[SIGFPE] = "Arithmetic exception"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2915 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2916 # ifdef SIGFREEZE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2917 sys_siglist[SIGFREEZE] = "SIGFREEZE"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2918 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2919 # ifdef SIGGRANT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2920 sys_siglist[SIGGRANT] = "Monitor mode granted"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2921 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2922 # ifdef SIGHUP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2923 sys_siglist[SIGHUP] = "Hangup"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2924 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2925 # ifdef SIGILL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2926 sys_siglist[SIGILL] = "Illegal instruction"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2927 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2928 # ifdef SIGINT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2929 sys_siglist[SIGINT] = "Interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2930 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2931 # ifdef SIGIO |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2932 sys_siglist[SIGIO] = "I/O possible"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2933 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2934 # ifdef SIGIOINT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2935 sys_siglist[SIGIOINT] = "I/O intervention required"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2936 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2937 # ifdef SIGIOT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2938 sys_siglist[SIGIOT] = "IOT trap"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2939 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2940 # ifdef SIGKILL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2941 sys_siglist[SIGKILL] = "Killed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2942 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2943 # ifdef SIGLOST |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2944 sys_siglist[SIGLOST] = "Resource lost"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2945 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2946 # ifdef SIGLWP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2947 sys_siglist[SIGLWP] = "SIGLWP"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2948 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2949 # ifdef SIGMSG |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2950 sys_siglist[SIGMSG] = "Monitor mode data available"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2951 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2952 # ifdef SIGPHONE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2953 sys_siglist[SIGWIND] = "SIGPHONE"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2954 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2955 # ifdef SIGPIPE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2956 sys_siglist[SIGPIPE] = "Broken pipe"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2957 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2958 # ifdef SIGPOLL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2959 sys_siglist[SIGPOLL] = "Pollable event occurred"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2960 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2961 # ifdef SIGPROF |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2962 sys_siglist[SIGPROF] = "Profiling timer expired"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2963 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2964 # ifdef SIGPTY |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2965 sys_siglist[SIGPTY] = "PTY I/O interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2966 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2967 # ifdef SIGPWR |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2968 sys_siglist[SIGPWR] = "Power-fail restart"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2969 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2970 # ifdef SIGQUIT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2971 sys_siglist[SIGQUIT] = "Quit"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2972 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2973 # ifdef SIGRETRACT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2974 sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2975 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2976 # ifdef SIGSAK |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2977 sys_siglist[SIGSAK] = "Secure attention"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2978 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2979 # ifdef SIGSEGV |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2980 sys_siglist[SIGSEGV] = "Segmentation violation"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2981 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2982 # ifdef SIGSOUND |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2983 sys_siglist[SIGSOUND] = "Sound completed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2984 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2985 # ifdef SIGSTOP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2986 sys_siglist[SIGSTOP] = "Stopped (signal)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2987 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2988 # ifdef SIGSTP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2989 sys_siglist[SIGSTP] = "Stopped (user)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2990 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2991 # ifdef SIGSYS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2992 sys_siglist[SIGSYS] = "Bad argument to system call"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2993 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2994 # ifdef SIGTERM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2995 sys_siglist[SIGTERM] = "Terminated"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2996 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2997 # ifdef SIGTHAW |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2998 sys_siglist[SIGTHAW] = "SIGTHAW"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2999 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3000 # ifdef SIGTRAP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3001 sys_siglist[SIGTRAP] = "Trace/breakpoint trap"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3002 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3003 # ifdef SIGTSTP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3004 sys_siglist[SIGTSTP] = "Stopped (user)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3005 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3006 # ifdef SIGTTIN |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3007 sys_siglist[SIGTTIN] = "Stopped (tty input)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3008 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3009 # ifdef SIGTTOU |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3010 sys_siglist[SIGTTOU] = "Stopped (tty output)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3011 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3012 # ifdef SIGURG |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3013 sys_siglist[SIGURG] = "Urgent I/O condition"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3014 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3015 # ifdef SIGUSR1 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3016 sys_siglist[SIGUSR1] = "User defined signal 1"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3017 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3018 # ifdef SIGUSR2 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3019 sys_siglist[SIGUSR2] = "User defined signal 2"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3020 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3021 # ifdef SIGVTALRM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3022 sys_siglist[SIGVTALRM] = "Virtual timer expired"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3023 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3024 # ifdef SIGWAITING |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3025 sys_siglist[SIGWAITING] = "Process's LWPs are blocked"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3026 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3027 # ifdef SIGWINCH |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3028 sys_siglist[SIGWINCH] = "Window size changed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3029 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3030 # ifdef SIGWIND |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3031 sys_siglist[SIGWIND] = "SIGWIND"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3032 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3033 # ifdef SIGXCPU |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3034 sys_siglist[SIGXCPU] = "CPU time limit exceeded"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3035 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3036 # ifdef SIGXFSZ |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3037 sys_siglist[SIGXFSZ] = "File size limit exceeded"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3038 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3039 } |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3040 #endif /* !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED */ |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3041 } |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3042 |
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
3043 #ifndef HAVE_RANDOM |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3044 #ifdef random |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3045 #define HAVE_RANDOM |
8368
0c30bec316c6
(random): Use rand differently, and distinguish BSD/USG.
Richard M. Stallman <rms@gnu.org>
parents:
8358
diff
changeset
|
3046 #endif |
8358
f9d8f778f73b
(random, srandom): Obey HAVE_RAND48 flag.
Richard M. Stallman <rms@gnu.org>
parents:
8330
diff
changeset
|
3047 #endif |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3048 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3049 /* Figure out how many bits the system's random number generator uses. |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3050 `random' and `lrand48' are assumed to return 31 usable bits. |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3051 BSD `rand' returns a 31 bit value but the low order bits are unusable; |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3052 so we'll shift it and treat it like the 15-bit USG `rand'. */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3053 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3054 #ifndef RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3055 # ifdef HAVE_RANDOM |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3056 # define RAND_BITS 31 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3057 # else /* !HAVE_RANDOM */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3058 # ifdef HAVE_LRAND48 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3059 # define RAND_BITS 31 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3060 # define random lrand48 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3061 # else /* !HAVE_LRAND48 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3062 # define RAND_BITS 15 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3063 # if RAND_MAX == 32767 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3064 # define random rand |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3065 # else /* RAND_MAX != 32767 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3066 # if RAND_MAX == 2147483647 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3067 # define random() (rand () >> 16) |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3068 # else /* RAND_MAX != 2147483647 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3069 # ifdef USG |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3070 # define random rand |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3071 # else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3072 # define random() (rand () >> 16) |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
3073 # endif /* !USG */ |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3074 # endif /* RAND_MAX != 2147483647 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3075 # endif /* RAND_MAX != 32767 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3076 # endif /* !HAVE_LRAND48 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3077 # endif /* !HAVE_RANDOM */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3078 #endif /* !RAND_BITS */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3079 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3080 void |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3081 seed_random (arg) |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3082 long arg; |
491 | 3083 { |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3084 #ifdef HAVE_RANDOM |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3085 srandom ((unsigned int)arg); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3086 #else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3087 # ifdef HAVE_LRAND48 |
8702
097fe97274e9
(srandom): Pass arg to srand48; no return value.
Karl Heuer <kwzh@gnu.org>
parents:
8699
diff
changeset
|
3088 srand48 (arg); |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3089 # else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3090 srand ((unsigned int)arg); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3091 # endif |
8358
f9d8f778f73b
(random, srandom): Obey HAVE_RAND48 flag.
Richard M. Stallman <rms@gnu.org>
parents:
8330
diff
changeset
|
3092 #endif |
491 | 3093 } |
3094 | |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3095 /* |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3096 * Build a full Emacs-sized word out of whatever we've got. |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3097 * This suffices even for a 64-bit architecture with a 15-bit rand. |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3098 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3099 long |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3100 get_random () |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3101 { |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3102 long val = random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3103 #if VALBITS > RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3104 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3105 #if VALBITS > 2*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3106 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3107 #if VALBITS > 3*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3108 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3109 #if VALBITS > 4*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3110 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3111 #endif /* need at least 5 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3112 #endif /* need at least 4 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3113 #endif /* need at least 3 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3114 #endif /* need at least 2 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3115 return val & ((1L << VALBITS) - 1); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3116 } |
491 | 3117 |
3118 #ifdef WRONG_NAME_INSQUE | |
3119 | |
3120 insque (q,p) | |
3121 caddr_t q,p; | |
3122 { | |
3123 _insque (q,p); | |
3124 } | |
3125 | |
3126 #endif | |
3127 | |
3128 #ifdef VMS | |
3129 | |
3130 #ifdef getenv | |
3131 /* If any place else asks for the TERM variable, | |
3132 allow it to be overridden with the EMACS_TERM variable | |
3133 before attempting to translate the logical name TERM. As a last | |
3134 resort, ask for VAX C's special idea of the TERM variable. */ | |
3135 #undef getenv | |
3136 char * | |
3137 sys_getenv (name) | |
3138 char *name; | |
3139 { | |
3140 register char *val; | |
3141 static char buf[256]; | |
3142 static struct dsc$descriptor_s equiv | |
3143 = {sizeof (buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf}; | |
3144 static struct dsc$descriptor_s d_name | |
3145 = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; | |
3146 short eqlen; | |
3147 | |
3148 if (!strcmp (name, "TERM")) | |
3149 { | |
3150 val = (char *) getenv ("EMACS_TERM"); | |
3151 if (val) | |
3152 return val; | |
3153 } | |
3154 | |
3155 d_name.dsc$w_length = strlen (name); | |
3156 d_name.dsc$a_pointer = name; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3157 if (LIB$SYS_TRNLOG (&d_name, &eqlen, &equiv) == 1) |
491 | 3158 { |
3159 char *str = (char *) xmalloc (eqlen + 1); | |
3160 bcopy (buf, str, eqlen); | |
3161 str[eqlen] = '\0'; | |
3162 /* This is a storage leak, but a pain to fix. With luck, | |
3163 no one will ever notice. */ | |
3164 return str; | |
3165 } | |
3166 return (char *) getenv (name); | |
3167 } | |
3168 #endif /* getenv */ | |
3169 | |
3170 #ifdef abort | |
3171 /* Since VMS doesn't believe in core dumps, the only way to debug this beast is | |
3172 to force a call on the debugger from within the image. */ | |
3173 #undef abort | |
3174 sys_abort () | |
3175 { | |
3176 reset_sys_modes (); | |
3177 LIB$SIGNAL (SS$_DEBUG); | |
3178 } | |
3179 #endif /* abort */ | |
3180 #endif /* VMS */ | |
3181 | |
3182 #ifdef VMS | |
3183 #ifdef LINK_CRTL_SHARE | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3184 #ifdef SHARABLE_LIB_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3185 /* Variables declared noshare and initialized in sharable libraries |
491 | 3186 cannot be shared. The VMS linker incorrectly forces you to use a private |
3187 version which is uninitialized... If not for this "feature", we | |
3188 could use the C library definition of sys_nerr and sys_errlist. */ | |
3189 int sys_nerr = 35; | |
3190 char *sys_errlist[] = | |
3191 { | |
3192 "error 0", | |
3193 "not owner", | |
3194 "no such file or directory", | |
3195 "no such process", | |
3196 "interrupted system call", | |
3197 "i/o error", | |
3198 "no such device or address", | |
3199 "argument list too long", | |
3200 "exec format error", | |
3201 "bad file number", | |
3202 "no child process", | |
3203 "no more processes", | |
3204 "not enough memory", | |
3205 "permission denied", | |
3206 "bad address", | |
3207 "block device required", | |
3208 "mount devices busy", | |
3209 "file exists", | |
3210 "cross-device link", | |
3211 "no such device", | |
3212 "not a directory", | |
3213 "is a directory", | |
3214 "invalid argument", | |
3215 "file table overflow", | |
3216 "too many open files", | |
3217 "not a typewriter", | |
3218 "text file busy", | |
3219 "file too big", | |
3220 "no space left on device", | |
3221 "illegal seek", | |
3222 "read-only file system", | |
3223 "too many links", | |
3224 "broken pipe", | |
3225 "math argument", | |
3226 "result too large", | |
3227 "I/O stream empty", | |
3228 "vax/vms specific error code nontranslatable error" | |
3229 }; | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3230 #endif /* SHARABLE_LIB_BUG */ |
491 | 3231 #endif /* LINK_CRTL_SHARE */ |
3232 #endif /* VMS */ | |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3233 |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3234 #ifndef HAVE_STRERROR |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3235 #ifndef WINDOWSNT |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3236 char * |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3237 strerror (errnum) |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3238 int errnum; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3239 { |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3240 extern char *sys_errlist[]; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3241 extern int sys_nerr; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3242 |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3243 if (errnum >= 0 && errnum < sys_nerr) |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3244 return sys_errlist[errnum]; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3245 return (char *) "Unknown error"; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3246 } |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3247 #endif /* not WINDOWSNT */ |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3248 #endif /* ! HAVE_STRERROR */ |
491 | 3249 |
3250 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3251 emacs_open (path, oflag, mode) |
491 | 3252 char *path; |
3253 int oflag, mode; | |
3254 { | |
3255 register int rtnval; | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3256 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3257 #ifdef BSD4_1 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3258 if (oflag & O_CREAT) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3259 return creat (path, mode); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3260 #endif |
491 | 3261 |
3262 while ((rtnval = open (path, oflag, mode)) == -1 | |
3263 && (errno == EINTR)); | |
3264 return (rtnval); | |
3265 } | |
3266 | |
21514 | 3267 int |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3268 emacs_close (fd) |
491 | 3269 int fd; |
3270 { | |
12547
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3271 int did_retry = 0; |
491 | 3272 register int rtnval; |
3273 | |
3274 while ((rtnval = close (fd)) == -1 | |
12547
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3275 && (errno == EINTR)) |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3276 did_retry = 1; |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3277 |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3278 /* If close is interrupted SunOS 4.1 may or may not have closed the |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3279 file descriptor. If it did the second close will fail with |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3280 errno = EBADF. That means we have succeeded. */ |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3281 if (rtnval == -1 && did_retry && errno == EBADF) |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3282 return 0; |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3283 |
491 | 3284 return rtnval; |
3285 } | |
3286 | |
3287 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3288 emacs_read (fildes, buf, nbyte) |
491 | 3289 int fildes; |
3290 char *buf; | |
3291 unsigned int nbyte; | |
3292 { | |
3293 register int rtnval; | |
3294 | |
3295 while ((rtnval = read (fildes, buf, nbyte)) == -1 | |
3296 && (errno == EINTR)); | |
3297 return (rtnval); | |
3298 } | |
3299 | |
3300 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3301 emacs_write (fildes, buf, nbyte) |
491 | 3302 int fildes; |
3303 char *buf; | |
3304 unsigned int nbyte; | |
3305 { | |
4772
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3306 register int rtnval, bytes_written; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3307 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3308 bytes_written = 0; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3309 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3310 while (nbyte > 0) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3311 { |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3312 rtnval = write (fildes, buf, nbyte); |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3313 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3314 if (rtnval == -1) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3315 { |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3316 if (errno == EINTR) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3317 continue; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3318 else |
5954
02f406110e4b
(sys_write): If any bytes were written, return how many.
Richard M. Stallman <rms@gnu.org>
parents:
5937
diff
changeset
|
3319 return (bytes_written ? bytes_written : -1); |
4772
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3320 } |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3321 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3322 buf += rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3323 nbyte -= rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3324 bytes_written += rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3325 } |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3326 return (bytes_written); |
491 | 3327 } |
3328 | |
3329 #ifdef USG | |
3330 /* | |
3331 * All of the following are for USG. | |
3332 * | |
3333 * On USG systems the system calls are INTERRUPTIBLE by signals | |
3334 * that the user program has elected to catch. Thus the system call | |
3335 * must be retried in these cases. To handle this without massive | |
3336 * changes in the source code, we remap the standard system call names | |
3337 * to names for our own functions in sysdep.c that do the system call | |
3338 * with retries. Actually, for portability reasons, it is good | |
3339 * programming practice, as this example shows, to limit all actual | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3340 * system calls to a single occurrence in the source. Sure, this |
491 | 3341 * adds an extra level of function call overhead but it is almost |
3342 * always negligible. Fred Fish, Unisoft Systems Inc. | |
3343 */ | |
3344 | |
3345 /* | |
3346 * Warning, this function may not duplicate 4.2 action properly | |
3347 * under error conditions. | |
3348 */ | |
3349 | |
3350 #ifndef MAXPATHLEN | |
3351 /* In 4.1, param.h fails to define this. */ | |
3352 #define MAXPATHLEN 1024 | |
3353 #endif | |
3354 | |
3355 #ifndef HAVE_GETWD | |
3356 | |
3357 char * | |
3358 getwd (pathname) | |
3359 char *pathname; | |
3360 { | |
3361 char *npath, *spath; | |
3362 extern char *getcwd (); | |
3363 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3364 BLOCK_INPUT; /* getcwd uses malloc */ |
491 | 3365 spath = npath = getcwd ((char *) 0, MAXPATHLEN); |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
3366 if (spath == 0) |
37219
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3367 { |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3368 UNBLOCK_INPUT; |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3369 return spath; |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3370 } |
491 | 3371 /* On Altos 3068, getcwd can return @hostname/dir, so discard |
3372 up to first slash. Should be harmless on other systems. */ | |
3373 while (*npath && *npath != '/') | |
3374 npath++; | |
3375 strcpy (pathname, npath); | |
3376 free (spath); /* getcwd uses malloc */ | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3377 UNBLOCK_INPUT; |
491 | 3378 return pathname; |
3379 } | |
3380 | |
3381 #endif /* HAVE_GETWD */ | |
3382 | |
3383 /* | |
3384 * Emulate rename using unlink/link. Note that this is | |
3385 * only partially correct. Also, doesn't enforce restriction | |
3386 * that files be of same type (regular->regular, dir->dir, etc). | |
3387 */ | |
3388 | |
621 | 3389 #ifndef HAVE_RENAME |
3390 | |
491 | 3391 rename (from, to) |
3842
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
3392 const char *from; |
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
3393 const char *to; |
491 | 3394 { |
3395 if (access (from, 0) == 0) | |
3396 { | |
3397 unlink (to); | |
3398 if (link (from, to) == 0) | |
3399 if (unlink (from) == 0) | |
3400 return (0); | |
3401 } | |
3402 return (-1); | |
3403 } | |
3404 | |
621 | 3405 #endif |
3406 | |
491 | 3407 |
3408 #ifdef HPUX | |
3409 #ifndef HAVE_PERROR | |
3410 | |
3411 /* HPUX curses library references perror, but as far as we know | |
3412 it won't be called. Anyway this definition will do for now. */ | |
3413 | |
3414 perror () | |
3415 { | |
3416 } | |
3417 | |
3418 #endif /* not HAVE_PERROR */ | |
3419 #endif /* HPUX */ | |
3420 | |
3421 #ifndef HAVE_DUP2 | |
3422 | |
3423 /* | |
3424 * Emulate BSD dup2. First close newd if it already exists. | |
3425 * Then, attempt to dup oldd. If not successful, call dup2 recursively | |
3426 * until we are, then close the unsuccessful ones. | |
3427 */ | |
3428 | |
3429 dup2 (oldd, newd) | |
3430 int oldd; | |
3431 int newd; | |
3432 { | |
3433 register int fd, ret; | |
3434 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3435 emacs_close (newd); |
491 | 3436 |
3437 #ifdef F_DUPFD | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3438 return fcntl (oldd, F_DUPFD, newd); |
491 | 3439 #else |
3440 fd = dup (old); | |
3441 if (fd == -1) | |
3442 return -1; | |
3443 if (fd == new) | |
3444 return new; | |
3445 ret = dup2 (old,new); | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3446 emacs_close (fd); |
491 | 3447 return ret; |
3448 #endif | |
3449 } | |
3450 | |
3451 #endif /* not HAVE_DUP2 */ | |
3452 | |
3453 /* | |
3454 * Gettimeofday. Simulate as much as possible. Only accurate | |
3455 * to nearest second. Emacs doesn't use tzp so ignore it for now. | |
3456 * Only needed when subprocesses are defined. | |
3457 */ | |
3458 | |
3459 #ifdef subprocesses | |
3460 #ifndef VMS | |
3461 #ifndef HAVE_GETTIMEOFDAY | |
3462 #ifdef HAVE_TIMEVAL | |
3463 | |
3464 /* ARGSUSED */ | |
21514 | 3465 int |
491 | 3466 gettimeofday (tp, tzp) |
3467 struct timeval *tp; | |
3468 struct timezone *tzp; | |
3469 { | |
3470 extern long time (); | |
3471 | |
3472 tp->tv_sec = time ((long *)0); | |
3473 tp->tv_usec = 0; | |
3239
2e4882a32671
(gettimeofday): Don't store in *tzp if tzp is 0.
Richard M. Stallman <rms@gnu.org>
parents:
3157
diff
changeset
|
3474 if (tzp != 0) |
2e4882a32671
(gettimeofday): Don't store in *tzp if tzp is 0.
Richard M. Stallman <rms@gnu.org>
parents:
3157
diff
changeset
|
3475 tzp->tz_minuteswest = -1; |
21514 | 3476 return 0; |
491 | 3477 } |
3478 | |
3479 #endif | |
3480 #endif | |
3481 #endif | |
3482 #endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL && !VMS */ | |
3483 | |
3484 /* | |
3485 * This function will go away as soon as all the stubs fixed. (fnf) | |
3486 */ | |
3487 | |
21514 | 3488 void |
491 | 3489 croak (badfunc) |
3490 char *badfunc; | |
3491 { | |
3492 printf ("%s not yet implemented\r\n", badfunc); | |
3493 reset_sys_modes (); | |
3494 exit (1); | |
3495 } | |
3496 | |
3497 #endif /* USG */ | |
3498 | |
3499 /* Directory routines for systems that don't have them. */ | |
3500 | |
3501 #ifdef SYSV_SYSTEM_DIR | |
3502 | |
3503 #include <dirent.h> | |
3504 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
3505 #if defined (BROKEN_CLOSEDIR) || !defined (HAVE_CLOSEDIR) |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3506 |
491 | 3507 int |
3508 closedir (dirp) | |
3509 register DIR *dirp; /* stream from opendir */ | |
3510 { | |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3511 int rtnval; |
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3512 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3513 rtnval = emacs_close (dirp->dd_fd); |
3760
e0be9df19ee1
* sysdep.c (closedir): Don't free directory buffer if it looks
Jim Blandy <jimb@redhat.com>
parents:
3759
diff
changeset
|
3514 |
3797
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3515 /* Some systems (like Solaris) allocate the buffer and the DIR all |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3516 in one block. Why in the world are we freeing this ourselves |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3517 anyway? */ |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3518 #if ! (defined (sun) && defined (USG5_4)) |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3519 xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */ |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3520 #endif |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3521 xfree ((char *) dirp); |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3522 |
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3523 return rtnval; |
491 | 3524 } |
5189
af88471e6799
(closedir): Test BROKEN_CLOSEDIR, not INTERRUPTIBLE_CLOSE.
Richard M. Stallman <rms@gnu.org>
parents:
5167
diff
changeset
|
3525 #endif /* BROKEN_CLOSEDIR or not HAVE_CLOSEDIR */ |
491 | 3526 #endif /* SYSV_SYSTEM_DIR */ |
3527 | |
3528 #ifdef NONSYSTEM_DIR_LIBRARY | |
3529 | |
3530 DIR * | |
3531 opendir (filename) | |
3532 char *filename; /* name of directory */ | |
3533 { | |
3534 register DIR *dirp; /* -> malloc'ed storage */ | |
3535 register int fd; /* file descriptor for read */ | |
3536 struct stat sbuf; /* result of fstat */ | |
3537 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3538 fd = emacs_open (filename, O_RDONLY, 0); |
491 | 3539 if (fd < 0) |
3540 return 0; | |
3541 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3542 BLOCK_INPUT; |
491 | 3543 if (fstat (fd, &sbuf) < 0 |
3544 || (sbuf.st_mode & S_IFMT) != S_IFDIR | |
30608
4ec0adbeda9d
(opendir, GetTempDirName, run_mac_command): Use xmalloc
Gerd Moellmann <gerd@gnu.org>
parents:
29911
diff
changeset
|
3545 || (dirp = (DIR *) xmalloc (sizeof (DIR))) == 0) |
491 | 3546 { |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3547 emacs_close (fd); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3548 UNBLOCK_INPUT; |
491 | 3549 return 0; /* bad luck today */ |
3550 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3551 UNBLOCK_INPUT; |
491 | 3552 |
3553 dirp->dd_fd = fd; | |
3554 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ | |
3555 | |
3556 return dirp; | |
3557 } | |
3558 | |
3559 void | |
3560 closedir (dirp) | |
3561 register DIR *dirp; /* stream from opendir */ | |
3562 { | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3563 emacs_close (dirp->dd_fd); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3564 xfree ((char *) dirp); |
491 | 3565 } |
3566 | |
3567 | |
3568 #ifndef VMS | |
3569 #define DIRSIZ 14 | |
3570 struct olddir | |
3571 { | |
3572 ino_t od_ino; /* inode */ | |
3573 char od_name[DIRSIZ]; /* filename */ | |
3574 }; | |
3575 #endif /* not VMS */ | |
3576 | |
3577 struct direct dir_static; /* simulated directory contents */ | |
3578 | |
3579 /* ARGUSED */ | |
3580 struct direct * | |
3581 readdir (dirp) | |
3582 register DIR *dirp; /* stream from opendir */ | |
3583 { | |
3584 #ifndef VMS | |
3585 register struct olddir *dp; /* -> directory data */ | |
3586 #else /* VMS */ | |
3587 register struct dir$_name *dp; /* -> directory data */ | |
3588 register struct dir$_version *dv; /* -> version data */ | |
3589 #endif /* VMS */ | |
3590 | |
3591 for (; ;) | |
3592 { | |
3593 if (dirp->dd_loc >= dirp->dd_size) | |
3594 dirp->dd_loc = dirp->dd_size = 0; | |
3595 | |
3596 if (dirp->dd_size == 0 /* refill buffer */ | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3597 && (dirp->dd_size = emacs_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) |
491 | 3598 return 0; |
3599 | |
3600 #ifndef VMS | |
3601 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; | |
3602 dirp->dd_loc += sizeof (struct olddir); | |
3603 | |
3604 if (dp->od_ino != 0) /* not deleted entry */ | |
3605 { | |
3606 dir_static.d_ino = dp->od_ino; | |
3607 strncpy (dir_static.d_name, dp->od_name, DIRSIZ); | |
3608 dir_static.d_name[DIRSIZ] = '\0'; | |
3609 dir_static.d_namlen = strlen (dir_static.d_name); | |
3610 dir_static.d_reclen = sizeof (struct direct) | |
3611 - MAXNAMLEN + 3 | |
3612 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3613 return &dir_static; /* -> simulated structure */ | |
3614 } | |
3615 #else /* VMS */ | |
3616 dp = (struct dir$_name *) dirp->dd_buf; | |
3617 if (dirp->dd_loc == 0) | |
3618 dirp->dd_loc = (dp->dir$b_namecount&1) ? dp->dir$b_namecount + 1 | |
3619 : dp->dir$b_namecount; | |
3620 dv = (struct dir$_version *)&dp->dir$t_name[dirp->dd_loc]; | |
3621 dir_static.d_ino = dv->dir$w_fid_num; | |
3622 dir_static.d_namlen = dp->dir$b_namecount; | |
3623 dir_static.d_reclen = sizeof (struct direct) | |
3624 - MAXNAMLEN + 3 | |
3625 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3626 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
3627 dir_static.d_name[dir_static.d_namlen] = '\0'; | |
3628 dirp->dd_loc = dirp->dd_size; /* only one record at a time */ | |
3629 return &dir_static; | |
3630 #endif /* VMS */ | |
3631 } | |
3632 } | |
3633 | |
3634 #ifdef VMS | |
3635 /* readdirver is just like readdir except it returns all versions of a file | |
3636 as separate entries. */ | |
3637 | |
3638 /* ARGUSED */ | |
3639 struct direct * | |
3640 readdirver (dirp) | |
3641 register DIR *dirp; /* stream from opendir */ | |
3642 { | |
3643 register struct dir$_name *dp; /* -> directory data */ | |
3644 register struct dir$_version *dv; /* -> version data */ | |
3645 | |
3646 if (dirp->dd_loc >= dirp->dd_size - sizeof (struct dir$_name)) | |
3647 dirp->dd_loc = dirp->dd_size = 0; | |
3648 | |
3649 if (dirp->dd_size == 0 /* refill buffer */ | |
3650 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
3651 return 0; | |
3652 | |
3653 dp = (struct dir$_name *) dirp->dd_buf; | |
3654 if (dirp->dd_loc == 0) | |
3655 dirp->dd_loc = (dp->dir$b_namecount & 1) ? dp->dir$b_namecount + 1 | |
3656 : dp->dir$b_namecount; | |
3657 dv = (struct dir$_version *) &dp->dir$t_name[dirp->dd_loc]; | |
3658 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
3659 sprintf (&dir_static.d_name[dp->dir$b_namecount], ";%d", dv->dir$w_version); | |
3660 dir_static.d_namlen = strlen (dir_static.d_name); | |
3661 dir_static.d_ino = dv->dir$w_fid_num; | |
3662 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 | |
3663 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3664 dirp->dd_loc = ((char *) (++dv) - dp->dir$t_name); | |
3665 return &dir_static; | |
3666 } | |
3667 | |
3668 #endif /* VMS */ | |
3669 | |
3670 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3671 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3672 |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3673 int |
9082
2c6875700c9f
(set_file_times): Fix typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
9081
diff
changeset
|
3674 set_file_times (filename, atime, mtime) |
9081
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3675 char *filename; |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3676 EMACS_TIME atime, mtime; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3677 { |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3678 #ifdef HAVE_UTIMES |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3679 struct timeval tv[2]; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3680 tv[0] = atime; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3681 tv[1] = mtime; |
9081
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3682 return utimes (filename, tv); |
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3683 #else /* not HAVE_UTIMES */ |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3684 struct utimbuf utb; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3685 utb.actime = EMACS_SECS (atime); |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3686 utb.modtime = EMACS_SECS (mtime); |
9081
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3687 return utime (filename, &utb); |
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3688 #endif /* not HAVE_UTIMES */ |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3689 } |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3690 |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3691 /* mkdir and rmdir functions, for systems which don't have them. */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3692 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3693 #ifndef HAVE_MKDIR |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3694 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3695 * Written by Robert Rother, Mariah Corporation, August 1985. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3696 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3697 * If you want it, it's yours. All I ask in return is that if you |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3698 * figure out how to do this in a Bourne Shell script you send me |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3699 * a copy. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3700 * sdcsvax!rmr or rmr@uscd |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3701 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3702 * Severely hacked over by John Gilmore to make a 4.2BSD compatible |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3703 * subroutine. 11Mar86; hoptoad!gnu |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3704 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3705 * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir, |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3706 * subroutine didn't return EEXIST. It does now. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3707 */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3708 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3709 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3710 * Make a directory. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3711 */ |
5682
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3712 #ifdef MKDIR_PROTOTYPE |
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3713 MKDIR_PROTOTYPE |
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3714 #else |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3715 int |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3716 mkdir (dpath, dmode) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3717 char *dpath; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3718 int dmode; |
5682
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3719 #endif |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3720 { |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3721 int cpid, status, fd; |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3722 struct stat statbuf; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3723 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3724 if (stat (dpath, &statbuf) == 0) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3725 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3726 errno = EEXIST; /* Stat worked, so it already exists */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3727 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3728 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3729 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3730 /* If stat fails for a reason other than non-existence, return error */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3731 if (errno != ENOENT) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3732 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3733 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3734 synch_process_alive = 1; |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3735 switch (cpid = fork ()) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3736 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3737 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3738 case -1: /* Error in fork */ |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3739 return (-1); /* Errno is set already */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3740 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3741 case 0: /* Child process */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3742 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3743 * Cheap hack to set mode of new directory. Since this |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3744 * child process is going away anyway, we zap its umask. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3745 * FIXME, this won't suffice to set SUID, SGID, etc. on this |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3746 * directory. Does anybody care? |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3747 */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3748 status = umask (0); /* Get current umask */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3749 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3750 fd = emacs_open ("/dev/null", O_RDWR, 0); |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3751 if (fd >= 0) |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3752 { |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3753 dup2 (fd, 0); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3754 dup2 (fd, 1); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3755 dup2 (fd, 2); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3756 } |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3757 execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3758 _exit (-1); /* Can't exec /bin/mkdir */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3759 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3760 default: /* Parent process */ |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3761 wait_for_termination (cpid); |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3762 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3763 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3764 if (synch_process_death != 0 || synch_process_retcode != 0) |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3765 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3766 errno = EIO; /* We don't know why, but */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3767 return -1; /* /bin/mkdir failed */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3768 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3769 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3770 return 0; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3771 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3772 #endif /* not HAVE_MKDIR */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3773 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3774 #ifndef HAVE_RMDIR |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3775 int |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3776 rmdir (dpath) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3777 char *dpath; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3778 { |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3779 int cpid, status, fd; |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3780 struct stat statbuf; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3781 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3782 if (stat (dpath, &statbuf) != 0) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3783 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3784 /* Stat just set errno. We don't have to */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3785 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3786 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3787 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3788 synch_process_alive = 1; |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3789 switch (cpid = fork ()) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3790 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3791 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3792 case -1: /* Error in fork */ |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3793 return (-1); /* Errno is set already */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3794 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3795 case 0: /* Child process */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3796 fd = emacs_open ("/dev/null", O_RDWR, 0); |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3797 if (fd >= 0) |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3798 { |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3799 dup2 (fd, 0); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3800 dup2 (fd, 1); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3801 dup2 (fd, 2); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3802 } |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3803 execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); |
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3804 _exit (-1); /* Can't exec /bin/rmdir */ |
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3805 |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3806 default: /* Parent process */ |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3807 wait_for_termination (cpid); |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3808 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3809 |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3810 if (synch_process_death != 0 || synch_process_retcode != 0) |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3811 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3812 errno = EIO; /* We don't know why, but */ |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3813 return -1; /* /bin/rmdir failed */ |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3814 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3815 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3816 return 0; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3817 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3818 #endif /* !HAVE_RMDIR */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3819 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3820 |
491 | 3821 |
3822 /* Functions for VMS */ | |
3823 #ifdef VMS | |
579 | 3824 #include "vms-pwd.h" |
491 | 3825 #include <acldef.h> |
3826 #include <chpdef.h> | |
3827 #include <jpidef.h> | |
3828 | |
3829 /* Return as a string the VMS error string pertaining to STATUS. | |
3830 Reuses the same static buffer each time it is called. */ | |
3831 | |
3832 char * | |
3833 vmserrstr (status) | |
3834 int status; /* VMS status code */ | |
3835 { | |
3836 int bufadr[2]; | |
3837 short len; | |
3838 static char buf[257]; | |
3839 | |
3840 bufadr[0] = sizeof buf - 1; | |
3841 bufadr[1] = (int) buf; | |
3842 if (! (SYS$GETMSG (status, &len, bufadr, 0x1, 0) & 1)) | |
3843 return "untranslatable VMS error status"; | |
3844 buf[len] = '\0'; | |
3845 return buf; | |
3846 } | |
3847 | |
3848 #ifdef access | |
3849 #undef access | |
3850 | |
3851 /* The following is necessary because 'access' emulation by VMS C (2.0) does | |
3852 * not work correctly. (It also doesn't work well in version 2.3.) | |
3853 */ | |
3854 | |
3855 #ifdef VMS4_4 | |
3856 | |
3857 #define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \ | |
3858 { strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string } | |
3859 | |
3860 typedef union { | |
3861 struct { | |
3862 unsigned short s_buflen; | |
3863 unsigned short s_code; | |
3864 char *s_bufadr; | |
3865 unsigned short *s_retlenadr; | |
3866 } s; | |
3867 int end; | |
3868 } item; | |
3869 #define buflen s.s_buflen | |
3870 #define code s.s_code | |
3871 #define bufadr s.s_bufadr | |
3872 #define retlenadr s.s_retlenadr | |
3873 | |
3874 #define R_OK 4 /* test for read permission */ | |
3875 #define W_OK 2 /* test for write permission */ | |
3876 #define X_OK 1 /* test for execute (search) permission */ | |
3877 #define F_OK 0 /* test for presence of file */ | |
3878 | |
3879 int | |
3880 sys_access (path, mode) | |
3881 char *path; | |
3882 int mode; | |
3883 { | |
3884 static char *user = NULL; | |
3885 char dir_fn[512]; | |
3886 | |
3887 /* translate possible directory spec into .DIR file name, so brain-dead | |
3888 * access can treat the directory like a file. */ | |
3889 if (directory_file_name (path, dir_fn)) | |
3890 path = dir_fn; | |
3891 | |
3892 if (mode == F_OK) | |
3893 return access (path, mode); | |
3894 if (user == NULL && (user = (char *) getenv ("USER")) == NULL) | |
3895 return -1; | |
3896 { | |
3897 int stat; | |
3898 int flags; | |
3899 int acces; | |
3900 unsigned short int dummy; | |
3901 item itemlst[3]; | |
3902 static int constant = ACL$C_FILE; | |
3903 DESCRIPTOR (path_desc, path); | |
3904 DESCRIPTOR (user_desc, user); | |
3905 | |
3906 flags = 0; | |
3907 acces = 0; | |
3908 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK)) | |
3909 return stat; | |
3910 if (mode & R_OK) | |
3911 acces |= CHP$M_READ; | |
3912 if (mode & W_OK) | |
3913 acces |= CHP$M_WRITE; | |
3914 itemlst[0].buflen = sizeof (int); | |
3915 itemlst[0].code = CHP$_FLAGS; | |
3916 itemlst[0].bufadr = (char *) &flags; | |
3917 itemlst[0].retlenadr = &dummy; | |
3918 itemlst[1].buflen = sizeof (int); | |
3919 itemlst[1].code = CHP$_ACCESS; | |
3920 itemlst[1].bufadr = (char *) &acces; | |
3921 itemlst[1].retlenadr = &dummy; | |
3922 itemlst[2].end = CHP$_END; | |
3923 stat = SYS$CHECK_ACCESS (&constant, &path_desc, &user_desc, itemlst); | |
3924 return stat == SS$_NORMAL ? 0 : -1; | |
3925 } | |
3926 } | |
3927 | |
3928 #else /* not VMS4_4 */ | |
3929 | |
3930 #include <prvdef.h> | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3931 #define ACE$M_WRITE 2 |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3932 #define ACE$C_KEYID 1 |
491 | 3933 |
3934 static unsigned short memid, grpid; | |
3935 static unsigned int uic; | |
3936 | |
3937 /* Called from init_sys_modes, so it happens not very often | |
3938 but at least each time Emacs is loaded. */ | |
21514 | 3939 void |
491 | 3940 sys_access_reinit () |
3941 { | |
3942 uic = 0; | |
3943 } | |
3944 | |
3945 int | |
3946 sys_access (filename, type) | |
3947 char * filename; | |
3948 int type; | |
3949 { | |
3950 struct FAB fab; | |
3951 struct XABPRO xab; | |
3952 int status, size, i, typecode, acl_controlled; | |
3953 unsigned int *aclptr, *aclend, aclbuf[60]; | |
3954 union prvdef prvmask; | |
3955 | |
3956 /* Get UIC and GRP values for protection checking. */ | |
3957 if (uic == 0) | |
3958 { | |
3959 status = LIB$GETJPI (&JPI$_UIC, 0, 0, &uic, 0, 0); | |
3960 if (! (status & 1)) | |
3961 return -1; | |
3962 memid = uic & 0xFFFF; | |
3963 grpid = uic >> 16; | |
3964 } | |
3965 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3966 if (type != 2) /* not checking write access */ |
491 | 3967 return access (filename, type); |
3968 | |
3969 /* Check write protection. */ | |
3970 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3971 #define CHECKPRIV(bit) (prvmask.bit) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3972 #define WRITABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) |
491 | 3973 |
3974 /* Find privilege bits */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3975 status = SYS$SETPRV (0, 0, 0, prvmask); |
491 | 3976 if (! (status & 1)) |
3977 error ("Unable to find privileges: %s", vmserrstr (status)); | |
3978 if (CHECKPRIV (PRV$V_BYPASS)) | |
3979 return 0; /* BYPASS enabled */ | |
3980 fab = cc$rms_fab; | |
3981 fab.fab$b_fac = FAB$M_GET; | |
3982 fab.fab$l_fna = filename; | |
3983 fab.fab$b_fns = strlen (filename); | |
3984 fab.fab$l_xab = &xab; | |
3985 xab = cc$rms_xabpro; | |
3986 xab.xab$l_aclbuf = aclbuf; | |
3987 xab.xab$w_aclsiz = sizeof (aclbuf); | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3988 status = SYS$OPEN (&fab, 0, 0); |
491 | 3989 if (! (status & 1)) |
3990 return -1; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3991 SYS$CLOSE (&fab, 0, 0); |
491 | 3992 /* Check system access */ |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3993 if (CHECKPRIV (PRV$V_SYSPRV) && WRITABLE (XAB$V_SYS)) |
491 | 3994 return 0; |
3995 /* Check ACL entries, if any */ | |
3996 acl_controlled = 0; | |
3997 if (xab.xab$w_acllen > 0) | |
3998 { | |
3999 aclptr = aclbuf; | |
4000 aclend = &aclbuf[xab.xab$w_acllen / 4]; | |
4001 while (*aclptr && aclptr < aclend) | |
4002 { | |
4003 size = (*aclptr & 0xff) / 4; | |
4004 typecode = (*aclptr >> 8) & 0xff; | |
4005 if (typecode == ACE$C_KEYID) | |
4006 for (i = size - 1; i > 1; i--) | |
4007 if (aclptr[i] == uic) | |
4008 { | |
4009 acl_controlled = 1; | |
4010 if (aclptr[1] & ACE$M_WRITE) | |
4011 return 0; /* Write access through ACL */ | |
4012 } | |
4013 aclptr = &aclptr[size]; | |
4014 } | |
4015 if (acl_controlled) /* ACL specified, prohibits write access */ | |
4016 return -1; | |
4017 } | |
4018 /* No ACL entries specified, check normal protection */ | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4019 if (WRITABLE (XAB$V_WLD)) /* World writable */ |
491 | 4020 return 0; |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4021 if (WRITABLE (XAB$V_GRP) && |
491 | 4022 (unsigned short) (xab.xab$l_uic >> 16) == grpid) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4023 return 0; /* Group writable */ |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4024 if (WRITABLE (XAB$V_OWN) && |
491 | 4025 (xab.xab$l_uic & 0xFFFF) == memid) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4026 return 0; /* Owner writable */ |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4027 |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4028 return -1; /* Not writable */ |
491 | 4029 } |
4030 #endif /* not VMS4_4 */ | |
4031 #endif /* access */ | |
4032 | |
4033 static char vtbuf[NAM$C_MAXRSS+1]; | |
4034 | |
4035 /* translate a vms file spec to a unix path */ | |
4036 char * | |
4037 sys_translate_vms (vfile) | |
4038 char * vfile; | |
4039 { | |
4040 char * p; | |
4041 char * targ; | |
4042 | |
4043 if (!vfile) | |
4044 return 0; | |
4045 | |
4046 targ = vtbuf; | |
4047 | |
4048 /* leading device or logical name is a root directory */ | |
4049 if (p = strchr (vfile, ':')) | |
4050 { | |
4051 *targ++ = '/'; | |
4052 while (vfile < p) | |
4053 *targ++ = *vfile++; | |
4054 vfile++; | |
4055 *targ++ = '/'; | |
4056 } | |
4057 p = vfile; | |
4058 if (*p == '[' || *p == '<') | |
4059 { | |
4060 while (*++vfile != *p + 2) | |
4061 switch (*vfile) | |
4062 { | |
4063 case '.': | |
4064 if (vfile[-1] == *p) | |
4065 *targ++ = '.'; | |
4066 *targ++ = '/'; | |
4067 break; | |
4068 | |
4069 case '-': | |
4070 *targ++ = '.'; | |
4071 *targ++ = '.'; | |
4072 break; | |
4073 | |
4074 default: | |
4075 *targ++ = *vfile; | |
4076 break; | |
4077 } | |
4078 vfile++; | |
4079 *targ++ = '/'; | |
4080 } | |
4081 while (*vfile) | |
4082 *targ++ = *vfile++; | |
4083 | |
4084 return vtbuf; | |
4085 } | |
4086 | |
4087 static char utbuf[NAM$C_MAXRSS+1]; | |
4088 | |
4089 /* translate a unix path to a VMS file spec */ | |
4090 char * | |
4091 sys_translate_unix (ufile) | |
4092 char * ufile; | |
4093 { | |
4094 int slash_seen = 0; | |
4095 char *p; | |
4096 char * targ; | |
4097 | |
4098 if (!ufile) | |
4099 return 0; | |
4100 | |
4101 targ = utbuf; | |
4102 | |
4103 if (*ufile == '/') | |
4104 { | |
4105 ufile++; | |
4106 } | |
4107 | |
4108 while (*ufile) | |
4109 { | |
4110 switch (*ufile) | |
4111 { | |
4112 case '/': | |
4113 if (slash_seen) | |
4114 if (index (&ufile[1], '/')) | |
4115 *targ++ = '.'; | |
4116 else | |
4117 *targ++ = ']'; | |
4118 else | |
4119 { | |
4120 *targ++ = ':'; | |
4121 if (index (&ufile[1], '/')) | |
4122 *targ++ = '['; | |
4123 slash_seen = 1; | |
4124 } | |
4125 break; | |
4126 | |
4127 case '.': | |
4128 if (strncmp (ufile, "./", 2) == 0) | |
4129 { | |
4130 if (!slash_seen) | |
4131 { | |
4132 *targ++ = '['; | |
4133 slash_seen = 1; | |
4134 } | |
4135 ufile++; /* skip the dot */ | |
4136 if (index (&ufile[1], '/')) | |
4137 *targ++ = '.'; | |
4138 else | |
4139 *targ++ = ']'; | |
4140 } | |
4141 else if (strncmp (ufile, "../", 3) == 0) | |
4142 { | |
4143 if (!slash_seen) | |
4144 { | |
4145 *targ++ = '['; | |
4146 slash_seen = 1; | |
4147 } | |
4148 *targ++ = '-'; | |
4149 ufile += 2; /* skip the dots */ | |
4150 if (index (&ufile[1], '/')) | |
4151 *targ++ = '.'; | |
4152 else | |
4153 *targ++ = ']'; | |
4154 } | |
4155 else | |
4156 *targ++ = *ufile; | |
4157 break; | |
4158 | |
4159 default: | |
4160 *targ++ = *ufile; | |
4161 break; | |
4162 } | |
4163 ufile++; | |
4164 } | |
4165 *targ = '\0'; | |
4166 | |
4167 return utbuf; | |
4168 } | |
4169 | |
4170 char * | |
4171 getwd (pathname) | |
4172 char *pathname; | |
4173 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4174 char *ptr, *val; |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4175 extern char *getcwd (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4176 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4177 #define MAXPATHLEN 1024 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4178 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
4179 ptr = xmalloc (MAXPATHLEN); |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4180 val = getcwd (ptr, MAXPATHLEN); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4181 if (val == 0) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4182 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4183 xfree (ptr); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4184 return val; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4185 } |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4186 strcpy (pathname, ptr); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
4187 xfree (ptr); |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4188 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4189 return pathname; |
491 | 4190 } |
4191 | |
21514 | 4192 int |
491 | 4193 getppid () |
4194 { | |
4195 long item_code = JPI$_OWNER; | |
4196 unsigned long parent_id; | |
4197 int status; | |
4198 | |
4199 if (((status = LIB$GETJPI (&item_code, 0, 0, &parent_id)) & 1) == 0) | |
4200 { | |
4201 errno = EVMSERR; | |
4202 vaxc$errno = status; | |
4203 return -1; | |
4204 } | |
4205 return parent_id; | |
4206 } | |
4207 | |
4208 #undef getuid | |
4209 unsigned | |
4210 sys_getuid () | |
4211 { | |
4212 return (getgid () << 16) | getuid (); | |
4213 } | |
4214 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
4215 #undef read |
491 | 4216 int |
4217 sys_read (fildes, buf, nbyte) | |
4218 int fildes; | |
4219 char *buf; | |
4220 unsigned int nbyte; | |
4221 { | |
4222 return read (fildes, buf, (nbyte < MAXIOSIZE ? nbyte : MAXIOSIZE)); | |
4223 } | |
4224 | |
4225 #if 0 | |
4226 int | |
4227 sys_write (fildes, buf, nbyte) | |
4228 int fildes; | |
4229 char *buf; | |
4230 unsigned int nbyte; | |
4231 { | |
4232 register int nwrote, rtnval = 0; | |
4233 | |
4234 while (nbyte > MAXIOSIZE && (nwrote = write (fildes, buf, MAXIOSIZE)) > 0) { | |
4235 nbyte -= nwrote; | |
4236 buf += nwrote; | |
4237 rtnval += nwrote; | |
4238 } | |
4239 if (nwrote < 0) | |
4240 return rtnval ? rtnval : -1; | |
4241 if ((nwrote = write (fildes, buf, nbyte)) < 0) | |
4242 return rtnval ? rtnval : -1; | |
4243 return (rtnval + nwrote); | |
4244 } | |
4245 #endif /* 0 */ | |
4246 | |
4247 /* | |
4248 * VAX/VMS VAX C RTL really loses. It insists that records | |
4249 * end with a newline (carriage return) character, and if they | |
4250 * don't it adds one (nice of it isn't it!) | |
4251 * | |
4252 * Thus we do this stupidity below. | |
4253 */ | |
4254 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
4255 #undef write |
491 | 4256 int |
4257 sys_write (fildes, buf, nbytes) | |
4258 int fildes; | |
4259 char *buf; | |
4260 unsigned int nbytes; | |
4261 { | |
4262 register char *p; | |
4263 register char *e; | |
525 | 4264 int sum = 0; |
4265 struct stat st; | |
4266 | |
4267 fstat (fildes, &st); | |
491 | 4268 p = buf; |
4269 while (nbytes > 0) | |
4270 { | |
525 | 4271 int len, retval; |
4272 | |
4273 /* Handle fixed-length files with carriage control. */ | |
4274 if (st.st_fab_rfm == FAB$C_FIX | |
4275 && ((st.st_fab_rat & (FAB$M_FTN | FAB$M_CR)) != 0)) | |
4276 { | |
4277 len = st.st_fab_mrs; | |
4278 retval = write (fildes, p, min (len, nbytes)); | |
4279 if (retval != len) | |
4280 return -1; | |
4281 retval++; /* This skips the implied carriage control */ | |
4282 } | |
4283 else | |
4284 { | |
4285 e = p + min (MAXIOSIZE, nbytes) - 1; | |
4286 while (*e != '\n' && e > p) e--; | |
4287 if (p == e) /* Ok.. so here we add a newline... sigh. */ | |
4288 e = p + min (MAXIOSIZE, nbytes) - 1; | |
4289 len = e + 1 - p; | |
4290 retval = write (fildes, p, len); | |
4291 if (retval != len) | |
4292 return -1; | |
4293 } | |
4294 p += retval; | |
4295 sum += retval; | |
491 | 4296 nbytes -= retval; |
4297 } | |
4298 return sum; | |
4299 } | |
4300 | |
4301 /* Create file NEW copying its attributes from file OLD. If | |
4302 OLD is 0 or does not exist, create based on the value of | |
4303 vms_stmlf_recfm. */ | |
4304 | |
4305 /* Protection value the file should ultimately have. | |
4306 Set by create_copy_attrs, and use by rename_sansversions. */ | |
4307 static unsigned short int fab_final_pro; | |
4308 | |
4309 int | |
4310 creat_copy_attrs (old, new) | |
4311 char *old, *new; | |
4312 { | |
4313 struct FAB fab = cc$rms_fab; | |
4314 struct XABPRO xabpro; | |
4315 char aclbuf[256]; /* Choice of size is arbitrary. See below. */ | |
4316 extern int vms_stmlf_recfm; | |
4317 | |
4318 if (old) | |
4319 { | |
4320 fab.fab$b_fac = FAB$M_GET; | |
4321 fab.fab$l_fna = old; | |
4322 fab.fab$b_fns = strlen (old); | |
4323 fab.fab$l_xab = (char *) &xabpro; | |
4324 xabpro = cc$rms_xabpro; | |
4325 xabpro.xab$l_aclbuf = aclbuf; | |
4326 xabpro.xab$w_aclsiz = sizeof aclbuf; | |
4327 /* Call $OPEN to fill in the fab & xabpro fields. */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4328 if (SYS$OPEN (&fab, 0, 0) & 1) |
491 | 4329 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4330 SYS$CLOSE (&fab, 0, 0); |
491 | 4331 fab.fab$l_alq = 0; /* zero the allocation quantity */ |
4332 if (xabpro.xab$w_acllen > 0) | |
4333 { | |
4334 if (xabpro.xab$w_acllen > sizeof aclbuf) | |
4335 /* If the acl buffer was too short, redo open with longer one. | |
4336 Wouldn't need to do this if there were some system imposed | |
4337 limit on the size of an ACL, but I can't find any such. */ | |
4338 { | |
4339 xabpro.xab$l_aclbuf = (char *) alloca (xabpro.xab$w_acllen); | |
4340 xabpro.xab$w_aclsiz = xabpro.xab$w_acllen; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4341 if (SYS$OPEN (&fab, 0, 0) & 1) |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4342 SYS$CLOSE (&fab, 0, 0); |
491 | 4343 else |
4344 old = 0; | |
4345 } | |
4346 } | |
4347 else | |
4348 xabpro.xab$l_aclbuf = 0; | |
4349 } | |
4350 else | |
4351 old = 0; | |
4352 } | |
4353 fab.fab$l_fna = new; | |
4354 fab.fab$b_fns = strlen (new); | |
4355 if (!old) | |
4356 { | |
4357 fab.fab$l_xab = 0; | |
4358 fab.fab$b_rfm = vms_stmlf_recfm ? FAB$C_STMLF : FAB$C_VAR; | |
4359 fab.fab$b_rat = FAB$M_CR; | |
4360 } | |
4361 | |
4362 /* Set the file protections such that we will be able to manipulate | |
4363 this file. Once we are done writing and renaming it, we will set | |
4364 the protections back. */ | |
4365 if (old) | |
4366 fab_final_pro = xabpro.xab$w_pro; | |
4367 else | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4368 SYS$SETDFPROT (0, &fab_final_pro); |
491 | 4369 xabpro.xab$w_pro &= 0xff0f; /* set O:rewd for now. This is set back later. */ |
4370 | |
4371 /* Create the new file with either default attrs or attrs copied | |
4372 from old file. */ | |
4373 if (!(SYS$CREATE (&fab, 0, 0) & 1)) | |
4374 return -1; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4375 SYS$CLOSE (&fab, 0, 0); |
491 | 4376 /* As this is a "replacement" for creat, return a file descriptor |
4377 opened for writing. */ | |
4378 return open (new, O_WRONLY); | |
4379 } | |
4380 | |
4381 #ifdef creat | |
4382 #undef creat | |
4383 #include <varargs.h> | |
4384 #ifdef __GNUC__ | |
4385 #ifndef va_count | |
4386 #define va_count(X) ((X) = *(((int *) &(va_alist)) - 1)) | |
4387 #endif | |
4388 #endif | |
4389 | |
21514 | 4390 int |
491 | 4391 sys_creat (va_alist) |
4392 va_dcl | |
4393 { | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4394 va_list list_incrementer; |
491 | 4395 char *name; |
4396 int mode; | |
4397 int rfd; /* related file descriptor */ | |
4398 int fd; /* Our new file descriptor */ | |
4399 int count; | |
4400 struct stat st_buf; | |
4401 char rfm[12]; | |
4402 char rat[15]; | |
4403 char mrs[13]; | |
4404 char fsz[13]; | |
4405 extern int vms_stmlf_recfm; | |
4406 | |
4407 va_count (count); | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4408 va_start (list_incrementer); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4409 name = va_arg (list_incrementer, char *); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4410 mode = va_arg (list_incrementer, int); |
491 | 4411 if (count > 2) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4412 rfd = va_arg (list_incrementer, int); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4413 va_end (list_incrementer); |
491 | 4414 if (count > 2) |
4415 { | |
4416 /* Use information from the related file descriptor to set record | |
4417 format of the newly created file. */ | |
4418 fstat (rfd, &st_buf); | |
4419 switch (st_buf.st_fab_rfm) | |
4420 { | |
4421 case FAB$C_FIX: | |
4422 strcpy (rfm, "rfm = fix"); | |
4423 sprintf (mrs, "mrs = %d", st_buf.st_fab_mrs); | |
4424 strcpy (rat, "rat = "); | |
4425 if (st_buf.st_fab_rat & FAB$M_CR) | |
4426 strcat (rat, "cr"); | |
4427 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4428 strcat (rat, "ftn"); | |
4429 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4430 strcat (rat, "prn"); | |
4431 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4432 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4433 strcat (rat, ", blk"); | |
4434 else | |
4435 strcat (rat, "blk"); | |
4436 return creat (name, 0, rfm, rat, mrs); | |
4437 | |
4438 case FAB$C_VFC: | |
4439 strcpy (rfm, "rfm = vfc"); | |
4440 sprintf (fsz, "fsz = %d", st_buf.st_fab_fsz); | |
4441 strcpy (rat, "rat = "); | |
4442 if (st_buf.st_fab_rat & FAB$M_CR) | |
4443 strcat (rat, "cr"); | |
4444 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4445 strcat (rat, "ftn"); | |
4446 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4447 strcat (rat, "prn"); | |
4448 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4449 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4450 strcat (rat, ", blk"); | |
4451 else | |
4452 strcat (rat, "blk"); | |
4453 return creat (name, 0, rfm, rat, fsz); | |
4454 | |
4455 case FAB$C_STM: | |
4456 strcpy (rfm, "rfm = stm"); | |
4457 break; | |
4458 | |
4459 case FAB$C_STMCR: | |
4460 strcpy (rfm, "rfm = stmcr"); | |
4461 break; | |
4462 | |
4463 case FAB$C_STMLF: | |
4464 strcpy (rfm, "rfm = stmlf"); | |
4465 break; | |
4466 | |
4467 case FAB$C_UDF: | |
4468 strcpy (rfm, "rfm = udf"); | |
4469 break; | |
4470 | |
4471 case FAB$C_VAR: | |
4472 strcpy (rfm, "rfm = var"); | |
4473 break; | |
4474 } | |
4475 strcpy (rat, "rat = "); | |
4476 if (st_buf.st_fab_rat & FAB$M_CR) | |
4477 strcat (rat, "cr"); | |
4478 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4479 strcat (rat, "ftn"); | |
4480 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4481 strcat (rat, "prn"); | |
4482 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4483 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4484 strcat (rat, ", blk"); | |
4485 else | |
4486 strcat (rat, "blk"); | |
4487 } | |
4488 else | |
4489 { | |
4490 strcpy (rfm, vms_stmlf_recfm ? "rfm = stmlf" : "rfm=var"); | |
4491 strcpy (rat, "rat=cr"); | |
4492 } | |
4493 /* Until the VAX C RTL fixes the many bugs with modes, always use | |
4494 mode 0 to get the user's default protection. */ | |
4495 fd = creat (name, 0, rfm, rat); | |
4496 if (fd < 0 && errno == EEXIST) | |
4497 { | |
4498 if (unlink (name) < 0) | |
4499 report_file_error ("delete", build_string (name)); | |
4500 fd = creat (name, 0, rfm, rat); | |
4501 } | |
4502 return fd; | |
4503 } | |
4504 #endif /* creat */ | |
4505 | |
4506 /* fwrite to stdout is S L O W. Speed it up by using fputc...*/ | |
21514 | 4507 int |
491 | 4508 sys_fwrite (ptr, size, num, fp) |
4509 register char * ptr; | |
4510 FILE * fp; | |
4511 { | |
4512 register int tot = num * size; | |
4513 | |
4514 while (tot--) | |
4515 fputc (*ptr++, fp); | |
21514 | 4516 return num; |
491 | 4517 } |
4518 | |
4519 /* | |
4520 * The VMS C library routine creat actually creates a new version of an | |
4521 * existing file rather than truncating the old version. There are times | |
4522 * when this is not the desired behavior, for instance, when writing an | |
4523 * auto save file (you only want one version), or when you don't have | |
4524 * write permission in the directory containing the file (but the file | |
4525 * itself is writable). Hence this routine, which is equivalent to | |
4526 * "close (creat (fn, 0));" on Unix if fn already exists. | |
4527 */ | |
4528 int | |
4529 vms_truncate (fn) | |
4530 char *fn; | |
4531 { | |
4532 struct FAB xfab = cc$rms_fab; | |
4533 struct RAB xrab = cc$rms_rab; | |
4534 int status; | |
4535 | |
4536 xfab.fab$l_fop = FAB$M_TEF; /* free allocated but unused blocks on close */ | |
4537 xfab.fab$b_fac = FAB$M_TRN | FAB$M_GET; /* allow truncate and get access */ | |
4538 xfab.fab$b_shr = FAB$M_NIL; /* allow no sharing - file must be locked */ | |
4539 xfab.fab$l_fna = fn; | |
4540 xfab.fab$b_fns = strlen (fn); | |
4541 xfab.fab$l_dna = ";0"; /* default to latest version of the file */ | |
4542 xfab.fab$b_dns = 2; | |
4543 xrab.rab$l_fab = &xfab; | |
4544 | |
4545 /* This gibberish opens the file, positions to the first record, and | |
4546 deletes all records from there until the end of file. */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4547 if ((SYS$OPEN (&xfab) & 01) == 01) |
491 | 4548 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4549 if ((SYS$CONNECT (&xrab) & 01) == 01 && |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4550 (SYS$FIND (&xrab) & 01) == 01 && |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4551 (SYS$TRUNCATE (&xrab) & 01) == 01) |
491 | 4552 status = 0; |
4553 else | |
4554 status = -1; | |
4555 } | |
4556 else | |
4557 status = -1; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4558 SYS$CLOSE (&xfab); |
491 | 4559 return status; |
4560 } | |
4561 | |
4562 /* Define this symbol to actually read SYSUAF.DAT. This requires either | |
4563 SYSPRV or a readable SYSUAF.DAT. */ | |
4564 | |
4565 #ifdef READ_SYSUAF | |
4566 /* | |
4567 * getuaf.c | |
4568 * | |
4569 * Routine to read the VMS User Authorization File and return | |
4570 * a specific user's record. | |
4571 */ | |
4572 | |
4573 static struct UAF retuaf; | |
4574 | |
4575 struct UAF * | |
4576 get_uaf_name (uname) | |
4577 char * uname; | |
4578 { | |
4579 register status; | |
4580 struct FAB uaf_fab; | |
4581 struct RAB uaf_rab; | |
4582 | |
4583 uaf_fab = cc$rms_fab; | |
4584 uaf_rab = cc$rms_rab; | |
4585 /* initialize fab fields */ | |
4586 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
4587 uaf_fab.fab$b_fns = 21; | |
4588 uaf_fab.fab$b_fac = FAB$M_GET; | |
4589 uaf_fab.fab$b_org = FAB$C_IDX; | |
4590 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
4591 /* initialize rab fields */ | |
4592 uaf_rab.rab$l_fab = &uaf_fab; | |
4593 /* open the User Authorization File */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4594 status = SYS$OPEN (&uaf_fab); |
491 | 4595 if (!(status&1)) |
4596 { | |
4597 errno = EVMSERR; | |
4598 vaxc$errno = status; | |
4599 return 0; | |
4600 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4601 status = SYS$CONNECT (&uaf_rab); |
491 | 4602 if (!(status&1)) |
4603 { | |
4604 errno = EVMSERR; | |
4605 vaxc$errno = status; | |
4606 return 0; | |
4607 } | |
4608 /* read the requested record - index is in uname */ | |
4609 uaf_rab.rab$l_kbf = uname; | |
4610 uaf_rab.rab$b_ksz = strlen (uname); | |
4611 uaf_rab.rab$b_rac = RAB$C_KEY; | |
4612 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
4613 uaf_rab.rab$w_usz = sizeof retuaf; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4614 status = SYS$GET (&uaf_rab); |
491 | 4615 if (!(status&1)) |
4616 { | |
4617 errno = EVMSERR; | |
4618 vaxc$errno = status; | |
4619 return 0; | |
4620 } | |
4621 /* close the User Authorization File */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4622 status = SYS$DISCONNECT (&uaf_rab); |
491 | 4623 if (!(status&1)) |
4624 { | |
4625 errno = EVMSERR; | |
4626 vaxc$errno = status; | |
4627 return 0; | |
4628 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4629 status = SYS$CLOSE (&uaf_fab); |
491 | 4630 if (!(status&1)) |
4631 { | |
4632 errno = EVMSERR; | |
4633 vaxc$errno = status; | |
4634 return 0; | |
4635 } | |
4636 return &retuaf; | |
4637 } | |
4638 | |
4639 struct UAF * | |
4640 get_uaf_uic (uic) | |
4641 unsigned long uic; | |
4642 { | |
4643 register status; | |
4644 struct FAB uaf_fab; | |
4645 struct RAB uaf_rab; | |
4646 | |
4647 uaf_fab = cc$rms_fab; | |
4648 uaf_rab = cc$rms_rab; | |
4649 /* initialize fab fields */ | |
4650 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
4651 uaf_fab.fab$b_fns = 21; | |
4652 uaf_fab.fab$b_fac = FAB$M_GET; | |
4653 uaf_fab.fab$b_org = FAB$C_IDX; | |
4654 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
4655 /* initialize rab fields */ | |
4656 uaf_rab.rab$l_fab = &uaf_fab; | |
4657 /* open the User Authorization File */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4658 status = SYS$OPEN (&uaf_fab); |
491 | 4659 if (!(status&1)) |
4660 { | |
4661 errno = EVMSERR; | |
4662 vaxc$errno = status; | |
4663 return 0; | |
4664 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4665 status = SYS$CONNECT (&uaf_rab); |
491 | 4666 if (!(status&1)) |
4667 { | |
4668 errno = EVMSERR; | |
4669 vaxc$errno = status; | |
4670 return 0; | |
4671 } | |
4672 /* read the requested record - index is in uic */ | |
4673 uaf_rab.rab$b_krf = 1; /* 1st alternate key */ | |
4674 uaf_rab.rab$l_kbf = (char *) &uic; | |
4675 uaf_rab.rab$b_ksz = sizeof uic; | |
4676 uaf_rab.rab$b_rac = RAB$C_KEY; | |
4677 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
4678 uaf_rab.rab$w_usz = sizeof retuaf; | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4679 status = SYS$GET (&uaf_rab); |
491 | 4680 if (!(status&1)) |
4681 { | |
4682 errno = EVMSERR; | |
4683 vaxc$errno = status; | |
4684 return 0; | |
4685 } | |
4686 /* close the User Authorization File */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4687 status = SYS$DISCONNECT (&uaf_rab); |
491 | 4688 if (!(status&1)) |
4689 { | |
4690 errno = EVMSERR; | |
4691 vaxc$errno = status; | |
4692 return 0; | |
4693 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4694 status = SYS$CLOSE (&uaf_fab); |
491 | 4695 if (!(status&1)) |
4696 { | |
4697 errno = EVMSERR; | |
4698 vaxc$errno = status; | |
4699 return 0; | |
4700 } | |
4701 return &retuaf; | |
4702 } | |
4703 | |
4704 static struct passwd retpw; | |
4705 | |
4706 struct passwd * | |
4707 cnv_uaf_pw (up) | |
4708 struct UAF * up; | |
4709 { | |
4710 char * ptr; | |
4711 | |
4712 /* copy these out first because if the username is 32 chars, the next | |
4713 section will overwrite the first byte of the UIC */ | |
4714 retpw.pw_uid = up->uaf$w_mem; | |
4715 retpw.pw_gid = up->uaf$w_grp; | |
4716 | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4717 /* I suppose this is not the best style, to possibly overwrite one |
491 | 4718 byte beyond the end of the field, but what the heck... */ |
4719 ptr = &up->uaf$t_username[UAF$S_USERNAME]; | |
4720 while (ptr[-1] == ' ') | |
4721 ptr--; | |
4722 *ptr = '\0'; | |
4723 strcpy (retpw.pw_name, up->uaf$t_username); | |
4724 | |
4725 /* the rest of these are counted ascii strings */ | |
4726 strncpy (retpw.pw_gecos, &up->uaf$t_owner[1], up->uaf$t_owner[0]); | |
4727 retpw.pw_gecos[up->uaf$t_owner[0]] = '\0'; | |
4728 strncpy (retpw.pw_dir, &up->uaf$t_defdev[1], up->uaf$t_defdev[0]); | |
4729 retpw.pw_dir[up->uaf$t_defdev[0]] = '\0'; | |
4730 strncat (retpw.pw_dir, &up->uaf$t_defdir[1], up->uaf$t_defdir[0]); | |
4731 retpw.pw_dir[up->uaf$t_defdev[0] + up->uaf$t_defdir[0]] = '\0'; | |
4732 strncpy (retpw.pw_shell, &up->uaf$t_defcli[1], up->uaf$t_defcli[0]); | |
4733 retpw.pw_shell[up->uaf$t_defcli[0]] = '\0'; | |
4734 | |
4735 return &retpw; | |
4736 } | |
4737 #else /* not READ_SYSUAF */ | |
4738 static struct passwd retpw; | |
4739 #endif /* not READ_SYSUAF */ | |
4740 | |
4741 struct passwd * | |
4742 getpwnam (name) | |
4743 char * name; | |
4744 { | |
4745 #ifdef READ_SYSUAF | |
4746 struct UAF *up; | |
4747 #else | |
4748 char * user; | |
4749 char * dir; | |
4750 unsigned char * full; | |
4751 #endif /* READ_SYSUAF */ | |
4752 char *ptr = name; | |
4753 | |
4754 while (*ptr) | |
4755 { | |
4756 if ('a' <= *ptr && *ptr <= 'z') | |
4757 *ptr -= 040; | |
4758 ptr++; | |
4759 } | |
4760 #ifdef READ_SYSUAF | |
4761 if (!(up = get_uaf_name (name))) | |
4762 return 0; | |
4763 return cnv_uaf_pw (up); | |
4764 #else | |
4765 if (strcmp (name, getenv ("USER")) == 0) | |
4766 { | |
4767 retpw.pw_uid = getuid (); | |
4768 retpw.pw_gid = getgid (); | |
4769 strcpy (retpw.pw_name, name); | |
4770 if (full = egetenv ("FULLNAME")) | |
4771 strcpy (retpw.pw_gecos, full); | |
4772 else | |
4773 *retpw.pw_gecos = '\0'; | |
4774 strcpy (retpw.pw_dir, egetenv ("HOME")); | |
4775 *retpw.pw_shell = '\0'; | |
4776 return &retpw; | |
4777 } | |
4778 else | |
4779 return 0; | |
4780 #endif /* not READ_SYSUAF */ | |
4781 } | |
4782 | |
4783 struct passwd * | |
4784 getpwuid (uid) | |
4785 unsigned long uid; | |
4786 { | |
4787 #ifdef READ_SYSUAF | |
4788 struct UAF * up; | |
4789 | |
4790 if (!(up = get_uaf_uic (uid))) | |
4791 return 0; | |
4792 return cnv_uaf_pw (up); | |
4793 #else | |
4794 if (uid == sys_getuid ()) | |
4795 return getpwnam (egetenv ("USER")); | |
4796 else | |
4797 return 0; | |
4798 #endif /* not READ_SYSUAF */ | |
4799 } | |
4800 | |
4801 /* return total address space available to the current process. This is | |
4802 the sum of the current p0 size, p1 size and free page table entries | |
4803 available. */ | |
21514 | 4804 int |
491 | 4805 vlimit () |
4806 { | |
4807 int item_code; | |
4808 unsigned long free_pages; | |
4809 unsigned long frep0va; | |
4810 unsigned long frep1va; | |
4811 register status; | |
4812 | |
4813 item_code = JPI$_FREPTECNT; | |
4814 if (((status = LIB$GETJPI (&item_code, 0, 0, &free_pages)) & 1) == 0) | |
4815 { | |
4816 errno = EVMSERR; | |
4817 vaxc$errno = status; | |
4818 return -1; | |
4819 } | |
4820 free_pages *= 512; | |
4821 | |
4822 item_code = JPI$_FREP0VA; | |
4823 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep0va)) & 1) == 0) | |
4824 { | |
4825 errno = EVMSERR; | |
4826 vaxc$errno = status; | |
4827 return -1; | |
4828 } | |
4829 item_code = JPI$_FREP1VA; | |
4830 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep1va)) & 1) == 0) | |
4831 { | |
4832 errno = EVMSERR; | |
4833 vaxc$errno = status; | |
4834 return -1; | |
4835 } | |
4836 | |
4837 return free_pages + frep0va + (0x7fffffff - frep1va); | |
4838 } | |
4839 | |
21514 | 4840 int |
491 | 4841 define_logical_name (varname, string) |
4842 char *varname; | |
4843 char *string; | |
4844 { | |
4845 struct dsc$descriptor_s strdsc = | |
4846 {strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string}; | |
4847 struct dsc$descriptor_s envdsc = | |
4848 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
4849 struct dsc$descriptor_s lnmdsc = | |
4850 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
4851 | |
4852 return LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0); | |
4853 } | |
4854 | |
21514 | 4855 int |
491 | 4856 delete_logical_name (varname) |
4857 char *varname; | |
4858 { | |
4859 struct dsc$descriptor_s envdsc = | |
4860 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
4861 struct dsc$descriptor_s lnmdsc = | |
4862 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
4863 | |
4864 return LIB$DELETE_LOGICAL (&envdsc, &lnmdsc); | |
4865 } | |
4866 | |
21514 | 4867 int |
491 | 4868 ulimit () |
21514 | 4869 { |
4870 return 0; | |
4871 } | |
4872 | |
4873 int | |
491 | 4874 setpgrp () |
21514 | 4875 { |
4876 return 0; | |
4877 } | |
4878 | |
4879 int | |
491 | 4880 execvp () |
4881 { | |
4882 error ("execvp system call not implemented"); | |
21514 | 4883 return -1; |
491 | 4884 } |
4885 | |
4886 int | |
4887 rename (from, to) | |
4888 char *from, *to; | |
4889 { | |
4890 int status; | |
4891 struct FAB from_fab = cc$rms_fab, to_fab = cc$rms_fab; | |
4892 struct NAM from_nam = cc$rms_nam, to_nam = cc$rms_nam; | |
4893 char from_esn[NAM$C_MAXRSS]; | |
4894 char to_esn[NAM$C_MAXRSS]; | |
4895 | |
4896 from_fab.fab$l_fna = from; | |
4897 from_fab.fab$b_fns = strlen (from); | |
4898 from_fab.fab$l_nam = &from_nam; | |
4899 from_fab.fab$l_fop = FAB$M_NAM; | |
4900 | |
4901 from_nam.nam$l_esa = from_esn; | |
4902 from_nam.nam$b_ess = sizeof from_esn; | |
4903 | |
4904 to_fab.fab$l_fna = to; | |
4905 to_fab.fab$b_fns = strlen (to); | |
4906 to_fab.fab$l_nam = &to_nam; | |
4907 to_fab.fab$l_fop = FAB$M_NAM; | |
4908 | |
4909 to_nam.nam$l_esa = to_esn; | |
4910 to_nam.nam$b_ess = sizeof to_esn; | |
4911 | |
4912 status = SYS$RENAME (&from_fab, 0, 0, &to_fab); | |
4913 | |
4914 if (status & 1) | |
4915 return 0; | |
4916 else | |
4917 { | |
4918 if (status == RMS$_DEV) | |
4919 errno = EXDEV; | |
4920 else | |
4921 errno = EVMSERR; | |
4922 vaxc$errno = status; | |
4923 return -1; | |
4924 } | |
4925 } | |
4926 | |
4927 /* This function renames a file like `rename', but it strips | |
4928 the version number from the "to" filename, such that the "to" file is | |
4929 will always be a new version. It also sets the file protection once it is | |
4930 finished. The protection that we will use is stored in fab_final_pro, | |
4931 and was set when we did a creat_copy_attrs to create the file that we | |
4932 are renaming. | |
4933 | |
4934 We could use the chmod function, but Eunichs uses 3 bits per user category | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4935 to describe the protection, and VMS uses 4 (write and delete are separate |
491 | 4936 bits). To maintain portability, the VMS implementation of `chmod' wires |
4937 the W and D bits together. */ | |
4938 | |
4939 | |
4940 static struct fibdef fib; /* We need this initialized to zero */ | |
4941 char vms_file_written[NAM$C_MAXRSS]; | |
4942 | |
4943 int | |
4944 rename_sans_version (from,to) | |
4945 char *from, *to; | |
4946 { | |
4947 short int chan; | |
4948 int stat; | |
4949 short int iosb[4]; | |
4950 int status; | |
4951 struct FAB to_fab = cc$rms_fab; | |
4952 struct NAM to_nam = cc$rms_nam; | |
4953 struct dsc$descriptor fib_d ={sizeof (fib),0,0,(char*) &fib}; | |
4954 struct dsc$descriptor fib_attr[2] | |
4955 = {{sizeof (fab_final_pro),ATR$C_FPRO,0,(char*) &fab_final_pro},{0,0,0,0}}; | |
4956 char to_esn[NAM$C_MAXRSS]; | |
4957 | |
4958 $DESCRIPTOR (disk,to_esn); | |
4959 | |
4960 to_fab.fab$l_fna = to; | |
4961 to_fab.fab$b_fns = strlen (to); | |
4962 to_fab.fab$l_nam = &to_nam; | |
4963 to_fab.fab$l_fop = FAB$M_NAM; | |
4964 | |
4965 to_nam.nam$l_esa = to_esn; | |
4966 to_nam.nam$b_ess = sizeof to_esn; | |
4967 | |
4968 status = SYS$PARSE (&to_fab, 0, 0); /* figure out the full file name */ | |
4969 | |
4970 if (to_nam.nam$l_fnb && NAM$M_EXP_VER) | |
4971 *(to_nam.nam$l_ver) = '\0'; | |
4972 | |
4973 stat = rename (from, to_esn); | |
4974 if (stat < 0) | |
4975 return stat; | |
4976 | |
4977 strcpy (vms_file_written, to_esn); | |
4978 | |
4979 to_fab.fab$l_fna = vms_file_written; /* this points to the versionless name */ | |
4980 to_fab.fab$b_fns = strlen (vms_file_written); | |
4981 | |
4982 /* Now set the file protection to the correct value */ | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4983 SYS$OPEN (&to_fab, 0, 0); /* This fills in the nam$w_fid fields */ |
491 | 4984 |
4985 /* Copy these fields into the fib */ | |
4986 fib.fib$r_fid_overlay.fib$w_fid[0] = to_nam.nam$w_fid[0]; | |
4987 fib.fib$r_fid_overlay.fib$w_fid[1] = to_nam.nam$w_fid[1]; | |
4988 fib.fib$r_fid_overlay.fib$w_fid[2] = to_nam.nam$w_fid[2]; | |
4989 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4990 SYS$CLOSE (&to_fab, 0, 0); |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4991 |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4992 stat = SYS$ASSIGN (&disk, &chan, 0, 0); /* open a channel to the disk */ |
491 | 4993 if (!stat) |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4994 LIB$SIGNAL (stat); |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4995 stat = SYS$QIOW (0, chan, IO$_MODIFY, iosb, 0, 0, &fib_d, |
491 | 4996 0, 0, 0, &fib_attr, 0); |
4997 if (!stat) | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4998 LIB$SIGNAL (stat); |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4999 stat = SYS$DASSGN (chan); |
491 | 5000 if (!stat) |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
5001 LIB$SIGNAL (stat); |
766 | 5002 strcpy (vms_file_written, to_esn); /* We will write this to the terminal*/ |
491 | 5003 return 0; |
5004 } | |
5005 | |
21514 | 5006 int |
491 | 5007 link (file, new) |
5008 char * file, * new; | |
5009 { | |
5010 register status; | |
5011 struct FAB fab; | |
5012 struct NAM nam; | |
5013 unsigned short fid[3]; | |
5014 char esa[NAM$C_MAXRSS]; | |
5015 | |
5016 fab = cc$rms_fab; | |
5017 fab.fab$l_fop = FAB$M_OFP; | |
5018 fab.fab$l_fna = file; | |
5019 fab.fab$b_fns = strlen (file); | |
5020 fab.fab$l_nam = &nam; | |
5021 | |
5022 nam = cc$rms_nam; | |
5023 nam.nam$l_esa = esa; | |
5024 nam.nam$b_ess = NAM$C_MAXRSS; | |
5025 | |
5026 status = SYS$PARSE (&fab); | |
5027 if ((status & 1) == 0) | |
5028 { | |
5029 errno = EVMSERR; | |
5030 vaxc$errno = status; | |
5031 return -1; | |
5032 } | |
5033 status = SYS$SEARCH (&fab); | |
5034 if ((status & 1) == 0) | |
5035 { | |
5036 errno = EVMSERR; | |
5037 vaxc$errno = status; | |
5038 return -1; | |
5039 } | |
5040 | |
5041 fid[0] = nam.nam$w_fid[0]; | |
5042 fid[1] = nam.nam$w_fid[1]; | |
5043 fid[2] = nam.nam$w_fid[2]; | |
5044 | |
5045 fab.fab$l_fna = new; | |
5046 fab.fab$b_fns = strlen (new); | |
5047 | |
5048 status = SYS$PARSE (&fab); | |
5049 if ((status & 1) == 0) | |
5050 { | |
5051 errno = EVMSERR; | |
5052 vaxc$errno = status; | |
5053 return -1; | |
5054 } | |
5055 | |
5056 nam.nam$w_fid[0] = fid[0]; | |
5057 nam.nam$w_fid[1] = fid[1]; | |
5058 nam.nam$w_fid[2] = fid[2]; | |
5059 | |
5060 nam.nam$l_esa = nam.nam$l_name; | |
5061 nam.nam$b_esl = nam.nam$b_name + nam.nam$b_type + nam.nam$b_ver; | |
5062 | |
5063 status = SYS$ENTER (&fab); | |
5064 if ((status & 1) == 0) | |
5065 { | |
5066 errno = EVMSERR; | |
5067 vaxc$errno = status; | |
5068 return -1; | |
5069 } | |
5070 | |
5071 return 0; | |
5072 } | |
5073 | |
21514 | 5074 void |
491 | 5075 croak (badfunc) |
5076 char *badfunc; | |
5077 { | |
5078 printf ("%s not yet implemented\r\n", badfunc); | |
5079 reset_sys_modes (); | |
5080 exit (1); | |
5081 } | |
5082 | |
5083 long | |
5084 random () | |
5085 { | |
5086 /* Arrange to return a range centered on zero. */ | |
5087 return rand () - (1 << 30); | |
5088 } | |
5089 | |
21514 | 5090 void |
491 | 5091 srandom (seed) |
5092 { | |
5093 srand (seed); | |
5094 } | |
5095 #endif /* VMS */ | |
5096 | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
5097 #ifdef AIXHFT |
491 | 5098 |
5099 /* Called from init_sys_modes. */ | |
21514 | 5100 void |
491 | 5101 hft_init () |
5102 { | |
5103 int junk; | |
5104 | |
5105 /* If we're not on an HFT we shouldn't do any of this. We determine | |
5106 if we are on an HFT by trying to get an HFT error code. If this | |
5107 call fails, we're not on an HFT. */ | |
5108 #ifdef IBMR2AIX | |
5109 if (ioctl (0, HFQERROR, &junk) < 0) | |
5110 return; | |
5111 #else /* not IBMR2AIX */ | |
5112 if (ioctl (0, HFQEIO, 0) < 0) | |
5113 return; | |
5114 #endif /* not IBMR2AIX */ | |
5115 | |
5116 /* On AIX the default hft keyboard mapping uses backspace rather than delete | |
5117 as the rubout key's ASCII code. Here this is changed. The bug is that | |
5118 there's no way to determine the old mapping, so in reset_sys_modes | |
5119 we need to assume that the normal map had been present. Of course, this | |
5120 code also doesn't help if on a terminal emulator which doesn't understand | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
5121 HFT VTD's. */ |
491 | 5122 { |
5123 struct hfbuf buf; | |
5124 struct hfkeymap keymap; | |
5125 | |
5126 buf.hf_bufp = (char *)&keymap; | |
5127 buf.hf_buflen = sizeof (keymap); | |
5128 keymap.hf_nkeys = 2; | |
5129 keymap.hfkey[0].hf_kpos = 15; | |
5130 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
5131 #ifdef IBMR2AIX | |
5132 keymap.hfkey[0].hf_keyidh = '<'; | |
5133 #else /* not IBMR2AIX */ | |
5134 keymap.hfkey[0].hf_page = '<'; | |
5135 #endif /* not IBMR2AIX */ | |
5136 keymap.hfkey[0].hf_char = 127; | |
5137 keymap.hfkey[1].hf_kpos = 15; | |
5138 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
5139 #ifdef IBMR2AIX | |
5140 keymap.hfkey[1].hf_keyidh = '<'; | |
5141 #else /* not IBMR2AIX */ | |
5142 keymap.hfkey[1].hf_page = '<'; | |
5143 #endif /* not IBMR2AIX */ | |
5144 keymap.hfkey[1].hf_char = 127; | |
5145 hftctl (0, HFSKBD, &buf); | |
5146 } | |
5147 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly | |
5148 at times. */ | |
5149 line_ins_del_ok = char_ins_del_ok = 0; | |
5150 } | |
5151 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
5152 /* Reset the rubout key to backspace. */ |
491 | 5153 |
21514 | 5154 void |
491 | 5155 hft_reset () |
5156 { | |
5157 struct hfbuf buf; | |
5158 struct hfkeymap keymap; | |
5159 int junk; | |
5160 | |
5161 #ifdef IBMR2AIX | |
5162 if (ioctl (0, HFQERROR, &junk) < 0) | |
5163 return; | |
5164 #else /* not IBMR2AIX */ | |
5165 if (ioctl (0, HFQEIO, 0) < 0) | |
5166 return; | |
5167 #endif /* not IBMR2AIX */ | |
5168 | |
5169 buf.hf_bufp = (char *)&keymap; | |
5170 buf.hf_buflen = sizeof (keymap); | |
5171 keymap.hf_nkeys = 2; | |
5172 keymap.hfkey[0].hf_kpos = 15; | |
5173 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
5174 #ifdef IBMR2AIX | |
5175 keymap.hfkey[0].hf_keyidh = '<'; | |
5176 #else /* not IBMR2AIX */ | |
5177 keymap.hfkey[0].hf_page = '<'; | |
5178 #endif /* not IBMR2AIX */ | |
5179 keymap.hfkey[0].hf_char = 8; | |
5180 keymap.hfkey[1].hf_kpos = 15; | |
5181 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
5182 #ifdef IBMR2AIX | |
5183 keymap.hfkey[1].hf_keyidh = '<'; | |
5184 #else /* not IBMR2AIX */ | |
5185 keymap.hfkey[1].hf_page = '<'; | |
5186 #endif /* not IBMR2AIX */ | |
5187 keymap.hfkey[1].hf_char = 8; | |
5188 hftctl (0, HFSKBD, &buf); | |
5189 } | |
5190 | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
5191 #endif /* AIXHFT */ |
9075
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5192 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5193 #ifdef USE_DL_STUBS |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5194 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5195 /* These are included on Sunos 4.1 when we do not use shared libraries. |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5196 X11 libraries may refer to these functions but (we hope) do not |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5197 actually call them. */ |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5198 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5199 void * |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5200 dlopen () |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5201 { |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5202 return 0; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5203 } |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5204 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5205 void * |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5206 dlsym () |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5207 { |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5208 return 0; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5209 } |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5210 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5211 int |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5212 dlclose () |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5213 { |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5214 return -1; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5215 } |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5216 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5217 #endif /* USE_DL_STUBS */ |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5218 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5219 #ifndef BSTRING |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5220 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5221 #ifndef bzero |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5222 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5223 void |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5224 bzero (b, length) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5225 register char *b; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5226 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5227 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5228 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5229 short zero = 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5230 long max_str = 65535; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5231 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5232 while (length > max_str) { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5233 (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5234 length -= max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5235 b += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5236 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5237 max_str = length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5238 (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5239 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5240 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5241 *b++ = 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5242 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5243 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5244 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5245 #endif /* no bzero */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5246 #endif /* BSTRING */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5247 |
11722
d7089b2620fb
(bcmp, bcopy): Fix backward BSTRING conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
11624
diff
changeset
|
5248 #if (!defined (BSTRING) && !defined (bcopy)) || defined (NEED_BCOPY) |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5249 #undef bcopy |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5250 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5251 /* Saying `void' requires a declaration, above, where bcopy is used |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5252 and that declaration causes pain for systems where bcopy is a macro. */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5253 bcopy (b1, b2, length) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5254 register char *b1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5255 register char *b2; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5256 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5257 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5258 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5259 long max_str = 65535; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5260 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5261 while (length > max_str) { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5262 (void) LIB$MOVC3 (&max_str, b1, b2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5263 length -= max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5264 b1 += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5265 b2 += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5266 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5267 max_str = length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5268 (void) LIB$MOVC3 (&length, b1, b2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5269 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5270 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5271 *b2++ = *b1++; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5272 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5273 } |
21514 | 5274 #endif /* (!defined (BSTRING) && !defined (bcopy)) || defined (NEED_BCOPY) */ |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5275 |
11722
d7089b2620fb
(bcmp, bcopy): Fix backward BSTRING conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
11624
diff
changeset
|
5276 #ifndef BSTRING |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5277 #ifndef bcmp |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5278 int |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5279 bcmp (b1, b2, length) /* This could be a macro! */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5280 register char *b1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5281 register char *b2; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5282 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5283 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5284 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5285 struct dsc$descriptor_s src1 = {length, DSC$K_DTYPE_T, DSC$K_CLASS_S, b1}; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5286 struct dsc$descriptor_s src2 = {length, DSC$K_DTYPE_T, DSC$K_CLASS_S, b2}; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5287 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5288 return STR$COMPARE (&src1, &src2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5289 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5290 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5291 if (*b1++ != *b2++) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5292 return 1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5293 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5294 return 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5295 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5296 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5297 #endif /* no bcmp */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5298 #endif /* not BSTRING */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5299 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5300 #ifndef HAVE_STRSIGNAL |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5301 char * |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5302 strsignal (code) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5303 int code; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5304 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5305 char *signame = 0; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5306 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5307 if (0 <= code && code < NSIG) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5308 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5309 #ifdef VMS |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5310 signame = sys_errlist[code]; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5311 #else |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5312 /* Cast to suppress warning if the table has const char *. */ |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5313 signame = (char *) sys_siglist[code]; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5314 #endif |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5315 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5316 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5317 return signame; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5318 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5319 #endif /* HAVE_STRSIGNAL */ |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
5320 |