1 /* system.h: system-dependent declarations; include this first.
2 $Id: system.h,v 1.12 2004/04/26 13:56:57 karl Exp $
4 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #ifndef TEXINFO_SYSTEM_H
22 #define TEXINFO_SYSTEM_H
29 #include <gnu-miktex.h>
30 #define S_ISDIR(x) ((x)&_S_IFDIR)
32 /* MiKTeX defines substring() in a separate DLL, where it has its
33 own __declspec declaration. We don't want to try to duplicate
34 this Microsoft-ism here. */
35 extern char *substring (const char *, const char *);
38 /* We follow the order of header inclusion from Autoconf's
39 ac_includes_default, more or less. */
41 #include <sys/types.h>
44 /* All systems nowadays probably have these functions, but ... */
48 #ifndef HAVE_SETLOCALE
49 #define setlocale(category,locale) /* empty */
52 /* For gettext (NLS). */
57 #define _(String) gettext (String)
58 #define N_(String) (String)
61 #define getopt system_getopt
65 extern char *getenv ();
68 /* Don't use bcopy! Use memmove if source and destination may overlap,
71 # if !STDC_HEADERS && HAVE_MEMORY_H
78 /* Always include <strings.h> if we have it. This is because that's
79 what Autoconf's AC_CHECK_DECL does. On IBM AIX 4.2, strncasecmp is
80 only declared in strings.h. */
84 #if !HAVE_STRNCASECMP || !HAVE_STRCASECMP
92 /* <unistd.h> defines _POSIX_VERSION, but Paul Eggert points out that is
93 only supposed to be used in user code, not other system headers. */
96 #endif /* HAVE_UNISTD_H */
106 #ifndef HAVE_DECL_STRERROR
107 extern char *strerror ();
114 #ifndef _POSIX_PATH_MAX
115 # define _POSIX_PATH_MAX 255
117 #define PATH_MAX _POSIX_PATH_MAX
120 #ifndef HAVE_DECL_STRCASECMP
121 extern int strcasecmp ();
124 #ifndef HAVE_DECL_STRNCASECMP
125 extern int strncasecmp ();
128 #ifndef HAVE_DECL_STRCOLL
129 extern int strcoll ();
132 #include <sys/stat.h>
133 #if STAT_MACROS_BROKEN
136 #if !defined(S_ISDIR) && defined(S_IFDIR)
137 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
140 #ifdef HAVE_SYS_FILE_H
141 #include <sys/file.h>
142 #endif /* HAVE_SYS_FILE_H */
145 /* Since <fcntl.h> is POSIX, prefer that to <sys/fcntl.h>.
146 This also avoids some useless warnings on (at least) Linux. */
149 #else /* not HAVE_FCNTL_H */
150 #ifdef HAVE_SYS_FCNTL_H
151 #include <sys/fcntl.h>
152 #endif /* not HAVE_SYS_FCNTL_H */
153 #endif /* not HAVE_FCNTL_H */
154 #endif /* not O_RDONLY */
156 /* MS-DOS and similar non-Posix systems have some peculiarities:
157 - they distinguish between binary and text files;
158 - they use both `/' and `\\' as directory separator in file names;
159 - they can have a drive letter X: prepended to a file name;
160 - they have a separate root directory on each drive;
161 - their filesystems are case-insensitive;
162 - directories in environment variables (like INFOPATH) are separated
163 by `;' rather than `:';
164 - text files can have their lines ended either with \n or with \r\n pairs;
165 These are all parameterized here except the last, which is
166 handled by the source code as appropriate (mostly, in info/). */
169 # define O_BINARY _O_BINARY
173 #endif /* O_BINARY */
175 /* We'd like to take advantage of _doprnt if it's around, a la error.c,
176 but then we'd have no VA_SPRINTF. */
180 # define VA_START(args, lastarg) va_start(args, lastarg)
182 # include <varargs.h>
183 # define VA_START(args, lastarg) va_start(args)
185 # define VA_FPRINTF(file, fmt, ap) vfprintf (file, fmt, ap)
186 # define VA_SPRINTF(str, fmt, ap) vsprintf (str, fmt, ap)
187 #else /* not HAVE_VPRINTF */
188 # define VA_START(args, lastarg)
189 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
190 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
191 # define va_end(args)
201 # define HAVE_LONG_FILENAMES(dir) (pathconf (dir, _PC_NAME_MAX) > 12)
202 # define NULL_DEVICE "/dev/null"
203 # define DEFAULT_INFOPATH "c:/djgpp/info;/usr/local/info;/usr/info;."
204 /* DJGPP supports /dev/null, which is okay for Unix aficionados,
205 shell scripts and Makefiles, but interactive DOS die-hards
206 would probably want to have NUL as well. */
207 # define ALSO_NULL_DEVICE "NUL"
208 # else /* O_BINARY && !__DJGPP__ */
209 # define HAVE_LONG_FILENAMES(dir) (0)
210 # define NULL_DEVICE "NUL"
211 # endif /* O_BINARY && !__DJGPP__ */
212 # define SET_SCREEN_SIZE_HELPER terminal_prep_terminal()
213 # define DEFAULT_INFO_PRINT_COMMAND ">PRN"
214 # else /* O_BINARY && !__MSDOS__ */
215 # define setmode(f,m) _setmode(f,m)
216 # define HAVE_LONG_FILENAMES(dir) (1)
217 # define NULL_DEVICE "NUL"
218 # endif /* O_BINARY && !__MSDOS__ */
220 # define DEFAULT_TMPDIR "/tmp/"
221 # define PATH_SEP ":"
222 # else /* O_BINARY && !__CYGWIN__ */
223 # define DEFAULT_TMPDIR "c:/"
224 # define PATH_SEP ";"
225 # endif /* O_BINARY && !__CYGWIN__ */
226 /* Back to any O_BINARY system. */
227 # define FILENAME_CMP strcasecmp
228 # define FILENAME_CMPN strncasecmp
229 # define FOPEN_RBIN "rb"
230 # define FOPEN_WBIN "wb"
231 # define HAVE_DRIVE(n) ((n)[0] && (n)[1] == ':')
232 # define IS_SLASH(c) ((c) == '/' || (c) == '\\')
233 # define IS_ABSOLUTE(n) (IS_SLASH((n)[0]) || ((n)[0] && (n)[1] == ':'))
234 # define PIPE_USE_FORK 0
235 # define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
236 # define STRIP_DOT_EXE 1
238 #else /* not O_BINARY, i.e., Unix */
239 # define SET_BINARY(f) (void)0
240 # define FOPEN_RBIN "r"
241 # define FOPEN_WBIN "w"
242 # define IS_SLASH(c) ((c) == '/')
243 # define HAVE_DRIVE(n) (0)
244 # define IS_ABSOLUTE(n) ((n)[0] == '/')
245 # define FILENAME_CMP strcmp
246 # define FILENAME_CMPN strncmp
247 # define HAVE_LONG_FILENAMES(dir) (1)
248 # define PATH_SEP ":"
249 # define STRIP_DOT_EXE 0
251 # define DEFAULT_TMPDIR "sys$scratch:"
253 # define DEFAULT_TMPDIR "/tmp/"
255 # define NULL_DEVICE "/dev/null"
256 # define PIPE_USE_FORK 1
257 #endif /* not O_BINARY */
259 /* Everything but DJGPP. */
260 #ifndef ALSO_NULL_DEVICE
261 # define ALSO_NULL_DEVICE ""
267 /* Some systems don't declare this function in pwd.h. */
268 struct passwd *getpwnam (const char *name);
270 /* Our library routines not included in any system library. */
271 extern void *xmalloc (size_t), *xrealloc (void *, size_t);
272 extern char *xstrdup (const char *);
273 extern void xexit (int);
275 /* For convenience. */
276 #define STREQ(s1,s2) (strcmp (s1, s2) == 0)
277 #define STRCASEEQ(s1,s2) (strcasecmp (s1, s2) == 0)
278 #define STRNCASEEQ(s1,s2,n) (strncasecmp (s1, s2, n) == 0)
280 /* We don't need anything fancy. If we did need something fancy, gnulib
285 #define MIN(a,b) ((a) < (b) ? (a) : (b))
289 #define MAX(a,b) ((a) > (b) ? (a) : (b))
291 #endif /* TEXINFO_SYSTEM_H */