home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / useful / dist / gnu / textutils / textutils-1.6-amiga / src / system.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-20  |  4.4 KB  |  167 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. #ifndef S_ISREG            /* Doesn't have POSIX.1 stat stuff. */
  22. #define mode_t unsigned short
  23. #endif
  24. #if !defined(S_ISBLK) && defined(S_IFBLK)
  25. #define    S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  26. #endif
  27. #if !defined(S_ISCHR) && defined(S_IFCHR)
  28. #define    S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  29. #endif
  30. #if !defined(S_ISDIR) && defined(S_IFDIR)
  31. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  32. #endif
  33. #if !defined(S_ISREG) && defined(S_IFREG)
  34. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  35. #endif
  36. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  37. #define    S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  38. #endif
  39. #if !defined(S_ISLNK) && defined(S_IFLNK)
  40. #define    S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  41. #endif
  42. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  43. #define    S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  44. #endif
  45. #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
  46. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  47. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  48. #endif
  49. #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
  50. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  51. #endif
  52. #if !defined(HAVE_MKFIFO)
  53. #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
  54. #endif
  55.  
  56. #ifdef HAVE_UNISTD_H
  57. #include <unistd.h>
  58. #endif
  59. #ifndef _POSIX_VERSION
  60. off_t lseek ();
  61. #endif
  62.  
  63. #if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
  64. #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
  65. #include <memory.h>
  66. #endif
  67. #include <string.h>
  68. #ifndef index
  69. #define index strchr
  70. #endif
  71. #ifndef rindex
  72. #define rindex strrchr
  73. #endif
  74. /* Don't define bcopy; we need one that can handle overlaps.  */
  75. #ifndef bzero
  76. #define bzero(s, n) memset ((s), 0, (n))
  77. #endif
  78. #ifndef bcmp
  79. #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
  80. #endif
  81. #else
  82. #include <strings.h>
  83. char *memchr ();
  84. #endif
  85.  
  86. #include <errno.h>
  87. #ifdef STDC_HEADERS
  88. #include <stdlib.h>
  89. #else
  90. char *getenv ();
  91. extern int errno;
  92. #endif
  93.  
  94. #if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
  95. #include <fcntl.h>
  96. #else
  97. #include <sys/file.h>
  98. #endif
  99.  
  100. #if !defined(SEEK_SET)
  101. #define SEEK_SET 0
  102. #define SEEK_CUR 1
  103. #define SEEK_END 2
  104. #endif
  105.  
  106. #ifndef _POSIX_SOURCE
  107. #include <sys/param.h>
  108. #endif
  109.  
  110. /* Get or fake the disk device blocksize.
  111.    Usually defined by sys/param.h (if at all).  */
  112. #if !defined(DEV_BSIZE) && defined(BSIZE)
  113. #define DEV_BSIZE BSIZE
  114. #endif
  115. #if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */
  116. #define DEV_BSIZE BBSIZE
  117. #endif
  118. #ifndef DEV_BSIZE
  119. #define DEV_BSIZE 4096
  120. #endif
  121.  
  122. /* Extract or fake data from a `struct stat'.
  123.    ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes. */
  124. #ifndef HAVE_ST_BLKSIZE
  125. # define ST_BLKSIZE(statbuf) DEV_BSIZE
  126. #else /* HAVE_ST_BLKSIZE */
  127. /* Some systems, like Sequents, return st_blksize of 0 on pipes. */
  128. # define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
  129.                    ? (statbuf).st_blksize : DEV_BSIZE)
  130. #endif /* HAVE_ST_BLKSIZE */
  131.  
  132. #ifndef S_ISLNK
  133. #define lstat stat
  134. #endif
  135.  
  136. #ifndef RETSIGTYPE
  137. #define RETSIGTYPE void
  138. #endif
  139.  
  140. #include <ctype.h>
  141.  
  142. #ifndef isascii
  143. #define isascii(c) 1
  144. #endif
  145.  
  146. #ifdef isblank
  147. #define ISBLANK(c) (isascii (c) && isblank (c))
  148. #else
  149. #define ISBLANK(c) ((c) == ' ' || (c) == '\t')
  150. #endif
  151. #ifdef isgraph
  152. #define ISGRAPH(c) (isascii (c) && isgraph (c))
  153. #else
  154. #define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c))
  155. #endif
  156.  
  157. #define ISPRINT(c) (isascii (c) && isprint (c))
  158. #define ISDIGIT(c) (isascii (c) && isdigit (c))
  159. #define ISALNUM(c) (isascii (c) && isalnum (c))
  160. #define ISALPHA(c) (isascii (c) && isalpha (c))
  161. #define ISCNTRL(c) (isascii (c) && iscntrl (c))
  162. #define ISLOWER(c) (isascii (c) && islower (c))
  163. #define ISPUNCT(c) (isascii (c) && ispunct (c))
  164. #define ISSPACE(c) (isascii (c) && isspace (c))
  165. #define ISUPPER(c) (isascii (c) && isupper (c))
  166. #define ISXDIGIT(c) (isascii (c) && isxdigit (c))
  167.