rockbox/utils/rbutilqt/mspack/lzss.h
Dominik Riebeling c876d3bbef rbutil: Merge rbutil with utils folder.
rbutil uses several components from the utils folder, and can be
considered part of utils too. Having it in a separate folder is an
arbitrary split that doesn't help anymore these days, so merge them.

This also allows other utils to easily use libtools.make without the
need to navigate to a different folder.

Change-Id: I3fc2f4de19e3e776553efb5dea5f779dfec0dc21
2021-12-24 18:05:53 +01:00

66 lines
2.3 KiB
C

/* This file is part of libmspack.
* (C) 2003-2004 Stuart Caie.
*
* libmspack is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License (LGPL) version 2.1
*
* For further details, see the file COPYING.LIB distributed with libmspack
*/
#ifndef MSPACK_LZSS_H
#define MSPACK_LZSS_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* LZSS compression / decompression definitions */
#define LZSS_WINDOW_SIZE (4096)
#define LZSS_WINDOW_FILL (0x20)
#define LZSS_MODE_EXPAND (0)
#define LZSS_MODE_MSHELP (1)
#define LZSS_MODE_QBASIC (2)
/**
* Decompresses an LZSS stream.
*
* Input bytes will be read in as necessary using the system->read()
* function with the input file handle given. This will continue until
* system->read() returns 0 bytes, or an error. Errors will be passed
* out of the function as MSPACK_ERR_READ errors. Input streams should
* convey an "end of input stream" by refusing to supply all the bytes
* that LZSS asks for when they reach the end of the stream, rather
* than return an error code.
*
* Output bytes will be passed to the system->write() function, using
* the output file handle given. More than one call may be made to
* system->write().
*
* As EXPAND.EXE (SZDD/KWAJ), Microsoft Help and QBasic have slightly
* different encodings for the control byte and matches, a "mode"
* parameter is allowed, to choose the encoding.
*
* @param system an mspack_system structure used to read from
* the input stream and write to the output
* stream, also to allocate and free memory.
* @param input an input stream with the LZSS data.
* @param output an output stream to write the decoded data to.
* @param input_buffer_size the number of bytes to use as an input
* bitstream buffer.
* @param mode one of #LZSS_MODE_EXPAND, #LZSS_MODE_MSHELP or
* #LZSS_MODE_QBASIC
* @return an error code, or MSPACK_ERR_OK if successful
*/
extern int lzss_decompress(struct mspack_system *system,
struct mspack_file *input,
struct mspack_file *output,
int input_buffer_size,
int mode);
#ifdef __cplusplus
}
#endif
#endif