CWSTUB.C 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. ** Command & Conquer(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <process.h>
  21. #include <errno.h>
  22. #include <string.h>
  23. char *dos4g_path()
  24. {
  25. static char *paths_to_check[] = {
  26. "DOS4GPATH",
  27. "PATH"
  28. };
  29. static char fullpath[80];
  30. char *dos4gpath;
  31. int i;
  32. /* If DOS4GPATH points to an executable file name, don't bother
  33. searching any paths for DOS4GW.EXE.
  34. */
  35. if (dos4gpath = getenv("DOS4GPATH")) {
  36. strlwr(strcpy(fullpath, dos4gpath));
  37. if (strstr(fullpath, ".exe")) {
  38. return(fullpath);
  39. }
  40. }
  41. for( i = 0; i < sizeof(paths_to_check) / sizeof(paths_to_check[0]); i++ ) {
  42. _searchenv("dos4gw.exe", paths_to_check[i], fullpath);
  43. if (fullpath[0]) {
  44. return( &fullpath );
  45. }
  46. }
  47. return("dos4gw.exe");
  48. }
  49. main( int argc, char *argv[] )
  50. {
  51. char *av[4];
  52. auto char cmdline[128];
  53. av[0] = dos4g_path(); /* Locate the DOS/4GW loader */
  54. av[1] = argv[0]; /* name of executable to run */
  55. av[2] = getcmd(cmdline); /* command line */
  56. av[3] = NULL; /* end of list */
  57. #ifdef VMM
  58. putenv("DOS4GVM=MINMEM#2000 MAXMEM#16000 SWAPMIN#4096 SWAPINC#1024 VIRTUALSIZE#10000 SWAPFILE#CONQUER.SWP DELETESWAP @CONQUER.VMC");
  59. #endif
  60. #ifdef QUIET
  61. putenv("DOS4G=QUIET"); /* disables DOS/4GW Copyright banner */
  62. #endif
  63. execvp(av[0], av);
  64. perror(av[0]);
  65. exit(1); /* indicate error */
  66. }