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