//----- (00453E6D) -------------------------------------------------------- void StorylineText::Initialize() { char* test_string; free(pHistoryTXT_Raw); pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); strtok(pHistoryTXT_Raw, "\r"); StoreLine[0].pText=nullptr; StoreLine[0].pPageTitle=nullptr; StoreLine[0].uTime=0; StoreLine[0].f_9=0; StoreLine[0].f_A=0; StoreLine[0].f_B=0; for (int i=0;i<28;++i) { test_string = strtok(NULL, "\r") + 1; auto tokens = Tokenize(test_string, '\t'); StoreLine[i+1].pText = RemoveQuotes(tokens[1]); StoreLine[i+1].uTime = atoi(tokens[2]); //strange but in text here string not digit StoreLine[i+1].pPageTitle = RemoveQuotes(tokens[3]); } }
// ---------------------------------------------------------------------------- // CSIPAuthenticationInfoHeaderParams::CheckAndUpdateParamL // ---------------------------------------------------------------------------- // void CSIPAuthenticationInfoHeaderParams::CheckAndUpdateParamL( RStringF aName, TBool /*aHasValue*/, TPtrC8& aValue) const { // nextnonce, cnonce if (aName == SIPStrings::StringF(SipStrConsts::ENextNonce) || aName == SIPStrings::StringF(SipStrConsts::ECNonce)) { RemoveQuotes(aValue); if (!SIPSyntaxCheck::QuotedStringValue(aValue)) { User::Leave(KErrSipCodecAuthenticationInfoHeader); } return; } // message-qop if (aName == SIPStrings::StringF(SipStrConsts::EQop)) { RemoveQuotes(aValue); if (!SIPSyntaxCheck::Token(aValue)) { User::Leave(KErrSipCodecAuthenticationInfoHeader); } return; } // response-auth if (aName == SIPStrings::StringF(SipStrConsts::EResponseAuth)) { RemoveQuotes(aValue); if (!SIPSyntaxCheck::HexValue(aValue)) { User::Leave(KErrSipCodecAuthenticationInfoHeader); } return; } // nonce-count if (aName == SIPStrings::StringF(SipStrConsts::ENonceCount)) { const TInt KNonceCountLength = 8; if (!SIPSyntaxCheck::HexValue(aValue,KNonceCountLength)) { User::Leave(KErrSipCodecAuthenticationInfoHeader); } return; } // The above are the only allowed parameters. No extensions allowed. User::Leave(KErrSipCodecAuthenticationInfoHeader); }
BString ParseArgvZeroFromString(const char* command) { char* ret = NULL; // make our own copy of the string... int slen = strlen(command); // need an extra nul byte to get GetNextWord() to stop char* cmd = new char[slen + 2]; strcpy(cmd, command); cmd[slen + 1] = '\0'; // zero out the second nul byte GunkSpaces(cmd); RemoveQuotes(cmd); char* beginWord = NULL, *endWord = cmd - 1; if (GetNextWord(&beginWord, &endWord)) { ret = new char[strlen(beginWord) + 1]; strcpy(ret, beginWord); UnGunk(ret); } delete [] cmd; BString retStr(ret?ret:""); delete [] ret; return retStr; }
void Preprocessor::ParsePragma( LexemList& args ) { args.pop_front(); if( args.empty() ) { PrintErrorMessage( "Pragmas need arguments." ); return; } std::string p_name = args.begin()->Value; args.pop_front(); std::string p_args; if( !args.empty() ) { if( args.begin()->Type != Lexem::STRING ) PrintErrorMessage( "Pragma parameter should be a string literal." ); p_args = RemoveQuotes( args.begin()->Value ); args.pop_front(); } if( !args.empty() ) PrintErrorMessage( "Too many parameters to pragma." ); Pragmas.push_back( p_name ); Pragmas.push_back( p_args ); Pragma::Instance pi; pi.Text = p_args; pi.CurrentFile = CurrentFile; pi.CurrentFileLine = LinesThisFile; pi.RootFile = RootFile; pi.GlobalLine = CurrentLine; if( CurPragmaCallback ) CurPragmaCallback->CallPragma( p_name, pi ); }
TBool CExampleCookieManager::CheckDomainMatch(CCookie& aCookie, const TUriC8& aUri) const { TChar domainSep = '.'; if(aUri.IsPresent(EUriHost)) { THTTPHdrVal attributeVal; aCookie.Attribute(CCookie::EDomain, attributeVal); const TDesC8& domain = aUri.Extract(EUriHost); const TPtrC8 cookieDomain = RemoveQuotes(attributeVal.StrF().DesC()); // Domain matching rules: // if the cookie domain doesn't start with a dot then it must match the uri domain exactly // if it does start with a dot and it TInt matchLoc = domain.FindF(cookieDomain); if((cookieDomain[0] != TUint(domainSep)) && (matchLoc == 0) && (domain.Length() == cookieDomain.Length())) return ETrue; else if((matchLoc != KErrNotFound) && (domain.Left(matchLoc).Locate(domainSep) == KErrNotFound)) return ETrue; } return EFalse; }
TBool CExampleCookieManager::CheckPortMatch(CCookie& aCookie, const TUriC8& aUri) const { THTTPHdrVal val; if(aCookie.Attribute(CCookie::EPort, val) == KErrNone) { TChar portSeparator(','); _LIT8(KDefaultPort, "80"); const TDesC8& port = aUri.IsPresent(EUriPort)? aUri.Extract(EUriPort) : KDefaultPort(); const TPtrC8& portList = RemoveQuotes(val.StrF().DesC()); TInt portPos = portList.FindF(port); // if we do not find the port in the list then do not match if(portPos == KErrNotFound) return EFalse; // if the number was the last in the list then match else if((portPos + port.Length()) == portList.Length()) return ETrue; // check that the number is followed by a separator ie do not match 80 with 8000 else if(portList[portPos + port.Length()] == TUint(portSeparator)) return ETrue; // we have not found a match else return EFalse; } // If the cookie does not have a portlist return ETrue to match any port return ETrue; }
TBool CExampleCookieManager::CheckPathMatch(CCookie& aCookie, const TUriC8& aUri) const { THTTPHdrVal attributeVal; aCookie.Attribute(CCookie::EPath, attributeVal); TPtrC8 cookiePath = RemoveQuotes(attributeVal.StrF().DesC()); const TDesC8& uriPath = aUri.Extract(EUriPath); if(uriPath.Length() == 0) { // if the uri has no path then it matches against no cookie path // or a cookie path of just a / const TInt pathLength = cookiePath.Length(); if(pathLength == 0 || pathLength == 1) return ETrue; } else if(uriPath.FindF(cookiePath) == 0) { TChar separator('/'); // Check that the character after the matched bit is a / otherwise // /path would match against /path2 const TInt uriLength = uriPath.Length(); const TInt cookieLength = cookiePath.Length(); if(uriLength == cookieLength) return ETrue; else if(uriLength > cookieLength) { if(cookiePath[cookieLength - 1] == TUint(separator)) return ETrue; else if(uriPath[cookieLength] == TUint(separator)) return ETrue; } } return EFalse; }
/* Function to return a specific argument parameter from a given command line input * format string. */ LPSTR GetArgV(LPSTR lpszCommandLine, int iIndex, LPSTR lpszDest, int iDestSize) { int i; int j; int iArgCount; int iStrLength; LPSTR lpszBeginStr; LPSTR lpszDestTemp; BOOL bFoundQuote; BOOL bFoundSpace; iArgCount = 0; lpszBeginStr = GetFirstNonSpace(lpszCommandLine); if(lpszBeginStr == NULL) return(NULL); lpszDestTemp = (char *)calloc(iDestSize, sizeof(char)); if(lpszDestTemp == NULL) { PrintError("Out of memory", ERROR_CODE_HIDE); exit(1); } ZeroMemory(lpszDest, iDestSize); iStrLength = lstrlen(lpszBeginStr); bFoundQuote = FALSE; bFoundSpace = TRUE; j = 0; for(i = 0; i < iStrLength; i++) { if(lpszCommandLine[i] == '\"') { if(bFoundQuote == FALSE) { ++iArgCount; bFoundQuote = TRUE; } else { bFoundQuote = FALSE; } } else if(bFoundQuote == FALSE) { if(!isspace(lpszCommandLine[i]) && (bFoundSpace == TRUE)) { ++iArgCount; bFoundSpace = FALSE; } else if(isspace(lpszCommandLine[i])) { bFoundSpace = TRUE; } } if((iIndex == (iArgCount - 1)) && ((bFoundQuote == TRUE) || (bFoundSpace == FALSE) || ((bFoundQuote == FALSE) && (lpszCommandLine[i] == '\"')))) { if(j < iDestSize) { lpszDestTemp[j] = lpszCommandLine[i]; ++j; } else { lpszDestTemp[j] = '\0'; } } } RemoveQuotes(lpszDestTemp, lpszDest, iDestSize); free(lpszDestTemp); return(lpszDest); }
void Preprocessor::RecursivePreprocess( std::string filename, FileLoader& file_source, LexemList& lexems, DefineTable& define_table ) { unsigned int start_line = CurrentLine; LinesThisFile = 0; CurrentFile = filename; SetFileMacro( define_table, CurrentFile ); SetLineMacro( define_table, LinesThisFile ); // Path formatting must be done in main application std::string CurrentFileRoot = RootPath + CurrentFile; if( std::find( FilesPreprocessed.begin(), FilesPreprocessed.end(), CurrentFileRoot ) == FilesPreprocessed.end() ) FilesPreprocessed.push_back( CurrentFileRoot ); std::vector<char> data; bool loaded = file_source.LoadFile( RootPath, filename, data ); if( !loaded ) { PrintErrorMessage( std::string( "Could not open file " ) + RootPath + filename ); return; } if( data.size() == 0 ) return; char* d_end = &data[data.size() - 1]; ++d_end; Lex( &data[0], d_end, lexems ); LexemList::iterator itr = lexems.begin(); LexemList::iterator end = lexems.end(); LLITR old = end; while( itr != end ) { if( itr->Type == Lexem::NEWLINE ) { if( itr != old ) { CurrentLine++; LinesThisFile++; SetLineMacro( define_table, LinesThisFile ); } old = itr; ++itr; } else if( itr->Type == Lexem::PREPROCESSOR ) { LLITR start_of_line = itr; LLITR end_of_line = ParsePreprocessor( lexems, itr, end ); LexemList directive( start_of_line, end_of_line ); if( SkipPragmas && directive.begin()->Value == "#pragma" ) { itr = end_of_line; Lexem wspace; wspace.Type = Lexem::WHITESPACE; wspace.Value = " "; for( LLITR it = start_of_line; it != end_of_line;) { ++it; it = lexems.insert( it, wspace ); ++it; } continue; } itr = lexems.erase( start_of_line, end_of_line ); std::string value = directive.begin()->Value; if( value == "#define" ) { ParseDefine( define_table, directive ); } else if( value == "#ifdef" ) { std::string def_name; ParseIf( directive, def_name ); DefineTable::iterator dti = define_table.find( def_name ); if( dti == define_table.end() ) { LLITR splice_to = ParseIfDef( itr, end ); itr = lexems.erase( itr, splice_to ); } } else if( value == "#ifndef" ) { std::string def_name; ParseIf( directive, def_name ); DefineTable::iterator dti = define_table.find( def_name ); if( dti != define_table.end() ) { LLITR splice_to = ParseIfDef( itr, end ); itr = lexems.erase( itr, splice_to ); } } else if( value == "#if" ) { bool satisfied = EvaluateExpression( define_table, directive ) != 0; if( !satisfied ) { LLITR splice_to = ParseIfDef( itr, end ); itr = lexems.erase( itr, splice_to ); } } else if( value == "#endif" ) { // ignore } else if( value == "#include" ) { if( LNT ) LNT->AddLineRange( PrependRootPath( filename ), start_line, CurrentLine - LinesThisFile ); unsigned int save_lines_this_file = LinesThisFile; std::string file_name; ParseIf( directive, file_name ); std::string file_name_ = RemoveQuotes( file_name ); if( IncludeTranslator ) IncludeTranslator->Call( file_name_ ); if( std::find( FileDependencies.begin(), FileDependencies.end(), file_name_ ) == FileDependencies.end() ) FileDependencies.push_back( file_name_ ); LexemList next_file; RecursivePreprocess( AddPaths( filename, file_name_ ), file_source, next_file, define_table ); lexems.splice( itr, next_file ); start_line = CurrentLine; LinesThisFile = save_lines_this_file; CurrentFile = filename; SetFileMacro( define_table, CurrentFile ); SetLineMacro( define_table, LinesThisFile ); } else if( value == "#pragma" ) { ParsePragma( directive ); } else if( value == "#message" ) { std::string message; ParseTextLine( directive, message ); PrintMessage( message ); } else if( value == "#warning" ) { std::string warning; ParseTextLine( directive, warning ); PrintWarningMessage( warning ); } else if( value == "#error" ) { std::string error; ParseTextLine( directive, error ); PrintErrorMessage( error ); } else { PrintErrorMessage( "Unknown directive '" + value + "'." ); } } else if( itr->Type == Lexem::IDENTIFIER ) { itr = ExpandDefine( itr, end, lexems, define_table ); } else { ++itr; } } if( LNT ) LNT->AddLineRange( PrependRootPath( filename ), start_line, CurrentLine - LinesThisFile ); }
//----- (00453F62) -------------------------------------------------------- void MapStats::Initialize() { char work_str[32]; // [sp+Ch] [bp-34h]@3 int work_str_pos; int work_str_len; int i; char* test_string; unsigned char c; bool break_loop; unsigned int temp_str_len; char* tmp_pos; int decode_step; // int item_counter; free(pMapStatsTXT_Raw); pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); strtok(pMapStatsTXT_Raw, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); for (i=1; i<77; ++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 1: pInfos[i].pName = RemoveQuotes(test_string); break; case 2: pInfos[i].pFilename = RemoveQuotes(test_string); break; case 3: pInfos[i].uNumResets = atoi(test_string); break; case 4: pInfos[i].uFirstVisitedAt = atoi(test_string); break; case 5: pInfos[i]._per = atoi(test_string); break; case 6: pInfos[i].uRespawnIntervalDays = atoi(test_string); break; case 7: pInfos[i]._alert_days = atoi(test_string); break; case 8: pInfos[i]._steal_perm = atoi(test_string); break; case 9: pInfos[i].LockX5 = atoi(test_string); break; case 10: pInfos[i].Trap_D20 = atoi(test_string); break; case 11: pInfos[i].Treasure_prob = atoi(test_string); break; case 12: pInfos[i].Encounter_percent = atoi(test_string); break; case 13: pInfos[i].EncM1percent = atoi(test_string); break; case 14: pInfos[i].EncM2percent = atoi(test_string); break; case 15: pInfos[i].EncM3percent = atoi(test_string); break; case 16: pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string); break; case 18: pInfos[i].Dif_M1 = atoi(test_string); break; case 19: pInfos[i].uEncounterMonster1AtLeast = 1; pInfos[i].uEncounterMonster1AtMost = 1; strcpy(work_str, test_string); work_str_pos = 0; work_str_len=strlen(work_str); if (work_str_len ) { while (work_str[work_str_pos] != '-' ) { ++work_str_pos; if (work_str_pos >= work_str_len ) break; } work_str[work_str_pos] = 0; pInfos[i].uEncounterMonster1AtLeast = atoi(work_str); if ( work_str_pos < work_str_len ) pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]); else pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast; } break; case 20: pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string); break; case 22: pInfos[i].Dif_M2 = atoi(test_string); break; case 23: pInfos[i].uEncounterMonster2AtLeast = 1; pInfos[i].uEncounterMonster2AtMost = 1; strcpy(work_str, test_string); work_str_pos = 0; work_str_len=strlen(work_str); if (work_str_len ) { while (work_str[work_str_pos] != '-' ) { ++work_str_pos; if (work_str_pos >= work_str_len ) break; } work_str[work_str_pos] = 0; pInfos[i].uEncounterMonster2AtLeast = atoi(work_str); if ( work_str_pos < work_str_len ) pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]); else pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast; } break; case 24: pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string); break; case 26: pInfos[i].Dif_M3 = atoi(test_string); break; case 27: pInfos[i].uEncounterMonster3AtLeast = 1; pInfos[i].uEncounterMonster3AtMost = 1; strcpy(work_str, test_string); work_str_pos = 0; work_str_len=strlen(work_str); if (work_str_len ) { while (work_str[work_str_pos] != '-' ) { ++work_str_pos; if (work_str_pos >= work_str_len ) break; } work_str[work_str_pos] = 0; pInfos[i].uEncounterMonster3AtLeast = atoi(work_str); if ( work_str_pos < work_str_len ) pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]); else pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast; } break; case 28: pInfos[i].uRedbookTrackID = atoi(test_string); break; case 29: { if ( !strcmp(test_string, "CAVE") ) { pInfos[i].uEAXEnv = 8; break; } if ( !strcmp(test_string, "STONEROOM") ) { pInfos[i].uEAXEnv = 5; break; } if ( !strcmp(test_string, "MOUNTAINS") ) { pInfos[i].uEAXEnv = 17; break; } if ( !strcmp(test_string, "PLAIN") ) { pInfos[i].uEAXEnv = 19; break; } if ( !strcmp(test_string, "FOREST") ) { pInfos[i].uEAXEnv = 15; break; } if ( !strcmp(test_string, "CITY") ) { pInfos[i].uEAXEnv = 16; break; } if ( !strcmp(test_string, "UNDERWATER") ) { pInfos[i].uEAXEnv = 22; break; } if ( !strcmp(test_string, "ARENA") ) { pInfos[i].uEAXEnv = 9; break; } if ( !strcmp(test_string, "GENERIC") ) { pInfos[i].uEAXEnv = 0; break; } if ( !strcmp(test_string, "PADDEDCELL") ) { pInfos[i].uEAXEnv = 1; break; } if ( !strcmp(test_string, "ROOM") ) { pInfos[i].uEAXEnv = 2; break; } if ( !strcmp(test_string, "BATHROOM") ) { pInfos[i].uEAXEnv = 3; break; } if ( !strcmp(test_string, "LIVINGROOM") ) { pInfos[i].uEAXEnv = 4; break; } if ( !strcmp(test_string, "AUDITORIUM") ) { pInfos[i].uEAXEnv = 6; break; } if ( !strcmp(test_string, "CONCERTHALL") ) { pInfos[i].uEAXEnv = 7; break; } if ( !strcmp(test_string, "HANGAR") ) { pInfos[i].uEAXEnv = 10; break; } if ( !strcmp(test_string, "CARPETEDHALLWAY") ) { pInfos[i].uEAXEnv = 11; break; } if ( !strcmp(test_string, "HALLWAY") ) { pInfos[i].uEAXEnv = 12; break; } if ( !strcmp(test_string, "STONECORRIDOR") ) { pInfos[i].uEAXEnv = 13; break; } if ( !strcmp(test_string, "ALLEY") ) { pInfos[i].uEAXEnv = 14; break; } if ( !strcmp(test_string, "QUARRY") ) { pInfos[i].uEAXEnv = 18; break; } if ( !strcmp(test_string, "PARKINGLOT") ) { pInfos[i].uEAXEnv = 20; break; } if ( !strcmp(test_string, "SEWERPIPE") ) { pInfos[i].uEAXEnv = 21; break; } if ( !strcmp(test_string, "DRUGGED") ) { pInfos[i].uEAXEnv = 23; break; } if ( !strcmp(test_string, "DIZZY") ) { pInfos[i].uEAXEnv = 24; break; } if ( !strcmp(test_string, "PSYCHOTIC") ) { pInfos[i].uEAXEnv = 25; break; } pInfos[i].uEAXEnv = 26; } break; } } else { break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<31)&&!break_loop); } uNumMaps = 77; }
bool RunCommands(CCommandArray& Commands, LPCTSTR pszOrigDocName) { s_bRunsCommands = true; char szCurDir[MAX_PATH]; _getcwd(szCurDir, MAX_PATH); procWnd.GetReady(); // cut up document name into file and extension components. // create two sets of buffers - one set with the long filename // and one set with the 8.3 format. char szDocLongPath[MAX_PATH] = {0}, szDocLongName[MAX_PATH] = {0}, szDocLongExt[MAX_PATH] = {0}; char szDocShortPath[MAX_PATH] = {0}, szDocShortName[MAX_PATH] = {0}, szDocShortExt[MAX_PATH] = {0}; GetFullPathName(pszOrigDocName, MAX_PATH, szDocLongPath, NULL); GetShortPathName(pszOrigDocName, szDocShortPath, MAX_PATH); // split them up char *p = strrchr(szDocLongPath, '.'); if(p && strrchr(szDocLongPath, '\\') < p && strrchr(szDocLongPath, '/') < p) { // got the extension strcpy(szDocLongExt, p+1); p[0] = 0; } p = strrchr(szDocLongPath, '\\'); if(!p) p = strrchr(szDocLongPath, '/'); if(p) { // got the filepart strcpy(szDocLongName, p+1); p[0] = 0; } // split the short part up p = strrchr(szDocShortPath, '.'); if(p && strrchr(szDocShortPath, '\\') < p && strrchr(szDocShortPath, '/') < p) { // got the extension strcpy(szDocShortExt, p+1); p[0] = 0; } p = strrchr(szDocShortPath, '\\'); if(!p) p = strrchr(szDocShortPath, '/'); if(p) { // got the filepart strcpy(szDocShortName, p+1); p[0] = 0; } int iSize = Commands.GetSize(), i = 0; char *ppParms[32]; while(iSize--) { CCOMMAND &cmd = Commands[i++]; // anything there? if((!cmd.szRun[0] && !cmd.iSpecialCmd) || !cmd.bEnable) continue; // set name pointers for long filenames pszDocExt = szDocLongExt; pszDocName = szDocLongName; pszDocPath = szDocLongPath; char szNewParms[MAX_PATH*5], szNewRun[MAX_PATH*5]; // HACK: force the spawnv call for launching the game if (!Q_stricmp(cmd.szRun, "$game_exe")) { cmd.bUseProcessWnd = FALSE; } FixGameVars(cmd.szRun, szNewRun, TRUE); FixGameVars(cmd.szParms, szNewParms, TRUE); CString strTmp; strTmp.Format("\r\n" "** Executing...\r\n" "** Command: %s\r\n" "** Parameters: %s\r\n\r\n", szNewRun, szNewParms); procWnd.Append(strTmp); // create a parameter list (not always required) if(!cmd.bUseProcessWnd || cmd.iSpecialCmd) { char *p = szNewParms; ppParms[0] = szNewRun; int iArg = 1; BOOL bDone = FALSE; while(p[0]) { ppParms[iArg++] = p; while(p[0]) { if(p[0] == ' ') { // found a space-separator p[0] = 0; p++; // skip remaining white space while (*p == ' ') p++; break; } // found the beginning of a quoted parameters if(p[0] == '\"') { while(1) { p++; if(p[0] == '\"') { // found the end if(p[1] == 0) bDone = TRUE; p[1] = 0; // kick its ass p += 2; // skip remaining white space while (*p == ' ') p++; break; } } break; } // else advance p ++p; } if(!p[0] || bDone) break; // done. } ppParms[iArg] = NULL; if(cmd.iSpecialCmd) { BOOL bError = FALSE; LPCTSTR pszError = ""; if(cmd.iSpecialCmd == CCCopyFile && iArg == 3) { RemoveQuotes(ppParms[1]); RemoveQuotes(ppParms[2]); // don't copy if we're already there if (stricmp(ppParms[1], ppParms[2]) && (!CopyFile(ppParms[1], ppParms[2], FALSE))) { bError = TRUE; pszError = GetErrorString(); } } else if(cmd.iSpecialCmd == CCDelFile && iArg == 2) { RemoveQuotes(ppParms[1]); if(!DeleteFile(ppParms[1])) { bError = TRUE; pszError = GetErrorString(); } } else if(cmd.iSpecialCmd == CCRenameFile && iArg == 3) { RemoveQuotes(ppParms[1]); RemoveQuotes(ppParms[2]); if(rename(ppParms[1], ppParms[2])) { bError = TRUE; pszError = strerror(errno); } } else if(cmd.iSpecialCmd == CCChangeDir && iArg == 2) { RemoveQuotes(ppParms[1]); if(mychdir(ppParms[1]) == -1) { bError = TRUE; pszError = strerror(errno); } } if(bError) { CString str; str.Format("The command failed. Windows reported the error:\r\n" " \"%s\"\r\n", pszError); procWnd.Append(str); procWnd.SetForegroundWindow(); str += "\r\nDo you want to continue?"; if(AfxMessageBox(str, MB_YESNO) == IDNO) break; } } else { // Change to the game exe folder before spawning the engine. // This is necessary for Steam to find the correct Steam DLL (it // uses the current working directory to search). char szDir[MAX_PATH]; Q_strncpy(szDir, szNewRun, sizeof(szDir)); Q_StripFilename(szDir); mychdir(szDir); // YWB Force asynchronous operation so that engine doesn't hang on // exit??? Seems to work. // spawnv doesn't like quotes RemoveQuotes(szNewRun); _spawnv(/*cmd.bNoWait ?*/ _P_NOWAIT /*: P_WAIT*/, szNewRun, (const char *const *)ppParms); } } else { procWnd.Execute(szNewRun, szNewParms); } // check for existence? if(cmd.bEnsureCheck) { char szFile[MAX_PATH]; FixGameVars(cmd.szEnsureFn, szFile, FALSE); if(GetFileAttributes(szFile) == 0xFFFFFFFF) { // not there! CString str; str.Format("The file '%s' was not built.\n" "Do you want to continue?", szFile); procWnd.SetForegroundWindow(); if(AfxMessageBox(str, MB_YESNO) == IDNO) break; // outta here } } } mychdir(szCurDir); s_bRunsCommands = false; return TRUE; }
/* * Process Response files on the command line * Returns true if it allocated a new argv array that must be freed later */ void ConsoleArgs::ProcessResponseArgs() { HRESULT hr; b_tree *response_files = NULL; WCHAR szFilename[MAX_PATH]; WCAllocBuffer textBuffer; for (WStrList * listCurArg = m_listArgs; listCurArg != NULL && !m_output->HadFatalError(); listCurArg = listCurArg->next) { WCHAR * szArg = listCurArg->arg; // Skip everything except Response files if (szArg == NULL || szArg[0] != '@') continue; if (wcslen(szArg) == 1) { m_output->ShowErrorIdString( ERR_NoFileSpec, ERROR_ERROR, szArg); goto CONTINUE; } // Check for duplicates if (!GetFullFileName( RemoveQuotes(WCBuffer::CreateFrom(&szArg[1])), szFilename, false)) continue; hr = TreeAdd(&response_files, szFilename); if (hr == E_OUTOFMEMORY) { m_output->ShowErrorId(FTL_NoMemory, ERROR_FATAL); goto CONTINUE; } else if (hr == S_FALSE) { m_output->ShowErrorIdString(ERR_DuplicateResponseFile, ERROR_ERROR, szFilename); goto CONTINUE; } FileType fileType; textBuffer.Clear(); if (FAILED(hr = ReadTextFile(szFilename, NULL, textBuffer, &fileType)) || hr == S_FALSE) { if (hr == E_OUTOFMEMORY) { m_output->ShowErrorId(FTL_NoMemory, ERROR_FATAL); } else if (FAILED(hr)) { if (fileType == ftBinary) m_output->ShowErrorIdString(ERR_BinaryFile, ERROR_ERROR, szFilename); else m_output->ShowErrorIdString(ERR_OpenResponseFile, ERROR_ERROR, szFilename, m_output->ErrorHR(hr)); } goto CONTINUE; } TextToArgs( textBuffer, &listCurArg->next); CONTINUE: // remove the response file argument, and continue to the next. listCurArg->arg = NULL; VSFree(szArg); } CleanupTree(response_files); }
TBool CExampleCookieManager::ValidateCookieL(CCookie& aCookie, const TUriC8& aUri) { THTTPHdrVal attributeVal; if(aCookie.Attribute(CCookie::EPath, attributeVal) == KErrNone) { // if the path attribute exists check it is a prefix of the path // of the uri that issued it (if not reject) RStringF cookiePath = attributeVal.StrF(); const TDesC8& uriPath = aUri.Extract(EUriPath); if(uriPath.FindF(RemoveQuotes(cookiePath.DesC())) != 0) return EFalse; } else { // if the path attribute doesn't exist add it THTTPHdrVal val(iStringPool.OpenFStringL(aUri.Extract(EUriPath))); aCookie.SetAttributeL(CCookie::EPath, val); } if(aCookie.Attribute(CCookie::EDomain, attributeVal) == KErrNone) { const TChar dot('.'); const TDesC8& cookieDomain = attributeVal.StrF().DesC(); const TDesC8& uriDomain = aUri.Extract(EUriHost); // if the domain does not exactly match the uri and does not begin // with a dot then add one if((cookieDomain.Compare(uriDomain) != 0) && (cookieDomain.Locate(dot) != 0)) { _LIT8(KAddDotString, ".%S"); HBufC8* newDomain = HBufC8::NewLC(cookieDomain.Length() + 1); newDomain->Des().AppendFormat(KAddDotString(), &cookieDomain); RStringF domain = iStringPool.OpenFStringL(*newDomain); CleanupStack::PopAndDestroy(newDomain); THTTPHdrVal val(domain); aCookie.SetAttributeL(CCookie::EDomain, val); domain.Close(); } // if the domain does not contain an embedded dot then reject it // ie reject .com or .com. // Start by removing one character from each end. ie start at pos 1 and take a length // which is 2 shorter than the original descriptor TPtrC8 domainMiddle = cookieDomain.Mid(1, cookieDomain.Length() - 2); if(domainMiddle.Locate(dot) == KErrNotFound) return EFalse; // Reject the cookie if the domain differs by two or more levels from the uri // ie if uri=www.x.y.com then accept a cookie with .x.y.com but reject .y.com TInt pos = uriDomain.FindF(cookieDomain); if(pos > 2) { const TDesC8& domainDiff = uriDomain.Left(pos); // Remove one character from each end. ie start at pos 1 and take a length // which is 2 shorter than the original descriptor const TDesC8& diffMiddle = domainDiff.Mid(1, domainDiff.Length() - 2); if(diffMiddle.Locate(dot) != KErrNotFound) return EFalse; } } else { // if the domain attribute is not found add it THTTPHdrVal val(iStringPool.OpenFStringL(aUri.Extract(EUriHost))); aCookie.SetAttributeL(CCookie::EDomain, val); val.StrF().Close(); } if(!CheckPortMatch(aCookie, aUri)) return EFalse; return ETrue; }