DebugPrint-1.0.0.2
来源:互联网 发布:for mac版什么意思 编辑:程序博客网 时间:2024/05/14 07:03
由于上一次的版本是只支持UNICODE编码的,这次经过改进让这个函数可以同时支持UNICODE字符集和多字节字符集,希,望大家多多指教……
/***
* debuglog.h - interface of the debugprint
*
* Copyright (c) 2009 by zfwolf <AsmSdk@hotmail.com>.
*
* This program is free software: you can redistribute it and modify it under
* the terms of the GNU General Public License as published by the Free Soft-
* ware foundation, either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITH-
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/
#ifndef __DEBUG_LOG_H__
#define __DEBUG_LOG_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <windows.h>
#include <tchar.h>
#if !defined(_DEBUG_LOG_)
#define __DEBUG_PRINT_LOG__
#endif /* _DEBUG_LOG_ */
extern void DebugPrint(LPCTSTR fmt, ...);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DEBUG_LOG_H__ */
其具体实现如下:
/***
* debugprint.c - implementation of the debugprint
*
* Copyright (c) 2009 by zfwolf <AsmSdk@hotmail.com>.
*
* This program is free software: you can redistribute it and modify it under
* the terms of the GNU General Public License as published by the Free Soft-
* ware foundation, either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITH-
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/
#include "debuglog.h"
#include <stdio.h>
#include <sys/timeb.h>
#include <time.h>
static BOOL g_bTakeControl = FALSE; /* take control of the display */
/***
* extern void DebugPrint(LPCTSTR fmt, ...)
*
* Purpose:
* this function to display the debug information into the file of
* 'debug.log'
*
* Entry:
* @param1 LPCTSTR fmt
* @param2 ...
*
* Exit: <void>
*
* Exceptions:
*************************************************************************/
extern void DebugPrint(LPCTSTR fmt, ...)
{
#ifdef __DEBUG_PRINT_LOG__
TCHAR* lpBuffer = NULL; /* buffer to display */
int size = 0; /* bytes of buffer */
int len = 0; /* len of buffer */
FILE* pFile = NULL;
va_list pArgs = NULL;
struct tm* pTm = NULL;
struct timeb tmb;
while (g_bTakeControl)
Sleep(100);
g_bTakeControl = TRUE;
va_start(pArgs, fmt);
len = _vsctprintf(fmt, pArgs) + 1;
size = len * sizeof(TCHAR);
if (NULL == (lpBuffer =
HeapAlloc(GetProcessHeap(), 0, size)))
return;
memset(lpBuffer, 0, size);
_vstprintf(lpBuffer, fmt, pArgs);
va_end(pArgs);
if (NULL == (pFile = _tfopen(_T("debug.log"), _T("a+"))))
return;
memset(&tmb, 0, sizeof(struct timeb));
ftime(&tmb);
pTm = localtime(&tmb.time);
_ftprintf(pFile, _T("(%.4d-%.2d-%.2d %.2d:%.2d:%.2d:%.3d) --- %s/n"),
pTm->tm_year + 1900, pTm->tm_mon + 1, pTm->tm_mday,
pTm->tm_hour, pTm->tm_min, pTm->tm_sec, tmb.millitm,
lpBuffer);
if (NULL != pFile) {
fclose(pFile);
pFile = NULL;
}
if (NULL != lpBuffer) {
HeapFree(GetProcessHeap(), 0, lpBuffer);
lpBuffer = NULL;
}
g_bTakeControl = FALSE;
#endif /* __DEBUG_PRINT_LOG__ */
}
- DebugPrint-1.0.0.2
- DebugPrint - 1.0.0.3
- DebugPrint
- DebugPrint
- debugPrint-1.1
- debugPrint-1.2
- debugPrint-1.3
- debugPrint-1.4
- DebugPrint 格式说明符
- DebugPrint和字符串转换
- DebugPrint格式输出
- 1.0.0.2
- Office Password Remover 1.0.0.2 汉化版
- 从Jboss4.0.2迁移到Jboss5.1.0
- 发布VB6安全多线程组件MT32.dll(1.0.0.2)
- GifOleControl.dll 1.0.0.2 支持unicode和ASCII
- 更新打印控件vWebPrint.ocx至1.0.0.2版
- OCM_简化安装oracle10.2.0.1.0以及升级为10.2.0.2.0
- JAVA/JSP编程规范参考
- 【经典】Java排序汇总
- eclipse
- 笔记本故障及解决办法总结
- 网工笔记之交换技术
- DebugPrint-1.0.0.2
- 《C语言也能干大事》19节:C语言也能开发网站
- gcc和vc在定义结构时的一点区别
- 人际交往
- 1
- Java Annotation入门
- 心情
- Java 5.0 Tiger 之 Annotation学习
- C中的可变参数研究