1*9781SMoriah.Waterland@Sun.COM /* 2*9781SMoriah.Waterland@Sun.COM * CDDL HEADER START 3*9781SMoriah.Waterland@Sun.COM * 4*9781SMoriah.Waterland@Sun.COM * The contents of this file are subject to the terms of the 5*9781SMoriah.Waterland@Sun.COM * Common Development and Distribution License (the "License"). 6*9781SMoriah.Waterland@Sun.COM * You may not use this file except in compliance with the License. 7*9781SMoriah.Waterland@Sun.COM * 8*9781SMoriah.Waterland@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9781SMoriah.Waterland@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*9781SMoriah.Waterland@Sun.COM * See the License for the specific language governing permissions 11*9781SMoriah.Waterland@Sun.COM * and limitations under the License. 12*9781SMoriah.Waterland@Sun.COM * 13*9781SMoriah.Waterland@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*9781SMoriah.Waterland@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9781SMoriah.Waterland@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*9781SMoriah.Waterland@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*9781SMoriah.Waterland@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*9781SMoriah.Waterland@Sun.COM * 19*9781SMoriah.Waterland@Sun.COM * CDDL HEADER END 20*9781SMoriah.Waterland@Sun.COM */ 21*9781SMoriah.Waterland@Sun.COM 22*9781SMoriah.Waterland@Sun.COM /* 23*9781SMoriah.Waterland@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*9781SMoriah.Waterland@Sun.COM * Use is subject to license terms. 25*9781SMoriah.Waterland@Sun.COM */ 26*9781SMoriah.Waterland@Sun.COM 27*9781SMoriah.Waterland@Sun.COM /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*9781SMoriah.Waterland@Sun.COM /* All Rights Reserved */ 29*9781SMoriah.Waterland@Sun.COM 30*9781SMoriah.Waterland@Sun.COM 31*9781SMoriah.Waterland@Sun.COM 32*9781SMoriah.Waterland@Sun.COM #include <stdio.h> 33*9781SMoriah.Waterland@Sun.COM #include <string.h> 34*9781SMoriah.Waterland@Sun.COM #include <limits.h> 35*9781SMoriah.Waterland@Sun.COM #include <stdlib.h> 36*9781SMoriah.Waterland@Sun.COM #include <unistd.h> 37*9781SMoriah.Waterland@Sun.COM #include <sys/types.h> 38*9781SMoriah.Waterland@Sun.COM #include "pkgstrct.h" 39*9781SMoriah.Waterland@Sun.COM 40*9781SMoriah.Waterland@Sun.COM int holdcinfo = 0; 41*9781SMoriah.Waterland@Sun.COM 42*9781SMoriah.Waterland@Sun.COM int 43*9781SMoriah.Waterland@Sun.COM ppkgmap(struct cfent *ept, FILE *fp) 44*9781SMoriah.Waterland@Sun.COM { 45*9781SMoriah.Waterland@Sun.COM if (ept->path == NULL) 46*9781SMoriah.Waterland@Sun.COM return (-1); 47*9781SMoriah.Waterland@Sun.COM 48*9781SMoriah.Waterland@Sun.COM if (ept->volno) { 49*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, "%d ", ept->volno) < 0) 50*9781SMoriah.Waterland@Sun.COM return (-1); 51*9781SMoriah.Waterland@Sun.COM } 52*9781SMoriah.Waterland@Sun.COM 53*9781SMoriah.Waterland@Sun.COM if (ept->ftype == 'i') { 54*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, "%c %s", ept->ftype, ept->path) < 0) 55*9781SMoriah.Waterland@Sun.COM return (-1); 56*9781SMoriah.Waterland@Sun.COM } else { 57*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, "%c %s %s", ept->ftype, ept->pkg_class, 58*9781SMoriah.Waterland@Sun.COM ept->path) < 0) 59*9781SMoriah.Waterland@Sun.COM return (-1); 60*9781SMoriah.Waterland@Sun.COM } 61*9781SMoriah.Waterland@Sun.COM 62*9781SMoriah.Waterland@Sun.COM if (ept->ainfo.local) { 63*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, "=%s", ept->ainfo.local) < 0) 64*9781SMoriah.Waterland@Sun.COM return (-1); 65*9781SMoriah.Waterland@Sun.COM } 66*9781SMoriah.Waterland@Sun.COM 67*9781SMoriah.Waterland@Sun.COM if (strchr("cb", ept->ftype)) { 68*9781SMoriah.Waterland@Sun.COM #ifdef SUNOS41 69*9781SMoriah.Waterland@Sun.COM if (ept->ainfo.xmajor == BADMAJOR) { 70*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " ?") < 0) 71*9781SMoriah.Waterland@Sun.COM return (-1); 72*9781SMoriah.Waterland@Sun.COM } else { 73*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " %d", ept->ainfo.xmajor) < 0) 74*9781SMoriah.Waterland@Sun.COM return (-1); 75*9781SMoriah.Waterland@Sun.COM } 76*9781SMoriah.Waterland@Sun.COM #else 77*9781SMoriah.Waterland@Sun.COM if (ept->ainfo.major == BADMAJOR) { 78*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " ?") < 0) 79*9781SMoriah.Waterland@Sun.COM return (-1); 80*9781SMoriah.Waterland@Sun.COM } else { 81*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " %d", ept->ainfo.major) < 0) 82*9781SMoriah.Waterland@Sun.COM return (-1); 83*9781SMoriah.Waterland@Sun.COM } 84*9781SMoriah.Waterland@Sun.COM #endif 85*9781SMoriah.Waterland@Sun.COM #ifdef SUNOS41 86*9781SMoriah.Waterland@Sun.COM if (ept->ainfo.xminor == BADMINOR) { 87*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " ?") < 0) 88*9781SMoriah.Waterland@Sun.COM return (-1); 89*9781SMoriah.Waterland@Sun.COM } else { 90*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " %d", ept->ainfo.xminor) < 0) 91*9781SMoriah.Waterland@Sun.COM return (-1); 92*9781SMoriah.Waterland@Sun.COM } 93*9781SMoriah.Waterland@Sun.COM #else 94*9781SMoriah.Waterland@Sun.COM if (ept->ainfo.minor == BADMINOR) { 95*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " ?") < 0) 96*9781SMoriah.Waterland@Sun.COM return (-1); 97*9781SMoriah.Waterland@Sun.COM } else { 98*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " %d", ept->ainfo.minor) < 0) 99*9781SMoriah.Waterland@Sun.COM return (-1); 100*9781SMoriah.Waterland@Sun.COM } 101*9781SMoriah.Waterland@Sun.COM #endif 102*9781SMoriah.Waterland@Sun.COM } 103*9781SMoriah.Waterland@Sun.COM 104*9781SMoriah.Waterland@Sun.COM if (strchr("dxcbpfve", ept->ftype)) { 105*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, ((ept->ainfo.mode == BADMODE) ? " ?" : " %04o"), 106*9781SMoriah.Waterland@Sun.COM ept->ainfo.mode) < 0) 107*9781SMoriah.Waterland@Sun.COM return (-1); 108*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, " %s %s", ept->ainfo.owner, ept->ainfo.group) < 109*9781SMoriah.Waterland@Sun.COM 0) 110*9781SMoriah.Waterland@Sun.COM return (-1); 111*9781SMoriah.Waterland@Sun.COM } 112*9781SMoriah.Waterland@Sun.COM if (holdcinfo) { 113*9781SMoriah.Waterland@Sun.COM if (fputc('\n', fp) == EOF) 114*9781SMoriah.Waterland@Sun.COM return (-1); 115*9781SMoriah.Waterland@Sun.COM return (0); 116*9781SMoriah.Waterland@Sun.COM } 117*9781SMoriah.Waterland@Sun.COM 118*9781SMoriah.Waterland@Sun.COM if (strchr("ifve", ept->ftype)) { 119*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, ((ept->cinfo.size == BADCONT) ? " ?" : " %llu"), 120*9781SMoriah.Waterland@Sun.COM ept->cinfo.size) < 0) 121*9781SMoriah.Waterland@Sun.COM return (-1); 122*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, ((ept->cinfo.cksum == BADCONT) ? " ?" : " %ld"), 123*9781SMoriah.Waterland@Sun.COM ept->cinfo.cksum) < 0) 124*9781SMoriah.Waterland@Sun.COM return (-1); 125*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, 126*9781SMoriah.Waterland@Sun.COM ((ept->cinfo.modtime == BADCONT) ? " ?" : " %ld"), 127*9781SMoriah.Waterland@Sun.COM ept->cinfo.modtime) < 0) 128*9781SMoriah.Waterland@Sun.COM return (-1); 129*9781SMoriah.Waterland@Sun.COM } 130*9781SMoriah.Waterland@Sun.COM 131*9781SMoriah.Waterland@Sun.COM if (ept->ftype == 'i') { 132*9781SMoriah.Waterland@Sun.COM if (fputc('\n', fp) == EOF) 133*9781SMoriah.Waterland@Sun.COM return (-1); 134*9781SMoriah.Waterland@Sun.COM return (0); 135*9781SMoriah.Waterland@Sun.COM } 136*9781SMoriah.Waterland@Sun.COM if (fprintf(fp, "\n") < 0) 137*9781SMoriah.Waterland@Sun.COM return (-1); 138*9781SMoriah.Waterland@Sun.COM return (0); 139*9781SMoriah.Waterland@Sun.COM } 140