Lines Matching refs:pkg

163 	struct package *pkg;  in pkgfs_init()  local
166 pkg = NULL; in pkgfs_init()
179 error = new_package(fd, &pkg); in pkgfs_init()
185 if (pkg == NULL) in pkgfs_init()
188 pkg->pkg_chain = package; in pkgfs_init()
189 package = pkg; in pkgfs_init()
421 get_byte(struct package *pkg, off_t *op) in get_byte() argument
425 if (pkg->pkg_zs.avail_in == 0) { in get_byte()
426 c = read(pkg->pkg_fd, pkg->pkg_buf, PKG_BUFSIZE); in get_byte()
429 pkg->pkg_zs.avail_in = c; in get_byte()
430 pkg->pkg_zs.next_in = pkg->pkg_buf; in get_byte()
433 c = *pkg->pkg_zs.next_in; in get_byte()
434 pkg->pkg_zs.next_in++; in get_byte()
435 pkg->pkg_zs.avail_in--; in get_byte()
441 get_zipped(struct package *pkg, void *buf, size_t bufsz) in get_zipped() argument
445 pkg->pkg_zs.next_out = buf; in get_zipped()
446 pkg->pkg_zs.avail_out = bufsz; in get_zipped()
448 while (pkg->pkg_zs.avail_out) { in get_zipped()
449 if (pkg->pkg_zs.avail_in == 0) { in get_zipped()
450 c = read(pkg->pkg_fd, pkg->pkg_buf, PKG_BUFSIZE); in get_zipped()
455 pkg->pkg_zs.avail_in = c; in get_zipped()
456 pkg->pkg_zs.next_in = pkg->pkg_buf; in get_zipped()
459 c = inflate(&pkg->pkg_zs, Z_SYNC_FLUSH); in get_zipped()
466 pkg->pkg_ofs += bufsz; in get_zipped()
473 struct package *pkg; in cache_data() local
482 pkg = tf->tf_pkg; in cache_data()
483 if (pkg == NULL) { in cache_data()
489 if (tf->tf_ofs != pkg->pkg_ofs) { in cache_data()
513 return (get_zipped(pkg, tf->tf_cache, sz)); in cache_data()
617 struct package *pkg; in new_package() local
621 pkg = malloc(sizeof(*pkg)); in new_package()
622 if (pkg == NULL) in new_package()
625 bzero(pkg, sizeof(*pkg)); in new_package()
626 pkg->pkg_fd = fd; in new_package()
635 if (get_byte(pkg, &ofs) != 0x1f || get_byte(pkg, &ofs) != 0x8b) in new_package()
638 if (get_byte(pkg, &ofs) != Z_DEFLATED) in new_package()
641 flags = get_byte(pkg, &ofs); in new_package()
647 if (get_byte(pkg, &ofs) == -1) in new_package()
653 i = (get_byte(pkg, &ofs) & 0xff) | in new_package()
654 ((get_byte(pkg, &ofs) << 8) & 0xff); in new_package()
656 if (get_byte(pkg, &ofs) == -1) in new_package()
664 i = get_byte(pkg, &ofs); in new_package()
673 i = get_byte(pkg, &ofs); in new_package()
684 if (get_byte(pkg, &ofs) == -1) in new_package()
686 if (get_byte(pkg, &ofs) == -1) in new_package()
693 error = inflateInit2(&pkg->pkg_zs, -15); in new_package()
697 *pp = pkg; in new_package()
701 free(pkg); in new_package()
706 scan_tarfile(struct package *pkg, struct tarfile *last) in scan_tarfile() argument
713 cur = (last != NULL) ? last->tf_next : pkg->pkg_first; in scan_tarfile()
716 pkg->pkg_ofs; in scan_tarfile()
720 if (ofs < pkg->pkg_ofs) { in scan_tarfile()
725 if (ofs != pkg->pkg_ofs) { in scan_tarfile()
726 if (last != NULL && pkg->pkg_ofs == last->tf_ofs) { in scan_tarfile()
730 sz = ofs - pkg->pkg_ofs; in scan_tarfile()
734 if (get_zipped(pkg, buf, sz) == -1) in scan_tarfile()
736 sz = ofs - pkg->pkg_ofs; in scan_tarfile()
745 cur->tf_pkg = pkg; in scan_tarfile()
748 if (get_zipped(pkg, &cur->tf_hdr, in scan_tarfile()
764 cur->tf_ofs = pkg->pkg_ofs; in scan_tarfile()
776 while (pkg->pkg_ofs < ofs) { in scan_tarfile()
777 if (get_zipped(pkg, buf, sizeof(buf)) == -1) { in scan_tarfile()
787 pkg->pkg_first = cur; in scan_tarfile()
788 pkg->pkg_last = cur; in scan_tarfile()