source: MondoRescue/branches/2.2.5/mindi-busybox/coreutils/cat.c@ 1765

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

Update to busybox 1.7.2

File size: 1019 bytes
RevLine 
[821]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 *
[1765]7 * Licensed under GPLv2, see file License in this tarball for details.
[821]8 */
9
10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
12
[1765]13#include "libbb.h"
[821]14
[1765]15/* This is a NOFORK applet. Be very careful! */
16
17
18int bb_cat(char **argv)
[821]19{
[1765]20 static const char *const argv_dash[] = { "-", NULL };
21
22 int fd;
[821]23 int retval = EXIT_SUCCESS;
24
[1765]25 if (!*argv)
26 argv = (char**) &argv_dash;
[821]27
28 do {
[1765]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)
[821]38 continue;
39 }
40 retval = EXIT_FAILURE;
41 } while (*++argv);
42
43 return retval;
44}
[1765]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.