s/fileno\(stdin\)/STDIN_FILENO/g
authorEric Andersen <andersen@codepoet.org>
Sat, 27 Mar 2004 10:02:48 +0000 (10:02 -0000)
committerEric Andersen <andersen@codepoet.org>
Sat, 27 Mar 2004 10:02:48 +0000 (10:02 -0000)
s/fileno\(stdout\)/STDOUT_FILENO/g

21 files changed:
archival/bunzip2.c
archival/cpio.c
archival/gunzip.c
archival/libunarchive/data_extract_to_stdout.c
archival/rpm2cpio.c
archival/tar.c
archival/uncompress.c
archival/unzip.c
coreutils/ls.c
coreutils/md5_sha1_sum.c
libbb/dump.c
libbb/print_file.c
networking/ftpgetput.c
networking/nc.c
networking/tftp.c
networking/wget.c
patches/tftp_timeout_multicast.diff
shell/cmdedit.c
shell/hush.c
shell/lash.c
util-linux/more.c

index e2c3ca9..ba42272 100644 (file)
@@ -52,7 +52,7 @@ int bunzip2_main(int argc, char **argv)
                /* Open input file */
                src_fd = bb_xopen(compressed_name, O_RDONLY);
        } else {
-               src_fd = fileno(stdin);
+               src_fd = STDIN_FILENO;
                opt |= BUNZIP2_OPT_STDOUT;
        }
 
