Beispiel #1
0
// ValidateCommandLine
// Checks command line incorrect syntax.
// returns:
//   TRUE if command line is correct
//   FALSE if command line is incorrect
// Error messages:
//   Internal error messages when FALSE is returned.
// Side affects:
//   Makes m_CmdInfo.m_sApplication and/or m_CmdInfo.m_sDialog lower case.
//   When it returns FALSE it places a command line usage statement into
//   m_sCommandLineUsage.
BOOL CCustinfoDriverApp::ValidateCommandLine()
{
   int dummy = 0;
   CString message;

   // Check flags.
   // Checking required flags.
   // Ignoring unnecessary flags.

   if (m_CmdInfo.m_sApplication.IsEmpty() &&
       m_CmdInfo.m_sDialog.IsEmpty() &&
       m_CmdInfo.m_sAccountid.IsEmpty() &&
       !m_CmdInfo.m_bExit)
   {
      FormatCommandLineUsage();
      ErrorMessage(__FILE__, __LINE__, m_sCommandLineUsage);
      return FALSE;
   }

   if (!ValidateName(m_CmdInfo.m_sApplication, m_sAppNames, MAX_APP_NAMES))
   {
      return FALSE;
   }

   if (!ValidateName(m_CmdInfo.m_sDialog, m_sDialogNames, MAX_DIALOG_NAMES))
   {
      return FALSE;
   }

   return TRUE;
}
Beispiel #2
0
NTSTATUS
CheckFI(
    IN PFI FIRecord,
    IN IFI ifi
    )
{
    int i;

    i = ValidateName( (IED)ifi,
                      FIRecord->nmFile,
                      cchFileMax,
                      TRUE
                    );
    if (i != -1) {
#if DBG
        SrvPrint1( "CheckFI( %3d ): ", ifi );
        SrvPrint4( "File name invalid in %d char (%02x) - %.*Fs\n",
                  i,
                  FIRecord->nmFile[ i ],
                  cchFileMax,
                  FIRecord->nmFile
                );
#endif

        return( (NTSTATUS)((ULONG)STATUS_UNSUCCESSFUL + 0x5000 + ifi) );
        }


    return( STATUS_SUCCESS );
}
bool CProposalValidator::Validate(bool fCheckExpiration)
{
    if(!fJSONValid) {
        strErrorMessages += "JSON parsing error;";
        return false;
    }
    if(!ValidateName()) {
        strErrorMessages += "Invalid name;";
        return false;
    }
    if(!ValidateStartEndEpoch(fCheckExpiration)) {
        strErrorMessages += "Invalid start:end range;";
        return false;
    }
    if(!ValidatePaymentAmount()) {
        strErrorMessages += "Invalid payment amount;";
        return false;
    }
    if(!ValidatePaymentAddress()) {
        strErrorMessages += "Invalid payment address;";
        return false;
    }
    if(!ValidateURL()) {
        strErrorMessages += "Invalid URL;";
        return false;
    }
    return true;
}
Beispiel #4
0
bool YumemiArchive_Base::DeserializeList(std::istream &is, uint32_t list_count, uint32_t filesize, EntryList &list)
{
  for(uint16_t i = 0; i < list_count; ++i) {
    Entry entry;
    uint16_t magic;
    char     padding[8];
    is.read((char *)&magic, 2);
    if(is.fail()) return false;
    is.read((char *)&entry.key, 1);
    if(is.fail()) return false;
    is.read(entry.name, 13);
    if(is.fail()) return false;
    is.read((char *)&entry.compsize, 2);
    if(is.fail()) return false;
    is.read((char *)&entry.origsize, 2);
    if(is.fail()) return false;
    is.read((char *)&entry.offset, 4);
    if(is.fail()) return false;
    is.read(padding, 8);
    if(is.fail()) return false;

    if(magic == 0) break;

    if(magic != 0x9595 && magic != 0xF388) return false;
    if(entry.offset >= filesize) return false;
    if((uint32_t)filesize - entry.offset < entry.compsize) return false;
    if(!ValidateName(entry.name)) return false;
    list.push_back(entry);
  }
  return true;
}
bool CFlashMenuObject::SaveGame(const char *fileName)
{
	string sSaveFileName = fileName;
	const char *reason = ValidateName(fileName);
	if(reason)
	{
		ShowMenuMessage(reason);
		return false;
	}
	else
	{
		IActor *pActor = g_pGame->GetIGameFramework()->GetClientActor();
		if(pActor && pActor->GetHealth() <= 0)
		{
			ShowMenuMessage("@ui_dead_no_save");
			return false;
		}

		sSaveFileName.append(".CRYSISJMSF");
		const bool bSuccess =	gEnv->pGame->GetIGameFramework()->SaveGame(sSaveFileName,true, false, eSGR_QuickSave, true);
		if (!bSuccess)
			return false;

		UpdateSaveGames();
	}
	return true;
}
Beispiel #6
0
	void Serializer::Deserialize (const string &name, const BufferPtr &data)
	{
		ValidateName (name);

		uint64 size = Deserialize <uint64> ();
		if (data.Size() != size)
			throw ParameterIncorrect (SRC_POS);

		DataStream->ReadCompleteBuffer (data);
	}
