⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uposixunix.c

📁 Scheme跨平台编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Generated from posixunix.scm by the CHICKEN compiler   http://www.call-with-current-continuation.org   2008-09-23 22:56   Version 3.3.0 - linux-unix-gnu-x86	[ manyargs dload ptables applyhook ]   SVN rev. 11106	compiled 2008-07-08 on galinha (Linux)   command line: posixunix.scm -quiet -no-trace -optimize-level 2 -include-path . -include-path ./ -explicit-use -unsafe -no-lambda-info -output-file uposixunix.c   unit: posix*/#include "chicken.h"#include <signal.h>#include <errno.h>#include <math.h>static int C_not_implemented(void);int C_not_implemented() { return -1; }static C_TLS int C_wait_status;#include <unistd.h>#include <sys/types.h>#include <sys/time.h>#include <sys/wait.h>#include <sys/utsname.h>#include <sys/stat.h>#include <sys/ioctl.h>#include <fcntl.h>#include <dirent.h>#include <pwd.h>#if defined(__sun__) && defined(__svr4__)# include <sys/tty.h>#endif#ifdef HAVE_GRP_H#include <grp.h>#endif#include <sys/mman.h>#include <time.h>#ifndef O_FSYNC# define O_FSYNC O_SYNC#endif#ifndef PIPE_BUF# ifdef __CYGWIN__#  define PIPE_BUF       _POSIX_PIPE_BUF# else#  define PIPE_BUF 1024# endif#endif#ifndef O_BINARY# define O_BINARY        0#endif#ifndef O_TEXT# define O_TEXT          0#endif#ifndef ARG_MAX# define ARG_MAX 256#endif#ifndef MAP_FILE# define MAP_FILE    0#endif#ifndef MAP_ANON# define MAP_ANON    0#endif#if defined(HAVE_CRT_EXTERNS_H)# include <crt_externs.h># define C_getenventry(i)       ((*_NSGetEnviron())[ i ])#elif defined(C_MACOSX)# define C_getenventry(i)       NULL#elseextern char **environ;# define C_getenventry(i)       (environ[ i ])#endif#ifndef ENV_MAX# define ENV_MAX        1024#endifstatic C_TLS char *C_exec_args[ ARG_MAX ];static C_TLS char *C_exec_env[ ENV_MAX ];static C_TLS struct utsname C_utsname;static C_TLS struct flock C_flock;static C_TLS DIR *temphandle;static C_TLS struct passwd *C_user;#ifdef HAVE_GRP_Hstatic C_TLS struct group *C_group;#elsestatic C_TLS struct {  char *gr_name, gr_passwd;  int gr_gid;  char *gr_mem[ 1 ];} C_group = { "", "", 0, { "" } };#endifstatic C_TLS int C_pipefds[ 2 ];static C_TLS time_t C_secs;static C_TLS struct tm C_tm;static C_TLS fd_set C_fd_sets[ 2 ];static C_TLS struct timeval C_timeval;static C_TLS char C_hostbuf[ 256 ];static C_TLS struct stat C_statbuf;#define C_mkdir(str)        C_fix(mkdir(C_c_string(str), S_IRWXU | S_IRWXG | S_IRWXO))#define C_chdir(str)        C_fix(chdir(C_c_string(str)))#define C_rmdir(str)        C_fix(rmdir(C_c_string(str)))#define C_opendir(x,h)          C_set_block_item(h, 0, (C_word) opendir(C_c_string(x)))#define C_closedir(h)           (closedir((DIR *)C_block_item(h, 0)), C_SCHEME_UNDEFINED)#define C_readdir(h,e)          C_set_block_item(e, 0, (C_word) readdir((DIR *)C_block_item(h, 0)))#define C_foundfile(e,b)        (strcpy(C_c_string(b), ((struct dirent *) C_block_item(e, 0))->d_name), C_fix(strlen(((struct dirent *) C_block_item(e, 0))->d_name)))#define C_curdir(buf)       (getcwd(C_c_string(buf), 256) ? C_fix(strlen(C_c_string(buf))) : C_SCHEME_FALSE)#define open_binary_input_pipe(a, n, name)   C_mpointer(a, popen(C_c_string(name), "r"))#define open_text_input_pipe(a, n, name)     open_binary_input_pipe(a, n, name)#define open_binary_output_pipe(a, n, name)  C_mpointer(a, popen(C_c_string(name), "w"))#define open_text_output_pipe(a, n, name)    open_binary_output_pipe(a, n, name)#define close_pipe(p)                        C_fix(pclose(C_port_file(p)))#define C_set_file_ptr(port, ptr)  (C_set_block_item(port, 0, (C_block_item(ptr, 0))), C_SCHEME_UNDEFINED)#define C_fork              fork#define C_waitpid(id, o)    C_fix(waitpid(C_unfix(id), &C_wait_status, C_unfix(o)))#define C_getpid            getpid#define C_getppid           getppid#define C_kill(id, s)       C_fix(kill(C_unfix(id), C_unfix(s)))#define C_getuid            getuid#define C_getgid            getgid#define C_geteuid           geteuid#define C_getegid           getegid#define C_chown(fn, u, g)   C_fix(chown(C_data_pointer(fn), C_unfix(u), C_unfix(g)))#define C_chmod(fn, m)      C_fix(chmod(C_data_pointer(fn), C_unfix(m)))#define C_setuid(id)        C_fix(setuid(C_unfix(id)))#define C_setgid(id)        C_fix(setgid(C_unfix(id)))#define C_seteuid(id)       C_fix(seteuid(C_unfix(id)))#define C_setegid(id)       C_fix(setegid(C_unfix(id)))#define C_setsid(dummy)     C_fix(setsid())#define C_setpgid(x, y)     C_fix(setpgid(C_unfix(x), C_unfix(y)))#define C_getpgid(x)        C_fix(getpgid(C_unfix(x)))#define C_symlink(o, n)     C_fix(symlink(C_data_pointer(o), C_data_pointer(n)))#define C_readlink(f, b)    C_fix(readlink(C_data_pointer(f), C_data_pointer(b), FILENAME_MAX))#define C_getpwnam(n)       C_mk_bool((C_user = getpwnam((char *)C_data_pointer(n))) != NULL)#define C_getpwuid(u)       C_mk_bool((C_user = getpwuid(C_unfix(u))) != NULL)#ifdef HAVE_GRP_H#define C_getgrnam(n)       C_mk_bool((C_group = getgrnam((char *)C_data_pointer(n))) != NULL)#define C_getgrgid(u)       C_mk_bool((C_group = getgrgid(C_unfix(u))) != NULL)#else#define C_getgrnam(n)       C_SCHEME_FALSE#define C_getgrgid(n)       C_SCHEME_FALSE#endif#define C_pipe(d)           C_fix(pipe(C_pipefds))#define C_truncate(f, n)    C_fix(truncate((char *)C_data_pointer(f), C_num_to_int(n)))#define C_ftruncate(f, n)   C_fix(ftruncate(C_unfix(f), C_num_to_int(n)))#define C_uname             C_fix(uname(&C_utsname))#define C_fdopen(a, n, fd, m) C_mpointer(a, fdopen(C_unfix(fd), C_c_string(m)))#define C_C_fileno(p)       C_fix(fileno(C_port_file(p)))#define C_dup(x)            C_fix(dup(C_unfix(x)))#define C_dup2(x, y)        C_fix(dup2(C_unfix(x), C_unfix(y)))#define C_alarm             alarm#define C_setvbuf(p, m, s)  C_fix(setvbuf(C_port_file(p), NULL, C_unfix(m), C_unfix(s)))#define C_access(fn, m)     C_fix(access((char *)C_data_pointer(fn), C_unfix(m)))#define C_close(fd)         C_fix(close(C_unfix(fd)))#define C_sleep             sleep#define C_putenv(s)         C_fix(putenv((char *)C_data_pointer(s)))#define C_stat(fn)          C_fix(stat((char *)C_data_pointer(fn), &C_statbuf))#define C_lstat(fn)         C_fix(lstat((char *)C_data_pointer(fn), &C_statbuf))#define C_fstat(f)          C_fix(fstat(C_unfix(f), &C_statbuf))#define C_islink            ((C_statbuf.st_mode & S_IFMT) == S_IFLNK)#define C_isreg             ((C_statbuf.st_mode & S_IFMT) == S_IFREG)#define C_isdir             ((C_statbuf.st_mode & S_IFMT) == S_IFDIR)#define C_ischr             ((C_statbuf.st_mode & S_IFMT) == S_IFCHR)#define C_isblk             ((C_statbuf.st_mode & S_IFMT) == S_IFBLK)#define C_isfifo            ((C_statbuf.st_mode & S_IFMT) == S_IFIFO)#ifdef S_IFSOCK#define C_issock            ((C_statbuf.st_mode & S_IFMT) == S_IFSOCK)#else#define C_issock            ((C_statbuf.st_mode & S_IFMT) == 0140000)#endif#ifdef C_GNU_ENV# define C_setenv(x, y)     C_fix(setenv((char *)C_data_pointer(x), (char *)C_data_pointer(y), 1))#elsestatic C_word C_fcall C_setenv(C_word x, C_word y) {  char *sx = C_data_pointer(x),       *sy = C_data_pointer(y);  int n1 = C_strlen(sx), n2 = C_strlen(sy);  char *buf = (char *)C_malloc(n1 + n2 + 2);  if(buf == NULL) return(C_fix(0));  else {    C_strcpy(buf, sx);    buf[ n1 ] = '=';    C_strcpy(buf + n1 + 1, sy);    return(C_fix(putenv(buf)));  }}#endifstatic void C_fcall C_set_arg_string(char **where, int i, char *a, int len) {  char *ptr;  if(a != NULL) {    ptr = (char *)C_malloc(len + 1);    C_memcpy(ptr, a, len);    ptr[ len ] = '\0';  }  else ptr = NULL;  where[ i ] = ptr;}static void C_fcall C_free_arg_string(char **where) {  while((*where) != NULL) C_free(*(where++));}static void C_set_timeval(C_word num, struct timeval *tm){  if((num & C_FIXNUM_BIT) != 0) {    tm->tv_sec = C_unfix(num);    tm->tv_usec = 0;  }  else {    double i;    tm->tv_usec = (int)(modf(C_flonum_magnitude(num), &i) * 1000000);    tm->tv_sec = (int)i;  }}#define C_set_exec_arg(i, a, len)	C_set_arg_string(C_exec_args, i, a, len)#define C_free_exec_args()		C_free_arg_string(C_exec_args)#define C_set_exec_env(i, a, len)	C_set_arg_string(C_exec_env, i, a, len)#define C_free_exec_env()		C_free_arg_string(C_exec_env)#define C_execvp(f)         C_fix(execvp(C_data_pointer(f), C_exec_args))#define C_execve(f)         C_fix(execve(C_data_pointer(f), C_exec_args, C_exec_env))#if defined(__FreeBSD__) || defined(C_MACOSX) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sgi__) || defined(sgi) || defined(__DragonFly__) || defined(__SUNPRO_C)static C_TLS int C_uw;# define C_WIFEXITED(n)      (C_uw = C_unfix(n), C_mk_bool(WIFEXITED(C_uw)))# define C_WIFSIGNALED(n)    (C_uw = C_unfix(n), C_mk_bool(WIFSIGNALED(C_uw)))# define C_WIFSTOPPED(n)     (C_uw = C_unfix(n), C_mk_bool(WIFSTOPPED(C_uw)))# define C_WEXITSTATUS(n)    (C_uw = C_unfix(n), C_fix(WEXITSTATUS(C_uw)))# define C_WTERMSIG(n)       (C_uw = C_unfix(n), C_fix(WTERMSIG(C_uw)))# define C_WSTOPSIG(n)       (C_uw = C_unfix(n), C_fix(WSTOPSIG(C_uw)))#else# define C_WIFEXITED(n)      C_mk_bool(WIFEXITED(C_unfix(n)))# define C_WIFSIGNALED(n)    C_mk_bool(WIFSIGNALED(C_unfix(n)))# define C_WIFSTOPPED(n)     C_mk_bool(WIFSTOPPED(C_unfix(n)))# define C_WEXITSTATUS(n)    C_fix(WEXITSTATUS(C_unfix(n)))# define C_WTERMSIG(n)       C_fix(WTERMSIG(C_unfix(n)))# define C_WSTOPSIG(n)       C_fix(WSTOPSIG(C_unfix(n)))#endif#ifdef __CYGWIN__# define C_mkfifo(fn, m)    C_fix(-1);#else# define C_mkfifo(fn, m)    C_fix(mkfifo((char *)C_data_pointer(fn), C_unfix(m)))#endif#define C_flock_setup(t, s, n) (C_flock.l_type = C_unfix(t), C_flock.l_start = C_num_to_int(s), C_flock.l_whence = SEEK_SET, C_flock.l_len = C_num_to_int(n), C_SCHEME_UNDEFINED)#define C_flock_test(p)     (fcntl(fileno(C_port_file(p)), F_GETLK, &C_flock) >= 0 ? (C_flock.l_type == F_UNLCK ? C_fix(0) : C_fix(C_flock.l_pid)) : C_SCHEME_FALSE)#define C_flock_lock(p)     C_fix(fcntl(fileno(C_port_file(p)), F_SETLK, &C_flock))#define C_flock_lockw(p)    C_fix(fcntl(fileno(C_port_file(p)), F_SETLKW, &C_flock))#ifndef FILENAME_MAX# define FILENAME_MAX          1024#endifstatic C_TLS sigset_t C_sigset;#define C_sigemptyset(d)    (sigemptyset(&C_sigset), C_SCHEME_UNDEFINED)#define C_sigaddset(s)      (sigaddset(&C_sigset, C_unfix(s)), C_SCHEME_UNDEFINED)#define C_sigdelset(s)      (sigdelset(&C_sigset, C_unfix(s)), C_SCHEME_UNDEFINED)#define C_sigismember(s)    C_mk_bool(sigismember(&C_sigset, C_unfix(s)))#define C_sigprocmask_set(d)        C_fix(sigprocmask(SIG_SETMASK, &C_sigset, NULL))#define C_sigprocmask_block(d)      C_fix(sigprocmask(SIG_BLOCK, &C_sigset, NULL))#define C_sigprocmask_unblock(d)    C_fix(sigprocmask(SIG_UNBLOCK, &C_sigset, NULL))#define C_open(fn, fl, m)   C_fix(open(C_c_string(fn), C_unfix(fl), C_unfix(m)))#define C_read(fd, b, n)    C_fix(read(C_unfix(fd), C_data_pointer(b), C_unfix(n)))#define C_write(fd, b, n)   C_fix(write(C_unfix(fd), C_data_pointer(b), C_unfix(n)))#define C_mkstemp(t)        C_fix(mkstemp(C_c_string(t)))#define C_ftell(p)            C_fix(ftell(C_port_file(p)))#define C_fseek(p, n, w)      C_mk_nbool(fseek(C_port_file(p), C_unfix(n), C_unfix(w)))#define C_lseek(fd, o, w)     C_fix(lseek(C_unfix(fd), C_unfix(o), C_unfix(w)))#define C_zero_fd_set(i)      FD_ZERO(&C_fd_sets[ i ])#define C_set_fd_set(i, fd)   FD_SET(fd, &C_fd_sets[ i ])#define C_test_fd_set(i, fd)  FD_ISSET(fd, &C_fd_sets[ i ])#define C_C_select(m)         C_fix(select(C_unfix(m), &C_fd_sets[ 0 ], &C_fd_sets[ 1 ], NULL, NULL))#define C_C_select_t(m, t)    (C_set_timeval(t, &C_timeval), \			       C_fix(select(C_unfix(m), &C_fd_sets[ 0 ], &C_fd_sets[ 1 ], NULL, &C_timeval)))#define C_ctime(n)          (C_secs = (n), ctime(&C_secs))#if defined(__SVR4)/* Seen here: http://lists.samba.org/archive/samba-technical/2002-November/025571.html */static time_t timegm(struct tm *t){  time_t tl, tb;  struct tm *tg;  tl = mktime (t);  if (tl == -1)    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -