]> Dogcows Code - chaz/tar/blob - src/port.h
Fix Solaris bug where chmod fails if we don't have PRIV_SYS_LINKDIR
[chaz/tar] / src / port.h
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 _POSIX_VERSION
38 #include <sys/wait.h>
39 #else /* !_POSIX_VERSION */
40 #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
41 #define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0)
42 #define WIFEXITED(w) (((w) & 0xff) == 0)
43
44 #define WSTOPSIG(w) (((w) >> 8) & 0xff)
45 #define WTERMSIG(w) ((w) & 0x7f)
46 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
47 #endif /* _POSIX_VERSION */
48
49 /* nonstandard */
50 #ifndef WIFCOREDUMPED
51 #define WIFCOREDUMPED(w) (((w) & 0x80) != 0)
52 #endif
53
54 #ifdef __MSDOS__
55 /* missing things from sys/stat.h */
56 #define S_ISUID 0
57 #define S_ISGID 0
58 #define S_ISVTX 0
59
60 /* device stuff */
61 #define makedev(ma, mi) ((ma << 8) | mi)
62 #define major(dev) (dev)
63 #define minor(dev) (dev)
64 typedef long off_t;
65 #endif /* __MSDOS__ */
66
67 #if defined(__STDC__) || defined(__TURBOC__)
68 #define PTR void *
69 #else
70 #define PTR char *
71 #define const
72 #endif
73
74 /* Since major is a function on SVR4, we can't just use `ifndef major'. */
75 #ifdef major /* Might be defined in sys/types.h. */
76 #define HAVE_MAJOR
77 #endif
78
79 #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_MKDEV)
80 #include <sys/mkdev.h>
81 #define HAVE_MAJOR
82 #endif
83
84 #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_SYSMACROS)
85 #include <sys/sysmacros.h>
86 #define HAVE_MAJOR
87 #endif
88
89 #ifndef HAVE_MAJOR
90 #define major(dev) (((dev) >> 8) & 0xff)
91 #define minor(dev) ((dev) & 0xff)
92 #define makedev(maj, min) (((maj) << 8) | (min))
93 #endif
94 #undef HAVE_MAJOR
95
96 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
97 #include <string.h>
98 #if !defined(__MSDOS__) && !defined(STDC_HEADERS)
99 #include <memory.h>
100 #endif
101 #ifdef index
102 #undef index
103 #endif
104 #ifdef rindex
105 #undef rindex
106 #endif
107 #define index strchr
108 #define rindex strrchr
109 #define bcopy(s, d, n) memcpy(d, s, n)
110 #define bzero(s, n) memset(s, 0, n)
111 #define bcmp memcmp
112 #else
113 #include <strings.h>
114 #endif
115
116 #if defined(STDC_HEADERS)
117 #include <stdlib.h>
118 #else
119 char *malloc (), *realloc ();
120 char *getenv ();
121 #endif
122
123 #ifndef _POSIX_VERSION
124 #ifdef __MSDOS__
125 #include <io.h>
126 #else /* !__MSDOS__ */
127 off_t lseek ();
128 #endif /* !__MSDOS__ */
129 char *getcwd ();
130 #endif /* !_POSIX_VERSION */
131
132 #ifndef NULL
133 #define NULL 0
134 #endif
135
136 #ifndef O_BINARY
137 #define O_BINARY 0
138 #endif
139 #ifndef O_CREAT
140 #define O_CREAT 0
141 #endif
142 #ifndef O_NDELAY
143 #define O_NDELAY 0
144 #endif
145 #ifndef O_RDONLY
146 #define O_RDONLY 0
147 #endif
148 #ifndef O_RDWR
149 #define O_RDWR 2
150 #endif
151
152 #include <sys/stat.h>
153 #ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
154 #define mode_t unsigned short
155 #endif
156 #if !defined(S_ISBLK) && defined(S_IFBLK)
157 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
158 #endif
159 #if !defined(S_ISCHR) && defined(S_IFCHR)
160 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
161 #endif
162 #if !defined(S_ISDIR) && defined(S_IFDIR)
163 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
164 #endif
165 #if !defined(S_ISREG) && defined(S_IFREG)
166 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
167 #endif
168 #if !defined(S_ISFIFO) && defined(S_IFIFO)
169 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
170 #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
171 #endif
172 #if !defined(S_ISLNK) && defined(S_IFLNK)
173 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
174 #endif
175 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
176 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
177 #endif
178 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
179 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
180 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
181 #endif
182 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
183 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
184 #endif
185 #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
186 #define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
187 #endif
188 #if !defined(S_ISVTX)
189 #define S_ISVTX 0001000
190 #endif
191
192 #ifdef __MSDOS__
193 #include "msd_dir.h"
194 #define NLENGTH(direct) ((direct)->d_namlen)
195
196 #else /* not __MSDOS__ */
197
198 #if defined(DIRENT) || defined(_POSIX_VERSION)
199 #include <dirent.h>
200 #define NLENGTH(direct) (strlen((direct)->d_name))
201 #else /* not (DIRENT or _POSIX_VERSION) */
202 #define dirent direct
203 #define NLENGTH(direct) ((direct)->d_namlen)
204 #ifdef SYSNDIR
205 #include <sys/ndir.h>
206 #endif /* SYSNDIR */
207 #ifdef SYSDIR
208 #include <sys/dir.h>
209 #endif /* SYSDIR */
210 #ifdef NDIR
211 #include <ndir.h>
212 #endif /* NDIR */
213 #endif /* DIRENT or _POSIX_VERSION */
214
215 #endif /* not __MSDOS__ */
This page took 0.040146 seconds and 4 git commands to generate.