Removed some development remarks

and implemented skipping of zisofs headers larger than 16 bytes.
This commit is contained in:
2009-04-15 13:22:20 +02:00
parent 00802a1934
commit d87e5721db
6 changed files with 26 additions and 56 deletions

View File

@ -243,9 +243,6 @@ int extf_stream_open_flag(IsoStream *stream, int flag)
return ret;
}
stream_open = 1;
/* >>> ??? should one replace non-blocking read() by select () ? */
/* Make filter outlet non-blocking */
ret = fcntl(recv_pipe[0], F_GETFL);
if (ret != -1) {
@ -401,9 +398,6 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
while (1) {
if (running->in_eof && !blocking) {
/* >>> ??? should one replace non-blocking read() by select () ? */
/* Make filter outlet blocking */
ret = fcntl(running->recv_fd, F_GETFL);
if (ret != -1) {
@ -415,9 +409,6 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
/* Try to read desired amount from filter */;
while (1) {
/* >>> ??? should one replace non-blocking read() by select () ? */
ret = read(running->recv_fd, ((char *) buf) + fill,
desired - fill);
if (ret < 0) {
@ -436,9 +427,6 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
}
if (running->in_eof) {
/* >>> ??? should one replace non-blocking read() by select () ? */
usleep(1000); /* just in case it is still non-blocking */
continue;
}
@ -476,10 +464,8 @@ int extf_stream_read(IsoStream *stream, void *buf, size_t desired)
#ifdef Libisofs_external_filters_selecT
/* >>> ??? should one replace non-blocking read()
by select () ? */
/* This saves 10 % CPU load but needs 50 % more real time*/
/* This select() based waiting saves 10 % CPU load but
needs 50 % more real time */
ret = extf_wait_for_io(running->recv_fd, running->send_fd,
100000, 0);

View File

@ -138,7 +138,10 @@ static off_t gunzip_ref_count = 0;
#ifdef Libisofs_with_zliB
/* Parameter for deflateInit2() , see <zlib.h> */
/* >>> ??? get this from zisofs.c ziso_compression_level ? */
/* ??? get this from zisofs.c ziso_compression_level ?
* ??? have an own global parameter API ?
* For now level 6 seems to be a fine compromise between speed and size.
*/
static int gzip_compression_level = 6;
#endif /* Libisofs_with_zliB */
@ -359,10 +362,8 @@ int gzip_stream_convert(IsoStream *stream, void *buf, size_t desired, int flag)
return (rng->error_ret = ret);
if (ret == 0) {
if (flag & 2) {
/* >>> ??? what to do on (early) input EOF ? */;
return (rng->error_ret = ISO_ZLIB_COMPR_ERR);
/* Early input EOF */
return (rng->error_ret = ISO_ZLIB_EARLY_EOF);
} else {
/* Tell zlib by the next call that it is over */
rng->do_flush = Z_FINISH;

View File

@ -507,12 +507,8 @@ int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
size_t fill = 0;
char *cbuf = buf;
uLongf buf_len;
#ifndef NIX
uint32_t uncompressed_size;
#else
char zisofs_head[16];
#endif
char waste_word[4];
if (stream == NULL) {
return ISO_NULL_POINTER;
@ -530,8 +526,6 @@ int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
while (1) {
if (rng->state == 0) {
/* Reading file header */
#ifndef NIX
ret = ziso_parse_zisofs_head(data->orig, &header_size, &bs_log2,
&uncompressed_size, 0);
if (ret < 0)
@ -539,34 +533,15 @@ int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
nstd->header_size_div4 = header_size;
header_size *= 4;
data->size = uncompressed_size;
#else
ret = iso_stream_read(data->orig, zisofs_head, 16);
if (ret < 0)
return (rng->error_ret = ret);
header_size = ((unsigned char *) zisofs_head)[12] * 4;
bs_log2 = ((unsigned char *) zisofs_head)[13];
if (ret != 16 || memcmp(zisofs_head, zisofs_magic, 8) != 0 ||
header_size < 16 || bs_log2 < 15 || bs_log2 > 17) {
return (rng->error_ret = ISO_ZISOFS_WRONG_INPUT);
}
data->size = iso_read_lsb(((uint8_t *) zisofs_head) + 8, 4);
nstd->header_size_div4 = header_size / 4;
#endif /* NIX */
nstd->block_size_log2 = bs_log2;
rng->block_size = 1 << bs_log2;
if (header_size > 16) {
/* Skip surplus header bytes */
/* >>> This must be a loop
ret = iso_stream_read(data->orig, zisofs_head, header_size-16);
if (ret < 0)
return (rng->error_ret = ret);
if (ret != header_size - 16)
*/
return (rng->error_ret = ISO_ZISOFS_WRONG_INPUT);
for (i = 16; i < header_size; i += 4) {
/* Skip surplus header words */
ret = iso_stream_read(data->orig, waste_word, 4);
if (ret < 0)
return (rng->error_ret = ret);
if (ret != 4)
return (rng->error_ret = ISO_ZISOFS_WRONG_INPUT);
}
if (desired == 0) {