2 Copyright (C) 2001, 2003, 2005, 2008 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 3 of the License, or
7 (at your option) any later version.
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, see <http://www.gnu.org/licenses/>. */
20 /* For systems that distinguish between text and binary I/O.
21 O_BINARY is usually declared in <fcntl.h>. */
24 /* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
25 so we include it here first. */
28 #if !defined O_BINARY && defined _O_BINARY
29 /* For MSC-compatible compilers. */
30 # define O_BINARY _O_BINARY
31 # define O_TEXT _O_TEXT
33 #if defined __BEOS__ || defined __HAIKU__
34 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
39 # if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
40 # include <io.h> /* declares setmode() */
42 # define setmode _setmode
44 # define fileno _fileno
47 # include <unistd.h> /* declares isatty() */
48 # /* Avoid putting stdin/stdout in binary mode if it is connected to the
49 # console, because that would make it impossible for the user to
50 # interrupt the program through Ctrl-C or Ctrl-Break. */
51 # define SET_BINARY(fd) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0)
53 # define SET_BINARY(fd) setmode (fd, O_BINARY)
56 /* On reasonable systems, binary I/O is the default. */
59 # define SET_BINARY(fd) /* nothing */
62 #endif /* _BINARY_H */