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

📄 cvjcompress.cpp

📁 PPP协议的实现演示
💻 CPP
字号:
/***************************************************************************                          cvjcompress.h  -  description                             -------------------    begin                : Wed Jun 6 2001    copyright            : (C) 2001 by stephane (birdy57)  &  Nicolas Jouanne    email                : birdy57@multimania.com ***************************************************************************/// Fichier original birdy57 + vjcompess de la rfc 1144// Modifier par Nicolas Jouanne pour une meilleur implementation au C++// (restructuration des source de la rfc1144 du c vers le C++)// et deboguage de l'enssemble !!/*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include "cvjcompress.h"#define mtod(m, t) ((t)(m->m_off))CVjcompress::CVjcompress(){    vjstruct = (struct slcompress *) new char[10500];    m_cTcpIpHeader = new CTcpIpHeader;    // testvjcompress    sl_compress_init(vjstruct);}CVjcompress::~CVjcompress(){}/** Decompresse une trame */unsigned short CVjcompress::Deflate(char *sBuffer, int nLen){    unsigned int nType;    char ssTmpBuffer[2000];    char *sTmpBuffer = &ssTmpBuffer[0];    char *pResult;    unsigned short nRet = nLen;// trame non compresse    if (sBuffer[0] != 0x45) {	if (sBuffer[0] != 0x75)	    nType = TYPE_COMPRESSED_TCP;	else {	    nType = TYPE_UNCOMPRESSED_TCP;	    sBuffer[0] = 0x45;	}	memcpy((sTmpBuffer + 200), sBuffer, nLen);	// demande de decompression	pResult =	    (char *) sl_uncompress_tcp((u_char *) (sTmpBuffer + 200), nLen,				       nType, vjstruct);	// trame non compresser ou erreur	if (pResult != NULL) {	    nRet += ((sTmpBuffer + 200) - pResult);	    memcpy(sBuffer, pResult, nRet);	}    }    return nRet;}/** Compress une trame TCP/IP */int CVjcompress::Compress(char *sBuffer, int nLon){    int nType, nRet;    mbuf mBuf;    nLon = TcpNormal(sBuffer, nLon);    nRet = nLon;// la compression    mBuf.m_off = (unsigned char *) sBuffer;    mBuf.m_len = nLon;    nType = sl_compress_tcp(&mBuf, vjstruct, 1);    if ((nType != TYPE_IP) && (nType != TYPE_ERROR)) {	nRet = mBuf.m_len;	// Type non compresser ? 0x75 sinon +0x80	(nType == TYPE_UNCOMPRESSED_TCP) ? (sBuffer[0] = 0x75) :	/* ici c du compresser */	    (sBuffer[0] += 0x80);    }    return nRet;}/** Reduit l'entete 

⌨️ 快捷键说明

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