Deleted Added
full compact
show.c (228990) show.c (240682)
1/*
2 * FreeBSD install - a package for the installation and maintenance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 5 unchanged lines hidden (view full) ---

14 * Jordan K. Hubbard
15 * 23 Aug 1993
16 *
17 * Various display routines for the info module.
18 *
19 */
20
21#include <sys/cdefs.h>
1/*
2 * FreeBSD install - a package for the installation and maintenance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 5 unchanged lines hidden (view full) ---

14 * Jordan K. Hubbard
15 * 23 Aug 1993
16 *
17 * Various display routines for the info module.
18 *
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/info/show.c 228990 2011-12-30 10:58:14Z uqs $");
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/info/show.c 240682 2012-09-18 22:09:23Z bapt $");
23
24#include "lib.h"
25#include "info.h"
26#include <err.h>
27#include <stdlib.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <md5.h>

--- 25 unchanged lines hidden (view full) ---

56void
57show_index(const char *title, const char *fname)
58{
59 FILE *fp;
60 char line[MAXINDEXSIZE+2];
61
62 strlcpy(line, "???\n", sizeof(line));
63
23
24#include "lib.h"
25#include "info.h"
26#include <err.h>
27#include <stdlib.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <md5.h>

--- 25 unchanged lines hidden (view full) ---

56void
57show_index(const char *title, const char *fname)
58{
59 FILE *fp;
60 char line[MAXINDEXSIZE+2];
61
62 strlcpy(line, "???\n", sizeof(line));
63
64 if (!Quiet)
64 if (!Quiet) {
65 printf("%s%s", InfoPrefix, title);
65 printf("%s%s", InfoPrefix, title);
66 fflush(stdout);
67 }
66 fp = fopen(fname, "r");
67 if (fp == (FILE *) NULL) {
68 warnx("show_file: can't open '%s' for reading", fname);
69 } else {
70 if(fgets(line, MAXINDEXSIZE + 1, fp)) {
71 size_t line_length = strlen(line);
72
73 if (line[line_length - 1] != '\n') { /* Do we have a trailing \n ? */

--- 9 unchanged lines hidden (view full) ---

