Lines Matching refs:pkg
165 struct package *pkg; in pkgfs_init() local
168 pkg = NULL; in pkgfs_init()
181 error = new_package(fd, &pkg); in pkgfs_init()
187 if (pkg == NULL) in pkgfs_init()
190 pkg->pkg_chain = package; in pkgfs_init()
191 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
522 pkg = tf->tf_pkg; in cache_data()
523 if (pkg == NULL) { in cache_data()
535 if (tf->tf_ofs != pkg->pkg_ofs) { in cache_data()
560 return (get_zipped(pkg, tf->tf_cache, sz)); in cache_data()
664 struct package *pkg; in new_package() local
668 pkg = malloc(sizeof(*pkg)); in new_package()
669 if (pkg == NULL) in new_package()
672 bzero(pkg, sizeof(*pkg)); in new_package()
673 pkg->pkg_fd = fd; in new_package()
682 if (get_byte(pkg, &ofs) != 0x1f || get_byte(pkg, &ofs) != 0x8b) in new_package()
685 if (get_byte(pkg, &ofs) != Z_DEFLATED) in new_package()
688 flags = get_byte(pkg, &ofs); in new_package()
694 if (get_byte(pkg, &ofs) == -1) in new_package()
700 i = (get_byte(pkg, &ofs) & 0xff) | in new_package()
701 ((get_byte(pkg, &ofs) << 8) & 0xff); in new_package()
703 if (get_byte(pkg, &ofs) == -1) in new_package()
711 i = get_byte(pkg, &ofs); in new_package()
720 i = get_byte(pkg, &ofs); in new_package()
731 if (get_byte(pkg, &ofs) == -1) in new_package()
733 if (get_byte(pkg, &ofs) == -1) in new_package()
740 error = inflateInit2(&pkg->pkg_zs, -15); in new_package()
744 *pp = pkg; in new_package()
748 free(pkg); in new_package()
753 scan_tarfile(struct package *pkg, struct tarfile *last) in scan_tarfile() argument
760 cur = (last != NULL) ? last->tf_next : pkg->pkg_first; in scan_tarfile()
763 pkg->pkg_ofs; in scan_tarfile()
767 if (ofs < pkg->pkg_ofs) { in scan_tarfile()
772 if (ofs != pkg->pkg_ofs) { in scan_tarfile()
773 if (last != NULL && pkg->pkg_ofs == last->tf_ofs) { in scan_tarfile()
777 sz = ofs - pkg->pkg_ofs; in scan_tarfile()
781 if (get_zipped(pkg, buf, sz) == -1) in scan_tarfile()
783 sz = ofs - pkg->pkg_ofs; in scan_tarfile()
792 cur->tf_pkg = pkg; in scan_tarfile()
795 if (get_zipped(pkg, &cur->tf_hdr, in scan_tarfile()
811 cur->tf_ofs = pkg->pkg_ofs; in scan_tarfile()
823 while (pkg->pkg_ofs < ofs) { in scan_tarfile()
824 if (get_zipped(pkg, buf, sizeof(buf)) == -1) { in scan_tarfile()
834 pkg->pkg_first = cur; in scan_tarfile()
835 pkg->pkg_last = cur; in scan_tarfile()