gzlib.c (6010a892b4258e90037dabf9765066d07b86f13f) | gzlib.c (cd8822075a38d0734e74b1735e4b5dbef9789170) |
---|---|
1/* gzlib.c -- zlib functions common to reading and writing gzip files | 1/* gzlib.c -- zlib functions common to reading and writing gzip files |
2 * Copyright (C) 2004-2017 Mark Adler | 2 * Copyright (C) 2004-2019 Mark Adler |
3 * For conditions of distribution and use, see copyright notice in zlib.h 4 */ 5 6/* $FreeBSD$ */ 7 8#include "gzguts.h" 9#include "zutil.h" 10#include <unistd.h> 11 | 3 * For conditions of distribution and use, see copyright notice in zlib.h 4 */ 5 6/* $FreeBSD$ */ 7 8#include "gzguts.h" 9#include "zutil.h" 10#include <unistd.h> 11 |
12#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) | 12#if defined(_WIN32) && !defined(__BORLANDC__) |
13# define LSEEK _lseeki64 14#else 15#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 16# define LSEEK lseek64 17#else 18# define LSEEK lseek 19#endif 20#endif --- 59 unchanged lines hidden (view full) --- 80 gz_statep state; 81{ 82 state->x.have = 0; /* no output data available */ 83 if (state->mode == GZ_READ) { /* for reading ... */ 84 state->eof = 0; /* not at end of file */ 85 state->past = 0; /* have not read past end yet */ 86 state->how = LOOK; /* look for gzip header */ 87 } | 13# define LSEEK _lseeki64 14#else 15#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 16# define LSEEK lseek64 17#else 18# define LSEEK lseek 19#endif 20#endif --- 59 unchanged lines hidden (view full) --- 80 gz_statep state; 81{ 82 state->x.have = 0; /* no output data available */ 83 if (state->mode == GZ_READ) { /* for reading ... */ 84 state->eof = 0; /* not at end of file */ 85 state->past = 0; /* have not read past end yet */ 86 state->how = LOOK; /* look for gzip header */ 87 } |
88 else /* for writing ... */ 89 state->reset = 0; /* no deflateReset pending */ |
|
88 state->seek = 0; /* no seek request pending */ 89 gz_error(state, Z_OK, NULL); /* clear error */ 90 state->x.pos = 0; /* no uncompressed data yet */ 91 state->strm.avail_in = 0; /* no input data yet */ 92} 93 94/* Open a gzip file either by name or file descriptor. */ 95local gzFile gz_open(path, fd, mode) --- 300 unchanged lines hidden (view full) --- 396 offset -= state->x.pos; 397 else if (state->seek) 398 offset += state->skip; 399 state->seek = 0; 400 401 /* if within raw area while reading, just go there */ 402 if (state->mode == GZ_READ && state->how == COPY && 403 state->x.pos + offset >= 0) { | 90 state->seek = 0; /* no seek request pending */ 91 gz_error(state, Z_OK, NULL); /* clear error */ 92 state->x.pos = 0; /* no uncompressed data yet */ 93 state->strm.avail_in = 0; /* no input data yet */ 94} 95 96/* Open a gzip file either by name or file descriptor. */ 97local gzFile gz_open(path, fd, mode) --- 300 unchanged lines hidden (view full) --- 398 offset -= state->x.pos; 399 else if (state->seek) 400 offset += state->skip; 401 state->seek = 0; 402 403 /* if within raw area while reading, just go there */ 404 if (state->mode == GZ_READ && state->how == COPY && 405 state->x.pos + offset >= 0) { |
404 ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); | 406 ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR); |
405 if (ret == -1) 406 return -1; 407 state->x.have = 0; 408 state->eof = 0; 409 state->past = 0; 410 state->seek = 0; 411 gz_error(state, Z_OK, NULL); 412 state->strm.avail_in = 0; --- 229 unchanged lines hidden --- | 407 if (ret == -1) 408 return -1; 409 state->x.have = 0; 410 state->eof = 0; 411 state->past = 0; 412 state->seek = 0; 413 gz_error(state, Z_OK, NULL); 414 state->strm.avail_in = 0; --- 229 unchanged lines hidden --- |