Since rangecoder is just a bunch of C functions, move it into the one user
[oweals/busybox.git] / coreutils / cat.c
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 or later, 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 "busybox.h"
14 #include <unistd.h>
15
16 int cat_main(int argc, char **argv)
17 {
18         FILE *f;
19         int retval = EXIT_SUCCESS;
20
21         bb_getopt_ulflags(argc, argv, "u");
22
23         argv += optind;
24         if (!*argv) {
25                 *--argv = "-";
26         }
27
28         do {
29                 if ((f = bb_wfopen_input(*argv)) != NULL) {
30                         int r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
31                         bb_fclose_nonstdin(f);
32                         if (r >= 0) {
33                                 continue;
34                         }
35                 }
36                 retval = EXIT_FAILURE;
37         } while (*++argv);
38
39         return retval;
40 }