xref: /aosp_15_r20/external/mtools/sysincludes.h (revision d5c9a868b113e0ec0db2f27bc2ce8a253e77c4b0)
1*d5c9a868SElliott Hughes /*  Copyright 1996-1999,2001,2002,2007-2009 Alain Knaff.
2*d5c9a868SElliott Hughes  *  This file is part of mtools.
3*d5c9a868SElliott Hughes  *
4*d5c9a868SElliott Hughes  *  Mtools is free software: you can redistribute it and/or modify
5*d5c9a868SElliott Hughes  *  it under the terms of the GNU General Public License as published by
6*d5c9a868SElliott Hughes  *  the Free Software Foundation, either version 3 of the License, or
7*d5c9a868SElliott Hughes  *  (at your option) any later version.
8*d5c9a868SElliott Hughes  *
9*d5c9a868SElliott Hughes  *  Mtools is distributed in the hope that it will be useful,
10*d5c9a868SElliott Hughes  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11*d5c9a868SElliott Hughes  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*d5c9a868SElliott Hughes  *  GNU General Public License for more details.
13*d5c9a868SElliott Hughes  *
14*d5c9a868SElliott Hughes  *  You should have received a copy of the GNU General Public License
15*d5c9a868SElliott Hughes  *  along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
16*d5c9a868SElliott Hughes  *
17*d5c9a868SElliott Hughes  * System includes for mtools
18*d5c9a868SElliott Hughes  */
19*d5c9a868SElliott Hughes 
20*d5c9a868SElliott Hughes #ifndef SYSINCLUDES_H
21*d5c9a868SElliott Hughes #define SYSINCLUDES_H
22*d5c9a868SElliott Hughes 
23*d5c9a868SElliott Hughes #define _GNU_SOURCE
24*d5c9a868SElliott Hughes 
25*d5c9a868SElliott Hughes #include "config.h"
26*d5c9a868SElliott Hughes 
27*d5c9a868SElliott Hughes 
28*d5c9a868SElliott Hughes /* OS/2 needs __inline__, but for some reason is not autodetected */
29*d5c9a868SElliott Hughes #ifdef __EMX__
30*d5c9a868SElliott Hughes # ifndef inline
31*d5c9a868SElliott Hughes #  define inline __inline__
32*d5c9a868SElliott Hughes # endif
33*d5c9a868SElliott Hughes #endif
34*d5c9a868SElliott Hughes 
35*d5c9a868SElliott Hughes /***********************************************************************/
36*d5c9a868SElliott Hughes /*                                                                     */
37*d5c9a868SElliott Hughes /* OS dependencies which cannot be covered by the autoconfigure script */
38*d5c9a868SElliott Hughes /*                                                                     */
39*d5c9a868SElliott Hughes /***********************************************************************/
40*d5c9a868SElliott Hughes 
41*d5c9a868SElliott Hughes 
42*d5c9a868SElliott Hughes #ifdef OS_aux
43*d5c9a868SElliott Hughes /* A/UX needs POSIX_SOURCE, just as AIX does. Unlike SCO and AIX, it seems
44*d5c9a868SElliott Hughes  * to prefer TERMIO over TERMIOS */
45*d5c9a868SElliott Hughes #ifndef _POSIX_SOURCE
46*d5c9a868SElliott Hughes # define _POSIX_SOURCE
47*d5c9a868SElliott Hughes #endif
48*d5c9a868SElliott Hughes #ifndef POSIX_SOURCE
49*d5c9a868SElliott Hughes # define POSIX_SOURCE
50*d5c9a868SElliott Hughes #endif
51*d5c9a868SElliott Hughes 
52*d5c9a868SElliott Hughes #endif
53*d5c9a868SElliott Hughes 
54*d5c9a868SElliott Hughes 
55*d5c9a868SElliott Hughes /* On AIX, we have to prefer strings.h, as string.h lacks a prototype
56*d5c9a868SElliott Hughes  * for strcasecmp. On Solaris, string.h lacks a prototype for strncasecmp_l.
57*d5c9a868SElliott Hughes  * On most other architectures, it's string.h which seems to be more complete */
58*d5c9a868SElliott Hughes #if ((defined OS_aix || defined OS_solaris) && defined HAVE_STRINGS_H)
59*d5c9a868SElliott Hughes # undef HAVE_STRING_H
60*d5c9a868SElliott Hughes #endif
61*d5c9a868SElliott Hughes 
62*d5c9a868SElliott Hughes 
63*d5c9a868SElliott Hughes #ifdef OS_ultrix
64*d5c9a868SElliott Hughes /* on ultrix, if termios present, prefer it instead of termio */
65*d5c9a868SElliott Hughes # ifdef HAVE_TERMIOS_H
66*d5c9a868SElliott Hughes #  undef HAVE_TERMIO_H
67*d5c9a868SElliott Hughes # endif
68*d5c9a868SElliott Hughes #endif
69*d5c9a868SElliott Hughes 
70*d5c9a868SElliott Hughes #ifdef OS_linux_gnu
71*d5c9a868SElliott Hughes /* RMS strikes again */
72*d5c9a868SElliott Hughes # ifndef OS_linux
73*d5c9a868SElliott Hughes #  define OS_linux
74*d5c9a868SElliott Hughes # endif
75*d5c9a868SElliott Hughes #endif
76*d5c9a868SElliott Hughes 
77*d5c9a868SElliott Hughes /* For compiling with MingW, use the following configure line
78*d5c9a868SElliott Hughes 
79*d5c9a868SElliott Hughes ac_cv_func_setpgrp_void=yes ../mtools/configure --build=i386-linux-gnu --host=i386-mingw32 --disable-floppyd --without-x --disable-raw-term --srcdir ../mtools
80*d5c9a868SElliott Hughes 
81*d5c9a868SElliott Hughes  */
82*d5c9a868SElliott Hughes #ifdef OS_mingw32
83*d5c9a868SElliott Hughes #ifndef OS_mingw32msvc
84*d5c9a868SElliott Hughes #define OS_mingw32msvc
85*d5c9a868SElliott Hughes #endif
86*d5c9a868SElliott Hughes #endif
87*d5c9a868SElliott Hughes 
88*d5c9a868SElliott Hughes #ifndef HAVE_CADDR_T
89*d5c9a868SElliott Hughes typedef void *caddr_t;
90*d5c9a868SElliott Hughes #endif
91*d5c9a868SElliott Hughes 
92*d5c9a868SElliott Hughes 
93*d5c9a868SElliott Hughes /***********************************************************************/
94*d5c9a868SElliott Hughes /*                                                                     */
95*d5c9a868SElliott Hughes /* Compiler dependencies                                               */
96*d5c9a868SElliott Hughes /*                                                                     */
97*d5c9a868SElliott Hughes /***********************************************************************/
98*d5c9a868SElliott Hughes 
99*d5c9a868SElliott Hughes 
100*d5c9a868SElliott Hughes #if defined __GNUC__ && defined __STDC__
101*d5c9a868SElliott Hughes /* gcc -traditional doesn't have PACKED, UNUSED and NORETURN */
102*d5c9a868SElliott Hughes # define PACKED __attribute__ ((packed))
103*d5c9a868SElliott Hughes # if __GNUC__ == 2 && __GNUC_MINOR__ > 6 || __GNUC__ >= 3
104*d5c9a868SElliott Hughes /* gcc 2.6.3 doesn't have "unused" */		/* mool */
105*d5c9a868SElliott Hughes #  define UNUSED(x) x __attribute__ ((unused));x
106*d5c9a868SElliott Hughes #  define UNUSEDP __attribute__ ((unused))
107*d5c9a868SElliott Hughes # endif
108*d5c9a868SElliott Hughes # define NORETURN __attribute__ ((noreturn))
109*d5c9a868SElliott Hughes # if __GNUC__ >= 8
110*d5c9a868SElliott Hughes #  define NONULLTERM __attribute__ ((nonstring))
111*d5c9a868SElliott Hughes # endif
112*d5c9a868SElliott Hughes #endif
113*d5c9a868SElliott Hughes 
114*d5c9a868SElliott Hughes #ifndef UNUSED
115*d5c9a868SElliott Hughes # define UNUSED(x) x
116*d5c9a868SElliott Hughes # define UNUSEDP /* */
117*d5c9a868SElliott Hughes #endif
118*d5c9a868SElliott Hughes 
119*d5c9a868SElliott Hughes #ifndef PACKED
120*d5c9a868SElliott Hughes # define PACKED /* */
121*d5c9a868SElliott Hughes #endif
122*d5c9a868SElliott Hughes 
123*d5c9a868SElliott Hughes #ifndef NORETURN
124*d5c9a868SElliott Hughes # define NORETURN /* */
125*d5c9a868SElliott Hughes #endif
126*d5c9a868SElliott Hughes 
127*d5c9a868SElliott Hughes #ifndef NONULLTERM
128*d5c9a868SElliott Hughes # define NONULLTERM /* */
129*d5c9a868SElliott Hughes #endif
130*d5c9a868SElliott Hughes 
131*d5c9a868SElliott Hughes /***********************************************************************/
132*d5c9a868SElliott Hughes /*                                                                     */
133*d5c9a868SElliott Hughes /* Include files                                                       */
134*d5c9a868SElliott Hughes /*                                                                     */
135*d5c9a868SElliott Hughes /***********************************************************************/
136*d5c9a868SElliott Hughes 
137*d5c9a868SElliott Hughes #ifdef HAVE_ASSERT_H
138*d5c9a868SElliott Hughes # include <assert.h>
139*d5c9a868SElliott Hughes #endif
140*d5c9a868SElliott Hughes 
141*d5c9a868SElliott Hughes #ifdef HAVE_FEATURES_H
142*d5c9a868SElliott Hughes # include <features.h>
143*d5c9a868SElliott Hughes #endif
144*d5c9a868SElliott Hughes 
145*d5c9a868SElliott Hughes 
146*d5c9a868SElliott Hughes #include <sys/types.h>
147*d5c9a868SElliott Hughes 
148*d5c9a868SElliott Hughes #ifdef HAVE_STDINT_H
149*d5c9a868SElliott Hughes # include <stdint.h>
150*d5c9a868SElliott Hughes #endif
151*d5c9a868SElliott Hughes 
152*d5c9a868SElliott Hughes #ifdef HAVE_STDARG_H
153*d5c9a868SElliott Hughes # include <stdarg.h>
154*d5c9a868SElliott Hughes #endif
155*d5c9a868SElliott Hughes 
156*d5c9a868SElliott Hughes #if HAVE_STDBOOL_H
157*d5c9a868SElliott Hughes # include <stdbool.h>
158*d5c9a868SElliott Hughes #else
159*d5c9a868SElliott Hughes # if ! HAVE__BOOL
160*d5c9a868SElliott Hughes #  ifdef __cplusplus
161*d5c9a868SElliott Hughes typedef bool _Bool;
162*d5c9a868SElliott Hughes #   else
163*d5c9a868SElliott Hughes typedef unsigned char _Bool;
164*d5c9a868SElliott Hughes #  endif
165*d5c9a868SElliott Hughes # endif
166*d5c9a868SElliott Hughes # define bool _Bool
167*d5c9a868SElliott Hughes # define false 0
168*d5c9a868SElliott Hughes # define true 1
169*d5c9a868SElliott Hughes # define __bool_true_false_are_defined 1
170*d5c9a868SElliott Hughes #endif
171*d5c9a868SElliott Hughes 
172*d5c9a868SElliott Hughes #ifdef HAVE_INTTYPES_H
173*d5c9a868SElliott Hughes # include <inttypes.h>
174*d5c9a868SElliott Hughes #endif
175*d5c9a868SElliott Hughes 
176*d5c9a868SElliott Hughes #ifdef HAVE_STDLIB_H
177*d5c9a868SElliott Hughes # include <stdlib.h>
178*d5c9a868SElliott Hughes #endif
179*d5c9a868SElliott Hughes 
180*d5c9a868SElliott Hughes #include <stdio.h>
181*d5c9a868SElliott Hughes #include <ctype.h>
182*d5c9a868SElliott Hughes 
183*d5c9a868SElliott Hughes #ifdef HAVE_UNISTD_H
184*d5c9a868SElliott Hughes # include <unistd.h>
185*d5c9a868SElliott Hughes #endif
186*d5c9a868SElliott Hughes 
187*d5c9a868SElliott Hughes #ifdef HAVE_LINUX_UNISTD_H
188*d5c9a868SElliott Hughes # include <linux/unistd.h>
189*d5c9a868SElliott Hughes #endif
190*d5c9a868SElliott Hughes 
191*d5c9a868SElliott Hughes #ifdef HAVE_LIBC_H
192*d5c9a868SElliott Hughes # include <libc.h>
193*d5c9a868SElliott Hughes #endif
194*d5c9a868SElliott Hughes 
195*d5c9a868SElliott Hughes #ifdef HAVE_GETOPT_H
196*d5c9a868SElliott Hughes # include <getopt.h>
197*d5c9a868SElliott Hughes #endif
198*d5c9a868SElliott Hughes 
199*d5c9a868SElliott Hughes #ifdef HAVE_FCNTL_H
200*d5c9a868SElliott Hughes # include <fcntl.h>
201*d5c9a868SElliott Hughes #endif
202*d5c9a868SElliott Hughes 
203*d5c9a868SElliott Hughes #ifdef HAVE_LIMITS_H
204*d5c9a868SElliott Hughes # include <limits.h>
205*d5c9a868SElliott Hughes #endif
206*d5c9a868SElliott Hughes 
207*d5c9a868SElliott Hughes #ifdef HAVE_SYS_FILE_H
208*d5c9a868SElliott Hughes # include <sys/file.h>
209*d5c9a868SElliott Hughes #endif
210*d5c9a868SElliott Hughes 
211*d5c9a868SElliott Hughes #ifdef HAVE_SYS_IOCTL_H
212*d5c9a868SElliott Hughes # ifndef sunos
213*d5c9a868SElliott Hughes # include <sys/ioctl.h>
214*d5c9a868SElliott Hughes #endif
215*d5c9a868SElliott Hughes #endif
216*d5c9a868SElliott Hughes /* if we don't have sys/ioctl.h, we rely on unistd to supply a prototype
217*d5c9a868SElliott Hughes  * for it. If it doesn't, we'll only get a (harmless) warning. The idea
218*d5c9a868SElliott Hughes  * is to get mtools compile on as many platforms as possible, but to not
219*d5c9a868SElliott Hughes  * suppress warnings if the platform is broken, as long as these warnings do
220*d5c9a868SElliott Hughes  * not prevent compilation */
221*d5c9a868SElliott Hughes 
222*d5c9a868SElliott Hughes #ifdef TIME_WITH_SYS_TIME
223*d5c9a868SElliott Hughes # include <sys/time.h>
224*d5c9a868SElliott Hughes # include <time.h>
225*d5c9a868SElliott Hughes #else
226*d5c9a868SElliott Hughes # ifdef HAVE_SYS_TIME_H
227*d5c9a868SElliott Hughes #  include <sys/time.h>
228*d5c9a868SElliott Hughes # else
229*d5c9a868SElliott Hughes #  include <time.h>
230*d5c9a868SElliott Hughes # endif
231*d5c9a868SElliott Hughes #endif
232*d5c9a868SElliott Hughes 
233*d5c9a868SElliott Hughes #ifndef NO_TERMIO
234*d5c9a868SElliott Hughes # ifdef HAVE_TERMIO_H
235*d5c9a868SElliott Hughes #  include <termio.h>
236*d5c9a868SElliott Hughes # elif defined HAVE_SYS_TERMIO_H
237*d5c9a868SElliott Hughes #  include <sys/termio.h>
238*d5c9a868SElliott Hughes # endif
239*d5c9a868SElliott Hughes # if !defined OS_ultrix || !(defined HAVE_TERMIO_H || defined HAVE_TERMIO_H)
240*d5c9a868SElliott Hughes /* on Ultrix, avoid double inclusion of both termio and termios */
241*d5c9a868SElliott Hughes #  ifdef HAVE_TERMIOS_H
242*d5c9a868SElliott Hughes #   include <termios.h>
243*d5c9a868SElliott Hughes #  elif defined HAVE_SYS_TERMIOS_H
244*d5c9a868SElliott Hughes #   include <sys/termios.h>
245*d5c9a868SElliott Hughes #  endif
246*d5c9a868SElliott Hughes # endif
247*d5c9a868SElliott Hughes # ifdef HAVE_STTY_H
248*d5c9a868SElliott Hughes #  include <sgtty.h>
249*d5c9a868SElliott Hughes # endif
250*d5c9a868SElliott Hughes #endif
251*d5c9a868SElliott Hughes 
252*d5c9a868SElliott Hughes 
253*d5c9a868SElliott Hughes #if defined(OS_aux) && !defined(_SYSV_SOURCE)
254*d5c9a868SElliott Hughes /* compiled in POSIX mode, this is left out unless SYSV */
255*d5c9a868SElliott Hughes #define	NCC	8
256*d5c9a868SElliott Hughes struct termio {
257*d5c9a868SElliott Hughes 	unsigned short	c_iflag;	/* input modes */
258*d5c9a868SElliott Hughes 	unsigned short	c_oflag;	/* output modes */
259*d5c9a868SElliott Hughes 	unsigned short	c_cflag;	/* control modes */
260*d5c9a868SElliott Hughes 	unsigned short	c_lflag;	/* line discipline modes */
261*d5c9a868SElliott Hughes 	char	c_line;			/* line discipline */
262*d5c9a868SElliott Hughes 	unsigned char	c_cc[NCC];	/* control chars */
263*d5c9a868SElliott Hughes };
264*d5c9a868SElliott Hughes extern int ioctl(int fildes, int request, void *arg);
265*d5c9a868SElliott Hughes #endif
266*d5c9a868SElliott Hughes 
267*d5c9a868SElliott Hughes 
268*d5c9a868SElliott Hughes #ifdef HAVE_MNTENT_H
269*d5c9a868SElliott Hughes # include <mntent.h>
270*d5c9a868SElliott Hughes #endif
271*d5c9a868SElliott Hughes 
272*d5c9a868SElliott Hughes #ifdef HAVE_SYS_PARAM_H
273*d5c9a868SElliott Hughes # include <sys/param.h>
274*d5c9a868SElliott Hughes #endif
275*d5c9a868SElliott Hughes 
276*d5c9a868SElliott Hughes /* Can only be done here, as BSD is defined in sys/param.h :-( */
277*d5c9a868SElliott Hughes #if defined BSD || defined __BEOS__
278*d5c9a868SElliott Hughes /* on BSD and on BEOS, we prefer gettimeofday, ... */
279*d5c9a868SElliott Hughes # ifdef HAVE_GETTIMEOFDAY
280*d5c9a868SElliott Hughes #  undef HAVE_TZSET
281*d5c9a868SElliott Hughes # endif
282*d5c9a868SElliott Hughes #else /* BSD */
283*d5c9a868SElliott Hughes /* ... elsewhere we prefer tzset */
284*d5c9a868SElliott Hughes # ifdef HAVE_TZSET
285*d5c9a868SElliott Hughes #  undef HAVE_GETTIMEOFDAY
286*d5c9a868SElliott Hughes # endif
287*d5c9a868SElliott Hughes #endif
288*d5c9a868SElliott Hughes 
289*d5c9a868SElliott Hughes 
290*d5c9a868SElliott Hughes #include <sys/stat.h>
291*d5c9a868SElliott Hughes 
292*d5c9a868SElliott Hughes #include <errno.h>
293*d5c9a868SElliott Hughes #ifndef errno
294*d5c9a868SElliott Hughes extern int errno;
295*d5c9a868SElliott Hughes #endif
296*d5c9a868SElliott Hughes 
297*d5c9a868SElliott Hughes #ifndef OS_mingw32msvc
298*d5c9a868SElliott Hughes #include <pwd.h>
299*d5c9a868SElliott Hughes #endif
300*d5c9a868SElliott Hughes 
301*d5c9a868SElliott Hughes 
302*d5c9a868SElliott Hughes #ifdef HAVE_STRING_H
303*d5c9a868SElliott Hughes # include <string.h>
304*d5c9a868SElliott Hughes #else
305*d5c9a868SElliott Hughes # ifdef HAVE_STRINGS_H
306*d5c9a868SElliott Hughes #  include <strings.h>
307*d5c9a868SElliott Hughes # endif
308*d5c9a868SElliott Hughes #endif
309*d5c9a868SElliott Hughes 
310*d5c9a868SElliott Hughes #ifdef HAVE_MEMORY_H
311*d5c9a868SElliott Hughes # include <memory.h>
312*d5c9a868SElliott Hughes #endif
313*d5c9a868SElliott Hughes 
314*d5c9a868SElliott Hughes #ifdef HAVE_MALLOC_H
315*d5c9a868SElliott Hughes # include <malloc.h>
316*d5c9a868SElliott Hughes #endif
317*d5c9a868SElliott Hughes 
318*d5c9a868SElliott Hughes #ifdef HAVE_IO_H
319*d5c9a868SElliott Hughes # include <io.h>
320*d5c9a868SElliott Hughes #endif
321*d5c9a868SElliott Hughes 
322*d5c9a868SElliott Hughes #ifdef HAVE_SIGNAL_H
323*d5c9a868SElliott Hughes # include <signal.h>
324*d5c9a868SElliott Hughes #else
325*d5c9a868SElliott Hughes # ifdef HAVE_SYS_SIGNAL_H
326*d5c9a868SElliott Hughes #  include <sys/signal.h>
327*d5c9a868SElliott Hughes # endif
328*d5c9a868SElliott Hughes #endif
329*d5c9a868SElliott Hughes 
330*d5c9a868SElliott Hughes #ifdef HAVE_UTIME_H
331*d5c9a868SElliott Hughes # include <utime.h>
332*d5c9a868SElliott Hughes #endif
333*d5c9a868SElliott Hughes 
334*d5c9a868SElliott Hughes #ifdef HAVE_SYS_WAIT_H
335*d5c9a868SElliott Hughes # ifndef DONT_NEED_WAIT
336*d5c9a868SElliott Hughes #  include <sys/wait.h>
337*d5c9a868SElliott Hughes # endif
338*d5c9a868SElliott Hughes #endif
339*d5c9a868SElliott Hughes 
340*d5c9a868SElliott Hughes #ifdef HAVE_WCHAR_H
341*d5c9a868SElliott Hughes # include <wchar.h>
342*d5c9a868SElliott Hughes # ifndef HAVE_PUTWC
343*d5c9a868SElliott Hughes #  define putwc(c,f) fprintf((f),"%lc",(c))
344*d5c9a868SElliott Hughes # endif
345*d5c9a868SElliott Hughes #else
346*d5c9a868SElliott Hughes # define wcscmp strcmp
347*d5c9a868SElliott Hughes # define wcscasecmp strcasecmp
348*d5c9a868SElliott Hughes # define wcsdup strdup
349*d5c9a868SElliott Hughes # define wcslen strlen
350*d5c9a868SElliott Hughes # define wcschr strchr
351*d5c9a868SElliott Hughes # define wcspbrk strpbrk
352*d5c9a868SElliott Hughes # define wchar_t char
353*d5c9a868SElliott Hughes # define putwc putc
354*d5c9a868SElliott Hughes #endif
355*d5c9a868SElliott Hughes 
356*d5c9a868SElliott Hughes #ifdef HAVE_WCTYPE_H
357*d5c9a868SElliott Hughes # include <wctype.h>
358*d5c9a868SElliott Hughes #else
359*d5c9a868SElliott Hughes # define towupper(x) toupper(x)
360*d5c9a868SElliott Hughes # define towlower(x) tolower(x)
361*d5c9a868SElliott Hughes # define iswupper(x) isupper(x)
362*d5c9a868SElliott Hughes # define iswlower(x) islower(x)
363*d5c9a868SElliott Hughes # define iswcntrl(x) iscntrl(x)
364*d5c9a868SElliott Hughes #endif
365*d5c9a868SElliott Hughes 
366*d5c9a868SElliott Hughes #ifdef HAVE_LOCALE_H
367*d5c9a868SElliott Hughes # include <locale.h>
368*d5c9a868SElliott Hughes #endif
369*d5c9a868SElliott Hughes 
370*d5c9a868SElliott Hughes #ifdef HAVE_XLOCALE_H
371*d5c9a868SElliott Hughes # include <xlocale.h>
372*d5c9a868SElliott Hughes #endif
373*d5c9a868SElliott Hughes 
374*d5c9a868SElliott Hughes #ifdef USE_FLOPPYD
375*d5c9a868SElliott Hughes 
376*d5c9a868SElliott Hughes #ifdef HAVE_SYS_SOCKET_H
377*d5c9a868SElliott Hughes #include <sys/socket.h>
378*d5c9a868SElliott Hughes #endif
379*d5c9a868SElliott Hughes 
380*d5c9a868SElliott Hughes #ifdef HAVE_NETINET_IN_H
381*d5c9a868SElliott Hughes #include <netinet/in.h>
382*d5c9a868SElliott Hughes #endif
383*d5c9a868SElliott Hughes 
384*d5c9a868SElliott Hughes #ifdef HAVE_NETINET_TCP_H
385*d5c9a868SElliott Hughes #include <netinet/tcp.h>
386*d5c9a868SElliott Hughes #endif
387*d5c9a868SElliott Hughes 
388*d5c9a868SElliott Hughes #ifdef HAVE_ARPA_INET_H
389*d5c9a868SElliott Hughes #include <arpa/inet.h>
390*d5c9a868SElliott Hughes #endif
391*d5c9a868SElliott Hughes 
392*d5c9a868SElliott Hughes #ifdef HAVE_NETDB_H
393*d5c9a868SElliott Hughes #include <netdb.h>
394*d5c9a868SElliott Hughes #endif
395*d5c9a868SElliott Hughes 
396*d5c9a868SElliott Hughes #ifdef HAVE_X11_XAUTH_H
397*d5c9a868SElliott Hughes #include <X11/Xauth.h>
398*d5c9a868SElliott Hughes #endif
399*d5c9a868SElliott Hughes 
400*d5c9a868SElliott Hughes #ifdef HAVE_X11_XLIB_H
401*d5c9a868SElliott Hughes #include <X11/Xlib.h>
402*d5c9a868SElliott Hughes #endif
403*d5c9a868SElliott Hughes 
404*d5c9a868SElliott Hughes #endif
405*d5c9a868SElliott Hughes 
406*d5c9a868SElliott Hughes #ifndef INADDR_NONE
407*d5c9a868SElliott Hughes #define INADDR_NONE (-1)
408*d5c9a868SElliott Hughes #endif
409*d5c9a868SElliott Hughes 
410*d5c9a868SElliott Hughes 
411*d5c9a868SElliott Hughes #ifdef sgi
412*d5c9a868SElliott Hughes #define MSGIHACK __EXTENSIONS__
413*d5c9a868SElliott Hughes #undef __EXTENSIONS__
414*d5c9a868SElliott Hughes #endif
415*d5c9a868SElliott Hughes #include <math.h>
416*d5c9a868SElliott Hughes #ifdef sgi
417*d5c9a868SElliott Hughes #define __EXTENSIONS__ MSGIHACK
418*d5c9a868SElliott Hughes #undef MSGIHACK
419*d5c9a868SElliott Hughes #endif
420*d5c9a868SElliott Hughes 
421*d5c9a868SElliott Hughes /* missing functions */
422*d5c9a868SElliott Hughes #ifndef HAVE_SRANDOM
423*d5c9a868SElliott Hughes # ifdef OS_mingw32msvc
424*d5c9a868SElliott Hughes #  define srandom srand
425*d5c9a868SElliott Hughes # else
426*d5c9a868SElliott Hughes #  define srandom srand48
427*d5c9a868SElliott Hughes # endif
428*d5c9a868SElliott Hughes #endif
429*d5c9a868SElliott Hughes 
430*d5c9a868SElliott Hughes #ifndef HAVE_RANDOM
431*d5c9a868SElliott Hughes # ifdef OS_mingw32msvc
432*d5c9a868SElliott Hughes #  define random (long)rand
433*d5c9a868SElliott Hughes # else
434*d5c9a868SElliott Hughes #  define random (long)lrand48
435*d5c9a868SElliott Hughes # endif
436*d5c9a868SElliott Hughes #endif
437*d5c9a868SElliott Hughes 
438*d5c9a868SElliott Hughes #ifndef HAVE_STRCHR
439*d5c9a868SElliott Hughes # define strchr index
440*d5c9a868SElliott Hughes #endif
441*d5c9a868SElliott Hughes 
442*d5c9a868SElliott Hughes #ifndef HAVE_STRRCHR
443*d5c9a868SElliott Hughes # define strrchr rindex
444*d5c9a868SElliott Hughes #endif
445*d5c9a868SElliott Hughes 
446*d5c9a868SElliott Hughes 
447*d5c9a868SElliott Hughes #ifndef HAVE_STRDUP
448*d5c9a868SElliott Hughes extern char *strdup(const char *str);
449*d5c9a868SElliott Hughes #endif /* HAVE_STRDUP */
450*d5c9a868SElliott Hughes 
451*d5c9a868SElliott Hughes #ifndef HAVE_STRNDUP
452*d5c9a868SElliott Hughes extern char *strndup(const char *s, size_t n);
453*d5c9a868SElliott Hughes #endif /* HAVE_STRDUP */
454*d5c9a868SElliott Hughes 
455*d5c9a868SElliott Hughes #ifndef HAVE_MEMCPY
456*d5c9a868SElliott Hughes extern char *memcpy(char *s1, const char *s2, size_t n);
457*d5c9a868SElliott Hughes #endif
458*d5c9a868SElliott Hughes 
459*d5c9a868SElliott Hughes #ifndef HAVE_MEMSET
460*d5c9a868SElliott Hughes extern char *memset(char *s, char c, size_t n);
461*d5c9a868SElliott Hughes #endif /* HAVE_MEMSET */
462*d5c9a868SElliott Hughes 
463*d5c9a868SElliott Hughes 
464*d5c9a868SElliott Hughes #ifndef HAVE_STRPBRK
465*d5c9a868SElliott Hughes extern char *strpbrk(const char *string, const char *brkset);
466*d5c9a868SElliott Hughes #endif /* HAVE_STRPBRK */
467*d5c9a868SElliott Hughes 
468*d5c9a868SElliott Hughes 
469*d5c9a868SElliott Hughes #ifndef HAVE_STRTOUL
470*d5c9a868SElliott Hughes unsigned long strtoul(const char *string, char **eptr, int base);
471*d5c9a868SElliott Hughes #endif /* HAVE_STRTOUL */
472*d5c9a868SElliott Hughes 
473*d5c9a868SElliott Hughes #ifndef HAVE_STRSPN
474*d5c9a868SElliott Hughes size_t strspn(const char *s, const char *accept);
475*d5c9a868SElliott Hughes #endif /* HAVE_STRSPN */
476*d5c9a868SElliott Hughes 
477*d5c9a868SElliott Hughes #ifndef HAVE_STRCSPN
478*d5c9a868SElliott Hughes size_t strcspn(const char *s, const char *reject);
479*d5c9a868SElliott Hughes #endif /* HAVE_STRCSPN */
480*d5c9a868SElliott Hughes 
481*d5c9a868SElliott Hughes #ifndef HAVE_STRERROR
482*d5c9a868SElliott Hughes char *strerror(int errno);
483*d5c9a868SElliott Hughes #endif
484*d5c9a868SElliott Hughes 
485*d5c9a868SElliott Hughes #ifndef HAVE_ATEXIT
486*d5c9a868SElliott Hughes int atexit(void (*function)(void));
487*d5c9a868SElliott Hughes 
488*d5c9a868SElliott Hughes #ifndef HAVE_ON_EXIT
489*d5c9a868SElliott Hughes void myexit(int code) NORETURN;
490*d5c9a868SElliott Hughes #define exit myexit
491*d5c9a868SElliott Hughes #endif
492*d5c9a868SElliott Hughes 
493*d5c9a868SElliott Hughes #endif
494*d5c9a868SElliott Hughes 
495*d5c9a868SElliott Hughes 
496*d5c9a868SElliott Hughes #ifndef HAVE_MEMMOVE
497*d5c9a868SElliott Hughes # define memmove(DST, SRC, N) bcopy(SRC, DST, N)
498*d5c9a868SElliott Hughes #endif
499*d5c9a868SElliott Hughes 
500*d5c9a868SElliott Hughes #ifndef HAVE_STRCASECMP
501*d5c9a868SElliott Hughes int strcasecmp(const char *s1, const char *s2);
502*d5c9a868SElliott Hughes #endif
503*d5c9a868SElliott Hughes 
504*d5c9a868SElliott Hughes #ifndef HAVE_STRNCASECMP
505*d5c9a868SElliott Hughes int strncasecmp(const char *s1, const char *s2, size_t n);
506*d5c9a868SElliott Hughes #endif
507*d5c9a868SElliott Hughes 
508*d5c9a868SElliott Hughes #ifndef HAVE_GETPASS
509*d5c9a868SElliott Hughes char *getpass(const char *prompt);
510*d5c9a868SElliott Hughes #endif
511*d5c9a868SElliott Hughes 
512*d5c9a868SElliott Hughes #ifdef HAVE_WCHAR_H
513*d5c9a868SElliott Hughes 
514*d5c9a868SElliott Hughes # ifndef HAVE_WCSDUP
515*d5c9a868SElliott Hughes wchar_t *wcsdup(const wchar_t *wcs);
516*d5c9a868SElliott Hughes # endif
517*d5c9a868SElliott Hughes 
518*d5c9a868SElliott Hughes # ifndef HAVE_WCSCASECMP
519*d5c9a868SElliott Hughes int wcscasecmp(const wchar_t *s1, const wchar_t *s2);
520*d5c9a868SElliott Hughes # endif
521*d5c9a868SElliott Hughes 
522*d5c9a868SElliott Hughes # ifndef HAVE_WCSNLEN
523*d5c9a868SElliott Hughes size_t wcsnlen(const wchar_t *wcs, size_t l);
524*d5c9a868SElliott Hughes # endif
525*d5c9a868SElliott Hughes 
526*d5c9a868SElliott Hughes #endif
527*d5c9a868SElliott Hughes 
528*d5c9a868SElliott Hughes #if 0
529*d5c9a868SElliott Hughes #ifndef HAVE_BASENAME
530*d5c9a868SElliott Hughes const char *basename(const char *filename);
531*d5c9a868SElliott Hughes #endif
532*d5c9a868SElliott Hughes #endif
533*d5c9a868SElliott Hughes 
534*d5c9a868SElliott Hughes const char *_basename(const char *filename);
535*d5c9a868SElliott Hughes 
536*d5c9a868SElliott Hughes void _stripexe(char *filename);
537*d5c9a868SElliott Hughes 
538*d5c9a868SElliott Hughes #ifndef __STDC__
539*d5c9a868SElliott Hughes # ifndef signed
540*d5c9a868SElliott Hughes #  define signed /**/
541*d5c9a868SElliott Hughes # endif
542*d5c9a868SElliott Hughes #endif /* !__STDC__ */
543*d5c9a868SElliott Hughes 
544*d5c9a868SElliott Hughes 
545*d5c9a868SElliott Hughes 
546*d5c9a868SElliott Hughes /***************************************************************************/
547*d5c9a868SElliott Hughes /*                                                                         */
548*d5c9a868SElliott Hughes /* Prototypes for systems where the functions exist but not the prototypes */
549*d5c9a868SElliott Hughes /*                                                                         */
550*d5c9a868SElliott Hughes /***************************************************************************/
551*d5c9a868SElliott Hughes 
552*d5c9a868SElliott Hughes 
553*d5c9a868SElliott Hughes 
554*d5c9a868SElliott Hughes /* prototypes which might be missing on some platforms, even if the functions
555*d5c9a868SElliott Hughes  * are present.  Do not declare argument types, in order to avoid conflict
556*d5c9a868SElliott Hughes  * on platforms where the prototypes _are_ correct.  Indeed, for most of
557*d5c9a868SElliott Hughes  * these, there are _several_ "correct" parameter definitions, and not all
558*d5c9a868SElliott Hughes  * platforms use the same.  For instance, some use the const attribute for
559*d5c9a868SElliott Hughes  * strings not modified by the function, and others do not.  By using just
560*d5c9a868SElliott Hughes  * the return type, which rarely changes, we avoid these problems.
561*d5c9a868SElliott Hughes  */
562*d5c9a868SElliott Hughes 
563*d5c9a868SElliott Hughes /* Correction:  Now it seems that even return values are not standardized :-(
564*d5c9a868SElliott Hughes   For instance  DEC-ALPHA, OSF/1 3.2d uses ssize_t as a return type for read
565*d5c9a868SElliott Hughes   and write.  NextStep uses a non-void return value for exit, etc.  With the
566*d5c9a868SElliott Hughes   advent of 64 bit system, we'll expect more of these problems in the future.
567*d5c9a868SElliott Hughes   Better uncomment the lot, except on SunOS, which is known to have bad
568*d5c9a868SElliott Hughes   incomplete files.  Add other OS'es with incomplete include files as needed
569*d5c9a868SElliott Hughes   */
570*d5c9a868SElliott Hughes #if (defined OS_sunos || defined OS_ultrix)
571*d5c9a868SElliott Hughes int read();
572*d5c9a868SElliott Hughes int write();
573*d5c9a868SElliott Hughes int fflush();
574*d5c9a868SElliott Hughes char *strdup();
575*d5c9a868SElliott Hughes int strcasecmp();
576*d5c9a868SElliott Hughes int strncasecmp();
577*d5c9a868SElliott Hughes char *getenv();
578*d5c9a868SElliott Hughes unsigned long strtoul();
579*d5c9a868SElliott Hughes int pclose();
580*d5c9a868SElliott Hughes void exit();
581*d5c9a868SElliott Hughes char *getpass();
582*d5c9a868SElliott Hughes int atoi();
583*d5c9a868SElliott Hughes FILE *fdopen();
584*d5c9a868SElliott Hughes FILE *popen();
585*d5c9a868SElliott Hughes #endif
586*d5c9a868SElliott Hughes 
587*d5c9a868SElliott Hughes #ifndef MAXPATHLEN
588*d5c9a868SElliott Hughes # ifdef PATH_MAX
589*d5c9a868SElliott Hughes #  define MAXPATHLEN PATH_MAX
590*d5c9a868SElliott Hughes # else
591*d5c9a868SElliott Hughes #  define MAXPATHLEN 1024
592*d5c9a868SElliott Hughes # endif
593*d5c9a868SElliott Hughes #endif
594*d5c9a868SElliott Hughes 
595*d5c9a868SElliott Hughes 
596*d5c9a868SElliott Hughes #ifndef OS_linux
597*d5c9a868SElliott Hughes # undef USE_XDF
598*d5c9a868SElliott Hughes #endif
599*d5c9a868SElliott Hughes 
600*d5c9a868SElliott Hughes #ifdef NO_XDF
601*d5c9a868SElliott Hughes # undef USE_XDF
602*d5c9a868SElliott Hughes #endif
603*d5c9a868SElliott Hughes 
604*d5c9a868SElliott Hughes #ifdef __EMX__
605*d5c9a868SElliott Hughes #define INCL_BASE
606*d5c9a868SElliott Hughes #define INCL_DOSDEVIOCTL
607*d5c9a868SElliott Hughes #include <os2.h>
608*d5c9a868SElliott Hughes #endif
609*d5c9a868SElliott Hughes 
610*d5c9a868SElliott Hughes #ifdef OS_nextstep
611*d5c9a868SElliott Hughes /* nextstep doesn't have this.  Unfortunately, we cannot test its presence
612*d5c9a868SElliott Hughes    using AC_EGREP_HEADER, as we don't know _which_ header to test, and in
613*d5c9a868SElliott Hughes    the general case utime.h might be non-existent */
614*d5c9a868SElliott Hughes struct utimbuf
615*d5c9a868SElliott Hughes {
616*d5c9a868SElliott Hughes   time_t actime,modtime;
617*d5c9a868SElliott Hughes };
618*d5c9a868SElliott Hughes #endif
619*d5c9a868SElliott Hughes 
620*d5c9a868SElliott Hughes /* NeXTStep doesn't have these */
621*d5c9a868SElliott Hughes #if !defined(S_ISREG) && defined (_S_IFMT) && defined (_S_IFREG)
622*d5c9a868SElliott Hughes #define S_ISREG(mode)   (((mode) & (_S_IFMT)) == (_S_IFREG))
623*d5c9a868SElliott Hughes #endif
624*d5c9a868SElliott Hughes 
625*d5c9a868SElliott Hughes #if !defined(S_ISDIR) && defined (_S_IFMT) && defined (_S_IFDIR)
626*d5c9a868SElliott Hughes #define S_ISDIR(mode)   (((mode) & (_S_IFMT)) == (_S_IFDIR))
627*d5c9a868SElliott Hughes #endif
628*d5c9a868SElliott Hughes 
629*d5c9a868SElliott Hughes 
630*d5c9a868SElliott Hughes #ifdef OS_aix
631*d5c9a868SElliott Hughes /* AIX has an offset_t time, but somehow it is not scalar ==> forget about it
632*d5c9a868SElliott Hughes  */
633*d5c9a868SElliott Hughes # undef HAVE_OFFSET_T
634*d5c9a868SElliott Hughes #endif
635*d5c9a868SElliott Hughes 
636*d5c9a868SElliott Hughes 
637*d5c9a868SElliott Hughes #ifdef HAVE_STAT64
638*d5c9a868SElliott Hughes #define MT_STAT stat64
639*d5c9a868SElliott Hughes #define MT_LSTAT lstat64
640*d5c9a868SElliott Hughes #define MT_FSTAT fstat64
641*d5c9a868SElliott Hughes #else
642*d5c9a868SElliott Hughes #define MT_STAT stat
643*d5c9a868SElliott Hughes #define MT_LSTAT lstat
644*d5c9a868SElliott Hughes #define MT_FSTAT fstat
645*d5c9a868SElliott Hughes #endif
646*d5c9a868SElliott Hughes 
647*d5c9a868SElliott Hughes 
648*d5c9a868SElliott Hughes #ifndef O_LARGEFILE
649*d5c9a868SElliott Hughes #define O_LARGEFILE 0
650*d5c9a868SElliott Hughes #endif
651*d5c9a868SElliott Hughes 
652*d5c9a868SElliott Hughes #ifndef __GNUC__
653*d5c9a868SElliott Hughes #ifndef __inline__
654*d5c9a868SElliott Hughes #define __inline__ inline
655*d5c9a868SElliott Hughes #endif
656*d5c9a868SElliott Hughes #endif
657*d5c9a868SElliott Hughes 
658*d5c9a868SElliott Hughes #endif
659