Remove fcntl.h includes throughout.

* fhandler.h: Move fcntl.h include here.
(fhandler_base::set_flags): Accept supplied_bin argument.  Make non-inlined.
* dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc.
(reset_to_open_binmode): Use set_flags.
* cygwin.din (open): Avoid newlib wrapper.
(read): Ditto.
(unlink): Ditto.
(write): Ditto.
* fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument.  Make
binmode decisions here.
(fhandler_base::open): Avoid using pc if it is NULL.  Eliminate binmode logic.
Just call set_flags with binmode argument.
(fhandler_base::init): Call set_flags with binmode argument.
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_console.cc (fhandler_console::open): Ditto.
(fhandler_console::init): Force binary on open.
* fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here.
Let it happen in base class.
* fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open.  Set return
value appropriately if unable to open.
* fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before
open_status.
* fhandler_process.cc (fhandler_process::open): Ditto.
* fhandler_registry.cc (fhandler_registry::open): Ditto.
* fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default.
* fhandler_serial.cc (fhandler_serial::init): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::open): Ditto.
(fhandler_pty_master::open): Ditto.
* fhandler_virtual.cc (fhandler_virtual::open): Ditto.
* fhandler_windows.cc (fhandler_windows::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
* net.cc (fdsock): Ditto.
* path.cc (path_conv::check): Avoid checking for extension when error or
directory.
(set_flags): Set PATH_TEXT explicitly, when appropriate.
(mount_info::conv_to_win32_path): Use set_flags() to set path flags.
* path.h (PATH_TEXT): New enum.
(path_conv::binmode): Return appropriate constant based on binmode.
* pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY.
* syscalls.cc (setmode_helper): Make debugging message a little clearer.
(setmode): Set binmode via set_flags.
This commit is contained in:
Christopher Faylor
2002-06-05 01:42:28 +00:00
parent 915d66ce9e
commit e35f391fa5
33 changed files with 157 additions and 146 deletions

View File

@@ -16,7 +16,6 @@ details. */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/cygwin.h>
#include <assert.h>
#include <ntdef.h>
@@ -216,7 +215,6 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
void
dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
{
int bin = -1;
const char *name;
CONSOLE_SCREEN_BUFFER_INFO buf;
struct sockaddr sa;
@@ -234,20 +232,13 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
name = NULL;
else
{
if (__fmode)
bin = __fmode;
else
bin = (int) binmode ?: -1;
/* See if we can consoleify it - if it is a console,
don't open it in binary. That will screw up our crlfs*/
/* See if we can consoleify it */
if (GetConsoleScreenBufferInfo (handle, &buf))
{
if (ISSTATE (myself, PID_USETTY))
name = "/dev/tty";
else
name = "/dev/conout";
bin = 0;
}
else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf))
{
@@ -255,7 +246,6 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
name = "/dev/tty";
else
name = "/dev/conin";
bin = 0;
}
else if (ft == FILE_TYPE_PIPE)
{
@@ -263,8 +253,6 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
name = "/dev/piper";
else
name = "/dev/pipew";
if (bin == 0)
bin = O_BINARY;
}
else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
name = "/dev/socket";
@@ -280,7 +268,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
{
path_conv pc;
build_fhandler_from_name (fd, name, handle, pc)->init (handle, myaccess,
bin < 0 ? pc.isbinary () : bin);
pc.binmode ());
set_std_handle (fd);
paranoid_printf ("fd %d, handle %p", fd, handle);
}