/** * Method for setting a specific descriptor (from settings file) to attribute structure * * @param aSetting * @param aName */ void CPwrPlugin::SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex) { // find the equal mark from the setting line TInt sepPos = aSetting.Find(KSettingItemSeparator); // check that '=' is found if (sepPos > 0) { // check that the element matches if (aSetting.Left(sepPos).CompareF(KEnabled) == 0) { TBool en; CSamplerPluginInterface::Str2Bool(aSetting.Right(aSetting.Length()-sepPos-1), en); if(en != iSamplerAttributes->At(aIndex).iEnabled) { iSamplerAttributes->At(aIndex).iEnabled = en; } } else if (aSetting.Left(sepPos).CompareF(KSamplingPeriodMs) == 0) { TInt sr; CSamplerPluginInterface::Str2Int(aSetting.Right(aSetting.Length()-sepPos-1), sr); if(sr != iSamplerAttributes->At(aIndex).iSampleRate) { iSamplerAttributes->At(aIndex).iSampleRate = sr; } } } }
void WRITE_VALUES(const TDesC8& lhs, const TDesC8& rhs) { TBuf<100> b; b.Copy(lhs.Left(100)); output->Write(b); output->Write(_L(" ")); b.Copy(rhs.Left(100)); output->Write(b); }
void CSenPropertiesElement::Set( const TDesC8& aNamespaceURI, const TDesC8& aLocalName, const TDesC8& aQName ) { if ( !ipStringPool ) { CSenXmlElement::Set(aNamespaceURI, aLocalName, aQName); } else { RString localName; TInt leaveCode(KErrNone); TRAP( leaveCode, localName = ipStringPool->OpenStringL(aLocalName); ) if( !leaveCode ) { iLocalName.Close(); iLocalName = localName; TPtrC8 prefix(KNullDesC8); if(aQName != KNullDesC8) { TInt colon(KErrNotFound); colon = aQName.Locate(':'); if(colon!=KErrNotFound) { prefix.Set(aQName.Left(colon)); } } TRAP( leaveCode, SetNamespaceL(prefix, aNamespaceURI); )
//returns >0 or CONNERR. int Syscall::httpCreateConnectionLC(const TDesC8& parturl, CHttpConnection*& conn, int method, SocketType socketType) { int port_m1_index = parturl.Locate(':'); int path_index = parturl.Locate('/'); if(path_index == KErrNotFound) { return CONNERR_URL; } if(port_m1_index > path_index) { port_m1_index = KErrNotFound; } TPtrC8 path(parturl.Mid(path_index)); int hostname_length; TUint16 port; if(port_m1_index == KErrNotFound) { port = (socketType == SSL) ? 443 : 80; hostname_length = path_index; } else { TLex8 portLex(parturl.Mid(port_m1_index + 1, path_index - (port_m1_index + 1))); hostname_length = port_m1_index; if(portLex.Val(port, EDecimal) != KErrNone) { return CONNERR_URL; } } TPtrC8 hostname(parturl.Left(hostname_length)); conn = new (ELeave) CHttpConnection(createSocket(socketType), method, port, gHttpStringPool); CleanupStack::PushL(conn); conn->ConstructL(hostname, path); return 1; }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CImeiSettings::MakeListboxL(const TDesC8& aType,const TDesC8& aData,const TDesC& aExtension) { iListBox = new (ELeave) CImeiSettingsListListbox(); iListBox->ConstructFromResourceL(R_MYTYPE_SETTING); iListBox->MakeVisible(ETrue); iListBox->SetRect(CEikonEnv::Static()->EikAppUi()->ClientRect()); iListBox->ActivateL(); TInt i =0; for(i = 0; i < aType.Length(); i++) { if(aType[i] == 47) break; } if(i < aType.Length()) { iListBox->iType.Copy(aType.Left(i)); iListBox->iTypeId.Copy(aType.Right(aType.Length() - (i+1))); } else { iListBox->iType.Copy(aType); } iListBox->iExtension.Copy(aExtension); iListBox->LoadSettingsL(); iListBox->DrawNow(); }
/** @SYMTestCaseID SYSLIB-CHARCONV-CT-0536 @SYMTestCaseDesc Splitting and converting from Unicode to EucJpPacked test @SYMTestPriority Medium @SYMTestActions Tests for conversion after splitting, from Unicode to EucJpPacked and back to Unicode @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void CT_EUCJP_PACKED_2::TestSplittingConvertingFromUnicodeToEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfEucJpPacked, const TDesC8& aExpectedEucJpPacked, const TDesC16& aOriginalUnicode) { INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0536 ")); test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); test(aMaximumLengthUpperLimit<=KBufferLength); TUint8 eucJpPackedBuffer[KBufferLength]; for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) { TPtr8 generatedFirstPartOfEucJpPacked(eucJpPackedBuffer, i); test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfEucJpPacked, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit); test(generatedFirstPartOfEucJpPacked==aExpectedEucJpPacked.Left(aExpectedLengthOfFirstPartOfEucJpPacked)); TBuf8<KBufferLength> generatedSecondPartOfEucJpPacked; test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfEucJpPacked, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0); test(generatedSecondPartOfEucJpPacked==aExpectedEucJpPacked.Mid(aExpectedLengthOfFirstPartOfEucJpPacked)); TInt state=CCnvCharacterSetConverter::KStateDefault; TBuf16<KBufferLength> generatedUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfEucJpPacked, state)==0); test(state==CCnvCharacterSetConverter::KStateDefault); TBuf16<KBufferLength> generatedSecondPartOfUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfEucJpPacked, state)==0); test(state==CCnvCharacterSetConverter::KStateDefault); generatedUnicode.Append(generatedSecondPartOfUnicode); test(generatedUnicode==aOriginalUnicode); } }
// ---------------------------------------------------------------------------------------- // CTerminalControlServer::FindLocalProcessInfoL // ---------------------------------------------------------------------------------------- CTerminalControlServer::TTcProcessInfo CTerminalControlServer::FindLocalProcessInfoL ( const TDesC8 &aProcessName ) { RDEBUG("CTerminalControlServer::FindLocalProcessInfoL"); TInt processCount = iProcessInfoArray->Count(); if(processCount == 0) { User::Leave( KErrNotFound ); } if(aProcessName.Length() < KFormatProcessNamePrefix().Length()+1) { User::Leave(KErrNotFound); } if(aProcessName.Left( KFormatProcessNamePrefix().Length() ).Compare(KFormatProcessNamePrefix) != KErrNone) { User::Leave(KErrNotFound); } // // Get process index from the name // TInt index; TLex8 lex; lex.Assign( aProcessName ); lex.Inc( KFormatProcessNamePrefix().Length() ); User::LeaveIfError( lex.Val(index) ); index --; if(index < 0 || index >= processCount) { User::Leave( KErrNotFound ); } return iProcessInfoArray->At(index); }
EXPORT_C TATParam::TATParam(const TDesC8& aValue, TATParamType aType) : iValueInt(0), iType(aType) { iValue.Copy(aValue.Left(iValue.MaxLength())); // to prevent panic for exceeding iValue length iValue.Trim(); if (EATDQStringParam == aType) AddDQ(); TRACE_INFO((_L8("param type %d, '%S'"), iType, &iValue)) }
// ------------------------------------------------------------------------------------------------ // TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI) // removes property from the uri // ------------------------------------------------------------------------------------------------ TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI) { TInt offset = aURI.Find(KNSmlDmQuestionMark); if(offset!=KErrNotFound) { return aURI.Left(offset); } return aURI; }
TBool CExampleResolver::Match(const TDesC8& aImplementationType, const TDesC8& aMatchType, TBool aUseWildcards) const { TInt matchPos = KErrNotFound; _LIT8(dataSeparator, "||"); const TInt separatorLength = dataSeparator().Length(); // Look for the section separator marker '||' TInt separatorPos = aImplementationType.Find(dataSeparator); if(separatorPos == KErrNotFound) { // Match against the whole string if(aUseWildcards) matchPos = aImplementationType.Match(aMatchType); else matchPos = aImplementationType.Compare(aMatchType); } else { // Find the first section, up to the separator TPtrC8 dataSection = aImplementationType.Left(separatorPos); TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength); // Match against each section in turn while(separatorPos != KErrNotFound) { // Search this section if(aUseWildcards) matchPos = dataSection.Match(aMatchType); else matchPos = dataSection.Compare(aMatchType); // If we found it then no need to continue, so return if(matchPos != KErrNotFound) return ETrue; // Move on to the next section separatorPos = remainingData.Find(dataSeparator); if(separatorPos != KErrNotFound) { dataSection.Set(remainingData.Left(separatorPos)); remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); } else dataSection.Set(remainingData); } // Check the final part if(aUseWildcards) matchPos = dataSection.Match(aMatchType); else matchPos = dataSection.Compare(aMatchType); } return matchPos != KErrNotFound; }
void CConfigRecognizer::DoRecognizeL(const TDesC & /*aName*/, const TDesC8 &aBuffer) { if ( aBuffer.Length() < KIdLength ) { return; } if ( aBuffer.Left(KIdLength).Compare(KSettingsId) ) { return; } iConfidence = ECertain; iDataType = TDataType(KMIMEType); }
// ----------------------------------------------------------------------------- // CSdpOriginField::Get63Msbs // Returns a maximum of 63 bits of information from the descriptor containing a // decimal number. // ----------------------------------------------------------------------------- // TInt64 CSdpOriginField::Get63Msbs( const TDesC8& aDecimalValue ) const { // The maximum amount of digits in a decimal number, that is guaranteed to // fit into 63 bits, is 18. Even if all the 18 digits are 9, the decimal // number is 999999999999999999. const TInt64 KMaxAmountOfDecimalDigits = 18; TInt64 value( 0 ); TPtrC8 msbPart = aDecimalValue.Left( KMaxAmountOfDecimalDigits ); TLex8( msbPart ).Val( value ); return value; }
DMAD_EXPORT_C TPtrC8 TDmAdUtil::RemoveLastUriSeg(const TDesC8& aUri) { TInt i; for (i=aUri.Length()-1; i>=0; i--) { if (aUri[i] == '/') { break; } } return aUri.Left(i); }
TBool CSocketEngine::GetSHttpConnStatus(const TDesC8& aDesc){ if(aDesc.Length()>0){ TPtrC8 tmp; tmp.Set(aDesc.Left(30)); if(tmp.FindF(_L8("200"))!=KErrNotFound||tmp.FindF(_L8("206"))!=KErrNotFound||tmp.FindF(_L8("301"))!=KErrNotFound||tmp.FindF(_L8("302"))!=KErrNotFound){ return ETrue; }else{ return EFalse; } }else{ return EFalse; } }
TBool CAiwResolver::MatchServiceCmd(const TDesC8& aOpaqueData, const TDesC8& aServiceCmd) const { _LIT8(dataSeparator, "||"); const TInt separatorLength = dataSeparator().Length(); // Look for the section separator marker '||' TInt separatorPos = aOpaqueData.Find(dataSeparator); if (separatorPos == KErrNotFound) { if (aServiceCmd.Compare(aOpaqueData) == 0) { return ETrue; } } else { // Find the first section, up to the separator TPtrC8 dataSection = aOpaqueData.Left(separatorPos); TPtrC8 remainingData = aOpaqueData.Mid(separatorPos + separatorLength); // Match against each section in turn while (separatorPos != KErrNotFound) { if (dataSection.Compare(aServiceCmd) == 0) { return ETrue; } // Move on to the next section separatorPos = remainingData.Find(dataSeparator); if (separatorPos != KErrNotFound) { dataSection.Set(remainingData.Left(separatorPos)); remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); } else { dataSection.Set(remainingData); } } if (dataSection.Compare(aServiceCmd) == 0) { return ETrue; } } return EFalse; }
// ----------------------------------------------------------------------------- // TSdpRtpmapValue::DecodeL // Decodes string and puts it into parts // ----------------------------------------------------------------------------- // EXPORT_C TSdpRtpmapValue TSdpRtpmapValue::DecodeL( const TDesC8& aText ) { __ASSERT_ALWAYS(aText.Length() > 0 && aText.Locate( KSlashChar ) != KErrNotFound, User::Leave(KErrSdpCodecMediaAttributeField)); TInt length( aText.Length() ); if ( aText[length - 1] == KLFChar ) { if ( length > 1 && aText[length - 2] == KCRChar ) { length--; } length--; } TPtrC8 restValue( aText.Left( length ) ); __ASSERT_ALWAYS(SdpUtil::IsByteString(restValue), User::Leave(KErrSdpCodecMediaAttributeField)); TInt pos = restValue.Locate( KSlashChar ); // <encoding name> TPtrC8 encName( restValue.Left( pos ) ); restValue.Set( restValue.Right( restValue.Length() - pos - 1 ) ); pos = restValue.Locate( KSlashChar ); // <clock rate> <encoding parameters> TPtrC8 encParam( KNullDesC8 ); TPtrC8 clockRate( KNullDesC8 ); if ( pos == KErrNotFound ) { clockRate.Set( restValue ); __ASSERT_ALWAYS( clockRate.Length() > 0 && encParam.Length() == 0, User::Leave( KErrSdpCodecMediaAttributeField ) ); } else { clockRate.Set( restValue.Left( pos ) ); encParam.Set( restValue.Right( restValue.Length() - pos - 1 ) ); __ASSERT_ALWAYS( clockRate.Length() > 0 && encParam.Length() > 0, User::Leave( KErrSdpCodecMediaAttributeField ) ); } return TSdpRtpmapValue( encName, clockRate, encParam ); }
/** Checks if the line of data contains the property (aProperty) parameter @param aLine The line of data to check @return True or False indicating if property found in the line of data */ TBool CTestCompareCntFiles::IsPropertyPresent(const TDesC8& aLine, TDes8& aProperty) { TInt propertyLength = aProperty.Length(); TBuf8<KMaxLengthField> propertyFromLine(aLine.Left(propertyLength)); if (!propertyFromLine.Compare(aProperty)) { return ETrue; } else { return EFalse; } }
void CCGMMCommandHandler::SetModelID(const TDesC8& aModelID) { TRACE_FUNC_ENTRY iModel.Zero(); if (aModelID.Length() <= CTelephony::KPhoneModelIdSize) { iModel.Copy(aModelID); } else { iModel.Copy(aModelID.Left(CTelephony::KPhoneModelIdSize)); } TRACE_FUNC_EXIT }
/* Compare the corresponding lines of two files @param aLine1 Complete line of a file to compare @param aLine2 Corresponding line to compare in the second file */ TBool CTestCompareCntFiles::CompareLine(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(KREV,"REV:"); TBool ret = !aLine1.Compare(aLine2); if (!ret) { TBufC8<4> propertyRev(aLine1.Left(4)); if(!propertyRev.Compare(KREV())) { return ETrue; } } return ret; }
void CCGMMCommandHandler::SetManufacturer(const TDesC8& aManufacturer) { TRACE_FUNC_ENTRY iManufacturer.Zero(); if (aManufacturer.Length() <= CTelephony::KPhoneManufacturerIdSize) { iManufacturer.Copy(aManufacturer); } else { iManufacturer.Copy(aManufacturer.Left(CTelephony::KPhoneManufacturerIdSize)); } TRACE_FUNC_EXIT }
void CPaddingSSLv3::UnPadL(const TDesC8& aInput,TDes8& aOutput) { TInt paddingLen = aInput[aInput.Length()-1] + 1; if (paddingLen > aInput.Length()) { User::Leave(KErrInvalidPadding); } TInt outlen = aInput.Length() - paddingLen; __ASSERT_DEBUG(aOutput.MaxLength() >= outlen, User::Panic(KCryptoPanic, ECryptoPanicOutputDescriptorOverflow)); aOutput.Append(aInput.Left(outlen)); }
TBool CAgentTest::CompareLines(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(Krev,"REV"); TBool ret=!aLine1.Compare(aLine2); if (!ret) { TBufC8<2> firstchar(aLine1.Left(2)); if(!firstchar.Compare(Krev())) { return ETrue; } } return ret; }
TInt CImConvertCharconv::StraightCopy( const TDesC8& aBufIn, TDes& rBufOut) { TInt inLen=aBufIn.Length(); TInt outMaxLen=rBufOut.MaxLength(); if (inLen >= outMaxLen) { TPtrC8 in = aBufIn.Left(outMaxLen); rBufOut.Copy(in); return (inLen-outMaxLen); } else rBufOut.Copy(aBufIn); return 0; }
/** @SYMTestCaseID SYSLIB-CHARCONV-CT-0537 @SYMTestCaseDesc Tests for truncated conversion from EucJpPacked to Unicode @SYMTestPriority Medium @SYMTestActions Tests for truncated conversion from EucJpPacked to Unicode and back to EucJpPacked @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void CT_EUCJP_PACKED_2::TestTruncatedConversionToUnicodeFromEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalEucJpPacked) { INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0537 ")); for (TInt i=aOriginalEucJpPacked.Length(); i>=3; --i) // 3 is the length of GBK's longest multi-byte characters { TInt state=CCnvCharacterSetConverter::KStateDefault; TBuf16<KBufferLength> generatedUnicode; const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalEucJpPacked.Left(i), state); test(returnValue>=0); TBuf16<KBufferLength> generatedsecondPartOfUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalEucJpPacked.Mid(i-returnValue), state)==0); generatedUnicode.Append(generatedsecondPartOfUnicode); test(generatedUnicode==aExpectedUnicode); } }
void CEntry::FeedState(const TDesC8& aBytes) { switch (iState) { case ETitle: { TInt space = iTitle.MaxLength() - iTitle.Length(); TInt min = Min(space, aBytes.Length()); iTitle.Append(aBytes.Left(min)); break; } case ESummary: { TInt space = iSummary.MaxLength() - iSummary.Length(); TInt min = Min(space, aBytes.Length()); iSummary.Append(aBytes.Left(min)); break; } case EElevation: { TInt space = iElevation.MaxLength() - iElevation.Length(); TInt min = Min(space, aBytes.Length()); iElevation.Append(aBytes.Left(min)); break; } case ELat: { TInt space = iLat.MaxLength() - iLat.Length(); TInt min = Min(space, aBytes.Length()); iLat.Append(aBytes.Left(min)); break; } case ELng: { TInt space = iLng.MaxLength() - iLng.Length(); TInt min = Min(space, aBytes.Length()); iLng.Append(aBytes.Left(min)); break; } case EWikipediaUrl: { TInt space = iWikipediaUrl.MaxLength() - iWikipediaUrl.Length(); TInt min = Min(space, aBytes.Length()); iWikipediaUrl.Append(aBytes.Left(min)); break; } default: break; } }
bool splitPurl(const TDesC8& parturl, TPtrC8& hostnamePtrC8, int& port, int portMax) { int port_m1_index = parturl.Locate(':'); if(port_m1_index == KErrNotFound) { return false; } TLex8 portLex(parturl.Mid(port_m1_index + 1)); //port = atoi(port_m1 + 1); int result = portLex.Val(port); if(result != KErrNone || port <= 0 || port >= portMax) { return false; } hostnamePtrC8.Set(parturl.Left(port_m1_index)); return true; }
/** @internalComponent Parses a segment of the form name=value and returns the name and value parts @param aSegment the name-value segemnt to parse @param aName the name part that is returned @param aValue the value part that is returned */ void GetNameValuePair(const TDesC8& aSegment, TPtrC8& aName, TPtrC8& aValue) { TPtrC8 value; TInt sepPos = aSegment.Locate(KEqualsSeparator); if (sepPos != KErrNotFound) { aName.Set(aSegment.Left(sepPos)); value.Set(aSegment.Mid(sepPos+1)); } else { aName.Set(aSegment); } aValue.Set(value); }
/** Compares each line, REV and UID are ignored as they can be different */ TBool CCntPBAPSupport::CompareLines(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(KPropREV,"REV:"); _LIT8(KPropUID,"UID:"); TBool ret = !aLine1.Compare(aLine2); if (!ret) { TBufC8<4> first4char(aLine1.Left(4)); if(!first4char.Compare(KPropREV()) || !first4char.Compare(KPropUID())) { return ETrue; } } return ret; }
TInt TMD5Checker::CheckFileL(class RFs& aFs, const TDesC& aFile, const TDesC8& aHash) { TInt ret = ReadAndHashFileL(aFs, aFile); _LIT8(KMd5Prefix, "md5:"); TInt offset = 0; if(aHash.Left(KMd5Prefix().Length()).CompareF(KMd5Prefix) == 0){ offset = KMd5Prefix().Length(); } const TUint numChars = sizeof(m_hex_md5_checksum) - 1; for(TUint i = 0; i < numChars && ret == KErrNone; ++i){ ret = (aHash[i+offset] == m_hex_md5_checksum[i]) ? KErrNone :KMd5NoMatch; } return ret; }
void CHttpClientHeaderReader::SetCookieNameAndValueL(CHeaderFieldPart& aCookie, const TDesC8& aNameValue) const { TInt equalPos = aNameValue.Locate('='); if (equalPos <= 0) User::Leave(KErrHttpDecodeCookie); TPtrC8 nameVal(aNameValue.Left(equalPos)); InetProtTextUtils::RemoveWhiteSpace(nameVal, InetProtTextUtils::ERemoveBoth); TPtrC8 name(iStrPool.StringF(HTTP::ECookieName,iStringTable).DesC()); SetNewStringParamL(aCookie, name ,nameVal); TPtrC8 valueVal(aNameValue.Right(aNameValue.Length() - (equalPos+1))); InetProtTextUtils::RemoveWhiteSpace(valueVal, InetProtTextUtils::ERemoveBoth); TPtrC8 value(iStrPool.StringF(HTTP::ECookieValue,iStringTable).DesC()); SetNewStringParamL(aCookie, value ,valueVal); }