/* Open input file */
src_fd = bb_xopen(compressed_name, O_RDONLY);
} else {
- src_fd = fileno(stdin);
+ src_fd = STDIN_FILENO;
opt |= BUNZIP2_OPT_STDOUT;
}
}
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) {
/* 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;
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);
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;
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);
}
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);
}
unsigned char magic[2];
if (argc == 1) {
- rpm_fd = fileno(stdin);
+ rpm_fd = STDIN_FILENO;
} else {
rpm_fd = bb_xopen(argv[1], O_RDONLY);
}
}
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");
}
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);
}
#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 */
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);
/* 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;
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);
}
}
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);
#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
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
/*
int src_fd;
if (strcmp(filename, "-") == 0) {
- src_fd = fileno(stdin);
+ src_fd = STDIN_FILENO;
} else {
src_fd = open(filename, O_RDONLY);
}
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) ||
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);
}
}
if ((local_path[0] == '-') && (local_path[1] == '\0')) {
- fd_local = fileno(stdout);
+ fd_local = STDOUT_FILENO;
do_continue = 0;
}
/* 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);
#ifdef GAPING_SECURITY_HOLE
if (pr00gie) {
/* won't need stdin */
- close (fileno(stdin));
+ close (STDIN_FILENO);
}
#endif /* GAPING_SECURITY_HOLE */
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
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;
* 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 $
*/
+ 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);
{
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) {
* 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++;
}
* 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();
/* 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");