Commit | Line | Data |
---|---|---|
5681c8bf 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[] = "@(#)print.c 5.2 (Berkeley) %G%"; |
5681c8bf KB |
13 | #endif /* not lint */ |
14 | ||
15 | #include <sys/param.h> | |
16 | #include <fcntl.h> | |
17 | #include <unistd.h> | |
18 | #include <dirent.h> | |
19 | #include <stdio.h> | |
20 | #include "archive.h" | |
21 | ||
22 | extern CHDR chdr; /* converted header */ | |
23 | extern char *archive; /* archive name */ | |
24 | ||
25 | /* | |
26 | * print -- | |
27 | * Prints archive members on stdout - if member names given only | |
28 | * print those members, otherwise print all members. | |
29 | */ | |
30 | print(argv) | |
31 | char **argv; | |
32 | { | |
33 | CF cf; | |
34 | register int afd, all; | |
35 | int eval; | |
36 | ||
37 | afd = open_archive(O_RDONLY); | |
38 | ||
39 | SETCF(afd, archive, STDOUT_FILENO, "stdout", RPAD); | |
40 | for (all = !*argv; get_header(afd);) { | |
41 | if (!all && !files(argv)) { | |
42 | SKIP(afd, chdr.size, archive); | |
43 | continue; | |
44 | } | |
45 | if (options & AR_V) { | |
46 | (void)printf("\n<%s>\n\n", chdr.name); | |
47 | (void)fflush(stdout); | |
48 | } | |
49 | copyfile(&cf, chdr.size); | |
50 | if (!all && !*argv) | |
51 | break; | |
52 | } | |
44c5e2d6 | 53 | eval = 0; |
5681c8bf KB |
54 | ORPHANS; |
55 | close_archive(afd); | |
56 | return(eval); | |
57 | } |