Esempio n. 1
0
// 8: The Window Procedure
LRESULT CALLBACK WindProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
   switch(msg)
   {
   case WM_CREATE:
      {
         // 9. Adding menus during window creation
         AddMenu(hwnd);
      }
      break;
   case WM_COMMAND:
      {
         // 10. Process the clicked menu item
         ProcessCommands(hwnd,wParam);
      }
      break;
   case WM_CLOSE:
      DestroyWindow(hwnd);
      break;
   case WM_DESTROY:
      PostQuitMessage(0);
      break;

      // DefWindowProc is must
   default:
      return DefWindowProc(hwnd, msg, wParam, lParam);
   }
   return 0;
}
void GameStateManager::UpdateGameStates(float deltaTime)
{
	ProcessCommands();

	for (auto iter = m_stateStack.begin(); iter != m_stateStack.end(); iter++)
		(*iter)->Update(deltaTime);
}
Esempio n. 3
0
char *
get_query (query_data * qd)
{
  char *line, *LinePtr;
  WritePrompt ();
  do
    {
      do
	{
	  line = GetMultiLine ();
	  if (line == NULL)
	    {
	      if (stdin == InFile)
		return (NULL);	/* EOF */
	      if (InPipe)
		pclose (InFile);
	      else
		fclose (InFile);
	      InPipe = 0;
	      InFile = stdin;
	    }
	}
      while (line == NULL);
      LinePtr = ProcessCommands (line, qd);
      if (CommandsErrorStr)
	fprintf (stderr, "%s\n", CommandsErrorStr);
    }
  while (*LinePtr == '\0' && !Quitting);
  return (LinePtr);
}
Esempio n. 4
0
int CzProgram::LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node)
{
	CzScene* scene = NULL;
	if (parent->getClassTypeHash() == CzHashes::Actor_Hash)
	{
		CzActor* actor = (CzActor*)parent;
		scene = actor->getScene();
	}
	else
	if (parent->getClassTypeHash() == CzHashes::Scene_Hash)
		scene = (CzScene*)parent;

	bool auto_run = false;
	bool priority = false;

	// Process program attributes
	for (CzXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++)
	{
		unsigned int name_hash = (*it)->getName().getHash();

		if (name_hash == CzHashes::Name_Hash)
			setName((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::Tag_Hash)
			setTag((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::AutoRun_Hash)
			auto_run = (*it)->getValueAsBool();
		else
		if (name_hash == CzHashes::Priority_Hash)
			priority = (*it)->getValueAsBool();
	}

	// Prrocess commands
	ProcessCommands(NULL, true, node);

/*	// If we are declared inside a scene then program is local to the scene
	if (scene != NULL)
		scene->getResourceManager()->addResource(this);
	else
		CZ_GLOBAL_RESOURCES->getResourceManager()->addResource(this);*/

	// Add the program to a program manager
	if (scene != NULL)
		scene->getProgramManager()->addProgram(this);
	else
		CZ_GLOBAL_RESOURCES->getProgramManager()->addProgram(this);

	// if auto_run then start the program running
	if (auto_run)
		start();

	// If set as priority program then inform manager
	if (priority)
		Manager->setPriorityProgram(this);

	return 1;
}
Esempio n. 5
0
void Application::ProcessInput()
{
  sf::Event event;
  while ( m_window.pollEvent(event) )
  {
    m_interface.ProcessInput(event);
  }
  ProcessCommands();
}
Esempio n. 6
0
static void Draw()
{
	BeginFrame();

	DrawAxis();

	void ProcessCommands();
	ProcessCommands();

	EndFrame();
}
Esempio n. 7
0
VOID CNetManager::WaitPacket(VOID)
{
	if(!m_Socket.isValid())
	{
        if (connect_state_ == 1)
        {
            if (show_ == true)
            {
                show_ = false;
                const char* szString = DICTIONARY_CONFIG_MGR::instance()->get_string_by_id(SERVER_DISCONNECT);
                UI_ModalDialogue_Layer::DoModal("",szString,UI_ModalDialogue_Layer::DT_OK,[]()
                {
                    Account_Logic::releaseData();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
                    MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
                    return;
#endif
                    
                    Director::getInstance()->end();
                    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
                    exit(0);
#endif
                }
                );

                //UI_ModalDialogue_Layer::DoModal("",szString,UI_ModalDialogue_Layer::DT_OK,Account_Logic::releaseData);
            }            
        }
        
		return;
	}
	
	//网络数据流操作
	if(!Select() || !ProcessExcept() || !ProcessInput() || !ProcessOutput())
	{
		//CEventSystem::GetMe()->PushEvent(GE_NET_CLOSE);
	}
	
	/*
	int s=Select() ;
	CCLog("--------------------s is %d",s);
	int p1=ProcessExcept();
	CCLog("--------------------p1 is %d",p1);
	int p2=ProcessInput();
	CCLog("--------------------p2 is %d",p2);
	int p3=ProcessOutput();
	CCLog("--------------------p3 is %d",p3);
	*/
	//Packet操作
	ProcessCommands( ) ;

}
Esempio n. 8
0
/******************************************************************************
** Function: LABTLM_Main
**
*/
void LABTLM_Main(void)
{

   int32  Status    = CFE_SEVERITY_ERROR;
   uint32 RunStatus = CFE_ES_APP_ERROR;


   Status = CFE_ES_RegisterApp();
   CFE_EVS_Register(NULL,0,0);

   /*
   ** Perform application specific initialization
   */
   if (Status == CFE_SUCCESS)
   {
       OS_printf("TO-LAB: About to call init\n");
       Status = InitApp();
   }

   /*
   ** At this point many flight apps use CFE_ES_WaitForStartupSync() to
   ** synchronize their startup timing with other apps. This is not
   ** needed.
   */

   if (Status == CFE_SUCCESS) RunStatus = CFE_ES_APP_RUN;

   /*
   ** Main process loop
   */
   OS_printf("TO-LAB: About to enter loop\n");
   while (CFE_ES_RunLoop(&RunStatus))
   {

      OS_TaskDelay(LABTLM_RUNLOOP_DELAY);

      PKTMGR_OutputTelemetry();

      ProcessCommands();

   } /* End CFE_ES_RunLoop */


   /* Write to system log in case events not working */

   CFE_ES_WriteToSysLog("LABTLM App terminating, err = 0x%08X\n", Status);

   CFE_EVS_SendEvent(LABTLM_EXIT_ERR_EID, CFE_EVS_CRITICAL, "LABTLM App: terminating, err = 0x%08X", Status);

   CFE_ES_ExitApp(RunStatus);  /* Let cFE kill the task (and any child tasks) */

} /* End of LABTLM_Main() */
Esempio n. 9
0
bool Pipe2Sock::OnStartup(int argc, const char*const* argv)
{
    if (argc == 1)
    {
        TRACE("No args!  Are you sure you want to be running without any args?\n");
        Usage();
    }
    if (!ProcessCommands(argc, argv))
    {
        PLOG(PL_ERROR, "pipe2Sock::OnStartup() error processing command line\n");
        Usage();
        return false;
    }
    //set the destination address/port info
    dst_addr.SetPort(dst_port);
    TRACE("Destination address set to %s/%d\n",dst_addr.GetHostString(),dst_port);

    //set the socket sending/binding port info
    if(!(socket.Bind(snd_port))){
        PLOG(PL_ERROR,"pipe2Sock::OnStartup() error binding to port %d\n",snd_port);
        return false;
    }
    if(!(socket.Open(snd_port,ProtoAddress::IPv4,false)))
    {
        PLOG(PL_ERROR,"pipe2Sock::OnStartup() error opening the socket on port  %d\n",snd_port);
        return false;
    }
    if(dst_addr.IsMulticast())
    {
        if(!socket.JoinGroup(dst_addr))
        {
            PLOG(PL_ERROR,"pipe2Sock::OnStartup() error joining multicast group %s\n",dst_addr.GetHostString());
            socket.Close();
            return false;
        }
        TRACE("Joined multicast group %s\n",dst_addr.GetHostString());
    }
    TRACE("Sending port set to %d\n",snd_port);

    //open up a listening pipe 
    if (!listen_pipe.Listen(listen_pipe_name))
    {
        socket.Close();
        PLOG(PL_ERROR, "Pipe2Sock::OnCommand() listen_pipe.Listen() error opening pipe with name %s\n",listen_pipe_name);
        return false;   
    }
    TRACE("pipe2Sock: listen \"%s\" listening ...\n", listen_pipe_name);

    return true;
}  // end Pipe2Sock::OnStartup()
Esempio n. 10
0
bool ServerManager::Tick( )
{
	bool ret;

	ret = Select( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,Select Faild",0,0);
	}

	ret = ProcessExceptions( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessExceptions Faild",0,0);
	}

	ret = ProcessInputs( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessInputs Faild",0,0);
	}

	ret = ProcessOutputs( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessOutputs Faild",0,0);
	}

	ret = ProcessCommands( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessCommands Faild",0,0);
	}

	ret = ProcessCacheCommands( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessCacheCommands Faild",0,0);
	}

	ret = HeartBeat( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,HeartBeat Faild",0,0);
	}

	//ret = SendQueuePlayerToWorld( );
	
	return true;
}
Esempio n. 11
0
MainObject::MainObject(QObject *parent,const char *name)
{
  input_fd=-1;
  dest_hostname=RMLSEND_DEFAULT_ADDR;
  dest_port=RMLSEND_DEFAULT_PORT;
  rml_ptr=0;

  ReadSwitches();
  ResolveName();
  InitStream();
  ProcessCommands();
  CloseStream();

  exit(0);
}
Esempio n. 12
0
bool Msg2Msg::OnStartup(int argc, const char*const* argv)
{
    if (argc == 1)
    {
        TRACE("No args!  Are you sure you want to be running without any args?\n");
        Usage();
    }
    if (!ProcessCommands(argc, argv))
    {
        PLOG(PL_ERROR, "msg2Msg::OnStartup() error processing command line\n");
        Usage();
        return false;
    }
    return true;
}  // end Msg2Msg::OnStartup()
Esempio n. 13
0
/**
 * @brief  Program entry point.
 * @param  none
 * @retval 0
 */
int main(void) {
	RCC_ClocksTypeDef RCC_Clocks;

	SystemInit();

	// Get the clock rate so we can set the sampling rate correctly.
	RCC_GetClocksFreq(&RCC_Clocks);
	ClockRate = RCC_Clocks.HCLK_Frequency;

	// NOTE: STM generic

	// Our timer (TIM2) uses the APB1 (PCLK1) clock.
	TimerBaseClockRate = RCC_Clocks.PCLK1_Frequency;

	// Set the SysTick interrupt to fire once every millisecond.
	SysTick_Config(RCC_Clocks.SYSCLK_Frequency / 1000);

	LedInit();

	// Turn the Orange LED on, signifying WAIT...
	LedSet(LED_ORANGE, LED_MODE_ON);

	UsartInit();
	Copyright();

	uint32_t commandTicks = Ticks;

	LedSet(LED_ORANGE, LED_MODE_OFF);

	// Loop forever...
	while (1) {
		if (SamplingActive) {
			LedSet(LED_RED, LED_MODE_OFF);

			// Turn the Blue LED on when sampling.
			LedSet(LED_BLUE, LED_MODE_ON);
			SampleLoop();
			LedSet(LED_BLUE, LED_MODE_OFF);
		}

		// Check for commands every 1/10 second.
		if ((Ticks - commandTicks) >= 100) {
			ProcessCommands();
			commandTicks = Ticks;
		}
	}
	return 0;
}
Esempio n. 14
0
VOID CNetManager::WaitPacket(VOID)
{
	if(!m_Socket.isValid())
	{
		return;
	}

	//网络数据流操作
	if(!Select() || !ProcessExcept() || !ProcessInput() || !ProcessOutput())
	{
		CEventSystem::GetMe()->PushEvent(GE_NET_CLOSE);
	}

	//Packet操作
	ProcessCommands( ) ;
}
Esempio n. 15
0
static TString ProcessArg(const _TCHAR *arg) {
    if (arg[0] == _T('@')) {
        TString res{ arg[0] };
        res += ProcessCommands(arg + 1);
        return res;
    } else if (arg[0] == _T('/') || arg[0] == _T('-')) {
        const _TCHAR *opt = arg + 1;
        if (_tcsicmp(opt, kLibOption) == 0) {
            lib_mode = true;
        } else if (_tcsnicmp(opt, kOutOption, _tcslen(kOutOption)) == 0) {
            out_argument.assign(opt + _tcslen(kOutOption));
        }
        return TString(arg);
    } else {
        // Input file, process
       return ProcessInputFile(arg);
    }
}
// called when a client connects to the shipgate server.
// this function simply sends an init comamnd and passes control off to the
// command handlers, which will do their jobs.
DWORD HandleShipgateClient(NEW_CLIENT_THREAD_DATA* nctd)
{
    SERVER* s = nctd->s;
    CLIENT* c = nctd->c;
    nctd->release = true;
    nctd = NULL;
    srand(GetTickCount());

    ConsolePrintColor("$0E> Shipgate server: new client\n");
    AddClient(s,c);

    CommandServerInit(c,true);
    ProcessCommands(s,c,0x0D,0);

    RemoveClient(s,c);
    DeleteClient(c);
    ConsolePrintColor("$0E> Shipgate server: disconnecting client\n");

    return 0;
}
Esempio n. 17
0
///=====================================================
/// 
///=====================================================
int __stdcall WinMain(HINSTANCE thisAppInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nShowCmd){
	FATAL_ASSERT(s_theMemoryManager != nullptr);

	JobManager* jobManager = new JobManager();
	RECOVERABLE_ASSERT(jobManager != nullptr);
	if (jobManager != nullptr){
		jobManager->Startup(6); //main thread + cricket audio thread + 6 = 8
	}

	CommandList commands = ParseCommands(lpCmdLine);
	bool forceQuit = ProcessCommands(commands);
	if (forceQuit){
		if (jobManager != nullptr){
			jobManager->Shutdown();
			delete jobManager;
		}

		return 0;
	}


	HWND myWindowHandle = CreateAppWindow(thisAppInstance, nShowCmd);

	s_theApp = new TheApp();
	s_theApp->Startup((void*)myWindowHandle);
	s_theApp->Run();
	s_theApp->Shutdown();

	delete s_theApp;


	if (jobManager != nullptr){
		jobManager->Shutdown();
		delete jobManager;
	}

	s_theMemoryManager->PrintMemoryLeaks();

	return 0;
}
//--------------------------------------------------------------------------
/// Processes the incoming request to see if it should activate any
/// of the added CommandObjects
/// \param rInCommObj CommandObject that needs to be handled
/// \return true if the CommandObject could be processed; false otherwise
//--------------------------------------------------------------------------
bool CommandProcessor::Process(CommandObject& rInCommObj)
{
    if (ProcessProcessors(rInCommObj))
    {
        return true;
    }

    // process as many of the commands in this processor as
    // can be found in the incomming command
    while (ProcessCommands(rInCommObj) == true)
    {
        // if there are more commands in the incomming command,
        // continue processing, otherwise handle this processors
        // commands and return
        if (rInCommObj.StepToNextCommand() == false)
        {
            // the last of the incomming commands was just processed
            HandleInternalCommands();
            return true;
        }
    }

    // The incomming command matched this processor, but couldn't match
    // and child-processors or any of the commands, so this must be a
    // bad command, report an error
    if (rInCommObj.GetResponseState() == NO_RESPONSE)
    {
        // there was an error activating a command
        CommandResponse response;
        response.SetContentType(CONTENT_TEXT);
        response.SetActiveRequest(rInCommObj);
        response.SendError("Command is invalid starting from: %s", rInCommObj.GetRemainingCommand());

        // need to return true to indicate that something has been sent back to the client
        return true;
    }

    return false;
}
Esempio n. 19
0
int WlibMainLine( char *argv[] )
{
    int     retcode;

    InitCmdLine();          // JBS 99/07/09 reset options for each use
    if( !setjmp( Env ) ) {
        ProcessCmdLine( argv );
        ProcessCommands();
        retcode = EXIT_SUCCESS;
    } else {
        retcode = EXIT_FAILURE;
    }
    if( !setjmp( Env ) ) {
        ResetInputLibs();
        ResetFileTab();
        ResetCmdLine();
        ResetLibIo();
        ResetMem();
    } else {
        retcode = EXIT_FAILURE;
    }
    return( retcode );
}
Esempio n. 20
0
bool CzProgram::ProcessCommands(CzCommand* parent, bool load_children, CzXmlNode* node)
{
	for (CzXmlNode::_Iterator it = node->begin(); it != node->end(); ++it)
	{
		unsigned int name_hash = (*it)->GetName().getHash();
		if (name_hash == CzHashes::Command_Hash)
		{
			CzString	name, method, ifreturn, condition;
			CzString	params[5];
			bool		active = true;
			bool		parallel = false;
			int			value = 0;

			for (CzXmlNode::_AttribIterator it2 = (*it)->attribs_begin(); it2 != (*it)->attribs_end(); ++it2)
			{
				unsigned int attrib_hash = (*it2)->getName().getHash();

				if (attrib_hash == CzHashes::Name_Hash)
					name = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Method_Hash)
					method = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Param1_Hash || attrib_hash == CzHashes::P1_Hash)
					params[0] = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Param2_Hash || attrib_hash == CzHashes::P2_Hash)
					params[1] = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Param3_Hash || attrib_hash == CzHashes::P3_Hash)
					params[2] = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Param4_Hash || attrib_hash == CzHashes::P4_Hash)
					params[3] = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Param5_Hash || attrib_hash == CzHashes::P5_Hash)
					params[4] = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Parallel_Hash)
					parallel = (*it2)->getValueAsBool();
				else
				if (attrib_hash == CzHashes::IfReturn_Hash)
					ifreturn = (*it2)->getValue();
				else
				if (attrib_hash == CzHashes::Value_Hash)
					value = (*it2)->getValueAsInt();
				else
				if (attrib_hash == CzHashes::Condition_Hash)
					condition = (*it2)->getValue();
			}

			// Find the commands creator
			CzCommand* command = NULL;
			if (method.isEmpty())
				method="nop";

			CzCommandCreator* creator = CZ_PROGRAMS->findCreator(method.getHash());
			if (creator != NULL)
			{
				// Create the command
				command = creator->CreateInstance();
				if (command != NULL)
				{
					command->setProgram(this);
					command->setParallel(parallel);
					command->setCommandName(name.c_str());
					if (!ifreturn.isEmpty())
					{
						IzCommandExecutor* ifcommand = findCommand(ifreturn.getHash());
						if (ifcommand == NULL)
							CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Program - IfReturn command could not be found - ", ifreturn.c_str(), (*it)->getParserFileName(), (*it)->Line);
						else
							command->setIfReturn(ifcommand, value);
					}

					for (int t = 0; t < 5; t++)
						command->setParameter(t, params[t]);

					// If no parent command then add to the program else add to the parent commands child list
					if (parent == NULL)
						addCommand(command);
					else
						parent->addCommand(command);

					if (!condition.isEmpty())
					{
						if (*(condition.c_str()) == '!')
							command->setConditions(condition.c_str() + 1, true);
						else
							command->setConditions(condition.c_str());
					}

				}
			}
			else
				CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Program - No creator for command method could be found - ", method.c_str(), (*it)->getParserFileName(), (*it)->Line);

			// If command contains sub commands then load them also
			if ((*it)->Children.size() != 0)
			{
				ProcessCommands(command, true, *it);
			}
		}
	}

	return true;
}
Esempio n. 21
0
static void __stdcall ProcessCommands_Hook(int length, int replay_process)
{
    REG_EAX(uint8_t *, data);
    ProcessCommands(data, length, replay_process);
}
// ---------------------------------------------------------------------------
// RunL.
// Executes the command that was requested with CommandQueue method.
//
// Runs in: WLAN Engine thread context.
// ---------------------------------------------------------------------------
//
void CWlanBgScanCommand::RunL()
    {
    DEBUG( "CWlanBgScanCommand::RunL()" );
    ProcessCommands();
    }