s->stream.avail_out -= oread(fd, s->stream.next_out, s->stream.avail_out);
int n; n = oread(fd, s->stream.next_out, s->stream.avail_out); if (n <= 0) { s->z_eof = 1; if (errno) { s->z_err = Z_ERRNO; break; } } s->stream.avail_out -= n;
read(fd, buf, len)	int fd;	void *buf;	size_t len;{	  struct sd *s;	  unsigned char *start = buf; /* starting point for crc computation */	  s = ss[fd];	  if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;	  if (s->z_err == Z_STREAM_END) return 0;  /* EOF */	  s->stream.next_out = buf;	  s->stream.avail_out = len;	  while (s->stream.avail_out != 0) {	    if (s->transparent) {	      /* Copy first the lookahead bytes: */	      unsigned int n = s->stream.avail_in;	      if (n > s->stream.avail_out) n = s->stream.avail_out;	      if (n > 0) {		zmemcpy(s->stream.next_out, s->stream.next_in, n);		s->stream.next_out += n;		s->stream.next_in   += n;		s->stream.avail_out -= n;		s->stream.avail_in  -= n;	      }	      if (s->stream.avail_out > 0) {		s->stream.avail_out -= oread(fd, s->stream.next_out, s->stream.avail_out);	      }	      len -= s->stream.avail_out;	      s->stream.total_in  += (unsigned long)len;	      s->stream.total_out += (unsigned long)len;	      if (len == 0) s->z_eof = 1;	      return (int)len;	    }	    if (s->stream.avail_in == 0 && !s->z_eof) {	      errno = 0;	      s->stream.avail_in = oread(fd, s->inbuf, Z_BUFSIZE);	      if (s->stream.avail_in == 0) {		s->z_eof = 1;		if (errno) {		  s->z_err = Z_ERRNO;		  break;		}	      }	      s->stream.next_in = s->inbuf;	    }	    s->z_err = inflate(&(s->stream), Z_NO_FLUSH);	    if (s->z_err == Z_STREAM_END) {	      /* Check CRC and original size */	      s->crc = crc32(s->crc, start, (unsigned int)(s->stream.next_out - start));	      start = s->stream.next_out;	      if (getLong(s) != s->crc) {		s->z_err = Z_DATA_ERROR;	      } else {		(void)getLong(s);		/* The uncompressed length returned by above getlong() may		 * be different from s->stream.total_out) in case of		 * concatenated .gz files. Check for such files:		 */		check_header(s);		if (s->z_err == Z_OK) {		  unsigned long total_in = s->stream.total_in;		  unsigned long total_out = s->stream.total_out;		  inflateReset(&(s->stream));		  s->stream.total_in = total_in;		  s->stream.total_out = total_out;		  s->crc = crc32(0L, Z_NULL, 0);		}	      }	    }	    if (s->z_err != Z_OK || s->z_eof) break;	  }	  s->crc = crc32(s->crc, start, (unsigned int)(s->stream.next_out - start));	  return (int)(len - s->stream.avail_out);}