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 >
Text File  |  1995-02-05  |  2KB  |  54 lines

  1. -- Copyright (C) International Computer Science Institute, 1994.  COPYRIGHT  --
  2. -- NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject --
  3. -- to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in    --
  4. -- the file "Doc/License" of the Sather distribution.  The license is also   --
  5. -- available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA.  --
  6. --------> Please email comments to "sather-bugs@icsi.berkeley.edu". <----------
  7.  
  8. class UNIX is
  9.  
  10.     system(s:STR):INT is
  11.     return C_UNIX::system(s);
  12.     end;
  13.  
  14.     get_env(var:STR):STR is
  15.     r::=C_UNIX::getenv(var);
  16.     if void(r) then return void;
  17. --      else return STR::create_from_c_string(r);                               -- NLP
  18.     end;
  19.         return STR::create_from_c_string(r);                                    -- NLP
  20.     end;
  21.  
  22.     exit(code:INT) is
  23.     C_UNIX::exit(code);
  24.     end;
  25.  
  26.    execve(prog:STR, argv:ARRAY{STR}, envp:ARRAY{STR}):INT is
  27.       -- Execute a file, by transforming the calling process into a
  28.       -- new process.  If `execve' returns to the calling process,
  29.       -- the returned value will be -1, ie an error has occurred.
  30.       -- `argv', `envp' should have a null pointer as the last pointer.
  31.       new_argv: EXT_OB;
  32.       if (argv.size /= 0) then
  33.      argv_sz:INT := argv.asize;
  34.      new_argv := C_STR::c_str_create_astr(argv.size, STR::concat_all(argv));
  35.       end; -- if
  36.       new_envp: EXT_OB;
  37.       if (envp.size /= 0) then
  38.      envp_sz:INT := envp.asize;
  39.      new_envp := C_STR::c_str_create_astr(envp.size, STR::concat_all(envp));
  40.       end; -- if
  41.       return C_UNIX::execve(prog, new_argv, new_envp);
  42.    end; -- execve
  43.  
  44. end;  -- UNIX
  45.  
  46. external class C_UNIX is
  47.  
  48.     system(s:STR):INT;
  49.     getenv(var:STR):EXT_OB;
  50.     exit(code:INT);
  51.     execve(prog:STR, argv:EXT_OB, envp: EXT_OB): INT;
  52.  
  53. end;
  54.