📄 lzrw3.h
字号:
#ifndef _LZRW3_H#define _LZRW3_H/* * $Source: /homes/cvs/ftape-stacked/ftape/compressor/lzrw3.h,v $ * $Revision: 1.1 $ * $Date: 1997/10/05 19:12:30 $ * * include files for lzrw3. Only slighty modified from the original * version. Assembles the three include files compress.h, port.h and * fastcopy.h from the original lzrw3 package. * */#include <linux/types.h>#include <linux/string.h>/******************************************************************************//* *//* COMPRESS.H *//* *//******************************************************************************//* *//* Author : Ross Williams. *//* Date : December 1989. *//* *//* This header file defines the interface to a set of functions called *//* 'compress', each member of which implements a particular data compression *//* algorithm. *//* *//* Normally in C programming, for each .H file, there is a corresponding .C *//* file that implements the functions promised in the .H file. *//* Here, there are many .C files corresponding to this header file. *//* Each comforming implementation file contains a single function *//* called 'compress' that implements a single data compression *//* algorithm that conforms with the interface specified in this header file. *//* Only one algorithm can be linked in at a time in this organization. *//* *//******************************************************************************//* *//* DEFINITION OF FUNCTION COMPRESS *//* =============================== *//* *//* Summary of Function Compress *//* ---------------------------- *//* The action that 'compress' takes depends on its first argument called *//* 'action'. The function provides three actions: *//* *//* - Return information about the algorithm. *//* - Compress a block of memory. *//* - Decompress a block of memory. *//* *//* Parameters *//* ---------- *//* See the formal C definition later for a description of the parameters. *//* *//* Constants *//* --------- *//* COMPRESS_OVERRUN: The constant COMPRESS_OVERRUN defines by how many bytes *//* an algorithm is allowed to expand a block during a compression operation. *//* *//* Although compression algorithms usually compress data, there will always *//* be data that a given compressor will expand (this can be proven). *//* Fortunately, the degree of expansion can be limited to a single bit, by *//* copying over the input data if the data gets bigger during compression. *//* To allow for this possibility, the first bit of a compressed *//* representation can be used as a flag indicating whether the *//* input data was copied over, or truly compressed. In practice, the first *//* byte would be used to store this bit so as to maintain byte alignment. *//* *//* Unfortunately, in general, the only way to tell if an algorithm will *//* expand a particular block of data is to run the algorithm on the data. *//* If the algorithm does not continuously monitor how many output bytes it *//* has written, it might write an output block far larger than the input *//* block before realizing that it has done so. *//* On the other hand, continuous checks on output length are inefficient. *//* *//* To cater for all these problems, this interface definition: *//* > Allows a compression algorithm to return an output block that is up to *//* COMPRESS_OVERRUN bytes longer than the input block. *//* > Allows a compression algorithm to write up to COMPRESS_OVERRUN bytes *//* more than the length of the input block to the memory of the output *//* block regardless of the length of the output block eventually returned. *//* This allows an algorithm to overrun the length of the input block in the *//* output block by up to COMPRESS_OVERRUN bytes between expansion checks. *//* *//* The problem does not arise for decompression. *//* *//* Identity Action *//* --------------- *//* > action must be COMPRESS_ACTION_IDENTITY. *//* > p_dst_len must point to a longword to receive a longword address. *//* > The value of the other parameters does not matter. *//* > After execution, the longword that p_dst_len points to will be a pointer *//* to a structure of type compress_identity. *//* Thus, for example, after the call, (*p_dst_len)->memory will return the *//* number of bytes of working memory that the algorithm requires to run. *//* > The values of the identity structure returned are fixed constant *//* attributes of the algorithm and must not vary from call to call. *//* *//* Common Requirements for Compression and Decompression Actions *//* ------------------------------------------------------------- *//* > wrk_mem must point to an unused block of memory of a length specified in *//* the algorithm's identity block. The identity block can be obtained by *//* making a separate call to compress, specifying the identity action. *//* > The INPUT BLOCK is defined to be Memory[src_addr,src_addr+src_len-1]. *//* > dst_len will be used to denote *p_dst_len. *//* > dst_len is not read by compress, only written. *//* > The value of dst_len is defined only upon termination. *//* > The OUTPUT BLOCK is defined to be Memory[dst_addr,dst_addr+dst_len-1]. *//* *//* Compression Action *//* ------------------ *//* > action must be COMPRESS_ACTION_COMPRESS. *//* > src_len must be in the range [0,COMPRESS_MAX_ORG]. *//* > The OUTPUT ZONE is defined to be *//* Memory[dst_addr,dst_addr+src_len-1+COMPRESS_OVERRUN]. *//* > The function can modify any part of the output zone regardless of the *//* final length of the output block. *//* > The input block and the output zone must not overlap. *//* > dst_len will be in the range [0,src_len+COMPRESS_OVERRUN]. *//* > dst_len will be in the range [0,COMPRESS_MAX_COM] (from prev fact). *//* > The output block will consist of a representation of the input block. *//* *//* Decompression Action *//* -------------------- *//* > action must be COMPRESS_ACTION_DECOMPRESS. *//* > The input block must be the result of an earlier compression operation. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -