Contents of /tags/mkinitrd-6_1_6/busybox/coreutils/cat.c
Parent Directory | Revision Log
Revision 903 -
(show annotations)
(download)
Wed Aug 5 19:21:45 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 951 byte(s)
Wed Aug 5 19:21:45 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 951 byte(s)
tagged 'mkinitrd-6_1_6'
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 | |
18 | int bb_cat(char **argv) |
19 | { |
20 | int fd; |
21 | int retval = EXIT_SUCCESS; |
22 | |
23 | if (!*argv) |
24 | argv = (char**) &bb_argv_dash; |
25 | |
26 | do { |
27 | 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 | if (r >= 0) |
34 | continue; |
35 | } |
36 | retval = EXIT_FAILURE; |
37 | } while (*++argv); |
38 | |
39 | return retval; |
40 | } |
41 | |
42 | int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
43 | int cat_main(int argc UNUSED_PARAM, char **argv) |
44 | { |
45 | getopt32(argv, "u"); |
46 | argv += optind; |
47 | return bb_cat(argv); |
48 | } |