Exemplo n.º 1
0
void CTRalcStep::TestClose()
	{
	// Check for open handles
	iThread.HandleCount(iEndProcessHandleCount, iEndThreadHandleCount);
	if(iStartThreadHandleCount != iEndThreadHandleCount)
		{__DEBUGGER()}							// Oops leaked some handles
	}
Exemplo n.º 2
0
void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine)
	{
	__DEBUGGER();
	TBuf8<256> buf;
	TSilentOverflow o;
	buf.AppendFormat(_L8("Assertion failed: \"%s\" in %s:%i\n"), &o, aAssertion, aFile, aLine);
	if (buf.Length()*2>buf.MaxLength()) buf.SetLength(buf.MaxLength()/2);
	console->Write(buf.Expand());
	User::Panic(_L("Fed"), aLine);
	}
Exemplo n.º 3
0
void TBitFieldAllocator::Free(TInt aValue)
	{
	TInt bitPos = aValue-iMin;
#ifdef _DEBUG
	if (!(iBitField & (1<<bitPos)))
		{
		// freeing an unclaimed bit - maybe due to a leave, but allow checking
		__DEBUGGER();
		}
#endif
	//Clear the bit in iSpace corresponding to aBitPos
	iBitField &= (~(1<<bitPos));	
	}
Exemplo n.º 4
0
void __DoTest(TBool aCondition, char* aFile, TInt aLine, TInt aErr)
	{
	if (aCondition)
		return;
		
	if (aErr==0)
		Test.Printf(_L("\r\nCheckpoint Fail at %s:%d\r\n"), aFile, aLine);
	else
		Test.Printf(_L("\r\nCheckpoint Fail at %s:%d: Return code = %d (0x%x)\r\n"), aFile, aLine, aErr, aErr);
	__DEBUGGER();
	Test.Getch();
	User::Exit(aErr);
	}
// -----------------------------------------------------------------------------
// CCbsTopicMessages::GetMessageContentsL
// Returns the content of the message to the client.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CCbsTopicMessages::GetMessageContentsL()
    {
    // Read the parameters from the client side.
    TPckgBuf< TCbsMessageHandle > pckgHandle( 0 );
    Message().ReadL( 0, pckgHandle );

    TInt bufSize( 0 );
    bufSize = Message().Int1();

    TCbsDbMessage message;
    iMessages.FindMessageByHandleL( pckgHandle(), message );
    
    if ( message.iLength != 0 )
        {
        // Message is not empty. 
        // First allocate memory and then get the contents.
        // Finally write data to client side.
        TInt size ( ( message.iLength < bufSize ) ? 
            message.iLength : bufSize );

        // guaranteed to allocate n bytes, n >= size
        HBufC* buffer = HBufC::NewLC( size );    // on CS

        TPtr16 pointer( buffer->Des() );
        pointer.Zero();

        // Note: parameter 'size' required, since MaxLength 
        // may be > bufSize
        iMessages.GetMessageContentsL( pckgHandle(), pointer, size );

#ifndef _DEBUG
        Message().WriteL( 2, pointer );
#else
        TRAPD( result, Message().WriteL( 2, pointer ) );
        if ( result != KErrNone )
            {
            RDebug::Print(_L("Server buffer length: %d, max: %d"), 
                pointer.Length(), pointer.MaxLength());
            __DEBUGGER();
            User::Leave( result );
            }
        
#endif
        CleanupStack::PopAndDestroy(); // buffer
        }

    // Complete the request.
    Message().Complete( KErrNone );
    }
Exemplo n.º 6
0
void CActiveReader::DoRead()
	{
#ifdef _EMULATOR_HWFC
	iPort.SetSignals(KSignalRTS,KSignalDTR);		//FIXME
#endif
	switch (iReadState)
		{
		case EReadHeader:
			iPort.Read(iStatus,iHeaderBuf, 1);
			break;

		case EReadOpcode:
			iPort.Read(iStatus,iOpcodeBuf, 2);
			break;

		case EReadCommandLength:
			iPort.Read(iStatus,iCommandLengthBuf, 1);
			break;

		case EReadDataLength:
			iPort.Read(iStatus,iDataLengthBuf, 2);
			break;

		case EReadConnectionHandleFlags:
			iPort.Read(iStatus,iConnectionHandleFlagsBuf, 2);
			break;

		case EReadCommandRemainder:
			{
			const TInt len = iCommandLengthBuf[0];
			iPort.Read(iStatus,iRemainderBuf, len);
			}
			break;

		case EReadDataRemainder:
			{
			const TUint16 len = static_cast<TUint16>((iDataLengthBuf[1] << 8) + iDataLengthBuf[0]);
			iPort.Read(iStatus,iRemainderBuf, len);
			}
			break;

		default:
			__DEBUGGER();
		}


	SetActive();
	}
