コード例 #1
0
// -----------------------------------------------------------------------------
// CUpnpHttpChunkParser::ParseL
// Decoding the chunked-encoded buffer
// -----------------------------------------------------------------------------
//
TBool CUpnpHttpChunkParser::ParseExtension( TDes8& aBuffer, TInt& aPos )
    {	
    if ( IsEmpty( aBuffer, aPos ) )
        {	    
        return ETrue;	
        }

    //if '\r\n' exists
    TInt lineFeed = aBuffer.Right( aBuffer.Length() - aPos ).FindF( UpnpString::KLineFeed );
    if ( lineFeed != KErrNotFound )
        {
        aBuffer.Delete( aPos, lineFeed + UpnpString::KLineFeed().Length() );		
        if ( !iChunkSize )
            {
            iContext = ETrailer;
            return EFalse;		
            }
        else
            {
            iContext = EBody;
            return EFalse;
            }		
        }
    else
        {
        //one character left - possible linefeed
        if ( aPos + 1 < aBuffer.Length() )
            {            
            aBuffer.Delete( aPos, aBuffer.Length() - aPos - 1 );
            }
        return ETrue;
        }
    }
コード例 #2
0
ファイル: Utils.cpp プロジェクト: fedor4ever/testfw
void CUtils::StripSpaces(TDes8& aText)
	{
	TInt i;
	for (i=0; i<aText.Length(); i++)
		if (aText[i] != ' ')
			break;
	if (i)
		aText.Delete(0,i);
	for (i=aText.Length()-1; i>=0; i--)
		if (aText[i] != ' ')
			break;
	if (i != aText.Length()-1)
		aText.Delete(i+1,aText.Length()-1-i);
	}
コード例 #3
0
// -----------------------------------------------------------------------------
// UpnpAVCPEngine::RemoveSlashes
// -----------------------------------------------------------------------------
//   
void RemoveSlashes(TDes8& aPath) 
	{
	if (aPath.Length() > 0 && aPath[0] == '/' ) 
		{        
		aPath.Delete(0,1);
		}

	// remove ending '/' 
	TInt length = aPath.Length();                
	if (length > 0 && aPath[length-1] == '/' ) 
		{
		aPath.Delete(length-1,1);   
		}	   
	}
コード例 #4
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();
	}
コード例 #5
0
ファイル: asf.cpp プロジェクト: kuailexs/symbiandump-mw1
// -----------------------------------------------------------------------------
// CAsf::FormatGUID
// -----------------------------------------------------------------------------
//
void CAsf::FormatGUID( TDes8 &aGUID )
    {
    LOGFN( "CAsf::FormatGUID" );

    TBuf8<16> copyGUID( aGUID );
    TInt i;
    for( i = 0; i < 4; i++ )
        {
        copyGUID[i] = aGUID[3-i];
        }
    for( i = 4; i < 6; i++ )
        {
        copyGUID[i] = aGUID[9 - i];
        }
    for ( i = 6; i < 8; i++ )
        {
        copyGUID[i] = aGUID[13 - i];
        }
    for( i = 8; i < 16 ; i++ )
        {
        copyGUID[i] = aGUID[i];
        }
    aGUID.Delete( 0, 32 );
    for( i = 0; i < 16; i++ )
        {
        aGUID.AppendNumFixedWidthUC( copyGUID[i], EHex, 2 );
        }
    }
コード例 #6
0
ファイル: SocketEngine.cpp プロジェクト: rusteer/symbian
void DeleteBlank(TDes8& aData){
  if(aData.Length()<=0) return;
  _LIT8(KBlank," ");
  TInt pos=aData.FindF(KBlank);
  if(-1!=pos){
    aData.Delete(pos,KBlank().Length());
    DeleteBlank(aData);
  }
}
コード例 #7
0
// -----------------------------------------------------------------------------
// CUpnpContentHandlersController::RemoveForbiddenCharacters
// Removes forbidden characters
// -----------------------------------------------------------------------------
//
void CUpnpContentHandlersController::RemoveForbiddenCharacters( TDes8& aDescription )
    {    
    for( TInt i=0; i<aDescription.Length(); i++ )
        {
        if ( ( aDescription[i] <= KUtfLowMax ) ||
            ( aDescription[i] >= KUtfHighMin && aDescription[i] <= KUtfHighMax ) )
            {
            aDescription.Delete( i, 1 );
            i--;
            }
        }
    }
