1 /* c-fopen.h: how to open files with fopen.
3 Copyright 1992, 1994, 1995, 1996, 2008 Karl Berry.
4 Copyright 1998, 2005 Olaf Weber.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, see <http://www.gnu.org/licenses/>. */
22 /* How to open a text file: */
24 #define FOPEN_A_MODE "a"
28 #define FOPEN_R_MODE "r"
32 #define FOPEN_W_MODE "w"
35 /* How to open a binary file for reading: */
36 #ifndef FOPEN_RBIN_MODE
37 #define FOPEN_RBIN_MODE "rb"
38 #endif /* not FOPEN_RBIN_MODE */
40 /* How to open a binary file for writing: */
41 #ifndef FOPEN_WBIN_MODE
42 #define FOPEN_WBIN_MODE "wb"
43 #endif /* not FOPEN_WBIN_MODE */
45 /* How to open a binary file for appending: */
46 #ifndef FOPEN_ABIN_MODE
47 #define FOPEN_ABIN_MODE "ab"
48 #endif /* not FOPEN_ABIN_MODE */
50 /* How to switch an already open file handle to binary mode.
51 Used on DOSISH systems when we need to switch a standard
52 stream, such as stdin or stdout, to binary mode. */
58 #define O_BINARY _O_BINARY
61 #if defined (__i386_pc_gnu__) || \
62 defined (WIN32) || defined (__WIN32__) || defined (_WIN32)
63 #define SET_BINARY(f) setmode((f), O_BINARY)
65 #else /* not DOSISH */
69 #define SET_BINARY(f) 0
70 #endif /* not DOSISH */
72 #endif /* not C_FOPEN_H */