Imported Upstream version 3.2
[platform/upstream/diffutils.git] / gnulib-tests / binary-io.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Binary mode I/O.
4    Copyright (C) 2001, 2003, 2005, 2008-2011 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _BINARY_H
20 #define _BINARY_H
21
22 /* For systems that distinguish between text and binary I/O.
23    O_BINARY is guaranteed by the gnulib <fcntl.h>. */
24 #include <fcntl.h>
25
26 /* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
27    so we include it here first.  */
28 #include <stdio.h>
29
30 /* SET_BINARY (fd);
31    changes the file descriptor fd to perform binary I/O.  */
32 #if O_BINARY
33 # if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
34 #  include <io.h> /* declares setmode() */
35 # else
36 #  define setmode _setmode
37 #  undef fileno
38 #  define fileno _fileno
39 # endif
40 # ifdef __DJGPP__
41 #  include <unistd.h> /* declares isatty() */
42    /* Avoid putting stdin/stdout in binary mode if it is connected to
43       the console, because that would make it impossible for the user
44       to interrupt the program through Ctrl-C or Ctrl-Break.  */
45 #  define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0))
46 # else
47 #  define SET_BINARY(fd) ((void) setmode (fd, O_BINARY))
48 # endif
49 #else
50   /* On reasonable systems, binary I/O is the default.  */
51 # define SET_BINARY(fd) /* do nothing */ ((void) 0)
52 #endif
53
54 #endif /* _BINARY_H */