home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / mtools_3.6.src.lzh / MTOOLS_3.6 / sysincludes.h < prev    next >
Text File  |  1997-11-12  |  8KB  |  378 lines

  1. /* System includes for mtools */
  2.  
  3. #ifndef SYSINCLUDES_H
  4. #define SYSINCLUDES_H
  5.  
  6. #include "config.h"
  7.  
  8. /***********************************************************************/
  9. /*                                                                     */
  10. /* OS dependancies which cannot be covered by the autoconfigure script */
  11. /*                                                                     */
  12. /***********************************************************************/
  13.  
  14. #ifdef BSD
  15. /* on BSD we prefer gettimeofday, ... */
  16. # ifdef HAVE_GETTIMEOFDAY
  17. #  undef HAVE_TZSET
  18. # endif
  19. #else /* BSD */
  20. /* ... elsewhere we prefer tzset */
  21. # ifdef HAVE_TZSET
  22. #  undef HAVE_GETTIMEOFDAY
  23. # endif
  24. #endif
  25.  
  26. #ifdef aux
  27. /* A/UX needs POSIX_SOURCE, just as AIX does. Unlike SCO and AIX, it seems
  28.  * to prefer TERMIO over TERMIOS */
  29. #ifndef _POSIX_SOURCE
  30. # define _POSIX_SOURCE
  31. #endif
  32. #ifndef POSIX_SOURCE
  33. # define POSIX_SOURCE
  34. #endif
  35.  
  36. #endif
  37.  
  38.  
  39. /* On AIX, we have to prefer strings.h, as string.h lacks a prototype 
  40.  * for strcasecmp. On most other architectures, it's string.h which seems
  41.  * to be more complete */
  42. #if (defined(aix) && defined (HAVE_STRINGS_H))
  43. # undef HAVE_STRING_H
  44. #endif
  45.  
  46.  
  47.  
  48. #ifdef linux_gnu
  49. /* RMS strikes again */
  50. # ifndef linux
  51. #  define linux
  52. # endif
  53. #endif
  54.  
  55.  
  56. /***********************************************************************/
  57. /*                                                                     */
  58. /* Compiler dependancies                                               */
  59. /*                                                                     */
  60. /***********************************************************************/
  61.  
  62.  
  63. #if defined __GNUC__ && defined __STDC__
  64. /* gcc -traditional doesn't have PACKED, UNUSED and NORETURN */
  65. # define PACKED __attribute__ ((packed))
  66. # if __GNUC__ == 2 && __GNUC_MINOR__ > 6 || __GNUC__ >= 3
  67. /* gcc 2.6.3 doesn't have "unused" */        /* mool */
  68. #  define UNUSED(x) x __attribute__ ((unused));x
  69. # else
  70. #  define UNUSED(x) x
  71. # endif
  72. # define NORETURN __attribute__ ((noreturn))
  73. #else
  74. # define UNUSED(x) x
  75. # define PACKED /* */
  76. # define NORETURN /* */
  77. #endif
  78.  
  79.  
  80. /***********************************************************************/
  81. /*                                                                     */
  82. /* Include files                                                       */
  83. /*                                                                     */
  84. /***********************************************************************/
  85.  
  86.  
  87. #ifndef _OSK
  88. #include <sys/types.h>
  89. #else
  90. #include <modes.h>
  91. typedef long off_t;
  92. #define MAXPATHLEN 256
  93. #define O_RDONLY S_IREAD
  94. #define O_WRONLY S_IWRITE
  95. #define O_RDWR S_IREAD | S_IWRITE
  96. #define O_CREAT 0x100
  97. #define O_TRUNC 0x200
  98. #endif
  99.  
  100. #ifdef HAVE_STDLIB_H
  101. # include <stdlib.h>
  102. #endif
  103.  
  104. #include <stdio.h>
  105. #include <ctype.h>
  106.  
  107. #ifdef HAVE_UNISTD_H
  108. # include <unistd.h>
  109. #endif
  110.  
  111. #ifdef HAVE_LIBC_H
  112. # include <libc.h>
  113. #endif
  114.  
  115. #ifdef HAVE_GETOPT_H
  116. # include <getopt.h>
  117. #else
  118. int getopt();
  119. extern char *optarg;
  120. extern int optind, opterr;
  121. #endif
  122.  
  123. #ifdef HAVE_FCNTL_H
  124. # include <fcntl.h>
  125. #endif
  126.  
  127. #ifdef HAVE_LIMITS_H
  128. # include <limits.h>
  129. #endif
  130.  
  131. #ifdef HAVE_SYS_FILE_H
  132. # include <sys/file.h>
  133. #endif
  134.  
  135. #ifdef HAVE_SYS_IOCTL_H
  136. # ifndef sunos
  137. # include <sys/ioctl.h>
  138. #endif
  139. #endif
  140. /* if we don't have sys/ioctl.h, we rely on unistd to supply a prototype
  141.  * for it. If it doesn't, we'll only get a (harmless) warning. The idea
  142.  * is to get mtools compile on as many platforms as possible, but to not
  143.  * suppress warnings if the platform is broken, as long as these warnings do
  144.  * not prevent compilation */
  145.  
  146. #ifndef _OSK
  147. #ifdef TIME_WITH_SYS_TIME
  148. # include <sys/time.h>
  149. # include <time.h>
  150. #else
  151. # ifdef HAVE_SYS_TIME_H
  152. #  include <sys/time.h>
  153. # else
  154. #  include <time.h>
  155. # endif
  156. #endif
  157. #endif
  158.  
  159. #ifndef NO_TERMIO
  160. # ifdef HAVE_TERMIO_H
  161. #  include <termio.h>
  162. # endif
  163. # ifdef HAVE_SYS_TERMIO_H
  164. #  include <sys/termio.h>
  165. # endif
  166. # ifdef HAVE_TERMIOS_H
  167. #  include <termios.h>
  168. # endif
  169. # ifdef HAVE_SYS_TERMIOS_H
  170. #  include <sys/termios.h>
  171. # endif
  172. #endif
  173.  
  174. #ifdef HAVE_SYS_PARAM_H
  175. # include <sys/param.h>
  176. #endif
  177.  
  178. #ifndef _OSK
  179. #include <sys/stat.h>
  180. #else
  181. #include <stat.h>
  182. #endif
  183.  
  184. #include <errno.h>
  185. extern int errno;
  186. #if !defined netbsd && !defined freebsd
  187. /* NetBSD seems to choke on this, due to a slightly non-standard definition */
  188. extern char *sys_errlist[];
  189. #endif
  190. #include <pwd.h>
  191.  
  192.  
  193. #ifdef HAVE_STRING_H
  194. # include <string.h>
  195. #else
  196. # ifdef HAVE_STRINGS_H
  197. #  include <strings.h>
  198. # endif
  199. #endif
  200.  
  201. #ifdef HAVE_MEMORY_H
  202. # include <memory.h>
  203. #endif
  204.  
  205. #ifdef HAVE_MALLOC_H
  206. # include <malloc.h>
  207. #endif
  208.  
  209. #ifdef HAVE_SIGNAL_H
  210. # include <signal.h>
  211. #else
  212. # ifdef HAVE_SYS_SIGNAL_H
  213. #  include <sys/signal.h>
  214. # endif
  215. #endif
  216.  
  217. #ifdef HAVE_UTIME_H
  218. # include <utime.h>
  219. #endif
  220.  
  221. #ifdef HAVE_SYS_WAIT_H
  222. # include <sys/wait.h>
  223. #endif
  224.  
  225. #ifdef linux
  226. # include <linux/fd.h>
  227. #endif
  228.  
  229.  
  230. /* missing functions */
  231. #ifndef HAVE_SRANDOM
  232. # define srandom srand48
  233. #endif
  234.  
  235. #ifndef HAVE_RANDOM
  236. # define random (long)lrand48
  237. #endif
  238.  
  239. #ifndef HAVE_STRCHR
  240. # define strchr index
  241. #endif
  242.  
  243. #ifndef HAVE_STRRCHR
  244. # define strrchr rindex
  245. #endif
  246.  
  247.  
  248. #define SIG_CAST RETSIGTYPE(*)()
  249.  
  250. #ifndef HAVE_STRDUP
  251. extern char *strdup(const char *str);
  252. #endif /* HAVE_STRDUP */
  253.  
  254.  
  255. #ifndef HAVE_MEMCPY
  256. extern char *memcpy(char *s1, const char *s2, size_t n);
  257. #endif
  258.  
  259. #ifndef HAVE_MEMSET
  260. extern char *memset(char *s, char c, size_t n);
  261. #endif /* HAVE_MEMSET */
  262.  
  263.  
  264. #ifndef HAVE_STRPBRK
  265. extern char *strpbrk(const char *string, const char *brkset);
  266. #endif /* HAVE_STRPBRK */
  267.  
  268.  
  269. #ifndef HAVE_STRTOUL
  270. unsigned long strtoul(const char *string, char **eptr, int base);
  271. #endif /* HAVE_STRTOUL */
  272.  
  273. #ifndef HAVE_STRSPN
  274. size_t strspn(const char *s, const char *accept);
  275. #endif /* HAVE_STRSPN */
  276.  
  277. #ifndef HAVE_STRCSPN
  278. size_t strcspn(const char *s, const char *reject);
  279. #endif /* HAVE_STRCSPN */
  280.  
  281. #ifndef HAVE_STRERROR
  282. char *strerror(int errno);
  283. #endif
  284.  
  285. #ifndef HAVE_ATEXIT
  286. #ifndef _OSK
  287. int atexit(void (*function)(void)); 
  288. #else
  289. void atexit(void (*func)()); /* libgcc2 */
  290. #endif
  291.  
  292. #ifndef HAVE_ON_EXIT
  293. void myexit(int code) NORETURN;
  294. #define exit myexit
  295. #endif
  296.  
  297. #endif
  298.  
  299.  
  300. #ifndef HAVE_MEMMOVE
  301. # define memmove(DST, SRC, N) bcopy(SRC, DST, N)
  302. #endif
  303.  
  304. #ifndef HAVE_STRCASECMP
  305. int strcasecmp(const char *s1, const char *s2);
  306. #endif
  307.  
  308. #ifndef HAVE_STRNCASECMP
  309. # ifdef __BEOS__
  310. int strncasecmp(const char *s1, const char *s2, unsigned int n);
  311. # else
  312. int strncasecmp(const char *s1, const char *s2, size_t n);
  313. # endif
  314. #endif
  315.  
  316. #ifndef HAVE_GETPASS
  317. char *getpass(const char *prompt);
  318. #endif
  319.  
  320.  
  321. #ifndef __STDC__
  322. # ifndef signed
  323. #  define signed /**/
  324. # endif 
  325. #endif /* !__STDC__ */
  326.  
  327.  
  328.  
  329. /***************************************************************************/
  330. /*                                                                         */
  331. /* Prototypes for systems where the functions exist but not the prototypes */
  332. /*                                                                         */
  333. /***************************************************************************/
  334.  
  335.  
  336.  
  337. /* prototypes which might be missing on some platforms, even if the functions
  338.  * are present.  Do not declare argument types, in order to avoid conflict
  339.  * on platforms where the prototypes _are_ correct.  Indeed, for most of
  340.  * these, there are _several_ "correct" parameter definitions, and not all
  341.  * platforms use the same.  For instance, some use the const attribute for
  342.  * strings not modified by the function, and others do not.  By using just
  343.  * the return type, which rarely changes, we avoid these problems.
  344.  */
  345. int read();
  346. int write();
  347. int fflush();
  348. char *strdup();
  349. int strcasecmp();
  350. int strncasecmp();
  351. char *getenv();
  352. unsigned long strtoul();
  353. int pclose();
  354. void exit();
  355. char *getpass();
  356. int atoi();
  357. FILE *fdopen();
  358. FILE *popen();
  359.  
  360. #ifndef MAXPATHLEN
  361. # ifdef PATH_MAX
  362. #  define MAXPATHLEN PATH_MAX
  363. # else
  364. #  define MAXPATHLEN 1024
  365. # endif
  366. #endif
  367.  
  368.  
  369. #ifndef linux
  370. # undef USE_XDF
  371. #endif
  372.  
  373. #ifdef NO_XDF
  374. # undef USE_XDF
  375. #endif
  376.  
  377. #endif
  378.