Update vendor/libarchive/dist to git commit 61c56e5 (post 3.2.0)
This commit is contained in:
parent
8c8f03ca5b
commit
4e579f6c94
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/libarchive/dist/; revision=299425 svn path=/vendor/libarchive/3.2.0/; revision=299528; tag=vendor/libarchive/3.2.0
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
*~
|
||||
*.o
|
||||
*.exe
|
||||
*.lo
|
||||
@ -7,6 +8,8 @@ Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
bsdcat
|
||||
bsdcat_test
|
||||
bsdcpio
|
||||
bsdcpio_test
|
||||
bsdtar
|
||||
@ -24,9 +27,13 @@ build/autoconf/ltversion.m4
|
||||
build/autoconf/lt~obsolete.m4
|
||||
build/autoconf/missing
|
||||
build/pkgconfig/libarchive.pc
|
||||
cat/.deps/
|
||||
cat/.dirstamp
|
||||
cat/test/.deps/
|
||||
cat/test/.dirstamp
|
||||
cat/test/list.h
|
||||
config.h
|
||||
config.h.in
|
||||
config.h.in~
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
@ -82,3 +89,17 @@ libarchive/libarchive.so
|
||||
libarchive/libarchive.so.*
|
||||
|
||||
.DS_Store
|
||||
|
||||
bsdcat_test.log
|
||||
bsdcat_test.trs
|
||||
bsdcpio_test.log
|
||||
bsdcpio_test.trs
|
||||
bsdtar_test.log
|
||||
bsdtar_test.trs
|
||||
build/autoconf/test-driver
|
||||
libarchive_test.log
|
||||
libarchive_test.trs
|
||||
test-suite.log
|
||||
|
||||
.sw?
|
||||
.*.sw?
|
||||
|
20
.travis.yml
Normal file
20
.travis.yml
Normal file
@ -0,0 +1,20 @@
|
||||
language: C
|
||||
sudo: true
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:kubuntu-ppa/backports -y
|
||||
- sudo apt-get update -qq
|
||||
install:
|
||||
- sudo apt-get install -y cmake=2.8.12.2-0ubuntu1~ubuntu12.04.1~ppa2
|
||||
- sudo apt-get install -y libbz2-dev libzip-dev liblzma-dev
|
||||
before_script:
|
||||
- BUILD_DIR=`pwd`/BUILD
|
||||
- mkdir -p ${BUILD_DIR}
|
||||
- cd ${BUILD_DIR}
|
||||
- cmake ..
|
||||
script:
|
||||
- cd ${BUILD_DIR}
|
||||
- make
|
||||
- make test
|
262
CMakeLists.txt
262
CMakeLists.txt
@ -1,5 +1,5 @@
|
||||
#
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6 FATAL_ERROR)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
|
||||
#
|
||||
PROJECT(libarchive C)
|
||||
#
|
||||
@ -15,7 +15,7 @@ endif()
|
||||
# RelWithDebInfo : Release build with Debug Info
|
||||
# MinSizeRel : Release Min Size build
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
|
||||
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
# Set a value type to properly display CMAKE_BUILD_TYPE on GUI if the
|
||||
# value type is "UNINITIALIZED".
|
||||
@ -35,6 +35,9 @@ ENDIF(NOT "${CMAKE_BUILD_TYPE}"
|
||||
# On MacOS, prefer MacPorts libraries to system libraries.
|
||||
# I haven't come up with a compelling argument for this to be conditional.
|
||||
list(APPEND CMAKE_PREFIX_PATH /opt/local)
|
||||
# Enable @rpath in the install name.
|
||||
# detail in "cmake --help-policy CMP0042"
|
||||
SET(CMAKE_MACOSX_RPATH ON)
|
||||
|
||||
#
|
||||
# Version - read from 'version' file.
|
||||
@ -55,6 +58,7 @@ STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision})
|
||||
SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}")
|
||||
SET(BSDCPIO_VERSION_STRING "${VERSION}")
|
||||
SET(BSDTAR_VERSION_STRING "${VERSION}")
|
||||
SET(BSDCAT_VERSION_STRING "${VERSION}")
|
||||
SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}")
|
||||
SET(LIBARCHIVE_VERSION_STRING "${VERSION}")
|
||||
|
||||
@ -84,7 +88,7 @@ SET(CMAKE_REQUIRED_FLAGS)
|
||||
# Especially for early development, we want to be a little
|
||||
# aggressive about diagnosing build problems; this can get
|
||||
# relaxed somewhat in final shipping versions.
|
||||
IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$")
|
||||
SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
|
||||
#################################################################
|
||||
# Set compile flags for all build types.
|
||||
@ -92,11 +96,43 @@ IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
#################################################################
|
||||
# Set compile flags for debug build.
|
||||
# This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -Wextra -Wunused")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
|
||||
ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$")
|
||||
IF (CMAKE_C_COMPILER_ID MATCHES "^Clang$")
|
||||
SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
|
||||
#################################################################
|
||||
# Set compile flags for all build types.
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security")
|
||||
#################################################################
|
||||
# Set compile flags for debug build.
|
||||
# This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
|
||||
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^Clang$")
|
||||
IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
|
||||
SET(CMAKE_C_COMPILER "xlc_r")
|
||||
SET(CMAKE_REQUIRED_FLAGS "-qflag=e:e -qformat=sec")
|
||||
#################################################################
|
||||
# Set compile flags for all build types.
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qflag=e:e -qformat=sec")
|
||||
#################################################################
|
||||
# Set compile flags for debug build.
|
||||
# This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qhalt=w")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qflag=w:w")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qinfo=pro:use")
|
||||
ENDIF(CMAKE_C_COMPILER_ID MATCHES "^XL$")
|
||||
IF (MSVC)
|
||||
#################################################################
|
||||
# Set compile flags for debug build.
|
||||
@ -143,17 +179,36 @@ include(CTest)
|
||||
|
||||
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
|
||||
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
|
||||
OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON)
|
||||
OPTION(ENABLE_ZLIB "Enable the use of the system found ZLIB library if found" ON)
|
||||
OPTION(ENABLE_BZip2 "Enable the use of the system found BZip2 library if found" ON)
|
||||
OPTION(ENABLE_LIBXML2 "Enable the use of the system found libxml2 library if found" ON)
|
||||
OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" ON)
|
||||
OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON)
|
||||
OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON)
|
||||
# CNG is used for encrypt/decrypt Zip archives on Windows.
|
||||
OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON)
|
||||
|
||||
OPTION(ENABLE_TAR "Enable tar building" ON)
|
||||
OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE)
|
||||
OPTION(ENABLE_CPIO "Enable cpio building" ON)
|
||||
OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE)
|
||||
OPTION(ENABLE_CAT "Enable cat building" ON)
|
||||
OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE)
|
||||
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
|
||||
OPTION(ENABLE_ACL "Enable ACL support" ON)
|
||||
OPTION(ENABLE_ICONV "Enable iconv support" ON)
|
||||
OPTION(ENABLE_TEST "Enable unit and regression tests" ON)
|
||||
OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE)
|
||||
OPTION(ENABLE_INSTALL "Enable installing of libraries" ON)
|
||||
|
||||
SET(POSIX_REGEX_LIB "AUTO" CACHE STRING "Choose what library should provide POSIX regular expression support")
|
||||
SET(ENABLE_SAFESEH "AUTO" CACHE STRING "Enable use of /SAFESEH linker flag (MSVC only)")
|
||||
SET(WINDOWS_VERSION "" CACHE STRING "Set Windows version to use (Windows only)")
|
||||
SET(WINDOWS_VERSION "WIN7" CACHE STRING "Set Windows version to use (Windows only)")
|
||||
|
||||
IF(ENABLE_COVERAGE)
|
||||
include(LibarchiveCodeCoverage)
|
||||
ENDIF(ENABLE_COVERAGE)
|
||||
|
||||
IF(ENABLE_TEST)
|
||||
ENABLE_TESTING()
|
||||
@ -161,22 +216,35 @@ ENDIF(ENABLE_TEST)
|
||||
|
||||
IF(WIN32)
|
||||
IF(WINDOWS_VERSION STREQUAL "WIN8")
|
||||
SET(NTDDI_VERSION 0x06020000)
|
||||
SET(_WIN32_WINNT 0x0602)
|
||||
SET(WINVER 0x0602)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "WIN7")
|
||||
SET(NTDDI_VERSION 0x06010000)
|
||||
SET(_WIN32_WINNT 0x0601)
|
||||
SET(WINVER 0x0601)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "WS08")
|
||||
SET(NTDDI_VERSION 0x06000100)
|
||||
SET(_WIN32_WINNT 0x0600)
|
||||
SET(WINVER 0x0600)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "VISTA")
|
||||
SET(NTDDI_VERSION 0x06000000)
|
||||
SET(_WIN32_WINNT 0x0600)
|
||||
SET(WINVER 0x0600)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "WS03")
|
||||
SET(NTDDI_VERSION 0x05020000)
|
||||
SET(_WIN32_WINNT 0x0502)
|
||||
SET(WINVER 0x0502)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "WINXP")
|
||||
SET(NTDDI_VERSION 0x05010000)
|
||||
SET(_WIN32_WINNT 0x0501)
|
||||
SET(WINVER 0x0501)
|
||||
ELSE(WINDOWS_VERSION STREQUAL "WIN8")
|
||||
# The default is to use Windows 2000 API.
|
||||
SET(WINVER 0x0500)
|
||||
# Default to Windows Server 2003 API if we don't recognize the specifier
|
||||
SET(NTDDI_VERSION 0x05020000)
|
||||
SET(_WIN32_WINNT 0x0502)
|
||||
SET(WINVER 0x0502)
|
||||
ENDIF(WINDOWS_VERSION STREQUAL "WIN8")
|
||||
SET(_WIN32_WINNT ${WINVER})
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(MSVC)
|
||||
@ -184,12 +252,12 @@ IF(MSVC)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH")
|
||||
SET(CMAKE_REQUIRED_LINKER_FLAGS "/SAFESEH")
|
||||
SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH")
|
||||
ELSEIF(ENABLE_SAFESEH STREQUAL "NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
|
||||
SET(CMAKE_REQUIRED_LINKER_FLAGS "/SAFESEH:NO")
|
||||
SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH:NO")
|
||||
ENDIF(ENABLE_SAFESEH STREQUAL "YES")
|
||||
ENDIF(MSVC)
|
||||
|
||||
@ -198,8 +266,8 @@ IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$")
|
||||
ENDIF()
|
||||
|
||||
#
|
||||
INCLUDE(LibarchiveCheckCSourceCompiles)
|
||||
INCLUDE(LibarchiveCheckCSourceRuns)
|
||||
INCLUDE(CheckCSourceCompiles)
|
||||
INCLUDE(CheckCSourceRuns)
|
||||
INCLUDE(CheckFileOffsetBits)
|
||||
INCLUDE(CheckFuncs)
|
||||
INCLUDE(CheckHeaderDirent)
|
||||
@ -263,9 +331,9 @@ MACRO (TRY_MACRO_FOR_LIBRARY INCLUDES LIBRARIES
|
||||
ENDIF(NOT "${PREV_VAR_WITH_LIB}" STREQUAL "${LIBRARIES}")
|
||||
# Check if the library can be used with the macro.
|
||||
IF("${TRY_TYPE}" MATCHES "COMPILES")
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR})
|
||||
CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR})
|
||||
ELSEIF("${TRY_TYPE}" MATCHES "RUNS")
|
||||
LIBARCHIVE_CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR})
|
||||
CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR})
|
||||
ELSE("${TRY_TYPE}" MATCHES "COMPILES")
|
||||
MESSAGE(FATAL_ERROR "UNKNOWN KEYWORD \"${TRY_TYPE}\" FOR TRY_TYPE")
|
||||
ENDIF("${TRY_TYPE}" MATCHES "COMPILES")
|
||||
@ -297,7 +365,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
|
||||
# e.g.
|
||||
# cmake -DCMAKE_PREFIX_PATH=<your-GnuWin32-path> <path-to-source>
|
||||
#
|
||||
# If compiling error occured in zconf.h, You may need patch to zconf.h.
|
||||
# If compiling error occurred in zconf.h, You may need patch to zconf.h.
|
||||
#--- zconf.h.orig 2005-07-21 00:40:26.000000000
|
||||
#+++ zconf.h 2009-01-19 11:39:10.093750000
|
||||
#@@ -286,7 +286,7 @@
|
||||
@ -315,7 +383,11 @@ SET(ADDITIONAL_LIBS "")
|
||||
#
|
||||
# Find ZLIB
|
||||
#
|
||||
FIND_PACKAGE(ZLIB)
|
||||
IF(ENABLE_ZLIB)
|
||||
FIND_PACKAGE(ZLIB)
|
||||
ELSE()
|
||||
SET(ZLIB_FOUND FALSE) # Override cached value
|
||||
ENDIF()
|
||||
IF(ZLIB_FOUND)
|
||||
SET(HAVE_LIBZ 1)
|
||||
SET(HAVE_ZLIB_H 1)
|
||||
@ -350,7 +422,11 @@ MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY)
|
||||
#
|
||||
# Find BZip2
|
||||
#
|
||||
FIND_PACKAGE(BZip2)
|
||||
IF(ENABLE_BZip2)
|
||||
FIND_PACKAGE(BZip2)
|
||||
ELSE()
|
||||
SET(BZIP2_FOUND FALSE) # Override cached value
|
||||
ENDIF()
|
||||
IF(BZIP2_FOUND)
|
||||
SET(HAVE_LIBBZ2 1)
|
||||
SET(HAVE_BZLIB_H 1)
|
||||
@ -370,10 +446,18 @@ IF(BZIP2_FOUND)
|
||||
ENDIF(BZIP2_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
|
||||
|
||||
|
||||
#
|
||||
# Find LZMA
|
||||
#
|
||||
FIND_PACKAGE(LZMA)
|
||||
IF(ENABLE_LZMA)
|
||||
FIND_PACKAGE(LZMA)
|
||||
ELSE()
|
||||
SET(LZMA_FOUND FALSE) # Override cached value
|
||||
SET(LZMADEC_FOUND FALSE) # Override cached value
|
||||
ENDIF()
|
||||
|
||||
IF(LZMA_FOUND)
|
||||
SET(HAVE_LIBLZMA 1)
|
||||
SET(HAVE_LZMA_H 1)
|
||||
@ -393,6 +477,8 @@ ELSEIF(LZMADEC_FOUND)
|
||||
SET(HAVE_LZMADEC_H 1)
|
||||
INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR})
|
||||
LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES})
|
||||
ELSE(LZMA_FOUND)
|
||||
# LZMA not found and will not be used.
|
||||
ENDIF(LZMA_FOUND)
|
||||
#
|
||||
# Find LZO2
|
||||
@ -418,6 +504,33 @@ IF(LZO2_FOUND)
|
||||
ENDIF(LZO2_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR LZO2_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR LZO2_LIBRARY)
|
||||
#
|
||||
# Find LZ4
|
||||
#
|
||||
IF (LZ4_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
SET(LZ4_FIND_QUIETLY TRUE)
|
||||
ENDIF (LZ4_INCLUDE_DIR)
|
||||
|
||||
FIND_PATH(LZ4_INCLUDE_DIR lz4.h)
|
||||
FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)
|
||||
IF(LZ4_FOUND)
|
||||
SET(HAVE_LIBLZ4 1)
|
||||
SET(HAVE_LZ4_H 1)
|
||||
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR})
|
||||
CHECK_INCLUDE_FILES("lz4hc.h" HAVE_LZ4HC_H)
|
||||
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
|
||||
INCLUDE_DIRECTORIES(${LZ4_INCLUDE_DIR})
|
||||
LIST(APPEND ADDITIONAL_LIBS ${LZ4_LIBRARY})
|
||||
#
|
||||
# TODO: test for static library.
|
||||
#
|
||||
ENDIF(LZ4_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR LZ4_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY)
|
||||
|
||||
#
|
||||
# Check headers
|
||||
@ -444,7 +557,7 @@ LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
|
||||
LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
|
||||
LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H)
|
||||
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES("#include <sys/ioctl.h>
|
||||
CHECK_C_SOURCE_COMPILES("#include <sys/ioctl.h>
|
||||
#include <ext2fs/ext2_fs.h>
|
||||
int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS)
|
||||
|
||||
@ -463,7 +576,9 @@ LA_CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
|
||||
LA_CHECK_INCLUDE_FILE("paths.h" HAVE_PATHS_H)
|
||||
LA_CHECK_INCLUDE_FILE("poll.h" HAVE_POLL_H)
|
||||
LA_CHECK_INCLUDE_FILE("process.h" HAVE_PROCESS_H)
|
||||
LA_CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H)
|
||||
LA_CHECK_INCLUDE_FILE("pwd.h" HAVE_PWD_H)
|
||||
LA_CHECK_INCLUDE_FILE("readpassphrase.h" HAVE_READPASSPHRASE_H)
|
||||
LA_CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H)
|
||||
LA_CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
|
||||
LA_CHECK_INCLUDE_FILE("spawn.h" HAVE_SPAWN_H)
|
||||
@ -494,6 +609,11 @@ LA_CHECK_INCLUDE_FILE("utime.h" HAVE_UTIME_H)
|
||||
LA_CHECK_INCLUDE_FILE("wchar.h" HAVE_WCHAR_H)
|
||||
LA_CHECK_INCLUDE_FILE("wctype.h" HAVE_WCTYPE_H)
|
||||
LA_CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
|
||||
IF(ENABLE_CNG)
|
||||
LA_CHECK_INCLUDE_FILE("Bcrypt.h" HAVE_BCRYPT_H)
|
||||
ELSE(ENABLE_CNG)
|
||||
UNSET(HAVE_BCRYPT_H CACHE)
|
||||
ENDIF(ENABLE_CNG)
|
||||
# Following files need windwos.h, so we should test it after windows.h test.
|
||||
LA_CHECK_INCLUDE_FILE("wincrypt.h" HAVE_WINCRYPT_H)
|
||||
LA_CHECK_INCLUDE_FILE("winioctl.h" HAVE_WINIOCTL_H)
|
||||
@ -507,7 +627,7 @@ FOREACH (it ${_HEADER})
|
||||
SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
|
||||
ENDFOREACH (it)
|
||||
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#define __EXTENSIONS__ 1
|
||||
${_INCLUDE_FILES}
|
||||
int main() { return 0;}"
|
||||
@ -520,11 +640,17 @@ IF(ENABLE_NETTLE)
|
||||
FIND_PACKAGE(Nettle)
|
||||
IF(NETTLE_FOUND)
|
||||
SET(HAVE_LIBNETTLE 1)
|
||||
SET(HAVE_NETTLE_MD5_H 1)
|
||||
SET(HAVE_NETTLE_RIPEMD160_H 1)
|
||||
SET(HAVE_NETTLE_SHA_H 1)
|
||||
INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR})
|
||||
LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES})
|
||||
INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR})
|
||||
|
||||
LIST(APPEND CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIR})
|
||||
LA_CHECK_INCLUDE_FILE("nettle/aes.h" HAVE_NETTLE_AES_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/hmac.h" HAVE_NETTLE_HMAC_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/md5.h" HAVE_NETTLE_MD5_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/ripemd160.h" HAVE_NETTLE_RIPEMD160_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/sha.h" HAVE_NETTLE_SHA_H)
|
||||
|
||||
ENDIF(NETTLE_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES)
|
||||
@ -536,6 +662,11 @@ ENDIF(ENABLE_NETTLE)
|
||||
#
|
||||
IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
FIND_PACKAGE(OpenSSL)
|
||||
IF(OPENSSL_FOUND)
|
||||
SET(HAVE_LIBCRYPTO 1)
|
||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||
LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_CRYPTO_LIBRARY})
|
||||
ENDIF(OPENSSL_FOUND)
|
||||
ELSE()
|
||||
SET(OPENSSL_FOUND FALSE) # Override cached value
|
||||
ENDIF()
|
||||
@ -554,7 +685,7 @@ ENDIF(NOT OPENSSL_FOUND)
|
||||
|
||||
#
|
||||
# How to prove that CRYPTO functions, which have several names on various
|
||||
# platforms, just see if archive_crypto.c can compile and link against
|
||||
# platforms, just see if archive_digest.c can compile and link against
|
||||
# required libraries.
|
||||
#
|
||||
MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION)
|
||||
@ -593,7 +724,7 @@ MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION)
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h)
|
||||
FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h"
|
||||
CONFDEFS_H)
|
||||
FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/libarchive/archive_crypto.c"
|
||||
FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/libarchive/archive_digest.c"
|
||||
ARCHIVE_CRYPTO_C)
|
||||
|
||||
SET(SOURCE "${CONFDEFS_H}
|
||||
@ -619,16 +750,10 @@ main(int argc, char **argv)
|
||||
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c" "${SOURCE}")
|
||||
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}")
|
||||
|
||||
IF(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
SET(CHECK_CRYPTO_ADD_LINKER_FLAGS
|
||||
"-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
|
||||
ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
SET(CHECK_CRYPTO_ADD_LINKER_FLAGS)
|
||||
ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
TRY_COMPILE(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c
|
||||
CMAKE_FLAGS ${CHECK_CRYPTO_ADD_LINKER_FLAGS}
|
||||
CMAKE_FLAGS
|
||||
"${TRY_CRYPTO_REQUIRED_LIBS}"
|
||||
"${TRY_CRYPTO_REQUIRED_INCLUDES}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
@ -713,16 +838,10 @@ main(int argc, char **argv)
|
||||
FILE(WRITE "${SOURCE_FILE}" "${SOURCE}")
|
||||
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN")
|
||||
|
||||
IF(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS
|
||||
"-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
|
||||
ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS)
|
||||
ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN
|
||||
${CMAKE_BINARY_DIR}
|
||||
${SOURCE_FILE}
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" ${CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS}
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
|
||||
@ -755,20 +874,25 @@ ENDMACRO(CHECK_CRYPTO_WIN CRYPTO_LIST)
|
||||
MACRO(CHECK_ICONV LIB TRY_ICONV_CONST)
|
||||
IF(NOT HAVE_ICONV)
|
||||
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
|
||||
IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
|
||||
#
|
||||
# During checking iconv proto type, we should use -Werror to avoid the
|
||||
# success of iconv detection with a warnig which success is a miss
|
||||
# detection. So this needs for all build mode(even it's a release mode).
|
||||
#
|
||||
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
|
||||
ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
|
||||
IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
|
||||
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -qhalt=w -qflag=w:w")
|
||||
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
|
||||
IF (MSVC)
|
||||
# NOTE: /WX option is the same as gcc's -Werror option.
|
||||
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX")
|
||||
ENDIF (MSVC)
|
||||
#
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
int main() {
|
||||
@ -884,7 +1008,11 @@ ENDIF(ENABLE_ICONV)
|
||||
#
|
||||
# Find Libxml2
|
||||
#
|
||||
FIND_PACKAGE(LibXml2)
|
||||
IF(ENABLE_LIBXML2)
|
||||
FIND_PACKAGE(LibXml2)
|
||||
ELSE()
|
||||
SET(LIBXML2_FOUND FALSE)
|
||||
ENDIF()
|
||||
IF(LIBXML2_FOUND)
|
||||
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
|
||||
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
|
||||
@ -909,7 +1037,11 @@ ELSE(LIBXML2_FOUND)
|
||||
#
|
||||
# Find Expat
|
||||
#
|
||||
FIND_PACKAGE(EXPAT)
|
||||
IF(ENABLE_EXPAT)
|
||||
FIND_PACKAGE(EXPAT)
|
||||
ELSE()
|
||||
SET(EXPAT_FOUND FALSE)
|
||||
ENDIF()
|
||||
IF(EXPAT_FOUND)
|
||||
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
|
||||
INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR})
|
||||
@ -979,8 +1111,16 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$"
|
||||
#
|
||||
# If requested, try finding library for PCREPOSIX
|
||||
#
|
||||
FIND_PACKAGE(LibGCC)
|
||||
FIND_PACKAGE(PCREPOSIX)
|
||||
IF(ENABLE_LibGCC)
|
||||
FIND_PACKAGE(LibGCC)
|
||||
ELSE()
|
||||
SET(LIBGCC_FOUND FALSE) # Override cached value
|
||||
ENDIF()
|
||||
IF(ENABLE_PCREPOSIX)
|
||||
FIND_PACKAGE(PCREPOSIX)
|
||||
ELSE()
|
||||
SET(PCREPOSIX_FOUND FALSE) # Override cached value
|
||||
ENDIF()
|
||||
IF(PCREPOSIX_FOUND)
|
||||
INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR})
|
||||
LIST(APPEND ADDITIONAL_LIBS ${PCREPOSIX_LIBRARIES})
|
||||
@ -1032,15 +1172,18 @@ ENDIF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX
|
||||
# Check functions
|
||||
#
|
||||
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
|
||||
IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
|
||||
#
|
||||
# During checking functions, we should use -fno-builtin to avoid the
|
||||
# failure of function detection which failure is an error "conflicting
|
||||
# types for built-in function" caused by using -Werror option.
|
||||
#
|
||||
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-builtin")
|
||||
ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
|
||||
ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
|
||||
CHECK_SYMBOL_EXISTS(_CrtSetReportMode "crtdbg.h" HAVE__CrtSetReportMode)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(arc4random_buf HAVE_ARC4RANDOM_BUF)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
|
||||
@ -1088,6 +1231,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(pipe HAVE_PIPE)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(poll HAVE_POLL)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(posix_spawnp HAVE_POSIX_SPAWNP)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(readlink HAVE_READLINK)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(readpassphrase HAVE_READPASSPHRASE)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(select HAVE_SELECT)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(setenv HAVE_SETENV)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(setlocale HAVE_SETLOCALE)
|
||||
@ -1126,19 +1270,20 @@ CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME)
|
||||
CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF)
|
||||
CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP)
|
||||
CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY)
|
||||
CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE)
|
||||
|
||||
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
|
||||
|
||||
# Make sure we have the POSIX version of readdir_r, not the
|
||||
# older 2-argument version.
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}"
|
||||
HAVE_READDIR_R)
|
||||
|
||||
|
||||
# Only detect readlinkat() if we also have AT_FDCWD in unistd.h.
|
||||
# NOTE: linux requires fcntl.h for AT_FDCWD.
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#include <fcntl.h>\n#include <unistd.h>\nint main() {char buf[10]; return readlinkat(AT_FDCWD, \"\", buf, 0);}"
|
||||
HAVE_READLINKAT)
|
||||
|
||||
@ -1147,10 +1292,10 @@ LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
# of interest and verify that the result can be linked.
|
||||
# CHECK_FUNCTION_EXISTS doesn't accept a header argument,
|
||||
# CHECK_SYMBOL_EXISTS doesn't test linkage.
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#include <sys/mkdev.h>\nint main() { return major(256); }"
|
||||
MAJOR_IN_MKDEV)
|
||||
LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#include <sys/sysmacros.h>\nint main() { return major(256); }"
|
||||
MAJOR_IN_SYSMACROS)
|
||||
|
||||
@ -1171,10 +1316,15 @@ ENDIF(HAVE_INTTYPES_H)
|
||||
CHECK_SYMBOL_EXISTS(EFTYPE "errno.h" HAVE_EFTYPE)
|
||||
CHECK_SYMBOL_EXISTS(EILSEQ "errno.h" HAVE_EILSEQ)
|
||||
CHECK_SYMBOL_EXISTS(D_MD_ORDER "langinfo.h" HAVE_D_MD_ORDER)
|
||||
CHECK_SYMBOL_EXISTS(INT32_MAX "${headers}" HAVE_DECL_INT32_MAX)
|
||||
CHECK_SYMBOL_EXISTS(INT32_MIN "${headers}" HAVE_DECL_INT32_MIN)
|
||||
CHECK_SYMBOL_EXISTS(INT64_MAX "${headers}" HAVE_DECL_INT64_MAX)
|
||||
CHECK_SYMBOL_EXISTS(INT64_MIN "${headers}" HAVE_DECL_INT64_MIN)
|
||||
CHECK_SYMBOL_EXISTS(INTMAX_MAX "${headers}" HAVE_DECL_INTMAX_MAX)
|
||||
CHECK_SYMBOL_EXISTS(INTMAX_MIN "${headers}" HAVE_DECL_INTMAX_MIN)
|
||||
CHECK_SYMBOL_EXISTS(UINT32_MAX "${headers}" HAVE_DECL_UINT32_MAX)
|
||||
CHECK_SYMBOL_EXISTS(UINT64_MAX "${headers}" HAVE_DECL_UINT64_MAX)
|
||||
CHECK_SYMBOL_EXISTS(UINTMAX_MAX "${headers}" HAVE_DECL_UINTMAX_MAX)
|
||||
CHECK_SYMBOL_EXISTS(SIZE_MAX "${headers}" HAVE_DECL_SIZE_MAX)
|
||||
CHECK_SYMBOL_EXISTS(SSIZE_MAX "limits.h" HAVE_DECL_SSIZE_MAX)
|
||||
|
||||
@ -1491,6 +1641,9 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in
|
||||
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||
|
||||
# Handle generation of the libarchive.pc file for pkg-config
|
||||
INCLUDE(CreatePkgConfigFile)
|
||||
|
||||
#
|
||||
# Register installation of PDF documents.
|
||||
#
|
||||
@ -1521,5 +1674,6 @@ IF(ENABLE_TEST)
|
||||
ENDIF(ENABLE_TEST)
|
||||
|
||||
add_subdirectory(libarchive)
|
||||
add_subdirectory(cat)
|
||||
add_subdirectory(tar)
|
||||
add_subdirectory(cpio)
|
||||
|
98
CONTRIBUTING.md
Normal file
98
CONTRIBUTING.md
Normal file
@ -0,0 +1,98 @@
|
||||
Thank you for helping us improve libarchive.
|
||||
The following guidelines will help ensure your contribution gets prompt attention.
|
||||
|
||||
# Bugs and other Issues
|
||||
|
||||
If you encounter any problems with libarchive,
|
||||
[please file an issue on our issue tracker](https://github.com/libarchive/libarchive/issues).
|
||||
|
||||
All bug reports should include the following information. You can copy the text below directly into the issue tracker to get started:
|
||||
|
||||
```
|
||||
Basic Information
|
||||
Version of libarchive:
|
||||
How you obtained it: (build from source, pre-packaged binary, etc)
|
||||
Operating system and version:
|
||||
What compiler and/or IDE you are using (include version):
|
||||
|
||||
If you are using a pre-packaged binary
|
||||
Exact package name and version:
|
||||
Repository you obtained it from:
|
||||
|
||||
Description of the problem you are seeing:
|
||||
What did you do?
|
||||
What did you expect to happen?
|
||||
What actually happened?
|
||||
What log files or error messages were produced?
|
||||
|
||||
How the libarchive developers can reproduce your problem:
|
||||
What other software was involved?
|
||||
What other files were involved?
|
||||
How can we obtain any of the above?
|
||||
```
|
||||
|
||||
Depending on the specific type of issue, other information will be helpful:
|
||||
|
||||
## Test Failures
|
||||
|
||||
If you see any test failures, please include the information above and also:
|
||||
|
||||
* Names of the tests that failed.
|
||||
|
||||
* Look for the .log files in the /tmp/libarchive_test_*date-and-time* directories. (On Mac OS, look in $TMPDIR which is different than /tmp.)
|
||||
|
||||
Please paste the .log files you will find there directly into your report.
|
||||
|
||||
|
||||
## Problems using libarchive in a program
|
||||
|
||||
If you are trying to write a program using libarchive, please include the information above and also:
|
||||
|
||||
* It will help us if we can actually run the program. This is easiest if you can provide source to a short program that illustrates your problem.
|
||||
|
||||
* If you have a sufficiently short program that shows the problem, you can either paste it into the report or [put it into a gist](https://gist.github.com).
|
||||
|
||||
|
||||
## Libarchive produced incorrect output
|
||||
|
||||
Please tell us what program you ran, any command-line arguments you provided, and details of the input files (`ls -l` output is helpful here). If the problem involved a command-line program, please copy the full terminal text into the report, including the command line and any error messages.
|
||||
|
||||
Please try to make the output file available to us. Unless it is very large, you can upload it into a fresh github repository and provide a link in your issue report.
|
||||
|
||||
|
||||
## Libarchive could not read a particular input file
|
||||
|
||||
Note: If you can provide a **very small** input file that reproduces the problem, we can add that to our test suite. This will ensure that the bug does not reappear in the future.
|
||||
|
||||
A link to the relevant file is usually sufficient.
|
||||
|
||||
If you cannot provide the input file or a link to the file, please let us know if there is some other way to obtain it.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
We are always interested in improving the libarchive documentation. Please tell us about any errors you find, including:
|
||||
|
||||
* Typos or errors in the manpages provided with libarchive source.
|
||||
|
||||
* Mistakes in the [libarchive Wiki](https://github.com/libarchive/libarchive/wiki)
|
||||
|
||||
* Problems with the PDF or Wiki files that are automatically generated from the manpages.
|
||||
|
||||
|
||||
# Code Submissions
|
||||
|
||||
We welcome all code submissions. But of course, some code submissions are easier for us to respond to than others. The best code submissions:
|
||||
|
||||
* Address a single issue. There have been many cases where a simple fix to an obvious problem did not get handled for months because the patch that was provided also included an unrelated change affecting an especially complex area of the code.
|
||||
|
||||
* Follow existing libarchive code style and conventions. Libarchive generally follows [BSD KNF](https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9) for formatting code.
|
||||
|
||||
* Do not make unnecessary changes to existing whitespace, capitalization, or spelling.
|
||||
|
||||
* Include detailed instructions for reproducing the problem you're fixing. We do try to verify that a submission actually fixes a real problem. If we can't reproduce the problem, it will take us longer to evaluate the fix. For this reason, we encourage you to file an issue report first with details on reproducing the problem, then refer to that issue in your pull request.
|
||||
|
||||
* Includes a test case. The libarchive Wiki has [detailed documentation for adding new test cases](https://github.com/libarchive/libarchive/wiki/LibarchiveAddingTest).
|
||||
|
||||
* Are provided via Github pull requests. We welcome patches in almost any format, but github's pull request management makes it significantly easier for us to evaluate and test changes.
|
||||
|
5
COPYING
5
COPYING
@ -17,12 +17,11 @@ the actual statements in the files are controlling.
|
||||
files for details:
|
||||
libarchive/archive_entry.c
|
||||
libarchive/archive_read_support_filter_compress.c
|
||||
libarchive/archive_write_set_filter_compress.c
|
||||
libarchive/archive_write_add_filter_compress.c
|
||||
libarchive/mtree.5
|
||||
tar/matching.c
|
||||
|
||||
* The following source files are in the public domain:
|
||||
tar/getdate.c
|
||||
libarchive/archive_getdate.c
|
||||
|
||||
* The build files---including Makefiles, configure scripts,
|
||||
and auxiliary scripts used as part of the compile process---have
|
||||
|
2
INSTALL
2
INSTALL
@ -1,5 +1,5 @@
|
||||
More complete build documentation is available on the libarchive
|
||||
Wiki: http://libarchive.googlecode.com/
|
||||
Wiki: https://github.com/libarchive/libarchive/wiki
|
||||
|
||||
On most Unix-like systems, you should be able to install libarchive,
|
||||
bsdtar, and bsdcpio using the following common steps:
|
||||
|
1711
Makefile.am
1711
Makefile.am
File diff suppressed because it is too large
Load Diff
32
NEWS
32
NEWS
@ -1,3 +1,35 @@
|
||||
Apr 09, 2016: libarchive 3.1.901a released
|
||||
Another test release in preparation for 3.2.0
|
||||
|
||||
Feb 13, 2016: libarchive 3.1.900a released
|
||||
This is a test release in preparation for 3.2.0
|
||||
|
||||
Oct 21, 2015: Preliminary port to OSF
|
||||
|
||||
Apr 11, 2015: libarchive's issue tracker is now hosted at GitHub.
|
||||
https://github.com/libarchive/libarchive/issues
|
||||
|
||||
Early 2015: Many fixes to crash and overflow bugs thanks to Hanno Boeck
|
||||
|
||||
Oct 13, 2014: Zip encryption and decryption support
|
||||
|
||||
Aug 13, 2014: Add support for lz4 compression.
|
||||
|
||||
Jun 10, 2014: Add warc format support
|
||||
|
||||
May 3, 2014: Add experimental Zip streaming extension
|
||||
|
||||
Apr 6, 2014: Add bsdcat command-line tool
|
||||
|
||||
Jan 12, 2014: Add Zip64 support
|
||||
|
||||
Dec 1, 2013: Rewrite Zip write logic
|
||||
|
||||
Jul 1, 2013: Add ability to detect encrypted entries for many formats
|
||||
(This does not add the ability to *decrypt* those entries, however)
|
||||
|
||||
Feb 23, 2013: "raw" write support added
|
||||
|
||||
Feb 09, 2013: libarchive 3.1.2 released
|
||||
|
||||
Jan 28, 2013: libarchive's new website moved to http://www.libarchive.org.
|
||||
|
24
README
24
README
@ -5,7 +5,7 @@ Questions? Issues?
|
||||
libarchive development, including documentation, and
|
||||
links to the libarchive mailing lists.
|
||||
* To report an issue, use the issue tracker at
|
||||
http://code.google.com/p/libarchive/issues/list
|
||||
https://github.com/libarchive/libarchive/issues
|
||||
* To submit an enhancement to libarchive, please submit
|
||||
a pull request via GitHub.
|
||||
https://github.com/libarchive/libarchive/pulls
|
||||
@ -13,9 +13,11 @@ Questions? Issues?
|
||||
This distribution bundle includes the following components:
|
||||
* libarchive: a library for reading and writing streaming archives
|
||||
* tar: the 'bsdtar' program is a full-featured 'tar'
|
||||
replacement built on libarchive
|
||||
implementation built on libarchive
|
||||
* cpio: the 'bsdcpio' program is a different interface to
|
||||
essentially the same functionality
|
||||
* cat: the 'bsdcat' program is a simple replacement tool for
|
||||
zcat, bzcat, xzcat, and such
|
||||
* examples: Some small example programs that you may find useful.
|
||||
* examples/minitar: a compact sample demonstrating use of libarchive.
|
||||
* contrib: Various items sent to me by third parties;
|
||||
@ -39,6 +41,7 @@ The following files in the top-level directory are used by the
|
||||
Guide to Documentation installed by this system:
|
||||
* bsdtar.1 explains the use of the bsdtar program
|
||||
* bsdcpio.1 explains the use of the bsdcpio program
|
||||
* bsdcat.1 explains the use of the bsdcat program
|
||||
* libarchive.3 gives an overview of the library as a whole
|
||||
* archive_read.3, archive_write.3, archive_write_disk.3, and
|
||||
archive_read_disk.3 provide detailed calling sequences for the read
|
||||
@ -84,6 +87,8 @@ The library also detects and handles any of the following before evaluating the
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
The library can create archives in any of the following formats:
|
||||
* POSIX ustar
|
||||
@ -91,6 +96,7 @@ The library can create archives in any of the following formats:
|
||||
* "restricted" pax format, which will create ustar archives except for
|
||||
entries that require pax extensions (for long filenames, ACLs, etc).
|
||||
* Old GNU tar format
|
||||
* Old V7 tar format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 "newc" cpio
|
||||
* shar archives
|
||||
@ -107,6 +113,8 @@ When creating archives, the result can be filtered with any of the following:
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
Notes about the library architecture:
|
||||
|
||||
@ -123,12 +131,12 @@ Notes about the library architecture:
|
||||
|
||||
* I've attempted to minimize static link pollution. If you don't
|
||||
explicitly invoke a particular feature (such as support for a
|
||||
particular compression or format), it won't get pulled in.
|
||||
In particular, if you don't explicitly enable a particular
|
||||
compression or decompression support, you won't need to link
|
||||
against the corresponding compression or decompression libraries.
|
||||
This also reduces the size of statically-linked binaries in
|
||||
environments where that matters.
|
||||
particular compression or format), it won't get pulled in to
|
||||
statically-linked programs. In particular, if you don't explicitly
|
||||
enable a particular compression or decompression support, you won't
|
||||
need to link against the corresponding compression or decompression
|
||||
libraries. This also reduces the size of statically-linked
|
||||
binaries in environments where that matters.
|
||||
|
||||
* On read, the library accepts whatever blocks you hand it.
|
||||
Your read callback is free to pass the library a byte at a time
|
||||
|
67
build/autoconf/ax_append_compile_flags.m4
Normal file
67
build/autoconf/ax_append_compile_flags.m4
Normal file
@ -0,0 +1,67 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
|
||||
# flag. If it does, the flag is added FLAGS-VARIABLE
|
||||
#
|
||||
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
|
||||
# CFLAGS) is used. During the check the flag is always added to the
|
||||
# current language's flags.
|
||||
#
|
||||
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||
# force the compiler to issue an error when a bad flag is given.
|
||||
#
|
||||
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
||||
#
|
||||
# NOTE: This macro depends on the AX_APPEND_FLAG and
|
||||
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
|
||||
# AX_APPEND_LINK_FLAGS.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 5
|
||||
|
||||
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
|
||||
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
|
||||
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
|
||||
for flag in $1; do
|
||||
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
|
||||
done
|
||||
])dnl AX_APPEND_COMPILE_FLAGS
|
71
build/autoconf/ax_append_flag.m4
Normal file
71
build/autoconf/ax_append_flag.m4
Normal file
@ -0,0 +1,71 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
|
||||
# added in between.
|
||||
#
|
||||
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
|
||||
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
|
||||
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
|
||||
# FLAG.
|
||||
#
|
||||
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 6
|
||||
|
||||
AC_DEFUN([AX_APPEND_FLAG],
|
||||
[dnl
|
||||
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
|
||||
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
|
||||
AS_VAR_SET_IF(FLAGS,[
|
||||
AS_CASE([" AS_VAR_GET(FLAGS) "],
|
||||
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
|
||||
[
|
||||
AS_VAR_APPEND(FLAGS,[" $1"])
|
||||
AC_RUN_LOG([: FLAGS="$FLAGS"])
|
||||
])
|
||||
],
|
||||
[
|
||||
AS_VAR_SET(FLAGS,[$1])
|
||||
AC_RUN_LOG([: FLAGS="$FLAGS"])
|
||||
])
|
||||
AS_VAR_POPDEF([FLAGS])dnl
|
||||
])dnl AX_APPEND_FLAG
|
74
build/autoconf/ax_check_compile_flag.m4
Normal file
74
build/autoconf/ax_check_compile_flag.m4
Normal file
@ -0,0 +1,74 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check whether the given FLAG works with the current language's compiler
|
||||
# or gives an error. (Warnings, however, are ignored)
|
||||
#
|
||||
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||
# success/failure.
|
||||
#
|
||||
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||
# force the compiler to issue an error when a bad flag is given.
|
||||
#
|
||||
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
||||
#
|
||||
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
|
||||
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 4
|
||||
|
||||
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
||||
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
||||
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
|
||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||
[AS_VAR_SET(CACHEVAR,[no])])
|
||||
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||
AS_VAR_IF(CACHEVAR,yes,
|
||||
[m4_default([$2], :)],
|
||||
[m4_default([$3], :)])
|
||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||
])dnl AX_CHECK_COMPILE_FLAGS
|
37
build/autoconf/ax_require_defined.m4
Normal file
37
build/autoconf/ax_require_defined.m4
Normal file
@ -0,0 +1,37 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_REQUIRE_DEFINED(MACRO)
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
|
||||
# been defined and thus are available for use. This avoids random issues
|
||||
# where a macro isn't expanded. Instead the configure script emits a
|
||||
# non-fatal:
|
||||
#
|
||||
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
|
||||
#
|
||||
# It's like AC_REQUIRE except it doesn't expand the required macro.
|
||||
#
|
||||
# Here's an example:
|
||||
#
|
||||
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 1
|
||||
|
||||
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
|
||||
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
|
||||
])dnl AX_REQUIRE_DEFINED
|
@ -1,5 +1,5 @@
|
||||
# iconv.m4 serial 18 (gettext-0.18.2)
|
||||
dnl Copyright (C) 2000-2002, 2007-2011 Free Software Foundation, Inc.
|
||||
# iconv.m4 serial 19 (gettext-0.18.2)
|
||||
dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -72,27 +72,33 @@ AC_DEFUN([AM_ICONV_LINK],
|
||||
if test $am_cv_lib_iconv = yes; then
|
||||
LIBS="$LIBS $LIBICONV"
|
||||
fi
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
am_cv_func_iconv_works=no
|
||||
for ac_iconv_const in '' 'const'; do
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#include <iconv.h>
|
||||
#include <string.h>
|
||||
int main ()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
#ifndef ICONV_CONST
|
||||
# define ICONV_CONST $ac_iconv_const
|
||||
#endif
|
||||
]],
|
||||
[[int result = 0;
|
||||
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
|
||||
returns. */
|
||||
{
|
||||
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
|
||||
if (cd_utf8_to_88591 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\342\202\254"; /* EURO SIGN */
|
||||
static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
|
||||
char buf[10];
|
||||
const char *inptr = input;
|
||||
ICONV_CONST char *inptr = input;
|
||||
size_t inbytesleft = strlen (input);
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = sizeof (buf);
|
||||
size_t res = iconv (cd_utf8_to_88591,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if (res == 0)
|
||||
result |= 1;
|
||||
@ -105,14 +111,14 @@ int main ()
|
||||
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
|
||||
if (cd_ascii_to_88591 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\263";
|
||||
static ICONV_CONST char input[] = "\263";
|
||||
char buf[10];
|
||||
const char *inptr = input;
|
||||
ICONV_CONST char *inptr = input;
|
||||
size_t inbytesleft = strlen (input);
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = sizeof (buf);
|
||||
size_t res = iconv (cd_ascii_to_88591,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if (res == 0)
|
||||
result |= 2;
|
||||
@ -124,14 +130,14 @@ int main ()
|
||||
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
|
||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\304";
|
||||
static ICONV_CONST char input[] = "\304";
|
||||
static char buf[2] = { (char)0xDE, (char)0xAD };
|
||||
const char *inptr = input;
|
||||
ICONV_CONST char *inptr = input;
|
||||
size_t inbytesleft = 1;
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = 1;
|
||||
size_t res = iconv (cd_88591_to_utf8,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
|
||||
result |= 4;
|
||||
@ -144,14 +150,14 @@ int main ()
|
||||
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
|
||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
||||
static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
||||
char buf[50];
|
||||
const char *inptr = input;
|
||||
ICONV_CONST char *inptr = input;
|
||||
size_t inbytesleft = strlen (input);
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = sizeof (buf);
|
||||
size_t res = iconv (cd_88591_to_utf8,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if ((int)res > 0)
|
||||
result |= 8;
|
||||
@ -171,17 +177,14 @@ int main ()
|
||||
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
|
||||
result |= 16;
|
||||
return result;
|
||||
}]])],
|
||||
[am_cv_func_iconv_works=yes],
|
||||
[am_cv_func_iconv_works=no],
|
||||
[
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
||||
*) am_cv_func_iconv_works="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
])
|
||||
]])],
|
||||
[am_cv_func_iconv_works=yes], ,
|
||||
[case "$host_os" in
|
||||
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
||||
*) am_cv_func_iconv_works="guessing yes" ;;
|
||||
esac])
|
||||
test "$am_cv_func_iconv_works" = no || break
|
||||
done
|
||||
LIBS="$am_save_LIBS"
|
||||
])
|
||||
case "$am_cv_func_iconv_works" in
|
||||
|
@ -43,7 +43,7 @@ cd ..
|
||||
# Substitute the versions into Libarchive's archive.h and archive_entry.h
|
||||
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive.h
|
||||
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive_entry.h
|
||||
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_STRING).*/\$1 \"libarchive $VS\"/" libarchive/archive.h
|
||||
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_ONLY_STRING).*/\$1 \"$VS\"/" libarchive/archive.h
|
||||
# Substitute versions into configure.ac as well
|
||||
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' configure.ac
|
||||
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac
|
||||
|
@ -62,8 +62,10 @@ rm -f build/autoconf/ltsugar.m4
|
||||
rm -f build/autoconf/ltversion.m4
|
||||
rm -f build/autoconf/lt~obsolete.m4
|
||||
rm -f build/autoconf/missing
|
||||
rm -f build/autoconf/test-driver
|
||||
rm -f build/pkgconfig/libarchive.pc
|
||||
rm -f build/version.old
|
||||
rm -f cat/test/list.h
|
||||
rm -f config.h
|
||||
rm -f config.h.in
|
||||
rm -f config.log
|
||||
|
33
build/cmake/CreatePkgConfigFile.cmake
Normal file
33
build/cmake/CreatePkgConfigFile.cmake
Normal file
@ -0,0 +1,33 @@
|
||||
# - Generate a libarchive.pc like autotools for pkg-config
|
||||
#
|
||||
|
||||
# Set the required variables (we use the same input file as autotools)
|
||||
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
SET(exec_prefix \${prefix})
|
||||
SET(libdir \${exec_prefix}/lib)
|
||||
SET(includedir \${prefix}/include)
|
||||
# Now, this is not particularly pretty, nor is it terribly accurate...
|
||||
# Loop over all our additional libs
|
||||
FOREACH(mylib ${ADDITIONAL_LIBS})
|
||||
# Extract the filename from the absolute path
|
||||
GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE)
|
||||
# Strip the lib prefix
|
||||
STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name})
|
||||
# Append it to our LIBS string
|
||||
SET(LIBS "${LIBS} -l${mylib_name}")
|
||||
ENDFOREACH()
|
||||
# libxml2 is easier, since it's already using pkg-config
|
||||
FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS})
|
||||
SET(LIBS "${LIBS} ${mylib}")
|
||||
ENDFOREACH()
|
||||
# FIXME: The order of the libraries doesn't take dependencies into account,
|
||||
# thus there's a good chance it'll make some binutils versions unhappy...
|
||||
# This only affects Libs.private (looked up for static builds) though.
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
|
||||
@ONLY)
|
||||
# And install it, of course ;).
|
||||
IF(ENABLE_INSTALL)
|
||||
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
|
||||
DESTINATION "lib/pkgconfig")
|
||||
ENDIF()
|
@ -1,106 +0,0 @@
|
||||
# - Check if given C source compiles and links into an executable
|
||||
# CHECK_C_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
|
||||
# <code> - source code to try to compile, must define 'main'
|
||||
# <var> - variable to store whether the source code compiled
|
||||
# <fail-regex> - fail if test output matches this regex
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
#
|
||||
# Extra arguments added by libarchive
|
||||
# CMAKE_REQUIRED_LINKER_FLAGS = string of linker command line flags
|
||||
#
|
||||
|
||||
include(CMakeExpandImportedTargets)
|
||||
|
||||
|
||||
macro(LIBARCHIVE_CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
||||
if("${VAR}" MATCHES "^${VAR}$")
|
||||
set(_FAIL_REGEX)
|
||||
set(_key)
|
||||
foreach(arg ${ARGN})
|
||||
if("${arg}" MATCHES "^(FAIL_REGEX)$")
|
||||
set(_key "${arg}")
|
||||
elseif(_key)
|
||||
list(APPEND _${_key} "${arg}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||
if(CMAKE_REQUIRED_LIBRARIES)
|
||||
# this one translates potentially used imported library targets to their files on disk
|
||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
||||
else()
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
else()
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS
|
||||
"-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
|
||||
else()
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS)
|
||||
endif()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
|
||||
"${SOURCE}\n")
|
||||
|
||||
message(STATUS "Performing Test ${VAR}")
|
||||
try_compile(${VAR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS}
|
||||
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
||||
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
foreach(_regex ${_FAIL_REGEX})
|
||||
if("${OUTPUT}" MATCHES "${_regex}")
|
||||
set(${VAR} 0)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(${VAR})
|
||||
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
|
||||
message(STATUS "Performing Test ${VAR} - Success")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
else()
|
||||
message(STATUS "Performing Test ${VAR} - Failed")
|
||||
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
@ -1,102 +0,0 @@
|
||||
# - Check if the given C source code compiles and runs.
|
||||
# CHECK_C_SOURCE_RUNS(<code> <var>)
|
||||
# <code> - source code to try to compile
|
||||
# <var> - variable to store the result
|
||||
# (1 for success, empty for failure)
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2006-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
#
|
||||
# Extra arguments added by libarchive
|
||||
# CMAKE_REQUIRED_LINKER_FLAGS = string of linker command line flags
|
||||
#
|
||||
|
||||
include(CMakeExpandImportedTargets)
|
||||
|
||||
|
||||
macro(LIBARCHIVE_CHECK_C_SOURCE_RUNS SOURCE VAR)
|
||||
if("${VAR}" MATCHES "^${VAR}$")
|
||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||
if(CMAKE_REQUIRED_LIBRARIES)
|
||||
# this one translates potentially used imported library targets to their files on disk
|
||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
||||
else()
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
else()
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
|
||||
endif()
|
||||
if(CMAKE_REQUIRED_LINKER_FLAGS)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS
|
||||
"-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
|
||||
else()
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS)
|
||||
endif()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
|
||||
"${SOURCE}\n")
|
||||
|
||||
message(STATUS "Performing Test ${VAR}")
|
||||
try_run(${VAR}_EXITCODE ${VAR}_COMPILED
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS}
|
||||
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
||||
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
||||
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
||||
# if it did not compile make the return value fail code of 1
|
||||
if(NOT ${VAR}_COMPILED)
|
||||
set(${VAR}_EXITCODE 1)
|
||||
endif()
|
||||
# if the return value was 0 then it worked
|
||||
if("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
|
||||
message(STATUS "Performing Test ${VAR} - Success")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Return value: ${${VAR}}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
else()
|
||||
if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
set(${VAR} "${${VAR}_EXITCODE}")
|
||||
else()
|
||||
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Performing Test ${VAR} - Failed")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Return value: ${${VAR}_EXITCODE}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
68
build/cmake/LibarchiveCodeCoverage.cmake
Normal file
68
build/cmake/LibarchiveCodeCoverage.cmake
Normal file
@ -0,0 +1,68 @@
|
||||
#################################################################
|
||||
# Adds a build target called "coverage" for code coverage.
|
||||
#
|
||||
# This compiles the code using special GCC flags, run the tests,
|
||||
# and then generates a nice HTML output. This new "coverage" make
|
||||
# target will only be available if you build using GCC in Debug
|
||||
# mode. If any of the required programs (lcov and genhtml) were
|
||||
# not found, a FATAL_ERROR message is printed.
|
||||
#
|
||||
# If not already done, this code will set ENABLE_TEST to ON.
|
||||
#
|
||||
# To build the code coverage and open it in your browser do this:
|
||||
#
|
||||
# mkdir debug
|
||||
# cd debug
|
||||
# cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
|
||||
# make -j4
|
||||
# make coverage
|
||||
# xdg-open coverage/index.html
|
||||
#################################################################
|
||||
|
||||
# Find programs we need
|
||||
FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable")
|
||||
FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable")
|
||||
MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
|
||||
|
||||
# Check, compiler, build types and programs are available
|
||||
IF(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
MESSAGE(FATAL_ERROR "Coverage can only be built on GCC")
|
||||
ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode")
|
||||
ELSEIF(NOT LCOV_EXECUTABLE)
|
||||
MESSAGE(FATAL_ERROR "lcov executable not found")
|
||||
ELSEIF(NOT GENHTML_EXECUTABLE)
|
||||
MESSAGE(FATAL_ERROR "genhtml executable not found")
|
||||
ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
# Enable testing if not already done
|
||||
SET(ENABLE_TEST ON)
|
||||
|
||||
#################################################################
|
||||
# Set special compiler and linker flags for test coverage
|
||||
#################################################################
|
||||
# 0. Enable debug: -g
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
|
||||
# 1. Disable optimizations: -O0
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
||||
# 2. Enable all kind of warnings:
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W")
|
||||
# 3. Enable special coverage flag (HINT: --coverage is a synonym for -fprofile-arcs -ftest-coverage)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||
#################################################################
|
||||
|
||||
ADD_CUSTOM_TARGET(coverage
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Beginning test coverage. Output is written to coverage.log."
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-1/5: Reset all execution counts to zero"
|
||||
COMMAND ${LCOV_EXECUTABLE} --directory . --zerocounters > coverage.log 2>&1
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-2/5: Run testrunner"
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} >> coverage.log 2>&1
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-3/5: Collect coverage data"
|
||||
COMMAND ${LCOV_EXECUTABLE} --capture --directory . --output-file "./coverage.info" >> coverage.log 2>&1
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-4/5: Generate HTML from coverage data"
|
||||
COMMAND ${GENHTML_EXECUTABLE} "coverage.info" --title="libarchive-${LIBARCHIVE_VERSION_STRING}" --show-details --legend --output-directory "./coverage" >> coverage.log 2>&1
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-5/5: Open test coverage HTML output in browser: xdg-open ./coverage/index.html"
|
||||
COMMENT "Runs testrunner and generates coverage output (formats: .info and .html)")
|
||||
|
@ -63,7 +63,7 @@ typedef long long int64_t;
|
||||
* Similarly for int32_t
|
||||
*/
|
||||
#if !defined(HAVE_INT32_T) && SIZE_OF_INT == 4
|
||||
typedef long int32_t;
|
||||
typedef int int32_t;
|
||||
#define HAVE_INT32_T
|
||||
#endif
|
||||
|
||||
@ -170,8 +170,6 @@ typedef unsigned char uint8_t;
|
||||
/* Define intmax_t and uintmax_t if they are not already defined. */
|
||||
#if !defined(HAVE_INTMAX_T)
|
||||
typedef int64_t intmax_t;
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_UINTMAX_T)
|
||||
@ -289,6 +287,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Version number of bsdtar */
|
||||
#cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}"
|
||||
|
||||
/* Version number of bsdcat */
|
||||
#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}"
|
||||
|
||||
/* Define to 1 if you have the `acl_create_entry' function. */
|
||||
#cmakedefine HAVE_ACL_CREATE_ENTRY 1
|
||||
|
||||
@ -325,9 +326,15 @@ typedef uint64_t uintmax_t;
|
||||
/* True for systems with POSIX ACL support */
|
||||
#cmakedefine HAVE_ACL_USER 1
|
||||
|
||||
/* Define to 1 if you have the `arc4random_buf' function. */
|
||||
#cmakedefine HAVE_ARC4RANDOM_BUF 1
|
||||
|
||||
/* Define to 1 if you have the <attr/xattr.h> header file. */
|
||||
#cmakedefine HAVE_ATTR_XATTR_H 1
|
||||
|
||||
/* Define to 1 if you have the <Bcrypt.h> header file. */
|
||||
#cmakedefine HAVE_BCRYPT_H 1
|
||||
|
||||
/* Define to 1 if you have the <bsdxml.h> header file. */
|
||||
#cmakedefine HAVE_BSDXML_H 1
|
||||
|
||||
@ -355,6 +362,14 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `cygwin_conv_path' function. */
|
||||
#cmakedefine HAVE_CYGWIN_CONV_PATH 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `INT32_MAX', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_INT32_MAX 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `INT32_MIN', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_INT32_MIN 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_INT64_MAX 1
|
||||
@ -363,6 +378,14 @@ typedef uint64_t uintmax_t;
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_INT64_MIN 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `INTMAX_MAX', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_INTMAX_MAX 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `INTMAX_MIN', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_INTMAX_MIN 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_SIZE_MAX 1
|
||||
@ -383,6 +406,10 @@ typedef uint64_t uintmax_t;
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_UINT64_MAX 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `UINTMAX_MAX', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_UINTMAX_MAX 1
|
||||
|
||||
/* Define to 1 if you have the <direct.h> header file. */
|
||||
#cmakedefine HAVE_DIRECT_H 1
|
||||
|
||||
@ -576,12 +603,21 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `bz2' library (-lbz2). */
|
||||
#cmakedefine HAVE_LIBBZ2 1
|
||||
|
||||
/* Define to 1 if you have the `charset' library (-lcharset). */
|
||||
#cmakedefine HAVE_LIBCHARSET 1
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#cmakedefine HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define to 1 if you have the `expat' library (-lexpat). */
|
||||
#cmakedefine HAVE_LIBEXPAT 1
|
||||
|
||||
/* Define to 1 if you have the `gcc' library (-lgcc). */
|
||||
#cmakedefine HAVE_LIBGCC 1
|
||||
|
||||
/* Define to 1 if you have the `lz4' library (-llz4). */
|
||||
#cmakedefine HAVE_LIBLZ4 1
|
||||
|
||||
/* Define to 1 if you have the `lzma' library (-llzma). */
|
||||
#cmakedefine HAVE_LIBLZMA 1
|
||||
|
||||
@ -673,6 +709,12 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `lutimes' function. */
|
||||
#cmakedefine HAVE_LUTIMES 1
|
||||
|
||||
/* Define to 1 if you have the <lz4hc.h> header file. */
|
||||
#cmakedefine HAVE_LZ4HC_H 1
|
||||
|
||||
/* Define to 1 if you have the <lz4.h> header file. */
|
||||
#cmakedefine HAVE_LZ4_H 1
|
||||
|
||||
/* Define to 1 if you have the <lzmadec.h> header file. */
|
||||
#cmakedefine HAVE_LZMADEC_H 1
|
||||
|
||||
@ -709,9 +751,18 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#cmakedefine HAVE_NDIR_H 1
|
||||
|
||||
/* Define to 1 if you have the <nettle/aes.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_AES_H 1
|
||||
|
||||
/* Define to 1 if you have the <nettle/hmac.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_HMAC_H 1
|
||||
|
||||
/* Define to 1 if you have the <nettle/md5.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_MD5_H 1
|
||||
|
||||
/* Define to 1 if you have the <nettle/pbkdf2.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_PBKDF2_H 1
|
||||
|
||||
/* Define to 1 if you have the <nettle/ripemd160.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_RIPEMD160_H 1
|
||||
|
||||
@ -733,6 +784,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `pipe' function. */
|
||||
#cmakedefine HAVE_PIPE 1
|
||||
|
||||
/* Define to 1 if you have the `PKCS5_PBKDF2_HMAC_SHA1' function. */
|
||||
#cmakedefine HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
|
||||
|
||||
/* Define to 1 if you have the `poll' function. */
|
||||
#cmakedefine HAVE_POLL 1
|
||||
|
||||
@ -745,6 +799,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <process.h> header file. */
|
||||
#cmakedefine HAVE_PROCESS_H 1
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#cmakedefine HAVE_PTHREAD_H 1
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#cmakedefine HAVE_PWD_H 1
|
||||
|
||||
@ -757,6 +814,12 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `readlinkat' function. */
|
||||
#cmakedefine HAVE_READLINKAT 1
|
||||
|
||||
/* Define to 1 if you have the `readpassphrase' function. */
|
||||
#cmakedefine HAVE_READPASSPHRASE 1
|
||||
|
||||
/* Define to 1 if you have the <readpassphrase.h> header file. */
|
||||
#cmakedefine HAVE_READPASSPHRASE_H 1
|
||||
|
||||
/* Define to 1 if you have the <regex.h> header file. */
|
||||
#cmakedefine HAVE_REGEX_H 1
|
||||
|
||||
@ -1012,6 +1075,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `wmemcpy' function. */
|
||||
#cmakedefine HAVE_WMEMCPY 1
|
||||
|
||||
/* Define to 1 if you have the `wmemmove' function. */
|
||||
#cmakedefine HAVE_WMEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */
|
||||
#cmakedefine HAVE_WORKING_EXT2_IOC_GETFLAGS 1
|
||||
|
||||
@ -1105,9 +1171,18 @@ typedef uint64_t uintmax_t;
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#cmakedefine _LARGE_FILES ${_LARGE_FILES}
|
||||
|
||||
/* Define for Windows to use Windows 2000+ APIs. */
|
||||
/* Define to control Windows SDK version */
|
||||
#ifndef NTDDI_VERSION
|
||||
#cmakedefine NTDDI_VERSION ${NTDDI_VERSION}
|
||||
#endif // NTDDI_VERSION
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
#cmakedefine _WIN32_WINNT ${_WIN32_WINNT}
|
||||
#endif // _WIN32_WINNT
|
||||
|
||||
#ifndef WINVER
|
||||
#cmakedefine WINVER ${WINVER}
|
||||
#endif // WINVER
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#cmakedefine const ${const}
|
||||
|
@ -1 +1 @@
|
||||
3001002
|
||||
3002000
|
||||
|
37
cat/CMakeLists.txt
Normal file
37
cat/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
||||
############################################
|
||||
#
|
||||
# How to build bsdcat
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_CAT)
|
||||
|
||||
SET(bsdcat_SOURCES
|
||||
bsdcat.c
|
||||
bsdcat.h
|
||||
bsdcat_platform.h
|
||||
cmdline.c
|
||||
../libarchive_fe/err.c
|
||||
../libarchive_fe/err.h
|
||||
../libarchive_fe/lafe_platform.h
|
||||
)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
|
||||
|
||||
# bsdcat documentation
|
||||
SET(bsdcat_MANS bsdcat.1)
|
||||
|
||||
# How to build bsdcat
|
||||
ADD_EXECUTABLE(bsdcat ${bsdcat_SOURCES})
|
||||
IF(ENABLE_CAT_SHARED)
|
||||
TARGET_LINK_LIBRARIES(bsdcat archive ${ADDITIONAL_LIBS})
|
||||
ELSE(ENABLE_CAT_SHARED)
|
||||
TARGET_LINK_LIBRARIES(bsdcat archive_static ${ADDITIONAL_LIBS})
|
||||
SET_TARGET_PROPERTIES(bsdcat PROPERTIES COMPILE_DEFINITIONS
|
||||
LIBARCHIVE_STATIC)
|
||||
ENDIF(ENABLE_CAT_SHARED)
|
||||
|
||||
# Installation rules
|
||||
INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
|
||||
INSTALL_MAN(${bsdcat_MANS})
|
||||
ENDIF(ENABLE_CAT)
|
||||
|
||||
add_subdirectory(test)
|
62
cat/bsdcat.1
Normal file
62
cat/bsdcat.1
Normal file
@ -0,0 +1,62 @@
|
||||
.\" Copyright (c) 2011-2014, Mike Kazantsev
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 1, 2014
|
||||
.Dt BSDCAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm bsdcat
|
||||
.Nd expand files to standard output
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op options
|
||||
.Op files
|
||||
.Pp
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
expands files to standard output.
|
||||
.Sh OPTIONS
|
||||
.Nm
|
||||
typically takes a filename as an argument or reads standard input when used in a
|
||||
pipe. In both cases decompressed data it written to standard output.
|
||||
.Sh EXAMPLES
|
||||
.Pp
|
||||
To decompress a file:
|
||||
.Pp
|
||||
.Dl bsdcat example.txt.gz > example.txt
|
||||
.Pp
|
||||
To decompress standard input in a pipe:
|
||||
.Pp
|
||||
.Dl cat example.txt.gz | bsdcat > example.txt
|
||||
.Pp
|
||||
Both examples achieve the same results - a decompressed file by redirecting
|
||||
output.
|
||||
.Sh SEE ALSO
|
||||
.Xr uncompress 1 ,
|
||||
.Xr zcat 1 ,
|
||||
.Xr bzcat 1 ,
|
||||
.Xr xzcat 1 ,
|
||||
.Xr libarchive-formats 5 ,
|
146
cat/bsdcat.c
Normal file
146
cat/bsdcat.c
Normal file
@ -0,0 +1,146 @@
|
||||
/*-
|
||||
* Copyright (c) 2011-2014, Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bsdcat_platform.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bsdcat.h"
|
||||
#include "err.h"
|
||||
|
||||
#define BYTES_PER_BLOCK (20*512)
|
||||
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
char *bsdcat_current_path;
|
||||
int exit_status = 0;
|
||||
|
||||
|
||||
void
|
||||
usage(FILE *stream, int eval)
|
||||
{
|
||||
const char *p;
|
||||
p = lafe_getprogname();
|
||||
fprintf(stream,
|
||||
"Usage: %s [-h] [--help] [--version] [--] [filenames...]\n", p);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
static void
|
||||
version(void)
|
||||
{
|
||||
printf("bsdcat %s - %s\n",
|
||||
BSDCAT_VERSION_STRING,
|
||||
archive_version_details());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
bsdcat_next()
|
||||
{
|
||||
a = archive_read_new();
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_empty(a);
|
||||
archive_read_support_format_raw(a);
|
||||
}
|
||||
|
||||
void
|
||||
bsdcat_print_error(void)
|
||||
{
|
||||
lafe_warnc(0, "%s: %s",
|
||||
bsdcat_current_path, archive_error_string(a));
|
||||
exit_status = 1;
|
||||
}
|
||||
|
||||
void
|
||||
bsdcat_read_to_stdout(char* filename)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (archive_read_open_filename(a, filename, BYTES_PER_BLOCK)
|
||||
!= ARCHIVE_OK)
|
||||
bsdcat_print_error();
|
||||
else if (r = archive_read_next_header(a, &ae),
|
||||
r != ARCHIVE_OK && r != ARCHIVE_EOF)
|
||||
bsdcat_print_error();
|
||||
else if (r == ARCHIVE_EOF)
|
||||
/* for empty payloads don't try and read data */
|
||||
;
|
||||
else if (archive_read_data_into_fd(a, 1) != ARCHIVE_OK)
|
||||
bsdcat_print_error();
|
||||
if (archive_read_free(a) != ARCHIVE_OK)
|
||||
bsdcat_print_error();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct bsdcat *bsdcat, bsdcat_storage;
|
||||
int c;
|
||||
|
||||
bsdcat = &bsdcat_storage;
|
||||
memset(bsdcat, 0, sizeof(*bsdcat));
|
||||
|
||||
lafe_setprogname(*argv, "bsdcat");
|
||||
|
||||
bsdcat->argv = argv;
|
||||
bsdcat->argc = argc;
|
||||
|
||||
while ((c = bsdcat_getopt(bsdcat)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(stdout, 0);
|
||||
break;
|
||||
case OPTION_VERSION:
|
||||
version();
|
||||
break;
|
||||
default:
|
||||
usage(stderr, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bsdcat_next();
|
||||
if (*bsdcat->argv == NULL) {
|
||||
bsdcat_current_path = "<stdin>";
|
||||
bsdcat_read_to_stdout(NULL);
|
||||
} else
|
||||
while (*bsdcat->argv) {
|
||||
bsdcat_current_path = *bsdcat->argv++;
|
||||
bsdcat_read_to_stdout(bsdcat_current_path);
|
||||
bsdcat_next();
|
||||
}
|
||||
|
||||
exit(exit_status);
|
||||
}
|
56
cat/bsdcat.h
Normal file
56
cat/bsdcat.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2014, Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(PLATFORM_CONFIG_H)
|
||||
/* Use hand-built config.h in environments that need it. */
|
||||
#include PLATFORM_CONFIG_H
|
||||
#else
|
||||
/* Not having a config.h of some sort is a serious problem. */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
|
||||
struct bsdcat {
|
||||
/* Option parser state */
|
||||
int getopt_state;
|
||||
char *getopt_word;
|
||||
|
||||
/* Miscellaneous state information */
|
||||
int argc;
|
||||
char **argv;
|
||||
const char *argument;
|
||||
};
|
||||
|
||||
enum {
|
||||
OPTION_VERSION
|
||||
};
|
||||
|
||||
int bsdcat_getopt(struct bsdcat *);
|
||||
void usage(FILE *stream, int eval);
|
||||
void bsdcat_next(void);
|
||||
void bsdcat_print_error(void);
|
||||
void bsdcat_read_to_stdout(char* filename);
|
75
cat/bsdcat_platform.h
Normal file
75
cat/bsdcat_platform.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header is the first thing included in any of the bsdtar
|
||||
* source files. As far as possible, platform-specific issues should
|
||||
* be dealt with here and not within individual source files.
|
||||
*/
|
||||
|
||||
#ifndef BSDCAT_PLATFORM_H_INCLUDED
|
||||
#define BSDCAT_PLATFORM_H_INCLUDED
|
||||
|
||||
#if defined(PLATFORM_CONFIG_H)
|
||||
/* Use hand-built config.h in environments that need it. */
|
||||
#include PLATFORM_CONFIG_H
|
||||
#else
|
||||
/* Not having a config.h of some sort is a serious problem. */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
/* If we're using the platform libarchive, include system headers. */
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#else
|
||||
/* Otherwise, include user headers. */
|
||||
#include "archive.h"
|
||||
#include "archive_entry.h"
|
||||
#endif
|
||||
|
||||
/* How to mark functions that don't return. */
|
||||
/* This facilitates use of some newer static code analysis tools. */
|
||||
#undef __LA_DEAD
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2 || \
|
||||
(__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
|
||||
#define __LA_DEAD __attribute__((__noreturn__))
|
||||
#else
|
||||
#define __LA_DEAD
|
||||
#endif
|
||||
|
||||
#endif /* !BSDCAT_PLATFORM_H_INCLUDED */
|
283
cat/cmdline.c
Normal file
283
cat/cmdline.c
Normal file
@ -0,0 +1,283 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2008 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Command line parser for tar.
|
||||
*/
|
||||
|
||||
#include "bsdcat_platform.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bsdcat.h"
|
||||
#include "err.h"
|
||||
|
||||
/*
|
||||
* Short options for tar. Please keep this sorted.
|
||||
*/
|
||||
static const char *short_options = "h";
|
||||
|
||||
/*
|
||||
* Long options for tar. Please keep this list sorted.
|
||||
*
|
||||
* The symbolic names for options that lack a short equivalent are
|
||||
* defined in bsdcat.h. Also note that so far I've found no need
|
||||
* to support optional arguments to long options. That would be
|
||||
* a small change to the code below.
|
||||
*/
|
||||
|
||||
static const struct bsdcat_option {
|
||||
const char *name;
|
||||
int required; /* 1 if this option requires an argument. */
|
||||
int equivalent; /* Equivalent short option. */
|
||||
} tar_longopts[] = {
|
||||
{ "help", 0, 'h' },
|
||||
{ "version", 0, OPTION_VERSION },
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* This getopt implementation has two key features that common
|
||||
* getopt_long() implementations lack. Apart from those, it's a
|
||||
* straightforward option parser, considerably simplified by not
|
||||
* needing to support the wealth of exotic getopt_long() features. It
|
||||
* has, of course, been shamelessly tailored for bsdcat. (If you're
|
||||
* looking for a generic getopt_long() implementation for your
|
||||
* project, I recommend Gregory Pietsch's public domain getopt_long()
|
||||
* implementation.) The two additional features are:
|
||||
*
|
||||
* Old-style tar arguments: The original tar implementation treated
|
||||
* the first argument word as a list of single-character option
|
||||
* letters. All arguments follow as separate words. For example,
|
||||
* tar xbf 32 /dev/tape
|
||||
* Here, the "xbf" is three option letters, "32" is the argument for
|
||||
* "b" and "/dev/tape" is the argument for "f". We support this usage
|
||||
* if the first command-line argument does not begin with '-'. We
|
||||
* also allow regular short and long options to follow, e.g.,
|
||||
* tar xbf 32 /dev/tape -P --format=pax
|
||||
*
|
||||
* -W long options: There's an obscure GNU convention (only rarely
|
||||
* supported even there) that allows "-W option=argument" as an
|
||||
* alternative way to support long options. This was supported in
|
||||
* early bsdcat as a way to access long options on platforms that did
|
||||
* not support getopt_long() and is preserved here for backwards
|
||||
* compatibility. (Of course, if I'd started with a custom
|
||||
* command-line parser from the beginning, I would have had normal
|
||||
* long option support on every platform so that hack wouldn't have
|
||||
* been necessary. Oh, well. Some mistakes you just have to live
|
||||
* with.)
|
||||
*
|
||||
* TODO: We should be able to use this to pull files and intermingled
|
||||
* options (such as -C) from the command line in write mode. That
|
||||
* will require a little rethinking of the argument handling in
|
||||
* bsdcat.c.
|
||||
*
|
||||
* TODO: If we want to support arbitrary command-line options from -T
|
||||
* input (as GNU tar does), we may need to extend this to handle option
|
||||
* words from sources other than argv/argc. I'm not really sure if I
|
||||
* like that feature of GNU tar, so it's certainly not a priority.
|
||||
*/
|
||||
|
||||
int
|
||||
bsdcat_getopt(struct bsdcat *bsdcat)
|
||||
{
|
||||
enum { state_start = 0, state_old_tar, state_next_word,
|
||||
state_short, state_long };
|
||||
|
||||
const struct bsdcat_option *popt, *match = NULL, *match2 = NULL;
|
||||
const char *p, *long_prefix = "--";
|
||||
size_t optlength;
|
||||
int opt = '?';
|
||||
int required = 0;
|
||||
|
||||
bsdcat->argument = NULL;
|
||||
|
||||
/* First time through, initialize everything. */
|
||||
if (bsdcat->getopt_state == state_start) {
|
||||
/* Skip program name. */
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
if (*bsdcat->argv == NULL)
|
||||
return (-1);
|
||||
/* Decide between "new style" and "old style" arguments. */
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
}
|
||||
|
||||
/*
|
||||
* We're ready to look at the next word in argv.
|
||||
*/
|
||||
if (bsdcat->getopt_state == state_next_word) {
|
||||
/* No more arguments, so no more options. */
|
||||
if (bsdcat->argv[0] == NULL)
|
||||
return (-1);
|
||||
/* Doesn't start with '-', so no more options. */
|
||||
if (bsdcat->argv[0][0] != '-')
|
||||
return (-1);
|
||||
/* "--" marks end of options; consume it and return. */
|
||||
if (strcmp(bsdcat->argv[0], "--") == 0) {
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
return (-1);
|
||||
}
|
||||
/* Get next word for parsing. */
|
||||
bsdcat->getopt_word = *bsdcat->argv++;
|
||||
--bsdcat->argc;
|
||||
if (bsdcat->getopt_word[1] == '-') {
|
||||
/* Set up long option parser. */
|
||||
bsdcat->getopt_state = state_long;
|
||||
bsdcat->getopt_word += 2; /* Skip leading '--' */
|
||||
} else {
|
||||
/* Set up short option parser. */
|
||||
bsdcat->getopt_state = state_short;
|
||||
++bsdcat->getopt_word; /* Skip leading '-' */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're parsing a group of POSIX-style single-character options.
|
||||
*/
|
||||
if (bsdcat->getopt_state == state_short) {
|
||||
/* Peel next option off of a group of short options. */
|
||||
opt = *bsdcat->getopt_word++;
|
||||
if (opt == '\0') {
|
||||
/* End of this group; recurse to get next option. */
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
return bsdcat_getopt(bsdcat);
|
||||
}
|
||||
|
||||
/* Does this option take an argument? */
|
||||
p = strchr(short_options, opt);
|
||||
if (p == NULL)
|
||||
return ('?');
|
||||
if (p[1] == ':')
|
||||
required = 1;
|
||||
|
||||
/* If it takes an argument, parse that. */
|
||||
if (required) {
|
||||
/* If arg is run-in, bsdcat->getopt_word already points to it. */
|
||||
if (bsdcat->getopt_word[0] == '\0') {
|
||||
/* Otherwise, pick up the next word. */
|
||||
bsdcat->getopt_word = *bsdcat->argv;
|
||||
if (bsdcat->getopt_word == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option -%c requires an argument",
|
||||
opt);
|
||||
return ('?');
|
||||
}
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
}
|
||||
if (opt == 'W') {
|
||||
bsdcat->getopt_state = state_long;
|
||||
long_prefix = "-W "; /* For clearer errors. */
|
||||
} else {
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
bsdcat->argument = bsdcat->getopt_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We're reading a long option, including -W long=arg convention. */
|
||||
if (bsdcat->getopt_state == state_long) {
|
||||
/* After this long option, we'll be starting a new word. */
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
|
||||
/* Option name ends at '=' if there is one. */
|
||||
p = strchr(bsdcat->getopt_word, '=');
|
||||
if (p != NULL) {
|
||||
optlength = (size_t)(p - bsdcat->getopt_word);
|
||||
bsdcat->argument = (char *)(uintptr_t)(p + 1);
|
||||
} else {
|
||||
optlength = strlen(bsdcat->getopt_word);
|
||||
}
|
||||
|
||||
/* Search the table for an unambiguous match. */
|
||||
for (popt = tar_longopts; popt->name != NULL; popt++) {
|
||||
/* Short-circuit if first chars don't match. */
|
||||
if (popt->name[0] != bsdcat->getopt_word[0])
|
||||
continue;
|
||||
/* If option is a prefix of name in table, record it.*/
|
||||
if (strncmp(bsdcat->getopt_word, popt->name, optlength) == 0) {
|
||||
match2 = match; /* Record up to two matches. */
|
||||
match = popt;
|
||||
/* If it's an exact match, we're done. */
|
||||
if (strlen(popt->name) == optlength) {
|
||||
match2 = NULL; /* Forget the others. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fail if there wasn't a unique match. */
|
||||
if (match == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s is not supported",
|
||||
long_prefix, bsdcat->getopt_word);
|
||||
return ('?');
|
||||
}
|
||||
if (match2 != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Ambiguous option %s%s (matches --%s and --%s)",
|
||||
long_prefix, bsdcat->getopt_word, match->name, match2->name);
|
||||
return ('?');
|
||||
}
|
||||
|
||||
/* We've found a unique match; does it need an argument? */
|
||||
if (match->required) {
|
||||
/* Argument required: get next word if necessary. */
|
||||
if (bsdcat->argument == NULL) {
|
||||
bsdcat->argument = *bsdcat->argv;
|
||||
if (bsdcat->argument == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s requires an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
}
|
||||
} else {
|
||||
/* Argument forbidden: fail if there is one. */
|
||||
if (bsdcat->argument != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s does not allow an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
}
|
||||
return (match->equivalent);
|
||||
}
|
||||
|
||||
return (opt);
|
||||
}
|
65
cat/test/CMakeLists.txt
Normal file
65
cat/test/CMakeLists.txt
Normal file
@ -0,0 +1,65 @@
|
||||
############################################
|
||||
#
|
||||
# How to build bsdtar_test
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_CAT AND ENABLE_TEST)
|
||||
SET(bsdcat_test_SOURCES
|
||||
../../test_utils/test_utils.c
|
||||
main.c
|
||||
test.h
|
||||
test_0.c
|
||||
test_empty_gz.c
|
||||
test_empty_lz4.c
|
||||
test_empty_xz.c
|
||||
test_error.c
|
||||
test_error_mixed.c
|
||||
test_expand_Z.c
|
||||
test_expand_bz2.c
|
||||
test_expand_gz.c
|
||||
test_expand_lz4.c
|
||||
test_expand_mixed.c
|
||||
test_expand_plain.c
|
||||
test_expand_xz.c
|
||||
test_help.c
|
||||
test_version.c
|
||||
)
|
||||
|
||||
#
|
||||
# Register target
|
||||
#
|
||||
ADD_EXECUTABLE(bsdcat_test ${bsdcat_test_SOURCES})
|
||||
SET_PROPERTY(TARGET bsdcat_test PROPERTY COMPILE_DEFINITIONS LIST_H)
|
||||
|
||||
#
|
||||
# Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
|
||||
#
|
||||
GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
|
||||
${CMAKE_CURRENT_LIST_FILE} ${bsdcat_test_SOURCES})
|
||||
SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# list.h has a line DEFINE_TEST(testname) for every
|
||||
# test. We can use that to define the tests for cmake by
|
||||
# defining a DEFINE_TEST macro and reading list.h in.
|
||||
MACRO (DEFINE_TEST _testname)
|
||||
ADD_TEST(
|
||||
NAME bsdcat_${_testname}
|
||||
COMMAND bsdcat_test -vv
|
||||
-p $<TARGET_FILE:bsdcat>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${_testname})
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
|
||||
# Experimental new test handling
|
||||
ADD_CUSTOM_TARGET(run_bsdcat_test
|
||||
COMMAND bsdcat_test -p $<TARGET_FILE:bsdcat>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_DEPENDENCIES(run_bsdcat_test bsdcat)
|
||||
ADD_DEPENDENCIES(run_all_tests run_bsdcat_test)
|
||||
|
||||
ENDIF(ENABLE_CAT AND ENABLE_TEST)
|
2969
cat/test/main.c
Normal file
2969
cat/test/main.c
Normal file
File diff suppressed because it is too large
Load Diff
344
cat/test/test.h
Normal file
344
cat/test/test.h
Normal file
@ -0,0 +1,344 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* Every test program should #include "test.h" as the first thing. */
|
||||
|
||||
/*
|
||||
* The goal of this file (and the matching test.c) is to
|
||||
* simplify the very repetitive test-*.c test programs.
|
||||
*/
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
/* Most POSIX platforms use the 'configure' script to build config.h */
|
||||
#include "config.h"
|
||||
#elif defined(__FreeBSD__)
|
||||
/* Building as part of FreeBSD system requires a pre-built config.h. */
|
||||
#include "config_freebsd.h"
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Win32 can't run the 'configure' script. */
|
||||
#include "config_windows.h"
|
||||
#else
|
||||
/* Warn if the library hasn't been (automatically or manually) configured. */
|
||||
#error Oops: No config.h and no pre-built configuration in test.h.
|
||||
#endif
|
||||
|
||||
#include <sys/types.h> /* Windows requires this before sys/stat.h */
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#ifdef HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#define dirent direct
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* System-specific tweaks. We really want to minimize these
|
||||
* as much as possible, since they make it harder to understand
|
||||
* the mainline code.
|
||||
*/
|
||||
|
||||
/* Windows (including Visual Studio and MinGW but not Cygwin) */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#if !defined(__BORLANDC__)
|
||||
#undef chdir
|
||||
#define chdir _chdir
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Visual Studio */
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#pragma warn -8068 /* Constant out of range in comparison. */
|
||||
#endif
|
||||
|
||||
/* Haiku OS and QNX */
|
||||
#if defined(__HAIKU__) || defined(__QNXNTO__)
|
||||
/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Redefine DEFINE_TEST for use in defining the test functions.
|
||||
*/
|
||||
#undef DEFINE_TEST
|
||||
#define DEFINE_TEST(name) void name(void); void name(void)
|
||||
|
||||
/* An implementation of the standard assert() macro */
|
||||
#define assert(e) assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
|
||||
/* chdir() and error if it fails */
|
||||
#define assertChdir(path) \
|
||||
assertion_chdir(__FILE__, __LINE__, path)
|
||||
/* Assert two integers are the same. Reports value of each one if not. */
|
||||
#define assertEqualInt(v1,v2) \
|
||||
assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* Assert two strings are the same. Reports value of each one if not. */
|
||||
#define assertEqualString(v1,v2) \
|
||||
assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0)
|
||||
#define assertEqualUTF8String(v1,v2) \
|
||||
assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
|
||||
/* As above, but v1 and v2 are wchar_t * */
|
||||
#define assertEqualWString(v1,v2) \
|
||||
assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* As above, but raw blocks of bytes. */
|
||||
#define assertEqualMem(v1, v2, l) \
|
||||
assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
|
||||
/* Assert that memory is full of a specified byte */
|
||||
#define assertMemoryFilledWith(v1, l, b) \
|
||||
assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL)
|
||||
/* Assert two files are the same. */
|
||||
#define assertEqualFile(f1, f2) \
|
||||
assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
|
||||
/* Assert that a file is empty. */
|
||||
#define assertEmptyFile(pathname) \
|
||||
assertion_empty_file(__FILE__, __LINE__, (pathname))
|
||||
/* Assert that a file is not empty. */
|
||||
#define assertNonEmptyFile(pathname) \
|
||||
assertion_non_empty_file(__FILE__, __LINE__, (pathname))
|
||||
#define assertFileAtime(pathname, sec, nsec) \
|
||||
assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileAtimeRecent(pathname) \
|
||||
assertion_file_atime_recent(__FILE__, __LINE__, pathname)
|
||||
#define assertFileBirthtime(pathname, sec, nsec) \
|
||||
assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileBirthtimeRecent(pathname) \
|
||||
assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
|
||||
/* Assert that a file exists; supports printf-style arguments. */
|
||||
#define assertFileExists(pathname) \
|
||||
assertion_file_exists(__FILE__, __LINE__, pathname)
|
||||
/* Assert that a file exists. */
|
||||
#define assertFileNotExists(pathname) \
|
||||
assertion_file_not_exists(__FILE__, __LINE__, pathname)
|
||||
/* Assert that file contents match a string. */
|
||||
#define assertFileContents(data, data_size, pathname) \
|
||||
assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
|
||||
#define assertFileMtime(pathname, sec, nsec) \
|
||||
assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileMtimeRecent(pathname) \
|
||||
assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
|
||||
#define assertFileNLinks(pathname, nlinks) \
|
||||
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
|
||||
#define assertFileSize(pathname, size) \
|
||||
assertion_file_size(__FILE__, __LINE__, pathname, size)
|
||||
#define assertTextFileContents(text, pathname) \
|
||||
assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
|
||||
#define assertFileContainsLinesAnyOrder(pathname, lines) \
|
||||
assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
|
||||
#define assertIsDir(pathname, mode) \
|
||||
assertion_is_dir(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertIsHardlink(path1, path2) \
|
||||
assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
|
||||
#define assertIsNotHardlink(path1, path2) \
|
||||
assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
|
||||
#define assertIsReg(pathname, mode) \
|
||||
assertion_is_reg(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertIsSymlink(pathname, contents) \
|
||||
assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
|
||||
/* Create a directory, report error if it fails. */
|
||||
#define assertMakeDir(dirname, mode) \
|
||||
assertion_make_dir(__FILE__, __LINE__, dirname, mode)
|
||||
#define assertMakeFile(path, mode, contents) \
|
||||
assertion_make_file(__FILE__, __LINE__, path, mode, -1, contents)
|
||||
#define assertMakeBinFile(path, mode, csize, contents) \
|
||||
assertion_make_file(__FILE__, __LINE__, path, mode, csize, contents)
|
||||
#define assertMakeHardlink(newfile, oldfile) \
|
||||
assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
|
||||
#define assertMakeSymlink(newfile, linkto) \
|
||||
assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
|
||||
#define assertNodump(path) \
|
||||
assertion_nodump(__FILE__, __LINE__, path)
|
||||
#define assertUmask(mask) \
|
||||
assertion_umask(__FILE__, __LINE__, mask)
|
||||
#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec) \
|
||||
assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
|
||||
|
||||
/*
|
||||
* This would be simple with C99 variadic macros, but I don't want to
|
||||
* require that. Instead, I insert a function call before each
|
||||
* skipping() call to pass the file and line information down. Crude,
|
||||
* but effective.
|
||||
*/
|
||||
#define skipping \
|
||||
skipping_setup(__FILE__, __LINE__);test_skipping
|
||||
|
||||
/* Function declarations. These are defined in test_utility.c. */
|
||||
void failure(const char *fmt, ...);
|
||||
int assertion_assert(const char *, int, int, const char *, void *);
|
||||
int assertion_chdir(const char *, int, const char *);
|
||||
int assertion_empty_file(const char *, int, const char *);
|
||||
int assertion_equal_file(const char *, int, const char *, const char *);
|
||||
int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
|
||||
int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
|
||||
int assertion_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *);
|
||||
int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
|
||||
int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
|
||||
int assertion_file_atime(const char *, int, const char *, long, long);
|
||||
int assertion_file_atime_recent(const char *, int, const char *);
|
||||
int assertion_file_birthtime(const char *, int, const char *, long, long);
|
||||
int assertion_file_birthtime_recent(const char *, int, const char *);
|
||||
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
|
||||
int assertion_file_contents(const char *, int, const void *, int, const char *);
|
||||
int assertion_file_exists(const char *, int, const char *);
|
||||
int assertion_file_mtime(const char *, int, const char *, long, long);
|
||||
int assertion_file_mtime_recent(const char *, int, const char *);
|
||||
int assertion_file_nlinks(const char *, int, const char *, int);
|
||||
int assertion_file_not_exists(const char *, int, const char *);
|
||||
int assertion_file_size(const char *, int, const char *, long);
|
||||
int assertion_is_dir(const char *, int, const char *, int);
|
||||
int assertion_is_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_not_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_reg(const char *, int, const char *, int);
|
||||
int assertion_is_symlink(const char *, int, const char *, const char *);
|
||||
int assertion_make_dir(const char *, int, const char *, int);
|
||||
int assertion_make_file(const char *, int, const char *, int, int, const void *);
|
||||
int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
|
||||
int assertion_make_symlink(const char *, int, const char *newpath, const char *);
|
||||
int assertion_nodump(const char *, int, const char *);
|
||||
int assertion_non_empty_file(const char *, int, const char *);
|
||||
int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
|
||||
int assertion_umask(const char *, int, int);
|
||||
int assertion_utimes(const char *, int, const char *, long, long, long, long );
|
||||
|
||||
void skipping_setup(const char *, int);
|
||||
void test_skipping(const char *fmt, ...);
|
||||
|
||||
/* Like sprintf, then system() */
|
||||
int systemf(const char * fmt, ...);
|
||||
|
||||
/* Delay until time() returns a value after this. */
|
||||
void sleepUntilAfter(time_t);
|
||||
|
||||
/* Return true if this platform can create symlinks. */
|
||||
int canSymlink(void);
|
||||
|
||||
/* Return true if this platform can run the "bzip2" program. */
|
||||
int canBzip2(void);
|
||||
|
||||
/* Return true if this platform can run the "grzip" program. */
|
||||
int canGrzip(void);
|
||||
|
||||
/* Return true if this platform can run the "gzip" program. */
|
||||
int canGzip(void);
|
||||
|
||||
/* Return true if this platform can run the specified command. */
|
||||
int canRunCommand(const char *);
|
||||
|
||||
/* Return true if this platform can run the "lrzip" program. */
|
||||
int canLrzip(void);
|
||||
|
||||
/* Return true if this platform can run the "lz4" program. */
|
||||
int canLz4(void);
|
||||
|
||||
/* Return true if this platform can run the "lzip" program. */
|
||||
int canLzip(void);
|
||||
|
||||
/* Return true if this platform can run the "lzma" program. */
|
||||
int canLzma(void);
|
||||
|
||||
/* Return true if this platform can run the "lzop" program. */
|
||||
int canLzop(void);
|
||||
|
||||
/* Return true if this platform can run the "xz" program. */
|
||||
int canXz(void);
|
||||
|
||||
/* Return true if this filesystem can handle nodump flags. */
|
||||
int canNodump(void);
|
||||
|
||||
/* Return true if the file has large i-node number(>0xffffffff). */
|
||||
int is_LargeInode(const char *);
|
||||
|
||||
/* Suck file into string allocated via malloc(). Call free() when done. */
|
||||
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
|
||||
char *slurpfile(size_t *, const char *fmt, ...);
|
||||
|
||||
/* Dump block of bytes to a file. */
|
||||
void dumpfile(const char *filename, void *, size_t);
|
||||
|
||||
/* Extracts named reference file to the current directory. */
|
||||
void extract_reference_file(const char *);
|
||||
/* Copies named reference file to the current directory. */
|
||||
void copy_reference_file(const char *);
|
||||
|
||||
/* Extracts a list of files to the current directory.
|
||||
* List must be NULL terminated.
|
||||
*/
|
||||
void extract_reference_files(const char **);
|
||||
|
||||
/* Path to working directory for current test */
|
||||
extern const char *testworkdir;
|
||||
|
||||
/*
|
||||
* Special interfaces for program test harness.
|
||||
*/
|
||||
|
||||
/* Pathname of exe to be tested. */
|
||||
extern const char *testprogfile;
|
||||
/* Name of exe to use in printf-formatted command strings. */
|
||||
/* On Windows, this includes leading/trailing quotes. */
|
||||
extern const char *testprog;
|
||||
|
||||
#ifdef USE_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
67
cat/test/test_0.c
Normal file
67
cat/test/test_0.c
Normal file
@ -0,0 +1,67 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* This first test does basic sanity checks on the environment. For
|
||||
* most of these, we just exit on failure.
|
||||
*/
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define DEV_NULL "/dev/null"
|
||||
#else
|
||||
#define DEV_NULL "NUL"
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_0)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
failure("File %s does not exist?!", testprog);
|
||||
if (!assertEqualInt(0, stat(testprogfile, &st))) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s does not exist; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
failure("%s is not executable?!", testprog);
|
||||
if (!assert((st.st_mode & 0111) != 0)) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s not executable; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to successfully run the program; this requires that
|
||||
* we know some option that will succeed.
|
||||
*/
|
||||
if (0 != systemf("%s --version >" DEV_NULL, testprog)) {
|
||||
failure("Unable to successfully run: %s --version\n", testprog, testprog);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/* TODO: Ensure that our reference files are available. */
|
||||
}
|
4
cat/test/test_empty.gz.uu
Normal file
4
cat/test/test_empty.gz.uu
Normal file
@ -0,0 +1,4 @@
|
||||
begin 644 test_empty.gz
|
||||
?'XL(""\MZE,``W1E<W1?96UP='D``P``````````````
|
||||
`
|
||||
end
|
4
cat/test/test_empty.lz4.uu
Normal file
4
cat/test/test_empty.lz4.uu
Normal file
@ -0,0 +1,4 @@
|
||||
begin 644 test_empty.lz4
|
||||
/!")-&&1PN0`````%7<P"
|
||||
`
|
||||
end
|
4
cat/test/test_empty.xz.uu
Normal file
4
cat/test/test_empty.xz.uu
Normal file
@ -0,0 +1,4 @@
|
||||
begin 644 test_empty.xz
|
||||
@_3=Z6%H```3FUK1&`````!S?1"$?MO-]`0`````$65H`
|
||||
`
|
||||
end
|
41
cat/test/test_empty_gz.c
Normal file
41
cat/test/test_empty_gz.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Sebastian Freundt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_empty_gz)
|
||||
{
|
||||
const char *reffile = "test_empty.gz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGzip()) {
|
||||
assertEqualInt(0, f);
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems gzip is not supported on this platform");
|
||||
}
|
||||
}
|
41
cat/test/test_empty_lz4.c
Normal file
41
cat/test/test_empty_lz4.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Sebastian Freundt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_empty_lz4)
|
||||
{
|
||||
const char *reffile = "test_empty.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, f);
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
41
cat/test/test_empty_xz.c
Normal file
41
cat/test/test_empty_xz.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Sebastian Freundt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_empty_xz)
|
||||
{
|
||||
const char *reffile = "test_empty.xz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canXz()) {
|
||||
assertEqualInt(0, f);
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems xz is not supported on this platform");
|
||||
}
|
||||
}
|
36
cat/test/test_error.c
Normal file
36
cat/test/test_error.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_error)
|
||||
{
|
||||
const char *reffile = "test_expand.error";
|
||||
|
||||
assertFileNotExists(reffile);
|
||||
assert(0 != systemf("%s %s >test.out 2>test.err", testprog, reffile));
|
||||
|
||||
assertEmptyFile("test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
}
|
43
cat/test/test_error_mixed.c
Normal file
43
cat/test/test_error_mixed.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_error_mixed)
|
||||
{
|
||||
const char *reffile1 = "test_expand.plain";
|
||||
const char *reffile2 = "test_expand.error";
|
||||
const char *reffile3 = "test_expand.Z";
|
||||
|
||||
assertFileNotExists(reffile2);
|
||||
extract_reference_file(reffile1);
|
||||
extract_reference_file(reffile3);
|
||||
assert(0 != systemf("%s %s %s %s >test.out 2>test.err",
|
||||
testprog, reffile1, reffile2, reffile3));
|
||||
|
||||
assertTextFileContents(
|
||||
"contents of test_expand.plain.\n"
|
||||
"contents of test_expand.Z.\n", "test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
}
|
3
cat/test/test_expand.Z.uu
Normal file
3
cat/test/test_expand.Z.uu
Normal file
@ -0,0 +1,3 @@
|
||||
begin 664 test_expand.Z
|
||||
@'YV08]ZXH5-FX!P0;\R`(#B'SI<R>."$<4/&A187"@`
|
||||
end
|
5
cat/test/test_expand.bz2.uu
Normal file
5
cat/test/test_expand.bz2.uu
Normal file
@ -0,0 +1,5 @@
|
||||
begin 664 test_expand.bz2
|
||||
M0EIH.3%!62936=[T@^L [__N000(!!(#!@\P+(, !@4 1 @$" (0 80$
|
||||
M(!D0 " 5%)D::#( #0]0 9J%1Z@>H :!B:&33(!"X";"%C@I$+32H/(0MXG
|
||||
J,EA1G51 WG-"6JV7JKA;/&]$X 6MNH 8'N@3[\XCA_%W)%.%"0WO2#ZP
|
||||
end
|
4
cat/test/test_expand.gz.uu
Normal file
4
cat/test/test_expand.gz.uu
Normal file
@ -0,0 +1,4 @@
|
||||
begin 664 test_expand.gz
|
||||
M'XL("-UD1%,``V%S9`!+SL\K2<TK*5;(3U,H22TNB4^M*$C,2]%+K]+C`@`Z
|
||||
'PQU''```````
|
||||
end
|
5
cat/test/test_expand.lz4.uu
Normal file
5
cat/test/test_expand.lz4.uu
Normal file
@ -0,0 +1,5 @@
|
||||
begin 644 test_expand.lz4
|
||||
M!")-&&1PN1T``(!C;VYT96YT<R!O9B!T97-T7V5X<&%N9"YL>C0N"@`````Y
|
||||
#!E9+
|
||||
`
|
||||
end
|
3
cat/test/test_expand.plain.uu
Normal file
3
cat/test/test_expand.plain.uu
Normal file
@ -0,0 +1,3 @@
|
||||
begin 664 test_expand.plain
|
||||
?8V]N=&5N=',@;V8@=&5S=%]E>'!A;F0N<&QA:6XN"@
|
||||
end
|
4
cat/test/test_expand.xz.uu
Normal file
4
cat/test/test_expand.xz.uu
Normal file
@ -0,0 +1,4 @@
|
||||
begin 664 test_expand.xz
|
||||
M_3=Z6%H 3FUK1& @ A 18 !T+^6C 0 ;8V]N=&5N=',@;V8@=&5S=%]E
|
||||
G>'!A;F0N>'HN"@!S;^LVAO^3[ !-!R3&JV/'[;S?0$ !%E:
|
||||
end
|
36
cat/test/test_expand_Z.c
Normal file
36
cat/test/test_expand_Z.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_Z)
|
||||
{
|
||||
const char *reffile = "test_expand.Z";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s %s >test.out 2>test.err", testprog, reffile));
|
||||
|
||||
assertTextFileContents("contents of test_expand.Z.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
42
cat/test/test_expand_bz2.c
Normal file
42
cat/test/test_expand_bz2.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_bz2)
|
||||
{
|
||||
const char *reffile = "test_expand.bz2";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canBzip2()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.bz2.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems bzip2 is not supported on this platform");
|
||||
}
|
||||
}
|
42
cat/test/test_expand_gz.c
Normal file
42
cat/test/test_expand_gz.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_gz)
|
||||
{
|
||||
const char *reffile = "test_expand.gz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGzip()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.gz.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems gzip is not supported on this platform");
|
||||
}
|
||||
}
|
42
cat/test/test_expand_lz4.c
Normal file
42
cat/test/test_expand_lz4.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012, 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_lz4)
|
||||
{
|
||||
const char *reffile = "test_expand.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.lz4.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
41
cat/test/test_expand_mixed.c
Normal file
41
cat/test/test_expand_mixed.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_mixed)
|
||||
{
|
||||
const char *reffile1 = "test_expand.Z";
|
||||
const char *reffile2 = "test_expand.plain";
|
||||
|
||||
extract_reference_file(reffile1);
|
||||
extract_reference_file(reffile2);
|
||||
assertEqualInt(0, systemf("%s %s %s >test.out 2>test.err",
|
||||
testprog, reffile1, reffile2));
|
||||
|
||||
assertTextFileContents(
|
||||
"contents of test_expand.Z.\n"
|
||||
"contents of test_expand.plain.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
36
cat/test/test_expand_plain.c
Normal file
36
cat/test/test_expand_plain.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_plain)
|
||||
{
|
||||
const char *reffile = "test_expand.plain";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s %s >test.out 2>test.err", testprog, reffile));
|
||||
|
||||
assertTextFileContents("contents of test_expand.plain.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
42
cat/test/test_expand_xz.c
Normal file
42
cat/test/test_expand_xz.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_xz)
|
||||
{
|
||||
const char *reffile = "test_expand.xz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canXz()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.xz.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems xz is not supported on this platform");
|
||||
}
|
||||
}
|
75
cat/test/test_help.c
Normal file
75
cat/test/test_help.c
Normal file
@ -0,0 +1,75 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* Test that "--help", "-h", and "-W help" options all work and
|
||||
* generate reasonable output.
|
||||
*/
|
||||
|
||||
static int
|
||||
in_first_line(const char *p, const char *substring)
|
||||
{
|
||||
size_t l = strlen(substring);
|
||||
|
||||
while (*p != '\0' && *p != '\n') {
|
||||
if (memcmp(p, substring, l) == 0)
|
||||
return (1);
|
||||
++p;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_help)
|
||||
{
|
||||
int r;
|
||||
char *p;
|
||||
size_t plen;
|
||||
|
||||
/* Exercise --help option. */
|
||||
r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("--help should generate nothing to stderr.");
|
||||
assertEmptyFile("help.stderr");
|
||||
/* Help message should start with name of program. */
|
||||
p = slurpfile(&plen, "help.stdout");
|
||||
failure("Help output should be long enough.");
|
||||
assert(plen >= 6);
|
||||
failure("First line of help output should contain 'bsdcat': %s", p);
|
||||
assert(in_first_line(p, "bsdcat"));
|
||||
/*
|
||||
* TODO: Extend this check to further verify that --help output
|
||||
* looks approximately right.
|
||||
*/
|
||||
free(p);
|
||||
|
||||
/* -h option should generate the same output. */
|
||||
r = systemf("%s -h >h.stdout 2>h.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("-h should generate nothing to stderr.");
|
||||
assertEmptyFile("h.stderr");
|
||||
failure("stdout should be same for -h and --help");
|
||||
assertEqualFile("h.stdout", "help.stdout");
|
||||
}
|
97
cat/test/test_version.c
Normal file
97
cat/test/test_version.c
Normal file
@ -0,0 +1,97 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* Test that --version option works and generates reasonable output.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_version)
|
||||
{
|
||||
int r;
|
||||
char *p, *q;
|
||||
size_t s;
|
||||
|
||||
|
||||
r = systemf("%s --version >version.stdout 2>version.stderr", testprog);
|
||||
failure("Unable to run %s --version", testprog);
|
||||
if (!assert(r == 0))
|
||||
return;
|
||||
|
||||
/* --version should generate nothing to stdout. */
|
||||
assertEmptyFile("version.stderr");
|
||||
/* Verify format of version message. */
|
||||
q = p = slurpfile(&s, "version.stdout");
|
||||
/* Version message should start with name of program, then space. */
|
||||
assert(s > 6);
|
||||
failure("Version must start with 'bsdcat': ``%s''", p);
|
||||
if (!assertEqualMem(q, "bsdcat ", 7))
|
||||
return;
|
||||
q += 7; s -= 7;
|
||||
/* Version number is a series of digits and periods. */
|
||||
while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* Version number terminated by space. */
|
||||
failure("No space after bsdcat version: ``%s''", p);
|
||||
assert(s > 1);
|
||||
/* Skip a single trailing a,b,c, or d. */
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
failure("No space after bsdcat version: ``%s''", p);
|
||||
assert(*q == ' ');
|
||||
++q; --s;
|
||||
/* Separator. */
|
||||
failure("No `-' between bsdcat and libarchive versions: ``%s''", p);
|
||||
assertEqualMem(q, "- ", 2);
|
||||
q += 2; s -= 2;
|
||||
/* libarchive name and version number */
|
||||
failure("Not long enough for libarchive version: ``%s''", p);
|
||||
assert(s > 11);
|
||||
failure("Libarchive version must start with `libarchive': ``%s''", p);
|
||||
assertEqualMem(q, "libarchive ", 11);
|
||||
q += 11; s -= 11;
|
||||
/* Version number is a series of digits and periods. */
|
||||
while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* Skip a single trailing a,b,c, or d. */
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* All terminated by end-of-line. */
|
||||
assert(s >= 1);
|
||||
/* Skip an optional CR character (e.g., Windows) */
|
||||
failure("Version output must end with \\n or \\r\\n");
|
||||
if (*q == '\r') { ++q; --s; }
|
||||
assertEqualMem(q, "\n", 1);
|
||||
free(p);
|
||||
}
|
139
configure.ac
139
configure.ac
@ -4,20 +4,21 @@ dnl First, define all of the version numbers up front.
|
||||
dnl In particular, this allows the version macro to be used in AC_INIT
|
||||
|
||||
dnl These first two version numbers are updated automatically on each release.
|
||||
m4_define([LIBARCHIVE_VERSION_S],[3.1.2])
|
||||
m4_define([LIBARCHIVE_VERSION_N],[3001002])
|
||||
m4_define([LIBARCHIVE_VERSION_S],[3.2.0])
|
||||
m4_define([LIBARCHIVE_VERSION_N],[3002000])
|
||||
|
||||
dnl bsdtar and bsdcpio versioning tracks libarchive
|
||||
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
|
||||
m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())
|
||||
m4_define([BSDCAT_VERSION_S],LIBARCHIVE_VERSION_S())
|
||||
|
||||
AC_PREREQ(2.65)
|
||||
AC_PREREQ([2.69])
|
||||
|
||||
#
|
||||
# Now starts the "real" configure script.
|
||||
#
|
||||
|
||||
AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[libarchive-discuss@googlegroups.com])
|
||||
AC_INIT([libarchive],[LIBARCHIVE_VERSION_S()],[libarchive-discuss@googlegroups.com])
|
||||
# Make sure the srcdir contains "libarchive" directory
|
||||
AC_CONFIG_SRCDIR([libarchive])
|
||||
# Use auxiliary subscripts from this subdirectory (cleans up root)
|
||||
@ -53,12 +54,15 @@ AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
|
||||
[Version number of bsdcpio])
|
||||
AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
|
||||
[Version number of bsdtar])
|
||||
AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
|
||||
[Version number of bsdcat])
|
||||
|
||||
# The shell variables here must be the same as the AC_SUBST() variables
|
||||
# below, but the shell variable names apparently cannot be the same as
|
||||
# the m4 macro names above. Why? Ask autoconf.
|
||||
BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
|
||||
BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
|
||||
BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
|
||||
LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
|
||||
LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
|
||||
|
||||
@ -68,6 +72,7 @@ LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
|
||||
AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
|
||||
AC_SUBST(BSDCPIO_VERSION_STRING)
|
||||
AC_SUBST(BSDTAR_VERSION_STRING)
|
||||
AC_SUBST(BSDCAT_VERSION_STRING)
|
||||
AC_SUBST(LIBARCHIVE_VERSION_STRING)
|
||||
AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
|
||||
|
||||
@ -102,6 +107,7 @@ AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
AC_PROG_LIBTOOL
|
||||
AC_CHECK_TOOL([STRIP],[strip])
|
||||
AC_PROG_MKDIR_P
|
||||
|
||||
#
|
||||
# Options for building bsdtar.
|
||||
@ -147,6 +153,50 @@ esac
|
||||
AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
|
||||
AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
|
||||
|
||||
#
|
||||
# Options for building bsdcat.
|
||||
#
|
||||
# Default is to build bsdcat, but allow people to override that.
|
||||
#
|
||||
AC_ARG_ENABLE([bsdcat],
|
||||
[AS_HELP_STRING([--enable-bsdcat], [enable build of bsdcat (default)])
|
||||
AS_HELP_STRING([--enable-bsdcat=static], [force static build of bsdcat])
|
||||
AS_HELP_STRING([--enable-bsdcat=shared], [force dynamic build of bsdcat])
|
||||
AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
|
||||
[], [enable_bsdcat=yes])
|
||||
|
||||
case "$enable_bsdcat" in
|
||||
yes)
|
||||
if test "$enable_static" = "no"; then
|
||||
static_bsdcat=no
|
||||
else
|
||||
static_bsdcat=yes
|
||||
fi
|
||||
build_bsdcat=yes
|
||||
;;
|
||||
dynamic|shared)
|
||||
if test "$enable_shared" = "no"; then
|
||||
AC_MSG_FAILURE([Shared linking of bsdcat requires shared libarchive])
|
||||
fi
|
||||
build_bsdcat=yes
|
||||
static_bsdcat=no
|
||||
;;
|
||||
static)
|
||||
build_bsdcat=yes
|
||||
static_bsdcat=yes
|
||||
;;
|
||||
no)
|
||||
build_bsdcat=no
|
||||
static_bsdcat=no
|
||||
;;
|
||||
*)
|
||||
AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
|
||||
AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
|
||||
|
||||
#
|
||||
# Options for building bsdcpio.
|
||||
#
|
||||
@ -193,8 +243,9 @@ AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
|
||||
# Set up defines needed before including any headers
|
||||
case $host in
|
||||
*mingw* | *cygwin* )
|
||||
AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
|
||||
AC_DEFINE([WINVER], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
|
||||
AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
|
||||
AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
|
||||
AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -218,7 +269,8 @@ AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
|
||||
|
||||
AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
|
||||
AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
|
||||
AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h signal.h spawn.h])
|
||||
AC_CHECK_HEADERS([locale.h paths.h poll.h pthread.h pwd.h])
|
||||
AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
|
||||
AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
|
||||
AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/extattr.h])
|
||||
AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
|
||||
@ -226,6 +278,7 @@ AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/statfs.h sys/statvfs.h
|
||||
AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h])
|
||||
AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
|
||||
AC_CHECK_HEADERS([windows.h])
|
||||
AC_CHECK_HEADERS([Bcrypt.h])
|
||||
# check windows.h first; the other headers require it.
|
||||
AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
|
||||
[[#ifdef HAVE_WINDOWS_H
|
||||
@ -299,12 +352,34 @@ if test "x$with_iconv" != "xno"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([lz4],
|
||||
AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
|
||||
|
||||
if test "x$with_lz4" != "xno"; then
|
||||
AC_CHECK_HEADERS([lz4.h lz4hc.h])
|
||||
AC_CHECK_LIB(lz4,LZ4_decompress_safe)
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([lzma],
|
||||
AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
|
||||
|
||||
if test "x$with_lzma" != "xno"; then
|
||||
AC_CHECK_HEADERS([lzma.h])
|
||||
AC_CHECK_LIB(lzma,lzma_stream_decoder)
|
||||
# Some pre-release (but widely distributed) versions of liblzma
|
||||
# included a disabled version of lzma_stream_encoder_mt that
|
||||
# fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
|
||||
# to do something more complex here:
|
||||
AC_CACHE_CHECK(
|
||||
[whether we have multithread support in lzma],
|
||||
ac_cv_lzma_has_mt,
|
||||
[AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[#include <lzma.h>]],
|
||||
[[lzma_stream_encoder_mt(0, 0);]])],
|
||||
[ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
|
||||
if test "x$ac_cv_lzma_has_mt" != xno; then
|
||||
AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([lzo2],
|
||||
@ -329,14 +404,14 @@ AC_ARG_WITH([expat],
|
||||
AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
|
||||
|
||||
if test "x$with_xml2" != "xno"; then
|
||||
AC_PATH_PROG([XML2_CONFIG], [xml2-config],, [${PATH}])
|
||||
if test "x$XML2_CONFIG" != "x"; then
|
||||
CPPFLAGS="${CPPFLAGS} `${XML2_CONFIG} --cflags`"
|
||||
LIBS="${LIBS} `${XML2_CONFIG} --libs`"
|
||||
PKG_PROG_PKG_CONFIG
|
||||
PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
|
||||
CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
|
||||
LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
|
||||
AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
|
||||
else
|
||||
], [
|
||||
AC_CHECK_LIB(xml2,xmlInitParser)
|
||||
fi
|
||||
])
|
||||
AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
|
||||
fi
|
||||
if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
|
||||
@ -411,9 +486,12 @@ fi
|
||||
# -larchive in that case.
|
||||
#AC_CHECK_LIB(archive,archive_version)
|
||||
|
||||
# Checks for supported compiler flags
|
||||
AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
# AC_TYPE_UID_T defaults to "int", which is incorrect for MinGW
|
||||
# la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
|
||||
# and MSVC. Use a customized version.
|
||||
la_TYPE_UID_T
|
||||
AC_TYPE_MODE_T
|
||||
@ -475,7 +553,9 @@ AC_TYPE_INT16_T
|
||||
AC_TYPE_UINT16_T
|
||||
AC_TYPE_UINT8_T
|
||||
|
||||
AC_CHECK_DECLS([SIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
|
||||
AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
|
||||
AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
|
||||
AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
|
||||
|
||||
AC_CHECK_DECL([SSIZE_MAX],
|
||||
[AC_DEFINE(HAVE_DECL_SSIZE_MAX, 1, [Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you don't.])],
|
||||
@ -512,7 +592,7 @@ AC_FUNC_VPRINTF
|
||||
# To avoid necessity for including windows.h or special forward declaration
|
||||
# workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
|
||||
AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
|
||||
AC_CHECK_FUNCS([chflags chown chroot ctime_r dirfd])
|
||||
AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r dirfd])
|
||||
AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
|
||||
AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
|
||||
AC_CHECK_FUNCS([futimens futimes futimesat])
|
||||
@ -522,10 +602,11 @@ AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat lutimes])
|
||||
AC_CHECK_FUNCS([mbrtowc memmove memset])
|
||||
AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
|
||||
AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
|
||||
AC_CHECK_FUNCS([readpassphrase])
|
||||
AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
|
||||
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
|
||||
AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
|
||||
AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy])
|
||||
AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
|
||||
AC_CHECK_FUNCS([_ctime64_s _fseeki64])
|
||||
AC_CHECK_FUNCS([_get_timezone _localtime64_s _mkgmtime64])
|
||||
# detects cygwin-1.7, as opposed to older versions
|
||||
@ -568,7 +649,7 @@ AC_ARG_ENABLE([xattr],
|
||||
if test "x$enable_xattr" != "xno"; then
|
||||
AC_CHECK_HEADERS([attr/xattr.h])
|
||||
AC_CHECK_HEADERS([sys/xattr.h sys/ea.h])
|
||||
AC_CHECK_LIB(attr,setxattr)
|
||||
AC_SEARCH_LIBS([setxattr], [attr])
|
||||
AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
|
||||
AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
|
||||
AC_CHECK_FUNCS([fgetxattr flistxattr fsetxattr getxattr])
|
||||
@ -642,7 +723,7 @@ AC_DEFUN([CRYPTO_CHECK], [
|
||||
#define ARCHIVE_CRYPTO_$1_$2
|
||||
#define PLATFORM_CONFIG_H "check_crypto_md.h"
|
||||
|
||||
$(cat "$srcdir/libarchive/archive_crypto.c")
|
||||
$(cat "$srcdir/libarchive/archive_digest.c")
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@ -717,8 +798,9 @@ esac
|
||||
|
||||
if test "x$with_nettle" != "xno"; then
|
||||
AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
|
||||
AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
|
||||
saved_LIBS=$LIBS
|
||||
AC_CHECK_LIB(nettle,main)
|
||||
AC_CHECK_LIB(nettle,nettle_sha1_init)
|
||||
CRYPTO_CHECK(MD5, NETTLE, md5)
|
||||
CRYPTO_CHECK(RMD160, NETTLE, rmd160)
|
||||
CRYPTO_CHECK(SHA1, NETTLE, sha1)
|
||||
@ -729,6 +811,7 @@ if test "x$with_nettle" != "xno"; then
|
||||
LIBS=$saved_LIBS
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$with_openssl" != "xno"; then
|
||||
AC_CHECK_HEADERS([openssl/evp.h])
|
||||
saved_LIBS=$LIBS
|
||||
@ -736,18 +819,18 @@ if test "x$with_openssl" != "xno"; then
|
||||
*mingw* | *cygwin*)
|
||||
case "$host_cpu" in
|
||||
x86_64)
|
||||
AC_CHECK_LIB(eay64,main)
|
||||
AC_CHECK_LIB(eay64,OPENSSL_config)
|
||||
if test "x$ac_cv_lib_eay64_main" != "xyes"; then
|
||||
AC_CHECK_LIB(eay32,main)
|
||||
AC_CHECK_LIB(eay32,OPENSSL_config)
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_LIB(eay32,main)
|
||||
AC_CHECK_LIB(eay32,OPENSSL_config)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_LIB(crypto,main)
|
||||
AC_CHECK_LIB(crypto,OPENSSL_config)
|
||||
;;
|
||||
esac
|
||||
CRYPTO_CHECK(MD5, OPENSSL, md5)
|
||||
@ -758,6 +841,8 @@ if test "x$with_openssl" != "xno"; then
|
||||
CRYPTO_CHECK(SHA512, OPENSSL, sha512)
|
||||
if test "x$found_OPENSSL" != "xyes"; then
|
||||
LIBS=$saved_LIBS
|
||||
else
|
||||
AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -765,7 +850,7 @@ fi
|
||||
# The two are incompatible and OpenSSL is more complete.
|
||||
AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
|
||||
saved_LIBS=$LIBS
|
||||
AC_CHECK_LIB(md,main)
|
||||
AC_CHECK_LIB(md,MD5Init)
|
||||
CRYPTO_CHECK(MD5, LIBMD, md5)
|
||||
CRYPTO_CHECK(RMD160, LIBMD, rmd160)
|
||||
CRYPTO_CHECK(SHA1, LIBMD, sha1)
|
||||
@ -785,4 +870,8 @@ case "$host_os" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Ensure test directories are present if building out-of-tree
|
||||
AC_CONFIG_COMMANDS([mkdirs],
|
||||
[mkdir -p libarchive/test tar/test cat/test cpio/test])
|
||||
|
||||
AC_OUTPUT
|
||||
|
306
contrib/android/Android.mk
Normal file
306
contrib/android/Android.mk
Normal file
@ -0,0 +1,306 @@
|
||||
#
|
||||
# Copyright (C) 2014 Trevor Drake
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
# A bit of a non-standard LOCAL_PATH declaration here
|
||||
# The Android.mk lives below the top source directory
|
||||
# but LOCAL_PATH needs to point to the top of the module
|
||||
# source tree to maintain the integrity of the intermediates
|
||||
# directories
|
||||
LOCAL_PATH := $(subst /contrib/android,,$(call my-dir))
|
||||
|
||||
libarchive_target_config := contrib/android/config/android.h
|
||||
|
||||
libarchive_src_files := libarchive/archive_acl.c \
|
||||
libarchive/archive_check_magic.c \
|
||||
libarchive/archive_cmdline.c \
|
||||
libarchive/archive_cryptor.c \
|
||||
libarchive/archive_digest.c \
|
||||
libarchive/archive_entry.c \
|
||||
libarchive/archive_entry_copy_stat.c \
|
||||
libarchive/archive_entry_link_resolver.c \
|
||||
libarchive/archive_entry_sparse.c \
|
||||
libarchive/archive_entry_stat.c \
|
||||
libarchive/archive_entry_strmode.c \
|
||||
libarchive/archive_entry_xattr.c \
|
||||
libarchive/archive_getdate.c \
|
||||
libarchive/archive_hmac.c \
|
||||
libarchive/archive_match.c \
|
||||
libarchive/archive_options.c \
|
||||
libarchive/archive_pack_dev.c \
|
||||
libarchive/archive_pathmatch.c \
|
||||
libarchive/archive_ppmd7.c \
|
||||
libarchive/archive_random.c \
|
||||
libarchive/archive_rb.c \
|
||||
libarchive/archive_read.c \
|
||||
libarchive/archive_read_add_passphrase.c \
|
||||
libarchive/archive_read_append_filter.c \
|
||||
libarchive/archive_read_data_into_fd.c \
|
||||
libarchive/archive_read_disk_entry_from_file.c \
|
||||
libarchive/archive_read_disk_posix.c \
|
||||
libarchive/archive_read_disk_set_standard_lookup.c \
|
||||
libarchive/archive_read_extract.c \
|
||||
libarchive/archive_read_extract2.c \
|
||||
libarchive/archive_read_open_fd.c \
|
||||
libarchive/archive_read_open_file.c \
|
||||
libarchive/archive_read_open_filename.c \
|
||||
libarchive/archive_read_open_memory.c \
|
||||
libarchive/archive_read_set_format.c \
|
||||
libarchive/archive_read_set_options.c \
|
||||
libarchive/archive_read_support_filter_all.c \
|
||||
libarchive/archive_read_support_filter_bzip2.c \
|
||||
libarchive/archive_read_support_filter_compress.c \
|
||||
libarchive/archive_read_support_filter_grzip.c \
|
||||
libarchive/archive_read_support_filter_gzip.c \
|
||||
libarchive/archive_read_support_filter_lrzip.c \
|
||||
libarchive/archive_read_support_filter_lz4.c \
|
||||
libarchive/archive_read_support_filter_lzop.c \
|
||||
libarchive/archive_read_support_filter_none.c \
|
||||
libarchive/archive_read_support_filter_program.c \
|
||||
libarchive/archive_read_support_filter_rpm.c \
|
||||
libarchive/archive_read_support_filter_uu.c \
|
||||
libarchive/archive_read_support_filter_xz.c \
|
||||
libarchive/archive_read_support_format_7zip.c \
|
||||
libarchive/archive_read_support_format_all.c \
|
||||
libarchive/archive_read_support_format_ar.c \
|
||||
libarchive/archive_read_support_format_by_code.c \
|
||||
libarchive/archive_read_support_format_cab.c \
|
||||
libarchive/archive_read_support_format_cpio.c \
|
||||
libarchive/archive_read_support_format_empty.c \
|
||||
libarchive/archive_read_support_format_iso9660.c \
|
||||
libarchive/archive_read_support_format_lha.c \
|
||||
libarchive/archive_read_support_format_mtree.c \
|
||||
libarchive/archive_read_support_format_rar.c \
|
||||
libarchive/archive_read_support_format_raw.c \
|
||||
libarchive/archive_read_support_format_tar.c \
|
||||
libarchive/archive_read_support_format_warc.c \
|
||||
libarchive/archive_read_support_format_xar.c \
|
||||
libarchive/archive_read_support_format_zip.c \
|
||||
libarchive/archive_string.c \
|
||||
libarchive/archive_string_sprintf.c \
|
||||
libarchive/archive_util.c \
|
||||
libarchive/archive_virtual.c \
|
||||
libarchive/archive_write.c \
|
||||
libarchive/archive_write_disk_acl.c \
|
||||
libarchive/archive_write_disk_posix.c \
|
||||
libarchive/archive_write_disk_set_standard_lookup.c \
|
||||
libarchive/archive_write_open_fd.c \
|
||||
libarchive/archive_write_open_file.c \
|
||||
libarchive/archive_write_open_filename.c \
|
||||
libarchive/archive_write_open_memory.c \
|
||||
libarchive/archive_write_add_filter.c \
|
||||
libarchive/archive_write_add_filter_b64encode.c \
|
||||
libarchive/archive_write_add_filter_by_name.c \
|
||||
libarchive/archive_write_add_filter_bzip2.c \
|
||||
libarchive/archive_write_add_filter_compress.c \
|
||||
libarchive/archive_write_add_filter_grzip.c \
|
||||
libarchive/archive_write_add_filter_gzip.c \
|
||||
libarchive/archive_write_add_filter_lrzip.c \
|
||||
libarchive/archive_write_add_filter_lz4.c \
|
||||
libarchive/archive_write_add_filter_lzop.c \
|
||||
libarchive/archive_write_add_filter_none.c \
|
||||
libarchive/archive_write_add_filter_program.c \
|
||||
libarchive/archive_write_add_filter_uuencode.c \
|
||||
libarchive/archive_write_add_filter_xz.c \
|
||||
libarchive/archive_write_set_format.c \
|
||||
libarchive/archive_write_set_format_7zip.c \
|
||||
libarchive/archive_write_set_format_ar.c \
|
||||
libarchive/archive_write_set_format_by_name.c \
|
||||
libarchive/archive_write_set_format_cpio.c \
|
||||
libarchive/archive_write_set_format_cpio_newc.c \
|
||||
libarchive/archive_write_set_format_iso9660.c \
|
||||
libarchive/archive_write_set_format_mtree.c \
|
||||
libarchive/archive_write_set_format_pax.c \
|
||||
libarchive/archive_write_set_format_raw.c \
|
||||
libarchive/archive_write_set_format_shar.c \
|
||||
libarchive/archive_write_set_format_ustar.c \
|
||||
libarchive/archive_write_set_format_v7tar.c \
|
||||
libarchive/archive_write_set_format_gnutar.c \
|
||||
libarchive/archive_write_set_format_warc.c \
|
||||
libarchive/archive_write_set_format_xar.c \
|
||||
libarchive/archive_write_set_format_zip.c \
|
||||
libarchive/archive_write_set_options.c \
|
||||
libarchive/archive_write_set_passphrase.c \
|
||||
libarchive/filter_fork_posix.c \
|
||||
libarchive/xxhash.c
|
||||
|
||||
ifeq ($(HOST_OS),windows)
|
||||
libarchive_host_src_files := \
|
||||
libarchive/archive_entry_copy_bhfi.c \
|
||||
libarchive/archive_read_disk_windows.c \
|
||||
libarchive/archive_write_disk_windows.c \
|
||||
libarchive/filter_fork_windows.c \
|
||||
libarchive/archive_windows.c
|
||||
else
|
||||
libarchive_host_src_files :=
|
||||
endif
|
||||
|
||||
libarchive_fe_src_files := libarchive_fe/err.c \
|
||||
libarchive_fe/line_reader.c \
|
||||
libarchive_fe/passphrase.c
|
||||
|
||||
bsdtar_src_files := tar/bsdtar.c \
|
||||
tar/bsdtar_windows.c \
|
||||
tar/cmdline.c \
|
||||
tar/creation_set.c \
|
||||
tar/read.c \
|
||||
tar/subst.c \
|
||||
tar/util.c \
|
||||
tar/write.c
|
||||
|
||||
bsdcpio_src_files := cpio/cmdline.c \
|
||||
cpio/cpio.c
|
||||
|
||||
bsdcat_src_files := cat/cmdline.c \
|
||||
cat/bsdcat.c
|
||||
|
||||
|
||||
ifeq ($(HOST_OS),darwin)
|
||||
$(warning Host : $(HOST_OS) Not Supported. Host Build Will Be Skipped )
|
||||
else
|
||||
libarchive_host_config := contrib/android/config/$(HOST_OS)_host.h
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libarchive
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_SRC_FILES := $(libarchive_src_files) $(libarchive_host_src_files)
|
||||
LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
|
||||
include $(BUILD_HOST_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libarchive
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz-host
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libarchive
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
|
||||
include $(BUILD_HOST_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libarchive_fe
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
|
||||
LOCAL_SRC_FILES := $(libarchive_fe_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive_fe
|
||||
include $(BUILD_HOST_STATIC_LIBRARY)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# Do not build target binaries if we are not targeting linux
|
||||
# on the host
|
||||
ifeq ($(HOST_OS),linux)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bsdtar
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DBSDTAR_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz-host
|
||||
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
|
||||
LOCAL_SRC_FILES := $(bsdtar_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
include $(BUILD_HOST_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bsdcpio
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DBSDCPIO_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz-host
|
||||
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
|
||||
LOCAL_SRC_FILES := $(bsdcpio_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
include $(BUILD_HOST_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bsdcat
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DBSDCAT_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz-host
|
||||
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
|
||||
LOCAL_SRC_FILES := $(bsdcat_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
include $(BUILD_HOST_EXECUTABLE)
|
||||
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libarchive
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_SRC_FILES := $(libarchive_src_files)
|
||||
LOCAL_STATIC_LIBRARIES := libz liblz4
|
||||
LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libarchive
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_C_INCLUDES :=
|
||||
LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libarchive
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libarchive_fe
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
|
||||
LOCAL_SRC_FILES := $(libarchive_fe_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive_fe
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bsdtar
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DBSDTAR_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz
|
||||
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
|
||||
LOCAL_SRC_FILES := $(bsdtar_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bsdcpio
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DBSDCPIO_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz
|
||||
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
|
||||
LOCAL_SRC_FILES := $(bsdcpio_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bsdcat
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS := -DBSDCAT_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
|
||||
LOCAL_SHARED_LIBRARIES := libz
|
||||
LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
|
||||
LOCAL_SRC_FILES := $(bsdcat_src_files)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
endif
|
184
contrib/android/config/android.h
Normal file
184
contrib/android/config/android.h
Normal file
@ -0,0 +1,184 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Trevor Drake
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
|
||||
#define ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
|
||||
|
||||
#include <android/api-level.h>
|
||||
#ifdef __ANDROID_API__
|
||||
#if __ANDROID_API__ > 20
|
||||
#define HAVE_FSTATVFS 1
|
||||
#define HAVE_STATVFS 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#define HAVE_SYS_XATTR_H 1
|
||||
#define HAVE_LINUX_FIEMAP_H 1
|
||||
#define HAVE_SYS_STATVFS_H 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define HAVE_CHOWN 1
|
||||
#define HAVE_CHROOT 1
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
|
||||
#define HAVE_DECL_INTMAX_MIN 1
|
||||
#define HAVE_DECL_INTMAX_MAX 1
|
||||
#define HAVE_DECL_INT64_MAX 1
|
||||
#define HAVE_DECL_INT64_MIN 1
|
||||
#define HAVE_DECL_SIZE_MAX 1
|
||||
#define HAVE_DECL_SSIZE_MAX 1
|
||||
#define HAVE_DECL_STRERROR_R 1
|
||||
#define HAVE_DECL_UINTMAX_MAX 1
|
||||
#define HAVE_DECL_UINT32_MAX 1
|
||||
#define HAVE_DECL_UINT64_MAX 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_DIRFD 1
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_EILSEQ 1
|
||||
#define HAVE_ERRNO_H 1
|
||||
#define HAVE_FCHDIR 1
|
||||
#define HAVE_FCHMOD 1
|
||||
#define HAVE_FCHOWN 1
|
||||
#define HAVE_FCNTL 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_FDOPENDIR 1
|
||||
#define HAVE_FGETXATTR 1
|
||||
#define HAVE_FLISTXATTR 1
|
||||
#define HAVE_FORK 1
|
||||
#define HAVE_FSEEKO 1
|
||||
#define HAVE_FSETXATTR 1
|
||||
#define HAVE_FSTAT 1
|
||||
#define HAVE_FSTATAT 1
|
||||
#define HAVE_FSTATFS 1
|
||||
#define HAVE_FTRUNCATE 1
|
||||
#define HAVE_GETEUID 1
|
||||
#define HAVE_GETPID 1
|
||||
#define HAVE_GETPWNAM_R 1
|
||||
#define HAVE_GETPWUID_R 1
|
||||
#define HAVE_GETXATTR 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define HAVE_GRP_H 1
|
||||
#define HAVE_INTMAX_T 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_LCHOWN 1
|
||||
#define HAVE_LGETXATTR 1
|
||||
#define HAVE_LIBLZMA 1
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_LINK 1
|
||||
#define HAVE_LINUX_FS_H 1
|
||||
#define HAVE_LINUX_MAGIC_H 1
|
||||
#define HAVE_LINUX_TYPES_H 1
|
||||
#define HAVE_LISTXATTR 1
|
||||
#define HAVE_LLISTXATTR 1
|
||||
#define HAVE_LOCALE_H 1
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_LONG_LONG_INT 1
|
||||
#define HAVE_LSETXATTR 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_MBRTOWC 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MKDIR 1
|
||||
#define HAVE_MKFIFO 1
|
||||
#define HAVE_MKNOD 1
|
||||
#define HAVE_MKSTEMP 1
|
||||
#define HAVE_OPENAT 1
|
||||
#define HAVE_PATHS_H 1
|
||||
#define HAVE_PIPE 1
|
||||
#define HAVE_POLL 1
|
||||
#define HAVE_POLL_H 1
|
||||
#define HAVE_PTHREAD_H 1
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_READDIR_R 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_READLINKAT 1
|
||||
#define HAVE_REGEX_H 1
|
||||
#define HAVE_SELECT 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_STATFS 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRERROR 1
|
||||
#define HAVE_STRERROR_R 1
|
||||
#define HAVE_STRFTIME 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
|
||||
#define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
|
||||
#define HAVE_STRUCT_TM_TM_GMTOFF 1
|
||||
#define HAVE_SYMLINK 1
|
||||
#define HAVE_SYS_CDEFS_H 1
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
#define HAVE_SYS_MOUNT_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_POLL_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
#define HAVE_SYS_STATFS_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_SYS_UTSNAME_H 1
|
||||
#define HAVE_SYS_VFS_H 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_TZSET 1
|
||||
#define HAVE_UINTMAX_T 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_UNSIGNED_LONG_LONG 1
|
||||
#define HAVE_UNSIGNED_LONG_LONG_INT 1
|
||||
#define HAVE_UTIME 1
|
||||
#define HAVE_UTIMENSAT 1
|
||||
#define HAVE_UTIMES 1
|
||||
#define HAVE_UTIME_H 1
|
||||
#define HAVE_VFORK 1
|
||||
#define HAVE_VPRINTF 1
|
||||
#define HAVE_WCHAR_H 1
|
||||
#define HAVE_WCHAR_T 1
|
||||
#define HAVE_WCRTOMB 1
|
||||
#define HAVE_WCSCMP 1
|
||||
#define HAVE_WCSCPY 1
|
||||
#define HAVE_WCSLEN 1
|
||||
#define HAVE_WCTOMB 1
|
||||
#define HAVE_WCTYPE_H 1
|
||||
#define HAVE_WMEMCMP 1
|
||||
#define HAVE_WMEMCPY 1
|
||||
#define HAVE_ARC4RANDOM_BUF 1
|
||||
#define HAVE_ZLIB_H 1
|
||||
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
|
||||
#define SIZEOF_WCHAR_T 4
|
||||
#define STDC_HEADERS 1
|
||||
#define STRERROR_R_CHAR_P 1
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
#endif
|
189
contrib/android/config/linux_host.h
Normal file
189
contrib/android/config/linux_host.h
Normal file
@ -0,0 +1,189 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Trevor Drake
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef ARCHIVE_PLATFORM_H_ANDROID_LINUX_HOST_INCLUDED
|
||||
#define ARCHIVE_PLATFORM_H_ANDROID_LINUX_HOST_INCLUDED
|
||||
|
||||
#define HAVE_CHOWN 1
|
||||
#define HAVE_CHROOT 1
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
|
||||
#define HAVE_DECL_INT64_MAX 1
|
||||
#define HAVE_DECL_INT64_MIN 1
|
||||
#define HAVE_DECL_SIZE_MAX 1
|
||||
#define HAVE_DECL_SSIZE_MAX 1
|
||||
#define HAVE_DECL_STRERROR_R 1
|
||||
#define HAVE_DECL_UINT32_MAX 1
|
||||
#define HAVE_DECL_UINT64_MAX 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_DIRFD 1
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_EILSEQ 1
|
||||
#define HAVE_ERRNO_H 1
|
||||
#define HAVE_FCHDIR 1
|
||||
#define HAVE_FCHMOD 1
|
||||
#define HAVE_FCHOWN 1
|
||||
#define HAVE_FCNTL 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_FDOPENDIR 1
|
||||
#define HAVE_FGETXATTR 1
|
||||
#define HAVE_FLISTXATTR 1
|
||||
#define HAVE_FORK 1
|
||||
#define HAVE_FSEEKO 1
|
||||
#define HAVE_FSETXATTR 1
|
||||
#define HAVE_FSTAT 1
|
||||
#define HAVE_FSTATAT 1
|
||||
#define HAVE_FSTATFS 1
|
||||
#define HAVE_FSTATVFS 1
|
||||
#define HAVE_FTRUNCATE 1
|
||||
#define HAVE_FUTIMENS 1
|
||||
#define HAVE_FUTIMES 1
|
||||
#define HAVE_FUTIMESAT 1
|
||||
#define HAVE_GETEUID 1
|
||||
#define HAVE_GETGRGID_R 1
|
||||
#define HAVE_GETGRNAM_R 1
|
||||
#define HAVE_GETPID 1
|
||||
#define HAVE_GETPWNAM_R 1
|
||||
#define HAVE_GETPWUID_R 1
|
||||
#define HAVE_GETXATTR 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define HAVE_GRP_H 1
|
||||
#define HAVE_ICONV 1
|
||||
#define HAVE_ICONV_H 1
|
||||
#define HAVE_INTMAX_T 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_LANGINFO_H 1
|
||||
#define HAVE_LCHOWN 1
|
||||
#define HAVE_LGETXATTR 1
|
||||
#define HAVE_LIBLZMA 1
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_LINK 1
|
||||
#define HAVE_LINUX_FIEMAP_H 1
|
||||
#define HAVE_LINUX_FS_H 1
|
||||
#define HAVE_LINUX_MAGIC_H 1
|
||||
#define HAVE_LINUX_TYPES_H 1
|
||||
#define HAVE_LISTXATTR 1
|
||||
#define HAVE_LLISTXATTR 1
|
||||
#define HAVE_LOCALE_H 1
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_LONG_LONG_INT 1
|
||||
#define HAVE_LSETXATTR 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_LUTIMES 1
|
||||
#define HAVE_MBRTOWC 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MKDIR 1
|
||||
#define HAVE_MKFIFO 1
|
||||
#define HAVE_MKNOD 1
|
||||
#define HAVE_MKSTEMP 1
|
||||
#define HAVE_NL_LANGINFO 1
|
||||
#define HAVE_OPENAT 1
|
||||
#define HAVE_PATHS_H 1
|
||||
#define HAVE_PIPE 1
|
||||
#define HAVE_POLL 1
|
||||
#define HAVE_POLL_H 1
|
||||
#define HAVE_POSIX_SPAWNP 1
|
||||
#define HAVE_PTHREAD_H 1
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_READDIR_R 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_READLINKAT 1
|
||||
#define HAVE_REGEX_H 1
|
||||
#define HAVE_SELECT 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_SPAWN_H 1
|
||||
#define HAVE_STATFS 1
|
||||
#define HAVE_STATVFS 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRERROR 1
|
||||
#define HAVE_STRERROR_R 1
|
||||
#define HAVE_STRFTIME 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
|
||||
#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
|
||||
#define HAVE_STRUCT_TM_TM_GMTOFF 1
|
||||
#define HAVE_SYMLINK 1
|
||||
#define HAVE_SYS_CDEFS_H 1
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
#define HAVE_SYS_MOUNT_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_POLL_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
#define HAVE_SYS_STATFS_H 1
|
||||
#define HAVE_SYS_STATVFS_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_SYS_UTSNAME_H 1
|
||||
#define HAVE_SYS_VFS_H 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_SYS_XATTR_H 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_TZSET 1
|
||||
#define HAVE_UINTMAX_T 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_UNSIGNED_LONG_LONG 1
|
||||
#define HAVE_UNSIGNED_LONG_LONG_INT 1
|
||||
#define HAVE_UTIME 1
|
||||
#define HAVE_UTIMENSAT 1
|
||||
#define HAVE_UTIMES 1
|
||||
#define HAVE_UTIME_H 1
|
||||
#define HAVE_VFORK 1
|
||||
#define HAVE_VPRINTF 1
|
||||
#define HAVE_WCHAR_H 1
|
||||
#define HAVE_WCHAR_T 1
|
||||
#define HAVE_WCRTOMB 1
|
||||
#define HAVE_WCSCMP 1
|
||||
#define HAVE_WCSCPY 1
|
||||
#define HAVE_WCSLEN 1
|
||||
#define HAVE_WCTOMB 1
|
||||
#define HAVE_WCTYPE_H 1
|
||||
#define HAVE_WMEMCMP 1
|
||||
#define HAVE_WMEMCPY 1
|
||||
#define HAVE_ZLIB_H 1
|
||||
#define ICONV_CONST
|
||||
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
|
||||
#define SIZEOF_WCHAR_T 4
|
||||
#define STDC_HEADERS 1
|
||||
#define STRERROR_R_CHAR_P 1
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#endif
|
1062
contrib/android/config/windows_host.h
Normal file
1062
contrib/android/config/windows_host.h
Normal file
File diff suppressed because it is too large
Load Diff
1
contrib/android/include/Bcrypt.h
Normal file
1
contrib/android/include/Bcrypt.h
Normal file
@ -0,0 +1 @@
|
||||
#include <bcrypt.h>
|
1
contrib/android/include/Windows.h
Normal file
1
contrib/android/include/Windows.h
Normal file
@ -0,0 +1 @@
|
||||
#include <windows.h>
|
47
contrib/android/include/android_lf.h
Normal file
47
contrib/android/include/android_lf.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Macros for file64 functions
|
||||
*
|
||||
* Android does not support the macro _FILE_OFFSET_BITS=64
|
||||
* As of android-21 it does however support many file64 functions
|
||||
*/
|
||||
|
||||
#ifndef ARCHIVE_ANDROID_LF_H_INCLUDED
|
||||
#define ARCHIVE_ANDROID_LF_H_INCLUDED
|
||||
|
||||
#if __ANDROID_API__ > 20
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
//dirent.h
|
||||
#define readdir_r readdir64_r
|
||||
#define readdir readdir64
|
||||
#define dirent dirent64
|
||||
//fcntl.h
|
||||
#define openat openat64
|
||||
#define open open64
|
||||
#define mkstemp mkstemp64
|
||||
//unistd.h
|
||||
#define lseek lseek64
|
||||
#define ftruncate ftruncate64
|
||||
//sys/stat.h
|
||||
#define fstatat fstatat64
|
||||
#define fstat fstat64
|
||||
#define lstat lstat64
|
||||
#define stat stat64
|
||||
//sys/statvfs.h
|
||||
#define fstatvfs fstatvfs64
|
||||
#define statvfs statvfs64
|
||||
//sys/types.h
|
||||
#define off_t off64_t
|
||||
//sys/vfs.h
|
||||
#define fstatfs fstatfs64
|
||||
#define statfs statfs64
|
||||
#endif
|
||||
|
||||
#endif /* ARCHIVE_ANDROID_LF_H_INCLUDED */
|
@ -1,14 +1,11 @@
|
||||
# $LastChangedRevision$, $LastChangedDate$
|
||||
Summary: Library to create and read several different archive formats
|
||||
Summary(pl): Biblioteka do tworzenia i odczytu ró¿nych formatów archiwów
|
||||
Name: libarchive
|
||||
Version: 2.0a3
|
||||
Version: 3.1.2
|
||||
Release: 1
|
||||
License: BSD
|
||||
Group: Libraries
|
||||
Source0: http://people.freebsd.org/~kientzle/libarchive/src/%{name}-%{version}.tar.gz
|
||||
Patch: %{name}-0123457890.patch
|
||||
URL: http://people.freebsd.org/~kientzle/libarchive/
|
||||
Source0: http://libarchive.org/downloads/%{name}-%{version}.tar.gz
|
||||
URL: http:/libarchive.org/
|
||||
Requires: glibc
|
||||
Requires: zlib
|
||||
Requires: bzip2
|
||||
@ -24,57 +21,47 @@ Libarchive is a programming library that can create and read several
|
||||
different streaming archive formats, including most popular TAR
|
||||
variants and several CPIO formats. It can also write SHAR archives.
|
||||
|
||||
%description -l pl
|
||||
Libarchive jest bibliotek± s³u¿ac± to tworzenia i odczytu wielu
|
||||
ró¿nych strumieniowych formatów archiwów, w³±czaj±c w to popularne
|
||||
odmiany TAR oraz wiele formatów CPIO. Biblioteka ta potrafi tak¿e
|
||||
zapisywaæ archiwa SHAR.
|
||||
|
||||
%package devel
|
||||
Summary: Header files for libarchive library
|
||||
Summary(pl): Pliki nag³ówkowe biblioteki libarchive
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
Header files for libarchive library.
|
||||
|
||||
%description devel -l pl
|
||||
Pliki nag³ówkowe biblioteki libarchive.
|
||||
|
||||
%package static
|
||||
Summary: Static libarchive library
|
||||
Summary(pl): Statyczna biblioteka libarchive
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}-devel = %{version}-%{release}
|
||||
|
||||
%description static
|
||||
Static libarchive library.
|
||||
|
||||
%description static -l pl
|
||||
Statyczna biblioteka libarchive.
|
||||
|
||||
%package -n bsdtar
|
||||
Summary: bsdtar - tar(1) implementation based on libarchive
|
||||
Summary(pl): bsdtar - implementacja programu tar(1) oparta na libarchive
|
||||
Group: Applications/Archiving
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description -n bsdtar
|
||||
bsdtar - tar(1) implementation based on libarchive.
|
||||
|
||||
%description -n bsdtar -l pl
|
||||
bsdtar - implementacja programu tar(1), oparta na libarchive.
|
||||
%package -n bsdcpio
|
||||
Summary: bsdcpio - cpio(1) implementation based on libarchive
|
||||
Group: Applications/Archiving
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description -n bsdcpio
|
||||
bsdcpio - cpio(1) implementation based on libarchive
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
|
||||
%build
|
||||
mkdir -p %{buildroot}
|
||||
./configure \
|
||||
--prefix=%{_prefix} \
|
||||
--libexecdir=%{_libexecdir} \
|
||||
--libdir=%{_libdir} \
|
||||
--mandir=%{_mandir} \
|
||||
--infodir=%{_infodir} \
|
||||
--enable-shared=yes \
|
||||
@ -85,63 +72,34 @@ make | tee %{buildroot}/make.log
|
||||
%install
|
||||
[ "%buildroot" != "/" ] && [ -d %buildroot ] && rm -rf %buildroot;
|
||||
make DESTDIR=%buildroot install
|
||||
# original install builds, but does install bsdtar
|
||||
cp .libs/%{name}.a %{buildroot}%{_libdir}
|
||||
cp bsdtar %{buildroot}%{_bindir}
|
||||
cp tar/bsdtar.1 %{buildroot}%{_mandir}/man1
|
||||
|
||||
%clean
|
||||
rm -fr %buildroot
|
||||
|
||||
%files
|
||||
%defattr(644,root,root,755)
|
||||
%{_libdir}/libarchive.so*
|
||||
|
||||
%files static
|
||||
%{_libdir}/libarchive.a
|
||||
|
||||
%files devel
|
||||
%defattr(644,root,root,755)
|
||||
%{_libdir}/pkgconfig/libarchive.pc
|
||||
%{_libdir}/libarchive.la
|
||||
%{_includedir}/*.h
|
||||
%doc %{_mandir}/man3/*
|
||||
%doc %{_mandir}/man5/*
|
||||
|
||||
%files -n bsdtar
|
||||
%defattr(644,root,root,755)
|
||||
%attr(755,root,root) %{_bindir}/bsdtar
|
||||
%doc %{_mandir}/man1/bsdtar.1*
|
||||
|
||||
%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
|
||||
%files -n bsdcpio
|
||||
%attr(755,root,root) %{_bindir}/bsdcpio
|
||||
%doc %{_mandir}/man1/bsdcpio.1*
|
||||
|
||||
%changelog
|
||||
* %{date} PLD Team <feedback@pld-linux.org>
|
||||
All persons listed below can be reached at <cvs_login>@pld-linux.org
|
||||
|
||||
$Log: libarchive.spec,v $
|
||||
Release 1 2006/12/12 rm1023@dcx.com
|
||||
- added libarchive-0123457890.patch for "0123457890" error
|
||||
- replaced libarchive-1.3.1.tar.gz with libarchive-2.0a3.tar.gz
|
||||
- removed obsolete -CVE-2006-5680.patch and -man_progname.patch
|
||||
|
||||
Revision 1.6 2006/11/15 10:41:28 qboosh
|
||||
- BR: acl-devel,attr-devel
|
||||
- devel deps
|
||||
|
||||
Revision 1.5 2006/11/08 22:22:25 twittner
|
||||
- up to 1.3.1
|
||||
- added BR: e2fsprogs-devel
|
||||
- added -CVE-2006-5680.patch against entering an infinite
|
||||
loop in corrupt archives
|
||||
- added bsdtar package (bsdtar is included now in libarchive
|
||||
sources)
|
||||
- rel. 0.1 for testing
|
||||
|
||||
Revision 1.4 2005/12/15 18:26:36 twittner
|
||||
- up to 1.2.37
|
||||
- removed -shared.patch (no longer needed)
|
||||
|
||||
Revision 1.3 2005/10/05 17:00:12 arekm
|
||||
- up to 1.02.034
|
||||
|
||||
Revision 1.2 2005/07/27 20:17:21 qboosh
|
||||
- typo
|
||||
|
||||
Revision 1.1 2005/07/27 08:36:03 adamg
|
||||
- new
|
||||
* Wed May 01 2013 Nikolai Lifanov <lifanov@mail.lifanov.com> - 3.1.2-1
|
||||
- Initial package
|
||||
- contrib/libarchive.spec by PLD team overhaul
|
||||
- Added "bsdcpio" package
|
||||
- Fixed build on x86_64 platform
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* This file is in the public domain. Use it as you see fit.
|
||||
*/
|
||||
|
||||
/*
|
||||
* "untar" is an extremely simple tar extractor:
|
||||
* * A single C source file, so it should be easy to compile
|
||||
@ -95,7 +99,7 @@ static FILE *
|
||||
create_file(char *pathname, int mode)
|
||||
{
|
||||
FILE *f;
|
||||
f = fopen(pathname, "w+");
|
||||
f = fopen(pathname, "wb+");
|
||||
if (f == NULL) {
|
||||
/* Try creating parent dir and then creating file. */
|
||||
char *p = strrchr(pathname, '/');
|
||||
@ -103,7 +107,7 @@ create_file(char *pathname, int mode)
|
||||
*p = '\0';
|
||||
create_dir(pathname, 0755);
|
||||
*p = '/';
|
||||
f = fopen(pathname, "w+");
|
||||
f = fopen(pathname, "wb+");
|
||||
}
|
||||
}
|
||||
return (f);
|
||||
@ -213,7 +217,7 @@ main(int argc, char **argv)
|
||||
|
||||
++argv; /* Skip program name */
|
||||
for ( ;*argv != NULL; ++argv) {
|
||||
a = fopen(*argv, "r");
|
||||
a = fopen(*argv, "rb");
|
||||
if (a == NULL)
|
||||
fprintf(stderr, "Unable to open %s\n", *argv);
|
||||
else {
|
||||
|
@ -15,7 +15,10 @@ IF(ENABLE_CPIO)
|
||||
../libarchive_fe/lafe_platform.h
|
||||
../libarchive_fe/line_reader.c
|
||||
../libarchive_fe/line_reader.h
|
||||
../libarchive_fe/passphrase.c
|
||||
../libarchive_fe/passphrase.h
|
||||
)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
LIST(APPEND bsdcpio_SOURCES cpio_windows.c)
|
||||
@ -34,8 +37,6 @@ IF(ENABLE_CPIO)
|
||||
SET_TARGET_PROPERTIES(bsdcpio PROPERTIES COMPILE_DEFINITIONS
|
||||
LIBARCHIVE_STATIC)
|
||||
ENDIF(ENABLE_CPIO_SHARED)
|
||||
# Full path to the compiled executable (used by test suite)
|
||||
GET_TARGET_PROPERTY(BSDCPIO bsdcpio LOCATION)
|
||||
|
||||
# Installation rules
|
||||
INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin)
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 7, 2012
|
||||
.Dd September 16, 2014
|
||||
.Dt CPIO 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -32,17 +32,17 @@
|
||||
.Nd copy files to and from archives
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Brq Fl i
|
||||
.Fl i
|
||||
.Op Ar options
|
||||
.Op Ar pattern ...
|
||||
.Op Ar < archive
|
||||
.Nm
|
||||
.Brq Fl o
|
||||
.Fl o
|
||||
.Op Ar options
|
||||
.Ar < name-list
|
||||
.Op Ar > archive
|
||||
.Nm
|
||||
.Brq Fl p
|
||||
.Fl p
|
||||
.Op Ar options
|
||||
.Ar dest-dir
|
||||
.Ar < name-list
|
||||
@ -156,7 +156,8 @@ See above for description.
|
||||
.It Fl Fl insecure
|
||||
(i and p mode only)
|
||||
Disable security checks during extraction or copying.
|
||||
This allows extraction via symbolic links and path names containing
|
||||
This allows extraction via symbolic links, absolute paths,
|
||||
and path names containing
|
||||
.Sq ..
|
||||
in the name.
|
||||
.It Fl J , Fl Fl xz
|
||||
@ -181,6 +182,11 @@ instead of copying.
|
||||
Compress the resulting archive with
|
||||
.Xr lrzip 1 .
|
||||
In input mode, this option is ignored.
|
||||
.It Fl Fl lz4
|
||||
(o mode only)
|
||||
Compress the archive with lz4-compatible compression before writing it.
|
||||
In input mode, this option is ignored; lz4 compression is recognized
|
||||
automatically on input.
|
||||
.It Fl Fl lzma
|
||||
(o mode only)
|
||||
Compress the file with lzma-compatible compression before writing it.
|
||||
@ -191,6 +197,15 @@ automatically on input.
|
||||
Compress the resulting archive with
|
||||
.Xr lzop 1 .
|
||||
In input mode, this option is ignored.
|
||||
.It Fl Fl passphrase Ar passphrase
|
||||
The
|
||||
.Pa passphrase
|
||||
is used to extract or create an encrypted archive.
|
||||
Currently, zip is only a format that
|
||||
.Nm
|
||||
can handle encrypted archives.
|
||||
You shouldn't use this option unless you realize how insecure
|
||||
use of this option is.
|
||||
.It Fl m , Fl Fl preserve-modification-time
|
||||
(i and p modes)
|
||||
Set file modification time on created files to match
|
||||
|
@ -73,6 +73,7 @@ static const struct option {
|
||||
{ "link", 0, 'l' },
|
||||
{ "list", 0, 't' },
|
||||
{ "lrzip", 0, OPTION_LRZIP },
|
||||
{ "lz4", 0, OPTION_LZ4 },
|
||||
{ "lzma", 0, OPTION_LZMA },
|
||||
{ "lzop", 0, OPTION_LZOP },
|
||||
{ "make-directories", 0, 'd' },
|
||||
@ -80,6 +81,7 @@ static const struct option {
|
||||
{ "null", 0, '0' },
|
||||
{ "numeric-uid-gid", 0, 'n' },
|
||||
{ "owner", 1, 'R' },
|
||||
{ "passphrase", 1, OPTION_PASSPHRASE },
|
||||
{ "pass-through", 0, 'p' },
|
||||
{ "preserve-modification-time", 0, 'm' },
|
||||
{ "preserve-owner", 0, OPTION_PRESERVE_OWNER },
|
||||
|
90
cpio/cpio.c
90
cpio/cpio.c
@ -82,6 +82,7 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle
|
||||
#include "cpio.h"
|
||||
#include "err.h"
|
||||
#include "line_reader.h"
|
||||
#include "passphrase.h"
|
||||
|
||||
/* Fixed size of uname/gname caches. */
|
||||
#define name_cache_size 101
|
||||
@ -123,6 +124,8 @@ static int restore_time(struct cpio *, struct archive_entry *,
|
||||
const char *, int fd);
|
||||
static void usage(void);
|
||||
static void version(void);
|
||||
static const char * passphrase_callback(struct archive *, void *);
|
||||
static void passphrase_free(char *);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
@ -149,20 +152,9 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Need lafe_progname before calling lafe_warnc. */
|
||||
if (*argv == NULL)
|
||||
lafe_progname = "bsdcpio";
|
||||
else {
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
lafe_progname = strrchr(*argv, '\\');
|
||||
if (strrchr(*argv, '/') > lafe_progname)
|
||||
#endif
|
||||
lafe_progname = strrchr(*argv, '/');
|
||||
if (lafe_progname != NULL)
|
||||
lafe_progname++;
|
||||
else
|
||||
lafe_progname = *argv;
|
||||
}
|
||||
/* Set lafe_progname before calling lafe_warnc. */
|
||||
lafe_setprogname(*argv, "bsdcpio");
|
||||
|
||||
#if HAVE_SETLOCALE
|
||||
if (setlocale(LC_ALL, "") == NULL)
|
||||
lafe_warnc(0, "Failed to set default locale");
|
||||
@ -179,6 +171,7 @@ main(int argc, char *argv[])
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_PERM;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_ACL;
|
||||
@ -264,6 +257,7 @@ main(int argc, char *argv[])
|
||||
case OPTION_INSECURE:
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
|
||||
break;
|
||||
case 'L': /* GNU cpio */
|
||||
cpio->option_follow_links = 1;
|
||||
@ -272,6 +266,7 @@ main(int argc, char *argv[])
|
||||
cpio->option_link = 1;
|
||||
break;
|
||||
case OPTION_LRZIP:
|
||||
case OPTION_LZ4:
|
||||
case OPTION_LZMA: /* GNU tar, others */
|
||||
case OPTION_LZOP: /* GNU tar, others */
|
||||
cpio->compress = opt;
|
||||
@ -301,6 +296,9 @@ main(int argc, char *argv[])
|
||||
cpio->mode = opt;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
break;
|
||||
case OPTION_PASSPHRASE:
|
||||
cpio->passphrase = cpio->argument;
|
||||
break;
|
||||
case OPTION_PRESERVE_OWNER:
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
|
||||
break;
|
||||
@ -429,6 +427,7 @@ main(int argc, char *argv[])
|
||||
free_cache(cpio->gname_cache);
|
||||
free_cache(cpio->uname_cache);
|
||||
free(cpio->destdir);
|
||||
passphrase_free(cpio->ppbuff);
|
||||
return (cpio->return_value);
|
||||
}
|
||||
|
||||
@ -437,7 +436,7 @@ usage(void)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
p = lafe_progname;
|
||||
p = lafe_getprogname();
|
||||
|
||||
fprintf(stderr, "Brief Usage:\n");
|
||||
fprintf(stderr, " List: %s -it < archive\n", p);
|
||||
@ -475,7 +474,7 @@ long_help(void)
|
||||
const char *prog;
|
||||
const char *p;
|
||||
|
||||
prog = lafe_progname;
|
||||
prog = lafe_getprogname();
|
||||
|
||||
fflush(stderr);
|
||||
|
||||
@ -500,7 +499,7 @@ version(void)
|
||||
{
|
||||
fprintf(stdout,"bsdcpio %s -- %s\n",
|
||||
BSDCPIO_VERSION_STRING,
|
||||
archive_version_string());
|
||||
archive_version_details());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -537,6 +536,9 @@ mode_out(struct cpio *cpio)
|
||||
case OPTION_LRZIP:
|
||||
r = archive_write_add_filter_lrzip(cpio->archive);
|
||||
break;
|
||||
case OPTION_LZ4:
|
||||
r = archive_write_add_filter_lz4(cpio->archive);
|
||||
break;
|
||||
case OPTION_LZMA:
|
||||
r = archive_write_add_filter_lzma(cpio->archive);
|
||||
break;
|
||||
@ -578,6 +580,14 @@ mode_out(struct cpio *cpio)
|
||||
cpio->linkresolver = archive_entry_linkresolver_new();
|
||||
archive_entry_linkresolver_set_strategy(cpio->linkresolver,
|
||||
archive_format(cpio->archive));
|
||||
if (cpio->passphrase != NULL)
|
||||
r = archive_write_set_passphrase(cpio->archive,
|
||||
cpio->passphrase);
|
||||
else
|
||||
r = archive_write_set_passphrase_callback(cpio->archive, cpio,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
|
||||
|
||||
/*
|
||||
* The main loop: Copy each file into the output archive.
|
||||
@ -944,6 +954,13 @@ mode_in(struct cpio *cpio)
|
||||
lafe_errc(1, 0, "Couldn't allocate archive object");
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
if (cpio->passphrase != NULL)
|
||||
r = archive_read_add_passphrase(a, cpio->passphrase);
|
||||
else
|
||||
r = archive_read_set_passphrase_callback(a, cpio,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
|
||||
if (archive_read_open_filename(a, cpio->filename,
|
||||
cpio->bytes_per_block))
|
||||
@ -1047,6 +1064,13 @@ mode_list(struct cpio *cpio)
|
||||
lafe_errc(1, 0, "Couldn't allocate archive object");
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
if (cpio->passphrase != NULL)
|
||||
r = archive_read_add_passphrase(a, cpio->passphrase);
|
||||
else
|
||||
r = archive_read_set_passphrase_callback(a, cpio,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
|
||||
if (archive_read_open_filename(a, cpio->filename,
|
||||
cpio->bytes_per_block))
|
||||
@ -1140,7 +1164,8 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
|
||||
else
|
||||
fmt = cpio->day_first ? "%d %b %H:%M" : "%b %d %H:%M";
|
||||
#else
|
||||
if (abs(mtime - now) > (365/2)*86400)
|
||||
if (mtime - now > 365*86400/2
|
||||
|| mtime - now < -365*86400/2)
|
||||
fmt = cpio->day_first ? "%e %b %Y" : "%b %e %Y";
|
||||
else
|
||||
fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
|
||||
@ -1235,8 +1260,10 @@ cpio_rename(const char *name)
|
||||
if (t == NULL)
|
||||
return (name);
|
||||
to = fopen("CONOUT$", "w");
|
||||
if (to == NULL)
|
||||
if (to == NULL) {
|
||||
fclose(t);
|
||||
return (name);
|
||||
}
|
||||
fprintf(to, "%s (Enter/./(new name))? ", name);
|
||||
fclose(to);
|
||||
#else
|
||||
@ -1416,3 +1443,28 @@ cpio_i64toa(int64_t n0)
|
||||
*--p = '-';
|
||||
return p;
|
||||
}
|
||||
|
||||
#define PPBUFF_SIZE 1024
|
||||
static const char *
|
||||
passphrase_callback(struct archive *a, void *_client_data)
|
||||
{
|
||||
struct cpio *cpio = (struct cpio *)_client_data;
|
||||
(void)a; /* UNUSED */
|
||||
|
||||
if (cpio->ppbuff == NULL) {
|
||||
cpio->ppbuff = malloc(PPBUFF_SIZE);
|
||||
if (cpio->ppbuff == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
}
|
||||
return lafe_readpassphrase("Enter passphrase:",
|
||||
cpio->ppbuff, PPBUFF_SIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
passphrase_free(char *ppbuff)
|
||||
{
|
||||
if (ppbuff != NULL) {
|
||||
memset(ppbuff, 0, PPBUFF_SIZE);
|
||||
free(ppbuff);
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ struct cpio {
|
||||
int gid_override;
|
||||
char *gname_override;
|
||||
int day_first; /* true if locale prefers day/mon */
|
||||
const char *passphrase;
|
||||
|
||||
/* If >= 0, then close this when done. */
|
||||
int fd;
|
||||
@ -90,6 +91,7 @@ struct cpio {
|
||||
struct archive *matching;
|
||||
char *buff;
|
||||
size_t buff_size;
|
||||
char *ppbuff;
|
||||
};
|
||||
|
||||
const char *owner_parse(const char *, int *, int *);
|
||||
@ -101,8 +103,10 @@ enum {
|
||||
OPTION_GRZIP,
|
||||
OPTION_INSECURE,
|
||||
OPTION_LRZIP,
|
||||
OPTION_LZ4,
|
||||
OPTION_LZMA,
|
||||
OPTION_LZOP,
|
||||
OPTION_PASSPHRASE,
|
||||
OPTION_NO_PRESERVE_OWNER,
|
||||
OPTION_PRESERVE_OWNER,
|
||||
OPTION_QUIET,
|
||||
|
@ -42,6 +42,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "cpio_windows.h"
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
@ -70,8 +74,4 @@
|
||||
#define __LA_DEAD
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "cpio_windows.h"
|
||||
#endif
|
||||
|
||||
#endif /* !CPIO_PLATFORM_H_INCLUDED */
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
#ifndef CPIO_WINDOWS_H
|
||||
#define CPIO_WINDOWS_H 1
|
||||
#include <windows.h>
|
||||
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
@ -35,8 +36,10 @@
|
||||
#define getpwnam(name) NULL
|
||||
#define getpwuid(id) NULL
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER < 1900
|
||||
#define snprintf sprintf_s
|
||||
#endif // _MSC_VER < 1900
|
||||
#define strdup _strdup
|
||||
#define open _open
|
||||
#define read _read
|
||||
|
@ -19,6 +19,7 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
test_extract_cpio_gz
|
||||
test_extract_cpio_lrz
|
||||
test_extract_cpio_lz
|
||||
test_extract_cpio_lz4
|
||||
test_extract_cpio_lzma
|
||||
test_extract_cpio_lzo
|
||||
test_extract_cpio_xz
|
||||
@ -39,9 +40,11 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
test_option_help.c
|
||||
test_option_l.c
|
||||
test_option_lrzip.c
|
||||
test_option_lz4.c
|
||||
test_option_lzma.c
|
||||
test_option_lzop.c
|
||||
test_option_m.c
|
||||
test_option_passphrase.c
|
||||
test_option_t.c
|
||||
test_option_u.c
|
||||
test_option_uuencode.c
|
||||
@ -82,11 +85,12 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
|
||||
# Experimental new test handling
|
||||
ADD_CUSTOM_TARGET(run_bsdcpio_test
|
||||
COMMAND bsdcpio_test -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
COMMAND bsdcpio_test -p $<TARGET_FILE:bsdcpio>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
|
||||
ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
|
||||
ENDIF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
|
155
cpio/test/main.c
155
cpio/test/main.c
@ -130,6 +130,16 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.3 2008/08/24 04:58:22 kient
|
||||
# include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/* Path to working directory for current test */
|
||||
const char *testworkdir;
|
||||
#ifdef PROGRAM
|
||||
/* Pathname of exe to be tested. */
|
||||
const char *testprogfile;
|
||||
/* Name of exe to use in printf-formatted command strings. */
|
||||
/* On Windows, this includes leading/trailing quotes. */
|
||||
const char *testprog;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
static void *GetFunctionKernel32(const char *);
|
||||
static int my_CreateSymbolicLinkA(const char *, const char *, int);
|
||||
@ -194,7 +204,7 @@ my_GetFileInformationByName(const char *path, BY_HANDLE_FILE_INFORMATION *bhfi)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE__CrtSetReportMode)
|
||||
#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__)
|
||||
static void
|
||||
invalid_parameter_handler(const wchar_t * expression,
|
||||
const wchar_t * function, const wchar_t * file,
|
||||
@ -565,10 +575,10 @@ static void strdump(const char *e, const char *p, int ewidth, int utf8)
|
||||
while (*p != '\0') {
|
||||
unsigned int c = 0xff & *p++;
|
||||
switch (c) {
|
||||
case '\a': printf("\a"); break;
|
||||
case '\b': printf("\b"); break;
|
||||
case '\n': printf("\n"); break;
|
||||
case '\r': printf("\r"); break;
|
||||
case '\a': logprintf("\\a"); break;
|
||||
case '\b': logprintf("\\b"); break;
|
||||
case '\n': logprintf("\\n"); break;
|
||||
case '\r': logprintf("\\r"); break;
|
||||
default:
|
||||
if (c >= 32 && c < 127)
|
||||
logprintf("%c", c);
|
||||
@ -771,6 +781,34 @@ assertion_equal_mem(const char *file, int line,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Verify that a block of memory is filled with the specified byte. */
|
||||
int
|
||||
assertion_memory_filled_with(const char *file, int line,
|
||||
const void *_v1, const char *vd,
|
||||
size_t l, const char *ld,
|
||||
char b, const char *bd, void *extra)
|
||||
{
|
||||
const char *v1 = (const char *)_v1;
|
||||
size_t c = 0;
|
||||
size_t i;
|
||||
(void)ld; /* UNUSED */
|
||||
|
||||
assertion_count(file, line);
|
||||
|
||||
for (i = 0; i < l; ++i) {
|
||||
if (v1[i] == b) {
|
||||
++c;
|
||||
}
|
||||
}
|
||||
if (c == l)
|
||||
return (1);
|
||||
|
||||
failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
|
||||
logprintf(" Only %d bytes were correct\n", (int)c);
|
||||
failure_finish(extra);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Verify that the named file exists and is empty. */
|
||||
int
|
||||
assertion_empty_file(const char *filename, int line, const char *f1)
|
||||
@ -1036,6 +1074,7 @@ assertion_file_contains_lines_any_order(const char *file, int line,
|
||||
if (expected == NULL) {
|
||||
failure_start(pathname, line, "Can't allocate memory");
|
||||
failure_finish(NULL);
|
||||
free(expected);
|
||||
return (0);
|
||||
}
|
||||
for (i = 0; lines[i] != NULL; ++i) {
|
||||
@ -1060,7 +1099,8 @@ assertion_file_contains_lines_any_order(const char *file, int line,
|
||||
free(expected);
|
||||
return (0);
|
||||
}
|
||||
for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
|
||||
for (j = 0, p = buff; p < buff + buff_size;
|
||||
p += 1 + strlen(p)) {
|
||||
if (*p != '\0') {
|
||||
actual[j] = p;
|
||||
++j;
|
||||
@ -1911,6 +1951,18 @@ canGzip(void)
|
||||
/*
|
||||
* Can this platform run the lrzip program?
|
||||
*/
|
||||
int
|
||||
canRunCommand(const char *cmd)
|
||||
{
|
||||
static int tested = 0, value = 0;
|
||||
if (!tested) {
|
||||
tested = 1;
|
||||
if (systemf("%s %s", cmd, redirectArgs) == 0)
|
||||
value = 1;
|
||||
}
|
||||
return (value);
|
||||
}
|
||||
|
||||
int
|
||||
canLrzip(void)
|
||||
{
|
||||
@ -1923,6 +1975,21 @@ canLrzip(void)
|
||||
return (value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Can this platform run the lz4 program?
|
||||
*/
|
||||
int
|
||||
canLz4(void)
|
||||
{
|
||||
static int tested = 0, value = 0;
|
||||
if (!tested) {
|
||||
tested = 1;
|
||||
if (systemf("lz4 -V %s", redirectArgs) == 0)
|
||||
value = 1;
|
||||
}
|
||||
return (value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Can this platform run the lzip program?
|
||||
*/
|
||||
@ -2135,8 +2202,31 @@ slurpfile(size_t * sizep, const char *fmt, ...)
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Slurp a file into memory for ease of comparison and testing.
|
||||
* Returns size of file in 'sizep' if non-NULL, null-terminates
|
||||
* data in memory for ease of use.
|
||||
*/
|
||||
void
|
||||
dumpfile(const char *filename, void *data, size_t len)
|
||||
{
|
||||
ssize_t bytes_written;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (f == NULL) {
|
||||
logprintf("Can't open file %s for writing\n", filename);
|
||||
return;
|
||||
}
|
||||
bytes_written = fwrite(data, 1, len, f);
|
||||
if (bytes_written < (ssize_t)len)
|
||||
logprintf("Can't write file %s\n", filename);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
/* Read a uuencoded file from the reference directory, decode, and
|
||||
* write the result into the current directory. */
|
||||
#define VALID_UUDECODE(c) (c >= 32 && c <= 96)
|
||||
#define UUDECODE(c) (((c) - 0x20) & 0x3f)
|
||||
void
|
||||
extract_reference_file(const char *name)
|
||||
@ -2160,7 +2250,6 @@ extract_reference_file(const char *name)
|
||||
break;
|
||||
}
|
||||
/* Now, decode the rest and write it. */
|
||||
/* Not a lot of error checking here; the input better be right. */
|
||||
out = fopen(name, "wb");
|
||||
while (fgets(buff, sizeof(buff), in) != NULL) {
|
||||
char *p = buff;
|
||||
@ -2174,17 +2263,21 @@ extract_reference_file(const char *name)
|
||||
int n = 0;
|
||||
/* Write out 1-3 bytes from that. */
|
||||
if (bytes > 0) {
|
||||
assert(VALID_UUDECODE(p[0]));
|
||||
assert(VALID_UUDECODE(p[1]));
|
||||
n = UUDECODE(*p++) << 18;
|
||||
n |= UUDECODE(*p++) << 12;
|
||||
fputc(n >> 16, out);
|
||||
--bytes;
|
||||
}
|
||||
if (bytes > 0) {
|
||||
assert(VALID_UUDECODE(p[0]));
|
||||
n |= UUDECODE(*p++) << 6;
|
||||
fputc((n >> 8) & 0xFF, out);
|
||||
--bytes;
|
||||
}
|
||||
if (bytes > 0) {
|
||||
assert(VALID_UUDECODE(p[0]));
|
||||
n |= UUDECODE(*p++);
|
||||
fputc(n & 0xFF, out);
|
||||
--bytes;
|
||||
@ -2195,6 +2288,32 @@ extract_reference_file(const char *name)
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
void
|
||||
copy_reference_file(const char *name)
|
||||
{
|
||||
char buff[1024];
|
||||
FILE *in, *out;
|
||||
size_t rbytes;
|
||||
|
||||
sprintf(buff, "%s/%s", refdir, name);
|
||||
in = fopen(buff, "rb");
|
||||
failure("Couldn't open reference file %s", buff);
|
||||
assert(in != NULL);
|
||||
if (in == NULL)
|
||||
return;
|
||||
/* Now, decode the rest and write it. */
|
||||
/* Not a lot of error checking here; the input better be right. */
|
||||
out = fopen(name, "wb");
|
||||
while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
|
||||
if (fwrite(buff, 1, rbytes, out) != rbytes) {
|
||||
logprintf("Error: fwrite\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
int
|
||||
is_LargeInode(const char *file)
|
||||
{
|
||||
@ -2216,6 +2335,14 @@ is_LargeInode(const char *file)
|
||||
return (ino > 0xffffffff);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
extract_reference_files(const char **names)
|
||||
{
|
||||
while (names && *names)
|
||||
extract_reference_file(*names++);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* TEST management
|
||||
@ -2245,7 +2372,7 @@ struct test_list_t tests[] = {
|
||||
* Summarize repeated failures in the just-completed test.
|
||||
*/
|
||||
static void
|
||||
test_summarize(int failed)
|
||||
test_summarize(int failed, int skips_num)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -2255,7 +2382,7 @@ test_summarize(int failed)
|
||||
fflush(stdout);
|
||||
break;
|
||||
case VERBOSITY_PASSFAIL:
|
||||
printf(failed ? "FAIL\n" : "ok\n");
|
||||
printf(failed ? "FAIL\n" : skips_num ? "ok (S)\n" : "ok\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2280,13 +2407,14 @@ test_run(int i, const char *tmpdir)
|
||||
char workdir[1024];
|
||||
char logfilename[64];
|
||||
int failures_before = failures;
|
||||
int skips_before = skips;
|
||||
int oldumask;
|
||||
|
||||
switch (verbosity) {
|
||||
case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */
|
||||
break;
|
||||
case VERBOSITY_PASSFAIL: /* rest of line will include ok/FAIL marker */
|
||||
printf("%3d: %-50s", i, tests[i].name);
|
||||
printf("%3d: %-64s", i, tests[i].name);
|
||||
fflush(stdout);
|
||||
break;
|
||||
default: /* Title of test, details will follow */
|
||||
@ -2336,7 +2464,7 @@ test_run(int i, const char *tmpdir)
|
||||
}
|
||||
/* Report per-test summaries. */
|
||||
tests[i].failures = failures - failures_before;
|
||||
test_summarize(tests[i].failures);
|
||||
test_summarize(tests[i].failures, skips - skips_before);
|
||||
/* Close the per-test log file. */
|
||||
fclose(logfile);
|
||||
logfile = NULL;
|
||||
@ -2479,6 +2607,7 @@ get_refdir(const char *d)
|
||||
failure:
|
||||
printf("Unable to locate known reference file %s\n", KNOWNREF);
|
||||
printf(" Checked following directories:\n%s\n", tried);
|
||||
printf("Use -r option to specify full path to reference directory\n");
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
|
||||
DebugBreak();
|
||||
#endif
|
||||
@ -2515,7 +2644,7 @@ main(int argc, char **argv)
|
||||
while (pwd[strlen(pwd) - 1] == '\n')
|
||||
pwd[strlen(pwd) - 1] = '\0';
|
||||
|
||||
#if defined(HAVE__CrtSetReportMode)
|
||||
#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__)
|
||||
/* To stop to run the default invalid parameter handler. */
|
||||
_set_invalid_parameter_handler(invalid_parameter_handler);
|
||||
/* Disable annoying assertion message box. */
|
||||
@ -2562,7 +2691,7 @@ main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
memmove(testprogdir + strlen(pwd) + 1, testprogdir,
|
||||
strlen(testprogdir));
|
||||
strlen(testprogdir) + 1);
|
||||
memcpy(testprogdir, pwd, strlen(pwd));
|
||||
testprogdir[strlen(pwd)] = '/';
|
||||
}
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -84,12 +85,14 @@
|
||||
/* Windows (including Visual Studio and MinGW but not Cygwin) */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#if !defined(__BORLANDC__)
|
||||
#undef chdir
|
||||
#define chdir _chdir
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Visual Studio */
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
@ -142,6 +145,9 @@
|
||||
/* As above, but raw blocks of bytes. */
|
||||
#define assertEqualMem(v1, v2, l) \
|
||||
assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
|
||||
/* Assert that memory is full of a specified byte */
|
||||
#define assertMemoryFilledWith(v1, l, b) \
|
||||
assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL)
|
||||
/* Assert two files are the same. */
|
||||
#define assertEqualFile(f1, f2) \
|
||||
assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
|
||||
@ -225,6 +231,7 @@ int assertion_empty_file(const char *, int, const char *);
|
||||
int assertion_equal_file(const char *, int, const char *, const char *);
|
||||
int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
|
||||
int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
|
||||
int assertion_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *);
|
||||
int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
|
||||
int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
|
||||
int assertion_file_atime(const char *, int, const char *, long, long);
|
||||
@ -275,9 +282,15 @@ int canGrzip(void);
|
||||
/* Return true if this platform can run the "gzip" program. */
|
||||
int canGzip(void);
|
||||
|
||||
/* Return true if this platform can run the specified command. */
|
||||
int canRunCommand(const char *);
|
||||
|
||||
/* Return true if this platform can run the "lrzip" program. */
|
||||
int canLrzip(void);
|
||||
|
||||
/* Return true if this platform can run the "lz4" program. */
|
||||
int canLz4(void);
|
||||
|
||||
/* Return true if this platform can run the "lzip" program. */
|
||||
int canLzip(void);
|
||||
|
||||
@ -300,21 +313,31 @@ int is_LargeInode(const char *);
|
||||
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
|
||||
char *slurpfile(size_t *, const char *fmt, ...);
|
||||
|
||||
/* Dump block of bytes to a file. */
|
||||
void dumpfile(const char *filename, void *, size_t);
|
||||
|
||||
/* Extracts named reference file to the current directory. */
|
||||
void extract_reference_file(const char *);
|
||||
/* Copies named reference file to the current directory. */
|
||||
void copy_reference_file(const char *);
|
||||
|
||||
/* Extracts a list of files to the current directory.
|
||||
* List must be NULL terminated.
|
||||
*/
|
||||
void extract_reference_files(const char **);
|
||||
|
||||
/* Path to working directory for current test */
|
||||
const char *testworkdir;
|
||||
extern const char *testworkdir;
|
||||
|
||||
/*
|
||||
* Special interfaces for program test harness.
|
||||
*/
|
||||
|
||||
/* Pathname of exe to be tested. */
|
||||
const char *testprogfile;
|
||||
extern const char *testprogfile;
|
||||
/* Name of exe to use in printf-formatted command strings. */
|
||||
/* On Windows, this includes leading/trailing quotes. */
|
||||
const char *testprog;
|
||||
extern const char *testprog;
|
||||
|
||||
#ifdef USE_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
|
@ -72,7 +72,7 @@ basic_cpio(const char *target,
|
||||
return;
|
||||
|
||||
/* Use the cpio program to create an archive. */
|
||||
r = systemf("%s -o %s < filelist >%s/archive 2>%s/pack.err",
|
||||
r = systemf("%s -R 1000:1000 -o %s < filelist >%s/archive 2>%s/pack.err",
|
||||
testprog, pack_options, target, target);
|
||||
failure("Error invoking %s -o %s", testprog, pack_options);
|
||||
assertEqualInt(r, 0);
|
||||
|
7
cpio/test/test_extract.cpio.lz4.uu
Normal file
7
cpio/test/test_extract.cpio.lz4.uu
Normal file
@ -0,0 +1,7 @@
|
||||
begin 644 test_extract.cpio.lz4
|
||||
M!")-&&1PN9$````A,#<"`&`P-#`P,3`!`&`Q,3`P-C8/`#0W-3`&```)``$&
|
||||
M`,$P,3(P,S(W-#`R,S01`!$V!@```@#Q!3(S9FEL93$`8V]N=&5N=',@;V8@
|
||||
M$@`A+@IC``AE`!\R90`4$#2#``YE`!TR90`6,F4`#P(`#@+H``P"`"<Q,Q(`
|
||||
=OU1204E,15(A(2$``0#'4````````````"BVD[$`
|
||||
`
|
||||
end
|
48
cpio/test/test_extract_cpio_lz4.c
Normal file
48
cpio/test/test_extract_cpio_lz4.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*-
|
||||
* Copyright (c) 2012,2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lz4)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lzo)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lrz";
|
||||
const char *reffile = "test_extract.cpio.lzo";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
|
@ -65,18 +65,14 @@ DEFINE_TEST(test_option_c)
|
||||
{
|
||||
FILE *filelist;
|
||||
int r;
|
||||
int uid = -1;
|
||||
int dev, ino, gid;
|
||||
int uid = 1000;
|
||||
int dev, ino, gid = 1000;
|
||||
time_t t, now;
|
||||
char *p, *e;
|
||||
size_t s;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
uid = getuid();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create an assortment of files.
|
||||
* TODO: Extend this to cover more filetypes.
|
||||
@ -101,7 +97,7 @@ DEFINE_TEST(test_option_c)
|
||||
|
||||
/* Use the cpio program to create an archive. */
|
||||
fclose(filelist);
|
||||
r = systemf("%s -oc <filelist >basic.out 2>basic.err", testprog);
|
||||
r = systemf("%s -R 1000:1000 -oc <filelist >basic.out 2>basic.err", testprog);
|
||||
/* Verify that nothing went to stderr. */
|
||||
assertTextFileContents("1 block\n", "basic.err");
|
||||
|
||||
|
74
cpio/test/test_option_lz4.c
Normal file
74
cpio/test/test_option_lz4.c
Normal file
@ -0,0 +1,74 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lz4)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lz4 compression. */
|
||||
r = systemf("echo f | %s -o --lz4 >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without lz4 support");
|
||||
return;
|
||||
}
|
||||
/* POSIX permits different handling of the spawnp
|
||||
* system call used to launch the subsidiary
|
||||
* program: */
|
||||
/* Some systems fail immediately to spawn the new process. */
|
||||
if (strstr(p, "Can't launch") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdcpio uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
/* Some systems successfully spawn the new process,
|
||||
* but fail to exec a program within that process.
|
||||
* This results in failure at the first attempt to
|
||||
* write. */
|
||||
if (strstr(p, "Can't write") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdcpio uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
failure("--lz4 option is broken: %s", p);
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has an lz4 signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x04\x22\x4d\x18", 4);
|
||||
}
|
43
cpio/test/test_option_passphrase.c
Normal file
43
cpio/test/test_option_passphrase.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_passphrase)
|
||||
{
|
||||
const char *reffile = "test_option_passphrase.zip";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -i --passphrase pass1 < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
}
|
12
cpio/test/test_option_passphrase.zip.uu
Normal file
12
cpio/test/test_option_passphrase.zip.uu
Normal file
@ -0,0 +1,12 @@
|
||||
begin 644 test_option_passphrase.zip
|
||||
M4$L#!`H`"0```#B91$7D$C4,'P```!,````%`!P`9FEL93%55`D``VS'+U0"
|
||||
MQR]4=7@+``$$]0$```04````BHPD*"^*I04=XKI\_FQ*TE+#),TD7TTKSP/7
|
||||
MR6R35%!+!PCD$C4,'P```!,```!02P,$"@`)````09E$1;VL<PX?````$P``
|
||||
M``4`'`!F:6QE,E54"0`#><<O5`+'+U1U>`L``03U`0``!!0```!D#6Z\@CI8
|
||||
MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL<PX?````$P```%!+`0(>
|
||||
M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE
|
||||
M,554!0`#;,<O5'5X"P`!!/4!```$%````%!+`0(>`PH`"0```$&91$6]K',.
|
||||
M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><<O5'5X"P`!
|
||||
@!/4!```$%````%!+!08``````@`"`)8```#<````````
|
||||
`
|
||||
end
|
@ -74,6 +74,11 @@ verify(const char *p, size_t s)
|
||||
/* Skip a single trailing a,b,c, or d. */
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* All terminated by end-of-line: \r, \r\n, or \n */
|
||||
assert(s >= 1);
|
||||
failure("Version: %s", p);
|
||||
|
@ -93,14 +93,44 @@ function breakline() {
|
||||
linecmd("<br>")
|
||||
}
|
||||
|
||||
function crossref(name, sect, other) {
|
||||
if (name == "cpio" && sect == 1) {
|
||||
n = "ManPageBsdcpio1"
|
||||
} else if (name == "cpio" && sect == 5) {
|
||||
n = "ManPageCpio5"
|
||||
} else if (name == "mtree" && sect == 5) {
|
||||
n = "ManPageMtree5"
|
||||
} else if (name == "tar" && sect == 1) {
|
||||
n = "ManPageBsdtar1"
|
||||
} else if (name == "tar" && sect == 5) {
|
||||
n = "ManPageTar5"
|
||||
} else if (!match(name, "^archive") && !match(name, "^libarchive")) {
|
||||
n = name "(" sect ")|http://www.freebsd.org/cgi/man.cgi?query=" name "&sektion=" sect
|
||||
} else {
|
||||
n = "ManPage"
|
||||
numbits = split(name, namebits, "[_-]")
|
||||
for (i = 1; i <= numbits; ++i) {
|
||||
p = namebits[i]
|
||||
n = n toupper(substr(p, 0, 1)) substr(p, 2)
|
||||
}
|
||||
n = n sect
|
||||
}
|
||||
n = "[[" n "]]"
|
||||
if (length other > 0)
|
||||
n = n other
|
||||
return n
|
||||
}
|
||||
|
||||
# Start an indented display
|
||||
function dispstart() {
|
||||
linecmd("```text")
|
||||
endline()
|
||||
print "```text"
|
||||
}
|
||||
|
||||
# End an indented display
|
||||
function dispend() {
|
||||
linecmd("```")
|
||||
endline()
|
||||
print "```"
|
||||
}
|
||||
|
||||
# Collect rest of input line
|
||||
@ -123,22 +153,22 @@ function splitwords(l, dest, n, o, w) {
|
||||
l = substr(l, 2)
|
||||
o = index(l, "\"")
|
||||
if (o > 0) {
|
||||
w = substr(l, 1, o-1)
|
||||
l = substr(l, o+1)
|
||||
dest[n++] = w
|
||||
w = substr(l, 1, o-1)
|
||||
l = substr(l, o+1)
|
||||
dest[n++] = w
|
||||
} else {
|
||||
dest[n++] = l
|
||||
l = ""
|
||||
dest[n++] = l
|
||||
l = ""
|
||||
}
|
||||
} else {
|
||||
o = match(l, "[ \t]")
|
||||
if (o > 0) {
|
||||
w = substr(l, 1, o-1)
|
||||
l = substr(l, o+1)
|
||||
dest[n++] = w
|
||||
w = substr(l, 1, o-1)
|
||||
l = substr(l, o+1)
|
||||
dest[n++] = w
|
||||
} else {
|
||||
dest[n++] = l
|
||||
l = ""
|
||||
dest[n++] = l
|
||||
l = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,6 +184,7 @@ function splitwords(l, dest, n, o, w) {
|
||||
/^\.\\"/ { next }
|
||||
|
||||
{
|
||||
gsub("\\\\e", "\\")
|
||||
sub("^\\.","")
|
||||
nwords=splitwords($0, words)
|
||||
# TODO: Instead of iterating 'w' over the array, have a separate
|
||||
@ -170,8 +201,8 @@ function splitwords(l, dest, n, o, w) {
|
||||
STATE = PRETAG_STATE
|
||||
if(match(words[w+1],"-literal")) {
|
||||
dispstart()
|
||||
displaylines=10000
|
||||
w=nwords
|
||||
displaylines=10000
|
||||
w=nwords
|
||||
}
|
||||
} else if(match(words[w],"^Ed$")) { # End display
|
||||
displaylines = 0
|
||||
@ -185,7 +216,7 @@ function splitwords(l, dest, n, o, w) {
|
||||
addopen("\"")
|
||||
add(words[++w])
|
||||
while(w<nwords&&!match(words[w+1],"^[\\.,]"))
|
||||
add(words[++w])
|
||||
add(words[++w])
|
||||
addclose("\"")
|
||||
} else if(match(words[w],"^Do$")) {
|
||||
addopen("\"")
|
||||
@ -241,16 +272,17 @@ function splitwords(l, dest, n, o, w) {
|
||||
section=wtail()
|
||||
linecmd("== " section " ==")
|
||||
} else if(match(words[w],"^Xr$")) {
|
||||
add("'''" words[++w] "'''(" words[++w] ")" words[++w])
|
||||
add(crossref(words[w+1], words[w+2], words[w+3]))
|
||||
w = w + 3
|
||||
} else if(match(words[w],"^Nm$")) {
|
||||
if(match(section,"SYNOPSIS"))
|
||||
breakline()
|
||||
if(w >= nwords)
|
||||
n=name
|
||||
n=name
|
||||
else if (match(words[w+1], "^[A-Z][a-z]$"))
|
||||
n=name
|
||||
n=name
|
||||
else if (match(words[w+1], "^[.,;:]$"))
|
||||
n=name
|
||||
n=name
|
||||
else {
|
||||
n=words[++w]
|
||||
if(!length(name))
|
||||
@ -259,27 +291,30 @@ function splitwords(l, dest, n, o, w) {
|
||||
if(!length(n))
|
||||
n=name
|
||||
if (displaylines == 0)
|
||||
add("'''" n "'''")
|
||||
add("'''" n "'''")
|
||||
else
|
||||
add(n)
|
||||
add(n)
|
||||
} else if(match(words[w],"^Nd$")) {
|
||||
add("- " wtail())
|
||||
} else if(match(words[w],"^Fl$")) {
|
||||
addopen("-")
|
||||
} else if(match(words[w],"^Ar$")) {
|
||||
if(w==nwords)
|
||||
add("''file ...''")
|
||||
add("''file ...''")
|
||||
else {
|
||||
++w
|
||||
gsub("<", "<", words[w])
|
||||
add("''" words[w] "''")
|
||||
++w
|
||||
gsub("<", "\\<", words[w])
|
||||
if (displaylines > 0)
|
||||
add(words[w])
|
||||
else
|
||||
add("''" words[w] "''")
|
||||
}
|
||||
} else if(match(words[w],"^Cm$")) {
|
||||
++w
|
||||
if (displaylines == 0) {
|
||||
add("'''" words[w] "'''")
|
||||
add("'''" words[w] "'''")
|
||||
} else
|
||||
add(words[w])
|
||||
add(words[w])
|
||||
} else if(match(words[w],"^Op$")) {
|
||||
addopen("<nowiki>[</nowiki>")
|
||||
option=1
|
||||
@ -290,36 +325,36 @@ function splitwords(l, dest, n, o, w) {
|
||||
print ""
|
||||
} else if(match(words[w],"^An$")) {
|
||||
if (match(words[w+1],"-nosplit"))
|
||||
++w
|
||||
++w
|
||||
endline()
|
||||
} else if(match(words[w],"^Ss$")) {
|
||||
add("===")
|
||||
trailer="==="
|
||||
} else if(match(words[w],"^Ft$")) {
|
||||
if (match(section, "SYNOPSIS")) {
|
||||
breakline()
|
||||
breakline()
|
||||
}
|
||||
l = wtail()
|
||||
add("'''" l "'''")
|
||||
add("''" l "''")
|
||||
if (match(section, "SYNOPSIS")) {
|
||||
breakline()
|
||||
breakline()
|
||||
}
|
||||
} else if(match(words[w],"^Fn$")) {
|
||||
++w
|
||||
F = "'''" words[w] "'''("
|
||||
Fsep = ""
|
||||
while(w<nwords) {
|
||||
++w
|
||||
if (match(words[w], "^[.,:]$")) {
|
||||
--w
|
||||
break
|
||||
}
|
||||
F = F Fsep "''" words[w] "''"
|
||||
Fsep = ", "
|
||||
++w
|
||||
if (match(words[w], "^[.,:]$")) {
|
||||
--w
|
||||
break
|
||||
}
|
||||
F = F Fsep "''" words[w] "''"
|
||||
Fsep = ", "
|
||||
}
|
||||
add(F ")")
|
||||
if (match(section, "SYNOPSIS")) {
|
||||
addclose(";")
|
||||
addclose(";")
|
||||
}
|
||||
} else if(match(words[w],"^Fo$")) {
|
||||
w++
|
||||
@ -332,7 +367,7 @@ function splitwords(l, dest, n, o, w) {
|
||||
} else if(match(words[w],"^Fc$")) {
|
||||
add(F ")")
|
||||
if (match(section, "SYNOPSIS")) {
|
||||
addclose(";")
|
||||
addclose(";")
|
||||
}
|
||||
} else if(match(words[w],"^Va$")) {
|
||||
w++
|
||||
@ -343,11 +378,11 @@ function splitwords(l, dest, n, o, w) {
|
||||
} else if(match(words[w],"^Pa$")) {
|
||||
w++
|
||||
# if(match(words[w],"^\\."))
|
||||
# add("\\&")
|
||||
# add("\\&")
|
||||
if (displaylines == 0)
|
||||
add("''" words[w] "''")
|
||||
add("''" words[w] "''")
|
||||
else
|
||||
add(words[w])
|
||||
add(words[w])
|
||||
} else if(match(words[w],"^Dv$")) {
|
||||
linecmd()
|
||||
} else if(match(words[w],"^Em|Ev$")) {
|
||||
@ -373,22 +408,22 @@ function splitwords(l, dest, n, o, w) {
|
||||
++listdepth
|
||||
listnext[listdepth]=""
|
||||
if(match(words[w+1],"-bullet")) {
|
||||
optlist[listdepth]=1
|
||||
addopen("<ul>")
|
||||
listclose[listdepth]="</ul>"
|
||||
optlist[listdepth]=1
|
||||
addopen("<ul>")
|
||||
listclose[listdepth]="</ul>"
|
||||
} else if(match(words[w+1],"-enum")) {
|
||||
optlist[listdepth]=2
|
||||
enum=0
|
||||
addopen("<ol>")
|
||||
listclose[listdepth]="</ol>"
|
||||
optlist[listdepth]=2
|
||||
enum=0
|
||||
addopen("<ol>")
|
||||
listclose[listdepth]="</ol>"
|
||||
} else if(match(words[w+1],"-tag")) {
|
||||
optlist[listdepth]=3
|
||||
addopen("<dl>")
|
||||
listclose[listdepth]="</dl>"
|
||||
optlist[listdepth]=3
|
||||
addopen("<dl>")
|
||||
listclose[listdepth]="</dl>"
|
||||
} else if(match(words[w+1],"-item")) {
|
||||
optlist[listdepth]=4
|
||||
addopen("<ul>")
|
||||
listclose[listdepth]="</ul>"
|
||||
optlist[listdepth]=4
|
||||
addopen("<ul>")
|
||||
listclose[listdepth]="</ul>"
|
||||
}
|
||||
w=nwords
|
||||
} else if(match(words[w],"^El$")) {
|
||||
@ -399,28 +434,30 @@ function splitwords(l, dest, n, o, w) {
|
||||
} else if(match(words[w],"^It$")) {
|
||||
addclose(listnext[listdepth])
|
||||
if(optlist[listdepth]==1) {
|
||||
addpunct("<li>")
|
||||
listnext[listdepth] = "</li>"
|
||||
addpunct("<li>")
|
||||
listnext[listdepth] = "</li>"
|
||||
} else if(optlist[listdepth]==2) {
|
||||
addpunct("<li>")
|
||||
listnext[listdepth] = "</li>"
|
||||
addpunct("<li>")
|
||||
listnext[listdepth] = "</li>"
|
||||
} else if(optlist[listdepth]==3) {
|
||||
addpunct("<dt>")
|
||||
listnext[listdepth] = "</dt>"
|
||||
if(match(words[w+1],"^Xo$")) {
|
||||
# Suppress trailer
|
||||
w++
|
||||
} else if(match(words[w+1],"^Pa$|^Ev$")) {
|
||||
addopen("'''")
|
||||
w++
|
||||
add(words[++w] "'''")
|
||||
} else {
|
||||
trailer = listnext[listdepth] "<dd>" trailer
|
||||
listnext[listdepth] = "</dd>"
|
||||
}
|
||||
addpunct("<dt>")
|
||||
listnext[listdepth] = "</dt>"
|
||||
if(match(words[w+1],"^Xo$")) {
|
||||
# Suppress trailer
|
||||
w++
|
||||
} else if(match(words[w+1],"^Pa$|^Ev$")) {
|
||||
addopen("'''")
|
||||
w++
|
||||
add(words[++w] "'''")
|
||||
trailer = listnext[listdepth] "<dd>" trailer
|
||||
listnext[listdepth] = "</dd>"
|
||||
} else {
|
||||
trailer = listnext[listdepth] "<dd>" trailer
|
||||
listnext[listdepth] = "</dd>"
|
||||
}
|
||||
} else if(optlist[listdepth]==4) {
|
||||
addpunct("<li>")
|
||||
listnext[listdepth] = "</li>"
|
||||
addpunct("<li>")
|
||||
listnext[listdepth] = "</li>"
|
||||
}
|
||||
} else if(match(words[w], "^Vt$")) {
|
||||
w++
|
||||
@ -430,9 +467,9 @@ function splitwords(l, dest, n, o, w) {
|
||||
} else if(match(words[w],"^Xc$")) {
|
||||
# TODO: Figure out how to handle this
|
||||
if (optlist[listdepth] == 3) {
|
||||
addclose(listnext[listdepth])
|
||||
addopen("<dd>")
|
||||
listnext[listdepth] = "</dd>"
|
||||
addclose(listnext[listdepth])
|
||||
addopen("<dd>")
|
||||
listnext[listdepth] = "</dd>"
|
||||
}
|
||||
} else if(match(words[w],"^[=]$")) {
|
||||
addpunct(words[w])
|
||||
|
@ -8,13 +8,19 @@ CFLAGS= \
|
||||
-I../../libarchive \
|
||||
-g
|
||||
|
||||
#
|
||||
# You may need to add additional libraries or link options here
|
||||
# For example, many Linux systems require -lacl
|
||||
#
|
||||
LIBS= -lz -lbz2
|
||||
|
||||
# How to link against libarchive.
|
||||
LIBARCHIVE= ../../libarchive/libarchive.a
|
||||
|
||||
all: minitar
|
||||
|
||||
minitar: minitar.o
|
||||
cc -g -o minitar minitar.o $(LIBARCHIVE) -lz -lbz2
|
||||
cc -g -o minitar minitar.o $(LIBARCHIVE) $(LIBS)
|
||||
strip minitar
|
||||
ls -l minitar
|
||||
|
||||
|
@ -249,7 +249,7 @@ create(const char *filename, int compress, const char **argv)
|
||||
break;
|
||||
}
|
||||
archive_write_set_format_ustar(a);
|
||||
if (strcmp(filename, "-") == 0)
|
||||
if (filename != NULL && strcmp(filename, "-") == 0)
|
||||
filename = NULL;
|
||||
archive_write_open_filename(a, filename);
|
||||
|
||||
@ -367,6 +367,7 @@ extract(const char *filename, int do_extract, int flags)
|
||||
exit(r);
|
||||
}
|
||||
for (;;) {
|
||||
int needcr = 0;
|
||||
r = archive_read_next_header(a, &entry);
|
||||
if (r == ARCHIVE_EOF)
|
||||
break;
|
||||
@ -377,16 +378,24 @@ extract(const char *filename, int do_extract, int flags)
|
||||
}
|
||||
if (verbose && do_extract)
|
||||
msg("x ");
|
||||
if (verbose || !do_extract)
|
||||
if (verbose || !do_extract) {
|
||||
msg(archive_entry_pathname(entry));
|
||||
msg(" ");
|
||||
needcr = 1;
|
||||
}
|
||||
if (do_extract) {
|
||||
r = archive_write_header(ext, entry);
|
||||
if (r != ARCHIVE_OK)
|
||||
if (r != ARCHIVE_OK) {
|
||||
errmsg(archive_error_string(a));
|
||||
else
|
||||
copy_data(a, ext);
|
||||
needcr = 1;
|
||||
}
|
||||
else {
|
||||
r = copy_data(a, ext);
|
||||
if (r != ARCHIVE_OK)
|
||||
needcr = 1;
|
||||
}
|
||||
}
|
||||
if (verbose || !do_extract)
|
||||
if (needcr)
|
||||
msg("\n");
|
||||
}
|
||||
archive_read_close(a);
|
||||
@ -400,16 +409,16 @@ copy_data(struct archive *ar, struct archive *aw)
|
||||
int r;
|
||||
const void *buff;
|
||||
size_t size;
|
||||
off_t offset;
|
||||
int64_t offset;
|
||||
|
||||
for (;;) {
|
||||
r = archive_read_data_block(ar, &buff, &size, &offset);
|
||||
if (r == ARCHIVE_EOF) {
|
||||
errmsg(archive_error_string(ar));
|
||||
if (r == ARCHIVE_EOF)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
if (r != ARCHIVE_OK)
|
||||
if (r != ARCHIVE_OK) {
|
||||
errmsg(archive_error_string(ar));
|
||||
return (r);
|
||||
}
|
||||
r = archive_write_data_block(aw, buff, size, offset);
|
||||
if (r != ARCHIVE_OK) {
|
||||
errmsg(archive_error_string(ar));
|
||||
@ -427,6 +436,9 @@ msg(const char *m)
|
||||
static void
|
||||
errmsg(const char *m)
|
||||
{
|
||||
if (m == NULL) {
|
||||
m = "Error: No error description provided.\n";
|
||||
}
|
||||
write(2, m, strlen(m));
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -191,6 +190,9 @@ extract(const char *filename, int do_extract, int flags)
|
||||
}
|
||||
archive_read_close(a);
|
||||
archive_read_free(a);
|
||||
|
||||
archive_write_close(ext);
|
||||
archive_write_free(ext);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -200,7 +202,7 @@ copy_data(struct archive *ar, struct archive *aw)
|
||||
int r;
|
||||
const void *buff;
|
||||
size_t size;
|
||||
#if ARCHIVE_VERSION >= 3000000
|
||||
#if ARCHIVE_VERSION_NUMBER >= 3000000
|
||||
int64_t offset;
|
||||
#else
|
||||
off_t offset;
|
||||
|
@ -18,8 +18,10 @@ SET(libarchive_SOURCES
|
||||
archive_cmdline.c
|
||||
archive_cmdline_private.h
|
||||
archive_crc32.h
|
||||
archive_crypto.c
|
||||
archive_crypto_private.h
|
||||
archive_cryptor.c
|
||||
archive_cryptor_private.h
|
||||
archive_digest.c
|
||||
archive_digest_private.h
|
||||
archive_endian.h
|
||||
archive_entry.c
|
||||
archive_entry.h
|
||||
@ -32,9 +34,14 @@ SET(libarchive_SOURCES
|
||||
archive_entry_strmode.c
|
||||
archive_entry_xattr.c
|
||||
archive_getdate.c
|
||||
archive_getdate.h
|
||||
archive_hmac.c
|
||||
archive_hmac_private.h
|
||||
archive_match.c
|
||||
archive_options.c
|
||||
archive_options_private.h
|
||||
archive_pack_dev.h
|
||||
archive_pack_dev.c
|
||||
archive_pathmatch.c
|
||||
archive_pathmatch.h
|
||||
archive_platform.h
|
||||
@ -42,9 +49,12 @@ SET(libarchive_SOURCES
|
||||
archive_ppmd7.c
|
||||
archive_ppmd7_private.h
|
||||
archive_private.h
|
||||
archive_random.c
|
||||
archive_random_private.h
|
||||
archive_rb.c
|
||||
archive_rb.h
|
||||
archive_read.c
|
||||
archive_read_add_passphrase.c
|
||||
archive_read_append_filter.c
|
||||
archive_read_data_into_fd.c
|
||||
archive_read_disk_entry_from_file.c
|
||||
@ -52,6 +62,7 @@ SET(libarchive_SOURCES
|
||||
archive_read_disk_private.h
|
||||
archive_read_disk_set_standard_lookup.c
|
||||
archive_read_extract.c
|
||||
archive_read_extract2.c
|
||||
archive_read_open_fd.c
|
||||
archive_read_open_file.c
|
||||
archive_read_open_filename.c
|
||||
@ -65,6 +76,7 @@ SET(libarchive_SOURCES
|
||||
archive_read_support_filter_gzip.c
|
||||
archive_read_support_filter_grzip.c
|
||||
archive_read_support_filter_lrzip.c
|
||||
archive_read_support_filter_lz4.c
|
||||
archive_read_support_filter_lzop.c
|
||||
archive_read_support_filter_none.c
|
||||
archive_read_support_filter_program.c
|
||||
@ -84,6 +96,7 @@ SET(libarchive_SOURCES
|
||||
archive_read_support_format_rar.c
|
||||
archive_read_support_format_raw.c
|
||||
archive_read_support_format_tar.c
|
||||
archive_read_support_format_warc.c
|
||||
archive_read_support_format_xar.c
|
||||
archive_read_support_format_zip.c
|
||||
archive_string.c
|
||||
@ -110,6 +123,7 @@ SET(libarchive_SOURCES
|
||||
archive_write_add_filter_grzip.c
|
||||
archive_write_add_filter_gzip.c
|
||||
archive_write_add_filter_lrzip.c
|
||||
archive_write_add_filter_lz4.c
|
||||
archive_write_add_filter_lzop.c
|
||||
archive_write_add_filter_none.c
|
||||
archive_write_add_filter_program.c
|
||||
@ -121,18 +135,24 @@ SET(libarchive_SOURCES
|
||||
archive_write_set_format_by_name.c
|
||||
archive_write_set_format_cpio.c
|
||||
archive_write_set_format_cpio_newc.c
|
||||
archive_write_set_format_filter_by_ext.c
|
||||
archive_write_set_format_gnutar.c
|
||||
archive_write_set_format_iso9660.c
|
||||
archive_write_set_format_mtree.c
|
||||
archive_write_set_format_pax.c
|
||||
archive_write_set_format_raw.c
|
||||
archive_write_set_format_shar.c
|
||||
archive_write_set_format_ustar.c
|
||||
archive_write_set_format_v7tar.c
|
||||
archive_write_set_format_warc.c
|
||||
archive_write_set_format_xar.c
|
||||
archive_write_set_format_zip.c
|
||||
archive_write_set_options.c
|
||||
archive_write_set_passphrase.c
|
||||
archive_xxhash.h
|
||||
filter_fork_posix.c
|
||||
filter_fork.h
|
||||
xxhash.c
|
||||
)
|
||||
|
||||
# Man pages
|
||||
@ -145,12 +165,14 @@ SET(libarchive_MANS
|
||||
archive_entry_stat.3
|
||||
archive_entry_time.3
|
||||
archive_read.3
|
||||
archive_read_add_passphrase.3
|
||||
archive_read_disk.3
|
||||
archive_read_set_options.3
|
||||
archive_util.3
|
||||
archive_write.3
|
||||
archive_write_disk.3
|
||||
archive_write_set_options.3
|
||||
archive_write_set_passphrase.3
|
||||
cpio.5
|
||||
libarchive.3
|
||||
libarchive_internals.3
|
||||
@ -175,6 +197,7 @@ SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION})
|
||||
|
||||
# archive_static is a static library
|
||||
ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS})
|
||||
TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS})
|
||||
SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS
|
||||
LIBARCHIVE_STATIC)
|
||||
# On Posix systems, libarchive.so and libarchive.a can co-exist.
|
||||
@ -182,12 +205,14 @@ IF(NOT WIN32 OR CYGWIN)
|
||||
SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive)
|
||||
ENDIF(NOT WIN32 OR CYGWIN)
|
||||
|
||||
# How to install the libraries
|
||||
INSTALL(TARGETS archive archive_static
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
INSTALL_MAN(${libarchive_MANS})
|
||||
INSTALL(FILES ${include_HEADERS} DESTINATION include)
|
||||
IF(ENABLE_INSTALL)
|
||||
# How to install the libraries
|
||||
INSTALL(TARGETS archive archive_static
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
INSTALL_MAN(${libarchive_MANS})
|
||||
INSTALL(FILES ${include_HEADERS} DESTINATION include)
|
||||
ENDIF()
|
||||
|
||||
add_subdirectory(test)
|
||||
|
@ -28,9 +28,20 @@
|
||||
#ifndef ARCHIVE_H_INCLUDED
|
||||
#define ARCHIVE_H_INCLUDED
|
||||
|
||||
/*
|
||||
* The version number is expressed as a single integer that makes it
|
||||
* easy to compare versions at build time: for version a.b.c, the
|
||||
* version number is printf("%d%03d%03d",a,b,c). For example, if you
|
||||
* know your application requires version 2.12.108 or later, you can
|
||||
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
|
||||
*/
|
||||
/* Note: Compiler will complain if this does not match archive_entry.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3002000
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stddef.h> /* for wchar_t */
|
||||
#include <stdio.h> /* For FILE * */
|
||||
#include <time.h> /* For time_t */
|
||||
|
||||
/*
|
||||
* Note: archive.h is for use outside of libarchive; the configuration
|
||||
@ -41,29 +52,53 @@
|
||||
*/
|
||||
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
|
||||
# include <stdint.h>
|
||||
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS)
|
||||
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/* Get appropriate definitions of standard POSIX-style types. */
|
||||
/* These should match the types used in 'struct stat' */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# define __LA_INT64_T __int64
|
||||
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
|
||||
# define __LA_SSIZE_T ssize_t
|
||||
# elif defined(_WIN64)
|
||||
# define __LA_SSIZE_T __int64
|
||||
# else
|
||||
# define __LA_SSIZE_T long
|
||||
/* Get appropriate definitions of 64-bit integer */
|
||||
#if !defined(__LA_INT64_T_DEFINED)
|
||||
/* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
|
||||
# if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
#define __LA_INT64_T la_int64_t
|
||||
# endif
|
||||
#else
|
||||
#define __LA_INT64_T_DEFINED
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||
typedef __int64 la_int64_t;
|
||||
# else
|
||||
# include <unistd.h> /* ssize_t */
|
||||
# if defined(_SCO_DS)
|
||||
# define __LA_INT64_T long long
|
||||
# else
|
||||
# define __LA_INT64_T int64_t
|
||||
# if defined(_SCO_DS) || defined(__osf__)
|
||||
typedef long long la_int64_t;
|
||||
# else
|
||||
typedef int64_t la_int64_t;
|
||||
# endif
|
||||
# endif
|
||||
# define __LA_SSIZE_T ssize_t
|
||||
#endif
|
||||
|
||||
/* The la_ssize_t should match the type used in 'struct stat' */
|
||||
#if !defined(__LA_SSIZE_T_DEFINED)
|
||||
/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
|
||||
# if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
#define __LA_SSIZE_T la_ssize_t
|
||||
# endif
|
||||
#define __LA_SSIZE_T_DEFINED
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
|
||||
typedef ssize_t la_ssize_t;
|
||||
# elif defined(_WIN64)
|
||||
typedef __int64 la_ssize_t;
|
||||
# else
|
||||
typedef long la_ssize_t;
|
||||
# endif
|
||||
# else
|
||||
# include <unistd.h> /* ssize_t */
|
||||
typedef ssize_t la_ssize_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Large file support for Android */
|
||||
#ifdef __ANDROID__
|
||||
#include "android_lf.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -115,24 +150,34 @@ extern "C" {
|
||||
* header and library are very different, you should expect some
|
||||
* strangeness. Don't do that.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The version number is expressed as a single integer that makes it
|
||||
* easy to compare versions at build time: for version a.b.c, the
|
||||
* version number is printf("%d%03d%03d",a,b,c). For example, if you
|
||||
* know your application requires version 2.12.108 or later, you can
|
||||
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
|
||||
*/
|
||||
/* Note: Compiler will complain if this does not match archive_entry.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3001002
|
||||
__LA_DECL int archive_version_number(void);
|
||||
|
||||
/*
|
||||
* Textual name/version of the library, useful for version displays.
|
||||
*/
|
||||
#define ARCHIVE_VERSION_STRING "libarchive 3.1.2"
|
||||
#define ARCHIVE_VERSION_ONLY_STRING "3.2.0"
|
||||
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
|
||||
__LA_DECL const char * archive_version_string(void);
|
||||
|
||||
/*
|
||||
* Detailed textual name/version of the library and its dependencies.
|
||||
* This has the form:
|
||||
* "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
|
||||
* the list of libraries described here will vary depending on how
|
||||
* libarchive was compiled.
|
||||
*/
|
||||
__LA_DECL const char * archive_version_details(void);
|
||||
|
||||
/*
|
||||
* Returns NULL if libarchive was compiled without the associated library.
|
||||
* Otherwise, returns the version number that libarchive was compiled
|
||||
* against.
|
||||
*/
|
||||
__LA_DECL const char * archive_zlib_version(void);
|
||||
__LA_DECL const char * archive_liblzma_version(void);
|
||||
__LA_DECL const char * archive_bzlib_version(void);
|
||||
__LA_DECL const char * archive_liblz4_version(void);
|
||||
|
||||
/* Declare our basic types. */
|
||||
struct archive;
|
||||
struct archive_entry;
|
||||
@ -173,7 +218,7 @@ struct archive_entry;
|
||||
*/
|
||||
|
||||
/* Returns pointer and size of next block of data from archive. */
|
||||
typedef __LA_SSIZE_T archive_read_callback(struct archive *,
|
||||
typedef la_ssize_t archive_read_callback(struct archive *,
|
||||
void *_client_data, const void **_buffer);
|
||||
|
||||
/* Skips at most request bytes from archive and returns the skipped amount.
|
||||
@ -181,18 +226,18 @@ typedef __LA_SSIZE_T archive_read_callback(struct archive *,
|
||||
* If you do skip fewer bytes than requested, libarchive will invoke your
|
||||
* read callback and discard data as necessary to make up the full skip.
|
||||
*/
|
||||
typedef __LA_INT64_T archive_skip_callback(struct archive *,
|
||||
void *_client_data, __LA_INT64_T request);
|
||||
typedef la_int64_t archive_skip_callback(struct archive *,
|
||||
void *_client_data, la_int64_t request);
|
||||
|
||||
/* Seeks to specified location in the file and returns the position.
|
||||
* Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
|
||||
* Return ARCHIVE_FATAL if the seek fails for any reason.
|
||||
*/
|
||||
typedef __LA_INT64_T archive_seek_callback(struct archive *,
|
||||
void *_client_data, __LA_INT64_T offset, int whence);
|
||||
typedef la_int64_t archive_seek_callback(struct archive *,
|
||||
void *_client_data, la_int64_t offset, int whence);
|
||||
|
||||
/* Returns size actually written, zero on EOF, -1 on error. */
|
||||
typedef __LA_SSIZE_T archive_write_callback(struct archive *,
|
||||
typedef la_ssize_t archive_write_callback(struct archive *,
|
||||
void *_client_data,
|
||||
const void *_buffer, size_t _length);
|
||||
|
||||
@ -207,6 +252,13 @@ typedef int archive_close_callback(struct archive *, void *_client_data);
|
||||
typedef int archive_switch_callback(struct archive *, void *_client_data1,
|
||||
void *_client_data2);
|
||||
|
||||
/*
|
||||
* Returns a passphrase used for encryption or decryption, NULL on nothing
|
||||
* to do and give it up.
|
||||
*/
|
||||
typedef const char *archive_passphrase_callback(struct archive *,
|
||||
void *_client_data);
|
||||
|
||||
/*
|
||||
* Codes to identify various stream filters.
|
||||
*/
|
||||
@ -223,6 +275,7 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
|
||||
#define ARCHIVE_FILTER_LRZIP 10
|
||||
#define ARCHIVE_FILTER_LZOP 11
|
||||
#define ARCHIVE_FILTER_GRZIP 12
|
||||
#define ARCHIVE_FILTER_LZ4 13
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
#define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE
|
||||
@ -284,6 +337,31 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
|
||||
#define ARCHIVE_FORMAT_CAB 0xC0000
|
||||
#define ARCHIVE_FORMAT_RAR 0xD0000
|
||||
#define ARCHIVE_FORMAT_7ZIP 0xE0000
|
||||
#define ARCHIVE_FORMAT_WARC 0xF0000
|
||||
|
||||
/*
|
||||
* Codes returned by archive_read_format_capabilities().
|
||||
*
|
||||
* This list can be extended with values between 0 and 0xffff.
|
||||
* The original purpose of this list was to let different archive
|
||||
* format readers expose their general capabilities in terms of
|
||||
* encryption.
|
||||
*/
|
||||
#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
|
||||
#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */
|
||||
#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */
|
||||
|
||||
/*
|
||||
* Codes returned by archive_read_has_encrypted_entries().
|
||||
*
|
||||
* In case the archive does not support encryption detection at all
|
||||
* ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
|
||||
* for some other reason (e.g. not enough bytes read) cannot say if
|
||||
* there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
|
||||
* is returned.
|
||||
*/
|
||||
#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
|
||||
#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
|
||||
|
||||
/*-
|
||||
* Basic outline for reading an archive:
|
||||
@ -342,6 +420,7 @@ __LA_DECL int archive_read_support_filter_compress(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_gzip(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_grzip(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_lrzip(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_lz4(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_lzip(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_lzma(struct archive *);
|
||||
__LA_DECL int archive_read_support_filter_lzop(struct archive *);
|
||||
@ -369,8 +448,17 @@ __LA_DECL int archive_read_support_format_mtree(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_rar(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_raw(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_tar(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_warc(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_xar(struct archive *);
|
||||
/* archive_read_support_format_zip() enables both streamable and seekable
|
||||
* zip readers. */
|
||||
__LA_DECL int archive_read_support_format_zip(struct archive *);
|
||||
/* Reads Zip archives as stream from beginning to end. Doesn't
|
||||
* correctly handle SFX ZIP files or ZIP archives that have been modified
|
||||
* in-place. */
|
||||
__LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
|
||||
/* Reads starting from central directory; requires seekable input. */
|
||||
__LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
|
||||
|
||||
/* Functions to manually set the format and filters to be used. This is
|
||||
* useful to bypass the bidding process when the format and filters to use
|
||||
@ -441,9 +529,9 @@ __LA_DECL int archive_read_open_file(struct archive *,
|
||||
const char *_filename, size_t _block_size) __LA_DEPRECATED;
|
||||
/* Read an archive that's stored in memory. */
|
||||
__LA_DECL int archive_read_open_memory(struct archive *,
|
||||
void * buff, size_t size);
|
||||
const void * buff, size_t size);
|
||||
/* A more involved version that is only used for internal testing. */
|
||||
__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff,
|
||||
__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
|
||||
size_t size, size_t read_size);
|
||||
/* Read an archive that's already open, using the file descriptor. */
|
||||
__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
|
||||
@ -464,14 +552,40 @@ __LA_DECL int archive_read_next_header2(struct archive *,
|
||||
* Retrieve the byte offset in UNCOMPRESSED data where last-read
|
||||
* header started.
|
||||
*/
|
||||
__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
|
||||
__LA_DECL la_int64_t archive_read_header_position(struct archive *);
|
||||
|
||||
/*
|
||||
* Returns 1 if the archive contains at least one encrypted entry.
|
||||
* If the archive format not support encryption at all
|
||||
* ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
|
||||
* If for any other reason (e.g. not enough data read so far)
|
||||
* we cannot say whether there are encrypted entries, then
|
||||
* ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
|
||||
* In general, this function will return values below zero when the
|
||||
* reader is uncertain or totally uncapable of encryption support.
|
||||
* When this function returns 0 you can be sure that the reader
|
||||
* supports encryption detection but no encrypted entries have
|
||||
* been found yet.
|
||||
*
|
||||
* NOTE: If the metadata/header of an archive is also encrypted, you
|
||||
* cannot rely on the number of encrypted entries. That is why this
|
||||
* function does not return the number of encrypted entries but#
|
||||
* just shows that there are some.
|
||||
*/
|
||||
__LA_DECL int archive_read_has_encrypted_entries(struct archive *);
|
||||
|
||||
/*
|
||||
* Returns a bitmask of capabilities that are supported by the archive format reader.
|
||||
* If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
|
||||
*/
|
||||
__LA_DECL int archive_read_format_capabilities(struct archive *);
|
||||
|
||||
/* Read data from the body of an entry. Similar to read(2). */
|
||||
__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
|
||||
__LA_DECL la_ssize_t archive_read_data(struct archive *,
|
||||
void *, size_t);
|
||||
|
||||
/* Seek within the body of an entry. Similar to lseek(2). */
|
||||
__LA_DECL __LA_INT64_T archive_seek_data(struct archive *, __LA_INT64_T, int);
|
||||
__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);
|
||||
|
||||
/*
|
||||
* A zero-copy version of archive_read_data that also exposes the file offset
|
||||
@ -480,7 +594,7 @@ __LA_DECL __LA_INT64_T archive_seek_data(struct archive *, __LA_INT64_T, int);
|
||||
* be strictly increasing and that returned blocks will not overlap.
|
||||
*/
|
||||
__LA_DECL int archive_read_data_block(struct archive *a,
|
||||
const void **buff, size_t *size, __LA_INT64_T *offset);
|
||||
const void **buff, size_t *size, la_int64_t *offset);
|
||||
|
||||
/*-
|
||||
* Some convenience functions that are built on archive_read_data:
|
||||
@ -510,6 +624,14 @@ __LA_DECL int archive_read_set_option(struct archive *_a,
|
||||
__LA_DECL int archive_read_set_options(struct archive *_a,
|
||||
const char *opts);
|
||||
|
||||
/*
|
||||
* Add a decryption passphrase.
|
||||
*/
|
||||
__LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
|
||||
__LA_DECL int archive_read_set_passphrase_callback(struct archive *,
|
||||
void *client_data, archive_passphrase_callback *);
|
||||
|
||||
|
||||
/*-
|
||||
* Convenience function to recreate the current entry (whose header
|
||||
* has just been read) on disk.
|
||||
@ -562,6 +684,10 @@ __LA_DECL int archive_read_set_options(struct archive *_a,
|
||||
/* Default: Do not use HFS+ compression if it was not compressed. */
|
||||
/* This has no effect except on Mac OS v10.6 or later. */
|
||||
#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000)
|
||||
/* Default: Do not reject entries with absolute paths */
|
||||
#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
|
||||
/* Default: Do not clear no-change flags when unlinking object */
|
||||
#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000)
|
||||
|
||||
__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
|
||||
int flags);
|
||||
@ -573,7 +699,7 @@ __LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
|
||||
/* Record the dev/ino of a file that will not be written. This is
|
||||
* generally set to the dev/ino of the archive being read. */
|
||||
__LA_DECL void archive_read_extract_set_skip_file(struct archive *,
|
||||
__LA_INT64_T, __LA_INT64_T);
|
||||
la_int64_t, la_int64_t);
|
||||
|
||||
/* Close the file and release most resources. */
|
||||
__LA_DECL int archive_read_close(struct archive *);
|
||||
@ -612,7 +738,7 @@ __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
|
||||
/* The dev/ino of a file that won't be archived. This is used
|
||||
* to avoid recursively adding an archive to itself. */
|
||||
__LA_DECL int archive_write_set_skip_file(struct archive *,
|
||||
__LA_INT64_T, __LA_INT64_T);
|
||||
la_int64_t, la_int64_t);
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
__LA_DECL int archive_write_set_compression_bzip2(struct archive *)
|
||||
@ -643,6 +769,7 @@ __LA_DECL int archive_write_add_filter_compress(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_grzip(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_gzip(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_lrzip(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_lz4(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_lzip(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_lzma(struct archive *);
|
||||
__LA_DECL int archive_write_add_filter_lzop(struct archive *);
|
||||
@ -670,12 +797,16 @@ __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
|
||||
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
|
||||
__LA_DECL int archive_write_set_format_pax(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_raw(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_shar(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_ustar(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_v7tar(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_warc(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_xar(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_zip(struct archive *);
|
||||
__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
|
||||
__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
|
||||
__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
|
||||
__LA_DECL int archive_write_zip_set_compression_store(struct archive *);
|
||||
__LA_DECL int archive_write_open(struct archive *, void *,
|
||||
@ -700,12 +831,12 @@ __LA_DECL int archive_write_open_memory(struct archive *,
|
||||
*/
|
||||
__LA_DECL int archive_write_header(struct archive *,
|
||||
struct archive_entry *);
|
||||
__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *,
|
||||
__LA_DECL la_ssize_t archive_write_data(struct archive *,
|
||||
const void *, size_t);
|
||||
|
||||
/* This interface is currently only available for archive_write_disk handles. */
|
||||
__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
|
||||
const void *, size_t, __LA_INT64_T);
|
||||
__LA_DECL la_ssize_t archive_write_data_block(struct archive *,
|
||||
const void *, size_t, la_int64_t);
|
||||
|
||||
__LA_DECL int archive_write_finish_entry(struct archive *);
|
||||
__LA_DECL int archive_write_close(struct archive *);
|
||||
@ -740,6 +871,13 @@ __LA_DECL int archive_write_set_option(struct archive *_a,
|
||||
__LA_DECL int archive_write_set_options(struct archive *_a,
|
||||
const char *opts);
|
||||
|
||||
/*
|
||||
* Set a encryption passphrase.
|
||||
*/
|
||||
__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
|
||||
__LA_DECL int archive_write_set_passphrase_callback(struct archive *,
|
||||
void *client_data, archive_passphrase_callback *);
|
||||
|
||||
/*-
|
||||
* ARCHIVE_WRITE_DISK API
|
||||
*
|
||||
@ -759,7 +897,7 @@ __LA_DECL int archive_write_set_options(struct archive *_a,
|
||||
__LA_DECL struct archive *archive_write_disk_new(void);
|
||||
/* This file will not be overwritten. */
|
||||
__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
|
||||
__LA_INT64_T, __LA_INT64_T);
|
||||
la_int64_t, la_int64_t);
|
||||
/* Set flags to control how the next item gets created.
|
||||
* This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
|
||||
__LA_DECL int archive_write_disk_set_options(struct archive *,
|
||||
@ -789,14 +927,14 @@ __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *);
|
||||
*/
|
||||
__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
|
||||
void * /* private_data */,
|
||||
__LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
|
||||
la_int64_t (*)(void *, const char *, la_int64_t),
|
||||
void (* /* cleanup */)(void *));
|
||||
__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
|
||||
void * /* private_data */,
|
||||
__LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
|
||||
la_int64_t (*)(void *, const char *, la_int64_t),
|
||||
void (* /* cleanup */)(void *));
|
||||
__LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T);
|
||||
__LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T);
|
||||
__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t);
|
||||
__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t);
|
||||
|
||||
/*
|
||||
* ARCHIVE_READ_DISK API
|
||||
@ -817,19 +955,19 @@ __LA_DECL int archive_read_disk_entry_from_file(struct archive *,
|
||||
struct archive_entry *, int /* fd */, const struct stat *);
|
||||
/* Look up gname for gid or uname for uid. */
|
||||
/* Default implementations are very, very stupid. */
|
||||
__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T);
|
||||
__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T);
|
||||
__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t);
|
||||
__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t);
|
||||
/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
|
||||
* results for performance. */
|
||||
__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
|
||||
/* You can install your own lookups if you like. */
|
||||
__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
|
||||
void * /* private_data */,
|
||||
const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
|
||||
const char *(* /* lookup_fn */)(void *, la_int64_t),
|
||||
void (* /* cleanup_fn */)(void *));
|
||||
__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
|
||||
void * /* private_data */,
|
||||
const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
|
||||
const char *(* /* lookup_fn */)(void *, la_int64_t),
|
||||
void (* /* cleanup_fn */)(void *));
|
||||
/* Start traversal. */
|
||||
__LA_DECL int archive_read_disk_open(struct archive *, const char *);
|
||||
@ -859,8 +997,10 @@ __LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
|
||||
/* Default: Skip a mac resource fork file whose prefix is "._" because of
|
||||
* using copyfile. */
|
||||
#define ARCHIVE_READDISK_MAC_COPYFILE (0x0004)
|
||||
/* Default: Do not traverse mount points. */
|
||||
/* Default: Traverse mount points. */
|
||||
#define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008)
|
||||
/* Default: Xattrs are read from disk. */
|
||||
#define ARCHIVE_READDISK_NO_XATTR (0x0010)
|
||||
|
||||
__LA_DECL int archive_read_disk_set_behavior(struct archive *,
|
||||
int flags);
|
||||
@ -879,6 +1019,10 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
|
||||
int (*_metadata_filter_func)(struct archive *, void *,
|
||||
struct archive_entry *), void *_client_data);
|
||||
|
||||
/* Simplified cleanup interface;
|
||||
* This calls archive_read_free() or archive_write_free() as needed. */
|
||||
__LA_DECL int archive_free(struct archive *);
|
||||
|
||||
/*
|
||||
* Accessor functions to read/set various information in
|
||||
* the struct archive object:
|
||||
@ -889,7 +1033,7 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
|
||||
* last filter, which is always the pseudo-filter that wraps the
|
||||
* client callbacks. */
|
||||
__LA_DECL int archive_filter_count(struct archive *);
|
||||
__LA_DECL __LA_INT64_T archive_filter_bytes(struct archive *, int);
|
||||
__LA_DECL la_int64_t archive_filter_bytes(struct archive *, int);
|
||||
__LA_DECL int archive_filter_code(struct archive *, int);
|
||||
__LA_DECL const char * archive_filter_name(struct archive *, int);
|
||||
|
||||
@ -897,10 +1041,10 @@ __LA_DECL const char * archive_filter_name(struct archive *, int);
|
||||
/* These don't properly handle multiple filters, so are deprecated and
|
||||
* will eventually be removed. */
|
||||
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
|
||||
__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *)
|
||||
__LA_DECL la_int64_t archive_position_compressed(struct archive *)
|
||||
__LA_DEPRECATED;
|
||||
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
|
||||
__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *)
|
||||
__LA_DECL la_int64_t archive_position_uncompressed(struct archive *)
|
||||
__LA_DEPRECATED;
|
||||
/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
|
||||
__LA_DECL const char *archive_compression_name(struct archive *)
|
||||
@ -1016,8 +1160,8 @@ __LA_DECL int archive_match_exclude_entry(struct archive *,
|
||||
__LA_DECL int archive_match_owner_excluded(struct archive *,
|
||||
struct archive_entry *);
|
||||
/* Add inclusion uid, gid, uname and gname. */
|
||||
__LA_DECL int archive_match_include_uid(struct archive *, __LA_INT64_T);
|
||||
__LA_DECL int archive_match_include_gid(struct archive *, __LA_INT64_T);
|
||||
__LA_DECL int archive_match_include_uid(struct archive *, la_int64_t);
|
||||
__LA_DECL int archive_match_include_gid(struct archive *, la_int64_t);
|
||||
__LA_DECL int archive_match_include_uname(struct archive *, const char *);
|
||||
__LA_DECL int archive_match_include_uname_w(struct archive *,
|
||||
const wchar_t *);
|
||||
@ -1025,6 +1169,10 @@ __LA_DECL int archive_match_include_gname(struct archive *, const char *);
|
||||
__LA_DECL int archive_match_include_gname_w(struct archive *,
|
||||
const wchar_t *);
|
||||
|
||||
/* Utility functions */
|
||||
/* Convenience function to sort a NULL terminated list of strings */
|
||||
__LA_DECL int archive_utility_string_sort(char **);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -1032,9 +1180,4 @@ __LA_DECL int archive_match_include_gname_w(struct archive *,
|
||||
/* These are meaningless outside of this header. */
|
||||
#undef __LA_DECL
|
||||
|
||||
/* These need to remain defined because they're used in the
|
||||
* callback type definitions. XXX Fix this. This is ugly. XXX */
|
||||
/* #undef __LA_INT64_T */
|
||||
/* #undef __LA_SSIZE_T */
|
||||
|
||||
#endif /* !ARCHIVE_H_INCLUDED */
|
||||
|
448
libarchive/archive_cryptor.c
Normal file
448
libarchive/archive_cryptor.c
Normal file
@ -0,0 +1,448 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "archive_platform.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "archive.h"
|
||||
#include "archive_cryptor_private.h"
|
||||
|
||||
/*
|
||||
* On systems that do not support any recognized crypto libraries,
|
||||
* this file will normally define no usable symbols.
|
||||
*
|
||||
* But some compilers and linkers choke on empty object files, so
|
||||
* define a public symbol that will always exist. This could
|
||||
* be removed someday if this file gains another always-present
|
||||
* symbol definition.
|
||||
*/
|
||||
int __libarchive_cryptor_build_hack(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||
|
||||
static int
|
||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
||||
size_t derived_key_len)
|
||||
{
|
||||
CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pw,
|
||||
pw_len, salt, salt_len, kCCPRFHmacAlgSHA1, rounds,
|
||||
derived_key, derived_key_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Bcrypt.lib")
|
||||
#endif
|
||||
|
||||
static int
|
||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
||||
size_t derived_key_len)
|
||||
{
|
||||
NTSTATUS status;
|
||||
BCRYPT_ALG_HANDLE hAlg;
|
||||
|
||||
status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_SHA1_ALGORITHM,
|
||||
MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
||||
if (!BCRYPT_SUCCESS(status))
|
||||
return -1;
|
||||
|
||||
status = BCryptDeriveKeyPBKDF2(hAlg,
|
||||
(PUCHAR)(uintptr_t)pw, (ULONG)pw_len,
|
||||
(PUCHAR)(uintptr_t)salt, (ULONG)salt_len, rounds,
|
||||
(PUCHAR)derived_key, (ULONG)derived_key_len, 0);
|
||||
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
|
||||
return (BCRYPT_SUCCESS(status)) ? 0: -1;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_PBKDF2_H)
|
||||
|
||||
static int
|
||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
||||
size_t derived_key_len) {
|
||||
pbkdf2_hmac_sha1((unsigned)pw_len, (const uint8_t *)pw, rounds,
|
||||
salt_len, salt, derived_key_len, derived_key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_PKCS5_PBKDF2_HMAC_SHA1)
|
||||
|
||||
static int
|
||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
||||
size_t derived_key_len) {
|
||||
|
||||
PKCS5_PBKDF2_HMAC_SHA1(pw, pw_len, salt, salt_len, rounds,
|
||||
derived_key_len, derived_key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Stub */
|
||||
static int
|
||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
||||
size_t derived_key_len) {
|
||||
(void)pw; /* UNUSED */
|
||||
(void)pw_len; /* UNUSED */
|
||||
(void)salt; /* UNUSED */
|
||||
(void)salt_len; /* UNUSED */
|
||||
(void)rounds; /* UNUSED */
|
||||
(void)derived_key; /* UNUSED */
|
||||
(void)derived_key_len; /* UNUSED */
|
||||
return -1; /* UNSUPPORTED */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
# define kCCAlgorithmAES kCCAlgorithmAES128
|
||||
# endif
|
||||
|
||||
static int
|
||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
{
|
||||
CCCryptorStatus r;
|
||||
|
||||
ctx->key_len = key_len;
|
||||
memcpy(ctx->key, key, key_len);
|
||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
||||
r = CCCryptorCreateWithMode(kCCEncrypt, kCCModeECB, kCCAlgorithmAES,
|
||||
ccNoPadding, NULL, key, key_len, NULL, 0, 0, 0, &ctx->ctx);
|
||||
return (r == kCCSuccess)? 0: -1;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
||||
{
|
||||
CCCryptorRef ref = ctx->ctx;
|
||||
CCCryptorStatus r;
|
||||
|
||||
r = CCCryptorReset(ref, NULL);
|
||||
if (r != kCCSuccess)
|
||||
return -1;
|
||||
r = CCCryptorUpdate(ref, ctx->nonce, AES_BLOCK_SIZE, ctx->encr_buf,
|
||||
AES_BLOCK_SIZE, NULL);
|
||||
return (r == kCCSuccess)? 0: -1;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
||||
{
|
||||
memset(ctx->key, 0, ctx->key_len);
|
||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
|
||||
static int
|
||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
{
|
||||
BCRYPT_ALG_HANDLE hAlg;
|
||||
BCRYPT_KEY_HANDLE hKey;
|
||||
DWORD keyObj_len, aes_key_len;
|
||||
PBYTE keyObj;
|
||||
ULONG result;
|
||||
NTSTATUS status;
|
||||
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
|
||||
|
||||
ctx->hAlg = NULL;
|
||||
ctx->hKey = NULL;
|
||||
ctx->keyObj = NULL;
|
||||
switch (key_len) {
|
||||
case 16: aes_key_len = 128; break;
|
||||
case 24: aes_key_len = 192; break;
|
||||
case 32: aes_key_len = 256; break;
|
||||
default: return -1;
|
||||
}
|
||||
status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_AES_ALGORITHM,
|
||||
MS_PRIMITIVE_PROVIDER, 0);
|
||||
if (!BCRYPT_SUCCESS(status))
|
||||
return -1;
|
||||
status = BCryptGetProperty(hAlg, BCRYPT_KEY_LENGTHS, (PUCHAR)&key_lengths,
|
||||
sizeof(key_lengths), &result, 0);
|
||||
if (!BCRYPT_SUCCESS(status)) {
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
return -1;
|
||||
}
|
||||
if (key_lengths.dwMinLength > aes_key_len
|
||||
|| key_lengths.dwMaxLength < aes_key_len) {
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
return -1;
|
||||
}
|
||||
status = BCryptGetProperty(hAlg, BCRYPT_OBJECT_LENGTH, (PUCHAR)&keyObj_len,
|
||||
sizeof(keyObj_len), &result, 0);
|
||||
if (!BCRYPT_SUCCESS(status)) {
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
return -1;
|
||||
}
|
||||
keyObj = (PBYTE)HeapAlloc(GetProcessHeap(), 0, keyObj_len);
|
||||
if (keyObj == NULL) {
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
return -1;
|
||||
}
|
||||
status = BCryptSetProperty(hAlg, BCRYPT_CHAINING_MODE,
|
||||
(PUCHAR)BCRYPT_CHAIN_MODE_ECB, sizeof(BCRYPT_CHAIN_MODE_ECB), 0);
|
||||
if (!BCRYPT_SUCCESS(status)) {
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
HeapFree(GetProcessHeap(), 0, keyObj);
|
||||
return -1;
|
||||
}
|
||||
status = BCryptGenerateSymmetricKey(hAlg, &hKey,
|
||||
keyObj, keyObj_len,
|
||||
(PUCHAR)(uintptr_t)key, (ULONG)key_len, 0);
|
||||
if (!BCRYPT_SUCCESS(status)) {
|
||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
||||
HeapFree(GetProcessHeap(), 0, keyObj);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->hAlg = hAlg;
|
||||
ctx->hKey = hKey;
|
||||
ctx->keyObj = keyObj;
|
||||
ctx->keyObj_len = keyObj_len;
|
||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
||||
{
|
||||
NTSTATUS status;
|
||||
ULONG result;
|
||||
|
||||
status = BCryptEncrypt(ctx->hKey, (PUCHAR)ctx->nonce, AES_BLOCK_SIZE,
|
||||
NULL, NULL, 0, (PUCHAR)ctx->encr_buf, AES_BLOCK_SIZE,
|
||||
&result, 0);
|
||||
return BCRYPT_SUCCESS(status) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
||||
{
|
||||
|
||||
if (ctx->hAlg != NULL) {
|
||||
BCryptCloseAlgorithmProvider(ctx->hAlg, 0);
|
||||
ctx->hAlg = NULL;
|
||||
BCryptDestroyKey(ctx->hKey);
|
||||
ctx->hKey = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, ctx->keyObj);
|
||||
ctx->keyObj = NULL;
|
||||
}
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
|
||||
|
||||
static int
|
||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
{
|
||||
ctx->key_len = key_len;
|
||||
memcpy(ctx->key, key, key_len);
|
||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
||||
memset(&ctx->ctx, 0, sizeof(ctx->ctx));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
||||
{
|
||||
aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
|
||||
aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
||||
{
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_LIBCRYPTO)
|
||||
|
||||
static int
|
||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
{
|
||||
|
||||
switch (key_len) {
|
||||
case 16: ctx->type = EVP_aes_128_ecb(); break;
|
||||
case 24: ctx->type = EVP_aes_192_ecb(); break;
|
||||
case 32: ctx->type = EVP_aes_256_ecb(); break;
|
||||
default: ctx->type = NULL; return -1;
|
||||
}
|
||||
|
||||
ctx->key_len = key_len;
|
||||
memcpy(ctx->key, key, key_len);
|
||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
||||
EVP_CIPHER_CTX_init(&ctx->ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
||||
{
|
||||
int outl = 0;
|
||||
int r;
|
||||
|
||||
r = EVP_EncryptInit_ex(&ctx->ctx, ctx->type, NULL, ctx->key, NULL);
|
||||
if (r == 0)
|
||||
return -1;
|
||||
r = EVP_EncryptUpdate(&ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
|
||||
AES_BLOCK_SIZE);
|
||||
if (r == 0 || outl != AES_BLOCK_SIZE)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
||||
{
|
||||
EVP_CIPHER_CTX_cleanup(&ctx->ctx);
|
||||
memset(ctx->key, 0, ctx->key_len);
|
||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define ARCHIVE_CRYPTOR_STUB
|
||||
/* Stub */
|
||||
static int
|
||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||
{
|
||||
(void)ctx; /* UNUSED */
|
||||
(void)key; /* UNUSED */
|
||||
(void)key_len; /* UNUSED */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
||||
{
|
||||
(void)ctx; /* UNUSED */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
||||
{
|
||||
(void)ctx; /* UNUSED */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ARCHIVE_CRYPTOR_STUB
|
||||
static int
|
||||
aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
|
||||
size_t in_len, uint8_t * const out, size_t *out_len)
|
||||
{
|
||||
(void)ctx; /* UNUSED */
|
||||
(void)in; /* UNUSED */
|
||||
(void)in_len; /* UNUSED */
|
||||
(void)out; /* UNUSED */
|
||||
(void)out_len; /* UNUSED */
|
||||
aes_ctr_encrypt_counter(ctx); /* UNUSED */ /* Fix unused function warning */
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
static void
|
||||
aes_ctr_increase_counter(archive_crypto_ctx *ctx)
|
||||
{
|
||||
uint8_t *const nonce = ctx->nonce;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (++nonce[j])
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
|
||||
size_t in_len, uint8_t * const out, size_t *out_len)
|
||||
{
|
||||
uint8_t *const ebuf = ctx->encr_buf;
|
||||
unsigned pos = ctx->encr_pos;
|
||||
unsigned max = (unsigned)((in_len < *out_len)? in_len: *out_len);
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < max; ) {
|
||||
if (pos == AES_BLOCK_SIZE) {
|
||||
aes_ctr_increase_counter(ctx);
|
||||
if (aes_ctr_encrypt_counter(ctx) != 0)
|
||||
return -1;
|
||||
while (max -i >= AES_BLOCK_SIZE) {
|
||||
for (pos = 0; pos < AES_BLOCK_SIZE; pos++)
|
||||
out[i+pos] = in[i+pos] ^ ebuf[pos];
|
||||
i += AES_BLOCK_SIZE;
|
||||
aes_ctr_increase_counter(ctx);
|
||||
if (aes_ctr_encrypt_counter(ctx) != 0)
|
||||
return -1;
|
||||
}
|
||||
pos = 0;
|
||||
if (i >= max)
|
||||
break;
|
||||
}
|
||||
out[i] = in[i] ^ ebuf[pos++];
|
||||
i++;
|
||||
}
|
||||
ctx->encr_pos = pos;
|
||||
*out_len = i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* ARCHIVE_CRYPTOR_STUB */
|
||||
|
||||
|
||||
const struct archive_cryptor __archive_cryptor =
|
||||
{
|
||||
&pbkdf2_sha1,
|
||||
&aes_ctr_init,
|
||||
&aes_ctr_update,
|
||||
&aes_ctr_release,
|
||||
&aes_ctr_init,
|
||||
&aes_ctr_update,
|
||||
&aes_ctr_release,
|
||||
};
|
163
libarchive/archive_cryptor_private.h
Normal file
163
libarchive/archive_cryptor_private.h
Normal file
@ -0,0 +1,163 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __LIBARCHIVE_BUILD
|
||||
#error This header is only to be used internally to libarchive.
|
||||
#endif
|
||||
|
||||
#ifndef ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
|
||||
#define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
|
||||
|
||||
/*
|
||||
* On systems that do not support any recognized crypto libraries,
|
||||
* the archive_cryptor.c file will normally define no usable symbols.
|
||||
*
|
||||
* But some compilers and linkers choke on empty object files, so
|
||||
* define a public symbol that will always exist. This could
|
||||
* be removed someday if this file gains another always-present
|
||||
* symbol definition.
|
||||
*/
|
||||
int __libarchive_cryptor_build_hack(void);
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <AvailabilityMacros.h>
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
|
||||
# define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||
#include <CommonCrypto/CommonCryptor.h>
|
||||
#include <CommonCrypto/CommonKeyDerivation.h>
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_MAX_KEY_SIZE kCCKeySizeAES256
|
||||
|
||||
typedef struct {
|
||||
CCCryptorRef ctx;
|
||||
uint8_t key[AES_MAX_KEY_SIZE];
|
||||
unsigned key_len;
|
||||
uint8_t nonce[AES_BLOCK_SIZE];
|
||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
||||
unsigned encr_pos;
|
||||
} archive_crypto_ctx;
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
||||
#include <Bcrypt.h>
|
||||
|
||||
/* Common in other bcrypt implementations, but missing from VS2008. */
|
||||
#ifndef BCRYPT_SUCCESS
|
||||
#define BCRYPT_SUCCESS(r) ((NTSTATUS)(r) == STATUS_SUCCESS)
|
||||
#endif
|
||||
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
#define AES_BLOCK_SIZE 16
|
||||
typedef struct {
|
||||
BCRYPT_ALG_HANDLE hAlg;
|
||||
BCRYPT_KEY_HANDLE hKey;
|
||||
PBYTE keyObj;
|
||||
DWORD keyObj_len;
|
||||
uint8_t nonce[AES_BLOCK_SIZE];
|
||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
||||
unsigned encr_pos;
|
||||
} archive_crypto_ctx;
|
||||
|
||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
|
||||
#if defined(HAVE_NETTLE_PBKDF2_H)
|
||||
#include <nettle/pbkdf2.h>
|
||||
#endif
|
||||
#include <nettle/aes.h>
|
||||
|
||||
typedef struct {
|
||||
struct aes_ctx ctx;
|
||||
uint8_t key[AES_MAX_KEY_SIZE];
|
||||
unsigned key_len;
|
||||
uint8_t nonce[AES_BLOCK_SIZE];
|
||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
||||
unsigned encr_pos;
|
||||
} archive_crypto_ctx;
|
||||
|
||||
#elif defined(HAVE_LIBCRYPTO)
|
||||
#include <openssl/evp.h>
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
|
||||
typedef struct {
|
||||
EVP_CIPHER_CTX ctx;
|
||||
const EVP_CIPHER *type;
|
||||
uint8_t key[AES_MAX_KEY_SIZE];
|
||||
unsigned key_len;
|
||||
uint8_t nonce[AES_BLOCK_SIZE];
|
||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
||||
unsigned encr_pos;
|
||||
} archive_crypto_ctx;
|
||||
|
||||
#else
|
||||
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
typedef int archive_crypto_ctx;
|
||||
|
||||
#endif
|
||||
|
||||
/* defines */
|
||||
#define archive_pbkdf2_sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)\
|
||||
__archive_cryptor.pbkdf2sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)
|
||||
|
||||
#define archive_decrypto_aes_ctr_init(ctx, key, key_len) \
|
||||
__archive_cryptor.decrypto_aes_ctr_init(ctx, key, key_len)
|
||||
#define archive_decrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
|
||||
__archive_cryptor.decrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
|
||||
#define archive_decrypto_aes_ctr_release(ctx) \
|
||||
__archive_cryptor.decrypto_aes_ctr_release(ctx)
|
||||
|
||||
#define archive_encrypto_aes_ctr_init(ctx, key, key_len) \
|
||||
__archive_cryptor.encrypto_aes_ctr_init(ctx, key, key_len)
|
||||
#define archive_encrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
|
||||
__archive_cryptor.encrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
|
||||
#define archive_encrypto_aes_ctr_release(ctx) \
|
||||
__archive_cryptor.encrypto_aes_ctr_release(ctx)
|
||||
|
||||
/* Minimal interface to cryptographic functionality for internal use in
|
||||
* libarchive */
|
||||
struct archive_cryptor
|
||||
{
|
||||
/* PKCS5 PBKDF2 HMAC-SHA1 */
|
||||
int (*pbkdf2sha1)(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
||||
size_t derived_key_len);
|
||||
/* AES CTR mode(little endian version) */
|
||||
int (*decrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
|
||||
int (*decrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
|
||||
size_t, uint8_t *, size_t *);
|
||||
int (*decrypto_aes_ctr_release)(archive_crypto_ctx *);
|
||||
int (*encrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
|
||||
int (*encrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
|
||||
size_t, uint8_t *, size_t *);
|
||||
int (*encrypto_aes_ctr_release)(archive_crypto_ctx *);
|
||||
};
|
||||
|
||||
extern const struct archive_cryptor __archive_cryptor;
|
||||
|
||||
#endif
|
@ -28,7 +28,7 @@
|
||||
#include "archive_platform.h"
|
||||
|
||||
#include "archive.h"
|
||||
#include "archive_crypto_private.h"
|
||||
#include "archive_digest_private.h"
|
||||
|
||||
/* In particular, force the configure probe to break if it tries
|
||||
* to test a combination of OpenSSL and libmd. */
|
||||
@ -1216,8 +1216,8 @@ __archive_stub_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
|
||||
#endif
|
||||
|
||||
/* NOTE: Crypto functions are set based on availability and by the following
|
||||
* order of preference.
|
||||
/* NOTE: Message Digest functions are set based on availability and by the
|
||||
* following order of preference.
|
||||
* 1. libc
|
||||
* 2. libc2
|
||||
* 3. libc3
|
||||
@ -1227,7 +1227,7 @@ __archive_stub_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
* 7. libmd
|
||||
* 8. Windows API
|
||||
*/
|
||||
const struct archive_crypto __archive_crypto =
|
||||
const struct archive_digest __archive_digest =
|
||||
{
|
||||
/* MD5 */
|
||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBC)
|
||||
@ -1412,7 +1412,7 @@ const struct archive_crypto __archive_crypto =
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
|
||||
&__archive_nettle_sha512init,
|
||||
&__archive_nettle_sha512update,
|
||||
&__archive_nettle_sha512final,
|
||||
&__archive_nettle_sha512final
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
|
||||
&__archive_openssl_sha512init,
|
||||
&__archive_openssl_sha512update,
|
@ -264,11 +264,11 @@ typedef unsigned char archive_sha512_ctx;
|
||||
#define ARCHIVE_HAS_MD5
|
||||
#endif
|
||||
#define archive_md5_init(ctx)\
|
||||
__archive_crypto.md5init(ctx)
|
||||
__archive_digest.md5init(ctx)
|
||||
#define archive_md5_final(ctx, md)\
|
||||
__archive_crypto.md5final(ctx, md)
|
||||
__archive_digest.md5final(ctx, md)
|
||||
#define archive_md5_update(ctx, buf, n)\
|
||||
__archive_crypto.md5update(ctx, buf, n)
|
||||
__archive_digest.md5update(ctx, buf, n)
|
||||
|
||||
#if defined(ARCHIVE_CRYPTO_RMD160_LIBC) ||\
|
||||
defined(ARCHIVE_CRYPTO_RMD160_NETTLE) ||\
|
||||
@ -276,11 +276,11 @@ typedef unsigned char archive_sha512_ctx;
|
||||
#define ARCHIVE_HAS_RMD160
|
||||
#endif
|
||||
#define archive_rmd160_init(ctx)\
|
||||
__archive_crypto.rmd160init(ctx)
|
||||
__archive_digest.rmd160init(ctx)
|
||||
#define archive_rmd160_final(ctx, md)\
|
||||
__archive_crypto.rmd160final(ctx, md)
|
||||
__archive_digest.rmd160final(ctx, md)
|
||||
#define archive_rmd160_update(ctx, buf, n)\
|
||||
__archive_crypto.rmd160update(ctx, buf, n)
|
||||
__archive_digest.rmd160update(ctx, buf, n)
|
||||
|
||||
#if defined(ARCHIVE_CRYPTO_SHA1_LIBC) ||\
|
||||
defined(ARCHIVE_CRYPTO_SHA1_LIBMD) || \
|
||||
@ -291,11 +291,11 @@ typedef unsigned char archive_sha512_ctx;
|
||||
#define ARCHIVE_HAS_SHA1
|
||||
#endif
|
||||
#define archive_sha1_init(ctx)\
|
||||
__archive_crypto.sha1init(ctx)
|
||||
__archive_digest.sha1init(ctx)
|
||||
#define archive_sha1_final(ctx, md)\
|
||||
__archive_crypto.sha1final(ctx, md)
|
||||
__archive_digest.sha1final(ctx, md)
|
||||
#define archive_sha1_update(ctx, buf, n)\
|
||||
__archive_crypto.sha1update(ctx, buf, n)
|
||||
__archive_digest.sha1update(ctx, buf, n)
|
||||
|
||||
#if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\
|
||||
defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\
|
||||
@ -308,11 +308,11 @@ typedef unsigned char archive_sha512_ctx;
|
||||
#define ARCHIVE_HAS_SHA256
|
||||
#endif
|
||||
#define archive_sha256_init(ctx)\
|
||||
__archive_crypto.sha256init(ctx)
|
||||
__archive_digest.sha256init(ctx)
|
||||
#define archive_sha256_final(ctx, md)\
|
||||
__archive_crypto.sha256final(ctx, md)
|
||||
__archive_digest.sha256final(ctx, md)
|
||||
#define archive_sha256_update(ctx, buf, n)\
|
||||
__archive_crypto.sha256update(ctx, buf, n)
|
||||
__archive_digest.sha256update(ctx, buf, n)
|
||||
|
||||
#if defined(ARCHIVE_CRYPTO_SHA384_LIBC) ||\
|
||||
defined(ARCHIVE_CRYPTO_SHA384_LIBC2) ||\
|
||||
@ -324,11 +324,11 @@ typedef unsigned char archive_sha512_ctx;
|
||||
#define ARCHIVE_HAS_SHA384
|
||||
#endif
|
||||
#define archive_sha384_init(ctx)\
|
||||
__archive_crypto.sha384init(ctx)
|
||||
__archive_digest.sha384init(ctx)
|
||||
#define archive_sha384_final(ctx, md)\
|
||||
__archive_crypto.sha384final(ctx, md)
|
||||
__archive_digest.sha384final(ctx, md)
|
||||
#define archive_sha384_update(ctx, buf, n)\
|
||||
__archive_crypto.sha384update(ctx, buf, n)
|
||||
__archive_digest.sha384update(ctx, buf, n)
|
||||
|
||||
#if defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\
|
||||
defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\
|
||||
@ -341,14 +341,14 @@ typedef unsigned char archive_sha512_ctx;
|
||||
#define ARCHIVE_HAS_SHA512
|
||||
#endif
|
||||
#define archive_sha512_init(ctx)\
|
||||
__archive_crypto.sha512init(ctx)
|
||||
__archive_digest.sha512init(ctx)
|
||||
#define archive_sha512_final(ctx, md)\
|
||||
__archive_crypto.sha512final(ctx, md)
|
||||
__archive_digest.sha512final(ctx, md)
|
||||
#define archive_sha512_update(ctx, buf, n)\
|
||||
__archive_crypto.sha512update(ctx, buf, n)
|
||||
__archive_digest.sha512update(ctx, buf, n)
|
||||
|
||||
/* Minimal interface to crypto functionality for internal use in libarchive */
|
||||
struct archive_crypto
|
||||
/* Minimal interface to digest functionality for internal use in libarchive */
|
||||
struct archive_digest
|
||||
{
|
||||
/* Message Digest */
|
||||
int (*md5init)(archive_md5_ctx *ctx);
|
||||
@ -371,6 +371,6 @@ struct archive_crypto
|
||||
int (*sha512final)(archive_sha512_ctx *, void *);
|
||||
};
|
||||
|
||||
extern const struct archive_crypto __archive_crypto;
|
||||
extern const struct archive_digest __archive_digest;
|
||||
|
||||
#endif
|
@ -44,10 +44,16 @@
|
||||
* - Watcom C++ in C code. (For any version?)
|
||||
* - SGI MIPSpro
|
||||
* - Microsoft Visual C++ 6.0 (supposedly newer versions too)
|
||||
* - IBM VisualAge 6 (XL v6)
|
||||
* - Sun WorkShop C (SunPro) before 5.9
|
||||
*/
|
||||
#if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__)
|
||||
#define inline
|
||||
#elif defined(_MSC_VER)
|
||||
#elif defined(__IBMC__) && __IBMC__ < 700
|
||||
#define inline
|
||||
#elif defined(__SUNPRO_C) && __SUNPRO_C < 0x590
|
||||
#define inline
|
||||
#elif defined(_MSC_VER) || defined(__osf__)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
@ -58,7 +64,13 @@ archive_be16dec(const void *pp)
|
||||
{
|
||||
unsigned char const *p = (unsigned char const *)pp;
|
||||
|
||||
return ((p[0] << 8) | p[1]);
|
||||
/* Store into unsigned temporaries before left shifting, to avoid
|
||||
promotion to signed int and then left shifting into the sign bit,
|
||||
which is undefined behaviour. */
|
||||
unsigned int p1 = p[1];
|
||||
unsigned int p0 = p[0];
|
||||
|
||||
return ((p0 << 8) | p1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
@ -66,7 +78,15 @@ archive_be32dec(const void *pp)
|
||||
{
|
||||
unsigned char const *p = (unsigned char const *)pp;
|
||||
|
||||
return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
/* Store into unsigned temporaries before left shifting, to avoid
|
||||
promotion to signed int and then left shifting into the sign bit,
|
||||
which is undefined behaviour. */
|
||||
unsigned int p3 = p[3];
|
||||
unsigned int p2 = p[2];
|
||||
unsigned int p1 = p[1];
|
||||
unsigned int p0 = p[0];
|
||||
|
||||
return ((p0 << 24) | (p1 << 16) | (p2 << 8) | p3);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
@ -82,7 +102,13 @@ archive_le16dec(const void *pp)
|
||||
{
|
||||
unsigned char const *p = (unsigned char const *)pp;
|
||||
|
||||
return ((p[1] << 8) | p[0]);
|
||||
/* Store into unsigned temporaries before left shifting, to avoid
|
||||
promotion to signed int and then left shifting into the sign bit,
|
||||
which is undefined behaviour. */
|
||||
unsigned int p1 = p[1];
|
||||
unsigned int p0 = p[0];
|
||||
|
||||
return ((p1 << 8) | p0);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
@ -90,7 +116,15 @@ archive_le32dec(const void *pp)
|
||||
{
|
||||
unsigned char const *p = (unsigned char const *)pp;
|
||||
|
||||
return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
||||
/* Store into unsigned temporaries before left shifting, to avoid
|
||||
promotion to signed int and then left shifting into the sign bit,
|
||||
which is undefined behaviour. */
|
||||
unsigned int p3 = p[3];
|
||||
unsigned int p2 = p[2];
|
||||
unsigned int p1 = p[1];
|
||||
unsigned int p0 = p[0];
|
||||
|
||||
return ((p3 << 24) | (p2 << 16) | (p1 << 8) | p0);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
|
@ -131,11 +131,11 @@ be discarded in favor of the new data.
|
||||
.\" .Sh RETURN VALUES
|
||||
.\" .Sh ERRORS
|
||||
.Sh SEE ALSO
|
||||
.Xr archive 3 ,
|
||||
.Xr archive_entry_acl 3 ,
|
||||
.Xr archive_entry_paths 3 ,
|
||||
.Xr archive_entry_perms 3 ,
|
||||
.Xr archive_entry_time 3
|
||||
.Xr libarchive 3 ,
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm libarchive
|
||||
|
@ -201,6 +201,9 @@ archive_entry_clone(struct archive_entry *entry)
|
||||
entry2->ae_set = entry->ae_set;
|
||||
archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
|
||||
|
||||
/* Copy encryption status */
|
||||
entry2->encryption = entry->encryption;
|
||||
|
||||
/* Copy ACL data over. */
|
||||
archive_acl_copy(&entry2->acl, &entry->acl);
|
||||
|
||||
@ -415,6 +418,18 @@ archive_entry_gname(struct archive_entry *entry)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
archive_entry_gname_utf8(struct archive_entry *entry)
|
||||
{
|
||||
const char *p;
|
||||
if (archive_mstring_get_utf8(entry->archive, &entry->ae_gname, &p) == 0)
|
||||
return (p);
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
const wchar_t *
|
||||
archive_entry_gname_w(struct archive_entry *entry)
|
||||
{
|
||||
@ -447,6 +462,20 @@ archive_entry_hardlink(struct archive_entry *entry)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
archive_entry_hardlink_utf8(struct archive_entry *entry)
|
||||
{
|
||||
const char *p;
|
||||
if ((entry->ae_set & AE_SET_HARDLINK) == 0)
|
||||
return (NULL);
|
||||
if (archive_mstring_get_utf8(
|
||||
entry->archive, &entry->ae_hardlink, &p) == 0)
|
||||
return (p);
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const wchar_t *
|
||||
archive_entry_hardlink_w(struct archive_entry *entry)
|
||||
{
|
||||
@ -533,6 +562,18 @@ archive_entry_pathname(struct archive_entry *entry)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
archive_entry_pathname_utf8(struct archive_entry *entry)
|
||||
{
|
||||
const char *p;
|
||||
if (archive_mstring_get_utf8(
|
||||
entry->archive, &entry->ae_pathname, &p) == 0)
|
||||
return (p);
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const wchar_t *
|
||||
archive_entry_pathname_w(struct archive_entry *entry)
|
||||
{
|
||||
@ -634,6 +675,20 @@ archive_entry_symlink(struct archive_entry *entry)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
archive_entry_symlink_utf8(struct archive_entry *entry)
|
||||
{
|
||||
const char *p;
|
||||
if ((entry->ae_set & AE_SET_SYMLINK) == 0)
|
||||
return (NULL);
|
||||
if (archive_mstring_get_utf8(
|
||||
entry->archive, &entry->ae_symlink, &p) == 0)
|
||||
return (p);
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const wchar_t *
|
||||
archive_entry_symlink_w(struct archive_entry *entry)
|
||||
{
|
||||
@ -677,6 +732,17 @@ archive_entry_uname(struct archive_entry *entry)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
archive_entry_uname_utf8(struct archive_entry *entry)
|
||||
{
|
||||
const char *p;
|
||||
if (archive_mstring_get_utf8(entry->archive, &entry->ae_uname, &p) == 0)
|
||||
return (p);
|
||||
if (errno == ENOMEM)
|
||||
__archive_errx(1, "No memory");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const wchar_t *
|
||||
archive_entry_uname_w(struct archive_entry *entry)
|
||||
{
|
||||
@ -695,6 +761,24 @@ _archive_entry_uname_l(struct archive_entry *entry,
|
||||
return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
|
||||
}
|
||||
|
||||
int
|
||||
archive_entry_is_data_encrypted(struct archive_entry *entry)
|
||||
{
|
||||
return ((entry->encryption & AE_ENCRYPTION_DATA) == AE_ENCRYPTION_DATA);
|
||||
}
|
||||
|
||||
int
|
||||
archive_entry_is_metadata_encrypted(struct archive_entry *entry)
|
||||
{
|
||||
return ((entry->encryption & AE_ENCRYPTION_METADATA) == AE_ENCRYPTION_METADATA);
|
||||
}
|
||||
|
||||
int
|
||||
archive_entry_is_encrypted(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->encryption & (AE_ENCRYPTION_DATA|AE_ENCRYPTION_METADATA));
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions to set archive_entry properties.
|
||||
*/
|
||||
@ -747,6 +831,12 @@ archive_entry_set_gname(struct archive_entry *entry, const char *name)
|
||||
archive_mstring_copy_mbs(&entry->ae_gname, name);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_gname_utf8(struct archive_entry *entry, const char *name)
|
||||
{
|
||||
archive_mstring_copy_utf8(&entry->ae_gname, name);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_copy_gname(struct archive_entry *entry, const char *name)
|
||||
{
|
||||
@ -803,6 +893,16 @@ archive_entry_set_hardlink(struct archive_entry *entry, const char *target)
|
||||
entry->ae_set &= ~AE_SET_HARDLINK;
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_hardlink_utf8(struct archive_entry *entry, const char *target)
|
||||
{
|
||||
archive_mstring_copy_utf8(&entry->ae_hardlink, target);
|
||||
if (target != NULL)
|
||||
entry->ae_set |= AE_SET_HARDLINK;
|
||||
else
|
||||
entry->ae_set &= ~AE_SET_HARDLINK;
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_copy_hardlink(struct archive_entry *entry, const char *target)
|
||||
{
|
||||
@ -941,6 +1041,15 @@ archive_entry_set_link(struct archive_entry *entry, const char *target)
|
||||
archive_mstring_copy_mbs(&entry->ae_hardlink, target);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_link_utf8(struct archive_entry *entry, const char *target)
|
||||
{
|
||||
if (entry->ae_set & AE_SET_SYMLINK)
|
||||
archive_mstring_copy_utf8(&entry->ae_symlink, target);
|
||||
else
|
||||
archive_mstring_copy_utf8(&entry->ae_hardlink, target);
|
||||
}
|
||||
|
||||
/* Set symlink if symlink is already set, else set hardlink. */
|
||||
void
|
||||
archive_entry_copy_link(struct archive_entry *entry, const char *target)
|
||||
@ -1030,6 +1139,12 @@ archive_entry_set_pathname(struct archive_entry *entry, const char *name)
|
||||
archive_mstring_copy_mbs(&entry->ae_pathname, name);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_pathname_utf8(struct archive_entry *entry, const char *name)
|
||||
{
|
||||
archive_mstring_copy_utf8(&entry->ae_pathname, name);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_copy_pathname(struct archive_entry *entry, const char *name)
|
||||
{
|
||||
@ -1130,6 +1245,16 @@ archive_entry_set_symlink(struct archive_entry *entry, const char *linkname)
|
||||
entry->ae_set &= ~AE_SET_SYMLINK;
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_symlink_utf8(struct archive_entry *entry, const char *linkname)
|
||||
{
|
||||
archive_mstring_copy_utf8(&entry->ae_symlink, linkname);
|
||||
if (linkname != NULL)
|
||||
entry->ae_set |= AE_SET_SYMLINK;
|
||||
else
|
||||
entry->ae_set &= ~AE_SET_SYMLINK;
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_copy_symlink(struct archive_entry *entry, const char *linkname)
|
||||
{
|
||||
@ -1193,6 +1318,12 @@ archive_entry_set_uname(struct archive_entry *entry, const char *name)
|
||||
archive_mstring_copy_mbs(&entry->ae_uname, name);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_uname_utf8(struct archive_entry *entry, const char *name)
|
||||
{
|
||||
archive_mstring_copy_utf8(&entry->ae_uname, name);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_copy_uname(struct archive_entry *entry, const char *name)
|
||||
{
|
||||
@ -1216,6 +1347,26 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_is_data_encrypted(struct archive_entry *entry, char is_encrypted)
|
||||
{
|
||||
if (is_encrypted) {
|
||||
entry->encryption |= AE_ENCRYPTION_DATA;
|
||||
} else {
|
||||
entry->encryption &= ~AE_ENCRYPTION_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char is_encrypted)
|
||||
{
|
||||
if (is_encrypted) {
|
||||
entry->encryption |= AE_ENCRYPTION_METADATA;
|
||||
} else {
|
||||
entry->encryption &= ~AE_ENCRYPTION_METADATA;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_archive_entry_copy_uname_l(struct archive_entry *entry,
|
||||
const char *name, size_t len, struct archive_string_conv *sc)
|
||||
@ -1588,19 +1739,23 @@ ae_strtofflags(const char *s, unsigned long *setp, unsigned long *clrp)
|
||||
while (*start == '\t' || *start == ' ' || *start == ',')
|
||||
start++;
|
||||
while (*start != '\0') {
|
||||
size_t length;
|
||||
/* Locate end of token. */
|
||||
end = start;
|
||||
while (*end != '\0' && *end != '\t' &&
|
||||
*end != ' ' && *end != ',')
|
||||
end++;
|
||||
length = end - start;
|
||||
for (flag = flags; flag->name != NULL; flag++) {
|
||||
if (memcmp(start, flag->name, end - start) == 0) {
|
||||
size_t flag_length = strlen(flag->name);
|
||||
if (length == flag_length
|
||||
&& memcmp(start, flag->name, length) == 0) {
|
||||
/* Matched "noXXXX", so reverse the sense. */
|
||||
clear |= flag->set;
|
||||
set |= flag->clear;
|
||||
break;
|
||||
} else if (memcmp(start, flag->name + 2, end - start)
|
||||
== 0) {
|
||||
} else if (length == flag_length - 2
|
||||
&& memcmp(start, flag->name + 2, length) == 0) {
|
||||
/* Matched "XXXX", so don't reverse. */
|
||||
set |= flag->set;
|
||||
clear |= flag->clear;
|
||||
@ -1652,19 +1807,23 @@ ae_wcstofflags(const wchar_t *s, unsigned long *setp, unsigned long *clrp)
|
||||
while (*start == L'\t' || *start == L' ' || *start == L',')
|
||||
start++;
|
||||
while (*start != L'\0') {
|
||||
size_t length;
|
||||
/* Locate end of token. */
|
||||
end = start;
|
||||
while (*end != L'\0' && *end != L'\t' &&
|
||||
*end != L' ' && *end != L',')
|
||||
end++;
|
||||
length = end - start;
|
||||
for (flag = flags; flag->wname != NULL; flag++) {
|
||||
if (wmemcmp(start, flag->wname, end - start) == 0) {
|
||||
size_t flag_length = wcslen(flag->wname);
|
||||
if (length == flag_length
|
||||
&& wmemcmp(start, flag->wname, length) == 0) {
|
||||
/* Matched "noXXXX", so reverse the sense. */
|
||||
clear |= flag->set;
|
||||
set |= flag->clear;
|
||||
break;
|
||||
} else if (wmemcmp(start, flag->wname + 2, end - start)
|
||||
== 0) {
|
||||
} else if (length == flag_length - 2
|
||||
&& wmemcmp(start, flag->wname + 2, length) == 0) {
|
||||
/* Matched "XXXX", so don't reverse. */
|
||||
set |= flag->set;
|
||||
clear |= flag->clear;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define ARCHIVE_ENTRY_H_INCLUDED
|
||||
|
||||
/* Note: Compiler will complain if this does not match archive.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3001002
|
||||
#define ARCHIVE_VERSION_NUMBER 3002000
|
||||
|
||||
/*
|
||||
* Note: archive_entry.h is for use outside of libarchive; the
|
||||
@ -48,14 +48,20 @@
|
||||
#endif
|
||||
|
||||
/* Get a suitable 64-bit integer type. */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# define __LA_INT64_T __int64
|
||||
#else
|
||||
#include <unistd.h>
|
||||
# if defined(_SCO_DS)
|
||||
# define __LA_INT64_T long long
|
||||
#if !defined(__LA_INT64_T_DEFINED)
|
||||
# if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
#define __LA_INT64_T la_int64_t
|
||||
# endif
|
||||
#define __LA_INT64_T_DEFINED
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||
typedef __int64 la_int64_t;
|
||||
# else
|
||||
# define __LA_INT64_T int64_t
|
||||
#include <unistd.h>
|
||||
# if defined(_SCO_DS) || defined(__osf__)
|
||||
typedef long long la_int64_t;
|
||||
# else
|
||||
typedef int64_t la_int64_t;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -63,12 +69,17 @@
|
||||
#if ARCHIVE_VERSION_NUMBER >= 3999000
|
||||
/* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */
|
||||
# define __LA_MODE_T int
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__)
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
|
||||
# define __LA_MODE_T unsigned short
|
||||
#else
|
||||
# define __LA_MODE_T mode_t
|
||||
#endif
|
||||
|
||||
/* Large file support for Android */
|
||||
#ifdef __ANDROID__
|
||||
#include "android_lf.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* On Windows, define LIBARCHIVE_STATIC if you're building or using a
|
||||
* .lib. The default here assumes you're building a DLL. Only
|
||||
@ -206,13 +217,15 @@ __LA_DECL void archive_entry_fflags(struct archive_entry *,
|
||||
unsigned long * /* set */,
|
||||
unsigned long * /* clear */);
|
||||
__LA_DECL const char *archive_entry_fflags_text(struct archive_entry *);
|
||||
__LA_DECL __LA_INT64_T archive_entry_gid(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_gid(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_gname(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_gname_utf8(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
|
||||
__LA_DECL __LA_INT64_T archive_entry_ino(struct archive_entry *);
|
||||
__LA_DECL __LA_INT64_T archive_entry_ino64(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_ino(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_ino_is_set(struct archive_entry *);
|
||||
__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);
|
||||
__LA_DECL time_t archive_entry_mtime(struct archive_entry *);
|
||||
@ -220,6 +233,7 @@ __LA_DECL long archive_entry_mtime_nsec(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_mtime_is_set(struct archive_entry *);
|
||||
__LA_DECL unsigned int archive_entry_nlink(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_pathname(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_pathname_utf8(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
|
||||
__LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
|
||||
@ -227,14 +241,19 @@ __LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);
|
||||
__LA_DECL __LA_INT64_T archive_entry_size(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_size(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_size_is_set(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_strmode(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_symlink(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);
|
||||
__LA_DECL __LA_INT64_T archive_entry_uid(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_uid(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_uname(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_uname_utf8(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
|
||||
|
||||
/*
|
||||
* Set fields in an archive_entry.
|
||||
@ -266,18 +285,21 @@ __LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *,
|
||||
const char *);
|
||||
__LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
|
||||
const wchar_t *);
|
||||
__LA_DECL void archive_entry_set_gid(struct archive_entry *, __LA_INT64_T);
|
||||
__LA_DECL void archive_entry_set_gid(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_set_gname(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_gname_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_gname(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_hardlink_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_ino(struct archive_entry *, __LA_INT64_T);
|
||||
__LA_DECL void archive_entry_set_ino64(struct archive_entry *, __LA_INT64_T);
|
||||
__LA_DECL void archive_entry_set_ino(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_set_ino64(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_link_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *);
|
||||
@ -286,6 +308,7 @@ __LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);
|
||||
__LA_DECL void archive_entry_unset_mtime(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);
|
||||
__LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_pathname_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *);
|
||||
@ -293,19 +316,23 @@ __LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
|
||||
__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_size(struct archive_entry *, __LA_INT64_T);
|
||||
__LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_unset_size(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_symlink_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_uid(struct archive_entry *, __LA_INT64_T);
|
||||
__LA_DECL void archive_entry_set_uid(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_uname_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);
|
||||
__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);
|
||||
/*
|
||||
* Routines to bulk copy fields to/from a platform-native "struct
|
||||
* stat." Libarchive used to just store a struct stat inside of each
|
||||
@ -514,7 +541,7 @@ __LA_DECL int archive_entry_xattr_next(struct archive_entry *,
|
||||
|
||||
__LA_DECL void archive_entry_sparse_clear(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *,
|
||||
__LA_INT64_T /* offset */, __LA_INT64_T /* length */);
|
||||
la_int64_t /* offset */, la_int64_t /* length */);
|
||||
|
||||
/*
|
||||
* To retrieve the xattr list, first "reset", then repeatedly ask for the
|
||||
@ -524,7 +551,7 @@ __LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *,
|
||||
__LA_DECL int archive_entry_sparse_count(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_sparse_reset(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_sparse_next(struct archive_entry *,
|
||||
__LA_INT64_T * /* offset */, __LA_INT64_T * /* length */);
|
||||
la_int64_t * /* offset */, la_int64_t * /* length */);
|
||||
|
||||
/*
|
||||
* Utility to match up hardlinks.
|
||||
|
@ -226,8 +226,8 @@ The returned long string is valid until the next call to
|
||||
or
|
||||
.Fn archive_entry_acl_text_w .
|
||||
.Sh SEE ALSO
|
||||
.Xr archive 3 ,
|
||||
.Xr archive_entry 3
|
||||
.Xr libarchive 3 ,
|
||||
.Sh BUGS
|
||||
.Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID
|
||||
and
|
||||
|
@ -44,6 +44,10 @@ archive_entry_copy_stat(struct archive_entry *entry, const struct stat *st)
|
||||
archive_entry_set_atime(entry, st->st_atime, st->st_atim.tv_nsec);
|
||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctim.tv_nsec);
|
||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtim.tv_nsec);
|
||||
#elif HAVE_STRUCT_STAT_ST_MTIME_NSEC
|
||||
archive_entry_set_atime(entry, st->st_atime, st->st_atime_nsec);
|
||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_nsec);
|
||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_nsec);
|
||||
#elif HAVE_STRUCT_STAT_ST_MTIME_N
|
||||
archive_entry_set_atime(entry, st->st_atime, st->st_atime_n);
|
||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_n);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user