home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sa104os2.zip
/
SATHR104.ZIP
/
SATHER
/
LIBRARY
/
UNIX.SA
< prev
next >
Wrap
Text File
|
1995-02-05
|
2KB
|
54 lines
-- 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 is
system(s:STR):INT is
return C_UNIX::system(s);
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); -- NLP
end;
return STR::create_from_c_string(r); -- NLP
end;
exit(code:INT) is
C_UNIX::exit(code);
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 := C_STR::c_str_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 := C_STR::c_str_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 is
system(s:STR):INT;
getenv(var:STR):EXT_OB;
exit(code:INT);
execve(prog:STR, argv:EXT_OB, envp: EXT_OB): INT;
end;