コード例 #8
0
// -----------------------------------------------------------------------------
// CUpnpHttpChunkParser::ParseL
// Decoding the chunked-encoded buffer
// -----------------------------------------------------------------------------
//
TBool CUpnpHttpChunkParser::ParseTrailer( TDes8& aBuffer, TInt& aPos )
	{		
    if ( IsEmpty( aBuffer, aPos ) )
        {	    
        return ETrue;
        }
    //if double '\r\n' exists
    TInt doublelineFeed = aBuffer.Right( aBuffer.Length() - aPos ).FindF( UpnpString::KDoubleLineFeed );
    if (doublelineFeed != KErrNotFound ) 
        {
        aBuffer.Delete( aPos, doublelineFeed + UpnpString::KDoubleLineFeed().Length() );		
        iContext = EFinish;
        return ETrue;	
        }
    else
        {
        //waiting,3 characters reserved for double linefeed
        if ( aPos + UpnpString::KCRLFCRLength < aBuffer.Length() )
            {            
            aBuffer.Delete( aPos, aBuffer.Length() - aPos - UpnpString::KCRLFCRLength );
            }
        return ETrue;	
        }
    }
コード例 #9
0
// -----------------------------------------------------------------------------
// CUpnpHttpChunkParser::ParseL
// Decoding the chunked-encoded buffer
// -----------------------------------------------------------------------------
//
TBool CUpnpHttpChunkParser::ParseBody( TDes8& aBuffer, TInt& aPos )
	{	
    if ( IsEmpty( aBuffer, aPos ) )
        {	    
        return ETrue;
        }

    TPtrC8 pointer( aBuffer.Right( aBuffer.Length() - aPos ) );	

    if ( iBytesAppended + pointer.Length() >= iChunkSize )
        {	
        aPos += ( iChunkSize - iBytesAppended );		
        pointer.Set( aBuffer.Right( aBuffer.Length() - aPos ) );
        TInt lineFeed = pointer.FindF(UpnpString::KLineFeed());		
        //linefeed found
        if ( !lineFeed )
            {			
            aBuffer.Delete( aPos, UpnpString::KLineFeed().Length() );
            iContext = EEndChunkBody;	
            return ( aPos == aBuffer.Length() );
            }
        //linefeed not found, end of buffer	
        else if ( lineFeed == KErrNotFound && 
                ( ( aPos + UpnpString::KLineFeed().Length() ) > aBuffer.Length() )
                )
            {			
            iBytesAppended = iChunkSize; 				
            return ETrue;
            }
        //size doesn't comply with the header value
        iError = KErrGeneral;	
        iContext = EError;	
        return EFalse;	
        }
    else
        {
        iBytesAppended += pointer.Length();
        aPos = aBuffer.Length();
        return ETrue;
        }		
    }
コード例 #10
0
// -----------------------------------------------------------------------------
// CUpnpHttpChunkParser::ParseL
// Decoding the chunked-encoded buffer
// -----------------------------------------------------------------------------
//
TBool CUpnpHttpChunkParser::ParseLastChunk( TDes8& aBuffer, TInt& aPos )
    {		
    //if empty or only one character present
    if ( (aBuffer.Length() - aPos) < UpnpString::KLineFeedLength )
        {	    
        return ETrue;
        }
    //if '\r\n' exists
    TInt lineFeed = aBuffer.Right( aBuffer.Length() - aPos ).FindF( UpnpString::KLineFeed );
    if ( !lineFeed )
        {
        aBuffer.Delete( aPos, lineFeed + UpnpString::KLineFeed().Length() );		
        iContext = EFinish;
        return ETrue;		
        }
    else
        {
        iContext = ETrailer;
        return EFalse;		
        }		

    }	
