| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | 
							- #include "stdafx.h"
 
- #include "SuperBuffer.h"
 
- int CSuperBuffer::HasPack()
 
- {
 
- 	static DWORD64 headid = 0xABAAAAAAAAAAAAAA;
 
- 	int i, nStart = -1;
 
- 	//find pack head
 
- 	for (i = 0; i < m_nPos - 1 && m_nPos > 4; i++)
 
- 	{
 
- 		if (*(DWORD64*)(m_pBuffer + i) == headid)
 
- 		{
 
- 			nStart = i;
 
- 			break;
 
- 		}
 
- 	}
 
- 	if (nStart == -1)
 
- 	{
 
- 		m_nPos = 0;
 
- 		return 0;
 
- 	}
 
- 	else if (nStart > 0)
 
- 	{
 
- 		m_nPos -= nStart;
 
- 		memmove(m_pBuffer, m_pBuffer + nStart, m_nPos);
 
- 		nStart = 0;
 
- 	}
 
- 	int nlen = 0;
 
- 	//find pack tail
 
- 	DWORD nLen = htonl(*(DWORD*)(m_pBuffer + sizeof(headid)));
 
- 	if ((DWORD)m_nPos >= sizeof(HJDATAHEAD2) + nLen + 2)
 
- 	{
 
- 		if (m_pBuffer[sizeof(HJDATAHEAD2) + nLen] == 0x00 && m_pBuffer[sizeof(HJDATAHEAD2) + nLen + 1] == 0xab)
 
- 		{
 
- 			nlen = sizeof(HJDATAHEAD2) + nLen + 2;
 
- 		}
 
- 		else
 
- 		{
 
- 			ASSERT(0);
 
- 			m_nPos = 0;
 
- 		}
 
- 	}
 
- 	return nlen;
 
- }
 
 
  |