Lines Matching refs: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;
202 zf = malloc(sizeof(struct z_file));
203 if (zf == NULL)
205 bzero(zf, sizeof(struct z_file));
206 zf->zf_rawfd = rawfd;
209 if (check_header(zf)) {
210 close(zf->zf_rawfd);
211 free(zf);
216 if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) {
217 printf("zf_open: inflateInit returned %d : %s\n", error, zf->zf_zstream.msg);
218 close(zf->zf_rawfd);
219 free(zf);
224 f->f_fsdata = zf;
231 struct z_file *zf = (struct z_file *)f->f_fsdata;
233 inflateEnd(&(zf->zf_zstream));
234 close(zf->zf_rawfd);
235 free(zf);
242 struct z_file *zf = (struct z_file *)f->f_fsdata;
245 zf->zf_zstream.next_out = buf; /* where and how much */
246 zf->zf_zstream.avail_out = size;
248 while (zf->zf_zstream.avail_out && zf->zf_endseen == 0) {
249 if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) {
253 if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */
255 if (zf->zf_zstream.avail_out == size)
260 error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH); /* decompression pass */
262 zf->zf_endseen = 1;
266 printf("inflate: %s\n", zf->zf_zstream.msg);
271 *resid = zf->zf_zstream.avail_out;
278 struct z_file *zf = (struct z_file *)f->f_fsdata;
280 if (lseek(zf->zf_rawfd, zf->zf_dataoffset, SEEK_SET) == -1)
282 zf->zf_zstream.avail_in = 0;
283 zf->zf_zstream.next_in = NULL;
284 zf->zf_endseen = 0;
285 (void)inflateReset(&zf->zf_zstream);
293 struct z_file *zf = (struct z_file *)f->f_fsdata;
302 target = offset + zf->zf_zstream.total_out;
312 if (target < zf->zf_zstream.total_out && zf_rewind(f) != 0)
316 while (target > zf->zf_zstream.total_out) {
318 target - zf->zf_zstream.total_out), NULL);
323 return(zf->zf_zstream.total_out);
330 struct z_file *zf = (struct z_file *)f->f_fsdata;
336 if ((result = fstat(zf->zf_rawfd, sb)) == 0) {
339 pos1 = lseek(zf->zf_rawfd, 0, SEEK_CUR);
340 pos2 = lseek(zf->zf_rawfd, sb->st_size - 4, SEEK_SET);
342 if (read(zf->zf_rawfd, &size, 4) == 4)
349 pos1 = lseek(zf->zf_rawfd, pos1, SEEK_SET);