Exemplo n.º 7
0
void CRemConAbsVolController::MrcibNewMessage(TUint aOperationId, const TDesC8& aData)
	{
	LOG_FUNC
	LOG1(_L("\taOperationId = 0x%02x"), aOperationId);
	LOG1(_L("\taData.Length = %d"), aData.Length());

	// Get the response error out of aData.
	if ( aData.Length() < KRemConExtApi1MinimumDataLength )
		{
		return; // ditch malformed messages
		}
	TInt err = static_cast<TInt>(aData.Ptr()[0]);

	switch ( aOperationId )
		{
	case ERemConGetAbsoluteVolume:
		{
		// 20 is the length of the abs volume data- 10 bytes for each of two 
		// '0x%08x'-formatted fields.
		if ( aData.Length() < KRemConExtApi1MinimumDataLength + 20 )
			{
			//Silently drop the message
			LOG(_L("Warning: Message is dropped due to invalid length!"));
			__DEBUGGER();
			return;
			}
		TUint absVol;
		TUint maxVol;
		if ( GetAbsMaxVol(aData.Mid(KRemConExtApi1MinimumDataLength, 20), absVol, maxVol) == KErrNone )
			{
			iObserver.MrcavcoGetAbsoluteVolumeResponse(absVol, maxVol, err);
			}
		}
		break;

	case ERemConSetAbsoluteVolume:
		iObserver.MrcavcoSetAbsoluteVolumeResponse(err);
		break;

	default:
		break;
		}
	}
Exemplo n.º 8
0
/**
Reports any errors occured while opening a file.
*/
void CCntPBAPSupport::ReportFileErrorL(TInt aErr, const TDesC& aFileName)
	{
	if (aErr == KErrNotFound)
		{
		_LIT(KMissingFile,"\r\n** FILE NOT FOUND: %S\r\n\r\n");
		test.Printf(KMissingFile, &aFileName);
		}
	else if (aErr == KErrPathNotFound)
		{	//You will get this error if you have not exported the test data files.
		_LIT(KMissingPath,"\r\n** PATH NOT FOUND: %S\r\n\r\n");
		test.Printf(KMissingPath, &aFileName);
		}
	else
		{
		_LIT(KError,"Error %d opening file %S\r\n");
		test.Printf(KError, aErr, &aFileName);
		}
	__DEBUGGER();
	User::Leave(aErr);
	}
Exemplo n.º 9
0
void CTestRandTerm::TimeComplete(TInt aStatus)
	{
	if (iTrace)
		Test.Printf(_L("CTestRandTerm::TimeComplete(%d)\r\n"), aStatus);

	if (aStatus!=KErrNone)
		{
		__DEBUGGER();
		return;
		}

	switch (iState)
		{
	case EWaitReset:
	    Test.Printf(_L("Waiting for Port\r\n"));
		iWriter->Ready();
		iTimer->After(1000000);
		iState = EWaitReady;
		break;
	case EWaitReady:
		if (++iRetries>10)
			{
			Test.Printf(_L("Too many retries\r\n"));
			Halt();
			}
		else
			{
			Test.Printf(_L("%c\r"), KSpinner[iSpin++ & 3]);
			iWriter->Ready();
			iTimer->After(1000000);
			}
		break;
	case EWaitIO:
		Fail(ETestFailBoth, KErrTimedOut);
		break;
	default:
		Reset();
		break;
		}
	}
Exemplo n.º 10
0
TInt CPanConnections::StopConnection()
	{
	TInt rerr = KErrNone;
	if(iActivePanConn >= iActiveConnections.Count())
		{
		rerr = KErrArgument;
		}
	else if(iActivePanConn != KErrNotFound)
		{
		// get the deivce we wish to disconnect
		TPtr8 ptr = iActiveConnections[iActivePanConn].Des();
		rerr = iConnection.Control(KCOLAgent, KCOAgentPanDisconnectDevice, ptr);
		if(rerr != KErrNone)
			{
			__DEBUGGER();
			}
		}
	else 
		{
		rerr = KErrNotFound;
		}
	return rerr;
	}
