2 Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
21 /* For systems that distinguish between text and binary I/O.
22 O_BINARY is usually declared in <fcntl.h>. */
25 /* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
26 so we include it here first. */
29 #if !defined O_BINARY && defined _O_BINARY
30 /* For MSC-compatible compilers. */
31 # define O_BINARY _O_BINARY
32 # define O_TEXT _O_TEXT
35 /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */
40 # if !(defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__)
41 # define setmode _setmode
43 # define fileno _fileno
45 # if defined __DJGPP__ || defined __CYGWIN__
46 # include <io.h> /* declares setmode() */
49 # include <unistd.h> /* declares isatty() */
50 # /* Avoid putting stdin/stdout in binary mode if it is connected to the
51 # console, because that would make it impossible for the user to
52 # interrupt the program through Ctrl-C or Ctrl-Break. */
53 # define SET_BINARY(fd) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0)
55 # define SET_BINARY(fd) setmode (fd, O_BINARY)
58 /* On reasonable systems, binary I/O is the default. */
61 # define SET_BINARY(fd) /* nothing */
64 #endif /* _BINARY_H */