W załączniku prosty testcase,
na 2.3.5 daje:
zfseek (0x8049aa0, 0, 0, 1) = 0
1: 0
zfseek (0x8049aa0, 0, 0, 1) = 0
2: / -1
(ftell zwraca -1)
na 2.3.4
zfseek (0x96e0050, 0, 0, 1) = 0
1: 0
2: / 1
(ftell zwraca prawdę)
Test przez:
gcc testcookie.c -lz -Wall; ./a.out jakis.gzipniety.plik.gz
poldek zwisa dlatego, że dostaje od ftell -1 zamiast czegoś sensownego w
jednym miejscu i się zapętla na amen (nie ma sprawdzania co ftell zwróciło).
--
Arkadiusz Miśkiewicz PLD/Linux Team
http://www.t17.ds.pwr.wroc.pl/~misiek/ http://ftp.pld-linux.org/
# define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <zlib.h>
int zfseek(void *stream, _IO_off64_t *offset, int whence)
{
int rc;
off_t off = *offset;
rc = gzseek(stream, off, whence);
if (rc >= 0)
rc = 0;
printf("zfseek (%p, %ld, %lld, %d) = %d\n", stream, off, *offset, whence, rc);
return rc;
}
cookie_io_functions_t gzio_cookie = {
(cookie_read_function_t*)gzread,
(cookie_write_function_t*)gzwrite,
zfseek,
(cookie_close_function_t*)gzclose
};
int main(int argc, char *argv[])
{
char *path = argv[1];
gzFile gzstream;
FILE *stream;
int c;
if ((gzstream = gzopen(path, "r")) != NULL) {
stream = fopencookie(gzstream, "r", gzio_cookie);
printf("1: %ld\n", ftell(stream));
fread(&c, 1, 1, stream);
printf("2: %c %ld\n", (unsigned char)c, ftell(stream));
}
gzclose(gzstream);
return 1;
}
_______________________________________________
pld-devel-pl mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-devel-pl