1 /* $NetBSD: system.h,v 1.10 2008/09/09 06:32:59 lukem Exp $ */
3 /* system.h: system-dependent declarations; include this first.
4 Id: system.h,v 1.12 2004/04/26 13:56:57 karl Exp
6 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #ifndef TEXINFO_SYSTEM_H
24 #define TEXINFO_SYSTEM_H
31 #include <gnu-miktex.h>
32 #define S_ISDIR(x) ((x)&_S_IFDIR)
34 /* MiKTeX defines substring() in a separate DLL, where it has its
35 own __declspec declaration. We don't want to try to duplicate
36 this Microsoft-ism here. */
37 extern char *substring (const char *, const char *);
40 /* We follow the order of header inclusion from Autoconf's
41 ac_includes_default, more or less. */
43 #include <sys/types.h>
46 /* All systems nowadays probably have these functions, but ... */
50 #ifndef HAVE_SETLOCALE
51 #define setlocale(category,locale) /* empty */
54 /* For gettext (NLS). */
59 #define _(String) gettext (String)
60 #define N_(String) (String)
63 #define getopt system_getopt
67 extern char *getenv ();
70 /* Don't use bcopy! Use memmove if source and destination may overlap,
73 # if !STDC_HEADERS && HAVE_MEMORY_H
80 /* Always include <strings.h> if we have it. This is because that's
81 what Autoconf's AC_CHECK_DECL does. On IBM AIX 4.2, strncasecmp is
82 only declared in strings.h. */
86 #if !HAVE_STRNCASECMP || !HAVE_STRCASECMP
94 /* <unistd.h> defines _POSIX_VERSION, but Paul Eggert points out that is
95 only supposed to be used in user code, not other system headers. */
98 #endif /* HAVE_UNISTD_H */
108 #ifndef HAVE_DECL_STRERROR
109 extern char *strerror ();
116 #ifndef _POSIX_PATH_MAX
117 # define _POSIX_PATH_MAX 255
119 #define PATH_MAX _POSIX_PATH_MAX
122 #ifndef HAVE_DECL_STRCASECMP
123 extern int strcasecmp ();
126 #ifndef HAVE_DECL_STRNCASECMP
127 extern int strncasecmp ();
130 #ifndef HAVE_DECL_STRCOLL
131 extern int strcoll ();
134 #include <sys/stat.h>
135 #if STAT_MACROS_BROKEN
138 #if !defined(S_ISDIR) && defined(S_IFDIR)
139 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
142 #ifdef HAVE_SYS_FILE_H
143 #include <sys/file.h>
144 #endif /* HAVE_SYS_FILE_H */
147 /* Since <fcntl.h> is POSIX, prefer that to <sys/fcntl.h>.
148 This also avoids some useless warnings on (at least) Linux. */
151 #else /* not HAVE_FCNTL_H */
152 #ifdef HAVE_SYS_FCNTL_H
153 #include <sys/fcntl.h>
154 #endif /* not HAVE_SYS_FCNTL_H */
155 #endif /* not HAVE_FCNTL_H */
156 #endif /* not O_RDONLY */
158 /* MS-DOS and similar non-Posix systems have some peculiarities:
159 - they distinguish between binary and text files;
160 - they use both `/' and `\\' as directory separator in file names;
161 - they can have a drive letter X: prepended to a file name;
162 - they have a separate root directory on each drive;
163 - their filesystems are case-insensitive;
164 - directories in environment variables (like INFOPATH) are separated
165 by `;' rather than `:';
166 - text files can have their lines ended either with \n or with \r\n pairs;
167 These are all parameterized here except the last, which is
168 handled by the source code as appropriate (mostly, in info/). */
171 # define O_BINARY _O_BINARY
175 #endif /* O_BINARY */
177 /* We'd like to take advantage of _doprnt if it's around, a la error.c,
178 but then we'd have no VA_SPRINTF. */
182 # define VA_START(args, lastarg) va_start(args, lastarg)
184 # include <varargs.h>
185 # define VA_START(args, lastarg) va_start(args)
187 # define VA_FPRINTF(file, fmt, ap) vfprintf (file, fmt, ap)
188 # define VA_SPRINTF(str, fmt, ap) vsprintf (str, fmt, ap)
189 #else /* not HAVE_VPRINTF */
190 # define VA_START(args, lastarg)
191 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
192 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
193 # define va_end(args)
203 # define HAVE_LONG_FILENAMES(dir) (pathconf (dir, _PC_NAME_MAX) > 12)
204 # define NULL_DEVICE "/dev/null"
205 # define DEFAULT_INFOPATH "c:/djgpp/info;/usr/local/info;/usr/info;."
206 /* DJGPP supports /dev/null, which is okay for Unix aficionados,
207 shell scripts and Makefiles, but interactive DOS die-hards
208 would probably want to have NUL as well. */
209 # define ALSO_NULL_DEVICE "NUL"
210 # else /* O_BINARY && !__DJGPP__ */
211 # define HAVE_LONG_FILENAMES(dir) (0)
212 # define NULL_DEVICE "NUL"
213 # endif /* O_BINARY && !__DJGPP__ */
214 # define SET_SCREEN_SIZE_HELPER terminal_prep_terminal()
215 # define DEFAULT_INFO_PRINT_COMMAND ">PRN"
216 # else /* O_BINARY && !__MSDOS__ */
217 # define setmode(f,m) _setmode(f,m)
218 # define HAVE_LONG_FILENAMES(dir) (1)
219 # define NULL_DEVICE "NUL"
220 # endif /* O_BINARY && !__MSDOS__ */
222 # define DEFAULT_TMPDIR "/tmp/"
223 # define PATH_SEP ":"
224 # else /* O_BINARY && !__CYGWIN__ */
225 # define DEFAULT_TMPDIR "c:/"
226 # define PATH_SEP ";"
227 # endif /* O_BINARY && !__CYGWIN__ */
228 /* Back to any O_BINARY system. */
229 # define FILENAME_CMP strcasecmp
230 # define FILENAME_CMPN strncasecmp
231 # define FOPEN_RBIN "rb"
232 # define FOPEN_WBIN "wb"
233 # define HAVE_DRIVE(n) ((n)[0] && (n)[1] == ':')
234 # define IS_SLASH(c) ((c) == '/' || (c) == '\\')
235 # define IS_ABSOLUTE(n) (IS_SLASH((n)[0]) || ((n)[0] && (n)[1] == ':'))
236 # define PIPE_USE_FORK 0
237 # define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
238 # define STRIP_DOT_EXE 1
240 #else /* not O_BINARY, i.e., Unix */
241 # define SET_BINARY(f) (void)0
242 # define FOPEN_RBIN "r"
243 # define FOPEN_WBIN "w"
244 # define IS_SLASH(c) ((c) == '/')
245 # define HAVE_DRIVE(n) (0)
246 # define IS_ABSOLUTE(n) ((n)[0] == '/')
247 # define FILENAME_CMP strcmp
248 # define FILENAME_CMPN strncmp
249 # define HAVE_LONG_FILENAMES(dir) (1)
250 # define PATH_SEP ":"
251 # define STRIP_DOT_EXE 0
253 # define DEFAULT_TMPDIR "sys$scratch:"
255 # define DEFAULT_TMPDIR "/tmp/"
257 # define NULL_DEVICE "/dev/null"
258 # define PIPE_USE_FORK 1
259 #endif /* not O_BINARY */
261 /* Everything but DJGPP. */
262 #ifndef ALSO_NULL_DEVICE
263 # define ALSO_NULL_DEVICE ""
269 /* Some systems don't declare this function in pwd.h. */
270 struct passwd
*getpwnam (const char *name
);
276 /* Our library routines not included in any system library. */
277 extern void *xmalloc (size_t), *xrealloc (void *, size_t);
278 extern char *xstrdup (const char *);
279 extern void xexit (int);
281 /* For convenience. */
282 #define STREQ(s1,s2) (strcmp (s1, s2) == 0)
283 #define STRCASEEQ(s1,s2) (strcasecmp (s1, s2) == 0)
284 #define STRNCASEEQ(s1,s2,n) (strncasecmp (s1, s2, n) == 0)
286 /* We don't need anything fancy. If we did need something fancy, gnulib
291 #define MIN(a,b) ((a) < (b) ? (a) : (b))
295 #define MAX(a,b) ((a) > (b) ? (a) : (b))
297 #endif /* TEXINFO_SYSTEM_H */