mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
deflate once again.
This commit is contained in:
parent
b4adf0d70d
commit
66fa83f7b5
@ -64,7 +64,11 @@ deflate_open(int window_size, struct stream_encoded *stream, int fd)
|
||||
data->after_first_read = 0;
|
||||
data->after_end = 0;
|
||||
|
||||
if (window_size > 0) {
|
||||
err = inflateInit2(&data->deflate_stream, window_size);
|
||||
} else {
|
||||
err = inflateInit(&data->deflate_stream);
|
||||
}
|
||||
if (err != Z_OK) {
|
||||
mem_free(data);
|
||||
return -1;
|
||||
@ -197,11 +201,21 @@ deflate_decode_buffer(struct stream_encoded *st, int window_size, unsigned char
|
||||
buffer = new_buffer;
|
||||
stream->next_out = buffer + stream->total_out;
|
||||
stream->avail_out = MAX_STR_LEN;
|
||||
|
||||
restart2:
|
||||
error = inflate(stream, Z_SYNC_FLUSH);
|
||||
if (error == Z_STREAM_END) {
|
||||
break;
|
||||
}
|
||||
if (error == Z_DATA_ERROR && !enc_data->after_first_read) {
|
||||
(void)inflateEnd(stream);
|
||||
error = inflateInit2(stream, -MAX_WBITS);
|
||||
if (error == Z_OK) {
|
||||
enc_data->after_first_read = 1;
|
||||
stream->next_in = data;
|
||||
stream->avail_in = len;
|
||||
goto restart2;
|
||||
}
|
||||
}
|
||||
} while (error == Z_OK && stream->avail_in > 0);
|
||||
|
||||
if (error == Z_STREAM_END) {
|
||||
|
Loading…
Reference in New Issue
Block a user