Beispiel #7
0
	list <wstring> Serializer::DeserializeWStringList (const string &name)
	{
		ValidateName (name);
		list <wstring> deserializedList;
		uint64 listSize = Deserialize <uint64> ();

		for (size_t i = 0; i < listSize; i++)
			deserializedList.push_back (DeserializeWString ());

		return deserializedList;
	}
Beispiel #8
0
NTSTATUS
CheckED(
    IN PED EDRecord,
    IN IED ied
    )
{
    int i;

    i = ValidatePath( ied, EDRecord, EDRecord->pthEd );
    if (i != -1) {
#if DBG
        SrvPrint1( "CheckED( %d ): ", ied );
        SrvPrint4( "%s %s (User Path invalid in %d char (%02x))\n",
                  EDRecord->nmOwner,
                  EDRecord->pthEd,
                  i,
                  EDRecord->pthEd[ i ]
                );
#endif
        return( (NTSTATUS)((ULONG)STATUS_UNSUCCESSFUL + 0x6000 + ied) );
        }

    i = ValidateName( ied,
                      EDRecord->nmOwner,
                      cchUserMax,
                      FALSE
                    );
    if (i != -1) {
#if DBG
        SrvPrint1( "CheckED( %d ): ", ied );
        SrvPrint4( "%s %s (Owner invalid in %d char (%02x))\n",
                  EDRecord->nmOwner,
                  EDRecord->pthEd,
                  i,
                  EDRecord->nmOwner[ i ]
                );
#endif
        return( (NTSTATUS)((ULONG)STATUS_UNSUCCESSFUL + 0x7000 + ied) );
        }

    return( STATUS_SUCCESS );
}
void CFlashMenuObject::DeleteSaveGame(const char *fileName)
{

	const char *reason = ValidateName(fileName);
	if(reason)
	{
		ShowMenuMessage(reason);
		return;
	}
	else
	{
		if(!m_pPlayerProfileManager)
			return;

		IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
		if(!pProfile)
			return;
		pProfile->DeleteSaveGame(fileName);
		UpdateSaveGames();
	}
}
Beispiel #10
0
	void Serializer::Deserialize (const string &name, wstring &data)
	{
		ValidateName (name);
		data = DeserializeWString ();
	}
Beispiel #11
0
	void Serializer::Deserialize (const string &name, uint64 &data)
	{
		ValidateName (name);
		data = Deserialize <uint64> ();
	}
Beispiel #12
0
	void Serializer::Deserialize (const string &name, int32 &data)
	{
		ValidateName (name);
		data = (int32) Deserialize <uint32> ();
	}
Beispiel #13
0
	void Serializer::Deserialize (const string &name, byte &data)
	{
		ValidateName (name);
		data = Deserialize <byte> ();
	}
Beispiel #14
0
	wstring Serializer::DeserializeWString (const string &name)
	{
		ValidateName (name);
		return DeserializeWString ();
	}
