Subversion Repositories Games.Carmageddon

Rev

Rev 1 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #include <stdlib.h>
  3.  
  4. #ifdef _WIN32
  5. #include <io.h>
  6. #include <stdio.h>
  7. #include <windows.h>
  8. #endif
  9.  
  10. #include "brender.h"
  11.  
  12. extern void Harness_Init (int *argc, char *argv[]);
  13. extern int original_main (int pArgc, char *pArgv[]);
  14.  
  15. void BR_CALLBACK _BrBeginHook (void)
  16. {
  17.    struct br_device *BR_EXPORT BrDrv1SoftPrimBegin (char *arguments);
  18.    struct br_device *BR_EXPORT BrDrv1SoftRendBegin (char *arguments);
  19.  
  20.    BrDevAddStatic (NULL, BrDrv1SoftPrimBegin, NULL);
  21.    BrDevAddStatic (NULL, BrDrv1SoftRendBegin, NULL);
  22.    // BrDevAddStatic(NULL, BrDrv1SDL2Begin, NULL);
  23. }
  24.  
  25. void BR_CALLBACK _BrEndHook (void)
  26. {
  27. }
  28.  
  29. int main (int argc, char *argv[])
  30. {
  31. #ifdef _WIN32
  32.     /* Attach to the console that started us if any */
  33.    if (AttachConsole (ATTACH_PARENT_PROCESS))
  34.    {
  35. /* We attached successfully, lets redirect IO to the consoles handles if not already redirected */
  36.       if (_fileno (stdout) == -2 || _get_osfhandle (_fileno (stdout)) == -2)
  37.       {
  38.          freopen ("CONOUT$", "w", stdout);
  39.       }
  40.  
  41.       if (_fileno (stderr) == -2 || _get_osfhandle (_fileno (stderr)) == -2)
  42.       {
  43.          freopen ("CONOUT$", "w", stderr);
  44.       }
  45.  
  46.       if (_fileno (stdin) == -2 || _get_osfhandle (_fileno (stdin)) == -2)
  47.       {
  48.          freopen ("CONIN$", "r", stdin);
  49.       }
  50.    }
  51. #endif
  52.  
  53.    Harness_Init (&argc, argv);
  54.  
  55.    return original_main (argc, argv);
  56. }
  57.  
  58. #ifdef _WIN32 // Pierre-Marie Baty -- missing entrypoint
  59. int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  60.    return main(__argc, __argv);
  61. }
  62. #endif // _WIN32
  63.