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