Exemplo n.º 11
0
void CActiveReader::RunL()
	{
	// the read has completed - for the moment we are not really interested at the moment

	if (iAuto)
		{
		switch (iReadState)
			{
			case EReadHeader:
				iReaderOutputConsole->Printf(_L("Header byte recvd\n"));
				iReadState = (DecodeHeader() == KHCIUARTCommandHeader ? EReadOpcode : EReadConnectionHandleFlags);
				break;
			case EReadOpcode:
				{
				iReaderOutputConsole->Printf(_L("Opcode bytes recvd\n"));
				TInt opcode = DecodeOpcode();
				if (opcode == 0)
					//NoOpCommand has no more parameters
					{
					iReadComplete = ETrue;
					iReadState = EReadHeader; // start again
					}
				else
					{
					iReadState = EReadCommandLength;
					}
				}
				break;
			case EReadCommandLength:
				iReaderOutputConsole->Printf(_L("Length byte recvd\n"));
				iReadState = EReadCommandRemainder;
				break;
			case EReadDataLength:
				iReaderOutputConsole->Printf(_L("Length byte recvd\n"));
				iReadState = EReadDataRemainder;
				break;
			case EReadConnectionHandleFlags:
				iReaderOutputConsole->Printf(_L("ConnectionHandle bytes recvd\n"));
				iReadState = EReadDataLength;
				break;
			case EReadCommandRemainder:
			case EReadDataRemainder:
				iReaderOutputConsole->Printf(_L("Remainder bytes recvd\n"));
				iReadComplete = ETrue;
				iReadState = EReadHeader; // start again
				break;

			default:
				__DEBUGGER();
			}
		
		if (iReadComplete)
			{
			iReaderOutputConsole->Printf(_L("Decoding...\n"));

			if (DecodeHeader() == KHCIUARTCommandHeader)
				{
				iReaderOutputConsole->Printf(_L("Decode: Command\n"));
				iEmulator.CommandReceived(iOpcodeBuf, iRemainderBuf);
				}
			else
				{
				iReaderOutputConsole->Printf(_L("Decode: ACL Data\n"));
				iEmulator.ACLDataReceived(iConnectionHandleFlagsBuf, iRemainderBuf);
				}
			iReadComplete = EFalse;
			}
				

		}

	// queue another one
	DoRead();
	}
Exemplo n.º 12
0
/**
 * Function called to Start a connection (IAP).
 */	
TInt CPanConnections::StartConnection(TBTDevAddr* aDevAddr, TBool aUsePANNotifier, TBool aUseTcpTransport)
	{
	TInt err = KErrNone;
	iUseTcpTransport = aUseTcpTransport;
	
	// Check if there is an existing IAP.
	if(iIapLoading == EFalse && iIapStarted == EFalse)
		{
		// No existing connection so configure IAP in CommDb and start IAP,
		// this is done by overriding RConnection's preferences with our IAP
		// information
		TRAP(err, ConfigureIAPL(ETrue, aDevAddr, aUsePANNotifier));
		if(err != KErrNone)
			{
			iConsole.Printf(_L("IAP Configuration Failed - %d.\n"), err);
			}
		else
			{
			err = StartIAP();
			if(err != KErrNone)
				{
				iConsole.Printf(_L("Failed to start IAP - %d.\n"), err);
				}
			}
		}
	else
		{
		#ifdef __NO_CONTROL_DURING_START__
			if(iIapLoading && aDevAddr != NULL)
				{
				// A new connection is required but a listening IAP is pending.
				Cancel();
				iConnection.Close();
			
				TRAP(err, ConfigureIAPL(ETrue, aDevAddr, aUsePANNotifier));
				if(err != KErrNone)
					{
					iConsole.Printf(_L("IAP Configuration Failed - %d.\n"), err);
					}
				else
					{
					err = StartIAP();
					if(err != KErrNone)
						{
						iConsole.Printf(_L("Failed to start IAP - %d.\n"), err);
						}
					}
				return err;
				}
		#endif			
		// An IAP already exists.
		// Make sure that we can store another connection
		if(iActiveConnections.Count() == 7)
			{
			err = KErrOverflow;
			}
		else if(aDevAddr)
			{
			// Add the BT address of the device to the existing RConnection
			iControlAddr = *aDevAddr;
			TPtr8 ptr = iControlAddr.Des();
			err = iConnection.Control(KCOLAgent, KCOAgentPanConnectDevice, ptr);
			if(err != KErrNone)
				{
				__DEBUGGER();
				}
			if (!iUseTcpTransport)
				{
				ReceiveRemoteName();
				}
			}
		}	
	return err;
	}