コード例 #11
0
// -----------------------------------------------------------------------------
// CUpnpHttpChunkParser::ParseL
// Decoding the chunked-encoded buffer
// -----------------------------------------------------------------------------
//
TBool CUpnpHttpChunkParser::ParseHeader( TDes8& aBuffer, TInt& aPos )
	{
    if ( IsEmpty( aBuffer, aPos ) )
        {	    
        return ETrue;
        }
    iChunkSize = KErrNotFound;
    iBytesAppended = 0;
    TPtrC8 pointer(NULL,0);
    //if '\r\n' exists
    TInt lineFeed = aBuffer.Right( aBuffer.Length() - aPos ).FindF( UpnpString::KLineFeed );
    //if ';' exists
    TInt semiColon = aBuffer.Right( aBuffer.Length() - aPos ).FindF( UpnpString::KSemiColon );
    //semicolon ignored if occurs after the linefeed
    if ( semiColon !=KErrNotFound && lineFeed !=KErrNotFound && lineFeed<semiColon )
        {
        semiColon = KErrNotFound;
        }
    if ( semiColon !=KErrNotFound )
        {		
        pointer.Set(aBuffer.Right( aBuffer.Length() - aPos ).Mid( 0,semiColon ) );		
        }
    else if ( lineFeed !=KErrNotFound )
        {
        pointer.Set( aBuffer.Right( aBuffer.Length() - aPos ).Mid( 0,lineFeed ) );		
        }
    else
        {
        pointer.Set( aBuffer.Right( aBuffer.Length() - aPos ) );		
        }

    TLex8 lex( pointer );	
    //skip white spaces	
    lex.SkipSpace();
    TUint size;
    //neither semicolon nor linefeed found
    if ( lineFeed == KErrNotFound && semiColon == KErrNotFound )
        {
        //remember the num of cut spaces
        TInt len = lex.Offset();
        if ( !lex.Eos() )
            {
            //check the chunk header size for the limit
            TInt error = lex.Val( size, EHex );			
            if ( error!= KErrNone || size > KMaxTInt )	
                {
                //size too big
                iError = ( error ) ? error: EHttpInsufficientStorage;
                iContext = EError;
                return EFalse;
                }			
            }

        aBuffer.Delete( aPos,len );
        return ETrue;
        }
			
    //get size	
    TInt error = lex.Val( size, EHex );
    if ( error!= KErrNone || size > KMaxTInt )
        {
        //unexpected characters or size too big
        iError = ( error ) ? error: EHttpInsufficientStorage ;
        iContext = EError;
        return EFalse;
        }	
    iChunkSize = size;	
    //skip white spaces	
    lex.SkipSpace();	
    if ( !lex.Eos() )
        {
        //unexpected characters
        iError = KErrGeneral;
        iContext = EError;
        return EFalse;
        }
    if ( lineFeed != KErrNotFound )
        {
        //the whole chunk header is parsed
        aBuffer.Delete( aPos, lineFeed + UpnpString::KLineFeed().Length() );
        //chunk size == 0
        if ( !iChunkSize )
            {        
            iContext = ELastChunk;
            }
        else
            {        
            iContext = EBody;
            }
        return ( aPos == aBuffer.Length() );
        }
    else if ( semiColon != KErrNotFound )
        {
        //extension found, 
        //one character left - possible linefeed
        if ( aPos<aBuffer.Length() )
            {            
            aBuffer.Delete( aPos, aBuffer.Length() - aPos - 1 );		
            }
        iContext = EExtension;
        return ETrue;	
        }
        
    iError = KErrUnknown;	
    iContext = EError;	
    return EFalse;		    	
    }
コード例 #12
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;
	}