libmspack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +5 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +4 -0
  6. data/README.md +75 -0
  7. data/Rakefile +22 -0
  8. data/UNLICENSE +24 -0
  9. data/ext/Rakefile +16 -0
  10. data/ext/i386-windows/libmspack.dll +0 -0
  11. data/ext/libmspack/AUTHORS +12 -0
  12. data/ext/libmspack/COPYING.LIB +504 -0
  13. data/ext/libmspack/ChangeLog +491 -0
  14. data/ext/libmspack/Makefile.am +100 -0
  15. data/ext/libmspack/NEWS +0 -0
  16. data/ext/libmspack/README +130 -0
  17. data/ext/libmspack/TODO +8 -0
  18. data/ext/libmspack/cleanup.sh +9 -0
  19. data/ext/libmspack/configure.ac +50 -0
  20. data/ext/libmspack/debian/changelog +6 -0
  21. data/ext/libmspack/debian/control +14 -0
  22. data/ext/libmspack/debian/rules +101 -0
  23. data/ext/libmspack/doc/Doxyfile.in +22 -0
  24. data/ext/libmspack/doc/Makefile.in +14 -0
  25. data/ext/libmspack/doc/szdd_kwaj_format.html +331 -0
  26. data/ext/libmspack/libmspack.pc.in +10 -0
  27. data/ext/libmspack/mspack/cab.h +127 -0
  28. data/ext/libmspack/mspack/cabc.c +24 -0
  29. data/ext/libmspack/mspack/cabd.c +1444 -0
  30. data/ext/libmspack/mspack/chm.h +122 -0
  31. data/ext/libmspack/mspack/chmc.c +24 -0
  32. data/ext/libmspack/mspack/chmd.c +1392 -0
  33. data/ext/libmspack/mspack/crc32.c +95 -0
  34. data/ext/libmspack/mspack/crc32.h +17 -0
  35. data/ext/libmspack/mspack/des.h +15 -0
  36. data/ext/libmspack/mspack/hlp.h +33 -0
  37. data/ext/libmspack/mspack/hlpc.c +24 -0
  38. data/ext/libmspack/mspack/hlpd.c +24 -0
  39. data/ext/libmspack/mspack/kwaj.h +118 -0
  40. data/ext/libmspack/mspack/kwajc.c +24 -0
  41. data/ext/libmspack/mspack/kwajd.c +561 -0
  42. data/ext/libmspack/mspack/lit.h +35 -0
  43. data/ext/libmspack/mspack/litc.c +24 -0
  44. data/ext/libmspack/mspack/litd.c +24 -0
  45. data/ext/libmspack/mspack/lzss.h +66 -0
  46. data/ext/libmspack/mspack/lzssd.c +93 -0
  47. data/ext/libmspack/mspack/lzx.h +221 -0
  48. data/ext/libmspack/mspack/lzxc.c +18 -0
  49. data/ext/libmspack/mspack/lzxd.c +895 -0
  50. data/ext/libmspack/mspack/mspack.def +28 -0
  51. data/ext/libmspack/mspack/mspack.h +2353 -0
  52. data/ext/libmspack/mspack/mszip.h +126 -0
  53. data/ext/libmspack/mspack/mszipc.c +18 -0
  54. data/ext/libmspack/mspack/mszipd.c +514 -0
  55. data/ext/libmspack/mspack/oab.h +60 -0
  56. data/ext/libmspack/mspack/oabc.c +24 -0
  57. data/ext/libmspack/mspack/oabd.c +408 -0
  58. data/ext/libmspack/mspack/qtm.h +128 -0
  59. data/ext/libmspack/mspack/qtmc.c +18 -0
  60. data/ext/libmspack/mspack/qtmd.c +489 -0
  61. data/ext/libmspack/mspack/readbits.h +207 -0
  62. data/ext/libmspack/mspack/readhuff.h +173 -0
  63. data/ext/libmspack/mspack/sha.h +15 -0
  64. data/ext/libmspack/mspack/system.c +239 -0
  65. data/ext/libmspack/mspack/system.h +124 -0
  66. data/ext/libmspack/mspack/szdd.h +39 -0
  67. data/ext/libmspack/mspack/szddc.c +24 -0
  68. data/ext/libmspack/mspack/szddd.c +247 -0
  69. data/ext/libmspack/rebuild.sh +8 -0
  70. data/ext/libmspack/test/cabd_c10 +19 -0
  71. data/ext/libmspack/test/cabd_compare +34 -0
  72. data/ext/libmspack/test/cabd_md5.c +161 -0
  73. data/ext/libmspack/test/cabd_memory.c +179 -0
  74. data/ext/libmspack/test/cabd_test.c +386 -0
  75. data/ext/libmspack/test/cabrip.c +81 -0
  76. data/ext/libmspack/test/chmd_compare +38 -0
  77. data/ext/libmspack/test/chmd_find.c +95 -0
  78. data/ext/libmspack/test/chmd_md5.c +67 -0
  79. data/ext/libmspack/test/chmd_order.c +144 -0
  80. data/ext/libmspack/test/chminfo.c +284 -0
  81. data/ext/libmspack/test/chmx.c +216 -0
  82. data/ext/libmspack/test/error.h +22 -0
  83. data/ext/libmspack/test/expand.c +79 -0
  84. data/ext/libmspack/test/md5.c +457 -0
  85. data/ext/libmspack/test/md5.h +165 -0
  86. data/ext/libmspack/test/md5_fh.h +123 -0
  87. data/ext/libmspack/test/msdecompile_md5 +24 -0
  88. data/ext/libmspack/test/msexpand_md5 +39 -0
  89. data/ext/libmspack/test/multifh.c +435 -0
  90. data/ext/libmspack/test/oabx.c +41 -0
  91. data/ext/libmspack/test/test_files/cabd/1.pl +84 -0
  92. data/ext/libmspack/test/test_files/cabd/2.pl +75 -0
  93. data/ext/libmspack/test/test_files/cabd/bad_folderindex.cab +0 -0
  94. data/ext/libmspack/test/test_files/cabd/bad_nofiles.cab +0 -0
  95. data/ext/libmspack/test/test_files/cabd/bad_nofolders.cab +0 -0
  96. data/ext/libmspack/test/test_files/cabd/bad_signature.cab +0 -0
  97. data/ext/libmspack/test/test_files/cabd/multi_basic_pt1.cab +0 -0
  98. data/ext/libmspack/test/test_files/cabd/multi_basic_pt2.cab +0 -0
  99. data/ext/libmspack/test/test_files/cabd/multi_basic_pt3.cab +0 -0
  100. data/ext/libmspack/test/test_files/cabd/multi_basic_pt4.cab +0 -0
  101. data/ext/libmspack/test/test_files/cabd/multi_basic_pt5.cab +0 -0
  102. data/ext/libmspack/test/test_files/cabd/normal_255c_filename.cab +0 -0
  103. data/ext/libmspack/test/test_files/cabd/normal_2files_1folder.cab +0 -0
  104. data/ext/libmspack/test/test_files/cabd/partial_nodata.cab +0 -0
  105. data/ext/libmspack/test/test_files/cabd/partial_nofiles.cab +0 -0
  106. data/ext/libmspack/test/test_files/cabd/partial_nofolder.cab +0 -0
  107. data/ext/libmspack/test/test_files/cabd/partial_shortextheader.cab +0 -0
  108. data/ext/libmspack/test/test_files/cabd/partial_shortfile1.cab +0 -0
  109. data/ext/libmspack/test/test_files/cabd/partial_shortfile2.cab +0 -0
  110. data/ext/libmspack/test/test_files/cabd/partial_shortfolder.cab +0 -0
  111. data/ext/libmspack/test/test_files/cabd/partial_shortheader.cab +0 -0
  112. data/ext/libmspack/test/test_files/cabd/partial_str_nofname.cab +0 -0
  113. data/ext/libmspack/test/test_files/cabd/partial_str_noninfo.cab +0 -0
  114. data/ext/libmspack/test/test_files/cabd/partial_str_nonname.cab +0 -0
  115. data/ext/libmspack/test/test_files/cabd/partial_str_nopinfo.cab +0 -0
  116. data/ext/libmspack/test/test_files/cabd/partial_str_nopname.cab +0 -0
  117. data/ext/libmspack/test/test_files/cabd/partial_str_shortfname.cab +0 -0
  118. data/ext/libmspack/test/test_files/cabd/partial_str_shortninfo.cab +0 -0
  119. data/ext/libmspack/test/test_files/cabd/partial_str_shortnname.cab +0 -0
  120. data/ext/libmspack/test/test_files/cabd/partial_str_shortpinfo.cab +0 -0
  121. data/ext/libmspack/test/test_files/cabd/partial_str_shortpname.cab +0 -0
  122. data/ext/libmspack/test/test_files/cabd/reserve_---.cab +0 -0
  123. data/ext/libmspack/test/test_files/cabd/reserve_--D.cab +0 -0
  124. data/ext/libmspack/test/test_files/cabd/reserve_-F-.cab +0 -0
  125. data/ext/libmspack/test/test_files/cabd/reserve_-FD.cab +0 -0
  126. data/ext/libmspack/test/test_files/cabd/reserve_H--.cab +0 -0
  127. data/ext/libmspack/test/test_files/cabd/reserve_H-D.cab +0 -0
  128. data/ext/libmspack/test/test_files/cabd/reserve_HF-.cab +0 -0
  129. data/ext/libmspack/test/test_files/cabd/reserve_HFD.cab +0 -0
  130. data/ext/libmspack/test/test_files/cabd/search_basic.cab +0 -0
  131. data/ext/libmspack/test/test_files/cabd/search_tricky1.cab +0 -0
  132. data/ext/libmspack/winbuild.sh +26 -0
  133. data/ext/x86_64-windows/libmspack.dll +0 -0
  134. data/lib/libmspack/constants.rb +9 -0
  135. data/lib/libmspack/exceptions.rb +12 -0
  136. data/lib/libmspack/mscab.rb +722 -0
  137. data/lib/libmspack/mschm.rb +301 -0
  138. data/lib/libmspack/mshlp.rb +15 -0
  139. data/lib/libmspack/mskwaj.rb +124 -0
  140. data/lib/libmspack/mslit.rb +18 -0
  141. data/lib/libmspack/msoab.rb +36 -0
  142. data/lib/libmspack/mspack.rb +208 -0
  143. data/lib/libmspack/msszdd.rb +81 -0
  144. data/lib/libmspack/system.rb +84 -0
  145. data/lib/libmspack/version.rb +4 -0
  146. data/lib/libmspack.rb +121 -0
  147. data/libmspack.gemspec +33 -0
  148. data/spec/libmspack_spec.rb +26 -0
  149. data/spec/spec_helper.rb +5 -0
  150. metadata +309 -0
