source: trunk/minix/commands/i386/mtools-3.9.7/sysincludes.h@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 10.9 KB
Line 
1/* System includes for mtools */
2
3#ifndef SYSINCLUDES_H
4#define SYSINCLUDES_H
5
6#include "config.h"
7
8/* OS/2 needs __inline__, but for some reason is not autodetected */
9#ifdef __EMX__
10# ifndef inline
11# define inline __inline__
12# endif
13#endif
14
15/***********************************************************************/
16/* */
17/* OS dependancies which cannot be covered by the autoconfigure script */
18/* */
19/***********************************************************************/
20
21
22#ifdef OS_aux
23/* A/UX needs POSIX_SOURCE, just as AIX does. Unlike SCO and AIX, it seems
24 * to prefer TERMIO over TERMIOS */
25#ifndef _POSIX_SOURCE
26# define _POSIX_SOURCE
27#endif
28#ifndef POSIX_SOURCE
29# define POSIX_SOURCE
30#endif
31
32#endif
33
34
35/* On AIX, we have to prefer strings.h, as string.h lacks a prototype
36 * for strcasecmp. On most other architectures, it's string.h which seems
37 * to be more complete */
38#if (defined OS_aix && defined HAVE_STRINGS_H)
39# undef HAVE_STRING_H
40#endif
41
42
43#ifdef OS_ultrix
44/* on ultrix, if termios present, prefer it instead of termio */
45# ifdef HAVE_TERMIOS_H
46# undef HAVE_TERMIO_H
47# endif
48#endif
49
50#ifdef OS_linux_gnu
51/* RMS strikes again */
52# ifndef OS_linux
53# define OS_linux
54# endif
55#endif
56
57#ifdef OS_Minix
58/* typedef unsigned char *caddr_t; */
59#endif
60
61
62/***********************************************************************/
63/* */
64/* Compiler dependancies */
65/* */
66/***********************************************************************/
67
68
69#if defined __GNUC__ && defined __STDC__
70/* gcc -traditional doesn't have PACKED, UNUSED and NORETURN */
71# define PACKED __attribute__ ((packed))
72# if __GNUC__ == 2 && __GNUC_MINOR__ > 6 || __GNUC__ >= 3
73/* gcc 2.6.3 doesn't have "unused" */ /* mool */
74# define UNUSED(x) x __attribute__ ((unused));x
75# else
76# define UNUSED(x) x
77# endif
78# define NORETURN __attribute__ ((noreturn))
79#else
80# define UNUSED(x) x
81# define PACKED /* */
82# define NORETURN /* */
83#endif
84
85
86/***********************************************************************/
87/* */
88/* Include files */
89/* */
90/***********************************************************************/
91
92
93#include <sys/types.h>
94
95#ifdef OS_Minix
96typedef unsigned long uoff_t;
97#define off_t uoff_t
98#endif
99
100#ifdef HAVE_STDLIB_H
101# include <stdlib.h>
102#endif
103
104#include <stdio.h>
105
106#ifndef OS_Minix
107# include <ctype.h>
108#else
109# ifdef __minix_vmd
110# include <bsd/asciictype.h> /* Minix-vmd: Ignore locales on purpose. */
111# else
112# include <ctype.h> /* Minix: What's that "locale" thing? */
113# endif
114#endif
115
116#ifdef HAVE_UNISTD_H
117# include <unistd.h>
118#endif
119
120#ifdef HAVE_LINUX_UNISTD_H
121# include <linux/unistd.h>
122#endif
123
124#ifdef HAVE_LIBC_H
125# include <libc.h>
126#endif
127
128#ifdef HAVE_GETOPT_H
129# include <getopt.h>
130#else
131# ifndef OS_Minix
132int getopt();
133extern char *optarg;
134extern int optind, opterr;
135# endif
136#endif
137
138#ifdef HAVE_FCNTL_H
139# include <fcntl.h>
140#endif
141
142#ifdef HAVE_LIMITS_H
143# include <limits.h>
144#endif
145
146#ifdef HAVE_SYS_FILE_H
147# include <sys/file.h>
148#endif
149
150#ifdef HAVE_SYS_IOCTL_H
151# ifndef sunos
152# include <sys/ioctl.h>
153#endif
154#endif
155/* if we don't have sys/ioctl.h, we rely on unistd to supply a prototype
156 * for it. If it doesn't, we'll only get a (harmless) warning. The idea
157 * is to get mtools compile on as many platforms as possible, but to not
158 * suppress warnings if the platform is broken, as long as these warnings do
159 * not prevent compilation */
160
161#ifdef TIME_WITH_SYS_TIME
162# include <sys/time.h>
163# include <time.h>
164#else
165# ifdef HAVE_SYS_TIME_H
166# include <sys/time.h>
167# else
168# include <time.h>
169# endif
170#endif
171
172#ifndef NO_TERMIO
173# ifdef HAVE_TERMIO_H
174# include <termio.h>
175# elif defined HAVE_SYS_TERMIO_H
176# include <sys/termio.h>
177# endif
178# if !defined OS_ultrix || !(defined HAVE_TERMIO_H || defined HAVE_TERMIO_H)
179/* on Ultrix, avoid double inclusion of both termio and termios */
180# ifdef HAVE_TERMIOS_H
181# include <termios.h>
182# elif defined HAVE_SYS_TERMIOS_H
183# include <sys/termios.h>
184# endif
185# endif
186# ifdef HAVE_STTY_H
187# include <sgtty.h>
188# endif
189#endif
190
191
192#if defined(OS_aux) && !defined(_SYSV_SOURCE)
193/* compiled in POSIX mode, this is left out unless SYSV */
194#define NCC 8
195struct termio {
196 unsigned short c_iflag; /* input modes */
197 unsigned short c_oflag; /* output modes */
198 unsigned short c_cflag; /* control modes */
199 unsigned short c_lflag; /* line discipline modes */
200 char c_line; /* line discipline */
201 unsigned char c_cc[NCC]; /* control chars */
202};
203extern int ioctl(int fildes, int request, void *arg);
204#endif
205
206
207#ifdef HAVE_MNTENT_H
208# include <mntent.h>
209#endif
210
211#ifdef HAVE_SYS_PARAM_H
212# include <sys/param.h>
213#endif
214
215/* Can only be done here, as BSD is defined in sys/param.h :-( */
216#if defined BSD || defined __BEOS__
217/* on BSD and on BEOS, we prefer gettimeofday, ... */
218# ifdef HAVE_GETTIMEOFDAY
219# undef HAVE_TZSET
220# endif
221#else /* BSD */
222/* ... elsewhere we prefer tzset */
223# ifdef HAVE_TZSET
224# undef HAVE_GETTIMEOFDAY
225# endif
226#endif
227
228
229#include <sys/stat.h>
230
231#include <errno.h>
232extern int errno;
233
234#include <pwd.h>
235
236
237#ifdef HAVE_STRING_H
238# include <string.h>
239#else
240# ifdef HAVE_STRINGS_H
241# include <strings.h>
242# endif
243#endif
244
245#ifdef HAVE_MEMORY_H
246# include <memory.h>
247#endif
248
249#ifdef HAVE_MALLOC_H
250# include <malloc.h>
251#endif
252
253#ifdef HAVE_SIGNAL_H
254# include <signal.h>
255#else
256# ifdef HAVE_SYS_SIGNAL_H
257# include <sys/signal.h>
258# endif
259#endif
260
261#ifdef HAVE_UTIME_H
262# include <utime.h>
263#endif
264
265#ifdef HAVE_SYS_WAIT_H
266# ifndef DONT_NEED_WAIT
267# include <sys/wait.h>
268# endif
269#endif
270
271
272#ifdef USE_FLOPPYD
273
274#ifdef HAVE_SYS_SOCKET_H
275#include <sys/socket.h>
276#endif
277
278#ifdef HAVE_NETINET_IN_H
279#include <netinet/in.h>
280#endif
281
282#ifdef HAVE_ARPA_INET_H
283#include <arpa/inet.h>
284#endif
285
286#ifdef HAVE_NETDB_H
287#include <netdb.h>
288#endif
289
290#ifdef HAVE_X11_XAUTH_H
291#include <X11/Xauth.h>
292#endif
293
294#ifdef HAVE_X11_XLIB_H
295#include <X11/Xlib.h>
296#endif
297
298#endif
299
300#ifndef INADDR_NONE
301#define INADDR_NONE (-1)
302#endif
303
304
305#ifdef sgi
306#define MSGIHACK __EXTENSIONS__
307#undef __EXTENSIONS__
308#endif
309#include <math.h>
310#ifdef sgi
311#define __EXTENSIONS__ MSGIHACK
312#undef MSGIHACK
313#endif
314
315/* missing functions */
316#ifndef HAVE_SRANDOM
317# define srandom srand48
318#endif
319
320#ifndef HAVE_RANDOM
321# define random (long)lrand48
322#endif
323
324#if __minix && !__minix_vmd
325# define srandom srand
326# define random rand
327#endif
328
329#ifndef HAVE_STRCHR
330# define strchr index
331#endif
332
333#ifndef HAVE_STRRCHR
334# define strrchr rindex
335#endif
336
337
338#define SIG_CAST RETSIGTYPE(*)()
339
340#ifndef HAVE_STRDUP
341extern char *strdup(const char *str);
342#endif /* HAVE_STRDUP */
343
344
345#ifndef HAVE_MEMCPY
346extern char *memcpy(char *s1, const char *s2, size_t n);
347#endif
348
349#ifndef HAVE_MEMSET
350extern char *memset(char *s, char c, size_t n);
351#endif /* HAVE_MEMSET */
352
353
354#ifndef HAVE_STRPBRK
355extern char *strpbrk(const char *string, const char *brkset);
356#endif /* HAVE_STRPBRK */
357
358
359#ifndef HAVE_STRTOUL
360unsigned long strtoul(const char *string, char **eptr, int base);
361#endif /* HAVE_STRTOUL */
362
363#ifndef HAVE_STRSPN
364size_t strspn(const char *s, const char *accept);
365#endif /* HAVE_STRSPN */
366
367#ifndef HAVE_STRCSPN
368size_t strcspn(const char *s, const char *reject);
369#endif /* HAVE_STRCSPN */
370
371#ifndef HAVE_STRERROR
372char *strerror(int errno);
373#endif
374
375#ifndef HAVE_ATEXIT
376int atexit(void (*function)(void));
377
378#ifndef HAVE_ON_EXIT
379void myexit(int code) NORETURN;
380#define exit myexit
381#endif
382
383#endif
384
385
386#ifndef HAVE_MEMMOVE
387# define memmove(DST, SRC, N) bcopy(SRC, DST, N)
388#endif
389
390#ifndef HAVE_STRCASECMP
391int strcasecmp(const char *s1, const char *s2);
392#endif
393
394#ifndef HAVE_STRNCASECMP
395int strncasecmp(const char *s1, const char *s2, size_t n);
396#endif
397
398#ifndef HAVE_GETPASS
399char *getpass(const char *prompt);
400#endif
401
402#if 0
403#ifndef HAVE_BASENAME
404const char *basename(const char *filename);
405#endif
406#endif
407
408const char *_basename(const char *filename);
409
410#ifndef __STDC__
411# ifndef signed
412# define signed /**/
413# endif
414#endif /* !__STDC__ */
415
416
417
418/***************************************************************************/
419/* */
420/* Prototypes for systems where the functions exist but not the prototypes */
421/* */
422/***************************************************************************/
423
424
425
426/* prototypes which might be missing on some platforms, even if the functions
427 * are present. Do not declare argument types, in order to avoid conflict
428 * on platforms where the prototypes _are_ correct. Indeed, for most of
429 * these, there are _several_ "correct" parameter definitions, and not all
430 * platforms use the same. For instance, some use the const attribute for
431 * strings not modified by the function, and others do not. By using just
432 * the return type, which rarely changes, we avoid these problems.
433 */
434
435/* Correction: Now it seems that even return values are not standardized :-(
436 For instance DEC-ALPHA, OSF/1 3.2d uses ssize_t as a return type for read
437 and write. NextStep uses a non-void return value for exit, etc. With the
438 advent of 64 bit system, we'll expect more of these problems in the future.
439 Better uncomment the lot, except on SunOS, which is known to have bad
440 incomplete files. Add other OS'es with incomplete include files as needed
441 */
442#if (defined OS_sunos || defined OS_ultrix)
443int read();
444int write();
445int fflush();
446char *strdup();
447int strcasecmp();
448int strncasecmp();
449char *getenv();
450unsigned long strtoul();
451int pclose();
452void exit();
453char *getpass();
454int atoi();
455FILE *fdopen();
456FILE *popen();
457#endif
458
459#ifndef MAXPATHLEN
460# ifdef PATH_MAX
461# define MAXPATHLEN PATH_MAX
462# else
463# define MAXPATHLEN 1024
464# endif
465#endif
466
467
468#ifndef OS_linux
469# undef USE_XDF
470#endif
471
472#ifdef NO_XDF
473# undef USE_XDF
474#endif
475
476#ifdef __EMX__
477#define INCL_BASE
478#define INCL_DOSDEVIOCTL
479#include <os2.h>
480#endif
481
482#ifdef OS_nextstep
483/* nextstep doesn't have this. Unfortunately, we cannot test its presence
484 using AC_EGREP_HEADER, as we don't know _which_ header to test, and in
485 the general case utime.h might be non-existent */
486struct utimbuf
487{
488 time_t actime,modtime;
489};
490#endif
491
492/* NeXTStep doesn't have these */
493#if !defined(S_ISREG) && defined (_S_IFMT) && defined (_S_IFREG)
494#define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))
495#endif
496
497#if !defined(S_ISDIR) && defined (_S_IFMT) && defined (_S_IFDIR)
498#define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
499#endif
500
501
502#if 0
503
504#define malloc(x) mymalloc(x)
505#define calloc(x,y) mycalloc(x,y)
506#define free(x) myfree(x)
507#define realloc(x,y) myrealloc(x,y)
508#define strdup(a) mystrdup(a)
509
510void *mycalloc(size_t nmemb, size_t size);
511void *mymalloc(size_t size);
512void myfree(void *ptr);
513void *myrealloc(void *ptr, size_t size);
514char *mystrdup(char *a);
515
516#endif
517
518#endif
Note: See TracBrowser for help on using the repository browser.