コード例 #1
0
TUint TInputManager::ReadString(TDes8& aStr)
	{
	TKeyCode key;
	
	aStr.Zero();
	
	while( (key = iConsole.Getch()) != EKeyEnter)
		{
		if (aStr.Length() == aStr.MaxLength())
			return aStr.MaxLength();
		
		if (key == EKeyBackspace)
			{
			if (aStr.Length() > 0)
				{
				aStr.Delete(aStr.Length()-1, 1);
				ConsoleBackspace(1);
				}
			}
		else
			{
			TUint8 keyChar(key);
			aStr.Append(keyChar);
			iConsole.Printf(_L("%c"), keyChar);
			}
		}
	iConsole.Printf(_L("\n"));
	return aStr.Length();
	}
コード例 #2
0
TInt	CWsGceCscBase::DebugInfo(TWsDebugInfoFunc aFunction, 
		                                 TInt aParam, 
		                                 TDes8& aHostBuffer,
		                                 const void*&aReturnedObject,
		                                 TInt aObjectSize)const
	{
	TInt reqSize=iSession.DebugInfo(aFunction,aHostBuffer,aParam);
	aReturnedObject=NULL;
	if (reqSize<0)
		{
		if ((reqSize%aObjectSize)!=0)
			{
			return KErrCorrupt;
			}
		else
			{
			return reqSize;
			}
		}
	if (reqSize>aHostBuffer.MaxLength())
		{
		return reqSize/aObjectSize;
		}
	if (reqSize==0)
		{
		reqSize=aHostBuffer.MaxLength();
		}
	if ((reqSize%aObjectSize)!=0)
		{
		return KErrCorrupt;
		}
	aReturnedObject=(const void*)aHostBuffer.Ptr();
	reqSize/=aObjectSize;
	return reqSize;
	}
