Lines Matching refs:bzf

85 bzf_fill(struct bz_file *bzf)
90 req = BZ_BUFSIZE - bzf->bzf_bzstream.avail_in;
97 bcopy(bzf->bzf_buf + req, bzf->bzf_buf, BZ_BUFSIZE - req);
100 result = read(bzf->bzf_rawfd, bzf->bzf_buf + bzf->bzf_bzstream.avail_in, req);
101 bzf->bzf_bzstream.next_in = bzf->bzf_buf;
103 bzf->bzf_bzstream.avail_in += result;
114 get_byte(struct bz_file *bzf)
116 if ((bzf->bzf_bzstream.avail_in == 0) && (bzf_fill(bzf) == -1))
118 bzf->bzf_bzstream.avail_in--;
119 return(*(bzf->bzf_bzstream.next_in)++);
125 check_header(struct bz_file *bzf)
132 c = get_byte(bzf);
138 c = get_byte(bzf);
143 bzf->bzf_bzstream.next_in -= 4;
144 bzf->bzf_bzstream.avail_in += 4;
154 struct bz_file *bzf;
192 bzf = malloc(sizeof(struct bz_file));
193 if (bzf == NULL)
195 bzero(bzf, sizeof(struct bz_file));
196 bzf->bzf_rawfd = rawfd;
199 if (check_header(bzf)) {
200 close(bzf->bzf_rawfd);
201 free(bzf);
206 if ((error = BZ2_bzDecompressInit(&(bzf->bzf_bzstream), 0, 1)) != BZ_OK) {
208 close(bzf->bzf_rawfd);
209 free(bzf);
214 f->f_fsdata = bzf;
221 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
223 BZ2_bzDecompressEnd(&(bzf->bzf_bzstream));
224 close(bzf->bzf_rawfd);
225 free(bzf);
232 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
235 bzf->bzf_bzstream.next_out = buf; /* where and how much */
236 bzf->bzf_bzstream.avail_out = size;
238 while (bzf->bzf_bzstream.avail_out && bzf->bzf_endseen == 0) {
239 if ((bzf->bzf_bzstream.avail_in == 0) && (bzf_fill(bzf) == -1)) {
243 if (bzf->bzf_bzstream.avail_in == 0) { /* oops, unexpected EOF */
245 if (bzf->bzf_bzstream.avail_out == size)
250 error = BZ2_bzDecompress(&bzf->bzf_bzstream); /* decompression pass */
252 bzf->bzf_endseen = 1;
261 *resid = bzf->bzf_bzstream.avail_out;
268 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
284 bzf_tmp->bzf_rawfd = bzf->bzf_rawfd;
293 if (lseek(bzf->bzf_rawfd, 0, SEEK_SET) == -1) {
300 BZ2_bzDecompressEnd(&(bzf->bzf_bzstream));
301 free(bzf);
312 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
321 target = offset + bzf->bzf_bzstream.total_out_lo32;
331 if (target < bzf->bzf_bzstream.total_out_lo32 && bzf_rewind(f) != 0) {
336 /* if bzf_rewind was called then bzf has changed */
337 bzf = (struct bz_file *)f->f_fsdata;
340 while (target > bzf->bzf_bzstream.total_out_lo32) {
342 target - bzf->bzf_bzstream.total_out_lo32), NULL);
347 return(bzf->bzf_bzstream.total_out_lo32);
353 struct bz_file *bzf = (struct bz_file *)f->f_fsdata;
357 if ((result = fstat(bzf->bzf_rawfd, sb)) == 0)