Lines Matching refs:pkg
157 struct package *pkg; in pkgfs_init() local
160 pkg = NULL; in pkgfs_init()
176 error = new_package(fd, &pkg); in pkgfs_init()
182 if (pkg == NULL) in pkgfs_init()
185 pkg->pkg_chain = package; in pkgfs_init()
186 package = pkg; in pkgfs_init()
449 get_byte(struct package *pkg, off_t *op) in get_byte() argument
453 if (pkg->pkg_zs.avail_in == 0) { in get_byte()
454 c = read(pkg->pkg_fd, pkg->pkg_buf, PKG_BUFSIZE); in get_byte()
457 pkg->pkg_zs.avail_in = c; in get_byte()
458 pkg->pkg_zs.next_in = pkg->pkg_buf; in get_byte()
461 c = *pkg->pkg_zs.next_in; in get_byte()
462 pkg->pkg_zs.next_in++; in get_byte()
463 pkg->pkg_zs.avail_in--; in get_byte()
469 get_zipped(struct package *pkg, void *buf, size_t bufsz) in get_zipped() argument
473 pkg->pkg_zs.next_out = buf; in get_zipped()
474 pkg->pkg_zs.avail_out = bufsz; in get_zipped()
476 while (pkg->pkg_zs.avail_out) { in get_zipped()
477 if (pkg->pkg_zs.avail_in == 0) { in get_zipped()
478 c = read(pkg->pkg_fd, pkg->pkg_buf, PKG_BUFSIZE); in get_zipped()
483 pkg->pkg_zs.avail_in = c; in get_zipped()
484 pkg->pkg_zs.next_in = pkg->pkg_buf; in get_zipped()
487 c = inflate(&pkg->pkg_zs, Z_SYNC_FLUSH); in get_zipped()
494 pkg->pkg_ofs += bufsz; in get_zipped()
513 struct package *pkg; in cache_data() local
523 pkg = tf->tf_pkg; in cache_data()
524 if (pkg == NULL) { in cache_data()
537 if (tf->tf_ofs != pkg->pkg_ofs) { in cache_data()
563 return (get_zipped(pkg, tf->tf_cache, sz)); in cache_data()
667 struct package *pkg; in new_package() local
671 pkg = malloc(sizeof(*pkg)); in new_package()
672 if (pkg == NULL) in new_package()
675 bzero(pkg, sizeof(*pkg)); in new_package()
676 pkg->pkg_fd = fd; in new_package()
685 if (get_byte(pkg, &ofs) != 0x1f || get_byte(pkg, &ofs) != 0x8b) in new_package()
688 if (get_byte(pkg, &ofs) != Z_DEFLATED) in new_package()
691 flags = get_byte(pkg, &ofs); in new_package()
697 if (get_byte(pkg, &ofs) == -1) in new_package()
703 i = (get_byte(pkg, &ofs) & 0xff) | in new_package()
704 ((get_byte(pkg, &ofs) << 8) & 0xff); in new_package()
706 if (get_byte(pkg, &ofs) == -1) in new_package()
714 i = get_byte(pkg, &ofs); in new_package()
723 i = get_byte(pkg, &ofs); in new_package()
734 if (get_byte(pkg, &ofs) == -1) in new_package()
736 if (get_byte(pkg, &ofs) == -1) in new_package()
743 error = inflateInit2(&pkg->pkg_zs, -15); in new_package()
747 *pp = pkg; in new_package()
751 free(pkg); in new_package()
756 scan_tarfile(struct package *pkg, struct tarfile *last) in scan_tarfile() argument
763 cur = (last != NULL) ? last->tf_next : pkg->pkg_first; in scan_tarfile()
766 pkg->pkg_ofs; in scan_tarfile()
770 if (ofs < pkg->pkg_ofs) { in scan_tarfile()
775 if (ofs != pkg->pkg_ofs) { in scan_tarfile()
776 if (last != NULL && pkg->pkg_ofs == last->tf_ofs) { in scan_tarfile()
780 sz = ofs - pkg->pkg_ofs; in scan_tarfile()
784 if (get_zipped(pkg, buf, sz) == -1) in scan_tarfile()
786 sz = ofs - pkg->pkg_ofs; in scan_tarfile()
795 cur->tf_pkg = pkg; in scan_tarfile()
798 if (get_zipped(pkg, &cur->tf_hdr, in scan_tarfile()
814 cur->tf_ofs = pkg->pkg_ofs; in scan_tarfile()
826 while (pkg->pkg_ofs < ofs) { in scan_tarfile()
827 if (get_zipped(pkg, buf, sizeof(buf)) == -1) { in scan_tarfile()
837 pkg->pkg_first = cur; in scan_tarfile()
838 pkg->pkg_last = cur; in scan_tarfile()