Example #1
0
void CCommands :: OnBNETCommand( CBNET *bnet, const QString &user, bool whisper, const CommandData &data )
{
	if( data.GetCommand() == "close" && !data.GetCommand().isEmpty( ) && m_GHost->GetCurrentGame() )
	{
		if( !m_GHost->GetCurrentGame()->GetLocked( ) )
		{
			// close as many slots as specified, e.g. "5 10" closes slots 5 and 10
			
			QTextStream SS;
			SS << data.GetPayload();
			
			while( !SS.atEnd() )
			{
				quint32 SID;
				SS >> SID;
				
				if( SS.status() != QTextStream::Ok )
				{
					//CONSOLE_Print( "[BNET: " + bnet->GetServerAlias() + "] bad input to close command" );
					break;
				}
				else
					m_GHost->GetCurrentGame()->CloseSlot( (unsigned char)( SID - 1 ), true );
			}
		}
		else
		{
CommandData GestureHoldModeAction::getAction(angleData ad)
{
    if (actionMap.find(ad.hash()) == actionMap.end())
    {
        CommandData retVal;
        retVal.setType(commandType::NONE);
        return retVal;
    }

    return actionMap[ad.hash()];
}
 void NetworkInterfaceImpl::_consumeNetworkRequests() {
     boost::unique_lock<boost::mutex> lk(_mutex);
     while (!_inShutdown) {
         if (_pending.empty()) {
             if (_threads.size() > kMinThreads) {
                 const Date_t nowDate = now();
                 const Date_t nextThreadRetirementDate =
                     _lastFullUtilizationDate + kMaxIdleThreadAge;
                 if (nowDate > nextThreadRetirementDate) {
                     _lastFullUtilizationDate = nowDate;
                     break;
                 }
             }
             _hasPending.wait_for(lk, kMaxIdleThreadAge);
             continue;
         }
         CommandData todo = _pending.front();
         _pending.pop_front();
         ++_numActiveNetworkRequests;
         --_numIdleThreads;
         lk.unlock();
         ResponseStatus result = _commandExec.runCommand(todo.request);
         LOG(2) << "Network status of sending " << todo.request.cmdObj.firstElementFieldName() <<
             " to " << todo.request.target << " was " << result.getStatus();
         todo.onFinish(result);
         lk.lock();
         --_numActiveNetworkRequests;
         ++_numIdleThreads;
         _signalWorkAvailable_inlock();
     }
     --_numIdleThreads;
     if (_inShutdown) {
         return;
     }
     // This thread is ending because it was idle for too long.
     // Find self in _threads, remove self from _threads, detach self.
     for (size_t i = 0; i < _threads.size(); ++i) {
         if (_threads[i]->get_id() != boost::this_thread::get_id()) {
             continue;
         }
         _threads[i]->detach();
         _threads[i].swap(_threads.back());
         _threads.pop_back();
         return;
     }
     severe().stream() << "Could not find this thread, with id " <<
         boost::this_thread::get_id() << " in the replication networking thread pool";
     fassertFailedNoTrace(28581);
 }
void NetworkInterfaceImpl::_runOneCommand() {
    stdx::unique_lock<stdx::mutex> lk(_mutex);
    if (_pending.empty()) {
        // This may happen if any commands were canceled.
        return;
    }
    CommandData todo = _pending.front();
    _pending.pop_front();
    ++_numActiveNetworkRequests;
    lk.unlock();
    TaskExecutor::ResponseStatus result = _commandRunner.runCommand(todo.request);
    LOG(2) << "Network status of sending " << todo.request.cmdObj.firstElementFieldName() << " to "
           << todo.request.target << " was " << result.getStatus();
    todo.onFinish(result);
    lk.lock();
    --_numActiveNetworkRequests;
    _signalWorkAvailable_inlock();
}
SequenceStatus GestureSeqRecorder::progressSequence(Pose::Type gesture, ControlState state, CommandData& response)
{
    SequenceStatus status = SequenceStatus::SUCCESS;
    response.setType(commandType::NONE);

    prevPose = gesture;

    if (activeSequences.size() != 0)
    {
        status = ensureSameState(state);
        if (status == SequenceStatus::SUCCESS)
        {
            status = progressActiveSequences(gesture, state, response);
        }       
    }
    else
    {
        status = findActivation(gesture, state, response);
        
        if (state.getMode() != prevState)
        {
            updateGuiSequences();
        }

        prevState = state.getMode();
    }

    if (response.getType() != commandType::NONE || status != SequenceStatus::SUCCESS)
    { 
        // if the response is not NONE, a sequence has completed. Therefore all
        // active sequences must be cleared so that all valid sequences can potentially
        // be started.
        emptyActiveSequences();

        if (response.getType() != commandType::NONE)
        {
            std::cout << "GestureSeqRecorder returning a registered response." << std::endl;
        }
    }

    return status;
}
bool NextPrimeCommand::execute(CommandData& data)
{
    //validation
    // check for a limit on the value sent
    if (data.getNextPrimeMessage ()->m_number > 100000)
    {
        data.getResponseHeader()->m_msgType = RESPONSE_ERROR;
        strcpy (data.getResponseError()->m_errorMsg, "Requested number beyond specified limit.");
        return false;
    }

    data.getResponseNextPrime()->m_number = Helper::getNextPrime (data.getNextPrimeMessage ()->m_number);
    data.getResponseHeader()->m_msgType = RESPONSE_NEXTPRIME;

    return true;
}
Example #7
0
	int android_unrar( int argc, char *argv[] )
	{
		if( _android_unrar_curr_file_logs != NULL )
			free( _android_unrar_curr_file_logs );
		_android_unrar_curr_file_logs = (char*)malloc(android_buffer);

		if( _android_unrar_logs != NULL )
			free( _android_unrar_logs );
		_android_unrar_logs = (char*)malloc(android_buffer);

		setlocale( LC_ALL, "" );
		setbuf( stdout, NULL );

		ErrHandler.SetSignalHandlers( true );
		RARInitData();

		CommandData Cmd;
		Cmd.PreprocessCommandLine( argc, argv );
		if ( !Cmd.ConfigDisabled )
		{
			Cmd.ReadConfig();
			Cmd.ParseEnvVar();
		}
		Cmd.ParseCommandLine( argc,argv );

		InitConsoleOptions( Cmd.MsgStream, Cmd.Sound );
		InitLogOptions( Cmd.LogName );
		ErrHandler.SetSilent( Cmd.AllYes || Cmd.MsgStream==MSG_NULL );
		ErrHandler.SetShutdown( Cmd.Shutdown );

		Cmd.OutTitle();
		Cmd.ProcessCommand();

		File::RemoveCreated();

		return( ErrHandler.GetErrorCode() );
	}
Example #8
0
int main(int argc, char* argv[])
{
#ifdef _UNIX
    setlocale(LC_ALL, "");
#endif
#if defined(_EMX) && !defined(_DJGPP)
    uni_init(0);
#endif
#if !defined(_SFX_RTL_) && !defined(_WIN_ALL)
    setbuf(stdout, NULL);
#endif
#if !defined(SFX_MODULE) && defined(_EMX)
    EnumConfigPaths(argv[0], -1);
#endif
    ErrHandler.SetSignalHandlers(true);
    RARInitData();
#ifdef SFX_MODULE
    char ModuleNameA[NM];
    wchar ModuleNameW[NM];
#ifdef _WIN_ALL
    GetModuleFileNameW(NULL, ModuleNameW, ASIZE(ModuleNameW));
    WideToChar(ModuleNameW, ModuleNameA);
#else
    strcpy(ModuleNameA, argv[0]);
    *ModuleNameW = 0;
#endif
#endif
#ifdef _WIN_ALL
    SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif
#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT)
    bool ShutdownOnClose;
#endif
#ifdef ALLOW_EXCEPTIONS

    try
#endif
    {
        CommandData Cmd;
#ifdef SFX_MODULE
        strcpy(Cmd.Command, "X");
        char* Switch = NULL;
#ifdef _SFX_RTL_
        char* CmdLine = GetCommandLineA();

        if (CmdLine != NULL && *CmdLine == '\"')
            CmdLine = strchr(CmdLine + 1, '\"');

        if (CmdLine != NULL && (CmdLine = strpbrk(CmdLine, " /")) != NULL)
        {
            while (IsSpace(*CmdLine))
                CmdLine++;

            Switch = CmdLine;
        }

#else
        Switch = argc > 1 ? argv[1] : NULL;
#endif

        if (Switch != NULL && Cmd.IsSwitch(Switch[0]))
        {
            int UpperCmd = etoupper(Switch[1]);

            switch (UpperCmd)
            {
                case 'T':
                case 'V':
                    Cmd.Command[0] = UpperCmd;
                    break;

                case '?':
                    Cmd.OutHelp();
                    break;
            }
        }

        Cmd.AddArcName(ModuleNameA, ModuleNameW);
#else

        if (Cmd.IsConfigEnabled(argc, argv))
        {
            Cmd.ReadConfig(argc, argv);
            Cmd.ParseEnvVar();
        }

        for (int I = 1; I < argc; I++)
            Cmd.ParseArg(argv[I], NULL);

#endif
        Cmd.ParseDone();
#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT)
        ShutdownOnClose = Cmd.Shutdown;
#endif
        InitConsoleOptions(Cmd.MsgStream, Cmd.Sound);
        InitLogOptions(Cmd.LogName);
        ErrHandler.SetSilent(Cmd.AllYes || Cmd.MsgStream == MSG_NULL);
        ErrHandler.SetShutdown(Cmd.Shutdown);
        Cmd.OutTitle();
        Cmd.ProcessCommand();
    }

#ifdef ALLOW_EXCEPTIONS

    catch (int ErrCode)
    {
        ErrHandler.SetErrorCode(ErrCode);
    }

#ifdef ENABLE_BAD_ALLOC

    catch (bad_alloc)
    {
        ErrHandler.SetErrorCode(MEMORY_ERROR);
    }

#endif

    catch (...)
    {
        ErrHandler.SetErrorCode(FATAL_ERROR);
    }

#endif
    File::RemoveCreated();
#if defined(SFX_MODULE) && defined(_DJGPP)
    _chmod(ModuleNameA, 1, 0x20);
#endif
#if defined(_EMX) && !defined(_DJGPP)
    uni_done();
#endif
#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT)

    if (ShutdownOnClose)
        Shutdown();

#endif
    return(ErrHandler.GetErrorCode());
}
void GestureSeqRecorder::progressSequenceTime(int delta, CommandData& response)
{
    if (gestureSignaller.getShowAll() != prevShowAll)
    {
        updateGuiSequences();
        prevShowAll = gestureSignaller.getShowAll();
    }
    if (controlStateHandle->getMode() != timeBasedPrevState)
    {
        updateGuiSequences();
        timeBasedPrevState = controlStateHandle->getMode();
    }

    // Provide response if hold is reached and cut off 'taps' if hold is reached
    if (holdGestTimer > 0 && holdGestTimer - delta <= 0 && activeSequences.size() > 0)
    {
        // This call to progressSequenceTime indicates a 'hold'.
        // Update activeSequences now.
        activeSequencesMutex.lock();
        std::list<sequenceInfo*>::iterator it = activeSequences.begin();
        while (it != activeSequences.end())
        {
            unsigned int seqProg = (*it)->progress;

            if (seqProg < (*it)->seq.size())
            {
                // We just hit the "hold" state, handle accordingly
                if (PoseLength::HOLD == (*it)->seq.at(seqProg).poseLen)
                {
                    (*it)->progress++;
                    if ((*it)->progress == (*it)->seq.size())
                    {
                        // found a complete sequence!
                        response = (*it)->sequenceResponse;
                        break;
                    }
                    it++;
                }
                else
                {
                    if (prevPose != Pose::rest)
                    {
                        // Erase if they're still holding a non-rest pose, since
                        // that means they 'actually' hit a hold-state.
                        (*it)->progress = 0;
                        it = activeSequences.erase(it);
                    }
                    else
                    {
                        it++;
                    }
                }

                updateGuiSequences();
            }
        }
        activeSequencesMutex.unlock();

        if (response.getType() != commandType::NONE)
        {
            // if the response is not NONE, a sequence has completed. Therefore all
            // active sequences must be cleared so that all valid sequences can potentially
            // be started.
            emptyActiveSequences();

            if (response.getType() != commandType::NONE)
            {
                std::cout << "GestureSeqRecorder returning a registered response." << std::endl;
            }
        }
    }

    if (holdGestTimer - delta <= 0)
    {
        // ensure value doesn't loop and cause we're results if decremented too much.
        holdGestTimer = 0;
    }
    else
    {
        holdGestTimer -= delta;
    }
}
Example #10
0
File: rar.cpp Project: chmoder/PS3
int main(int argc, char *argv[])
{
#ifdef _UNIX
  setlocale(LC_ALL,"");
#endif

#if defined(_EMX) && !defined(_DJGPP)
  uni_init(0);
#endif

#if !defined(_SFX_RTL_) && !defined(_WIN_32)
  setbuf(stdout,NULL);
#endif

#if !defined(SFX_MODULE) && defined(_EMX)
  EnumConfigPaths(argv[0],-1);
#endif

  ErrHandler.SetSignalHandlers(true);

  RARInitData();

#ifdef SFX_MODULE
  char ModuleName[NM];
#ifdef _WIN_32
  GetModuleFileName(NULL,ModuleName,sizeof(ModuleName));
#else
  strcpy(ModuleName,argv[0]);
#endif
#endif

#ifdef _WIN_32
  SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT|SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);


#endif

#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(SHELL_EXT)
  bool ShutdownOnClose;
#endif

#ifdef ALLOW_EXCEPTIONS
  try 
#endif
  {
  
    CommandData Cmd;
#ifdef SFX_MODULE
    strcpy(Cmd.Command,"X");
    char *Switch=NULL;
#ifdef _SFX_RTL_
    char *CmdLine=GetCommandLine();
    if (CmdLine!=NULL && *CmdLine=='\"')
      CmdLine=strchr(CmdLine+1,'\"');
    if (CmdLine!=NULL && (CmdLine=strpbrk(CmdLine," /"))!=NULL)
    {
      while (isspace(*CmdLine))
        CmdLine++;
      Switch=CmdLine;
    }
#else
    Switch=argc>1 ? argv[1]:NULL;
#endif
    if (Switch!=NULL && Cmd.IsSwitch(Switch[0]))
    {
      int UpperCmd=etoupper(Switch[1]);
      switch(UpperCmd)
      {
        case 'T':
        case 'V':
          Cmd.Command[0]=UpperCmd;
          break;
        case '?':
          Cmd.OutHelp();
          break;
      }
    }
    Cmd.AddArcName(ModuleName,NULL);
#else
    if (Cmd.IsConfigEnabled(argc,argv))
    {
      Cmd.ReadConfig(argc,argv);
      Cmd.ParseEnvVar();
    }
    for (int I=1;I<argc;I++)
      Cmd.ParseArg(argv[I],NULL);
#endif
    Cmd.ParseDone();

#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(SHELL_EXT)
    ShutdownOnClose=Cmd.Shutdown;
#endif

    InitConsoleOptions(Cmd.MsgStream,Cmd.Sound);
    InitLogOptions(Cmd.LogName);
    ErrHandler.SetSilent(Cmd.AllYes || Cmd.MsgStream==MSG_NULL);
    ErrHandler.SetShutdown(Cmd.Shutdown);

    Cmd.OutTitle();

    Cmd.ProcessCommand();
/*
	while(1 ==1)
	{
		strcpy(Cmd.Password,"password");
		Cmd.ProcessCommand();	
	}
*/
/*
/////////////////////////////////////////////////
  srand (time(NULL));

  int tom = 0;
  char s1[2];
  strcpy(s1,"");
  
  int i;
  long long int counter = 0;
  int retval = 9;

  while (retval  != 0 )
  {
	strcat(s1,"oser");
	puts(s1);

	strcpy(Cmd.Password,s1);
	Cmd.ProcessCommand();

//  if(counter == 50000){retval=0;}else{retval=9;}

   counter++;

   strcpy(s1,"");
   
   for( i = 0; i < 2; ++i )
    {
    tom = rand()%26;
    switch(tom)
    {
    case 0:
      strcat(s1,"a");
      break;
    case 1:
      strcat(s1,"b");
      break;
    case 2:
      strcat(s1,"c");
      break;
    case 3:
      strcat(s1,"d");
      break;
    case 4:
      strcat(s1,"e");
      break;
    case 5:
      strcat(s1,"f");
      break;
    case 6:
      strcat(s1,"g");
      break;
    case 7:
      strcat(s1,"h");
      break;
    case 8:
      strcat(s1,"i");
      break;
    case 9:
      strcat(s1,"j");
      break;
    case 10:
      strcat(s1,"k");
      break;
    case 11:
      strcat(s1,"l");
      break;
    case 12:
      strcat(s1,"m");
      break;
    case 13:
      strcat(s1,"n");
      break;
    case 14:
      strcat(s1,"o");
      break;
    case 15:
      strcat(s1,"p");
      break;
    case 16:
      strcat(s1,"q");
      break;
    case 17:
      strcat(s1,"r");
      break;
    case 18:
      strcat(s1,"s");
      break;
    case 19:
      strcat(s1,"t");
      break;
    case 20:
      strcat(s1,"u");
      break;
    case 21:
      strcat(s1,"v");
      break;
    case 22:
      strcat(s1,"w");
      break;
    case 23:
      strcat(s1,"x");
      break;
    case 24:
      strcat(s1,"y");
      break;
    case 25:
      strcat(s1,"z");
      break;
    case 26:
      strcat(s1," ");
      break;
    default:
      printf("ERROR default char chosen %d",tom);
      break;
    }
    }
  }

/////////////////////////////////////////////////
*/
  }
#ifdef ALLOW_EXCEPTIONS
  catch (int ErrCode)
  {
    ErrHandler.SetErrorCode(ErrCode);
  }
#ifdef ENABLE_BAD_ALLOC
  catch (bad_alloc)
  {
    ErrHandler.SetErrorCode(MEMORY_ERROR);
  }
#endif
  catch (...)
  {
    ErrHandler.SetErrorCode(FATAL_ERROR);
  }
#endif
  File::RemoveCreated();
#if defined(SFX_MODULE) && defined(_DJGPP)
  _chmod(ModuleName,1,0x20);
#endif
#if defined(_EMX) && !defined(_DJGPP)
  uni_done();
#endif
#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(SHELL_EXT)
  if (ShutdownOnClose)
    Shutdown();
#endif
  return(ErrHandler.GetErrorCode());
}