source: trunk/texinfo/lib/system.h@ 2619

Last change on this file since 2619 was 2619, checked in by bird, 19 years ago

applied OS/2 patches (manually).

File size: 8.6 KB
Line 
1/* system.h: system-dependent declarations; include this first.
2 $Id: system.h,v 1.12 2004/04/26 13:56:57 karl Exp $
3
4 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
5 Foundation, Inc.
6
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)
10 any later version.
11
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.
16
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. */
20
21#ifndef TEXINFO_SYSTEM_H
22#define TEXINFO_SYSTEM_H
23
24#define _GNU_SOURCE
25
26#include <config.h>
27
28#ifdef MIKTEX
29#include <gnu-miktex.h>
30#define S_ISDIR(x) ((x)&_S_IFDIR)
31#else
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. */
35extern char *substring (const char *, const char *);
36#endif
37
38/* We follow the order of header inclusion from Autoconf's
39 ac_includes_default, more or less. */
40#include <stdio.h>
41#include <sys/types.h>
42#include <ctype.h>
43
44/* All systems nowadays probably have these functions, but ... */
45#ifdef HAVE_LOCALE_H
46#include <locale.h>
47#endif
48#ifndef HAVE_SETLOCALE
49#define setlocale(category,locale) /* empty */
50#endif
51
52/* For gettext (NLS). */
53#define const
54#include "gettext.h"
55#undef const
56
57#define _(String) gettext (String)
58#define N_(String) (String)
59
60#ifdef STDC_HEADERS
61#define getopt system_getopt
62#include <stdlib.h>
63#undef getopt
64#else
65extern char *getenv ();
66#endif
67
68/* Don't use bcopy! Use memmove if source and destination may overlap,
69 memcpy otherwise. */
70#if HAVE_STRING_H
71# if !STDC_HEADERS && HAVE_MEMORY_H
72# include <memory.h>
73# endif
74# include <string.h>
75#endif
76
77#if HAVE_STRINGS_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. */
81# include <strings.h>
82#endif
83
84#if !HAVE_STRNCASECMP || !HAVE_STRCASECMP
85# include "strcase.h"
86#endif
87
88#if !HAVE_DECL_MEMCHR
89char *memchr ();
90#endif
91
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. */
94#ifdef HAVE_UNISTD_H
95#include <unistd.h>
96#endif /* HAVE_UNISTD_H */
97
98#include <errno.h>
99#ifndef errno
100extern int errno;
101#endif
102#ifdef VMS
103#include <perror.h>
104#endif
105
106#ifndef HAVE_DECL_STRERROR
107extern char *strerror ();
108#endif
109
110#ifdef HAVE_LIMITS_H
111#include <limits.h>
112#endif
113#ifndef PATH_MAX
114#ifndef _POSIX_PATH_MAX
115# define _POSIX_PATH_MAX 255
116#endif
117#define PATH_MAX _POSIX_PATH_MAX
118#endif
119
120#ifndef HAVE_DECL_STRCASECMP
121extern int strcasecmp ();
122#endif
123
124#ifndef HAVE_DECL_STRNCASECMP
125extern int strncasecmp ();
126#endif
127
128#ifndef HAVE_DECL_STRCOLL
129extern int strcoll ();
130#endif
131
132#include <sys/stat.h>
133#if STAT_MACROS_BROKEN
134# undef S_ISDIR
135#endif
136#if !defined(S_ISDIR) && defined(S_IFDIR)
137# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
138#endif
139
140#ifdef HAVE_SYS_FILE_H
141#include <sys/file.h>
142#endif /* HAVE_SYS_FILE_H */
143
144#ifndef O_RDONLY
145/* Since <fcntl.h> is POSIX, prefer that to <sys/fcntl.h>.
146 This also avoids some useless warnings on (at least) Linux. */
147#ifdef HAVE_FCNTL_H
148#include <fcntl.h>
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 */
155
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/). */
167#ifndef O_BINARY
168# ifdef _O_BINARY
169# define O_BINARY _O_BINARY
170# else
171# define O_BINARY 0
172# endif
173#endif /* O_BINARY */
174
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. */
177#if HAVE_VPRINTF
178# if __STDC__
179# include <stdarg.h>
180# define VA_START(args, lastarg) va_start(args, lastarg)
181# else
182# include <varargs.h>
183# define VA_START(args, lastarg) va_start(args)
184# endif
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)
192#endif
193
194#if O_BINARY
195# ifdef HAVE_IO_H
196# include <io.h>
197# endif
198# ifdef __MSDOS__
199# include <limits.h>
200# ifdef __DJGPP__
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# ifdef __EMX__
216# define NULL_DEVICE "nul"
217# define HAVE_LONG_FILENAMES(dir) (1)
218# define DEFAULT_INFO_PRINT_COMMAND "expand --tabs=4 >>InfoLog.tmp"
219# else
220# define setmode(f,m) _setmode(f,m)
221# define HAVE_LONG_FILENAMES(dir) (1)
222# define NULL_DEVICE "NUL"
223# endif /* !__EMX__ */
224# endif /* O_BINARY && !__MSDOS__ */
225# ifdef __CYGWIN__
226# define DEFAULT_TMPDIR "/tmp/"
227# define PATH_SEP ":"
228# else /* O_BINARY && !__CYGWIN__ */
229# define DEFAULT_TMPDIR "c:/"
230# define PATH_SEP ";"
231# endif /* O_BINARY && !__CYGWIN__ */
232 /* Back to any O_BINARY system. */
233# define FILENAME_CMP strcasecmp
234# define FILENAME_CMPN strncasecmp
235# define FOPEN_RBIN "rb"
236# define FOPEN_WBIN "wb"
237# ifdef __EMX__ /* bird - start */
238# define FOPEN_RTXT "rt"
239# define FOPEN_WTXT "wt"
240# else
241# define FOPEN_RTXT "r"
242# define FOPEN_WTXT "w"
243# endif /* bird - end */
244# define HAVE_DRIVE(n) ((n)[0] && (n)[1] == ':')
245# define IS_SLASH(c) ((c) == '/' || (c) == '\\')
246# define IS_ABSOLUTE(n) (IS_SLASH((n)[0]) || ((n)[0] && (n)[1] == ':'))
247# define PIPE_USE_FORK 0
248# define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
249# define STRIP_DOT_EXE 1
250
251#else /* not O_BINARY, i.e., Unix */
252# define SET_BINARY(f) (void)0
253# define FOPEN_RBIN "r"
254# define FOPEN_WBIN "w"
255# define FOPEN_RTXT "r" /* bird */
256# define FOPEN_WTXT "w" /* bird */
257# define IS_SLASH(c) ((c) == '/')
258# define HAVE_DRIVE(n) (0)
259# define IS_ABSOLUTE(n) ((n)[0] == '/')
260# define FILENAME_CMP strcmp
261# define FILENAME_CMPN strncmp
262# define HAVE_LONG_FILENAMES(dir) (1)
263# define PATH_SEP ":"
264# define STRIP_DOT_EXE 0
265# ifdef VMS
266# define DEFAULT_TMPDIR "sys$scratch:"
267# else
268# define DEFAULT_TMPDIR "/tmp/"
269# endif
270# define NULL_DEVICE "/dev/null"
271# define PIPE_USE_FORK 1
272#endif /* not O_BINARY */
273
274/* Everything but DJGPP. */
275#ifndef ALSO_NULL_DEVICE
276# define ALSO_NULL_DEVICE ""
277#endif
278
279#ifdef HAVE_PWD_H
280#include <pwd.h>
281#endif
282/* Some systems don't declare this function in pwd.h. */
283struct passwd *getpwnam (const char *name);
284
285/* Our library routines not included in any system library. */
286extern void *xmalloc (size_t), *xrealloc (void *, size_t);
287extern char *xstrdup (const char *);
288extern void xexit (int);
289
290/* For convenience. */
291#define STREQ(s1,s2) (strcmp (s1, s2) == 0)
292#define STRCASEEQ(s1,s2) (strcasecmp (s1, s2) == 0)
293#define STRNCASEEQ(s1,s2,n) (strncasecmp (s1, s2, n) == 0)
294
295/* We don't need anything fancy. If we did need something fancy, gnulib
296 has it. */
297#ifdef MIN
298#undef MIN
299#endif
300#define MIN(a,b) ((a) < (b) ? (a) : (b))
301#ifdef MAX
302#undef MAX
303#endif
304#define MAX(a,b) ((a) > (b) ? (a) : (b))
305
306#endif /* TEXINFO_SYSTEM_H */
Note: See TracBrowser for help on using the repository browser.