summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/mspack/lzss.h
blob: 55e761b5bf919cb260e8403807d36342e1e29ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* 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