bsdebug.c

来自「GZip Compress Souce Code」· C语言 代码 · 共 84 行

C
84
字号

#include "bsdebug.h"
#include <stdio.h>
#include <stdarg.h>

#define MS_DOS_DEBUG_OUT	1

#ifdef MS_DOS_DEBUG_OUT
#undef OutputDebugString
#undef UNICODE
#define OutputDebugString(a)	printf("%s", a);
#endif

static int tabCount = 0;

#define MY_CP_ACP 0
#define NUMofELMS(aa) (sizeof(aa)/sizeof((aa)[0]))



void DbgPrintfi(const char *_format, ...)
{
#if defined(_TRACEHELPER_DEBUG_ALL_) || defined(_TRACEHELPER_DEBUG_EACH_OF_FILE_)
	char str[2048];
	int i;
#ifdef _UNICODE
	wchar_t tstr[1024];
#endif
	va_list _ap; 	
   	va_start(_ap, _format);
	vsprintf(str,  _format, _ap);

#ifdef _UNICODE
	MultiByteToWideChar(MY_CP_ACP, 0, str, -1, tstr, NUMofELMS(tstr));	
	for(i=0; i < tabCount; i++)
		OutputDebugString(L"  ");

	OutputDebugString(tstr);
#else
	for(i=0; i < tabCount; i++)
		OutputDebugString("  ");
	
	OutputDebugString(str);
#endif

	tabCount++;

   	va_end(_ap);
#endif
}

void DbgPrintfo(const char *_format, ...)
{
#if defined(_TRACEHELPER_DEBUG_ALL_) || defined(_TRACEHELPER_DEBUG_EACH_OF_FILE_)
	char str[2048];
	int i;
#ifdef _UNICODE
	wchar_t tstr[1024];
#endif

	va_list _ap; 	
   	va_start(_ap, _format);
	vsprintf(str, _format, _ap);

	tabCount--;

#ifdef _UNICODE
	MultiByteToWideChar(MY_CP_ACP, 0, str, -1, tstr, NUMofELMS(tstr));	
	for(i=0; i < tabCount; i++)
		OutputDebugString(L"  ");

	OutputDebugString(tstr);
#else
	for(i=0; i < tabCount; i++)
		OutputDebugString("  ");
	
	OutputDebugString(str);
#endif

   	va_end(_ap);
#endif
}

⌨️ 快捷键说明

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