////////////////////////////////////////////////////////////////////////// // EXPORTED FUNCTIONS ////////////////////////////////////////////////////////////////////////// __declspec(dllexport) BYTE* CompileBuffer(BYTE* Buffer, char* Source, DWORD BufferSize, DWORD* CompiledSize){ YY_BUFFER_STATE state; BYTE* ret = NULL; if(Buffer==NULL){ if(CompiledSize)*CompiledSize = 0; return NULL; } state = yy_scan_bytes(Buffer, BufferSize); lineno=1; yyparse(); yy_delete_buffer(state); if(errorCheck()) goto finish_error; weedSCRIPTCOLLECTION(thescriptcollection); if(errorCheck()) goto finish_error; symSCRIPTCOLLECTION(thescriptcollection); if(errorCheck()) goto finish_error; ret = opcodeSCRIPTCOLLECTION(thescriptcollection, Source, CompiledSize); if(errorCheck()) goto finish_error; FinalCleanup(); return ret; finish_error: if(ret!=NULL) free(ret); *CompiledSize = 0; FinalCleanup(); return NULL; }
int main(int argc, char **argv ) /******************************/ { int retval = 0; MemInit(); #if defined( _BETAVER ) put( banner1w1( "Far Call Optimization Enabling Utility" ) ); put( banner1w2( _FCENABLE_VERSION_ ) ); #else put( banner1w( "Far Call Optimization Enabling Utility", _FCENABLE_VERSION_ ) ); #endif put( banner2 ); put( banner2a( "1990" ) ); put( banner3 ); put( banner3a ); InputBuffer = InitRecStuff(); InFile = NOFILE; OutFile = NOFILE; ClassList = MemAlloc( sizeof( name_list ) + sizeof( DEF_CLASS ) - 1 ); ClassList->next = NULL; ClassList->lnameidx = 0; memcpy( ClassList->name, DEF_CLASS, sizeof( DEF_CLASS ) - 1 ); if( ( argc < 2 ) || ( argv[1][0] == '?' ) ) { put( HelpMsg ); } else { argv++; // skip the program name retval = Spawn1( ProcessFiles, argv ); } FinalCleanup(); MemFini(); return( retval ); }
//----------------------------------------------------------------------------- // Name: Run() // Desc: Handles the message loop and calls FrameMove() and Render() when // idle. //----------------------------------------------------------------------------- INT CMyApplication::Run() { MSG msg; // Message loop to run the app while( TRUE ) { if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // Skip WM_KEYDOWN so they aren't handled by the dialog if( msg.message == WM_KEYDOWN ) continue; if( !IsDialogMessage( m_hWnd, &msg ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } if( msg.message == WM_QUIT ) { DestroyWindow( m_hWnd ); break; } } else { // Update the time variables m_fTime = DXUtil_Timer( TIMER_GETAPPTIME ); m_fElapsedTime = DXUtil_Timer( TIMER_GETELAPSEDTIME ); // This app uses idle time processing for the game loop if( FAILED( FrameMove() ) ) SendMessage( m_hWnd, WM_DESTROY, 0, 0 ); if( FAILED( Render() ) ) SendMessage( m_hWnd, WM_DESTROY, 0, 0 ); Sleep( 20 ); } } FinalCleanup(); return (INT)msg.wParam; }
bool Lacrimi::run() { Delay(400); if(GetConfigBool("Features", "LuaEngine", true)) { L_LuaEngineMgr = new LuaEngineMgr(); L_LuaEngineMgr->Startup(); Delay(100); while(LuaEngineIsStarting) Delay(100); } uint32 curTime = getMSTime(); uint32 m_StatDumpTimer = curTime+15000, m_CleanupDelay = curTime+10000; while(GetThreadState() != THREADSTATE_SELF_TERMINATE) { curTime = getMSTime(); if(!SetThreadState(THREADSTATE_BUSY)) break; if(dumpstats) { if(curTime > m_StatDumpTimer) { DumpStats(); m_StatDumpTimer = curTime+60000; } } if(curTime > m_CleanupDelay) Cleanup(); if(!SetThreadState(THREADSTATE_SLEEPING)) break; Delay(5); } sLog.Notice("Lacrimi", "Terminating..."); FinalCleanup(); if(database) _StopDB(); OnShutdown(); return true; }
//----------------------------------------------------------------------------- // Name: ~CAppForm() // Desc: Destructor for the dialog resource form. Shuts down the app //----------------------------------------------------------------------------- CAppForm::~CAppForm() { Cleanup3DEnvironment(); SAFE_RELEASE( m_pD3D ); FinalCleanup(); }
int main(void) { int error; pthread_t command_processor_pid; /* Initializes zlog first.*/ if ((error = zLogInit()) != 0) { return error; } /* Parses ini file for config. */ memset(&gAppConfig, 0, sizeof(AppConfig)); if (ini_parse(INI_FILENAME, iniHandler, &gAppConfig) < 0) { zlog_fatal(gZlogCategories[ZLOG_MAIN], "Can't load '%s'\n", INI_FILENAME); return 1; } /* Initializes SocketServer */ SocketServerConfig config; config.eventHandler = SSECallback; config.port = gAppConfig.uServerPort; zlog_info(gZlogCategories[ZLOG_MAIN], "Initializing SocketServer on port %d\n", config.port); SocketServerInit(&config); /* Initializes local XBee radio */ XBeeRadioInit(&gAppConfig.xbeeRadioConfig); /* Initializes Radio Network */ RadioNetworkInit(&gAppConfig.radioNetworkConfig); _SocketIdInit(); /* Initializes command processing thread with default settings */ pthread_create(&command_processor_pid, NULL, &RadioNetworkProcessCommandQueue, UpdateReturnData); SocketServerStart(); SocketServerRun(); /* Wait to join the command processing thread */ pthread_join(command_processor_pid, NULL); _SocketIdDestroy(); SocketServerStop(); SocketServerDestroy(); /* Destroys Radio Network */ RadioNetworkDestroy(); /* Destroys local XBee radio */ XBeeRadioDestroy(); zLogDestroy(); /* final clean ups of memory */ FinalCleanup(); return 0; }