TInt CCmdSetPrompt::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD( error, param.Set( ParamsL( aCommand )) ); if ( error != KErrNone ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); TLex parse( param ); if ( !parse.Eos() && !parse.Peek().IsSpace() ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); // ParseOnly => not executed. if ( Family()->Switch(CCmdFamily::EParseOnly) ) return error; // Alter prompt, back to the default one if no new one. param.Set( TfrLex::TrimAndPeel( param ) ); if ( param.Length() == 0 ) param.Set(THA_CommandPrompt); if ( error = Machine()->SetPrompt( param ), error != KErrNone ) // ### Failure Log( TFR_KFmtErrFailed, &Keyphrase(), error ); return error; }
TInt CCmdPause::ProcessL(const TDesC& aCommand) { TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); } TLex parse( param ); if (!parse.Eos() && !parse.Peek().IsSpace()) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); } // ParseOnly => not executed. if (Family()->Switch(CCmdFamily::EParseOnly)) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return error; } // Ask any key, prompt is either param or a default. param.Set( TfrLex::TrimAndPeel(param)); if (param.Length() == 0) param.Set(TFR_KTxtMsgPressAnyKey); Machine()->Pause(param); return error; }
TInt CCmdLogPath::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD( error, param.Set( ParamsL( aCommand )) ); if ( error != KErrNone ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); TLex parse( param ); if ( !parse.Eos() && !parse.Peek().IsSpace() ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); // Set log file path. param.Set( TfrLex::TrimAndPeel( param ) ); // if ( error = Machine()->SetLogPath( param ), error != KErrNone ) { // Failed if ( error == KErrArgument ) // Bad arguments Log( TFR_KFmtErrParams, &Keyphrase() ); else // Other errors Log( TFR_KFmtErrFailed, &Keyphrase(), error ); } return error; }
TInt CCmdPrint::ProcessL(const TDesC& aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); TLex parse(param); if ( !parse.Eos() && !parse.Peek().IsSpace() ) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); // ParseOnly => not executed. if (Family()->Switch(CCmdFamily::EParseOnly)) return error; iCurEchoMode = Machine()->EchoMode(); Machine()->SetEchoMode(EFalse); // Print out the param text. param.Set(TfrLex::TrimAndPeel(param)); //Print(param, EFalse); Print(param, ETrue); //Print(param.Mid(6), EFalse); // reset the echo mode to that of before this command! Machine()->SetEchoMode(iCurEchoMode); return error; }
TInt CCmdEndTransaction::ProcessL(const TDesC& aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC transname; TInt error = KErrNone; if (( error = ParseCmdArgs( aCommand, transname)) != KErrNone) return error; CAnyObject *obj = (CAnyObject *)Machine()->Domains()->Name(transname); if ((obj == NULL) || (obj->Tag() != THA_KHTTP_Transaction)) return Error(KErrArgument, THA_KErrInvalidTransaction, &transname); CTestTransaction *transaction = (CTestTransaction *) obj->Ptr(); transaction->CloseTransaction(); delete transaction; Machine()->Domains()->Delete(transname); return error; }
TInt CCmdSetPath::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); TLex parse( param ); if ( !parse.Eos() && !parse.Peek().IsSpace() ) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); // Set the command file path. param.Set( TfrLex::TrimAndPeel(param)); error = Machine()->SetCmdPath(param); switch (error) { // Bad argument case KErrArgument : Log(TFR_KFmtErrParams, &Keyphrase()); break; case KErrNone : break; // Other errors default : Log(TFR_KFmtErrFailed, &Keyphrase(), error); break; } return error; }
TInt CCmdShowTransaction::ProcessL(const TDesC& aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TInt error = KErrNone; TRAP(error, param.Set( ParamsL(aCommand))); if (error != KErrNone) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); CObjCatalogue *trnsctns = Machine()->Domains(); TInt iTrans = 0; Log(_L("\tCurrent Transactions:")); Log(_L("\tName \tMethod \tURI")); for (TInt i = 0; i < trnsctns->Count(); ++i) { CAnyObject *obj = (CAnyObject *)trnsctns->At(i); if (obj->Tag() == THA_KHTTP_Transaction) { TPtrC label = obj->Name(); TInt eStrIndex = obj->Index(); CTestTransaction *trans = (CTestTransaction *)obj->Ptr(); TBuf<256> uri; uri.Copy (trans->Uri()) ; TPtrC mthd; switch (eStrIndex) { case HTTP::EGET : mthd.Set(THA_TxtCmdTransactionGET); break; case HTTP::EPOST : mthd.Set(THA_TxtCmdTransactionPOST); break; case HTTP::EPUT : mthd.Set(THA_TxtCmdTransactionPUT); break; case HTTP::EDELETE : mthd.Set(THA_TxtCmdTransactionDELETE); break; case HTTP::EHEAD : mthd.Set(THA_TxtCmdTransactionHEAD); break; case HTTP::EOPTIONS : mthd.Set(THA_TxtCmdTransactionOPTIONS); break; case HTTP::ETRACE : mthd.Set(THA_TxtCmdTransactionTRACE); break; default : break; } ++iTrans; // if (trans->iState == CTestTransaction::EActive) if (trans->State() == CTestTransaction::EActive) { Log(_L("\t%d\t%S\t%S\t%S"), iTrans, &label, &mthd, &uri); } } } if (iTrans == 0) Log(_L("\tNo transactions have been defined")); return KErrNone; }
TInt CCmdDisconnect::ProcessL(const TDesC& aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TInt error; TPtrC conname; if (( error = ParseCmdArgs( aCommand, conname )) != KErrNone) return error; // Check if the connection already is defined. // If it is return error, if not create a session and ptr! CAnyObject *obj = (CAnyObject *) Machine()->Domains()->Name(conname); // at this point we can find the session that the disconnect refers to // in the Session, save disconnects eventhandler. if (obj != NULL) // connection (name) exists { // get reference to list in CmdConnect from Family and retrieve the reference to the session CCmdConnect *iConnect = (CCmdConnect *)Family()->Command(THA_KHTTP_Connect); iConnect->DisconnectL(conname); TBool frmwrk = ((CFrmwrkSession *) obj->Ptr())->UseWSPProtocol() ; if (!frmwrk) // HTTP Session so complete request { // check that there are no existing transactions (live) for this session // and that the session is not already closed (i.e. in error) //XXXXXXX iConnect->Delete(conname); Machine()->Domains()->Delete(conname); // what about the iSessionIndex - this is going to be problematic since we need to track the // index into the session when it changes... WriteDateStamp(); Log(_L("\tConnection '%S' has been disconnected!"), &conname); } else { Log(_L("Issued DisconnectL")); } } else return Error(KErrNotFound, THA_KErrConnectionErr, &conname); if ( error != KErrNone ) Log(TFR_KFmtErrFailed, &Keyphrase(), error); return error; }
TInt CCmdCall::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD( error, param.Set( ParamsL( aCommand )) ); if ( error != KErrNone ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); TLex parse( param ); if ( !parse.Peek().IsSpace() ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); // Extract command file name. parse = TfrLex::Trim( param ); TPtrC file; TRAP(error,file.Set(TfrLex::GetL(parse))); if ( error != KErrNone ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); file.Set(TfrLex::PeelAndTrim(file)); if ( file.Length() == 0 ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); // The remainder contains optional arguments TPtrC args = TfrLex::Trim(parse.Remainder()); // Before calling the command file, do check that the argument list // is lexically correct and that there are not too many of them.... TPtrC argv; TInt argc = -1; do { argc++; TRAP(error, argv.Set(TfrLex::GetL(parse))); } while ( error == KErrNone && argv.Length() > 0 ); // Well, how was it? if ( error != KErrNone || argc > TFR_MAX_CALL_ARGUMENTS ) { if ( error == KErrNone ) error = KErrArgument; return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); } // Call the command file with the argument list. error = Machine()->CallCmdFile(file, args); if (error != KErrNone ) // ### Failure Log( TFR_KFmtErrFailed, &Keyphrase(), error ); return error; }
TInt CCmdConnect::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC framework; TPtrC conname; TInt error; if (( error = ParseCmdArgs( aCommand, framework, conname )) != KErrNone) return error; if (conname.Size() != 0) { // Check if the connection already is defined. // If it is return error, if not create a session and ptr! CAnyObject *cnx = (CAnyObject *)Machine()->Domains()->Name(conname); if (cnx != NULL) // already exists return Error(KErrAlreadyExists, THA_KErrCnxionExists, &conname); else { CFrmwrkSession *cithc = CFrmwrkSession::NewLC(conname, framework, Machine()); cithc->iEventDispatcher = iEventDispatcher ; TRAPD(error, cithc->OpenL()); if (error == KErrNone) { cithc->SetPropertiesL(); TRAP(error, cithc->ConnectL()); if (error == KErrNone) { // now create reference to name in domains // note: the value is 1 for HTTP and 0 for WSP Machine()->Domains()->AddL(conname, 0, THA_KHTTP_Connect, (TAny *) cithc); WriteDateStamp(); Log(_L("Connection '%S' has been opened!"), &conname); } else Error(error, KTxtErrConnectFailed); } CleanupStack::Pop(); // cithc } } else { (void) ShowSessions () ; } return error; }
TInt CCmdHold::ProcessL( const TDesC& aCommand ) { TPtrC param; TRAPD( error, param.Set( ParamsL( aCommand )) ); if ( error != KErrNone ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return Error(error, TFR_KFmtErrBadCmd, &Keyphrase() ); } TLex parse( param ); if ( !parse.Eos() && !parse.Peek().IsSpace() ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); } // Param must be integer. If no param then default is 1 second. param.Set( TfrLex::TrimAndPeel(param) ); parse = param; TInt n; if ( parse.Eos() ) n = 1; else if (parse.Val(n) != KErrNone || !parse.Eos()) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); } // ParseOnly => not executed! if (Family()->Switch(CCmdFamily::EParseOnly) ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); return error; } // Hold processing for n seconds. TTimeIntervalMicroSeconds32 microseconds; microseconds = 1000000 * n; Machine()->Hold(microseconds); return error; }
void Game::Update(float a) { _delta = a; if (_delta <= 0 || _delta > 60) _delta = 0.001f; Machine(SIGNAL_UPDATE); }
void CTestTransaction::Log(TRefByValue<const TDesC> aFmt, ... ) { VA_LIST list; VA_START(list, aFmt); Machine()->MsgPrintfln(aFmt, list); }
void CTestTransaction::WriteDateStamp(const TDateTime &aDate) { TDateTime date; TTime now; TBool iEOL = (aDate.Year() == K_OUTOFBOUNDS_YEAR); if (iEOL) { now.HomeTime(); date = now.DateTime(); } else date = aDate; TTime t(date); TBuf<128> dateTimeString; TRAPD(err, t.FormatL(dateTimeString, KDateFormat)); if (err == KErrNone) { if (iEOL) Machine()->MsgPrintf(_L("[%S] "), &dateTimeString); else Log(_L("[%S]\r\n"), &dateTimeString); } }
TInt CTestTransaction::Error( TInt aError, TRefByValue<const TDesC> aFmt, ... ) { VA_LIST list; VA_START(list, aFmt); Machine()->MsgPrintfln(aFmt, list); return aError; }
void CCmdConnect::DisconnectL(const TDesC& aLabel) { CAnyObject *obj = (CAnyObject *)Machine()->Domains()->Name(aLabel); CFrmwrkSession *frmwk = (CFrmwrkSession *) obj->Ptr(); TPtrC myName = frmwk->Name() ; Log(_L("CCmdConnect::DisconnectL, Session %S"), &myName); frmwk->DisconnectL(); }
TInt CCmdRemark::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); if (!Recognize(aCommand)) return Error(KErrArgument, TFR_KFmtErrBadCmd, &Keyphrase()); // Do nothing. return KErrNone; }
TInt CCmdElse::ProcessL(const TDesC &aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(ret, param.Set(ParamsL(aCommand))); if (ret != KErrNone) return Error(ret, KFmtErrInvalidCmd, &Keyphrase()); // determine what the state is and if already in an IF, need to increment the IF counter! //Machine()->UpdateIFState(CIFControl::EInELSE); Machine()->SetIfState(CIFControl::EInELSE); // expect endif next //TBool iResult = (iIFPile->Peek()) ? (iIFPile->Peek())->GetIFResult() : EFalse; //Machine()->SetIfMode(CIFControl::EENDIF, iResult); return ret; }
TBool CTestTransaction::AddAcceptHeaderL(RHTTPHeaders &aHeaders, RStringPool &aStrPool) { // some tests may require specific 'Accept' parameters TBuf8<KMaxAcceptLengthSize> acceptBuf; acceptBuf.Copy(Machine()->GetDefine(KITHAccept)); RStringF accept = (acceptBuf.Length() == 0) ? aStrPool.StringF(HTTP::EAnyAny, RHTTPSession::GetTable()) : aStrPool.OpenFStringL(acceptBuf); THTTPHdrVal acceptHdr(accept); aHeaders.SetFieldL(aStrPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), acceptHdr); accept.Close(); return ETrue; }
TInt CCmdListAll::ProcessL(const TDesC& aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); if (!Recognize(aCommand)) return Error(KErrArgument, TFR_KFmtErrBadCmd, &Keyphrase()); // List commands out Family()->ListAll(Console()); return KErrNone; }
TInt CCmdReturn::ProcessL(const TDesC& aCommand) { // Complete the test machine Machine()->CompleteRequest(); TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); TLex parse(param); parse.SkipSpace(); if (!parse.Eos()) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); // Return from the current command file error = Machine()->CloseCmdFile(); if (error != KErrNone) Log(TFR_KFmtErrFailed, &Keyphrase(), error); return error; }
TInt CCmdEndIf::ProcessL(const TDesC& aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(ret, param.Set(ParamsL(aCommand))); if (ret != KErrNone) return Error(ret, KFmtErrInvalidCmd, &Keyphrase()); // clearing the end if block is actually not as simple as at first // might be thought. we should get the 'machine' to verify that // the endif is appropriate (i.e. we are not reading an endif within // a step'd over clause // probably academic now! //Machine()->SetIfState(CIFControl::EIgnoreIF); Machine()->EndIf(); return ret; }
TInt CCmdEndLog::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD( error, param.Set( ParamsL( aCommand )) ); if ( error != KErrNone ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); TLex parse( param ); parse.SkipSpace(); if ( !parse.Eos() ) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() ); // Close present log file if ( error = Machine()->CloseLogFile(), error != KErrNone ) // ### Failure Log( TFR_KFmtErrFailed, &Keyphrase(), error ); return error; }
TInt CCmdExit::ProcessL(const TDesC &aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone ) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); TLex parse( param ); if (!parse.Eos() && !parse.Peek().IsSpace()) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase()); // Print out param if any and stop. param.Set( TfrLex::Peel(param)); if (param.Length() > 0) Print(param); Machine()->StopEngine(); return error; }
TInt CCmdLogFile::ProcessL( const TDesC& aCommand ) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); TLex parse(param); if (!parse.Peek().IsSpace()) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); // Open log file. param.Set(TfrLex::TrimAndPeel(param)); error = Machine()->OpenLogFile(param); if (error != KErrNone) // ### Failure Log(TFR_KFmtErrFailed, &Keyphrase(), error); return error; }
TBool CTestTransaction::SetContentLengthL(RHTTPHeaders &aHeaders, RStringPool &aStrPool) { TBuf8<KMaxContentLengthSize> contLengthBuf; contLengthBuf.Copy(Machine()->GetDefine(KITHContentLength)); if (contLengthBuf.Length() != 0) { RStringF contLengthStr = aStrPool.OpenFStringL(contLengthBuf); THTTPHdrVal contLength(contLengthStr); aHeaders.SetFieldL(aStrPool.StringF(HTTP::EContentLength, RHTTPSession::GetTable()), contLength); contLengthStr.Close(); } return ETrue; }
TBool CTestTransaction::AcceptEncodingL(RHTTPHeaders &aHeaders, RStringPool &aStrPool) { TBuf8<KMaxAcceptEncodingSize> acceptEncodingBuf; acceptEncodingBuf.Copy(Machine()->GetDefine(KITHAcceptEncoding)); if (acceptEncodingBuf.Length() > 0) { RStringF acceptEncoding = aStrPool.OpenFStringL(acceptEncodingBuf); THTTPHdrVal acceptEncodingHdr(acceptEncoding); aHeaders.SetFieldL(aStrPool.StringF(HTTP::EAcceptCharset, RHTTPSession::GetTable()), acceptEncodingHdr); acceptEncoding.Close(); } return ETrue; }
int set_ncpus( struct pbsnode *current, struct pbsnode *parent, int ncpus) { int difference; int i; int orig_svr_clnodes; if (current == NULL) return(PBSE_BAD_PARAMETER); difference = ncpus - current->nd_slots.get_total_execution_slots(); orig_svr_clnodes = svr_clnodes; for (i = 0; i < abs(difference); i++) { if (difference > 0) { add_execution_slot(current); svr_clnodes++; } else if (difference < 0) { delete_a_subnode(current); svr_clnodes--; } } if (difference < 0) { snprintf(log_buffer, sizeof(log_buffer), "ncpus was reduced from %d to %d", orig_svr_clnodes, svr_clnodes); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_NODE, __func__, log_buffer); } else if (current->nd_slots.get_total_execution_slots() > parent->max_subnode_nppn) parent->max_subnode_nppn = current->nd_slots.get_total_execution_slots(); #ifdef PENABLE_LINUX_CGROUPS if (current->nd_layout.getTotalThreads() != current->nd_slots.get_total_execution_slots()) { current->nd_layout = Machine(current->nd_slots.get_total_execution_slots()); } #endif return(PBSE_NONE); } /* END set_ncpus() */
void CTestTransaction::DumpResponseBody(RHTTPTransaction &aTrans) { MHTTPDataSupplier *body = aTrans.Response().Body(); TPtrC8 dataChunk; TBool isLast = body->GetNextDataPart(dataChunk); Machine()->DumpData(dataChunk); if (isLast)// && !iEngine->IsSilent()) { // date stamp the response WriteDateStamp(); Log(_L(" - Got last data chunk.")); } body->ReleaseData(); }
TBool CTestTransaction::SetUserAgentL(RHTTPHeaders &aHeaders, RStringPool &aStrPool) { // get the DEFINE for UserAgent TBuf8<KMaxUserAgentSize> userAgentBuf; userAgentBuf.Copy(Machine()->GetDefine(KITHUserAgent)); TInt iLen = userAgentBuf.Length(); // assign the selection RStringF agent = (iLen == 0) ? aStrPool.OpenFStringL(KUserAgent) : aStrPool.OpenFStringL(userAgentBuf); THTTPHdrVal userAgent(agent); aHeaders.SetFieldL(aStrPool.StringF(HTTP::EUserAgent, RHTTPSession::GetTable()), userAgent); agent.Close(); return ETrue; }