beta-0.89.2
[luatex.git] / source / texk / kpathsea / c-fopen.h
blob7b64ef46352001c15d4307658532d5469d82a310
1 /* c-fopen.h: how to open files with fopen.
3 Copyright 1992, 1994, 1995, 1996, 2008, 2011 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/>. */
19 #ifndef C_FOPEN_H
20 #define C_FOPEN_H
22 /* How to open a text file: */
23 /* From Akira:
24 I'm using Unix style line ending character to write text files.
25 I find it is easiest to define FOPEN_W_MODE == FOPEN_WBIN_MODE etc. for
26 my purpose. */
27 #ifndef FOPEN_A_MODE
28 #define FOPEN_A_MODE "ab"
29 #endif
31 #ifndef FOPEN_R_MODE
32 #define FOPEN_R_MODE "r"
33 #endif
35 #ifndef FOPEN_W_MODE
36 #define FOPEN_W_MODE "wb"
37 #endif
39 /* How to open a binary file for reading: */
40 #ifndef FOPEN_RBIN_MODE
41 #define FOPEN_RBIN_MODE "rb"
42 #endif /* not FOPEN_RBIN_MODE */
44 /* How to open a binary file for writing: */
45 #ifndef FOPEN_WBIN_MODE
46 #define FOPEN_WBIN_MODE "wb"
47 #endif /* not FOPEN_WBIN_MODE */
49 /* How to open a binary file for appending: */
50 #ifndef FOPEN_ABIN_MODE
51 #define FOPEN_ABIN_MODE "ab"
52 #endif /* not FOPEN_ABIN_MODE */
54 /* How to switch an already open file handle to binary mode.
55 Used on DOSISH systems when we need to switch a standard
56 stream, such as stdin or stdout, to binary mode.
57 We never use the value return by setmode(). */
58 #include <fcntl.h>
59 #ifdef DOSISH
60 #include <io.h>
61 #ifndef O_BINARY
62 #ifdef _O_BINARY
63 #define O_BINARY _O_BINARY
64 #endif
65 #endif
66 #if defined (__i386_pc_gnu__) || \
67 defined (WIN32) || defined (__WIN32__) || defined (_WIN32)
68 #define SET_BINARY(f) (void)setmode((f), O_BINARY)
69 #endif
70 #else /* not DOSISH */
71 #ifndef O_BINARY
72 #define O_BINARY 0
73 #endif
74 #define SET_BINARY(f) (void)0
75 #endif /* not DOSISH */
77 #endif /* not C_FOPEN_H */