home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / textutils-1.11-src.lha / textutils-1.11 / src / system.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-03  |  4.6 KB  |  180 lines

  1. /* system-dependent definitions for textutils programs.
  2.    Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /* Include sys/types.h before this file.  */
  19.  
  20. #include <sys/stat.h>
  21.  
  22. #ifdef STAT_MACROS_BROKEN
  23. #undef S_ISBLK
  24. #undef S_ISCHR
  25. #undef S_ISDIR
  26. #undef S_ISFIFO
  27. #undef S_ISLNK
  28. #undef S_ISMPB
  29. #undef S_ISMPC
  30. #undef S_ISNWK
  31. #undef S_ISREG
  32. #undef S_ISSOCK
  33. #endif /* STAT_MACROS_BROKEN.  */
  34.  
  35. #if !defined(S_ISBLK) && defined(S_IFBLK)
  36. #define    S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  37. #endif
  38. #if !defined(S_ISCHR) && defined(S_IFCHR)
  39. #define    S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  40. #endif
  41. #if !defined(S_ISDIR) && defined(S_IFDIR)
  42. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  43. #endif
  44. #if !defined(S_ISREG) && defined(S_IFREG)
  45. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  46. #endif
  47. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  48. #define    S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  49. #endif
  50. #if !defined(S_ISLNK) && defined(S_IFLNK)
  51. #define    S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  52. #endif
  53. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  54. #define    S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  55. #endif
  56. #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
  57. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  58. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  59. #endif
  60. #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
  61. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  62. #endif
  63. #if !defined(HAVE_MKFIFO)
  64. #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
  65. #endif
  66.  
  67. #ifdef HAVE_UNISTD_H
  68. #include <unistd.h>
  69. #endif
  70. #ifndef _POSIX_VERSION
  71. off_t lseek ();
  72. #endif
  73.  
  74. #if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
  75. #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
  76. #include <memory.h>
  77. #endif
  78. #include <string.h>
  79. #ifndef index
  80. #define index strchr
  81. #endif
  82. #ifndef rindex
  83. #define rindex strrchr
  84. #endif
  85. /* Don't define bcopy; we need one that can handle overlaps.  */
  86. #ifndef bzero
  87. #define bzero(s, n) memset ((s), 0, (n))
  88. #endif
  89. #ifndef bcmp
  90. #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
  91. #endif
  92. #else
  93. #include <strings.h>
  94. char *memchr ();
  95. #endif
  96.  
  97. #include <errno.h>
  98. #ifdef STDC_HEADERS
  99. #include <stdlib.h>
  100. #else
  101. char *getenv ();
  102. extern int errno;
  103. #endif
  104.  
  105. #ifdef HAVE_FCNTL_H
  106. #include <fcntl.h>
  107. #else
  108. #include <sys/file.h>
  109. #endif
  110.  
  111. #if !defined(SEEK_SET)
  112. #define SEEK_SET 0
  113. #define SEEK_CUR 1
  114. #define SEEK_END 2
  115. #endif
  116.  
  117. #ifndef _POSIX_SOURCE
  118. #include <sys/param.h>
  119. #endif
  120.  
  121. /* Get or fake the disk device blocksize.
  122.    Usually defined by sys/param.h (if at all).  */
  123. #if !defined(DEV_BSIZE) && defined(BSIZE)
  124. #define DEV_BSIZE BSIZE
  125. #endif
  126. #if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */
  127. #define DEV_BSIZE BBSIZE
  128. #endif
  129. #ifndef DEV_BSIZE
  130. #define DEV_BSIZE 4096
  131. #endif
  132.  
  133. /* Extract or fake data from a `struct stat'.
  134.    ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. */
  135. #ifndef HAVE_ST_BLKSIZE
  136. # define ST_BLKSIZE(statbuf) DEV_BSIZE
  137. #else /* HAVE_ST_BLKSIZE */
  138. /* Some systems, like Sequents, return st_blksize of 0 on pipes. */
  139. # define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
  140.                    ? (statbuf).st_blksize : DEV_BSIZE)
  141. #endif /* HAVE_ST_BLKSIZE */
  142.  
  143. #ifndef S_ISLNK
  144. #define lstat stat
  145. #endif
  146.  
  147. #ifndef RETSIGTYPE
  148. #define RETSIGTYPE void
  149. #endif
  150.  
  151. #include <ctype.h>
  152.  
  153. #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
  154. #define ISASCII(c) 1
  155. #else
  156. #define ISASCII(c) isascii(c)
  157. #endif
  158.  
  159. #ifdef isblank
  160. #define ISBLANK(c) (ISASCII (c) && isblank (c))
  161. #else
  162. #define ISBLANK(c) ((c) == ' ' || (c) == '\t')
  163. #endif
  164. #ifdef isgraph
  165. #define ISGRAPH(c) (ISASCII (c) && isgraph (c))
  166. #else
  167. #define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
  168. #endif
  169.  
  170. #define ISPRINT(c) (ISASCII (c) && isprint (c))
  171. #define ISDIGIT(c) (ISASCII (c) && isdigit (c))
  172. #define ISALNUM(c) (ISASCII (c) && isalnum (c))
  173. #define ISALPHA(c) (ISASCII (c) && isalpha (c))
  174. #define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
  175. #define ISLOWER(c) (ISASCII (c) && islower (c))
  176. #define ISPUNCT(c) (ISASCII (c) && ispunct (c))
  177. #define ISSPACE(c) (ISASCII (c) && isspace (c))
  178. #define ISUPPER(c) (ISASCII (c) && isupper (c))
  179. #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
  180.