home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / install / fips / source / host_os.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-11  |  2.1 KB  |  115 lines

  1. // host_os.cpp    host operating system classes 
  2. //        dave mccaldon (d.mccalden@staffordshire.ac.uk) 
  3.  
  4. #include "host_os.h" 
  5. #include <stdio.h> 
  6. #include <stdlib.h> 
  7. #include <string.h> 
  8. #include <dos.h> 
  9.  
  10. char *msdos_info (void) 
  11.     return ("MS-DOS version %d.%d"); 
  12. }; 
  13.  
  14. char *dosemu_info (void) 
  15.     return ("Linux dosemu version %d.%d"); 
  16. }; 
  17.  
  18. char *mswindows_info (void) 
  19.     return ("MS-Windows version %d.%d"); 
  20. }; 
  21.  
  22. char *desqview_info (void) 
  23.     return ("Desq-View version %d.%d"); 
  24. }; 
  25.  
  26. host_os::host_os (void) 
  27.     status = NOT_OK; 
  28.     if (mswindows_detect () == true) format = mswindows_info; 
  29. //    else if (dosemu_detect () == true) format = dosemu_info; 
  30.     else if (desqview_detect () == true) format = desqview_info; 
  31.     else 
  32.     { 
  33.         status = OK; 
  34.         msdos_version (); 
  35.         format = msdos_info; 
  36.     } 
  37.  
  38.  
  39. char *host_os::information( char *p ) 
  40.     if( p == NULL ) 
  41.         p = (char *) malloc( strlen( format() ) + 12 ); 
  42.     sprintf( p, format(), ver_major, ver_minor ); 
  43.  
  44.     return p; 
  45.  
  46. void host_os::msdos_version() 
  47.     ver_major = _osmajor;            // borlandc constants 
  48.     ver_minor = _osminor; 
  49.  
  50. boolean host_os::mswindows_detect() 
  51.     union   REGS r; 
  52.  
  53.     r.x.ax = 0x1600; 
  54.     int86( 0x2F, &r, &r ); 
  55.     if( r.h.al & 0x7F ) 
  56.     { 
  57.         ver_major = r.h.al; 
  58.         ver_minor = r.h.ah; 
  59.         return (true); 
  60.     } 
  61.  
  62.     return (false); 
  63.  
  64. boolean host_os::dosemu_detect() 
  65.     union   REGS r; 
  66.  
  67.     // this is slightly more difficult than just calling the dosemu 
  68.     // interrupt (0xE5), we need to check if the interrupt has a 
  69.     // handler, as DOS and BIOS don't establish a default handler 
  70.  
  71.     if( getvect( 0xE5 ) == NULL ) 
  72.         return (false); 
  73.     r.x.ax = 0; 
  74.     int86( 0xE5, &r, &r ); 
  75.     if( r.x.ax == 0xAA55 )            // check signature 
  76.     { 
  77.         ver_major = r.h.bh; 
  78.         ver_minor = r.h.bl; 
  79.         return (true); 
  80.     } 
  81.  
  82.     return (false); 
  83.  
  84. boolean host_os::desqview_detect() 
  85.     union   REGS r; 
  86.  
  87.     r.x.ax = 0x2B01;                // AL=01 => get desqview version 
  88.     r.x.cx = 0x4445;        // CX = 'DE' 
  89.     r.x.dx = 0x5351;        // DX = 'SQ' 
  90.     int86( 0x21, &r, &r ); 
  91.     if( r.h.al != 0xFF ) 
  92.     { 
  93.         ver_major = r.h.bh; 
  94.         ver_minor = r.h.bl; 
  95.         return (true); 
  96.     } 
  97.  
  98.     return (false); 
  99.