// --------------------------------------------------------------------------- // SdpUtil::SkipSpacesUntilNextLineBreak // Skips spaces until next line break, if the line break can be found. // Examples: " \r\n" -> "\r\n", "abc def\r\n" -> "abc def\r\n" // --------------------------------------------------------------------------- // TBool SdpUtil::SkipSpacesUntilNextLineBreak( TLex8& aLexer ) { TBool found = EFalse; if ( aLexer.Peek() == KSPChar ) { TInt spaceCount = 0; while ( aLexer.Peek() == KSPChar ) { spaceCount++; aLexer.Get(); } if ( aLexer.Peek() != KCRChar && aLexer.Peek() != KLFChar ) { for ( TInt i=0; i < spaceCount; i++ ) { aLexer.UnGet(); } } else { found = ETrue; } } return found; }
// ----------------------------------------------------------------------------- // CWPPushMessage::GetTextString // ----------------------------------------------------------------------------- // TPtrC8 CWPPushMessage::GetTextString( TLex8& aPointer ) const { // Text-string can be quoted. if( aPointer.Peek() == KQuotedTextStringStart ) { aPointer.Inc(); } aPointer.Mark(); while( aPointer.Get() != EKeyNull ) { // Nothing } // We don't want to have NULL in the resulting descriptor, so // back that out. aPointer.UnGet(); TPtrC8 result( aPointer.MarkedToken() ); aPointer.Inc(); return result; }
void CDomainNameCodec::EncodeL(TDomainNameArray& aNames, RBuf8& aBuf8) { TUint requiredLength = 0; TUint8 nameIdx = 0; for (nameIdx=0;nameIdx<aNames.Count();nameIdx++) { // The total length required for the labels that comprise an // individual domain name needs to take into the length octet // for the initial label and the null-termination character. // Hence the '+ 2' below. requiredLength += (aNames[nameIdx].Length() + 2); // A further length check is performed on each domain name to // ensure it does not exceed the maximum length permitted according // to RFC 1035. if(aNames[nameIdx].Length() > KMaxDomainNameLength) { User::Leave(KErrArgument); } } aBuf8.Zero(); aBuf8.ReAllocL(requiredLength); TLex8 domainName; TPtrC8 currentLabel; for (nameIdx=0;nameIdx<aNames.Count();nameIdx++) { domainName.Assign(aNames[nameIdx]); domainName.Mark(); while (!domainName.Eos()) { TChar ch; do { ch = domainName.Get(); } while ( ch != TChar('.') && !domainName.Eos() ); // if not the end of the string, unget the previous char to skip the trailing // dot in our marked token // if( !domainName.Eos() ) { domainName.UnGet(); } currentLabel.Set(domainName.MarkedToken()); // move past the dot again, or do nothing in particular at EOS // domainName.Get(); User::LeaveIfError(currentLabel.Length() > KMaxDnsLabelLength ? KErrArgument : KErrNone); aBuf8.Append(TChar(currentLabel.Length())); aBuf8.Append(currentLabel); domainName.Mark(); } aBuf8.Append(TChar(0)); } }