コード例 #3
0
/**
Copies the content of a binary column, identified by aColumnIndex, to the place refered by aDest parameter.

If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.

@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.

@return KErrNone, if the function completes successfully,
                  otherwise one of the other system-wide error codes.

@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/	
TInt CSqlStatementImpl::ColumnBinary(TInt aColumnIndex, TDes8& aDest)
	{
	__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
	__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
	iColumnValBufIt.MoveTo(aColumnIndex);		
	TInt err = KErrNone;
	//The binary column value has not been transferred to the client side if its length is >= KSqlMaxDesLen bytes.
	//In this case an additional call to the server is made to get the column value.
	if(!iColumnValBufIt.IsPresent())
		{
		if(iColumnValBufIt.Type() != ESqlBinary)
			{
			aDest.Zero();
			return err;
			}
		err = iSqlStmtSession.ReadColumnValue(aColumnIndex, aDest);
		}
	else
		{
		TPtrC8 src = iColumnValBufIt.Binary();
		TInt len = src.Length();
		if(len > aDest.MaxLength())
			{
			len = aDest.MaxLength();
			err = KErrOverflow;
			}
		aDest.Copy(src.Ptr(), len);
		}
	return err;
	}
コード例 #4
0
ファイル: d_medt1.cpp プロジェクト: kuailexs/symbiandump-os1
void DMediaDriverTest::Caps(TDes8& aCapsBuf)
//
// Return the capabilities of the media
	{

	TLocalDriveCapsV2 caps;
	caps.iType=EMediaRam;
	caps.iConnectionBusType=EConnectionBusInternal;
	caps.iDriveAtt=KDriveAttLocal|KDriveAttRemovable;
	caps.iMediaAtt=KMediaAttFormattable;
	caps.iFileSystemId=KDriveFileSysFAT;
	caps.iHiddenSectors=0;
	aCapsBuf.FillZ(aCapsBuf.MaxLength());
	aCapsBuf.Copy((TUint8 *)&caps,Min(aCapsBuf.MaxLength(),sizeof(caps)));
	}
コード例 #5
0
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);
		}
	}
コード例 #6
0
TInt RCdlSession::GetCust(TDes8& aCust, TInt& aNewSize) const
	{
	TPckg<TInt> pckg(aNewSize);

	TIpcArgs p(&aCust, aCust.MaxLength(), &pckg);
	return SendReceive(ECdlServCmdGetCust,p);
	}
コード例 #7
0
// -----------------------------------------------------------------------------
// CRedirDesc::Read
// Implementation for Read
// -----------------------------------------------------------------------------
//
void CRedirDesc::Read(TDes8& aDes, TRequestStatus& aStatus)
	{
	if( ENotConnected == iStatus )
		{
		iLock.Wait();
		if( ENotConnected == iStatus )
			{
			Configure();	
			}
		iLock.Signal();
		}
	if( EConnected == iStatus && !iReadNone )
		{
		iSession.Read(aStatus, aDes, aDes.MaxLength());
		}
	else 
		{
		// If no session is there i.e. no server in production code or in the
		// config.ini file for the stdioserver the both media type is NONE then
		// just complete the request with EOF so that libc can handle it.
		TRequestStatus* status = &aStatus;
		User::RequestComplete(status, KErrEof);
		}
	
	}
コード例 #8
0
ファイル: ProvSC.cpp プロジェクト: kuailexs/symbiandump-mw3
// -----------------------------------------------------------------------------
// CWimOMAProv::Retrieve()
// Fetches the whole data of provisioning information string.
// -----------------------------------------------------------------------------
//
EXPORT_C void CWimOMAProv::Retrieve( const TOMAType& aOMAType, 
                                     TDes8& aOMAData, 
                                     TRequestStatus& aStatus )
    {
    _WIMTRACE ( _L( "CWimOMAProv::Retrieve" ) );    
    aStatus = KRequestPending;
    iClientStatus = &aStatus;

    if ( !iClientSession || !iConnectionHandle )
        {
        User::RequestComplete( iClientStatus, KErrGeneral );
        return;
        }

    if ( aOMAData.MaxLength() )
        {
        iOMAType = aOMAType;
        iData = &aOMAData;
        iPhase = ERetrieve;
        SignalOwnStatusAndComplete();
        }
    else
        {
        User::RequestComplete( iClientStatus, KErrGeneral );
        }
    }
コード例 #9
0
ファイル: t_modem1.cpp プロジェクト: kuailexs/symbiandump-os1
LOCAL_C TInt TranslateCrLf(TDes8 &aDes)
//
// Search for CR/LF characters in a string and replace them with
// '\r' '\n' format. Also replaces unprintable characters with "?"
//
{

    TText8 buf[KBlockSize];
    TText8 *pS=(TText8*)aDes.Ptr();
    TText8 *pSE=pS+aDes.Size();
    TText8 *pT=&buf[0];
    TText8 *pTMax=pT+(KBlockSize-1);
    for (; pS<pSE; pS++,pT++)
    {
        if (pT>=pTMax)
            return(KErrTooBig);
        if (*pS=='\xD'||*pS=='\xA')
        {
            *pT++='\\';
            *pT=(*pS=='\xD')?'r':'n';
        }
        else if (((TChar)*pS).IsPrint())
            *pT=*pS;
        else
            *pT='\?';
    }
    *pT=0;
    if ((pT-&buf[0])>aDes.MaxLength())
        return(KErrTooBig);
    aDes.Copy(&buf[0]);
    return(KErrNone);
}
コード例 #10
0
ファイル: t_fsched.cpp プロジェクト: kuailexs/symbiandump-os1
/**  Fills a buffer with character aC

	@param aBuffer  Buffer to be filled, output
	@param aLength  Length to be filled
	@param aC		Character to be used to fill the buffer
*/
void FillBuffer(TDes8& aBuffer, TInt aLength, TChar aC)
	{
	test (aBuffer.MaxLength() >= aLength);
	for(TInt i=0; i<aLength; i++)
		{
		aBuffer.Append(aC);
		}
	}
コード例 #11
0
ファイル: US_BUF.CPP プロジェクト: cdaffara/symbiandump-os2
/** Reads data from the stream buffer into the specified descriptor.

This function is called by ReadL(TDes8&,TInt,TRequestStatus&).

This implementation deals with the request synchronously, and completes the 
request with KErrNone. Other implementations may choose to deal with this 
in a true asynchronous manner.

In addition, the read operation itself uses the DoReadL(TAny*,TInt) variant.

@param aDes The target descriptor for the data read from the stream buffer. 
On return, the length of the descriptor is set to the number of bytes read 
from the stream buffer.
@param aMaxLength The maximum number of bytes to be read. This value must not 
be greater than the maximum length of the descriptor, otherwise the function 
raises a STORE-Stream 2 panic.
@param aStatus The request status that indicates the completion status of this 
asynchronous request.
@return The maximum number of bytes to be read, as used in this request. This 
implementation uses, and returns, the value supplied in aMaxLength. Other 
implementations may choose to use a different value.
@see MStreamBuf::ReadL() */
EXPORT_C TInt MStreamBuf::DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
	{
	__ASSERT_DEBUG(aMaxLength<=aDes.MaxLength(),Panic(EStreamReadBeyondEnd));
	aDes.SetLength(DoReadL((TUint8*)aDes.Ptr(),aMaxLength));
	TRequestStatus* stat=&aStatus;
	User::RequestComplete(stat,KErrNone);
	return aMaxLength;
	}
コード例 #12
0
// -----------------------------------------------------------------------------
// CDirectoryDesc::Read : Reading from a Directory
// -----------------------------------------------------------------------------
void CDirectoryDesc::Read(TDes8& aDesc, TRequestStatus& aStatus)
{
    TInt errorNum = KErrNone;
    const TInt16 KDirentSize = 8;
    TInt readLen = aDesc.MaxLength();
    TUint8* bufPtr = const_cast<TUint8*>(aDesc.Ptr());
    TInt copiedInfo = 0;
    TEntryArray entries;
    errorNum = iDir.Read( entries );
    TDirent direntEntry;

    if (errorNum == KErrNone || errorNum == KErrEof)
    {
        errorNum = KErrNone;
        TEntry entry;
        TInt len = 0;
        TInt count = entries.Count();
        TBuf8<KMaxFileName> fileName;
        TInt index = 0;
        TInt copyLen = 0;
        //Loop through each entry and get all the informations
        for (; index<count && copiedInfo<readLen; index++, copiedInfo += copyLen)
        {
            entry = entries[index];
            //Copy File's UID
            TUid fileUID = entry.iType.MostDerived();
            direntEntry.iEntryNum = fileUID.iUid;
            HBufC8 *name;
            if(ConvertUnicodeToUtf8(entry.iName,name,errorNum) == -1)
            {
                break;
            }
            //Copy entry type and record Length
            fileName.Copy( name->Des() );
            delete name;
            len = fileName.Length();
            direntEntry.iRecLen = KDirentSize + len + 1;
            //Maintaing a four byte boundary.
            direntEntry.iRecLen = Align4(direntEntry.iRecLen);
            direntEntry.iEntryType = 0;
            direntEntry.iNameLen = len;
            //Copy entry name
            Mem::Copy( direntEntry.iEntryName, fileName.PtrZ(), len+1);

            //Copy structure on to the buffer
            copyLen = Min(direntEntry.iRecLen, (readLen - copiedInfo));
            Mem::Copy( bufPtr, &direntEntry, copyLen );
            bufPtr += copyLen;
        }
    }

    //Set the Length
    aDesc.SetLength( copiedInfo );
    TRequestStatus* status = &aStatus;
    User::RequestComplete(status, errorNum);
}
コード例 #13
0
ファイル: CStep.cpp プロジェクト: cdaffara/symbiandump-os1
/**
    Performing ECNControl actions.
*/
TInt CPARAM_MESS_NAMEStep::ConnectionControl(TUint aOptionLevel, TUint aOptionName, TDes8& aOption)
{
	TSockOpt arg;
	arg.optionName = aOptionName;
	arg.optionVal = &aOption;	//Note that optionVal will be useless on the server side
	arg.optionLen = aOption.MaxLength();
	TPckgC<TSockOpt> buf(arg);

	return SendReceive(ECNControl, TIpcArgs(&buf, aOptionLevel, &aOption,iSSRef ));
}
コード例 #14
0
ファイル: pccenrep.cpp プロジェクト: cdaffara/symbiandump-os2
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@param aActualLength Returns the actual length of the setting if it is a descriptor.
@return
	KErrNone if successful,
	KErrNotFound if the setting does not exist,
	KErrArgument if the setting exists but is not a descriptor,
	KErrOverflow if the descriptor is too small to receive the value in the repository,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue, TInt& aActualLength)
	{
	TBuf8<KMaxBinaryLength> val;
	TInt ret = iImpl->Get(aKey, val);	
	if (ret==KErrNone)
		{
		TInt settingValueLength=val.Length();
		//now check whether any string overflow
		if (settingValueLength > aValue.MaxLength())
			{
			aActualLength=settingValueLength;
			aValue.Copy(val.Left(aValue.MaxLength()));
			return KErrOverflow;
			}
		else
			{
			aValue.Copy(val);
			}
		}	
	return ret;	
	}
コード例 #15
0
ファイル: MetaType.cpp プロジェクト: cdaffara/symbiandump-os1
EXPORT_C TInt TMetaArrayBase::Store(TDes8& aBuffer) const
/**
 * Stores content of a meta object (in iData) to a descriptor
 */
	{
	if (aBuffer.MaxLength() - aBuffer.Length() < (TInt)sizeof(TInt))
		{
		return KErrOverflow;
		}
	TInt count = Count();
	aBuffer.Append((TUint8*)&count, sizeof(TInt));
	TInt size = SizeOfType();
	for ( TInt n = 0; n < count; n++ )
		{
		if (aBuffer.MaxLength() - aBuffer.Length() < size)
			{
			return KErrOverflow;
			}
		aBuffer.Append(At(n), size);
		}
	return KErrNone;
	}
コード例 #16
0
EXPORT_C TInt COMASuplTriggeredStart::GetVer(TDes8& aVer)const
    {
    if( iOptionalMask & (1<<KVerShift) )
        {
        if(aVer.MaxLength() >= iVer.Length())
            aVer = iVer;
        else
            return KErrArgument;
        return KErrNone;
        }
    else
        return KErrOMASuplParamNotSet;
    }
コード例 #17
0
ファイル: netImpl.cpp プロジェクト: Felard/MoSync
void CHttpConnection::RecvOneOrMoreL(TDes8& aDes, CPublicActive& op) {
	MYASSERT(mState == FINISHED, ERR_HTTP_NOT_FINISHED);
	if(mPos < mBufPtr.Length()) {	//there's still some data left in the buffer
		int len = MIN(mBufPtr.Length() - mPos, aDes.MaxLength());
		aDes.Copy(mBufPtr.Ptr() + mPos, len);
		mPos += len;
		op.SetActive();
		TRequestStatus* temp = &op.iStatus;
		User::RequestComplete(temp, len);
	} else {	//we gotta read from outside
		mTransport->RecvOneOrMoreL(aDes, op);
	}
}
コード例 #18
0
ファイル: pdd.cpp プロジェクト: cdaffara/symbiandump-os1
/**
  Returns the drivers capabilities. This is not used by the Symbian OS device driver framework
  but may be useful for the LDD to use.

  @param aDes Descriptor to write capabilities information into
*/
void DZeroCopyLoopbackPddFactory::GetCaps(TDes8& aDes) const
	{
	// Create a capabilities object
	DZeroCopyLoopback::TCaps caps;
	caps.iVersion = iVersion;
	// Zero the buffer
	TInt maxLen = aDes.MaxLength();
	aDes.FillZ(maxLen);
	// Copy cpabilities
	TInt size=sizeof(caps);
	if(size>maxLen)
		size=maxLen;
	aDes.Copy((TUint8*)&caps,size);
	}
コード例 #19
0
EXPORT_C void CStreamCipher::Process(const TDesC8& aInput, TDes8& aOutput)
	{
	TInt outputIndex = aOutput.Size();

	// aOutput may already have outputIndex bytes of data in it
	// check there will still be enough space to process the result
	__ASSERT_DEBUG(aOutput.MaxLength() - outputIndex >= MaxOutputLength(aInput.Length()), User::Panic(KCryptoPanic, ECryptoPanicOutputDescriptorOverflow));

	aOutput.Append(aInput);

	TPtr8 transformBuf((TUint8*)(aOutput.Ptr()) + outputIndex, aInput.Size(),
		aInput.Size());
	DoProcess(transformBuf);
	}
コード例 #20
0
EXPORT_C void RFotaEngineSession::GetCurrentFirmwareDetailsL(TDes8& aName, TDes8& aVersion, TInt& aSize)
    {
    FLOG(_L("RFotaEngineSession::GetCurrentFirmwareDetailsL >>"));
    
    TPckg<TInt>     pkgsize(aSize);
    
    __ASSERT_ALWAYS(aName.MaxLength() >= KFotaMaxPkgNameLength, User::Leave(KErrArgument) );
    __ASSERT_ALWAYS(aName.MaxLength() >= KFotaMaxPkgVersionLength, User::Leave(KErrArgument) );
    
    TInt err = SendReceive(EGetCurrFwDetails, TIpcArgs(&aName, &aVersion, &pkgsize));
    
    FLOG(_L("RFotaEngineSession::GetCurrentFirmwareDetailsL, err = %d <<"), err);
    User::LeaveIfError(err);
    }
