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 <time.h> 385c51f124SMoriah Waterland #include <sys/types.h> 395c51f124SMoriah Waterland #include "pkgstrct.h" 405c51f124SMoriah Waterland #include "pkglocale.h" 415c51f124SMoriah Waterland 425c51f124SMoriah Waterland #define MSG_INVALID "invalid entry" 435c51f124SMoriah Waterland 445c51f124SMoriah Waterland void 455c51f124SMoriah Waterland tputcfent(struct cfent *ept, FILE *fp) 465c51f124SMoriah Waterland { 475c51f124SMoriah Waterland int count, status; 485c51f124SMoriah Waterland char *pt; 495c51f124SMoriah Waterland struct pinfo *pinfo; 505c51f124SMoriah Waterland struct tm *timep; 515c51f124SMoriah Waterland char timeb[BUFSIZ]; 525c51f124SMoriah Waterland 535c51f124SMoriah Waterland if (ept->path == NULL) 545c51f124SMoriah Waterland return; 555c51f124SMoriah Waterland 565c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Pathname: %s\n"), ept->path); 575c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Type: ")); 585c51f124SMoriah Waterland 595c51f124SMoriah Waterland switch (ept->ftype) { 605c51f124SMoriah Waterland case 'f': 615c51f124SMoriah Waterland (void) fputs(pkg_gt("regular file\n"), fp); 625c51f124SMoriah Waterland break; 635c51f124SMoriah Waterland 645c51f124SMoriah Waterland case 'd': 655c51f124SMoriah Waterland (void) fputs(pkg_gt("directory\n"), fp); 665c51f124SMoriah Waterland break; 675c51f124SMoriah Waterland 685c51f124SMoriah Waterland case 'x': 695c51f124SMoriah Waterland (void) fputs(pkg_gt("exclusive directory\n"), fp); 705c51f124SMoriah Waterland break; 715c51f124SMoriah Waterland 725c51f124SMoriah Waterland case 'v': 735c51f124SMoriah Waterland (void) fputs(pkg_gt("volatile file\n"), fp); 745c51f124SMoriah Waterland break; 755c51f124SMoriah Waterland 765c51f124SMoriah Waterland case 'e': 775c51f124SMoriah Waterland (void) fputs(pkg_gt("editted file\n"), fp); 785c51f124SMoriah Waterland break; 795c51f124SMoriah Waterland 805c51f124SMoriah Waterland case 'p': 815c51f124SMoriah Waterland (void) fputs(pkg_gt("named pipe\n"), fp); 825c51f124SMoriah Waterland break; 835c51f124SMoriah Waterland 845c51f124SMoriah Waterland case 'i': 855c51f124SMoriah Waterland (void) fputs(pkg_gt("installation file\n"), fp); 865c51f124SMoriah Waterland break; 875c51f124SMoriah Waterland 885c51f124SMoriah Waterland case 'c': 895c51f124SMoriah Waterland case 'b': 905c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("%s special device\n"), 915c51f124SMoriah Waterland (ept->ftype == 'b') ? pkg_gt("block") : 925c51f124SMoriah Waterland pkg_gt("character")); 935c51f124SMoriah Waterland 945c51f124SMoriah Waterland if (ept->ainfo.major == BADMAJOR) 955c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Major device number: %s\n"), 965c51f124SMoriah Waterland MSG_INVALID); 975c51f124SMoriah Waterland else 98*4656d474SGarrett D'Amore (void) fprintf(fp, pkg_gt("Major device number: %ld\n"), 995c51f124SMoriah Waterland ept->ainfo.major); 1005c51f124SMoriah Waterland 1015c51f124SMoriah Waterland if (ept->ainfo.minor == BADMINOR) 1025c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Minor device number: %s\n"), 1035c51f124SMoriah Waterland MSG_INVALID); 1045c51f124SMoriah Waterland else 105*4656d474SGarrett D'Amore (void) fprintf(fp, pkg_gt("Minor device number: %ld\n"), 1065c51f124SMoriah Waterland ept->ainfo.minor); 1075c51f124SMoriah Waterland 1085c51f124SMoriah Waterland break; 1095c51f124SMoriah Waterland 1105c51f124SMoriah Waterland case 'l': 1115c51f124SMoriah Waterland (void) fputs(pkg_gt("linked file\n"), fp); 1125c51f124SMoriah Waterland pt = (ept->ainfo.local ? ept->ainfo.local : 1135c51f124SMoriah Waterland (char *)pkg_gt("(unknown)")); 1145c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Source of link: %s\n"), pt); 1155c51f124SMoriah Waterland break; 1165c51f124SMoriah Waterland 1175c51f124SMoriah Waterland case 's': 1185c51f124SMoriah Waterland (void) fputs(pkg_gt("symbolic link\n"), fp); 1195c51f124SMoriah Waterland pt = (ept->ainfo.local ? ept->ainfo.local : 1205c51f124SMoriah Waterland (char *)pkg_gt("(unknown)")); 1215c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Source of link: %s\n"), pt); 1225c51f124SMoriah Waterland break; 1235c51f124SMoriah Waterland 1245c51f124SMoriah Waterland default: 1255c51f124SMoriah Waterland (void) fputs(pkg_gt("unknown\n"), fp); 1265c51f124SMoriah Waterland break; 1275c51f124SMoriah Waterland } 1285c51f124SMoriah Waterland 1295c51f124SMoriah Waterland if (!strchr("lsin", ept->ftype)) { 1305c51f124SMoriah Waterland if (ept->ainfo.mode == BADMODE) 1315c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected mode: %s\n"), 1325c51f124SMoriah Waterland "?"); 1335c51f124SMoriah Waterland else 134*4656d474SGarrett D'Amore (void) fprintf(fp, pkg_gt("Expected mode: %04lo\n"), 1355c51f124SMoriah Waterland ept->ainfo.mode); 1365c51f124SMoriah Waterland 1375c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected owner: %s\n"), 1385c51f124SMoriah Waterland ept->ainfo.owner); 1395c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Expected group: %s\n"), 1405c51f124SMoriah Waterland ept->ainfo.group); 1415c51f124SMoriah Waterland } 1425c51f124SMoriah Waterland if (strchr("?infv", ept->ftype)) { 1435c51f124SMoriah Waterland (void) fprintf(fp, 1445c51f124SMoriah Waterland pkg_gt("Expected file size (bytes): %llu\n"), 1455c51f124SMoriah Waterland ept->cinfo.size); 1465c51f124SMoriah Waterland (void) fprintf(fp, 1475c51f124SMoriah Waterland pkg_gt("Expected sum(1) of contents: %ld\n"), 1485c51f124SMoriah Waterland ept->cinfo.cksum); 1495c51f124SMoriah Waterland if (ept->cinfo.modtime > 0) { 1505c51f124SMoriah Waterland timep = localtime(&(ept->cinfo.modtime)); 151*4656d474SGarrett D'Amore (void) strftime(timeb, sizeof (timeb), 1525c51f124SMoriah Waterland pkg_gt("Expected last modification: %b %d %X %Y\n"), 1535c51f124SMoriah Waterland timep); 154*4656d474SGarrett D'Amore (void) fputs(timeb, fp); 1555c51f124SMoriah Waterland } else 1565c51f124SMoriah Waterland (void) fprintf(fp, 1575c51f124SMoriah Waterland pkg_gt("Expected last modification: ?\n")); 1585c51f124SMoriah Waterland } 1595c51f124SMoriah Waterland if (ept->ftype == 'i') { 1605c51f124SMoriah Waterland (void) fputc('\n', fp); 1615c51f124SMoriah Waterland return; 1625c51f124SMoriah Waterland } 1635c51f124SMoriah Waterland 1645c51f124SMoriah Waterland status = count = 0; 1655c51f124SMoriah Waterland if ((pinfo = ept->pinfo) != NULL) { 1665c51f124SMoriah Waterland (void) fprintf(fp, 1675c51f124SMoriah Waterland pkg_gt("Referenced by the following packages:\n\t")); 1685c51f124SMoriah Waterland while (pinfo) { 1695c51f124SMoriah Waterland /* 1705c51f124SMoriah Waterland * Check for partially installed object. Need 1715c51f124SMoriah Waterland * to explicitly check for '!', because objects 1725c51f124SMoriah Waterland * that are provided by a server will have a 1735c51f124SMoriah Waterland * different status character. 1745c51f124SMoriah Waterland */ 1755c51f124SMoriah Waterland if (pinfo->status == '!') 1765c51f124SMoriah Waterland status++; 1775c51f124SMoriah Waterland (void) fprintf(fp, "%-15s", pinfo->pkg); 1785c51f124SMoriah Waterland if ((++count % 5) == 0) { 1795c51f124SMoriah Waterland (void) fputc('\n', fp); 1805c51f124SMoriah Waterland (void) fputc('\t', fp); 1815c51f124SMoriah Waterland count = 0; 1825c51f124SMoriah Waterland } 1835c51f124SMoriah Waterland pinfo = pinfo->next; 1845c51f124SMoriah Waterland } 1855c51f124SMoriah Waterland (void) fputc('\n', fp); 1865c51f124SMoriah Waterland } 1875c51f124SMoriah Waterland (void) fprintf(fp, pkg_gt("Current status: %s\n"), 1885c51f124SMoriah Waterland status ? pkg_gt("partially installed") : 1895c51f124SMoriah Waterland pkg_gt("installed")); 1905c51f124SMoriah Waterland (void) fputc('\n', fp); 1915c51f124SMoriah Waterland } 192