📄 posixunix.c
字号:
/* Generated from posixunix.scm by the CHICKEN compiler http://www.call-with-current-continuation.org 2008-09-23 22:55 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 -output-file posixunix.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));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -