コード例 #1
0
ファイル: EcmtMMCEvent.cpp プロジェクト: fedor4ever/packaging
// -----------------------------------------------------------------------------
// CEcmtMMCEvent::WinsRemovableDrivesL
// Public method to get descrpitor containing removable drives
// -----------------------------------------------------------------------------
//
void CEcmtMMCEvent::WinsRemovableDrivesL( TDes8& aBuff )
	{
	//update list to get number of drives up to date
	iWinsRemDrives->UpdateRemDrives();
	//allocate space for drive letters string
	char* drives = new char[sizeof(char)* 3* iWinsRemDrives->NumOfDrives()+1];
	User::LeaveIfNull( drives );
	//get letters
	iWinsRemDrives->GetRemovableDrives( drives );
	const TPtrC8 iWinsDrives( (const TUint8*) drives, (TInt) strlen(drives) );
	aBuff.Copy( iWinsDrives );
	//remove / from string
	TChar ch('\\');
	TInt pos=aBuff.Locate( ch );
	while ( pos != KErrNotFound )
	{
		aBuff.Replace( pos, 1, KBlank );
		pos=aBuff.Locate( ch );
	}
		
	delete [] drives;
	}
コード例 #2
0
void CImSmtpSession::GetIpAddress(TDes8& aAddress)
/** Gets the local IP address from the socket without any trailing scope identifiers
@param aAddress Buffer in which the IP address of the socket will be returned */
	{
    aAddress.Copy(iSocket->LocalName());

    // Remove the %nn scope identifier if present Eg. x.x.x.x.x.x%1 becomes x.x.x.x.x.x
	//  This only occurs with IPv6 and was a requirement of multi-homing.
	TInt pos = aAddress.Locate(TChar('%'));
	if (pos>0)
		{
		aAddress.SetLength(pos);
		}
	}
コード例 #3
0
ファイル: utils.cpp プロジェクト: cdaffara/symbiandump-os1
TInt ParseMixedBinaryAsciiDataL(TDes8& aTextToConvert)
/**
Parses aTextToConvert based on the following rules:
'\\' (double backslash) is used to denote a single '\'
(single backslash)
'\xnn' denote a byte of binary data where nn is in hex-decimal.
The '\xnn' in aTextToConvert is replaced by the binary byte
that it represents.

For example: If aTextToConvert contains "abc\\def\xFF",
after parsing, it will contain "abc\def?" where ? = 0xFF.

@param aTextToConvert Modifiable buffer which will be parsed. 

@return KErrNone if aTextToConvert is in valid
        EAdditionalParamDataFormatMixedBinaryAndAscii format.
        KErrArgument if aTextToConvert is in an incorrect format.

@panic KErrNoMemory if there is not enough memory to do the parsing.
*/
	{
	// Pointer to unparsed portion of additionalParamDataBuffer
	HBufC8* resultBuffer = HBufC8::NewLC(aTextToConvert.Length());

	__ASSERT_ALWAYS(resultBuffer, PanicClient(KErrNoMemory));
	
	TPtr8 result(resultBuffer->Des());
	
	// Position of backslash
	TInt pos = 0;

	while ((pos = aTextToConvert.Locate('\\')) != KErrNotFound)
		{
		// Check that the backslash is followed by at least one more character
		if ((pos+1) >= aTextToConvert.Length())
			{
			return KErrArgument;
			}

		TUint8 modifier = aTextToConvert[pos+1];

		// Parse depending on character after the backslash
		switch (modifier)
			{
		case '\\':
			// Next character after the '\' is another '\'.
			// Replace it with a single '\' and move
			// on.
			result.Append(aTextToConvert.Left(pos+1));
			aTextToConvert.Delete(0, pos+2);
			break;
		case 'x':
			// Next character is an 'x' so check that there are three 
			// characters after the backslash (one for the x and two
			// characters of HEX.
			if ((pos+3) >= aTextToConvert.Length()) 
				{
				return KErrArgument;
				}
			// Convert those to HEX and replace '\xNN' with this.
			result.Append(aTextToConvert.Left(pos));
			TUint8 hexAsInt;
			if (AsciiHexToNum(aTextToConvert.MidTPtr(pos+2,2), hexAsInt) != KErrNone)
				{
				return KErrArgument;
				}
			// Append the raw byte to the result
			result.SetLength(result.Length()+1);
			result[result.Length()-1] = hexAsInt;
			aTextToConvert.Delete(0, pos+4);
			break;		
			}
		} // End while
	aTextToConvert.Insert(0, result);
	
	CleanupStack::PopAndDestroy(resultBuffer);
	return KErrNone;
	}