int reading_position;
int loop;
int error;
- uint16_t crc16;
};
struct lzh_stream {
static uint16_t lha_crc16(uint16_t, const void *, size_t);
static int lzh_decode_init(struct lzh_stream *, const char *);
static void lzh_decode_free(struct lzh_stream *);
-static uint16_t lzh_crc16(struct lzh_stream *);
static int lzh_decode(struct lzh_stream *, int);
static int lzh_br_fillup(struct lzh_stream *, struct lzh_br *);
static int lzh_huffman_init(struct huffman *, size_t, int);
*offset = lha->entry_offset;
*size = lha->strm.next_out - lha->uncompressed_buffer;
*buff = lha->uncompressed_buffer;
- lha->entry_crc_calculated = lzh_crc16(&(lha->strm));
+ lha->entry_crc_calculated =
+ lha_crc16(lha->entry_crc_calculated, *buff, *size);
lha->entry_offset += *size;
} else {
*offset = lha->entry_offset;
return (ARCHIVE_FATAL);
}
memset(ds->w_buff, 0x20, ds->w_size);
- ds->crc16 = 0;
ds->w_pos = 0;
ds->state = 0;
ds->pos_pt_len_size = w_bits + 1;
strm->ds = NULL;
}
-static uint16_t
-lzh_crc16(struct lzh_stream *strm)
-{
-
- if (strm->ds == NULL)
- return (0);
- return (strm->ds->crc16);
-}
-
-
/*
* Bit stream reader.
*/
int w_pos = ds->w_pos, w_mask = ds->w_mask, w_size = ds->w_size;
int lt_max_bits = lt->max_bits, pt_max_bits = pt->max_bits;
int state = ds->state;
- uint16_t crc16 = ds->crc16;
for (;;) {
switch (state) {
ds->state = ST_RD_BLOCK;
ds->br = bre;
ds->blocks_avail = 0;
- ds->crc16 = crc16;
ds->w_pos = w_pos;
strm->avail_out = endp - outp;
return (100);
* afterward. */
w_buff[w_pos] = c;
w_pos = (w_pos + 1) & w_mask;
- CRC16(crc16, c);
/* Store the decoded code to the output
* buffer. */
*outp++ = c;
|| (w_pos + l < copy_pos))) {
memcpy(w_buff + w_pos, s, l);
memcpy(outp, s, l);
- crc16 = lha_crc16(crc16, s, l);
} else {
unsigned char *d;
int li;
d = w_buff + w_pos;
- for (li = 0; li < l; li++) {
- c = outp[li] = d[li] = s[li];
- CRC16(crc16, c);
- }
+ for (li = 0; li < l; li++)
+ outp[li] = d[li] = s[li];
}
outp += l;
copy_pos = (copy_pos + l) & w_mask;
next_data:
ds->br = bre;
ds->blocks_avail = blocks_avail;
- ds->crc16 = crc16;
ds->state = state;
ds->w_pos = w_pos;
strm->avail_out = endp - outp;