|
kusano |
7d535a |
|
|
kusano |
7d535a |
============================================================================
|
|
kusano |
7d535a |
LZO -- a real-time data compression library LIBRARY REFERENCE
|
|
kusano |
7d535a |
============================================================================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
[ please read LZO.FAQ first ]
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Table of Contents
|
|
kusano |
7d535a |
=================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
1 Introduction to the LZO Library Reference
|
|
kusano |
7d535a |
1.1 Preliminary notes
|
|
kusano |
7d535a |
1.2 Headers
|
|
kusano |
7d535a |
2 General
|
|
kusano |
7d535a |
2.1 The memory model
|
|
kusano |
7d535a |
2.2 Public integral types
|
|
kusano |
7d535a |
2.3 Public pointer types
|
|
kusano |
7d535a |
2.4 Public function types
|
|
kusano |
7d535a |
3 Function reference
|
|
kusano |
7d535a |
3.1 Initialization
|
|
kusano |
7d535a |
3.2 Compression
|
|
kusano |
7d535a |
3.3 Decompression
|
|
kusano |
7d535a |
3.4 Optimization
|
|
kusano |
7d535a |
3.5 String functions
|
|
kusano |
7d535a |
3.6 Checksum functions
|
|
kusano |
7d535a |
3.7 Version functions
|
|
kusano |
7d535a |
4 Variable reference
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
1 Introduction to the LZO Library Reference
|
|
kusano |
7d535a |
=============================================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
1.1 Preliminary notes
|
|
kusano |
7d535a |
---------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
- `C90' is short for ISO 9899-1990, the ANSI/ISO standard for the C
|
|
kusano |
7d535a |
programming language
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
1.2 Headers
|
|
kusano |
7d535a |
-----------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This section briefly describes the headers.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
<lzo lzoconf.h=""></lzo>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Contains definitions for the basic integral and pointer types,
|
|
kusano |
7d535a |
provides wrappers for the library calling conventions, defines
|
|
kusano |
7d535a |
error codes and contains prototypes for the generic functions.
|
|
kusano |
7d535a |
This file is automatically included by all LZO headers.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
<lzo lzo1.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1a.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1b.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1c.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1f.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1x.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1y.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo1z.h=""></lzo>
|
|
kusano |
7d535a |
<lzo lzo2a.h=""></lzo>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
These files provide definitions and prototypes for the
|
|
kusano |
7d535a |
actual (de-)compression functions.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
2 General
|
|
kusano |
7d535a |
=========
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
2.1 The memory model
|
|
kusano |
7d535a |
--------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The documentation indicates that LZO requires 32-bit integers. It's
|
|
kusano |
7d535a |
not the integer size that really matters, though, but the memory
|
|
kusano |
7d535a |
model. If your memory model allows to access pointers at 32-bit
|
|
kusano |
7d535a |
offsets, then there is no problem at all - LZO works fine on my
|
|
kusano |
7d535a |
old Atari ST, which has 16 bit integers and a flat 32-bit memory model.
|
|
kusano |
7d535a |
Using 'huge' 32-bit pointers under 16-bit DOS is a workaround for this.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
While LZO also works with a strict 16-bit memory model, I don't officially
|
|
kusano |
7d535a |
support this because this limits the maximum block size to 64 kB - and this
|
|
kusano |
7d535a |
makes the library incompatible with other platforms, i.e. you cannot
|
|
kusano |
7d535a |
decompress larger blocks compressed on those platforms.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
2.2 Public integral types
|
|
kusano |
7d535a |
-------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_uint
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
used as size_t, must be 32 bits or more for compatibility reasons
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_uint32
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
*must* be 32 bits or more
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_bool
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
can store the values 0 ("false") and 1 ("true")
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_byte
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
unsigned char (memory model specific)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
2.3 Public pointer types
|
|
kusano |
7d535a |
------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
All pointer types are memory model specific.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_voidp
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
pointer to void
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_bytep
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
pointer to unsigned char
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_bytepp
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
array of pointers to unsigned char
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
2.4 Public function types
|
|
kusano |
7d535a |
-------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_compress_t
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_decompress_t
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_optimize_t
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
lzo_callback_t
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
3 Function reference
|
|
kusano |
7d535a |
====================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
3.1 Initialization
|
|
kusano |
7d535a |
------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int lzo_init ( void );
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This function initializes the LZO library. It must be the first LZO
|
|
kusano |
7d535a |
function you call, and you cannot use any of the other LZO library
|
|
kusano |
7d535a |
functions if the call fails.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Return value:
|
|
kusano |
7d535a |
Returns LZO_E_OK on success, error code otherwise.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Note:
|
|
kusano |
7d535a |
This function is actually implemented using a macro.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
3.2 Compression
|
|
kusano |
7d535a |
---------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
All compressors compress the memory block at `src' with the uncompressed
|
|
kusano |
7d535a |
length `src_len' to the address given by `dst'.
|
|
kusano |
7d535a |
The length of the compressed blocked will be returned in the variable
|
|
kusano |
7d535a |
pointed by `dst_len'.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The two blocks may overlap under certain conditions (see examples/overlap.c),
|
|
kusano |
7d535a |
thereby allowing "in-place" compression.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
kusano |
7d535a |
#include <lzo lzo1x.h=""></lzo>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len,
|
|
kusano |
7d535a |
lzo_bytep dst, lzo_uintp dst_len,
|
|
kusano |
7d535a |
lzo_voidp wrkmem );
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Algorithm: LZO1X
|
|
kusano |
7d535a |
Compression level: LZO1X-1
|
|
kusano |
7d535a |
Memory requirements: LZO1X_1_MEM_COMPRESS (64 kB on 32-bit machines)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This compressor is pretty fast.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Return value:
|
|
kusano |
7d535a |
Always returns LZO_E_OK (this function can never fail).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
kusano |
7d535a |
#include <lzo lzo1x.h=""></lzo>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int lzo1x_999_compress ( const lzo_bytep src, lzo_uint src_len,
|
|
kusano |
7d535a |
lzo_bytep dst, lzo_uintp dst_len,
|
|
kusano |
7d535a |
lzo_voidp wrkmem );
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Algorithm: LZO1X
|
|
kusano |
7d535a |
Compression level: LZO1X-999
|
|
kusano |
7d535a |
Memory requirements: LZO1X_999_MEM_COMPRESS (448 kB on 32-bit machines)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This compressor is quite slow but achieves a good compression
|
|
kusano |
7d535a |
ratio. It is mainly intended for generating pre-compressed data.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Return value:
|
|
kusano |
7d535a |
Always returns LZO_E_OK (this function can never fail).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
[ ... lots of other compressors which all follow the same principle ... ]
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
3.3 Decompression
|
|
kusano |
7d535a |
-----------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
All decompressors decompress the memory block at `src' with the compressed
|
|
kusano |
7d535a |
length `src_len' to the address given by `dst'.
|
|
kusano |
7d535a |
The length of the decompressed block will be returned in the variable
|
|
kusano |
7d535a |
pointed by `dst_len' - on error the number of bytes that have
|
|
kusano |
7d535a |
been decompressed so far will be returned.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The safe decompressors expect that the number of bytes available in
|
|
kusano |
7d535a |
the `dst' block is passed via the variable pointed by `dst_len'.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The two blocks may overlap under certain conditions (see examples/overlap.c),
|
|
kusano |
7d535a |
thereby allowing "in-place" decompression.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Description of return values:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_OK
|
|
kusano |
7d535a |
Success.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_INPUT_NOT_CONSUMED
|
|
kusano |
7d535a |
The end of the compressed block has been detected before all
|
|
kusano |
7d535a |
bytes in the compressed block have been used.
|
|
kusano |
7d535a |
This may actually not be an error (if `src_len' is too large).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_INPUT_OVERRUN
|
|
kusano |
7d535a |
The decompressor requested more bytes from the compressed
|
|
kusano |
7d535a |
block than available.
|
|
kusano |
7d535a |
Your data is corrupted (or `src_len' is too small).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_OUTPUT_OVERRUN
|
|
kusano |
7d535a |
The decompressor requested to write more bytes to the uncompressed
|
|
kusano |
7d535a |
block than available.
|
|
kusano |
7d535a |
Either your data is corrupted, or you should increase the number of
|
|
kusano |
7d535a |
available bytes passed in the variable pointed by `dst_len'.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_LOOKBEHIND_OVERRUN
|
|
kusano |
7d535a |
Your data is corrupted.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_EOF_NOT_FOUND
|
|
kusano |
7d535a |
No EOF code was found in the compressed block.
|
|
kusano |
7d535a |
Your data is corrupted (or `src_len' is too small).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
LZO_E_ERROR
|
|
kusano |
7d535a |
Any other error (data corrupted).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
kusano |
7d535a |
#include <lzo1x.h></lzo1x.h>
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len,
|
|
kusano |
7d535a |
lzo_bytep dst, lzo_uintp dst_len,
|
|
kusano |
7d535a |
lzo_voidp wrkmem );
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Algorithm: LZO1X
|
|
kusano |
7d535a |
Memory requirements: 0
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
[ ... lots of other decompressors which all follow the same principle ... ]
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
4 Variable reference
|
|
kusano |
7d535a |
====================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The variables are listed alphabetically.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
[ no public variables yet ]
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
--------------------------- END OF LZOAPI.TXT ------------------------------
|
|
kusano |
7d535a |
|