From 70060d25d23278f6b636a535edca4a0c4006decd Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 27 Mar 2004 10:02:48 +0000 Subject: s/fileno\(stdin\)/STDIN_FILENO/g s/fileno\(stdout\)/STDOUT_FILENO/g --- archival/bunzip2.c | 4 ++-- archival/cpio.c | 2 +- archival/gunzip.c | 8 ++++---- archival/libunarchive/data_extract_to_stdout.c | 2 +- archival/rpm2cpio.c | 4 ++-- archival/tar.c | 4 ++-- archival/uncompress.c | 8 ++++---- archival/unzip.c | 2 +- coreutils/ls.c | 8 ++++---- coreutils/md5_sha1_sum.c | 2 +- libbb/dump.c | 2 +- libbb/print_file.c | 2 +- networking/ftpgetput.c | 4 ++-- networking/nc.c | 2 +- networking/tftp.c | 2 +- networking/wget.c | 4 ++-- patches/tftp_timeout_multicast.diff | 2 +- shell/cmdedit.c | 2 +- shell/hush.c | 2 +- shell/lash.c | 2 +- util-linux/more.c | 2 +- 21 files changed, 35 insertions(+), 35 deletions(-) diff --git a/archival/bunzip2.c b/archival/bunzip2.c index e2c3ca9..ba42272 100644 --- a/archival/bunzip2.c +++ b/archival/bunzip2.c @@ -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) { diff --git a/archival/cpio.c b/archival/cpio.c index aff6a55..0fbe7b8 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -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; diff --git a/archival/gunzip.c b/archival/gunzip.c index dec53f6..2c4dc49 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c @@ -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); } diff --git a/archival/libunarchive/data_extract_to_stdout.c b/archival/libunarchive/data_extract_to_stdout.c index 7c4e7c7..d4137a1 100644 --- a/archival/libunarchive/data_extract_to_stdout.c +++ b/archival/libunarchive/data_extract_to_stdout.c @@ -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); } diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c index 7b50595..5314e53 100644 --- a/archival/rpm2cpio.c +++ b/archival/rpm2cpio.c @@ -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"); } diff --git a/archival/tar.c b/archival/tar.c index 2310e80..279cbfd 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -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 */ diff --git a/archival/uncompress.c b/archival/uncompress.c index 2de37d2..48b4e2c 100644 --- a/archival/uncompress.c +++ b/archival/uncompress.c @@ -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); } diff --git a/archival/unzip.c b/archival/unzip.c index c670073..4e357d6 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -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); diff --git a/coreutils/ls.c b/coreutils/ls.c index 8b5065a..5fc60a3 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -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 /* diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 64e0693..3a07da0 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c @@ -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); } diff --git a/libbb/dump.c b/libbb/dump.c index f169da6..52a6c06 100644 --- a/libbb/dump.c +++ b/libbb/dump.c @@ -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) || diff --git a/libbb/print_file.c b/libbb/print_file.c index bd7108d..8f85cb4 100644 --- a/libbb/print_file.c +++ b/libbb/print_file.c @@ -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); } diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index a13aaa2..47ffb5d 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -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); diff --git a/networking/nc.c b/networking/nc.c index 9a353c9..3099763 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -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 */ diff --git a/networking/tftp.c b/networking/tftp.c index bd973d7..bfa9897 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -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 diff --git a/networking/wget.c b/networking/wget.c index 619c138..5c94c58 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -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 $ */ diff --git a/patches/tftp_timeout_multicast.diff b/patches/tftp_timeout_multicast.diff index 0f09d4a..ca431fc 100644 --- a/patches/tftp_timeout_multicast.diff +++ b/patches/tftp_timeout_multicast.diff @@ -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); diff --git a/shell/cmdedit.c b/shell/cmdedit.c index bf945f7..cbe1eeb 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c @@ -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) { diff --git a/shell/hush.c b/shell/hush.c index 5da9757..0a32099 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -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++; } diff --git a/shell/lash.c b/shell/lash.c index d2d4298..e20c2a2 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -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(); diff --git a/util-linux/more.c b/util-linux/more.c index 5ece188..e910388 100644 --- a/util-linux/more.c +++ b/util-linux/more.c @@ -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"); -- cgit v1.1