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