show.c revision 328
1#ifndef lint
2static const char *rcsid = "$Id: show.c,v 1.3 1993/08/26 08:47:07 jkh Exp $";
3#endif
4
5/*
6 * FreeBSD install - a package for the installation and maintainance
7 * of non-core utilities.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * Jordan K. Hubbard
19 * 23 Aug 1993
20 *
21 * Various display routines for the info module.
22 *
23 */
24
25#include "lib.h"
26#include "info.h"
27
28void
29show_file(char *title, char *fname)
30{
31    FILE *fp;
32    char line[1024];
33    int n;
34
35    printf(title);
36    fp = fopen(fname, "r");
37    if (!fp) {
38	whinge("show_file: Can't open '%s' for reading.", fname);
39	return;
40    }
41    while (n = fread(line, 1, 1024, fp))
42	fwrite(line, 1, n, stdout);
43    fclose(fp);
44    printf("\n");	/* just in case */
45}
46
47/* Show a packing list item type.  If type is -1, show all */
48void
49show_plist(char *title, Package *plist, plist_t type)
50{
51    PackingList p;
52    Boolean ign = FALSE;
53
54    printf(title);
55    p = plist->head;
56    while (p) {
57	if (p->type != type && type != -1) {
58	    p = p->next;
59	    continue;
60	}
61	switch(p->type) {
62	case PLIST_FILE:
63	    if (ign) {
64		printf("File: %s (ignored)\n", p->name);
65		ign = FALSE;
66	    }
67	    else
68		printf("File: %s\n", p->name);
69	    break;
70
71	case PLIST_CWD:
72	    printf("\tCWD to %s\n", p->name);
73	    break;
74
75	case PLIST_CMD:
76	    printf("\tEXEC '%s'\n", p->name);
77	    break;
78
79	case PLIST_CHMOD:
80	    printf("\tCHMOD to %s\n", p->name ? p->name : "(no default)");
81	    break;
82
83	case PLIST_CHOWN:
84	    printf("\tCHOWN to %s\n", p->name ? p->name : "(no default)");
85	    break;
86
87	case PLIST_CHGRP:
88	    printf("\tCHGRP to %s\n", p->name ? p->name : "(no default)");
89	    break;
90
91	case PLIST_COMMENT:
92	    printf("\tComment: %s\n", p->name);
93	    break;
94
95	case PLIST_IGNORE:
96	    ign = TRUE;
97	    break;
98
99	case PLIST_NAME:
100	    printf("\tPackage name: %s\n", p->name);
101	    break;
102
103	default:
104	    barf("Unknown command type %d (%s)\n", p->type, p->name);
105	    break;
106	}
107	p = p->next;
108    }
109}
110
111