예제 #1
0
void SocketLibEvent::close(bool force) {
	if (closing_) return;
	closing_ = true;

	if (force || getOutputLength() == 0) {
		closeReal();
	}
}
예제 #2
0
//
// 函数:encoder(const char *plain, unsigned int inLen, char * cipher, unsigned int& outLen)
//
// 目的:基于内存映像的加密
//      如果inBuf == outBuf,执行就地加密
//
bool YCBFEncryption::encode(const char *plain, unsigned int inLen, char * cipher, unsigned int& outLen)
{
	if (plain != cipher)
		memcpy(cipher, plain, inLen);
	
	outLen = getOutputLength(inLen);
	for(DWORD lCount = 0; lCount < outLen; lCount += 8)
	{
		// if padding is required.
		if (lCount + 8 > inLen)
		{
			// point at byte past the end of actual data
			char *po = (char*)cipher + (inLen - lCount);
			// padding with 255 (FF) characters.
			for(DWORD i = 0; i < (outLen - inLen); i++)
				*po++ = (char)0;
		}
		Enc_encipher((DWORD*)cipher, (DWORD*)(cipher + 4));
		cipher += 8;
	}
	return (outLen > 0);
}