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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lzss.c

?? 一個加密庫代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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;
  }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产亚洲午夜高清国产拍精品| 国产亲近乱来精品视频| 欧美一级高清片| 亚洲国产精品精华液2区45| 亚洲欧美日韩国产综合| 日本欧美在线看| 91在线精品一区二区三区| 日韩一区二区精品在线观看| 自拍av一区二区三区| 男男gaygay亚洲| 欧美自拍丝袜亚洲| 欧美国产日产图区| 精品亚洲aⅴ乱码一区二区三区| 一本到高清视频免费精品| 久久亚洲免费视频| 蜜臀91精品一区二区三区| 欧美午夜影院一区| 中文字幕中文在线不卡住| 国产中文字幕精品| 欧美一级久久久久久久大片| 亚洲欧美激情一区二区| 成人国产精品免费观看| 欧美精品一区二区久久久| 视频一区二区不卡| 欧美男男青年gay1069videost | 中文一区在线播放 | 国产精品久久久久永久免费观看 | 91精品国产91热久久久做人人| 国产精品视频第一区| 老司机午夜精品| 欧美一区二区三区性视频| 亚洲成年人影院| 精品视频资源站| 麻豆国产欧美一区二区三区| 欧美男生操女生| 亚洲国产一区视频| 欧美日本视频在线| 亚洲妇熟xx妇色黄| 宅男噜噜噜66一区二区66| 午夜日韩在线电影| 日韩一区二区在线播放| 日本中文字幕不卡| 欧美一区二视频| 精品亚洲成a人在线观看| 久久日韩精品一区二区五区| 国产在线精品一区二区不卡了| 精品国产乱码91久久久久久网站| 人人精品人人爱| 精品久久久久久久久久久久久久久久久 | 欧美日韩二区三区| 婷婷成人激情在线网| 欧美一区二区三区婷婷月色| 日本91福利区| 久久亚洲精精品中文字幕早川悠里| 国内久久精品视频| 亚洲天堂成人在线观看| 91高清在线观看| 欧美a级一区二区| 国产农村妇女毛片精品久久麻豆| 色综合久久久久综合99| 亚洲午夜视频在线| 欧美不卡视频一区| 成人国产视频在线观看| 亚洲va韩国va欧美va| 精品粉嫩aⅴ一区二区三区四区| 高清国产一区二区| 亚洲大片一区二区三区| 久久免费的精品国产v∧| 99久久国产免费看| 日本va欧美va欧美va精品| 日本一区二区三区久久久久久久久不| 色综合视频在线观看| 日产欧产美韩系列久久99| 中文字幕成人av| 91精品国产综合久久国产大片| 精品一二线国产| 亚洲一二三四在线| 26uuu精品一区二区三区四区在线| aaa欧美大片| 经典三级在线一区| 亚洲精品免费在线| 精品国免费一区二区三区| 99久久精品免费看国产| 免费在线观看视频一区| 国产精品色婷婷| 日韩午夜电影在线观看| 色综合久久久久网| 国产精品91xxx| 首页亚洲欧美制服丝腿| 国产精品免费丝袜| 日韩欧美国产精品| 欧美偷拍一区二区| 91农村精品一区二区在线| 黄一区二区三区| 午夜精品福利久久久| 国产精品女人毛片| 国产午夜精品一区二区三区四区 | 欧美成人精品1314www| 欧美伊人久久大香线蕉综合69| 国产成人av影院| 久久99久久99| 日本午夜一本久久久综合| 亚洲欧美视频在线观看| 国产精品嫩草99a| 欧美国产乱子伦| 国产视频亚洲色图| 久久久91精品国产一区二区精品| 日韩你懂的在线播放| 欧美人牲a欧美精品| 欧美性猛交xxxx乱大交退制版| 波多野洁衣一区| 成人免费毛片a| 成人一道本在线| 国产一区在线看| 美女视频黄频大全不卡视频在线播放| 日韩理论片中文av| 亚洲人成7777| 中日韩免费视频中文字幕| 日韩欧美123| 在线电影国产精品| 国产精品综合二区| 高清不卡在线观看| 国产精品一区二区在线播放 | 国产精品久久三| 国产欧美1区2区3区| 日韩欧美一级二级| 日韩一区二区免费在线观看| 在线看国产一区| 91官网在线观看| 精品视频在线免费观看| 欧美色网站导航| 欧美日韩二区三区| 在线综合视频播放| 日韩一级完整毛片| 国产校园另类小说区| 国产日韩精品一区二区三区 | 国产三级精品三级在线专区| 精品国产三级a在线观看| 欧美一级生活片| 欧美哺乳videos| 久久综合给合久久狠狠狠97色69| 国产亚洲成av人在线观看导航 | 国产精品久久三| 久久久精品人体av艺术| 中文一区二区在线观看| 最新国产の精品合集bt伙计| 中文字幕在线不卡| 亚洲三级理论片| 一区二区三区免费网站| 亚洲综合在线电影| 婷婷中文字幕综合| 日韩国产欧美在线播放| 国产精品99久久久久| 99精品视频一区二区三区| 91色porny在线视频| 欧美日韩一区不卡| 欧美日韩视频专区在线播放| 国产清纯美女被跳蛋高潮一区二区久久w| 久久精品亚洲国产奇米99| 国产精品不卡视频| 性做久久久久久免费观看| 青青青伊人色综合久久| voyeur盗摄精品| 欧美日韩视频第一区| 精品久久99ma| 亚洲欧美在线高清| 婷婷开心久久网| 色综合亚洲欧洲| 日韩精品中文字幕一区二区三区| 欧美激情一区二区三区全黄| 亚洲一区二区三区在线播放| 国产一区二区三区久久久| 91在线精品一区二区三区| 日韩一区二区在线观看视频播放| 久久精品一区二区三区四区| 99久久综合国产精品| 91美女精品福利| 国产成人午夜高潮毛片| 麻豆视频观看网址久久| 在线精品国精品国产尤物884a| 精品国产乱码久久久久久蜜臀| 一区二区三区电影在线播| 国产河南妇女毛片精品久久久| 欧美图区在线视频| 亚洲综合图片区| 国产精品一区二区在线看| 欧美电视剧在线观看完整版| 国产日产亚洲精品系列| 国内精品不卡在线| 日韩欧美一区在线观看| 洋洋av久久久久久久一区| 99久久精品一区| 久久精品无码一区二区三区| 精久久久久久久久久久| 欧美日韩色综合| 亚洲日本va午夜在线电影| 激情都市一区二区| 久久精品一二三| 精品一区二区三区日韩| 欧美日韩国产高清一区二区三区 |