]> Dogcows Code - chaz/tar/blob - src/port.h
481f36ab3f4aaefbf80e85e5fa37e5fc144b1543
[chaz/tar] / src / port.h
1 /* Portability declarations. Requires sys/types.h.
2 Copyright (C) 1988 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 #include "pathmax.h"
21
22 #ifdef __GNUC__
23 #define alloca __builtin_alloca
24 #endif
25
26 #ifdef _POSIX_VERSION
27 #include <sys/wait.h>
28 #else /* !_POSIX_VERSION */
29 #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
30 #define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0)
31 #define WIFEXITED(w) (((w) & 0xff) == 0)
32
33 #define WSTOPSIG(w) (((w) >> 8) & 0xff)
34 #define WTERMSIG(w) ((w) & 0x7f)
35 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
36 #endif /* _POSIX_VERSION */
37
38 /* nonstandard */
39 #ifndef WIFCOREDUMPED
40 #define WIFCOREDUMPED(w) (((w) & 0x80) != 0)
41 #endif
42
43 #ifdef __MSDOS__
44 /* missing things from sys/stat.h */
45 #define S_ISUID 0
46 #define S_ISGID 0
47 #define S_ISVTX 0
48
49 /* device stuff */
50 #define makedev(ma, mi) ((ma << 8) | mi)
51 #define major(dev) (dev)
52 #define minor(dev) (dev)
53 typedef long off_t;
54 #endif /* __MSDOS__ */
55
56 #if defined(__STDC__) || defined(__TURBOC__)
57 #define PTR void *
58 #else
59 #define PTR char *
60 #define const
61 #endif
62
63 /* Since major is a function on SVR4, we can't just use `ifndef major'. */
64 #ifdef major /* Might be defined in sys/types.h. */
65 #define HAVE_MAJOR
66 #endif
67
68 #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_MKDEV)
69 #include <sys/mkdev.h>
70 #define HAVE_MAJOR
71 #endif
72
73 #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_SYSMACROS)
74 #include <sys/sysmacros.h>
75 #define HAVE_MAJOR
76 #endif
77
78 #ifndef HAVE_MAJOR
79 #define major(dev) (((dev) >> 8) & 0xff)
80 #define minor(dev) ((dev) & 0xff)
81 #define makedev(maj, min) (((maj) << 8) | (min))
82 #endif
83 #undef HAVE_MAJOR
84
85 #if defined(STDC_HEADERS) || defined(USG)
86 #include <string.h>
87 #if !defined(__MSDOS__) && !defined(STDC_HEADERS)
88 #include <memory.h>
89 #endif
90 #define index strchr
91 #define rindex strrchr
92 #define bcopy(s, d, n) memcpy(d, s, n)
93 #define bzero(s, n) memset(s, 0, n)
94 #define bcmp memcmp
95 #else
96 #include <strings.h>
97 #endif
98
99 #if defined(STDC_HEADERS)
100 #include <stdlib.h>
101 #else
102 char *malloc(), *realloc();
103 char *getenv();
104 #endif
105
106 #ifndef _POSIX_VERSION
107 #ifdef __MSDOS__
108 #include <io.h>
109 #else /* !__MSDOS__ */
110 off_t lseek();
111 #endif /* !__MSDOS__ */
112 char *getcwd();
113 #endif /* !_POSIX_VERSION */
114
115 #ifndef NULL
116 #define NULL 0
117 #endif
118
119 #ifndef O_BINARY
120 #define O_BINARY 0
121 #endif
122 #ifndef O_CREAT
123 #define O_CREAT 0
124 #endif
125 #ifndef O_NDELAY
126 #define O_NDELAY 0
127 #endif
128 #ifndef O_RDONLY
129 #define O_RDONLY 0
130 #endif
131 #ifndef O_RDWR
132 #define O_RDWR 2
133 #endif
134
135 #include <sys/stat.h>
136 #ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
137 #define mode_t unsigned short
138 #endif
139 #if !defined(S_ISBLK) && defined(S_IFBLK)
140 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
141 #endif
142 #if !defined(S_ISCHR) && defined(S_IFCHR)
143 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
144 #endif
145 #if !defined(S_ISDIR) && defined(S_IFDIR)
146 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
147 #endif
148 #if !defined(S_ISREG) && defined(S_IFREG)
149 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
150 #endif
151 #if !defined(S_ISFIFO) && defined(S_IFIFO)
152 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
153 #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
154 #endif
155 #if !defined(S_ISLNK) && defined(S_IFLNK)
156 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
157 #endif
158 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
159 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
160 #endif
161 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
162 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
163 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
164 #endif
165 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
166 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
167 #endif
168 #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
169 #define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
170 #endif
171 #if !defined(S_ISVTX)
172 #define S_ISVTX 0001000
173 #endif
This page took 0.040831 seconds and 3 git commands to generate.