Mercurial > emacs
annotate src/sysdep.c @ 2598:2189edb30955
Removed spurious comment (obsoleted by ;;;###autoload).
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Wed, 28 Apr 1993 17:08:14 +0000 |
parents | 5f41134610a6 |
children | 93eda11d38de |
rev | line source |
---|---|
491 | 1 /* Interfaces to system-dependent kernel and library entries. |
579 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1992 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 | |
8 the Free Software Foundation; either version 1, or (at your option) | |
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 | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include <signal.h> | |
22 #include <setjmp.h> | |
23 | |
24 #include "config.h" | |
25 #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
|
26 #include "blockinput.h" |
491 | 27 #undef NULL |
28 | |
29 #define min(x,y) ((x) > (y) ? (y) : (x)) | |
30 | |
31 /* In this file, open, read and write refer to the system calls, | |
32 not our sugared interfaces sys_open, sys_read and sys_write. | |
33 Contrariwise, for systems where we use the system calls directly, | |
34 define sys_read, etc. here as aliases for them. */ | |
35 #ifndef read | |
36 #define sys_read read | |
37 #define sys_write write | |
38 #endif /* `read' is not a macro */ | |
39 | |
40 #undef read | |
41 #undef write | |
42 | |
43 #ifndef close | |
44 #define sys_close close | |
45 #else | |
46 #undef close | |
47 #endif | |
48 | |
49 #ifndef open | |
50 #define sys_open open | |
51 #else /* `open' is a macro */ | |
52 #undef open | |
53 #endif /* `open' is a macro */ | |
54 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
55 /* 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
|
56 #ifndef fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
57 #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
|
58 #else |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
59 #undef fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
60 #endif |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
61 |
491 | 62 #include <stdio.h> |
63 #include <sys/types.h> | |
64 #include <sys/stat.h> | |
65 #include <errno.h> | |
66 | |
67 extern int errno; | |
68 #ifndef VMS | |
69 extern char *sys_errlist[]; | |
70 #endif | |
71 | |
72 #ifdef VMS | |
73 #include <rms.h> | |
74 #include <ttdef.h> | |
75 #include <tt2def.h> | |
76 #include <iodef.h> | |
77 #include <ssdef.h> | |
78 #include <descrip.h> | |
79 #include <fibdef.h> | |
80 #include <atrdef.h> | |
81 #include <ctype.h> | |
82 #include <string.h> | |
83 #ifdef __GNUC__ | |
84 #include <sys/file.h> | |
85 #else | |
86 #include <file.h> | |
87 #endif | |
88 #undef F_SETFL | |
89 #ifndef RAB$C_BID | |
90 #include <rab.h> | |
91 #endif | |
92 #define MAXIOSIZE ( 32 * PAGESIZE ) /* Don't I/O more than 32 blocks at a time */ | |
93 #endif /* VMS */ | |
94 | |
95 #ifndef BSD4_1 | |
96 #ifdef BSD /* this is done this way to avoid defined (BSD) || defined (USG) | |
97 because the vms compiler doesn't grok `defined' */ | |
98 #include <fcntl.h> | |
99 #endif | |
100 #ifdef USG | |
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
101 #ifndef USG5 |
491 | 102 #include <fcntl.h> |
103 #endif | |
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
104 #endif |
491 | 105 #endif /* not 4.1 bsd */ |
106 | |
107 /* Get DGUX definition for FASYNC - DJB */ | |
108 #ifdef DGUX | |
109 #include <sys/file.h> | |
110 #endif /* DGUX */ | |
111 | |
112 #include <sys/ioctl.h> | |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
113 #include "systty.h" |
491 | 114 |
115 #ifdef BSD | |
116 #ifdef BSD4_1 | |
117 #include <wait.h> | |
118 #else /* not 4.1 */ | |
119 #include <sys/wait.h> | |
120 #endif /* not 4.1 */ | |
121 #endif /* BSD */ | |
122 | |
123 #ifdef BROKEN_TIOCGWINSZ | |
124 #undef TIOCGWINSZ | |
125 #endif | |
126 | |
127 #ifdef USG | |
128 #include <sys/utsname.h> | |
129 #include <string.h> | |
130 #ifndef MEMORY_IN_STRING_H | |
131 #include <memory.h> | |
132 #endif | |
133 #ifdef TIOCGWINSZ | |
134 #ifdef NEED_SIOCTL | |
135 #include <sys/sioctl.h> | |
136 #endif | |
137 #ifdef NEED_PTEM_H | |
138 #include <sys/stream.h> | |
139 #include <sys/ptem.h> | |
140 #endif | |
141 #endif /* TIOCGWINSZ */ | |
142 #endif /* USG */ | |
143 | |
144 extern int quit_char; | |
145 | |
766 | 146 #include "frame.h" |
491 | 147 #include "window.h" |
148 #include "termhooks.h" | |
149 #include "termchar.h" | |
150 #include "termopts.h" | |
151 #include "dispextern.h" | |
152 #include "process.h" | |
153 | |
154 #ifdef NONSYSTEM_DIR_LIBRARY | |
155 #include "ndir.h" | |
156 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
157 | |
579 | 158 #include "syssignal.h" |
159 #include "systime.h" | |
491 | 160 |
161 static int baud_convert[] = | |
162 #ifdef BAUD_CONVERT | |
163 BAUD_CONVERT; | |
164 #else | |
165 { | |
166 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, | |
167 1800, 2400, 4800, 9600, 19200, 38400 | |
168 }; | |
169 #endif | |
170 | |
171 extern short ospeed; | |
172 | |
579 | 173 /* The file descriptor for Emacs's input terminal. |
174 Under Unix, this is always left zero; | |
175 under VMS, we place the input channel number here. | |
176 This allows us to write more code that works for both VMS and Unix. */ | |
177 static int input_fd; | |
178 | |
491 | 179 discard_tty_input () |
180 { | |
579 | 181 struct emacs_tty buf; |
491 | 182 |
183 if (noninteractive) | |
184 return; | |
185 | |
186 /* Discarding input is not safe when the input could contain | |
187 replies from the X server. So don't do it. */ | |
188 if (read_socket_hook) | |
189 return; | |
190 | |
191 #ifdef VMS | |
192 end_kbd_input (); | |
579 | 193 SYS$QIOW (0, input_fd, IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, |
194 &buf.main, 0, 0, terminator_mask, 0, 0); | |
491 | 195 queue_kbd_input (); |
196 #else /* not VMS */ | |
197 #ifdef APOLLO | |
198 { | |
199 int zero = 0; | |
200 ioctl (0, TIOCFLUSH, &zero); | |
201 } | |
202 #else /* not Apollo */ | |
579 | 203 EMACS_GET_TTY (input_fd, &buf); |
204 EMACS_SET_TTY (input_fd, &buf, 0); | |
491 | 205 #endif /* not Apollo */ |
206 #endif /* not VMS */ | |
207 } | |
208 | |
209 #ifdef SIGTSTP | |
210 | |
211 stuff_char (c) | |
212 char c; | |
213 { | |
214 /* Should perhaps error if in batch mode */ | |
215 #ifdef TIOCSTI | |
216 ioctl (0, TIOCSTI, &c); | |
217 #else /* no TIOCSTI */ | |
218 error ("Cannot stuff terminal input characters in this version of Unix."); | |
219 #endif /* no TIOCSTI */ | |
220 } | |
221 | |
222 #endif /* SIGTSTP */ | |
223 | |
224 init_baud_rate () | |
225 { | |
226 if (noninteractive) | |
227 ospeed = 0; | |
228 else | |
229 { | |
230 #ifdef VMS | |
579 | 231 struct sensemode sg; |
232 | |
233 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0, | |
491 | 234 &sg.class, 12, 0, 0, 0, 0 ); |
579 | 235 ospeed = sg.xmit_baud; |
236 #else /* not VMS */ | |
237 #ifdef HAVE_TERMIOS | |
238 struct termios sg; | |
239 | |
240 sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; | |
241 tcgetattr (0, &sg); | |
242 ospeed = sg.c_cflag & CBAUD; | |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
243 #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
|
244 #ifdef HAVE_TERMIO |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
245 struct termio sg; |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
246 |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
247 sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
248 #ifdef HAVE_TCATTR |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
249 tcgetattr (0, &sg); |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
250 #else |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
251 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
|
252 #endif |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
253 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
|
254 #else /* neither VMS nor TERMIOS nor TERMIO */ |
579 | 255 struct sgttyb sg; |
256 | |
257 sg.sg_ospeed = B9600; | |
258 ioctl (0, TIOCGETP, &sg); | |
259 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
|
260 #endif /* not HAVE_TERMIO */ |
579 | 261 #endif /* not HAVE_TERMIOS */ |
491 | 262 #endif /* not VMS */ |
263 } | |
264 | |
265 baud_rate = (ospeed < sizeof baud_convert / sizeof baud_convert[0] | |
266 ? baud_convert[ospeed] : 9600); | |
267 if (baud_rate == 0) | |
268 baud_rate = 1200; | |
269 } | |
270 | |
271 /*ARGSUSED*/ | |
272 set_exclusive_use (fd) | |
273 int fd; | |
274 { | |
275 #ifdef FIOCLEX | |
276 ioctl (fd, FIOCLEX, 0); | |
277 #endif | |
278 /* Ok to do nothing if this feature does not exist */ | |
279 } | |
280 | |
281 #ifndef subprocesses | |
282 | |
283 wait_without_blocking () | |
284 { | |
285 #ifdef BSD | |
286 wait3 (0, WNOHANG | WUNTRACED, 0); | |
287 #else | |
288 croak ("wait_without_blocking"); | |
289 #endif | |
290 synch_process_alive = 0; | |
291 } | |
292 | |
293 #endif /* not subprocesses */ | |
294 | |
295 int wait_debugging; /* Set nonzero to make following function work under dbx | |
296 (at least for bsd). */ | |
297 | |
298 SIGTYPE | |
299 wait_for_termination_signal () | |
300 {} | |
301 | |
302 /* Wait for subprocess with process id `pid' to terminate and | |
303 make sure it will get eliminated (not remain forever as a zombie) */ | |
304 | |
305 wait_for_termination (pid) | |
306 int pid; | |
307 { | |
308 while (1) | |
309 { | |
310 #ifdef subprocesses | |
311 #ifdef VMS | |
312 int status; | |
313 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
314 status = SYS$FORCEX (&pid, 0, 0); |
491 | 315 break; |
316 #else /* not VMS */ | |
317 | |
318 /* Exit if the process has terminated. */ | |
319 if (!synch_process_alive) | |
320 break; | |
321 /* Otherwise wait 1 second or until a signal comes in. */ | |
322 signal (SIGALRM, wait_for_termination_signal); | |
323 alarm (1); | |
324 pause (); | |
325 alarm (0); | |
326 signal (SIGALRM, SIG_IGN); | |
327 #endif /* not VMS */ | |
328 #else /* not subprocesses */ | |
329 #ifndef BSD4_1 | |
330 if (kill (pid, 0) < 0) | |
331 break; | |
332 wait (0); | |
333 #else /* BSD4_1 */ | |
334 int status; | |
335 status = wait (0); | |
336 if (status == pid || status == -1) | |
337 break; | |
338 #endif /* BSD4_1 */ | |
339 #endif /* not subprocesses */ | |
340 } | |
341 } | |
342 | |
343 #ifdef subprocesses | |
344 | |
345 /* | |
346 * flush any pending output | |
347 * (may flush input as well; it does not matter the way we use it) | |
348 */ | |
349 | |
350 flush_pending_output (channel) | |
351 int channel; | |
352 { | |
353 #ifdef HAVE_TERMIOS | |
354 /* If we try this, we get hit with SIGTTIN, because | |
355 the child's tty belongs to the child's pgrp. */ | |
356 #else | |
357 #ifdef TCFLSH | |
358 ioctl (channel, TCFLSH, 1); | |
359 #else | |
360 #ifdef TIOCFLUSH | |
361 int zero = 0; | |
362 /* 3rd arg should be ignored | |
363 but some 4.2 kernels actually want the address of an int | |
364 and nonzero means something different. */ | |
365 ioctl (channel, TIOCFLUSH, &zero); | |
366 #endif | |
367 #endif | |
368 #endif | |
369 } | |
370 | |
371 #ifndef VMS | |
372 /* Set up the terminal at the other end of a pseudo-terminal that | |
373 we will be controlling an inferior through. | |
374 It should not echo or do line-editing, since that is done | |
375 in Emacs. No padding needed for insertion into an Emacs buffer. */ | |
376 | |
377 child_setup_tty (out) | |
378 int out; | |
379 { | |
579 | 380 struct emacs_tty s; |
381 | |
382 EMACS_GET_TTY (out, &s); | |
383 | |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
384 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
579 | 385 s.main.c_oflag |= OPOST; /* Enable output postprocessing */ |
386 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */ | |
387 s.main.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); | |
388 /* No output delays */ | |
389 s.main.c_lflag &= ~ECHO; /* Disable echo */ | |
390 s.main.c_lflag |= ISIG; /* Enable signals */ | |
391 s.main.c_iflag &= ~IUCLC; /* Disable map of upper case to lower on | |
392 input */ | |
393 s.main.c_oflag &= ~OLCUC; /* Disable map of lower case to upper on | |
394 output */ | |
395 #if 0 | |
396 /* Said to be unnecesary: */ | |
397 s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */ | |
398 s.main.c_cc[VTIME] = 0; /* wait forever for at least 1 character */ | |
399 #endif | |
400 | |
401 s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */ | |
402 s.main.c_cc[VEOF] = 04; /* insure that EOF is Control-D */ | |
403 s.main.c_cc[VERASE] = 0377; /* disable erase processing */ | |
404 s.main.c_cc[VKILL] = 0377; /* disable kill processing */ | |
405 | |
491 | 406 #ifdef HPUX |
579 | 407 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ |
491 | 408 #endif /* HPUX */ |
579 | 409 |
491 | 410 #ifdef AIX |
411 /* AIX enhanced edit loses NULs, so disable it */ | |
412 #ifndef IBMR2AIX | |
579 | 413 s.main.c_line = 0; |
414 s.main.c_iflag &= ~ASCEDIT; | |
491 | 415 #endif |
416 /* Also, PTY overloads NUL and BREAK. | |
417 don't ignore break, but don't signal either, so it looks like NUL. */ | |
579 | 418 s.main.c_iflag &= ~IGNBRK; |
419 s.main.c_iflag &= ~BRKINT; | |
420 /* QUIT and INTR work better as signals, so disable character forms */ | |
421 s.main.c_cc[VQUIT] = 0377; | |
422 s.main.c_cc[VINTR] = 0377; | |
423 s.main.c_cc[VEOL] = 0377; | |
424 s.main.c_lflag &= ~ISIG; | |
425 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ | |
491 | 426 #endif /* AIX */ |
427 | |
428 #else /* not HAVE_TERMIO */ | |
579 | 429 |
430 s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE | |
431 | CBREAK | TANDEM); | |
432 s.main.sg_erase = 0377; | |
433 s.main.sg_kill = 0377; | |
434 | |
491 | 435 #endif /* not HAVE_TERMIO */ |
436 | |
579 | 437 EMACS_SET_TTY (out, &s, 0); |
491 | 438 |
439 #ifdef BSD4_1 | |
440 if (interrupt_input) | |
441 reset_sigio (); | |
442 #endif /* BSD4_1 */ | |
443 #ifdef RTU | |
444 { | |
445 int zero = 0; | |
446 ioctl (out, FIOASYNC, &zero); | |
447 } | |
448 #endif /* RTU */ | |
449 } | |
450 #endif /* not VMS */ | |
451 | |
452 #endif /* subprocesses */ | |
453 | |
454 /*ARGSUSED*/ | |
455 setpgrp_of_tty (pid) | |
456 int pid; | |
457 { | |
648 | 458 EMACS_SET_TTY_PGRP (input_fd, &pid); |
491 | 459 } |
460 | |
461 /* Record a signal code and the handler for it. */ | |
462 struct save_signal | |
463 { | |
464 int code; | |
465 SIGTYPE (*handler) (); | |
466 }; | |
467 | |
468 /* Suspend the Emacs process; give terminal to its superior. */ | |
469 | |
470 sys_suspend () | |
471 { | |
472 #ifdef VMS | |
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
473 /* "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
|
474 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
|
475 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
|
476 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
|
477 char *fpid_string; |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
478 |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
479 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
|
480 if (fpid_string != NULL) |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
481 { |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
482 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
|
483 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
|
484 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
|
485 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
486 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
487 } |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
488 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
489 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
490 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
491 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
|
492 |
491 | 493 if (parent_id && parent_id != 0xffffffff) |
494 { | |
495 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); | |
496 int status = LIB$ATTACH (&parent_id) & 1; | |
497 signal (SIGINT, oldsig); | |
498 return status; | |
499 } | |
500 else | |
501 { | |
502 struct { | |
503 int l; | |
504 char *a; | |
505 } d_prompt; | |
506 d_prompt.l = sizeof ("Emacs: "); /* Our special prompt */ | |
507 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
|
508 LIB$SPAWN (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &d_prompt, 0); |
491 | 509 return 1; |
510 } | |
511 return -1; | |
512 #else | |
513 #ifdef SIGTSTP | |
514 | |
579 | 515 EMACS_KILLPG (getpgrp (0), SIGTSTP); |
491 | 516 |
517 #else /* No SIGTSTP */ | |
518 #ifdef USG_JOBCTRL /* If you don't know what this is don't mess with it */ | |
519 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */ | |
520 kill (getpid (), SIGQUIT); | |
521 | |
522 #else /* No SIGTSTP or USG_JOBCTRL */ | |
523 | |
524 /* On a system where suspending is not implemented, | |
525 instead fork a subshell and let it talk directly to the terminal | |
526 while we wait. */ | |
527 int pid = fork (); | |
528 struct save_signal saved_handlers[5]; | |
529 | |
530 saved_handlers[0].code = SIGINT; | |
531 saved_handlers[1].code = SIGQUIT; | |
532 saved_handlers[2].code = SIGTERM; | |
533 #ifdef SIGIO | |
534 saved_handlers[3].code = SIGIO; | |
535 saved_handlers[4].code = 0; | |
536 #else | |
537 saved_handlers[3].code = 0; | |
538 #endif | |
539 | |
540 if (pid == -1) | |
541 error ("Can't spawn subshell"); | |
542 if (pid == 0) | |
543 { | |
544 char *sh; | |
545 | |
546 sh = (char *) egetenv ("SHELL"); | |
547 if (sh == 0) | |
548 sh = "sh"; | |
549 /* Use our buffer's default directory for the subshell. */ | |
550 { | |
551 Lisp_Object dir; | |
552 unsigned char *str; | |
553 int len; | |
554 | |
555 /* mentioning current_buffer->buffer would mean including buffer.h, | |
556 which somehow wedges the hp compiler. So instead... */ | |
557 | |
558 dir = intern ("default-directory"); | |
559 /* Can't use NULL */ | |
560 if (XFASTINT (Fboundp (dir)) == XFASTINT (Qnil)) | |
561 goto xyzzy; | |
562 dir = Fsymbol_value (dir); | |
563 if (XTYPE (dir) != Lisp_String) | |
564 goto xyzzy; | |
565 | |
566 str = (unsigned char *) alloca (XSTRING (dir)->size + 2); | |
567 len = XSTRING (dir)->size; | |
568 bcopy (XSTRING (dir)->data, str, len); | |
569 if (str[len - 1] != '/') str[len++] = '/'; | |
570 str[len] = 0; | |
571 chdir (str); | |
572 } | |
573 xyzzy: | |
574 #ifdef subprocesses | |
575 close_process_descs (); /* Close Emacs's pipes/ptys */ | |
576 #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
|
577 |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
578 #ifdef PRIO_PROCESS |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
579 { |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
580 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
|
581 |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
582 if (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
|
583 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
|
584 } |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
585 #endif |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
586 |
491 | 587 execlp (sh, sh, 0); |
588 write (1, "Can't execute subshell", 22); | |
589 _exit (1); | |
590 } | |
591 | |
592 save_signal_handlers (saved_handlers); | |
593 wait_for_termination (pid); | |
594 restore_signal_handlers (saved_handlers); | |
595 | |
596 #endif /* no USG_JOBCTRL */ | |
597 #endif /* no SIGTSTP */ | |
598 #endif /* not VMS */ | |
599 } | |
600 | |
601 save_signal_handlers (saved_handlers) | |
602 struct save_signal *saved_handlers; | |
603 { | |
604 while (saved_handlers->code) | |
605 { | |
692 | 606 saved_handlers->handler |
607 = (SIGTYPE (*) ()) signal (saved_handlers->code, SIG_IGN); | |
491 | 608 saved_handlers++; |
609 } | |
610 } | |
611 | |
612 restore_signal_handlers (saved_handlers) | |
613 struct save_signal *saved_handlers; | |
614 { | |
615 while (saved_handlers->code) | |
616 { | |
617 signal (saved_handlers->code, saved_handlers->handler); | |
618 saved_handlers++; | |
619 } | |
620 } | |
621 | |
622 #ifdef F_SETFL | |
623 | |
624 int old_fcntl_flags; | |
625 | |
626 init_sigio () | |
627 { | |
628 #ifdef FASYNC | |
629 old_fcntl_flags = fcntl (0, F_GETFL, 0) & ~FASYNC; | |
630 #endif | |
631 request_sigio (); | |
632 } | |
633 | |
634 reset_sigio () | |
635 { | |
636 unrequest_sigio (); | |
637 } | |
638 | |
639 #ifdef FASYNC /* F_SETFL does not imply existance of FASYNC */ | |
640 | |
641 request_sigio () | |
642 { | |
643 #ifdef SIGWINCH | |
638 | 644 sigunblock (sigmask (SIGWINCH)); |
491 | 645 #endif |
646 fcntl (0, F_SETFL, old_fcntl_flags | FASYNC); | |
647 | |
648 interrupts_deferred = 0; | |
649 } | |
650 | |
651 unrequest_sigio () | |
652 { | |
653 #ifdef SIGWINCH | |
638 | 654 sigblock (sigmask (SIGWINCH)); |
491 | 655 #endif |
656 fcntl (0, F_SETFL, old_fcntl_flags); | |
657 interrupts_deferred = 1; | |
658 } | |
659 | |
660 #else /* no FASYNC */ | |
661 #ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */ | |
662 | |
663 request_sigio () | |
664 { | |
665 int on = 1; | |
666 ioctl (0, FIOASYNC, &on); | |
667 interrupts_deferred = 0; | |
668 } | |
669 | |
670 unrequest_sigio () | |
671 { | |
672 int off = 0; | |
673 | |
674 ioctl (0, FIOASYNC, &off); | |
675 interrupts_deferred = 1; | |
676 } | |
677 | |
678 #else /* not FASYNC, not STRIDE */ | |
679 | |
680 request_sigio () | |
681 { | |
682 croak ("request_sigio"); | |
683 } | |
684 | |
685 unrequest_sigio () | |
686 { | |
687 croak ("unrequest_sigio"); | |
688 } | |
689 | |
690 #endif /* STRIDE */ | |
691 #endif /* FASYNC */ | |
692 #endif /* F_SETFL */ | |
693 | |
579 | 694 /* The initial tty mode bits */ |
695 struct emacs_tty old_tty; | |
491 | 696 |
697 int term_initted; /* 1 if outer tty status has been recorded */ | |
698 | |
579 | 699 #ifdef BSD4_1 |
700 /* BSD 4.1 needs to keep track of the lmode bits in order to start | |
701 sigio. */ | |
702 int lmode; | |
703 #endif | |
704 | |
491 | 705 #ifdef F_SETOWN |
706 int old_fcntl_owner; | |
707 #endif /* F_SETOWN */ | |
708 | |
709 /* This may also be defined in stdio, | |
710 but if so, this does no harm, | |
711 and using the same name avoids wasting the other one's space. */ | |
712 | |
713 #if defined (USG) || defined (DGUX) | |
714 unsigned char _sobuf[BUFSIZ+8]; | |
715 #else | |
716 char _sobuf[BUFSIZ]; | |
717 #endif | |
718 | |
719 #ifdef TIOCGLTC | |
720 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; | |
721 #endif | |
722 #ifdef TIOCGETC | |
723 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; | |
724 #endif | |
725 | |
726 init_sys_modes () | |
727 { | |
579 | 728 struct emacs_tty tty; |
729 | |
491 | 730 #ifdef VMS |
731 #if 0 | |
732 static int oob_chars[2] = {0, 1 << 7}; /* catch C-g's */ | |
733 extern int (*interrupt_signal) (); | |
734 #endif | |
735 #endif | |
736 | |
737 if (noninteractive) | |
738 return; | |
739 | |
740 #ifdef VMS | |
741 if (!input_ef) | |
742 input_ef = get_kbd_event_flag (); | |
743 /* LIB$GET_EF (&input_ef); */ | |
744 SYS$CLREF (input_ef); | |
745 waiting_for_ast = 0; | |
746 if (!timer_ef) | |
747 timer_ef = get_timer_event_flag (); | |
748 /* LIB$GET_EF (&timer_ef); */ | |
749 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
|
750 #if 0 |
491 | 751 if (!process_ef) |
752 { | |
753 LIB$GET_EF (&process_ef); | |
754 SYS$CLREF (process_ef); | |
755 } | |
756 if (input_ef / 32 != process_ef / 32) | |
757 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
|
758 #endif |
491 | 759 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
|
760 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
|
761 #if 0 |
491 | 762 input_eflist = ((unsigned) 1 << (input_ef % 32)) | |
763 ((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
|
764 #endif |
491 | 765 timer_eflist = ((unsigned) 1 << (input_ef % 32)) | |
766 ((unsigned) 1 << (timer_ef % 32)); | |
767 #ifndef VMS4_4 | |
768 sys_access_reinit (); | |
769 #endif | |
770 #endif /* not VMS */ | |
579 | 771 |
772 EMACS_GET_TTY (input_fd, &old_tty); | |
773 | |
491 | 774 if (!read_socket_hook && EQ (Vwindow_system, Qnil)) |
775 { | |
579 | 776 tty = old_tty; |
491 | 777 |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
778 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
579 | 779 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ |
780 tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ | |
491 | 781 #ifdef ISTRIP |
579 | 782 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ |
491 | 783 #endif |
579 | 784 tty.main.c_lflag &= ~ECHO; /* Disable echo */ |
785 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
|
786 #ifdef IEXTEN |
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
787 tty.main.c_iflag &= ~IEXTEN; /* Disable other editing characters. */ |
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
788 #endif |
579 | 789 tty.main.c_lflag |= ISIG; /* Enable signals */ |
491 | 790 if (flow_control) |
791 { | |
579 | 792 tty.main.c_iflag |= IXON; /* Enable start/stop output control */ |
491 | 793 #ifdef IXANY |
579 | 794 tty.main.c_iflag &= ~IXANY; |
491 | 795 #endif /* IXANY */ |
796 } | |
797 else | |
579 | 798 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ |
799 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL | |
800 on output */ | |
801 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ | |
491 | 802 #ifdef CS8 |
803 if (meta_key) | |
804 { | |
579 | 805 tty.main.c_cflag |= CS8; /* allow 8th bit on input */ |
806 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ | |
491 | 807 } |
808 #endif | |
579 | 809 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ |
491 | 810 /* Set up C-g for both SIGQUIT and SIGINT. |
811 We don't know which we will get, but we handle both alike | |
812 so which one it really gives us does not matter. */ | |
579 | 813 tty.main.c_cc[VQUIT] = quit_char; |
814 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ | |
815 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */ | |
491 | 816 #ifdef VSWTCH |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
817 tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use |
579 | 818 of C-z */ |
491 | 819 #endif /* VSWTCH */ |
820 #if defined (mips) || defined (HAVE_TCATTR) | |
821 #ifdef VSUSP | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
822 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ |
491 | 823 #endif /* VSUSP */ |
824 #ifdef V_DSUSP | |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
825 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ |
491 | 826 #endif /* V_DSUSP */ |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
827 #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
|
828 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
|
829 #endif /* VDSUSP */ |
491 | 830 #endif /* mips or HAVE_TCATTR */ |
831 #ifdef AIX | |
832 #ifndef IBMR2AIX | |
833 /* AIX enhanced edit loses NULs, so disable it */ | |
579 | 834 tty.main.c_line = 0; |
835 tty.main.c_iflag &= ~ASCEDIT; | |
491 | 836 #else |
579 | 837 tty.main.c_cc[VSTRT] = 255; |
838 tty.main.c_cc[VSTOP] = 255; | |
839 tty.main.c_cc[VSUSP] = 255; | |
840 tty.main.c_cc[VDSUSP] = 255; | |
491 | 841 #endif /* IBMR2AIX */ |
842 /* Also, PTY overloads NUL and BREAK. | |
843 don't ignore break, but don't signal either, so it looks like NUL. | |
844 This really serves a purpose only if running in an XTERM window | |
845 or via TELNET or the like, but does no harm elsewhere. */ | |
579 | 846 tty.main.c_iflag &= ~IGNBRK; |
847 tty.main.c_iflag &= ~BRKINT; | |
491 | 848 #endif |
849 #else /* if not HAVE_TERMIO */ | |
850 #ifdef VMS | |
579 | 851 tty.main.tt_char |= TT$M_NOECHO; |
491 | 852 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
|
853 tty.main.tt_char |= TT$M_EIGHTBIT; |
491 | 854 if (flow_control) |
579 | 855 tty.main.tt_char |= TT$M_TTSYNC; |
491 | 856 else |
579 | 857 tty.main.tt_char &= ~TT$M_TTSYNC; |
858 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; | |
491 | 859 #else /* not VMS (BSD, that is) */ |
579 | 860 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); |
491 | 861 if (meta_key) |
579 | 862 tty.main.sg_flags |= ANYP; |
863 tty.main.sg_flags |= interrupt_input ? RAW : CBREAK; | |
491 | 864 #endif /* not VMS (BSD, that is) */ |
865 #endif /* not HAVE_TERMIO */ | |
866 | |
579 | 867 /* If going to use CBREAK mode, we must request C-g to interrupt |
868 and turn off start and stop chars, etc. If not going to use | |
869 CBREAK mode, do this anyway so as to turn off local flow | |
870 control for user coming over network on 4.2; in this case, | |
871 only t_stopc and t_startc really matter. */ | |
872 #ifndef HAVE_TERMIO | |
873 #ifdef TIOCGETC | |
874 /* Note: if not using CBREAK mode, it makes no difference how we | |
875 set this */ | |
876 tty.tchars = new_tchars; | |
877 tty.tchars.t_intrc = quit_char; | |
878 if (flow_control) | |
879 { | |
880 tty.tchars.t_startc = '\021'; | |
881 tty.tchars.t_stopc = '\023'; | |
882 } | |
883 | |
884 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ | |
885 #ifndef LPASS8 | |
886 #define LPASS8 0 | |
491 | 887 #endif |
579 | 888 |
889 #ifdef BSD4_1 | |
890 #define LNOFLSH 0100000 | |
891 #endif | |
892 | |
893 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | old_tty.lmode; | |
894 | |
895 #ifdef BSD4_1 | |
896 lmode = tty.lmode; | |
897 #endif | |
898 | |
899 #endif /* TIOCGETC */ | |
900 #endif /* not HAVE_TERMIO */ | |
901 | |
902 #ifdef TIOCGLTC | |
903 tty.ltchars = new_ltchars; | |
904 #endif /* TIOCGLTC */ | |
905 | |
906 EMACS_SET_TTY (input_fd, &tty, 0); | |
491 | 907 |
908 /* This code added to insure that, if flow-control is not to be used, | |
766 | 909 we have an unlocked terminal at the start. */ |
579 | 910 |
491 | 911 #ifdef TCXONC |
912 if (!flow_control) ioctl (0, TCXONC, 1); | |
913 #endif | |
914 #ifndef APOLLO | |
915 #ifdef TIOCSTART | |
916 if (!flow_control) ioctl (0, TIOCSTART, 0); | |
917 #endif | |
918 #endif | |
919 | |
920 #ifdef AIX | |
921 hft_init (); | |
922 #ifdef IBMR2AIX | |
923 { | |
924 /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it | |
925 to be only LF. This is the way that is done. */ | |
926 struct termio tty; | |
927 | |
928 if (ioctl (1, HFTGETID, &tty) != -1) | |
929 write (1, "\033[20l", 5); | |
930 } | |
931 #endif | |
932 #endif | |
933 | |
934 #ifdef VMS | |
935 /* Appears to do nothing when in PASTHRU mode. | |
579 | 936 SYS$QIOW (0, input_fd, IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, |
491 | 937 interrupt_signal, oob_chars, 0, 0, 0, 0); |
938 */ | |
939 queue_kbd_input (0); | |
940 #endif /* VMS */ | |
941 } | |
942 | |
943 #ifdef F_SETFL | |
944 #ifdef F_GETOWN /* F_SETFL does not imply existance of F_GETOWN */ | |
945 if (interrupt_input) | |
946 { | |
947 old_fcntl_owner = fcntl (0, F_GETOWN, 0); | |
948 fcntl (0, F_SETOWN, getpid ()); | |
949 init_sigio (); | |
950 } | |
951 #endif /* F_GETOWN */ | |
952 #endif /* F_SETFL */ | |
953 | |
954 #ifdef BSD4_1 | |
955 if (interrupt_input) | |
956 init_sigio (); | |
957 #endif | |
958 | |
959 #ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ | |
960 #undef _IOFBF | |
961 #endif | |
962 #ifdef _IOFBF | |
963 /* This symbol is defined on recent USG systems. | |
964 Someone says without this call USG won't really buffer the file | |
965 even with a call to setbuf. */ | |
966 setvbuf (stdout, _sobuf, _IOFBF, sizeof _sobuf); | |
967 #else | |
968 setbuf (stdout, _sobuf); | |
969 #endif | |
970 set_terminal_modes (); | |
971 if (term_initted && no_redraw_on_reenter) | |
972 { | |
973 if (display_completed) | |
974 direct_output_forward_char (0); | |
975 } | |
976 else | |
977 { | |
766 | 978 frame_garbaged = 1; |
979 #ifdef MULTI_FRAME | |
980 if (FRAMEP (Vterminal_frame)) | |
981 FRAME_GARBAGED_P (XFRAME (Vterminal_frame)) = 1; | |
491 | 982 #endif |
983 } | |
579 | 984 |
491 | 985 term_initted = 1; |
986 } | |
987 | |
988 /* Return nonzero if safe to use tabs in output. | |
989 At the time this is called, init_sys_modes has not been done yet. */ | |
990 | |
991 tabs_safe_p () | |
992 { | |
579 | 993 struct emacs_tty tty; |
994 | |
995 EMACS_GET_TTY (input_fd, &tty); | |
996 return EMACS_TTY_TABS_OK (&tty); | |
491 | 997 } |
998 | |
999 /* Get terminal size from system. | |
1000 Store number of lines into *heightp and width into *widthp. | |
1001 If zero or a negative number is stored, the value is not valid. */ | |
1002 | |
766 | 1003 get_frame_size (widthp, heightp) |
491 | 1004 int *widthp, *heightp; |
1005 { | |
579 | 1006 |
1007 #ifdef TIOCGWINSZ | |
1008 | |
1009 /* BSD-style. */ | |
1010 struct winsize size; | |
1011 | |
1012 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) | |
1013 *widthp = *heightp = 0; | |
1014 else | |
1015 { | |
1016 *widthp = size.ws_col; | |
1017 *heightp = size.ws_row; | |
1018 } | |
1019 | |
1020 #else | |
491 | 1021 #ifdef TIOCGSIZE |
579 | 1022 |
1023 /* SunOS - style. */ | |
1024 struct ttysize size; | |
1025 | |
1026 if (ioctl (input_fd, TIOCGSIZE, &size) == -1) | |
1027 *widthp = *heightp = 0; | |
1028 else | |
1029 { | |
1030 *widthp = size.ts_cols; | |
1031 *heightp = size.ts_lines; | |
1032 } | |
1033 | |
1034 #else | |
491 | 1035 #ifdef VMS |
579 | 1036 |
1037 struct sensemode tty; | |
1038 | |
1039 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, | |
491 | 1040 &tty.class, 12, 0, 0, 0, 0); |
1041 *widthp = tty.scr_wid; | |
1042 *heightp = tty.scr_len; | |
579 | 1043 |
491 | 1044 #else /* system doesn't know size */ |
579 | 1045 |
491 | 1046 *widthp = 0; |
1047 *heightp = 0; | |
579 | 1048 |
1049 #endif /* not VMS */ | |
1050 #endif /* not SunOS-style */ | |
1051 #endif /* not BSD-style */ | |
491 | 1052 } |
579 | 1053 |
491 | 1054 |
579 | 1055 /* Prepare the terminal for exiting Emacs; move the cursor to the |
766 | 1056 bottom of the frame, turn off interrupt-driven I/O, etc. */ |
491 | 1057 reset_sys_modes () |
1058 { | |
1059 if (noninteractive) | |
1060 { | |
1061 fflush (stdout); | |
1062 return; | |
1063 } | |
1064 if (!term_initted) | |
1065 return; | |
1066 if (read_socket_hook || !EQ (Vwindow_system, Qnil)) | |
1067 return; | |
766 | 1068 cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0); |
1069 clear_end_of_line (FRAME_WIDTH (selected_frame)); | |
491 | 1070 /* clear_end_of_line may move the cursor */ |
766 | 1071 cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0); |
491 | 1072 #ifdef IBMR2AIX |
1073 { | |
1074 /* HFT devices normally use ^J as a LF/CR. We forced it to | |
1075 do the LF only. Now, we need to reset it. */ | |
1076 struct termio tty; | |
1077 | |
1078 if (ioctl (1, HFTGETID, &tty) != -1) | |
1079 write (1, "\033[20h", 5); | |
1080 } | |
1081 #endif | |
1082 | |
1083 reset_terminal_modes (); | |
1084 fflush (stdout); | |
1085 #ifdef BSD | |
1086 #ifndef BSD4_1 | |
1087 /* Avoid possible loss of output when changing terminal modes. */ | |
1088 fsync (fileno (stdout)); | |
1089 #endif | |
1090 #endif | |
579 | 1091 |
491 | 1092 #ifdef F_SETFL |
1093 #ifdef F_SETOWN /* F_SETFL does not imply existance of F_SETOWN */ | |
1094 if (interrupt_input) | |
1095 { | |
1096 reset_sigio (); | |
1097 fcntl (0, F_SETOWN, old_fcntl_owner); | |
1098 } | |
1099 #endif /* F_SETOWN */ | |
1100 #endif /* F_SETFL */ | |
1101 #ifdef BSD4_1 | |
1102 if (interrupt_input) | |
1103 reset_sigio (); | |
1104 #endif /* BSD4_1 */ | |
579 | 1105 |
2287
907efc217cfe
* sysdep.c (reset_sys_modes): Fix usage of EMACS_SET_TTY.
Jim Blandy <jimb@redhat.com>
parents:
2264
diff
changeset
|
1106 while (! EMACS_SET_TTY (input_fd, &old_tty, 0) && errno == EINTR) |
579 | 1107 ; |
491 | 1108 |
1109 #ifdef AIX | |
1110 hft_reset (); | |
1111 #endif | |
1112 } | |
1113 | |
1114 #ifdef HAVE_PTYS | |
1115 | |
1116 /* Set up the proper status flags for use of a pty. */ | |
1117 | |
1118 setup_pty (fd) | |
1119 int fd; | |
1120 { | |
1121 /* I'm told that TOICREMOTE does not mean control chars | |
1122 "can't be sent" but rather that they don't have | |
1123 input-editing or signaling effects. | |
1124 That should be good, because we have other ways | |
1125 to do those things in Emacs. | |
1126 However, telnet mode seems not to work on 4.2. | |
1127 So TIOCREMOTE is turned off now. */ | |
1128 | |
1129 /* Under hp-ux, if TIOCREMOTE is turned on, some calls | |
1130 will hang. In particular, the "timeout" feature (which | |
1131 causes a read to return if there is no data available) | |
1132 does this. Also it is known that telnet mode will hang | |
1133 in such a way that Emacs must be stopped (perhaps this | |
1134 is the same problem). | |
1135 | |
1136 If TIOCREMOTE is turned off, then there is a bug in | |
1137 hp-ux which sometimes loses data. Apparently the | |
1138 code which blocks the master process when the internal | |
1139 buffer fills up does not work. Other than this, | |
1140 though, everything else seems to work fine. | |
1141 | |
1142 Since the latter lossage is more benign, we may as well | |
1143 lose that way. -- cph */ | |
1144 #ifdef FIONBIO | |
1145 #ifdef SYSV_PTYS | |
1146 { | |
1147 int on = 1; | |
1148 ioctl (fd, FIONBIO, &on); | |
1149 } | |
1150 #endif | |
1151 #endif | |
1152 #ifdef IBMRTAIX | |
1153 /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */ | |
1154 /* ignore SIGHUP once we've started a child on a pty. Note that this may */ | |
1155 /* cause EMACS not to die when it should, i.e., when its own controlling */ | |
1156 /* tty goes away. I've complained to the AIX developers, and they may */ | |
1157 /* change this behavior, but I'm not going to hold my breath. */ | |
1158 signal (SIGHUP, SIG_IGN); | |
1159 #endif | |
1160 } | |
1161 #endif /* HAVE_PTYS */ | |
1162 | |
1163 #ifdef VMS | |
1164 | |
1165 /* Assigning an input channel is done at the start of Emacs execution. | |
1166 This is called each time Emacs is resumed, also, but does nothing | |
1167 because input_chain is no longer zero. */ | |
1168 | |
1169 init_vms_input () | |
1170 { | |
1171 int status; | |
1172 | |
579 | 1173 if (input_fd == 0) |
491 | 1174 { |
579 | 1175 status = SYS$ASSIGN (&input_dsc, &input_fd, 0, 0); |
491 | 1176 if (! (status & 1)) |
1177 LIB$STOP (status); | |
1178 } | |
1179 } | |
1180 | |
1181 /* Deassigning the input channel is done before exiting. */ | |
1182 | |
1183 stop_vms_input () | |
1184 { | |
579 | 1185 return SYS$DASSGN (input_fd); |
491 | 1186 } |
1187 | |
1188 short input_buffer; | |
1189 | |
1190 /* Request reading one character into the keyboard buffer. | |
1191 This is done as soon as the buffer becomes empty. */ | |
1192 | |
1193 queue_kbd_input () | |
1194 { | |
1195 int status; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1196 extern kbd_input_ast (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1197 |
491 | 1198 waiting_for_ast = 0; |
1199 stop_input = 0; | |
579 | 1200 status = SYS$QIO (0, input_fd, IO$_READVBLK, |
491 | 1201 &input_iosb, kbd_input_ast, 1, |
1202 &input_buffer, 1, 0, terminator_mask, 0, 0); | |
1203 } | |
1204 | |
1205 int input_count; | |
1206 | |
1207 /* Ast routine that is called when keyboard input comes in | |
1208 in accord with the SYS$QIO above. */ | |
1209 | |
1210 kbd_input_ast () | |
1211 { | |
1212 register int c = -1; | |
1213 int old_errno = errno; | |
648 | 1214 extern EMACS_TIME *input_available_clear_time; |
491 | 1215 |
1216 if (waiting_for_ast) | |
1217 SYS$SETEF (input_ef); | |
1218 waiting_for_ast = 0; | |
1219 input_count++; | |
1220 #ifdef ASTDEBUG | |
1221 if (input_count == 25) | |
1222 exit (1); | |
1223 printf ("Ast # %d,", input_count); | |
1224 printf (" iosb = %x, %x, %x, %x", | |
1225 input_iosb.offset, input_iosb.status, input_iosb.termlen, | |
1226 input_iosb.term); | |
1227 #endif | |
1228 if (input_iosb.offset) | |
1229 { | |
1230 c = input_buffer; | |
1231 #ifdef ASTDEBUG | |
1232 printf (", char = 0%o", c); | |
1233 #endif | |
1234 } | |
1235 #ifdef ASTDEBUG | |
1236 printf ("\n"); | |
1237 fflush (stdout); | |
1238 sleep (1); | |
1239 #endif | |
1240 if (! stop_input) | |
1241 queue_kbd_input (); | |
1242 if (c >= 0) | |
1243 { | |
1244 struct input_event e; | |
1245 e.kind = ascii_keystroke; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1246 XSET (e.code, Lisp_Int, c); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1247 #ifdef MULTI_FRAME |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1248 XSET(e.frame_or_window, Lisp_Frame, selected_frame); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1249 #else |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1250 e.frame_or_window = Qnil; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1251 #endif |
491 | 1252 kbd_buffer_store_event (&e); |
1253 } | |
648 | 1254 if (input_available_clear_time) |
1255 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | |
491 | 1256 errno = old_errno; |
1257 } | |
1258 | |
1259 /* Wait until there is something in kbd_buffer. */ | |
1260 | |
1261 wait_for_kbd_input () | |
1262 { | |
1263 extern int have_process_input, process_exited; | |
1264 | |
1265 /* If already something, avoid doing system calls. */ | |
1266 if (detect_input_pending ()) | |
1267 { | |
1268 return; | |
1269 } | |
1270 /* Clear a flag, and tell ast routine above to set it. */ | |
1271 SYS$CLREF (input_ef); | |
1272 waiting_for_ast = 1; | |
1273 /* Check for timing error: ast happened while we were doing that. */ | |
1274 if (!detect_input_pending ()) | |
1275 { | |
1276 /* No timing error: wait for flag to be set. */ | |
1277 set_waiting_for_input (0); | |
1278 SYS$WFLOR (input_ef, input_eflist); | |
1279 clear_waiting_for_input (0); | |
1280 if (!detect_input_pending ()) | |
1281 /* Check for subprocess input availability */ | |
1282 { | |
1283 int dsp = have_process_input || process_exited; | |
1284 | |
1285 SYS$CLREF (process_ef); | |
1286 if (have_process_input) | |
1287 process_command_input (); | |
1288 if (process_exited) | |
1289 process_exit (); | |
1290 if (dsp) | |
1291 { | |
1292 update_mode_lines++; | |
1293 redisplay_preserve_echo_area (); | |
1294 } | |
1295 } | |
1296 } | |
1297 waiting_for_ast = 0; | |
1298 } | |
1299 | |
1300 /* Get rid of any pending QIO, when we are about to suspend | |
1301 or when we want to throw away pending input. | |
1302 We wait for a positive sign that the AST routine has run | |
1303 and therefore there is no I/O request queued when we return. | |
1304 SYS$SETAST is used to avoid a timing error. */ | |
1305 | |
1306 end_kbd_input () | |
1307 { | |
1308 #ifdef ASTDEBUG | |
1309 printf ("At end_kbd_input.\n"); | |
1310 fflush (stdout); | |
1311 sleep (1); | |
1312 #endif | |
1313 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ | |
1314 { | |
579 | 1315 SYS$CANCEL (input_fd); |
491 | 1316 return; |
1317 } | |
1318 | |
1319 SYS$SETAST (0); | |
1320 /* Clear a flag, and tell ast routine above to set it. */ | |
1321 SYS$CLREF (input_ef); | |
1322 waiting_for_ast = 1; | |
1323 stop_input = 1; | |
579 | 1324 SYS$CANCEL (input_fd); |
491 | 1325 SYS$SETAST (1); |
1326 SYS$WAITFR (input_ef); | |
1327 waiting_for_ast = 0; | |
1328 } | |
1329 | |
1330 /* Wait for either input available or time interval expiry. */ | |
1331 | |
1332 input_wait_timeout (timeval) | |
1333 int timeval; /* Time to wait, in seconds */ | |
1334 { | |
1335 int time [2]; | |
1336 static int zero = 0; | |
1337 static int large = -10000000; | |
1338 | |
1339 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
1340 | |
1341 /* If already something, avoid doing system calls. */ | |
1342 if (detect_input_pending ()) | |
1343 { | |
1344 return; | |
1345 } | |
1346 /* Clear a flag, and tell ast routine above to set it. */ | |
1347 SYS$CLREF (input_ef); | |
1348 waiting_for_ast = 1; | |
1349 /* Check for timing error: ast happened while we were doing that. */ | |
1350 if (!detect_input_pending ()) | |
1351 { | |
1352 /* No timing error: wait for flag to be set. */ | |
1353 SYS$CANTIM (1, 0); | |
1354 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
1355 SYS$WFLOR (timer_ef, timer_eflist); /* Wait for timer expiry or input */ | |
1356 } | |
1357 waiting_for_ast = 0; | |
1358 } | |
1359 | |
1360 /* The standard `sleep' routine works some other way | |
1361 and it stops working if you have ever quit out of it. | |
1362 This one continues to work. */ | |
1363 | |
1364 sys_sleep (timeval) | |
1365 int timeval; | |
1366 { | |
1367 int time [2]; | |
1368 static int zero = 0; | |
1369 static int large = -10000000; | |
1370 | |
1371 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
1372 | |
1373 SYS$CANTIM (1, 0); | |
1374 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
1375 SYS$WAITFR (timer_ef); /* Wait for timer expiry only */ | |
1376 } | |
1377 | |
1378 init_sigio () | |
1379 { | |
1380 request_sigio (); | |
1381 } | |
1382 | |
1383 reset_sigio () | |
1384 { | |
1385 unrequest_sigio (); | |
1386 } | |
1387 | |
1388 request_sigio () | |
1389 { | |
1390 croak ("request sigio"); | |
1391 } | |
1392 | |
1393 unrequest_sigio () | |
1394 { | |
1395 croak ("unrequest sigio"); | |
1396 } | |
1397 | |
1398 #endif /* VMS */ | |
1399 | |
1400 /* Note that VMS compiler won't accept defined (CANNOT_DUMP). */ | |
1401 #ifndef CANNOT_DUMP | |
1402 #define NEED_STARTS | |
1403 #endif | |
1404 | |
1405 #ifndef SYSTEM_MALLOC | |
1406 #ifndef NEED_STARTS | |
1407 #define NEED_STARTS | |
1408 #endif | |
1409 #endif | |
1410 | |
1411 #ifdef NEED_STARTS | |
1412 /* Some systems that cannot dump also cannot implement these. */ | |
1413 | |
1414 /* | |
1415 * Return the address of the start of the text segment prior to | |
1416 * doing an unexec. After unexec the return value is undefined. | |
1417 * See crt0.c for further explanation and _start. | |
1418 * | |
1419 */ | |
1420 | |
1421 #ifndef CANNOT_UNEXEC | |
1422 char * | |
1423 start_of_text () | |
1424 { | |
1425 #ifdef TEXT_START | |
1426 return ((char *) TEXT_START); | |
1427 #else | |
1428 #ifdef GOULD | |
1429 extern csrt (); | |
1430 return ((char *) csrt); | |
1431 #else /* not GOULD */ | |
1432 extern int _start (); | |
1433 return ((char *) _start); | |
1434 #endif /* GOULD */ | |
1435 #endif /* TEXT_START */ | |
1436 } | |
1437 #endif /* not CANNOT_UNEXEC */ | |
1438 | |
1439 /* | |
1440 * Return the address of the start of the data segment prior to | |
1441 * doing an unexec. After unexec the return value is undefined. | |
1442 * See crt0.c for further information and definition of data_start. | |
1443 * | |
1444 * Apparently, on BSD systems this is etext at startup. On | |
1445 * USG systems (swapping) this is highly mmu dependent and | |
1446 * is also dependent on whether or not the program is running | |
1447 * with shared text. Generally there is a (possibly large) | |
1448 * gap between end of text and start of data with shared text. | |
1449 * | |
1450 * On Uniplus+ systems with shared text, data starts at a | |
1451 * fixed address. Each port (from a given oem) is generally | |
1452 * different, and the specific value of the start of data can | |
1453 * be obtained via the UniPlus+ specific "uvar" system call, | |
1454 * however the method outlined in crt0.c seems to be more portable. | |
1455 * | |
1456 * Probably what will have to happen when a USG unexec is available, | |
1457 * at least on UniPlus, is temacs will have to be made unshared so | |
1458 * that text and data are contiguous. Then once loadup is complete, | |
1459 * unexec will produce a shared executable where the data can be | |
1460 * at the normal shared text boundry and the startofdata variable | |
1461 * will be patched by unexec to the correct value. | |
1462 * | |
1463 */ | |
1464 | |
1465 char * | |
1466 start_of_data () | |
1467 { | |
1468 #ifdef DATA_START | |
1469 return ((char *) DATA_START); | |
1470 #else | |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1471 #ifdef ORDINARY_LINK |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1472 /* |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1473 * 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
|
1474 * 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
|
1475 * 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
|
1476 * 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
|
1477 */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1478 extern char **environ; |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1479 |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1480 return((char *) &environ); |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1481 #else |
491 | 1482 extern int data_start; |
1483 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
|
1484 #endif /* ORDINARY_LINK */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1485 #endif /* DATA_START */ |
491 | 1486 } |
1487 #endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ | |
1488 | |
1489 #ifndef CANNOT_DUMP | |
1490 /* Some systems that cannot dump also cannot implement these. */ | |
1491 | |
1492 /* | |
1493 * Return the address of the end of the text segment prior to | |
1494 * doing an unexec. After unexec the return value is undefined. | |
1495 */ | |
1496 | |
1497 char * | |
1498 end_of_text () | |
1499 { | |
1500 #ifdef TEXT_END | |
1501 return ((char *) TEXT_END); | |
1502 #else | |
1503 extern int etext; | |
1504 return ((char *) &etext); | |
1505 #endif | |
1506 } | |
1507 | |
1508 /* | |
1509 * Return the address of the end of the data segment prior to | |
1510 * doing an unexec. After unexec the return value is undefined. | |
1511 */ | |
1512 | |
1513 char * | |
1514 end_of_data () | |
1515 { | |
1516 #ifdef DATA_END | |
1517 return ((char *) DATA_END); | |
1518 #else | |
1519 extern int edata; | |
1520 return ((char *) &edata); | |
1521 #endif | |
1522 } | |
1523 | |
1524 #endif /* not CANNOT_DUMP */ | |
1525 | |
1526 /* Get_system_name returns as its value | |
1527 a string for the Lisp function system-name to return. */ | |
1528 | |
1529 #ifdef BSD4_1 | |
1530 #include <whoami.h> | |
1531 #endif | |
1532 | |
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1533 /* Can't have this within the function since `static' is #defined to |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1534 nothing for some USG systems. */ |
491 | 1535 #ifdef USG |
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1536 #ifdef HAVE_GETHOSTNAME |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1537 static char get_system_name_name[256]; |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1538 #else /* not HAVE_GETHOSTNAME */ |
491 | 1539 static struct utsname get_system_name_name; |
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1540 #endif /* not HAVE_GETHOSTNAME */ |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1541 #endif /* USG */ |
491 | 1542 |
1543 char * | |
1544 get_system_name () | |
1545 { | |
1546 #ifdef USG | |
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1547 #ifdef HAVE_GETHOSTNAME |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1548 gethostname (get_system_name_name, sizeof (get_system_name_name)); |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1549 return get_system_name_name; |
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1550 #else /* not HAVE_GETHOSTNAME */ |
491 | 1551 uname (&get_system_name_name); |
1552 return (get_system_name_name.nodename); | |
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1553 #endif /* not HAVE_GETHOSTNAME */ |
491 | 1554 #else /* Not USG */ |
1555 #ifdef BSD4_1 | |
1556 return sysname; | |
1557 #else /* not USG, not 4.1 */ | |
1558 static char system_name_saved[32]; | |
1559 #ifdef VMS | |
1560 char *sp; | |
1561 if ((sp = egetenv ("SYS$NODE")) == 0) | |
1562 sp = "vax-vms"; | |
1563 else | |
1564 { | |
1565 char *end; | |
1566 | |
1567 if ((end = index (sp, ':')) != 0) | |
1568 *end = '\0'; | |
1569 } | |
1570 strcpy (system_name_saved, sp); | |
1571 #else /* not VMS */ | |
1572 gethostname (system_name_saved, sizeof (system_name_saved)); | |
1573 #endif /* not VMS */ | |
1574 return system_name_saved; | |
1575 #endif /* not USG, not 4.1 */ | |
1576 #endif /* not USG */ | |
1577 } | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1578 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1579 #ifdef VMS |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1580 #ifndef HAVE_GETHOSTNAME |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1581 void gethostname(buf, len) |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1582 char *buf; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1583 int len; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1584 { |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1585 char *s; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1586 s = getenv ("SYS$NODE"); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1587 if (s == NULL) |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1588 buf[0] = '\0'; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1589 else { |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1590 strncpy (buf, s, len - 2); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1591 buf[len - 1] = '\0'; |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1592 } /* else */ |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1593 } /* static void gethostname */ |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1594 #endif /* ! HAVE_GETHOSTNAME */ |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1595 #endif /* VMS */ |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1596 |
491 | 1597 |
1598 #ifndef VMS | |
1599 #ifndef HAVE_SELECT | |
1600 | |
1601 #ifdef HAVE_X_WINDOWS | |
1602 /* Cause explanatory error message at compile time, | |
1603 since the select emulation is not good enough for X. */ | |
1604 int *x = &x_windows_lose_if_no_select_system_call; | |
1605 #endif | |
1606 | |
1607 /* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs | |
1608 * Only checks read descriptors. | |
1609 */ | |
1610 /* How long to wait between checking fds in select */ | |
1611 #define SELECT_PAUSE 1 | |
1612 int select_alarmed; | |
1613 | |
1614 /* For longjmp'ing back to read_input_waiting. */ | |
1615 | |
1616 jmp_buf read_alarm_throw; | |
1617 | |
1618 /* Nonzero if the alarm signal should throw back to read_input_waiting. | |
1619 The read_socket_hook function sets this to 1 while it is waiting. */ | |
1620 | |
1621 int read_alarm_should_throw; | |
1622 | |
1623 SIGTYPE | |
1624 select_alarm () | |
1625 { | |
1626 select_alarmed = 1; | |
1627 #ifdef BSD4_1 | |
1628 sigrelse (SIGALRM); | |
1629 #else /* not BSD4_1 */ | |
1630 signal (SIGALRM, SIG_IGN); | |
1631 #endif /* not BSD4_1 */ | |
1632 if (read_alarm_should_throw) | |
1633 longjmp (read_alarm_throw, 1); | |
1634 } | |
1635 | |
1636 /* Only rfds are checked. */ | |
1637 int | |
1638 select (nfds, rfds, wfds, efds, timeout) | |
1639 int nfds; | |
1640 int *rfds, *wfds, *efds, *timeout; | |
1641 { | |
1642 int ravail = 0, orfds = 0, old_alarm; | |
1643 int timeoutval = timeout ? *timeout : 100000; | |
1644 int *local_timeout = &timeoutval; | |
1645 extern int proc_buffered_char[]; | |
1646 #ifndef subprocesses | |
1647 int process_tick = 0, update_tick = 0; | |
1648 #else | |
1649 extern int process_tick, update_tick; | |
1650 #endif | |
1651 SIGTYPE (*old_trap) (); | |
1652 unsigned char buf; | |
1653 | |
1654 if (rfds) | |
1655 { | |
1656 orfds = *rfds; | |
1657 *rfds = 0; | |
1658 } | |
1659 if (wfds) | |
1660 *wfds = 0; | |
1661 if (efds) | |
1662 *efds = 0; | |
1663 | |
1664 /* If we are looking only for the terminal, with no timeout, | |
1665 just read it and wait -- that's more efficient. */ | |
1666 if (orfds == 1 && *local_timeout == 100000 && process_tick == update_tick) | |
1667 { | |
1668 if (! detect_input_pending ()) | |
1669 read_input_waiting (); | |
1670 *rfds = 1; | |
1671 return 1; | |
1672 } | |
1673 | |
1674 /* Once a second, till the timer expires, check all the flagged read | |
1675 * descriptors to see if any input is available. If there is some then | |
1676 * set the corresponding bit in the return copy of rfds. | |
1677 */ | |
1678 while (1) | |
1679 { | |
1680 register int to_check, bit, fd; | |
1681 | |
1682 if (rfds) | |
1683 { | |
1684 for (to_check = nfds, bit = 1, fd = 0; --to_check >= 0; bit <<= 1, fd++) | |
1685 { | |
1686 if (orfds & bit) | |
1687 { | |
1688 int avail = 0, status = 0; | |
1689 | |
1690 if (bit == 1) | |
1691 avail = detect_input_pending (); /* Special keyboard handler */ | |
1692 else | |
1693 { | |
1694 #ifdef FIONREAD | |
1695 status = ioctl (fd, FIONREAD, &avail); | |
1696 #else /* no FIONREAD */ | |
1697 /* Hoping it will return -1 if nothing available | |
1698 or 0 if all 0 chars requested are read. */ | |
1699 if (proc_buffered_char[fd] >= 0) | |
1700 avail = 1; | |
1701 else | |
1702 { | |
1703 avail = read (fd, &buf, 1); | |
1704 if (avail > 0) | |
1705 proc_buffered_char[fd] = buf; | |
1706 } | |
1707 #endif /* no FIONREAD */ | |
1708 } | |
1709 if (status >= 0 && avail > 0) | |
1710 { | |
1711 (*rfds) |= bit; | |
1712 ravail++; | |
1713 } | |
1714 } | |
1715 } | |
1716 } | |
1717 if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick) | |
1718 break; | |
1719 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
|
1720 old_trap = signal (SIGALRM, select_alarm); |
491 | 1721 select_alarmed = 0; |
1722 alarm (SELECT_PAUSE); | |
1723 /* Wait for a SIGALRM (or maybe a SIGTINT) */ | |
1724 while (select_alarmed == 0 && *local_timeout != 0 | |
1725 && process_tick == update_tick) | |
1726 { | |
1727 /* If we are interested in terminal input, | |
1728 wait by reading the terminal. | |
1729 That makes instant wakeup for terminal input at least. */ | |
1730 if (orfds & 1) | |
1731 { | |
1732 read_input_waiting (); | |
1733 if (detect_input_pending ()) | |
1734 select_alarmed = 1; | |
1735 } | |
1736 else | |
1737 pause (); | |
1738 } | |
1739 (*local_timeout) -= SELECT_PAUSE; | |
1740 /* Reset the old alarm if there was one */ | |
1741 alarm (0); | |
1742 signal (SIGALRM, old_trap); | |
1743 if (old_alarm != 0) | |
1744 { | |
1745 /* Reset or forge an interrupt for the original handler. */ | |
1746 old_alarm -= SELECT_PAUSE; | |
1747 if (old_alarm <= 0) | |
1748 kill (getpid (), SIGALRM); /* Fake an alarm with the orig' handler */ | |
1749 else | |
1750 alarm (old_alarm); | |
1751 } | |
1752 if (*local_timeout == 0) /* Stop on timer being cleared */ | |
1753 break; | |
1754 } | |
1755 return ravail; | |
1756 } | |
1757 | |
1758 /* Read keyboard input into the standard buffer, | |
1759 waiting for at least one character. */ | |
1760 | |
1761 /* Make all keyboard buffers much bigger when using X windows. */ | |
1762 #ifdef HAVE_X_WINDOWS | |
1763 #define BUFFER_SIZE_FACTOR 16 | |
1764 #else | |
1765 #define BUFFER_SIZE_FACTOR 1 | |
1766 #endif | |
1767 | |
1768 read_input_waiting () | |
1769 { | |
1770 char buf[256 * BUFFER_SIZE_FACTOR]; | |
1771 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
|
1772 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
|
1773 extern int quit_char; |
491 | 1774 |
1775 if (read_socket_hook) | |
1776 { | |
1777 read_alarm_should_throw = 0; | |
1778 if (! setjmp (read_alarm_throw)) | |
1779 nread = (*read_socket_hook) (0, buf, 256 * BUFFER_SIZE_FACTOR, 1, 0); | |
1780 else | |
1781 nread = -1; | |
1782 } | |
1783 else | |
1784 nread = read (fileno (stdin), buf, 1); | |
1785 | |
1786 /* Scan the chars for C-g and store them in kbd_buffer. */ | |
1787 e.kind = ascii_keystroke; | |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1788 e.frame_or_window = selected_frame; |
2589
5f41134610a6
(read_pending_input): Fix the garbaged-modifiers bug under System Vs previous
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2439
diff
changeset
|
1789 e.modifiers = 0; |
491 | 1790 for (i = 0; i < nread; i++) |
1791 { | |
1792 XSET (e.code, Lisp_Int, buf[i]); | |
1793 kbd_buffer_store_event (&e); | |
1794 /* Don't look at input that follows a C-g too closely. | |
1795 This reduces lossage due to autorepeat on C-g. */ | |
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
1796 if (buf[i] == quit_char) |
491 | 1797 break; |
1798 } | |
1799 } | |
1800 | |
1801 #endif /* not HAVE_SELECT */ | |
1802 #endif /* not VMS */ | |
1803 | |
1804 #ifdef BSD4_1 | |
1805 /* | |
1806 * Partially emulate 4.2 open call. | |
1807 * open is defined as this in 4.1. | |
1808 * | |
1809 * - added by Michael Bloom @ Citicorp/TTI | |
1810 * | |
1811 */ | |
1812 | |
1813 int | |
1814 sys_open (path, oflag, mode) | |
1815 char *path; | |
1816 int oflag, mode; | |
1817 { | |
1818 if (oflag & O_CREAT) | |
1819 return creat (path, mode); | |
1820 else | |
1821 return open (path, oflag); | |
1822 } | |
1823 | |
1824 init_sigio () | |
1825 { | |
1826 if (noninteractive) | |
1827 return; | |
1828 lmode = LINTRUP | lmode; | |
1829 ioctl (0, TIOCLSET, &lmode); | |
1830 } | |
1831 | |
1832 reset_sigio () | |
1833 { | |
1834 if (noninteractive) | |
1835 return; | |
1836 lmode = ~LINTRUP & lmode; | |
1837 ioctl (0, TIOCLSET, &lmode); | |
1838 } | |
1839 | |
1840 request_sigio () | |
1841 { | |
1842 sigrelse (SIGTINT); | |
1843 | |
1844 interrupts_deferred = 0; | |
1845 } | |
1846 | |
1847 unrequest_sigio () | |
1848 { | |
1849 sighold (SIGTINT); | |
1850 | |
1851 interrupts_deferred = 1; | |
1852 } | |
1853 | |
1854 /* still inside #ifdef BSD4_1 */ | |
1855 #ifdef subprocesses | |
1856 | |
1857 int sigheld; /* Mask of held signals */ | |
1858 | |
1859 sigholdx (signum) | |
1860 int signum; | |
1861 { | |
1862 sigheld |= sigbit (signum); | |
1863 sighold (signum); | |
1864 } | |
1865 | |
1866 sigisheld (signum) | |
1867 int signum; | |
1868 { | |
1869 sigheld |= sigbit (signum); | |
1870 } | |
1871 | |
1872 sigunhold (signum) | |
1873 int signum; | |
1874 { | |
1875 sigheld &= ~sigbit (signum); | |
1876 sigrelse (signum); | |
1877 } | |
1878 | |
1879 sigfree () /* Free all held signals */ | |
1880 { | |
1881 int i; | |
1882 for (i = 0; i < NSIG; i++) | |
1883 if (sigheld & sigbit (i)) | |
1884 sigrelse (i); | |
1885 sigheld = 0; | |
1886 } | |
1887 | |
1888 sigbit (i) | |
1889 { | |
1890 return 1 << (i - 1); | |
1891 } | |
1892 #endif /* subprocesses */ | |
1893 #endif /* BSD4_1 */ | |
1894 | |
1895 /* POSIX signals support - DJB */ | |
1896 /* Anyone with POSIX signals should have ANSI C declarations */ | |
1897 | |
1898 #ifdef POSIX_SIGNALS | |
1899 | |
1900 sigset_t old_mask, empty_mask, full_mask, temp_mask; | |
1901 static struct sigaction new_action, old_action; | |
1902 | |
1903 init_signals () | |
1904 { | |
1905 #ifdef POSIX_SIGNALS | |
1906 sigemptyset (&signal_empty_mask); | |
1907 sigfillset (&signal_full_mask); | |
1908 #endif | |
1909 } | |
1910 | |
1911 int (*signal_handler_t) (); | |
1912 | |
1913 signal_handler_t | |
1914 sys_signal (int signal_number, signal_handler_t action) | |
1915 { | |
1916 #ifdef DGUX | |
1917 /* This gets us restartable system calls for efficiency. | |
1918 The "else" code will works as well. */ | |
1919 return (berk_signal (signal_number, action)); | |
1920 #else | |
1921 sigemptyset (&new_action.sa_mask); | |
1922 new_action.sa_handler = action; | |
1923 new_action.sa_flags = NULL; | |
709 | 1924 sigaction (signal_number, &new_action, &old_action); |
491 | 1925 return (old_action.sa_handler); |
1926 #endif /* DGUX */ | |
1927 } | |
1928 | |
638 | 1929 #ifndef __GNUC__ |
1930 /* If we're compiling with GCC, we don't need this function, since it | |
1931 can be written as a macro. */ | |
1932 sigset_t | |
1933 sys_sigmask (int sig) | |
1934 { | |
1935 sigset_t mask; | |
1936 sigemptyset (&mask); | |
1937 sigaddset (&mask, sig); | |
1938 return mask; | |
1939 } | |
1940 #endif | |
1941 | |
491 | 1942 int |
1943 sys_sigpause (sigset_t new_mask) | |
1944 { | |
1945 /* pause emulating berk sigpause... */ | |
1946 sigsuspend (&new_mask); | |
1947 return (EINTR); | |
1948 } | |
1949 | |
1950 /* I'd like to have these guys return pointers to the mask storage in here, | |
1951 but there'd be trouble if the code was saving multiple masks. I'll be | |
1952 safe and pass the structure. It normally won't be more than 2 bytes | |
1953 anyhow. - DJB */ | |
1954 | |
1955 sigset_t | |
1956 sys_sigblock (sigset_t new_mask) | |
1957 { | |
1958 sigset_t old_mask; | |
1959 sigprocmask (SIG_BLOCK, &new_mask, &old_mask); | |
1960 return (old_mask); | |
1961 } | |
1962 | |
1963 sigset_t | |
1964 sys_sigunblock (sigset_t new_mask) | |
1965 { | |
1966 sigset_t old_mask; | |
1967 sigprocmask (SIG_UNBLOCK, &new_mask, &old_mask); | |
1968 return (old_mask); | |
1969 } | |
1970 | |
1971 sigset_t | |
1972 sys_sigsetmask (sigset_t new_mask) | |
1973 { | |
1974 sigset_t old_mask; | |
1975 sigprocmask (SIG_SETMASK, &new_mask, &old_mask); | |
1976 return (old_mask); | |
1977 } | |
1978 | |
1979 #endif /* POSIX_SIGNALS */ | |
1980 | |
1981 #ifndef BSTRING | |
1982 | |
1983 void | |
1984 bzero (b, length) | |
1985 register char *b; | |
1986 register int length; | |
1987 { | |
1988 #ifdef VMS | |
1989 short zero = 0; | |
1990 long max_str = 65535; | |
1991 | |
1992 while (length > max_str) { | |
1993 (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); | |
1994 length -= max_str; | |
1995 b += max_str; | |
1996 } | |
1997 max_str = length; | |
1998 (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); | |
1999 #else | |
2000 while (length-- > 0) | |
2001 *b++ = 0; | |
2002 #endif /* not VMS */ | |
2003 } | |
2004 | |
2005 /* Saying `void' requires a declaration, above, where bcopy is used | |
2006 and that declaration causes pain for systems where bcopy is a macro. */ | |
2007 bcopy (b1, b2, length) | |
2008 register char *b1; | |
2009 register char *b2; | |
2010 register int length; | |
2011 { | |
2012 #ifdef VMS | |
2013 long max_str = 65535; | |
2014 | |
2015 while (length > max_str) { | |
2016 (void) LIB$MOVC3 (&max_str, b1, b2); | |
2017 length -= max_str; | |
2018 b1 += max_str; | |
2019 b2 += max_str; | |
2020 } | |
2021 max_str = length; | |
2022 (void) LIB$MOVC3 (&length, b1, b2); | |
2023 #else | |
2024 while (length-- > 0) | |
2025 *b2++ = *b1++; | |
2026 #endif /* not VMS */ | |
2027 } | |
2028 | |
2029 int | |
2030 bcmp (b1, b2, length) /* This could be a macro! */ | |
2031 register char *b1; | |
2032 register char *b2; | |
2033 register int length; | |
2034 { | |
2035 #ifdef VMS | |
2036 struct dsc$descriptor_s src1 = {length, DSC$K_DTYPE_T, DSC$K_CLASS_S, b1}; | |
2037 struct dsc$descriptor_s src2 = {length, DSC$K_DTYPE_T, DSC$K_CLASS_S, b2}; | |
2038 | |
2039 return STR$COMPARE (&src1, &src2); | |
2040 #else | |
2041 while (length-- > 0) | |
2042 if (*b1++ != *b2++) | |
2043 return 1; | |
2044 | |
2045 return 0; | |
2046 #endif /* not VMS */ | |
2047 } | |
2048 #endif /* not BSTRING */ | |
2049 | |
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
2050 #ifndef HAVE_RANDOM |
491 | 2051 #ifdef USG |
2052 /* | |
2053 * The BSD random returns numbers in the range of | |
2054 * 0 to 2e31 - 1. The USG rand returns numbers in the | |
2055 * range of 0 to 2e15 - 1. This is probably not significant | |
2056 * in this usage. | |
2057 */ | |
2058 | |
2059 long | |
2060 random () | |
2061 { | |
2062 /* Arrange to return a range centered on zero. */ | |
2063 return (rand () << 15) + rand () - (1 << 29); | |
2064 } | |
2065 | |
2066 srandom (arg) | |
2067 int arg; | |
2068 { | |
2069 srand (arg); | |
2070 } | |
2071 | |
2072 #endif /* USG */ | |
2073 | |
2074 #ifdef BSD4_1 | |
2075 long random () | |
2076 { | |
2077 /* Arrange to return a range centered on zero. */ | |
2078 return (rand () << 15) + rand () - (1 << 29); | |
2079 } | |
2080 | |
2081 srandom (arg) | |
2082 int arg; | |
2083 { | |
2084 srand (arg); | |
2085 } | |
2086 #endif /* BSD4_1 */ | |
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
2087 #endif |
491 | 2088 |
2089 #ifdef WRONG_NAME_INSQUE | |
2090 | |
2091 insque (q,p) | |
2092 caddr_t q,p; | |
2093 { | |
2094 _insque (q,p); | |
2095 } | |
2096 | |
2097 #endif | |
2098 | |
2099 #ifdef VMS | |
2100 | |
2101 #ifdef getenv | |
2102 /* If any place else asks for the TERM variable, | |
2103 allow it to be overridden with the EMACS_TERM variable | |
2104 before attempting to translate the logical name TERM. As a last | |
2105 resort, ask for VAX C's special idea of the TERM variable. */ | |
2106 #undef getenv | |
2107 char * | |
2108 sys_getenv (name) | |
2109 char *name; | |
2110 { | |
2111 register char *val; | |
2112 static char buf[256]; | |
2113 static struct dsc$descriptor_s equiv | |
2114 = {sizeof (buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf}; | |
2115 static struct dsc$descriptor_s d_name | |
2116 = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; | |
2117 short eqlen; | |
2118 | |
2119 if (!strcmp (name, "TERM")) | |
2120 { | |
2121 val = (char *) getenv ("EMACS_TERM"); | |
2122 if (val) | |
2123 return val; | |
2124 } | |
2125 | |
2126 d_name.dsc$w_length = strlen (name); | |
2127 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
|
2128 if (LIB$SYS_TRNLOG (&d_name, &eqlen, &equiv) == 1) |
491 | 2129 { |
2130 char *str = (char *) xmalloc (eqlen + 1); | |
2131 bcopy (buf, str, eqlen); | |
2132 str[eqlen] = '\0'; | |
2133 /* This is a storage leak, but a pain to fix. With luck, | |
2134 no one will ever notice. */ | |
2135 return str; | |
2136 } | |
2137 return (char *) getenv (name); | |
2138 } | |
2139 #endif /* getenv */ | |
2140 | |
2141 #ifdef abort | |
2142 /* Since VMS doesn't believe in core dumps, the only way to debug this beast is | |
2143 to force a call on the debugger from within the image. */ | |
2144 #undef abort | |
2145 sys_abort () | |
2146 { | |
2147 reset_sys_modes (); | |
2148 LIB$SIGNAL (SS$_DEBUG); | |
2149 } | |
2150 #endif /* abort */ | |
2151 #endif /* VMS */ | |
2152 | |
2153 #ifdef VMS | |
2154 #ifdef LINK_CRTL_SHARE | |
2155 #ifdef SHAREABLE_LIB_BUG | |
2156 /* Variables declared noshare and initialized in shareable libraries | |
2157 cannot be shared. The VMS linker incorrectly forces you to use a private | |
2158 version which is uninitialized... If not for this "feature", we | |
2159 could use the C library definition of sys_nerr and sys_errlist. */ | |
2160 int sys_nerr = 35; | |
2161 char *sys_errlist[] = | |
2162 { | |
2163 "error 0", | |
2164 "not owner", | |
2165 "no such file or directory", | |
2166 "no such process", | |
2167 "interrupted system call", | |
2168 "i/o error", | |
2169 "no such device or address", | |
2170 "argument list too long", | |
2171 "exec format error", | |
2172 "bad file number", | |
2173 "no child process", | |
2174 "no more processes", | |
2175 "not enough memory", | |
2176 "permission denied", | |
2177 "bad address", | |
2178 "block device required", | |
2179 "mount devices busy", | |
2180 "file exists", | |
2181 "cross-device link", | |
2182 "no such device", | |
2183 "not a directory", | |
2184 "is a directory", | |
2185 "invalid argument", | |
2186 "file table overflow", | |
2187 "too many open files", | |
2188 "not a typewriter", | |
2189 "text file busy", | |
2190 "file too big", | |
2191 "no space left on device", | |
2192 "illegal seek", | |
2193 "read-only file system", | |
2194 "too many links", | |
2195 "broken pipe", | |
2196 "math argument", | |
2197 "result too large", | |
2198 "I/O stream empty", | |
2199 "vax/vms specific error code nontranslatable error" | |
2200 }; | |
2201 #endif /* SHAREABLE_LIB_BUG */ | |
2202 #endif /* LINK_CRTL_SHARE */ | |
2203 #endif /* VMS */ | |
2204 | |
2205 #ifdef INTERRUPTIBLE_OPEN | |
2206 | |
2207 int | |
2208 /* VARARGS 2 */ | |
2209 sys_open (path, oflag, mode) | |
2210 char *path; | |
2211 int oflag, mode; | |
2212 { | |
2213 register int rtnval; | |
2214 | |
2215 while ((rtnval = open (path, oflag, mode)) == -1 | |
2216 && (errno == EINTR)); | |
2217 return (rtnval); | |
2218 } | |
2219 | |
2220 #endif /* INTERRUPTIBLE_OPEN */ | |
2221 | |
2222 #ifdef INTERRUPTIBLE_CLOSE | |
2223 | |
2224 sys_close (fd) | |
2225 int fd; | |
2226 { | |
2227 register int rtnval; | |
2228 | |
2229 while ((rtnval = close (fd)) == -1 | |
2230 && (errno == EINTR)); | |
2231 return rtnval; | |
2232 } | |
2233 | |
2234 #endif /* INTERRUPTIBLE_CLOSE */ | |
2235 | |
2236 #ifdef INTERRUPTIBLE_IO | |
2237 | |
2238 int | |
2239 sys_read (fildes, buf, nbyte) | |
2240 int fildes; | |
2241 char *buf; | |
2242 unsigned int nbyte; | |
2243 { | |
2244 register int rtnval; | |
2245 | |
2246 while ((rtnval = read (fildes, buf, nbyte)) == -1 | |
2247 && (errno == EINTR)); | |
2248 return (rtnval); | |
2249 } | |
2250 | |
2251 int | |
2252 sys_write (fildes, buf, nbyte) | |
2253 int fildes; | |
2254 char *buf; | |
2255 unsigned int nbyte; | |
2256 { | |
2257 register int rtnval; | |
2258 | |
2259 while ((rtnval = write (fildes, buf, nbyte)) == -1 | |
2260 && (errno == EINTR)); | |
2261 return (rtnval); | |
2262 } | |
2263 | |
2264 #endif /* INTERRUPTIBLE_IO */ | |
2265 | |
2266 #ifdef USG | |
2267 /* | |
2268 * All of the following are for USG. | |
2269 * | |
2270 * On USG systems the system calls are INTERRUPTIBLE by signals | |
2271 * that the user program has elected to catch. Thus the system call | |
2272 * must be retried in these cases. To handle this without massive | |
2273 * changes in the source code, we remap the standard system call names | |
2274 * to names for our own functions in sysdep.c that do the system call | |
2275 * with retries. Actually, for portability reasons, it is good | |
2276 * programming practice, as this example shows, to limit all actual | |
2277 * system calls to a single occurance in the source. Sure, this | |
2278 * adds an extra level of function call overhead but it is almost | |
2279 * always negligible. Fred Fish, Unisoft Systems Inc. | |
2280 */ | |
2281 | |
2282 char *sys_siglist[NSIG + 1] = | |
2283 { | |
2284 #ifdef AIX | |
2285 /* AIX has changed the signals a bit */ | |
2286 "bogus signal", /* 0 */ | |
2287 "hangup", /* 1 SIGHUP */ | |
2288 "interrupt", /* 2 SIGINT */ | |
2289 "quit", /* 3 SIGQUIT */ | |
2290 "illegal instruction", /* 4 SIGILL */ | |
2291 "trace trap", /* 5 SIGTRAP */ | |
2292 "IOT instruction", /* 6 SIGIOT */ | |
2293 "crash likely", /* 7 SIGDANGER */ | |
2294 "floating point exception", /* 8 SIGFPE */ | |
2295 "kill", /* 9 SIGKILL */ | |
2296 "bus error", /* 10 SIGBUS */ | |
2297 "segmentation violation", /* 11 SIGSEGV */ | |
2298 "bad argument to system call", /* 12 SIGSYS */ | |
2299 "write on a pipe with no one to read it", /* 13 SIGPIPE */ | |
2300 "alarm clock", /* 14 SIGALRM */ | |
2301 "software termination signum", /* 15 SIGTERM */ | |
2302 "user defined signal 1", /* 16 SIGUSR1 */ | |
2303 "user defined signal 2", /* 17 SIGUSR2 */ | |
2304 "death of a child", /* 18 SIGCLD */ | |
2305 "power-fail restart", /* 19 SIGPWR */ | |
2306 "bogus signal", /* 20 */ | |
2307 "bogus signal", /* 21 */ | |
2308 "bogus signal", /* 22 */ | |
2309 "bogus signal", /* 23 */ | |
2310 "bogus signal", /* 24 */ | |
2311 "LAN I/O interrupt", /* 25 SIGAIO */ | |
2312 "PTY I/O interrupt", /* 26 SIGPTY */ | |
2313 "I/O intervention required", /* 27 SIGIOINT */ | |
2314 "HFT grant", /* 28 SIGGRANT */ | |
2315 "HFT retract", /* 29 SIGRETRACT */ | |
2316 "HFT sound done", /* 30 SIGSOUND */ | |
2317 "HFT input ready", /* 31 SIGMSG */ | |
2318 #else /* not AIX */ | |
2319 "bogus signal", /* 0 */ | |
2320 "hangup", /* 1 SIGHUP */ | |
2321 "interrupt", /* 2 SIGINT */ | |
2322 "quit", /* 3 SIGQUIT */ | |
2323 "illegal instruction", /* 4 SIGILL */ | |
2324 "trace trap", /* 5 SIGTRAP */ | |
2325 "IOT instruction", /* 6 SIGIOT */ | |
2326 "EMT instruction", /* 7 SIGEMT */ | |
2327 "floating point exception", /* 8 SIGFPE */ | |
2328 "kill", /* 9 SIGKILL */ | |
2329 "bus error", /* 10 SIGBUS */ | |
2330 "segmentation violation", /* 11 SIGSEGV */ | |
2331 "bad argument to system call", /* 12 SIGSYS */ | |
2332 "write on a pipe with no one to read it", /* 13 SIGPIPE */ | |
2333 "alarm clock", /* 14 SIGALRM */ | |
2334 "software termination signum", /* 15 SIGTERM */ | |
2335 "user defined signal 1", /* 16 SIGUSR1 */ | |
2336 "user defined signal 2", /* 17 SIGUSR2 */ | |
2337 "death of a child", /* 18 SIGCLD */ | |
2338 "power-fail restart", /* 19 SIGPWR */ | |
2339 #endif /* not AIX */ | |
2340 0 | |
2341 }; | |
2342 | |
2343 /* | |
2344 * Warning, this function may not duplicate 4.2 action properly | |
2345 * under error conditions. | |
2346 */ | |
2347 | |
2348 #ifndef MAXPATHLEN | |
2349 /* In 4.1, param.h fails to define this. */ | |
2350 #define MAXPATHLEN 1024 | |
2351 #endif | |
2352 | |
2353 #ifndef HAVE_GETWD | |
2354 | |
2355 char * | |
2356 getwd (pathname) | |
2357 char *pathname; | |
2358 { | |
2359 char *npath, *spath; | |
2360 extern char *getcwd (); | |
2361 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2362 BLOCK_INPUT; /* getcwd uses malloc */ |
491 | 2363 spath = npath = getcwd ((char *) 0, MAXPATHLEN); |
2364 /* On Altos 3068, getcwd can return @hostname/dir, so discard | |
2365 up to first slash. Should be harmless on other systems. */ | |
2366 while (*npath && *npath != '/') | |
2367 npath++; | |
2368 strcpy (pathname, npath); | |
2369 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
|
2370 UNBLOCK_INPUT; |
491 | 2371 return pathname; |
2372 } | |
2373 | |
2374 #endif /* HAVE_GETWD */ | |
2375 | |
2376 /* | |
2377 * Emulate rename using unlink/link. Note that this is | |
2378 * only partially correct. Also, doesn't enforce restriction | |
2379 * that files be of same type (regular->regular, dir->dir, etc). | |
2380 */ | |
2381 | |
621 | 2382 #ifndef HAVE_RENAME |
2383 | |
491 | 2384 rename (from, to) |
2385 char *from; | |
2386 char *to; | |
2387 { | |
2388 if (access (from, 0) == 0) | |
2389 { | |
2390 unlink (to); | |
2391 if (link (from, to) == 0) | |
2392 if (unlink (from) == 0) | |
2393 return (0); | |
2394 } | |
2395 return (-1); | |
2396 } | |
2397 | |
621 | 2398 #endif |
2399 | |
491 | 2400 #ifndef HAVE_VFORK |
2401 | |
2402 /* | |
2403 * Substitute fork for vfork on USG flavors. | |
2404 */ | |
2405 | |
2406 vfork () | |
2407 { | |
2408 return (fork ()); | |
2409 } | |
2410 | |
2411 #endif /* not HAVE_VFORK */ | |
2412 | |
2413 #ifdef MISSING_UTIMES | |
2414 | |
2415 /* HPUX (among others) sets HAVE_TIMEVAL but does not implement utimes. */ | |
2416 | |
2417 utimes () | |
2418 { | |
2419 } | |
2420 #endif | |
2421 | |
2422 #ifdef IRIS_UTIME | |
2423 | |
2424 /* The IRIS (3.5) has timevals, but uses sys V utime, and doesn't have the | |
2425 utimbuf structure defined anywhere but in the man page. */ | |
2426 | |
2427 struct utimbuf | |
2428 { | |
2429 long actime; | |
2430 long modtime; | |
2431 }; | |
2432 | |
2433 utimes (name, tvp) | |
2434 char *name; | |
2435 struct timeval tvp[]; | |
2436 { | |
2437 struct utimbuf utb; | |
2438 utb.actime = tvp[0].tv_sec; | |
2439 utb.modtime = tvp[1].tv_sec; | |
2440 utime (name, &utb); | |
2441 } | |
2442 #endif /* IRIS_UTIME */ | |
2443 | |
2444 | |
2445 #ifdef HPUX | |
2446 #ifndef HAVE_PERROR | |
2447 | |
2448 /* HPUX curses library references perror, but as far as we know | |
2449 it won't be called. Anyway this definition will do for now. */ | |
2450 | |
2451 perror () | |
2452 { | |
2453 } | |
2454 | |
2455 #endif /* not HAVE_PERROR */ | |
2456 #endif /* HPUX */ | |
2457 | |
2458 #ifndef HAVE_DUP2 | |
2459 | |
2460 /* | |
2461 * Emulate BSD dup2. First close newd if it already exists. | |
2462 * Then, attempt to dup oldd. If not successful, call dup2 recursively | |
2463 * until we are, then close the unsuccessful ones. | |
2464 */ | |
2465 | |
2466 dup2 (oldd, newd) | |
2467 int oldd; | |
2468 int newd; | |
2469 { | |
2470 register int fd, ret; | |
2471 | |
2472 sys_close (newd); | |
2473 | |
2474 #ifdef F_DUPFD | |
2475 fd = fcntl (oldd, F_DUPFD, newd); | |
2476 if (fd != newd) | |
2477 error ("can't dup2 (%i,%i) : %s", oldd, newd, sys_errlist[errno]); | |
2478 #else | |
2479 fd = dup (old); | |
2480 if (fd == -1) | |
2481 return -1; | |
2482 if (fd == new) | |
2483 return new; | |
2484 ret = dup2 (old,new); | |
2485 sys_close (fd); | |
2486 return ret; | |
2487 #endif | |
2488 } | |
2489 | |
2490 #endif /* not HAVE_DUP2 */ | |
2491 | |
2492 /* | |
2493 * Gettimeofday. Simulate as much as possible. Only accurate | |
2494 * to nearest second. Emacs doesn't use tzp so ignore it for now. | |
2495 * Only needed when subprocesses are defined. | |
2496 */ | |
2497 | |
2498 #ifdef subprocesses | |
2499 #ifndef VMS | |
2500 #ifndef HAVE_GETTIMEOFDAY | |
2501 #ifdef HAVE_TIMEVAL | |
2502 | |
2503 /* ARGSUSED */ | |
2504 gettimeofday (tp, tzp) | |
2505 struct timeval *tp; | |
2506 struct timezone *tzp; | |
2507 { | |
2508 extern long time (); | |
2509 | |
2510 tp->tv_sec = time ((long *)0); | |
2511 tp->tv_usec = 0; | |
2512 tzp->tz_minuteswest = -1; | |
2513 } | |
2514 | |
2515 #endif | |
2516 #endif | |
2517 #endif | |
2518 #endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL && !VMS */ | |
2519 | |
2520 /* | |
2521 * This function will go away as soon as all the stubs fixed. (fnf) | |
2522 */ | |
2523 | |
2524 croak (badfunc) | |
2525 char *badfunc; | |
2526 { | |
2527 printf ("%s not yet implemented\r\n", badfunc); | |
2528 reset_sys_modes (); | |
2529 exit (1); | |
2530 } | |
2531 | |
2532 #endif /* USG */ | |
2533 | |
2534 #ifdef DGUX | |
2535 | |
2536 char *sys_siglist[NSIG + 1] = | |
2537 { | |
2538 "null signal", /* 0 SIGNULL */ | |
2539 "hangup", /* 1 SIGHUP */ | |
2540 "interrupt", /* 2 SIGINT */ | |
2541 "quit", /* 3 SIGQUIT */ | |
2542 "illegal instruction", /* 4 SIGILL */ | |
2543 "trace trap", /* 5 SIGTRAP */ | |
2544 "abort termination", /* 6 SIGABRT */ | |
2545 "SIGEMT", /* 7 SIGEMT */ | |
2546 "floating point exception", /* 8 SIGFPE */ | |
2547 "kill", /* 9 SIGKILL */ | |
2548 "bus error", /* 10 SIGBUS */ | |
2549 "segmentation violation", /* 11 SIGSEGV */ | |
2550 "bad argument to system call", /* 12 SIGSYS */ | |
2551 "write on a pipe with no reader", /* 13 SIGPIPE */ | |
2552 "alarm clock", /* 14 SIGALRM */ | |
2553 "software termination signal", /* 15 SIGTERM */ | |
2554 "user defined signal 1", /* 16 SIGUSR1 */ | |
2555 "user defined signal 2", /* 17 SIGUSR2 */ | |
2556 "child stopped or terminated", /* 18 SIGCLD */ | |
2557 "power-fail restart", /* 19 SIGPWR */ | |
2558 "window size changed", /* 20 SIGWINCH */ | |
2559 "undefined", /* 21 */ | |
2560 "pollable event occured", /* 22 SIGPOLL */ | |
2561 "sendable stop signal not from tty", /* 23 SIGSTOP */ | |
2562 "stop signal from tty", /* 24 SIGSTP */ | |
2563 "continue a stopped process", /* 25 SIGCONT */ | |
2564 "attempted background tty read", /* 26 SIGTTIN */ | |
2565 "attempted background tty write", /* 27 SIGTTOU */ | |
2566 "undefined", /* 28 */ | |
2567 "undefined", /* 29 */ | |
2568 "undefined", /* 30 */ | |
2569 "undefined", /* 31 */ | |
2570 "undefined", /* 32 */ | |
2571 "socket (TCP/IP) urgent data arrival", /* 33 SIGURG */ | |
2572 "I/O is possible", /* 34 SIGIO */ | |
2573 "exceeded cpu time limit", /* 35 SIGXCPU */ | |
2574 "exceeded file size limit", /* 36 SIGXFSZ */ | |
2575 "virtual time alarm", /* 37 SIGVTALRM */ | |
2576 "profiling time alarm", /* 38 SIGPROF */ | |
2577 "undefined", /* 39 */ | |
2578 "file record locks revoked", /* 40 SIGLOST */ | |
2579 "undefined", /* 41 */ | |
2580 "undefined", /* 42 */ | |
2581 "undefined", /* 43 */ | |
2582 "undefined", /* 44 */ | |
2583 "undefined", /* 45 */ | |
2584 "undefined", /* 46 */ | |
2585 "undefined", /* 47 */ | |
2586 "undefined", /* 48 */ | |
2587 "undefined", /* 49 */ | |
2588 "undefined", /* 50 */ | |
2589 "undefined", /* 51 */ | |
2590 "undefined", /* 52 */ | |
2591 "undefined", /* 53 */ | |
2592 "undefined", /* 54 */ | |
2593 "undefined", /* 55 */ | |
2594 "undefined", /* 56 */ | |
2595 "undefined", /* 57 */ | |
2596 "undefined", /* 58 */ | |
2597 "undefined", /* 59 */ | |
2598 "undefined", /* 60 */ | |
2599 "undefined", /* 61 */ | |
2600 "undefined", /* 62 */ | |
2601 "undefined", /* 63 */ | |
2602 "notification message in mess. queue", /* 64 SIGDGNOTIFY */ | |
2603 0 | |
2604 }; | |
2605 | |
2606 #endif /* DGUX */ | |
2607 | |
2608 /* Directory routines for systems that don't have them. */ | |
2609 | |
2610 #ifdef SYSV_SYSTEM_DIR | |
2611 | |
2612 #include <dirent.h> | |
2613 | |
2614 #ifndef AIX | |
2615 int | |
2616 closedir (dirp) | |
2617 register DIR *dirp; /* stream from opendir */ | |
2618 { | |
2619 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
|
2620 xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */ |
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2621 xfree ((char *) dirp); |
491 | 2622 } |
2623 #endif /* not AIX */ | |
2624 #endif /* SYSV_SYSTEM_DIR */ | |
2625 | |
2626 #ifdef NONSYSTEM_DIR_LIBRARY | |
2627 | |
2628 DIR * | |
2629 opendir (filename) | |
2630 char *filename; /* name of directory */ | |
2631 { | |
2632 register DIR *dirp; /* -> malloc'ed storage */ | |
2633 register int fd; /* file descriptor for read */ | |
2634 struct stat sbuf; /* result of fstat */ | |
2635 | |
2636 fd = sys_open (filename, 0); | |
2637 if (fd < 0) | |
2638 return 0; | |
2639 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2640 BLOCK_INPUT; |
491 | 2641 if (fstat (fd, &sbuf) < 0 |
2642 || (sbuf.st_mode & S_IFMT) != S_IFDIR | |
2643 || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) | |
2644 { | |
2645 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
|
2646 UNBLOCK_INPUT; |
491 | 2647 return 0; /* bad luck today */ |
2648 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2649 UNBLOCK_INPUT; |
491 | 2650 |
2651 dirp->dd_fd = fd; | |
2652 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ | |
2653 | |
2654 return dirp; | |
2655 } | |
2656 | |
2657 void | |
2658 closedir (dirp) | |
2659 register DIR *dirp; /* stream from opendir */ | |
2660 { | |
2661 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
|
2662 xfree ((char *) dirp); |
491 | 2663 } |
2664 | |
2665 | |
2666 #ifndef VMS | |
2667 #define DIRSIZ 14 | |
2668 struct olddir | |
2669 { | |
2670 ino_t od_ino; /* inode */ | |
2671 char od_name[DIRSIZ]; /* filename */ | |
2672 }; | |
2673 #endif /* not VMS */ | |
2674 | |
2675 struct direct dir_static; /* simulated directory contents */ | |
2676 | |
2677 /* ARGUSED */ | |
2678 struct direct * | |
2679 readdir (dirp) | |
2680 register DIR *dirp; /* stream from opendir */ | |
2681 { | |
2682 #ifndef VMS | |
2683 register struct olddir *dp; /* -> directory data */ | |
2684 #else /* VMS */ | |
2685 register struct dir$_name *dp; /* -> directory data */ | |
2686 register struct dir$_version *dv; /* -> version data */ | |
2687 #endif /* VMS */ | |
2688 | |
2689 for (; ;) | |
2690 { | |
2691 if (dirp->dd_loc >= dirp->dd_size) | |
2692 dirp->dd_loc = dirp->dd_size = 0; | |
2693 | |
2694 if (dirp->dd_size == 0 /* refill buffer */ | |
2695 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
2696 return 0; | |
2697 | |
2698 #ifndef VMS | |
2699 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; | |
2700 dirp->dd_loc += sizeof (struct olddir); | |
2701 | |
2702 if (dp->od_ino != 0) /* not deleted entry */ | |
2703 { | |
2704 dir_static.d_ino = dp->od_ino; | |
2705 strncpy (dir_static.d_name, dp->od_name, DIRSIZ); | |
2706 dir_static.d_name[DIRSIZ] = '\0'; | |
2707 dir_static.d_namlen = strlen (dir_static.d_name); | |
2708 dir_static.d_reclen = sizeof (struct direct) | |
2709 - MAXNAMLEN + 3 | |
2710 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
2711 return &dir_static; /* -> simulated structure */ | |
2712 } | |
2713 #else /* VMS */ | |
2714 dp = (struct dir$_name *) dirp->dd_buf; | |
2715 if (dirp->dd_loc == 0) | |
2716 dirp->dd_loc = (dp->dir$b_namecount&1) ? dp->dir$b_namecount + 1 | |
2717 : dp->dir$b_namecount; | |
2718 dv = (struct dir$_version *)&dp->dir$t_name[dirp->dd_loc]; | |
2719 dir_static.d_ino = dv->dir$w_fid_num; | |
2720 dir_static.d_namlen = dp->dir$b_namecount; | |
2721 dir_static.d_reclen = sizeof (struct direct) | |
2722 - MAXNAMLEN + 3 | |
2723 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
2724 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
2725 dir_static.d_name[dir_static.d_namlen] = '\0'; | |
2726 dirp->dd_loc = dirp->dd_size; /* only one record at a time */ | |
2727 return &dir_static; | |
2728 #endif /* VMS */ | |
2729 } | |
2730 } | |
2731 | |
2732 #ifdef VMS | |
2733 /* readdirver is just like readdir except it returns all versions of a file | |
2734 as separate entries. */ | |
2735 | |
2736 /* ARGUSED */ | |
2737 struct direct * | |
2738 readdirver (dirp) | |
2739 register DIR *dirp; /* stream from opendir */ | |
2740 { | |
2741 register struct dir$_name *dp; /* -> directory data */ | |
2742 register struct dir$_version *dv; /* -> version data */ | |
2743 | |
2744 if (dirp->dd_loc >= dirp->dd_size - sizeof (struct dir$_name)) | |
2745 dirp->dd_loc = dirp->dd_size = 0; | |
2746 | |
2747 if (dirp->dd_size == 0 /* refill buffer */ | |
2748 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
2749 return 0; | |
2750 | |
2751 dp = (struct dir$_name *) dirp->dd_buf; | |
2752 if (dirp->dd_loc == 0) | |
2753 dirp->dd_loc = (dp->dir$b_namecount & 1) ? dp->dir$b_namecount + 1 | |
2754 : dp->dir$b_namecount; | |
2755 dv = (struct dir$_version *) &dp->dir$t_name[dirp->dd_loc]; | |
2756 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
2757 sprintf (&dir_static.d_name[dp->dir$b_namecount], ";%d", dv->dir$w_version); | |
2758 dir_static.d_namlen = strlen (dir_static.d_name); | |
2759 dir_static.d_ino = dv->dir$w_fid_num; | |
2760 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 | |
2761 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
2762 dirp->dd_loc = ((char *) (++dv) - dp->dir$t_name); | |
2763 return &dir_static; | |
2764 } | |
2765 | |
2766 #endif /* VMS */ | |
2767 | |
2768 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
2769 | |
2770 /* Functions for VMS */ | |
2771 #ifdef VMS | |
579 | 2772 #include "vms-pwd.h" |
491 | 2773 #include <acldef.h> |
2774 #include <chpdef.h> | |
2775 #include <jpidef.h> | |
2776 | |
2777 /* Return as a string the VMS error string pertaining to STATUS. | |
2778 Reuses the same static buffer each time it is called. */ | |
2779 | |
2780 char * | |
2781 vmserrstr (status) | |
2782 int status; /* VMS status code */ | |
2783 { | |
2784 int bufadr[2]; | |
2785 short len; | |
2786 static char buf[257]; | |
2787 | |
2788 bufadr[0] = sizeof buf - 1; | |
2789 bufadr[1] = (int) buf; | |
2790 if (! (SYS$GETMSG (status, &len, bufadr, 0x1, 0) & 1)) | |
2791 return "untranslatable VMS error status"; | |
2792 buf[len] = '\0'; | |
2793 return buf; | |
2794 } | |
2795 | |
2796 #ifdef access | |
2797 #undef access | |
2798 | |
2799 /* The following is necessary because 'access' emulation by VMS C (2.0) does | |
2800 * not work correctly. (It also doesn't work well in version 2.3.) | |
2801 */ | |
2802 | |
2803 #ifdef VMS4_4 | |
2804 | |
2805 #define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \ | |
2806 { strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string } | |
2807 | |
2808 typedef union { | |
2809 struct { | |
2810 unsigned short s_buflen; | |
2811 unsigned short s_code; | |
2812 char *s_bufadr; | |
2813 unsigned short *s_retlenadr; | |
2814 } s; | |
2815 int end; | |
2816 } item; | |
2817 #define buflen s.s_buflen | |
2818 #define code s.s_code | |
2819 #define bufadr s.s_bufadr | |
2820 #define retlenadr s.s_retlenadr | |
2821 | |
2822 #define R_OK 4 /* test for read permission */ | |
2823 #define W_OK 2 /* test for write permission */ | |
2824 #define X_OK 1 /* test for execute (search) permission */ | |
2825 #define F_OK 0 /* test for presence of file */ | |
2826 | |
2827 int | |
2828 sys_access (path, mode) | |
2829 char *path; | |
2830 int mode; | |
2831 { | |
2832 static char *user = NULL; | |
2833 char dir_fn[512]; | |
2834 | |
2835 /* translate possible directory spec into .DIR file name, so brain-dead | |
2836 * access can treat the directory like a file. */ | |
2837 if (directory_file_name (path, dir_fn)) | |
2838 path = dir_fn; | |
2839 | |
2840 if (mode == F_OK) | |
2841 return access (path, mode); | |
2842 if (user == NULL && (user = (char *) getenv ("USER")) == NULL) | |
2843 return -1; | |
2844 { | |
2845 int stat; | |
2846 int flags; | |
2847 int acces; | |
2848 unsigned short int dummy; | |
2849 item itemlst[3]; | |
2850 static int constant = ACL$C_FILE; | |
2851 DESCRIPTOR (path_desc, path); | |
2852 DESCRIPTOR (user_desc, user); | |
2853 | |
2854 flags = 0; | |
2855 acces = 0; | |
2856 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK)) | |
2857 return stat; | |
2858 if (mode & R_OK) | |
2859 acces |= CHP$M_READ; | |
2860 if (mode & W_OK) | |
2861 acces |= CHP$M_WRITE; | |
2862 itemlst[0].buflen = sizeof (int); | |
2863 itemlst[0].code = CHP$_FLAGS; | |
2864 itemlst[0].bufadr = (char *) &flags; | |
2865 itemlst[0].retlenadr = &dummy; | |
2866 itemlst[1].buflen = sizeof (int); | |
2867 itemlst[1].code = CHP$_ACCESS; | |
2868 itemlst[1].bufadr = (char *) &acces; | |
2869 itemlst[1].retlenadr = &dummy; | |
2870 itemlst[2].end = CHP$_END; | |
2871 stat = SYS$CHECK_ACCESS (&constant, &path_desc, &user_desc, itemlst); | |
2872 return stat == SS$_NORMAL ? 0 : -1; | |
2873 } | |
2874 } | |
2875 | |
2876 #else /* not VMS4_4 */ | |
2877 | |
2878 #include <prvdef.h> | |
2879 #define ACE$M_WRITE 2 | |
2880 #define ACE$C_KEYID 1 | |
2881 | |
2882 static unsigned short memid, grpid; | |
2883 static unsigned int uic; | |
2884 | |
2885 /* Called from init_sys_modes, so it happens not very often | |
2886 but at least each time Emacs is loaded. */ | |
2887 sys_access_reinit () | |
2888 { | |
2889 uic = 0; | |
2890 } | |
2891 | |
2892 int | |
2893 sys_access (filename, type) | |
2894 char * filename; | |
2895 int type; | |
2896 { | |
2897 struct FAB fab; | |
2898 struct XABPRO xab; | |
2899 int status, size, i, typecode, acl_controlled; | |
2900 unsigned int *aclptr, *aclend, aclbuf[60]; | |
2901 union prvdef prvmask; | |
2902 | |
2903 /* Get UIC and GRP values for protection checking. */ | |
2904 if (uic == 0) | |
2905 { | |
2906 status = LIB$GETJPI (&JPI$_UIC, 0, 0, &uic, 0, 0); | |
2907 if (! (status & 1)) | |
2908 return -1; | |
2909 memid = uic & 0xFFFF; | |
2910 grpid = uic >> 16; | |
2911 } | |
2912 | |
2913 if (type != 2) /* not checking write access */ | |
2914 return access (filename, type); | |
2915 | |
2916 /* Check write protection. */ | |
2917 | |
2918 #define CHECKPRIV(bit) (prvmask.bit) | |
2919 #define WRITEABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) | |
2920 | |
2921 /* 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
|
2922 status = SYS$SETPRV (0, 0, 0, prvmask); |
491 | 2923 if (! (status & 1)) |
2924 error ("Unable to find privileges: %s", vmserrstr (status)); | |
2925 if (CHECKPRIV (PRV$V_BYPASS)) | |
2926 return 0; /* BYPASS enabled */ | |
2927 fab = cc$rms_fab; | |
2928 fab.fab$b_fac = FAB$M_GET; | |
2929 fab.fab$l_fna = filename; | |
2930 fab.fab$b_fns = strlen (filename); | |
2931 fab.fab$l_xab = &xab; | |
2932 xab = cc$rms_xabpro; | |
2933 xab.xab$l_aclbuf = aclbuf; | |
2934 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
|
2935 status = SYS$OPEN (&fab, 0, 0); |
491 | 2936 if (! (status & 1)) |
2937 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
|
2938 SYS$CLOSE (&fab, 0, 0); |
491 | 2939 /* Check system access */ |
2940 if (CHECKPRIV (PRV$V_SYSPRV) && WRITEABLE (XAB$V_SYS)) | |
2941 return 0; | |
2942 /* Check ACL entries, if any */ | |
2943 acl_controlled = 0; | |
2944 if (xab.xab$w_acllen > 0) | |
2945 { | |
2946 aclptr = aclbuf; | |
2947 aclend = &aclbuf[xab.xab$w_acllen / 4]; | |
2948 while (*aclptr && aclptr < aclend) | |
2949 { | |
2950 size = (*aclptr & 0xff) / 4; | |
2951 typecode = (*aclptr >> 8) & 0xff; | |
2952 if (typecode == ACE$C_KEYID) | |
2953 for (i = size - 1; i > 1; i--) | |
2954 if (aclptr[i] == uic) | |
2955 { | |
2956 acl_controlled = 1; | |
2957 if (aclptr[1] & ACE$M_WRITE) | |
2958 return 0; /* Write access through ACL */ | |
2959 } | |
2960 aclptr = &aclptr[size]; | |
2961 } | |
2962 if (acl_controlled) /* ACL specified, prohibits write access */ | |
2963 return -1; | |
2964 } | |
2965 /* No ACL entries specified, check normal protection */ | |
2966 if (WRITEABLE (XAB$V_WLD)) /* World writeable */ | |
2967 return 0; | |
2968 if (WRITEABLE (XAB$V_GRP) && | |
2969 (unsigned short) (xab.xab$l_uic >> 16) == grpid) | |
2970 return 0; /* Group writeable */ | |
2971 if (WRITEABLE (XAB$V_OWN) && | |
2972 (xab.xab$l_uic & 0xFFFF) == memid) | |
2973 return 0; /* Owner writeable */ | |
2974 | |
2975 return -1; /* Not writeable */ | |
2976 } | |
2977 #endif /* not VMS4_4 */ | |
2978 #endif /* access */ | |
2979 | |
2980 static char vtbuf[NAM$C_MAXRSS+1]; | |
2981 | |
2982 /* translate a vms file spec to a unix path */ | |
2983 char * | |
2984 sys_translate_vms (vfile) | |
2985 char * vfile; | |
2986 { | |
2987 char * p; | |
2988 char * targ; | |
2989 | |
2990 if (!vfile) | |
2991 return 0; | |
2992 | |
2993 targ = vtbuf; | |
2994 | |
2995 /* leading device or logical name is a root directory */ | |
2996 if (p = strchr (vfile, ':')) | |
2997 { | |
2998 *targ++ = '/'; | |
2999 while (vfile < p) | |
3000 *targ++ = *vfile++; | |
3001 vfile++; | |
3002 *targ++ = '/'; | |
3003 } | |
3004 p = vfile; | |
3005 if (*p == '[' || *p == '<') | |
3006 { | |
3007 while (*++vfile != *p + 2) | |
3008 switch (*vfile) | |
3009 { | |
3010 case '.': | |
3011 if (vfile[-1] == *p) | |
3012 *targ++ = '.'; | |
3013 *targ++ = '/'; | |
3014 break; | |
3015 | |
3016 case '-': | |
3017 *targ++ = '.'; | |
3018 *targ++ = '.'; | |
3019 break; | |
3020 | |
3021 default: | |
3022 *targ++ = *vfile; | |
3023 break; | |
3024 } | |
3025 vfile++; | |
3026 *targ++ = '/'; | |
3027 } | |
3028 while (*vfile) | |
3029 *targ++ = *vfile++; | |
3030 | |
3031 return vtbuf; | |
3032 } | |
3033 | |
3034 static char utbuf[NAM$C_MAXRSS+1]; | |
3035 | |
3036 /* translate a unix path to a VMS file spec */ | |
3037 char * | |
3038 sys_translate_unix (ufile) | |
3039 char * ufile; | |
3040 { | |
3041 int slash_seen = 0; | |
3042 char *p; | |
3043 char * targ; | |
3044 | |
3045 if (!ufile) | |
3046 return 0; | |
3047 | |
3048 targ = utbuf; | |
3049 | |
3050 if (*ufile == '/') | |
3051 { | |
3052 ufile++; | |
3053 } | |
3054 | |
3055 while (*ufile) | |
3056 { | |
3057 switch (*ufile) | |
3058 { | |
3059 case '/': | |
3060 if (slash_seen) | |
3061 if (index (&ufile[1], '/')) | |
3062 *targ++ = '.'; | |
3063 else | |
3064 *targ++ = ']'; | |
3065 else | |
3066 { | |
3067 *targ++ = ':'; | |
3068 if (index (&ufile[1], '/')) | |
3069 *targ++ = '['; | |
3070 slash_seen = 1; | |
3071 } | |
3072 break; | |
3073 | |
3074 case '.': | |
3075 if (strncmp (ufile, "./", 2) == 0) | |
3076 { | |
3077 if (!slash_seen) | |
3078 { | |
3079 *targ++ = '['; | |
3080 slash_seen = 1; | |
3081 } | |
3082 ufile++; /* skip the dot */ | |
3083 if (index (&ufile[1], '/')) | |
3084 *targ++ = '.'; | |
3085 else | |
3086 *targ++ = ']'; | |
3087 } | |
3088 else if (strncmp (ufile, "../", 3) == 0) | |
3089 { | |
3090 if (!slash_seen) | |
3091 { | |
3092 *targ++ = '['; | |
3093 slash_seen = 1; | |
3094 } | |
3095 *targ++ = '-'; | |
3096 ufile += 2; /* skip the dots */ | |
3097 if (index (&ufile[1], '/')) | |
3098 *targ++ = '.'; | |
3099 else | |
3100 *targ++ = ']'; | |
3101 } | |
3102 else | |
3103 *targ++ = *ufile; | |
3104 break; | |
3105 | |
3106 default: | |
3107 *targ++ = *ufile; | |
3108 break; | |
3109 } | |
3110 ufile++; | |
3111 } | |
3112 *targ = '\0'; | |
3113 | |
3114 return utbuf; | |
3115 } | |
3116 | |
3117 char * | |
3118 getwd (pathname) | |
3119 char *pathname; | |
3120 { | |
3121 char *ptr; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3122 extern char *getcwd (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3123 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3124 #define MAXPATHLEN 1024 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3125 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3126 ptr = xmalloc (MAXPATHLEN); |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3127 getcwd (ptr, MAXPATHLEN); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3128 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
|
3129 xfree (ptr); |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3130 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3131 return pathname; |
491 | 3132 } |
3133 | |
3134 getppid () | |
3135 { | |
3136 long item_code = JPI$_OWNER; | |
3137 unsigned long parent_id; | |
3138 int status; | |
3139 | |
3140 if (((status = LIB$GETJPI (&item_code, 0, 0, &parent_id)) & 1) == 0) | |
3141 { | |
3142 errno = EVMSERR; | |
3143 vaxc$errno = status; | |
3144 return -1; | |
3145 } | |
3146 return parent_id; | |
3147 } | |
3148 | |
3149 #undef getuid | |
3150 unsigned | |
3151 sys_getuid () | |
3152 { | |
3153 return (getgid () << 16) | getuid (); | |
3154 } | |
3155 | |
3156 int | |
3157 sys_read (fildes, buf, nbyte) | |
3158 int fildes; | |
3159 char *buf; | |
3160 unsigned int nbyte; | |
3161 { | |
3162 return read (fildes, buf, (nbyte < MAXIOSIZE ? nbyte : MAXIOSIZE)); | |
3163 } | |
3164 | |
3165 #if 0 | |
3166 int | |
3167 sys_write (fildes, buf, nbyte) | |
3168 int fildes; | |
3169 char *buf; | |
3170 unsigned int nbyte; | |
3171 { | |
3172 register int nwrote, rtnval = 0; | |
3173 | |
3174 while (nbyte > MAXIOSIZE && (nwrote = write (fildes, buf, MAXIOSIZE)) > 0) { | |
3175 nbyte -= nwrote; | |
3176 buf += nwrote; | |
3177 rtnval += nwrote; | |
3178 } | |
3179 if (nwrote < 0) | |
3180 return rtnval ? rtnval : -1; | |
3181 if ((nwrote = write (fildes, buf, nbyte)) < 0) | |
3182 return rtnval ? rtnval : -1; | |
3183 return (rtnval + nwrote); | |
3184 } | |
3185 #endif /* 0 */ | |
3186 | |
3187 /* | |
3188 * VAX/VMS VAX C RTL really loses. It insists that records | |
3189 * end with a newline (carriage return) character, and if they | |
3190 * don't it adds one (nice of it isn't it!) | |
3191 * | |
3192 * Thus we do this stupidity below. | |
3193 */ | |
3194 | |
3195 int | |
3196 sys_write (fildes, buf, nbytes) | |
3197 int fildes; | |
3198 char *buf; | |
3199 unsigned int nbytes; | |
3200 { | |
3201 register char *p; | |
3202 register char *e; | |
525 | 3203 int sum = 0; |
3204 struct stat st; | |
3205 | |
3206 fstat (fildes, &st); | |
491 | 3207 p = buf; |
3208 while (nbytes > 0) | |
3209 { | |
525 | 3210 int len, retval; |
3211 | |
3212 /* Handle fixed-length files with carriage control. */ | |
3213 if (st.st_fab_rfm == FAB$C_FIX | |
3214 && ((st.st_fab_rat & (FAB$M_FTN | FAB$M_CR)) != 0)) | |
3215 { | |
3216 len = st.st_fab_mrs; | |
3217 retval = write (fildes, p, min (len, nbytes)); | |
3218 if (retval != len) | |
3219 return -1; | |
3220 retval++; /* This skips the implied carriage control */ | |
3221 } | |
3222 else | |
3223 { | |
3224 e = p + min (MAXIOSIZE, nbytes) - 1; | |
3225 while (*e != '\n' && e > p) e--; | |
3226 if (p == e) /* Ok.. so here we add a newline... sigh. */ | |
3227 e = p + min (MAXIOSIZE, nbytes) - 1; | |
3228 len = e + 1 - p; | |
3229 retval = write (fildes, p, len); | |
3230 if (retval != len) | |
3231 return -1; | |
3232 } | |
3233 p += retval; | |
3234 sum += retval; | |
491 | 3235 nbytes -= retval; |
3236 } | |
3237 return sum; | |
3238 } | |
3239 | |
3240 /* Create file NEW copying its attributes from file OLD. If | |
3241 OLD is 0 or does not exist, create based on the value of | |
3242 vms_stmlf_recfm. */ | |
3243 | |
3244 /* Protection value the file should ultimately have. | |
3245 Set by create_copy_attrs, and use by rename_sansversions. */ | |
3246 static unsigned short int fab_final_pro; | |
3247 | |
3248 int | |
3249 creat_copy_attrs (old, new) | |
3250 char *old, *new; | |
3251 { | |
3252 struct FAB fab = cc$rms_fab; | |
3253 struct XABPRO xabpro; | |
3254 char aclbuf[256]; /* Choice of size is arbitrary. See below. */ | |
3255 extern int vms_stmlf_recfm; | |
3256 | |
3257 if (old) | |
3258 { | |
3259 fab.fab$b_fac = FAB$M_GET; | |
3260 fab.fab$l_fna = old; | |
3261 fab.fab$b_fns = strlen (old); | |
3262 fab.fab$l_xab = (char *) &xabpro; | |
3263 xabpro = cc$rms_xabpro; | |
3264 xabpro.xab$l_aclbuf = aclbuf; | |
3265 xabpro.xab$w_aclsiz = sizeof aclbuf; | |
3266 /* 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
|
3267 if (SYS$OPEN (&fab, 0, 0) & 1) |
491 | 3268 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3269 SYS$CLOSE (&fab, 0, 0); |
491 | 3270 fab.fab$l_alq = 0; /* zero the allocation quantity */ |
3271 if (xabpro.xab$w_acllen > 0) | |
3272 { | |
3273 if (xabpro.xab$w_acllen > sizeof aclbuf) | |
3274 /* If the acl buffer was too short, redo open with longer one. | |
3275 Wouldn't need to do this if there were some system imposed | |
3276 limit on the size of an ACL, but I can't find any such. */ | |
3277 { | |
3278 xabpro.xab$l_aclbuf = (char *) alloca (xabpro.xab$w_acllen); | |
3279 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
|
3280 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
|
3281 SYS$CLOSE (&fab, 0, 0); |
491 | 3282 else |
3283 old = 0; | |
3284 } | |
3285 } | |
3286 else | |
3287 xabpro.xab$l_aclbuf = 0; | |
3288 } | |
3289 else | |
3290 old = 0; | |
3291 } | |
3292 fab.fab$l_fna = new; | |
3293 fab.fab$b_fns = strlen (new); | |
3294 if (!old) | |
3295 { | |
3296 fab.fab$l_xab = 0; | |
3297 fab.fab$b_rfm = vms_stmlf_recfm ? FAB$C_STMLF : FAB$C_VAR; | |
3298 fab.fab$b_rat = FAB$M_CR; | |
3299 } | |
3300 | |
3301 /* Set the file protections such that we will be able to manipulate | |
3302 this file. Once we are done writing and renaming it, we will set | |
3303 the protections back. */ | |
3304 if (old) | |
3305 fab_final_pro = xabpro.xab$w_pro; | |
3306 else | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3307 SYS$SETDFPROT (0, &fab_final_pro); |
491 | 3308 xabpro.xab$w_pro &= 0xff0f; /* set O:rewd for now. This is set back later. */ |
3309 | |
3310 /* Create the new file with either default attrs or attrs copied | |
3311 from old file. */ | |
3312 if (!(SYS$CREATE (&fab, 0, 0) & 1)) | |
3313 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
|
3314 SYS$CLOSE (&fab, 0, 0); |
491 | 3315 /* As this is a "replacement" for creat, return a file descriptor |
3316 opened for writing. */ | |
3317 return open (new, O_WRONLY); | |
3318 } | |
3319 | |
3320 #ifdef creat | |
3321 #undef creat | |
3322 #include <varargs.h> | |
3323 #ifdef __GNUC__ | |
3324 #ifndef va_count | |
3325 #define va_count(X) ((X) = *(((int *) &(va_alist)) - 1)) | |
3326 #endif | |
3327 #endif | |
3328 | |
3329 sys_creat (va_alist) | |
3330 va_dcl | |
3331 { | |
3332 va_list list_incrementor; | |
3333 char *name; | |
3334 int mode; | |
3335 int rfd; /* related file descriptor */ | |
3336 int fd; /* Our new file descriptor */ | |
3337 int count; | |
3338 struct stat st_buf; | |
3339 char rfm[12]; | |
3340 char rat[15]; | |
3341 char mrs[13]; | |
3342 char fsz[13]; | |
3343 extern int vms_stmlf_recfm; | |
3344 | |
3345 va_count (count); | |
3346 va_start (list_incrementor); | |
3347 name = va_arg (list_incrementor, char *); | |
3348 mode = va_arg (list_incrementor, int); | |
3349 if (count > 2) | |
3350 rfd = va_arg (list_incrementor, int); | |
3351 va_end (list_incrementor); | |
3352 if (count > 2) | |
3353 { | |
3354 /* Use information from the related file descriptor to set record | |
3355 format of the newly created file. */ | |
3356 fstat (rfd, &st_buf); | |
3357 switch (st_buf.st_fab_rfm) | |
3358 { | |
3359 case FAB$C_FIX: | |
3360 strcpy (rfm, "rfm = fix"); | |
3361 sprintf (mrs, "mrs = %d", st_buf.st_fab_mrs); | |
3362 strcpy (rat, "rat = "); | |
3363 if (st_buf.st_fab_rat & FAB$M_CR) | |
3364 strcat (rat, "cr"); | |
3365 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
3366 strcat (rat, "ftn"); | |
3367 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
3368 strcat (rat, "prn"); | |
3369 if (st_buf.st_fab_rat & FAB$M_BLK) | |
3370 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
3371 strcat (rat, ", blk"); | |
3372 else | |
3373 strcat (rat, "blk"); | |
3374 return creat (name, 0, rfm, rat, mrs); | |
3375 | |
3376 case FAB$C_VFC: | |
3377 strcpy (rfm, "rfm = vfc"); | |
3378 sprintf (fsz, "fsz = %d", st_buf.st_fab_fsz); | |
3379 strcpy (rat, "rat = "); | |
3380 if (st_buf.st_fab_rat & FAB$M_CR) | |
3381 strcat (rat, "cr"); | |
3382 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
3383 strcat (rat, "ftn"); | |
3384 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
3385 strcat (rat, "prn"); | |
3386 if (st_buf.st_fab_rat & FAB$M_BLK) | |
3387 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
3388 strcat (rat, ", blk"); | |
3389 else | |
3390 strcat (rat, "blk"); | |
3391 return creat (name, 0, rfm, rat, fsz); | |
3392 | |
3393 case FAB$C_STM: | |
3394 strcpy (rfm, "rfm = stm"); | |
3395 break; | |
3396 | |
3397 case FAB$C_STMCR: | |
3398 strcpy (rfm, "rfm = stmcr"); | |
3399 break; | |
3400 | |
3401 case FAB$C_STMLF: | |
3402 strcpy (rfm, "rfm = stmlf"); | |
3403 break; | |
3404 | |
3405 case FAB$C_UDF: | |
3406 strcpy (rfm, "rfm = udf"); | |
3407 break; | |
3408 | |
3409 case FAB$C_VAR: | |
3410 strcpy (rfm, "rfm = var"); | |
3411 break; | |
3412 } | |
3413 strcpy (rat, "rat = "); | |
3414 if (st_buf.st_fab_rat & FAB$M_CR) | |
3415 strcat (rat, "cr"); | |
3416 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
3417 strcat (rat, "ftn"); | |
3418 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
3419 strcat (rat, "prn"); | |
3420 if (st_buf.st_fab_rat & FAB$M_BLK) | |
3421 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
3422 strcat (rat, ", blk"); | |
3423 else | |
3424 strcat (rat, "blk"); | |
3425 } | |
3426 else | |
3427 { | |
3428 strcpy (rfm, vms_stmlf_recfm ? "rfm = stmlf" : "rfm=var"); | |
3429 strcpy (rat, "rat=cr"); | |
3430 } | |
3431 /* Until the VAX C RTL fixes the many bugs with modes, always use | |
3432 mode 0 to get the user's default protection. */ | |
3433 fd = creat (name, 0, rfm, rat); | |
3434 if (fd < 0 && errno == EEXIST) | |
3435 { | |
3436 if (unlink (name) < 0) | |
3437 report_file_error ("delete", build_string (name)); | |
3438 fd = creat (name, 0, rfm, rat); | |
3439 } | |
3440 return fd; | |
3441 } | |
3442 #endif /* creat */ | |
3443 | |
3444 /* fwrite to stdout is S L O W. Speed it up by using fputc...*/ | |
3445 sys_fwrite (ptr, size, num, fp) | |
3446 register char * ptr; | |
3447 FILE * fp; | |
3448 { | |
3449 register int tot = num * size; | |
3450 | |
3451 while (tot--) | |
3452 fputc (*ptr++, fp); | |
3453 } | |
3454 | |
3455 /* | |
3456 * The VMS C library routine creat actually creates a new version of an | |
3457 * existing file rather than truncating the old version. There are times | |
3458 * when this is not the desired behavior, for instance, when writing an | |
3459 * auto save file (you only want one version), or when you don't have | |
3460 * write permission in the directory containing the file (but the file | |
3461 * itself is writable). Hence this routine, which is equivalent to | |
3462 * "close (creat (fn, 0));" on Unix if fn already exists. | |
3463 */ | |
3464 int | |
3465 vms_truncate (fn) | |
3466 char *fn; | |
3467 { | |
3468 struct FAB xfab = cc$rms_fab; | |
3469 struct RAB xrab = cc$rms_rab; | |
3470 int status; | |
3471 | |
3472 xfab.fab$l_fop = FAB$M_TEF; /* free allocated but unused blocks on close */ | |
3473 xfab.fab$b_fac = FAB$M_TRN | FAB$M_GET; /* allow truncate and get access */ | |
3474 xfab.fab$b_shr = FAB$M_NIL; /* allow no sharing - file must be locked */ | |
3475 xfab.fab$l_fna = fn; | |
3476 xfab.fab$b_fns = strlen (fn); | |
3477 xfab.fab$l_dna = ";0"; /* default to latest version of the file */ | |
3478 xfab.fab$b_dns = 2; | |
3479 xrab.rab$l_fab = &xfab; | |
3480 | |
3481 /* This gibberish opens the file, positions to the first record, and | |
3482 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
|
3483 if ((SYS$OPEN (&xfab) & 01) == 01) |
491 | 3484 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3485 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
|
3486 (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
|
3487 (SYS$TRUNCATE (&xrab) & 01) == 01) |
491 | 3488 status = 0; |
3489 else | |
3490 status = -1; | |
3491 } | |
3492 else | |
3493 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
|
3494 SYS$CLOSE (&xfab); |
491 | 3495 return status; |
3496 } | |
3497 | |
3498 /* Define this symbol to actually read SYSUAF.DAT. This requires either | |
3499 SYSPRV or a readable SYSUAF.DAT. */ | |
3500 | |
3501 #ifdef READ_SYSUAF | |
3502 /* | |
3503 * getuaf.c | |
3504 * | |
3505 * Routine to read the VMS User Authorization File and return | |
3506 * a specific user's record. | |
3507 */ | |
3508 | |
3509 static struct UAF retuaf; | |
3510 | |
3511 struct UAF * | |
3512 get_uaf_name (uname) | |
3513 char * uname; | |
3514 { | |
3515 register status; | |
3516 struct FAB uaf_fab; | |
3517 struct RAB uaf_rab; | |
3518 | |
3519 uaf_fab = cc$rms_fab; | |
3520 uaf_rab = cc$rms_rab; | |
3521 /* initialize fab fields */ | |
3522 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
3523 uaf_fab.fab$b_fns = 21; | |
3524 uaf_fab.fab$b_fac = FAB$M_GET; | |
3525 uaf_fab.fab$b_org = FAB$C_IDX; | |
3526 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
3527 /* initialize rab fields */ | |
3528 uaf_rab.rab$l_fab = &uaf_fab; | |
3529 /* 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
|
3530 status = SYS$OPEN (&uaf_fab); |
491 | 3531 if (!(status&1)) |
3532 { | |
3533 errno = EVMSERR; | |
3534 vaxc$errno = status; | |
3535 return 0; | |
3536 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3537 status = SYS$CONNECT (&uaf_rab); |
491 | 3538 if (!(status&1)) |
3539 { | |
3540 errno = EVMSERR; | |
3541 vaxc$errno = status; | |
3542 return 0; | |
3543 } | |
3544 /* read the requested record - index is in uname */ | |
3545 uaf_rab.rab$l_kbf = uname; | |
3546 uaf_rab.rab$b_ksz = strlen (uname); | |
3547 uaf_rab.rab$b_rac = RAB$C_KEY; | |
3548 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
3549 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
|
3550 status = SYS$GET (&uaf_rab); |
491 | 3551 if (!(status&1)) |
3552 { | |
3553 errno = EVMSERR; | |
3554 vaxc$errno = status; | |
3555 return 0; | |
3556 } | |
3557 /* 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
|
3558 status = SYS$DISCONNECT (&uaf_rab); |
491 | 3559 if (!(status&1)) |
3560 { | |
3561 errno = EVMSERR; | |
3562 vaxc$errno = status; | |
3563 return 0; | |
3564 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3565 status = SYS$CLOSE (&uaf_fab); |
491 | 3566 if (!(status&1)) |
3567 { | |
3568 errno = EVMSERR; | |
3569 vaxc$errno = status; | |
3570 return 0; | |
3571 } | |
3572 return &retuaf; | |
3573 } | |
3574 | |
3575 struct UAF * | |
3576 get_uaf_uic (uic) | |
3577 unsigned long uic; | |
3578 { | |
3579 register status; | |
3580 struct FAB uaf_fab; | |
3581 struct RAB uaf_rab; | |
3582 | |
3583 uaf_fab = cc$rms_fab; | |
3584 uaf_rab = cc$rms_rab; | |
3585 /* initialize fab fields */ | |
3586 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
3587 uaf_fab.fab$b_fns = 21; | |
3588 uaf_fab.fab$b_fac = FAB$M_GET; | |
3589 uaf_fab.fab$b_org = FAB$C_IDX; | |
3590 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
3591 /* initialize rab fields */ | |
3592 uaf_rab.rab$l_fab = &uaf_fab; | |
3593 /* 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
|
3594 status = SYS$OPEN (&uaf_fab); |
491 | 3595 if (!(status&1)) |
3596 { | |
3597 errno = EVMSERR; | |
3598 vaxc$errno = status; | |
3599 return 0; | |
3600 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3601 status = SYS$CONNECT (&uaf_rab); |
491 | 3602 if (!(status&1)) |
3603 { | |
3604 errno = EVMSERR; | |
3605 vaxc$errno = status; | |
3606 return 0; | |
3607 } | |
3608 /* read the requested record - index is in uic */ | |
3609 uaf_rab.rab$b_krf = 1; /* 1st alternate key */ | |
3610 uaf_rab.rab$l_kbf = (char *) &uic; | |
3611 uaf_rab.rab$b_ksz = sizeof uic; | |
3612 uaf_rab.rab$b_rac = RAB$C_KEY; | |
3613 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
3614 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
|
3615 status = SYS$GET (&uaf_rab); |
491 | 3616 if (!(status&1)) |
3617 { | |
3618 errno = EVMSERR; | |
3619 vaxc$errno = status; | |
3620 return 0; | |
3621 } | |
3622 /* 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
|
3623 status = SYS$DISCONNECT (&uaf_rab); |
491 | 3624 if (!(status&1)) |
3625 { | |
3626 errno = EVMSERR; | |
3627 vaxc$errno = status; | |
3628 return 0; | |
3629 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3630 status = SYS$CLOSE (&uaf_fab); |
491 | 3631 if (!(status&1)) |
3632 { | |
3633 errno = EVMSERR; | |
3634 vaxc$errno = status; | |
3635 return 0; | |
3636 } | |
3637 return &retuaf; | |
3638 } | |
3639 | |
3640 static struct passwd retpw; | |
3641 | |
3642 struct passwd * | |
3643 cnv_uaf_pw (up) | |
3644 struct UAF * up; | |
3645 { | |
3646 char * ptr; | |
3647 | |
3648 /* copy these out first because if the username is 32 chars, the next | |
3649 section will overwrite the first byte of the UIC */ | |
3650 retpw.pw_uid = up->uaf$w_mem; | |
3651 retpw.pw_gid = up->uaf$w_grp; | |
3652 | |
3653 /* I suppose this is not the best sytle, to possibly overwrite one | |
3654 byte beyond the end of the field, but what the heck... */ | |
3655 ptr = &up->uaf$t_username[UAF$S_USERNAME]; | |
3656 while (ptr[-1] == ' ') | |
3657 ptr--; | |
3658 *ptr = '\0'; | |
3659 strcpy (retpw.pw_name, up->uaf$t_username); | |
3660 | |
3661 /* the rest of these are counted ascii strings */ | |
3662 strncpy (retpw.pw_gecos, &up->uaf$t_owner[1], up->uaf$t_owner[0]); | |
3663 retpw.pw_gecos[up->uaf$t_owner[0]] = '\0'; | |
3664 strncpy (retpw.pw_dir, &up->uaf$t_defdev[1], up->uaf$t_defdev[0]); | |
3665 retpw.pw_dir[up->uaf$t_defdev[0]] = '\0'; | |
3666 strncat (retpw.pw_dir, &up->uaf$t_defdir[1], up->uaf$t_defdir[0]); | |
3667 retpw.pw_dir[up->uaf$t_defdev[0] + up->uaf$t_defdir[0]] = '\0'; | |
3668 strncpy (retpw.pw_shell, &up->uaf$t_defcli[1], up->uaf$t_defcli[0]); | |
3669 retpw.pw_shell[up->uaf$t_defcli[0]] = '\0'; | |
3670 | |
3671 return &retpw; | |
3672 } | |
3673 #else /* not READ_SYSUAF */ | |
3674 static struct passwd retpw; | |
3675 #endif /* not READ_SYSUAF */ | |
3676 | |
3677 struct passwd * | |
3678 getpwnam (name) | |
3679 char * name; | |
3680 { | |
3681 #ifdef READ_SYSUAF | |
3682 struct UAF *up; | |
3683 #else | |
3684 char * user; | |
3685 char * dir; | |
3686 unsigned char * full; | |
3687 #endif /* READ_SYSUAF */ | |
3688 char *ptr = name; | |
3689 | |
3690 while (*ptr) | |
3691 { | |
3692 if ('a' <= *ptr && *ptr <= 'z') | |
3693 *ptr -= 040; | |
3694 ptr++; | |
3695 } | |
3696 #ifdef READ_SYSUAF | |
3697 if (!(up = get_uaf_name (name))) | |
3698 return 0; | |
3699 return cnv_uaf_pw (up); | |
3700 #else | |
3701 if (strcmp (name, getenv ("USER")) == 0) | |
3702 { | |
3703 retpw.pw_uid = getuid (); | |
3704 retpw.pw_gid = getgid (); | |
3705 strcpy (retpw.pw_name, name); | |
3706 if (full = egetenv ("FULLNAME")) | |
3707 strcpy (retpw.pw_gecos, full); | |
3708 else | |
3709 *retpw.pw_gecos = '\0'; | |
3710 strcpy (retpw.pw_dir, egetenv ("HOME")); | |
3711 *retpw.pw_shell = '\0'; | |
3712 return &retpw; | |
3713 } | |
3714 else | |
3715 return 0; | |
3716 #endif /* not READ_SYSUAF */ | |
3717 } | |
3718 | |
3719 struct passwd * | |
3720 getpwuid (uid) | |
3721 unsigned long uid; | |
3722 { | |
3723 #ifdef READ_SYSUAF | |
3724 struct UAF * up; | |
3725 | |
3726 if (!(up = get_uaf_uic (uid))) | |
3727 return 0; | |
3728 return cnv_uaf_pw (up); | |
3729 #else | |
3730 if (uid == sys_getuid ()) | |
3731 return getpwnam (egetenv ("USER")); | |
3732 else | |
3733 return 0; | |
3734 #endif /* not READ_SYSUAF */ | |
3735 } | |
3736 | |
3737 /* return total address space available to the current process. This is | |
3738 the sum of the current p0 size, p1 size and free page table entries | |
3739 available. */ | |
3740 vlimit () | |
3741 { | |
3742 int item_code; | |
3743 unsigned long free_pages; | |
3744 unsigned long frep0va; | |
3745 unsigned long frep1va; | |
3746 register status; | |
3747 | |
3748 item_code = JPI$_FREPTECNT; | |
3749 if (((status = LIB$GETJPI (&item_code, 0, 0, &free_pages)) & 1) == 0) | |
3750 { | |
3751 errno = EVMSERR; | |
3752 vaxc$errno = status; | |
3753 return -1; | |
3754 } | |
3755 free_pages *= 512; | |
3756 | |
3757 item_code = JPI$_FREP0VA; | |
3758 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep0va)) & 1) == 0) | |
3759 { | |
3760 errno = EVMSERR; | |
3761 vaxc$errno = status; | |
3762 return -1; | |
3763 } | |
3764 item_code = JPI$_FREP1VA; | |
3765 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep1va)) & 1) == 0) | |
3766 { | |
3767 errno = EVMSERR; | |
3768 vaxc$errno = status; | |
3769 return -1; | |
3770 } | |
3771 | |
3772 return free_pages + frep0va + (0x7fffffff - frep1va); | |
3773 } | |
3774 | |
3775 define_logical_name (varname, string) | |
3776 char *varname; | |
3777 char *string; | |
3778 { | |
3779 struct dsc$descriptor_s strdsc = | |
3780 {strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string}; | |
3781 struct dsc$descriptor_s envdsc = | |
3782 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
3783 struct dsc$descriptor_s lnmdsc = | |
3784 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
3785 | |
3786 return LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0); | |
3787 } | |
3788 | |
3789 delete_logical_name (varname) | |
3790 char *varname; | |
3791 { | |
3792 struct dsc$descriptor_s envdsc = | |
3793 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
3794 struct dsc$descriptor_s lnmdsc = | |
3795 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
3796 | |
3797 return LIB$DELETE_LOGICAL (&envdsc, &lnmdsc); | |
3798 } | |
3799 | |
3800 ulimit () | |
3801 {} | |
3802 | |
3803 setpgrp () | |
3804 {} | |
3805 | |
3806 execvp () | |
3807 { | |
3808 error ("execvp system call not implemented"); | |
3809 } | |
3810 | |
3811 int | |
3812 rename (from, to) | |
3813 char *from, *to; | |
3814 { | |
3815 int status; | |
3816 struct FAB from_fab = cc$rms_fab, to_fab = cc$rms_fab; | |
3817 struct NAM from_nam = cc$rms_nam, to_nam = cc$rms_nam; | |
3818 char from_esn[NAM$C_MAXRSS]; | |
3819 char to_esn[NAM$C_MAXRSS]; | |
3820 | |
3821 from_fab.fab$l_fna = from; | |
3822 from_fab.fab$b_fns = strlen (from); | |
3823 from_fab.fab$l_nam = &from_nam; | |
3824 from_fab.fab$l_fop = FAB$M_NAM; | |
3825 | |
3826 from_nam.nam$l_esa = from_esn; | |
3827 from_nam.nam$b_ess = sizeof from_esn; | |
3828 | |
3829 to_fab.fab$l_fna = to; | |
3830 to_fab.fab$b_fns = strlen (to); | |
3831 to_fab.fab$l_nam = &to_nam; | |
3832 to_fab.fab$l_fop = FAB$M_NAM; | |
3833 | |
3834 to_nam.nam$l_esa = to_esn; | |
3835 to_nam.nam$b_ess = sizeof to_esn; | |
3836 | |
3837 status = SYS$RENAME (&from_fab, 0, 0, &to_fab); | |
3838 | |
3839 if (status & 1) | |
3840 return 0; | |
3841 else | |
3842 { | |
3843 if (status == RMS$_DEV) | |
3844 errno = EXDEV; | |
3845 else | |
3846 errno = EVMSERR; | |
3847 vaxc$errno = status; | |
3848 return -1; | |
3849 } | |
3850 } | |
3851 | |
3852 /* This function renames a file like `rename', but it strips | |
3853 the version number from the "to" filename, such that the "to" file is | |
3854 will always be a new version. It also sets the file protection once it is | |
3855 finished. The protection that we will use is stored in fab_final_pro, | |
3856 and was set when we did a creat_copy_attrs to create the file that we | |
3857 are renaming. | |
3858 | |
3859 We could use the chmod function, but Eunichs uses 3 bits per user category | |
3860 to describe the protection, and VMS uses 4 (write and delete are seperate | |
3861 bits). To maintain portability, the VMS implementation of `chmod' wires | |
3862 the W and D bits together. */ | |
3863 | |
3864 | |
3865 static struct fibdef fib; /* We need this initialized to zero */ | |
3866 char vms_file_written[NAM$C_MAXRSS]; | |
3867 | |
3868 int | |
3869 rename_sans_version (from,to) | |
3870 char *from, *to; | |
3871 { | |
3872 short int chan; | |
3873 int stat; | |
3874 short int iosb[4]; | |
3875 int status; | |
3876 struct FAB to_fab = cc$rms_fab; | |
3877 struct NAM to_nam = cc$rms_nam; | |
3878 struct dsc$descriptor fib_d ={sizeof (fib),0,0,(char*) &fib}; | |
3879 struct dsc$descriptor fib_attr[2] | |
3880 = {{sizeof (fab_final_pro),ATR$C_FPRO,0,(char*) &fab_final_pro},{0,0,0,0}}; | |
3881 char to_esn[NAM$C_MAXRSS]; | |
3882 | |
3883 $DESCRIPTOR (disk,to_esn); | |
3884 | |
3885 to_fab.fab$l_fna = to; | |
3886 to_fab.fab$b_fns = strlen (to); | |
3887 to_fab.fab$l_nam = &to_nam; | |
3888 to_fab.fab$l_fop = FAB$M_NAM; | |
3889 | |
3890 to_nam.nam$l_esa = to_esn; | |
3891 to_nam.nam$b_ess = sizeof to_esn; | |
3892 | |
3893 status = SYS$PARSE (&to_fab, 0, 0); /* figure out the full file name */ | |
3894 | |
3895 if (to_nam.nam$l_fnb && NAM$M_EXP_VER) | |
3896 *(to_nam.nam$l_ver) = '\0'; | |
3897 | |
3898 stat = rename (from, to_esn); | |
3899 if (stat < 0) | |
3900 return stat; | |
3901 | |
3902 strcpy (vms_file_written, to_esn); | |
3903 | |
3904 to_fab.fab$l_fna = vms_file_written; /* this points to the versionless name */ | |
3905 to_fab.fab$b_fns = strlen (vms_file_written); | |
3906 | |
3907 /* 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
|
3908 SYS$OPEN (&to_fab, 0, 0); /* This fills in the nam$w_fid fields */ |
491 | 3909 |
3910 /* Copy these fields into the fib */ | |
3911 fib.fib$r_fid_overlay.fib$w_fid[0] = to_nam.nam$w_fid[0]; | |
3912 fib.fib$r_fid_overlay.fib$w_fid[1] = to_nam.nam$w_fid[1]; | |
3913 fib.fib$r_fid_overlay.fib$w_fid[2] = to_nam.nam$w_fid[2]; | |
3914 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3915 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
|
3916 |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3917 stat = SYS$ASSIGN (&disk, &chan, 0, 0); /* open a channel to the disk */ |
491 | 3918 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
|
3919 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
|
3920 stat = SYS$QIOW (0, chan, IO$_MODIFY, iosb, 0, 0, &fib_d, |
491 | 3921 0, 0, 0, &fib_attr, 0); |
3922 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
|
3923 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
|
3924 stat = SYS$DASSGN (chan); |
491 | 3925 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
|
3926 LIB$SIGNAL (stat); |
766 | 3927 strcpy (vms_file_written, to_esn); /* We will write this to the terminal*/ |
491 | 3928 return 0; |
3929 } | |
3930 | |
3931 link (file, new) | |
3932 char * file, * new; | |
3933 { | |
3934 register status; | |
3935 struct FAB fab; | |
3936 struct NAM nam; | |
3937 unsigned short fid[3]; | |
3938 char esa[NAM$C_MAXRSS]; | |
3939 | |
3940 fab = cc$rms_fab; | |
3941 fab.fab$l_fop = FAB$M_OFP; | |
3942 fab.fab$l_fna = file; | |
3943 fab.fab$b_fns = strlen (file); | |
3944 fab.fab$l_nam = &nam; | |
3945 | |
3946 nam = cc$rms_nam; | |
3947 nam.nam$l_esa = esa; | |
3948 nam.nam$b_ess = NAM$C_MAXRSS; | |
3949 | |
3950 status = SYS$PARSE (&fab); | |
3951 if ((status & 1) == 0) | |
3952 { | |
3953 errno = EVMSERR; | |
3954 vaxc$errno = status; | |
3955 return -1; | |
3956 } | |
3957 status = SYS$SEARCH (&fab); | |
3958 if ((status & 1) == 0) | |
3959 { | |
3960 errno = EVMSERR; | |
3961 vaxc$errno = status; | |
3962 return -1; | |
3963 } | |
3964 | |
3965 fid[0] = nam.nam$w_fid[0]; | |
3966 fid[1] = nam.nam$w_fid[1]; | |
3967 fid[2] = nam.nam$w_fid[2]; | |
3968 | |
3969 fab.fab$l_fna = new; | |
3970 fab.fab$b_fns = strlen (new); | |
3971 | |
3972 status = SYS$PARSE (&fab); | |
3973 if ((status & 1) == 0) | |
3974 { | |
3975 errno = EVMSERR; | |
3976 vaxc$errno = status; | |
3977 return -1; | |
3978 } | |
3979 | |
3980 nam.nam$w_fid[0] = fid[0]; | |
3981 nam.nam$w_fid[1] = fid[1]; | |
3982 nam.nam$w_fid[2] = fid[2]; | |
3983 | |
3984 nam.nam$l_esa = nam.nam$l_name; | |
3985 nam.nam$b_esl = nam.nam$b_name + nam.nam$b_type + nam.nam$b_ver; | |
3986 | |
3987 status = SYS$ENTER (&fab); | |
3988 if ((status & 1) == 0) | |
3989 { | |
3990 errno = EVMSERR; | |
3991 vaxc$errno = status; | |
3992 return -1; | |
3993 } | |
3994 | |
3995 return 0; | |
3996 } | |
3997 | |
3998 croak (badfunc) | |
3999 char *badfunc; | |
4000 { | |
4001 printf ("%s not yet implemented\r\n", badfunc); | |
4002 reset_sys_modes (); | |
4003 exit (1); | |
4004 } | |
4005 | |
4006 long | |
4007 random () | |
4008 { | |
4009 /* Arrange to return a range centered on zero. */ | |
4010 return rand () - (1 << 30); | |
4011 } | |
4012 | |
4013 srandom (seed) | |
4014 { | |
4015 srand (seed); | |
4016 } | |
4017 #endif /* VMS */ | |
4018 | |
4019 #ifdef AIX | |
4020 | |
4021 /* Called from init_sys_modes. */ | |
4022 hft_init () | |
4023 { | |
4024 int junk; | |
4025 | |
4026 /* If we're not on an HFT we shouldn't do any of this. We determine | |
4027 if we are on an HFT by trying to get an HFT error code. If this | |
4028 call fails, we're not on an HFT. */ | |
4029 #ifdef IBMR2AIX | |
4030 if (ioctl (0, HFQERROR, &junk) < 0) | |
4031 return; | |
4032 #else /* not IBMR2AIX */ | |
4033 if (ioctl (0, HFQEIO, 0) < 0) | |
4034 return; | |
4035 #endif /* not IBMR2AIX */ | |
4036 | |
4037 /* On AIX the default hft keyboard mapping uses backspace rather than delete | |
4038 as the rubout key's ASCII code. Here this is changed. The bug is that | |
4039 there's no way to determine the old mapping, so in reset_sys_modes | |
4040 we need to assume that the normal map had been present. Of course, this | |
4041 code also doesn't help if on a terminal emulator which doesn't understand | |
4042 HFT VTD's. */ | |
4043 { | |
4044 struct hfbuf buf; | |
4045 struct hfkeymap keymap; | |
4046 | |
4047 buf.hf_bufp = (char *)&keymap; | |
4048 buf.hf_buflen = sizeof (keymap); | |
4049 keymap.hf_nkeys = 2; | |
4050 keymap.hfkey[0].hf_kpos = 15; | |
4051 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
4052 #ifdef IBMR2AIX | |
4053 keymap.hfkey[0].hf_keyidh = '<'; | |
4054 #else /* not IBMR2AIX */ | |
4055 keymap.hfkey[0].hf_page = '<'; | |
4056 #endif /* not IBMR2AIX */ | |
4057 keymap.hfkey[0].hf_char = 127; | |
4058 keymap.hfkey[1].hf_kpos = 15; | |
4059 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
4060 #ifdef IBMR2AIX | |
4061 keymap.hfkey[1].hf_keyidh = '<'; | |
4062 #else /* not IBMR2AIX */ | |
4063 keymap.hfkey[1].hf_page = '<'; | |
4064 #endif /* not IBMR2AIX */ | |
4065 keymap.hfkey[1].hf_char = 127; | |
4066 hftctl (0, HFSKBD, &buf); | |
4067 } | |
4068 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly | |
4069 at times. */ | |
4070 line_ins_del_ok = char_ins_del_ok = 0; | |
4071 } | |
4072 | |
4073 /* Reset the rubout key to backspace. */ | |
4074 | |
4075 hft_reset () | |
4076 { | |
4077 struct hfbuf buf; | |
4078 struct hfkeymap keymap; | |
4079 int junk; | |
4080 | |
4081 #ifdef IBMR2AIX | |
4082 if (ioctl (0, HFQERROR, &junk) < 0) | |
4083 return; | |
4084 #else /* not IBMR2AIX */ | |
4085 if (ioctl (0, HFQEIO, 0) < 0) | |
4086 return; | |
4087 #endif /* not IBMR2AIX */ | |
4088 | |
4089 buf.hf_bufp = (char *)&keymap; | |
4090 buf.hf_buflen = sizeof (keymap); | |
4091 keymap.hf_nkeys = 2; | |
4092 keymap.hfkey[0].hf_kpos = 15; | |
4093 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
4094 #ifdef IBMR2AIX | |
4095 keymap.hfkey[0].hf_keyidh = '<'; | |
4096 #else /* not IBMR2AIX */ | |
4097 keymap.hfkey[0].hf_page = '<'; | |
4098 #endif /* not IBMR2AIX */ | |
4099 keymap.hfkey[0].hf_char = 8; | |
4100 keymap.hfkey[1].hf_kpos = 15; | |
4101 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
4102 #ifdef IBMR2AIX | |
4103 keymap.hfkey[1].hf_keyidh = '<'; | |
4104 #else /* not IBMR2AIX */ | |
4105 keymap.hfkey[1].hf_page = '<'; | |
4106 #endif /* not IBMR2AIX */ | |
4107 keymap.hfkey[1].hf_char = 8; | |
4108 hftctl (0, HFSKBD, &buf); | |
4109 } | |
4110 | |
4111 #endif /* AIX */ |