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

📄 litaopacket.cpp

📁 一个SGIP网关的程序源码.vc代码
💻 CPP
字号:
// LitaoPacket.cpp: implementation of the CLitaoPacket class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SGIPGateWay.h"
#include "LitaoPacket.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLitaoPacket::CLitaoPacket()
{

}

CLitaoPacket::~CLitaoPacket()
{

}
int CLitaoPacket::GetPacket(BYTE *lpBuffer, LPCTSTR strSender, LPCTSTR strSendTo, LPCTSTR strMsg)
{
	if( !lpBuffer )
		return 0;
	_SMPacket sp;
	memset(&sp, 0, sizeof(sp));
	sp.nHeader = 0x21212121;
	sp.strSender[0] = strlen(strSender);
	memcpy(&sp.strSender[1], strSender, sp.strSender[0]&0xff);
	sp.strSendTo[0] = strlen(strSendTo);
	memcpy(&sp.strSendTo[1], strSendTo, sp.strSendTo[0]&0xff);
	sp.strMsg[0] = strlen(strMsg);
	memcpy(&sp.strMsg[1], strMsg, sp.strMsg[0]&0xff);
	memcpy(lpBuffer, &sp, sizeof(sp));

	return sizeof(sp);
}
void CLitaoPacket::ParsePacket(BYTE *lpBuffer, LPTSTR strSender, LPTSTR strSendTo, LPTSTR strMsg)
{
	if( !lpBuffer )
		return;
	_SMPacket sp;
	memcpy(&sp, lpBuffer, sizeof(sp));
	if( strSender )
	{
		memcpy(strSender, &sp.strSender[1], sp.strSender[0]&0xff);
		strSender[sp.strSender[0]&0xff] = 0;
	}
	if( strSendTo )
	{
		memcpy(strSendTo, &sp.strSendTo[1], sp.strSendTo[0]&0xff);
		strSendTo[sp.strSendTo[0]&0xff] = 0;
	}
	if( strMsg )
	{
		memcpy(strMsg, &sp.strMsg[1], sp.strMsg[0]&0xff);
		strMsg[sp.strMsg[0]&0xff] = 0;
	}
}

⌨️ 快捷键说明

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