Exemplo n.º 1
0
void CCustomCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
	if (bFlag) {
		CString sParam(lpszParam);
		if (sParam.Left(2) == "c:") {
			m_sHostAddr = sParam.Right(sParam.GetLength() - 2);
			m_bClient = TRUE;
			return;
		}

		if (sParam.Left(1) == "h") {
			m_bHost = TRUE;
			return;
		}
		if (sParam.Left(3) == "poc") {
			m_bStunPoc = TRUE;
			return;
		}
		if (sParam.Left(7) == "syslog:") {
			m_sSyslogAddr = sParam.Right(sParam.GetLength() - 7);
			m_bSyslog = TRUE;
			return;
		}
	}
}
void CNTServiceCommandLineInfo::ParseParam(LPCTSTR pszParam, BOOL bFlag, BOOL bLast)
{
	if (bFlag)
	{
    CString sParam(pszParam);
    CString sParamUpper(sParam);
    sParamUpper.MakeUpper();
    int nParamLength = sParam.GetLength();

    if (_tcsicmp(pszParam, _T("install")) == 0)
      m_nShellCommand = InstallService;
    else if (_tcsicmp(pszParam, _T("silent")) == 0)
      m_bSilent = TRUE;
    else if (_tcsicmp(pszParam, _T("start")) == 0)
      m_nShellCommand = StartTheService;
    else if (_tcsicmp(pszParam, _T("pause")) == 0)
      m_nShellCommand = PauseService;
    else if (_tcsicmp(pszParam, _T("continue")) == 0)
      m_nShellCommand = ContinueService;
    else if (_tcsicmp(pszParam, _T("stop")) == 0)
      m_nShellCommand = StopService;
    else if (_tcsicmp(pszParam, _T("auto")) == 0)
      m_bAutoStart = TRUE;
    else if ((_tcsicmp(pszParam, _T("remove")) == 0) ||
             (_tcsicmp(pszParam, _T("uninstall")) == 0) )
      m_nShellCommand = UninstallService;
    else if ((_tcsicmp(pszParam, _T("debug")) == 0) || (_tcsicmp(pszParam, _T("app")) == 0) || 
             (_tcsicmp(pszParam, _T("application")) == 0) || (_tcsicmp(pszParam, _T("console")) == 0))
      m_nShellCommand = DebugService;
    else if ((_tcsicmp(pszParam, _T("help")) == 0) ||
             (_tcsicmp(pszParam, _T("?")) == 0) )
      m_nShellCommand = ShowServiceHelp;
    else if (sParamUpper.Find(_T("T:")) == 0 && nParamLength > 2)
      m_dwTimeout = _ttoi(sParam.Right(nParamLength - 2));
    else if (sParamUpper.Find(_T("SCL:")) == 0 && nParamLength > 4)
      m_sServiceCommandLine = sParam.Right(nParamLength - 4);
    else if (sParamUpper.Find(_T("SD:")) == 0 && nParamLength > 3)
      m_sServiceDescription = sParam.Right(nParamLength - 3);
    else if (sParamUpper.Find(_T("SN:")) == 0 && nParamLength > 3)
      m_sServiceName = sParam.Right(nParamLength - 3);
    else if (sParamUpper.Find(_T("SDN:")) == 0 && nParamLength > 4)
      m_sServiceDisplayName = sParam.Right(nParamLength - 4);
    else if (sParamUpper.Find(_T("P:")) == 0 && nParamLength > 2)
      m_sPassword = sParam.Right(nParamLength - 2);
    else if (sParamUpper.Find(_T("U:")) == 0 && nParamLength > 2)
      m_sUserName = sParam.Right(nParamLength - 2);
	}
	else
	{
		//Currently don't support parsing anything from
		//the command line except flags
	}

	if (bLast)
	{
		//Again the we don't support anything for the
		//last parameter
	}
}
Exemplo n.º 3
0
void MyCommandLineParser::ParseParam(const char* pszParam, BOOL bFlag, BOOL bLast)
  {
#if 0
    if(0 == strcmp(pszParam, "z"))
    {
		m_pp = TRUE;
	}
#endif

	if(bFlag) 
	{
		CString sParam(pszParam);

		if (sParam.Left(2) == "p:") 
		{
			CString sTemp;
			sTemp = sParam.Right(sParam.GetLength() - 2);
			m_port = atoi(sTemp);
			m_pp = TRUE;
			return;
		}
	}

  }