83/* Show a packing list item type. If showall is TRUE, show all */
84void
85show_plist(const char *title, Package *plist, plist_t type, Boolean showall)
86{
87 PackingList p;
88 Boolean ign = FALSE;
89 char *prefix = NULL;
90
68 fp = fopen(fname, "r");
69 if (fp == (FILE *) NULL) {
70 warnx("show_file: can't open '%s' for reading", fname);
71 } else {
72 if(fgets(line, MAXINDEXSIZE + 1, fp)) {
73 size_t line_length = strlen(line);
74
75 if (line[line_length - 1] != '\n') { /* Do we have a trailing \n ? */

--- 9 unchanged lines hidden (view full) ---

85/* Show a packing list item type. If showall is TRUE, show all */
86void
87show_plist(const char *title, Package *plist, plist_t type, Boolean showall)
88{
89 PackingList p;
90 Boolean ign = FALSE;
91 char *prefix = NULL;
92
91 if (!Quiet)
93 if (!Quiet) {
92 printf("%s%s", InfoPrefix, title);
94 printf("%s%s", InfoPrefix, title);
95 fflush(stdout);
96 }
93 p = plist->head;
94 while (p) {
95 if (p->type != type && showall != TRUE) {
96 p = p->next;
97 continue;
98 }
99 switch(p->type) {
100 case PLIST_FILE:

--- 166 unchanged lines hidden (view full) ---

267 char tmp[FILENAME_MAX];
268 unsigned long size = 0;
269 long blksize;
270 int headerlen;
271 char *descr;
272 char *prefix = NULL;
273
274 descr = getbsize(&headerlen, &blksize);
97 p = plist->head;
98 while (p) {
99 if (p->type != type && showall != TRUE) {
100 p = p->next;
101 continue;
102 }
103 switch(p->type) {
104 case PLIST_FILE:

--- 166 unchanged lines hidden (view full) ---

271 char tmp[FILENAME_MAX];
272 unsigned long size = 0;
273 long blksize;
274 int headerlen;
275 char *descr;
276 char *prefix = NULL;
277
278 descr = getbsize(&headerlen, &blksize);
275 if (!Quiet)
279 if (!Quiet) {
276 printf("%s%s", InfoPrefix, title);
280 printf("%s%s", InfoPrefix, title);
281 fflush(stdout);
282 }
277 for (p = plist->head; p != NULL; p = p->next) {
278 switch (p->type) {
279 case PLIST_FILE:
280 if (!ign) {
281 snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
282 if (!lstat(tmp, &sb)) {
283 size += sb.st_size;
284 if (Verbose)

--- 26 unchanged lines hidden (view full) ---

311 else
312 if (UseBlkSz)
313 printf("%lu\n", howmany(size, blksize));
314 else
315 printf("%lu\n", size);
316}
317
318/* Show files that don't match the recorded checksum */
283 for (p = plist->head; p != NULL; p = p->next) {
284 switch (p->type) {
285 case PLIST_FILE:
286 if (!ign) {
287 snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
288 if (!lstat(tmp, &sb)) {
289 size += sb.st_size;
290 if (Verbose)

--- 26 unchanged lines hidden (view full) ---

317 else
318 if (UseBlkSz)
319 printf("%lu\n", howmany(size, blksize));
320 else
321 printf("%lu\n", size);
322}
323
324/* Show files that don't match the recorded checksum */
319void
325int
320show_cksum(const char *title, Package *plist)
321{
322 PackingList p;
323 const char *dir = ".";
324 char *prefix = NULL;
325 char tmp[FILENAME_MAX];
326show_cksum(const char *title, Package *plist)
327{
328 PackingList p;
329 const char *dir = ".";
330 char *prefix = NULL;
331 char tmp[FILENAME_MAX];
332 int errcode = 0;
326
333
327 if (!Quiet)
334 if (!Quiet) {
328 printf("%s%s", InfoPrefix, title);
335 printf("%s%s", InfoPrefix, title);
336 fflush(stdout);
337 }
329
330 for (p = plist->head; p != NULL; p = p->next)
331 if (p->type == PLIST_CWD) {
332 if (!prefix)
333 prefix = p->name;
334 if (p->name == NULL)
335 dir = prefix;
336 else
337 dir = p->name;
338 } else if (p->type == PLIST_FILE) {
339 snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
338
339 for (p = plist->head; p != NULL; p = p->next)
340 if (p->type == PLIST_CWD) {
341 if (!prefix)
342 prefix = p->name;
343 if (p->name == NULL)
344 dir = prefix;
345 else
346 dir = p->name;
347 } else if (p->type == PLIST_FILE) {
348 snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
340 if (!fexists(tmp))
349 if (!fexists(tmp)) {
341 warnx("%s doesn't exist", tmp);
350 warnx("%s doesn't exist", tmp);
342 else if (p->next && p->next->type == PLIST_COMMENT &&
351 errcode = 1;
352 } else if (p->next && p->next->type == PLIST_COMMENT &&
343 (strncmp(p->next->name, "MD5:", 4) == 0)) {
344 char *cp = NULL, buf[33];
345
346 /*
347 * For packing lists whose version is 1.1 or greater, the md5
348 * hash for a symlink is calculated on the string returned
349 * by readlink().
350 */

--- 10 unchanged lines hidden (view full) ---

361 /* Mismatch? */
362 if (strcmp(cp, p->next->name + 4))
363 printf("%s fails the original MD5 checksum\n", tmp);
364 else if (Verbose)
365 printf("%s matched the original MD5 checksum\n", tmp);
366 }
367 }
368 }
353 (strncmp(p->next->name, "MD5:", 4) == 0)) {
354 char *cp = NULL, buf[33];
355
356 /*
357 * For packing lists whose version is 1.1 or greater, the md5
358 * hash for a symlink is calculated on the string returned
359 * by readlink().
360 */

--- 10 unchanged lines hidden (view full) ---

371 /* Mismatch? */
372 if (strcmp(cp, p->next->name + 4))
373 printf("%s fails the original MD5 checksum\n", tmp);
374 else if (Verbose)
375 printf("%s matched the original MD5 checksum\n", tmp);
376 }
377 }
378 }
379 return (errcode);
369}
370
371/* Show an "origin" path (usually category/portname) */
372void
373show_origin(const char *title, Package *plist)
374{
375
380}
381
382/* Show an "origin" path (usually category/portname) */
383void
384show_origin(const char *title, Package *plist)
385{
386
376 if (!Quiet)
387 if (!Quiet) {
377 printf("%s%s", InfoPrefix, title);
388 printf("%s%s", InfoPrefix, title);
389 fflush(stdout);
390 }
378 printf("%s\n", plist->origin != NULL ? plist->origin : "");
379}
380
381/* Show revision number of the packing list */
382void
383show_fmtrev(const char *title, Package *plist)
384{
385
391 printf("%s\n", plist->origin != NULL ? plist->origin : "");
392}
393
394/* Show revision number of the packing list */
395void
396show_fmtrev(const char *title, Package *plist)
397{
398
386 if (!Quiet)
399 if (!Quiet) {
387 printf("%s%s", InfoPrefix, title);
400 printf("%s%s", InfoPrefix, title);
401 fflush(stdout);
402 }
388 printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr);
389}
403 printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr);
404}