* src/include/nonposix.h: Remove first line -- this file is used in C also.
[s-roff.git] / src / include / nonposix.h
blobe4b02da3c2e01253619e92dac90dde9ba3501710
1 /* Copyright (C) 2000 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 # define setmode(f,m) _setmode(f,m)
28 # define fileno(f) _fileno(f)
29 #endif
31 #if defined(__MSDOS__) || (defined(_WIN32) && !defined(__CYGWIN32__))
33 /* Binary I/O nuisances. Note: "setmode" is right for DJGPP and
34 Borland; Windows compilers might need _setmode or some such. */
35 # include <fcntl.h>
36 # include <io.h>
37 # ifdef HAVE_UNISTD_H
38 # include <unistd.h>
39 # endif
40 # define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
41 # define FOPEN_RB "rb"
42 # define FOPEN_WB "wb"
43 # define FOPEN_RWB "wb+"
44 # ifdef _MSC_VER
45 # define POPEN_RT "rt"
46 # define POPEN_WT "wt"
47 # define popen(c,m) _popen(c,m)
48 # define pclose(p) _pclose(p)
49 # define getpid() (1)
50 # endif
51 # ifndef O_BINARY
52 # ifdef _O_BINARY
53 # define O_BINARY (_O_BINARY)
54 # endif
55 # endif
57 /* The system shell. Groff assumes a Unixy shell, but non-Posix
58 systems don't have standard places where it lives, and might not
59 have it installed to begin with. We want to give them some leeway. */
60 # define BSHELL (system_shell_name())
61 # define BSHELL_DASH_C (system_shell_dash_c())
62 # define IS_BSHELL(s) (is_system_shell(s))
64 /* The separator for directories in PATH and other environment
65 variables. */
66 # define PATH_SEP ";"
68 /* Characters that separate directories in a path name. */
69 # define DIR_SEPS "/\\:"
71 /* How to tell if the argument is an absolute file name. */
72 # define IS_ABSOLUTE(f) \
73 ((f)[0] == '/' || (f)[0] == '\\' || (f)[0] && (f)[1] == ':')
75 /* The executable extension. */
76 # define EXE_EXT ".exe"
78 /* The system null device. */
79 # define NULL_DEV "NUL"
81 /* Prototypes. */
82 # ifdef __cplusplus
83 extern "C" {
84 # endif
85 const char * system_shell_name(void);
86 const char * system_shell_dash_c(void);
87 int is_system_shell(const char *);
88 # ifdef __cplusplus
90 # endif
92 #endif
94 /* Defaults, for Posix systems. */
96 #ifndef FOPEN_RB
97 # define FOPEN_RB "r"
98 #endif
99 #ifndef FOPEN_WB
100 # define FOPEN_WB "w"
101 #endif
102 #ifndef FOPEN_RWB
103 # define FOPEN_RWB "w+"
104 #endif
105 #ifndef POPEN_RT
106 # define POPEN_RT "r"
107 #endif
108 #ifndef POPEN_WT
109 # define POPEN_WT "w"
110 #endif
111 #ifndef O_BINARY
112 # define O_BINARY 0
113 #endif
114 #ifndef BSHELL
115 # define BSHELL "/bin/sh"
116 #endif
117 #ifndef BSHELL_DASH_C
118 # define BSHELL_DASH_C "-c"
119 #endif
120 #ifndef IS_BSHELL
121 # define IS_BSHELL(s) ((s) && strcmp(s,BSHELL) == 0)
122 #endif
123 #ifndef PATH_SEP
124 # define PATH_SEP ":"
125 #endif
126 #ifndef DIR_SEPS
127 # define DIR_SEPS "/"
128 #endif
129 #ifndef IS_ABSOLUTE
130 # define IS_ABSOLUTE(f) ((f)[0] == '/')
131 #endif
132 #ifndef EXE_EXT
133 # define EXE_EXT ""
134 #endif
135 #ifndef NULL_DEV
136 # define NULL_DEV "/dev/null"
137 #endif