Annotation of /trunk/mkinitrd-magellan/busybox/coreutils/cat.c
Parent Directory | Revision Log
Revision 816 -
(hide annotations)
(download)
Fri Apr 24 18:33:46 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 951 byte(s)
Fri Apr 24 18:33:46 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 951 byte(s)
-updated to busybox-1.13.4
1 | niro | 532 | /* 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 | niro | 816 | #include "libbb.h" |
14 | niro | 532 | |
15 | niro | 816 | /* This is a NOFORK applet. Be very careful! */ |
16 | |||
17 | |||
18 | niro | 532 | int bb_cat(char **argv) |
19 | { | ||
20 | niro | 816 | int fd; |
21 | niro | 532 | int retval = EXIT_SUCCESS; |
22 | |||
23 | niro | 816 | if (!*argv) |
24 | argv = (char**) &bb_argv_dash; | ||
25 | niro | 532 | |
26 | do { | ||
27 | niro | 816 | fd = open_or_warn_stdin(*argv); |
28 | if (fd >= 0) { | ||
29 | /* This is not a xfunc - never exits */ | ||
30 | off_t r = bb_copyfd_eof(fd, STDOUT_FILENO); | ||
31 | if (fd != STDIN_FILENO) | ||
32 | close(fd); | ||
33 | niro | 532 | if (r >= 0) |
34 | continue; | ||
35 | } | ||
36 | retval = EXIT_FAILURE; | ||
37 | } while (*++argv); | ||
38 | |||
39 | return retval; | ||
40 | } | ||
41 | |||
42 | niro | 816 | int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
43 | int cat_main(int argc UNUSED_PARAM, char **argv) | ||
44 | niro | 532 | { |
45 | niro | 816 | getopt32(argv, "u"); |
46 | niro | 532 | argv += optind; |
47 | return bb_cat(argv); | ||
48 | } |