File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libiconv / srclib / binary-io.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 09:29:43 2012 UTC (12 years, 1 month ago) by misho
Branches: libiconv, MAIN
CVS tags: v1_14p0, v1_14, HEAD
libiconv v1.14

    1: /* Binary mode I/O.
    2:    Copyright (C) 2001, 2003, 2005, 2008-2011 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 <http://www.gnu.org/licenses/>.  */
   16: 
   17: #ifndef _BINARY_H
   18: #define _BINARY_H
   19: 
   20: /* For systems that distinguish between text and binary I/O.
   21:    O_BINARY is guaranteed by the gnulib <fcntl.h>. */
   22: #include <fcntl.h>
   23: 
   24: /* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
   25:    so we include it here first.  */
   26: #include <stdio.h>
   27: 
   28: /* SET_BINARY (fd);
   29:    changes the file descriptor fd to perform binary I/O.  */
   30: #if O_BINARY
   31: # if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
   32: #  include <io.h> /* declares setmode() */
   33: # else
   34: #  define setmode _setmode
   35: #  undef fileno
   36: #  define fileno _fileno
   37: # endif
   38: # ifdef __DJGPP__
   39: #  include <unistd.h> /* declares isatty() */
   40:    /* Avoid putting stdin/stdout in binary mode if it is connected to
   41:       the console, because that would make it impossible for the user
   42:       to interrupt the program through Ctrl-C or Ctrl-Break.  */
   43: #  define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0))
   44: # else
   45: #  define SET_BINARY(fd) ((void) setmode (fd, O_BINARY))
   46: # endif
   47: #else
   48:   /* On reasonable systems, binary I/O is the default.  */
   49: # define SET_BINARY(fd) /* do nothing */ ((void) 0)
   50: #endif
   51: 
   52: #endif /* _BINARY_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>