home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / utility / misc / master / source / m_system.c < prev    next >
C/C++ Source or Header  |  1988-08-31  |  810b  |  47 lines

  1. #include <osbind.h>
  2.  
  3. static    long    (*shell_p)();
  4. extern    int    errno;
  5.  
  6. static
  7. read_shell()
  8. {
  9.     long    *_shell_p = (long *) 0x4F6L;
  10.  
  11.     shell_p = (long (*)())(*_shell_p);
  12. }
  13.  
  14. static int
  15. init_system()
  16. {
  17.     int    ret;
  18.  
  19.     Supexec(read_shell);
  20.     if(!(long)shell_p) return(0);
  21.     ret = 1;
  22.     if((*((long *)(((long) shell_p)-10)) == 0x00420135L))
  23.         ret = 2; /* Gulam */
  24.     if((*((long *)(((long) shell_p)-4)) == 0xCDCEC5D2L) || /* Master 5.0 */
  25.        (*((long *)(((long) shell_p)-8)) == 0x4D415354L))   /* Master 5.4 */
  26.         ret = 3; /* Master */
  27.     return(ret);
  28. }
  29.  
  30. long
  31. system(cmd)
  32. char    *cmd;
  33. {
  34.     if(init_system()) return(errno = (shell_p[0])(cmd));
  35.     return(-1L);
  36. }
  37.  
  38. long
  39. m_getenv(cmd)
  40. char    *cmd;
  41. {
  42.     extern long    getenv();
  43.  
  44.     if(init_system() == 3) return((shell_p[4])(1L,cmd));
  45.     return(getenv(cmd));
  46. }
  47.