Subversion Repositories Kolibri OS

Rev

Rev 5191 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5191 serge 1
/* Binary mode I/O.
2
   Copyright (C) 2001, 2003, 2005, 2008 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 3 of the License, or
7
   (at your option) 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, see .  */
16
 
17
#ifndef _BINARY_H
18
#define _BINARY_H
19
 
20
/* Include this header after  and , because
21
   systems that distinguish between text and binary I/O usually
22
   define O_BINARY in , and the MSVC7  doesn't
23
   like to be included after '#define fileno ...'
24
 
25
   We don't include  here because not all systems have
26
   that header.  */
27
 
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
32
#endif
33
#ifdef __BEOS__
34
  /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */
35
# undef O_BINARY
36
# undef O_TEXT
37
#endif
38
#if O_BINARY
39
# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
40
#  include  /* declares setmode() */
41
# else
42
#  define setmode _setmode
43
# endif
44
# ifdef __DJGPP__
45
#  include  /* declares isatty() */
46
#  /* Avoid putting stdin/stdout in binary mode if it is connected to the
47
#     console, because that would make it impossible for the user to
48
#     interrupt the program through Ctrl-C or Ctrl-Break.  */
49
#  define SET_BINARY(fd) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0)
50
# else
51
#  define SET_BINARY(fd) setmode (fd, O_BINARY)
52
# endif
53
#else
54
  /* On reasonable systems, binary I/O is the default.  */
55
# undef O_BINARY
56
# define O_BINARY 0
57
# define SET_BINARY(fd) /* nothing */
58
#endif
59
 
60
#endif /* _BINARY_H */