1caf54c4fSMartin Matuska /*- 2caf54c4fSMartin Matuska * Copyright (c) 2003-2007 Tim Kientzle 3caf54c4fSMartin Matuska * All rights reserved. 4caf54c4fSMartin Matuska * 5caf54c4fSMartin Matuska * Redistribution and use in source and binary forms, with or without 6caf54c4fSMartin Matuska * modification, are permitted provided that the following conditions 7caf54c4fSMartin Matuska * are met: 8caf54c4fSMartin Matuska * 1. Redistributions of source code must retain the above copyright 9caf54c4fSMartin Matuska * notice, this list of conditions and the following disclaimer. 10caf54c4fSMartin Matuska * 2. Redistributions in binary form must reproduce the above copyright 11caf54c4fSMartin Matuska * notice, this list of conditions and the following disclaimer in the 12caf54c4fSMartin Matuska * documentation and/or other materials provided with the distribution. 13caf54c4fSMartin Matuska * 14caf54c4fSMartin Matuska * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15caf54c4fSMartin Matuska * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16caf54c4fSMartin Matuska * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17caf54c4fSMartin Matuska * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18caf54c4fSMartin Matuska * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19caf54c4fSMartin Matuska * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20caf54c4fSMartin Matuska * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21caf54c4fSMartin Matuska * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22caf54c4fSMartin Matuska * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23caf54c4fSMartin Matuska * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24caf54c4fSMartin Matuska * 256c22d9efSMartin Matuska * $FreeBSD$ 26caf54c4fSMartin Matuska */ 27caf54c4fSMartin Matuska 28caf54c4fSMartin Matuska /* 29caf54c4fSMartin Matuska * This header is the first thing included in any of the bsdtar 30caf54c4fSMartin Matuska * source files. As far as possible, platform-specific issues should 31caf54c4fSMartin Matuska * be dealt with here and not within individual source files. 32caf54c4fSMartin Matuska */ 33caf54c4fSMartin Matuska 34caf54c4fSMartin Matuska #ifndef BSDTAR_PLATFORM_H_INCLUDED 35caf54c4fSMartin Matuska #define BSDTAR_PLATFORM_H_INCLUDED 36caf54c4fSMartin Matuska 37caf54c4fSMartin Matuska #if defined(PLATFORM_CONFIG_H) 38caf54c4fSMartin Matuska /* Use hand-built config.h in environments that need it. */ 39caf54c4fSMartin Matuska #include PLATFORM_CONFIG_H 40caf54c4fSMartin Matuska #else 41caf54c4fSMartin Matuska /* Not having a config.h of some sort is a serious problem. */ 42caf54c4fSMartin Matuska #include "config.h" 43caf54c4fSMartin Matuska #endif 44caf54c4fSMartin Matuska 45caf54c4fSMartin Matuska /* Get a real definition for __FBSDID if we can */ 46caf54c4fSMartin Matuska #if HAVE_SYS_CDEFS_H 47caf54c4fSMartin Matuska #include <sys/cdefs.h> 48caf54c4fSMartin Matuska #endif 49caf54c4fSMartin Matuska 50caf54c4fSMartin Matuska /* If not, define it so as to avoid dangling semicolons. */ 51caf54c4fSMartin Matuska #ifndef __FBSDID 52caf54c4fSMartin Matuska #define __FBSDID(a) struct _undefined_hack 53caf54c4fSMartin Matuska #endif 54caf54c4fSMartin Matuska 55caf54c4fSMartin Matuska #ifdef HAVE_LIBARCHIVE 56caf54c4fSMartin Matuska /* If we're using the platform libarchive, include system headers. */ 57caf54c4fSMartin Matuska #include <archive.h> 58caf54c4fSMartin Matuska #include <archive_entry.h> 59caf54c4fSMartin Matuska #else 60caf54c4fSMartin Matuska /* Otherwise, include user headers. */ 61caf54c4fSMartin Matuska #include "archive.h" 62caf54c4fSMartin Matuska #include "archive_entry.h" 63caf54c4fSMartin Matuska #endif 64caf54c4fSMartin Matuska 65caf54c4fSMartin Matuska #ifdef HAVE_LIBACL 66caf54c4fSMartin Matuska #include <acl/libacl.h> 67caf54c4fSMartin Matuska #endif 68caf54c4fSMartin Matuska 69caf54c4fSMartin Matuska /* 70*6c95142eSMartin Matuska * Include "dirent.h" (or its equivalent on several different platforms). 71caf54c4fSMartin Matuska * 72caf54c4fSMartin Matuska * This is slightly modified from the GNU autoconf recipe. 73*6c95142eSMartin Matuska * In particular, FreeBSD includes d_namlen in its dirent structure, 74caf54c4fSMartin Matuska * so my configure script includes an explicit test for the d_namlen 75caf54c4fSMartin Matuska * field. 76caf54c4fSMartin Matuska */ 77caf54c4fSMartin Matuska #if HAVE_DIRENT_H 78caf54c4fSMartin Matuska # include <dirent.h> 79caf54c4fSMartin Matuska # if HAVE_DIRENT_D_NAMLEN 80caf54c4fSMartin Matuska # define DIRENT_NAMLEN(dirent) (dirent)->d_namlen 81caf54c4fSMartin Matuska # else 82caf54c4fSMartin Matuska # define DIRENT_NAMLEN(dirent) strlen((dirent)->d_name) 83caf54c4fSMartin Matuska # endif 84caf54c4fSMartin Matuska #else 85caf54c4fSMartin Matuska # define dirent direct 86caf54c4fSMartin Matuska # define DIRENT_NAMLEN(dirent) (dirent)->d_namlen 87caf54c4fSMartin Matuska # if HAVE_SYS_NDIR_H 88caf54c4fSMartin Matuska # include <sys/ndir.h> 89caf54c4fSMartin Matuska # endif 90caf54c4fSMartin Matuska # if HAVE_SYS_DIR_H 91caf54c4fSMartin Matuska # include <sys/dir.h> 92caf54c4fSMartin Matuska # endif 93caf54c4fSMartin Matuska # if HAVE_NDIR_H 94caf54c4fSMartin Matuska # include <ndir.h> 95caf54c4fSMartin Matuska # endif 96caf54c4fSMartin Matuska #endif 97caf54c4fSMartin Matuska 98caf54c4fSMartin Matuska #if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 99caf54c4fSMartin Matuska #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctimespec.tv_nsec 100caf54c4fSMartin Matuska #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtimespec.tv_nsec 101caf54c4fSMartin Matuska #elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 102caf54c4fSMartin Matuska #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctim.tv_nsec 103caf54c4fSMartin Matuska #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtim.tv_nsec 104caf54c4fSMartin Matuska #elif HAVE_STRUCT_STAT_ST_MTIME_N 105caf54c4fSMartin Matuska #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_n 106caf54c4fSMartin Matuska #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_n 107caf54c4fSMartin Matuska #elif HAVE_STRUCT_STAT_ST_UMTIME 108caf54c4fSMartin Matuska #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_uctime * 1000 109caf54c4fSMartin Matuska #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_umtime * 1000 110caf54c4fSMartin Matuska #elif HAVE_STRUCT_STAT_ST_MTIME_USEC 111caf54c4fSMartin Matuska #define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_usec * 1000 112caf54c4fSMartin Matuska #define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_usec * 1000 113caf54c4fSMartin Matuska #else 114caf54c4fSMartin Matuska #define ARCHIVE_STAT_CTIME_NANOS(st) (0) 115caf54c4fSMartin Matuska #define ARCHIVE_STAT_MTIME_NANOS(st) (0) 116caf54c4fSMartin Matuska #endif 117caf54c4fSMartin Matuska 118caf54c4fSMartin Matuska /* How to mark functions that don't return. */ 119caf54c4fSMartin Matuska /* This facilitates use of some newer static code analysis tools. */ 120caf54c4fSMartin Matuska #undef __LA_DEAD 121caf54c4fSMartin Matuska #if defined(__GNUC__) && (__GNUC__ > 2 || \ 122caf54c4fSMartin Matuska (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) 123caf54c4fSMartin Matuska #define __LA_DEAD __attribute__((__noreturn__)) 124caf54c4fSMartin Matuska #else 125caf54c4fSMartin Matuska #define __LA_DEAD 126caf54c4fSMartin Matuska #endif 127caf54c4fSMartin Matuska 128caf54c4fSMartin Matuska #if defined(_WIN32) && !defined(__CYGWIN__) 129caf54c4fSMartin Matuska #include "bsdtar_windows.h" 130caf54c4fSMartin Matuska #endif 131caf54c4fSMartin Matuska 132caf54c4fSMartin Matuska #endif /* !BSDTAR_PLATFORM_H_INCLUDED */ 133