Exemplo n.º 4
0
bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet) {
  CStdLock Lock(pIRCClient->getCSec());
  // process chat input - return false if no more pasting is to be done (i.e.,
  // on /quit or /part in channel)
  bool fResult = true;
  bool fIRCSuccess = true;
  // not connected?
  if (!pIRCClient->IsConnected()) {
    pChatSheet->DoError(LoadResStr("IDS_ERR_NOTCONNECTEDTOSERVER"));
    return fResult;
  }
  // safety
  if (!szInput || !*szInput || !pChatSheet) return fResult;
  // command?
  if (*szInput == '/' && !SEqual2NoCase(szInput + 1, "me ")) {
    StdStrBuf sCommand, sParam("");
    ;
    sCommand.Copy(szInput + 1);
    sCommand.SplitAtChar(' ', &sParam);
    if (SEqualNoCase(sCommand.getData(), "quit")) {
      // query disconnect from IRC server
      fIRCSuccess = pIRCClient->Quit(sParam.getData());
      fResult = false;
    } else if (SEqualNoCase(sCommand.getData(), "part")) {
      // part channel. Default to current channel if typed within a channel
      if (!sParam.getLength() &&
          pChatSheet->GetSheetType() == ChatSheet::CS_Channel) {
        sParam.Copy(pChatSheet->GetIdent());
        fResult = false;
      }
      fIRCSuccess = pIRCClient->Part(sParam.getData());
    } else if (SEqualNoCase(sCommand.getData(), "join") ||
               SEqualNoCase(sCommand.getData(), "j")) {
      if (!sParam.getLength()) sParam.Copy(Config.IRC.Channel);
      fIRCSuccess = pIRCClient->Join(sParam.getData());
    } else if (SEqualNoCase(sCommand.getData(), "notice") ||
               SEqualNoCase(sCommand.getData(), "msg")) {
      bool fMsg = SEqualNoCase(sCommand.getData(), "msg");
      StdStrBuf sMsg;
      if (!sParam.SplitAtChar(' ', &sMsg) || !sMsg.getLength()) {
        pChatSheet->DoError(
            FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"),
                         sCommand.getData()).getData());
      } else {
        if (fMsg)
          fIRCSuccess = pIRCClient->Message(sParam.getData(), sMsg.getData());
        else
          fIRCSuccess = pIRCClient->Notice(sParam.getData(), sMsg.getData());
      }
    } else if (SEqualNoCase(sCommand.getData(), "raw")) {
      if (!sParam.getLength())
        pChatSheet->DoError(
            FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"),
                         sCommand.getData()).getData());
      else
        fIRCSuccess = pIRCClient->Send(sParam.getData());
    } else if (SEqualNoCase(sCommand.getData(), "ns") ||
               SEqualNoCase(sCommand.getData(), "cs") ||
               SEqualNoCase(sCommand.getData(), "ms")) {
      if (!sParam.getLength())
        pChatSheet->DoError(
            FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"),
                         sCommand.getData()).getData());
      else {
        const char *szMsgTarget;
        if (SEqualNoCase(sCommand.getData(), "ns"))
          szMsgTarget = "NickServ";
        else if (SEqualNoCase(sCommand.getData(), "cs"))
          szMsgTarget = "ChanServ";
        else
          szMsgTarget = "MemoServ";
        fIRCSuccess = pIRCClient->Message(szMsgTarget, sParam.getData());
      }
    } else if (SEqualNoCase(sCommand.getData(), "query") ||
               SEqualNoCase(sCommand.getData(), "q")) {
      if (!sParam.getLength())
        pChatSheet->DoError(
            FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"),
                         sCommand.getData()).getData());
      else
        OpenQuery(sParam.getData(), true, NULL);
    } else if (SEqualNoCase(sCommand.getData(), "nick")) {
      if (C4InVal::ValidateString(sParam, C4InVal::VAL_IRCName))
        pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_INVALIDNICKNAME2"),
                                         sCommand.getData()).getData());
      else
        fIRCSuccess = pIRCClient->ChangeNick(sParam.getData());
    } else {
      // unknown command
      pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_UNKNOWNCMD"),
                                       sCommand.getData()).getData());
    }
  } else {
    // regular chat input: Send as message to current channel/user
    const char *szMsgTarget;
    ChatSheet::SheetType eSheetType = pChatSheet->GetSheetType();
    if (eSheetType == ChatSheet::CS_Server) {
      pChatSheet->DoError(LoadResStr("IDS_ERR_NOTONACHANNEL"));
    } else {
      szMsgTarget = pChatSheet->GetTitle();
      if (*szInput == '/')  // action
        fIRCSuccess = pIRCClient->Action(szMsgTarget, szInput + 4);
      else
        fIRCSuccess = pIRCClient->Message(szMsgTarget, szInput);
    }
  }
  // IRC sending error? log it
  if (!fIRCSuccess) {
    pChatSheet->DoError(pIRCClient->GetError());
  }
  return fResult;
}
Exemplo n.º 5
0
ScreenOptionsMaster::ScreenOptionsMaster( const CString &sClassName ):
	ScreenOptions( sClassName )
{
	LOG->Trace("ScreenOptionsMaster::ScreenOptionsMaster(%s)", m_sName.c_str() );

	/* If this file doesn't exist, leave the music alone (eg. ScreenPlayerOptions music sample
	 * left over from ScreenSelectMusic).  If you really want to play no music, add a redir
	 * to _silent. */
	CString MusicPath = THEME->GetPathToS( ssprintf("%s music", m_sName.c_str()), true );
	if( MusicPath != "" )
		SOUND->PlayMusic( MusicPath );

	CStringArray asLineNames;
	split( LINE_NAMES, ",", asLineNames );
	if( asLineNames.empty() )
		RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() );


	CStringArray Flags;
	split( OPTION_MENU_FLAGS, ";", Flags, true );
	InputMode im = INPUTMODE_INDIVIDUAL;
	bool Explanations = false;
	
	unsigned i;
	for( i = 0; i < Flags.size(); ++i )
	{
		CString &flag = Flags[i];
		flag.MakeLower();

		if( flag == "together" )
			im = INPUTMODE_SHARE_CURSOR;
		else if( flag == "explanations" )
			Explanations = true;
		else if( flag == "forceallplayers" )
		{
			FOREACH_PlayerNumber( pn )
				GAMESTATE->m_bSideIsJoined[pn] = true;
			GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0);
		}
		else if( flag == "smnavigation" )
			SetNavigation( NAV_THREE_KEY_MENU );
		else if( flag == "toggle" || flag == "firstchoicegoesdown" )
			SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
	}

	m_OptionRowAlloc = new OptionRowData[asLineNames.size()];
	for( i = 0; i < asLineNames.size(); ++i )
	{
		OptionRowData &row = m_OptionRowAlloc[i];
		
		vector<ParsedCommand> vCommands;
		ParseCommands( LINE(asLineNames[i]), vCommands );
		
		if( vCommands.size() < 1 )
			RageException::Throw( "Parse error in %s::Line%i", m_sName.c_str(), i+1 );

		OptionRowHandler hand;
		for( unsigned part = 0; part < vCommands.size(); ++part)
		{
			ParsedCommand& command = vCommands[part];

			HandleParams;

			const CString name = sParam(0);

			if( !name.CompareNoCase("list") )
			{
				SetList( row, hand, sParam(1), row.name );
			}
			else if( !name.CompareNoCase("steps") )
			{
				SetStep( row, hand );
				row.name = "Steps";
			}
			else if( !name.CompareNoCase("conf") )
			{
				SetConf( row, hand, sParam(1), row.name );
			}
			else if( !name.CompareNoCase("characters") )
			{
				SetCharacter( row, hand );
				row.name = "Characters";
			}
			else
				RageException::Throw( "Unexpected type '%s' in %s::Line%i", name.c_str(), m_sName.c_str(), i );

			CheckHandledParams;
		}

		// TRICKY:  Insert a down arrow as the first choice in the row.
		if( m_OptionsNavigation == NAV_TOGGLE_THREE_KEY )
		{
			row.choices.insert( row.choices.begin(), ENTRY_NAME("NextRow") );
			hand.ListEntries.insert( hand.ListEntries.begin(), ModeChoice() );
		}

		OptionRowHandlers.push_back( hand );
	}

	ASSERT( OptionRowHandlers.size() == asLineNames.size() );

	Init( im, m_OptionRowAlloc, asLineNames.size() );
}
Exemplo n.º 6
0
void Actor::HandleCommand( const ParsedCommand &command )
{
	HandleParams;

	const CString& sName = sParam(0);

	// Commands that go in the tweening queue:
	if     ( sName=="sleep" )			Sleep( fParam(1) );
	else if( sName=="linear" )			BeginTweening( fParam(1), TWEEN_LINEAR );
	else if( sName=="accelerate" )		BeginTweening( fParam(1), TWEEN_ACCELERATE );
	else if( sName=="decelerate" )		BeginTweening( fParam(1), TWEEN_DECELERATE );
	else if( sName=="bouncebegin" )		BeginTweening( fParam(1), TWEEN_BOUNCE_BEGIN );
	else if( sName=="bounceend" )		BeginTweening( fParam(1), TWEEN_BOUNCE_END );
	else if( sName=="spring" )			BeginTweening( fParam(1), TWEEN_SPRING );
	else if( sName=="stoptweening" )	{ StopTweening(); BeginTweening( 0.0001f, TWEEN_LINEAR ); }	// Why BeginT again? -Chris
	else if( sName=="finishtweening" )	FinishTweening();
	else if( sName=="hurrytweening" )	HurryTweening( fParam(1) );
	else if( sName=="x" )				SetX( fParam(1) );
	else if( sName=="y" )				SetY( fParam(1) );
	else if( sName=="z" )				SetZ( fParam(1) );
	else if( sName=="addx" )			SetX( GetDestX()+fParam(1) );
	else if( sName=="addy" )			SetY( GetDestY()+fParam(1) );
	else if( sName=="addz" )			SetZ( GetDestZ()+fParam(1) );
	else if( sName=="zoom" )			SetZoom( fParam(1) );
	else if( sName=="zoomx" )			SetZoomX( fParam(1) );
	else if( sName=="zoomy" )			SetZoomY( fParam(1) );
	else if( sName=="zoomz" )			SetZoomZ( fParam(1) );
	else if( sName=="zoomtowidth" )		ZoomToWidth( fParam(1) );
	else if( sName=="zoomtoheight" )	ZoomToHeight( fParam(1) );
	else if( sName=="stretchto" )		StretchTo( RectF( fParam(1), fParam(2), fParam(3), fParam(4) ) );
	else if( sName=="cropleft" )		SetCropLeft( fParam(1) );
	else if( sName=="croptop" )			SetCropTop( fParam(1) );
	else if( sName=="cropright" )		SetCropRight( fParam(1) );
	else if( sName=="cropbottom" )		SetCropBottom( fParam(1) );
	else if( sName=="fadeleft" )		SetFadeLeft( fParam(1) );
	else if( sName=="fadetop" )			SetFadeTop( fParam(1) );
	else if( sName=="faderight" )		SetFadeRight( fParam(1) );
	else if( sName=="fadebottom" )		SetFadeBottom( fParam(1) );
	else if( sName=="fadecolor" )		SetFadeDiffuseColor( cParam(1) );
	else if( sName=="diffuse" )			SetDiffuse( cParam(1) );
	else if( sName=="diffuseleftedge" )		SetDiffuseLeftEdge( cParam(1) );
	else if( sName=="diffuserightedge" )	SetDiffuseRightEdge( cParam(1) );
	else if( sName=="diffusetopedge" )		SetDiffuseTopEdge( cParam(1) );
	else if( sName=="diffusebottomedge" )	SetDiffuseBottomEdge( cParam(1) );
	/* Add left/right/top/bottom for alpha if needed. */
	else if( sName=="diffusealpha" )	SetDiffuseAlpha( fParam(1) );
	else if( sName=="diffusecolor" )	SetDiffuseColor( cParam(1) );
	else if( sName=="glow" )			SetGlow( cParam(1) );
	else if( sName=="glowmode" ) {
		if(!sParam(1).CompareNoCase("whiten"))
			SetGlowMode( GLOW_WHITEN );
		else if(!sParam(1).CompareNoCase("brighten"))
			SetGlowMode( GLOW_BRIGHTEN );
		else ASSERT(0);
	}
	else if( sName=="rotationx" )		SetRotationX( fParam(1) );
	else if( sName=="rotationy" )		SetRotationY( fParam(1) );
	else if( sName=="rotationz" )		SetRotationZ( fParam(1) );
	else if( sName=="heading" )			AddRotationH( fParam(1) );
	else if( sName=="pitch" )			AddRotationP( fParam(1) );
	else if( sName=="roll" ) 			AddRotationR( fParam(1) );
	else if( sName=="shadowlength" )	SetShadowLength( fParam(1) );
	else if( sName=="horizalign" )		SetHorizAlign( sParam(1) );
	else if( sName=="vertalign" )		SetVertAlign( sParam(1) );
	else if( sName=="diffuseblink" )	SetEffectDiffuseBlink();
	else if( sName=="diffuseshift" )	SetEffectDiffuseShift();
	else if( sName=="glowblink" )		SetEffectGlowBlink();
	else if( sName=="glowshift" )		SetEffectGlowShift();
	else if( sName=="rainbow" )			SetEffectRainbow();
	else if( sName=="wag" )				SetEffectWag();
	else if( sName=="bounce" )			SetEffectBounce();
	else if( sName=="bob" )				SetEffectBob();
	else if( sName=="pulse" )			SetEffectPulse();
	else if( sName=="spin" )			SetEffectSpin();
	else if( sName=="vibrate" )			SetEffectVibrate();
	else if( sName=="stopeffect" )		SetEffectNone();
	else if( sName=="effectcolor1" )	SetEffectColor1( cParam(1) );
	else if( sName=="effectcolor2" )	SetEffectColor2( cParam(1) );
	else if( sName=="effectperiod" )	SetEffectPeriod( fParam(1) );
	else if( sName=="effectoffset" )	SetEffectOffset( fParam(1) );
	else if( sName=="effectdelay" )		SetEffectDelay( fParam(1) );
	else if( sName=="effectclock" )		SetEffectClock( sParam(1) );
	else if( sName=="effectmagnitude" )	SetEffectMagnitude( RageVector3(fParam(1),fParam(2),fParam(3)) );
	else if( sName=="scaletocover" )	{ RectI R(iParam(1), iParam(2), iParam(3), iParam(4));  ScaleToCover(R); }
	else if( sName=="scaletofit" )		{ RectI R(iParam(1), iParam(2), iParam(3), iParam(4));  ScaleToFitInside(R); }
	// Commands that take effect immediately (ignoring the tweening queue):
	else if( sName=="animate" )			EnableAnimation( bParam(1) );
	else if( sName=="setstate" )		SetState( iParam(1) );
	else if( sName=="texturewrapping" )	SetTextureWrapping( bParam(1) );
	else if( sName=="additiveblend" )	SetBlendMode( bParam(1) ? BLEND_ADD : BLEND_NORMAL );
	else if( sName=="blend" )			SetBlendMode( sParam(1) );
	else if( sName=="zbuffer" )			SetUseZBuffer( bParam(1) );
	else if( sName=="ztest" )			SetZTestMode( bParam(1)?ZTEST_WRITE_ON_PASS:ZTEST_OFF );
	else if( sName=="ztestmode" )		SetZTestMode( sParam(1) );
	else if( sName=="zwrite" )			SetZWrite( bParam(1) );
	else if( sName=="clearzbuffer" )	SetClearZBuffer( bParam(1) );
	else if( sName=="backfacecull" )	SetCullMode( bParam(1) ? CULL_BACK : CULL_NONE );
	else if( sName=="cullmode" )		SetCullMode( sParam(1) );
	else if( sName=="hidden" )			SetHidden( bParam(1) );
	else if( sName=="hibernate" )		SetHibernate( fParam(1) );
	else if( sName=="draworder" )		SetDrawOrder( iParam(1) );
	else if( sName=="playcommand" )		PlayCommand( sParam(1) );
	else if( sName=="queuecommand" )	
	{
		ParsedCommand newcommand = command;
		newcommand.vTokens.erase( newcommand.vTokens.begin() );
		QueueCommand( newcommand );
		return;	// don't do parameter number checking
	}

	/* These are commands intended for a Sprite commands, but they will get 
	 * sent to all sub-actors (which aren't necessarily Sprites) on 
	 * GainFocus and LoseFocus.  So, don't run CheckHandledParams 
	 * on these commands. */
	else if( sName=="customtexturerect" || sName=="texcoordvelocity" || sName=="scaletoclipped" ||
		 sName=="stretchtexcoords" || sName=="position" || sName=="loop" || sName=="play" ||
		 sName=="pause" || sName=="rate" )
		return;
	else
	{
		CString sError = ssprintf( "Actor::HandleCommand: Unrecognized command name '%s'.", sName.c_str() );
		LOG->Warn( sError );
		Dialog::OK( sError );
	}

	CheckHandledParams;
}