1 /* system.h: system-dependent declarations; include this first.
2 $Id: system.h,v 1.22 2002/02/26 14:31:18 karl Exp $
4 Copyright (C) 1997, 98, 99, 00, 01, 02 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #ifndef TEXINFO_SYSTEM_H
21 #define TEXINFO_SYSTEM_H
27 /* <unistd.h> should be included before any preprocessor test
31 #endif /* HAVE_UNISTD_H */
34 #include <sys/types.h>
37 /* All systems nowadays probably have these functions, but ... */
41 #ifndef HAVE_SETLOCALE
42 #define setlocale(category,locale) /* empty */
45 /* For gettext (NLS). */
47 #define _(String) gettext (String)
48 #define N_(String) (String)
50 #ifndef HAVE_LC_MESSAGES
51 #define LC_MESSAGES (-1)
55 #define getopt system_getopt
59 extern char *getenv ();
62 /* Don't use bcopy! Use memmove if source and destination may overlap,
65 # if !STDC_HEADERS && HAVE_MEMORY_H
82 #ifndef HAVE_DECL_STRERROR
83 extern char *strerror ();
90 #ifndef _POSIX_PATH_MAX
91 # define _POSIX_PATH_MAX 255
93 #define PATH_MAX _POSIX_PATH_MAX
96 #ifndef HAVE_DECL_STRCASECMP
97 extern int strcasecmp ();
100 #ifndef HAVE_DECL_STRNCASECMP
101 extern int strncasecmp ();
104 #ifndef HAVE_DECL_STRCOLL
105 extern int strcoll ();
108 #include <sys/stat.h>
109 #if STAT_MACROS_BROKEN
112 #if !defined(S_ISDIR) && defined(S_IFDIR)
113 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
116 #ifdef HAVE_SYS_FILE_H
117 #include <sys/file.h>
118 #endif /* HAVE_SYS_FILE_H */
121 /* Since <fcntl.h> is POSIX, prefer that to <sys/fcntl.h>.
122 This also avoids some useless warnings on (at least) Linux. */
125 #else /* not HAVE_FCNTL_H */
126 #ifdef HAVE_SYS_FCNTL_H
127 #include <sys/fcntl.h>
128 #endif /* not HAVE_SYS_FCNTL_H */
129 #endif /* not HAVE_FCNTL_H */
130 #endif /* not O_RDONLY */
132 /* MS-DOS and similar non-Posix systems have some peculiarities:
133 - they distinguish between binary and text files;
134 - they use both `/' and `\\' as directory separator in file names;
135 - they can have a drive letter X: prepended to a file name;
136 - they have a separate root directory on each drive;
137 - their filesystems are case-insensitive;
138 - directories in environment variables (like INFOPATH) are separated
139 by `;' rather than `:';
140 - text files can have their lines ended either with \n or with \r\n pairs;
141 These are all parameterized here except the last, which is
142 handled by the source code as appropriate (mostly, in info/). */
145 # define O_BINARY _O_BINARY
149 #endif /* O_BINARY */
151 /* We'd like to take advantage of _doprnt if it's around, a la error.c,
152 but then we'd have no VA_SPRINTF. */
156 # define VA_START(args, lastarg) va_start(args, lastarg)
158 # include <varargs.h>
159 # define VA_START(args, lastarg) va_start(args)
161 # define VA_FPRINTF(file, fmt, ap) vfprintf (file, fmt, ap)
162 # define VA_SPRINTF(str, fmt, ap) vsprintf (str, fmt, ap)
163 #else /* not HAVE_VPRINTF */
164 # define VA_START(args, lastarg)
165 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
166 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
167 # define va_end(args)
177 # define HAVE_LONG_FILENAMES(dir) (pathconf (dir, _PC_NAME_MAX) > 12)
178 # define NULL_DEVICE "/dev/null"
179 # define DEFAULT_INFOPATH "c:/djgpp/info;/usr/local/info;/usr/info;."
180 # else /* !__DJGPP__ */
181 # define HAVE_LONG_FILENAMES(dir) (0)
182 # define NULL_DEVICE "NUL"
183 # endif /* !__DJGPP__ */
184 # define SET_SCREEN_SIZE_HELPER terminal_prep_terminal()
185 # define DEFAULT_INFO_PRINT_COMMAND ">PRN"
186 # else /* !__MSDOS__ */
187 # define setmode(f,m) _setmode(f,m)
188 # define HAVE_LONG_FILENAMES(dir) (1)
189 # define NULL_DEVICE "NUL"
190 # endif /* !__MSDOS__ */
191 # define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
192 # define FOPEN_RBIN "rb"
193 # define FOPEN_WBIN "wb"
194 # define IS_SLASH(c) ((c) == '/' || (c) == '\\')
195 # define HAVE_DRIVE(n) ((n)[0] && (n)[1] == ':')
196 # define IS_ABSOLUTE(n) (IS_SLASH((n)[0]) || ((n)[0] && (n)[1] == ':'))
197 # define FILENAME_CMP strcasecmp
198 # define FILENAME_CMPN strncasecmp
199 # define PATH_SEP ";"
200 # define STRIP_DOT_EXE 1
201 # define DEFAULT_TMPDIR "c:/"
202 # define PIPE_USE_FORK 0
203 #else /* not O_BINARY */
204 # define SET_BINARY(f) (void)0
205 # define FOPEN_RBIN "r"
206 # define FOPEN_WBIN "w"
207 # define IS_SLASH(c) ((c) == '/')
208 # define HAVE_DRIVE(n) (0)
209 # define IS_ABSOLUTE(n) ((n)[0] == '/')
210 # define FILENAME_CMP strcmp
211 # define FILENAME_CMPN strncmp
212 # define HAVE_LONG_FILENAMES(dir) (1)
213 # define PATH_SEP ":"
214 # define STRIP_DOT_EXE 0
216 # define DEFAULT_TMPDIR "sys$scratch:"
218 # define DEFAULT_TMPDIR "/tmp/"
220 # define NULL_DEVICE "/dev/null"
221 # define PIPE_USE_FORK 1
222 #endif /* not O_BINARY */
224 /* DJGPP supports /dev/null, which is okay for Unix aficionados,
225 shell scripts and Makefiles, but interactive DOS die-hards
226 would probably want to have NUL as well. */
228 # define ALSO_NULL_DEVICE "NUL"
230 # define ALSO_NULL_DEVICE ""
236 /* Some systems don't declare this function in pwd.h. */
237 struct passwd *getpwnam ();
239 /* Our library routines not included in any system library. */
240 extern void *xmalloc (), *xrealloc ();
241 extern char *xstrdup ();
242 extern void xexit ();
243 extern char *substring ();
245 /* For convenience. */
246 #define STREQ(s1,s2) (strcmp (s1, s2) == 0)
248 #endif /* TEXINFO_SYSTEM_H */