1 /* Binary mode I/O with checking
2 Copyright 2017-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
20 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn. */
21 #if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
25 #include "binary-io.h"
27 _GL_INLINE_HEADER_BEGIN
28 #ifndef XBINARY_IO_INLINE
29 # define XBINARY_IO_INLINE _GL_INLINE
38 extern _Noreturn
void xset_binary_mode_error (void);
40 XBINARY_IO_INLINE
void xset_binary_mode_error (void) {}
43 /* Set the mode of FD to MODE, which should be either O_TEXT or O_BINARY.
44 Report an error and exit if this fails. */
46 XBINARY_IO_INLINE
void
47 xset_binary_mode (int fd
, int mode
)
49 if (set_binary_mode (fd
, mode
) < 0)
50 xset_binary_mode_error ();
60 #endif /* _XBINARY_IO_H */