* configure.in: add tests for figuring out whether buffered data
[bpt/guile.git] / libguile / posix.c
1 /* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16 *
17 * As a special exception, the Free Software Foundation gives permission
18 * for additional uses of the text contained in its release of GUILE.
19 *
20 * The exception is that, if you link the GUILE library with other files
21 * to produce an executable, this does not by itself cause the
22 * resulting executable to be covered by the GNU General Public License.
23 * Your use of that executable is in no way restricted on account of
24 * linking the GUILE library code into it.
25 *
26 * This exception does not however invalidate any other reasons why
27 * the executable file might be covered by the GNU General Public License.
28 *
29 * This exception applies only to the code released by the
30 * Free Software Foundation under the name GUILE. If you copy
31 * code from other Free Software Foundation releases into a copy of
32 * GUILE, as the General Public License permits, the exception does
33 * not apply to the code that you add in this way. To avoid misleading
34 * anyone as to the status of such modified files, you must delete
35 * this exception notice from them.
36 *
37 * If you write modifications of your own for GUILE, it is your choice
38 * whether to permit this exception to apply to your modifications.
39 * If you do not wish that, delete this exception notice.
40 */
41 \f
42
43 #include <stdio.h>
44 #include "_scm.h"
45 #include "fports.h"
46 #include "genio.h"
47 #include "scmsigs.h"
48 #include "read.h"
49 #include "unif.h"
50 #include "feature.h"
51 #include "sequences.h"
52
53 #include "posix.h"
54 \f
55
56 #ifdef HAVE_STRING_H
57 #include <string.h>
58 #endif
59 #ifdef TIME_WITH_SYS_TIME
60 # include <sys/time.h>
61 # include <time.h>
62 #else
63 # if HAVE_SYS_TIME_H
64 # include <sys/time.h>
65 # else
66 # include <time.h>
67 # endif
68 #endif
69
70 #ifdef HAVE_UNISTD_H
71 #include <unistd.h>
72 #else
73 #ifndef ttyname
74 extern char *ttyname();
75 #endif
76 #endif
77
78 #ifdef HAVE_LIBC_H
79 #include <libc.h>
80 #endif
81
82 #ifdef HAVE_SYS_SELECT_H
83 #include <sys/select.h>
84 #endif
85
86 #include <sys/types.h>
87 #include <sys/stat.h>
88 #include <fcntl.h>
89
90 #include <pwd.h>
91
92 #if HAVE_SYS_WAIT_H
93 # include <sys/wait.h>
94 #endif
95 #ifndef WEXITSTATUS
96 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
97 #endif
98 #ifndef WIFEXITED
99 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
100 #endif
101
102 #include <signal.h>
103
104 #ifdef FD_SET
105
106 #define SELECT_TYPE fd_set
107 #define SELECT_SET_SIZE FD_SETSIZE
108
109 #else /* no FD_SET */
110
111 /* Define the macros to access a single-int bitmap of descriptors. */
112 #define SELECT_SET_SIZE 32
113 #define SELECT_TYPE int
114 #define FD_SET(n, p) (*(p) |= (1 << (n)))
115 #define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
116 #define FD_ISSET(n, p) (*(p) & (1 << (n)))
117 #define FD_ZERO(p) (*(p) = 0)
118
119 #endif /* no FD_SET */
120
121 extern FILE *popen ();
122 extern char ** environ;
123
124 #include <grp.h>
125 #include <sys/utsname.h>
126
127 #if HAVE_DIRENT_H
128 # include <dirent.h>
129 # define NAMLEN(dirent) strlen((dirent)->d_name)
130 #else
131 # define dirent direct
132 # define NAMLEN(dirent) (dirent)->d_namlen
133 # if HAVE_SYS_NDIR_H
134 # include <sys/ndir.h>
135 # endif
136 # if HAVE_SYS_DIR_H
137 # include <sys/dir.h>
138 # endif
139 # if HAVE_NDIR_H
140 # include <ndir.h>
141 # endif
142 #endif
143
144 char *strptime ();
145
146 #ifdef HAVE_SETLOCALE
147 #include <locale.h>
148 #endif
149
150 /* Some Unix systems don't define these. CPP hair is dangerous, but
151 this seems safe enough... */
152 #ifndef R_OK
153 #define R_OK 4
154 #endif
155
156 #ifndef W_OK
157 #define W_OK 2
158 #endif
159
160 #ifndef X_OK
161 #define X_OK 1
162 #endif
163
164 #ifndef F_OK
165 #define F_OK 0
166 #endif
167
168 /* On NextStep, <utime.h> doesn't define struct utime, unless we
169 #define _POSIX_SOURCE before #including it. I think this is less
170 of a kludge than defining struct utimbuf ourselves. */
171 #ifdef UTIMBUF_NEEDS_POSIX
172 #define _POSIX_SOURCE
173 #endif
174
175 #ifdef HAVE_SYS_UTIME_H
176 #include <sys/utime.h>
177 #endif
178
179 #ifdef HAVE_UTIME_H
180 #include <utime.h>
181 #endif
182
183 /* Please don't add any more #includes or #defines here. The hack
184 above means that _POSIX_SOURCE may be #defined, which will
185 encourage header files to do strange things. */
186
187 \f
188
189
190 SCM_PROC (s_pipe, "pipe", 0, 0, 0, scm_pipe);
191
192 SCM
193 scm_pipe ()
194 {
195 int fd[2], rv;
196 FILE *f_rd, *f_wt;
197 SCM p_rd, p_wt;
198 struct scm_port_table * ptr;
199 struct scm_port_table * ptw;
200
201 SCM_NEWCELL (p_rd);
202 SCM_NEWCELL (p_wt);
203 rv = pipe (fd);
204 if (rv)
205 scm_syserror (s_pipe);
206 f_rd = fdopen (fd[0], "r");
207 if (!f_rd)
208 {
209 SCM_SYSCALL (close (fd[0]));
210 SCM_SYSCALL (close (fd[1]));
211 scm_syserror (s_pipe);
212 }
213 f_wt = fdopen (fd[1], "w");
214 if (!f_wt)
215 {
216 int en;
217 en = errno;
218 fclose (f_rd);
219 SCM_SYSCALL (close (fd[1]));
220 errno = en;
221 scm_syserror (s_pipe);
222 }
223 ptr = scm_add_to_port_table (p_rd);
224 ptw = scm_add_to_port_table (p_wt);
225 SCM_SETPTAB_ENTRY (p_rd, ptr);
226 SCM_SETPTAB_ENTRY (p_wt, ptw);
227 SCM_SETCAR (p_rd, scm_tc16_fport | scm_mode_bits ("r"));
228 SCM_SETCAR (p_wt, scm_tc16_fport | scm_mode_bits ("w"));
229 SCM_SETSTREAM (p_rd, (SCM)f_rd);
230 SCM_SETSTREAM (p_wt, (SCM)f_wt);
231
232 SCM_ALLOW_INTS;
233 return scm_cons (p_rd, p_wt);
234 }
235
236
237
238 SCM_PROC (s_getgroups, "getgroups", 0, 0, 0, scm_getgroups);
239
240 SCM
241 scm_getgroups()
242 {
243 SCM grps, ans;
244 int ngroups = getgroups (0, NULL);
245 if (!ngroups)
246 scm_syserror (s_getgroups);
247 SCM_NEWCELL(grps);
248 SCM_DEFER_INTS;
249 {
250 GETGROUPS_T *groups;
251 int val;
252
253 groups = (GETGROUPS_T *) scm_must_malloc(ngroups * sizeof(GETGROUPS_T),
254 s_getgroups);
255 val = getgroups(ngroups, groups);
256 if (val < 0)
257 {
258 scm_must_free((char *)groups);
259 scm_syserror (s_getgroups);
260 }
261 SCM_SETCHARS(grps, groups); /* set up grps as a GC protect */
262 SCM_SETLENGTH(grps, 0L + ngroups * sizeof(GETGROUPS_T), scm_tc7_string);
263 SCM_ALLOW_INTS;
264 ans = scm_make_vector(SCM_MAKINUM(ngroups), SCM_UNDEFINED, SCM_BOOL_F);
265 while (--ngroups >= 0) SCM_VELTS(ans)[ngroups] = SCM_MAKINUM(groups[ngroups]);
266 SCM_SETCHARS(grps, groups); /* to make sure grps stays around. */
267 return ans;
268 }
269 }
270
271
272
273 SCM_PROC (s_getpwuid, "getpw", 0, 1, 0, scm_getpwuid);
274
275 SCM
276 scm_getpwuid (user)
277 SCM user;
278 {
279 SCM result;
280 struct passwd *entry;
281 SCM *ve;
282
283 result = scm_make_vector (SCM_MAKINUM (7), SCM_UNSPECIFIED, SCM_BOOL_F);
284 ve = SCM_VELTS (result);
285 if (SCM_UNBNDP (user) || SCM_FALSEP (user))
286 {
287 SCM_DEFER_INTS;
288 SCM_SYSCALL (entry = getpwent ());
289 }
290 else if (SCM_INUMP (user))
291 {
292 SCM_DEFER_INTS;
293 entry = getpwuid (SCM_INUM (user));
294 }
295 else
296 {
297 SCM_ASSERT (SCM_NIMP (user) && SCM_ROSTRINGP (user), user, SCM_ARG1, s_getpwuid);
298 if (SCM_SUBSTRP (user))
299 user = scm_makfromstr (SCM_ROCHARS (user), SCM_ROLENGTH (user), 0);
300 SCM_DEFER_INTS;
301 entry = getpwnam (SCM_ROCHARS (user));
302 }
303 if (!entry)
304 scm_syserror (s_getpwuid);
305
306 ve[0] = scm_makfrom0str (entry->pw_name);
307 ve[1] = scm_makfrom0str (entry->pw_passwd);
308 ve[2] = scm_ulong2num ((unsigned long) entry->pw_uid);
309 ve[3] = scm_ulong2num ((unsigned long) entry->pw_gid);
310 ve[4] = scm_makfrom0str (entry->pw_gecos);
311 if (!entry->pw_dir)
312 ve[5] = scm_makfrom0str ("");
313 else
314 ve[5] = scm_makfrom0str (entry->pw_dir);
315 if (!entry->pw_shell)
316 ve[6] = scm_makfrom0str ("");
317 else
318 ve[6] = scm_makfrom0str (entry->pw_shell);
319 SCM_ALLOW_INTS;
320 return result;
321 }
322
323
324
325 SCM_PROC (s_setpwent, "setpw", 0, 1, 0, scm_setpwent);
326
327 SCM
328 scm_setpwent (arg)
329 SCM arg;
330 {
331 if (SCM_UNBNDP (arg) || SCM_FALSEP (arg))
332 endpwent ();
333 else
334 setpwent ();
335 return SCM_UNSPECIFIED;
336 }
337
338
339
340 /* Combines getgrgid and getgrnam. */
341 SCM_PROC (s_getgrgid, "getgr", 0, 1, 0, scm_getgrgid);
342
343 SCM
344 scm_getgrgid (name)
345 SCM name;
346 {
347 SCM result;
348 struct group *entry;
349 SCM *ve;
350 result = scm_make_vector (SCM_MAKINUM (4), SCM_UNSPECIFIED, SCM_BOOL_F);
351 ve = SCM_VELTS (result);
352 SCM_DEFER_INTS;
353 if (SCM_UNBNDP (name) || (name == SCM_BOOL_F))
354 SCM_SYSCALL (entry = getgrent ());
355 else if (SCM_INUMP (name))
356 SCM_SYSCALL (entry = getgrgid (SCM_INUM (name)));
357 else
358 {
359 SCM_ASSERT (SCM_NIMP (name) && SCM_STRINGP (name), name, SCM_ARG1, s_getgrgid);
360 if (SCM_SUBSTRP (name))
361 name = scm_makfromstr (SCM_ROCHARS (name), SCM_ROLENGTH (name), 0);
362 SCM_SYSCALL (entry = getgrnam (SCM_CHARS (name)));
363 }
364 if (!entry)
365 scm_syserror (s_getgrgid);
366
367 ve[0] = scm_makfrom0str (entry->gr_name);
368 ve[1] = scm_makfrom0str (entry->gr_passwd);
369 ve[2] = scm_ulong2num ((unsigned long) entry->gr_gid);
370 ve[3] = scm_makfromstrs (-1, entry->gr_mem);
371 SCM_ALLOW_INTS;
372 return result;
373 }
374
375
376
377 SCM_PROC (s_setgrent, "setgr", 0, 1, 0, scm_setgrent);
378
379 SCM
380 scm_setgrent (arg)
381 SCM arg;
382 {
383 if (SCM_UNBNDP (arg) || SCM_FALSEP (arg))
384 endgrent ();
385 else
386 setgrent ();
387 return SCM_UNSPECIFIED;
388 }
389
390
391
392 SCM_PROC (s_kill, "kill", 2, 0, 0, scm_kill);
393
394 SCM
395 scm_kill (pid, sig)
396 SCM pid;
397 SCM sig;
398 {
399 SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_kill);
400 SCM_ASSERT (SCM_INUMP (sig), sig, SCM_ARG2, s_kill);
401 /* Signal values are interned in scm_init_posix(). */
402 if (kill ((int) SCM_INUM (pid), (int) SCM_INUM (sig)) != 0)
403 scm_syserror (s_kill);
404 return SCM_UNSPECIFIED;
405 }
406
407
408
409 SCM_PROC (s_waitpid, "waitpid", 1, 1, 0, scm_waitpid);
410
411 SCM
412 scm_waitpid (pid, options)
413 SCM pid;
414 SCM options;
415 {
416 #ifdef HAVE_WAITPID
417 int i;
418 int status;
419 int ioptions;
420 SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_waitpid);
421 if (SCM_UNBNDP (options))
422 ioptions = 0;
423 else
424 {
425 SCM_ASSERT (SCM_INUMP (options), options, SCM_ARG2, s_waitpid);
426 /* Flags are interned in scm_init_posix. */
427 ioptions = SCM_INUM (options);
428 }
429 SCM_SYSCALL (i = waitpid (SCM_INUM (pid), &status, ioptions));
430 if (i == -1)
431 scm_syserror (s_waitpid);
432 return scm_cons (SCM_MAKINUM (0L + i), SCM_MAKINUM (0L + status));
433 #else
434 scm_sysmissing (s_waitpid);
435 /* not reached. */
436 return SCM_BOOL_F;
437 #endif
438 }
439
440
441
442 SCM_PROC (s_getppid, "getppid", 0, 0, 0, scm_getppid);
443
444 SCM
445 scm_getppid ()
446 {
447 return SCM_MAKINUM (0L + getppid ());
448 }
449
450
451
452 SCM_PROC (s_getuid, "getuid", 0, 0, 0, scm_getuid);
453
454 SCM
455 scm_getuid ()
456 {
457 return SCM_MAKINUM (0L + getuid ());
458 }
459
460
461
462 SCM_PROC (s_getgid, "getgid", 0, 0, 0, scm_getgid);
463
464 SCM
465 scm_getgid ()
466 {
467 return SCM_MAKINUM (0L + getgid ());
468 }
469
470
471
472 SCM_PROC (s_geteuid, "geteuid", 0, 0, 0, scm_geteuid);
473
474 SCM
475 scm_geteuid ()
476 {
477 #ifdef HAVE_GETEUID
478 return SCM_MAKINUM (0L + geteuid ());
479 #else
480 return SCM_MAKINUM (0L + getuid ());
481 #endif
482 }
483
484
485
486 SCM_PROC (s_getegid, "getegid", 0, 0, 0, scm_getegid);
487
488 SCM
489 scm_getegid ()
490 {
491 #ifdef HAVE_GETEUID
492 return SCM_MAKINUM (0L + getegid ());
493 #else
494 return SCM_MAKINUM (0L + getgid ());
495 #endif
496 }
497
498
499 SCM_PROC (s_setuid, "setuid", 1, 0, 0, scm_setuid);
500
501 SCM
502 scm_setuid (id)
503 SCM id;
504 {
505 SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_setuid);
506 if (setuid (SCM_INUM (id)) != 0)
507 scm_syserror (s_setuid);
508 return SCM_UNSPECIFIED;
509 }
510
511 SCM_PROC (s_setgid, "setgid", 1, 0, 0, scm_setgid);
512
513 SCM
514 scm_setgid (id)
515 SCM id;
516 {
517 SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_setgid);
518 if (setgid (SCM_INUM (id)) != 0)
519 scm_syserror (s_setgid);
520 return SCM_UNSPECIFIED;
521 }
522
523 SCM_PROC (s_seteuid, "seteuid", 1, 0, 0, scm_seteuid);
524
525 SCM
526 scm_seteuid (id)
527 SCM id;
528 {
529 int rv;
530
531 SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_seteuid);
532 #ifdef HAVE_SETEUID
533 rv = seteuid (SCM_INUM (id));
534 #else
535 rv = setuid (SCM_INUM (id));
536 #endif
537 if (rv != 0)
538 scm_syserror (s_seteuid);
539 return SCM_UNSPECIFIED;
540 }
541
542 SCM_PROC (s_setegid, "setegid", 1, 0, 0, scm_setegid);
543
544 SCM
545 scm_setegid (id)
546 SCM id;
547 {
548 int rv;
549
550 SCM_ASSERT (SCM_INUMP (id), id, SCM_ARG1, s_setegid);
551 #ifdef HAVE_SETEUID
552 rv = setegid (SCM_INUM (id));
553 #else
554 rv = setgid (SCM_INUM (id));
555 #endif
556 if (rv != 0)
557 scm_syserror (s_setegid);
558 return SCM_UNSPECIFIED;
559
560 }
561
562 SCM_PROC (s_getpgrp, "getpgrp", 0, 0, 0, scm_getpgrp);
563 SCM
564 scm_getpgrp ()
565 {
566 int (*fn)();
567 fn = (int (*) ()) getpgrp;
568 return SCM_MAKINUM (fn (0));
569 }
570
571 SCM_PROC (s_setpgid, "setpgid", 2, 0, 0, scm_setpgid);
572 SCM
573 scm_setpgid (pid, pgid)
574 SCM pid, pgid;
575 {
576 #ifdef HAVE_SETPGID
577 SCM_ASSERT (SCM_INUMP (pid), pid, SCM_ARG1, s_setpgid);
578 SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_setpgid);
579 /* FIXME(?): may be known as setpgrp. */
580 if (setpgid (SCM_INUM (pid), SCM_INUM (pgid)) != 0)
581 scm_syserror (s_setpgid);
582 return SCM_UNSPECIFIED;
583 #else
584 scm_sysmissing (s_setpgid);
585 /* not reached. */
586 return SCM_BOOL_F;
587 #endif
588 }
589
590 SCM_PROC (s_setsid, "setsid", 0, 0, 0, scm_setsid);
591 SCM
592 scm_setsid ()
593 {
594 #ifdef HAVE_SETSID
595 pid_t sid = setsid ();
596 if (sid == -1)
597 scm_syserror (s_setsid);
598 return SCM_UNSPECIFIED;
599 #else
600 scm_sysmissing (s_setsid);
601 /* not reached. */
602 return SCM_BOOL_F;
603 #endif
604 }
605
606 SCM_PROC (s_ttyname, "ttyname", 1, 0, 0, scm_ttyname);
607
608 SCM
609 scm_ttyname (port)
610 SCM port;
611 {
612 char *ans;
613 int fd;
614 SCM_ASSERT (SCM_NIMP (port) && SCM_OPPORTP (port), port, SCM_ARG1, s_ttyname);
615 if (scm_tc16_fport != SCM_TYP16 (port))
616 return SCM_BOOL_F;
617 fd = fileno ((FILE *)SCM_STREAM (port));
618 if (fd == -1)
619 scm_syserror (s_ttyname);
620 SCM_SYSCALL (ans = ttyname (fd));
621 if (!ans)
622 scm_syserror (s_ttyname);
623 /* ans could be overwritten by another call to ttyname */
624 return (scm_makfrom0str (ans));
625 }
626
627
628 SCM_PROC (s_ctermid, "ctermid", 0, 0, 0, scm_ctermid);
629 SCM
630 scm_ctermid ()
631 {
632 #ifdef HAVE_CTERMID
633 char *result = ctermid (NULL);
634 if (*result == '\0')
635 scm_syserror (s_ctermid);
636 return scm_makfrom0str (result);
637 #else
638 scm_sysmissing (s_ctermid);
639 /* not reached. */
640 return SCM_BOOL_F;
641 #endif
642 }
643
644 SCM_PROC (s_tcgetpgrp, "tcgetpgrp", 1, 0, 0, scm_tcgetpgrp);
645 SCM
646 scm_tcgetpgrp (port)
647 SCM port;
648 {
649 #ifdef HAVE_TCGETPGRP
650 int fd;
651 pid_t pgid;
652 SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_tcgetpgrp);
653 fd = fileno ((FILE *)SCM_STREAM (port));
654 if (fd == -1 || (pgid = tcgetpgrp (fd)) == -1)
655 scm_syserror (s_tcgetpgrp);
656 return SCM_MAKINUM (pgid);
657 #else
658 scm_sysmissing (s_tcgetpgrp);
659 /* not reached. */
660 return SCM_BOOL_F;
661 #endif
662 }
663
664 SCM_PROC (s_tcsetpgrp, "tcsetpgrp", 2, 0, 0, scm_tcsetpgrp);
665 SCM
666 scm_tcsetpgrp (port, pgid)
667 SCM port, pgid;
668 {
669 #ifdef HAVE_TCSETPGRP
670 int fd;
671 SCM_ASSERT (SCM_NIMP (port) && SCM_OPFPORTP (port), port, SCM_ARG1, s_tcsetpgrp);
672 SCM_ASSERT (SCM_INUMP (pgid), pgid, SCM_ARG2, s_tcsetpgrp);
673 fd = fileno ((FILE *)SCM_STREAM (port));
674 if (fd == -1 || tcsetpgrp (fd, SCM_INUM (pgid)) == -1)
675 scm_syserror (s_tcsetpgrp);
676 return SCM_UNSPECIFIED;
677 #else
678 scm_sysmissing (s_tcsetpgrp);
679 /* not reached. */
680 return SCM_BOOL_F;
681 #endif
682 }
683
684 /* Copy exec args from an SCM vector into a new C array. */
685
686 static char ** scm_convert_exec_args SCM_P ((SCM args));
687
688 static char **
689 scm_convert_exec_args (args)
690 SCM args;
691 {
692 char **execargv;
693 int num_args;
694 int i;
695 SCM_DEFER_INTS;
696 num_args = scm_ilength (args);
697 execargv = (char **)
698 scm_must_malloc ((num_args + 1) * sizeof (char *), s_ttyname);
699 for (i = 0; SCM_NNULLP (args); args = SCM_CDR (args), ++i)
700 {
701 scm_sizet len;
702 char *dst;
703 char *src;
704 SCM_ASSERT (SCM_NIMP (SCM_CAR (args)) && SCM_ROSTRINGP (SCM_CAR (args)), SCM_CAR (args),
705 "wrong type in SCM_ARG", "exec arg");
706 len = 1 + SCM_ROLENGTH (SCM_CAR (args));
707 dst = (char *) scm_must_malloc ((long) len, s_ttyname);
708 src = SCM_ROCHARS (SCM_CAR (args));
709 while (len--)
710 dst[len] = src[len];
711 execargv[i] = dst;
712 }
713 execargv[i] = 0;
714 SCM_ALLOW_INTS;
715 return execargv;
716 }
717
718 SCM_PROC (s_execl, "execl", 0, 0, 1, scm_execl);
719
720 SCM
721 scm_execl (args)
722 SCM args;
723 {
724 char **execargv;
725 SCM filename = SCM_CAR (args);
726 SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_execl);
727 if (SCM_SUBSTRP (filename))
728 filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0);
729 args = SCM_CDR (args);
730 execargv = scm_convert_exec_args (args);
731 execv (SCM_ROCHARS (filename), execargv);
732 scm_syserror (s_execl);
733 /* not reached. */
734 return SCM_BOOL_F;
735 }
736
737 SCM_PROC (s_execlp, "execlp", 0, 0, 1, scm_execlp);
738
739 SCM
740 scm_execlp (args)
741 SCM args;
742 {
743 char **execargv;
744 SCM filename = SCM_CAR (args);
745 SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_execlp);
746 if (SCM_SUBSTRP (filename))
747 filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0);
748 args = SCM_CDR (args);
749 execargv = scm_convert_exec_args (args);
750 execvp (SCM_ROCHARS (filename), execargv);
751 scm_syserror (s_execlp);
752 /* not reached. */
753 return SCM_BOOL_F;
754 }
755
756 /* Flushing streams etc., is not done here. */
757 SCM_PROC (s_fork, "fork", 0, 0, 0, scm_fork);
758
759 SCM
760 scm_fork()
761 {
762 int pid;
763 pid = fork ();
764 if (pid == -1)
765 scm_syserror (s_fork);
766 return SCM_MAKINUM (0L+pid);
767 }
768
769
770 SCM_PROC (s_uname, "uname", 0, 0, 0, scm_uname);
771
772 SCM
773 scm_uname ()
774 {
775 #ifdef HAVE_UNAME
776 struct utsname buf;
777 SCM ans = scm_make_vector(SCM_MAKINUM(5), SCM_UNSPECIFIED, SCM_BOOL_F);
778 SCM *ve = SCM_VELTS (ans);
779 if (uname (&buf))
780 return SCM_MAKINUM (errno);
781 ve[0] = scm_makfrom0str (buf.sysname);
782 ve[1] = scm_makfrom0str (buf.nodename);
783 ve[2] = scm_makfrom0str (buf.release);
784 ve[3] = scm_makfrom0str (buf.version);
785 ve[4] = scm_makfrom0str (buf.machine);
786 /*
787 a linux special?
788 ve[5] = scm_makfrom0str (buf.domainname);
789 */
790 return ans;
791 #else
792 scm_sysmissing (s_uname);
793 /* not reached. */
794 return SCM_BOOL_F;
795 #endif
796 }
797
798 SCM_PROC (s_environ, "environ", 0, 1, 0, scm_environ);
799
800 SCM
801 scm_environ (env)
802 SCM env;
803 {
804 if (SCM_UNBNDP (env))
805 return scm_makfromstrs (-1, environ);
806 else
807 {
808 int num_strings;
809 char **new_environ;
810 int i = 0;
811 SCM_ASSERT (SCM_NULLP (env) || (SCM_NIMP (env) && SCM_CONSP (env)),
812 env, SCM_ARG1, s_environ);
813 num_strings = scm_ilength (env);
814 new_environ = (char **) scm_must_malloc ((num_strings + 1)
815 * sizeof (char *),
816 s_environ);
817 while (SCM_NNULLP (env))
818 {
819 int len;
820 char *src;
821 SCM_ASSERT (SCM_NIMP (SCM_CAR (env)) && SCM_ROSTRINGP (SCM_CAR (env)), env, SCM_ARG1,
822 s_environ);
823 len = 1 + SCM_ROLENGTH (SCM_CAR (env));
824 new_environ[i] = scm_must_malloc ((long) len, s_environ);
825 src = SCM_ROCHARS (SCM_CAR (env));
826 while (len--)
827 new_environ[i][len] = src[len];
828 env = SCM_CDR (env);
829 i++;
830 }
831 new_environ[i] = 0;
832 /* Free the old environment, except when called for the first
833 * time.
834 */
835 {
836 char **ep;
837 static int first = 1;
838 if (!first)
839 {
840 for (ep = environ; *ep != NULL; ep++)
841 scm_must_free (*ep);
842 scm_must_free ((char *) environ);
843 }
844 first = 0;
845 }
846 environ = new_environ;
847 return SCM_UNSPECIFIED;
848 }
849 }
850
851
852 SCM_PROC (s_open_pipe, "open-pipe", 2, 0, 0, scm_open_pipe);
853
854 SCM
855 scm_open_pipe (pipestr, modes)
856 SCM pipestr;
857 SCM modes;
858 {
859 FILE *f;
860 register SCM z;
861 struct scm_port_table * pt;
862
863 SCM_ASSERT (SCM_NIMP (pipestr) && SCM_ROSTRINGP (pipestr), pipestr, SCM_ARG1, s_open_pipe);
864 if (SCM_SUBSTRP (pipestr))
865 pipestr = scm_makfromstr (SCM_ROCHARS (pipestr), SCM_ROLENGTH (pipestr), 0);
866 SCM_ASSERT (SCM_NIMP (modes) && SCM_ROSTRINGP (modes), modes, SCM_ARG2, s_open_pipe);
867 if (SCM_SUBSTRP (modes))
868 modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_ROLENGTH (modes), 0);
869 SCM_NEWCELL (z);
870 SCM_DEFER_INTS;
871 scm_ignore_signals ();
872 SCM_SYSCALL (f = popen (SCM_ROCHARS (pipestr), SCM_ROCHARS (modes)));
873 scm_unignore_signals ();
874 if (!f)
875 scm_syserror (s_open_pipe);
876 pt = scm_add_to_port_table (z);
877 SCM_SETPTAB_ENTRY (z, pt);
878 SCM_SETCAR (z, scm_tc16_pipe | SCM_OPN
879 | (strchr (SCM_ROCHARS (modes), 'r') ? SCM_RDNG : SCM_WRTNG));
880 SCM_SETSTREAM (z, (SCM)f);
881 SCM_ALLOW_INTS;
882 return z;
883 }
884
885
886 SCM_PROC (s_open_input_pipe, "open-input-pipe", 1, 0, 0, scm_open_input_pipe);
887
888 SCM
889 scm_open_input_pipe(pipestr)
890 SCM pipestr;
891 {
892 return scm_open_pipe(pipestr, scm_makfromstr("r", (sizeof "r")-1, 0));
893 }
894
895 SCM_PROC (s_open_output_pipe, "open-output-pipe", 1, 0, 0, scm_open_output_pipe);
896
897 SCM
898 scm_open_output_pipe(pipestr)
899 SCM pipestr;
900 {
901 return scm_open_pipe(pipestr, scm_makfromstr("w", (sizeof "w")-1, 0));
902 }
903
904
905 SCM_PROC (s_utime, "utime", 1, 2, 0, scm_utime);
906
907 SCM
908 scm_utime (pathname, actime, modtime)
909 SCM pathname;
910 SCM actime;
911 SCM modtime;
912 {
913 int rv;
914 struct utimbuf utm_tmp;
915
916 SCM_ASSERT (SCM_NIMP (pathname) && SCM_STRINGP (pathname), pathname, SCM_ARG1, s_utime);
917
918 if (SCM_UNBNDP (actime))
919 SCM_SYSCALL (time (&utm_tmp.actime));
920 else
921 utm_tmp.actime = scm_num2ulong (actime, (char *) SCM_ARG2, s_utime);
922
923 if (SCM_UNBNDP (modtime))
924 SCM_SYSCALL (time (&utm_tmp.modtime));
925 else
926 utm_tmp.modtime = scm_num2ulong (modtime, (char *) SCM_ARG3, s_utime);
927
928 SCM_SYSCALL (rv = utime (SCM_CHARS (pathname), &utm_tmp));
929 if (rv != 0)
930 scm_syserror (s_utime);
931 return SCM_UNSPECIFIED;
932 }
933
934 SCM_PROC (s_access, "access?", 2, 0, 0, scm_access);
935
936 SCM
937 scm_access (path, how)
938 SCM path;
939 SCM how;
940 {
941 int rv;
942
943 SCM_ASSERT (SCM_NIMP (path) && SCM_ROSTRINGP (path), path, SCM_ARG1, s_access);
944 if (SCM_SUBSTRP (path))
945 path = scm_makfromstr (SCM_ROCHARS (path), SCM_ROLENGTH (path), 0);
946 SCM_ASSERT (SCM_INUMP (how), how, SCM_ARG2, s_access);
947 rv = access (SCM_ROCHARS (path), SCM_INUM (how));
948 return rv ? SCM_BOOL_F : SCM_BOOL_T;
949 }
950
951 SCM_PROC (s_getpid, "getpid", 0, 0, 0, scm_getpid);
952
953 SCM
954 scm_getpid ()
955 {
956 return SCM_MAKINUM ((unsigned long) getpid ());
957 }
958
959 SCM_PROC (s_putenv, "putenv", 1, 0, 0, scm_putenv);
960
961 SCM
962 scm_putenv (str)
963 SCM str;
964 {
965 #ifdef HAVE_PUTENV
966 int rv;
967
968 SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str), str, SCM_ARG1, s_putenv);
969 rv = putenv (SCM_CHARS (str));
970 if (rv < 0)
971 scm_syserror (s_putenv);
972 return SCM_UNSPECIFIED;
973 #else
974 scm_sysmissing (s_putenv);
975 /* not reached. */
976 return SCM_BOOL_F;
977 #endif
978 }
979
980 SCM_PROC (s_read_line, "read-line", 0, 2, 0, scm_read_line);
981
982 SCM
983 scm_read_line (port, include_terminator)
984 SCM port;
985 SCM include_terminator;
986 {
987 register int c;
988 register int j = 0;
989 scm_sizet len = 30;
990 SCM tok_buf;
991 register char *p;
992 int include;
993
994 tok_buf = scm_makstr ((long) len, 0);
995 p = SCM_CHARS (tok_buf);
996 if (SCM_UNBNDP (port))
997 port = scm_cur_inp;
998 else
999 SCM_ASSERT (SCM_NIMP (port) && SCM_OPINPORTP (port), port, SCM_ARG1, s_read_line);
1000
1001 if (SCM_UNBNDP (include_terminator))
1002 include = 0;
1003 else
1004 include = SCM_NFALSEP (include_terminator);
1005
1006 if (EOF == (c = scm_gen_getc (port)))
1007 return SCM_EOF_VAL;
1008 while (1)
1009 {
1010 switch (c)
1011 {
1012 case SCM_LINE_INCREMENTORS:
1013 if (j >= len)
1014 {
1015 p = scm_grow_tok_buf (&tok_buf);
1016 len = SCM_LENGTH (tok_buf);
1017 }
1018 p[j++] = c;
1019 /* fallthrough */
1020 case EOF:
1021 if (len == j)
1022 return tok_buf;
1023 return scm_vector_set_length_x (tok_buf, (SCM) SCM_MAKINUM (j));
1024
1025 default:
1026 if (j >= len)
1027 {
1028 p = scm_grow_tok_buf (&tok_buf);
1029 len = SCM_LENGTH (tok_buf);
1030 }
1031 p[j++] = c;
1032 c = scm_gen_getc (port);
1033 break;
1034 }
1035 }
1036 }
1037
1038 SCM_PROC (s_read_line_x, "read-line!", 1, 1, 0, scm_read_line_x);
1039
1040 SCM
1041 scm_read_line_x (str, port)
1042 SCM str;
1043 SCM port;
1044 {
1045 register int c;
1046 register int j = 0;
1047 register char *p;
1048 scm_sizet len;
1049 SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str), str, SCM_ARG1, s_read_line_x);
1050 p = SCM_CHARS (str);
1051 len = SCM_LENGTH (str);
1052 if SCM_UNBNDP
1053 (port) port = scm_cur_inp;
1054 else
1055 SCM_ASSERT (SCM_NIMP (port) && SCM_OPINPORTP (port), port, SCM_ARG2, s_read_line_x);
1056 c = scm_gen_getc (port);
1057 if (EOF == c)
1058 return SCM_EOF_VAL;
1059 while (1)
1060 {
1061 switch (c)
1062 {
1063 case SCM_LINE_INCREMENTORS:
1064 case EOF:
1065 return SCM_MAKINUM (j);
1066 default:
1067 if (j >= len)
1068 {
1069 scm_gen_ungetc (c, port);
1070 return SCM_BOOL_F;
1071 }
1072 p[j++] = c;
1073 c = scm_gen_getc (port);
1074 }
1075 }
1076 }
1077
1078 SCM_PROC (s_write_line, "write-line", 1, 1, 0, scm_write_line);
1079
1080 SCM
1081 scm_write_line (obj, port)
1082 SCM obj;
1083 SCM port;
1084 {
1085 scm_display (obj, port);
1086 return scm_newline (port);
1087 }
1088
1089 SCM_PROC (s_setlocale, "setlocale", 1, 1, 0, scm_setlocale);
1090
1091 SCM
1092 scm_setlocale (category, locale)
1093 SCM category;
1094 SCM locale;
1095 {
1096 #ifdef HAVE_SETLOCALE
1097 char *clocale;
1098 char *rv;
1099
1100 SCM_ASSERT (SCM_INUMP (category), category, SCM_ARG1, s_setlocale);
1101 if (SCM_UNBNDP (locale))
1102 {
1103 clocale = NULL;
1104 }
1105 else
1106 {
1107 SCM_ASSERT (SCM_NIMP (locale) && SCM_STRINGP (locale), locale, SCM_ARG2, s_setlocale);
1108 clocale = SCM_CHARS (locale);
1109 }
1110
1111 rv = setlocale (SCM_INUM (category), clocale);
1112 if (rv == NULL)
1113 scm_syserror (s_setlocale);
1114 return scm_makfrom0str (rv);
1115 #else
1116 scm_sysmissing (s_setlocale);
1117 /* not reached. */
1118 return SCM_BOOL_F;
1119 #endif
1120 }
1121
1122 SCM_PROC (s_strftime, "strftime", 2, 0, 0, scm_strftime);
1123
1124 SCM
1125 scm_strftime (format, stime)
1126 SCM format;
1127 SCM stime;
1128 {
1129 struct tm t;
1130
1131 char *tbuf;
1132 int n;
1133 int size = 50;
1134 char *fmt;
1135 int len;
1136
1137 SCM_ASSERT (SCM_NIMP (format) && SCM_STRINGP (format), format, SCM_ARG1, s_strftime);
1138 SCM_ASSERT (SCM_NIMP (stime) && SCM_VECTORP (stime) && scm_obj_length (stime) == 9,
1139 stime, SCM_ARG2, s_strftime);
1140
1141 fmt = SCM_ROCHARS (format);
1142 len = SCM_ROLENGTH (format);
1143
1144 #define tm_deref scm_num2long (SCM_VELTS (stime)[n++], (char *)SCM_ARG2, s_strftime)
1145 n = 0;
1146 t.tm_sec = tm_deref;
1147 t.tm_min = tm_deref;
1148 t.tm_hour = tm_deref;
1149 t.tm_mday = tm_deref;
1150 t.tm_mon = tm_deref;
1151 t.tm_year = tm_deref;
1152 /* not used by mktime.
1153 t.tm_wday = tm_deref;
1154 t.tm_yday = tm_deref; */
1155 t.tm_isdst = tm_deref;
1156 #undef tm_deref
1157
1158 /* fill in missing fields and set the timezone. */
1159 mktime (&t);
1160
1161 tbuf = scm_must_malloc (size, s_strftime);
1162 while ((len = strftime (tbuf, size, fmt, &t)) == size)
1163 {
1164 scm_must_free (tbuf);
1165 size *= 2;
1166 tbuf = scm_must_malloc (size, s_strftime);
1167 }
1168 return scm_makfromstr (tbuf, len, 0);
1169 }
1170
1171 SCM_PROC (s_strptime, "strptime", 2, 0, 0, scm_strptime);
1172
1173 SCM
1174 scm_strptime (format, string)
1175 SCM format;
1176 SCM string;
1177 {
1178 #ifdef HAVE_STRPTIME
1179 SCM stime;
1180 struct tm t;
1181
1182 char *fmt, *str, *rest;
1183 int n;
1184
1185 SCM_ASSERT (SCM_NIMP (format) && SCM_ROSTRINGP (format), format, SCM_ARG1, s_strptime);
1186 if (SCM_SUBSTRP (format))
1187 format = scm_makfromstr (SCM_ROCHARS (format), SCM_ROLENGTH (format), 0);
1188 SCM_ASSERT (SCM_NIMP (string) && SCM_ROSTRINGP (string), string, SCM_ARG2, s_strptime);
1189 if (SCM_SUBSTRP (string))
1190 string = scm_makfromstr (SCM_ROCHARS (string), SCM_ROLENGTH (string), 0);
1191
1192 fmt = SCM_CHARS (format);
1193 str = SCM_CHARS (string);
1194
1195 /* initialize the struct tm */
1196 #define tm_init(field) t.field = 0
1197 tm_init (tm_sec);
1198 tm_init (tm_min);
1199 tm_init (tm_hour);
1200 tm_init (tm_mday);
1201 tm_init (tm_mon);
1202 tm_init (tm_year);
1203 tm_init (tm_wday);
1204 tm_init (tm_yday);
1205 tm_init (tm_isdst);
1206 #undef tm_init
1207
1208 SCM_DEFER_INTS;
1209 rest = strptime (str, fmt, &t);
1210 SCM_ALLOW_INTS;
1211
1212 if (rest == NULL)
1213 scm_syserror (s_strptime);
1214
1215 stime = scm_make_vector (SCM_MAKINUM (9), scm_long2num (0), SCM_UNDEFINED);
1216
1217 #define stime_set(val) scm_vector_set_x (stime, SCM_MAKINUM (n++), scm_long2num (t.val));
1218 n = 0;
1219 stime_set (tm_sec);
1220 stime_set (tm_min);
1221 stime_set (tm_hour);
1222 stime_set (tm_mday);
1223 stime_set (tm_mon);
1224 stime_set (tm_year);
1225 stime_set (tm_wday);
1226 stime_set (tm_yday);
1227 stime_set (tm_isdst);
1228 #undef stime_set
1229
1230 return scm_cons (stime, scm_makfrom0str (rest));
1231 #else
1232 scm_sysmissing (s_strptime);
1233 /* not reached. */
1234 return SCM_BOOL_F;
1235 #endif
1236 }
1237
1238 SCM_PROC (s_mknod, "mknod", 3, 0, 0, scm_mknod);
1239
1240 SCM
1241 scm_mknod(path, mode, dev)
1242 SCM path;
1243 SCM mode;
1244 SCM dev;
1245 {
1246 #ifdef HAVE_MKNOD
1247 int val;
1248 SCM_ASSERT(SCM_NIMP(path) && SCM_STRINGP(path), path, SCM_ARG1, s_mknod);
1249 SCM_ASSERT(SCM_INUMP(mode), mode, SCM_ARG2, s_mknod);
1250 SCM_ASSERT(SCM_INUMP(dev), dev, SCM_ARG3, s_mknod);
1251 SCM_SYSCALL(val = mknod(SCM_CHARS(path), SCM_INUM(mode), SCM_INUM(dev)));
1252 if (val != 0)
1253 scm_syserror (s_mknod);
1254 return SCM_UNSPECIFIED;
1255 #else
1256 scm_sysmissing (s_mknod);
1257 /* not reached. */
1258 return SCM_BOOL_F;
1259 #endif
1260 }
1261
1262
1263 SCM_PROC (s_nice, "nice", 1, 0, 0, scm_nice);
1264
1265 SCM
1266 scm_nice(incr)
1267 SCM incr;
1268 {
1269 #ifdef HAVE_NICE
1270 SCM_ASSERT(SCM_INUMP(incr), incr, SCM_ARG1, s_nice);
1271 if (nice(SCM_INUM(incr)) != 0)
1272 scm_syserror (s_nice);
1273 return SCM_UNSPECIFIED;
1274 #else
1275 scm_sysmissing (s_nice);
1276 /* not reached. */
1277 return SCM_BOOL_F;
1278 #endif
1279 }
1280
1281
1282 SCM_PROC (s_sync, "sync", 0, 0, 0, scm_sync);
1283
1284 SCM
1285 scm_sync()
1286 {
1287 #ifdef HAVE_SYNC
1288 sync();
1289 #else
1290 scm_sysmissing (s_sync);
1291 /* not reached. */
1292 #endif
1293 return SCM_BOOL_F;
1294 }
1295
1296
1297
1298
1299 void
1300 scm_init_posix ()
1301 {
1302 scm_add_feature ("posix");
1303 #ifdef HAVE_GETEUID
1304 scm_add_feature ("EIDs");
1305 #endif
1306 #ifdef WAIT_ANY
1307 scm_sysintern ("WAIT_ANY", SCM_MAKINUM (WAIT_ANY));
1308 #endif
1309 #ifdef WAIT_MYPGRP
1310 scm_sysintern ("WAIT_MYPGRP", SCM_MAKINUM (WAIT_MYPGRP));
1311 #endif
1312 #ifdef WNOHANG
1313 scm_sysintern ("WNOHANG", SCM_MAKINUM (WNOHANG));
1314 #endif
1315 #ifdef WUNTRACED
1316 scm_sysintern ("WUNTRACED", SCM_MAKINUM (WUNTRACED));
1317 #endif
1318
1319 #ifdef EINTR
1320 scm_sysintern ("EINTR", SCM_MAKINUM (EINTR));
1321 #endif
1322
1323 #ifdef SIGHUP
1324 scm_sysintern ("SIGHUP", SCM_MAKINUM (SIGHUP));
1325 #endif
1326 #ifdef SIGINT
1327 scm_sysintern ("SIGINT", SCM_MAKINUM (SIGINT));
1328 #endif
1329 #ifdef SIGQUIT
1330 scm_sysintern ("SIGQUIT", SCM_MAKINUM (SIGQUIT));
1331 #endif
1332 #ifdef SIGILL
1333 scm_sysintern ("SIGILL", SCM_MAKINUM (SIGILL));
1334 #endif
1335 #ifdef SIGTRAP
1336 scm_sysintern ("SIGTRAP", SCM_MAKINUM (SIGTRAP));
1337 #endif
1338 #ifdef SIGABRT
1339 scm_sysintern ("SIGABRT", SCM_MAKINUM (SIGABRT));
1340 #endif
1341 #ifdef SIGIOT
1342 scm_sysintern ("SIGIOT", SCM_MAKINUM (SIGIOT));
1343 #endif
1344 #ifdef SIGBUS
1345 scm_sysintern ("SIGBUS", SCM_MAKINUM (SIGBUS));
1346 #endif
1347 #ifdef SIGFPE
1348 scm_sysintern ("SIGFPE", SCM_MAKINUM (SIGFPE));
1349 #endif
1350 #ifdef SIGKILL
1351 scm_sysintern ("SIGKILL", SCM_MAKINUM (SIGKILL));
1352 #endif
1353 #ifdef SIGUSR1
1354 scm_sysintern ("SIGUSR1", SCM_MAKINUM (SIGUSR1));
1355 #endif
1356 #ifdef SIGSEGV
1357 scm_sysintern ("SIGSEGV", SCM_MAKINUM (SIGSEGV));
1358 #endif
1359 #ifdef SIGUSR2
1360 scm_sysintern ("SIGUSR2", SCM_MAKINUM (SIGUSR2));
1361 #endif
1362 #ifdef SIGPIPE
1363 scm_sysintern ("SIGPIPE", SCM_MAKINUM (SIGPIPE));
1364 #endif
1365 #ifdef SIGALRM
1366 scm_sysintern ("SIGALRM", SCM_MAKINUM (SIGALRM));
1367 #endif
1368 #ifdef SIGTERM
1369 scm_sysintern ("SIGTERM", SCM_MAKINUM (SIGTERM));
1370 #endif
1371 #ifdef SIGSTKFLT
1372 scm_sysintern ("SIGSTKFLT", SCM_MAKINUM (SIGSTKFLT));
1373 #endif
1374 #ifdef SIGCHLD
1375 scm_sysintern ("SIGCHLD", SCM_MAKINUM (SIGCHLD));
1376 #endif
1377 #ifdef SIGCONT
1378 scm_sysintern ("SIGCONT", SCM_MAKINUM (SIGCONT));
1379 #endif
1380 #ifdef SIGSTOP
1381 scm_sysintern ("SIGSTOP", SCM_MAKINUM (SIGSTOP));
1382 #endif
1383 #ifdef SIGTSTP
1384 scm_sysintern ("SIGTSTP", SCM_MAKINUM (SIGTSTP));
1385 #endif
1386 #ifdef SIGTTIN
1387 scm_sysintern ("SIGTTIN", SCM_MAKINUM (SIGTTIN));
1388 #endif
1389 #ifdef SIGTTOU
1390 scm_sysintern ("SIGTTOU", SCM_MAKINUM (SIGTTOU));
1391 #endif
1392 #ifdef SIGIO
1393 scm_sysintern ("SIGIO", SCM_MAKINUM (SIGIO));
1394 #endif
1395 #ifdef SIGPOLL
1396 scm_sysintern ("SIGPOLL", SCM_MAKINUM (SIGPOLL));
1397 #endif
1398 #ifdef SIGURG
1399 scm_sysintern ("SIGURG", SCM_MAKINUM (SIGURG));
1400 #endif
1401 #ifdef SIGXCPU
1402 scm_sysintern ("SIGXCPU", SCM_MAKINUM (SIGXCPU));
1403 #endif
1404 #ifdef SIGXFSZ
1405 scm_sysintern ("SIGXFSZ", SCM_MAKINUM (SIGXFSZ));
1406 #endif
1407 #ifdef SIGVTALRM
1408 scm_sysintern ("SIGVTALRM", SCM_MAKINUM (SIGVTALRM));
1409 #endif
1410 #ifdef SIGPROF
1411 scm_sysintern ("SIGPROF", SCM_MAKINUM (SIGPROF));
1412 #endif
1413 #ifdef SIGWINCH
1414 scm_sysintern ("SIGWINCH", SCM_MAKINUM (SIGWINCH));
1415 #endif
1416 #ifdef SIGLOST
1417 scm_sysintern ("SIGLOST", SCM_MAKINUM (SIGLOST));
1418 #endif
1419 #ifdef SIGPWR
1420 scm_sysintern ("SIGPWR", SCM_MAKINUM (SIGPWR));
1421 #endif
1422 /* access() symbols. */
1423 scm_sysintern ("R_OK", SCM_MAKINUM (R_OK));
1424 scm_sysintern ("W_OK", SCM_MAKINUM (W_OK));
1425 scm_sysintern ("X_OK", SCM_MAKINUM (X_OK));
1426 scm_sysintern ("F_OK", SCM_MAKINUM (F_OK));
1427
1428 #ifdef LC_COLLATE
1429 scm_sysintern ("LC_COLLATE", SCM_MAKINUM (LC_COLLATE));
1430 #endif
1431 #ifdef LC_CTYPE
1432 scm_sysintern ("LC_CTYPE", SCM_MAKINUM (LC_CTYPE));
1433 #endif
1434 #ifdef LC_MONETARY
1435 scm_sysintern ("LC_MONETARY", SCM_MAKINUM (LC_MONETARY));
1436 #endif
1437 #ifdef LC_NUMERIC
1438 scm_sysintern ("LC_NUMERIC", SCM_MAKINUM (LC_NUMERIC));
1439 #endif
1440 #ifdef LC_TIME
1441 scm_sysintern ("LC_TIME", SCM_MAKINUM (LC_TIME));
1442 #endif
1443 #ifdef LC_MESSAGES
1444 scm_sysintern ("LC_MESSAGES", SCM_MAKINUM (LC_MESSAGES));
1445 #endif
1446 #ifdef LC_ALL
1447 scm_sysintern ("LC_ALL", SCM_MAKINUM (LC_ALL));
1448 #endif
1449 #include "posix.x"
1450 }