20 static LISP lgetenv(LISP name)
22 return rintern(getenv(get_c_string(name)));
25 static LISP lsetenv(LISP name,LISP value)
27 char *entry=walloc(
char,strlen(get_c_string(name))+
28 strlen(get_c_string(value))+16);
29 sprintf(entry,
"%s=%s",get_c_string(name),get_c_string(value));
34 static LISP lsystem(LISP name)
36 system(get_c_string(name));
40 static LISP lpwd(
void)
44 cwd = getcwd(NULL,1024);
49 static LISP lchdir(LISP args, LISP env)
54 if (siod_llength(args) == 0)
56 home = getenv(
"HOME");
62 chdir(get_c_string(leval(car(args),env)));
67 static LISP lgetpid(
void)
69 return flocons((
float)getpid());
72 static long siod_time_base;
80 gettimeofday(&tv,&tz);
82 return flocons(((
double)(tv.tv_sec-siod_time_base))+
83 ((
double)tv.tv_usec/1000000));
89 void init_subrs_sys(
void)
96 gettimeofday(&tv,&tz);
98 siod_time_base = tv.tv_sec;
101 init_subr_0(
"getpid",lgetpid,
103 Return process id.");
104 init_fsubr(
"cd",lchdir,
106 Change directory to DIRNAME, if DIRNAME is nil or not specified \n\
107 change directory to user's HOME directory.");
108 init_subr_0(
"pwd",lpwd,
110 Returns current directory as a string.");
111 init_subr_1(
"getenv",lgetenv,
113 Returns value of UNIX environment variable VARNAME, or nil if VARNAME\n\
115 init_subr_2(
"setenv",lsetenv,
116 "(setenv VARNAME VALUE)\n\
117 Set the UNIX environment variable VARNAME to VALUE.");
118 init_subr_1(
"system",lsystem,
120 Execute COMMAND (a string) with the UNIX shell.");
121 init_subr_0(
"time", siod_time,
123 Returns number of seconds since start of epoch (if OS permits it\n\