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

📄 dg_rtl.h

📁 该模块基于USB FX2开发板
💻 H
字号:
#ifndef __DG_RTL_H__
#define __DG_RTL_H__

//#ifdef  __cplusplus
//extern "C" {
//#endif
#include "Lock.h"

#define INC_LINE __FILE__, __LINE__
#define NON_LINE NULL, -1

extern CMutex g_UsbMutex[8];

//memcpy must be replaced by the below format
//memcpy(buf, pbData, min(cbData,BUFFER_SIZE));


/*
 * dg_snprintf 	it's something like the stdio function - snprintf(),
 *		the difference is that the function need input INC_LINE or NON_LINE as 
 *		the first parameter, other parameters are same as snprintf().
 *
 * @szFile, nLine - whether outputing the location of error or not.
 *		it should be the one of INC_LINE and NON_LINE.
 *		INC_LINE: outputing the location of error occuring.
 *		NON_LINE: not outputing it.
 *
 * sample for stresstest, salvation etc. :
	-----------------------------------
	char msg[256];
	//sprintf (msg, "%d %s", 100, "abc");
	//snprintf (msg, sizeof(msg), "%d %s", 100, "abc");
	dg_snprintf (INC_LINE, msg, sizeof(msg), "%d %s", 100, "abc");
	-----------------------------------
 */
int dg_snprintf(
	const char* szFile, int nLine, // replace with INC_LINE or NON_LINE
	char *buffer,
	size_t count,
	const char* format, ...
);

/*
 * dg_strcpy 	it's something like the stdio function - strcpy(),
 *		the difference is that the function need input INC_LINE or NON_LINE as 
 *		the first parameter and the maximum number of characters of destination
 *      buffer, other parameters are same as strcpy().
 *
 * @szFile, nLine - whether outputing the location of error or not.
 *		it should be the one of INC_LINE and NON_LINE.
 *		INC_LINE: outputing the location of error occuring.
 *		NON_LINE: not outputing it.
 * @count - Maximum number of characters to store. 
 *
 * sample for stresstest, salvation etc. :
	-----------------------------------
	char msg[256];
	//strcpy (msg, strSource);
	dg_strcpy (INC_LINE, msg, sizeof(msg), strSource);
	-----------------------------------
 */
int dg_strcpy(
	const char* szFile, int nLine, // replace with INC_LINE or NON_LINE
	char *strDest,
	size_t count, 
	const char *strSource
);

/*
 * dg_strcat 	it's something like the stdio function - strcat(),
 *		the difference is that the function need input INC_LINE or NON_LINE as 
 *		the first parameter and the maximum number of characters of destination
 *      buffer, other parameters are same as strcat().
 *
 * @szFile, nLine - whether outputing the location of error or not.
 *		it should be the one of INC_LINE and NON_LINE.
 *		INC_LINE: outputing the location of error occuring.
 *		NON_LINE: not outputing it.
 * @count - Maximum number of characters to store. 
 *
 * sample for stresstest, salvation etc. :
	-----------------------------------
	char msg[256];
	//strcat (msg, strSource);
	dg_strcat (INC_LINE, msg, sizeof(msg), strSource);
	-----------------------------------
 */
char *dg_strcat(
	const char* szFile, int nLine, // replace with INC_LINE or NON_LINE
	char *strDest,
	size_t count, 
	const char *strSource
);

//#ifdef  __cplusplus
//}
//#endif

#endif //__DG_RTL_H__

⌨️ 快捷键说明

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