home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / diff20.zip / diff-2.0 / system.h < prev    next >
C/C++ Source or Header  |  1992-09-12  |  3KB  |  140 lines

  1. /* System dependent declarations.
  2.    Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU DIFF.
  5.  
  6. GNU DIFF 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)
  9. any later version.
  10.  
  11. GNU DIFF 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.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU DIFF; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22.  
  23. #ifndef S_ISDIR
  24. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  25. #endif
  26. #ifndef S_ISREG
  27. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  28. #endif
  29.  
  30. #ifdef HAVE_UNISTD_H
  31. #include <unistd.h>
  32. #endif
  33.  
  34. #if defined (USG) || defined (_POSIX_VERSION)
  35. #include <time.h>
  36. #include <fcntl.h>
  37. #else
  38. #include <sys/time.h>
  39. #include <sys/file.h>
  40. #endif
  41.  
  42. #ifndef HAVE_DUP2
  43. #define dup2(f,t)    (close (t),  fcntl (f,F_DUPFD,t))
  44. #endif
  45.  
  46. #ifndef O_RDONLY
  47. #define O_RDONLY 0
  48. #endif
  49.  
  50. #if !defined (USG) || defined (_POSIX_VERSION)
  51. #include <sys/wait.h>
  52. #endif
  53.  
  54. #ifndef WEXITSTATUS
  55. #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  56. #undef WIFEXITED        /* Avoid 4.3BSD incompatibility with Posix.  */
  57. #endif
  58. #ifndef WIFEXITED
  59. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  60. #endif
  61.  
  62. #if HAVE_ST_BLKSIZE
  63. #define STAT_BLOCKSIZE(s) (s).st_blksize
  64. #else
  65. #define STAT_BLOCKSIZE(s) (S_ISREG ((s).st_mode) ? 8192 : 4096)
  66. #endif
  67.  
  68. #if defined (DIRENT) || defined (_POSIX_VERSION)
  69. #include <dirent.h>
  70. #ifdef direct
  71. #undef direct
  72. #endif
  73. #define direct dirent
  74. #else /* not (DIRENT or _POSIX_VERSION) */
  75. #ifdef USG
  76. #ifdef SYSNDIR
  77. #include <sys/ndir.h>
  78. #else /* !SYSNDIR */
  79. #include <ndir.h>
  80. #endif /* SYSNDIR */
  81. #else /* !USG */
  82. #include <sys/dir.h>
  83. #endif /* USG */
  84. #endif /* DIRENT or _POSIX_VERSION */
  85.  
  86. #ifdef HAVE_VFORK_H
  87. #include <vfork.h>
  88. #endif
  89.  
  90. #if defined (USG) || defined (STDC_HEADERS)
  91. #include <string.h>
  92. #define index    strchr
  93. #define rindex    strrchr
  94. #define bcopy(s,d,n)    memcpy (d,s,n)
  95. #define bcmp(s1,s2,n)    memcmp (s1,s2,n)
  96. #define bzero(s,n)    memset (s,0,n)
  97. #else
  98. #include <strings.h>
  99. #endif
  100. #if !HAVE_MEMCHR || (!STDC_HEADERS && !USG)
  101. char *memchr ();
  102. #endif
  103.  
  104. #if defined (STDC_HEADERS)
  105. #include <stdlib.h>
  106. #include <limits.h>
  107. #else
  108. char *getenv ();
  109. char *malloc ();
  110. char *realloc ();
  111. #if __STDC__ || __GNUC__
  112. #include "limits.h"
  113. #else
  114. #define INT_MAX 2147483647
  115. #define CHAR_BIT 8
  116. #endif
  117. #endif
  118.  
  119. #include <errno.h>
  120. #ifndef STDC_HEADERS
  121. extern int errno;
  122. #endif
  123.  
  124. #ifdef TRUE
  125. #undef TRUE
  126. #endif
  127. #ifdef FALSE
  128. #undef FALSE
  129. #endif
  130. #define TRUE        1
  131. #define    FALSE        0
  132.  
  133. #if !__STDC__
  134. #define const
  135. #define volatile
  136. #endif
  137.  
  138. #define min(a,b) ((a) <= (b) ? (a) : (b))
  139. #define max(a,b) ((a) >= (b) ? (a) : (b))
  140.