Lines Matching defs:bzf

84 bzf_fill(struct bz_file *bzf)
89 req = BZ_BUFSIZE - bzf->bzf_bzstream.avail_in;
96 bcopy(bzf->bzf_buf + req, bzf->bzf_buf, BZ_BUFSIZE - req);
99 result = read(bzf->bzf_rawfd, bzf->bzf_buf + bzf->bzf_bzstream.avail_in, req);
100 bzf->bzf_bzstream.next_in = bzf->bzf_buf;
102 bzf->bzf_bzstream.avail_in += result;
113 get_byte(struct bz_file *bzf)
115 if ((bzf->bzf_bzstream.avail_in == 0) && (bzf_fill(bzf) == -1))
117 bzf->bzf_bzstream.avail_in--;
118 return(*(bzf->bzf_bzstream.next_in)++);
124 check_header(struct bz_file *bzf)
131 c = get_byte(bzf);
137 c = get_byte(bzf);
142 bzf->bzf_bzstream.next_in -= 4;
143 bzf->bzf_bzstream.avail_in += 4;
153 struct bz_file *bzf;
191 bzf = malloc(sizeof(struct bz_file));
192 if (bzf == NULL)
194 bzero(bzf, sizeof(struct bz_file));
195 bzf->bzf_rawfd = rawfd;
198 if (check_header(bzf)) {
199 close(bzf->bzf_rawfd);
200 free(bzf);
205 if ((error = BZ2_bzDecompressInit(&(bzf->bzf_bzstream), 0, 1)) != BZ_OK) {
207 close(bzf->bzf_rawfd);
208 free(bzf);
213 f->f_fsdata = bzf;
220 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
222 BZ2_bzDecompressEnd(&(bzf->bzf_bzstream));
223 close(bzf->bzf_rawfd);
224 free(bzf);
231 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
234 bzf->bzf_bzstream.next_out = buf; /* where and how much */
235 bzf->bzf_bzstream.avail_out = size;
237 while (bzf->bzf_bzstream.avail_out && bzf->bzf_endseen == 0) {
238 if ((bzf->bzf_bzstream.avail_in == 0) && (bzf_fill(bzf) == -1)) {
242 if (bzf->bzf_bzstream.avail_in == 0) { /* oops, unexpected EOF */
244 if (bzf->bzf_bzstream.avail_out == size)
249 error = BZ2_bzDecompress(&bzf->bzf_bzstream); /* decompression pass */
251 bzf->bzf_endseen = 1;
260 *resid = bzf->bzf_bzstream.avail_out;
267 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
283 bzf_tmp->bzf_rawfd = bzf->bzf_rawfd;
292 if (lseek(bzf->bzf_rawfd, 0, SEEK_SET) == -1) {
299 BZ2_bzDecompressEnd(&(bzf->bzf_bzstream));
300 free(bzf);
311 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
320 target = offset + bzf->bzf_bzstream.total_out_lo32;
328 if (target < bzf->bzf_bzstream.total_out_lo32 && bzf_rewind(f) != 0) {
333 /* if bzf_rewind was called then bzf has changed */
334 bzf = (struct bz_file *)f->f_fsdata;
337 while (target > bzf->bzf_bzstream.total_out_lo32) {
339 target - bzf->bzf_bzstream.total_out_lo32), NULL);
344 return(bzf->bzf_bzstream.total_out_lo32);
350 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
354 if ((result = fstat(bzf->bzf_rawfd, sb)) == 0)