@@ -0,0 +1,93 @@
1
+ /* This file is part of libmspack.
2
+ * (C) 2003-2010 Stuart Caie.
3
+ *
4
+ * LZSS is a derivative of LZ77 and was created by James Storer and
5
+ * Thomas Szymanski in 1982. Haruhiko Okumura wrote a very popular C
6
+ * implementation.
7
+ *
8
+ * libmspack is free software; you can redistribute it and/or modify it under
9
+ * the terms of the GNU Lesser General Public License (LGPL) version 2.1
10
+ *
11
+ * For further details, see the file COPYING.LIB distributed with libmspack
12
+ */
13
+
14
+ #include <system.h>
15
+ #include <lzss.h>
16
+
17
+ #define ENSURE_BYTES do { \
18
+ if (i_ptr >= i_end) { \
19
+ read = system->read(input, &inbuf[0], \
20
+ input_buffer_size); \
21
+ if (read <= 0) { \
22
+ system->free(window); \
23
+ return (read < 0) ? MSPACK_ERR_READ \
24
+ : MSPACK_ERR_OK; \
25
+ } \
26
+ i_ptr = &inbuf[0]; i_end = &inbuf[read]; \
27
+ } \
28
+ } while (0)
29
+
30
+ #define WRITE_BYTE do { \
31
+ if (system->write(output, &window[pos], 1) != 1) { \
32
+ system->free(window); \
33
+ return MSPACK_ERR_WRITE; \
34
+ } \
35
+ } while (0)
36
+
37
+ int lzss_decompress(struct mspack_system *system,
38
+ struct mspack_file *input,
39
+ struct mspack_file *output,
40
+ int input_buffer_size,
41
+ int mode)
42
+ {
43
+ unsigned char *window, *inbuf, *i_ptr, *i_end;
44
+ unsigned int pos, i, c, invert, mpos, len;
45
+ int read;
46
+
47
+ /* check parameters */
48
+ if (!system || input_buffer_size < 1 || (mode != LZSS_MODE_EXPAND &&
49
+ mode != LZSS_MODE_MSHELP && mode != LZSS_MODE_QBASIC))
50
+ {
51
+ return MSPACK_ERR_ARGS;
52
+ }
53
+
54
+ /* allocate memory */
55
+ window = (unsigned char *) system->alloc(system, LZSS_WINDOW_SIZE + input_buffer_size);
56
+ if (!window) return MSPACK_ERR_NOMEMORY;
57
+
58
+ /* initialise decompression */
59
+ inbuf = &window[LZSS_WINDOW_SIZE];
60
+ memset(window, LZSS_WINDOW_FILL, (size_t) LZSS_WINDOW_SIZE);
61
+ pos = LZSS_WINDOW_SIZE - ((mode == LZSS_MODE_QBASIC) ? 18 : 16);
62
+ invert = (mode == LZSS_MODE_MSHELP) ? ~0 : 0;
63
+ i_ptr = i_end = &inbuf[0];
64
+
65
+ /* loop forever; exit condition is in ENSURE_BYTES macro */
66
+ for (;;) {
67
+ ENSURE_BYTES; c = *i_ptr++ ^ invert;
68
+ for (i = 0x01; i & 0xFF; i <<= 1) {
69
+ if (c & i) {
70
+ /* literal */
71
+ ENSURE_BYTES; window[pos] = *i_ptr++;
72
+ WRITE_BYTE;
73
+ pos++; pos &= LZSS_WINDOW_SIZE - 1;
74
+ }
75
+ else {
76
+ /* match */
77
+ ENSURE_BYTES; mpos = *i_ptr++;
78
+ ENSURE_BYTES; mpos |= (*i_ptr & 0xF0) << 4;
79
+ len = (*i_ptr++ & 0x0F) + 3;
80
+ while (len--) {
81
+ window[pos] = window[mpos];
82
+ WRITE_BYTE;
83
+ pos++; pos &= LZSS_WINDOW_SIZE - 1;
84
+ mpos++; mpos &= LZSS_WINDOW_SIZE - 1;
85
+ }
86
+ }
87
+ }
88
+ }
89
+
90
+ /* not reached */
91
+ system->free(window);
92
+ return MSPACK_ERR_OK;
93
+ }
@@ -0,0 +1,221 @@
1
+ /* This file is part of libmspack.
2
+ * (C) 2003-2013 Stuart Caie.
3
+ *
4
+ * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted
5
+ * by Microsoft Corporation.
6
+ *
7
+ * libmspack is free software; you can redistribute it and/or modify it under
8
+ * the terms of the GNU Lesser General Public License (LGPL) version 2.1
9
+ *
10
+ * For further details, see the file COPYING.LIB distributed with libmspack
11
+ */
12
+
13
+ #ifndef MSPACK_LZX_H
14
+ #define MSPACK_LZX_H 1
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+ /* LZX compression / decompression definitions */
21
+
22
+ /* some constants defined by the LZX specification */
23
+ #define LZX_MIN_MATCH (2)
24
+ #define LZX_MAX_MATCH (257)
25
+ #define LZX_NUM_CHARS (256)
26
+ #define LZX_BLOCKTYPE_INVALID (0) /* also blocktypes 4-7 invalid */
27
+ #define LZX_BLOCKTYPE_VERBATIM (1)
28
+ #define LZX_BLOCKTYPE_ALIGNED (2)
29
+ #define LZX_BLOCKTYPE_UNCOMPRESSED (3)
30
+ #define LZX_PRETREE_NUM_ELEMENTS (20)
31
+ #define LZX_ALIGNED_NUM_ELEMENTS (8) /* aligned offset tree #elements */
32
+ #define LZX_NUM_PRIMARY_LENGTHS (7) /* this one missing from spec! */
33
+ #define LZX_NUM_SECONDARY_LENGTHS (249) /* length tree #elements */
34
+
35
+ /* LZX huffman defines: tweak tablebits as desired */
36
+ #define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS)
37
+ #define LZX_PRETREE_TABLEBITS (6)
38
+ #define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 290*8)
39
+ #define LZX_MAINTREE_TABLEBITS (12)
40
+ #define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1)
41
+ #define LZX_LENGTH_TABLEBITS (12)
42
+ #define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS)
43
+ #define LZX_ALIGNED_TABLEBITS (7)
44
+ #define LZX_LENTABLE_SAFETY (64) /* table decoding overruns are allowed */
45
+
46
+ #define LZX_FRAME_SIZE (32768) /* the size of a frame in LZX */
47
+
48
+ struct lzxd_stream {
49
+ struct mspack_system *sys; /* I/O routines */
50
+ struct mspack_file *input; /* input file handle */
51
+ struct mspack_file *output; /* output file handle */
52
+
53
+ off_t offset; /* number of bytes actually output */
54
+ off_t length; /* overall decompressed length of stream */
55
+
56
+ unsigned char *window; /* decoding window */
57
+ unsigned int window_size; /* window size */
58
+ unsigned int ref_data_size; /* LZX DELTA reference data size */
59
+ unsigned int num_offsets; /* number of match_offset entries in table */
60
+ unsigned int window_posn; /* decompression offset within window */
61
+ unsigned int frame_posn; /* current frame offset within in window */
62
+ unsigned int frame; /* the number of 32kb frames processed */
63
+ unsigned int reset_interval; /* which frame do we reset the compressor? */
64
+
65
+ unsigned int R0, R1, R2; /* for the LRU offset system */
66
+ unsigned int block_length; /* uncompressed length of this LZX block */
67
+ unsigned int block_remaining; /* uncompressed bytes still left to decode */
68
+
69
+ signed int intel_filesize; /* magic header value used for transform */
70
+ signed int intel_curpos; /* current offset in transform space */
71
+
72
+ unsigned char intel_started; /* has intel E8 decoding started? */
73
+ unsigned char block_type; /* type of the current block */
74
+ unsigned char header_read; /* have we started decoding at all yet? */
75
+ unsigned char input_end; /* have we reached the end of input? */
76
+ unsigned char is_delta; /* does stream follow LZX DELTA spec? */
77
+
78
+ int error;
79
+
80
+ /* I/O buffering */
81
+ unsigned char *inbuf, *i_ptr, *i_end, *o_ptr, *o_end;
82
+ unsigned int bit_buffer, bits_left, inbuf_size;
83
+
84
+ /* huffman code lengths */
85
+ unsigned char PRETREE_len [LZX_PRETREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY];
86
+ unsigned char MAINTREE_len [LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY];
87
+ unsigned char LENGTH_len [LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY];
88
+ unsigned char ALIGNED_len [LZX_ALIGNED_MAXSYMBOLS + LZX_LENTABLE_SAFETY];
89
+
90
+ /* huffman decoding tables */
91
+ unsigned short PRETREE_table [(1 << LZX_PRETREE_TABLEBITS) +
92
+ (LZX_PRETREE_MAXSYMBOLS * 2)];
93
+ unsigned short MAINTREE_table[(1 << LZX_MAINTREE_TABLEBITS) +
94
+ (LZX_MAINTREE_MAXSYMBOLS * 2)];
95
+ unsigned short LENGTH_table [(1 << LZX_LENGTH_TABLEBITS) +
96
+ (LZX_LENGTH_MAXSYMBOLS * 2)];
97
+ unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) +
98
+ (LZX_ALIGNED_MAXSYMBOLS * 2)];
99
+ unsigned char LENGTH_empty;
100
+
101
+ /* this is used purely for doing the intel E8 transform */
102
+ unsigned char e8_buf[LZX_FRAME_SIZE];
103
+ };
104
+
105
+ /**
106
+ * Allocates and initialises LZX decompression state for decoding an LZX
107
+ * stream.
108
+ *
109
+ * This routine uses system->alloc() to allocate memory. If memory
110
+ * allocation fails, or the parameters to this function are invalid,
111
+ * NULL is returned.
112
+ *
113
+ * @param system an mspack_system structure used to read from
114
+ * the input stream and write to the output
115
+ * stream, also to allocate and free memory.
116
+ * @param input an input stream with the LZX data.
117
+ * @param output an output stream to write the decoded data to.
118
+ * @param window_bits the size of the decoding window, which must be
119
+ * between 15 and 21 inclusive for regular LZX
120
+ * data, or between 17 and 25 inclusive for
121
+ * LZX DELTA data.
122
+ * @param reset_interval the interval at which the LZX bitstream is
123
+ * reset, in multiples of LZX frames (32678
124
+ * bytes), e.g. a value of 2 indicates the input
125
+ * stream resets after every 65536 output bytes.
126
+ * A value of 0 indicates that the bitstream never
127
+ * resets, such as in CAB LZX streams.
128
+ * @param input_buffer_size the number of bytes to use as an input
129
+ * bitstream buffer.
130
+ * @param output_length the length in bytes of the entirely
131
+ * decompressed output stream, if known in
132
+ * advance. It is used to correctly perform the
133
+ * Intel E8 transformation, which must stop 6
134
+ * bytes before the very end of the
135
+ * decompressed stream. It is not otherwise used
136
+ * or adhered to. If the full decompressed
137
+ * length is known in advance, set it here.
138
+ * If it is NOT known, use the value 0, and call
139
+ * lzxd_set_output_length() once it is
140
+ * known. If never set, 4 of the final 6 bytes
141
+ * of the output stream may be incorrect.
142
+ * @param is_delta should be zero for all regular LZX data,
143
+ * non-zero for LZX DELTA encoded data.
144
+ * @return a pointer to an initialised lzxd_stream structure, or NULL if
145
+ * there was not enough memory or parameters to the function were wrong.
146
+ */
147
+ extern struct lzxd_stream *lzxd_init(struct mspack_system *system,
148
+ struct mspack_file *input,
149
+ struct mspack_file *output,
150
+ int window_bits,
151
+ int reset_interval,
152
+ int input_buffer_size,
153
+ off_t output_length,
154
+ char is_delta);
155
+
156
+ /* see description of output_length in lzxd_init() */
157
+ extern void lzxd_set_output_length(struct lzxd_stream *lzx,
158
+ off_t output_length);
159
+
160
+ /**
161
+ * Reads LZX DELTA reference data into the window and allows
162
+ * lzxd_decompress() to reference it.
163
+ *
164
+ * Call this before the first call to lzxd_decompress().
165
+
166
+ * @param lzx the LZX stream to apply this reference data to
167
+ * @param system an mspack_system implementation to use with the
168
+ * input param. Only read() will be called.
169
+ * @param input an input file handle to read reference data using
170
+ * system->read().
171
+ * @param length the length of the reference data. Cannot be longer
172
+ * than the LZX window size.
173
+ * @return an error code, or MSPACK_ERR_OK if successful
174
+ */
175
+ extern int lzxd_set_reference_data(struct lzxd_stream *lzx,
176
+ struct mspack_system *system,
177
+ struct mspack_file *input,
178
+ unsigned int length);
179
+
180
+ /**
181
+ * Decompresses entire or partial LZX streams.
182
+ *
183
+ * The number of bytes of data that should be decompressed is given as the
184
+ * out_bytes parameter. If more bytes are decoded than are needed, they
185
+ * will be kept over for a later invocation.
186
+ *
187
+ * The output bytes will be passed to the system->write() function given in
188
+ * lzxd_init(), using the output file handle given in lzxd_init(). More than
189
+ * one call may be made to system->write().
190
+
191
+ * Input bytes will be read in as necessary using the system->read()
192
+ * function given in lzxd_init(), using the input file handle given in
193
+ * lzxd_init(). This will continue until system->read() returns 0 bytes,
194
+ * or an error. Errors will be passed out of the function as
195
+ * MSPACK_ERR_READ errors. Input streams should convey an "end of input
196
+ * stream" by refusing to supply all the bytes that LZX asks for when they
197
+ * reach the end of the stream, rather than return an error code.
198
+ *
199
+ * If any error code other than MSPACK_ERR_OK is returned, the stream
200
+ * should be considered unusable and lzxd_decompress() should not be
201
+ * called again on this stream.
202
+ *
203
+ * @param lzx LZX decompression state, as allocated by lzxd_init().
204
+ * @param out_bytes the number of bytes of data to decompress.
205
+ * @return an error code, or MSPACK_ERR_OK if successful
206
+ */
207
+ extern int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes);
208
+
209
+ /**
210
+ * Frees all state associated with an LZX data stream. This will call
211
+ * system->free() using the system pointer given in lzxd_init().
212
+ *
213
+ * @param lzx LZX decompression state to free.
214
+ */
215
+ void lzxd_free(struct lzxd_stream *lzx);
216
+
217
+ #ifdef __cplusplus
218
+ }
219
+ #endif
220
+
221
+ #endif
@@ -0,0 +1,18 @@
1
+ /* This file is part of libmspack.
2
+ * (C) 2003-2004 Stuart Caie.
3
+ *
4
+ * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted
5
+ * by Microsoft Corporation.
6
+ *
7
+ * libmspack is free software; you can redistribute it and/or modify it under
8
+ * the terms of the GNU Lesser General Public License (LGPL) version 2.1
9
+ *
10
+ * For further details, see the file COPYING.LIB distributed with libmspack
11
+ */
12
+
13
+ /* LZX compression implementation */
14
+
15
+ #include <system.h>
16
+ #include <lzx.h>
17
+
18
+ /* todo */