Lines Matching defs:zf

66 zf_fill(struct z_file *zf)
71 req = Z_BUFSIZE - zf->zf_zstream.avail_in;
78 bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req);
81 result = read(zf->zf_rawfd, zf->zf_buf + zf->zf_zstream.avail_in, req);
82 zf->zf_zstream.next_in = zf->zf_buf;
84 zf->zf_zstream.avail_in += result;
95 get_byte(struct z_file *zf, off_t *curoffp)
97 if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1))
99 zf->zf_zstream.avail_in--;
101 return(*(zf->zf_zstream.next_in)++);
115 check_header(struct z_file *zf)
122 zf->zf_dataoffset = 0;
125 c = get_byte(zf, &zf->zf_dataoffset);
130 method = get_byte(zf, &zf->zf_dataoffset);
131 flags = get_byte(zf, &zf->zf_dataoffset);
137 for (len = 0; len < 6; len++) (void)get_byte(zf, &zf->zf_dataoffset);
140 len = (uInt)get_byte(zf, &zf->zf_dataoffset);
141 len += ((uInt)get_byte(zf, &zf->zf_dataoffset))<<8;
143 while (len-- != 0 && get_byte(zf, &zf->zf_dataoffset) != -1) ;
146 while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1) ;
149 while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1) ;
152 for (len = 0; len < 2; len++) c = get_byte(zf, &zf->zf_dataoffset);
163 struct z_file *zf;
201 zf = malloc(sizeof(struct z_file));
202 if (zf == NULL)
204 bzero(zf, sizeof(struct z_file));
205 zf->zf_rawfd = rawfd;
208 if (check_header(zf)) {
209 close(zf->zf_rawfd);
210 free(zf);
215 if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) {
216 printf("zf_open: inflateInit returned %d : %s\n", error, zf->zf_zstream.msg);
217 close(zf->zf_rawfd);
218 free(zf);
223 f->f_fsdata = zf;
230 struct z_file *zf = (struct z_file *)f->f_fsdata;
232 inflateEnd(&(zf->zf_zstream));
233 close(zf->zf_rawfd);
234 free(zf);
241 struct z_file *zf = (struct z_file *)f->f_fsdata;
244 zf->zf_zstream.next_out = buf; /* where and how much */
245 zf->zf_zstream.avail_out = size;
247 while (zf->zf_zstream.avail_out && zf->zf_endseen == 0) {
248 if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) {
252 if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */
254 if (zf->zf_zstream.avail_out == size)
259 error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH); /* decompression pass */
261 zf->zf_endseen = 1;
265 printf("inflate: %s\n", zf->zf_zstream.msg);
270 *resid = zf->zf_zstream.avail_out;
277 struct z_file *zf = (struct z_file *)f->f_fsdata;
279 if (lseek(zf->zf_rawfd, zf->zf_dataoffset, SEEK_SET) == -1)
281 zf->zf_zstream.avail_in = 0;
282 zf->zf_zstream.next_in = NULL;
283 zf->zf_endseen = 0;
284 (void)inflateReset(&zf->zf_zstream);
292 struct z_file *zf = (struct z_file *)f->f_fsdata;
301 target = offset + zf->zf_zstream.total_out;
311 if (target < zf->zf_zstream.total_out && zf_rewind(f) != 0)
315 while (target > zf->zf_zstream.total_out) {
317 target - zf->zf_zstream.total_out), NULL);
322 return(zf->zf_zstream.total_out);
329 struct z_file *zf = (struct z_file *)f->f_fsdata;
333 if ((result = fstat(zf->zf_rawfd, sb)) == 0)