Merge from vendor branch ZLIB:
[dragonfly.git] / contrib / cpio / system.h
1 /* System dependent declarations.  Requires sys/types.h.
2    Copyright (C) 1992 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
17
18 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
19 #include <string.h>
20 #ifndef index
21 #define index   strchr
22 #endif
23 #ifndef rindex
24 #define rindex  strrchr
25 #endif
26 #ifndef bcmp
27 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
28 #endif
29 #ifndef bzero
30 #define bzero(s, n)     memset ((s), 0, (n))
31 #endif
32 #else
33 #include <strings.h>
34 #endif
35
36 #include <time.h>
37
38 #ifdef STDC_HEADERS
39 #include <stdlib.h>
40 #endif
41
42 #ifdef HAVE_UNISTD_H
43 #include <unistd.h>
44 #endif
45
46 #ifndef SEEK_SET
47 #define SEEK_SET 0
48 #define SEEK_CUR 1
49 #define SEEK_END 2
50 #endif
51
52 #ifndef _POSIX_VERSION
53 #if defined(__MSDOS__) && !defined(__GNUC__)
54 typedef long off_t;
55 #endif
56 off_t lseek ();
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
65 #ifdef MAJOR_IN_SYSMACROS
66 #include <sys/sysmacros.h>
67 #define HAVE_MAJOR
68 #endif
69
70 #ifdef major                    /* Might be defined in sys/types.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(ma, mi) (((ma) << 8) | (mi))
78 #endif
79 #undef HAVE_MAJOR
80
81 #if defined(__MSDOS__) || defined(_POSIX_VERSION) || defined(HAVE_FCNTL_H)
82 #include <fcntl.h>
83 #else
84 #include <sys/file.h>
85 #endif
86 #ifndef O_BINARY
87 #define O_BINARY 0
88 #endif
89
90 #include <errno.h>
91 #ifndef errno
92 extern int errno;
93 #endif
94 #ifdef __EMX__                  /* gcc on OS/2.  */
95 #define EPERM EACCES
96 #define ENXIO EIO
97 #endif
98
99 #ifdef HAVE_UTIME_H
100 #include <utime.h>
101 #else
102 struct utimbuf
103 {
104   time_t actime;
105   time_t modtime;
106 };
107 #endif
108
109 #ifdef TRUE
110 #undef TRUE
111 #endif
112 #define TRUE 1
113 #ifdef FALSE
114 #undef FALSE
115 #endif
116 #define FALSE 0
117
118 #ifndef __MSDOS__
119 #define CONSOLE "/dev/tty"
120 #else
121 #define CONSOLE "con"
122 #endif
123
124 #if defined(__MSDOS__) && !defined(__GNUC__)
125 typedef int uid_t;
126 typedef int gid_t;
127 #endif
128
129 /* On most systems symlink() always creates links with rwxrwxrwx
130    protection modes, but on some (HP/UX 8.07; I think maybe DEC's OSF
131    on MIPS too) symlink() uses the value of umask, so links' protection modes
132    aren't always rwxrwxrwx.  There doesn't seem to be any way to change
133    the modes of a link (no system call like, say, lchmod() ), it seems
134    the only way to set the modes right is to set umask before calling
135    symlink(). */
136
137 #ifndef SYMLINK_USES_UMASK
138 #define UMASKED_SYMLINK(name1,name2,mode)    symlink(name1,name2)
139 #else
140 #define UMASKED_SYMLINK(name1,name2,mode)    umasked_symlink(name1,name2,mode)
141 #endif /* SYMLINK_USES_UMASK */
142