Commit | Line | Data |
---|---|---|
d7a7b86b KB |
1 | /*- |
2 | * Copyright (c) 1990 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * Hugh Smith at The University of Guelph. | |
7 | * | |
8 | * %sccs.include.redist.c% | |
9 | */ | |
10 | ||
11 | #ifndef lint | |
44c5e2d6 | 12 | static char sccsid[] = "@(#)contents.c 5.2 (Berkeley) %G%"; |
d7a7b86b KB |
13 | #endif /* not lint */ |
14 | ||
15 | #include <sys/param.h> | |
16 | #include <sys/stat.h> | |
17 | #include <sys/time.h> | |
18 | #include <fcntl.h> | |
19 | #include <unistd.h> | |
20 | #include <tzfile.h> | |
21 | #include <dirent.h> | |
22 | #include <stdio.h> | |
23 | #include <ar.h> | |
24 | #include "archive.h" | |
25 | ||
26 | extern CHDR chdr; /* converted header */ | |
27 | extern char *archive; /* archive name */ | |
28 | ||
29 | /* | |
30 | * contents -- | |
31 | * Handles t[v] option - opens the archive and then reads headers, | |
44c5e2d6 | 32 | * skipping member contents. |
d7a7b86b KB |
33 | */ |
34 | contents(argv) | |
35 | register char **argv; | |
36 | { | |
37 | register int afd, all; | |
38 | int eval; | |
39 | struct tm *tp; | |
40 | char buf[25]; | |
41 | ||
42 | afd = open_archive(O_RDONLY); | |
43 | ||
44 | for (all = !*argv; get_header(afd);) { | |
45 | if (all || files(argv)) { | |
46 | if (options & AR_V) { | |
47 | (void)strmode(chdr.mode, buf); | |
48 | (void)printf("%s %6d/%-6d %8ld ", | |
49 | buf + 1, chdr.uid, chdr.gid, chdr.size); | |
50 | tp = localtime(&chdr.date); | |
51 | (void)strftime(buf, sizeof(buf), | |
52 | "%b %e %H:%M %Y", tp); | |
53 | (void)printf("%s %s\n", buf, chdr.name); | |
54 | } else | |
55 | (void)printf("%s\n", chdr.name); | |
56 | if (!all && !*argv) | |
57 | break; | |
58 | } | |
59 | SKIP(afd, chdr.size, archive); | |
60 | } | |
44c5e2d6 | 61 | eval = 0; |
d7a7b86b KB |
62 | ORPHANS; |
63 | close_archive(afd); | |
64 | return(eval); | |
65 | } |