void RLog::Next(const TDesC &aHeading) { // Logs in the file and calls the "Next" function from RTest TBuf8 <256> Buffer; TBuf8 <1024> pHeading; pHeading.Copy(aHeading); if(aHeading.Length()){ Buffer.Copy(aHeading); if(pHeading.Mid(pHeading.Length() - 1, 1) == _L8("\n")){ Buffer.Insert(pHeading.Length() - 1, _L8("\r")); } else { Buffer.Append(_L("\r\n")); } file.Write(Buffer); } test->Next(aHeading); }
//------------------------------------------------------------------------------ // CAddBuffer::AddNodeToBuffer() //------------------------------------------------------------------------------ TInt CAddBuffer::GetGroup( const TDesC8& aRoot, RPointerArray<CConnMoNodeElement>* aGroup ) { OstTraceExt1( TRACE_NORMAL, CADDBUFFER_GETGROUP_ENTRY, "ENTRY: CAddBuffer::GetGroup;aRoot=%s", aRoot ); iCache.Reset(); TInt retval( KErrNotFound ); TBool first = ETrue; TBuf8<KSmlMaxURISegLen> groupTag; groupTag.Copy( aRoot ); groupTag.Append( KChildNodeWildCardPattern ); for ( TInt i = 0; i < iBuffer.Count(); ++i ) { if ( iBuffer[i]->iUri.Match( groupTag ) != KErrNotFound && !iBuffer[i]->iProcessed ) { if ( first ) { groupTag.Insert( aRoot.Length(), KNodeSeparator ); groupTag.Insert( aRoot.Length() + 1, CUtils::GetSecondURISeg( iBuffer[i]->iUri ) ); first = EFalse; retval = 0; } TInt err = KErrNone; TRAP(err,aGroup->AppendL(iBuffer[i])); if(err != KErrNone) { retval = err; break; } TRAP(err,iCache.AppendL(iBuffer[i])); if(err != KErrNone) { TInt indx = aGroup->Find(iBuffer[i]); if(indx != KErrNotFound) aGroup->Remove(indx); retval = err; break; } retval++; } } OstTrace1( TRACE_NORMAL, CADDBUFFER_GETGROUP_EXIT, "EXIT: CAddBuffer::GetGroup;retval=%d", retval ); return retval; }
HBufC8* CPolicyPatchInfo::CheckSubjectNameSyntaxL(const TDesC8& aSubj) { const TInt KMaxSubjectItems = 20; _LIT8(KEqualSign, "="); _LIT8(KCommaSign, ","); _LIT8(KReplacementChar, "\""); //counts positions for equal sign characters CArrayFixFlat<TInt>* equalSignArr=new (ELeave) CArrayFixFlat<TInt> (KMaxSubjectItems); //counts positions for comma characters CArrayFixFlat<TInt>* commaSignArr=new (ELeave) CArrayFixFlat<TInt> (KMaxSubjectItems); //counts positions for double quatiation characters CArrayFixFlat<TInt>* updateArr=new (ELeave) CArrayFixFlat<TInt> (KMaxSubjectItems); TInt subjLth=aSubj.Length(); TInt equalArrItemCount=0; TInt commaArrItemCount=0; TInt updateArrCount=0; CleanupStack::PushL(equalSignArr); CleanupStack::PushL(commaSignArr); //register '=' and ',' character positions for (TInt i=0; i<subjLth; i++) { if ( aSubj.Mid(i, 1)== KEqualSign ) { equalSignArr->AppendL(i); equalArrItemCount++; } if ( aSubj.Mid(i, 1)== KCommaSign ) { commaSignArr->AppendL(i); commaArrItemCount++; } } CleanupStack::PushL(updateArr); TInt i=0; TInt j=0; // At least one comma required. Otherwise there is no chance for extra commas if ( commaArrItemCount ) { while ( i< equalArrItemCount ) { //advance starting position for every iteration TInt eqSignStartIndex=i; TInt cmCount=0; //check wether there is more than one comma between two adjacent fields. while ( commaSignArr->At(j)< equalSignArr->At(eqSignStartIndex) ) { cmCount++; j++; if ( j==commaArrItemCount ) break; } //at least one extra comma character found. Mark positions for mofifications. if (cmCount>1) { TInt equalPos=equalSignArr->At(eqSignStartIndex-1) + 1; updateArr->AppendL(equalPos); TInt commaPos=commaSignArr->At(j-1); updateArr->AppendL(commaPos); updateArrCount++; updateArrCount++; } i++; } } //Checking also last attribute of Subject Name string if ( j<commaArrItemCount ) { updateArr->AppendL(equalSignArr->At(equalArrItemCount-1) + 1); updateArr->AppendL(subjLth); updateArrCount++; updateArrCount++; } TBuf8<256> resultBuf; resultBuf.Copy(aSubj); i=0; //update subjectname acoording to updateArr array. if ( updateArr->Count()>0 ) { while (i<updateArrCount) { if ( resultBuf.Length()<256 ) resultBuf.Insert(updateArr->At(i) + i, KReplacementChar); else User::Leave(KErrNotSupported); i++; } } CleanupStack::Pop(updateArr); CleanupStack::Pop(commaSignArr); CleanupStack::Pop(equalSignArr); delete equalSignArr; equalSignArr=NULL; delete commaSignArr; commaSignArr=NULL; delete updateArr; updateArr=NULL; HBufC8* resultHeap = resultBuf.AllocL(); return resultHeap; }
// ---------------------------------------------------------------------------------------- // CFMSServer::ReadFromFile() // ---------------------------------------------------------------------------------------- TBool CFMSServer::ReadFromFile(TInt& aReason, TInt& aBearer, TInt& aDrive, TInt& aSize , TInt& aWcdmaBearer ) { TInt err = iFile.Open(iFs,KFotaInterruptFileName,EFileRead); FLOG(_L("CFMSServer::ReadFromFile() error as %d"),err); if(err == KErrNone) { TInt size = KErrNone; err = iFile.Size(size); if(size == 0) //file empty { FLOG(_L("CFMSServer::ReadFromFile() file size is empty")); iFile.Close(); return EFalse; } TBuf8<30> data; iFile.Read(data); iFile.Close(); TBuf8<30> data1; if(data.Length()>0) { TInt len =0 ; if((len=data.LocateF(',')) > 0) { TLex8 value( data.Left(len)); value.Val(aReason); FLOG(_L("CFMSServer::ReadFromFile() retrieving reason as %d"),aReason); data1.Insert(0,data.Right(data.Length()-(len+1))); data.Zero(); // len=data1.LocateF(','); if( data1.Length() > 0 && (len=data1.LocateF(',')) > 0) { value=data1.Left(len); value.Val(aBearer); FLOG(_L("CFMSServer::ReadFromFile() retrieving aBearer as %d"),aBearer); data.Insert(0,data1.Right(data1.Length()-(len+1))); data1.Zero(); // len=data.LocateF(','); if(data.Length() > 0 && ( len=data.LocateF(','))> 0) { value=data.Left(len); value.Val(aDrive); FLOG(_L("CFMSServer::ReadFromFile() retrieving aDrive as %d"),aDrive); data1.Insert(0,data.Right(data.Length()-(len+1))); data.Zero(); if(data1.Length() > 0 && ( len=data1.LocateF(','))> 0 ) { value=data1.Left(len); value.Val(aSize); FLOG(_L("CFMSServer::ReadFromFile() retrieving aSize as %d"),aSize); data.Insert(0,data1.Right(data1.Length()-len-1)); data1.Zero(); if(data.Length() > 0 ) { value=data; value.Val(aWcdmaBearer); FLOG(_L("CFMSServer::ReadFromFile() retrieving aWcdmaBearer as %d"),aWcdmaBearer); } } } } } } } else { return EFalse; } return ETrue; }