//----------------------------------------------------------------------------- // Init, shutdown //----------------------------------------------------------------------------- InitReturnVal_t CEngineAPI::Init() { InitReturnVal_t nRetVal = BaseClass::Init(); if ( nRetVal != INIT_OK ) return nRetVal; m_bRunningSimulation = false; // Initialize the FPU control word #if !defined( SWDS ) && !defined( _X360 ) _asm { fninit } #endif SetupFPUControlWord(); // This creates the videomode singleton object, it doesn't depend on the registry VideoMode_Create(); // Initialize the editor hwnd to render into m_hEditorHWnd = NULL; // One-time setup // FIXME: OnStartup + OnShutdown should be removed + moved into the launcher // or the launcher code should be merged into the engine into the code in OnStartup/OnShutdown if ( !OnStartup( m_StartupInfo.m_pInstance, m_StartupInfo.m_pInitialMod ) ) { return HandleSetModeError(); } return INIT_OK; }
void CThread::Action() { try { OnStartup(); } catch (...) { LOG(LOG_ERROR, "thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", m_ThreadName.c_str(), IsAutoDelete()); if (IsAutoDelete()) return; } try { Process(); } catch (...) { LOG(LOG_ERROR, "thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", m_ThreadName.c_str(), IsAutoDelete()); } try { OnExit(); } catch (...) { LOG(LOG_ERROR, "thread %s, Unhandled exception caught in thread OnExit, aborting. auto delete: %d", m_ThreadName.c_str(), IsAutoDelete()); } }
void CThread::Action() { try { OnStartup(); } catch (...) { CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete()); if (IsAutoDelete()) return; } try { Process(); } catch (...) { CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete()); } try { OnExit(); } catch (...) { CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread exit, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete()); } }
void CEngine::Run() { FKeepRunning = true; OnStartup(); while(FKeepRunning) { OnFrame(); } OnShutDown(); }
void clsScriptManager::Restart() { OnExit(); Stop(); CheckForDeletedScripts(); Start(); OnStartup(); #ifdef _BUILD_GUI clsMainWindowPageScripts::mPtr->AddScriptsToList(true); #endif }
SYSSTATUS CMainApp::InitInstance() { CoInitialize(NULL); if (InitServer(8070)!=0) { the_log.LogT(8, "InitInstance: Failed to init server on port 8070\n"); return STATUS_UNSUCCESSFUL; } the_log.LogT(2, "InitInstance: DONE\n"); //the_log.SetLogFile("c:\log.txt"); OnStartup(); return STATUS_SUCCESS; }
BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: OnStartup(); break; case DLL_PROCESS_DETACH: OnExit(); break; } return TRUE; }
void Game::OnLoop() { //Gets the start ticks OnStartup(); //Set default cursor every frame SDL_SetCursor(SDL_GetDefaultCursor()); if(LeftButtonPressed == true) { Map1.building = true; } //Caps the frame rate depending on the ticks that have past FrameRate(FPS); }
void CThread::Action() { try { OnStartup(); } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("OnStartup"); if (IsAutoDelete()) return; } catch (...) { LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete()); if (IsAutoDelete()) return; } try { Process(); } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("Process"); } catch (...) { LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete()); } try { OnExit(); } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("OnExit"); } catch (...) { LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread OnExit, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete()); } }
void mpStartup::Startup() { if(g_bIsShutDown) { // Reset to initial state. g_bIsStarted = false; g_bIsShutDown = false; } if(g_bIsStarted) return; for (auto pInit = g_pInit; pInit != nullptr; pInit = pInit->m_pNext) { pInit->OnStartup(); } g_bIsStarted = true; }
void CommandDispatcher (PA_long32 pProcNum, PA_PluginParameters params) { switch(pProcNum) { case kInitPlugin : case kServerInitPlugin : OnStartup(); break; // --- Common Crypto case 1 : PEM_From_P12(params); break; case 2 : Get_timestamp(params); break; case 3 : Get_timestring(params); break; case 4 : Get_unixtime(params); break; case 5 : RSASHA256(params); break; case 6 : HMACMD5(params); break; case 7 : HMACSHA1(params); break; case 8 : HMACSHA256(params); break; case 9 : HMACSHA384(params); break; case 10 : HMACSHA512(params); break; case 11 : SHA384(params); break; case 12 : SHA512(params); break; case 13 : MD5(params); break; case 14 : SHA1(params); break; case 15 : SHA256(params); break; case 16 : RSASHA1(params); break; case 17 : AES128(params); break; case 18 : AES192(params); break; case 19 : AES256(params); break; case 20 : RIPEMD160(params); break; case 21 : RSAVERIFYSHA1(params); break; case 22 : RSAVERIFYSHA256(params); break; } }
unsigned Listener::Process() { //Profile profile("Listener::Process"); //////////////////////////////////////// // handle inactive state (with UdpManager) if (!IsActive() && mTcpManager) { // check all connections to see if they are idle std::set<Connection *>::iterator iterator; for (iterator = mConnections.begin(); iterator != mConnections.end(); iterator++) { Connection * connection = *iterator; if (connection->IsConnected()) connection->Disconnect(); } // close the UdpManager if all the connections are closed if (!mConnectionCount) { mTcpManager->Release(); mTcpManager = 0; OnShutdown(); } } //////////////////////////////////////// // handle active state (without UdpManager) else if (IsActive() && !mTcpManager) { mParams = GetConnectionParams(); mActiveMax = GetActiveRequestMax(); mTcpManager = new TcpManager(mParams); mTcpManager->SetHandler(this); if (mTcpManager->BindAsServer()){ OnStartup(); }else{ OnFailedStartup(); return 0; } } //////////////////////////////////////// // process the TcpManager if (mTcpManager) { //Profile subProfile("TcpManager::GiveTime()"); mTcpManager->GiveTime(); } // check all closed connections to see if they are idle std::list<Connection *>::iterator closedIterator = mClosedConnections.begin(); while (closedIterator != mClosedConnections.end()) { //Profile profile("Listener::Process (cleanup connection)"); std::list<Connection *>::iterator current = closedIterator++; Connection * connection = *current; if (!connection->GetActiveRequests() && !connection->GetQueuedRequests()) { mClosedConnections.erase(current); mConnections.erase(connection); mConnectionCount--; OnConnectionDestroyed(connection); delete connection; } } //////////////////////////////////////// // process request queue while (!mQueuedRequests.empty() && (!mActiveMax || mActiveCount < mActiveMax)) { //Profile profile("Listener::Process (activate queued request)"); QueueNode & node = mQueuedRequests.front(); if (!IsActive()) { // If not active, discard queued request if (node.connection) { // normal request, internal requests have no connection node.connection->NotifyDiscardRequest(node.request); } DestroyRequest(node.request); } else { // Move request to active list if (node.connection) { // normal request, internal requests have no connection node.connection->NotifyBeginRequest(node.request); } mActiveRequests.push_back(node); mActiveCount++; } mQueuedRequests.pop_front(); } //////////////////////////////////////// // Process active requests unsigned requestsProcessed = 0; std::list<QueueNode>::iterator iterator = mActiveRequests.begin(); while (iterator != mActiveRequests.end()) { //Profile profile("Listener::Process (process request)"); std::list<QueueNode>::iterator current = iterator++; RequestBase * request = current->request; Connection * connection = current->connection; if (request->Process()) { if (connection) { // normal request, internal requests have no connection connection->NotifyEndRequest(request); } DestroyRequest(request); mActiveRequests.erase(current); mActiveCount--; } else if (mSleepingRequests.find(request) != mSleepingRequests.end()) { mActiveRequests.erase(current); } requestsProcessed++; } return requestsProcessed; }
/*------------------------------------------------ 「その他」ページ用ダイアログプロシージャ --------------------------------------------------*/ BOOL CALLBACK PageMiscProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: OnInit(hDlg); return TRUE; case WM_COMMAND: { WORD id, code; id = LOWORD(wParam); code = HIWORD(wParam); switch(id) { // 「時計を改造しない」 case IDC_NOCLOCK: case IDC_TASKWNDCTRL: { g_bApplyClock = TRUE; SendPSChanged(hDlg); break; } // 「デスクトップカレンダーの自動更新」 case IDC_DESKCAL: OnDeskcal(hDlg); break; // 「定期的にネットワークの確認」 case IDC_CHECKNETWORK: OnCheckNet(hDlg); break; case IDC_CHECKNETINTERVAL: if(code == EN_CHANGE) SendPSChanged(hDlg); break; // チェックボックス case IDC_MCIWAVE: case IDC_ONLYDATECHANGED: case IDC_RESUMESUSPEND: case IDC_TONIKAKU: case IDC_WATCHWALL: SendPSChanged(hDlg); break; // 何秒後に開始 case IDC_DELAYSTART: case IDC_DELAYNET: if(code == EN_CHANGE) SendPSChanged(hDlg); break; // 「...」 デスクトップカレンダーの参照 case IDC_SANSHODESKCAL: OnSanshoDeskcal(hDlg, id); break; // 「スタートアップ」にショートカットをつくる case IDC_STARTUP: OnStartup(hDlg); break; case IDC_DELREG: { int r; r = DelRegAll(); if (r == 0) MyMessageBox(hDlg,MyString(IDS_DELREGNGINI),MyString(IDS_DELREGT),MB_OK,MB_ICONEXCLAMATION); else if (r == 1) MyMessageBox(hDlg,MyString(IDS_DELREGOK),MyString(IDS_DELREGT),MB_OK,MB_ICONINFORMATION); else MyMessageBox(hDlg,MyString(IDS_DELREGNG),MyString(IDS_DELREGT),MB_OK,MB_ICONEXCLAMATION); } break; case IDC_CONFMAX: case IDC_CFMAXSPIN: SendPSChanged(hDlg); break; } return TRUE; } case WM_NOTIFY: switch(((NMHDR *)lParam)->code) { case PSN_APPLY: OnApply(hDlg); break; case PSN_HELP: My2chHelp(GetParent(hDlg), 11); break; } return TRUE; } return FALSE; }
/*-------------------------------------------------- "Apply" button ----------------- IS NOT USED HERE! --------------------------------------------------*/ void OnApply(HWND hDlg) { if(IsDlgButtonChecked(hDlg, IDC_STARTUP)) OnStartup(hDlg); else RemoveStartup(hDlg); }
//============================================================ // <T>服务器启动处理。</T> // // @return 处理结果 //============================================================ TResult FServer::Startup(){ MO_INFO("Server '%s' startup.", (TCharC*)_name); _stop = EFalse; return OnStartup(); }
int main(int ac, char **av, char **envp) { BinaryDir = GetFullProgDir(av[0]); if (BinaryDir[BinaryDir.length() - 1] == '.') BinaryDir = BinaryDir.substr(0, BinaryDir.length() - 2); #ifdef _WIN32 Anope::string::size_type n = BinaryDir.rfind('\\'); #else Anope::string::size_type n = BinaryDir.rfind('/'); #endif Anope::ServicesDir = BinaryDir.substr(0, n); #ifdef _WIN32 /* Clean out the module runtime directory prior to running, just in case files were left behind during a previous run */ ModuleManager::CleanupRuntimeDirectory(); OnStartup(); #endif try { /* General initialization first */ Anope::Init(ac, av); } catch (const CoreException &ex) { Anope::Logger.Log(ex.GetReason()); return -1; } try { Uplink::Connect(); } catch (const SocketException &ex) { Anope::Logger.Terminal(_("Unable to connect to uplink #{0} ({1}:{2}): {3}"), Anope::CurrentUplink + 1, Config->Uplinks[Anope::CurrentUplink].host, Config->Uplinks[Anope::CurrentUplink].port, ex.GetReason()); } /* Set up timers */ time_t last_check = Anope::CurTime; ExpireTimer expireTimer(Config->GetBlock("options")->Get<time_t>("expiretimeout", "30m")); Uplink::PingTimer pingTimer(30); /*** Main loop. ***/ while (!Anope::Quitting) { Anope::Logger.Debug2("Top of main loop"); /* Process timers */ if (Anope::CurTime - last_check >= Config->TimeoutCheck) { TimerManager::TickTimers(Anope::CurTime); last_check = Anope::CurTime; } /* Process the socket engine */ SocketEngine::Process(); if (Anope::Signal) Anope::HandleSignal(); } if (Anope::Restarting) { EventManager::Get()->Dispatch(&Event::Restart::OnRestart); } else { EventManager::Get()->Dispatch(&Event::Shutdown::OnShutdown); } if (Anope::QuitReason.empty()) Anope::QuitReason = "Terminating, reason unknown"; Anope::Logger.Log(Anope::QuitReason); delete UplinkSock; ModuleManager::UnloadAll(); SocketEngine::Shutdown(); for (Module *m; (m = ModuleManager::FindFirstOf(PROTOCOL)) != NULL;) ModuleManager::UnloadModule(m, NULL); #ifdef _WIN32 ModuleManager::CleanupRuntimeDirectory(); OnShutdown(); #endif if (Anope::Restarting) { chdir(BinaryDir.c_str()); Anope::string sbin = "./" + Anope::ServicesBin; av[0] = const_cast<char *>(sbin.c_str()); execve(Anope::ServicesBin.c_str(), av, envp); Anope::Logger.Log("Restart failed"); Anope::ReturnValue = -1; } return Anope::ReturnValue; }