source: MondoRescue/branches/2.2.8.selinux/mindi-busybox/coreutils/cat.c@ 3528

Last change on this file since 3528 was 1765, checked in by Bruno Cornec, 16 years ago

Update to busybox 1.7.2

File size: 1019 bytes
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * cat implementation for busybox
4 *
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 *
7 * Licensed under GPLv2, see file License in this tarball for details.
8 */
9
10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
12
13#include "libbb.h"
14
15/* This is a NOFORK applet. Be very careful! */
16
17
18int bb_cat(char **argv)
19{
20 static const char *const argv_dash[] = { "-", NULL };
21
22 int fd;
23 int retval = EXIT_SUCCESS;
24
25 if (!*argv)
26 argv = (char**) &argv_dash;
27
28 do {
29 fd = STDIN_FILENO;
30 if (!LONE_DASH(*argv))
31 fd = open_or_warn(*argv, O_RDONLY);
32 if (fd >= 0) {
33 /* This is not an xfunc - never exits */
34 off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
35 if (fd != STDIN_FILENO)
36 close(fd);
37 if (r >= 0)
38 continue;
39 }
40 retval = EXIT_FAILURE;
41 } while (*++argv);
42
43 return retval;
44}
45
46int cat_main(int argc, char **argv);
47int cat_main(int argc, char **argv)
48{
49 getopt32(argv, "u");
50 argv += optind;
51 return bb_cat(argv);
52}
Note: See TracBrowser for help on using the repository browser.