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