]> Dogcows Code - chaz/tar/blob - src/port.h
Initial revision
[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 use `ifndef major'. */
60 #ifdef MAJOR_IN_MKDEV
61 #include <sys/mkdev.h>
62 #define HAVE_MAJOR
63 #endif
64 #ifdef MAJOR_IN_SYSMACROS
65 #include <sys/sysmacros.h>
66 #define HAVE_MAJOR
67 #endif
68 #ifdef major /* Might be defined in sys/types.h. */
69 #define HAVE_MAJOR
70 #endif
71
72 #ifndef HAVE_MAJOR
73 #define major(dev) (((dev) >> 8) & 0xff)
74 #define minor(dev) ((dev) & 0xff)
75 #define makedev(maj, min) (((maj) << 8) | (min))
76 #endif
77 #undef HAVE_MAJOR
78
79 #if defined(STDC_HEADERS) || defined(USG)
80 #include <string.h>
81 #if !defined(__MSDOS__) && !defined(STDC_HEADERS)
82 #include <memory.h>
83 #endif
84 #define index strchr
85 #define rindex strrchr
86 #define bcopy(s, d, n) memcpy(d, s, n)
87 #define bzero(s, n) memset(s, 0, n)
88 #define bcmp memcmp
89 #else
90 #include <strings.h>
91 #endif
92
93 #if defined(STDC_HEADERS)
94 #include <stdlib.h>
95 #else
96 char *malloc(), *realloc();
97 char *getenv();
98 #endif
99
100 #ifndef _POSIX_VERSION
101 #ifdef __MSDOS__
102 #include <io.h>
103 #else /* !__MSDOS__ */
104 off_t lseek();
105 #endif /* !__MSDOS__ */
106 char *getcwd();
107 #endif /* !_POSIX_VERSION */
108
109 #ifndef NULL
110 #define NULL 0
111 #endif
112
113 #ifndef O_BINARY
114 #define O_BINARY 0
115 #endif
116 #ifndef O_CREAT
117 #define O_CREAT 0
118 #endif
119 #ifndef O_NDELAY
120 #define O_NDELAY 0
121 #endif
122 #ifndef O_RDONLY
123 #define O_RDONLY 0
124 #endif
125 #ifndef O_RDWR
126 #define O_RDWR 2
127 #endif
128
129 #include <sys/stat.h>
130 #ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
131 #define mode_t unsigned short
132 #endif
133 #if !defined(S_ISBLK) && defined(S_IFBLK)
134 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
135 #endif
136 #if !defined(S_ISCHR) && defined(S_IFCHR)
137 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
138 #endif
139 #if !defined(S_ISDIR) && defined(S_IFDIR)
140 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
141 #endif
142 #if !defined(S_ISREG) && defined(S_IFREG)
143 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
144 #endif
145 #if !defined(S_ISFIFO) && defined(S_IFIFO)
146 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
147 #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
148 #endif
149 #if !defined(S_ISLNK) && defined(S_IFLNK)
150 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
151 #endif
152 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
153 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
154 #endif
155 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
156 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
157 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
158 #endif
159 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
160 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
161 #endif
162 #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
163 #define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
164 #endif
165 #if !defined(S_ISVTX)
166 #define S_ISVTX 0001000
167 #endif
This page took 0.049815 seconds and 5 git commands to generate.