Exemplo n.º 13
0
// Method to find a named field within the Cache Control header
//
// In:
//  aField		- the field type
//
// Out:
//	the found aCacheControl string
//
// Rtn: TInt - set to KErrNotFound if the field was not found,
//		otherwise the position in the cache control descriptor that the field
//		was found
//
TInt CHTTPResponse::FindCacheControlFieldValue(TCacheControlFieldValue aField,
											   TPtrC8& aCacheControl) const
// Find a named field within the Cache Control header
	{
	__LOG_ENTER(_L("CHTTPResponse::FindCacheControlFieldValue"));
	TInt pos = KErrNotFound;
	TInt index = LocateField(EHttpCacheControl, 0);
    if (index >0)
        {
		// Have the cache control descriptor
		// Now we need to search for the field

		// The following rules are used to encode cache control values.
		// Cache-control-value	=	No-cache | No-store | Max-stale |
		//							Only-if-cached | Private | Public |
		//							No-transform | Must-revalidate | 
		//							Proxy-revalidate | Cache-extension | 
		//							Value-length Cache-directive
		// Cache-directive	=	No-cache 1*(Field-name) | 
		//						Max-age Delta-second-value |
		//						Max-stale Delta-second-value |
		//						Min-fresh Delta-second-value |
		//						Private 1*(Field-name) |
		//						Cache-extension Parameter
		TUint8 byteCode = iResponse->Des()[index];		// check the first byte for a recognised value
		if((byteCode >= 32) && (byteCode <= 127))
			{
			// Hit the start of a Header Name string - this will be assumed
			// continuous until the NUL is found or until the end
			// of the header is hit (which would be an error)
			// - not supported
			return pos;				
			}
		switch (byteCode)
			{
			case ECacheControlNoCache:		// "no-cache"
			case ECacheCtrlNoStore:			// "no-store"
			case ECacheCtrlMaxStale:		// "max-stale"
			case ECacheCtrlOnlyIfCached:	// "only-if-cached"
			case ECacheCtrlPublic:			// "public"
			case ECacheCtrlPrivate:			// "private"
			case ECacheCtrlNoTransform:		// "no-transform"
			case ECacheCtrlMustRevalidate:	// "must-revalidate"
			case ECacheCtrlProxyRevalidate:	// "proxy-revalidate"
				if( aField == byteCode )
					pos = index;			// Right here (right now).
				break;
			case ECacheCtrlCacheExtension:	// "cache-extension":
				break;						// Not handled
			default:
				{
			// Value-length Cache-directive
				if(FindBinaryDescField(EHttpCacheControl,aCacheControl))
					{
					TInt respLength = aCacheControl.Length();
					TUint8 byteCode = 0;
					for (TInt count = 0; count < respLength; count++)
						{
						byteCode = aCacheControl[count];
						if(aField == byteCode)
							{
							// Found the field we are looking for
							pos = count;
							break;
							}
						else if(count < (respLength - 1))	// Check for overrun... if this occurs it should be an error
							{
							if (byteCode <= 30)
								{
								// Codes 0-30 represent that number of following data
								// octets, check the cache directive field after the length
								if(aField == aCacheControl[count + 1])
									{
									// Found the one we want
									pos = count + 1;
									break;
									}
								else if(byteCode)
									{
									// so the following data octets should be skipped
									count += byteCode;
									}
								else
									{
									__DEBUGGER();
									count++;	// 0 data octets follow !???? : (Strange but true)
									}
								}
							else if (byteCode == 31)
								{
								// Code 31 indicates that the following bytes make a
								// UIntVar,  which indicates the number of data octets
								// after it. 
								// The UIntVar itself could be composed of upto 5 bytes
								// Copy a full 5 bytes from the header
								// Note that actually fewer might have been used; 
								// the UIntVar to Int converter function returns the exact
								// number that were used.
								TInt value = 0;
								TInt consumed = ParseUIntVar(aCacheControl.Mid(count + 1), value);
								
								if( consumed < KErrNone )
									return KErrCorrupt;
																
								if(aField == aCacheControl[count + 1 + consumed])
									{
									// Found the one we want
									pos = count + 1 + consumed;
									break;
									}
								else
									{
									// so the following data octets should be skipped
									count += 1 + consumed + value;
									}
								}
							}
						}
					}
				}
				break;
			}
		}
	__LOG_RETURN;
	return pos;
	}