Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 640688 Details for
Bug 828112
evolution-ews: Contains embedded copy of 'lzx' functionality from libmspack library
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
changes
changes.patch (text/plain), 23.12 KB, created by
Milan Crha
on 2012-11-08 09:54:53 UTC
(
hide
)
Description:
changes
Filename:
MIME Type:
Creator:
Milan Crha
Created:
2012-11-08 09:54:53 UTC
Size:
23.12 KB
patch
obsolete
>diff -upr mspack/lzxd.c ./lzxd.c >--- mspack/lzxd.c 2011-05-10 12:02:43.000000000 +0200 >+++ ./lzxd.c 2011-07-25 06:44:53.228735834 +0200 >@@ -12,8 +12,7 @@ > > /* LZX decompression implementation */ > >-#include <system.h> >-#include <lzx.h> >+#include "lzx.h" > > /* Microsoft's LZX document (in cab-sdk.exe) and their implementation > * of the com.ms.util.cab Java package do not concur. >@@ -85,15 +84,15 @@ > READ_IF_NEEDED; b1 = *i_ptr++; \ > INJECT_BITS((b1 << 8) | b0, 16); \ > } while (0) >-#include <readbits.h> >+#include "readbits.h" > > /* import huffman-reading macros and code */ > #define TABLEBITS(tbl) LZX_##tbl##_TABLEBITS > #define MAXSYMBOLS(tbl) LZX_##tbl##_MAXSYMBOLS > #define HUFF_TABLE(tbl,idx) lzx->tbl##_table[idx] > #define HUFF_LEN(tbl,idx) lzx->tbl##_len[idx] >-#define HUFF_ERROR return lzx->error = MSPACK_ERR_DECRUNCH >-#include <readhuff.h> >+#define HUFF_ERROR return lzx->error = LZX_ERR_DECRUNCH >+#include "readhuff.h" > > /* BUILD_TABLE(tbl) builds a huffman lookup table from code lengths */ > #define BUILD_TABLE(tbl) \ >@@ -101,25 +100,9 @@ > &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0))) \ > { \ > D(("failed to build %s table", #tbl)) \ >- return lzx->error = MSPACK_ERR_DECRUNCH; \ >+ return lzx->error = LZX_ERR_DECRUNCH; \ > } > >-#define BUILD_TABLE_MAYBE_EMPTY(tbl) do { \ >- lzx->tbl##_empty = 0; \ >- if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl), \ >- &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0))) \ >- { \ >- for (i = 0; i < MAXSYMBOLS(tbl); i++) { \ >- if (HUFF_LEN(tbl, i) > 0) { \ >- D(("failed to build %s table", #tbl)) \ >- return lzx->error = MSPACK_ERR_DECRUNCH; \ >- } \ >- } \ >- /* empty tree - allow it, but don't decode symbols with it */ \ >- lzx->tbl##_empty = 1; \ >- } \ >-} while (0) >- > /* READ_LENGTHS(tablename, first, last) reads in code lengths for symbols > * first to last in the given table. The code lengths are stored in their > * own special LZX way. >@@ -180,7 +163,7 @@ static int lzxd_read_lens(struct lzxd_st > > STORE_BITS; > >- return MSPACK_ERR_OK; >+ return LZX_ERR_OK; > } > > /* LZX static data tables: >@@ -228,10 +211,10 @@ static void lzxd_reset_state(struct lzxd > } > > /*-------- main LZX code --------*/ >+static int pos_slots[9] = {34, 36, 38, 42, 50, 66, 98, 162, 290}; > >-struct lzxd_stream *lzxd_init(struct mspack_system *system, >- struct mspack_file *input, >- struct mspack_file *output, >+struct lzxd_stream *lzxd_init(FILE *input, >+ FILE *output, > int window_bits, > int reset_interval, > int input_buffer_size, >@@ -240,31 +223,28 @@ struct lzxd_stream *lzxd_init(struct msp > unsigned int window_size = 1 << window_bits; > struct lzxd_stream *lzx; > >- if (!system) return NULL; >- >- /* LZX supports window sizes of 2^15 (32Kb) through 2^21 (2Mb) */ >- if (window_bits < 15 || window_bits > 21) return NULL; >+ /* LZX supports window sizes of 2^17 (128Kb) through 2^25 (32Mb) */ >+ if (window_bits < 17 || window_bits > 26) return NULL; > > input_buffer_size = (input_buffer_size + 1) & -2; > if (!input_buffer_size) return NULL; > > /* allocate decompression state */ >- if (!(lzx = (struct lzxd_stream *) system->alloc(system, sizeof(struct lzxd_stream)))) { >+ if (!(lzx = malloc(sizeof(struct lzxd_stream)))) { > return NULL; > } > > /* allocate decompression window and input buffer */ >- lzx->window = (unsigned char *) system->alloc(system, (size_t) window_size); >- lzx->inbuf = (unsigned char *) system->alloc(system, (size_t) input_buffer_size); >+ lzx->window = malloc((size_t) window_size); >+ lzx->inbuf = malloc((size_t) input_buffer_size); > if (!lzx->window || !lzx->inbuf) { >- system->free(lzx->window); >- system->free(lzx->inbuf); >- system->free(lzx); >+ free(lzx->window); >+ free(lzx->inbuf); >+ free(lzx); > return NULL; > } > > /* initialise decompression state */ >- lzx->sys = system; > lzx->input = input; > lzx->output = output; > lzx->offset = 0; >@@ -279,12 +259,11 @@ struct lzxd_stream *lzxd_init(struct msp > lzx->intel_filesize = 0; > lzx->intel_curpos = 0; > lzx->intel_started = 0; >- lzx->error = MSPACK_ERR_OK; >+ lzx->error = LZX_ERR_OK; > >- /* window bits: 15 16 17 18 19 20 21 >- * position slots: 30 32 34 36 38 42 50 */ >- lzx->posn_slots = ((window_bits == 21) ? 50 : >- ((window_bits == 20) ? 42 : (window_bits << 1))); >+ /* window bits: 17 18 19 20 21 22 23 24 25 >+ * position slots: 34 36 38 42 50 66 98 162 290 */ >+ lzx->posn_slots = pos_slots[window_bits-17]; > > lzx->o_ptr = lzx->o_end = &lzx->e8_buf[0]; > lzxd_reset_state(lzx); >@@ -310,21 +289,21 @@ int lzxd_decompress(struct lzxd_stream * > unsigned int R0, R1, R2; > > /* easy answers */ >- if (!lzx || (out_bytes < 0)) return MSPACK_ERR_ARGS; >+ if (!lzx || (out_bytes < 0)) return LZX_ERR_ARGS; > if (lzx->error) return lzx->error; > > /* flush out any stored-up bytes before we begin */ > i = lzx->o_end - lzx->o_ptr; > if ((off_t) i > out_bytes) i = (int) out_bytes; > if (i) { >- if (lzx->sys->write(lzx->output, lzx->o_ptr, i) != i) { >- return lzx->error = MSPACK_ERR_WRITE; >+ if (fwrite(lzx->o_ptr, 1, i, lzx->output) != i) { >+ return lzx->error = LZX_ERR_WRITE; > } > lzx->o_ptr += i; > lzx->offset += i; > out_bytes -= i; > } >- if (out_bytes == 0) return MSPACK_ERR_OK; >+ if (out_bytes == 0) return LZX_ERR_OK; > > /* restore local state */ > RESTORE_BITS; >@@ -337,11 +316,13 @@ int lzxd_decompress(struct lzxd_stream * > end_frame = (unsigned int)((lzx->offset + out_bytes) / LZX_FRAME_SIZE) + 1; > > while (lzx->frame < end_frame) { >+ int chunk_size; >+ > /* have we reached the reset interval? (if there is one?) */ > if (lzx->reset_interval && ((lzx->frame % lzx->reset_interval) == 0)) { > if (lzx->block_remaining) { > D(("%d bytes remaining at reset interval", lzx->block_remaining)) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; > } > > /* re-read the intel header and reset the huffman lengths */ >@@ -351,6 +332,9 @@ int lzxd_decompress(struct lzxd_stream * > R2 = lzx->R2; > } > >+ /* LZXD format has the chunk_size. not present in lzx format */ >+ READ_BITS (chunk_size, 16); >+ > /* read header if necessary */ > if (!lzx->header_read) { > /* read 1 bit. if bit=0, intel filesize = 0. >@@ -385,7 +369,7 @@ int lzxd_decompress(struct lzxd_stream * > READ_BITS(lzx->block_type, 3); > READ_BITS(i, 16); READ_BITS(j, 8); > lzx->block_remaining = lzx->block_length = (i << 8) | j; >- /*D(("new block t%d len %u", lzx->block_type, lzx->block_length))*/ >+ D(("new block type %d len %u", lzx->block_type, lzx->block_length)) > > /* read individual block headers */ > switch (lzx->block_type) { >@@ -403,7 +387,7 @@ int lzxd_decompress(struct lzxd_stream * > if (lzx->MAINTREE_len[0xE8] != 0) lzx->intel_started = 1; > /* read lengths of and build lengths huffman decoding tree */ > READ_LENGTHS(LENGTH, 0, LZX_NUM_SECONDARY_LENGTHS); >- BUILD_TABLE_MAYBE_EMPTY(LENGTH); >+ BUILD_TABLE(LENGTH); > break; > > case LZX_BLOCKTYPE_UNCOMPRESSED: >@@ -426,8 +410,8 @@ int lzxd_decompress(struct lzxd_stream * > break; > > default: >- D(("bad block type")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ D(("bad block type \n")) >+ return lzx->error = LZX_ERR_DECRUNCH; > } > } > >@@ -451,16 +435,14 @@ int lzxd_decompress(struct lzxd_stream * > this_run--; > } > else { >+ int bit = 0, extra_len = 0; >+ > /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ > main_element -= LZX_NUM_CHARS; > > /* get match length */ > match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; > if (match_length == LZX_NUM_PRIMARY_LENGTHS) { >- if (lzx->LENGTH_empty) { >- D(("LENGTH symbol needed but tree is empty")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >- } > READ_HUFFSYM(LENGTH, length_footer); > match_length += length_footer; > } >@@ -480,10 +462,41 @@ int lzxd_decompress(struct lzxd_stream * > } > > if ((window_posn + match_length) > lzx->window_size) { >- D(("match ran over window wrap")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ D(("match ran over window wrap %lu %d ", ftell (lzx->input), match_length)) >+ lzx->o_ptr = &lzx->window[lzx->frame_posn]; >+ return lzx->error = LZX_ERR_DECRUNCH; > } >- >+ >+ /* check for extra len */ >+ if (match_length == 257) { >+ READ_BITS (bit, 1); >+ if (bit) { >+ bit = 0; >+ READ_BITS (bit, 1); >+ if (bit) { >+ bit = 0; >+ READ_BITS (bit, 1); >+ if (bit) { >+ /* 111 */ >+ READ_BITS (extra_len, 15); >+ } else { >+ /* 110 */ >+ READ_BITS (extra_len, 12); >+ extra_len += 256 + 1024; >+ } >+ } else { >+ /* 10 */ >+ READ_BITS (extra_len, 10); >+ extra_len += 256; >+ } >+ } else { >+ /* 0 */ >+ READ_BITS (extra_len, 8); >+ } >+ } >+ >+ match_length += extra_len; >+ > /* copy match */ > rundest = &window[window_posn]; > i = match_length; >@@ -493,7 +506,7 @@ int lzxd_decompress(struct lzxd_stream * > j = match_offset - window_posn; > if (j > (int) lzx->window_size) { > D(("match offset beyond window boundaries")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; > } > runsrc = &window[lzx->window_size - j]; > if (j < i) { >@@ -507,10 +520,10 @@ int lzxd_decompress(struct lzxd_stream * > runsrc = rundest - match_offset; > while (i-- > 0) *rundest++ = *runsrc++; > } >- > this_run -= match_length; > window_posn += match_length; > } >+ > } /* while (this_run > 0) */ > break; > >@@ -523,16 +536,14 @@ int lzxd_decompress(struct lzxd_stream * > this_run--; > } > else { >+ int bit = 0, extra_len = 0; >+ > /* match: LZX_NUM_CHARS + ((slot<<3) | length_header (3 bits)) */ > main_element -= LZX_NUM_CHARS; > > /* get match length */ > match_length = main_element & LZX_NUM_PRIMARY_LENGTHS; > if (match_length == LZX_NUM_PRIMARY_LENGTHS) { >- if (lzx->LENGTH_empty) { >- D(("LENGTH symbol needed but tree is empty")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >- } > READ_HUFFSYM(LENGTH, length_footer); > match_length += length_footer; > } >@@ -574,7 +585,35 @@ int lzxd_decompress(struct lzxd_stream * > > if ((window_posn + match_length) > lzx->window_size) { > D(("match ran over window wrap")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; >+ } >+ >+ /* check for extra len */ >+ if (match_length == 257) { >+ READ_BITS (bit, 1); >+ if (bit) { >+ bit = 0; >+ READ_BITS (bit, 1); >+ if (bit) { >+ bit = 0; >+ READ_BITS (bit, 1); >+ if (bit) { >+ /* 111 */ >+ READ_BITS (extra_len, 15); >+ } else { >+ /* 110 */ >+ READ_BITS (extra_len, 12); >+ extra_len += 256 + 1024; >+ } >+ } else { >+ /* 10 */ >+ READ_BITS (extra_len, 10); >+ extra_len += 256; >+ } >+ } else { >+ /* 0 */ >+ READ_BITS (extra_len, 8); >+ } > } > > /* copy match */ >@@ -586,7 +625,7 @@ int lzxd_decompress(struct lzxd_stream * > j = match_offset - window_posn; > if (j > (int) lzx->window_size) { > D(("match offset beyond window boundaries")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; > } > runsrc = &window[lzx->window_size - j]; > if (j < i) { >@@ -618,7 +657,7 @@ int lzxd_decompress(struct lzxd_stream * > } > else { > if (i > this_run) i = this_run; >- lzx->sys->copy(i_ptr, rundest, (size_t) i); >+ memcpy(rundest, i_ptr, (size_t) i); > rundest += i; > i_ptr += i; > this_run -= i; >@@ -627,7 +666,7 @@ int lzxd_decompress(struct lzxd_stream * > break; > > default: >- return lzx->error = MSPACK_ERR_DECRUNCH; /* might as well */ >+ return lzx->error = LZX_ERR_DECRUNCH; /* might as well */ > } > > /* did the final match overrun our desired this_run length? */ >@@ -635,7 +674,7 @@ int lzxd_decompress(struct lzxd_stream * > if ((unsigned int)(-this_run) > lzx->block_remaining) { > D(("overrun went past end of block by %d (%d remaining)", > -this_run, lzx->block_remaining )) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; > } > lzx->block_remaining -= -this_run; > } >@@ -645,7 +684,7 @@ int lzxd_decompress(struct lzxd_stream * > if ((window_posn - lzx->frame_posn) != frame_size) { > D(("decode beyond output frame limits! %d != %d", > window_posn - lzx->frame_posn, frame_size)) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; > } > > /* re-align input bitstream */ >@@ -654,8 +693,8 @@ int lzxd_decompress(struct lzxd_stream * > > /* check that we've used all of the previous frame first */ > if (lzx->o_ptr != lzx->o_end) { >- D(("%ld avail bytes, new %d frame", lzx->o_end-lzx->o_ptr, frame_size)) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ D(("%d avail bytes, new %d frame", (int)(lzx->o_end-lzx->o_ptr), frame_size)) >+ return lzx->error = LZX_ERR_DECRUNCH; > } > > /* does this intel block _really_ need decoding? */ >@@ -670,7 +709,7 @@ int lzxd_decompress(struct lzxd_stream * > > /* copy e8 block to the e8 buffer and tweak if needed */ > lzx->o_ptr = data; >- lzx->sys->copy(&lzx->window[lzx->frame_posn], data, frame_size); >+ memcpy(data, &lzx->window[lzx->frame_posn], frame_size); > > while (data < dataend) { > if (*data++ != 0xE8) { curpos++; continue; } >@@ -695,8 +734,8 @@ int lzxd_decompress(struct lzxd_stream * > > /* write a frame */ > i = (out_bytes < (off_t)frame_size) ? (unsigned int)out_bytes : frame_size; >- if (lzx->sys->write(lzx->output, lzx->o_ptr, i) != i) { >- return lzx->error = MSPACK_ERR_WRITE; >+ if (fwrite(lzx->o_ptr, 1, i, lzx->output) != i) { >+ return lzx->error = LZX_ERR_WRITE; > } > lzx->o_ptr += i; > lzx->offset += i; >@@ -714,7 +753,7 @@ int lzxd_decompress(struct lzxd_stream * > > if (out_bytes) { > D(("bytes left to output")) >- return lzx->error = MSPACK_ERR_DECRUNCH; >+ return lzx->error = LZX_ERR_DECRUNCH; > } > > /* store local state */ >@@ -724,15 +763,13 @@ int lzxd_decompress(struct lzxd_stream * > lzx->R1 = R1; > lzx->R2 = R2; > >- return MSPACK_ERR_OK; >+ return LZX_ERR_OK; > } > > void lzxd_free(struct lzxd_stream *lzx) { >- struct mspack_system *sys; > if (lzx) { >- sys = lzx->sys; >- sys->free(lzx->inbuf); >- sys->free(lzx->window); >- sys->free(lzx); >+ free(lzx->inbuf); >+ free(lzx->window); >+ free(lzx); > } > } >diff -upr mspack/lzx.h ./lzx.h >--- mspack/lzx.h 2010-09-24 12:45:31.000000000 +0200 >+++ ./lzx.h 2011-06-30 08:42:34.565446016 +0200 >@@ -10,12 +10,16 @@ > * For further details, see the file COPYING.LIB distributed with libmspack > */ > >-#ifndef MSPACK_LZX_H >-#define MSPACK_LZX_H 1 >+#ifndef LZX_H >+#define LZX_H 1 > >-#ifdef __cplusplus >-extern "C" { >-#endif >+#include <fcntl.h> >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+ >+#define D(x) do { printf("%s:%d (%s) \n",__FILE__, __LINE__, __func__); \ >+ printf x ; fputc('\n', stdout); fflush(stdout);} while (0); > > /* LZX compression / decompression definitions */ > >@@ -45,10 +49,36 @@ extern "C" { > > #define LZX_FRAME_SIZE (32768) /* the size of a frame in LZX */ > >+/* --- error codes --------------------------------------------------------- */ >+ >+/** Error code: no error */ >+#define LZX_ERR_OK (0) >+/** Error code: bad arguments to method */ >+#define LZX_ERR_ARGS (1) >+/** Error code: error opening file */ >+#define LZX_ERR_OPEN (2) >+/** Error code: error reading file */ >+#define LZX_ERR_READ (3) >+/** Error code: error writing file */ >+#define LZX_ERR_WRITE (4) >+/** Error code: seek error */ >+#define LZX_ERR_SEEK (5) >+/** Error code: out of memory */ >+#define LZX_ERR_NOMEMORY (6) >+/** Error code: bad "magic id" in file */ >+#define LZX_ERR_SIGNATURE (7) >+/** Error code: bad or corrupt file format */ >+#define LZX_ERR_DATAFORMAT (8) >+/** Error code: bad checksum or CRC */ >+#define LZX_ERR_CHECKSUM (9) >+/** Error code: error during compression */ >+#define LZX_ERR_CRUNCH (10) >+/** Error code: error during decompression */ >+#define LZX_ERR_DECRUNCH (11) >+ > struct lzxd_stream { >- struct mspack_system *sys; /* I/O routines */ >- struct mspack_file *input; /* input file handle */ >- struct mspack_file *output; /* output file handle */ >+ FILE *input; /* input file handle */ >+ FILE *output; /* output file handle */ > > off_t offset; /* number of bytes actually output */ > off_t length; /* overall decompressed length of stream */ >@@ -94,7 +124,6 @@ struct lzxd_stream { > (LZX_LENGTH_MAXSYMBOLS * 2)]; > unsigned short ALIGNED_table [(1 << LZX_ALIGNED_TABLEBITS) + > (LZX_ALIGNED_MAXSYMBOLS * 2)]; >- unsigned char LENGTH_empty; > > /* this is used purely for doing the intel E8 transform */ > unsigned char e8_buf[LZX_FRAME_SIZE]; >@@ -104,13 +133,10 @@ struct lzxd_stream { > * Allocates and initialises LZX decompression state for decoding an LZX > * stream. > * >- * This routine uses system->alloc() to allocate memory. If memory >+ * This routine uses malloc() to allocate memory. If memory > * allocation fails, or the parameters to this function are invalid, > * NULL is returned. > * >- * @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 LZX data. > * @param output an output stream to write the decoded data to. > * @param window_bits the size of the decoding window, which must be >@@ -138,9 +164,8 @@ struct lzxd_stream { > * @return a pointer to an initialised lzxd_stream structure, or NULL if > * there was not enough memory or parameters to the function were wrong. > */ >-extern struct lzxd_stream *lzxd_init(struct mspack_system *system, >- struct mspack_file *input, >- struct mspack_file *output, >+extern struct lzxd_stream *lzxd_init(FILE *input, >+ FILE *output, > int window_bits, > int reset_interval, > int input_buffer_size, >@@ -157,38 +182,34 @@ extern void lzxd_set_output_length(struc > * out_bytes parameter. If more bytes are decoded than are needed, they > * will be kept over for a later invocation. > * >- * The output bytes will be passed to the system->write() function given in >+ * The output bytes will be passed to the write() function given in > * lzxd_init(), using the output file handle given in lzxd_init(). More than >- * one call may be made to system->write(). >+ * one call may be made to write(). > >- * Input bytes will be read in as necessary using the system->read() >+ * Input bytes will be read in as necessary using the read() > * function given in lzxd_init(), using the input file handle given in >- * lzxd_init(). This will continue until system->read() returns 0 bytes, >+ * lzxd_init(). This will continue until 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 >+ * LZX_ERR_READ errors. Input streams should convey an "end of input > * stream" by refusing to supply all the bytes that LZX asks for when they > * reach the end of the stream, rather than return an error code. > * >- * If any error code other than MSPACK_ERR_OK is returned, the stream >+ * If any error code other than LZX_ERR_OK is returned, the stream > * should be considered unusable and lzxd_decompress() should not be > * called again on this stream. > * > * @param lzx LZX decompression state, as allocated by lzxd_init(). > * @param out_bytes the number of bytes of data to decompress. >- * @return an error code, or MSPACK_ERR_OK if successful >+ * @return an error code, or LZX_ERR_OK if successful > */ > extern int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes); > > /** > * Frees all state associated with an LZX data stream. This will call >- * system->free() using the system pointer given in lzxd_init(). >+ * free(). > * > * @param lzx LZX decompression state to free. > */ > void lzxd_free(struct lzxd_stream *lzx); > >-#ifdef __cplusplus >-} >-#endif >- > #endif >diff -upr mspack/readbits.h ./readbits.h >--- mspack/readbits.h 2010-09-23 19:06:09.000000000 +0200 >+++ ./readbits.h 2011-06-30 08:42:34.565446016 +0200 >@@ -7,8 +7,8 @@ > * For further details, see the file COPYING.LIB distributed with libmspack > */ > >-#ifndef MSPACK_READBITS_H >-#define MSPACK_READBITS_H 1 >+#ifndef READBITS_H >+#define READBITS_H 1 > > /* this header defines macros that read data streams by > * the individual bits >@@ -46,7 +46,6 @@ > * > * If you use read_input() and READ_IF_NEEDED, they also expect these > * structure members: >- * - struct mspack_system *sys; // to access sys->read() > * - unsigned int error; // to record/return read errors > * - unsigned char input_end; // to mark reaching the EOF > * - unsigned char *inbuf; // the input byte buffer >@@ -92,12 +91,8 @@ > # endif > #endif > >-#if HAVE_LIMITS_H > # include <limits.h> >-#endif >-#ifndef CHAR_BIT >-# define CHAR_BIT (8) >-#endif >+ > #define BITBUF_WIDTH (sizeof(bit_buffer) * CHAR_BIT) > > #define INIT_BITS do { \ >@@ -181,15 +176,14 @@ static const unsigned short lsb_bit_mask > } while (0) > > static int read_input(BITS_TYPE *p) { >- int read = p->sys->read(p->input, &p->inbuf[0], (int)p->inbuf_size); >- if (read < 0) return p->error = MSPACK_ERR_READ; >+ int read = fread(p->inbuf, 1, (int)p->inbuf_size, p->input); >+ if (read < 0) return p->error = LZX_ERR_READ; > > /* we might overrun the input stream by asking for bits we don't use, > * so fake 2 more bytes at the end of input */ > if (read == 0) { > if (p->input_end) { >- D(("out of input bytes")) >- return p->error = MSPACK_ERR_READ; >+ return p->error = LZX_ERR_READ; > } > else { > read = 2; >@@ -201,7 +195,7 @@ static int read_input(BITS_TYPE *p) { > /* update i_ptr and i_end */ > p->i_ptr = &p->inbuf[0]; > p->i_end = &p->inbuf[read]; >- return MSPACK_ERR_OK; >+ return LZX_ERR_OK; > } > #endif > #endif >diff -upr mspack/readhuff.h ./readhuff.h >--- mspack/readhuff.h 2010-09-24 16:07:17.000000000 +0200 >+++ ./readhuff.h 2011-06-30 08:42:34.566446027 +0200 >@@ -29,9 +29,6 @@ > # define HUFF_MAXBITS 16 > #endif > >-/* Decodes the next huffman symbol from the input bitstream into var. >- * Do not use this macro on a table unless build_decode_table() succeeded. >- */ > #define READ_HUFFSYM(tbl, var) do { \ > ENSURE_BITS(HUFF_MAXBITS); \ > sym = HUFF_TABLE(tbl, PEEK_BITS(TABLEBITS(tbl))); \ >@@ -168,6 +165,10 @@ static int make_decode_table(unsigned in > } > > /* full table? */ >- return (pos == table_mask) ? 0 : 1; >+ if (pos == table_mask) return 0; >+ >+ /* either erroneous table, or all elements are 0 - let's find out. */ >+ for (sym = 0; sym < nsyms; sym++) if (length[sym]) return 1; >+ return 0; > } > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 828112
: 640688