EXPORT_C #if defined (_DEBUG) /** Function to do a write of the supplied data, literally where possible. @param aData The descriptor that holds the supplied data. */ void THttpLogger::WriteComment(const TDesC8& aData) //Do a write of the supplied data, literally where possible { if(iLogger) { // If the connection to flogger was made if(iLogger->Handle() != 0) { TPtrC8 line; line.Set(aData); while (line.Length() > KMaxLogLineLength) { iLogger->Write(line.Left(KMaxLogLineLength)); line.Set(line.Right(line.Length() - KMaxLogLineLength)); } iLogger->Write(line.Left(line.Length())); } } }
TPtrC8 CSocketEngine::GetHttpHeaderInfo(const TDesC8 &aHeaderData,const TDesC8 &aHeaderInfo){ _LIT8(KEnter,"\r\n"); TBuf8<256> bufInfo(aHeaderInfo); bufInfo.Append(_L8(": ")); TPtrC8 ret; TPtrC8 ptr; ptr.Set(aHeaderData); TInt pos=ptr.FindF(bufInfo); if(pos>0){ TInt start=pos+bufInfo.Length(); ptr.Set(ptr.Mid(start)); pos=ptr.FindF(KEnter); if(pos>0){ ptr.Set(ptr.Left(pos)); ret.Set(ptr); }else if(-1==pos){ pos=ptr.FindF(_L8("\n")); if(pos>0){ ptr.Set(ptr.Left(pos)); ret.Set(ptr); } } } return ret; }
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData) { if (aLength <= aData.Length()) { // Can read it from this buffer TPtrC8 res(aData.Left(aLength)); aData.Set(aData.Mid(aLength)); return res; } else /*if (aLength > aData.Length())*/ { // Descriptor spans wrap point, so need to copy into temp buf aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated TInt overflowLen = aLength - aData.Length(); aData.Set(aOverflowData); // Wrap aData aOverflowData.Set(TPtrC8()); if (overflowLen > aData.Length()) { ASSERT(EFalse); // Shouldn't happen // in urel, return everything we've got return aData; } aTempBuf.Append(aData.Left(overflowLen)); aData.Set(aData.Mid(overflowLen)); return TPtrC8(aTempBuf); } }
EXPORT_C #if defined (_DEBUG) void TInuLogger::WriteComment(const TDesC8& aData) //Do a write of the supplied data, literally where possible { TPtrC8 line; line.Set(aData); while (line.Length() > KMaxLogLineLength) { iLogger.Write(line.Left(KMaxLogLineLength)); line.Set(line.Right(line.Length() - KMaxLogLineLength)); } iLogger.Write(line.Left(line.Length())); }
TBool CPolicyNormalizer::ValidateElementNsL(CSenElement* aAssertion) { CSenElement& element = AsElement(); RPointerArray<CSenNamespace>& namespaces = element.NamespacesL(); if(aAssertion->NamespaceURI().Length() < 1 ) { TPtrC8 elementName = aAssertion->LocalName(); TInt location = elementName.Find(KColon); if (location) { TPtrC8 nsPrefix = elementName.Left(location); CSenNamespace* ns = NULL; TInt count = namespaces.Count(); for (TInt i=0; i < count; i++) { ns = (namespaces)[i]; if(ns->Prefix().Compare(nsPrefix) == 0) { aAssertion->SetNamespaceL(ns->Prefix(),ns->URI()); return ETrue; } } } } return EFalse; }
void CUPnPHeaderReader::DecodeGenericNumberL(RHeaderField& aHeader) const { TPtrC8 buffer; aHeader.RawDataL(buffer); TInt number = KErrNotFound; TInt decimalPos = buffer.Locate('.'); if(decimalPos == 0) { // first character is decimal. So, set the value as zero. SetNewIntegerPartL(aHeader, 0, 0); } else { // Search for '\n' separator. In the case when a duplicate header has been received, // only use the fist instance of the valid data. TInt newLinePos = buffer.Locate('\n'); if (newLinePos != KErrNotFound) { buffer.Set(buffer.Left(newLinePos)); } TInt value = KErrNotFound; TInt ret = InetProtTextUtils::ConvertDescriptorToInt(buffer, value); if ( ret > KErrNone ) { // Extract an integer. Do not permit terminators other than WS or EOL. InetProtTextUtils::ExtractIntegerValueL(buffer, number, EFalse); } SetNewIntegerPartL(aHeader, 0, number); // part 0, i.e. the first (and only) part } }
void CUPnPHeaderReader::DecodeTimeoutHeaderL(RHeaderField& aHeader) const { TPtrC8 buffer; aHeader.RawDataL(buffer); // Search for '\n' separator. In the case when a duplicate header has been received, // only use the fist instance of the valid data. TInt newLinePos = buffer.Locate('\n'); if (newLinePos != KErrNotFound) { buffer.Set(buffer.Left(newLinePos)); } RStringF infinite = iStringPool.StringF(UPnP::EInfinite, TUPnPTable::Table()); if(buffer.Compare(infinite.DesC()) == 0) { SetNewIntegerPartL(aHeader, 0, -(KMaxTInt)); } else { TPtrC8 token; InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KSemiSpaceSep); TInt consumed = token.Locate('-'); token.Set(token.Mid(consumed+1)); TInt intVal; InetProtTextUtils::ConvertDescriptorToInt(token, intVal); SetNewIntegerPartL(aHeader, 0, intVal); // part 0, i.e. the first (and only) part } }
// ----------------------------------------------------------------------------- // CContactSubscriber::RunL() // Assyncronous request handler , on completion of notification // ----------------------------------------------------------------------------- // void CContactSubscriber::RunL() { __TRACE_CALLSTACK; SubscribeChangeNotiFication(); // property updated, get new value TBuf8 <KBufferSize> value; TPtrC8 id; TPtrC8 sourceType; TPtrC8 addressCount; if ( KErrNone == iProperty.Get( value ) ) { TInt pos = value.Locate(TChar('-')); id.Set( value.Left(pos) ); TPtrC8 ptr = value.Right(3); sourceType.Set(ptr.Left(1)); addressCount.Set(ptr.Right(1)); TInt appId = -1, addressType = -1, addressTypeCount = -1; TLex8 lex(id); lex.Val(appId); TLex8 lex1(sourceType); lex1.Val( addressType ); TLex8 lex2(addressCount); lex2.Val(addressTypeCount); iNotifyChange.GetChangeNotificationL( appId, addressType,addressTypeCount ); } }
TInt CVBookmarkConverter::ReadAssignment( const TDesC8& aBuffer, TInt& aPosition, TPtrC8& aTag, TPtrC8& aValue ) { LOGGER_ENTERFN( "CVBookmarkConverter::ReadAssignment" ); TPtrC8 start = aBuffer.Mid( aPosition ); TInt assignment = start.Find( KVBMKAssignment ); TInt linefeed = start.Find( KVBMKLinefeed ); // Did we find the delimeter and the linefeed if ( ( assignment == KErrNotFound) || ( linefeed == KErrNotFound ) ) { return KErrNotFound; } // Linefeed must reside behind the delimeter if ( linefeed <= assignment ) { return KErrNotFound; } // Extract tag aTag.Set( start.Left( assignment ) ); IgnoreSpaces( aTag ); // Extract value aValue.Set( start.Mid( assignment + 1, ( linefeed - 1 ) - assignment ) ); IgnoreSpaces( aValue ); // update position aPosition += ( linefeed + KVBMKLinefeed().Length() ); LOGGER_LEAVEFN( "CVBookmarkConverter::ReadAssignment" ); return KErrNone; }
void CContentWindowContainer::DataReceived(class MBrCtlLinkContent* aLinkContent, const isab::DataGuiMess* aMess, const char *aUrl) { HBufC8* data = NULL; HBufC* contentType = NULL; HBufC* url = WFTextUtil::AllocLC(aUrl); TPtr8 ptr(const_cast<unsigned char*>(aMess->getData()), aMess->getSize(), aMess->getSize()); TInt neck = ptr.Find(KNeck()); if (neck == KErrNotFound) { data = HBufC8::NewLC( ptr.Length()); data->Des().Copy(ptr); contentType = WFTextUtil::AllocLC("text/html"); } else { TPtrC8 header = ptr.Left(neck); TPtrC8 body = ptr.Mid(neck+4); data = HBufC8::NewLC( body.Length()); data->Des().Copy(body); TInt pos = header.Find(KLineEnd); TPtrC8 rest = header; while (pos != KErrNotFound) { TPtrC8 tmp = rest.Left(pos); rest.Set(rest.Mid(pos+2)); pos = rest.Find(KLineEnd); TInt ctpos = tmp.FindF(KContentTypeMarker); if (ctpos != KErrNotFound) { TPtrC8 tmp2 = tmp.Mid(ctpos+KContentTypeMarker().Length()); TInt scpos = tmp2.Find(KSemiColon); if (scpos == KErrNotFound) { contentType = HBufC::NewLC(tmp2.Length()); contentType->Des().Copy(tmp2); } else { contentType = HBufC::NewLC(tmp2.Left(scpos).Length()); contentType->Des().Copy(tmp2.Left(scpos)); } break; } } if (!contentType) { contentType = WFTextUtil::AllocLC("text/html"); } } /* contentType = RecognizeLC(*url, ptr); */ /* contentType = WFTextUtil::AllocLC("text/html"); */ aLinkContent->HandleResolveComplete(*contentType, KCharSet, data); CleanupStack::PopAndDestroy(contentType); CleanupStack::PopAndDestroy(data); CleanupStack::PopAndDestroy(url); }
CSenElement* CPolicyNormalizer::ProcessPolicyReferenceL(CSenElement* aPolicy, CPolicyRegistry* aRegistry) { //Loop for wsp:PolicyReference element and if found then replace // it with wsp:All and copy everything from found policy to here if(aRegistry == NULL) return NULL; //Check if there is a reference if yes then resolve it RPointerArray<CSenElement> referenceChildren; if(aPolicy->ElementsL(referenceChildren, KWsPolicyReference) == KErrNone) { TInt childCount = referenceChildren.Count(); TInt i = 0; CSenElement* pNextChild; while (i < childCount) { pNextChild = referenceChildren[i]; TPtrC8 localName = pNextChild->LocalName(); TPtrC8 uri = GetReferenceUriL(pNextChild); _LIT8(KHash, "#"); HBufC8* aRippedUri = NULL; if(uri.Left(1).Compare(KHash) == 0) aRippedUri = uri.Right(uri.Length()-1).AllocL(); if(aRippedUri->Length() > 0) { CSenElement* referedPolicy = aRegistry->LookupPolicy(aRippedUri->Des()); if(referedPolicy) { ReplacePolicyReferenceL(pNextChild,referedPolicy); } } delete aRippedUri; i++; } } //Check in all children recursively PolicyReferences and resolve them RPointerArray<CSenElement>& children = aPolicy->ElementsL(); TInt childCount = children.Count(); CSenElement* pNextChild; TInt i=0; while (i < childCount) { pNextChild = children[i]; TPtrC8 localName = pNextChild->LocalName(); ProcessPolicyReferenceL(pNextChild, aRegistry); i++; } return NULL; }
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; }
/** Parses the descriptor aUri into uri components. @param aUri A reference to a descriptor pointer of an Uri. @param aScheme A reference to a descriptor pointer for retieved scheme component. */ void TUriParser8::RetrieveScheme(const TPtrC8& aUri, TPtrC8& aScheme) { TInt schemePos = aUri.Locate(KSchemeDelimiter); if(schemePos != KErrNotFound) { // Got a scheme - store information aScheme.Set(aUri.Left(schemePos)); } }
void RElementIdArray::SetListL( const TDesC8& aChilds) { TInt index = 0; TPtrC8 ptr = aChilds; while ( 0 <= ( index = ptr.Locate( KMessageDelimiterChar))) { AppendL( ptr.Left( index).AllocL()); ptr.Set( ptr.Mid(index + 1)); } }
// ----------------------------------------------------------------------------- // 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 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); } }
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; }
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; }
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; }
void CUPnPHeaderReader::DecodeGenericUpnpHeadersL(RHeaderField& aHeader) const { TPtrC8 buffer; aHeader.RawDataL(buffer); // Search for '\n' separator. In the case when a duplicate header has been received, // only use the fist instance of the valid data. TInt newLinePos = buffer.Locate('\n'); if (newLinePos != KErrNotFound) { buffer.Set(buffer.Left(newLinePos)); } TPtrC8 token; InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KSemiSpaceSep); SetNewFStringPartL(aHeader, 0, token); // part 0, i.e. the first (and only) part }
// --------------------------------------------------------------------------- // CTransactionIDGenerator::GetIDL // CMD5 exists only during hash computing, to save memory. // --------------------------------------------------------------------------- // void CTransactionIDGenerator::GetIDL( TAny* aObject, TInt aObjectSize, TNATFWUNSAFTransactionID& aTransactionID ) { ++iCounter; HBufC8* data = BuildInputDataLC( aObject, aObjectSize ); CMD5* md5 = CMD5::NewL(); CleanupStack::PushL( md5 ); TPtrC8 hash = md5->Hash( *data ); __STUN_ASSERT_L( md5->HashSize() >= KMaxNATFWUNSAFTransactionIdLength, KErrUnderflow ); TPtrC8 ptrToHash = hash.Left(KMaxNATFWUNSAFTransactionIdLength); aTransactionID = ptrToHash; CleanupStack::PopAndDestroy( md5 ); CleanupStack::PopAndDestroy( data ); }
// buf to array EXPORT_C TInt CRpsMsg::InternalizeL(const TDesC8& aBufIn) { TInt length(aBufIn.Length()); if(length <= 0) { return KErrCorrupt; } if(iMsgDataArray != NULL) iMsgDataArray->Reset(); TBuf8<KMaxElementSize> buf; // Dismantle msg into data elements first TBool stop(EFalse); while (stop == EFalse) { TPtrC8 ptr = aBufIn.Right(length); TInt offset = ptr.Find(KComma); if(offset == KErrNotFound) { if(length > 0) { buf.Copy(ptr); iMsgDataArray->AppendL(buf); break; } } buf.Copy(ptr.Left(offset)); iMsgDataArray->AppendL(buf); length -= ++offset; if(length <= 0) { stop = ETrue; } } return KErrNone; }
void CSmtpAuthPlainMechanismHelper::GetNextClientMessageL(TDes8& aNextMessage) { // Build up the un-encoded authorisation string in parts HBufC8* authString = HBufC8::NewMaxLC(KMaxLengthOfPlainMessage); TPtr8 authStringPtr = authString->Des(); TBuf8<1> nul; nul.SetLength(1); nul[0] = 0; authStringPtr = nul; // Start with the NUL TPtrC8 loginName = iSettings.LoginName(); TInt length= Min(loginName.Length(),KMaxLengthOfPlainMessageComponent); authStringPtr.Append(loginName.Left(length)); authStringPtr.Append(nul); // Separator between login and password length= Min(iSettings.Password().Length(), KMaxLengthOfPlainMessageComponent); authStringPtr.Append(iSettings.Password().Left(length)); // Auth string is now built, encode it HBufC8* encodedBuf = HBufC8::NewMaxLC(KMaxLengthOfPlainMessageBase64); TPtr8 encodedBufPtr = encodedBuf->Des(); iEncoder.Encode(authStringPtr,encodedBufPtr); // Now build the message iNextClientMessage.Zero(); iNextClientMessage.Append(KSmtpAuthCommand); iNextClientMessage.Append(KPlainMechanism); iNextClientMessage.Append(encodedBufPtr); iNextClientMessage.Append(KSmtpCrLf); aNextMessage = iNextClientMessage; CleanupStack::PopAndDestroy(encodedBuf); CleanupStack::PopAndDestroy(authString); }
// ----------------------------------------------------------------------------- // CUpnpDevice::DescriptionUrlAddressL // Return description URL address. // ----------------------------------------------------------------------------- // EXPORT_C TInetAddr CUpnpDevice::DescriptionUrlAddressL() const { if ( iAddress == TInetAddr( INET_ADDR( 0,0,0,0 ), 0) ) { const TDesC8& url = DescriptionUrl(); if ( url.Length()> KHttp().Length() ) { TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() ); TInt index = addrAndPath.Find( KSepar() ); if ( index == KErrNotFound ) { index = addrAndPath.Find( KSlash8() ); } if ( index == KErrNotFound ) { return TInetAddr( INET_ADDR( 0,0,0,0 ), 0 ); } TPtrC8 addr = addrAndPath.Left( index ); TInetAddr address; HBufC* addrBuf = HBufC::NewLC(addr.Length()); addrBuf->Des().Copy(addr); address.Input(*addrBuf); CleanupStack::PopAndDestroy(addrBuf); return address; } return TInetAddr(INET_ADDR( 0,0,0,0 ), 0 ); } return iAddress; }
/** Loads a drawsection from externalized data. @param aData The parser for the externalized data. @param aIndex The index of the drawsection in CCommandBuffer::iDrawSections to load from the externalized data. */ TInt CDrawSection::LoadL(const TWsGraphicMsgBufParser& aData, TInt aIndex) { if(aData.Uid(aIndex).iUid != KDrawSection.iUid) { return KErrArgument; } const TPtrC8 pckg = aData.Data(aIndex); const TPtrC8 drawRectPtr = pckg.Left(sizeof(TRect)); const TPtrC8 boundingRectPtr = pckg.Mid(sizeof(TRect), sizeof(TRect)); const TPtrC8 segBufPtr = pckg.Mid(sizeof(TRect)*2); Mem::Copy(&iDrawRect, drawRectPtr.Ptr(), sizeof(TRect)); Mem::Copy(&iBoundingRect, boundingRectPtr.Ptr(), sizeof(TRect)); if(iSectionSegBuf) delete iSectionSegBuf; iSectionSegBuf = CBufSeg::NewL(KBufferSize); iSectionSegBuf->InsertL(0, segBufPtr); return KErrNone; }
// --------------------------------------------------------- // CDdEng::ParseLicenseL() // --------------------------------------------------------- // void CDdEng::ParseLicenseL() { HBufC8* descriptorBuf = CodUtil::ConvertLC( iCodBuf->Des()); TPtrC8 license; TPtrC8 descriptor (descriptorBuf->Ptr()); TInt startTag = descriptor.Find(KLicenseStartTag); // "<license" if (startTag != KErrNotFound) { descriptor.Set(descriptor.Right(descriptor.Length()- startTag -1)); TInt endTag = descriptor.Locate(KElementEnd); //'>' if (endTag != KErrNotFound) { license.Set(descriptor.Right(descriptor.Length()-endTag-1)); TInt licenseTagEnd = license.Find(KLicenseEndTag); // "</license" if (licenseTagEnd != KErrNotFound) { license.Set(license.Left(licenseTagEnd)); } } } iSaver->AppendData( license ); CleanupStack::PopAndDestroy( descriptorBuf ); }
TInt AsciiToNum(const TPtrC8 aParam, TInt32& aVal) /** * Converts a hexadecimal or decimal value stored in a TPtrC to its TUint value * * @param aParam TPtr pointing to the hexadecimal or decimal number to convert * @param aVal TUint reference to the val converted. * @return TInt Standard error return. */ { _LIT8(KHexPrefix,"0x"); TInt ret=KErrNone; if(aParam.Left(2).Compare(KHexPrefix)==0) { TLex8 lex(aParam.Mid(2)); ret=lex.Val(aVal,EHex); } else { TLex8 lex(aParam); ret=lex.Val(aVal,EDecimal); } return ret; }
void CSatNotifySendSs::CheckCallForwarding ( TPtrC8 aSource, RSat::TSsString& aSsString ) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKCALLFORWARDING_1, "CSAT:: CSatNotifySendSs::CheckCallForwarding"); _LIT8(KCFU,"*21*"); // Call forwarding unconditional (CFU) _LIT8(KCFB,"*67*"); // Call forwarding on Mobile Subscriber Busy(CFB) _LIT8(KCFNRy, "*61*"); // Call forwarding on No Reply (CFNRy) _LIT8(KCFNRc, "*62*"); // Call forwarding on Mobile Subscriber Not // Reachable (CFNRc) // Try to find call forwarding string TInt pos( aSource.Find( KCFU ) ); if ( KErrNotFound == pos ) { pos = aSource.Find( KCFB ); } if ( KErrNotFound == pos ) { pos = aSource.Find( KCFNRy ); } if ( KErrNotFound == pos ) { pos = aSource.Find( KCFNRc ); } if ( KErrNotFound != pos ) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKCALLFORWARDING_2, "CSAT:: CSatNotifySendSs::CheckCallForwarding, String is for call forwarding"); aSsString.iSsString.Zero(); aSsString.iSsString.Append( aSource.Left( pos + 4 ) ); aSsString.iSsString.Append( KPlusMarkCharacterCode ); aSsString.iSsString.Append( aSource.Right( aSource.Length() - ( pos + 4) ) ); } }
SYSCALL(MAHandle, maConnect(const char* url)) { TPtrC8 urlP(CBP url, SYSCALL_THIS->ValidatedStrLen(url)); LOGST("Connect %i %s", gConnNextHandle, url); if(gConnections.size() >= CONN_MAX) return CONNERR_MAX; _LIT8(KLocalhost, "localhost"); CConnection* conn = NULL; TPtrC8 match; SocketType socketType = TCP; // initialized to placate stupid compiler ConnectionType type; // determine type of connection if(SSTREQ(urlP, KSocket)) { match.Set(KSocket); type = eSocket; socketType = TCP; } else if(SSTREQ(urlP, KDatagram)) { match.Set(KDatagram); type = eSocket; socketType = UDP; } else if(SSTREQ(urlP, KSsl)) { match.Set(KSsl); type = eSocket; socketType = SSL; } else if(SSTREQ(urlP, KHttp)) { match.Set(KHttp); type = eHttp; socketType = TCP; } else if(SSTREQ(urlP, KHttps)) { match.Set(KHttps); type = eHttp; socketType = SSL; } else if(SSTREQ(urlP, KBtspp)) { match.Set(KBtspp); type = eBtspp; } else { //error return CONNERR_URL; } TPtrC8 parturl = urlP.Mid(match.Length()); if(type == eSocket) { TPtrC8 hostnamePtrC8; int port; if(!splitPurl(parturl, hostnamePtrC8, port, (1<<16))) { return CONNERR_URL; } Smartie<CSocket> sockp(createSocket(socketType)); _LIT8(K127, "127."); TInetAddr addr; bool localhost = false; if(hostnamePtrC8 == KLocalhost) { localhost = true; addr.SetAddress(INET_ADDR(127,0,0,1)); } else if(hostnamePtrC8.Length() > K127().Length()) { if(hostnamePtrC8.Left(K127().Length()) == K127) { localhost = true; Smartie<HBufC16> hostname(CreateHBufC16FromDesC8LC(hostnamePtrC8)); addr.Input(*hostname()); } } sockp->state |= CONNOP_CONNECT; if(localhost) { StartConnOpL(CO_AddrConnect::NewL(false, *this, gConnNextHandle, *sockp(), addr, port, *sockp())); } else { Smartie<HBufC16> hostname(CreateHBufC16FromDesC8LC(hostnamePtrC8)); CleanupStack::Pop(hostname()); StartConnOpL(CO_NameConnect::NewL(gNetworkingState != EStarted, *this, gConnNextHandle, *sockp(), hostname, port, *sockp())); } conn = sockp.extract(); } else if(type == eHttp) { CHttpConnection* http; TLTZ_PASS(httpCreateConnectionLC(parturl, http, HTTP_GET, socketType)); http->state |= CONNOP_CONNECT; StartConnOpL(CO_HttpFinish::NewL(gNetworkingState != EStarted, *this, gConnNextHandle, *http, *http, true)); http->mState = CHttpConnection::WRITING; conn = http; CleanupStack::Pop(conn); } else if(type == eBtspp) { if(gBtState != eAvailable) { return CONNERR_UNAVAILABLE; } TPtrC8 hostnamePtrC8; int port_m1_index = parturl.Locate(':'); if(port_m1_index == KErrNotFound) { return false; } hostnamePtrC8.Set(parturl.Left(port_m1_index)); if(hostnamePtrC8 == KLocalhost) { // server // extract and parse uuid static const int KUuidLength = 32; int uuidStartIndex = port_m1_index + 1; int paramStartIndex = uuidStartIndex + KUuidLength; if(parturl.Length() < paramStartIndex) { return CONNERR_URL; } TPtrC8 uuidPtrC8(parturl.Mid(uuidStartIndex, KUuidLength)); TUint32 us[4]; for(int i=0; i<4; i++) { TPtrC8 p(uuidPtrC8.Mid(i*8, 8)); for(int j=0; j<8; j++) { if(!TChar(p[j]).IsHexDigit()) return CONNERR_URL; } LHEL(TLex8(p).Val(us[i], EHex)); } TUUID uuid(us[0], us[1], us[2], us[3]); //TUUID uuid(KSerialPortUUID); //temp hack // create listener socket Smartie<CBtServerSocket> sockp(new (ELeave) CBtServerSocket(gBtSdpDB)); // extract name, if it's there. initialize the socket. TPtrC8 paramPtrC8(parturl.Mid(paramStartIndex)); _LIT8(KNameParam, ";name="); if(SSTREQ(paramPtrC8, KNameParam)) { TPtrC8 namePtrC8(paramPtrC8.Mid(KNameParam().Length())); sockp->init(gSocketServ, uuid, true, namePtrC8); } else if(paramPtrC8.Length() == 0) { sockp->init(gSocketServ, uuid, false); } else { return CONNERR_URL; } //skip the async/connect step gConnections.insert(gConnNextHandle, sockp.extract()); return gConnNextHandle++; } else { // client // extract port number int port; if(!splitPurl(parturl, hostnamePtrC8, port, 31)) { return CONNERR_URL; } TRfcommSockAddr rfcsa; // parse address TBTDevAddr btaddr; for(int i=0; i<BTADDR_LEN; i++) { TLex8 btaLex(parturl.Mid(i*2, 2)); int result = btaLex.Val(btaddr[i], EHex); if(result != KErrNone) return CONNERR_URL; } rfcsa.SetBTAddr(btaddr); // create socket Smartie<CSocket> sockp(new (ELeave) CSocket(gSocketServ, CSocket::ERfcomm)); sockp->state |= CONNOP_CONNECT; StartConnOpL(CO_AddrConnect::NewL(false, *this, gConnNextHandle, *sockp(), rfcsa, port, *sockp())); conn = sockp.extract(); } } CleanupStack::PushL(conn); gConnections.insert(gConnNextHandle, conn); CleanupStack::Pop(conn); return gConnNextHandle++; }
// --------------------------------------------------------------------------- // CUpnpHttpFileTransferWriter::StartL // Sends the HTTP headers of the content // --------------------------------------------------------------------------- // void CUpnpHttpFileTransferWriter::SendHeadersL() { if(iState == EHeaders) if( iSession.FileAccess() ) if(!IsActive()) { //in case session not connected,waiting... if(!iSession.IsConnected()) { iWaiting = ETrue; return; } iSendBuffer.Zero(); if ( ( iSession.FileAccess()->GetHeaders().Length() - iSession.FileAccess()->TransferredBytes()) <= iSendBuffer.MaxLength() ) { TPtrC8 headerPointer; headerPointer.Set(iSession.FileAccess()->GetHeaders()); headerPointer.Set( headerPointer.Right( iSession.FileAccess()->GetHeaders().Length()- iSession.FileAccess()->TransferredBytes()) ); iSendBuffer.Append( headerPointer ); iSession.FileAccess()->SetHeadersSent(); // Adding file content to the header TInt length = iSendBuffer.MaxLength()-iSendBuffer.Length(); HBufC8* tmpBuffer = HBufC8::NewLC(length); iSendPointer.Set(tmpBuffer->Des()); if( iSession.FileAccess()->GetL(iSendPointer,length) ) { iState = EFinished; } iSendBuffer.Append(iSendPointer); CleanupStack::PopAndDestroy( tmpBuffer ); } else { TPtrC8 headerPointer; headerPointer.Set( iSession.FileAccess()->GetHeaders() ); headerPointer.Set( headerPointer.Right( iSession.FileAccess()->GetHeaders().Length() - iSession.FileAccess()->TransferredBytes() ) ); headerPointer.Set( headerPointer.Left( iSendBuffer.Length() ) ); iSendBuffer.Append( headerPointer ); iSession.FileAccess()->SetPosOfHeader( iSession.FileAccess()->TransferredBytes() + headerPointer.Length() ); } iSendPointer.Set((TUint8*)iSendBuffer.Ptr(),iSendBuffer.Length(),iSendBuffer.MaxLength()); iSession.TimerCancel(); WriteToSocket(); iSession.StartTimeoutTimer(ETrue); if(!iHttpPostStarted) { iSession.NotifyUpperLayersOnPostL(); iHttpPostStarted = ETrue; } } }