本文整理汇总了C++中TPtr8::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtr8::Length方法的具体用法?C++ TPtr8::Length怎么用?C++ TPtr8::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtr8
的用法示例。
在下文中一共展示了TPtr8::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TPtr8 CSmtpAuthCramMd5MechanismHelper::FormSharedSecret(TPtr8 aPassword)
{
TPtr8 secret = aPassword;
if (aPassword.Length() <= KMd5BlockLength)
{
//pad up to 64 bytes with zeros
secret.SetLength(64);
TInt origLen = aPassword.Length();
TInt lengthToFill = KMd5BlockLength-aPassword.Length();
for (TInt i = 0; i<lengthToFill; i++)
{
secret[origLen+i]=0x00;
}
}
else
{
//make shared secret the Digest of the password
secret.Zero();
iMd5Hash->Reset();
secret = (iMd5Hash->Hash(aPassword));
//do we need to call this function again now to pad out the 16 byte result?
}
return secret;
}
示例2: UpdateCurrentConnections
/**
* Function that will look at all the devices on the RConnection
* and update the device array accordingly.
*/
TInt CPanConnections::UpdateCurrentConnections()
{
TInt rerr = KErrNone;
HBufC8* buffer=0;
const TInt KAddrLen = sizeof(TBTDevAddr);
TRAP(rerr, buffer = HBufC8::NewL(7*KAddrLen));// create a buffer to house the device address
if(rerr == KErrNone)
{
TPtr8 ptr = buffer->Des();
// use RConnection to enumerate all the devices
rerr = iConnection.Control(KCOLAgent, KCOAgentPanEnumerateDevices, ptr);
if(rerr == KErrNone)
{
iActiveConnections.Reset();
while(ptr.Length()>=KBTDevAddrSize)
{
// inspect the addr's in the descriptor and append them to the array.
TBTDevAddr parsedAddr(ptr.Mid(ptr.Length()-KAddrLen, KBTDevAddrSize));
ptr.SetLength(Max(ptr.Length()-KAddrLen, 0));
iActiveConnections.Append(parsedAddr);
}
}
}
delete buffer;
return rerr;
}
示例3: ExternalizeL
/**
Intended Usage : Stream out the internal state to aStream.
Error Condition : Leave with the error code.
@leave KErrNoMemory.
@leave @see RWriteStream.
@since 7.0
@param aClientSide a boolean indicating whether the streaming is to performed in client/server side
@param aStream The stream to store the data in.
@pre CImplementationInformation is fully constructed and initialized
*/
void CImplementationInformation::ExternalizeL(TBool aClientSide,RWriteStream& aStream) const
{
aStream.WriteInt32L(iImplementationUid.iUid);
aStream.WriteInt32L(iVersion);
if(iDisplayName)
{
TPtr outputBuf = iDisplayName->Des();
aStream.WriteInt32L(outputBuf.Length());
aStream.WriteL(outputBuf);
}
else
{
aStream.WriteInt32L(0);
}
if(iData)
{
TPtr8 outputBuf = iData->Des();
aStream.WriteInt32L(outputBuf.Length());
aStream.WriteL(outputBuf);
}
else
{
aStream.WriteInt32L(0);
}
if(iOpaqueData)
{
TPtr8 outputBuf = iOpaqueData->Des();
aStream.WriteInt32L(outputBuf.Length());
aStream.WriteL(outputBuf);
}
else
{
aStream.WriteInt32L(0);
}
if (aClientSide)
{
aStream.WriteInt32L(iDrive);
aStream.WriteInt32L(iVid.iId);
}
TInt additionalImplInfo=iRomOnly;
additionalImplInfo|=iRomBased<<1;
additionalImplInfo|=iDisabled<<2;
aStream.WriteInt8L(additionalImplInfo);
if (iExtendedInterfaceList != NULL)
{
TInt count = iExtendedInterfaceList->Count();
aStream.WriteInt32L(count);
for(TInt i = 0; i < count; ++i)
{
aStream.WriteInt32L((*iExtendedInterfaceList)[i].iUid);
}
}
else
{
aStream.WriteInt32L(KNoneExtendedInterface);
}
}
示例4: PrintfStr
void CBrdSession::PrintfStr(TPtr8 &bufPtr, TPtr8 &bufPtr2)
{
CBrdServer *server = (CBrdServer*)Server();
TInt lth = bufPtr.Length();
HBufC* uniBuf=HBufC::NewL(lth*2);
CleanupStack::PushL(uniBuf);
TPtr uniBufPtr = uniBuf->Des();
uniBufPtr.Copy(bufPtr);
lth = bufPtr2.Length();
HBufC* uniBuf2=HBufC::NewL((lth*2)+2);
CleanupStack::PushL(uniBuf2);
TPtr uniBufPtr2 = uniBuf2->Des();
uniBufPtr2.Copy(bufPtr2);
server->iControl->WriteText(uniBufPtr, uniBufPtr2.PtrZ());
server->iControl->ShowText(_L("\n"));
CleanupStack::Pop();
CleanupStack::Pop();
delete uniBuf;
uniBuf = NULL;
delete uniBuf2;
uniBuf2 = NULL;
}
示例5:
// The caller must free the returned buffer. The buffer is guaranteed
// to have a zero terminator.
HBufC8* ConvToUtf8ZL(const TDesC& name16)
{
// Note that there is no non-leaving variant of this function, such
// that the result has no maximum size.
//
// Do not know what happens if any 0 values appear in "name16"; this
// is not documented.
HBufC8* name8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(name16);
// Ensure there is a zero terminator. Quite a lot of work to do this
// efficiently.
TPtr8 ptr = name8->Des();
if (ptr.Length() < ptr.MaxLength()) {
ptr.PtrZ(); // modifies HBufC8 content
} else {
HBufC8* bigger8 = name8->ReAlloc(ptr.Length() + 1);
if (bigger8) {
name8 = bigger8; // name8 already deleted by ReAlloc
name8->Des().PtrZ(); // modifies HBufC8 content
} else {
delete name8;
User::Leave(KErrNoMemory);
}
}
return name8;
}
示例6: ExecuteMessageL
EXPORT_C TInt CDosExtensionBase::ExecuteMessageL(const RMessage2& aMessage)
{
API_TRACE_( "[DOSSERVER] CDosExtensionBase::ExecuteMessageL(...)" );
__ASSERT_DEBUG(aMessage.Function() == ECallFunction,
PanicClient(aMessage,EPanicIllegalFunction));
TInt retVal(KErrNone);
TBool parameterModifiedByDSY(EFalse);
// Get data from RMessage
TExtensionParPckg extPars;
aMessage.ReadL(0, extPars);
TInt dataLength(extPars().iParLength);
if (dataLength >= 0)
{
HBufC8* dataBuffer = HBufC8::NewMaxLC( dataLength );
TPtr8 dataPtr = dataBuffer->Des();
aMessage.ReadL( 1, dataPtr );
// Check autocomplete flag
TUint autoCompl(aMessage.Int2());
if (autoCompl == KAutoComplete)
{
COM_TRACE_4( "[DOSSERVER] MDosExtensionBaseDSY::CallFunctionL(0x%x,0x%x,0x%x,0x%x)"
,extPars().iFunc
,dataPtr.Ptr()
,dataPtr.Length()
,autoCompl );
retVal = CallFunctionL(extPars().iFunc, const_cast<TUint8*>(dataPtr.Ptr()), dataPtr.Length(), parameterModifiedByDSY);
if((retVal == KErrNone) && parameterModifiedByDSY)
{
// Write over client's parameters
retVal = aMessage.Write(1, dataPtr);
}
}
else
{
COM_TRACE_3( "[DOSSERVER] MDosExtensionBaseDSY::CallFunctionAndCompleteL(0x%x,0x%x,0x%x)"
,extPars().iFunc
,dataPtr.Ptr()
,dataPtr.Length() );
CallFunctionAndCompleteL(extPars().iFunc, const_cast<TUint8*>(dataPtr.Ptr()), dataPtr.Length(), aMessage);
}
CleanupStack::PopAndDestroy(); // dataBuffer
}
else
{
// Client passed negative parameter length
retVal = KErrGeneral;
}
return retVal;
}
示例7: DecryptAndVerifyL
TInt CTlsEncrypt::DecryptAndVerifyL(const TDesC8& aInput,HBufC8*& aOutput,
TInt64& aSeqNumber, TRecordProtocol& aType)
{
if(!aInput.Length())
return KErrBadDescriptor;
TLSPROV_LOG2(_L("Before Decryption...RecordType: %d"),(TInt)aType)
TLSPROV_LOG_HEX(aInput.Ptr(),aInput.Size() )
TInt nAlloc = iCryptos.iDecryptor->MaxFinalOutputLength(aInput.Size()) + 24;
if ( !aOutput || aOutput->Des().MaxLength() < nAlloc )
{
delete aOutput;
aOutput = NULL;
aOutput = HBufC8::NewL( nAlloc );
}
TPtr8 DecOutput = aOutput->Des();
DecOutput.Zero();
TRAP_IGNORE(iCryptos.iDecryptor->ProcessFinalL(aInput,DecOutput));
TUint HashSize = KSetOfTLSCipherSuites[iCipherIndex].iHashSize;
if(DecOutput.Length() < HashSize)
{
return KErrSSLAlertDecryptError;
}
//set ptr to MAC
TPtrC8 ReceivedMac = DecOutput.Mid(DecOutput.Length()-HashSize,HashSize);
//& set length to trim MAC
DecOutput.SetLength( DecOutput.Length()-HashSize );
TBuf8<64> CalculatedMac;
ComputeMacL(CalculatedMac,DecOutput,ETrue,aSeqNumber,aType);
TInt err = KErrBadMAC;
if(ReceivedMac.Compare(CalculatedMac) == 0)
{
err = KErrNone;
}
else
{
TLSPROV_LOG(_L("Decryption: Received MAC error"))
err = KErrSSLAlertBadRecordMac;
}
TLSPROV_LOG(_L("After Decryption , no mac"))
TLSPROV_LOG_HEX(aOutput->Ptr(),aOutput->Size() )
return err;
}
示例8: DataReceivedL
// ----------------------------------------------------------------------------
// TTCPCompMsgEnd::DataReceivedL
// ----------------------------------------------------------------------------
//
void TTCPCompMsgEnd::DataReceivedL( TPtr8 aData, TUint& aNextLength )
{
// panic if sigcomp is not supported in debug mode.leaves in release mode.
__SIP_ASSERT_LEAVE( iMsgAssembler.SigComp().IsSupported(), KErrGeneral );
// panic if received data is not compressed in debug mode.
// leaves in release mode.
__SIP_ASSERT_LEAVE( iMsgAssembler.SigComp().IsSigCompMsg( aData ),
KErrGeneral );
// panic if received data is not completed compressed msg in debug mode.
// leaves in release mode.
__SIP_ASSERT_LEAVE(
iMsgAssembler.SigComp().IsCompleteSigCompMessageL( aData ),
KErrGeneral );
TUint bytesConsumed( 0 );
CBufBase* decompressedData = iMsgAssembler.SigComp().DecompressL(
aData, bytesConsumed, ETrue);
TUint dataLen( static_cast<TUint>( aData.Length() ) );
// Whole data was not decompressed and non-decompressed data might
// be part of next sigcomp message, remember amount of non-decompressed
// data
iMsgAssembler.SetUnConsumedBytes( dataLen - bytesConsumed );
if ( bytesConsumed < dataLen )
{
CleanupStack::PushL(decompressedData);
aData.Delete(0, bytesConsumed);
HBufC8* newData =
HBufC8::NewL( decompressedData->Size() + aData.Length() );
// copy the msg buffer data and the received data to new data buffer
TPtr8 newDataPtr = newData->Des();
newDataPtr.Append(decompressedData->Ptr(0));
CleanupStack::PopAndDestroy(decompressedData);
newDataPtr.Append(aData);
// delete all content of received data
aData.Delete( 0, aData.Length() );
CleanupStack::PushL(newData);
DecideNextStateL( newDataPtr, aNextLength );
CleanupStack::PopAndDestroy(newData);
}
else if ( bytesConsumed == dataLen )
{
CleanupStack::PushL( decompressedData );
aData.Delete(0, bytesConsumed);
TPtr8 decompressedDataPtr = decompressedData->Ptr(0);
DecideNextStateL( decompressedDataPtr, aNextLength );
CleanupStack::PopAndDestroy( decompressedData );
}
else // bytesConsumed > dataLen error happens, reset the state
{
delete decompressedData;
iMsgAssembler.ChangeState( MMsgAssemblerContext::EMsgInit );
}
}
示例9: CleanupClosePushL
TInt TMD5Checker::ReadAndHashFileL(class RFs& aFs, const TDesC& aFile)
{
TInt ret = KErrNone;
class RFile file;
// CAP: dependent
User::LeaveIfError(file.Open(aFs, aFile, EFileRead));
CleanupClosePushL(file);
HBufC8* readBuf = HBufC8::NewLC(6*1024);
TPtr8 buf = readBuf->Des();
Reset();
User::LeaveIfError(file.Read(buf));
while(buf.Length() > 0){
Append(buf);
User::LeaveIfError(file.Read(buf));
}
Finish();
CleanupStack::PopAndDestroy(readBuf);
CleanupStack::PopAndDestroy(/*file*/);
return ret;
}
示例10: if
EXPORT_C int Tptr8ToWcharp(const TPtr8& aSrc, wchar_t* aDes, int& n_size)
{
int retval = ESuccess;
unsigned int ilen = aSrc.Length();
int minusone = -1;
if (0 == ilen)
{
return EDescriptorNoData;
}
else if(!aDes)
{
return EInvalidPointer;
}
else if(n_size < ilen+1)
{
n_size = ilen+1 ;
return EInvalidSize;
}
if(minusone != mbstowcs(aDes, (const char*)aSrc.Ptr(), ilen))
{
aDes[ilen] = L'\0';
}
else
{
retval = EInvalidMBSSequence;
}
return retval;
}
示例11: SendCbwL
void CBulkOnlyTransport::SendCbwL(const MClientCommandServiceReq* aReq,
TBotCbw::TCbwDirection aDirection,
TUint32 aTransferLength)
{
__MSFNLOG
__BOTPRINT1(_L("Cbw Tag=0x%x"), iCbwTag);
iCbw.SetTag(iCbwTag++);
iCbw.SetDataTransferLength(aTransferLength);
iCbw.SetDataTransferDirection(aDirection);
iCbw.SetLun(iLun);
TPtr8 buf = iBulkOutCbwTd.WritableBuffer();
iCbw.EncodeL(buf, aReq);
iBulkOutCbwTd.SaveData(buf.Length());
iBulkPipeOut.Transfer(iBulkOutCbwTd, iStatus);
User::WaitForRequest(iStatus);
TInt r = iStatus.Int();
if (r != KErrNone)
{
if (r == KErrUsbStalled)
{
__BOTPRINT(_L("Cbw: BulkOut stalled"));
DoResetRecovery();
}
__BOTPRINT1(_L("Usb transfer error %d"),r);
User::Leave(KErrGeneral);
}
}
示例12: main
int main()
{
__UHEAP_MARK;
int retval =ESuccess;
wchar_t* mywcharstring = L"Hello Widechar String";
int wchar_length= wcslen(mywcharstring);
TBufC8<30> buf;
TPtr8 myTptr = buf.Des();
char* temp=new char[30];
retval = WcharpToTptr8(mywcharstring,temp, myTptr);
int buf_len = myTptr.Length();
if (retval ==ESuccess &&\
wchar_length == buf_len )
{
printf("wcharptotptr8 boundary1 Passed\n");
}
else
{
assert_failed = true;
printf("wcharptotptr8 boundary1 Failed\n");
}
delete[] temp;
__UHEAP_MARKEND;
testResultXml("test_wcharptotptr8_boundary1");
return 0;
}
示例13: DecodeL
void CDomainNameCodec::DecodeL(TPtr8& aInDes)
{
TDomainName domainName;
TUint8* pChar = const_cast<TUint8*>(aInDes.Ptr());
TUint listLength = aInDes.Length();
TUint8 labelLength = 0;
// Walk the list of domain names
while(pChar < aInDes.Ptr() + listLength)
{
domainName.Zero();
while(*pChar++ != NULL)
{
if(domainName.Length() > 0)
{
domainName.Append('.');
}
labelLength = *(pChar - 1);
// The two highest order bits must be clear
User::LeaveIfError(labelLength & 0xC0 ? KErrArgument : KErrNone);
// Add in the label data
domainName.Append(pChar, labelLength);
// Advance the pointer to the next length value
pChar += labelLength;
}
iDomainList.Append(domainName);
}
}
示例14: SetRedPayloadsL
// -----------------------------------------------------------------------------
// CMccCodecRed::SetRedCodecs
// Set the payload types used in redundancy
// -----------------------------------------------------------------------------
//
void CMccCodecRed::SetRedPayloadsL( RArray<TUint>& aRedPayloads )
{
iRedPayloads.Reset();
TInt i;
for( i = 0; i < aRedPayloads.Count(); i++ )
{
iRedPayloads.AppendL( aRedPayloads[ i ] );
}
// Convert parsed payload formats back to string and set
// the iFmtpAttr variable
const TInt KCharsPerPayload( 4 );
delete iFmtpAttr;
iFmtpAttr = NULL;
iFmtpAttr = HBufC8::NewL( iRedPayloads.Count() * KCharsPerPayload );
TPtr8 descPtr = iFmtpAttr->Des();
for( i = 0; i < iRedPayloads.Count(); i++ )
{
descPtr.AppendNum( static_cast<TUint64>( iRedPayloads[i] ), EDecimal );
descPtr.Append( KCharSlash );
}
// Remove the last slash character
descPtr.SetLength( descPtr.Length() - 1 );
}
示例15: main
int main()
{
__UHEAP_MARK;
int retval =ESuccess;
wchar_t* mywcharstring = L"Hello Widechar String";
int wchar_length= wcslen(mywcharstring);
TBufC8<30> buf;
TPtr8 myTptr = buf.Des();
char* temp=new char[30];
retval = WcharpToTptr8(mywcharstring,temp, myTptr);
int buf_len = myTptr.Length();
if (retval ==ESuccess &&\
wchar_length == buf_len &&\
strncmp("Hello Widechar String",(char*)myTptr.Ptr() , 21) ==0 )
{
printf("wcharptotptr8 content check Passed\n");
}
else
{
assert_failed = true;
printf("wcharptotptr8 content check Failed\n");
}
delete []temp;
__UHEAP_MARKEND;
testResultXml("test_wcharptotptr8_content_check");
return 0;
}