コード例 #21
0
ファイル: Cafutils.cpp プロジェクト: cdaffara/symbiandump-os2
void TCafUtils::ReadDescriptor8L(RReadStream& aStream, TDes8& aBuffer)
	{
	aBuffer.SetLength(0);
	
	// Read the 8 bit data from a stream
	TInt dataLength = aStream.ReadInt32L();
	if(dataLength > aBuffer.MaxLength())
		{
		User::Leave(KErrOverflow);
		}
	if(dataLength > 0)
		{
		aStream.ReadL(aBuffer, dataLength);
		}
	}
コード例 #22
0
TInt CImConvertCharconv::StraightCopy( const TDesC& aBufIn, TDes8& rBufOut)
	{
	TInt inLen=aBufIn.Length();
	TInt outMaxLen=rBufOut.MaxLength();

	if (inLen >= outMaxLen)
		{
		TPtrC16 in = aBufIn.Left(outMaxLen);
		rBufOut.Copy(in);
		return (inLen-outMaxLen);
		}
	else
		rBufOut.Copy(aBufIn);
	return 0;
	}
コード例 #23
0
ファイル: padding.cpp プロジェクト: cdaffara/symbiandump-os2
EXPORT_C void CPadding::PadL(const TDesC8& aInput, TDes8& aOutput)
	{
	// Check that the input is small enough to fit inside one padded block
	// Won't leave if input text is equal to blocksize. Let DoPadL handle such situations
	if(aInput.Length() > BlockSize() - MinPaddingLength()
			&& aInput.Length() != BlockSize()) 	
		User::Leave(KErrArgument);
	
	// Check that the output descriptor supplied is large enough to store the result
	if(aOutput.MaxLength() < MaxPaddedLength(aInput.Length())) 	
		User::Leave(KErrOverflow);

	// Call the virtual function, implemented by derived classes
	DoPadL(aInput, aOutput);
	}
コード例 #24
0
ファイル: padding.cpp プロジェクト: cdaffara/symbiandump-os2
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));
	}
コード例 #25
0
/**
 Private Setter, used by the constructor and the assignment operator
 @param aDes Data buffer to create extended inquiry response from
 */
EXPORT_C void TExtendedInquiryResponseDataCodec::Set(TDes8& aDes)
	{
	LOG_FUNC
	// Check length consistency
	TUint16 length = ComputeSignificantLength(aDes);
	if(length > KNameRecord8BitMaxLength)
		{
		// Reset the EIR and discard any data it may contain, since it was malformed anyway
		iEir.Set(NULL, 0, 0);
		}
	else
		{
		iEir.Set(const_cast<TUint8*>(aDes.Ptr()), length, aDes.MaxLength());
		}
	}
コード例 #26
0
TBool TDebugFunctionality::GetStopModeFunctionality(TDes8& aDFBlock)
{
    TUint32 size = GetStopModeFunctionalityBufSize();
    if (aDFBlock.MaxLength() < size)
    {
        // Insufficient space to contain the debug functionality block
        return EFalse;
    }

    TUint8* ptr = (TUint8*)&size;
    aDFBlock.SetLength(0);
    aDFBlock.Append(ptr, 4);
    TVersion version = TVersion(KStopModeMajorVersionNumber, KStopModeMinorVersionNumber, KStopModePatchVersionNumber);
    ptr = (TUint8*)&version;
    aDFBlock.Append(ptr, sizeof(TVersion));

    AppendBlock((const TSubBlock&)StopModeFunctionalityCore,aDFBlock);
    AppendBlock((const TSubBlock&)StopModeFunctionalityFunctions,aDFBlock);
    AppendBlock((const TSubBlock&)StopModeFunctionalityList,aDFBlock);

    const TTagHeader& header = StopModeFunctionalityBuffers->iHeader;
    aDFBlock.Append((TUint8*)&header, sizeof(TTagHeader));

    for(TInt i=0; i<EBuffersLast; i++)
    {
        TTag tag;
        TheDBufferManager.GetBufferDetails((TBufferType)i, tag);
        aDFBlock.Append((TUint8*)&tag, sizeof(TTag));
    }

    if(aDFBlock.Length() != size - 4)
    {
        return EFalse;
    }

    TUint32* ptr32 = (TUint32*)aDFBlock.Ptr();
    TUint32 checksum = 0;
    for(TInt i=0; i<aDFBlock.Length(); i+=4)
    {
        checksum^=*ptr32;
        ptr32++;
    }

    ptr = (TUint8*)&checksum;
    aDFBlock.Append(ptr, 4);

    return ETrue;
}
コード例 #27
0
	void CStorageManager::ReadFromDiskL(TFileName& aFile, TDes8& aData, TBool& aFinished)
		/**
		Read data from a disk

		@param aFile - file to read
		@param aData - reference to a buffer to put the data from a file

		*/
		{
		RFile file;
		CleanupClosePushL(file);

		TInt err = file.Open(iTestStep->Fs(), aFile, EFileRead);
		if (err != KErrNone)
			{
			CleanupStack::PopAndDestroy(&file);
			User::Leave(err);
			}

		TInt size;
		file.Size(size);

		TInt availableSpace = aData.MaxLength() - aData.Length();

		if (availableSpace - (size - iBytesRead) >= 0)
			{
			aFinished = ETrue;
			}
		else
			{
			aFinished = EFalse;
			}

		err = file.Read(iBytesRead, aData);
		file.Flush();
		CleanupStack::PopAndDestroy(&file);

		User::LeaveIfError(err);

		if (aFinished)
			{
			iBytesRead = 0;
			}
		else
			{
			iBytesRead += availableSpace;
			}
		}
