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