unix.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
---------------------------> Sather 1.1 source file <--------------------------
-- Copyright (C) International Computer Science Institute, 1994. COPYRIGHT --
-- NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject --
-- to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in --
-- the file "Doc/License" of the Sather distribution. The license is also --
-- available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA. --
--------> Please email comments to sather-bugs@icsi.berkeley.edu. <----------
class UNIX
class UNIX is
system(s:STR):INT is
return C_UNIX::system(s);
end;
sather_home: STR is
r ::= get_env("SATHER_HOME");
if void(r) then
raise "The environment variable SATHER_HOME is not set\n";
else
if r[r.size-1] = '/' then
raise "Environment variable SATHER_HOME should not end with /";
else
return r;
end;
end;
end;
get_env(var:STR):STR is
r::=C_UNIX::getenv(var);
if void(r) then return void;
else return STR::create_from_c_string(r);
end;
end;
exit(code:INT) is
C_UNIX::exit(code);
end;
abort is
C_UNIX::abort;
end;
execve(prog:STR, argv:ARRAY{STR}, envp:ARRAY{STR}):INT is
-- Execute a file, by transforming the calling process into a
-- new process. If `execve' returns to the calling process,
-- the returned value will be -1, ie an error has occurred.
-- `argv', `envp' should have a null pointer as the last pointer.
new_argv: EXT_OB;
if (argv.size /= 0) then
argv_sz:INT := argv.asize;
new_argv := RUNTIME::rt_create_astr(argv.size, STR::concat_all(argv));
end; -- if
new_envp: EXT_OB;
if (envp.size /= 0) then
envp_sz:INT := envp.asize;
new_envp := RUNTIME::rt_create_astr(envp.size, STR::concat_all(envp));
end; -- if
return C_UNIX::execve(prog, new_argv, new_envp);
end; -- execve
end; -- UNIX
external class C_UNIX
external class C_UNIX is
system(s:STR):INT;
getenv(var:STR):EXT_OB;
exit(code:INT);
execve(prog:STR, argv:EXT_OB, envp: EXT_OB): INT;
abort;
end;