Merge from vendor branch BIND:
[dragonfly.git] / contrib / libarchive-1.3.1 / tar / bsdtar_platform.h
1 /*-
2  * Copyright (c) 2003-2004 Tim Kientzle
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer
10  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD: src/usr.bin/tar/bsdtar_platform.h,v 1.20 2006/03/21 17:03:51 kientzle Exp $
27  */
28
29 /*
30  * This header is the first thing included in any of the bsdtar
31  * source files.  As far as possible, platform-specific issues should
32  * be dealt with here and not within individual source files.
33  */
34
35 #ifndef BSDTAR_PLATFORM_H_INCLUDED
36 #define BSDTAR_PLATFORM_H_INCLUDED
37
38 #if HAVE_CONFIG_H
39 #include "../config.h"
40 #else
41
42 #ifdef __FreeBSD__
43 #include <sys/param.h>  /* __FreeBSD_version */
44 /* A default configuration for FreeBSD, used if there is no config.h. */
45 #define PACKAGE_NAME "bsdtar"
46
47 #if __FreeBSD__ > 4
48 #define HAVE_ACL_GET_PERM 0
49 #define HAVE_ACL_GET_PERM_NP 1
50 #define HAVE_ACL_PERMSET_T 1
51 #endif
52 #define HAVE_BZLIB_H 1
53 #define HAVE_CHFLAGS 1
54 #define HAVE_DIRENT_D_NAMLEN 1
55 #define HAVE_DIRENT_H 1
56 #define HAVE_D_MD_ORDER 1
57 #define HAVE_FCHDIR 1
58 #define HAVE_FCNTL_H 1
59 #define HAVE_FNMATCH 1
60 #define HAVE_FNM_LEADING_DIR 1
61 #define HAVE_FTRUNCATE 1
62 #define HAVE_GETOPT_LONG 1
63 #define HAVE_INTTYPES_H 1
64 #define HAVE_LANGINFO_H 1
65 #define HAVE_LIBARCHIVE 1
66 #define HAVE_LIBBZ2 1
67 #define HAVE_LIBZ 1
68 #define HAVE_LIMITS_H 1
69 #define HAVE_LOCALE_H 1
70 #define HAVE_MALLOC 1
71 #define HAVE_MEMMOVE 1
72 #define HAVE_MEMORY_H 1
73 #define HAVE_MEMSET 1
74 #if __FreeBSD_version >= 450002 /* nl_langinfo introduced */
75 #define HAVE_NL_LANGINFO 1
76 #endif
77 #define HAVE_PATHS_H 1
78 #define HAVE_SETLOCALE 1
79 #define HAVE_STDINT_H 1
80 #define HAVE_STDLIB_H 1
81 #define HAVE_STRCHR 1
82 #define HAVE_STRDUP 1
83 #define HAVE_STRERROR 1
84 #define HAVE_STRFTIME 1
85 #define HAVE_STRINGS_H 1
86 #define HAVE_STRING_H 1
87 #define HAVE_STRRCHR 1
88 #define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
89 #define HAVE_STRUCT_STAT_ST_RDEV 1
90 #define HAVE_SYS_ACL_H 1
91 #define HAVE_SYS_IOCTL_H 1
92 #define HAVE_SYS_PARAM_H 1
93 #define HAVE_SYS_STAT_H 1
94 #define HAVE_SYS_TYPES_H 1
95 #define HAVE_UINTMAX_T 1
96 #define HAVE_UNISTD_H 1
97 #define HAVE_VPRINTF 1
98 #define HAVE_ZLIB_H 1
99 #define STDC_HEADERS 1
100
101 #else /* !__FreeBSD__ */
102 /* Warn if bsdtar hasn't been (automatically or manually) configured. */
103 #error Oops: No config.h and no built-in configuration in bsdtar_platform.h.
104 #endif /* !__FreeBSD__ */
105
106 #endif /* !HAVE_CONFIG_H */
107
108 /* No non-FreeBSD platform will have __FBSDID, so just define it here. */
109 #ifdef __FreeBSD__
110 #include <sys/cdefs.h>  /* For __FBSDID */
111 #else
112 #define __FBSDID(a)     /* null */
113 #endif
114
115 #ifdef HAVE_LIBARCHIVE
116 /* If we're using the platform libarchive, include system headers. */
117 #include <archive.h>
118 #include <archive_entry.h>
119 #else
120 /* Otherwise, include user headers. */
121 #include "archive.h"
122 #include "archive_entry.h"
123 #endif
124
125 /*
126  * Does this platform have complete-looking POSIX-style ACL support,
127  * including some variant of the acl_get_perm() function (which was
128  * omitted from the POSIX.1e draft)?
129  */
130 #if HAVE_SYS_ACL_H && HAVE_ACL_PERMSET_T && HAVE_ACL_USER
131 #if HAVE_ACL_GET_PERM || HAVE_ACL_GET_PERM_NP
132 #define HAVE_POSIX_ACL  1
133 #endif
134 #endif
135
136 #ifdef HAVE_LIBACL
137 #include <acl/libacl.h>
138 #endif
139
140 #if HAVE_ACL_GET_PERM
141 #define ACL_GET_PERM acl_get_perm
142 #else
143 #if HAVE_ACL_GET_PERM_NP
144 #define ACL_GET_PERM acl_get_perm_np
145 #endif
146 #endif
147
148 /*
149  * Include "dirent.h" (or it's equivalent on several different platforms).
150  *
151  * This is slightly modified from the GNU autoconf recipe.
152  * In particular, FreeBSD includes d_namlen in it's dirent structure,
153  * so my configure script includes an explicit test for the d_namlen
154  * field.
155  */
156 #if HAVE_DIRENT_H
157 # include <dirent.h>
158 # if HAVE_DIRENT_D_NAMLEN
159 #  define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
160 # else
161 #  define DIRENT_NAMLEN(dirent) strlen((dirent)->d_name)
162 # endif
163 #else
164 # define dirent direct
165 # define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
166 # if HAVE_SYS_NDIR_H
167 #  include <sys/ndir.h>
168 # endif
169 # if HAVE_SYS_DIR_H
170 #  include <sys/dir.h>
171 # endif
172 # if HAVE_NDIR_H
173 #  include <ndir.h>
174 # endif
175 #endif
176
177
178 /*
179  * We need to be able to display a filesize using printf().  The type
180  * and format string here must be compatible with one another and
181  * large enough for any file.
182  */
183 #if HAVE_UINTMAX_T
184 #define BSDTAR_FILESIZE_TYPE    uintmax_t
185 #define BSDTAR_FILESIZE_PRINTF  "%ju"
186 #else
187 #if HAVE_UNSIGNED_LONG_LONG
188 #define BSDTAR_FILESIZE_TYPE    unsigned long long
189 #define BSDTAR_FILESIZE_PRINTF  "%llu"
190 #else
191 #define BSDTAR_FILESIZE_TYPE    unsigned long
192 #define BSDTAR_FILESIZE_PRINTF  "%lu"
193 #endif
194 #endif
195
196 #if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
197 #define ARCHIVE_STAT_CTIME_NANOS(st)    (st)->st_ctimespec.tv_nsec
198 #define ARCHIVE_STAT_MTIME_NANOS(st)    (st)->st_mtimespec.tv_nsec
199 #else
200 #if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
201 #define ARCHIVE_STAT_CTIME_NANOS(st)    (st)->st_ctim.tv_nsec
202 #define ARCHIVE_STAT_MTIME_NANOS(st)    (st)->st_mtim.tv_nsec
203 #else
204 #define ARCHIVE_STAT_CTIME_NANOS(st)    (0)
205 #define ARCHIVE_STAT_MTIME_NANOS(st)    (0)
206 #endif
207 #endif
208
209 #endif /* !BSDTAR_PLATFORM_H_INCLUDED */