@@ -62,7 +62,7 @@ int bunzip2_main(int argc, char **argv)
        }
 
        if (opt & BUNZIP2_OPT_STDOUT) {
-               dst_fd = fileno(stdout);
+               dst_fd = STDOUT_FILENO;
        } else {
                int len = strlen(compressed_name) - 4;
                if (strcmp(compressed_name + len, ".bz2") != 0) {
index aff6a55..0fbe7b8 100644 (file)
@@ -47,7 +47,7 @@ extern int cpio_main(int argc, char **argv)
 
        /* Initialise */
        archive_handle = init_handle();
-       archive_handle->src_fd = fileno(stdin);
+       archive_handle->src_fd = STDIN_FILENO;
        archive_handle->seek = seek_by_char;
        archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
 
index dec53f6..2c4dc49 100644 (file)
@@ -98,7 +98,7 @@ extern int gunzip_main(int argc, char **argv)
                optind++;
 
                if (old_path == NULL || strcmp(old_path, "-") == 0) {
-                       src_fd = fileno(stdin);
+                       src_fd = STDIN_FILENO;
                        opt |= GUNZIP_OPT_STDOUT;
                } else {
                        src_fd = bb_xopen(old_path, O_RDONLY);
@@ -119,7 +119,7 @@ extern int gunzip_main(int argc, char **argv)
                if (opt & GUNZIP_OPT_TEST) {
                        dst_fd = bb_xopen("/dev/null", O_WRONLY);       /* why does test use filenum 2 ? */
                } else if (opt & GUNZIP_OPT_STDOUT) {
-                       dst_fd = fileno(stdout);
+                       dst_fd = STDOUT_FILENO;
                } else {
                        char *extension;
 
@@ -178,10 +178,10 @@ extern int gunzip_main(int argc, char **argv)
                        delete_path = new_path;
                }
 
-               if (dst_fd != fileno(stdout)) {
+               if (dst_fd != STDOUT_FILENO) {
                        close(dst_fd);
                }
-               if (src_fd != fileno(stdin)) {
+               if (src_fd != STDIN_FILENO) {
                        close(src_fd);
                }
 
index 7c4e7c7..d4137a1 100644 (file)
@@ -18,5 +18,5 @@
 
 extern void data_extract_to_stdout(archive_handle_t *archive_handle)
 {
-       bb_copyfd_size(archive_handle->src_fd, fileno(stdout), archive_handle->file_header->size);
+       bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
 }
index 7b50595..5314e53 100644 (file)
@@ -73,7 +73,7 @@ extern int rpm2cpio_main(int argc, char **argv)
        unsigned char magic[2];
 
        if (argc == 1) {
-               rpm_fd = fileno(stdin);
+               rpm_fd = STDIN_FILENO;
        } else {
                rpm_fd = bb_xopen(argv[1], O_RDONLY);
        }
@@ -96,7 +96,7 @@ extern int rpm2cpio_main(int argc, char **argv)
        }
 
        check_header_gzip(rpm_fd);
-       if (inflate_gunzip(rpm_fd, fileno(stdout)) != 0) {
+       if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
                bb_error_msg("Error inflating");
        }
 
index 2310e80..279cbfd 100644 (file)
@@ -308,7 +308,7 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
        if (tbInfo->verboseFlag) {
                FILE *vbFd = stdout;
 
-               if (tbInfo->tarFd == fileno(stdout))    /* If the archive goes to stdout, verbose to stderr */
+               if (tbInfo->tarFd == STDOUT_FILENO)     /* If the archive goes to stdout, verbose to stderr */
                        vbFd = stderr;
 
                fprintf(vbFd, "%s\n", header.name);
@@ -883,7 +883,7 @@ int tar_main(int argc, char **argv)
        }
 
 #ifdef CONFIG_FEATURE_CLEAN_UP
-       if (tar_handle->src_fd != fileno(stdin)) {
+       if (tar_handle->src_fd != STDIN_FILENO) {
                close(tar_handle->src_fd);
        }
 #endif /* CONFIG_FEATURE_CLEAN_UP */
index 2de37d2..48b4e2c 100644 (file)
@@ -46,7 +46,7 @@ extern int uncompress_main(int argc, char **argv)
                int dst_fd;
 
                if (strcmp(compressed_file, "-") == 0) {
-                       src_fd = fileno(stdin);
+                       src_fd = STDIN_FILENO;
                        flags |= GUNZIP_TO_STDOUT;
                } else {
                        src_fd = bb_xopen(compressed_file, O_RDONLY);
@@ -60,7 +60,7 @@ extern int uncompress_main(int argc, char **argv)
 
                /* Set output filename and number */
                if (flags & GUNZIP_TO_STDOUT) {
-                       dst_fd = fileno(stdout);
+                       dst_fd = STDOUT_FILENO;
                } else {
                        struct stat stat_buf;
                        char *extension;
@@ -96,10 +96,10 @@ extern int uncompress_main(int argc, char **argv)
                        delete_path = uncompressed_file;
                }
 
-               if (dst_fd != fileno(stdout)) {
+               if (dst_fd != STDOUT_FILENO) {
                        close(dst_fd);
                }
-               if (src_fd != fileno(stdin)) {
+               if (src_fd != STDIN_FILENO) {
                        close(src_fd);
                }
 
index c670073..4e357d6 100644 (file)
@@ -135,7 +135,7 @@ extern int unzip_main(int argc, char **argv)
        }
 
        if (*argv[optind] == '-') {
-               archive_handle->src_fd = fileno(stdin);
+               archive_handle->src_fd = STDIN_FILENO;
                archive_handle->seek = seek_by_char;
        } else {
                archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
index 8b5065a..5fc60a3 100644 (file)
@@ -982,13 +982,13 @@ extern int ls_main(int argc, char **argv)
 
 #ifdef CONFIG_FEATURE_AUTOWIDTH
        /* Obtain the terminal width.  */
-       get_terminal_width_height(fileno(stdout), &terminal_width, NULL);
+       get_terminal_width_height(STDOUT_FILENO, &terminal_width, NULL);
        /* Go one less... */
        terminal_width--;
 #endif
 
 #ifdef CONFIG_FEATURE_LS_COLOR
-       if (isatty(fileno(stdout)))
+       if (isatty(STDOUT_FILENO))
                show_color = 1;
 #endif
 
@@ -1060,9 +1060,9 @@ extern int ls_main(int argc, char **argv)
        if ((all_fmt & STYLE_MASK) == STYLE_AUTO)
 #if STYLE_AUTO != 0
                all_fmt = (all_fmt & ~STYLE_MASK)
-                               | (isatty(fileno(stdout)) ? STYLE_COLUMNS : STYLE_SINGLE);
+                               | (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
 #else
-               all_fmt |= (isatty(fileno(stdout)) ? STYLE_COLUMNS : STYLE_SINGLE);
+               all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
 #endif
 
        /*
index 64e0693..3a07da0 100644 (file)
@@ -55,7 +55,7 @@ static uint8_t *hash_file(const char *filename, uint8_t hash_algo)
        int src_fd;
 
        if (strcmp(filename, "-") == 0) {
-               src_fd = fileno(stdin);
+               src_fd = STDIN_FILENO;
        } else {
                src_fd = open(filename, O_RDONLY);
        }
index f169da6..52a6c06 100644 (file)
@@ -311,7 +311,7 @@ static void do_skip(char *fname, int statok)
        struct stat sbuf;
 
        if (statok) {
-               if (fstat(fileno(stdin), &sbuf)) {
+               if (fstat(STDIN_FILENO, &sbuf)) {
                        bb_perror_msg_and_die("%s", fname);
                }
                if ((!(S_ISCHR(sbuf.st_mode) ||
index bd7108d..8f85cb4 100644 (file)
@@ -28,7 +28,7 @@ extern void bb_xprint_and_close_file(FILE *file)
        bb_xfflush_stdout();
        /* Note: Do not use STDOUT_FILENO here, as this is a lib routine
         *       and the calling code may have reassigned stdout. */
-       if (bb_copyfd_eof(fileno(file), fileno(stdout)) == -1) {
+       if (bb_copyfd_eof(fileno(file), STDOUT_FILENO) == -1) {
                /* bb_copyfd outputs any needed messages, so just die. */
                exit(bb_default_error_retval);
        }
index a13aaa2..47ffb5d 100644 (file)
@@ -154,7 +154,7 @@ static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream,
        }
 
        if ((local_path[0] == '-') && (local_path[1] == '\0')) {
-               fd_local = fileno(stdout);
+               fd_local = STDOUT_FILENO;
                do_continue = 0;
        }
 
@@ -230,7 +230,7 @@ static int ftp_send(ftp_host_info_t *server, FILE *control_stream,
 
        /* get the local file */
        if ((local_path[0] == '-') && (local_path[1] == '\0')) {
-               fd_local = fileno(stdin);
+               fd_local = STDIN_FILENO;
        } else {
                fd_local = bb_xopen(local_path, O_RDONLY);
                fstat(fd_local, &sbuf);
index 9a353c9..3099763 100644 (file)
@@ -79,7 +79,7 @@ int nc_main(int argc, char **argv)
 #ifdef GAPING_SECURITY_HOLE
        if (pr00gie) {
                /* won't need stdin */
-               close (fileno(stdin));      
+               close (STDIN_FILENO);      
        }
 #endif /* GAPING_SECURITY_HOLE */
 
index bd973d7..bfa9897 100644 (file)
@@ -576,7 +576,7 @@ int tftp_main(int argc, char **argv)
        result = tftp(cmd, host, remotefile, fd, port, blocksize);
 
 #ifdef CONFIG_FEATURE_CLEAN_UP
-       if (!(fd == fileno(stdout) || fd == fileno(stdin))) {
+       if (!(fd == STDOUT_FILENO || fd == STDIN_FILENO)) {
            close(fd);
        }
 #endif
index 619c138..5c94c58 100644 (file)
@@ -794,7 +794,7 @@ progressmeter(int flag)
                snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
                         "%02d:%02d ETA", i / 60, i % 60);
        }
-       write(fileno(stderr), buf, strlen(buf));
+       write(STDERR_FILENO, buf, strlen(buf));
 
        if (flag == -1) {
                struct sigaction sa;
@@ -846,7 +846,7 @@ progressmeter(int flag)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     $Id: wget.c,v 1.71 2004/03/15 08:28:53 andersen Exp $
+ *     $Id: wget.c,v 1.72 2004/03/27 10:02:43 andersen Exp $
  */
 
 
index 0f09d4a..ca431fc 100644 (file)
@@ -1031,7 +1031,7 @@ diff -u -r1.25 tftp.c
 +      result = tftp(cmd, host, remotefile, fd, port, &option);
 
  #ifdef CONFIG_FEATURE_CLEAN_UP
-       if (!(fd == fileno(stdout) || fd == fileno(stdin))) {
+       if (!(fd == STDOUT_FILENO || fd == STDIN_FILENO)) {
 @@ -582,3 +980,18 @@
  #endif
        return(result);
index bf945f7..cbe1eeb 100644 (file)
@@ -186,7 +186,7 @@ static void cmdedit_reset_term(void)
 {
        if ((handlers_sets & SET_RESET_TERM) != 0) {
 /* sparc and other have broken termios support: use old termio handling. */
-               setTermSettings(fileno(stdin), (void *) &initial_settings);
+               setTermSettings(STDIN_FILENO, (void *) &initial_settings);
                handlers_sets &= ~SET_RESET_TERM;
        }
        if ((handlers_sets & SET_WCHG_HANDLERS) != 0) {
index 5da9757..0a32099 100644 (file)
@@ -2825,7 +2825,7 @@ int hush_main(int argc, char **argv)
         *    standard output is a terminal
         *    Refer to Posix.2, the description of the `sh' utility. */
        if (argv[optind]==NULL && input==stdin &&
-                       isatty(fileno(stdin)) && isatty(fileno(stdout))) {
+                       isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
                interactive++;
        }
 
index d2d4298..e20c2a2 100644 (file)
@@ -1668,7 +1668,7 @@ int lash_main(int argc_l, char **argv_l)
         *    standard output is a terminal
         *    Refer to Posix.2, the description of the `sh' utility. */
        if (argv[optind]==NULL && input==stdin &&
-                       isatty(fileno(stdin)) && isatty(fileno(stdout))) {
+                       isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
                interactive=TRUE;
        }
        setup_job_control();
index 5ece188..e910388 100644 (file)
@@ -76,7 +76,7 @@ extern int more_main(int argc, char **argv)
 
 
        /* not use inputing from terminal if usage: more > outfile */
-       if(isatty(fileno(stdout))) {
+       if(isatty(STDOUT_FILENO)) {
                cin = fopen(CURRENT_TTY, "r");
                if (!cin)
                        cin = bb_xfopen(CONSOLE_DEV, "r");