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 | |
ce478bb7 | 12 | static char sccsid[] = "@(#)print.c 5.6 (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" | |
afe3014a | 21 | #include "extern.h" |
5681c8bf KB |
22 | |
23 | extern CHDR chdr; /* converted header */ | |
24 | extern char *archive; /* archive name */ | |
25 | ||
26 | /* | |
27 | * print -- | |
28 | * Prints archive members on stdout - if member names given only | |
29 | * print those members, otherwise print all members. | |
30 | */ | |
31 | print(argv) | |
32 | char **argv; | |
33 | { | |
34 | CF cf; | |
35 | register int afd, all; | |
af52bb8a | 36 | char *file; |
5681c8bf KB |
37 | |
38 | afd = open_archive(O_RDONLY); | |
39 | ||
35aab8af | 40 | /* Read from an archive, write to stdout; pad on read. */ |
5681c8bf | 41 | SETCF(afd, archive, STDOUT_FILENO, "stdout", RPAD); |
ce478bb7 | 42 | for (all = !*argv; get_arobj(afd);) { |
af52bb8a KB |
43 | if (all) |
44 | file = chdr.name; | |
afe3014a | 45 | else if (!(file = files(argv))) { |
ce478bb7 | 46 | skip_arobj(afd); |
afe3014a | 47 | continue; |
5681c8bf KB |
48 | } |
49 | if (options & AR_V) { | |
af52bb8a | 50 | (void)printf("\n<%s>\n\n", file); |
5681c8bf KB |
51 | (void)fflush(stdout); |
52 | } | |
ce478bb7 | 53 | copy_ar(&cf, chdr.size); |
5681c8bf KB |
54 | if (!all && !*argv) |
55 | break; | |
56 | } | |
5681c8bf | 57 | close_archive(afd); |
afe3014a KB |
58 | |
59 | if (*argv) { | |
60 | orphans(argv); | |
61 | return(1); | |
62 | } | |
63 | return(0); | |
5681c8bf | 64 | } |