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