void CFlashMenuObject::UpdateSaveGames()
{
	CFlashMenuScreen* pScreen = m_pCurrentFlashMenuScreen;
	if(!pScreen)
		return;

	//*************************************************************************

	std::vector<SaveGameMetaData> saveGameData;
	
	//*************************************************************************

	pScreen->CheckedInvoke("resetSPGames");

	// TODO: find a better place for this as it needs to be set only once -- CW
	gEnv->pSystem->SetFlashLoadMovieHandler(this);

	if(!m_pPlayerProfileManager)
		return;

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile)
		return;
 
	ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
	ISaveGameEnumeratorPtr pSGE = pProfile->CreateSaveGameEnumerator();
	ISaveGameEnumerator::SGameDescription desc;	

	//get the meta data into the struct
	for (int i=0; i<pSGE->GetCount(); ++i)
	{
		pSGE->GetDescription(i, desc);

		int kills = 0;
		float levelPlayTimeSec = 0.0f;
		float gamePlayTimeSec = 0.0f;
		int difficulty = g_pGameCVars->g_difficultyLevel;
		desc.metaData.xmlMetaDataNode->getAttr("sp_kills", kills);
		desc.metaData.xmlMetaDataNode->getAttr("sp_levelPlayTime", levelPlayTimeSec);
		desc.metaData.xmlMetaDataNode->getAttr("sp_gamePlayTime", gamePlayTimeSec);
		desc.metaData.xmlMetaDataNode->getAttr("sp_difficulty", difficulty);

		SaveGameMetaData data;
		data.name = desc.name;
		data.buildVersion = desc.metaData.buildVersion;
		data.description = desc.description;
		data.fileVersion = desc.metaData.fileVersion;
		data.gamePlayTimeSec = gamePlayTimeSec;
		data.gameRules = desc.metaData.gameRules;
		data.humanName = desc.humanName;
		data.levelName = g_pGame->GetMappedLevelName(desc.metaData.levelName);
		data.levelPlayTimeSec = levelPlayTimeSec;
		data.saveTime = desc.metaData.saveTime;
		data.kills = kills;
		data.difficulty = difficulty;
		saveGameData.push_back(data);
	}

	if(saveGameData.size())
	{
		//sort by the set sorting rules
		std::sort(saveGameData.begin(), saveGameData.end(), SaveGameDataCompare(m_eSaveGameCompareMode));

		//send sorted data to flash
		int start = (m_bSaveGameSortUp)?0:saveGameData.size()-1;
		int end = (m_bSaveGameSortUp)?saveGameData.size():-1;
		int inc = (m_bSaveGameSortUp)?1:-1;
		for(int i = start; i != end; i+=inc)
		{
			SaveGameMetaData data = saveGameData[i];

			wstring levelPlayTimeString;
			pLocMgr->LocalizeDuration((int)data.levelPlayTimeSec, levelPlayTimeString);

			wstring gamePlayTimeSecString;
			pLocMgr->LocalizeDuration((int)data.gamePlayTimeSec, gamePlayTimeSecString);

			wstring dateString;
			pLocMgr->LocalizeDate(data.saveTime, true, true, true, dateString);

			wstring timeString;
			pLocMgr->LocalizeTime(data.saveTime, true, false, timeString);

			dateString+=L" ";
			dateString+=timeString;

			bool levelStart = (ValidateName(data.name))?true:false;

			SFlashVarValue args[12] =
			{
				data.name, 
				data.description, 
				data.humanName, 
				data.levelName, 
				data.gameRules, 
				data.fileVersion, 
				data.buildVersion, 
				levelPlayTimeString.c_str(),
				dateString.c_str(),
				levelStart,
				data.kills,
				data.difficulty
			};		
			pScreen->CheckedInvoke("addGameToList", args, sizeof(args) / sizeof(args[0]));
		}
	}

	pScreen->CheckedInvoke("updateGameList");
}
Beispiel #16
0
int
ValidatePath(
    IN IED ied,
    IN PED EDRecord,
    IN char *Path
    )
{
    char *s = Path;
    UCHAR ComponentName[ 32 ];
    int i;
    int MaxLength = cchPthMax;

    EDRecord;

    if (*s++ != '/') {
        return( 0 );
        }

    if (*s++ != '/') {
        return( 1 );
        }

    if (((*s >= 'a' && *s <= 'z') || (*s >= 'A' && *s <= 'Z')) && s[ 1 ] == ':') {
        s += 2;
        if (GetPathToken( ComponentName, cchVolMax, s )) {
            i = ValidateName( ied, ComponentName, cchVolMax, FALSE );
            if (i != -1) {
                return( i + (s - Path) );
                }
            }
        else {
            return( s - Path );
            }
        }
    else {
        if (GetPathToken( ComponentName, cchMachMax, s )) {
            i = ValidateName( ied, ComponentName, cchMachMax, FALSE );
            if (i != -1) {
                return( i + (s - Path) );
                }
            }
        else {
            return( s - Path );
            }
        }

    while (TRUE) {
        s += strlen( ComponentName );
        if (*s == '/') {
            s++;
            }
        else {
            break;
            }

        if (!GetPathToken( ComponentName, cchFileMax, s )) {
            return( s - Path );
            }

        i = ValidateName( ied, ComponentName, cchFileMax, TRUE );
        if (i != -1) {
            return( i + (s - Path) );
            }
        }

    i = s - Path;
    if (i > MaxLength) {
        return( MaxLength );
        }

    return( -1 );
}
Beispiel #17
0
	int32 Serializer::DeserializeInt32 (const string &name)
	{
		ValidateName (name);
		return Deserialize <uint32> ();
	}
Beispiel #18
0
	uint64 Serializer::DeserializeUInt64 (const string &name)
	{
		ValidateName (name);
		return Deserialize <uint64> ();
	}