Lines Matching defs:zf
65 zf_fill(struct z_file *zf)
70 req = Z_BUFSIZE - zf->zf_zstream.avail_in;
77 bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req);
80 result = read(zf->zf_rawfd, zf->zf_buf + zf->zf_zstream.avail_in, req);
81 zf->zf_zstream.next_in = zf->zf_buf;
83 zf->zf_zstream.avail_in += result;
94 get_byte(struct z_file *zf, off_t *curoffp)
96 if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1))
98 zf->zf_zstream.avail_in--;
100 return(*(zf->zf_zstream.next_in)++);
114 check_header(struct z_file *zf)
121 zf->zf_dataoffset = 0;
124 c = get_byte(zf, &zf->zf_dataoffset);
129 method = get_byte(zf, &zf->zf_dataoffset);
130 flags = get_byte(zf, &zf->zf_dataoffset);
136 for (len = 0; len < 6; len++) (void)get_byte(zf, &zf->zf_dataoffset);
139 len = (uInt)get_byte(zf, &zf->zf_dataoffset);
140 len += ((uInt)get_byte(zf, &zf->zf_dataoffset))<<8;
142 while (len-- != 0 && get_byte(zf, &zf->zf_dataoffset) != -1) ;
145 while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1) ;
148 while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1) ;
151 for (len = 0; len < 2; len++) c = get_byte(zf, &zf->zf_dataoffset);
162 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;
309 if (target < zf->zf_zstream.total_out && zf_rewind(f) != 0)
313 while (target > zf->zf_zstream.total_out) {
315 target - zf->zf_zstream.total_out), NULL);
320 return(zf->zf_zstream.total_out);
327 struct z_file *zf = (struct z_file *)f->f_fsdata;
333 if ((result = fstat(zf->zf_rawfd, sb)) == 0) {
336 pos1 = lseek(zf->zf_rawfd, 0, SEEK_CUR);
337 pos2 = lseek(zf->zf_rawfd, sb->st_size - 4, SEEK_SET);
339 if (read(zf->zf_rawfd, &size, 4) == 4)
346 pos1 = lseek(zf->zf_rawfd, pos1, SEEK_SET);