More fixes for MSVC compiler.
[s-roff.git] / src / include / nonposix.h
bloba9e78cc418b9922cc78785ccefed0c798a81b9e9
1 /* Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
2 Written by Eli Zaretskii (eliz@is.elta.co.il)
4 This file is part of groff.
6 groff is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
11 groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License along
17 with groff; see the file COPYING. If not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* This header file compartmentalize all idiosyncrasies of non-Posix
21 systems, such as MS-DOS, MS-Windows, etc. */
23 #if defined _MSC_VER
24 # ifndef _WIN32
25 # define _WIN32
26 # endif
27 #endif
29 #if defined(__MSDOS__) || defined(__EMX__) \
30 || (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__))
32 /* Binary I/O nuisances. Note: "setmode" is right for DJGPP and
33 Borland; Windows compilers might need _setmode or some such. */
34 # include <fcntl.h>
35 # include <io.h>
36 # ifdef HAVE_UNISTD_H
37 # include <unistd.h>
38 # endif
39 # ifndef STDIN_FILENO
40 # define STDIN_FILENO 0
41 # define STDOUT_FILENO 1
42 # define STDERR_FILENO 2
43 # endif
44 # ifdef HAVE_DIRECT_H
45 # include <direct.h>
46 # endif
47 # ifdef HAVE_PROCESS_H
48 # include <process.h>
49 # endif
50 # if defined(_MSC_VER) || defined(__MINGW32__)
51 # define POPEN_RT "rt"
52 # define POPEN_WT "wt"
53 # define popen(c,m) _popen(c,m)
54 # define pclose(p) _pclose(p)
55 # define pipe(pfd) _pipe((pfd),0,_O_BINARY|_O_NOINHERIT)
56 # define mkdir(p,m) _mkdir(p)
57 # define setmode(f,m) _setmode(f,m)
58 # define WAIT(s,p,m) _cwait(s,p,m)
59 # define creat(p,m) _creat(p,m)
60 # define read(f,b,s) _read(f,b,s)
61 # endif
62 # define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
63 # define FOPEN_RB "rb"
64 # define FOPEN_WB "wb"
65 # define FOPEN_RWB "wb+"
66 # ifndef O_BINARY
67 # ifdef _O_BINARY
68 # define O_BINARY (_O_BINARY)
69 # endif
70 # endif
72 /* The system shell. Groff assumes a Unixy shell, but non-Posix
73 systems don't have standard places where it lives, and might not
74 have it installed to begin with. We want to give them some leeway. */
75 # ifdef __EMX__
76 # define getcwd(b,s) _getcwd2(b,s)
77 # else
78 # define BSHELL (system_shell_name())
79 # define BSHELL_DASH_C (system_shell_dash_c())
80 # define IS_BSHELL(s) (is_system_shell(s))
81 # endif
83 /* The separator for directories in PATH and other environment
84 variables. */
85 # define PATH_SEP ";"
86 # define PATH_SEP_CHAR ';'
88 /* Characters that separate directories in a path name. */
89 # define DIR_SEPS "/\\:"
91 /* How to tell if the argument is an absolute file name. */
92 # define IS_ABSOLUTE(f) \
93 ((f)[0] == '/' || (f)[0] == '\\' || (f)[0] && (f)[1] == ':')
95 /* The executable extension. */
96 # define EXE_EXT ".exe"
98 /* The system null device. */
99 # define NULL_DEV "NUL"
101 /* The default place to create temporary files. */
102 # ifndef P_tmpdir
103 # ifdef _P_tmpdir
104 # define P_tmpdir _P_tmpdir
105 # else
106 # define P_tmpdir "c:/temp"
107 # endif
108 # endif
110 /* Prototypes. */
111 # ifdef __cplusplus
112 extern "C" {
113 # endif
114 const char * system_shell_name(void);
115 const char * system_shell_dash_c(void);
116 int is_system_shell(const char *);
117 # ifdef __cplusplus
119 # endif
121 #endif
123 /* Defaults, for Posix systems. */
125 #ifndef SET_BINARY
126 # define SET_BINARY(f) do {} while(0)
127 #endif
128 #ifndef FOPEN_RB
129 # define FOPEN_RB "r"
130 #endif
131 #ifndef FOPEN_WB
132 # define FOPEN_WB "w"
133 #endif
134 #ifndef FOPEN_RWB
135 # define FOPEN_RWB "w+"
136 #endif
137 #ifndef POPEN_RT
138 # define POPEN_RT "r"
139 #endif
140 #ifndef POPEN_WT
141 # define POPEN_WT "w"
142 #endif
143 #ifndef O_BINARY
144 # define O_BINARY 0
145 #endif
146 #ifndef BSHELL
147 # define BSHELL "/bin/sh"
148 #endif
149 #ifndef BSHELL_DASH_C
150 # define BSHELL_DASH_C "-c"
151 #endif
152 #ifndef IS_BSHELL
153 # define IS_BSHELL(s) ((s) && strcmp(s,BSHELL) == 0)
154 #endif
155 #ifndef PATH_SEP
156 # define PATH_SEP ":"
157 # define PATH_SEP_CHAR ':'
158 #endif
159 #ifndef DIR_SEPS
160 # define DIR_SEPS "/"
161 #endif
162 #ifndef IS_ABSOLUTE
163 # define IS_ABSOLUTE(f) ((f)[0] == '/')
164 #endif
165 #ifndef EXE_EXT
166 # define EXE_EXT ""
167 #endif
168 #ifndef NULL_DEV
169 # define NULL_DEV "/dev/null"
170 #endif
171 #ifndef GS_NAME
172 # define GS_NAME "gs"
173 #endif
174 #ifndef WAIT
175 # define WAIT(s,p,m) wait(s)
176 #endif
177 #ifndef _WAIT_CHILD
178 # define _WAIT_CHILD 0
179 #endif