亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? lzss.c

?? 一個(gè)加密庫代碼
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/*
 * Copyright 1997-2005 Markus Hahn 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "cpkernel.h"
#include "LZSS.h"

#include <stdlib.h>
#include <memory.h>

// i/o exception codes
#define LZSS_EOB         257    // end of buffer
#define LZSS_EOD         258    // end of data


// some compressor constants
#define LZSS_N          4096    // size of ring buffer
#define LZSS_F            18    // upper limit for match_length
#define LZSS_THRESHOLD     2    // encode string into position and length
                                // if match_length is greater than this
#define LZSS_NIL      LZSS_N    // index for root of binary search trees



struct LZSSCTX 
{
  // state freeze for compression
  BYTEBOOL blSaveDone;
  int nSaveI, nSaveR, nSaveC, nSaveLen, nSaveS;
  int nSaveLastMatchLength, nSaveCodeBufPtr;
  WORD8 bSaveMask;
  WORD8 saveCode_buf[17];
  // state freeze for decompression (additional necessary data)
  int nSaveJ, nSaveK;
  WORD16 wSaveFlags;
  // the interrupt point code
  WORD16 wInterruptPoint;

  // general runtime stuff
  WORD8 text_buf[LZSS_N + LZSS_F - 1];      // ring buffer of size N, with
                                            // extra F-1 bytes to facilitate
                                            // string comparison
  int nMatchPosition, nMatchLength;   // of longest match.
  // these are set by the insertNode() procedure.
  int lson[LZSS_N + 1];     // left & right children & parents
  int rson[LZSS_N + 257];   // these constitute binary search trees
  int dad[LZSS_N + 1];
  // for readByte() and writeByte()
  WORD32 lSourceSize;
  WORD32 lDrainSize;
  WORD32 lBytesRead;
  WORD32 lBytesWritten;
  WORD8* pDataSource;
  WORD8* pDataDrain;
  // End Of Data (stream)
  BYTEBOOL blEOD;
};




PLZSSCTX CRYPTPAK_API LZSS_Create() 
{
#ifdef KERNEL_COMPILE
	return (PLZSSCTX)ExAllocatePool( NonPagedPool, sizeof(LZSSCTX)  );
#else
	return (PLZSSCTX) malloc(sizeof(LZSSCTX));
#endif
}


void CRYPTPAK_API LZSS_Destroy
  (PLZSSCTX pCtx) 
{
#ifdef KERNEL_COMPILE
	if (pCtx) ExFreePool( pCtx );
#else
	if (pCtx) free(pCtx);
#endif

}




// internal (de)compression routines...


// initialize trees
static void initTree(PLZSSCTX pCtx) 
{
    int nI;

    // for nI = 0 to LZSS_N - 1, rson[nI] and lson[nI] will be the right and
    // left children of node nI.  These nodes need not be initialized.
    // Also, dad[nI] is the parent of node nI.  These are initialized to
    // LZSS_NIL (= LZSS_N), which stands for 'not used.'
    // For nI = 0 to 255, rson[LZSS_N + nI + 1] is the root of the tree
    // for strings that begin with character nI.  These are initialized
    // to LZSS_NIL.  Note there are 256 trees.
    for (nI = LZSS_N + 1; nI <= (LZSS_N + 256); nI++) 
      pCtx->rson[nI] = LZSS_NIL;
    for (nI = 0; nI < LZSS_N; nI++) 
      pCtx->dad[nI] = LZSS_NIL;
}



// inserts a mode into tree
void insertNode
  (PLZSSCTX pCtx, 
   int nR) 
{
  // copy some context members to local members to
  // increase the execution speed
  WORD8* text_buf = pCtx->text_buf;
  int* lson = pCtx->lson;
  int* rson = pCtx->rson;
  int* dad = pCtx->dad;
  int nMatchPosition = pCtx->nMatchPosition;
  int nMatchLength = 0;

  // local variables
  WORD8* pKey = &text_buf[nR];
  int nI;
  int nP = LZSS_N + 1 + pKey[0];
  int nCmp = 1;

  // (Inserts string of length LZSS_F, text_buf[nR..nR + LZSS_F - 1], into one
  // of the trees (text_buf[nR]'th tree) and returns the longest-match position
  // and length via the global variables nMatchPosition and nMatchLength. If 
  // nMatchLength = F, then removes the old node in favor of the new one,
  // because the old one will be deleted sooner. Note nR plays double role, as
  // tree node and position in buffer.)

  lson[nR] = rson[nR] = LZSS_NIL;
  for (;;)
  {
    if (nCmp >= 0) 
    {
      if (rson[nP] != LZSS_NIL) 
        nP = rson[nP];
      else 
      {
        rson[nP] = nR;
        dad[nR] = nP;
        pCtx->nMatchPosition = nMatchPosition;
        pCtx->nMatchLength = nMatchLength;
        return;
      }
    }
    else 
    {
      if (lson[nP] != LZSS_NIL) 
        nP = lson[nP];
      else 
      {
        lson[nP] = nR;
        dad[nR] = nP;
        pCtx->nMatchPosition = nMatchPosition;
        pCtx->nMatchLength = nMatchLength;
        return;
      }
    }
    for (nI = 1; nI < LZSS_F; nI++) 
    {
      if ((nCmp = pKey[nI] - text_buf[nP + nI]) != 0)  break;
    }
    if (nI > nMatchLength) 
    {
      nMatchPosition = nP;
      if ((nMatchLength = nI) >= LZSS_F) break;
    }
  }
  dad[nR] = dad[nP];
  lson[nR] = lson[nP];
  rson[nR] = rson[nP];
  dad[lson[nP]] = nR;
  dad[rson[nP]] = nR;
  if (rson[dad[nP]] == nP) rson[dad[nP]] = nR;
  else                     lson[dad[nP]] = nR;
  dad[nP] = LZSS_NIL; // remove nP

  pCtx->nMatchPosition = nMatchPosition;
  pCtx->nMatchLength = nMatchLength;
}



// deletes node p from tree
void deleteNode(PLZSSCTX pCtx, int nP) {

  // copy some context members to local members to
  // to increase the execution speed
  int* lson = pCtx->lson;
  int* rson = pCtx->rson;
  int* dad = pCtx->dad;

  // local variable
  int nQ;

  // start...
  if (dad[nP] == LZSS_NIL) return;  // not in tree
  if (rson[nP] == LZSS_NIL) 
    nQ = lson[nP];
  else 
  {
    if (lson[nP] == LZSS_NIL)
      nQ = rson[nP];
    else 
    {
      nQ = lson[nP];
      if (rson[nQ] != LZSS_NIL) 
      {
        do 
        {
          nQ = rson[nQ];
        } 
        while (rson[nQ] != LZSS_NIL);

        rson[dad[nQ]] = lson[nQ];
        dad[lson[nQ]] = dad[nQ];
        lson[nQ] = lson[nP];
        dad[lson[nP]] = nQ;
      }
      rson[nQ] = rson[nP];
      dad[rson[nP]] = nQ;
    }
  }
  dad[nQ] = dad[nP];
  if (rson[dad[nP]] == nP) rson[dad[nP]] = nQ;
  else                     lson[dad[nP]] = nQ;
  dad[nP] = LZSS_NIL;
}



// internal stream i/o routines...


// reads a byte from the input buffer and checks if the 
// buffer run out of data
WORD16 readByte
  (PLZSSCTX pCtx) 
{
  // enough bytes?
  if (pCtx->lBytesRead < pCtx->lSourceSize)
    // return the actual byte in the buffer
    return pCtx->pDataSource[pCtx->lBytesRead++];
  if (pCtx->blEOD) 
    return LZSS_EOD; // end of data
  else 
    return LZSS_EOB; // end of buffer, but we'll be back
}




// writes a byte to the output buffer, used for compression,
// does no range check because compressed data won't be much
// larger (in the worst case) than the original data (and an
// additional check will cost too much overhead)
void cWriteByte
  (PLZSSCTX pCtx, 
   WORD8 bVal) 
{
  // just write the byte to the output buffer
  pCtx->pDataDrain[pCtx->lBytesWritten++] = bVal;
}



// writes a byte to the output buffer and checks if the buffer
// is full, used for decompression (because just a hundred of
// compressed bytes might create millions of original bytes)
BYTEBOOL dWriteByte
  (PLZSSCTX pCtx, 
   WORD8 bVal) 
{
  // enough free space?
  if (pCtx->lBytesWritten < pCtx->lDrainSize) 
  {
    pCtx->pDataDrain[pCtx->lBytesWritten++] = bVal;
    return BOOL_TRUE;
  }
  return BOOL_FALSE;
}



// macro to save the local variables in a context, used in LZSS_Compress()
#define COMPRESS_SAVE_LOCAL_VAR pCtx->blSaveDone = blDone;                     \
                                pCtx->nSaveI = nI;                             \
                                pCtx->nSaveC = nC;                             \
                                pCtx->nSaveLen = nLen;                         \
                                pCtx->nSaveR = nR;                             \
                                pCtx->nSaveS = nS;                             \
                                pCtx->nSaveLastMatchLength = nLastMatchLength; \
                                pCtx->nSaveCodeBufPtr = nCodeBufPtr;           \
                                pCtx->bSaveMask = bMask;                       \
                                memcpy(pCtx->saveCode_buf, code_buf, 17);



WORD32 CRYPTPAK_API LZSS_Compress
  (PLZSSCTX pCtx, 
   const void* pSource, 
   void* pTarget, 
   WORD32 lNumOfBytes, 
   WORD8 bCondition) 
{
  BYTEBOOL blDone;
  int nI, nC, nLen, nR, nS, nLastMatchLength, nCodeBufPtr;
  WORD8 bMask;
  WORD8 code_buf[17];
  WORD16 wTemp;  // (this variable must not be saved)

  // first setup the i/o pointers and the counters
  pCtx->pDataSource = (WORD8*) pSource;
  pCtx->pDataDrain = (WORD8*) pTarget;
  pCtx->lSourceSize = lNumOfBytes;
  pCtx->lBytesRead = 0;
  pCtx->lBytesWritten = 0;
  
  // end of data stream?
  if ((bCondition & LZSS_STOP) == LZSS_STOP) pCtx->blEOD = BOOL_TRUE;
  else pCtx->blEOD = BOOL_FALSE;

  // must we first launch the compression engine?
  if ((bCondition & LZSS_START) == LZSS_START)
  {
	  // (populate state things, otherwise the debug version will fail because
	  //  of assumed missing initialization)
	  nC = nLen = nR = nS = 0;
	  nLastMatchLength = nCodeBufPtr = 0;
	  goto ENTRYPOINT1;
  }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久亚洲国产美女国产盗摄 | 丰满少妇久久久久久久| 国产精品亲子伦对白| 精品视频一区三区九区| 国产成人精品一区二区三区四区| 亚洲妇熟xx妇色黄| 中文字幕二三区不卡| 欧美一区二区高清| 一本久道中文字幕精品亚洲嫩| 精品一区二区三区的国产在线播放| 日韩理论片在线| 久久久久久黄色| 欧美精品久久99久久在免费线| 成人黄色一级视频| 国产一区二区三区黄视频| 五月综合激情日本mⅴ| 亚洲少妇最新在线视频| 久久精品夜夜夜夜久久| 日韩女优电影在线观看| 欧美疯狂做受xxxx富婆| 欧美性大战久久久久久久蜜臀| 成人av在线资源| 国产凹凸在线观看一区二区| 日韩av在线免费观看不卡| 亚洲一区二区三区四区在线观看| 中文字幕一区二区三区不卡在线| 精品国产乱子伦一区| 欧美精品v国产精品v日韩精品 | 亚洲综合成人网| 亚洲色图制服诱惑 | 欧美伊人精品成人久久综合97| 成人综合婷婷国产精品久久免费| 久久不见久久见免费视频1| 婷婷久久综合九色综合伊人色| 一级做a爱片久久| 亚洲精品综合在线| 亚洲欧美偷拍卡通变态| 综合在线观看色| 中文字幕在线一区二区三区| 欧美国产日本视频| 中文字幕成人在线观看| 欧美激情综合网| 亚洲国产高清aⅴ视频| 日本一区二区视频在线| 国产精品萝li| 中文字幕日韩欧美一区二区三区| 国产精品久久99| 国产亚洲福利社区一区| 欧美国产亚洲另类动漫| 国产精品国产三级国产a| 国产精品福利一区二区| 中文字幕在线一区免费| 一区二区三区国产精华| 亚洲国产人成综合网站| 视频一区欧美精品| 日本欧美肥老太交大片| 久久99国产乱子伦精品免费| 国产在线不卡一区| 成人黄色综合网站| 欧美少妇一区二区| 日韩免费观看高清完整版| 国产午夜亚洲精品不卡| 男男gaygay亚洲| 久久99国产精品久久99果冻传媒| 国产真实乱子伦精品视频| 国产精品88av| 色婷婷国产精品久久包臀 | 欧美一级一级性生活免费录像| 日韩一区和二区| 国产视频一区二区在线| 中文字幕一区二区三区色视频 | 制服.丝袜.亚洲.另类.中文 | 欧美一区午夜视频在线观看| 欧美一区二区网站| 国产视频一区在线观看| 一区二区三区高清不卡| 美女一区二区视频| av中文字幕在线不卡| 欧美精品久久99久久在免费线| 久久综合久久久久88| 亚洲欧美日韩在线播放| 日本不卡视频一二三区| 成人午夜在线播放| 欧美精选午夜久久久乱码6080| 久久久国产精品午夜一区ai换脸| 中文字幕一区二区三区色视频| 日韩在线a电影| 成人动漫av在线| 制服丝袜日韩国产| 国产精品久久久久久福利一牛影视| 一区二区三区四区五区视频在线观看| 日日嗨av一区二区三区四区| 丁香婷婷深情五月亚洲| 9191成人精品久久| 国产精品国产三级国产aⅴ中文| 男人操女人的视频在线观看欧美| jizzjizzjizz欧美| 欧美成人精品二区三区99精品| 国产精品全国免费观看高清 | 一区二区三区色| 久久精品国产77777蜜臀| 色综合久久久久综合| 欧美精品一区二区三区高清aⅴ| 亚洲精品第一国产综合野| 国产在线不卡一卡二卡三卡四卡| 欧美三级一区二区| 亚洲欧美日韩国产成人精品影院| 久久aⅴ国产欧美74aaa| 欧美日韩小视频| 亚洲伦在线观看| 国产成人鲁色资源国产91色综| 欧美精三区欧美精三区| 亚洲激情网站免费观看| 成人激情校园春色| 精品国产99国产精品| 婷婷亚洲久悠悠色悠在线播放| 日本久久一区二区| 亚洲图片你懂的| 国产高清不卡二三区| 日韩一二三区视频| 丝袜美腿亚洲综合| 欧美日韩中文字幕一区二区| 亚洲精品国产一区二区精华液| 国产91精品在线观看| 久久久久久99精品| 国产一区在线不卡| 26uuu国产日韩综合| 久久99精品久久久久久久久久久久| 制服丝袜av成人在线看| 日韩高清在线不卡| 欧美三级电影一区| 午夜精品久久久久久不卡8050| 欧美亚洲综合另类| 亚洲综合色噜噜狠狠| 欧美主播一区二区三区美女| 一片黄亚洲嫩模| 欧美色图天堂网| 亚洲国产日韩a在线播放| 精品视频一区三区九区| 三级影片在线观看欧美日韩一区二区| 在线精品视频免费播放| 亚洲综合一二区| 欧美体内she精高潮| 亚洲一区二区五区| 91精品欧美久久久久久动漫| 日韩中文字幕不卡| 日韩一区二区精品在线观看| 精品综合免费视频观看| 久久无码av三级| 国产99精品视频| 中文字幕一区二区在线观看| 色综合天天综合网国产成人综合天| 综合分类小说区另类春色亚洲小说欧美 | 国产麻豆成人传媒免费观看| 国产视频亚洲色图| 99久久免费视频.com| 亚洲色图在线视频| 欧美三级乱人伦电影| 捆绑变态av一区二区三区| 久久久午夜精品| jlzzjlzz欧美大全| 亚洲大型综合色站| 亚洲国产sm捆绑调教视频| 日韩一区二区三区视频| 国产又黄又大久久| 中文字幕亚洲一区二区va在线| 欧美午夜寂寞影院| 韩国女主播成人在线| 国产精品成人在线观看| 欧洲av在线精品| 韩国精品一区二区| 亚洲人成影院在线观看| 91精品蜜臀在线一区尤物| 国产精品一二三四区| 亚洲欧美另类在线| 欧美一区二区三区的| 成人免费毛片嘿嘿连载视频| 亚洲宅男天堂在线观看无病毒| 精品久久免费看| 色菇凉天天综合网| 久久99精品国产麻豆婷婷| 亚洲美女屁股眼交| 久久―日本道色综合久久| 色综合久久综合中文综合网| 久草热8精品视频在线观看| 最近中文字幕一区二区三区| 日韩精品中文字幕一区| 91亚洲精品一区二区乱码| 麻豆精品新av中文字幕| 亚洲色图欧洲色图婷婷| 欧美大度的电影原声| 在线免费观看日本一区| 国产伦精品一区二区三区免费| 一区二区三区色| 日本一区二区三区久久久久久久久不| 欧美日韩高清影院| 色综合久久天天综合网| 国产精品一区不卡| 蜜桃av一区二区三区| 亚洲综合在线免费观看|