#include <stdlib.h>
#ifdef _WIN32
#include <io.h>
#include <stdio.h>
#include <windows.h>
#endif
extern void Harness_Init(int* argc, char* argv[]);
extern int original_main(int pArgc, char* pArgv[]);
int main(int argc, char* argv[]) {
#ifdef _WIN32
/* Attach to the console that started us if any */
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
/* We attached successfully, lets redirect IO to the consoles handles if not already redirected */
if (_fileno(stdout) == -2 || _get_osfhandle(_fileno(stdout)) == -2) {
}
if (_fileno(stderr) == -2 || _get_osfhandle(_fileno(stderr)) == -2) {
}
if (_fileno(stdin) == -2 || _get_osfhandle(_fileno(stdin)) == -2) {
}
}
#endif
Harness_Init(&argc, argv);
return original_main(argc, argv);
}
#ifdef _WIN32 // Pierre-Marie Baty -- missing entrypoint
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
return main(__argc, __argv);
}
#endif // _WIN32