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