home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c495 / watcm951.arj / WSTUBSRC.WPK / WSTUB.C
Encoding:
C/C++ Source or Header  |  1993-02-16  |  1.2 KB  |  48 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <process.h>
  4. #include <errno.h>
  5. #include <string.h>
  6.  
  7. /* Add environment strings to be searched here */
  8. char *paths_to_check[] = {
  9.     "DOS4GPATH",
  10.     "PATH"};
  11.  
  12. char *dos4g_path()
  13. {
  14.     static char fullpath[80];
  15.     int i;
  16.     
  17.     for( i = 0;
  18.          i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) {
  19.     _searchenv( "dos4gw.exe", paths_to_check[i], fullpath );
  20.     if( fullpath[0] ) return( &fullpath );
  21.     }    
  22.     for( i = 0;
  23.          i < sizeof( paths_to_check ) / sizeof( paths_to_check[0] ); i++ ) {
  24.     _searchenv( "dos4g.exe", paths_to_check[i], fullpath );
  25.     if( fullpath[0] ) return( &fullpath );
  26.     }    
  27.     return( "dos4gw.exe" );
  28. }
  29.  
  30. main( int argc, char *argv[] )
  31. {
  32.     char    *av[4];
  33.     auto char     cmdline[128];
  34.     
  35.     av[0] = dos4g_path();        /* Locate the DOS/4G loader */
  36.     av[1] = argv[0];            /* name of executable to run */
  37.     av[2] = getcmd( cmdline );        /* command line */
  38.     av[3] = NULL;            /* end of list */
  39. #ifdef QUIET
  40.     putenv( "DOS4G=QUIET" );    /* disables DOS/4G Copyright banner */
  41. #endif
  42.     execvp( av[0], av );
  43.     puts( "Stub exec failed:" );
  44.     puts( av[0] );
  45.     puts( strerror( errno ) );
  46.     exit( 1 );            /* indicate error */
  47. }
  48.