Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/binary-io.h @ 4928:6904dd9a5ccf
Avoid compilation warnings on Cygwin.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 20 Jan 2004 16:54:56 +0000 |
parents | 35fed2680490 |
children | a48fb0e98c8c |
rev | line source |
---|---|
4273 | 1 /* Binary mode I/O. |
2 Copyright (C) 2001, 2003 Free Software Foundation, Inc. | |
3 | |
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) | |
7 any later version. | |
8 | |
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. | |
13 | |
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
17 | |
18 #ifndef _BINARY_H | |
19 #define _BINARY_H | |
20 | |
21 /* For systems that distinguish between text and binary I/O. | |
22 O_BINARY is usually declared in <fcntl.h>. */ | |
4608 | 23 #include <fcntl.h> |
24 | |
25 /* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...', | |
26 so we include it here first. */ | |
27 #include <stdio.h> | |
28 | |
4273 | 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 | |
33 #endif | |
34 #ifdef __BEOS__ | |
35 /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ | |
36 # undef O_BINARY | |
37 # undef O_TEXT | |
38 #endif | |
39 #if O_BINARY | |
4928
6904dd9a5ccf
Avoid compilation warnings on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
4611
diff
changeset
|
40 # if !(defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__) |
4273 | 41 # define setmode _setmode |
42 # define fileno _fileno | |
43 # endif | |
4928
6904dd9a5ccf
Avoid compilation warnings on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
4611
diff
changeset
|
44 # if defined __DJGPP__ || defined __CYGWIN__ |
6904dd9a5ccf
Avoid compilation warnings on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
4611
diff
changeset
|
45 # include <io.h> /* declares setmode() */ |
6904dd9a5ccf
Avoid compilation warnings on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
4611
diff
changeset
|
46 # endif |
4273 | 47 # ifdef __DJGPP__ |
48 # include <unistd.h> /* declares isatty() */ | |
49 # /* Avoid putting stdin/stdout in binary mode if it is connected to the | |
50 # console, because that would make it impossible for the user to | |
51 # interrupt the program through Ctrl-C or Ctrl-Break. */ | |
52 # define SET_BINARY(fd) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0) | |
53 # else | |
54 # define SET_BINARY(fd) setmode (fd, O_BINARY) | |
55 # endif | |
56 #else | |
57 /* On reasonable systems, binary I/O is the default. */ | |
4611 | 58 # undef O_BINARY |
4273 | 59 # define O_BINARY 0 |
60 # define SET_BINARY(fd) /* nothing */ | |
61 #endif | |
62 | |
63 #endif /* _BINARY_H */ |