home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / sh-utils-1.12-src.tgz / tar.out / fsf / sh-utils / src / system.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  4KB  |  146 lines

  1. /* system-dependent definitions for shellutils programs.
  2.    Copyright (C) 89, 91, 92, 93, 1994 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. #ifndef S_IFMT
  36. #define S_IFMT 0170000
  37. #endif
  38. #if !defined(S_ISBLK) && defined(S_IFBLK)
  39. #define    S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  40. #endif
  41. #if !defined(S_ISCHR) && defined(S_IFCHR)
  42. #define    S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  43. #endif
  44. #if !defined(S_ISDIR) && defined(S_IFDIR)
  45. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  46. #endif
  47. #if !defined(S_ISREG) && defined(S_IFREG)
  48. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  49. #endif
  50. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  51. #define    S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  52. #endif
  53. #if !defined(S_ISLNK) && defined(S_IFLNK)
  54. #define    S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  55. #endif
  56. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  57. #define    S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  58. #endif
  59. #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
  60. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  61. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  62. #endif
  63. #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
  64. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  65. #endif
  66.  
  67. #ifdef HAVE_UNISTD_H
  68. #include <unistd.h>
  69. #endif
  70.  
  71. #ifndef _POSIX_VERSION
  72. char *getlogin ();
  73. char *ttyname ();
  74. off_t lseek ();
  75. uid_t geteuid ();
  76. #endif /* _POSIX_VERSION */
  77.  
  78. #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
  79. #include <string.h>
  80. #ifndef index
  81. #define index strchr
  82. #endif
  83. #ifndef rindex
  84. #define rindex strrchr
  85. #endif
  86. #ifndef bcopy
  87. #define bcopy(from, to, len) memcpy ((to), (from), (len))
  88. #endif
  89. #ifndef bzero
  90. #define bzero(s, n) memset ((s), 0, (n))
  91. #endif
  92. #else
  93. #include <strings.h>
  94. #endif
  95.  
  96. #include <errno.h>
  97. #ifdef STDC_HEADERS
  98. #include <stdlib.h>
  99. #else
  100. char *getenv ();
  101. extern int errno;
  102. #endif
  103.  
  104. #ifdef HAVE_FCNTL_H
  105. #include <fcntl.h>
  106. #else
  107. #include <sys/file.h>
  108. #endif
  109.  
  110. #ifndef F_OK
  111. #define F_OK 0
  112. #define X_OK 1
  113. #define W_OK 2
  114. #define R_OK 4
  115. #endif
  116.  
  117. #include <ctype.h>
  118.  
  119. #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
  120. #define ISASCII(c) 1
  121. #else
  122. #define ISASCII(c) isascii(c)
  123. #endif
  124.  
  125. #ifdef isblank
  126. #define ISBLANK(c) (ISASCII (c) && isblank (c))
  127. #else
  128. #define ISBLANK(c) ((c) == ' ' || (c) == '\t')
  129. #endif
  130. #ifdef isgraph
  131. #define ISGRAPH(c) (ISASCII (c) && isgraph (c))
  132. #else
  133. #define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
  134. #endif
  135.  
  136. #define ISPRINT(c) (ISASCII (c) && isprint (c))
  137. #define ISDIGIT(c) (ISASCII (c) && isdigit (c))
  138. #define ISALNUM(c) (ISASCII (c) && isalnum (c))
  139. #define ISALPHA(c) (ISASCII (c) && isalpha (c))
  140. #define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
  141. #define ISLOWER(c) (ISASCII (c) && islower (c))
  142. #define ISPUNCT(c) (ISASCII (c) && ispunct (c))
  143. #define ISSPACE(c) (ISASCII (c) && isspace (c))
  144. #define ISUPPER(c) (ISASCII (c) && isupper (c))
  145. #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
  146.