dvitomp fix from Akira
[mplib] / src / texk / kpathsea / c-fopen.h
1 /* c-fopen.h: how to open files with fopen.
2
3    Copyright 1992, 1994, 1995, 1996, 2008 Karl Berry.
4    Copyright 1998, 2005 Olaf Weber.
5
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.
10
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.
15
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/>.  */
18
19 #ifndef C_FOPEN_H
20 #define C_FOPEN_H
21
22 /* How to open a text file:  */
23 #ifndef FOPEN_A_MODE
24 #define FOPEN_A_MODE "a"
25 #endif
26
27 #ifndef FOPEN_R_MODE
28 #define FOPEN_R_MODE "r"
29 #endif
30
31 #ifndef FOPEN_W_MODE
32 #define FOPEN_W_MODE "w"
33 #endif
34
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 */
39
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 */
44
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 */
49
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.  */
53 #include <fcntl.h>
54 #ifdef DOSISH
55 #include <io.h>
56 #ifndef O_BINARY
57 #ifdef _O_BINARY
58 #define O_BINARY _O_BINARY
59 #endif
60 #endif
61 #if defined (__i386_pc_gnu__) || \
62     defined (WIN32) || defined (__WIN32__) || defined (_WIN32)
63 #define SET_BINARY(f) setmode((f), O_BINARY)
64 #endif
65 #else  /* not DOSISH */
66 #ifndef O_BINARY
67 #define O_BINARY 0
68 #endif
69 #define SET_BINARY(f) 0
70 #endif /* not DOSISH */
71
72 #endif /* not C_FOPEN_H */