scsh-0.6/scsh/syscalls.c

1273 lines
27 KiB
C
Raw Normal View History

/* This is an Scheme48/C interface file,
** automatically generated by a hacked version of cig 3.0.
step 4
*/
#include <stdio.h>
#include <stdlib.h> /* For malloc. */
#include "libcig.h"
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/time.h>
#include <fcntl.h> /* for O_RDWR */
#include <sys/stat.h>
#include <netdb.h>
#include <pwd.h>
#include <unistd.h>
/* Make sure foreign-function stubs interface to the C funs correctly: */
#include "dirstuff1.h"
#include "select1.h"
#include "syscalls1.h"
#include "userinfo1.h"
extern int errno;
#define errno_on_zero_or_false(x) ((x) ? S48_FALSE : s48_enter_fixnum(errno))
#define errno_or_false(x) (((x) == -1) ? s48_enter_fixnum(errno) : S48_FALSE)
#define False_on_zero(x) ((x) ? s48_enter_fixnum(x) : S48_FALSE)
s48_value df_scheme_exec(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_exec(const char *, s48_value , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_exec(s48_extract_string(g1), g2, g3);
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_exit(s48_value g1)
{
extern void exit(int );
exit(s48_extract_fixnum(g1));
return S48_FALSE;
}
s48_value df__exit(s48_value g1)
{
extern void _exit(int );
_exit(s48_extract_fixnum(g1));
return S48_FALSE;
}
s48_value df_fork(s48_value mv_vec)
{
extern pid_t fork(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
pid_t r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = fork();
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_wait_pid(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern s48_value wait_pid(pid_t , int , pid_t *, int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
s48_value r1;
pid_t r2;
int r3;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = wait_pid(s48_extract_fixnum(g1), s48_extract_fixnum(g2), &r2, &r3);
ret1 = r1;
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r2));
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r3));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_chdir(s48_value g1)
{
extern int chdir(const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = chdir(s48_extract_string(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_cwd(s48_value mv_vec)
{
extern int scheme_cwd(const char **);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
const char *r2;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_cwd(&r2);
ret1 = False_on_zero(r1);
1999-09-23 10:36:25 -04:00
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getgid(void)
{
extern gid_t getgid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
gid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = getgid();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getegid(void)
{
extern gid_t getegid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
gid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = getegid();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_setgid(s48_value g1)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = setgid(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_num_supp_groups(s48_value mv_vec)
{
extern int num_supp_groups(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = num_supp_groups();
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_get_groups(s48_value g1, s48_value mv_vec)
{
extern int get_groups(s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = get_groups(g1);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getuid(void)
{
extern uid_t getuid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
uid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = getuid();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_geteuid(void)
{
extern uid_t geteuid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
uid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = geteuid();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_setuid(s48_value g1)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = setuid(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getpid(void)
{
extern pid_t getpid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
pid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = getpid();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getppid(void)
{
extern pid_t getppid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
pid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = getppid();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getpgrp(void)
{
extern pid_t getpgrp(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
pid_t r1;
S48_GC_PROTECT_1(ret1);
r1 = getpgrp();
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_setpgid(s48_value g1, s48_value g2)
{
extern int setpgid(pid_t , pid_t );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = setpgid(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_setsid(s48_value mv_vec)
{
extern pid_t setsid(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
pid_t r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = setsid();
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_umask(s48_value g1)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
mode_t r1;
S48_GC_PROTECT_1(ret1);
r1 = umask(s48_extract_fixnum(g1));
ret1 = s48_enter_fixnum(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_process_times(s48_value mv_vec)
{
extern int process_times(clock_t *, clock_t *, clock_t *, clock_t *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
clock_t r2;
clock_t r3;
clock_t r4;
clock_t r5;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = process_times(&r2, &r3, &r4, &r5);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r2));
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r3));
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
S48_VECTOR_SET(mv_vec,3,s48_enter_fixnum(r5));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_cpu_clock_ticks_per_sec(void)
{
extern int cpu_clock_ticks_per_sec(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = cpu_clock_ticks_per_sec();
ret1 = s48_enter_integer(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_chmod(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = chmod(s48_extract_string(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_fchmod(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = fchmod(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_chown(s48_value g1, s48_value g2, s48_value g3)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = chown(s48_extract_string(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_fchown(s48_value g1, s48_value g2, s48_value g3)
{
extern int fchown(int , uid_t , gid_t );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = fchown(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_access(s48_value g1, s48_value g2)
{
extern int access(const char *, int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = access(s48_extract_string(g1), s48_extract_integer(g2));
ret1 = ENTER_BOOLEAN(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_link(s48_value g1, s48_value g2)
{
extern int link(const char *, const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = link(s48_extract_string(g1), s48_extract_string(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_mkfifo(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = mkfifo(s48_extract_string(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_mkdir(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = mkdir(s48_extract_string(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_readlink(s48_value g1, s48_value mv_vec)
{
extern s48_value scm_readlink(const char *, s48_value *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
s48_value r1;
s48_value r2;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scm_readlink(s48_extract_string(g1), &r2);
ret1 = r1;
S48_VECTOR_SET(mv_vec,0,r2);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_rename(s48_value g1, s48_value g2)
{
extern int rename(const char *, const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = rename(s48_extract_string(g1), s48_extract_string(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_rmdir(s48_value g1)
{
extern int rmdir(const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = rmdir(s48_extract_string(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_utime(s48_value g1, s48_value g2, s48_value g3)
{
extern int scm_utime(const char *, time_t , time_t );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scm_utime(s48_extract_string(g1), s48_extract_integer(g2), s48_extract_integer(g3));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_utime_now(s48_value g1)
{
extern int scm_utime_now(const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scm_utime_now(s48_extract_string(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_stat(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_stat(const char *, s48_value , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_stat(s48_extract_string(g1), g2, EXTRACT_BOOLEAN(g3));
ret1 = False_on_zero(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_fstat(s48_value g1, s48_value g2)
{
extern int scheme_fstat(int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_fstat(s48_extract_integer(g1), g2);
ret1 = False_on_zero(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_symlink(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = symlink(s48_extract_string(g1), s48_extract_string(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_truncate(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = truncate(s48_extract_string(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_ftruncate(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = ftruncate(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_unlink(s48_value g1)
{
extern int unlink(const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = unlink(s48_extract_string(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_fsync(s48_value g1)
{
extern int fsync(int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = fsync(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_sync(void)
{
sync();
return S48_FALSE;
}
s48_value df_close(s48_value g1)
{
extern int close(int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = close(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_dup(s48_value g1, s48_value mv_vec)
{
extern int dup(int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = dup(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_dup2(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int dup2(int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = dup2(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_lseek(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern off_t lseek(int , off_t , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
off_t r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = lseek(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_char_ready_fdes(s48_value g1)
{
extern s48_value char_ready_fdes(int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = char_ready_fdes(s48_extract_fixnum(g1));
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_open(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = open(s48_extract_string(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_pipe(s48_value mv_vec)
{
extern int scheme_pipe(int *, int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2;
int r3;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_pipe(&r2, &r3);
ret1 = False_on_zero(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r2));
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r3));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_read_fdes_char(s48_value g1)
{
extern s48_value read_fdes_char(int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = read_fdes_char(s48_extract_fixnum(g1));
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_write_fdes_char(s48_value g1, s48_value g2)
{
extern int write_fdes_char(char , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = write_fdes_char(s48_extract_char(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_read_fdes_substring(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value mv_vec)
{
extern int read_fdes_substring(s48_value , size_t , size_t , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = read_fdes_substring(g1, s48_extract_fixnum(g2), s48_extract_fixnum(g3), s48_extract_fixnum(g4));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_write_fdes_substring(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value mv_vec)
{
extern int write_fdes_substring(s48_value , size_t , size_t , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = write_fdes_substring(g1, s48_extract_fixnum(g2), s48_extract_fixnum(g3), s48_extract_fixnum(g4));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_kill(s48_value g1, s48_value g2)
{
extern int kill(pid_t , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = kill(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_pause(void)
{
pause();
return S48_FALSE;
}
s48_value df_open_dir(s48_value g1, s48_value mv_vec)
{
extern int open_dir(const char *, char** *, int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char** r2;
int r3;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = open_dir(s48_extract_string(g1), &r2, &r3);
ret1 = False_on_zero(r1);
1999-09-23 10:36:25 -04:00
SetAlienVal(S48_VECTOR_REF(mv_vec,0),(long) r2);//simple-assign
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r3));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_sort_filevec(s48_value g1, s48_value g2)
{
extern void scm_sort_filevec(const char** , int );
scm_sort_filevec((const char** )AlienVal(g1), s48_extract_fixnum(g2));
return S48_FALSE;
}
s48_value df_scm_envvec(s48_value mv_vec)
{
extern char** scm_envvec(int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
char** r1;
int r2;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scm_envvec(&r2);
ret1 = S48_VECTOR_REF(mv_vec,0);
1999-09-23 10:36:25 -04:00
SetAlienVal(ret1,(long) r1);//simple-assign
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r2));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_install_env(s48_value g1)
{
extern int install_env(s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = install_env(g1);
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_create_env(s48_value g1, s48_value mv_vec)
{
extern int create_env(s48_value , s48_value *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
s48_value r2;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = create_env(g1, &r2);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,r2);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_align_env(s48_value g1)
{
extern void align_env(s48_value );
align_env(g1);
return S48_FALSE;
}
s48_value df_envvec_setenv(s48_value g1, s48_value g2)
{
extern s48_value envvec_setenv(s48_value , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = envvec_setenv(g1, g2);
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_getenv(s48_value g1, s48_value mv_vec)
{
extern char *getenv(const char *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
char *r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = getenv(s48_extract_string(g1));
ret1 = S48_VECTOR_REF(mv_vec,0);
SetAlienVal(S48_CAR(ret1),(long) r1); S48_SET_CDR(ret1,strlen_or_false(r1));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
#define errno_on_nonzero_or_false(x) ((x) ? s48_enter_fixnum(errno) : S48_FALSE)
s48_value df_delete_env(s48_value g1)
{
extern void delete_env(const char *);
delete_env(s48_extract_string(g1));
return S48_FALSE;
}
s48_value df_set_cloexec(s48_value g1, s48_value g2)
{
extern int set_cloexec(int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = set_cloexec(s48_extract_fixnum(g1), EXTRACT_BOOLEAN(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_fcntl_read(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int fcntl_read(int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = fcntl_read(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_fcntl_write(s48_value g1, s48_value g2, s48_value g3)
{
extern int fcntl_write(int , int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = fcntl_write(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_sleep_until(s48_value g1)
{
extern s48_value sleep_until(time_t );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = sleep_until(s48_extract_integer(g1));
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_gethostname(void)
{
extern s48_value scm_gethostname(void);
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = scm_gethostname();
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_errno_msg(s48_value g1, s48_value mv_vec)
{
extern char *errno_msg(int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
char *r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = errno_msg(s48_extract_integer(g1));
ret1 = S48_VECTOR_REF(mv_vec,0);
1999-09-23 10:36:25 -04:00
SetAlienVal(S48_CAR(ret1),(long) r1); S48_SET_CDR(ret1,strlen_or_false(r1));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_crypt(s48_value g1, s48_value g2)
{
extern s48_value scm_crypt(s48_value , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = scm_crypt(g1, g2);
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value s48_init_syscalls(void)
{
S48_EXPORT_FUNCTION(df_scheme_exec);
S48_EXPORT_FUNCTION(df_exit);
S48_EXPORT_FUNCTION(df__exit);
S48_EXPORT_FUNCTION(df_fork);
S48_EXPORT_FUNCTION(df_wait_pid);
S48_EXPORT_FUNCTION(df_chdir);
S48_EXPORT_FUNCTION(df_scheme_cwd);
S48_EXPORT_FUNCTION(df_getgid);
S48_EXPORT_FUNCTION(df_getegid);
S48_EXPORT_FUNCTION(df_setgid);
S48_EXPORT_FUNCTION(df_num_supp_groups);
S48_EXPORT_FUNCTION(df_get_groups);
S48_EXPORT_FUNCTION(df_getuid);
S48_EXPORT_FUNCTION(df_geteuid);
S48_EXPORT_FUNCTION(df_setuid);
S48_EXPORT_FUNCTION(df_getpid);
S48_EXPORT_FUNCTION(df_getppid);
S48_EXPORT_FUNCTION(df_getpgrp);
S48_EXPORT_FUNCTION(df_setpgid);
S48_EXPORT_FUNCTION(df_setsid);
S48_EXPORT_FUNCTION(df_umask);
S48_EXPORT_FUNCTION(df_process_times);
S48_EXPORT_FUNCTION(df_cpu_clock_ticks_per_sec);
S48_EXPORT_FUNCTION(df_chmod);
S48_EXPORT_FUNCTION(df_fchmod);
S48_EXPORT_FUNCTION(df_chown);
S48_EXPORT_FUNCTION(df_fchown);
S48_EXPORT_FUNCTION(df_access);
S48_EXPORT_FUNCTION(df_link);
S48_EXPORT_FUNCTION(df_mkfifo);
S48_EXPORT_FUNCTION(df_mkdir);
S48_EXPORT_FUNCTION(df_scm_readlink);
S48_EXPORT_FUNCTION(df_rename);
S48_EXPORT_FUNCTION(df_rmdir);
S48_EXPORT_FUNCTION(df_scm_utime);
S48_EXPORT_FUNCTION(df_scm_utime_now);
S48_EXPORT_FUNCTION(df_scheme_stat);
S48_EXPORT_FUNCTION(df_scheme_fstat);
S48_EXPORT_FUNCTION(df_symlink);
S48_EXPORT_FUNCTION(df_truncate);
S48_EXPORT_FUNCTION(df_ftruncate);
S48_EXPORT_FUNCTION(df_unlink);
S48_EXPORT_FUNCTION(df_fsync);
S48_EXPORT_FUNCTION(df_sync);
S48_EXPORT_FUNCTION(df_close);
S48_EXPORT_FUNCTION(df_dup);
S48_EXPORT_FUNCTION(df_dup2);
S48_EXPORT_FUNCTION(df_lseek);
S48_EXPORT_FUNCTION(df_char_ready_fdes);
S48_EXPORT_FUNCTION(df_open);
S48_EXPORT_FUNCTION(df_scheme_pipe);
S48_EXPORT_FUNCTION(df_read_fdes_char);
S48_EXPORT_FUNCTION(df_write_fdes_char);
S48_EXPORT_FUNCTION(df_read_fdes_substring);
S48_EXPORT_FUNCTION(df_write_fdes_substring);
S48_EXPORT_FUNCTION(df_kill);
S48_EXPORT_FUNCTION(df_pause);
S48_EXPORT_FUNCTION(df_open_dir);
S48_EXPORT_FUNCTION(df_scm_sort_filevec);
S48_EXPORT_FUNCTION(df_scm_envvec);
S48_EXPORT_FUNCTION(df_install_env);
S48_EXPORT_FUNCTION(df_create_env);
S48_EXPORT_FUNCTION(df_align_env);
S48_EXPORT_FUNCTION(df_envvec_setenv);
S48_EXPORT_FUNCTION(df_getenv);
S48_EXPORT_FUNCTION(df_delete_env);
S48_EXPORT_FUNCTION(df_set_cloexec);
S48_EXPORT_FUNCTION(df_fcntl_read);
S48_EXPORT_FUNCTION(df_fcntl_write);
S48_EXPORT_FUNCTION(df_sleep_until);
S48_EXPORT_FUNCTION(df_scm_gethostname);
S48_EXPORT_FUNCTION(df_errno_msg);
S48_EXPORT_FUNCTION(df_scm_crypt);
return S48_UNSPECIFIC;
}