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 <time.h> 38*5c51f124SMoriah Waterland #include <sys/types.h> 39*5c51f124SMoriah Waterland #include "pkgstrct.h" 40*5c51f124SMoriah Waterland #include "pkglocale.h" 41*5c51f124SMoriah Waterland 42*5c51f124SMoriah Waterland #define MSG_INVALID "invalid entry" 43*5c51f124SMoriah Waterland 44*5c51f124SMoriah Waterland void 45*5c51f124SMoriah Waterland tputcfent(struct cfent *ept, FILE *fp) 46*5c51f124SMoriah Waterland { 47*5c51f124SMoriah Waterland int count, status; 48*5c51f124SMoriah Waterland char *pt; 49*5c51f124SMoriah Waterland struct pinfo *pinfo; 50*5c51f124SMoriah Waterland struct tm *timep; 51*5c51f124SMoriah Waterland char timeb[BUFSIZ]; 52*5c51f124SMoriah Waterland 53*5c51f124SMoriah Waterland if (ept->path == NULL) 54*5c51f124SMoriah Waterland return; 55*5c51f124SMoriah Waterland 56*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Pathname: %s\n"), ept->path); 57*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Type: ")); 58*5c51f124SMoriah Waterland 59*5c51f124SMoriah Waterland switch (ept->ftype) { 60*5c51f124SMoriah Waterland case 'f': 61*5c51f124SMoriah Waterland (void) fputs(pkg_gt("regular file\n"), fp); 62*5c51f124SMoriah Waterland break; 63*5c51f124SMoriah Waterland 64*5c51f124SMoriah Waterland case 'd': 65*5c51f124SMoriah Waterland (void) fputs(pkg_gt("directory\n"), fp); 66*5c51f124SMoriah Waterland break; 67*5c51f124SMoriah Waterland 68*5c51f124SMoriah Waterland case 'x': 69*5c51f124SMoriah Waterland (void) fputs(pkg_gt("exclusive directory\n"), fp); 70*5c51f124SMoriah Waterland break; 71*5c51f124SMoriah Waterland 72*5c51f124SMoriah Waterland case 'v': 73*5c51f124SMoriah Waterland (void) fputs(pkg_gt("volatile file\n"), fp); 74*5c51f124SMoriah Waterland break; 75*5c51f124SMoriah Waterland 76*5c51f124SMoriah Waterland case 'e': 77*5c51f124SMoriah Waterland (void) fputs(pkg_gt("editted file\n"), fp); 78*5c51f124SMoriah Waterland break; 79*5c51f124SMoriah Waterland 80*5c51f124SMoriah Waterland case 'p': 81*5c51f124SMoriah Waterland (void) fputs(pkg_gt("named pipe\n"), fp); 82*5c51f124SMoriah Waterland break; 83*5c51f124SMoriah Waterland 84*5c51f124SMoriah Waterland case 'i': 85*5c51f124SMoriah Waterland (void) fputs(pkg_gt("installation file\n"), fp); 86*5c51f124SMoriah Waterland break; 87*5c51f124SMoriah Waterland 88*5c51f124SMoriah Waterland case 'c': 89*5c51f124SMoriah Waterland case 'b': 90*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("%s special device\n"), 91*5c51f124SMoriah Waterland (ept->ftype == 'b') ? pkg_gt("block") : 92*5c51f124SMoriah Waterland pkg_gt("character")); 93*5c51f124SMoriah Waterland 94*5c51f124SMoriah Waterland if (ept->ainfo.major == BADMAJOR) 95*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Major device number: %s\n"), 96*5c51f124SMoriah Waterland MSG_INVALID); 97*5c51f124SMoriah Waterland else 98*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Major device number: %d\n"), 99*5c51f124SMoriah Waterland ept->ainfo.major); 100*5c51f124SMoriah Waterland 101*5c51f124SMoriah Waterland if (ept->ainfo.minor == BADMINOR) 102*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Minor device number: %s\n"), 103*5c51f124SMoriah Waterland MSG_INVALID); 104*5c51f124SMoriah Waterland else 105*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Minor device number: %d\n"), 106*5c51f124SMoriah Waterland ept->ainfo.minor); 107*5c51f124SMoriah Waterland 108*5c51f124SMoriah Waterland break; 109*5c51f124SMoriah Waterland 110*5c51f124SMoriah Waterland case 'l': 111*5c51f124SMoriah Waterland (void) fputs(pkg_gt("linked file\n"), fp); 112*5c51f124SMoriah Waterland pt = (ept->ainfo.local ? ept->ainfo.local : 113*5c51f124SMoriah Waterland (char *)pkg_gt("(unknown)")); 114*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Source of link: %s\n"), pt); 115*5c51f124SMoriah Waterland break; 116*5c51f124SMoriah Waterland 117*5c51f124SMoriah Waterland case 's': 118*5c51f124SMoriah Waterland (void) fputs(pkg_gt("symbolic link\n"), fp); 119*5c51f124SMoriah Waterland pt = (ept->ainfo.local ? ept->ainfo.local : 120*5c51f124SMoriah Waterland (char *)pkg_gt("(unknown)")); 121*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Source of link: %s\n"), pt); 122*5c51f124SMoriah Waterland break; 123*5c51f124SMoriah Waterland 124*5c51f124SMoriah Waterland default: 125*5c51f124SMoriah Waterland (void) fputs(pkg_gt("unknown\n"), fp); 126*5c51f124SMoriah Waterland break; 127*5c51f124SMoriah Waterland } 128*5c51f124SMoriah Waterland 129*5c51f124SMoriah Waterland if (!strchr("lsin", ept->ftype)) { 130*5c51f124SMoriah Waterland if (ept->ainfo.mode == BADMODE) 131*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected mode: %s\n"), 132*5c51f124SMoriah Waterland "?"); 133*5c51f124SMoriah Waterland else 134*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected mode: %04o\n"), 135*5c51f124SMoriah Waterland ept->ainfo.mode); 136*5c51f124SMoriah Waterland 137*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected owner: %s\n"), 138*5c51f124SMoriah Waterland ept->ainfo.owner); 139*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected group: %s\n"), 140*5c51f124SMoriah Waterland ept->ainfo.group); 141*5c51f124SMoriah Waterland } 142*5c51f124SMoriah Waterland if (strchr("?infv", ept->ftype)) { 143*5c51f124SMoriah Waterland (void) fprintf(fp, 144*5c51f124SMoriah Waterland pkg_gt("Expected file size (bytes): %llu\n"), 145*5c51f124SMoriah Waterland ept->cinfo.size); 146*5c51f124SMoriah Waterland (void) fprintf(fp, 147*5c51f124SMoriah Waterland pkg_gt("Expected sum(1) of contents: %ld\n"), 148*5c51f124SMoriah Waterland ept->cinfo.cksum); 149*5c51f124SMoriah Waterland if (ept->cinfo.modtime > 0) { 150*5c51f124SMoriah Waterland timep = localtime(&(ept->cinfo.modtime)); 151*5c51f124SMoriah Waterland strftime(timeb, sizeof (timeb), 152*5c51f124SMoriah Waterland pkg_gt("Expected last modification: %b %d %X %Y\n"), 153*5c51f124SMoriah Waterland timep); 154*5c51f124SMoriah Waterland (void) fprintf(fp, timeb); 155*5c51f124SMoriah Waterland } else 156*5c51f124SMoriah Waterland (void) fprintf(fp, 157*5c51f124SMoriah Waterland pkg_gt("Expected last modification: ?\n")); 158*5c51f124SMoriah Waterland } 159*5c51f124SMoriah Waterland if (ept->ftype == 'i') { 160*5c51f124SMoriah Waterland (void) fputc('\n', fp); 161*5c51f124SMoriah Waterland return; 162*5c51f124SMoriah Waterland } 163*5c51f124SMoriah Waterland 164*5c51f124SMoriah Waterland status = count = 0; 165*5c51f124SMoriah Waterland if ((pinfo = ept->pinfo) != NULL) { 166*5c51f124SMoriah Waterland (void) fprintf(fp, 167*5c51f124SMoriah Waterland pkg_gt("Referenced by the following packages:\n\t")); 168*5c51f124SMoriah Waterland while (pinfo) { 169*5c51f124SMoriah Waterland /* 170*5c51f124SMoriah Waterland * Check for partially installed object. Need 171*5c51f124SMoriah Waterland * to explicitly check for '!', because objects 172*5c51f124SMoriah Waterland * that are provided by a server will have a 173*5c51f124SMoriah Waterland * different status character. 174*5c51f124SMoriah Waterland */ 175*5c51f124SMoriah Waterland if (pinfo->status == '!') 176*5c51f124SMoriah Waterland status++; 177*5c51f124SMoriah Waterland (void) fprintf(fp, "%-15s", pinfo->pkg); 178*5c51f124SMoriah Waterland if ((++count % 5) == 0) { 179*5c51f124SMoriah Waterland (void) fputc('\n', fp); 180*5c51f124SMoriah Waterland (void) fputc('\t', fp); 181*5c51f124SMoriah Waterland count = 0; 182*5c51f124SMoriah Waterland } 183*5c51f124SMoriah Waterland pinfo = pinfo->next; 184*5c51f124SMoriah Waterland } 185*5c51f124SMoriah Waterland (void) fputc('\n', fp); 186*5c51f124SMoriah Waterland } 187*5c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Current status: %s\n"), 188*5c51f124SMoriah Waterland status ? pkg_gt("partially installed") : 189*5c51f124SMoriah Waterland pkg_gt("installed")); 190*5c51f124SMoriah Waterland (void) fputc('\n', fp); 191*5c51f124SMoriah Waterland } 192