Magellan Linux

Annotation of /trunk/mkinitrd-magellan/busybox/coreutils/cat.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (hide annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 823 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

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     #include "busybox.h"
14    
15     int bb_cat(char **argv)
16     {
17     static char *const argv_dash[] = { "-", NULL };
18     FILE *f;
19     int retval = EXIT_SUCCESS;
20    
21     if (!*argv) argv = (char**) &argv_dash;
22    
23     do {
24     f = fopen_or_warn_stdin(*argv);
25     if (f) {
26     off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
27     fclose_if_not_stdin(f);
28     if (r >= 0)
29     continue;
30     }
31     retval = EXIT_FAILURE;
32     } while (*++argv);
33    
34     return retval;
35     }
36    
37     int cat_main(int argc, char **argv)
38     {
39     getopt32(argc, argv, "u");
40     argv += optind;
41     return bb_cat(argv);
42     }