Commit | Line | Data |
---|---|---|
5681c8bf | 1 | /*- |
4e6c9859 KB |
2 | * Copyright (c) 1990, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
5681c8bf KB |
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 | |
706c0358 | 12 | static char sccsid[] = "@(#)print.c 8.2 (Berkeley) %G%"; |
5681c8bf KB |
13 | #endif /* not lint */ |
14 | ||
15 | #include <sys/param.h> | |
706c0358 | 16 | |
5681c8bf | 17 | #include <dirent.h> |
706c0358 | 18 | #include <fcntl.h> |
5681c8bf | 19 | #include <stdio.h> |
706c0358 JSP |
20 | #include <unistd.h> |
21 | ||
5681c8bf | 22 | #include "archive.h" |
afe3014a | 23 | #include "extern.h" |
5681c8bf | 24 | |
5681c8bf KB |
25 | /* |
26 | * print -- | |
27 | * Prints archive members on stdout - if member names given only | |
28 | * print those members, otherwise print all members. | |
29 | */ | |
706c0358 | 30 | int |
5681c8bf KB |
31 | print(argv) |
32 | char **argv; | |
33 | { | |
34 | CF cf; | |
706c0358 | 35 | 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); | |
706c0358 | 61 | return (1); |
afe3014a | 62 | } |
706c0358 | 63 | return (0); |
5681c8bf | 64 | } |