15c51f124SMoriah Waterland /* 25c51f124SMoriah Waterland * CDDL HEADER START 35c51f124SMoriah Waterland * 45c51f124SMoriah Waterland * The contents of this file are subject to the terms of the 55c51f124SMoriah Waterland * Common Development and Distribution License (the "License"). 65c51f124SMoriah Waterland * You may not use this file except in compliance with the License. 75c51f124SMoriah Waterland * 85c51f124SMoriah Waterland * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95c51f124SMoriah Waterland * or http://www.opensolaris.org/os/licensing. 105c51f124SMoriah Waterland * See the License for the specific language governing permissions 115c51f124SMoriah Waterland * and limitations under the License. 125c51f124SMoriah Waterland * 135c51f124SMoriah Waterland * When distributing Covered Code, include this CDDL HEADER in each 145c51f124SMoriah Waterland * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155c51f124SMoriah Waterland * If applicable, add the following below this CDDL HEADER, with the 165c51f124SMoriah Waterland * fields enclosed by brackets "[]" replaced with your own identifying 175c51f124SMoriah Waterland * information: Portions Copyright [yyyy] [name of copyright owner] 185c51f124SMoriah Waterland * 195c51f124SMoriah Waterland * CDDL HEADER END 205c51f124SMoriah Waterland */ 215c51f124SMoriah Waterland 225c51f124SMoriah Waterland /* 235c51f124SMoriah Waterland * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 245c51f124SMoriah Waterland * Use is subject to license terms. 255c51f124SMoriah Waterland */ 265c51f124SMoriah Waterland 275c51f124SMoriah Waterland /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 285c51f124SMoriah Waterland /* All Rights Reserved */ 295c51f124SMoriah Waterland 305c51f124SMoriah Waterland 315c51f124SMoriah Waterland 325c51f124SMoriah Waterland #include <stdio.h> 335c51f124SMoriah Waterland #include <string.h> 345c51f124SMoriah Waterland #include <limits.h> 355c51f124SMoriah Waterland #include <stdlib.h> 365c51f124SMoriah Waterland #include <unistd.h> 375c51f124SMoriah Waterland #include <sys/types.h> 385c51f124SMoriah Waterland #include "pkgstrct.h" 395c51f124SMoriah Waterland 405c51f124SMoriah Waterland int holdcinfo = 0; 415c51f124SMoriah Waterland 425c51f124SMoriah Waterland int 435c51f124SMoriah Waterland ppkgmap(struct cfent *ept, FILE *fp) 445c51f124SMoriah Waterland { 455c51f124SMoriah Waterland if (ept->path == NULL) 465c51f124SMoriah Waterland return (-1); 475c51f124SMoriah Waterland 485c51f124SMoriah Waterland if (ept->volno) { 495c51f124SMoriah Waterland if (fprintf(fp, "%d ", ept->volno) < 0) 505c51f124SMoriah Waterland return (-1); 515c51f124SMoriah Waterland } 525c51f124SMoriah Waterland 535c51f124SMoriah Waterland if (ept->ftype == 'i') { 545c51f124SMoriah Waterland if (fprintf(fp, "%c %s", ept->ftype, ept->path) < 0) 555c51f124SMoriah Waterland return (-1); 565c51f124SMoriah Waterland } else { 575c51f124SMoriah Waterland if (fprintf(fp, "%c %s %s", ept->ftype, ept->pkg_class, 585c51f124SMoriah Waterland ept->path) < 0) 595c51f124SMoriah Waterland return (-1); 605c51f124SMoriah Waterland } 615c51f124SMoriah Waterland 625c51f124SMoriah Waterland if (ept->ainfo.local) { 635c51f124SMoriah Waterland if (fprintf(fp, "=%s", ept->ainfo.local) < 0) 645c51f124SMoriah Waterland return (-1); 655c51f124SMoriah Waterland } 665c51f124SMoriah Waterland 675c51f124SMoriah Waterland if (strchr("cb", ept->ftype)) { 685c51f124SMoriah Waterland if (ept->ainfo.major == BADMAJOR) { 695c51f124SMoriah Waterland if (fprintf(fp, " ?") < 0) 705c51f124SMoriah Waterland return (-1); 715c51f124SMoriah Waterland } else { 72*4656d474SGarrett D'Amore if (fprintf(fp, " %ld", ept->ainfo.major) < 0) 735c51f124SMoriah Waterland return (-1); 745c51f124SMoriah Waterland } 755c51f124SMoriah Waterland if (ept->ainfo.minor == BADMINOR) { 765c51f124SMoriah Waterland if (fprintf(fp, " ?") < 0) 775c51f124SMoriah Waterland return (-1); 785c51f124SMoriah Waterland } else { 79*4656d474SGarrett D'Amore if (fprintf(fp, " %ld", ept->ainfo.minor) < 0) 805c51f124SMoriah Waterland return (-1); 815c51f124SMoriah Waterland } 825c51f124SMoriah Waterland } 835c51f124SMoriah Waterland 845c51f124SMoriah Waterland if (strchr("dxcbpfve", ept->ftype)) { 855c51f124SMoriah Waterland if (fprintf(fp, ((ept->ainfo.mode == BADMODE) ? " ?" : " %04o"), 865c51f124SMoriah Waterland ept->ainfo.mode) < 0) 875c51f124SMoriah Waterland return (-1); 885c51f124SMoriah Waterland if (fprintf(fp, " %s %s", ept->ainfo.owner, ept->ainfo.group) < 895c51f124SMoriah Waterland 0) 905c51f124SMoriah Waterland return (-1); 915c51f124SMoriah Waterland } 925c51f124SMoriah Waterland if (holdcinfo) { 935c51f124SMoriah Waterland if (fputc('\n', fp) == EOF) 945c51f124SMoriah Waterland return (-1); 955c51f124SMoriah Waterland return (0); 965c51f124SMoriah Waterland } 975c51f124SMoriah Waterland 985c51f124SMoriah Waterland if (strchr("ifve", ept->ftype)) { 995c51f124SMoriah Waterland if (fprintf(fp, ((ept->cinfo.size == BADCONT) ? " ?" : " %llu"), 1005c51f124SMoriah Waterland ept->cinfo.size) < 0) 1015c51f124SMoriah Waterland return (-1); 1025c51f124SMoriah Waterland if (fprintf(fp, ((ept->cinfo.cksum == BADCONT) ? " ?" : " %ld"), 1035c51f124SMoriah Waterland ept->cinfo.cksum) < 0) 1045c51f124SMoriah Waterland return (-1); 1055c51f124SMoriah Waterland if (fprintf(fp, 1065c51f124SMoriah Waterland ((ept->cinfo.modtime == BADCONT) ? " ?" : " %ld"), 1075c51f124SMoriah Waterland ept->cinfo.modtime) < 0) 1085c51f124SMoriah Waterland return (-1); 1095c51f124SMoriah Waterland } 1105c51f124SMoriah Waterland 1115c51f124SMoriah Waterland if (ept->ftype == 'i') { 1125c51f124SMoriah Waterland if (fputc('\n', fp) == EOF) 1135c51f124SMoriah Waterland return (-1); 1145c51f124SMoriah Waterland return (0); 1155c51f124SMoriah Waterland } 1165c51f124SMoriah Waterland if (fprintf(fp, "\n") < 0) 1175c51f124SMoriah Waterland return (-1); 1185c51f124SMoriah Waterland return (0); 1195c51f124SMoriah Waterland } 120