Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / groff / src / include / nonposix.h
1 /* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
2      Written by Eli Zaretskii (eliz@is.elta.co.il)
3
4 This file is part of groff.
5
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.
10
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.
15
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. */
19
20 /* This header file compartmentalize all idiosyncrasies of non-Posix
21    systems, such as MS-DOS, MS-Windows, etc.  */
22
23 #if defined _MSC_VER
24 # ifndef _WIN32
25 #  define _WIN32
26 # endif
27 #endif
28
29 #if defined(__MSDOS__) \
30     || (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__))
31
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 # ifdef _MSC_VER
40 #  define POPEN_RT     "rt"
41 #  define POPEN_WT     "wt"
42 #  define popen(c,m)   _popen(c,m)
43 #  define pclose(p)    _pclose(p)
44 #  define getpid()     (1)
45 #  define mkdir(p,m)   _mkdir(p)
46 #  define setmode(f,m) _setmode(f,m)
47 #  define WAIT(s,p,m)  _cwait(s,p,m)
48 #  define creat(p,m)   _creat(p,m)
49 # endif
50 # define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
51 # define FOPEN_RB      "rb"
52 # define FOPEN_WB      "wb"
53 # define FOPEN_RWB     "wb+"
54 # ifndef O_BINARY
55 #  ifdef _O_BINARY
56 #   define O_BINARY    (_O_BINARY)
57 #  endif
58 # endif
59
60 /* The system shell.  Groff assumes a Unixy shell, but non-Posix
61    systems don't have standard places where it lives, and might not
62    have it installed to begin with.  We want to give them some leeway.  */
63 # define BSHELL        (system_shell_name())
64 # define BSHELL_DASH_C (system_shell_dash_c())
65 # define IS_BSHELL(s)  (is_system_shell(s))
66
67 /* The separator for directories in PATH and other environment
68    variables.  */
69 # define PATH_SEP      ";"
70
71 /* Characters that separate directories in a path name.  */
72 # define DIR_SEPS      "/\\:"
73
74 /* How to tell if the argument is an absolute file name.  */
75 # define IS_ABSOLUTE(f) \
76  ((f)[0] == '/' || (f)[0] == '\\' || (f)[0] && (f)[1] == ':')
77
78 /* The executable extension.  */
79 # define EXE_EXT       ".exe"
80
81 /* The system null device.  */
82 # define NULL_DEV      "NUL"
83
84 /* Prototypes.  */
85 # ifdef __cplusplus
86   extern "C" {
87 # endif
88     const char * system_shell_name(void);
89     const char * system_shell_dash_c(void);
90     int          is_system_shell(const char *);
91 # ifdef __cplusplus
92   }
93 # endif
94
95 #endif
96
97 /* Defaults, for Posix systems.  */
98
99 #ifndef FOPEN_RB
100 # define FOPEN_RB      "r"
101 #endif
102 #ifndef FOPEN_WB
103 # define FOPEN_WB      "w"
104 #endif
105 #ifndef FOPEN_RWB
106 # define FOPEN_RWB     "w+"
107 #endif
108 #ifndef POPEN_RT
109 # define POPEN_RT      "r"
110 #endif
111 #ifndef POPEN_WT
112 # define POPEN_WT      "w"
113 #endif
114 #ifndef O_BINARY
115 # define O_BINARY      0
116 #endif
117 #ifndef BSHELL
118 # define BSHELL        "/bin/sh"
119 #endif
120 #ifndef BSHELL_DASH_C
121 # define BSHELL_DASH_C "-c"
122 #endif
123 #ifndef IS_BSHELL
124 # define IS_BSHELL(s)  ((s) && strcmp(s,BSHELL) == 0)
125 #endif
126 #ifndef PATH_SEP
127 # define PATH_SEP      ":"
128 #endif
129 #ifndef DIR_SEPS
130 # define DIR_SEPS      "/"
131 #endif
132 #ifndef IS_ABSOLUTE
133 # define IS_ABSOLUTE(f) ((f)[0] == '/')
134 #endif
135 #ifndef EXE_EXT
136 # define EXE_EXT       ""
137 #endif
138 #ifndef NULL_DEV
139 # define NULL_DEV      "/dev/null"
140 #endif
141 #ifndef GS_NAME
142 # define GS_NAME       "gs"
143 #endif
144 #ifndef WAIT
145 # define WAIT(s,p,m)   wait(s)
146 #endif
147 #ifndef _WAIT_CHILD
148 # define _WAIT_CHILD   0
149 #endif