14 #define CHUNK_SIZE 16384 18 int ret = Z_STREAM_ERROR;
32 input_fd = open(input, O_RDONLY);
36 if (fstat(input_fd, &stbuf) < 0)
39 ptr = mmap(NULL, stbuf.st_size, PROT_READ, MAP_PRIVATE, input_fd, 0);
40 if (ptr == MAP_FAILED)
43 if (inflateInit2(&zs, 16 + MAX_WBITS) != Z_OK)
47 zs.avail_in = stbuf.st_size;
53 ret = inflate(&zs, Z_NO_FLUSH);
66 if (
writen(output_fd, buf, len) != len) {
71 }
while (ret != Z_STREAM_END);
76 munmap(ptr, stbuf.st_size);
80 return ret == Z_STREAM_END ? 0 : -1;
static int input(yyscan_t yyscanner)
int gzip_decompress_to_file(const char *input, int output_fd)
ssize_t writen(int fd, const void *buf, size_t n)