⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
字号:
/***************************************************************************
 * Name        : debug.cpp
 * Title       : MBX WinCE driver GPE class
 * Author(s)   : Imagination Technologies
 * Created	   : 6th January 2003
 *
 * Copyright   : 2003 by Imagination Technologies. All rights reserved.
 *             : No part of this software, either material or conceptual 
 *             : may be copied or distributed, transmitted, transcribed,
 *             : stored in a retrieval system or translated into any 
 *             : human or computer language in any form by any means,
 *             : electronic, mechanical, manual or other-wise, or 
 *             : disclosed to third parties without the express written
 *             : permission of Imagination Technologies Limited, Unit 8,
 *             : HomePark Industrial Estate, King's Langley, Hertfordshire,
 *             : WD4 8LZ, U.K.
 *
 * Description : MBX WinCE driver GPE class.
 *
 * Platform    : WinCE
 *
 * Modifications:-
 * $Log: debug.cpp $
 *
 *
 ****************************************************************************/
#include	"precomp.h"
//#include	"debug.h"

// This constant is the size of the buffer that the printf style formatting
// is done in. Hope nothing overflows this!

#define MESSAGE_BUFFER_SIZE 1024

#ifdef DEBUG

wchar_t szwBuffer[MESSAGE_BUFFER_SIZE] = L"\0";
ULONG	ulOffset = 0;

/*****************************************************************************
 FUNCTION	: 	Dpf
 PURPOSE	:	
 PARAMETERS	: 	
 RETURNS	: 	
*****************************************************************************/
void Dpf( LPWSTR pszwFormat, ... )
{
	// MessageFunction
	// This function formats a message using printf-style formating and
	// then spews it out to the debug logging facility.

	// Local variables.

	va_list Parameters;

	if (ulOffset == 0)
	{
		ulOffset = wsprintf(szwBuffer, L"%s: ", dpCurSettings.lpszName);
	}

	va_start(Parameters, pszwFormat);
	_vsnwprintf(&szwBuffer[ulOffset], MESSAGE_BUFFER_SIZE, pszwFormat, Parameters);
	va_end(Parameters);

	wcscat(szwBuffer, L"\n");
	OutputDebugString( szwBuffer );
}


/*****************************************************************************
 FUNCTION	: 	fn_dpf
 PURPOSE	:	Used for tracing calls to the driver
 PARAMETERS	: 	
 RETURNS	: 	
*****************************************************************************/
#define BUFF_LEN 128
static TCHAR ptszStream[BUFF_LEN];
static char szStore[BUFF_LEN]={0}; // Initialise the first member to 0
static char szNew[BUFF_LEN];
static int nLen=0;
static int nStoreLen=0;

void fn_dpf(PSTR pszFormat, ...)
{
	va_list vararg_list;
	int nLen;

	va_start (vararg_list, pszFormat);
	
	// Note : these are not wide strings
	nLen = vsprintf (szNew, pszFormat, vararg_list);

	// Accumulate text until cr or overflow.
	if (nLen > 0)
	{
		if	(		(szNew[nLen-1] == '\r')
				||	(szNew[nLen-1] == '\n')
				||	((nLen+nStoreLen) > BUFF_LEN)
			)
		{
			// Prepare to output
			if ((szNew[nLen-1] == '\r') || (szNew[nLen-1] == '\n'))
			{
				szNew[nLen-1] = '\0';
			}

			// Combine and widen
			nLen = wsprintf( ptszStream, L"%hs%hs", szStore, szNew);

			// Flush to output
			if (nLen > 0)
			{
				OutputDebugString( ptszStream );
			}

			// Start again
			nStoreLen=0;
			nLen=0;
			szStore[0]='\0';
		}
		else
		{
			// Save for later
			strcat(szStore, szNew);
			nStoreLen += nLen;
		}
	}

	va_end(vararg_list);
}


#endif //#ifdef DEBUG


/********************************** end of file ******************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -