void CSenXmlReader::OnEndElementL(const RTagInfo& aElement, TInt /* aErrorCode */) { if(!iContentHandler) { SENDEBUG_L("OnEndElementL: KErrSenXmlContentHandlerNotSet"); User::Leave(KErrSenXmlContentHandlerNotSet); } const TPtrC8 localName = aElement.LocalName().DesC(); const TPtrC8 nsUri = aElement.Uri().DesC(); const TPtrC8 prefix = aElement.Prefix().DesC(); TPtrC8 qualifiedName = localName; if (prefix != KNullDesC8) { HBufC8* pQName = HBufC8::NewLC(prefix.Length()+localName.Length()+ KSenColon().Length()); TPtr8 qName = pQName->Des(); qName.Append(prefix); qName.Append(KSenColon); qName.Append(localName); qualifiedName.Set(qName); } iContentHandler->EndElement(nsUri, localName, qualifiedName); if (prefix != KNullDesC8) { CleanupStack::PopAndDestroy(); // pQName } }
QVariant QSymSQLResult::data(int idx) { QVariant r; switch (d->stmt.ColumnType(idx)) { case ESqlBinary: { TPtrC8 data; d->stmt.ColumnBinary(idx, data); return QByteArray(reinterpret_cast<const char *>(data.Ptr()), data.Length()); break; } case ESqlInt: r = QVariant(d->stmt.ColumnInt(idx)); break; case ESqlInt64: r = QVariant(d->stmt.ColumnInt64(idx)); break; case ESqlReal: switch(numericalPrecisionPolicy()) { case QSql::LowPrecisionInt32: r = QVariant(d->stmt.ColumnInt(idx)); break; case QSql::LowPrecisionInt64: r = QVariant(d->stmt.ColumnInt64(idx)); break; case QSql::LowPrecisionDouble: r = QVariant(d->stmt.ColumnReal(idx)); break; case QSql::HighPrecision: default: TPtrC res; d->stmt.ColumnText(idx, res); r = QVariant(qt_TDesC2QString(res)); break; }; break; case ESqlNull: r = QVariant(QVariant::String); break; default: TPtrC res; d->stmt.ColumnText(idx, res); r = QVariant(qt_TDesC2QString(res)); break; } return r; }
void CWspHeaderReader::DecodeEncodingVersionL(RHeaderField& aHeader) const { TPtrC8 rawData; aHeader.RawDataL(rawData); CheckLengthL(rawData, 1); TWspPrimitiveDecoder wspDecoder(rawData); if( !(CheckNullDesPartL(aHeader, rawData, 0)) ) { // Check type and decode accordingly switch( wspDecoder.VarType() ) { case TWspPrimitiveDecoder::ELengthVal: { TInt valLength = 0; TInt bytesRead = 0; TInt err = wspDecoder.LengthVal(valLength); User::LeaveIfError(err); bytesRead += err; if( wspDecoder.VarType() == TWspPrimitiveDecoder::E7BitVal ) { TUint8 codePage = 0; err = wspDecoder.Val7Bit(codePage); User::LeaveIfError(err); bytesRead += err; SetNewIntegerPartL(aHeader, 0, codePage); if( bytesRead < rawData.Length() ) { // Check for Null string first if( rawData[bytesRead] == 0 ) SetNewFStringPartL(aHeader, 1, KNullDesC8()); else DecodeGenericVersionL(aHeader, wspDecoder, 1); } } else User::Leave(KErrCorrupt); } break; case TWspPrimitiveDecoder::EString: case TWspPrimitiveDecoder::E7BitVal: { DecodeGenericVersionL(aHeader, wspDecoder, 0); } break; default: User::Leave(KErrCorrupt); break; } } }
TInt CVersionFileReader::ReadNewVersionFileL(const TDesC& versionFile) { iNewVersionArray->Reset(); class RFs& fs = CCoeEnv::Static()->FsSession(); class RFile file; TInt ret = file.Open(fs, versionFile, EFileStreamText | EFileRead); if(ret != KErrNone) { /* Could not open file, return the error code */ return ret; } HBufC8* line = HBufC8::NewLC(40); TInt pos = -1; file.Seek(ESeekStart, pos); TPtr8 pLine = line->Des(); ret = file.Read(pLine); if(line->Length() == 0) { // Empty file file.Close(); return KErrEof; } file.Close(); // The file contains a string that should match this regex: // [0-9]+\.[0-9]+\.[0-9]\+:[0-9]+\.[0-9]+\.[0-9]\+:[0-9]\+ // The string is separated into three parts by ':'. // The first part is the application version // The second part is the resource version // The third part is the mlfw version. const TChar colon = ':'; const TChar dot = '.'; while(line->Length() > 0) { if(line->Locate(colon) != KErrNotFound) { TPtrC8 part = line->Left(line->Locate(colon)); TPtrC8 version = part.Left(part.LocateReverse(dot)); TPtrC8 misc = part.Right(part.Length() - part.LocateReverse(dot) - 1); iNewVersionArray->AppendL(part); iNewVersionArray->AppendL(version); iNewVersionArray->AppendL(misc); line->Des().CopyF(line->Right(line->Length() - line->Locate(colon) - 1)); } else { iNewVersionArray->AppendL(*line); break; } } CleanupStack::PopAndDestroy(line); return 0; }
void CHttpController::ProcessResponseBodyDataL( RHTTPTransaction& aTransaction ) { MHTTPDataSupplier* body = aTransaction.Response().Body(); TPtrC8 dataPart; body->GetNextDataPart( dataPart ); if ( iOutputStream ) { iOutputStream->WriteL( dataPart ); } else { TInt bufLength( iResponseData->Des().Length() ); TInt maxBufLength( iResponseData->Des().MaxLength() ); if ( bufLength + dataPart.Length() > maxBufLength ) { iResponseData = iResponseData->ReAllocL( bufLength + dataPart.Length() ); } iResponseData->Des().Append( dataPart ); } body->ReleaseData(); StartTimeout(); }
void CRDebugWriter::WriteBufL(const TDesC8& aBuf) { TInt maxLen = 256; // RDebug::Print only accepts 256 chars on the kernel side, so split the write up TInt pos = 0; while (pos < aBuf.Length()) { TPtrC8 frag = aBuf.Mid(pos, Min(maxLen, aBuf.Length() - pos)); //Exec::DebugPrint((TAny*)&frag, 1); // This is quicker than calling RDebugPrint - cuts down on a memory copy // ^ Except that you can't do it from non-euser code... LtkUtils::RawPrint(frag); pos += frag.Length(); } }
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; }
// ----------------------------------------------------------------------------- // CSeiForwardPlugin::ReceiveMessageL // // // ----------------------------------------------------------------------------- // void CSeiForwardPlugin::ReceiveMessageL( TInt aChannel, TPtrC8 aMessage ) { RDebug::Print( _L( "EcmtSeiForwardPlugin::ReceiveMessageL: channel = %d" ), aChannel ); HBufC8* buf = HBufC8::NewLC( KMaxMsgPrefixLen + 1 + aMessage.Length() ); TPtr8 message = buf->Des(); message.Format( KMsg, aChannel ); message.Append( KBlanco ); message.Append( aMessage ); CEcmtMessageEvent* m = iMessaging->NewMessageEvent( TUid::Uid( KSEIFORWARDPLUGIN_IMPL_UID ), message ); User::LeaveIfNull( m ); iMessaging->GetMessageSender()->SendMessage( m ); }
TBool CTestConfig::IsNewComment(const TDesC8& aSource, const TLex8& aLex) const { TBool ret(EFalse); const TPtrC8 token(aLex.MarkedToken()); const TPtrC8 commentStart(KScriptCommentStart); const TInt commentStartLen(commentStart.Length()); const TInt tokenLen(token.Length()); if (commentStartLen <= tokenLen && token.Left(commentStartLen).Compare(commentStart) == 0) { ret = IsAtStartOfNewLine(aSource, aLex, ETrue); } return ret; }
EXPORT_C TInt CSenWsSecurityHeader::UsernameTokenL(const TDesC8& aUsername, HBufC8*& aToken) { TPtrC8 nsPrefix = KSecurityXmlNsPrefix(); aToken = HBufC8::NewLC( KUsernameTokenStartTagFmt().Length() + KUsernameFmt().Length() + KUsernameTokenEndTag().Length() + aUsername.Length() + nsPrefix.Length() * 4 ); TPtr8 ptr = aToken->Des(); ptr.Format(KUsernameTokenStartTagFmt, &nsPrefix); ptr.AppendFormat(KUsernameFmt, &nsPrefix, &aUsername, &nsPrefix); ptr.AppendFormat(KUsernameTokenEndTag, &nsPrefix); CleanupStack::Pop(); // aToken return KErrNone; }
// ----------------------------------------------------------------------------- // SdpUtil::IsTokenTextPair // Checks if aValue is valid pair ("valid token":"valid byte-string") // ----------------------------------------------------------------------------- // TBool SdpUtil::IsTokenTextPair( const TDesC8& aValue, TInt aStart, TInt aEnd ) { // token ":" text TBool result = EFalse; if ( aStart >= 0 && aEnd <= aValue.Length() && aStart < aEnd ) { TPtrC8 subVal = aValue.Mid( aStart, aEnd - aStart ); TInt colonPos = subVal.Locate( KColonChar ); result = colonPos != KErrNone && IsToken( subVal, 0, colonPos ) && IsByteString( subVal, colonPos + 1, subVal.Length() ); } return result; }
SHVStringBufferUTF8 SHVStringUTF8::Copy(const TPtrC8& aPtr) { SHVStringBufferUTF8 retVal; size_t len = aPtr.Length(); if (len) { retVal.Buffer = (SHVChar*)::malloc((len+1)*sizeof(SHVChar)); if (retVal.Buffer) { memcpy(retVal.Buffer, aPtr.Ptr(), len*sizeof(SHVChar)); retVal.Buffer[len] = 0; } } return retVal; }
TPtrC8 CIdWsfCoreServiceConsumer::FrameworkVersion() { TPtrC8 fwVersion = iService->FrameworkVersion(); #ifdef _SENDEBUG if(fwVersion.Length()>0) { TLSLOG(KSenCoreServiceManagerLogChannelBase , KMaxLogLevel ,(fwVersion)); } else { TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel ," - framework version not set - "); } #endif return fwVersion; }
void CATSmsMessagingRead::PopulateScaFieldsAndRemove(TPtrC8& aPdu, RMobilePhone::TMobileAddress& aGsmServiceCentre) // // Populate the SCA field in the MM ETel structure from the SCA prepended in a received PDU. // { const TUint8 KTONBitMask =0x70; const TUint8 KNPIBitMask=0x0f; const TUint8 KTONBitShift=4; const TUint8 KNPIBitShift=0; _LIT(KInternationalPrefix,"+"); __ASSERT_ALWAYS(aPdu.Length()>0,Panic(ECMTHandlerDesPassedWithZeroLength)); aGsmServiceCentre.iTypeOfNumber=(RMobilePhone::TMobileTON)0; aGsmServiceCentre.iNumberPlan=(RMobilePhone::TMobileNPI)0; aGsmServiceCentre.iTelNumber.Zero(); TUint8 len=aPdu[0]; if(len==0) { // A zero length SCA has been prepended - just strip this first byte off aPdu.Set(aPdu.Mid(len+1)); return; } TUint8 numDes=aPdu[1]; aGsmServiceCentre.iTypeOfNumber=(RMobilePhone::TMobileTON)((numDes&KTONBitMask)>>KTONBitShift); aGsmServiceCentre.iNumberPlan=(RMobilePhone::TMobileNPI)((numDes&KNPIBitMask)>>KNPIBitShift); if(aGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber) aGsmServiceCentre.iTelNumber.Append(KInternationalPrefix); TInt i; TUint16 digit; for(i=2;i<(len+1);i++) { digit=(TUint16)((aPdu[i]&0x0f)+0x30); aGsmServiceCentre.iTelNumber.Append(digit); digit=(TUint16)(((aPdu[i]&0xf0)>>4)+0x30); if(digit==0x003f) // 'F' is the padding digit at the end of a number break; aGsmServiceCentre.iTelNumber.Append(digit); } aPdu.Set(aPdu.Mid(len+1)); }
EXPORT_C TInt TMetaVarLenBase::Load(TPtrC8& aBuffer) /** * Loads content of descriptor data member */ { // Check if the descriptor is long enough TInt errlen = CheckBuf( aBuffer ); if (errlen < 0) { return errlen; } //and copy whatever we can into the client descriptor CopyBuf(aBuffer,errlen); aBuffer.Set(aBuffer.Ptr() + errlen, aBuffer.Length() - errlen); //update pointer return KErrNone; }
void CCreateFileCertStore::ConstructL(const TTestActionSpec& aTestActionSpec) { CCertStoreTestAction::ConstructL(aTestActionSpec); TInt err = KErrNone; TInt pos = 0; TPtrC8 fileName = Input::ParseElement(aTestActionSpec.iActionBody, KFileNameStart, KFileNameEnd, pos, err); iFileName = HBufC::NewL(fileName.Length()); iFileName->Des().Copy(fileName); // Set expected result pos = 0; HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length()); TPtr(result->Des()).Copy(aTestActionSpec.iActionResult); Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult); CleanupStack::PopAndDestroy(result); }
TPtrC8 CIdWsfCoreServiceConsumer::TrustAnchor() const { TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel ,"CIdWsfCoreServiceConsumer::TrustAnchor"); TPtrC8 trustAnchor = iService->TrustAnchor(); #ifdef _SENDEBUG if(trustAnchor.Length()>0) { TLSLOG(KSenCoreServiceManagerLogChannelBase , KMinLogLevel ,(trustAnchor)); } else { TLSLOG_L(KSenCoreServiceManagerLogChannelBase , KMinLogLevel ," - trust anchor not set - "); } #endif return trustAnchor; }
TBool CWspHeaderReader::CheckForNullStringL(TPtrC8& aRawData, TInt& aBytesRead, TWspPrimitiveDecoder& aDecoder) const { // Check that the buffer is not out of range if( aBytesRead >= aRawData.Length() ) User::Leave(KErrCorrupt); // Check if the data at the indicated position is a NULL terminator if( aRawData[aBytesRead] == 0 ) { TUint8 value = 0; TInt err = aDecoder.Val7Bit(value); User::LeaveIfError(err); aBytesRead += err; return ETrue; } return EFalse; }
// ----------------------------------------------------------------------------- // CUpnpDevice::DescriptionUrlPath // Return description URL path. // ----------------------------------------------------------------------------- // EXPORT_C const TPtrC8 CUpnpDevice::DescriptionUrlPath() const { const TDesC8& url = DescriptionUrl(); if ( url.Length()> KHttp().Length() ) { TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() ); TInt index = addrAndPath.Find( KSlash8() ); if ( index != KErrNotFound ) { TPtrC8 addr = addrAndPath.Right( addrAndPath.Length() - index ); return addr; } } return TPtrC8( KNullDesC8 ); }
void CDebugRouterClient::RunL() { TUint chunkSize = iSharedChunk.Size(); const TUint KDataStartOffset = sizeof(SDebugChunkHeader); SDebugChunkHeader* chunkHeader = (SDebugChunkHeader*)iSharedChunk.Base(); TUint start = chunkHeader->iStartOffset; TUint end = chunkHeader->iEndOffset; TUint overflows = chunkHeader->iOverflows; TBool wrap = (start > end); TUint endLen = wrap ? chunkSize - start : end - start; TUint startLen = wrap ? end - KDataStartOffset : 0; TPtrC8 endData(iSharedChunk.Base() + start, endLen); TPtrC8 startData; if (wrap) startData.Set(iSharedChunk.Base() + KDataStartOffset, startLen); TPtrC8 data(endData); while (data.Length()) { TPtrC8 header = Read(iTempBuf, data, sizeof(SCloggerTraceInfo), startData); if (header.Length() < (TInt)sizeof(SCloggerTraceInfo)) { ASSERT(EFalse); // for udeb break; // Something's broken } SCloggerTraceInfo info; Mem::Copy(&info, header.Ptr(), sizeof(SCloggerTraceInfo)); ASSERT(info.iTraceType == 'K' || info.iTraceType == 'U' || info.iTraceType == 'P'); TPtrC8 msg = Read(iTempBuf, data, info.iLength, startData); iServer.LogKernMessage(info.iTraceType, info.iTickCount, info.iThreadId, msg); } if (overflows) { _LIT8(KErr, "RDebug::Print buffer overflowed, %u calls not logged"); iServer.LogError(KErr, overflows); } // Zero the memory so it's easier to read in the crashlog memclr(iSharedChunk.Base() + start, endLen); if (startLen) memclr(iSharedChunk.Base() + KDataStartOffset, startLen); StartRouting(-1); // Magic number to indicate no need to call EnableDebugRouting again }
// ----------------------------------------------------------------------------- // CUpnpDeviceLibraryElement::AddInfoFromNotificationTypeHeaderL // // Supported NT (Notification Type) messages: // "uuid:" (length: 5 ) // "upnp:rootdevice" (length: 15) // "urn:schemas-upnp-org:device:" (length: 28) // "urn:schemas-upnp-org:service:" (length: 29) // ----------------------------------------------------------------------------- // TBool CUpnpDeviceLibraryElement::AddInfoFromNotificationTypeHeaderL( CUpnpSsdpMessage* aMessage ) { TPtrC8 nt = aMessage->St( ); if ( nt.Length( ) == 0 ) { nt.Set( aMessage->Nt( ) ); } if ( HasPrefix( nt, KUPnPUuid ) ) { // an uuid advertisement return ETrue; } if ( iDeviceType->Length( ) == 0 ) { if ( nt == KUPnPRootDevice ) { // a root device advertisement SetDeviceTypeL( nt ); return ETrue; } if ( HasPrefix( nt, KUPnPDeviceSchema ) ) { // a device advertisement SetDeviceTypeL( nt ); return ETrue; } } if ( HasPrefix( nt, KUPnPServiceSchema ) ) { // a service advertisement AddServiceTypeL( nt ); return ETrue; } return EFalse; }
// ----------------------------------------------------------------------------- // MceSip::ToSIPExtensionHeadersL // ----------------------------------------------------------------------------- // void MceSip::ToSIPExtensionHeadersL( RPointerArray<CSIPHeaderBase>& aSIPHeaders, const MDesC8Array& aHeaders ) { for ( int i = 0; i < aHeaders.MdcaCount(); i++ ) { TPtrC8 param = aHeaders.MdcaPoint( i ); TInt index = param.Locate( KMceSipSeparator ); if ( index != KErrNotFound && param.Left( index ) != KMceSipSubscriptionStateHeader ) { CSIPExtensionHeader* extHeader = CSIPExtensionHeader::NewL( param.Left(index), param.Right( param.Length() - ( index + 1 ) ) ); CleanupStack::PushL( extHeader ); User::LeaveIfError( aSIPHeaders.Append( extHeader ) ); CleanupStack::Pop( extHeader ); } } }
void CTextModeTestMultiTrans::ValidateBodyL(RHTTPTransaction aTransaction) { // In this test, the test URLs point to resources that contain just characters from the test number // i.e. http:/xxx/1.txt will contain only the char 1, CR or LF. // These numbers should also align with the transaction ID, since they were created in order RHTTPResponse resp = aTransaction.Response(); MHTTPDataSupplier* body = resp.Body(); TPtrC8 data; body->GetNextDataPart(data); TChar reqdCh = (TChar)(aTransaction.Id() + 48); for (TInt ii = 0; ii < data.Length(); ii++) { TChar ch = data[ii]; if ((ch != reqdCh) && (ch != (TChar)0x0d) && (ch != (TChar)0x0a)) User::Leave(KMultiTransFailed); } // OK - release the block body->ReleaseData(); }
/** @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery7L @SYMPREQ 538 @SYMTestCaseDesc Given the size of data that is returned from the server is greater than the default 1024 bytes of the buffer, test if a larger buffer is assigned in such cases @SYMTestPriority @SYMTestStatus Implemented @SYMTestActions Call GetAppServicesLC with the app uid as parameter. The size of the resource data in the registration file should be greater than the default size. on z: drive.\n API Calls:\n RApaLsSession::GetAppServicesLC(TUid aAppUid) const @SYMTestExpectedResults A larger buffer is allocated. The size of the buffer can be tested by checking the size of the returned data. */ void CT_ServicesTestStep::TestServiceDiscovery7L() { INFO_PRINTF1(_L("TestServiceDiscovery7 about to start...")); const TUid KUidServerApp = {0x10004c57}; // get all services for a particular app CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(KUidServerApp); TArray<TApaAppServiceInfo> serviceArray(array->Array()); TInt count = serviceArray.Count(); TEST(count == 16); TPtrC8 opaqueData; TInt size(0); for(TInt i=0;i<count;i++) { opaqueData.Set(serviceArray[i].OpaqueData()); size +=opaqueData.Length(); } TEST(size>=1024); CleanupStack::PopAndDestroy(array); // the servicearray array = NULL; }
EXPORT_C TInt CSenWsSecurityHeader::TimestampL(const TDesC8& aCreated, HBufC8*& aToken) { TPtrC8 nsPrefix = KSecurityUtilityXmlNsPrefix(); aToken = HBufC8::NewLC(KTimestampFormatString8().Length() + aCreated.Length() + nsPrefix.Length()*5 + KSecurityUtilityXmlNs().Length()); TPtr8 ptr = aToken->Des(); ptr.Format(KTimestampFormatString8, &nsPrefix, &nsPrefix, &KSecurityUtilityXmlNs(), &nsPrefix, &aCreated, &nsPrefix, &nsPrefix); CleanupStack::Pop(aToken); return KErrNone; }
// Extract a WSP encoded MultiOctet Integer encoding into 32-bit integer // // In: // aSource - the source Multi-Octet integer // // Out: // aInt - the 32-bit resulting integer // void CHTTPResponse::ExtractMultiOctetInteger(TInt& aInt, const TPtrC8& aSource) const // Extract a WSP encoded integer from the source descriptor { __LOG_ENTER(_L("CHTTPResponse::ExtractMultiOctetInteger")); // Get num bytes encoding the integer - // we are positioned at that location in the source descriptor TUint8 numBytes = aSource[0]; aInt = 0; if (numBytes <= 30) { __ASSERT_DEBUG(numBytes <= aSource.Length(), User::Invariant()); // Loop over the source, taking each byte and shifting it in to the count. for (TInt count = 1; (count <= numBytes); count++) aInt = (aInt << 8) + aSource[count]; } else if (numBytes & 0x80) // check top bit is set aInt = numBytes & 0x7f; // anything between 30 and 127 is not handled... __LOG_RETURN; }
void CWspHeaderReader::DecodeProfileWarningL(RHeaderField& aHeader) const { TPtrC8 rawData; aHeader.RawDataL(rawData); CheckLengthL(rawData, 1); TWspPrimitiveDecoder wspDecoder(rawData); switch (wspDecoder.VarType()) { case TWspPrimitiveDecoder::E7BitVal: // This is a short int profile warn-code { DecodeGenericWarnCodeL(aHeader, wspDecoder); } break; case TWspPrimitiveDecoder::ELengthVal: { TInt length = 0; TInt bytesRead = wspDecoder.LengthVal(length); User::LeaveIfError(bytesRead); // Get the first part - profile warn-code (short int) DecodeGenericWarnCodeL(aHeader, wspDecoder); ++bytesRead; // Get the second part - warn-target if(CheckForNullStringL(rawData, bytesRead, wspDecoder)) SetNewFStringPartL(aHeader, 1, KNullDesC8()); else bytesRead += AddNewDecoderStringPartL(aHeader, wspDecoder, 1); // Get the warn-date if it exists if( bytesRead < rawData.Length() ) { TDateTime dateTime(1970, EJanuary, 0, 0, 0, 0, 0); User::LeaveIfError(wspDecoder.Date(dateTime)); SetNewDatePartL(aHeader, 2, dateTime); } } break; default: User::Leave(KErrCorrupt); break; } }
void TaggedDataParser::ParseTaggedDataL(const TDesC8& aData, MTaggedDataParserClient& aClient) { TPtrC8 data(aData); TInt readPosition = 0; TBool moreData = data.Length() ? ETrue : EFalse; while (moreData) { // Assumes that this segment will begin with a tag TPtrC8 restOfData = data.Mid(readPosition); TInt endPos = restOfData.MatchF(KTagMatch); if (endPos == KErrNotFound) User::Leave(KErrCorrupt); // extract the tag TPtrC8 tag = restOfData.Left(KTagLength); readPosition += KTagLength; // Find the next tag restOfData.Set(data.Mid(readPosition)); endPos = restOfData.MatchF(KTagMatch); TPtrC8 tagData; if (endPos == KErrNotFound) { // If we didn't find a tag, we must be at the end of the data tagData.Set(restOfData); readPosition = restOfData.Length(); moreData = EFalse; } else { tagData.Set(restOfData.Left(endPos)); readPosition += endPos; } aClient.ProcessTaggedDataL(tag, tagData); } }
EXPORT_C TInt CSenWsSecurityHeader::UsernameTokenL(const TDesC8& aUsername, const TDesC8& aPassword, CSenWsSecurityHeader::TPasswordType aType, HBufC8*& aToken) { switch(aType) { case EText: { return UsernameTokenL(aUsername, aPassword, aToken); } case EDigest: { TPtrC8 nsPrefix = KSecurityXmlNsPrefix(); TPtrC8 typeAttr(KSecurityAttrTypeDigest); aToken = HBufC8::NewLC( KUsernameTokenStartTagFmt().Length() + KUsernameFmt().Length() + KUsernameTokenEndTag().Length() + KPasswordStartTagTypeFmt().Length() + KPasswordEndTagFmt().Length() + aUsername.Length() + aPassword.Length() + typeAttr.Length() + nsPrefix.Length() * 7 ); TPtr8 ptr = aToken->Des(); ptr.Format(KUsernameTokenStartTagFmt, &nsPrefix); ptr.AppendFormat(KUsernameFmt, &nsPrefix, &aUsername, &nsPrefix); ptr.AppendFormat(KPasswordStartTagTypeFmt, &nsPrefix, &nsPrefix, &typeAttr, &aPassword); // Type = wsse:PasswordDigest ptr.AppendFormat(KPasswordEndTagFmt, &nsPrefix); ptr.AppendFormat(KUsernameTokenEndTag, &nsPrefix); CleanupStack::Pop(); // aToken return KErrNone; } default: { return KErrNotSupported; } } }
void CHttpClientHeaderReader::DecodeSetCookieL(RHeaderField& aHeader) const { // The generic header will add each cookie on a separate line. Each cookie forms 1 part. // Each cookie will be made up of a number of parameters with name being the first and value the second, following that // will be just the actual parameters that form part of a cookie. TPtrC8 buffer; aHeader.RawDataL(buffer); TInt remainingSize = buffer.Length(); TPtrC8 token; TInt cookieCount = 0; while (remainingSize > 0) { // Extract tokens seperated by header field separator defined as KFieldSeparator in textmodestd.h remainingSize -= InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KFieldSeparator); DecodeOneCookieL(aHeader, token, cookieCount); ++cookieCount; } }