(root)/
coreutils-9.4/
lib/
xbinary-io.h
       1  /* Binary mode I/O with checking
       2     Copyright 2017-2023 Free Software Foundation, Inc.
       3  
       4     This file is free software: you can redistribute it and/or modify
       5     it under the terms of the GNU Lesser General Public License as
       6     published by the Free Software Foundation, either version 3 of the
       7     License, or (at your option) any later version.
       8  
       9     This file 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 Lesser General Public License for more details.
      13  
      14     You should have received a copy of the GNU Lesser General Public License
      15     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      16  
      17  #ifndef _XBINARY_IO_H
      18  #define _XBINARY_IO_H
      19  
      20  /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn.  */
      21  #if !_GL_CONFIG_H_INCLUDED
      22   #error "Please include config.h first."
      23  #endif
      24  
      25  #include "binary-io.h"
      26  
      27  _GL_INLINE_HEADER_BEGIN
      28  #ifndef XBINARY_IO_INLINE
      29  # define XBINARY_IO_INLINE _GL_INLINE
      30  #endif
      31  
      32  #if O_BINARY
      33  extern _Noreturn void xset_binary_mode_error (void);
      34  #else
      35  XBINARY_IO_INLINE void xset_binary_mode_error (void) {}
      36  #endif
      37  
      38  /* Set the mode of FD to MODE, which should be either O_TEXT or O_BINARY.
      39     Report an error and exit if this fails.  */
      40  
      41  XBINARY_IO_INLINE void
      42  xset_binary_mode (int fd, int mode)
      43  {
      44    if (set_binary_mode (fd, mode) < 0)
      45      xset_binary_mode_error ();
      46  }
      47  
      48  _GL_INLINE_HEADER_END
      49  
      50  #endif /* _XBINARY_IO_H */