~peter-pearse/ubuntu/natty/diffutils/prop001

« back to all changes in this revision

Viewing changes to gnulib-tests/binary-io.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2010-05-04 20:38:00 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100504203800-f67xd9rsa9xl9qqj
Tags: 1:3.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, 2009, 2010 Free Software Foundation,
 
5
   Inc.
 
6
 
 
7
   This program is free software: you can redistribute it and/or modify
 
8
   it under the terms of the GNU General Public License as published by
 
9
   the Free Software Foundation; either version 3 of the License, or
 
10
   (at your option) any later version.
 
11
 
 
12
   This program is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
   GNU General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License
 
18
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
19
 
 
20
#ifndef _BINARY_H
 
21
#define _BINARY_H
 
22
 
 
23
/* For systems that distinguish between text and binary I/O.
 
24
   O_BINARY is usually declared in <fcntl.h>. */
 
25
#include <fcntl.h>
 
26
 
 
27
/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
 
28
   so we include it here first.  */
 
29
#include <stdio.h>
 
30
 
 
31
#if !defined O_BINARY && defined _O_BINARY
 
32
  /* For MSC-compatible compilers.  */
 
33
# define O_BINARY _O_BINARY
 
34
# define O_TEXT _O_TEXT
 
35
#endif
 
36
#if defined __BEOS__ || defined __HAIKU__
 
37
  /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */
 
38
# undef O_BINARY
 
39
# undef O_TEXT
 
40
#endif
 
41
 
 
42
/* SET_BINARY (fd);
 
43
   changes the file descriptor fd to perform binary I/O.  */
 
44
#if O_BINARY
 
45
# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
 
46
#  include <io.h> /* declares setmode() */
 
47
# else
 
48
#  define setmode _setmode
 
49
#  undef fileno
 
50
#  define fileno _fileno
 
51
# endif
 
52
# ifdef __DJGPP__
 
53
#  include <unistd.h> /* declares isatty() */
 
54
   /* Avoid putting stdin/stdout in binary mode if it is connected to
 
55
      the console, because that would make it impossible for the user
 
56
      to interrupt the program through Ctrl-C or Ctrl-Break.  */
 
57
#  define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0))
 
58
# else
 
59
#  define SET_BINARY(fd) ((void) setmode (fd, O_BINARY))
 
60
# endif
 
61
#else
 
62
  /* On reasonable systems, binary I/O is the default.  */
 
63
# undef O_BINARY
 
64
# define O_BINARY 0
 
65
# define SET_BINARY(fd) /* do nothing */ ((void) 0)
 
66
#endif
 
67
 
 
68
#endif /* _BINARY_H */