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