Lines Matching defs:pkg

52 	"pkg",
165 struct package *pkg;
168 pkg = NULL;
181 error = new_package(fd, &pkg);
187 if (pkg == NULL)
190 pkg->pkg_chain = package;
191 package = pkg;
221 * at the first filename that has the .pkg extension. This is
432 get_byte(struct package *pkg, off_t *op)
436 if (pkg->pkg_zs.avail_in == 0) {
437 c = read(pkg->pkg_fd, pkg->pkg_buf, PKG_BUFSIZE);
440 pkg->pkg_zs.avail_in = c;
441 pkg->pkg_zs.next_in = pkg->pkg_buf;
444 c = *pkg->pkg_zs.next_in;
445 pkg->pkg_zs.next_in++;
446 pkg->pkg_zs.avail_in--;
452 get_zipped(struct package *pkg, void *buf, size_t bufsz)
456 pkg->pkg_zs.next_out = buf;
457 pkg->pkg_zs.avail_out = bufsz;
459 while (pkg->pkg_zs.avail_out) {
460 if (pkg->pkg_zs.avail_in == 0) {
461 c = read(pkg->pkg_fd, pkg->pkg_buf, PKG_BUFSIZE);
466 pkg->pkg_zs.avail_in = c;
467 pkg->pkg_zs.next_in = pkg->pkg_buf;
470 c = inflate(&pkg->pkg_zs, Z_SYNC_FLUSH);
477 pkg->pkg_ofs += bufsz;
496 struct package *pkg;
505 pkg = tf->tf_pkg;
506 if (pkg == NULL) {
518 if (tf->tf_ofs != pkg->pkg_ofs) {
543 return (get_zipped(pkg, tf->tf_cache, sz));
622 * Technically, GNU pkg considers a field to be in base-256
647 struct package *pkg;
651 pkg = malloc(sizeof(*pkg));
652 if (pkg == NULL)
655 bzero(pkg, sizeof(*pkg));
656 pkg->pkg_fd = fd;
665 if (get_byte(pkg, &ofs) != 0x1f || get_byte(pkg, &ofs) != 0x8b)
668 if (get_byte(pkg, &ofs) != Z_DEFLATED)
671 flags = get_byte(pkg, &ofs);
677 if (get_byte(pkg, &ofs) == -1)
683 i = (get_byte(pkg, &ofs) & 0xff) |
684 ((get_byte(pkg, &ofs) << 8) & 0xff);
686 if (get_byte(pkg, &ofs) == -1)
694 i = get_byte(pkg, &ofs);
703 i = get_byte(pkg, &ofs);
714 if (get_byte(pkg, &ofs) == -1)
716 if (get_byte(pkg, &ofs) == -1)
723 error = inflateInit2(&pkg->pkg_zs, -15);
727 *pp = pkg;
731 free(pkg);
736 scan_tarfile(struct package *pkg, struct tarfile *last)
743 cur = (last != NULL) ? last->tf_next : pkg->pkg_first;
746 pkg->pkg_ofs;
750 if (ofs < pkg->pkg_ofs) {
755 if (ofs != pkg->pkg_ofs) {
756 if (last != NULL && pkg->pkg_ofs == last->tf_ofs) {
760 sz = ofs - pkg->pkg_ofs;
764 if (get_zipped(pkg, buf, sz) == -1)
766 sz = ofs - pkg->pkg_ofs;
775 cur->tf_pkg = pkg;
778 if (get_zipped(pkg, &cur->tf_hdr,
794 cur->tf_ofs = pkg->pkg_ofs;
806 while (pkg->pkg_ofs < ofs) {
807 if (get_zipped(pkg, buf, sizeof(buf)) == -1) {
817 pkg->pkg_first = cur;
818 pkg->pkg_last = cur;