home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / unix / unixports / tarsrc / tar1112 / h / port < prev    next >
Encoding:
Text File  |  1994-02-11  |  5.9 KB  |  249 lines

  1. /* Portability declarations.  Requires sys/types.h.
  2.    Copyright (C) 1988, 1992 Free Software Foundation
  3.  
  4. This file is part of GNU Tar.
  5.  
  6. GNU Tar 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 Tar 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 Tar; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* AIX requires this to be the first thing in the file. */
  21. #ifdef __GNUC__
  22. #define alloca __builtin_alloca
  23. #else /* not __GNUC__ */
  24. #if HAVE_ALLOCA_H
  25. #include <alloca.h>
  26. #else /* not HAVE_ALLOCA_H */
  27. #ifdef _AIX
  28.  #pragma alloca
  29. #else /* not _AIX */
  30. char *alloca ();
  31. #endif /* not _AIX */
  32. #endif /* not HAVE_ALLOCA_H */
  33. #endif /* not __GNUC__ */
  34.  
  35. #include "pathmax.h"
  36.  
  37. #ifdef ARCH
  38. #define setmode(x,y)
  39. #endif
  40.  
  41. #ifdef _POSIX_VERSION
  42. #include <sys/wait.h>
  43. #else /* !_POSIX_VERSION */
  44. #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
  45. #define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0)
  46. #define WIFEXITED(w) (((w) & 0xff) == 0)
  47.  
  48. #define WSTOPSIG(w) (((w) >> 8) & 0xff)
  49. #define WTERMSIG(w) ((w) & 0x7f)
  50. #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
  51. #endif /* _POSIX_VERSION */
  52.  
  53. /* nonstandard */
  54. #ifndef WIFCOREDUMPED
  55. #define WIFCOREDUMPED(w) (((w) & 0x80) != 0)
  56. #endif
  57.  
  58. #ifdef __MSDOS__
  59. /* missing things from sys/stat.h */
  60. #define    S_ISUID        0
  61. #define    S_ISGID        0
  62. #define    S_ISVTX        0
  63.  
  64. /* device stuff */
  65. #define    makedev(ma, mi)        ((ma << 8) | mi)
  66. #define    major(dev)        (dev)
  67. #define    minor(dev)        (dev)
  68. typedef long off_t;
  69. #endif /* __MSDOS__ */
  70.  
  71. #if defined(__STDC__) || defined(__TURBOC__)
  72. #define PTR void *
  73. #else
  74. #define PTR char *
  75. #define const
  76. #endif
  77.  
  78. /* Since major is a function on SVR4, we can't just use `ifndef major'.  */
  79. #ifdef major            /* Might be defined in sys/types.h.  */
  80. #define HAVE_MAJOR
  81. #endif
  82.  
  83. #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_MKDEV)
  84. #include <sys/mkdev.h>
  85. #define HAVE_MAJOR
  86. #endif
  87.  
  88. #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_SYSMACROS)
  89. #include <sys/sysmacros.h>
  90. #define HAVE_MAJOR
  91. #endif
  92.  
  93. #ifndef HAVE_MAJOR
  94. #define major(dev)  (((dev) >> 8) & 0xff)
  95. #define minor(dev)  ((dev) & 0xff)
  96. #define makedev(maj, min)  (((maj) << 8) | (min))
  97. #endif
  98. #undef HAVE_MAJOR
  99.  
  100. #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
  101. #include <string.h>
  102. #if !defined(__MSDOS__) && !defined(STDC_HEADERS)
  103. #include <memory.h>
  104. #endif
  105. #ifdef index
  106. #undef index
  107. #endif
  108. #ifdef rindex
  109. #undef rindex
  110. #endif
  111. #define index strchr
  112. #define rindex strrchr
  113. #ifdef bcopy
  114. #undef bcopy
  115. #endif
  116. #ifdef bzero
  117. #undef bzero
  118. #endif
  119. #ifdef bcmp
  120. #undef bcmp
  121. #endif
  122. #define bcopy(s, d, n) memcpy(d, s, n)
  123. #define bzero(s, n) memset(s, 0, n)
  124. #define bcmp memcmp
  125. #else
  126. #include <strings.h>
  127. #endif
  128.  
  129. #if defined(STDC_HEADERS)
  130. #include <stdlib.h>
  131. #else
  132. char *malloc (), *realloc ();
  133. char *getenv ();
  134. #endif
  135.  
  136. #ifndef _POSIX_VERSION
  137. #ifdef __MSDOS__
  138. #include <io.h>
  139. #else /* !__MSDOS__ */
  140. #ifndef ARCH
  141. off_t lseek ();
  142. #endif
  143. #endif /* !__MSDOS__ */
  144. char *getcwd ();
  145. #endif /* !_POSIX_VERSION */
  146.  
  147. #ifndef NULL
  148. #define NULL 0
  149. #endif
  150.  
  151. #ifndef    O_BINARY
  152. #define    O_BINARY    0
  153. #endif
  154. #ifndef O_CREAT
  155. #define O_CREAT        0
  156. #endif
  157. #ifndef    O_NDELAY
  158. #define    O_NDELAY    0
  159. #endif
  160. #ifndef    O_RDONLY
  161. #define    O_RDONLY    0
  162. #endif
  163. #ifndef O_RDWR
  164. #define O_RDWR        2
  165. #endif
  166.  
  167. #include <sys/stat.h>
  168. #ifndef S_ISREG            /* Doesn't have POSIX.1 stat stuff. */
  169. #define mode_t unsigned short
  170. #endif
  171. #if !defined(S_ISBLK) && defined(S_IFBLK)
  172. #define    S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  173. #endif
  174. #if !defined(S_ISCHR) && defined(S_IFCHR)
  175. #define    S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  176. #endif
  177. #if !defined(S_ISDIR) && defined(S_IFDIR)
  178. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  179. #endif
  180. #if !defined(S_ISREG) && defined(S_IFREG)
  181. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  182. #endif
  183. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  184. #define    S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  185. #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
  186. #endif
  187. #if !defined(S_ISLNK) && defined(S_IFLNK) && !defined(ARCH)
  188. #define    S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  189. #endif
  190. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  191. #define    S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  192. #endif
  193. #if !defined(S_ISMPB) && defined(S_IFMPB)    /* V7 */
  194. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  195. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  196. #endif
  197. #if !defined(S_ISNWK) && defined(S_IFNWK)    /* HP/UX */
  198. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  199. #endif
  200. #if !defined(S_ISCTG) && defined(S_IFCTG)    /* contiguous file */
  201. #define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
  202. #endif
  203. #if !defined(S_ISVTX)
  204. #define S_ISVTX 0001000
  205. #endif
  206.  
  207. #ifdef __MSDOS__
  208. #include "msd_dir.h"
  209. #define NLENGTH(direct) ((direct)->d_namlen)
  210.  
  211. #else /* not __MSDOS__ */
  212.  
  213. #if defined(DIRENT) || defined(_POSIX_VERSION)
  214. #include <dirent.h>
  215. # ifdef ARCH
  216. /* Hacks to fix UnixLib 3.6c bugs
  217.  */
  218.  
  219. /* As supplied, UnixLib can only hold one directory open.
  220.  * If you try to open two, it returns a valid directory pointer,
  221.  * but overwrites the old version. This stops tar from recursing the
  222.  * directory tree. dirent.c is a fixed version of UnixLib's dirent.
  223.  */
  224. # define opendir(x)        fix_opendir(x)
  225. # define readdir(x)        fix_readdir(x)
  226. # define telldir(x)        fix_telldir(x)
  227. # define seekdir(x,y)    fix_seekdir(x,y)
  228. # undef rewinddir
  229. # define rewinddir(x)    fix_rewinddir(x)
  230. # define closedir(x)    fix_closedir(x)
  231.  
  232. # endif /* ARCH */
  233. #define NLENGTH(direct) (strlen((direct)->d_name))
  234. #else /* not (DIRENT or _POSIX_VERSION) */
  235. #define dirent direct
  236. #define NLENGTH(direct) ((direct)->d_namlen)
  237. #ifdef SYSNDIR
  238. #include <sys/ndir.h>
  239. #endif /* SYSNDIR */
  240. #ifdef SYSDIR
  241. #include <sys/dir.h>
  242. #endif /* SYSDIR */
  243. #ifdef NDIR
  244. #include <ndir.h>
  245. #endif /* NDIR */
  246. #endif /* DIRENT or _POSIX_VERSION */
  247.  
  248. #endif /* not __MSDOS__ */
  249.