Mercurial > emacs
annotate src/sysdep.c @ 39620:93b817947309
(read-file-name-electric-shadow): Autoload cookie removed; they
apparently don't work with faces.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 05 Oct 2001 16:43:54 +0000 |
parents | 54dd36cef0e2 |
children | 5f60884970a8 |
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 |
22 | |
32236 | 23 #include "config.h" |
491 | 24 #include <signal.h> |
25 #include <setjmp.h> | |
29387
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
26 #ifdef HAVE_UNISTD_H |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
27 #include <unistd.h> |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
28 #endif |
491 | 29 #include "lisp.h" |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
30 /* Including stdlib.h isn't necessarily enough to get srandom |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
31 declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */ |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
32 #ifdef HAVE_RANDOM |
35189 | 33 #if 0 /* It turns out that defining _OSF_SOURCE in osf5-0.h gets |
34 random prototyped as returning `int'. It looks to me as | |
35 though the best way to DTRT is to prefer the rand48 functions | |
36 (per libc.info). -- fx */ | |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
37 extern long int random P_ ((void)); |
35189 | 38 #endif |
35077
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
39 #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
|
40 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
|
41 4.1. */ |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
42 extern void srandom P_ ((unsigned int)); |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
43 #endif |
35077
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
44 #endif |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
45 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
46 #include "blockinput.h" |
491 | 47 #undef NULL |
48 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
49 #ifdef macintosh |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
50 /* 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
|
51 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
|
52 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
|
53 #include <stdlib.h> |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
54 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
55 #ifndef subprocesses |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
56 /* 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
|
57 static int delete_exited_processes; |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
58 #endif |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
59 #endif /* macintosh */ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
60 |
491 | 61 #define min(x,y) ((x) > (y) ? (y) : (x)) |
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 |
18808 | 250 #if defined (HAVE_TERMIOS_H) && defined (LINUX) |
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 */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
481 #ifdef POSIX_SIGNALS /* would this work for 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 */ | |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
593 #ifdef IUCLC |
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
594 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
|
595 #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
|
596 #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
|
597 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
|
598 #endif |
5972
ccb0f99750e3
(child_setup_tty): Typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5967
diff
changeset
|
599 #ifdef OLCUC |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
600 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
|
601 #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
|
602 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
|
603 s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */ |
579 | 604 #if 0 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
605 /* Said to be unnecessary: */ |
579 | 606 s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */ |
607 s.main.c_cc[VTIME] = 0; /* wait forever for at least 1 character */ | |
608 #endif | |
609 | |
610 s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */ | |
611 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
|
612 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
|
613 s.main.c_cc[VKILL] = CDISABLE; /* disable kill processing */ |
579 | 614 |
491 | 615 #ifdef HPUX |
579 | 616 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ |
491 | 617 #endif /* HPUX */ |
579 | 618 |
491 | 619 #ifdef AIX |
620 /* AIX enhanced edit loses NULs, so disable it */ | |
621 #ifndef IBMR2AIX | |
579 | 622 s.main.c_line = 0; |
623 s.main.c_iflag &= ~ASCEDIT; | |
491 | 624 #endif |
625 /* Also, PTY overloads NUL and BREAK. | |
626 don't ignore break, but don't signal either, so it looks like NUL. */ | |
579 | 627 s.main.c_iflag &= ~IGNBRK; |
628 s.main.c_iflag &= ~BRKINT; | |
629 /* QUIT and INTR work better as signals, so disable character forms */ | |
630 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
|
631 #ifdef SIGNALS_VIA_CHARACTERS |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
632 /* 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 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
|
638 #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
|
639 /* 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
|
640 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
|
641 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
|
642 s.main.c_lflag &= ~ISIG; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
643 #endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ |
579 | 644 s.main.c_cc[VEOL] = 0377; |
645 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ | |
491 | 646 #endif /* AIX */ |
647 | |
648 #else /* not HAVE_TERMIO */ | |
579 | 649 |
650 s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE | |
651 | CBREAK | TANDEM); | |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
652 s.main.sg_flags |= LPASS8; |
579 | 653 s.main.sg_erase = 0377; |
654 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
|
655 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */ |
579 | 656 |
491 | 657 #endif /* not HAVE_TERMIO */ |
658 | |
579 | 659 EMACS_SET_TTY (out, &s, 0); |
491 | 660 |
661 #ifdef BSD4_1 | |
662 if (interrupt_input) | |
663 reset_sigio (); | |
664 #endif /* BSD4_1 */ | |
665 #ifdef RTU | |
666 { | |
667 int zero = 0; | |
668 ioctl (out, FIOASYNC, &zero); | |
669 } | |
670 #endif /* RTU */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
671 #endif /* not DOS_NT */ |
491 | 672 } |
673 #endif /* not VMS */ | |
674 | |
675 #endif /* subprocesses */ | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
676 |
491 | 677 /* Record a signal code and the handler for it. */ |
678 struct save_signal | |
679 { | |
680 int code; | |
20348 | 681 SIGTYPE (*handler) P_ ((int)); |
491 | 682 }; |
683 | |
20348 | 684 static void save_signal_handlers P_ ((struct save_signal *)); |
685 static void restore_signal_handlers P_ ((struct save_signal *)); | |
686 | |
491 | 687 /* Suspend the Emacs process; give terminal to its superior. */ |
688 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
689 void |
491 | 690 sys_suspend () |
691 { | |
692 #ifdef VMS | |
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
693 /* "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
|
694 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
|
695 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
|
696 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
|
697 char *fpid_string; |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
698 |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
699 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
|
700 if (fpid_string != NULL) |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
701 { |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
706 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
707 } |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
708 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
709 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
710 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
711 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
|
712 |
491 | 713 if (parent_id && parent_id != 0xffffffff) |
714 { | |
715 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); | |
716 int status = LIB$ATTACH (&parent_id) & 1; | |
717 signal (SIGINT, oldsig); | |
718 return status; | |
719 } | |
720 else | |
721 { | |
722 struct { | |
723 int l; | |
724 char *a; | |
725 } d_prompt; | |
726 d_prompt.l = sizeof ("Emacs: "); /* Our special prompt */ | |
727 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
|
728 LIB$SPAWN (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &d_prompt, 0); |
491 | 729 return 1; |
730 } | |
731 return -1; | |
732 #else | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
733 #if defined (SIGTSTP) && !defined (MSDOS) |
491 | 734 |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
735 { |
4958
8d58e388e71b
(sys_suspend): Use EMACS_GETPGRP macro.
Richard M. Stallman <rms@gnu.org>
parents:
4952
diff
changeset
|
736 int pgrp = EMACS_GETPGRP (0); |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
737 EMACS_KILLPG (pgrp, SIGTSTP); |
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
738 } |
491 | 739 |
740 #else /* No SIGTSTP */ | |
741 #ifdef USG_JOBCTRL /* If you don't know what this is don't mess with it */ | |
742 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */ | |
743 kill (getpid (), SIGQUIT); | |
744 | |
745 #else /* No SIGTSTP or USG_JOBCTRL */ | |
746 | |
747 /* On a system where suspending is not implemented, | |
748 instead fork a subshell and let it talk directly to the terminal | |
749 while we wait. */ | |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
750 sys_subshell (); |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
751 |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
752 #endif /* no USG_JOBCTRL */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
753 #endif /* no SIGTSTP */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
754 #endif /* not VMS */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
755 } |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
756 |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
757 /* Fork a subshell. */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
758 |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
759 #ifndef macintosh |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
760 void |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
761 sys_subshell () |
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 #ifndef VMS |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
764 #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
|
765 int st; |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
766 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
|
767 #endif |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
768 int pid; |
491 | 769 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
|
770 Lisp_Object dir; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
771 unsigned char *str = 0; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
772 int len; |
491 | 773 |
774 saved_handlers[0].code = SIGINT; | |
775 saved_handlers[1].code = SIGQUIT; | |
776 saved_handlers[2].code = SIGTERM; | |
777 #ifdef SIGIO | |
778 saved_handlers[3].code = SIGIO; | |
779 saved_handlers[4].code = 0; | |
780 #else | |
781 saved_handlers[3].code = 0; | |
782 #endif | |
783 | |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
784 /* 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
|
785 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
|
786 |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
787 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
|
788 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
|
789 goto xyzzy; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
790 dir = Fsymbol_value (dir); |
9110
c0eefdfd11f4
(sys_subshell): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9082
diff
changeset
|
791 if (!STRINGP (dir)) |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
792 goto xyzzy; |
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 = 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
|
795 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
|
796 len = XSTRING (dir)->size; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
797 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
|
798 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
|
799 str[len] = 0; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
800 xyzzy: |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
801 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
802 #ifdef DOS_NT |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
803 pid = 0; |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
804 #if __DJGPP__ > 1 |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
805 save_signal_handlers (saved_handlers); |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
806 synch_process_alive = 1; |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
807 #endif /* __DJGPP__ > 1 */ |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
808 #else |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
809 pid = vfork (); |
491 | 810 if (pid == -1) |
811 error ("Can't spawn subshell"); | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
812 #endif |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
813 |
491 | 814 if (pid == 0) |
815 { | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
816 char *sh = 0; |
491 | 817 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
818 #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
|
819 getwd (oldwd); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
820 if (sh == 0) |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
821 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
|
822 #endif |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
823 if (sh == 0) |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
824 sh = (char *) egetenv ("SHELL"); |
491 | 825 if (sh == 0) |
826 sh = "sh"; | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
827 |
491 | 828 /* 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
|
829 if (str) |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
830 chdir ((char *) str); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
831 |
491 | 832 #ifdef subprocesses |
833 close_process_descs (); /* Close Emacs's pipes/ptys */ | |
834 #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
|
835 |
7482
8193d122cf6e
(sys_subshell): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7326
diff
changeset
|
836 #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
|
837 { |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
838 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
|
839 |
7482
8193d122cf6e
(sys_subshell): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7326
diff
changeset
|
840 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
|
841 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
|
842 } |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
843 #endif |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
844 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
845 #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
|
846 st = system (sh); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
847 chdir (oldwd); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
848 #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
|
849 if (st) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
850 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
|
851 #endif |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
852 #else /* not MSDOS */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
853 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
854 /* Waits for process completion */ |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
855 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
|
856 chdir (oldwd); |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
857 if (pid == -1) |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
858 write (1, "Can't execute subshell", 22); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
859 #else /* not WINDOWSNT */ |
491 | 860 execlp (sh, sh, 0); |
861 write (1, "Can't execute subshell", 22); | |
862 _exit (1); | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
863 #endif /* not WINDOWSNT */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
864 #endif /* not MSDOS */ |
491 | 865 } |
866 | |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
867 /* 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
|
868 #if !defined (MSDOS) || __DJGPP__ == 1 |
491 | 869 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
|
870 synch_process_alive = 1; |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
871 #endif |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
872 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
873 #ifndef DOS_NT |
491 | 874 wait_for_termination (pid); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
875 #endif |
491 | 876 restore_signal_handlers (saved_handlers); |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
877 synch_process_alive = 0; |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
878 #endif /* !VMS */ |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
879 } |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
880 #endif /* !macintosh */ |
491 | 881 |
20348 | 882 static void |
491 | 883 save_signal_handlers (saved_handlers) |
884 struct save_signal *saved_handlers; | |
885 { | |
886 while (saved_handlers->code) | |
887 { | |
692 | 888 saved_handlers->handler |
20348 | 889 = (SIGTYPE (*) P_ ((int))) signal (saved_handlers->code, SIG_IGN); |
491 | 890 saved_handlers++; |
891 } | |
892 } | |
893 | |
20348 | 894 static void |
491 | 895 restore_signal_handlers (saved_handlers) |
896 struct save_signal *saved_handlers; | |
897 { | |
898 while (saved_handlers->code) | |
899 { | |
900 signal (saved_handlers->code, saved_handlers->handler); | |
901 saved_handlers++; | |
902 } | |
903 } | |
904 | |
905 #ifdef F_SETFL | |
906 | |
907 int old_fcntl_flags; | |
908 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
909 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
910 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
911 int fd; |
491 | 912 { |
913 #ifdef FASYNC | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
914 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
|
915 fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); |
491 | 916 #endif |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
917 interrupts_deferred = 0; |
491 | 918 } |
919 | |
20379
e6db4b8d2834
(reset_sigio): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20367
diff
changeset
|
920 void |
491 | 921 reset_sigio () |
922 { | |
923 unrequest_sigio (); | |
924 } | |
925 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
926 #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ |
491 | 927 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
928 void |
491 | 929 request_sigio () |
930 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
931 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
932 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
933 |
491 | 934 #ifdef SIGWINCH |
638 | 935 sigunblock (sigmask (SIGWINCH)); |
491 | 936 #endif |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
937 fcntl (input_fd, F_SETFL, old_fcntl_flags | FASYNC); |
491 | 938 |
939 interrupts_deferred = 0; | |
940 } | |
941 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
942 void |
491 | 943 unrequest_sigio () |
944 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
945 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
946 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
947 |
491 | 948 #ifdef SIGWINCH |
638 | 949 sigblock (sigmask (SIGWINCH)); |
491 | 950 #endif |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
951 fcntl (input_fd, F_SETFL, old_fcntl_flags); |
491 | 952 interrupts_deferred = 1; |
953 } | |
954 | |
955 #else /* no FASYNC */ | |
956 #ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */ | |
957 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
958 void |
491 | 959 request_sigio () |
960 { | |
961 int on = 1; | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
962 |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
963 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
964 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
965 |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
966 ioctl (input_fd, FIOASYNC, &on); |
491 | 967 interrupts_deferred = 0; |
968 } | |
969 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
970 void |
491 | 971 unrequest_sigio () |
972 { | |
973 int off = 0; | |
974 | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
975 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
976 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
977 |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
978 ioctl (input_fd, FIOASYNC, &off); |
491 | 979 interrupts_deferred = 1; |
980 } | |
981 | |
982 #else /* not FASYNC, not STRIDE */ | |
983 | |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
984 #ifdef _CX_UX |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
985 |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
986 #include <termios.h> |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
987 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
988 void |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
989 request_sigio () |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
990 { |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
991 int on = 1; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
992 sigset_t st; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
993 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
994 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
995 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
996 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
997 sigemptyset (&st); |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
998 sigaddset (&st, SIGIO); |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
999 ioctl (input_fd, FIOASYNC, &on); |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1000 interrupts_deferred = 0; |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1001 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
|
1002 } |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1003 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1004 void |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1005 unrequest_sigio () |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1006 { |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1007 int off = 0; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1008 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1009 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1010 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1011 |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1012 ioctl (input_fd, FIOASYNC, &off); |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1013 interrupts_deferred = 1; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1014 } |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1015 |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1016 #else /* ! _CX_UX */ |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1017 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1018 void |
491 | 1019 request_sigio () |
1020 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1021 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1022 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1023 |
491 | 1024 croak ("request_sigio"); |
1025 } | |
1026 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1027 void |
491 | 1028 unrequest_sigio () |
1029 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1030 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1031 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1032 |
491 | 1033 croak ("unrequest_sigio"); |
1034 } | |
1035 | |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1036 #endif /* _CX_UX */ |
491 | 1037 #endif /* STRIDE */ |
1038 #endif /* FASYNC */ | |
1039 #endif /* F_SETFL */ | |
1040 | |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1041 /* 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
|
1042 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1043 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1044 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1045 /* 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
|
1046 started. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1047 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1048 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
|
1049 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
|
1050 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
|
1051 Everything is fine. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1052 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1053 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
|
1054 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
|
1055 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
|
1056 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
|
1057 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
|
1058 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
|
1059 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
|
1060 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
|
1061 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
|
1062 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
|
1063 int inherited_pgroup; |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1064 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1065 /* 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
|
1066 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
|
1067 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
|
1068 to be in our own process group to receive SIGIO properly. */ |
21514 | 1069 void |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1070 narrow_foreground_group () |
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 int me = getpid (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1073 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1074 setpgrp (0, inherited_pgroup); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1075 if (inherited_pgroup != me) |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1076 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
|
1077 setpgrp (0, me); |
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 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1080 /* Set the tty to our original foreground group. */ |
21514 | 1081 void |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1082 widen_foreground_group () |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1083 { |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1084 if (inherited_pgroup != getpid ()) |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1085 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
|
1086 setpgrp (0, inherited_pgroup); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1087 } |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1088 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1089 #endif /* BSD_PGRPS */ |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1090 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1091 /* 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
|
1092 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1093 /* 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
|
1094 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
|
1095 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
|
1096 int |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1097 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
|
1098 int fd; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1099 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
|
1100 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1101 /* 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
|
1102 #ifdef HAVE_TCATTR |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1103 /* 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
|
1104 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
|
1105 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
|
1106 return -1; |
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 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1109 #ifdef HAVE_TERMIO |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1110 /* 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
|
1111 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
|
1112 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1113 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1114 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1115 #ifdef VMS |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1116 /* Vehemently Monstrous System? :-) */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1117 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
|
1118 &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
|
1119 & 1)) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1120 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1121 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1122 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1123 #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
|
1124 /* 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
|
1125 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
|
1126 return -1; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1127 #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
|
1128 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1129 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1130 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1131 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1132 /* 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
|
1133 #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
|
1134 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
|
1135 return -1; |
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 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1138 /* 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
|
1139 #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
|
1140 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
|
1141 || 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
|
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 /* 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
|
1146 return 0; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1147 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1148 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1149 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1150 /* 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
|
1151 *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
|
1152 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
|
1153 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1154 int |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1155 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
|
1156 int fd; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1157 struct emacs_tty *settings; |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1158 int flushp; |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1159 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1160 /* 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
|
1161 #ifdef HAVE_TCATTR |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1162 int i; |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1163 /* 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
|
1164 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
|
1165 "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
|
1166 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
|
1167 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
|
1168 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
|
1169 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
|
1170 /* 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
|
1171 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
|
1172 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
|
1173 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1174 if (errno == EINTR) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1175 continue; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1176 else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1177 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1178 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1179 else |
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 struct termios new; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1182 |
21843
600f19764b68
(emacs_get_tty): Zero out termios structure before
Andreas Schwab <schwab@suse.de>
parents:
21769
diff
changeset
|
1183 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
|
1184 /* 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
|
1185 tcgetattr (fd, &new); |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1186 /* 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
|
1187 * 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
|
1188 * not be filled in. |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1189 */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1190 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
|
1191 && 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
|
1192 && 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
|
1193 && 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
|
1194 && 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
|
1195 break; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1196 else |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1197 continue; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1198 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1199 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1200 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1201 #ifdef HAVE_TERMIO |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1202 /* The SYSV-style interface? */ |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1203 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
|
1204 return -1; |
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 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1207 #ifdef VMS |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1208 /* Vehemently Monstrous System? :-) */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1209 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
|
1210 &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
|
1211 & 1)) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1212 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1213 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1214 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1215 #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
|
1216 /* 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
|
1217 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
|
1218 return -1; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1219 #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
|
1220 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1221 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1222 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1223 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1224 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1225 /* 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
|
1226 #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
|
1227 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
|
1228 return -1; |
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 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1231 /* 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
|
1232 #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
|
1233 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
|
1234 || 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
|
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 /* 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
|
1239 return 0; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1240 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1241 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1242 |
579 | 1243 /* The initial tty mode bits */ |
1244 struct emacs_tty old_tty; | |
491 | 1245 |
12070 | 1246 /* 1 if we have been through init_sys_modes. */ |
1247 int term_initted; | |
1248 | |
1249 /* 1 if outer tty status has been recorded. */ | |
1250 int old_tty_valid; | |
491 | 1251 |
579 | 1252 #ifdef BSD4_1 |
1253 /* BSD 4.1 needs to keep track of the lmode bits in order to start | |
1254 sigio. */ | |
1255 int lmode; | |
1256 #endif | |
1257 | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1258 #ifndef F_SETOWN_BUG |
491 | 1259 #ifdef F_SETOWN |
1260 int old_fcntl_owner; | |
1261 #endif /* F_SETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1262 #endif /* F_SETOWN_BUG */ |
491 | 1263 |
1264 /* This may also be defined in stdio, | |
1265 but if so, this does no harm, | |
1266 and using the same name avoids wasting the other one's space. */ | |
1267 | |
23631
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1268 #ifdef nec_ews_svr4 |
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1269 extern char *_sobuf ; |
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1270 #else |
491 | 1271 #if defined (USG) || defined (DGUX) |
1272 unsigned char _sobuf[BUFSIZ+8]; | |
1273 #else | |
1274 char _sobuf[BUFSIZ]; | |
1275 #endif | |
23631
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1276 #endif |
491 | 1277 |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1278 #ifdef HAVE_LTCHARS |
491 | 1279 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; |
1280 #endif | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1281 #ifdef HAVE_TCHARS |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1282 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; |
491 | 1283 #endif |
1284 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1285 void |
491 | 1286 init_sys_modes () |
1287 { | |
579 | 1288 struct emacs_tty tty; |
1289 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1290 #ifdef macintosh |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
1291 /* 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
|
1292 #ifndef subprocesses |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1293 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1294 "*Non-nil means delete processes immediately when they exit.\n\ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1295 nil means don't delete them until `list-processes' is run."); |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1296 delete_exited_processes = 0; |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1297 #endif |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1298 #endif /* not macintosh */ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1299 |
491 | 1300 #ifdef VMS |
1301 #if 0 | |
1302 static int oob_chars[2] = {0, 1 << 7}; /* catch C-g's */ | |
1303 extern int (*interrupt_signal) (); | |
1304 #endif | |
1305 #endif | |
1306 | |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1307 Vtty_erase_char = Qnil; |
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1308 |
491 | 1309 if (noninteractive) |
1310 return; | |
1311 | |
1312 #ifdef VMS | |
1313 if (!input_ef) | |
1314 input_ef = get_kbd_event_flag (); | |
1315 /* LIB$GET_EF (&input_ef); */ | |
1316 SYS$CLREF (input_ef); | |
1317 waiting_for_ast = 0; | |
1318 if (!timer_ef) | |
1319 timer_ef = get_timer_event_flag (); | |
1320 /* LIB$GET_EF (&timer_ef); */ | |
1321 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
|
1322 #if 0 |
491 | 1323 if (!process_ef) |
1324 { | |
1325 LIB$GET_EF (&process_ef); | |
1326 SYS$CLREF (process_ef); | |
1327 } | |
1328 if (input_ef / 32 != process_ef / 32) | |
1329 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
|
1330 #endif |
491 | 1331 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
|
1332 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
|
1333 #if 0 |
491 | 1334 input_eflist = ((unsigned) 1 << (input_ef % 32)) | |
1335 ((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
|
1336 #endif |
491 | 1337 timer_eflist = ((unsigned) 1 << (input_ef % 32)) | |
1338 ((unsigned) 1 << (timer_ef % 32)); | |
1339 #ifndef VMS4_4 | |
1340 sys_access_reinit (); | |
1341 #endif | |
1342 #endif /* not VMS */ | |
579 | 1343 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1344 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1345 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
|
1346 narrow_foreground_group (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1347 #endif |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1348 |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
1349 #ifdef HAVE_WINDOW_SYSTEM |
9572 | 1350 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore |
1351 needs the initialization code below. */ | |
491 | 1352 if (!read_socket_hook && EQ (Vwindow_system, Qnil)) |
9572 | 1353 #endif |
491 | 1354 { |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1355 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
|
1356 |
12070 | 1357 old_tty_valid = 1; |
1358 | |
579 | 1359 tty = old_tty; |
491 | 1360 |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
1361 #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
|
1362 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
|
1363 |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1364 #ifdef DGUX |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1365 /* 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
|
1366 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
|
1367 #endif |
579 | 1368 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ |
1369 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
|
1370 #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
|
1371 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
|
1372 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
|
1373 #endif |
491 | 1374 #ifdef ISTRIP |
579 | 1375 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ |
491 | 1376 #endif |
579 | 1377 tty.main.c_lflag &= ~ECHO; /* Disable echo */ |
1378 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
|
1379 #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
|
1380 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
|
1381 #endif |
579 | 1382 tty.main.c_lflag |= ISIG; /* Enable signals */ |
491 | 1383 if (flow_control) |
1384 { | |
579 | 1385 tty.main.c_iflag |= IXON; /* Enable start/stop output control */ |
491 | 1386 #ifdef IXANY |
579 | 1387 tty.main.c_iflag &= ~IXANY; |
491 | 1388 #endif /* IXANY */ |
1389 } | |
1390 else | |
579 | 1391 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ |
1392 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL | |
1393 on output */ | |
1394 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ | |
491 | 1395 #ifdef CS8 |
1396 if (meta_key) | |
1397 { | |
579 | 1398 tty.main.c_cflag |= CS8; /* allow 8th bit on input */ |
1399 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ | |
491 | 1400 } |
1401 #endif | |
579 | 1402 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ |
491 | 1403 /* Set up C-g for both SIGQUIT and SIGINT. |
1404 We don't know which we will get, but we handle both alike | |
1405 so which one it really gives us does not matter. */ | |
579 | 1406 tty.main.c_cc[VQUIT] = quit_char; |
1407 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ | |
1408 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */ | |
491 | 1409 #ifdef VSWTCH |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1410 tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use |
579 | 1411 of C-z */ |
491 | 1412 #endif /* VSWTCH */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1413 |
491 | 1414 #if defined (mips) || defined (HAVE_TCATTR) |
1415 #ifdef VSUSP | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1416 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ |
491 | 1417 #endif /* VSUSP */ |
1418 #ifdef V_DSUSP | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1419 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ |
491 | 1420 #endif /* V_DSUSP */ |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1421 #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
|
1422 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
|
1423 #endif /* VDSUSP */ |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1424 #ifdef VLNEXT |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1425 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
|
1426 #endif /* VLNEXT */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1427 #ifdef VREPRINT |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1428 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
|
1429 #endif /* VREPRINT */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1430 #ifdef VWERASE |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1431 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
|
1432 #endif /* VWERASE */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1433 #ifdef VDISCARD |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1434 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
|
1435 #endif /* VDISCARD */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1436 |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1437 if (flow_control) |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1438 { |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1439 #ifdef VSTART |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1440 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
|
1441 #endif /* VSTART */ |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1442 #ifdef VSTOP |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1443 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
|
1444 #endif /* VSTOP */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1445 } |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1446 else |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1447 { |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1448 #ifdef VSTART |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1449 tty.main.c_cc[VSTART] = CDISABLE; |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1450 #endif /* VSTART */ |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1451 #ifdef VSTOP |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1452 tty.main.c_cc[VSTOP] = CDISABLE; |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1453 #endif /* VSTOP */ |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1454 } |
491 | 1455 #endif /* mips or HAVE_TCATTR */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1456 |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1457 #ifdef SET_LINE_DISCIPLINE |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
1458 /* 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
|
1459 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
|
1460 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
|
1461 #endif |
491 | 1462 #ifdef AIX |
1463 #ifndef IBMR2AIX | |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1464 /* AIX enhanced edit loses NULs, so disable it. */ |
579 | 1465 tty.main.c_line = 0; |
1466 tty.main.c_iflag &= ~ASCEDIT; | |
491 | 1467 #else |
579 | 1468 tty.main.c_cc[VSTRT] = 255; |
1469 tty.main.c_cc[VSTOP] = 255; | |
1470 tty.main.c_cc[VSUSP] = 255; | |
1471 tty.main.c_cc[VDSUSP] = 255; | |
491 | 1472 #endif /* IBMR2AIX */ |
18232
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1473 if (flow_control) |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1474 { |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1475 #ifdef VSTART |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1476 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
|
1477 #endif /* VSTART */ |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1478 #ifdef VSTOP |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1479 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
|
1480 #endif /* VSTOP */ |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1481 } |
491 | 1482 /* Also, PTY overloads NUL and BREAK. |
1483 don't ignore break, but don't signal either, so it looks like NUL. | |
1484 This really serves a purpose only if running in an XTERM window | |
1485 or via TELNET or the like, but does no harm elsewhere. */ | |
579 | 1486 tty.main.c_iflag &= ~IGNBRK; |
1487 tty.main.c_iflag &= ~BRKINT; | |
491 | 1488 #endif |
1489 #else /* if not HAVE_TERMIO */ | |
1490 #ifdef VMS | |
579 | 1491 tty.main.tt_char |= TT$M_NOECHO; |
491 | 1492 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
|
1493 tty.main.tt_char |= TT$M_EIGHTBIT; |
491 | 1494 if (flow_control) |
579 | 1495 tty.main.tt_char |= TT$M_TTSYNC; |
491 | 1496 else |
579 | 1497 tty.main.tt_char &= ~TT$M_TTSYNC; |
1498 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; | |
491 | 1499 #else /* not VMS (BSD, that is) */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1500 #ifndef DOS_NT |
21532
fff5e42d7b2a
(init_sys_modes): Fix mixing of Lisp_Object and int
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
1501 XSETINT (Vtty_erase_char, tty.main.sg_erase); |
579 | 1502 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); |
491 | 1503 if (meta_key) |
579 | 1504 tty.main.sg_flags |= ANYP; |
1505 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
|
1506 #endif /* not DOS_NT */ |
491 | 1507 #endif /* not VMS (BSD, that is) */ |
1508 #endif /* not HAVE_TERMIO */ | |
1509 | |
579 | 1510 /* If going to use CBREAK mode, we must request C-g to interrupt |
1511 and turn off start and stop chars, etc. If not going to use | |
1512 CBREAK mode, do this anyway so as to turn off local flow | |
1513 control for user coming over network on 4.2; in this case, | |
1514 only t_stopc and t_startc really matter. */ | |
1515 #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
|
1516 #ifdef HAVE_TCHARS |
579 | 1517 /* Note: if not using CBREAK mode, it makes no difference how we |
1518 set this */ | |
1519 tty.tchars = new_tchars; | |
1520 tty.tchars.t_intrc = quit_char; | |
1521 if (flow_control) | |
1522 { | |
1523 tty.tchars.t_startc = '\021'; | |
1524 tty.tchars.t_stopc = '\023'; | |
1525 } | |
1526 | |
1527 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
|
1528 #ifdef ultrix |
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1529 /* 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
|
1530 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
|
1531 tty.lmode &= ~LLITOUT; |
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1532 #endif |
579 | 1533 |
1534 #ifdef BSD4_1 | |
1535 lmode = tty.lmode; | |
1536 #endif | |
1537 | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1538 #endif /* HAVE_TCHARS */ |
579 | 1539 #endif /* not HAVE_TERMIO */ |
1540 | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1541 #ifdef HAVE_LTCHARS |
579 | 1542 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
|
1543 #endif /* HAVE_LTCHARS */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1544 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ |
9572 | 1545 if (!term_initted) |
1546 internal_terminal_init (); | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1547 dos_ttraw (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1548 #endif |
579 | 1549 |
1550 EMACS_SET_TTY (input_fd, &tty, 0); | |
491 | 1551 |
1552 /* This code added to insure that, if flow-control is not to be used, | |
766 | 1553 we have an unlocked terminal at the start. */ |
579 | 1554 |
491 | 1555 #ifdef TCXONC |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1556 if (!flow_control) ioctl (input_fd, TCXONC, 1); |
491 | 1557 #endif |
1558 #ifndef APOLLO | |
1559 #ifdef TIOCSTART | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1560 if (!flow_control) ioctl (input_fd, TIOCSTART, 0); |
491 | 1561 #endif |
1562 #endif | |
1563 | |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1564 #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
|
1565 #ifdef TCOON |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1566 if (!flow_control) tcflow (input_fd, TCOON); |
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1567 #endif |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
1568 #endif |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1569 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1570 #ifdef AIXHFT |
491 | 1571 hft_init (); |
1572 #ifdef IBMR2AIX | |
1573 { | |
1574 /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it | |
1575 to be only LF. This is the way that is done. */ | |
1576 struct termio tty; | |
1577 | |
1578 if (ioctl (1, HFTGETID, &tty) != -1) | |
1579 write (1, "\033[20l", 5); | |
1580 } | |
1581 #endif | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1582 #endif /* AIXHFT */ |
491 | 1583 |
1584 #ifdef VMS | |
1585 /* Appears to do nothing when in PASTHRU mode. | |
579 | 1586 SYS$QIOW (0, input_fd, IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, |
491 | 1587 interrupt_signal, oob_chars, 0, 0, 0, 0); |
1588 */ | |
1589 queue_kbd_input (0); | |
1590 #endif /* VMS */ | |
1591 } | |
1592 | |
1593 #ifdef F_SETFL | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1594 #ifndef F_SETOWN_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1595 #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
|
1596 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
|
1597 && ! read_socket_hook && EQ (Vwindow_system, Qnil)) |
491 | 1598 { |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1599 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
|
1600 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
|
1601 init_sigio (input_fd); |
491 | 1602 } |
1603 #endif /* F_GETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1604 #endif /* F_SETOWN_BUG */ |
491 | 1605 #endif /* F_SETFL */ |
1606 | |
1607 #ifdef BSD4_1 | |
1608 if (interrupt_input) | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1609 init_sigio (input_fd); |
491 | 1610 #endif |
1611 | |
1612 #ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ | |
1613 #undef _IOFBF | |
1614 #endif | |
1615 #ifdef _IOFBF | |
1616 /* This symbol is defined on recent USG systems. | |
1617 Someone says without this call USG won't really buffer the file | |
1618 even with a call to setbuf. */ | |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
1619 setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf); |
491 | 1620 #else |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
1621 setbuf (stdout, (char *) _sobuf); |
491 | 1622 #endif |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
1623 #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
|
1624 /* 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
|
1625 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
|
1626 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
|
1627 #ifndef WINDOWSNT |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1628 /* 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
|
1629 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
|
1630 && (! read_socket_hook) |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1631 #endif |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1632 ) |
13174
d9170c4ec837
(init_sys_modes) [!HAVE_X_WINDOWS (MSDOS)]: Always call set_terminal_modes.
Kim F. Storm <storm@cua.dk>
parents:
12988
diff
changeset
|
1633 #endif |
7878
546334ab3974
(init_sys_modes): Don't call set_terminal_modes
Richard M. Stallman <rms@gnu.org>
parents:
7559
diff
changeset
|
1634 set_terminal_modes (); |
546334ab3974
(init_sys_modes): Don't call set_terminal_modes
Richard M. Stallman <rms@gnu.org>
parents:
7559
diff
changeset
|
1635 |
25157
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1636 if (!term_initted |
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1637 && FRAMEP (Vterminal_frame) |
1978f057423d
(init_sys_modes): Call init_frame_faces for termcap
Eli Zaretskii <eliz@gnu.org>
parents:
23631
diff
changeset
|
1638 && 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
|
1639 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
|
1640 |
491 | 1641 if (term_initted && no_redraw_on_reenter) |
1642 { | |
1643 if (display_completed) | |
1644 direct_output_forward_char (0); | |
1645 } | |
1646 else | |
1647 { | |
766 | 1648 frame_garbaged = 1; |
1649 if (FRAMEP (Vterminal_frame)) | |
1650 FRAME_GARBAGED_P (XFRAME (Vterminal_frame)) = 1; | |
491 | 1651 } |
579 | 1652 |
491 | 1653 term_initted = 1; |
1654 } | |
1655 | |
1656 /* Return nonzero if safe to use tabs in output. | |
1657 At the time this is called, init_sys_modes has not been done yet. */ | |
1658 | |
21514 | 1659 int |
491 | 1660 tabs_safe_p () |
1661 { | |
579 | 1662 struct emacs_tty tty; |
1663 | |
1664 EMACS_GET_TTY (input_fd, &tty); | |
1665 return EMACS_TTY_TABS_OK (&tty); | |
491 | 1666 } |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1667 |
491 | 1668 /* Get terminal size from system. |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1669 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
|
1670 We store 0 if there's no valid information. */ |
491 | 1671 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1672 void |
766 | 1673 get_frame_size (widthp, heightp) |
491 | 1674 int *widthp, *heightp; |
1675 { | |
579 | 1676 |
1677 #ifdef TIOCGWINSZ | |
1678 | |
1679 /* BSD-style. */ | |
1680 struct winsize size; | |
1681 | |
1682 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) | |
1683 *widthp = *heightp = 0; | |
1684 else | |
1685 { | |
1686 *widthp = size.ws_col; | |
1687 *heightp = size.ws_row; | |
1688 } | |
1689 | |
1690 #else | |
491 | 1691 #ifdef TIOCGSIZE |
579 | 1692 |
1693 /* SunOS - style. */ | |
1694 struct ttysize size; | |
1695 | |
1696 if (ioctl (input_fd, TIOCGSIZE, &size) == -1) | |
1697 *widthp = *heightp = 0; | |
1698 else | |
1699 { | |
1700 *widthp = size.ts_cols; | |
1701 *heightp = size.ts_lines; | |
1702 } | |
1703 | |
1704 #else | |
491 | 1705 #ifdef VMS |
579 | 1706 |
1707 struct sensemode tty; | |
1708 | |
1709 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, | |
491 | 1710 &tty.class, 12, 0, 0, 0, 0); |
1711 *widthp = tty.scr_wid; | |
1712 *heightp = tty.scr_len; | |
579 | 1713 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1714 #else |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1715 #ifdef MSDOS |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1716 *widthp = ScreenCols (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1717 *heightp = ScreenRows (); |
491 | 1718 #else /* system doesn't know size */ |
1719 *widthp = 0; | |
1720 *heightp = 0; | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1721 #endif |
579 | 1722 |
1723 #endif /* not VMS */ | |
1724 #endif /* not SunOS-style */ | |
1725 #endif /* not BSD-style */ | |
491 | 1726 } |
579 | 1727 |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1728 /* 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
|
1729 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
|
1730 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1731 int |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1732 set_window_size (fd, height, width) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1733 int fd, height, width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1734 { |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1735 #ifdef TIOCSWINSZ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1736 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1737 /* BSD-style. */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1738 struct winsize size; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1739 size.ws_row = height; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1740 size.ws_col = 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 if (ioctl (fd, TIOCSWINSZ, &size) == -1) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1743 return 0; /* error */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1744 else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1745 return 1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1746 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1747 #else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1748 #ifdef TIOCSSIZE |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1749 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1750 /* SunOS - style. */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1751 struct ttysize size; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1752 size.ts_lines = height; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1753 size.ts_cols = width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1754 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1755 if (ioctl (fd, TIOCGSIZE, &size) == -1) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1756 return 0; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1757 else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1758 return 1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1759 #else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1760 return -1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1761 #endif /* not SunOS-style */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1762 #endif /* not BSD-style */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1763 } |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1764 |
491 | 1765 |
579 | 1766 /* Prepare the terminal for exiting Emacs; move the cursor to the |
766 | 1767 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
|
1768 void |
491 | 1769 reset_sys_modes () |
1770 { | |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1771 struct frame *sf; |
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1772 |
491 | 1773 if (noninteractive) |
1774 { | |
1775 fflush (stdout); | |
1776 return; | |
1777 } | |
1778 if (!term_initted) | |
1779 return; | |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
1780 #ifdef HAVE_WINDOW_SYSTEM |
9572 | 1781 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore |
1782 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
|
1783 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
|
1784 #ifndef WINDOWSNT |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1785 /* 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
|
1786 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
|
1787 || read_socket_hook |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1788 #endif |
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
1789 ) |
491 | 1790 return; |
9572 | 1791 #endif |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1792 sf = SELECTED_FRAME (); |
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1793 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
|
1794 clear_end_of_line (FRAME_WIDTH (sf)); |
491 | 1795 /* 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
|
1796 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
|
1797 #if defined (IBMR2AIX) && defined (AIXHFT) |
491 | 1798 { |
1799 /* HFT devices normally use ^J as a LF/CR. We forced it to | |
1800 do the LF only. Now, we need to reset it. */ | |
1801 struct termio tty; | |
1802 | |
1803 if (ioctl (1, HFTGETID, &tty) != -1) | |
1804 write (1, "\033[20h", 5); | |
1805 } | |
1806 #endif | |
1807 | |
1808 reset_terminal_modes (); | |
1809 fflush (stdout); | |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
1810 #ifdef BSD_SYSTEM |
491 | 1811 #ifndef BSD4_1 |
1812 /* Avoid possible loss of output when changing terminal modes. */ | |
1813 fsync (fileno (stdout)); | |
1814 #endif | |
1815 #endif | |
579 | 1816 |
491 | 1817 #ifdef F_SETFL |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1818 #ifndef F_SETOWN_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1819 #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ |
491 | 1820 if (interrupt_input) |
1821 { | |
1822 reset_sigio (); | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1823 fcntl (input_fd, F_SETOWN, old_fcntl_owner); |
491 | 1824 } |
1825 #endif /* F_SETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1826 #endif /* F_SETOWN_BUG */ |
6489
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1827 #ifdef O_NDELAY |
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1828 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
|
1829 #endif |
491 | 1830 #endif /* F_SETFL */ |
1831 #ifdef BSD4_1 | |
1832 if (interrupt_input) | |
1833 reset_sigio (); | |
1834 #endif /* BSD4_1 */ | |
579 | 1835 |
12070 | 1836 if (old_tty_valid) |
1837 while (EMACS_SET_TTY (input_fd, &old_tty, 0) < 0 && errno == EINTR) | |
1838 ; | |
491 | 1839 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1840 #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
|
1841 dos_ttcooked (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1842 #endif |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1843 |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1844 #ifdef SET_LINE_DISCIPLINE |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1845 /* 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
|
1846 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
|
1847 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
|
1848 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
|
1849 #endif |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1850 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1851 #ifdef AIXHFT |
491 | 1852 hft_reset (); |
1853 #endif | |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1854 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1855 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1856 widen_foreground_group (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1857 #endif |
491 | 1858 } |
1859 | |
1860 #ifdef HAVE_PTYS | |
1861 | |
1862 /* Set up the proper status flags for use of a pty. */ | |
1863 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1864 void |
491 | 1865 setup_pty (fd) |
1866 int fd; | |
1867 { | |
1868 /* I'm told that TOICREMOTE does not mean control chars | |
1869 "can't be sent" but rather that they don't have | |
1870 input-editing or signaling effects. | |
1871 That should be good, because we have other ways | |
1872 to do those things in Emacs. | |
1873 However, telnet mode seems not to work on 4.2. | |
1874 So TIOCREMOTE is turned off now. */ | |
1875 | |
1876 /* Under hp-ux, if TIOCREMOTE is turned on, some calls | |
1877 will hang. In particular, the "timeout" feature (which | |
1878 causes a read to return if there is no data available) | |
1879 does this. Also it is known that telnet mode will hang | |
1880 in such a way that Emacs must be stopped (perhaps this | |
1881 is the same problem). | |
1882 | |
1883 If TIOCREMOTE is turned off, then there is a bug in | |
1884 hp-ux which sometimes loses data. Apparently the | |
1885 code which blocks the master process when the internal | |
1886 buffer fills up does not work. Other than this, | |
1887 though, everything else seems to work fine. | |
1888 | |
1889 Since the latter lossage is more benign, we may as well | |
1890 lose that way. -- cph */ | |
1891 #ifdef FIONBIO | |
29033
bad1d68a57e3
(setup_pty): Treat case that UNIX98_PTYS is defined
Gerd Moellmann <gerd@gnu.org>
parents:
27933
diff
changeset
|
1892 #if defined(SYSV_PTYS) || defined(UNIX98_PTYS) |
491 | 1893 { |
1894 int on = 1; | |
1895 ioctl (fd, FIONBIO, &on); | |
1896 } | |
1897 #endif | |
1898 #endif | |
1899 #ifdef IBMRTAIX | |
1900 /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */ | |
1901 /* ignore SIGHUP once we've started a child on a pty. Note that this may */ | |
1902 /* cause EMACS not to die when it should, i.e., when its own controlling */ | |
1903 /* tty goes away. I've complained to the AIX developers, and they may */ | |
1904 /* change this behavior, but I'm not going to hold my breath. */ | |
1905 signal (SIGHUP, SIG_IGN); | |
1906 #endif | |
1907 } | |
1908 #endif /* HAVE_PTYS */ | |
1909 | |
1910 #ifdef VMS | |
1911 | |
1912 /* Assigning an input channel is done at the start of Emacs execution. | |
1913 This is called each time Emacs is resumed, also, but does nothing | |
1914 because input_chain is no longer zero. */ | |
1915 | |
21514 | 1916 void |
491 | 1917 init_vms_input () |
1918 { | |
1919 int status; | |
1920 | |
579 | 1921 if (input_fd == 0) |
491 | 1922 { |
579 | 1923 status = SYS$ASSIGN (&input_dsc, &input_fd, 0, 0); |
491 | 1924 if (! (status & 1)) |
1925 LIB$STOP (status); | |
1926 } | |
1927 } | |
1928 | |
1929 /* Deassigning the input channel is done before exiting. */ | |
1930 | |
21514 | 1931 void |
491 | 1932 stop_vms_input () |
1933 { | |
579 | 1934 return SYS$DASSGN (input_fd); |
491 | 1935 } |
1936 | |
1937 short input_buffer; | |
1938 | |
1939 /* Request reading one character into the keyboard buffer. | |
1940 This is done as soon as the buffer becomes empty. */ | |
1941 | |
21514 | 1942 void |
491 | 1943 queue_kbd_input () |
1944 { | |
1945 int status; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1946 extern kbd_input_ast (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1947 |
491 | 1948 waiting_for_ast = 0; |
1949 stop_input = 0; | |
579 | 1950 status = SYS$QIO (0, input_fd, IO$_READVBLK, |
491 | 1951 &input_iosb, kbd_input_ast, 1, |
1952 &input_buffer, 1, 0, terminator_mask, 0, 0); | |
1953 } | |
1954 | |
1955 int input_count; | |
1956 | |
1957 /* Ast routine that is called when keyboard input comes in | |
1958 in accord with the SYS$QIO above. */ | |
1959 | |
21514 | 1960 void |
491 | 1961 kbd_input_ast () |
1962 { | |
1963 register int c = -1; | |
1964 int old_errno = errno; | |
648 | 1965 extern EMACS_TIME *input_available_clear_time; |
491 | 1966 |
1967 if (waiting_for_ast) | |
1968 SYS$SETEF (input_ef); | |
1969 waiting_for_ast = 0; | |
1970 input_count++; | |
1971 #ifdef ASTDEBUG | |
1972 if (input_count == 25) | |
1973 exit (1); | |
1974 printf ("Ast # %d,", input_count); | |
1975 printf (" iosb = %x, %x, %x, %x", | |
1976 input_iosb.offset, input_iosb.status, input_iosb.termlen, | |
1977 input_iosb.term); | |
1978 #endif | |
1979 if (input_iosb.offset) | |
1980 { | |
1981 c = input_buffer; | |
1982 #ifdef ASTDEBUG | |
1983 printf (", char = 0%o", c); | |
1984 #endif | |
1985 } | |
1986 #ifdef ASTDEBUG | |
1987 printf ("\n"); | |
1988 fflush (stdout); | |
1989 sleep (1); | |
1990 #endif | |
1991 if (! stop_input) | |
1992 queue_kbd_input (); | |
1993 if (c >= 0) | |
1994 { | |
1995 struct input_event e; | |
1996 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
|
1997 XSETINT (e.code, c); |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
1998 e.frame_or_window = selected_frame; |
491 | 1999 kbd_buffer_store_event (&e); |
2000 } | |
648 | 2001 if (input_available_clear_time) |
2002 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | |
491 | 2003 errno = old_errno; |
2004 } | |
2005 | |
2006 /* Wait until there is something in kbd_buffer. */ | |
2007 | |
21514 | 2008 void |
491 | 2009 wait_for_kbd_input () |
2010 { | |
2011 extern int have_process_input, process_exited; | |
2012 | |
2013 /* If already something, avoid doing system calls. */ | |
2014 if (detect_input_pending ()) | |
2015 { | |
2016 return; | |
2017 } | |
2018 /* Clear a flag, and tell ast routine above to set it. */ | |
2019 SYS$CLREF (input_ef); | |
2020 waiting_for_ast = 1; | |
2021 /* Check for timing error: ast happened while we were doing that. */ | |
2022 if (!detect_input_pending ()) | |
2023 { | |
2024 /* No timing error: wait for flag to be set. */ | |
2025 set_waiting_for_input (0); | |
2026 SYS$WFLOR (input_ef, input_eflist); | |
2027 clear_waiting_for_input (0); | |
2028 if (!detect_input_pending ()) | |
2029 /* Check for subprocess input availability */ | |
2030 { | |
2031 int dsp = have_process_input || process_exited; | |
2032 | |
2033 SYS$CLREF (process_ef); | |
2034 if (have_process_input) | |
2035 process_command_input (); | |
2036 if (process_exited) | |
2037 process_exit (); | |
2038 if (dsp) | |
2039 { | |
2040 update_mode_lines++; | |
5253
1846f03ac8f3
[VMS] (wait_for_kbd_input): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5189
diff
changeset
|
2041 prepare_menu_bars (); |
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
35189
diff
changeset
|
2042 redisplay_preserve_echo_area (18); |
491 | 2043 } |
2044 } | |
2045 } | |
2046 waiting_for_ast = 0; | |
2047 } | |
2048 | |
2049 /* Get rid of any pending QIO, when we are about to suspend | |
2050 or when we want to throw away pending input. | |
2051 We wait for a positive sign that the AST routine has run | |
2052 and therefore there is no I/O request queued when we return. | |
2053 SYS$SETAST is used to avoid a timing error. */ | |
2054 | |
21514 | 2055 void |
491 | 2056 end_kbd_input () |
2057 { | |
2058 #ifdef ASTDEBUG | |
2059 printf ("At end_kbd_input.\n"); | |
2060 fflush (stdout); | |
2061 sleep (1); | |
2062 #endif | |
2063 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ | |
2064 { | |
579 | 2065 SYS$CANCEL (input_fd); |
491 | 2066 return; |
2067 } | |
2068 | |
2069 SYS$SETAST (0); | |
2070 /* Clear a flag, and tell ast routine above to set it. */ | |
2071 SYS$CLREF (input_ef); | |
2072 waiting_for_ast = 1; | |
2073 stop_input = 1; | |
579 | 2074 SYS$CANCEL (input_fd); |
491 | 2075 SYS$SETAST (1); |
2076 SYS$WAITFR (input_ef); | |
2077 waiting_for_ast = 0; | |
2078 } | |
2079 | |
2080 /* Wait for either input available or time interval expiry. */ | |
2081 | |
21514 | 2082 void |
491 | 2083 input_wait_timeout (timeval) |
2084 int timeval; /* Time to wait, in seconds */ | |
2085 { | |
2086 int time [2]; | |
2087 static int zero = 0; | |
2088 static int large = -10000000; | |
2089 | |
2090 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
2091 | |
2092 /* If already something, avoid doing system calls. */ | |
2093 if (detect_input_pending ()) | |
2094 { | |
2095 return; | |
2096 } | |
2097 /* Clear a flag, and tell ast routine above to set it. */ | |
2098 SYS$CLREF (input_ef); | |
2099 waiting_for_ast = 1; | |
2100 /* Check for timing error: ast happened while we were doing that. */ | |
2101 if (!detect_input_pending ()) | |
2102 { | |
2103 /* No timing error: wait for flag to be set. */ | |
2104 SYS$CANTIM (1, 0); | |
2105 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
2106 SYS$WFLOR (timer_ef, timer_eflist); /* Wait for timer expiry or input */ | |
2107 } | |
2108 waiting_for_ast = 0; | |
2109 } | |
2110 | |
2111 /* The standard `sleep' routine works some other way | |
2112 and it stops working if you have ever quit out of it. | |
2113 This one continues to work. */ | |
2114 | |
2115 sys_sleep (timeval) | |
2116 int timeval; | |
2117 { | |
2118 int time [2]; | |
2119 static int zero = 0; | |
2120 static int large = -10000000; | |
2121 | |
2122 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
2123 | |
2124 SYS$CANTIM (1, 0); | |
2125 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
2126 SYS$WAITFR (timer_ef); /* Wait for timer expiry only */ | |
2127 } | |
2128 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2129 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2130 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2131 int fd; |
491 | 2132 { |
2133 request_sigio (); | |
2134 } | |
2135 | |
2136 reset_sigio () | |
2137 { | |
2138 unrequest_sigio (); | |
2139 } | |
2140 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2141 void |
491 | 2142 request_sigio () |
2143 { | |
2144 croak ("request sigio"); | |
2145 } | |
2146 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2147 void |
491 | 2148 unrequest_sigio () |
2149 { | |
2150 croak ("unrequest sigio"); | |
2151 } | |
2152 | |
2153 #endif /* VMS */ | |
2154 | |
2155 /* Note that VMS compiler won't accept defined (CANNOT_DUMP). */ | |
2156 #ifndef CANNOT_DUMP | |
2157 #define NEED_STARTS | |
2158 #endif | |
2159 | |
2160 #ifndef SYSTEM_MALLOC | |
2161 #ifndef NEED_STARTS | |
2162 #define NEED_STARTS | |
2163 #endif | |
2164 #endif | |
2165 | |
2166 #ifdef NEED_STARTS | |
2167 /* Some systems that cannot dump also cannot implement these. */ | |
2168 | |
2169 /* | |
2170 * Return the address of the start of the text segment prior to | |
2171 * doing an unexec. After unexec the return value is undefined. | |
2172 * See crt0.c for further explanation and _start. | |
2173 * | |
2174 */ | |
2175 | |
27922
db5a4af9fafd
(start_of_text): Don't define this function for NetBSD
Gerd Moellmann <gerd@gnu.org>
parents:
27709
diff
changeset
|
2176 #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
|
2177 #ifndef HAVE_TEXT_START |
491 | 2178 char * |
2179 start_of_text () | |
2180 { | |
2181 #ifdef TEXT_START | |
2182 return ((char *) TEXT_START); | |
2183 #else | |
2184 #ifdef GOULD | |
2185 extern csrt (); | |
2186 return ((char *) csrt); | |
2187 #else /* not GOULD */ | |
2188 extern int _start (); | |
2189 return ((char *) _start); | |
2190 #endif /* GOULD */ | |
2191 #endif /* TEXT_START */ | |
2192 } | |
9039
22e5c594d59d
(start_of_text): Don't test CANNOT_UNEXEC.
Richard M. Stallman <rms@gnu.org>
parents:
9036
diff
changeset
|
2193 #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
|
2194 #endif |
491 | 2195 |
2196 /* | |
2197 * Return the address of the start of the data segment prior to | |
2198 * doing an unexec. After unexec the return value is undefined. | |
2199 * See crt0.c for further information and definition of data_start. | |
2200 * | |
2201 * Apparently, on BSD systems this is etext at startup. On | |
2202 * USG systems (swapping) this is highly mmu dependent and | |
2203 * is also dependent on whether or not the program is running | |
2204 * with shared text. Generally there is a (possibly large) | |
2205 * gap between end of text and start of data with shared text. | |
2206 * | |
2207 * On Uniplus+ systems with shared text, data starts at a | |
2208 * fixed address. Each port (from a given oem) is generally | |
2209 * different, and the specific value of the start of data can | |
2210 * be obtained via the UniPlus+ specific "uvar" system call, | |
2211 * however the method outlined in crt0.c seems to be more portable. | |
2212 * | |
2213 * Probably what will have to happen when a USG unexec is available, | |
2214 * at least on UniPlus, is temacs will have to be made unshared so | |
2215 * that text and data are contiguous. Then once loadup is complete, | |
2216 * 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
|
2217 * at the normal shared text boundary and the startofdata variable |
491 | 2218 * will be patched by unexec to the correct value. |
2219 * | |
2220 */ | |
2221 | |
2222 char * | |
2223 start_of_data () | |
2224 { | |
2225 #ifdef DATA_START | |
2226 return ((char *) DATA_START); | |
2227 #else | |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2228 #ifdef ORDINARY_LINK |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2229 /* |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2230 * 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
|
2231 * 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
|
2232 * 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
|
2233 * 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
|
2234 */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2235 extern char **environ; |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2236 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
2237 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
|
2238 #else |
491 | 2239 extern int data_start; |
2240 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
|
2241 #endif /* ORDINARY_LINK */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2242 #endif /* DATA_START */ |
491 | 2243 } |
2244 #endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ | |
2245 | |
2246 #ifndef CANNOT_DUMP | |
2247 /* Some systems that cannot dump also cannot implement these. */ | |
2248 | |
2249 /* | |
2250 * Return the address of the end of the text segment prior to | |
2251 * doing an unexec. After unexec the return value is undefined. | |
2252 */ | |
2253 | |
2254 char * | |
2255 end_of_text () | |
2256 { | |
2257 #ifdef TEXT_END | |
2258 return ((char *) TEXT_END); | |
2259 #else | |
2260 extern int etext; | |
2261 return ((char *) &etext); | |
2262 #endif | |
2263 } | |
2264 | |
2265 /* | |
2266 * Return the address of the end of the data segment prior to | |
2267 * doing an unexec. After unexec the return value is undefined. | |
2268 */ | |
2269 | |
2270 char * | |
2271 end_of_data () | |
2272 { | |
2273 #ifdef DATA_END | |
2274 return ((char *) DATA_END); | |
2275 #else | |
2276 extern int edata; | |
2277 return ((char *) &edata); | |
2278 #endif | |
2279 } | |
2280 | |
2281 #endif /* not CANNOT_DUMP */ | |
2282 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2283 /* 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
|
2284 system-name to return. */ |
491 | 2285 |
2286 #ifdef BSD4_1 | |
2287 #include <whoami.h> | |
2288 #endif | |
2289 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2290 extern Lisp_Object Vsystem_name; |
491 | 2291 |
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2292 #ifndef BSD4_1 |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2293 #ifndef VMS |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2294 #ifdef HAVE_SOCKETS |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2295 #include <sys/socket.h> |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2296 #include <netdb.h> |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2297 #endif /* HAVE_SOCKETS */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2298 #endif /* not VMS */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2299 #endif /* not BSD4_1 */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2300 |
33718
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2301 #ifdef TRY_AGAIN |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2302 #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
|
2303 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
|
2304 #endif |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2305 #endif /* TRY_AGAIN */ |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2306 |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2307 void |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2308 init_system_name () |
491 | 2309 { |
2310 #ifdef BSD4_1 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2311 Vsystem_name = build_string (sysname); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2312 #else |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2313 #ifdef VMS |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2314 char *sp, *end; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2315 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
|
2316 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
|
2317 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
|
2318 Vsystem_name = build_string (sp); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2319 else |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2320 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
|
2321 #else |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2322 #ifndef HAVE_GETHOSTNAME |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2323 struct utsname uts; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2324 uname (&uts); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2325 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
|
2326 #else /* HAVE_GETHOSTNAME */ |
11800
a2f009e1b85b
(init_system_name): Clean up signedness mismatch.
Karl Heuer <kwzh@gnu.org>
parents:
11722
diff
changeset
|
2327 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
|
2328 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
|
2329 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2330 /* 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
|
2331 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
|
2332 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
|
2333 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
|
2334 for (;;) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2335 { |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2336 gethostname (hostname, hostname_size - 1); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2337 hostname[hostname_size - 1] = '\0'; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2338 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2339 /* 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
|
2340 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
|
2341 break; |
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 hostname_size <<= 1; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2344 hostname = (char *) alloca (hostname_size); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2345 } |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2346 #ifdef HAVE_SOCKETS |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2347 /* 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
|
2348 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
|
2349 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
|
2350 #ifndef CANNOT_DUMP |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2351 if (initialized) |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2352 #endif /* not CANNOT_DUMP */ |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2353 if (! index (hostname, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2354 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2355 struct hostent *hp; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2356 int count; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2357 for (count = 0;; count++) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2358 { |
8330
60adc323cfe7
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8285
diff
changeset
|
2359 #ifdef TRY_AGAIN |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2360 h_errno = 0; |
8330
60adc323cfe7
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8285
diff
changeset
|
2361 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2362 hp = gethostbyname (hostname); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
2363 #ifdef TRY_AGAIN |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2364 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
|
2365 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2366 break; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2367 if (count >= 5) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2368 break; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2369 Fsleep_for (make_number (1), Qnil); |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2370 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2371 if (hp) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2372 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2373 char *fqdn = (char *) hp->h_name; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2374 char *p; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2375 |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2376 if (!index (fqdn, '.')) |
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 /* 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
|
2379 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
|
2380 char **alias = hp->h_aliases; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2381 while (*alias && !index (*alias, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2382 alias++; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2383 if (*alias) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2384 fqdn = *alias; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2385 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2386 hostname = fqdn; |
6799 | 2387 #if 0 |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2388 /* 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
|
2389 /* 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
|
2390 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
|
2391 p = hostname; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2392 while (*p) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2393 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2394 if (*p >= 'A' && *p <= 'Z') |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2395 *p += 'a' - 'A'; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2396 p++; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2397 } |
6799 | 2398 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2399 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2400 } |
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2401 #endif /* HAVE_SOCKETS */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2402 /* We used to try using getdomainname here, |
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2403 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
|
2404 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
|
2405 as in Internet domain name. */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2406 #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
|
2407 correct Internet domain. */ |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2408 #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
|
2409 if (! index (hostname, '.')) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2410 { |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2411 /* 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
|
2412 |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2413 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
|
2414 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
|
2415 |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2416 for (;;) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2417 { |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2418 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
|
2419 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
|
2420 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
|
2421 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
|
2422 break; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2423 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
|
2424 { |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2425 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
|
2426 continue; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2427 } |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2428 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
|
2429 if (domain[0] == '.') |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2430 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
|
2431 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
|
2432 { |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2433 fqdn[hostlen] = '.'; |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2434 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
|
2435 } |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2436 hostname = fqdn; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2437 break; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2438 } |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2439 } |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2440 #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
|
2441 #endif /* 0 */ |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2442 Vsystem_name = build_string (hostname); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2443 #endif /* HAVE_GETHOSTNAME */ |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2444 #endif /* VMS */ |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2445 #endif /* BSD4_1 */ |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2446 { |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2447 unsigned char *p; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2448 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
|
2449 if (*p == ' ' || *p == '\t') |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2450 *p = '-'; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2451 } |
491 | 2452 } |
2453 | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
2454 #ifndef MSDOS |
491 | 2455 #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
|
2456 #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
|
2457 |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2458 #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
|
2459 #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
|
2460 |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2461 #if defined (HAVE_X_WINDOWS) && !defined (HAVE_SELECT) |
491 | 2462 /* Cause explanatory error message at compile time, |
2463 since the select emulation is not good enough for X. */ | |
2464 int *x = &x_windows_lose_if_no_select_system_call; | |
2465 #endif | |
2466 | |
2467 /* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs | |
2468 * Only checks read descriptors. | |
2469 */ | |
2470 /* How long to wait between checking fds in select */ | |
2471 #define SELECT_PAUSE 1 | |
2472 int select_alarmed; | |
2473 | |
2474 /* For longjmp'ing back to read_input_waiting. */ | |
2475 | |
2476 jmp_buf read_alarm_throw; | |
2477 | |
2478 /* Nonzero if the alarm signal should throw back to read_input_waiting. | |
2479 The read_socket_hook function sets this to 1 while it is waiting. */ | |
2480 | |
2481 int read_alarm_should_throw; | |
2482 | |
2483 SIGTYPE | |
2484 select_alarm () | |
2485 { | |
2486 select_alarmed = 1; | |
2487 #ifdef BSD4_1 | |
2488 sigrelse (SIGALRM); | |
2489 #else /* not BSD4_1 */ | |
2490 signal (SIGALRM, SIG_IGN); | |
2491 #endif /* not BSD4_1 */ | |
2492 if (read_alarm_should_throw) | |
2493 longjmp (read_alarm_throw, 1); | |
2494 } | |
2495 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
2496 #ifndef WINDOWSNT |
491 | 2497 /* Only rfds are checked. */ |
2498 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
|
2499 sys_select (nfds, rfds, wfds, efds, timeout) |
491 | 2500 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
|
2501 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
|
2502 EMACS_TIME *timeout; |
491 | 2503 { |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2504 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
|
2505 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
|
2506 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
|
2507 int *local_timeout; |
491 | 2508 extern int proc_buffered_char[]; |
2509 #ifndef subprocesses | |
2510 int process_tick = 0, update_tick = 0; | |
2511 #else | |
2512 extern int process_tick, update_tick; | |
2513 #endif | |
2514 unsigned char buf; | |
2515 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2516 #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
|
2517 /* 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
|
2518 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
|
2519 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
|
2520 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
|
2521 #endif |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2522 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
|
2523 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
|
2524 FD_ZERO (&orfds); |
491 | 2525 if (rfds) |
2526 { | |
2527 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
|
2528 FD_ZERO (rfds); |
491 | 2529 } |
2530 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
|
2531 FD_ZERO (wfds); |
491 | 2532 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
|
2533 FD_ZERO (efds); |
491 | 2534 |
2535 /* If we are looking only for the terminal, with no timeout, | |
2536 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
|
2537 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
|
2538 && FD_ISSET (0, &orfds)) |
491 | 2539 { |
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 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
|
2541 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
|
2542 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
|
2543 goto hardway; |
491 | 2544 if (! detect_input_pending ()) |
2545 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
|
2546 FD_SET (0, rfds); |
491 | 2547 return 1; |
2548 } | |
2549 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2550 hardway: |
491 | 2551 /* Once a second, till the timer expires, check all the flagged read |
2552 * descriptors to see if any input is available. If there is some then | |
2553 * set the corresponding bit in the return copy of rfds. | |
2554 */ | |
2555 while (1) | |
2556 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2557 register int to_check, fd; |
491 | 2558 |
2559 if (rfds) | |
2560 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2561 for (to_check = nfds, fd = 0; --to_check >= 0; fd++) |
491 | 2562 { |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2563 if (FD_ISSET (fd, &orfds)) |
491 | 2564 { |
2565 int avail = 0, status = 0; | |
2566 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2567 if (fd == 0) |
491 | 2568 avail = detect_input_pending (); /* Special keyboard handler */ |
2569 else | |
2570 { | |
2571 #ifdef FIONREAD | |
2572 status = ioctl (fd, FIONREAD, &avail); | |
2573 #else /* no FIONREAD */ | |
2574 /* Hoping it will return -1 if nothing available | |
2575 or 0 if all 0 chars requested are read. */ | |
2576 if (proc_buffered_char[fd] >= 0) | |
2577 avail = 1; | |
2578 else | |
2579 { | |
2580 avail = read (fd, &buf, 1); | |
2581 if (avail > 0) | |
2582 proc_buffered_char[fd] = buf; | |
2583 } | |
2584 #endif /* no FIONREAD */ | |
2585 } | |
2586 if (status >= 0 && avail > 0) | |
2587 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2588 FD_SET (fd, rfds); |
491 | 2589 ravail++; |
2590 } | |
2591 } | |
2592 } | |
2593 } | |
2594 if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick) | |
2595 break; | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2596 |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2597 turn_on_atimers (0); |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2598 signal (SIGALRM, select_alarm); |
491 | 2599 select_alarmed = 0; |
2600 alarm (SELECT_PAUSE); | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2601 |
491 | 2602 /* Wait for a SIGALRM (or maybe a SIGTINT) */ |
2603 while (select_alarmed == 0 && *local_timeout != 0 | |
2604 && process_tick == update_tick) | |
2605 { | |
2606 /* If we are interested in terminal input, | |
2607 wait by reading the terminal. | |
2608 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
|
2609 if (FD_ISSET (0, &orfds)) |
491 | 2610 { |
2611 read_input_waiting (); | |
2612 if (detect_input_pending ()) | |
2613 select_alarmed = 1; | |
2614 } | |
2615 else | |
2616 pause (); | |
2617 } | |
2618 (*local_timeout) -= SELECT_PAUSE; | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2619 |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2620 /* 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
|
2621 turn_on_atimers (1); |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2622 |
491 | 2623 if (*local_timeout == 0) /* Stop on timer being cleared */ |
2624 break; | |
2625 } | |
2626 return ravail; | |
2627 } | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
2628 #endif /* not WINDOWSNT */ |
491 | 2629 |
2630 /* Read keyboard input into the standard buffer, | |
2631 waiting for at least one character. */ | |
2632 | |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
2633 /* 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
|
2634 #ifdef HAVE_WINDOW_SYSTEM |
491 | 2635 #define BUFFER_SIZE_FACTOR 16 |
2636 #else | |
2637 #define BUFFER_SIZE_FACTOR 1 | |
2638 #endif | |
2639 | |
21514 | 2640 void |
491 | 2641 read_input_waiting () |
2642 { | |
2643 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
|
2644 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
|
2645 extern int quit_char; |
491 | 2646 |
2647 if (read_socket_hook) | |
2648 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2649 struct input_event buf[256]; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2650 |
491 | 2651 read_alarm_should_throw = 0; |
2652 if (! setjmp (read_alarm_throw)) | |
33217
960181d7eebf
(read_input_waiting): Remove extraneous argument to
Andrew Innes <andrewi@gnu.org>
parents:
32752
diff
changeset
|
2653 nread = (*read_socket_hook) (0, buf, 256, 1); |
491 | 2654 else |
2655 nread = -1; | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2656 |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2657 /* 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
|
2658 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
|
2659 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2660 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
|
2661 /* 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
|
2662 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
|
2663 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
|
2664 && 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
|
2665 break; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2666 } |
491 | 2667 } |
2668 else | |
2669 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2670 char buf[3]; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2671 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
|
2672 |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2673 /* 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
|
2674 e.kind = ascii_keystroke; |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
2675 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
|
2676 e.modifiers = 0; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2677 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
|
2678 { |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2679 /* 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
|
2680 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
|
2681 if (read_socket_hook == 0) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2682 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2683 /* 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
|
2684 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
|
2685 e.modifiers = meta_modifier; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2686 if (meta_key != 2) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2687 buf[i] &= ~0x80; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2688 } |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2689 |
9279
2382e2f3884e
(kbd_input_ast, read_input_waiting): Use new accessor macros instead of
Karl Heuer <kwzh@gnu.org>
parents:
9239
diff
changeset
|
2690 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
|
2691 kbd_buffer_store_event (&e); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2692 /* 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
|
2693 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
|
2694 if (buf[i] == quit_char) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2695 break; |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2696 } |
491 | 2697 } |
2698 } | |
2699 | |
2700 #endif /* not HAVE_SELECT */ | |
2701 #endif /* not VMS */ | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
2702 #endif /* not MSDOS */ |
491 | 2703 |
2704 #ifdef BSD4_1 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2705 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2706 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2707 int fd; |
491 | 2708 { |
2709 if (noninteractive) | |
2710 return; | |
2711 lmode = LINTRUP | lmode; | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2712 ioctl (fd, TIOCLSET, &lmode); |
491 | 2713 } |
2714 | |
21514 | 2715 void |
491 | 2716 reset_sigio () |
2717 { | |
2718 if (noninteractive) | |
2719 return; | |
2720 lmode = ~LINTRUP & lmode; | |
2721 ioctl (0, TIOCLSET, &lmode); | |
2722 } | |
2723 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2724 void |
491 | 2725 request_sigio () |
2726 { | |
2727 sigrelse (SIGTINT); | |
2728 | |
2729 interrupts_deferred = 0; | |
2730 } | |
2731 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2732 void |
491 | 2733 unrequest_sigio () |
2734 { | |
2735 sighold (SIGTINT); | |
2736 | |
2737 interrupts_deferred = 1; | |
2738 } | |
2739 | |
2740 /* still inside #ifdef BSD4_1 */ | |
2741 #ifdef subprocesses | |
2742 | |
2743 int sigheld; /* Mask of held signals */ | |
2744 | |
21514 | 2745 void |
491 | 2746 sigholdx (signum) |
2747 int signum; | |
2748 { | |
2749 sigheld |= sigbit (signum); | |
2750 sighold (signum); | |
2751 } | |
2752 | |
21514 | 2753 void |
491 | 2754 sigisheld (signum) |
2755 int signum; | |
2756 { | |
2757 sigheld |= sigbit (signum); | |
2758 } | |
2759 | |
21514 | 2760 void |
491 | 2761 sigunhold (signum) |
2762 int signum; | |
2763 { | |
2764 sigheld &= ~sigbit (signum); | |
2765 sigrelse (signum); | |
2766 } | |
2767 | |
21514 | 2768 void |
491 | 2769 sigfree () /* Free all held signals */ |
2770 { | |
2771 int i; | |
2772 for (i = 0; i < NSIG; i++) | |
2773 if (sigheld & sigbit (i)) | |
2774 sigrelse (i); | |
2775 sigheld = 0; | |
2776 } | |
2777 | |
21514 | 2778 int |
491 | 2779 sigbit (i) |
2780 { | |
2781 return 1 << (i - 1); | |
2782 } | |
2783 #endif /* subprocesses */ | |
2784 #endif /* BSD4_1 */ | |
2785 | |
2786 /* POSIX signals support - DJB */ | |
2787 /* Anyone with POSIX signals should have ANSI C declarations */ | |
2788 | |
2789 #ifdef POSIX_SIGNALS | |
2790 | |
20948 | 2791 sigset_t empty_mask, full_mask; |
491 | 2792 |
2793 signal_handler_t | |
2794 sys_signal (int signal_number, signal_handler_t action) | |
2795 { | |
20948 | 2796 struct sigaction new_action, old_action; |
491 | 2797 sigemptyset (&new_action.sa_mask); |
20498
22dd2d861e36
(sys_signal): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
20456
diff
changeset
|
2798 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
|
2799 #ifdef SA_RESTART |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2800 /* 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
|
2801 * 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
|
2802 */ |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2803 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
|
2804 #else |
3292
6209d0e98e35
(sys_signal): Use 0, not NULL, to set sa_flags.
Richard M. Stallman <rms@gnu.org>
parents:
3268
diff
changeset
|
2805 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
|
2806 #endif |
709 | 2807 sigaction (signal_number, &new_action, &old_action); |
20498
22dd2d861e36
(sys_signal): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
20456
diff
changeset
|
2808 return (old_action.sa_handler); |
491 | 2809 } |
2810 | |
638 | 2811 #ifndef __GNUC__ |
2812 /* If we're compiling with GCC, we don't need this function, since it | |
2813 can be written as a macro. */ | |
2814 sigset_t | |
2815 sys_sigmask (int sig) | |
2816 { | |
2817 sigset_t mask; | |
2818 sigemptyset (&mask); | |
2819 sigaddset (&mask, sig); | |
2820 return mask; | |
2821 } | |
2822 #endif | |
2823 | |
491 | 2824 /* I'd like to have these guys return pointers to the mask storage in here, |
2825 but there'd be trouble if the code was saving multiple masks. I'll be | |
2826 safe and pass the structure. It normally won't be more than 2 bytes | |
2827 anyhow. - DJB */ | |
2828 | |
2829 sigset_t | |
2830 sys_sigblock (sigset_t new_mask) | |
2831 { | |
2832 sigset_t old_mask; | |
2833 sigprocmask (SIG_BLOCK, &new_mask, &old_mask); | |
2834 return (old_mask); | |
2835 } | |
2836 | |
2837 sigset_t | |
2838 sys_sigunblock (sigset_t new_mask) | |
2839 { | |
2840 sigset_t old_mask; | |
2841 sigprocmask (SIG_UNBLOCK, &new_mask, &old_mask); | |
2842 return (old_mask); | |
2843 } | |
2844 | |
2845 sigset_t | |
2846 sys_sigsetmask (sigset_t new_mask) | |
2847 { | |
2848 sigset_t old_mask; | |
2849 sigprocmask (SIG_SETMASK, &new_mask, &old_mask); | |
2850 return (old_mask); | |
2851 } | |
2852 | |
2853 #endif /* POSIX_SIGNALS */ | |
2854 | |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2855 #if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2856 static char *my_sys_siglist[NSIG]; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2857 # ifdef sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2858 # undef sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2859 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2860 # define sys_siglist my_sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2861 #endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2862 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2863 void |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2864 init_signals () |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2865 { |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2866 #ifdef POSIX_SIGNALS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2867 sigemptyset (&empty_mask); |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2868 sigfillset (&full_mask); |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2869 #endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2870 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2871 #if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2872 if (! initialized) |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2873 { |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2874 # ifdef SIGABRT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2875 sys_siglist[SIGABRT] = "Aborted"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2876 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2877 # ifdef SIGAIO |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2878 sys_siglist[SIGAIO] = "LAN I/O interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2879 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2880 # ifdef SIGALRM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2881 sys_siglist[SIGALRM] = "Alarm clock"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2882 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2883 # ifdef SIGBUS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2884 sys_siglist[SIGBUS] = "Bus error"; |
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 SIGCLD |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2887 sys_siglist[SIGCLD] = "Child status changed"; |
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 SIGCHLD |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2890 sys_siglist[SIGCHLD] = "Child status changed"; |
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 SIGCONT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2893 sys_siglist[SIGCONT] = "Continued"; |
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 SIGDANGER |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2896 sys_siglist[SIGDANGER] = "Swap space dangerously low"; |
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 SIGDGNOTIFY |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2899 sys_siglist[SIGDGNOTIFY] = "Notification message in queue"; |
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 SIGEMT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2902 sys_siglist[SIGEMT] = "Emulation trap"; |
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 SIGFPE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2905 sys_siglist[SIGFPE] = "Arithmetic exception"; |
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 SIGFREEZE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2908 sys_siglist[SIGFREEZE] = "SIGFREEZE"; |
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 SIGGRANT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2911 sys_siglist[SIGGRANT] = "Monitor mode granted"; |
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 SIGHUP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2914 sys_siglist[SIGHUP] = "Hangup"; |
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 SIGILL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2917 sys_siglist[SIGILL] = "Illegal instruction"; |
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 SIGINT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2920 sys_siglist[SIGINT] = "Interrupt"; |
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 SIGIO |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2923 sys_siglist[SIGIO] = "I/O possible"; |
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 SIGIOINT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2926 sys_siglist[SIGIOINT] = "I/O intervention required"; |
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 SIGIOT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2929 sys_siglist[SIGIOT] = "IOT trap"; |
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 SIGKILL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2932 sys_siglist[SIGKILL] = "Killed"; |
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 SIGLOST |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2935 sys_siglist[SIGLOST] = "Resource lost"; |
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 SIGLWP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2938 sys_siglist[SIGLWP] = "SIGLWP"; |
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 SIGMSG |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2941 sys_siglist[SIGMSG] = "Monitor mode data available"; |
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 SIGPHONE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2944 sys_siglist[SIGWIND] = "SIGPHONE"; |
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 SIGPIPE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2947 sys_siglist[SIGPIPE] = "Broken pipe"; |
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 SIGPOLL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2950 sys_siglist[SIGPOLL] = "Pollable event occurred"; |
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 SIGPROF |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2953 sys_siglist[SIGPROF] = "Profiling timer expired"; |
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 SIGPTY |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2956 sys_siglist[SIGPTY] = "PTY I/O interrupt"; |
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 SIGPWR |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2959 sys_siglist[SIGPWR] = "Power-fail restart"; |
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 SIGQUIT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2962 sys_siglist[SIGQUIT] = "Quit"; |
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 SIGRETRACT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2965 sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode"; |
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 SIGSAK |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2968 sys_siglist[SIGSAK] = "Secure attention"; |
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 SIGSEGV |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2971 sys_siglist[SIGSEGV] = "Segmentation violation"; |
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 SIGSOUND |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2974 sys_siglist[SIGSOUND] = "Sound completed"; |
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 SIGSTOP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2977 sys_siglist[SIGSTOP] = "Stopped (signal)"; |
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 SIGSTP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2980 sys_siglist[SIGSTP] = "Stopped (user)"; |
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 SIGSYS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2983 sys_siglist[SIGSYS] = "Bad argument to system call"; |
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 SIGTERM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2986 sys_siglist[SIGTERM] = "Terminated"; |
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 SIGTHAW |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2989 sys_siglist[SIGTHAW] = "SIGTHAW"; |
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 SIGTRAP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2992 sys_siglist[SIGTRAP] = "Trace/breakpoint trap"; |
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 SIGTSTP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2995 sys_siglist[SIGTSTP] = "Stopped (user)"; |
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 SIGTTIN |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2998 sys_siglist[SIGTTIN] = "Stopped (tty input)"; |
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 SIGTTOU |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3001 sys_siglist[SIGTTOU] = "Stopped (tty output)"; |
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 SIGURG |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3004 sys_siglist[SIGURG] = "Urgent I/O condition"; |
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 SIGUSR1 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3007 sys_siglist[SIGUSR1] = "User defined signal 1"; |
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 SIGUSR2 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3010 sys_siglist[SIGUSR2] = "User defined signal 2"; |
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 SIGVTALRM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3013 sys_siglist[SIGVTALRM] = "Virtual timer expired"; |
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 SIGWAITING |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3016 sys_siglist[SIGWAITING] = "Process's LWPs are blocked"; |
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 SIGWINCH |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3019 sys_siglist[SIGWINCH] = "Window size changed"; |
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 SIGWIND |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3022 sys_siglist[SIGWIND] = "SIGWIND"; |
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 SIGXCPU |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3025 sys_siglist[SIGXCPU] = "CPU time limit exceeded"; |
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 SIGXFSZ |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3028 sys_siglist[SIGXFSZ] = "File size limit exceeded"; |
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 } |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3031 #endif /* !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED */ |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3032 } |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3033 |
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
3034 #ifndef HAVE_RANDOM |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3035 #ifdef random |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3036 #define HAVE_RANDOM |
8368
0c30bec316c6
(random): Use rand differently, and distinguish BSD/USG.
Richard M. Stallman <rms@gnu.org>
parents:
8358
diff
changeset
|
3037 #endif |
8358
f9d8f778f73b
(random, srandom): Obey HAVE_RAND48 flag.
Richard M. Stallman <rms@gnu.org>
parents:
8330
diff
changeset
|
3038 #endif |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3039 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3040 /* 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
|
3041 `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
|
3042 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
|
3043 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
|
3044 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3045 #ifndef RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3046 # ifdef HAVE_RANDOM |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3047 # define RAND_BITS 31 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3048 # else /* !HAVE_RANDOM */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3049 # ifdef HAVE_LRAND48 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3050 # define RAND_BITS 31 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3051 # define random lrand48 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3052 # else /* !HAVE_LRAND48 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3053 # define RAND_BITS 15 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3054 # if RAND_MAX == 32767 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3055 # define random rand |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3056 # else /* RAND_MAX != 32767 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3057 # if RAND_MAX == 2147483647 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3058 # define random() (rand () >> 16) |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3059 # else /* RAND_MAX != 2147483647 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3060 # ifdef USG |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3061 # define random rand |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3062 # else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3063 # define random() (rand () >> 16) |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
3064 # endif /* !USG */ |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3065 # endif /* RAND_MAX != 2147483647 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3066 # endif /* RAND_MAX != 32767 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3067 # endif /* !HAVE_LRAND48 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3068 # endif /* !HAVE_RANDOM */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3069 #endif /* !RAND_BITS */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3070 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3071 void |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3072 seed_random (arg) |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3073 long arg; |
491 | 3074 { |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3075 #ifdef HAVE_RANDOM |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3076 srandom ((unsigned int)arg); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3077 #else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3078 # ifdef HAVE_LRAND48 |
8702
097fe97274e9
(srandom): Pass arg to srand48; no return value.
Karl Heuer <kwzh@gnu.org>
parents:
8699
diff
changeset
|
3079 srand48 (arg); |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3080 # else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3081 srand ((unsigned int)arg); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3082 # endif |
8358
f9d8f778f73b
(random, srandom): Obey HAVE_RAND48 flag.
Richard M. Stallman <rms@gnu.org>
parents:
8330
diff
changeset
|
3083 #endif |
491 | 3084 } |
3085 | |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3086 /* |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3087 * 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
|
3088 * 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
|
3089 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3090 long |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3091 get_random () |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3092 { |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3093 long val = random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3094 #if VALBITS > RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3095 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3096 #if VALBITS > 2*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3097 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3098 #if VALBITS > 3*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3099 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3100 #if VALBITS > 4*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3101 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3102 #endif /* need at least 5 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3103 #endif /* need at least 4 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3104 #endif /* need at least 3 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3105 #endif /* need at least 2 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3106 return val & ((1L << VALBITS) - 1); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3107 } |
491 | 3108 |
3109 #ifdef WRONG_NAME_INSQUE | |
3110 | |
3111 insque (q,p) | |
3112 caddr_t q,p; | |
3113 { | |
3114 _insque (q,p); | |
3115 } | |
3116 | |
3117 #endif | |
3118 | |
3119 #ifdef VMS | |
3120 | |
3121 #ifdef getenv | |
3122 /* If any place else asks for the TERM variable, | |
3123 allow it to be overridden with the EMACS_TERM variable | |
3124 before attempting to translate the logical name TERM. As a last | |
3125 resort, ask for VAX C's special idea of the TERM variable. */ | |
3126 #undef getenv | |
3127 char * | |
3128 sys_getenv (name) | |
3129 char *name; | |
3130 { | |
3131 register char *val; | |
3132 static char buf[256]; | |
3133 static struct dsc$descriptor_s equiv | |
3134 = {sizeof (buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf}; | |
3135 static struct dsc$descriptor_s d_name | |
3136 = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; | |
3137 short eqlen; | |
3138 | |
3139 if (!strcmp (name, "TERM")) | |
3140 { | |
3141 val = (char *) getenv ("EMACS_TERM"); | |
3142 if (val) | |
3143 return val; | |
3144 } | |
3145 | |
3146 d_name.dsc$w_length = strlen (name); | |
3147 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
|
3148 if (LIB$SYS_TRNLOG (&d_name, &eqlen, &equiv) == 1) |
491 | 3149 { |
3150 char *str = (char *) xmalloc (eqlen + 1); | |
3151 bcopy (buf, str, eqlen); | |
3152 str[eqlen] = '\0'; | |
3153 /* This is a storage leak, but a pain to fix. With luck, | |
3154 no one will ever notice. */ | |
3155 return str; | |
3156 } | |
3157 return (char *) getenv (name); | |
3158 } | |
3159 #endif /* getenv */ | |
3160 | |
3161 #ifdef abort | |
3162 /* Since VMS doesn't believe in core dumps, the only way to debug this beast is | |
3163 to force a call on the debugger from within the image. */ | |
3164 #undef abort | |
3165 sys_abort () | |
3166 { | |
3167 reset_sys_modes (); | |
3168 LIB$SIGNAL (SS$_DEBUG); | |
3169 } | |
3170 #endif /* abort */ | |
3171 #endif /* VMS */ | |
3172 | |
3173 #ifdef VMS | |
3174 #ifdef LINK_CRTL_SHARE | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3175 #ifdef SHARABLE_LIB_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3176 /* Variables declared noshare and initialized in sharable libraries |
491 | 3177 cannot be shared. The VMS linker incorrectly forces you to use a private |
3178 version which is uninitialized... If not for this "feature", we | |
3179 could use the C library definition of sys_nerr and sys_errlist. */ | |
3180 int sys_nerr = 35; | |
3181 char *sys_errlist[] = | |
3182 { | |
3183 "error 0", | |
3184 "not owner", | |
3185 "no such file or directory", | |
3186 "no such process", | |
3187 "interrupted system call", | |
3188 "i/o error", | |
3189 "no such device or address", | |
3190 "argument list too long", | |
3191 "exec format error", | |
3192 "bad file number", | |
3193 "no child process", | |
3194 "no more processes", | |
3195 "not enough memory", | |
3196 "permission denied", | |
3197 "bad address", | |
3198 "block device required", | |
3199 "mount devices busy", | |
3200 "file exists", | |
3201 "cross-device link", | |
3202 "no such device", | |
3203 "not a directory", | |
3204 "is a directory", | |
3205 "invalid argument", | |
3206 "file table overflow", | |
3207 "too many open files", | |
3208 "not a typewriter", | |
3209 "text file busy", | |
3210 "file too big", | |
3211 "no space left on device", | |
3212 "illegal seek", | |
3213 "read-only file system", | |
3214 "too many links", | |
3215 "broken pipe", | |
3216 "math argument", | |
3217 "result too large", | |
3218 "I/O stream empty", | |
3219 "vax/vms specific error code nontranslatable error" | |
3220 }; | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3221 #endif /* SHARABLE_LIB_BUG */ |
491 | 3222 #endif /* LINK_CRTL_SHARE */ |
3223 #endif /* VMS */ | |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3224 |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3225 #ifndef HAVE_STRERROR |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3226 #ifndef WINDOWSNT |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3227 char * |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3228 strerror (errnum) |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3229 int errnum; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3230 { |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3231 extern char *sys_errlist[]; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3232 extern int sys_nerr; |
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 if (errnum >= 0 && errnum < sys_nerr) |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3235 return sys_errlist[errnum]; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3236 return (char *) "Unknown error"; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3237 } |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3238 #endif /* not WINDOWSNT */ |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3239 #endif /* ! HAVE_STRERROR */ |
491 | 3240 |
3241 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3242 emacs_open (path, oflag, mode) |
491 | 3243 char *path; |
3244 int oflag, mode; | |
3245 { | |
3246 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
|
3247 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3248 #ifdef BSD4_1 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3249 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
|
3250 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
|
3251 #endif |
491 | 3252 |
3253 while ((rtnval = open (path, oflag, mode)) == -1 | |
3254 && (errno == EINTR)); | |
3255 return (rtnval); | |
3256 } | |
3257 | |
21514 | 3258 int |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3259 emacs_close (fd) |
491 | 3260 int fd; |
3261 { | |
12547
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3262 int did_retry = 0; |
491 | 3263 register int rtnval; |
3264 | |
3265 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
|
3266 && (errno == EINTR)) |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3267 did_retry = 1; |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3268 |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3269 /* 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
|
3270 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
|
3271 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
|
3272 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
|
3273 return 0; |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3274 |
491 | 3275 return rtnval; |
3276 } | |
3277 | |
3278 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3279 emacs_read (fildes, buf, nbyte) |
491 | 3280 int fildes; |
3281 char *buf; | |
3282 unsigned int nbyte; | |
3283 { | |
3284 register int rtnval; | |
3285 | |
3286 while ((rtnval = read (fildes, buf, nbyte)) == -1 | |
3287 && (errno == EINTR)); | |
3288 return (rtnval); | |
3289 } | |
3290 | |
3291 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3292 emacs_write (fildes, buf, nbyte) |
491 | 3293 int fildes; |
3294 char *buf; | |
3295 unsigned int nbyte; | |
3296 { | |
4772
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3297 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
|
3298 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3299 bytes_written = 0; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3300 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3301 while (nbyte > 0) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3302 { |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3303 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
|
3304 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3305 if (rtnval == -1) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3306 { |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3307 if (errno == EINTR) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3308 continue; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3309 else |
5954
02f406110e4b
(sys_write): If any bytes were written, return how many.
Richard M. Stallman <rms@gnu.org>
parents:
5937
diff
changeset
|
3310 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
|
3311 } |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3312 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3313 buf += rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3314 nbyte -= rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3315 bytes_written += rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3316 } |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3317 return (bytes_written); |
491 | 3318 } |
3319 | |
3320 #ifdef USG | |
3321 /* | |
3322 * All of the following are for USG. | |
3323 * | |
3324 * On USG systems the system calls are INTERRUPTIBLE by signals | |
3325 * that the user program has elected to catch. Thus the system call | |
3326 * must be retried in these cases. To handle this without massive | |
3327 * changes in the source code, we remap the standard system call names | |
3328 * to names for our own functions in sysdep.c that do the system call | |
3329 * with retries. Actually, for portability reasons, it is good | |
3330 * 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
|
3331 * system calls to a single occurrence in the source. Sure, this |
491 | 3332 * adds an extra level of function call overhead but it is almost |
3333 * always negligible. Fred Fish, Unisoft Systems Inc. | |
3334 */ | |
3335 | |
3336 /* | |
3337 * Warning, this function may not duplicate 4.2 action properly | |
3338 * under error conditions. | |
3339 */ | |
3340 | |
3341 #ifndef MAXPATHLEN | |
3342 /* In 4.1, param.h fails to define this. */ | |
3343 #define MAXPATHLEN 1024 | |
3344 #endif | |
3345 | |
3346 #ifndef HAVE_GETWD | |
3347 | |
3348 char * | |
3349 getwd (pathname) | |
3350 char *pathname; | |
3351 { | |
3352 char *npath, *spath; | |
3353 extern char *getcwd (); | |
3354 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3355 BLOCK_INPUT; /* getcwd uses malloc */ |
491 | 3356 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
|
3357 if (spath == 0) |
37219
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3358 { |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3359 UNBLOCK_INPUT; |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3360 return spath; |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3361 } |
491 | 3362 /* On Altos 3068, getcwd can return @hostname/dir, so discard |
3363 up to first slash. Should be harmless on other systems. */ | |
3364 while (*npath && *npath != '/') | |
3365 npath++; | |
3366 strcpy (pathname, npath); | |
3367 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
|
3368 UNBLOCK_INPUT; |
491 | 3369 return pathname; |
3370 } | |
3371 | |
3372 #endif /* HAVE_GETWD */ | |
3373 | |
3374 /* | |
3375 * Emulate rename using unlink/link. Note that this is | |
3376 * only partially correct. Also, doesn't enforce restriction | |
3377 * that files be of same type (regular->regular, dir->dir, etc). | |
3378 */ | |
3379 | |
621 | 3380 #ifndef HAVE_RENAME |
3381 | |
491 | 3382 rename (from, to) |
3842
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
3383 const char *from; |
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
3384 const char *to; |
491 | 3385 { |
3386 if (access (from, 0) == 0) | |
3387 { | |
3388 unlink (to); | |
3389 if (link (from, to) == 0) | |
3390 if (unlink (from) == 0) | |
3391 return (0); | |
3392 } | |
3393 return (-1); | |
3394 } | |
3395 | |
621 | 3396 #endif |
3397 | |
491 | 3398 |
3399 #ifdef HPUX | |
3400 #ifndef HAVE_PERROR | |
3401 | |
3402 /* HPUX curses library references perror, but as far as we know | |
3403 it won't be called. Anyway this definition will do for now. */ | |
3404 | |
3405 perror () | |
3406 { | |
3407 } | |
3408 | |
3409 #endif /* not HAVE_PERROR */ | |
3410 #endif /* HPUX */ | |
3411 | |
3412 #ifndef HAVE_DUP2 | |
3413 | |
3414 /* | |
3415 * Emulate BSD dup2. First close newd if it already exists. | |
3416 * Then, attempt to dup oldd. If not successful, call dup2 recursively | |
3417 * until we are, then close the unsuccessful ones. | |
3418 */ | |
3419 | |
3420 dup2 (oldd, newd) | |
3421 int oldd; | |
3422 int newd; | |
3423 { | |
3424 register int fd, ret; | |
3425 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3426 emacs_close (newd); |
491 | 3427 |
3428 #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
|
3429 return fcntl (oldd, F_DUPFD, newd); |
491 | 3430 #else |
3431 fd = dup (old); | |
3432 if (fd == -1) | |
3433 return -1; | |
3434 if (fd == new) | |
3435 return new; | |
3436 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
|
3437 emacs_close (fd); |
491 | 3438 return ret; |
3439 #endif | |
3440 } | |
3441 | |
3442 #endif /* not HAVE_DUP2 */ | |
3443 | |
3444 /* | |
3445 * Gettimeofday. Simulate as much as possible. Only accurate | |
3446 * to nearest second. Emacs doesn't use tzp so ignore it for now. | |
3447 * Only needed when subprocesses are defined. | |
3448 */ | |
3449 | |
3450 #ifdef subprocesses | |
3451 #ifndef VMS | |
3452 #ifndef HAVE_GETTIMEOFDAY | |
3453 #ifdef HAVE_TIMEVAL | |
3454 | |
3455 /* ARGSUSED */ | |
21514 | 3456 int |
491 | 3457 gettimeofday (tp, tzp) |
3458 struct timeval *tp; | |
3459 struct timezone *tzp; | |
3460 { | |
3461 extern long time (); | |
3462 | |
3463 tp->tv_sec = time ((long *)0); | |
3464 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
|
3465 if (tzp != 0) |
2e4882a32671
(gettimeofday): Don't store in *tzp if tzp is 0.
Richard M. Stallman <rms@gnu.org>
parents:
3157
diff
changeset
|
3466 tzp->tz_minuteswest = -1; |
21514 | 3467 return 0; |
491 | 3468 } |
3469 | |
3470 #endif | |
3471 #endif | |
3472 #endif | |
3473 #endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL && !VMS */ | |
3474 | |
3475 /* | |
3476 * This function will go away as soon as all the stubs fixed. (fnf) | |
3477 */ | |
3478 | |
21514 | 3479 void |
491 | 3480 croak (badfunc) |
3481 char *badfunc; | |
3482 { | |
3483 printf ("%s not yet implemented\r\n", badfunc); | |
3484 reset_sys_modes (); | |
3485 exit (1); | |
3486 } | |
3487 | |
3488 #endif /* USG */ | |
3489 | |
3490 /* Directory routines for systems that don't have them. */ | |
3491 | |
3492 #ifdef SYSV_SYSTEM_DIR | |
3493 | |
3494 #include <dirent.h> | |
3495 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
3496 #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
|
3497 |
491 | 3498 int |
3499 closedir (dirp) | |
3500 register DIR *dirp; /* stream from opendir */ | |
3501 { | |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3502 int rtnval; |
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3503 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3504 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
|
3505 |
3797
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3506 /* 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
|
3507 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
|
3508 anyway? */ |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3509 #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
|
3510 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
|
3511 #endif |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3512 xfree ((char *) dirp); |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3513 |
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3514 return rtnval; |
491 | 3515 } |
5189
af88471e6799
(closedir): Test BROKEN_CLOSEDIR, not INTERRUPTIBLE_CLOSE.
Richard M. Stallman <rms@gnu.org>
parents:
5167
diff
changeset
|
3516 #endif /* BROKEN_CLOSEDIR or not HAVE_CLOSEDIR */ |
491 | 3517 #endif /* SYSV_SYSTEM_DIR */ |
3518 | |
3519 #ifdef NONSYSTEM_DIR_LIBRARY | |
3520 | |
3521 DIR * | |
3522 opendir (filename) | |
3523 char *filename; /* name of directory */ | |
3524 { | |
3525 register DIR *dirp; /* -> malloc'ed storage */ | |
3526 register int fd; /* file descriptor for read */ | |
3527 struct stat sbuf; /* result of fstat */ | |
3528 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3529 fd = emacs_open (filename, O_RDONLY, 0); |
491 | 3530 if (fd < 0) |
3531 return 0; | |
3532 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3533 BLOCK_INPUT; |
491 | 3534 if (fstat (fd, &sbuf) < 0 |
3535 || (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
|
3536 || (dirp = (DIR *) xmalloc (sizeof (DIR))) == 0) |
491 | 3537 { |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3538 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
|
3539 UNBLOCK_INPUT; |
491 | 3540 return 0; /* bad luck today */ |
3541 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3542 UNBLOCK_INPUT; |
491 | 3543 |
3544 dirp->dd_fd = fd; | |
3545 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ | |
3546 | |
3547 return dirp; | |
3548 } | |
3549 | |
3550 void | |
3551 closedir (dirp) | |
3552 register DIR *dirp; /* stream from opendir */ | |
3553 { | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3554 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
|
3555 xfree ((char *) dirp); |
491 | 3556 } |
3557 | |
3558 | |
3559 #ifndef VMS | |
3560 #define DIRSIZ 14 | |
3561 struct olddir | |
3562 { | |
3563 ino_t od_ino; /* inode */ | |
3564 char od_name[DIRSIZ]; /* filename */ | |
3565 }; | |
3566 #endif /* not VMS */ | |
3567 | |
3568 struct direct dir_static; /* simulated directory contents */ | |
3569 | |
3570 /* ARGUSED */ | |
3571 struct direct * | |
3572 readdir (dirp) | |
3573 register DIR *dirp; /* stream from opendir */ | |
3574 { | |
3575 #ifndef VMS | |
3576 register struct olddir *dp; /* -> directory data */ | |
3577 #else /* VMS */ | |
3578 register struct dir$_name *dp; /* -> directory data */ | |
3579 register struct dir$_version *dv; /* -> version data */ | |
3580 #endif /* VMS */ | |
3581 | |
3582 for (; ;) | |
3583 { | |
3584 if (dirp->dd_loc >= dirp->dd_size) | |
3585 dirp->dd_loc = dirp->dd_size = 0; | |
3586 | |
3587 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
|
3588 && (dirp->dd_size = emacs_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) |
491 | 3589 return 0; |
3590 | |
3591 #ifndef VMS | |
3592 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; | |
3593 dirp->dd_loc += sizeof (struct olddir); | |
3594 | |
3595 if (dp->od_ino != 0) /* not deleted entry */ | |
3596 { | |
3597 dir_static.d_ino = dp->od_ino; | |
3598 strncpy (dir_static.d_name, dp->od_name, DIRSIZ); | |
3599 dir_static.d_name[DIRSIZ] = '\0'; | |
3600 dir_static.d_namlen = strlen (dir_static.d_name); | |
3601 dir_static.d_reclen = sizeof (struct direct) | |
3602 - MAXNAMLEN + 3 | |
3603 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3604 return &dir_static; /* -> simulated structure */ | |
3605 } | |
3606 #else /* VMS */ | |
3607 dp = (struct dir$_name *) dirp->dd_buf; | |
3608 if (dirp->dd_loc == 0) | |
3609 dirp->dd_loc = (dp->dir$b_namecount&1) ? dp->dir$b_namecount + 1 | |
3610 : dp->dir$b_namecount; | |
3611 dv = (struct dir$_version *)&dp->dir$t_name[dirp->dd_loc]; | |
3612 dir_static.d_ino = dv->dir$w_fid_num; | |
3613 dir_static.d_namlen = dp->dir$b_namecount; | |
3614 dir_static.d_reclen = sizeof (struct direct) | |
3615 - MAXNAMLEN + 3 | |
3616 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3617 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
3618 dir_static.d_name[dir_static.d_namlen] = '\0'; | |
3619 dirp->dd_loc = dirp->dd_size; /* only one record at a time */ | |
3620 return &dir_static; | |
3621 #endif /* VMS */ | |
3622 } | |
3623 } | |
3624 | |
3625 #ifdef VMS | |
3626 /* readdirver is just like readdir except it returns all versions of a file | |
3627 as separate entries. */ | |
3628 | |
3629 /* ARGUSED */ | |
3630 struct direct * | |
3631 readdirver (dirp) | |
3632 register DIR *dirp; /* stream from opendir */ | |
3633 { | |
3634 register struct dir$_name *dp; /* -> directory data */ | |
3635 register struct dir$_version *dv; /* -> version data */ | |
3636 | |
3637 if (dirp->dd_loc >= dirp->dd_size - sizeof (struct dir$_name)) | |
3638 dirp->dd_loc = dirp->dd_size = 0; | |
3639 | |
3640 if (dirp->dd_size == 0 /* refill buffer */ | |
3641 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
3642 return 0; | |
3643 | |
3644 dp = (struct dir$_name *) dirp->dd_buf; | |
3645 if (dirp->dd_loc == 0) | |
3646 dirp->dd_loc = (dp->dir$b_namecount & 1) ? dp->dir$b_namecount + 1 | |
3647 : dp->dir$b_namecount; | |
3648 dv = (struct dir$_version *) &dp->dir$t_name[dirp->dd_loc]; | |
3649 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
3650 sprintf (&dir_static.d_name[dp->dir$b_namecount], ";%d", dv->dir$w_version); | |
3651 dir_static.d_namlen = strlen (dir_static.d_name); | |
3652 dir_static.d_ino = dv->dir$w_fid_num; | |
3653 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 | |
3654 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3655 dirp->dd_loc = ((char *) (++dv) - dp->dir$t_name); | |
3656 return &dir_static; | |
3657 } | |
3658 | |
3659 #endif /* VMS */ | |
3660 | |
3661 #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
|
3662 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3663 |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3664 int |
9082
2c6875700c9f
(set_file_times): Fix typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
9081
diff
changeset
|
3665 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
|
3666 char *filename; |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3667 EMACS_TIME atime, mtime; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3668 { |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3669 #ifdef HAVE_UTIMES |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3670 struct timeval tv[2]; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3671 tv[0] = atime; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3672 tv[1] = mtime; |
9081
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3673 return utimes (filename, tv); |
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3674 #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
|
3675 struct utimbuf utb; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3676 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
|
3677 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
|
3678 return utime (filename, &utb); |
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3679 #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
|
3680 } |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3681 |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3682 /* 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
|
3683 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3684 #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
|
3685 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3686 * 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
|
3687 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3688 * 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
|
3689 * 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
|
3690 * a copy. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3691 * 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
|
3692 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3693 * 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
|
3694 * 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
|
3695 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3696 * 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
|
3697 * 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
|
3698 */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3699 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3700 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3701 * 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
|
3702 */ |
5682
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3703 #ifdef MKDIR_PROTOTYPE |
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3704 MKDIR_PROTOTYPE |
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3705 #else |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3706 int |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3707 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
|
3708 char *dpath; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3709 int dmode; |
5682
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3710 #endif |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3711 { |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3712 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
|
3713 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
|
3714 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3715 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
|
3716 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3717 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
|
3718 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3719 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3720 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3721 /* 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
|
3722 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
|
3723 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3724 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3725 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
|
3726 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
|
3727 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3728 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3729 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
|
3730 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
|
3731 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3732 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
|
3733 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3734 * 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
|
3735 * 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
|
3736 * 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
|
3737 * 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
|
3738 */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3739 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
|
3740 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
|
3741 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
|
3742 if (fd >= 0) |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3743 { |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3744 dup2 (fd, 0); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3745 dup2 (fd, 1); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3746 dup2 (fd, 2); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3747 } |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3748 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
|
3749 _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
|
3750 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3751 default: /* Parent process */ |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3752 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
|
3753 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3754 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3755 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
|
3756 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3757 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
|
3758 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
|
3759 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3760 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3761 return 0; |
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 #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
|
3764 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3765 #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
|
3766 int |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3767 rmdir (dpath) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3768 char *dpath; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3769 { |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3770 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
|
3771 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
|
3772 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3773 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
|
3774 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3775 /* 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
|
3776 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3777 } |
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 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
|
3780 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
|
3781 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3782 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3783 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
|
3784 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
|
3785 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3786 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
|
3787 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
|
3788 if (fd >= 0) |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3789 { |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3790 dup2 (fd, 0); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3791 dup2 (fd, 1); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3792 dup2 (fd, 2); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3793 } |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3794 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
|
3795 _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
|
3796 |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3797 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
|
3798 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
|
3799 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3800 |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3801 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
|
3802 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3803 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
|
3804 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
|
3805 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3806 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3807 return 0; |
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 #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
|
3810 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3811 |
491 | 3812 |
3813 /* Functions for VMS */ | |
3814 #ifdef VMS | |
579 | 3815 #include "vms-pwd.h" |
491 | 3816 #include <acldef.h> |
3817 #include <chpdef.h> | |
3818 #include <jpidef.h> | |
3819 | |
3820 /* Return as a string the VMS error string pertaining to STATUS. | |
3821 Reuses the same static buffer each time it is called. */ | |
3822 | |
3823 char * | |
3824 vmserrstr (status) | |
3825 int status; /* VMS status code */ | |
3826 { | |
3827 int bufadr[2]; | |
3828 short len; | |
3829 static char buf[257]; | |
3830 | |
3831 bufadr[0] = sizeof buf - 1; | |
3832 bufadr[1] = (int) buf; | |
3833 if (! (SYS$GETMSG (status, &len, bufadr, 0x1, 0) & 1)) | |
3834 return "untranslatable VMS error status"; | |
3835 buf[len] = '\0'; | |
3836 return buf; | |
3837 } | |
3838 | |
3839 #ifdef access | |
3840 #undef access | |
3841 | |
3842 /* The following is necessary because 'access' emulation by VMS C (2.0) does | |
3843 * not work correctly. (It also doesn't work well in version 2.3.) | |
3844 */ | |
3845 | |
3846 #ifdef VMS4_4 | |
3847 | |
3848 #define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \ | |
3849 { strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string } | |
3850 | |
3851 typedef union { | |
3852 struct { | |
3853 unsigned short s_buflen; | |
3854 unsigned short s_code; | |
3855 char *s_bufadr; | |
3856 unsigned short *s_retlenadr; | |
3857 } s; | |
3858 int end; | |
3859 } item; | |
3860 #define buflen s.s_buflen | |
3861 #define code s.s_code | |
3862 #define bufadr s.s_bufadr | |
3863 #define retlenadr s.s_retlenadr | |
3864 | |
3865 #define R_OK 4 /* test for read permission */ | |
3866 #define W_OK 2 /* test for write permission */ | |
3867 #define X_OK 1 /* test for execute (search) permission */ | |
3868 #define F_OK 0 /* test for presence of file */ | |
3869 | |
3870 int | |
3871 sys_access (path, mode) | |
3872 char *path; | |
3873 int mode; | |
3874 { | |
3875 static char *user = NULL; | |
3876 char dir_fn[512]; | |
3877 | |
3878 /* translate possible directory spec into .DIR file name, so brain-dead | |
3879 * access can treat the directory like a file. */ | |
3880 if (directory_file_name (path, dir_fn)) | |
3881 path = dir_fn; | |
3882 | |
3883 if (mode == F_OK) | |
3884 return access (path, mode); | |
3885 if (user == NULL && (user = (char *) getenv ("USER")) == NULL) | |
3886 return -1; | |
3887 { | |
3888 int stat; | |
3889 int flags; | |
3890 int acces; | |
3891 unsigned short int dummy; | |
3892 item itemlst[3]; | |
3893 static int constant = ACL$C_FILE; | |
3894 DESCRIPTOR (path_desc, path); | |
3895 DESCRIPTOR (user_desc, user); | |
3896 | |
3897 flags = 0; | |
3898 acces = 0; | |
3899 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK)) | |
3900 return stat; | |
3901 if (mode & R_OK) | |
3902 acces |= CHP$M_READ; | |
3903 if (mode & W_OK) | |
3904 acces |= CHP$M_WRITE; | |
3905 itemlst[0].buflen = sizeof (int); | |
3906 itemlst[0].code = CHP$_FLAGS; | |
3907 itemlst[0].bufadr = (char *) &flags; | |
3908 itemlst[0].retlenadr = &dummy; | |
3909 itemlst[1].buflen = sizeof (int); | |
3910 itemlst[1].code = CHP$_ACCESS; | |
3911 itemlst[1].bufadr = (char *) &acces; | |
3912 itemlst[1].retlenadr = &dummy; | |
3913 itemlst[2].end = CHP$_END; | |
3914 stat = SYS$CHECK_ACCESS (&constant, &path_desc, &user_desc, itemlst); | |
3915 return stat == SS$_NORMAL ? 0 : -1; | |
3916 } | |
3917 } | |
3918 | |
3919 #else /* not VMS4_4 */ | |
3920 | |
3921 #include <prvdef.h> | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3922 #define ACE$M_WRITE 2 |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3923 #define ACE$C_KEYID 1 |
491 | 3924 |
3925 static unsigned short memid, grpid; | |
3926 static unsigned int uic; | |
3927 | |
3928 /* Called from init_sys_modes, so it happens not very often | |
3929 but at least each time Emacs is loaded. */ | |
21514 | 3930 void |
491 | 3931 sys_access_reinit () |
3932 { | |
3933 uic = 0; | |
3934 } | |
3935 | |
3936 int | |
3937 sys_access (filename, type) | |
3938 char * filename; | |
3939 int type; | |
3940 { | |
3941 struct FAB fab; | |
3942 struct XABPRO xab; | |
3943 int status, size, i, typecode, acl_controlled; | |
3944 unsigned int *aclptr, *aclend, aclbuf[60]; | |
3945 union prvdef prvmask; | |
3946 | |
3947 /* Get UIC and GRP values for protection checking. */ | |
3948 if (uic == 0) | |
3949 { | |
3950 status = LIB$GETJPI (&JPI$_UIC, 0, 0, &uic, 0, 0); | |
3951 if (! (status & 1)) | |
3952 return -1; | |
3953 memid = uic & 0xFFFF; | |
3954 grpid = uic >> 16; | |
3955 } | |
3956 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3957 if (type != 2) /* not checking write access */ |
491 | 3958 return access (filename, type); |
3959 | |
3960 /* Check write protection. */ | |
3961 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3962 #define CHECKPRIV(bit) (prvmask.bit) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3963 #define WRITABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) |
491 | 3964 |
3965 /* 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
|
3966 status = SYS$SETPRV (0, 0, 0, prvmask); |
491 | 3967 if (! (status & 1)) |
3968 error ("Unable to find privileges: %s", vmserrstr (status)); | |
3969 if (CHECKPRIV (PRV$V_BYPASS)) | |
3970 return 0; /* BYPASS enabled */ | |
3971 fab = cc$rms_fab; | |
3972 fab.fab$b_fac = FAB$M_GET; | |
3973 fab.fab$l_fna = filename; | |
3974 fab.fab$b_fns = strlen (filename); | |
3975 fab.fab$l_xab = &xab; | |
3976 xab = cc$rms_xabpro; | |
3977 xab.xab$l_aclbuf = aclbuf; | |
3978 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
|
3979 status = SYS$OPEN (&fab, 0, 0); |
491 | 3980 if (! (status & 1)) |
3981 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
|
3982 SYS$CLOSE (&fab, 0, 0); |
491 | 3983 /* Check system access */ |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3984 if (CHECKPRIV (PRV$V_SYSPRV) && WRITABLE (XAB$V_SYS)) |
491 | 3985 return 0; |
3986 /* Check ACL entries, if any */ | |
3987 acl_controlled = 0; | |
3988 if (xab.xab$w_acllen > 0) | |
3989 { | |
3990 aclptr = aclbuf; | |
3991 aclend = &aclbuf[xab.xab$w_acllen / 4]; | |
3992 while (*aclptr && aclptr < aclend) | |
3993 { | |
3994 size = (*aclptr & 0xff) / 4; | |
3995 typecode = (*aclptr >> 8) & 0xff; | |
3996 if (typecode == ACE$C_KEYID) | |
3997 for (i = size - 1; i > 1; i--) | |
3998 if (aclptr[i] == uic) | |
3999 { | |
4000 acl_controlled = 1; | |
4001 if (aclptr[1] & ACE$M_WRITE) | |
4002 return 0; /* Write access through ACL */ | |
4003 } | |
4004 aclptr = &aclptr[size]; | |
4005 } | |
4006 if (acl_controlled) /* ACL specified, prohibits write access */ | |
4007 return -1; | |
4008 } | |
4009 /* No ACL entries specified, check normal protection */ | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4010 if (WRITABLE (XAB$V_WLD)) /* World writable */ |
491 | 4011 return 0; |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4012 if (WRITABLE (XAB$V_GRP) && |
491 | 4013 (unsigned short) (xab.xab$l_uic >> 16) == grpid) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4014 return 0; /* Group writable */ |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4015 if (WRITABLE (XAB$V_OWN) && |
491 | 4016 (xab.xab$l_uic & 0xFFFF) == memid) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4017 return 0; /* Owner writable */ |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4018 |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4019 return -1; /* Not writable */ |
491 | 4020 } |
4021 #endif /* not VMS4_4 */ | |
4022 #endif /* access */ | |
4023 | |
4024 static char vtbuf[NAM$C_MAXRSS+1]; | |
4025 | |
4026 /* translate a vms file spec to a unix path */ | |
4027 char * | |
4028 sys_translate_vms (vfile) | |
4029 char * vfile; | |
4030 { | |
4031 char * p; | |
4032 char * targ; | |
4033 | |
4034 if (!vfile) | |
4035 return 0; | |
4036 | |
4037 targ = vtbuf; | |
4038 | |
4039 /* leading device or logical name is a root directory */ | |
4040 if (p = strchr (vfile, ':')) | |
4041 { | |
4042 *targ++ = '/'; | |
4043 while (vfile < p) | |
4044 *targ++ = *vfile++; | |
4045 vfile++; | |
4046 *targ++ = '/'; | |
4047 } | |
4048 p = vfile; | |
4049 if (*p == '[' || *p == '<') | |
4050 { | |
4051 while (*++vfile != *p + 2) | |
4052 switch (*vfile) | |
4053 { | |
4054 case '.': | |
4055 if (vfile[-1] == *p) | |
4056 *targ++ = '.'; | |
4057 *targ++ = '/'; | |
4058 break; | |
4059 | |
4060 case '-': | |
4061 *targ++ = '.'; | |
4062 *targ++ = '.'; | |
4063 break; | |
4064 | |
4065 default: | |
4066 *targ++ = *vfile; | |
4067 break; | |
4068 } | |
4069 vfile++; | |
4070 *targ++ = '/'; | |
4071 } | |
4072 while (*vfile) | |
4073 *targ++ = *vfile++; | |
4074 | |
4075 return vtbuf; | |
4076 } | |
4077 | |
4078 static char utbuf[NAM$C_MAXRSS+1]; | |
4079 | |
4080 /* translate a unix path to a VMS file spec */ | |
4081 char * | |
4082 sys_translate_unix (ufile) | |
4083 char * ufile; | |
4084 { | |
4085 int slash_seen = 0; | |
4086 char *p; | |
4087 char * targ; | |
4088 | |
4089 if (!ufile) | |
4090 return 0; | |
4091 | |
4092 targ = utbuf; | |
4093 | |
4094 if (*ufile == '/') | |
4095 { | |
4096 ufile++; | |
4097 } | |
4098 | |
4099 while (*ufile) | |
4100 { | |
4101 switch (*ufile) | |
4102 { | |
4103 case '/': | |
4104 if (slash_seen) | |
4105 if (index (&ufile[1], '/')) | |
4106 *targ++ = '.'; | |
4107 else | |
4108 *targ++ = ']'; | |
4109 else | |
4110 { | |
4111 *targ++ = ':'; | |
4112 if (index (&ufile[1], '/')) | |
4113 *targ++ = '['; | |
4114 slash_seen = 1; | |
4115 } | |
4116 break; | |
4117 | |
4118 case '.': | |
4119 if (strncmp (ufile, "./", 2) == 0) | |
4120 { | |
4121 if (!slash_seen) | |
4122 { | |
4123 *targ++ = '['; | |
4124 slash_seen = 1; | |
4125 } | |
4126 ufile++; /* skip the dot */ | |
4127 if (index (&ufile[1], '/')) | |
4128 *targ++ = '.'; | |
4129 else | |
4130 *targ++ = ']'; | |
4131 } | |
4132 else if (strncmp (ufile, "../", 3) == 0) | |
4133 { | |
4134 if (!slash_seen) | |
4135 { | |
4136 *targ++ = '['; | |
4137 slash_seen = 1; | |
4138 } | |
4139 *targ++ = '-'; | |
4140 ufile += 2; /* skip the dots */ | |
4141 if (index (&ufile[1], '/')) | |
4142 *targ++ = '.'; | |
4143 else | |
4144 *targ++ = ']'; | |
4145 } | |
4146 else | |
4147 *targ++ = *ufile; | |
4148 break; | |
4149 | |
4150 default: | |
4151 *targ++ = *ufile; | |
4152 break; | |
4153 } | |
4154 ufile++; | |
4155 } | |
4156 *targ = '\0'; | |
4157 | |
4158 return utbuf; | |
4159 } | |
4160 | |
4161 char * | |
4162 getwd (pathname) | |
4163 char *pathname; | |
4164 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4165 char *ptr, *val; |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4166 extern char *getcwd (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4167 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4168 #define MAXPATHLEN 1024 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4169 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
4170 ptr = xmalloc (MAXPATHLEN); |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4171 val = getcwd (ptr, MAXPATHLEN); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4172 if (val == 0) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4173 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4174 xfree (ptr); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4175 return val; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4176 } |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4177 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
|
4178 xfree (ptr); |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4179 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4180 return pathname; |
491 | 4181 } |
4182 | |
21514 | 4183 int |
491 | 4184 getppid () |
4185 { | |
4186 long item_code = JPI$_OWNER; | |
4187 unsigned long parent_id; | |
4188 int status; | |
4189 | |
4190 if (((status = LIB$GETJPI (&item_code, 0, 0, &parent_id)) & 1) == 0) | |
4191 { | |
4192 errno = EVMSERR; | |
4193 vaxc$errno = status; | |
4194 return -1; | |
4195 } | |
4196 return parent_id; | |
4197 } | |
4198 | |
4199 #undef getuid | |
4200 unsigned | |
4201 sys_getuid () | |
4202 { | |
4203 return (getgid () << 16) | getuid (); | |
4204 } | |
4205 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
4206 #undef read |
491 | 4207 int |
4208 sys_read (fildes, buf, nbyte) | |
4209 int fildes; | |
4210 char *buf; | |
4211 unsigned int nbyte; | |
4212 { | |
4213 return read (fildes, buf, (nbyte < MAXIOSIZE ? nbyte : MAXIOSIZE)); | |
4214 } | |
4215 | |
4216 #if 0 | |
4217 int | |
4218 sys_write (fildes, buf, nbyte) | |
4219 int fildes; | |
4220 char *buf; | |
4221 unsigned int nbyte; | |
4222 { | |
4223 register int nwrote, rtnval = 0; | |
4224 | |
4225 while (nbyte > MAXIOSIZE && (nwrote = write (fildes, buf, MAXIOSIZE)) > 0) { | |
4226 nbyte -= nwrote; | |
4227 buf += nwrote; | |
4228 rtnval += nwrote; | |
4229 } | |
4230 if (nwrote < 0) | |
4231 return rtnval ? rtnval : -1; | |
4232 if ((nwrote = write (fildes, buf, nbyte)) < 0) | |
4233 return rtnval ? rtnval : -1; | |
4234 return (rtnval + nwrote); | |
4235 } | |
4236 #endif /* 0 */ | |
4237 | |
4238 /* | |
4239 * VAX/VMS VAX C RTL really loses. It insists that records | |
4240 * end with a newline (carriage return) character, and if they | |
4241 * don't it adds one (nice of it isn't it!) | |
4242 * | |
4243 * Thus we do this stupidity below. | |
4244 */ | |
4245 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
4246 #undef write |
491 | 4247 int |
4248 sys_write (fildes, buf, nbytes) | |
4249 int fildes; | |
4250 char *buf; | |
4251 unsigned int nbytes; | |
4252 { | |
4253 register char *p; | |
4254 register char *e; | |
525 | 4255 int sum = 0; |
4256 struct stat st; | |
4257 | |
4258 fstat (fildes, &st); | |
491 | 4259 p = buf; |
4260 while (nbytes > 0) | |
4261 { | |
525 | 4262 int len, retval; |
4263 | |
4264 /* Handle fixed-length files with carriage control. */ | |
4265 if (st.st_fab_rfm == FAB$C_FIX | |
4266 && ((st.st_fab_rat & (FAB$M_FTN | FAB$M_CR)) != 0)) | |
4267 { | |
4268 len = st.st_fab_mrs; | |
4269 retval = write (fildes, p, min (len, nbytes)); | |
4270 if (retval != len) | |
4271 return -1; | |
4272 retval++; /* This skips the implied carriage control */ | |
4273 } | |
4274 else | |
4275 { | |
4276 e = p + min (MAXIOSIZE, nbytes) - 1; | |
4277 while (*e != '\n' && e > p) e--; | |
4278 if (p == e) /* Ok.. so here we add a newline... sigh. */ | |
4279 e = p + min (MAXIOSIZE, nbytes) - 1; | |
4280 len = e + 1 - p; | |
4281 retval = write (fildes, p, len); | |
4282 if (retval != len) | |
4283 return -1; | |
4284 } | |
4285 p += retval; | |
4286 sum += retval; | |
491 | 4287 nbytes -= retval; |
4288 } | |
4289 return sum; | |
4290 } | |
4291 | |
4292 /* Create file NEW copying its attributes from file OLD. If | |
4293 OLD is 0 or does not exist, create based on the value of | |
4294 vms_stmlf_recfm. */ | |
4295 | |
4296 /* Protection value the file should ultimately have. | |
4297 Set by create_copy_attrs, and use by rename_sansversions. */ | |
4298 static unsigned short int fab_final_pro; | |
4299 | |
4300 int | |
4301 creat_copy_attrs (old, new) | |
4302 char *old, *new; | |
4303 { | |
4304 struct FAB fab = cc$rms_fab; | |
4305 struct XABPRO xabpro; | |
4306 char aclbuf[256]; /* Choice of size is arbitrary. See below. */ | |
4307 extern int vms_stmlf_recfm; | |
4308 | |
4309 if (old) | |
4310 { | |
4311 fab.fab$b_fac = FAB$M_GET; | |
4312 fab.fab$l_fna = old; | |
4313 fab.fab$b_fns = strlen (old); | |
4314 fab.fab$l_xab = (char *) &xabpro; | |
4315 xabpro = cc$rms_xabpro; | |
4316 xabpro.xab$l_aclbuf = aclbuf; | |
4317 xabpro.xab$w_aclsiz = sizeof aclbuf; | |
4318 /* 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
|
4319 if (SYS$OPEN (&fab, 0, 0) & 1) |
491 | 4320 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4321 SYS$CLOSE (&fab, 0, 0); |
491 | 4322 fab.fab$l_alq = 0; /* zero the allocation quantity */ |
4323 if (xabpro.xab$w_acllen > 0) | |
4324 { | |
4325 if (xabpro.xab$w_acllen > sizeof aclbuf) | |
4326 /* If the acl buffer was too short, redo open with longer one. | |
4327 Wouldn't need to do this if there were some system imposed | |
4328 limit on the size of an ACL, but I can't find any such. */ | |
4329 { | |
4330 xabpro.xab$l_aclbuf = (char *) alloca (xabpro.xab$w_acllen); | |
4331 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
|
4332 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
|
4333 SYS$CLOSE (&fab, 0, 0); |
491 | 4334 else |
4335 old = 0; | |
4336 } | |
4337 } | |
4338 else | |
4339 xabpro.xab$l_aclbuf = 0; | |
4340 } | |
4341 else | |
4342 old = 0; | |
4343 } | |
4344 fab.fab$l_fna = new; | |
4345 fab.fab$b_fns = strlen (new); | |
4346 if (!old) | |
4347 { | |
4348 fab.fab$l_xab = 0; | |
4349 fab.fab$b_rfm = vms_stmlf_recfm ? FAB$C_STMLF : FAB$C_VAR; | |
4350 fab.fab$b_rat = FAB$M_CR; | |
4351 } | |
4352 | |
4353 /* Set the file protections such that we will be able to manipulate | |
4354 this file. Once we are done writing and renaming it, we will set | |
4355 the protections back. */ | |
4356 if (old) | |
4357 fab_final_pro = xabpro.xab$w_pro; | |
4358 else | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4359 SYS$SETDFPROT (0, &fab_final_pro); |
491 | 4360 xabpro.xab$w_pro &= 0xff0f; /* set O:rewd for now. This is set back later. */ |
4361 | |
4362 /* Create the new file with either default attrs or attrs copied | |
4363 from old file. */ | |
4364 if (!(SYS$CREATE (&fab, 0, 0) & 1)) | |
4365 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
|
4366 SYS$CLOSE (&fab, 0, 0); |
491 | 4367 /* As this is a "replacement" for creat, return a file descriptor |
4368 opened for writing. */ | |
4369 return open (new, O_WRONLY); | |
4370 } | |
4371 | |
4372 #ifdef creat | |
4373 #undef creat | |
4374 #include <varargs.h> | |
4375 #ifdef __GNUC__ | |
4376 #ifndef va_count | |
4377 #define va_count(X) ((X) = *(((int *) &(va_alist)) - 1)) | |
4378 #endif | |
4379 #endif | |
4380 | |
21514 | 4381 int |
491 | 4382 sys_creat (va_alist) |
4383 va_dcl | |
4384 { | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4385 va_list list_incrementer; |
491 | 4386 char *name; |
4387 int mode; | |
4388 int rfd; /* related file descriptor */ | |
4389 int fd; /* Our new file descriptor */ | |
4390 int count; | |
4391 struct stat st_buf; | |
4392 char rfm[12]; | |
4393 char rat[15]; | |
4394 char mrs[13]; | |
4395 char fsz[13]; | |
4396 extern int vms_stmlf_recfm; | |
4397 | |
4398 va_count (count); | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4399 va_start (list_incrementer); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4400 name = va_arg (list_incrementer, char *); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4401 mode = va_arg (list_incrementer, int); |
491 | 4402 if (count > 2) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4403 rfd = va_arg (list_incrementer, int); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4404 va_end (list_incrementer); |
491 | 4405 if (count > 2) |
4406 { | |
4407 /* Use information from the related file descriptor to set record | |
4408 format of the newly created file. */ | |
4409 fstat (rfd, &st_buf); | |
4410 switch (st_buf.st_fab_rfm) | |
4411 { | |
4412 case FAB$C_FIX: | |
4413 strcpy (rfm, "rfm = fix"); | |
4414 sprintf (mrs, "mrs = %d", st_buf.st_fab_mrs); | |
4415 strcpy (rat, "rat = "); | |
4416 if (st_buf.st_fab_rat & FAB$M_CR) | |
4417 strcat (rat, "cr"); | |
4418 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4419 strcat (rat, "ftn"); | |
4420 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4421 strcat (rat, "prn"); | |
4422 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4423 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4424 strcat (rat, ", blk"); | |
4425 else | |
4426 strcat (rat, "blk"); | |
4427 return creat (name, 0, rfm, rat, mrs); | |
4428 | |
4429 case FAB$C_VFC: | |
4430 strcpy (rfm, "rfm = vfc"); | |
4431 sprintf (fsz, "fsz = %d", st_buf.st_fab_fsz); | |
4432 strcpy (rat, "rat = "); | |
4433 if (st_buf.st_fab_rat & FAB$M_CR) | |
4434 strcat (rat, "cr"); | |
4435 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4436 strcat (rat, "ftn"); | |
4437 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4438 strcat (rat, "prn"); | |
4439 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4440 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4441 strcat (rat, ", blk"); | |
4442 else | |
4443 strcat (rat, "blk"); | |
4444 return creat (name, 0, rfm, rat, fsz); | |
4445 | |
4446 case FAB$C_STM: | |
4447 strcpy (rfm, "rfm = stm"); | |
4448 break; | |
4449 | |
4450 case FAB$C_STMCR: | |
4451 strcpy (rfm, "rfm = stmcr"); | |
4452 break; | |
4453 | |
4454 case FAB$C_STMLF: | |
4455 strcpy (rfm, "rfm = stmlf"); | |
4456 break; | |
4457 | |
4458 case FAB$C_UDF: | |
4459 strcpy (rfm, "rfm = udf"); | |
4460 break; | |
4461 | |
4462 case FAB$C_VAR: | |
4463 strcpy (rfm, "rfm = var"); | |
4464 break; | |
4465 } | |
4466 strcpy (rat, "rat = "); | |
4467 if (st_buf.st_fab_rat & FAB$M_CR) | |
4468 strcat (rat, "cr"); | |
4469 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4470 strcat (rat, "ftn"); | |
4471 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4472 strcat (rat, "prn"); | |
4473 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4474 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4475 strcat (rat, ", blk"); | |
4476 else | |
4477 strcat (rat, "blk"); | |
4478 } | |
4479 else | |
4480 { | |
4481 strcpy (rfm, vms_stmlf_recfm ? "rfm = stmlf" : "rfm=var"); | |
4482 strcpy (rat, "rat=cr"); | |
4483 } | |
4484 /* Until the VAX C RTL fixes the many bugs with modes, always use | |
4485 mode 0 to get the user's default protection. */ | |
4486 fd = creat (name, 0, rfm, rat); | |
4487 if (fd < 0 && errno == EEXIST) | |
4488 { | |
4489 if (unlink (name) < 0) | |
4490 report_file_error ("delete", build_string (name)); | |
4491 fd = creat (name, 0, rfm, rat); | |
4492 } | |
4493 return fd; | |
4494 } | |
4495 #endif /* creat */ | |
4496 | |
4497 /* fwrite to stdout is S L O W. Speed it up by using fputc...*/ | |
21514 | 4498 int |
491 | 4499 sys_fwrite (ptr, size, num, fp) |
4500 register char * ptr; | |
4501 FILE * fp; | |
4502 { | |
4503 register int tot = num * size; | |
4504 | |
4505 while (tot--) | |
4506 fputc (*ptr++, fp); | |
21514 | 4507 return num; |
491 | 4508 } |
4509 | |
4510 /* | |
4511 * The VMS C library routine creat actually creates a new version of an | |
4512 * existing file rather than truncating the old version. There are times | |
4513 * when this is not the desired behavior, for instance, when writing an | |
4514 * auto save file (you only want one version), or when you don't have | |
4515 * write permission in the directory containing the file (but the file | |
4516 * itself is writable). Hence this routine, which is equivalent to | |
4517 * "close (creat (fn, 0));" on Unix if fn already exists. | |
4518 */ | |
4519 int | |
4520 vms_truncate (fn) | |
4521 char *fn; | |
4522 { | |
4523 struct FAB xfab = cc$rms_fab; | |
4524 struct RAB xrab = cc$rms_rab; | |
4525 int status; | |
4526 | |
4527 xfab.fab$l_fop = FAB$M_TEF; /* free allocated but unused blocks on close */ | |
4528 xfab.fab$b_fac = FAB$M_TRN | FAB$M_GET; /* allow truncate and get access */ | |
4529 xfab.fab$b_shr = FAB$M_NIL; /* allow no sharing - file must be locked */ | |
4530 xfab.fab$l_fna = fn; | |
4531 xfab.fab$b_fns = strlen (fn); | |
4532 xfab.fab$l_dna = ";0"; /* default to latest version of the file */ | |
4533 xfab.fab$b_dns = 2; | |
4534 xrab.rab$l_fab = &xfab; | |
4535 | |
4536 /* This gibberish opens the file, positions to the first record, and | |
4537 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
|
4538 if ((SYS$OPEN (&xfab) & 01) == 01) |
491 | 4539 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4540 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
|
4541 (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
|
4542 (SYS$TRUNCATE (&xrab) & 01) == 01) |
491 | 4543 status = 0; |
4544 else | |
4545 status = -1; | |
4546 } | |
4547 else | |
4548 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
|
4549 SYS$CLOSE (&xfab); |
491 | 4550 return status; |
4551 } | |
4552 | |
4553 /* Define this symbol to actually read SYSUAF.DAT. This requires either | |
4554 SYSPRV or a readable SYSUAF.DAT. */ | |
4555 | |
4556 #ifdef READ_SYSUAF | |
4557 /* | |
4558 * getuaf.c | |
4559 * | |
4560 * Routine to read the VMS User Authorization File and return | |
4561 * a specific user's record. | |
4562 */ | |
4563 | |
4564 static struct UAF retuaf; | |
4565 | |
4566 struct UAF * | |
4567 get_uaf_name (uname) | |
4568 char * uname; | |
4569 { | |
4570 register status; | |
4571 struct FAB uaf_fab; | |
4572 struct RAB uaf_rab; | |
4573 | |
4574 uaf_fab = cc$rms_fab; | |
4575 uaf_rab = cc$rms_rab; | |
4576 /* initialize fab fields */ | |
4577 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
4578 uaf_fab.fab$b_fns = 21; | |
4579 uaf_fab.fab$b_fac = FAB$M_GET; | |
4580 uaf_fab.fab$b_org = FAB$C_IDX; | |
4581 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
4582 /* initialize rab fields */ | |
4583 uaf_rab.rab$l_fab = &uaf_fab; | |
4584 /* 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
|
4585 status = SYS$OPEN (&uaf_fab); |
491 | 4586 if (!(status&1)) |
4587 { | |
4588 errno = EVMSERR; | |
4589 vaxc$errno = status; | |
4590 return 0; | |
4591 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4592 status = SYS$CONNECT (&uaf_rab); |
491 | 4593 if (!(status&1)) |
4594 { | |
4595 errno = EVMSERR; | |
4596 vaxc$errno = status; | |
4597 return 0; | |
4598 } | |
4599 /* read the requested record - index is in uname */ | |
4600 uaf_rab.rab$l_kbf = uname; | |
4601 uaf_rab.rab$b_ksz = strlen (uname); | |
4602 uaf_rab.rab$b_rac = RAB$C_KEY; | |
4603 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
4604 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
|
4605 status = SYS$GET (&uaf_rab); |
491 | 4606 if (!(status&1)) |
4607 { | |
4608 errno = EVMSERR; | |
4609 vaxc$errno = status; | |
4610 return 0; | |
4611 } | |
4612 /* 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
|
4613 status = SYS$DISCONNECT (&uaf_rab); |
491 | 4614 if (!(status&1)) |
4615 { | |
4616 errno = EVMSERR; | |
4617 vaxc$errno = status; | |
4618 return 0; | |
4619 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4620 status = SYS$CLOSE (&uaf_fab); |
491 | 4621 if (!(status&1)) |
4622 { | |
4623 errno = EVMSERR; | |
4624 vaxc$errno = status; | |
4625 return 0; | |
4626 } | |
4627 return &retuaf; | |
4628 } | |
4629 | |
4630 struct UAF * | |
4631 get_uaf_uic (uic) | |
4632 unsigned long uic; | |
4633 { | |
4634 register status; | |
4635 struct FAB uaf_fab; | |
4636 struct RAB uaf_rab; | |
4637 | |
4638 uaf_fab = cc$rms_fab; | |
4639 uaf_rab = cc$rms_rab; | |
4640 /* initialize fab fields */ | |
4641 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
4642 uaf_fab.fab$b_fns = 21; | |
4643 uaf_fab.fab$b_fac = FAB$M_GET; | |
4644 uaf_fab.fab$b_org = FAB$C_IDX; | |
4645 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
4646 /* initialize rab fields */ | |
4647 uaf_rab.rab$l_fab = &uaf_fab; | |
4648 /* 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
|
4649 status = SYS$OPEN (&uaf_fab); |
491 | 4650 if (!(status&1)) |
4651 { | |
4652 errno = EVMSERR; | |
4653 vaxc$errno = status; | |
4654 return 0; | |
4655 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4656 status = SYS$CONNECT (&uaf_rab); |
491 | 4657 if (!(status&1)) |
4658 { | |
4659 errno = EVMSERR; | |
4660 vaxc$errno = status; | |
4661 return 0; | |
4662 } | |
4663 /* read the requested record - index is in uic */ | |
4664 uaf_rab.rab$b_krf = 1; /* 1st alternate key */ | |
4665 uaf_rab.rab$l_kbf = (char *) &uic; | |
4666 uaf_rab.rab$b_ksz = sizeof uic; | |
4667 uaf_rab.rab$b_rac = RAB$C_KEY; | |
4668 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
4669 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
|
4670 status = SYS$GET (&uaf_rab); |
491 | 4671 if (!(status&1)) |
4672 { | |
4673 errno = EVMSERR; | |
4674 vaxc$errno = status; | |
4675 return 0; | |
4676 } | |
4677 /* 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
|
4678 status = SYS$DISCONNECT (&uaf_rab); |
491 | 4679 if (!(status&1)) |
4680 { | |
4681 errno = EVMSERR; | |
4682 vaxc$errno = status; | |
4683 return 0; | |
4684 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4685 status = SYS$CLOSE (&uaf_fab); |
491 | 4686 if (!(status&1)) |
4687 { | |
4688 errno = EVMSERR; | |
4689 vaxc$errno = status; | |
4690 return 0; | |
4691 } | |
4692 return &retuaf; | |
4693 } | |
4694 | |
4695 static struct passwd retpw; | |
4696 | |
4697 struct passwd * | |
4698 cnv_uaf_pw (up) | |
4699 struct UAF * up; | |
4700 { | |
4701 char * ptr; | |
4702 | |
4703 /* copy these out first because if the username is 32 chars, the next | |
4704 section will overwrite the first byte of the UIC */ | |
4705 retpw.pw_uid = up->uaf$w_mem; | |
4706 retpw.pw_gid = up->uaf$w_grp; | |
4707 | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4708 /* I suppose this is not the best style, to possibly overwrite one |
491 | 4709 byte beyond the end of the field, but what the heck... */ |
4710 ptr = &up->uaf$t_username[UAF$S_USERNAME]; | |
4711 while (ptr[-1] == ' ') | |
4712 ptr--; | |
4713 *ptr = '\0'; | |
4714 strcpy (retpw.pw_name, up->uaf$t_username); | |
4715 | |
4716 /* the rest of these are counted ascii strings */ | |
4717 strncpy (retpw.pw_gecos, &up->uaf$t_owner[1], up->uaf$t_owner[0]); | |
4718 retpw.pw_gecos[up->uaf$t_owner[0]] = '\0'; | |
4719 strncpy (retpw.pw_dir, &up->uaf$t_defdev[1], up->uaf$t_defdev[0]); | |
4720 retpw.pw_dir[up->uaf$t_defdev[0]] = '\0'; | |
4721 strncat (retpw.pw_dir, &up->uaf$t_defdir[1], up->uaf$t_defdir[0]); | |
4722 retpw.pw_dir[up->uaf$t_defdev[0] + up->uaf$t_defdir[0]] = '\0'; | |
4723 strncpy (retpw.pw_shell, &up->uaf$t_defcli[1], up->uaf$t_defcli[0]); | |
4724 retpw.pw_shell[up->uaf$t_defcli[0]] = '\0'; | |
4725 | |
4726 return &retpw; | |
4727 } | |
4728 #else /* not READ_SYSUAF */ | |
4729 static struct passwd retpw; | |
4730 #endif /* not READ_SYSUAF */ | |
4731 | |
4732 struct passwd * | |
4733 getpwnam (name) | |
4734 char * name; | |
4735 { | |
4736 #ifdef READ_SYSUAF | |
4737 struct UAF *up; | |
4738 #else | |
4739 char * user; | |
4740 char * dir; | |
4741 unsigned char * full; | |
4742 #endif /* READ_SYSUAF */ | |
4743 char *ptr = name; | |
4744 | |
4745 while (*ptr) | |
4746 { | |
4747 if ('a' <= *ptr && *ptr <= 'z') | |
4748 *ptr -= 040; | |
4749 ptr++; | |
4750 } | |
4751 #ifdef READ_SYSUAF | |
4752 if (!(up = get_uaf_name (name))) | |
4753 return 0; | |
4754 return cnv_uaf_pw (up); | |
4755 #else | |
4756 if (strcmp (name, getenv ("USER")) == 0) | |
4757 { | |
4758 retpw.pw_uid = getuid (); | |
4759 retpw.pw_gid = getgid (); | |
4760 strcpy (retpw.pw_name, name); | |
4761 if (full = egetenv ("FULLNAME")) | |
4762 strcpy (retpw.pw_gecos, full); | |
4763 else | |
4764 *retpw.pw_gecos = '\0'; | |
4765 strcpy (retpw.pw_dir, egetenv ("HOME")); | |
4766 *retpw.pw_shell = '\0'; | |
4767 return &retpw; | |
4768 } | |
4769 else | |
4770 return 0; | |
4771 #endif /* not READ_SYSUAF */ | |
4772 } | |
4773 | |
4774 struct passwd * | |
4775 getpwuid (uid) | |
4776 unsigned long uid; | |
4777 { | |
4778 #ifdef READ_SYSUAF | |
4779 struct UAF * up; | |
4780 | |
4781 if (!(up = get_uaf_uic (uid))) | |
4782 return 0; | |
4783 return cnv_uaf_pw (up); | |
4784 #else | |
4785 if (uid == sys_getuid ()) | |
4786 return getpwnam (egetenv ("USER")); | |
4787 else | |
4788 return 0; | |
4789 #endif /* not READ_SYSUAF */ | |
4790 } | |
4791 | |
4792 /* return total address space available to the current process. This is | |
4793 the sum of the current p0 size, p1 size and free page table entries | |
4794 available. */ | |
21514 | 4795 int |
491 | 4796 vlimit () |
4797 { | |
4798 int item_code; | |
4799 unsigned long free_pages; | |
4800 unsigned long frep0va; | |
4801 unsigned long frep1va; | |
4802 register status; | |
4803 | |
4804 item_code = JPI$_FREPTECNT; | |
4805 if (((status = LIB$GETJPI (&item_code, 0, 0, &free_pages)) & 1) == 0) | |
4806 { | |
4807 errno = EVMSERR; | |
4808 vaxc$errno = status; | |
4809 return -1; | |
4810 } | |
4811 free_pages *= 512; | |
4812 | |
4813 item_code = JPI$_FREP0VA; | |
4814 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep0va)) & 1) == 0) | |
4815 { | |
4816 errno = EVMSERR; | |
4817 vaxc$errno = status; | |
4818 return -1; | |
4819 } | |
4820 item_code = JPI$_FREP1VA; | |
4821 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep1va)) & 1) == 0) | |
4822 { | |
4823 errno = EVMSERR; | |
4824 vaxc$errno = status; | |
4825 return -1; | |
4826 } | |
4827 | |
4828 return free_pages + frep0va + (0x7fffffff - frep1va); | |
4829 } | |
4830 | |
21514 | 4831 int |
491 | 4832 define_logical_name (varname, string) |
4833 char *varname; | |
4834 char *string; | |
4835 { | |
4836 struct dsc$descriptor_s strdsc = | |
4837 {strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string}; | |
4838 struct dsc$descriptor_s envdsc = | |
4839 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
4840 struct dsc$descriptor_s lnmdsc = | |
4841 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
4842 | |
4843 return LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0); | |
4844 } | |
4845 | |
21514 | 4846 int |
491 | 4847 delete_logical_name (varname) |
4848 char *varname; | |
4849 { | |
4850 struct dsc$descriptor_s envdsc = | |
4851 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
4852 struct dsc$descriptor_s lnmdsc = | |
4853 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
4854 | |
4855 return LIB$DELETE_LOGICAL (&envdsc, &lnmdsc); | |
4856 } | |
4857 | |
21514 | 4858 int |
491 | 4859 ulimit () |
21514 | 4860 { |
4861 return 0; | |
4862 } | |
4863 | |
4864 int | |
491 | 4865 setpgrp () |
21514 | 4866 { |
4867 return 0; | |
4868 } | |
4869 | |
4870 int | |
491 | 4871 execvp () |
4872 { | |
4873 error ("execvp system call not implemented"); | |
21514 | 4874 return -1; |
491 | 4875 } |
4876 | |
4877 int | |
4878 rename (from, to) | |
4879 char *from, *to; | |
4880 { | |
4881 int status; | |
4882 struct FAB from_fab = cc$rms_fab, to_fab = cc$rms_fab; | |
4883 struct NAM from_nam = cc$rms_nam, to_nam = cc$rms_nam; | |
4884 char from_esn[NAM$C_MAXRSS]; | |
4885 char to_esn[NAM$C_MAXRSS]; | |
4886 | |
4887 from_fab.fab$l_fna = from; | |
4888 from_fab.fab$b_fns = strlen (from); | |
4889 from_fab.fab$l_nam = &from_nam; | |
4890 from_fab.fab$l_fop = FAB$M_NAM; | |
4891 | |
4892 from_nam.nam$l_esa = from_esn; | |
4893 from_nam.nam$b_ess = sizeof from_esn; | |
4894 | |
4895 to_fab.fab$l_fna = to; | |
4896 to_fab.fab$b_fns = strlen (to); | |
4897 to_fab.fab$l_nam = &to_nam; | |
4898 to_fab.fab$l_fop = FAB$M_NAM; | |
4899 | |
4900 to_nam.nam$l_esa = to_esn; | |
4901 to_nam.nam$b_ess = sizeof to_esn; | |
4902 | |
4903 status = SYS$RENAME (&from_fab, 0, 0, &to_fab); | |
4904 | |
4905 if (status & 1) | |
4906 return 0; | |
4907 else | |
4908 { | |
4909 if (status == RMS$_DEV) | |
4910 errno = EXDEV; | |
4911 else | |
4912 errno = EVMSERR; | |
4913 vaxc$errno = status; | |
4914 return -1; | |
4915 } | |
4916 } | |
4917 | |
4918 /* This function renames a file like `rename', but it strips | |
4919 the version number from the "to" filename, such that the "to" file is | |
4920 will always be a new version. It also sets the file protection once it is | |
4921 finished. The protection that we will use is stored in fab_final_pro, | |
4922 and was set when we did a creat_copy_attrs to create the file that we | |
4923 are renaming. | |
4924 | |
4925 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
|
4926 to describe the protection, and VMS uses 4 (write and delete are separate |
491 | 4927 bits). To maintain portability, the VMS implementation of `chmod' wires |
4928 the W and D bits together. */ | |
4929 | |
4930 | |
4931 static struct fibdef fib; /* We need this initialized to zero */ | |
4932 char vms_file_written[NAM$C_MAXRSS]; | |
4933 | |
4934 int | |
4935 rename_sans_version (from,to) | |
4936 char *from, *to; | |
4937 { | |
4938 short int chan; | |
4939 int stat; | |
4940 short int iosb[4]; | |
4941 int status; | |
4942 struct FAB to_fab = cc$rms_fab; | |
4943 struct NAM to_nam = cc$rms_nam; | |
4944 struct dsc$descriptor fib_d ={sizeof (fib),0,0,(char*) &fib}; | |
4945 struct dsc$descriptor fib_attr[2] | |
4946 = {{sizeof (fab_final_pro),ATR$C_FPRO,0,(char*) &fab_final_pro},{0,0,0,0}}; | |
4947 char to_esn[NAM$C_MAXRSS]; | |
4948 | |
4949 $DESCRIPTOR (disk,to_esn); | |
4950 | |
4951 to_fab.fab$l_fna = to; | |
4952 to_fab.fab$b_fns = strlen (to); | |
4953 to_fab.fab$l_nam = &to_nam; | |
4954 to_fab.fab$l_fop = FAB$M_NAM; | |
4955 | |
4956 to_nam.nam$l_esa = to_esn; | |
4957 to_nam.nam$b_ess = sizeof to_esn; | |
4958 | |
4959 status = SYS$PARSE (&to_fab, 0, 0); /* figure out the full file name */ | |
4960 | |
4961 if (to_nam.nam$l_fnb && NAM$M_EXP_VER) | |
4962 *(to_nam.nam$l_ver) = '\0'; | |
4963 | |
4964 stat = rename (from, to_esn); | |
4965 if (stat < 0) | |
4966 return stat; | |
4967 | |
4968 strcpy (vms_file_written, to_esn); | |
4969 | |
4970 to_fab.fab$l_fna = vms_file_written; /* this points to the versionless name */ | |
4971 to_fab.fab$b_fns = strlen (vms_file_written); | |
4972 | |
4973 /* 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
|
4974 SYS$OPEN (&to_fab, 0, 0); /* This fills in the nam$w_fid fields */ |
491 | 4975 |
4976 /* Copy these fields into the fib */ | |
4977 fib.fib$r_fid_overlay.fib$w_fid[0] = to_nam.nam$w_fid[0]; | |
4978 fib.fib$r_fid_overlay.fib$w_fid[1] = to_nam.nam$w_fid[1]; | |
4979 fib.fib$r_fid_overlay.fib$w_fid[2] = to_nam.nam$w_fid[2]; | |
4980 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4981 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
|
4982 |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4983 stat = SYS$ASSIGN (&disk, &chan, 0, 0); /* open a channel to the disk */ |
491 | 4984 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
|
4985 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
|
4986 stat = SYS$QIOW (0, chan, IO$_MODIFY, iosb, 0, 0, &fib_d, |
491 | 4987 0, 0, 0, &fib_attr, 0); |
4988 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
|
4989 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
|
4990 stat = SYS$DASSGN (chan); |
491 | 4991 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
|
4992 LIB$SIGNAL (stat); |
766 | 4993 strcpy (vms_file_written, to_esn); /* We will write this to the terminal*/ |
491 | 4994 return 0; |
4995 } | |
4996 | |
21514 | 4997 int |
491 | 4998 link (file, new) |
4999 char * file, * new; | |
5000 { | |
5001 register status; | |
5002 struct FAB fab; | |
5003 struct NAM nam; | |
5004 unsigned short fid[3]; | |
5005 char esa[NAM$C_MAXRSS]; | |
5006 | |
5007 fab = cc$rms_fab; | |
5008 fab.fab$l_fop = FAB$M_OFP; | |
5009 fab.fab$l_fna = file; | |
5010 fab.fab$b_fns = strlen (file); | |
5011 fab.fab$l_nam = &nam; | |
5012 | |
5013 nam = cc$rms_nam; | |
5014 nam.nam$l_esa = esa; | |
5015 nam.nam$b_ess = NAM$C_MAXRSS; | |
5016 | |
5017 status = SYS$PARSE (&fab); | |
5018 if ((status & 1) == 0) | |
5019 { | |
5020 errno = EVMSERR; | |
5021 vaxc$errno = status; | |
5022 return -1; | |
5023 } | |
5024 status = SYS$SEARCH (&fab); | |
5025 if ((status & 1) == 0) | |
5026 { | |
5027 errno = EVMSERR; | |
5028 vaxc$errno = status; | |
5029 return -1; | |
5030 } | |
5031 | |
5032 fid[0] = nam.nam$w_fid[0]; | |
5033 fid[1] = nam.nam$w_fid[1]; | |
5034 fid[2] = nam.nam$w_fid[2]; | |
5035 | |
5036 fab.fab$l_fna = new; | |
5037 fab.fab$b_fns = strlen (new); | |
5038 | |
5039 status = SYS$PARSE (&fab); | |
5040 if ((status & 1) == 0) | |
5041 { | |
5042 errno = EVMSERR; | |
5043 vaxc$errno = status; | |
5044 return -1; | |
5045 } | |
5046 | |
5047 nam.nam$w_fid[0] = fid[0]; | |
5048 nam.nam$w_fid[1] = fid[1]; | |
5049 nam.nam$w_fid[2] = fid[2]; | |
5050 | |
5051 nam.nam$l_esa = nam.nam$l_name; | |
5052 nam.nam$b_esl = nam.nam$b_name + nam.nam$b_type + nam.nam$b_ver; | |
5053 | |
5054 status = SYS$ENTER (&fab); | |
5055 if ((status & 1) == 0) | |
5056 { | |
5057 errno = EVMSERR; | |
5058 vaxc$errno = status; | |
5059 return -1; | |
5060 } | |
5061 | |
5062 return 0; | |
5063 } | |
5064 | |
21514 | 5065 void |
491 | 5066 croak (badfunc) |
5067 char *badfunc; | |
5068 { | |
5069 printf ("%s not yet implemented\r\n", badfunc); | |
5070 reset_sys_modes (); | |
5071 exit (1); | |
5072 } | |
5073 | |
5074 long | |
5075 random () | |
5076 { | |
5077 /* Arrange to return a range centered on zero. */ | |
5078 return rand () - (1 << 30); | |
5079 } | |
5080 | |
21514 | 5081 void |
491 | 5082 srandom (seed) |
5083 { | |
5084 srand (seed); | |
5085 } | |
5086 #endif /* VMS */ | |
5087 | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
5088 #ifdef AIXHFT |
491 | 5089 |
5090 /* Called from init_sys_modes. */ | |
21514 | 5091 void |
491 | 5092 hft_init () |
5093 { | |
5094 int junk; | |
5095 | |
5096 /* If we're not on an HFT we shouldn't do any of this. We determine | |
5097 if we are on an HFT by trying to get an HFT error code. If this | |
5098 call fails, we're not on an HFT. */ | |
5099 #ifdef IBMR2AIX | |
5100 if (ioctl (0, HFQERROR, &junk) < 0) | |
5101 return; | |
5102 #else /* not IBMR2AIX */ | |
5103 if (ioctl (0, HFQEIO, 0) < 0) | |
5104 return; | |
5105 #endif /* not IBMR2AIX */ | |
5106 | |
5107 /* On AIX the default hft keyboard mapping uses backspace rather than delete | |
5108 as the rubout key's ASCII code. Here this is changed. The bug is that | |
5109 there's no way to determine the old mapping, so in reset_sys_modes | |
5110 we need to assume that the normal map had been present. Of course, this | |
5111 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
|
5112 HFT VTD's. */ |
491 | 5113 { |
5114 struct hfbuf buf; | |
5115 struct hfkeymap keymap; | |
5116 | |
5117 buf.hf_bufp = (char *)&keymap; | |
5118 buf.hf_buflen = sizeof (keymap); | |
5119 keymap.hf_nkeys = 2; | |
5120 keymap.hfkey[0].hf_kpos = 15; | |
5121 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
5122 #ifdef IBMR2AIX | |
5123 keymap.hfkey[0].hf_keyidh = '<'; | |
5124 #else /* not IBMR2AIX */ | |
5125 keymap.hfkey[0].hf_page = '<'; | |
5126 #endif /* not IBMR2AIX */ | |
5127 keymap.hfkey[0].hf_char = 127; | |
5128 keymap.hfkey[1].hf_kpos = 15; | |
5129 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
5130 #ifdef IBMR2AIX | |
5131 keymap.hfkey[1].hf_keyidh = '<'; | |
5132 #else /* not IBMR2AIX */ | |
5133 keymap.hfkey[1].hf_page = '<'; | |
5134 #endif /* not IBMR2AIX */ | |
5135 keymap.hfkey[1].hf_char = 127; | |
5136 hftctl (0, HFSKBD, &buf); | |
5137 } | |
5138 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly | |
5139 at times. */ | |
5140 line_ins_del_ok = char_ins_del_ok = 0; | |
5141 } | |
5142 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
5143 /* Reset the rubout key to backspace. */ |
491 | 5144 |
21514 | 5145 void |
491 | 5146 hft_reset () |
5147 { | |
5148 struct hfbuf buf; | |
5149 struct hfkeymap keymap; | |
5150 int junk; | |
5151 | |
5152 #ifdef IBMR2AIX | |
5153 if (ioctl (0, HFQERROR, &junk) < 0) | |
5154 return; | |
5155 #else /* not IBMR2AIX */ | |
5156 if (ioctl (0, HFQEIO, 0) < 0) | |
5157 return; | |
5158 #endif /* not IBMR2AIX */ | |
5159 | |
5160 buf.hf_bufp = (char *)&keymap; | |
5161 buf.hf_buflen = sizeof (keymap); | |
5162 keymap.hf_nkeys = 2; | |
5163 keymap.hfkey[0].hf_kpos = 15; | |
5164 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
5165 #ifdef IBMR2AIX | |
5166 keymap.hfkey[0].hf_keyidh = '<'; | |
5167 #else /* not IBMR2AIX */ | |
5168 keymap.hfkey[0].hf_page = '<'; | |
5169 #endif /* not IBMR2AIX */ | |
5170 keymap.hfkey[0].hf_char = 8; | |
5171 keymap.hfkey[1].hf_kpos = 15; | |
5172 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
5173 #ifdef IBMR2AIX | |
5174 keymap.hfkey[1].hf_keyidh = '<'; | |
5175 #else /* not IBMR2AIX */ | |
5176 keymap.hfkey[1].hf_page = '<'; | |
5177 #endif /* not IBMR2AIX */ | |
5178 keymap.hfkey[1].hf_char = 8; | |
5179 hftctl (0, HFSKBD, &buf); | |
5180 } | |
5181 | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
5182 #endif /* AIXHFT */ |
9075
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5183 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5184 #ifdef USE_DL_STUBS |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5185 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5186 /* 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
|
5187 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
|
5188 actually call them. */ |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5189 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5190 void * |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5191 dlopen () |
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 return 0; |
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 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5196 void * |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5197 dlsym () |
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 return 0; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5200 } |
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 int |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5203 dlclose () |
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 return -1; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5206 } |
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 #endif /* USE_DL_STUBS */ |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5209 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5210 #ifndef BSTRING |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5211 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5212 #ifndef bzero |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5213 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5214 void |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5215 bzero (b, length) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5216 register char *b; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5217 register int length; |
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 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5220 short zero = 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5221 long max_str = 65535; |
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 while (length > max_str) { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5224 (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
|
5225 length -= max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5226 b += max_str; |
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 max_str = length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5229 (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
|
5230 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5231 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5232 *b++ = 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5233 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5234 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5235 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5236 #endif /* no bzero */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5237 #endif /* BSTRING */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5238 |
11722
d7089b2620fb
(bcmp, bcopy): Fix backward BSTRING conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
11624
diff
changeset
|
5239 #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
|
5240 #undef bcopy |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5241 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5242 /* 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
|
5243 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
|
5244 bcopy (b1, b2, length) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5245 register char *b1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5246 register char *b2; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5247 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5248 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5249 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5250 long max_str = 65535; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5251 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5252 while (length > max_str) { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5253 (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
|
5254 length -= max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5255 b1 += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5256 b2 += max_str; |
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 max_str = length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5259 (void) LIB$MOVC3 (&length, b1, b2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5260 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5261 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5262 *b2++ = *b1++; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5263 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5264 } |
21514 | 5265 #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
|
5266 |
11722
d7089b2620fb
(bcmp, bcopy): Fix backward BSTRING conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
11624
diff
changeset
|
5267 #ifndef BSTRING |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5268 #ifndef bcmp |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5269 int |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5270 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
|
5271 register char *b1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5272 register char *b2; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5273 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5274 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5275 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5276 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
|
5277 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
|
5278 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5279 return STR$COMPARE (&src1, &src2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5280 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5281 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5282 if (*b1++ != *b2++) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5283 return 1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5284 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5285 return 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5286 #endif /* not VMS */ |
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 #endif /* no bcmp */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5289 #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
|
5290 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5291 #ifndef HAVE_STRSIGNAL |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5292 char * |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5293 strsignal (code) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5294 int code; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5295 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5296 char *signame = 0; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5297 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5298 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
|
5299 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5300 #ifdef VMS |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5301 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
|
5302 #else |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5303 /* 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
|
5304 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
|
5305 #endif |
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 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5308 return signame; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5309 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5310 #endif /* HAVE_STRSIGNAL */ |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
5311 |