/** * Take control from player, if the player has it. * Return TRUE if control taken, FALSE if not. */ bool GetControl(int param) { if (TinselV2) return GetControl(); else if (TestToken(TOKEN_CONTROL)) { Control(param); return true; } else return false; }
int main( int argc, char *argv[] ) { #ifdef __SW_BW FILE *my_stdout; my_stdout = freopen( "tmp.log", "a", stdout ); if( my_stdout == NULL ) { fprintf( stderr, "Unable to redirect stdout\n" ); exit( -1 ); } #endif /*** Initialize ***/ strcpy( ProgramName, strlwr( argv[0] ) ); /* store filename */ /*** Test various functions ***/ TestCompare(); /* compare stuff */ TestMove(); /* moving data about */ TestCase(); /* upper/lowercase stuff */ TestSearch(); /* searching stuff */ TestSubstring(); /* substring stuff */ TestToken(); /* tokenizing stuff */ TestLocale(); /* locale stuff */ TestError(); /* error string stuff */ TestFormatted(); /* formatted I/O stuff */ TestBounded(); /* bounded string stuff */ #ifdef __X86__ TestCompareF(); TestMoveF(); TestCaseF(); TestSearchF(); TestSubstringF(); TestTokenF(); #endif /*** Print a pass/fail message and quit ***/ if( NumErrors != 0 ) { printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors ); return( EXIT_FAILURE ); } printf( "Tests completed (%s).\n", strlwr( argv[0] ) ); #ifdef __SW_BW fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) ); fclose( my_stdout ); _dwShutDown(); #endif return( 0 ); }
// Our main test program int main(int argc,TCHAR* argv[], TCHAR* /*envp[]*/) { int nRetCode = 0; HMODULE hModule = ::GetModuleHandle(NULL); InitializeCriticalSection(&std_stream); if(hModule == NULL) { _tprintf(_T("Fatal Error: GetModuleHandle failed\n")); nRetCode = 1; } else { // initialize MFC and print and error on failure if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0)) { _tprintf(_T("Fatal Error: MFC initialization failed\n")); nRetCode = 1; } else { printf("TESTPROGAM: MARLIN SERVER\n"); printf("=========================\n"); printf("\n"); printf("Version string: %s\n",MARLIN_SERVER_VERSION); printf("----------------------------------\n"); printf("\n"); // See if we must do the standalone WebServiceServer test // Or that we should do the flat HTTPServer tests if(argc >= 2) { if(_stricmp(argv[1],"/ws") == 0) { CString contract = "http://interface.marlin.org/testing/"; printf("WebServiceServer test for \"%s\"\n",contract.GetString()); printf("----------------------------------------------------------------\n"); printf("\n"); // Test the Interface nRetCode = TestWebServiceServer(NULL,contract,logLevel); } } else { HTTPServer* server = nullptr; LogAnalysis* logfile = nullptr; if(StartServer(server,logfile)) { // Fire up all of our test sites int errors = 0; // Individual tests errors += Test_CrackURL(); errors += Test_HTTPTime(); errors += TestThreadPool(server->GetThreadPool()); // HTTP tests errors += TestBaseSite(server); errors += TestSecureSite(server); errors += TestClientCertificate(server,true); errors += TestCookies(server); errors += TestFormData(server); errors += TestJsonData(server); errors += TestInsecure(server); errors += TestPushEvents(server); errors += TestBodySigning(server); errors += TestBodyEncryption(server); errors += TestMessageEncryption(server); errors += TestReliable(server); errors += TestReliableBA(server); errors += TestToken(server); errors += TestSubSites(server); errors += TestFilter(server); errors += TestPatch(server); errors += TestCompression(server); errors += TestAsynchrone(server); errors += TestWebSocket(server); // Test the WebServiceServer program generation CString contract = "http://interface.marlin.org/testing/"; errors += TestJsonServer(server,contract,logLevel); errors += TestWebServiceServer(server,contract,logLevel); // See if we should wait for testing to occur if(errors) { printf("\n" "SERVER (OR PROGRAMMING) IN ERROR STATE!!\n" "%d sites not correctly started\n" "\n",errors); } else { printf("\n" "Server running....\n" "Waiting to be called by test clients...\n" "\n"); // Wait for key to occur WaitForKey(); } // Try to stop the WebSocket // errors += StopWebSocket(); // // Try to stop the subsites errors += StopSubsites(server); // Testing the errorlog function server->ErrorLog(__FUNCTION__,5,"Not a real error message, but a test to see if it works :-)"); printf("Stopping the server\n"); server->StopServer(); // See if the server is indeed in stopped state printf("The server is %s\n",server->GetIsRunning() ? "still running!\n" : "stopped.\n"); // Remember for a cmd shell nRetCode = errors; } else { totalErrors = 1; printf("HTTPServer in error state in : Error %lu: %s\n" ,server->GetLastError() ,(LPCTSTR)GetLastErrorAsString(GetLastError())); } CleanupServer(server,logfile); } } printf("\n"); printf("SUMMARY OF ALL SERVER TESTS\n"); printf("===========================\n"); if(totalErrors) { printf("ERRORS: %d\n",nRetCode += totalErrors); } else { printf("ALL OK !!!! YIPEEEE!!!!\n"); } WaitForKey(); WaitForKey(); } DeleteCriticalSection(&std_stream); return nRetCode; }
/** * Runs glitter code associated with a polygon. */ void PolyTinselProcess(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; INT_CONTEXT *pic; bool bTookControl; // Set if this function takes control CORO_END_CONTEXT(_ctx); const PTP_INIT *to = (const PTP_INIT *)param; // get the stuff copied to process when it was created CORO_BEGIN_CODE(_ctx); if (TinselV2) { // Take control for CONVERSE events if (to->event == CONVERSE) { _ctx->bTookControl = GetControl(); HideConversation(true); } else _ctx->bTookControl = false; CORO_INVOKE_1(Interpret, to->pic); // Restore conv window if applicable if (to->event == CONVERSE) { // Free control if we took it if (_ctx->bTookControl) ControlOn(); HideConversation(false); } } else { CORO_INVOKE_1(AllowDclick, to->bev); // May kill us if single click // Control may have gone off during AllowDclick() if (!TestToken(TOKEN_CONTROL) && (to->event == WALKTO || to->event == ACTION || to->event == LOOK)) CORO_KILL_SELF(); // Take control, if requested if (to->take_control) _ctx->bTookControl = GetControl(CONTROL_OFF); else _ctx->bTookControl = false; // Hide conversation if appropriate if (to->event == CONVERSE) HideConversation(true); // Run the code _ctx->pic = InitInterpretContext(GS_POLYGON, GetPolyScript(to->hPoly), to->event, to->hPoly, to->actor, NULL); CORO_INVOKE_1(Interpret, _ctx->pic); // Free control if we took it if (_ctx->bTookControl) Control(CONTROL_ON); // Restore conv window if applicable if (to->event == CONVERSE) HideConversation(false); } CORO_END_CODE; }
bool ControlIsOn() { if (TinselV2) return (g_controlState == CONTROL_ON); return TestToken(TOKEN_CONTROL); }