Lines Matching defs:pkg

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