int __cdecl main(int argc, const char* argv[]) { // // parse cmd line parameters // struct Synchronization synch; //sychronization structure synch.ulStructSize = sizeof(synch); synch.hStopEvent = NULL; synch.hStartEvent = NULL; CmdLineParser cmdLineParser; Profile profile; if (!cmdLineParser.ParseCmdLine(argc, argv, &profile, &synch)) { return ERROR_PARSE_CMD_LINE; } synch.pfnCallbackTestStarted = TestStarted; synch.pfnCallbackTestFinished = TestFinished; // // create abort event if stop event is not explicitly provided by the user (otherwise use the stop event) // if (NULL == synch.hStopEvent) { synch.hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if( NULL == synch.hStopEvent ) { fprintf(stderr, "Unable to create an abort event for CTRL+C\n"); //FUTURE EXTENSION: change error code return 1; } } g_hAbortEvent = synch.hStopEvent; // set abort event to either stop event provided by user or the just created event // // capture ctrl+c // if( !SetConsoleCtrlHandler(ctrlCRoutine, TRUE) ) { fprintf(stderr, "Unable to set CTRL+C routine\n"); //FUTURE EXTENSION: change error code return 1; } // // call IO request generator // ResultParser resultParser; XmlResultParser xmlResultParser; IResultParser *pResultParser = nullptr; if (profile.GetResultsFormat() == ResultsFormat::Xml) { pResultParser = &xmlResultParser; } else { pResultParser = &resultParser; } IORequestGenerator ioGenerator; if (!ioGenerator.GenerateRequests(profile, *pResultParser, (PRINTF)PrintOut, (PRINTF)PrintError, (PRINTF)PrintOut, &synch)) { fprintf(stderr, "Error generating I/O requests\n"); return 1; } if( NULL != synch.hStartEvent ) { CloseHandle(synch.hStartEvent); } if( NULL != synch.hStopEvent ) { CloseHandle(synch.hStopEvent); } if( g_hEventStarted ) { CloseHandle(g_hEventStarted); } if( NULL != g_hEventFinished ) { CloseHandle(g_hEventFinished); } return 0; }