コード例 #28
0
ファイル: UM_BUF.CPP プロジェクト: cdaffara/symbiandump-os2
EXPORT_C void TDesBuf::Set(TDes8& aDes,TInt aMode)
/** Sets up the stream to use the specified descriptor.

@param aDes The descriptor that hosts the stream and that also acts as the 
intermediate buffer.
@param aMode The mode in which the buffer is to be used. It can be used in 
either or both read and write modes, represented by ERead and EWrite.
@see TDes8
@see MStreamBuf::TRead
@see MStreamBuf::TWrite */
	{
	iDes=&aDes;
	TUint8* ptr=(TUint8*)aDes.Ptr();
	SetBuf(ERead,(aMode&ERead)?ptr:NULL,ptr+aDes.Length());
	SetBuf(EWrite,(aMode&EWrite)?ptr:NULL,ptr+aDes.MaxLength());
	}
コード例 #29
0
TInt CPropertyList::GetCustomProperty(TUid aPropertyId, TDes8& aValue) const
	{
	TInt index = PropertyIndex(aPropertyId, Bookmark::EDataTypeDes8);
	if (index == KErrNotFound)
		{
		return KErrNotFound;
		}

	TDes8* desc8Ptr = static_cast<TDes8*>(iPropertyValues[index]);
	if (aValue.MaxLength() < desc8Ptr->Length())
		{
		return KErrArgument;
		}
	aValue = *desc8Ptr;
	return KErrNone;
	}
コード例 #30
0
ファイル: padding.cpp プロジェクト: cdaffara/symbiandump-os2
void CPaddingPKCS1Signature::UnPadL(const TDesC8& aInput,TDes8& aOutput)
	{
	// erm, oops, this is not quite as simplistic as it first looks...
	// our integer class will strip any leading zeros so we might actually
	// get some real data that starts out looking like padding but isn't 
	// really
	
	TInt inputLen = aInput.Length();
	if (inputLen <=0 )				
		User::Leave(KErrInvalidPadding);	//	Invalid padding data

	// Leading zero may have been stripped off by integer class
	TInt dataStart=0;
	if (aInput[dataStart] == 0)
		{
		++dataStart;
		}

	if (dataStart < inputLen && aInput[dataStart])		//	might be mode one or mode zero,
		{
		++dataStart;
		while (dataStart < inputLen && aInput[dataStart] == 0xff)
			{
			++dataStart;
			}
		
		if (dataStart == inputLen || aInput[dataStart])	//	this would mean theres no zero between 0x01ff and data...so its not mode one
			dataStart=0;			//	mode zero, start from begining of data
		else
			++dataStart;
		}
	else							//	We've definitely got a mode zero 
		{							//	or broken data, assume mode zero
		dataStart=0;		
		}

	TInt len=inputLen-dataStart;

	__ASSERT_DEBUG(aOutput.MaxLength() >= len, User::Panic(KCryptoPanic, ECryptoPanicOutputDescriptorOverflow));

	aOutput.SetLength(len);
	TInt i=0;
	while (dataStart<inputLen)
		{
		aOutput[i++]=aInput[dataStart++];
		}
	}