[BACK]Return to gzopen.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / compress

Diff for /src/usr.bin/compress/gzopen.c between version 1.29 and 1.30

version 1.29, 2015/08/20 22:32:41 version 1.30, 2016/04/28 14:21:24
Line 83 
Line 83 
 typedef  typedef
 struct gz_stream {  struct gz_stream {
         int     z_fd;           /* .gz file */          int     z_fd;           /* .gz file */
         z_stream z_stream;      /* libz stream */  
         int     z_eof;          /* set if end of input file */          int     z_eof;          /* set if end of input file */
           z_stream z_stream;      /* libz stream */
         u_char  z_buf[Z_BUFSIZE]; /* i/o buffer */          u_char  z_buf[Z_BUFSIZE]; /* i/o buffer */
           char    z_mode;         /* 'w' or 'r' */
         u_int32_t z_time;       /* timestamp (mtime) */          u_int32_t z_time;       /* timestamp (mtime) */
         u_int32_t z_hlen;       /* length of the gz header */  
         u_int32_t z_crc;        /* crc32 of uncompressed data */          u_int32_t z_crc;        /* crc32 of uncompressed data */
         char    z_mode;         /* 'w' or 'r' */          u_int32_t z_hlen;       /* length of the gz header */
           u_int64_t z_total_in;   /* # bytes in */
           u_int64_t z_total_out;  /* # bytes out */
 } gz_stream;  } gz_stream;
   
 static const u_char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */  static const u_char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
Line 128 
Line 129 
         s->z_eof = 0;          s->z_eof = 0;
         s->z_time = 0;          s->z_time = 0;
         s->z_hlen = 0;          s->z_hlen = 0;
           s->z_total_in = 0;
           s->z_total_out = 0;
         s->z_crc = crc32(0L, Z_NULL, 0);          s->z_crc = crc32(0L, Z_NULL, 0);
         s->z_mode = mode[0];          s->z_mode = mode[0];
   
Line 206 
Line 209 
                 info->mtime = s->z_time;                  info->mtime = s->z_time;
                 info->crc = s->z_crc;                  info->crc = s->z_crc;
                 info->hlen = s->z_hlen;                  info->hlen = s->z_hlen;
                 info->total_in = (off_t)s->z_stream.total_in;                  info->total_in = s->z_total_in;
                 info->total_out = (off_t)s->z_stream.total_out;                  info->total_out = s->z_total_out;
         }          }
   
         setfile(name, s->z_fd, sb);          setfile(name, s->z_fd, sb);
Line 336 
Line 339 
         (void)get_byte(s);          (void)get_byte(s);
         (void)get_byte(s);          (void)get_byte(s);
   
         s->z_hlen = 10; /* magic, method, flags, time, xflags, OS code */          s->z_hlen += 10; /* magic, method, flags, time, xflags, OS code */
         if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */          if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
                 len  =  (uInt)get_byte(s);                  len  =  (uInt)get_byte(s);
                 len += ((uInt)get_byte(s))<<8;                  len += ((uInt)get_byte(s))<<8;
Line 438 
Line 441 
   
                 if (error == Z_DATA_ERROR) {                  if (error == Z_DATA_ERROR) {
                         errno = EINVAL;                          errno = EINVAL;
                         return -1;                          goto bad;
                 }                  }
                 if (error == Z_BUF_ERROR) {                  if (error == Z_BUF_ERROR) {
                         errno = EIO;                          errno = EIO;
                         return -1;                          goto bad;
                 }                  }
                 if (error == Z_STREAM_END) {                  if (error == Z_STREAM_END) {
                         /* Check CRC and original size */                          /* Check CRC and original size */
Line 452 
Line 455 
   
                         if (get_int32(s) != s->z_crc) {                          if (get_int32(s) != s->z_crc) {
                                 errno = EINVAL;                                  errno = EINVAL;
                                 return -1;                                  goto bad;
                         }                          }
                         if (get_int32(s) != (u_int32_t)s->z_stream.total_out) {                          if (get_int32(s) != (u_int32_t)s->z_stream.total_out) {
                                 errno = EIO;                                  errno = EIO;
                                 return -1;                                  return -1;
                         }                          }
                         s->z_hlen += 2 * sizeof(int32_t);                          s->z_hlen += 2 * sizeof(int32_t);
   
                           /* Add byte counts from the finished stream. */
                           s->z_total_in += s->z_stream.total_in;
                           s->z_total_out += s->z_stream.total_out;
   
                         /* Check for the existence of an appended file. */                          /* Check for the existence of an appended file. */
                         if (get_header(s, NULL, 0) != 0) {                          if (get_header(s, NULL, 0) != 0) {
                                 s->z_eof = 1;                                  s->z_eof = 1;
Line 474 
Line 482 
         len -= s->z_stream.avail_out;          len -= s->z_stream.avail_out;
   
         return (len);          return (len);
   bad:
           /* Add byte counts from the finished stream. */
           s->z_total_in += s->z_stream.total_in;
           s->z_total_out += s->z_stream.total_out;
           return (-1);
 }  }
   
 int  int

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30