18 static long siod_time_base;
21 static LISP lgetenv(LISP name)
23 return rintern(getenv(get_c_string(name)));
26 static LISP lsetenv(LISP name,LISP value)
28 char *entry=walloc(
char,strlen(get_c_string(name))+
29 strlen(get_c_string(value))+16);
30 sprintf(entry,
"%s=%s",get_c_string(name),get_c_string(value));
35 static LISP lsystem(LISP name)
37 (void)system(get_c_string(name));
41 static LISP lpwd(
void)
45 cwd = getcwd(NULL,1024);
50 static LISP lchdir(LISP args, LISP env)
55 if (siod_llength(args) == 0)
57 home = getenv(
"HOME");
63 chdir(get_c_string(leval(car(args),env)));
68 static LISP lgetpid(
void)
70 return flocons((
float)getpid());
79 gettimeofday(&tv,&tz);
81 return flocons(((
double)(tv.tv_sec-siod_time_base))+
82 ((
double)tv.tv_usec/1000000));
88 void init_subrs_sys(
void)
95 gettimeofday(&tv,&tz);
97 siod_time_base = tv.tv_sec;
100 init_subr_0(
"getpid",lgetpid,
102 Return process id.");
103 init_fsubr(
"cd",lchdir,
105 Change directory to DIRNAME, if DIRNAME is nil or not specified \n\
106 change directory to user's HOME directory.");
107 init_subr_0(
"pwd",lpwd,
109 Returns current directory as a string.");
110 init_subr_1(
"getenv",lgetenv,
112 Returns value of UNIX environment variable VARNAME, or nil if VARNAME\n\
114 init_subr_2(
"setenv",lsetenv,
115 "(setenv VARNAME VALUE)\n\
116 Set the UNIX environment variable VARNAME to VALUE.");
117 init_subr_1(
"system",lsystem,
119 Execute COMMAND (a string) with the UNIX shell.");
120 init_subr_0(
"time", siod_time,
122 Returns number of seconds since start of epoch (if OS permits it\n\