home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs57pc3.zip / diff / system.h < prev    next >
C/C++ Source or Header  |  1999-03-29  |  5KB  |  265 lines

  1. /* System dependent declarations.
  2.    Copyright (C) 1988, 1989, 1992, 1993, 1994 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. /* We must define `volatile' and `const' first (the latter inside config.h),
  21.    so that they're used consistently in all system includes.  */
  22. #if !__STDC__
  23. #ifndef volatile
  24. #define volatile
  25. #endif
  26. #endif
  27. #include <config.h>
  28.  
  29. #include <sys/types.h>
  30. #include <sys/stat.h>
  31.  
  32. #if __STDC__
  33. #define PARAMS(args) args
  34. #define VOID void
  35. #else
  36. #define PARAMS(args) ()
  37. #define VOID char
  38. #endif
  39.  
  40. #if STAT_MACROS_BROKEN
  41. #undef S_ISBLK
  42. #undef S_ISCHR
  43. #undef S_ISDIR
  44. #undef S_ISFIFO
  45. #undef S_ISREG
  46. #undef S_ISSOCK
  47. #endif
  48. #ifndef S_ISDIR
  49. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  50. #endif
  51. #ifndef S_ISREG
  52. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  53. #endif
  54. #if !defined (S_ISBLK) && defined (S_IFBLK)
  55. #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
  56. #endif
  57. #if !defined (S_ISCHR) && defined (S_IFCHR)
  58. #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
  59. #endif
  60. #if !defined (S_ISFIFO) && defined (S_IFFIFO)
  61. #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
  62. #endif
  63. #if !defined (S_ISSOCK) && defined (S_IFSOCK)
  64. #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
  65. #endif
  66.  
  67. #if HAVE_UNISTD_H
  68. #include <unistd.h>
  69. #endif
  70.  
  71. #ifndef SEEK_SET
  72. #define SEEK_SET 0
  73. #endif
  74. #ifndef SEEK_CUR
  75. #define SEEK_CUR 1
  76. #endif
  77.  
  78. #ifndef STDIN_FILENO
  79. #define STDIN_FILENO 0
  80. #endif
  81. #ifndef STDOUT_FILENO
  82. #define STDOUT_FILENO 1
  83. #endif
  84. #ifndef STDERR_FILENO
  85. #define STDERR_FILENO 2
  86. #endif
  87.  
  88. #if HAVE_TIME_H
  89. #include <time.h>
  90. #else
  91. #include <sys/time.h>
  92. #endif
  93.  
  94. #if HAVE_FCNTL_H
  95. #include <fcntl.h>
  96. #else
  97. #if HAVE_SYS_FILE_H
  98. #include <sys/file.h>
  99. #endif
  100. #endif
  101.  
  102. #if !HAVE_DUP2
  103. #define dup2(f,t)    (close (t),  fcntl (f,F_DUPFD,t))
  104. #endif
  105.  
  106. #ifndef O_RDONLY
  107. #define O_RDONLY 0
  108. #endif
  109.  
  110. #if HAVE_SYS_WAIT_H
  111. #include <sys/wait.h>
  112. #endif
  113. #ifndef WEXITSTATUS
  114. #define WEXITSTATUS(stat_val) ((unsigned) (stat_val) >> 8)
  115. #endif
  116. #ifndef WIFEXITED
  117. #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  118. #endif
  119.  
  120. #ifndef STAT_BLOCKSIZE
  121. #if HAVE_ST_BLKSIZE
  122. #define STAT_BLOCKSIZE(s) (s).st_blksize
  123. #else
  124. #define STAT_BLOCKSIZE(s) (8 * 1024)
  125. #endif
  126. #endif
  127.  
  128. #if HAVE_DIRENT_H
  129. # include <dirent.h>
  130. # define NAMLEN(dirent) strlen ((dirent)->d_name)
  131. #else
  132. # define dirent direct
  133. # define NAMLEN(dirent) ((dirent)->d_namlen)
  134. # if HAVE_SYS_NDIR_H
  135. #  include <sys/ndir.h>
  136. # endif
  137. # if HAVE_SYS_DIR_H
  138. #  include <sys/dir.h>
  139. # endif
  140. # if HAVE_NDIR_H
  141. #  include <ndir.h>
  142. # endif
  143. #endif
  144.  
  145. #if HAVE_VFORK_H
  146. #include <vfork.h>
  147. #endif
  148.  
  149. #if HAVE_STDLIB_H
  150. #include <stdlib.h>
  151. #endif
  152. #ifndef getenv
  153. char *getenv ();
  154. #endif
  155.  
  156. #if HAVE_LIMITS_H
  157. #include <limits.h>
  158. #endif
  159. #ifndef INT_MAX
  160. #define INT_MAX 2147483647
  161. #endif
  162. #ifndef CHAR_BIT
  163. #define CHAR_BIT 8
  164. #endif
  165.  
  166. #if STDC_HEADERS || HAVE_STRING_H
  167. # include <string.h>
  168. # ifndef bzero
  169. #  define bzero(s, n) memset (s, 0, n)
  170. # endif
  171. #else
  172. # if !HAVE_STRCHR
  173. #  define strchr index
  174. #  define strrchr rindex
  175. # endif
  176. char *strchr (), *strrchr ();
  177. # if !HAVE_MEMCHR
  178. #  define memcmp(s1, s2, n) bcmp (s1, s2, n)
  179. #  define memcpy(d, s, n) bcopy (s, d, n)
  180. void *memchr ();
  181. # endif
  182. #endif
  183.  
  184. #if HAVE_LIBINTL_H
  185. # include <libintl.h>
  186. #else
  187. # define gettext(msgid) (msgid)
  188. #endif
  189.  
  190. #if HAVE_LOCALE_H
  191. # include <locale.h>
  192. #else
  193. # define setlocale(category, locale)
  194. #endif
  195.  
  196. #include <ctype.h>
  197. /* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
  198.    as an argument to <ctype.h> macros like `isspace'.  */
  199. #if STDC_HEADERS
  200. #define CTYPE_DOMAIN(c) 1
  201. #else
  202. #define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
  203. #endif
  204. #ifndef ISPRINT
  205. #define ISPRINT(c) (CTYPE_DOMAIN (c) && isprint (c))
  206. #endif
  207. #ifndef ISSPACE
  208. #define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
  209. #endif
  210. #ifndef ISUPPER
  211. #define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
  212. #endif
  213.  
  214. #ifndef ISDIGIT
  215. #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
  216. #endif
  217.  
  218. #ifndef _tolower
  219. #define _tolower(c) tolower (c)
  220. #endif
  221.  
  222. #include <errno.h>
  223. #if !STDC_HEADERS
  224. extern int errno;
  225. #endif
  226.  
  227. #ifdef min
  228. #undef min
  229. #endif
  230. #ifdef max
  231. #undef max
  232. #endif
  233. #define min(a,b) ((a) <= (b) ? (a) : (b))
  234. #define max(a,b) ((a) >= (b) ? (a) : (b))
  235.  
  236. size_t system_quote_arg PARAMS((char *, char const *));
  237.  
  238. /* This section contains Posix-compliant defaults for macros
  239.    that are meant to be overridden by hand in config.h as needed.  */
  240.  
  241. #ifndef filename_cmp
  242. #define filename_cmp(a, b) strcmp (a, b)
  243. #endif
  244.  
  245. #ifndef filename_lastdirchar
  246. #define filename_lastdirchar(filename) strrchr (filename, '/')
  247. #endif
  248.  
  249. #ifndef HAVE_FORK
  250. #define HAVE_FORK 1
  251. #endif
  252.  
  253. #ifndef HAVE_SETMODE
  254. #define HAVE_SETMODE 0
  255. #endif
  256.  
  257. #ifndef initialize_main
  258. #define initialize_main(argcp, argvp)
  259. #endif
  260.  
  261. /* Do struct stat *S, *T describe the same file?  Answer -1 if unknown.  */
  262. #ifndef same_file
  263. #define same_file(s,t) ((s)->st_ino==(t)->st_ino && (s)->st_dev==(t)->st_dev)
  264. #endif
  265.