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

📄 lzss.h

📁 一个加密库代码
💻 H
字号:
/*
 * 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.
 */

#ifndef __LZSS_H
#define __LZSS_H

#include "cpconfig.h"
#include "BasicTypes.h"


#ifdef __cplusplus
extern "C" {
#endif


// the condition codes, these are bitflags
#define  LZSS_START  1
#define  LZSS_WORK   2
#define  LZSS_STOP   4



// LZSS context
typedef struct LZSSCTX  LZSSCTX, *PLZSSCTX;



/*
 * creates an LZSS context
 * <- pointer to LZSS context (NULL if out of memory)
 */
PLZSSCTX CRYPTPAK_API LZSS_Create();


/*
 * destroys an LZSS context
 * -> pointer to LZSS context
 */
void CRYPTPAK_API LZSS_Destroy(PLZSSCTX);



/*
 * compresses a buffer content into a second buffer, due to
 * the stream characteristic of the original source we need 
 * a clever interruption technique, and it's not guaranteed
 * that there'll be something in the target buffer, so the
 * target buffer should be least 12.5% larger than the source
 * -> pointer to work context
 * -> pointer to source buffer
 * -> pointer to target buffer
 * -> number of bytes to compress
 * -> code number, for sending start and stop signals
 * <- number of compressed bytes
 */
WORD32 CRYPTPAK_API 
    LZSS_Compress (PLZSSCTX, const void*, void*, WORD32, WORD8);

                   
/*
 * decompresses a data stream, has two interrupt
 * possibilities in a cycle: either a buffer has been
 * processed completely or the output buffer is full and
 * needs to be emptied
 * -> pointer to work context
 * -> pointer to source buffer
 * -> pointer to target buffer
 * -> number of bytes to decompress
 * -> size of the output buffer
 * -> code number, for sending start and stop signals
 * -> pointer to a flag which 
 *        a) lets the routine detect that not all input data
 *           of the last cycle has been decompressed
 *        b) forces the caller to empty its output buffer
 *           and to recall (!) the routine
 *        (the flag has to be set to BOOL_FALSE for a new input buffer)
 * <- number of decompressed bytes when the cycle is finished
 */
WORD32 CRYPTPAK_API 
    LZSS_Decompress (PLZSSCTX, const void*, void*, WORD32, WORD32, WORD8, BYTEBOOL*);


#ifdef __cplusplus
}
#endif


#endif

⌨️ 快捷键说明

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