diff options
author | adam <adam@pkgsrc.org> | 2015-01-17 12:48:19 +0000 |
---|---|---|
committer | adam <adam@pkgsrc.org> | 2015-01-17 12:48:19 +0000 |
commit | d905234c3b61b40558f4652383865d7a730028db (patch) | |
tree | 5dae7f9c514ff70dc47a77fdefca4ed2c2617399 /archivers | |
parent | 5b4d241e09ad30ecc3895c72048a0e6a3d645b72 (diff) | |
download | pkgsrc-d905234c3b61b40558f4652383865d7a730028db.tar.gz |
Removed extra files
Diffstat (limited to 'archivers')
73 files changed, 0 insertions, 18475 deletions
diff --git a/archivers/libarchive/files/build/cmake/AddTest28.cmake b/archivers/libarchive/files/build/cmake/AddTest28.cmake deleted file mode 100644 index ab26a9a9b8b..00000000000 --- a/archivers/libarchive/files/build/cmake/AddTest28.cmake +++ /dev/null @@ -1,107 +0,0 @@ -# - Macro approximating the CMake 2.8 ADD_TEST(NAME) signature. -# ADD_TEST_28(NAME <name> COMMAND <command> [arg1 [arg2 ...]]) -# <name> - The name of the test -# <command> - The test executable -# [argN...] - Arguments to the test executable -# This macro approximates the ADD_TEST(NAME) signature provided in -# CMake 2.8 but works with CMake 2.6 too. See CMake 2.8 documentation -# of ADD_TEST()for details. -# -# This macro automatically replaces a <command> that names an -# executable target with the target location. A generator expression -# of the form "$<TARGET_FILE:tgt>" is supported in both the command -# and arguments of the test. Howerver, this macro only works for -# targets without per-config output name properties set. -# -# Example usage: -# add_test(NAME mytest COMMAND testDriver --exe $<TARGET_FILE:myexe>) -# This creates a test "mytest" whose command runs a testDriver tool -# passing the full path to the executable file produced by target -# "myexe". - -#============================================================================= -# Copyright 2009 Kitware, Inc. -# 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 -# in this position and unchanged. -# 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. -#============================================================================= - -CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3) - -# CMake 2.8 supports ADD_TEST(NAME) natively. -IF(NOT "${CMAKE_VERSION}" VERSION_LESS "2.8") - MACRO(ADD_TEST_28) - ADD_TEST(${ARGV}) - ENDMACRO() - RETURN() -ENDIF() - -# Simulate ADD_TEST(NAME) signature from CMake 2.8. -MACRO(ADD_TEST_28 NAME name COMMAND command) - # Enforce the signature. - IF(NOT "x${NAME}" STREQUAL "xNAME") - MESSAGE(FATAL_ERROR "First ADD_TEST_28 argument must be \"NAME\"") - ENDIF() - IF(NOT "x${COMMAND}" STREQUAL "xCOMMAND") - MESSAGE(FATAL_ERROR "Third ADD_TEST_28 argument must be \"COMMAND\"") - ENDIF() - - # Perform "COMMAND myexe ..." substitution. - SET(cmd "${command}") - IF(TARGET "${cmd}") - _ADD_TEST_28_GET_EXE(${cmd} cmd) - ENDIF() - - # Perform "COMMAND ... $<TARGET_FILE:myexe> ..." substitution. - SET(target_file "\\$<TARGET_FILE:(.+)>") - SET(args) - FOREACH(ARG ${cmd} ${ARGN}) - SET(arg "${ARG}") - IF("${arg}" MATCHES "${target_file}") - STRING(REGEX REPLACE "${target_file}" "\\1" tgt "${arg}") - IF(TARGET "${tgt}") - _ADD_TEST_28_GET_EXE(${tgt} exe) - STRING(REGEX REPLACE "${target_file}" "${exe}" arg "${arg}") - ENDIF() - ENDIF() - LIST(APPEND args "${arg}") - ENDFOREACH() - - # Invoke old ADD_TEST() signature with transformed arguments. - ADD_TEST(${name} ${args}) -ENDMACRO() - -# Get the test-time location of an executable target. -MACRO(_ADD_TEST_28_GET_EXE tgt exe_var) - # The LOCATION property gives a build-time location. - GET_TARGET_PROPERTY(${exe_var} ${tgt} LOCATION) - - # In single-configuration generatrs the build-time and test-time - # locations are the same because there is no per-config variable - # reference. In multi-configuration generators the following - # substitution converts the build-time configuration variable - # reference to a test-time configuration variable reference. - IF(CMAKE_CONFIGURATION_TYPES) - STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CTEST_CONFIGURATION_TYPE}" - ${exe_var} "${${exe_var}}") - ENDIF(CMAKE_CONFIGURATION_TYPES) -ENDMACRO() diff --git a/archivers/libarchive/files/build/windows/mvcpp.nt b/archivers/libarchive/files/build/windows/mvcpp.nt deleted file mode 100644 index 811996d8bb5..00000000000 --- a/archivers/libarchive/files/build/windows/mvcpp.nt +++ /dev/null @@ -1,122 +0,0 @@ -#/* FILE: mvcpp.nt
-# *
-# * Copyright (c) 2008
-# * TouchNet Information Systems, Inc.
-# * All Rights Reserved
-# *
-# * This program is an unpublished copyright work of TouchNet Information
-# * Systems, Inc. of Lenexa, KS. The program, all information disclosed
-# * and the matter shown and described hereon or herewith are confidential
-# * and proprietary to TouchNet Information Systems, Inc.
-# *
-# ******************************************************************************
-# *
-# * $LastChangedBy: kientzle $
-# * $Locker: $
-# * $ProjectName: $
-# * $ProjectRevision: $
-# * $LastChangedRevision: 29 $
-# * $LastChangedDate: 2008-05-06 00:10:33 +0200 (Tue, 06 May 2008) $
-# * $State: Exp $
-# * $RCSfile: mvcpp.nt,v $
-# * $Source: /cvsroot/pkgsrc/archivers/libarchive/files/build/windows/Attic/mvcpp.nt,v $
-# *
-# * Change Log:
-# * $Log: mvcpp.nt,v $ -# * Revision 1.1.1.4 2010/07/09 11:53:09 joerg -# * Import libarchive-2.8.4: -# * - Improved reliability of hash function detection -# * - Fix issues on ancient FreeBSD, QNX, ancient NetBSD and Minix -# *
-# *
-# */
-
-.SUFFIXES : .c .cpp .obm
-
-ZLIB_INCL=\3rdParty\ZLib\Current\Include
-
-EXTRA_DEFINES=/DLIBARCHIVE_STATIC=1
-
-!ifdef DEBUG
-DEST_PATH=.\lib\mvcpp\debug
-OBJ_DIR=obj\debug
-COMPILE_FLAG=/MTd /DDEBUG=1 $(EXTRA_DEFINES) /Zi /Fd$(OBJ_DIR)\libarchive.pdb
-!else
-DEST_PATH=.\lib\mvcpp
-OBJ_DIR=obj
-COMPILE_FLAG=/MT $(EXTRA_DEFINES) /Fd$(OBJ_DIR)\libarchive.pdb
-!endif
-
-INCLUDE=.;$(MSDEVDIR)\INCLUDE;$(ZLIB_INCL);
-INCLUDE_OPTS=
-
-NT_CPP=cl
-NT_C=cl
-NT_LIBRARIAN=lib
-
-###
-NT_C_OPTS=$(COMPILE_FLAG) /GX /Zl /Zp1 /nologo /c /G5 /Oi /Ot /TC /DVC_EXTRANLEAN /DWIN32_LEAN_AND_MEAN $(INCLUDE_OPTS)
-NT_CPP_OPTS=$(COMPILE_FLAG) /GX /Zl /Zp1 /nologo /c /G5 /Oi /Ot /TP /DVC_EXTRANLEAN /DWIN32_LEAN_AND_MEAN $(INCLUDE_OPTS)
-NT_LIB_OPTS=
-
-.cpp{$(OBJ_DIR)}.obm:
- -md $(OBJ_DIR) > nul 2>nul
- $(NT_CPP) $(NT_CPP_OPTS) -Fo$*.obm $<
-
-.c{$(OBJ_DIR)}.obm:
- -md $(OBJ_DIR) > nul 2>nul
- $(NT_C) $(NT_C_OPTS) -Fo$*.obm $<
-
-
-OBJS=\
- $(OBJ_DIR)\archive_check_magic.obm $(OBJ_DIR)\archive_entry.obm \
- $(OBJ_DIR)\archive_entry_copy_stat.obm $(OBJ_DIR)\archive_entry_link_resolver.obm \
- $(OBJ_DIR)\archive_entry_stat.obm $(OBJ_DIR)\archive_entry_strmode.obm \
- $(OBJ_DIR)\archive_read.obm $(OBJ_DIR)\archive_read_data_into_fd.obm \
- $(OBJ_DIR)\archive_read_extract.obm $(OBJ_DIR)\archive_read_open_fd.obm \
- $(OBJ_DIR)\archive_read_open_file.obm $(OBJ_DIR)\archive_read_open_filename.obm \
- $(OBJ_DIR)\archive_read_open_memory.obm $(OBJ_DIR)\archive_read_support_compression_all.obm \
- $(OBJ_DIR)\archive_read_support_compression_bzip2.obm \
- $(OBJ_DIR)\archive_read_support_compression_compress.obm \
- $(OBJ_DIR)\archive_read_support_compression_gzip.obm \
- $(OBJ_DIR)\archive_read_support_compression_none.obm \
- $(OBJ_DIR)\archive_read_support_compression_program.obm \
- $(OBJ_DIR)\archive_read_support_format_all.obm \
- $(OBJ_DIR)\archive_read_support_format_ar.obm \
- $(OBJ_DIR)\archive_read_support_format_cpio.obm \
- $(OBJ_DIR)\archive_read_support_format_empty.obm \
- $(OBJ_DIR)\archive_read_support_format_iso9660.obm \
- $(OBJ_DIR)\archive_read_support_format_mtree.obm \
- $(OBJ_DIR)\archive_read_support_format_tar.obm \
- $(OBJ_DIR)\archive_read_support_format_zip.obm \
- $(OBJ_DIR)\archive_string.obm $(OBJ_DIR)\archive_string_sprintf.obm \
- $(OBJ_DIR)\archive_util.obm $(OBJ_DIR)\archive_virtual.obm \
- $(OBJ_DIR)\archive_write.obm $(OBJ_DIR)\archive_write_disk.obm \
- $(OBJ_DIR)\archive_write_disk_set_standard_lookup.obm \
- $(OBJ_DIR)\archive_write_open_fd.obm $(OBJ_DIR)\archive_write_open_file.obm \
- $(OBJ_DIR)\archive_write_open_filename.obm $(OBJ_DIR)\archive_write_open_memory.obm \
- $(OBJ_DIR)\archive_write_set_compression_bzip2.obm $(OBJ_DIR)\archive_write_set_compression_compress.obm \
- $(OBJ_DIR)\archive_write_set_compression_gzip.obm $(OBJ_DIR)\archive_write_set_compression_none.obm \
- $(OBJ_DIR)\archive_write_set_compression_program.obm $(OBJ_DIR)\archive_write_set_format.obm \
- $(OBJ_DIR)\archive_write_set_format_ar.obm $(OBJ_DIR)\archive_write_set_format_by_name.obm \
- $(OBJ_DIR)\archive_write_set_format_cpio.obm $(OBJ_DIR)\archive_write_set_format_cpio_newc.obm \
- $(OBJ_DIR)\archive_write_set_format_pax.obm $(OBJ_DIR)\archive_write_set_format_shar.obm \
- $(OBJ_DIR)\archive_write_set_format_ustar.obm $(OBJ_DIR)\filter_fork.obm \
- $(OBJ_DIR)\libarchive-nonposix.obm
-
-all: CLEAN $(DEST_PATH)\libarchive.lib
-
-$(DEST_PATH)\libarchive.lib :: $(OBJS) $(DEST_PATH)
-
-$(DEST_PATH)\libarchive.lib ::
- $(NT_LIBRARIAN) $(NT_LIB_OPTS) /OUT:$(DEST_PATH)\libarchive.lib $(OBJS)
-
-$(DEST_PATH):
- -md $(DEST_PATH) > nul 2>nul
-
-CLEAN:
-!ifdef CLEAN
- -del $(OBJ_DIR)\*.pd? > nul 2>nul
- -ren $(OBJ_DIR)\*.pdb *.pd1 > nul 2>nul
- -ren $(OBJ_DIR)\*.pdb *.pd2 > nul 2>nul
-!endif
diff --git a/archivers/libarchive/files/build/windows/vc71/libarchive.sln b/archivers/libarchive/files/build/windows/vc71/libarchive.sln deleted file mode 100644 index aa73e659ed0..00000000000 --- a/archivers/libarchive/files/build/windows/vc71/libarchive.sln +++ /dev/null @@ -1,23 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libarchive", "libarchive.vcproj", "{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectDependencies) = postSolution
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Debug.ActiveCfg = Debug|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Debug.Build.0 = Debug|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Release.ActiveCfg = Release|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
diff --git a/archivers/libarchive/files/build/windows/vc71/libarchive.vcproj b/archivers/libarchive/files/build/windows/vc71/libarchive.vcproj deleted file mode 100644 index 31505faa0e4..00000000000 --- a/archivers/libarchive/files/build/windows/vc71/libarchive.vcproj +++ /dev/null @@ -1,327 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="libarchive"
- ProjectGUID="{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;PLATFORM_CONFIG_H="\"config_windows.h\"""
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="../../lib/$(ProjectName)-vc71-mt-d.lib"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="4"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;PLATFORM_CONFIG_H="\"config_windows.h\"""
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLibrarianTool"
- OutputFile="../../lib/$(ProjectName)-vc71-mt.lib"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
- <File
- RelativePath="..\..\libarchive\archive_check_magic.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_copy_stat.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_link_resolver.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_stat.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_strmode.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_data_into_fd.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk_set_standard_lookup.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_extract.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_fd.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_file.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_filename.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_memory.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_all.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_bzip2.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_compress.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_gzip.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_lzma.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_none.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_program.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_all.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_ar.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_cpio.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_empty.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_iso9660.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_mtree.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_tar.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_zip.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string_sprintf.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_util.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_virtual.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_windows.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk_set_standard_lookup.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_fd.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_file.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_filename.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_memory.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_bzip2.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_compress.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_gzip.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_none.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_program.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_ar.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_by_name.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_cpio.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_cpio_newc.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_mtree.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_pax.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_shar.c">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_ustar.c">
- </File>
- <File
- RelativePath="..\..\libarchive\filter_fork.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
- <File
- RelativePath="..\..\libarchive\archive.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_endian.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_private.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_platform.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_private.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk_private.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_private.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_windows.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk_private.h">
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_private.h">
- </File>
- <File
- RelativePath="..\..\libarchive\config_windows.h">
- </File>
- <File
- RelativePath="..\..\libarchive\filter_fork.h">
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/archivers/libarchive/files/build/windows/vc80/libarchive.sln b/archivers/libarchive/files/build/windows/vc80/libarchive.sln deleted file mode 100644 index f1d4331ec4f..00000000000 --- a/archivers/libarchive/files/build/windows/vc80/libarchive.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libarchive", "libarchive.vcproj", "{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libarchive_test", "libarchive_test\libarchive_test.vcproj", "{407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Debug|Win32.ActiveCfg = Debug|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Debug|Win32.Build.0 = Debug|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Release|Win32.ActiveCfg = Release|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Release|Win32.Build.0 = Release|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Debug|Win32.ActiveCfg = Debug|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Debug|Win32.Build.0 = Debug|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Release|Win32.ActiveCfg = Release|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/archivers/libarchive/files/build/windows/vc80/libarchive.vcproj b/archivers/libarchive/files/build/windows/vc80/libarchive.vcproj deleted file mode 100644 index 376af77bd4e..00000000000 --- a/archivers/libarchive/files/build/windows/vc80/libarchive.vcproj +++ /dev/null @@ -1,455 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="libarchive"
- ProjectGUID="{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
- RootNamespace="libarchive"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;PLATFORM_CONFIG_H="\"config_windows.h\"";LIBARCHIVE_STATIC"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="../../lib/$(ProjectName)-vc80-mt-d.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;PLATFORM_CONFIG_H="\"config_windows.h\"";LIBARCHIVE_STATIC"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="../../lib/$(ProjectName)-vc80-mt.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\libarchive\archive_check_magic.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_copy_stat.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_link_resolver.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_stat.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_strmode.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_data_into_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk_set_standard_lookup.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_extract.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_file.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_filename.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_memory.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_all.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_bzip2.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_compress.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_lzma.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_none.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_program.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_all.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_cpio.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_iso9660.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_mtree.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_tar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_zip.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string_sprintf.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_util.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_virtual.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_windows.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk_set_standard_lookup.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_file.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_filename.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_memory.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_bzip2.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_compress.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_none.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_program.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_by_name.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_cpio.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_cpio_newc.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_mtree.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_pax.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_shar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_ustar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\filter_fork.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\libarchive\archive.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_endian.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_platform.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_windows.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\config_windows.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\filter_fork.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/archivers/libarchive/files/build/windows/vc80/libarchive_test/libarchive_test.vcproj b/archivers/libarchive/files/build/windows/vc80/libarchive_test/libarchive_test.vcproj deleted file mode 100644 index 02a2a8fb136..00000000000 --- a/archivers/libarchive/files/build/windows/vc80/libarchive_test/libarchive_test.vcproj +++ /dev/null @@ -1,495 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="libarchive_test"
- ProjectGUID="{407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}"
- RootNamespace="libarchive_test"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..\libarchive"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;LIBARCHIVE_STATIC"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- CompileAs="1"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- ShowProgress="0"
- OutputFile="..\..\..\$(ProjectName).exe"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- EmbedManifest="true"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\..\libarchive"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;LIBARCHIVE_STATIC"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- CompileAs="1"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="..\..\..\$(ProjectName).exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- <ProjectReference
- ReferencedProjectIdentifier="{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
- CopyLocal="false"
- CopyLocalDependencies="false"
- CopyLocalSatelliteAssemblies="false"
- RelativePathToProject=".\libarchive.vcproj"
- />
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\..\libarchive\test\main.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\read_open_memory.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_acl_basic.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_acl_freebsd.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_acl_pax.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_archive_api_feature.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_bad_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_bzip2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_gtar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_tar_hardlink.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_zip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_empty_write.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_entry.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_entry_strmode.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_fuzz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_link_resolver.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_pax_filename_encoding.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_compress_program.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_data_large.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_extract.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin_bz2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin_gz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin_Z.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_odc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_svr4_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_svr4c_Z.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_gtar_gz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_gtar_lzma.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_gtar_sparse.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_iso_gz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_isorr_bz2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_mtree.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_pax_bz2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tar_empty_filename.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tbz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tgz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_zip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_large.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_pax_truncated.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_position.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_truncated.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_tar_filenames.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_tar_large.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_ustar_filenames.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_compress.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_compress_program.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_hardlink.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_perms.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_secure.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_times.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio_newc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio_odc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_pax.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_shar_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_tar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_tar_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_tar_ustar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_open_memory.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\..\libarchive\test\list.h"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/archivers/libarchive/files/build/windows/vc90/libarchive.sln b/archivers/libarchive/files/build/windows/vc90/libarchive.sln deleted file mode 100644 index c3e69c81137..00000000000 --- a/archivers/libarchive/files/build/windows/vc90/libarchive.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libarchive", "libarchive.vcproj", "{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libarchive_test", "libarchive_test\libarchive_test.vcproj", "{407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Debug|Win32.ActiveCfg = Debug|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Debug|Win32.Build.0 = Debug|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Release|Win32.ActiveCfg = Release|Win32
- {0C758FDB-BE1D-47E9-8E18-9168AB34A308}.Release|Win32.Build.0 = Release|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Debug|Win32.ActiveCfg = Debug|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Debug|Win32.Build.0 = Debug|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Release|Win32.ActiveCfg = Release|Win32
- {407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/archivers/libarchive/files/build/windows/vc90/libarchive.vcproj b/archivers/libarchive/files/build/windows/vc90/libarchive.vcproj deleted file mode 100644 index 6a5499eb098..00000000000 --- a/archivers/libarchive/files/build/windows/vc90/libarchive.vcproj +++ /dev/null @@ -1,456 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="libarchive"
- ProjectGUID="{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
- RootNamespace="libarchive"
- Keyword="Win32Proj"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;PLATFORM_CONFIG_H="\"config_windows.h\"""
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="../../lib/$(ProjectName)-vc90-mt-d.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;PLATFORM_CONFIG_H="\"config_windows.h\"""
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="../../lib/$(ProjectName)-vc90-mt.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\libarchive\archive_check_magic.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_copy_stat.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_link_resolver.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_stat.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_strmode.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_data_into_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk_set_standard_lookup.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_extract.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_file.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_filename.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_open_memory.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_all.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_bzip2.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_compress.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_lzma.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_none.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_compression_program.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_all.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_cpio.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_iso9660.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_mtree.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_tar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_support_format_zip.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string_sprintf.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_util.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_virtual.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_windows.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk_set_standard_lookup.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_file.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_filename.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_open_memory.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_bzip2.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_compress.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_none.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_compression_program.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_by_name.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_cpio.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_cpio_newc.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_mtree.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_pax.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_shar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_set_format_ustar.c"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\filter_fork.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\libarchive\archive.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_endian.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_entry_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_platform.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_disk_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_read_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_string.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_windows.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_disk_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\archive_write_private.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\config_windows.h"
- >
- </File>
- <File
- RelativePath="..\..\libarchive\filter_fork.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/archivers/libarchive/files/build/windows/vc90/libarchive_test/libarchive_test.vcproj b/archivers/libarchive/files/build/windows/vc90/libarchive_test/libarchive_test.vcproj deleted file mode 100644 index 5164820eb55..00000000000 --- a/archivers/libarchive/files/build/windows/vc90/libarchive_test/libarchive_test.vcproj +++ /dev/null @@ -1,494 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="libarchive_test"
- ProjectGUID="{407CA0B9-0CCB-4F02-A20B-CBBAEAAA2E4B}"
- RootNamespace="libarchive_test"
- Keyword="Win32Proj"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..\libarchive"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;LIBARCHIVE_STATIC"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- CompileAs="1"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- ShowProgress="0"
- OutputFile="..\..\..\$(ProjectName).exe"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- EmbedManifest="true"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\..\libarchive"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;LIBARCHIVE_STATIC"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- CompileAs="1"
- DisableSpecificWarnings="4996"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="..\..\..\$(ProjectName).exe"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- <ProjectReference
- ReferencedProjectIdentifier="{0C758FDB-BE1D-47E9-8E18-9168AB34A308}"
- CopyLocal="false"
- CopyLocalDependencies="false"
- CopyLocalSatelliteAssemblies="false"
- RelativePathToProject=".\libarchive.vcproj"
- />
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\..\libarchive\test\main.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\read_open_memory.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_acl_basic.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_acl_freebsd.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_acl_pax.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_archive_api_feature.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_bad_fd.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_bzip2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_gtar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_tar_hardlink.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_compat_zip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_empty_write.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_entry.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_entry_strmode.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_fuzz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_link_resolver.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_pax_filename_encoding.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_compress_program.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_data_large.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_extract.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin_bz2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin_gz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_bin_Z.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_odc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_svr4_gzip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_cpio_svr4c_Z.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_gtar_gz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_gtar_lzma.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_gtar_sparse.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_iso_gz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_isorr_bz2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_mtree.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_pax_bz2.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tar_empty_filename.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tbz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tgz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_tz.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_format_zip.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_large.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_pax_truncated.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_position.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_read_truncated.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_tar_filenames.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_tar_large.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_ustar_filenames.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_compress.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_compress_program.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_hardlink.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_perms.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_secure.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_disk_times.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_ar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio_newc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_cpio_odc.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_pax.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_shar_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_tar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_tar_empty.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_format_tar_ustar.c"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test_write_open_memory.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\..\libarchive\test\list.h"
- >
- </File>
- <File
- RelativePath="..\..\..\libarchive\test\test.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/archivers/libarchive/files/build/windows/wccpp.nt b/archivers/libarchive/files/build/windows/wccpp.nt deleted file mode 100644 index 7a6be664150..00000000000 --- a/archivers/libarchive/files/build/windows/wccpp.nt +++ /dev/null @@ -1,112 +0,0 @@ -#/* FILE: wccpp.nt
-# *
-# * Copyright (c) 2008
-# * TouchNet Information Systems, Inc.
-# * All Rights Reserved
-# *
-# * This program is an unpublished copyright work of TouchNet Information
-# * Systems, Inc. of Lenexa, KS. The program, all information disclosed
-# * and the matter shown and described hereon or herewith are confidential
-# * and proprietary to TouchNet Information Systems, Inc.
-# *
-# ******************************************************************************
-# *
-# * $LastChangedBy: kientzle $
-# * $Locker: $
-# * $ProjectName: $
-# * $ProjectRevision: $
-# * $LastChangedRevision: 29 $
-# * $LastChangedDate: 2008-05-06 00:10:33 +0200 (Tue, 06 May 2008) $
-# * $State: Exp $
-# * $RCSfile: wccpp.nt,v $
-# * $Source: /cvsroot/pkgsrc/archivers/libarchive/files/build/windows/Attic/wccpp.nt,v $
-# *
-# * Change Log:
-# * $Log: wccpp.nt,v $ -# * Revision 1.1.1.4 2010/07/09 11:53:09 joerg -# * Import libarchive-2.8.4: -# * - Improved reliability of hash function detection -# * - Fix issues on ancient FreeBSD, QNX, ancient NetBSD and Minix -# *
-# *
-# */
-
-.EXTENSIONS:
-.EXTENSIONS: .obn .cpp .c
-
-ZLIB_INCL=\3rdParty\ZLib\Current\Include
-
-!ifdef DEBUG
-DEST_PATH=.\lib\wccpp\debug
-OBJ_DIR=obj\debug
-EXT_COMPILE_FLAG=-d2 -DLIBARCHIVE_STATIC=1
-!else
-DEST_PATH=.\lib\wccpp
-OBJ_DIR=obj
-EXT_COMPILE_FLAG=-DLIBARCHIVE_STATIC=1
-!endif
-
-# ----- NT compiler options -----------------------------------------------
-NT_CPP=wpp386
-NT_C=wcc386
-NT_LIBRARIAN=wlib
-
-
-###
-INCLUDE_OPTS=/I.;$(%watcom)\h;$(%watcom)\h\nt;$(ZLIB_INCL);
-NT_CPP_OPTS=-ei -wx -xs -xss -xst -od -of+ -zp1 -5 -bt=nt -bm $(EXT_COMPILE_FLAG) $(INCLUDE_OPTS) -DWIN32_LEAN_AND_MEAN
-NT_C_OPTS=-ei -wx -od -of+ -zp1 -5 -bt=nt -bm $(EXT_COMPILE_FLAG) $(INCLUDE_OPTS) -DWIN32_LEAN_AND_MEAN
-NT_LIB_OPTS=
-
-.cpp{$(OBJ_DIR)}.obn:
- -md $(OBJ_DIR) > nul 2>nul
- $(NT_CPP) $(NT_CPP_OPTS) -zp1 -fo=$*.obn $<
-
-.c{$(OBJ_DIR)}.obn:
- -md $(OBJ_DIR) > nul 2>nul
- $(NT_C) $(NT_C_OPTS) -zp1 -fo=$*.obn $<
-
-OBJS = &
- $(OBJ_DIR)\archive_check_magic.obn $(OBJ_DIR)\archive_entry.obn &
- $(OBJ_DIR)\archive_entry_copy_stat.obn $(OBJ_DIR)\archive_entry_link_resolver.obn &
- $(OBJ_DIR)\archive_entry_stat.obn $(OBJ_DIR)\archive_entry_strmode.obn &
- $(OBJ_DIR)\archive_read.obn $(OBJ_DIR)\archive_read_data_into_fd.obn &
- $(OBJ_DIR)\archive_read_extract.obn $(OBJ_DIR)\archive_read_open_fd.obn &
- $(OBJ_DIR)\archive_read_open_file.obn $(OBJ_DIR)\archive_read_open_filename.obn &
- $(OBJ_DIR)\archive_read_open_memory.obn $(OBJ_DIR)\archive_read_support_compression_all.obn &
- $(OBJ_DIR)\archive_read_support_compression_bzip2.obn &
- $(OBJ_DIR)\archive_read_support_compression_compress.obn &
- $(OBJ_DIR)\archive_read_support_compression_gzip.obn &
- $(OBJ_DIR)\archive_read_support_compression_none.obn &
- $(OBJ_DIR)\archive_read_support_compression_program.obn &
- $(OBJ_DIR)\archive_read_support_format_all.obn &
- $(OBJ_DIR)\archive_read_support_format_ar.obn &
- $(OBJ_DIR)\archive_read_support_format_cpio.obn &
- $(OBJ_DIR)\archive_read_support_format_empty.obn &
- $(OBJ_DIR)\archive_read_support_format_iso9660.obn &
- $(OBJ_DIR)\archive_read_support_format_mtree.obn &
- $(OBJ_DIR)\archive_read_support_format_tar.obn &
- $(OBJ_DIR)\archive_read_support_format_zip.obn &
- $(OBJ_DIR)\archive_string.obn $(OBJ_DIR)\archive_string_sprintf.obn &
- $(OBJ_DIR)\archive_util.obn $(OBJ_DIR)\archive_virtual.obn &
- $(OBJ_DIR)\archive_write.obn $(OBJ_DIR)\archive_write_disk.obn &
- $(OBJ_DIR)\archive_write_disk_set_standard_lookup.obn &
- $(OBJ_DIR)\archive_write_open_fd.obn $(OBJ_DIR)\archive_write_open_file.obn &
- $(OBJ_DIR)\archive_write_open_filename.obn $(OBJ_DIR)\archive_write_open_memory.obn &
- $(OBJ_DIR)\archive_write_set_compression_bzip2.obn $(OBJ_DIR)\archive_write_set_compression_compress.obn &
- $(OBJ_DIR)\archive_write_set_compression_gzip.obn $(OBJ_DIR)\archive_write_set_compression_none.obn &
- $(OBJ_DIR)\archive_write_set_compression_program.obn $(OBJ_DIR)\archive_write_set_format.obn &
- $(OBJ_DIR)\archive_write_set_format_ar.obn $(OBJ_DIR)\archive_write_set_format_by_name.obn &
- $(OBJ_DIR)\archive_write_set_format_cpio.obn $(OBJ_DIR)\archive_write_set_format_cpio_newc.obn &
- $(OBJ_DIR)\archive_write_set_format_pax.obn $(OBJ_DIR)\archive_write_set_format_shar.obn &
- $(OBJ_DIR)\archive_write_set_format_ustar.obn $(OBJ_DIR)\filter_fork.obn &
- $(OBJ_DIR)\libarchive-nonposix.obn
-
-$(DEST_PATH)\LibArchive.lib :: $(OBJS) $(DEST_PATH)
-
-$(DEST_PATH)\LibArchive.lib ::
- -md $(DEST_PATH) > nul 2>nul
- $(NT_LIBRARIAN) $@ -+ $(OBJS)
-
-$(DEST_PATH):
- -md $(DEST_PATH) > nul 2>nul
diff --git a/archivers/libarchive/files/cpio/match.c b/archivers/libarchive/files/cpio/match.c deleted file mode 100644 index 0e647c9cbab..00000000000 --- a/archivers/libarchive/files/cpio/match.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "cpio.h" - -int -pathmatch(const char *p, const char *s) -{ - int r; - int matched; - const char *end; - - for (;;) { - switch (*p) { - case '[': - ++p; - end = p; - /* Leading ']' is non-special. */ - if (*end == ']') - ++end; - while (*end != '\0' && *end != ']') - ++end; - if (*end == '\0') { /* Unmatched '[' is plain char */ - if (*s != '[') - return (0); - ++s; - break; - } - matched = 0; - while (!matched) { - switch (*p) { - case ']': - if (p == end) - return (0); - else if (*s == ']') { - p = end + 1; - matched = 1; - ++s; - } else - ++p; - break; - default: - /* Trailing - is not special. */ - if (p[1] == '-' && p + 2 < end) { - if (p[0] <= *s && *s <= p[2]) { - p = end + 1; - matched = 1; - ++s; - } else - p += 3; - } else { - if (*p == *s) { - p = end + 1; - matched = 1; - ++s; - } else - ++p; - } - } - } - break; - case '*': - while (*p == '*') - ++p; - if (*p == '\0') - return (1); - while (*s) { - r = pathmatch(p, s); - if (r) - return (r); - ++s; - } - return (0); - break; - case '?': - ++p; - ++s; - break; - case '\0': - return (*s == '\0'); - break; - default: - if (*p != *s) - return (0); - ++p; - ++s; - break; - } - } -} diff --git a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.bin b/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.bin Binary files differdeleted file mode 100644 index 4fbd9b5270d..00000000000 --- a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.bin +++ /dev/null diff --git a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.crc b/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.crc Binary files differdeleted file mode 100644 index 7125f82119f..00000000000 --- a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.crc +++ /dev/null diff --git a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.newc b/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.newc Binary files differdeleted file mode 100644 index 22bf2c413cb..00000000000 --- a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.newc +++ /dev/null diff --git a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.ustar b/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.ustar Binary files differdeleted file mode 100644 index bb1fba943f7..00000000000 --- a/archivers/libarchive/files/cpio/test/test_gcpio_compat_ref.ustar +++ /dev/null diff --git a/archivers/libarchive/files/cpio/test/test_help.c b/archivers/libarchive/files/cpio/test/test_help.c deleted file mode 100644 index 0aedfd3e9b1..00000000000 --- a/archivers/libarchive/files/cpio/test/test_help.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD$"); - -/* - * Test that "--help", "-h", and "-W help" options all work and - * generate reasonable output. - */ - -DEFINE_TEST(test_help) -{ - int r; - char *p; - size_t plen; - - /* Exercise --help option. */ - r = systemf("%s --help >help.stdout 2>help.stderr", testprog); - /* --help should generate nothing to stderr. */ - assertEmptyFile("help.stderr"); - /* Help message should start with name of program. */ - p = slurpfile(&plen, "help.stdout"); - assert(plen > 6); - assert(strncmp(p, "bsdcpio", 6) == 0); - /* - * 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); - /* -h should generate nothing to stderr. */ - assertEmptyFile("h.stderr"); - /* stdout should be same for -h and --help */ - assertEqualFile("h.stdout", "help.stdout"); - - /* -W help should be another synonym. */ - r = systemf("%s -W help >Whelp.stdout 2>Whelp.stderr", testprog); - /* -W help should generate nothing to stderr. */ - assertEmptyFile("Whelp.stderr"); - /* stdout should be same for -W help and --help */ - assertEqualFile("Whelp.stdout", "help.stdout"); -} diff --git a/archivers/libarchive/files/cpio/test/test_option_m.cpio b/archivers/libarchive/files/cpio/test/test_option_m.cpio Binary files differdeleted file mode 100644 index 2f05266abad..00000000000 --- a/archivers/libarchive/files/cpio/test/test_option_m.cpio +++ /dev/null diff --git a/archivers/libarchive/files/cpio/test/test_option_t.cpio b/archivers/libarchive/files/cpio/test/test_option_t.cpio Binary files differdeleted file mode 100644 index 2f05266abad..00000000000 --- a/archivers/libarchive/files/cpio/test/test_option_t.cpio +++ /dev/null diff --git a/archivers/libarchive/files/cpio/test/test_option_t.stdout b/archivers/libarchive/files/cpio/test/test_option_t.stdout deleted file mode 100644 index f73f3093ff8..00000000000 --- a/archivers/libarchive/files/cpio/test/test_option_t.stdout +++ /dev/null @@ -1 +0,0 @@ -file diff --git a/archivers/libarchive/files/cpio/test/test_option_tv.stdout b/archivers/libarchive/files/cpio/test/test_option_tv.stdout deleted file mode 100644 index 420f15d715c..00000000000 --- a/archivers/libarchive/files/cpio/test/test_option_tv.stdout +++ /dev/null @@ -1 +0,0 @@ --rw-r--r-- 1 (null) (null) 0 file diff --git a/archivers/libarchive/files/cpio/test/test_pathmatch.c b/archivers/libarchive/files/cpio/test/test_pathmatch.c deleted file mode 100644 index 177c2bcc4af..00000000000 --- a/archivers/libarchive/files/cpio/test/test_pathmatch.c +++ /dev/null @@ -1,243 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD$"); - -#include "pathmatch.h" - -/* - * Verify that the pattern matcher implements the wildcard logic specified - * in SUSv2 for the cpio command. This is essentially the - * shell glob syntax: - * * - matches any sequence of chars, including '/' - * ? - matches any single char, including '/' - * [...] - matches any of a set of chars, '-' specifies a range, - * initial '!' is undefined - * - * The specification in SUSv2 is a bit incomplete, I assume the following: - * Trailing '-' in [...] is not special. - * - * TODO: Figure out if there's a good way to extend this to handle - * Windows paths that use '\' as a path separator. <sigh> - */ - -DEFINE_TEST(test_pathmatch) -{ - assertEqualInt(1, lafe_pathmatch("a/b/c", "a/b/c", 0)); - assertEqualInt(0, lafe_pathmatch("a/b/", "a/b/c", 0)); - assertEqualInt(0, lafe_pathmatch("a/b", "a/b/c", 0)); - assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b/", 0)); - assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b", 0)); - - /* Empty pattern only matches empty string. */ - assertEqualInt(1, lafe_pathmatch("","", 0)); - assertEqualInt(0, lafe_pathmatch("","a", 0)); - assertEqualInt(1, lafe_pathmatch("*","", 0)); - assertEqualInt(1, lafe_pathmatch("*","a", 0)); - assertEqualInt(1, lafe_pathmatch("*","abcd", 0)); - /* SUSv2: * matches / */ - assertEqualInt(1, lafe_pathmatch("*","abcd/efgh/ijkl", 0)); - assertEqualInt(1, lafe_pathmatch("abcd*efgh/ijkl","abcd/efgh/ijkl", 0)); - assertEqualInt(1, lafe_pathmatch("abcd***efgh/ijkl","abcd/efgh/ijkl", 0)); - assertEqualInt(1, lafe_pathmatch("abcd***/efgh/ijkl","abcd/efgh/ijkl", 0)); - assertEqualInt(0, lafe_pathmatch("?", "", 0)); - assertEqualInt(0, lafe_pathmatch("?", "\0", 0)); - assertEqualInt(1, lafe_pathmatch("?", "a", 0)); - assertEqualInt(0, lafe_pathmatch("?", "ab", 0)); - assertEqualInt(1, lafe_pathmatch("?", ".", 0)); - assertEqualInt(1, lafe_pathmatch("?", "?", 0)); - assertEqualInt(1, lafe_pathmatch("a", "a", 0)); - assertEqualInt(0, lafe_pathmatch("a", "ab", 0)); - assertEqualInt(0, lafe_pathmatch("a", "ab", 0)); - assertEqualInt(1, lafe_pathmatch("a?c", "abc", 0)); - /* SUSv2: ? matches / */ - assertEqualInt(1, lafe_pathmatch("a?c", "a/c", 0)); - assertEqualInt(1, lafe_pathmatch("a?*c*", "a/c", 0)); - assertEqualInt(1, lafe_pathmatch("*a*", "a/c", 0)); - assertEqualInt(1, lafe_pathmatch("*a*", "/a/c", 0)); - assertEqualInt(1, lafe_pathmatch("*a*", "defaaaaaaa", 0)); - assertEqualInt(0, lafe_pathmatch("a*", "defghi", 0)); - assertEqualInt(0, lafe_pathmatch("*a*", "defghi", 0)); - - /* Character classes */ - assertEqualInt(1, lafe_pathmatch("abc[def", "abc[def", 0)); - assertEqualInt(0, lafe_pathmatch("abc[def]", "abc[def", 0)); - assertEqualInt(0, lafe_pathmatch("abc[def", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[def]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[def]", "abce", 0)); - assertEqualInt(1, lafe_pathmatch("abc[def]", "abcf", 0)); - assertEqualInt(0, lafe_pathmatch("abc[def]", "abcg", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abc*", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d*f]", "abcdefghi", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d*", "abcdefghi", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d*", "abc[defghi", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abce", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcf", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d-f]", "abcg", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abca", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abce", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcf", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcg", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abch", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abci", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcj", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abck", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcl", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abc-", 0)); - - /* [] matches nothing, [!] is the same as ? */ - assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcdefg", 0)); - assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcqefg", 0)); - assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcefg", 0)); - assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcdefg", 0)); - assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcqefg", 0)); - assertEqualInt(0, lafe_pathmatch("abc[!]efg", "abcefg", 0)); - - /* I assume: Trailing '-' is non-special. */ - assertEqualInt(0, lafe_pathmatch("abc[d-fh-]", "abcl", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abch", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0)); - - /* ']' can be backslash-quoted within a character class. */ - assertEqualInt(1, lafe_pathmatch("abc[\\]]", "abc]", 0)); - assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abc]", 0)); - assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abc]", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d]e]", "abcde]", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d\\]e]", "abc]", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d\\]e]", "abcd]e", 0)); - assertEqualInt(0, lafe_pathmatch("abc[d]e]", "abc]", 0)); - - /* backslash-quoted chars can appear as either end of a range. */ - assertEqualInt(1, lafe_pathmatch("abc[\\d-f]gh", "abcegh", 0)); - assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abcggh", 0)); - assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abc\\gh", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d-\\f]gh", "abcegh", 0)); - assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0)); - assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0)); - /* backslash-quoted '-' isn't special. */ - assertEqualInt(0, lafe_pathmatch("abc[d\\-f]gh", "abcegh", 0)); - assertEqualInt(1, lafe_pathmatch("abc[d\\-f]gh", "abc-gh", 0)); - - /* Leading '!' negates a character class. */ - assertEqualInt(0, lafe_pathmatch("abc[!d]", "abcd", 0)); - assertEqualInt(1, lafe_pathmatch("abc[!d]", "abce", 0)); - assertEqualInt(1, lafe_pathmatch("abc[!d]", "abcc", 0)); - assertEqualInt(0, lafe_pathmatch("abc[!d-z]", "abcq", 0)); - assertEqualInt(1, lafe_pathmatch("abc[!d-gi-z]", "abch", 0)); - assertEqualInt(1, lafe_pathmatch("abc[!fgijkl]", "abch", 0)); - assertEqualInt(0, lafe_pathmatch("abc[!fghijkl]", "abch", 0)); - - /* Backslash quotes next character. */ - assertEqualInt(0, lafe_pathmatch("abc\\[def]", "abc\\d", 0)); - assertEqualInt(1, lafe_pathmatch("abc\\[def]", "abc[def]", 0)); - assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc[def]", 0)); - assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc\\[def]", 0)); - assertEqualInt(1, lafe_pathmatch("abc\\\\[def]", "abc\\d", 0)); - assertEqualInt(1, lafe_pathmatch("abcd\\", "abcd\\", 0)); - assertEqualInt(0, lafe_pathmatch("abcd\\", "abcd\\[", 0)); - assertEqualInt(0, lafe_pathmatch("abcd\\", "abcde", 0)); - assertEqualInt(0, lafe_pathmatch("abcd\\[", "abcd\\", 0)); - - /* - * Because '.' and '/' have special meanings, we can - * identify many equivalent paths even if they're expressed - * differently. (But quoting a character with '\\' suppresses - * special meanings!) - */ - assertEqualInt(0, lafe_pathmatch("a/b/", "a/bc", 0)); - assertEqualInt(1, lafe_pathmatch("a/./b", "a/b", 0)); - assertEqualInt(0, lafe_pathmatch("a\\/./b", "a/b", 0)); - assertEqualInt(0, lafe_pathmatch("a/\\./b", "a/b", 0)); - assertEqualInt(0, lafe_pathmatch("a/.\\/b", "a/b", 0)); - assertEqualInt(0, lafe_pathmatch("a\\/\\.\\/b", "a/b", 0)); - assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def/", 0)); - assertEqualInt(1, lafe_pathmatch("abc/def", "./././abc/./def", 0)); - assertEqualInt(1, lafe_pathmatch("abc/def/././//", "./././abc/./def/", 0)); - assertEqualInt(1, lafe_pathmatch(".////abc/.//def", "./././abc/./def", 0)); - assertEqualInt(1, lafe_pathmatch("./abc?def/", "abc/def/", 0)); - failure("\"?./\" is not the same as \"/./\""); - assertEqualInt(0, lafe_pathmatch("./abc?./def/", "abc/def/", 0)); - failure("Trailing '/' should match no trailing '/'"); - assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def", 0)); - failure("Trailing '/./' is still the same directory."); - assertEqualInt(1, lafe_pathmatch("./abc/./def/./", "abc/def", 0)); - failure("Trailing '/.' is still the same directory."); - assertEqualInt(1, lafe_pathmatch("./abc/./def/.", "abc/def", 0)); - assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/", 0)); - failure("Trailing '/./' is still the same directory."); - assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/./", 0)); - failure("Trailing '/.' is still the same directory."); - assertEqualInt(1, lafe_pathmatch("./abc*/./def", "abc/def/.", 0)); - - /* Matches not anchored at beginning. */ - assertEqualInt(0, - lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_START)); - assertEqualInt(1, - lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_START)); - assertEqualInt(0, - lafe_pathmatch("^bcd", "abcd", PATHMATCH_NO_ANCHOR_START)); - assertEqualInt(1, - lafe_pathmatch("b/c/d", "a/b/c/d", PATHMATCH_NO_ANCHOR_START)); - assertEqualInt(0, - lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START)); - assertEqualInt(0, - lafe_pathmatch("^b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START)); - - /* Matches not anchored at end. */ - assertEqualInt(0, - lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("abcd", "abcd/", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("abcd", "abcd/.", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(0, - lafe_pathmatch("abc", "abcd", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("a/b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(0, - lafe_pathmatch("a/b/c$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("a/b/c$", "a/b/c", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("a/b/c$", "a/b/c/", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("a/b/c/", "a/b/c/d", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(0, - lafe_pathmatch("a/b/c/$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("a/b/c/$", "a/b/c/", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(1, - lafe_pathmatch("a/b/c/$", "a/b/c", PATHMATCH_NO_ANCHOR_END)); - assertEqualInt(0, - lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END)); -} diff --git a/archivers/libarchive/files/cpio/test/test_version.c b/archivers/libarchive/files/cpio/test/test_version.c deleted file mode 100644 index 973d9ff3cb8..00000000000 --- a/archivers/libarchive/files/cpio/test/test_version.c +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD$"); - -/* - * 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); - /* --version should generate nothing to stdout. */ - assertEmptyFile("version.stdout"); - /* Verify format of version message. */ - q = p = slurpfile(&s, "version.stderr"); - /* Version message should start with name of program, then space. */ - assert(s > 6); - assertEqualMem(q, "bsdcpio ", 8); - q += 8; s -= 8; - /* Version number is a series of digits and periods. */ - while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) { - ++q; - --s; - } - /* Version number terminated by space. */ - assert(s > 1); - assert(*q == ' '); - ++q; --s; - /* Separator. */ - assertEqualMem(q, "-- ", 3); - q += 3; s -= 3; - /* libarchive name and version number */ - assert(s > 11); - 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; - } - /* All terminated by a newline. */ - assert(s >= 1); - assertEqualMem(q, "\n", 1); - free(p); -} diff --git a/archivers/libarchive/files/cpio/test/test_write_odc.c b/archivers/libarchive/files/cpio/test/test_write_odc.c deleted file mode 100644 index 50c97f71515..00000000000 --- a/archivers/libarchive/files/cpio/test/test_write_odc.c +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD$"); - -static int -is_octal(const char *p, size_t l) -{ - while (l > 0) { - if (*p < '0' || *p > '7') - return (0); - --l; - ++p; - } - return (1); -} - -static int -from_octal(const char *p, size_t l) -{ - int r = 0; - - while (l > 0) { - r *= 8; - r += *p - '0'; - --l; - ++p; - } - return (r); -} - -DEFINE_TEST(test_write_odc) -{ - int fd, filelist; - int r; - int dev, ino, gid; - time_t t, now; - char *p, *e; - size_t s; - - /* - * Create an assortment of files. - * TODO: Extend this to cover more filetypes. - */ - filelist = open("filelist", O_CREAT | O_WRONLY, 0644); - - /* "file" */ - fd = open("file", O_CREAT | O_WRONLY, 0644); - assert(fd >= 0); - assertEqualInt(10, write(fd, "123456789", 10)); - close(fd); - assertEqualInt(5, write(filelist, "file\n", 5)); - - /* "symlink" */ - assertEqualInt(0, symlink("file", "symlink")); - assertEqualInt(8, write(filelist, "symlink\n", 8)); - - /* "dir" */ - assertEqualInt(0, mkdir("dir", 0775)); - /* Record some facts about what we just created: */ - now = time(NULL); /* They were all created w/in last two seconds. */ - assertEqualInt(4, write(filelist, "dir\n", 4)); - - /* Use the cpio program to create an archive. */ - close(filelist); - r = systemf("%s -o <filelist >basic.out 2>basic.err", testprog); - assertEqualInt(r, 0); - - /* Verify that nothing went to stderr. */ - assertEmptyFile("basic.err"); - - /* Verify that stdout is a well-formed cpio file in "odc" format. */ - p = slurpfile(&s, "basic.out"); - assertEqualInt(s, 512); - e = p; - - /* - * Some of these assertions could be stronger, but it's - * a little tricky because they depend on the local environment. - */ - - /* First entry is "file" */ - assert(is_octal(e, 76)); /* Entire header is octal digits. */ - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assert(is_octal(e + 6, 6)); /* dev */ - dev = from_octal(e + 6, 6); - assert(is_octal(e + 12, 6)); /* ino */ - ino = from_octal(e + 12, 6); - assertEqualMem(e + 18, "100644", 6); /* Mode */ - assertEqualInt(from_octal(e + 24, 6), getuid()); /* uid */ - assert(is_octal(e + 30, 6)); /* gid */ - gid = from_octal(e + 30, 6); - assertEqualMem(e + 36, "000001", 6); /* nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - t = from_octal(e + 48, 11); /* mtime */ - assert(t <= now); /* File wasn't created in future. */ - assert(t >= now - 2); /* File was created w/in last 2 secs. */ - assertEqualMem(e + 59, "000005", 6); /* Name size */ - assertEqualMem(e + 65, "00000000012", 11); /* File size */ - assertEqualMem(e + 76, "file\0", 5); /* Name contents */ - assertEqualMem(e + 81, "123456789\0", 10); /* File contents */ - e += 91; - - /* Second entry is "symlink" pointing to "file" */ - assert(is_octal(e, 76)); /* Entire header is octal digits. */ - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualInt(dev, from_octal(e + 6, 6)); /* dev */ - assert(dev != from_octal(e + 12, 6)); /* ino */ - assertEqualMem(e + 18, "120755", 6); /* Mode */ - assertEqualInt(from_octal(e + 24, 6), getuid()); /* uid */ - assertEqualInt(gid, from_octal(e + 30, 6)); /* gid */ - assertEqualMem(e + 36, "000001", 6); /* nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - t = from_octal(e + 48, 11); /* mtime */ - assert(t <= now); /* File wasn't created in future. */ - assert(t >= now - 2); /* File was created w/in last 2 secs. */ - assertEqualMem(e + 59, "000010", 6); /* Name size */ - assertEqualMem(e + 65, "00000000004", 11); /* File size */ - assertEqualMem(e + 76, "symlink\0", 8); /* Name contents */ - assertEqualMem(e + 84, "file", 4); /* Symlink target. */ - e += 88; - - /* Second entry is "dir" */ - assert(is_octal(e, 76)); - assertEqualMem(e + 0, "070707", 6); /* Magic */ - /* Dev should be same as first entry. */ - assert(is_octal(e + 6, 6)); /* dev */ - assertEqualInt(dev, from_octal(e + 6, 6)); - /* Ino must be different from first entry. */ - assert(is_octal(e + 12, 6)); /* ino */ - assert(dev != from_octal(e + 12, 6)); - assertEqualMem(e + 18, "040755", 6); /* Mode */ - assertEqualInt(from_octal(e + 24, 6), getuid()); /* uid */ - /* Gid should be same as first entry. */ - assert(is_octal(e + 30, 6)); /* gid */ - assertEqualInt(gid, from_octal(e + 30, 6)); - assertEqualMem(e + 36, "000002", 6); /* Nlink */ - t = from_octal(e + 48, 11); /* mtime */ - assert(t <= now); /* File wasn't created in future. */ - assert(t >= now - 2); /* File was created w/in last 2 secs. */ - assertEqualMem(e + 59, "000004", 6); /* Name size */ - assertEqualMem(e + 65, "00000000000", 11); /* File size */ - assertEqualMem(e + 76, "dir\0", 4); /* name */ - e += 80; - - /* TODO: Verify other types of entries. */ - - /* Last entry is end-of-archive marker. */ - assert(is_octal(e, 76)); - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualMem(e + 6, "000000", 6); /* dev */ - assertEqualMem(e + 12, "000000", 6); /* ino */ - assertEqualMem(e + 18, "000000", 6); /* Mode */ - assertEqualMem(e + 24, "000000", 6); /* uid */ - assertEqualMem(e + 30, "000000", 6); /* gid */ - assertEqualMem(e + 36, "000001", 6); /* Nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - assertEqualMem(e + 48, "00000000000", 11); /* mtime */ - assertEqualMem(e + 59, "000013", 6); /* Name size */ - assertEqualMem(e + 65, "00000000000", 11); /* File size */ - assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */ - - free(p); -} diff --git a/archivers/libarchive/files/examples/minitar/Makefile b/archivers/libarchive/files/examples/minitar/Makefile deleted file mode 100644 index 485eb8d481d..00000000000 --- a/archivers/libarchive/files/examples/minitar/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -CFLAGS= \ - -DNO_BZIP2_CREATE \ - -DNO_BZIP2_EXTRACT \ - -DNO_COMPRESS_EXTRACT \ - -DNO_CPIO_EXTRACT \ - -DNO_CREATE \ - -DNO_GZIP_CREATE \ - -DNO_GZIP_EXTRACT \ - -# Omit 'tree.o' if you're not including create support -#OBJS= minitar.o tree.o -OBJS= minitar.o - -all: minitar - -minitar: $(OBJS) - cc -o minitar -static $> -larchive -lz -lbz2 - strip minitar - ls -l minitar - -minitar.o: minitar.c - -tree.o: tree.c - -clean:: - rm -f *.o - rm -f minitar - rm -f *~ diff --git a/archivers/libarchive/files/examples/minitar/tree.c b/archivers/libarchive/files/examples/minitar/tree.c deleted file mode 100644 index 8af0b4d88e7..00000000000 --- a/archivers/libarchive/files/examples/minitar/tree.c +++ /dev/null @@ -1,423 +0,0 @@ -/*- - * Copyright (c) 2003-2004 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 - * in this position and unchanged. - * 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. - */ - -/*- - * There is a single list of "tree_entry" items that represent - * filesystem objects that require further attention. Non-directories - * are not kept in memory: they are pulled from readdir(), returned to - * the client, then freed as soon as possible. Any directory entry to - * be traversed gets pushed onto the stack. - * - * There is surprisingly little information that needs to be kept for - * each item on the stack. Just the name, depth (represented here as the - * string length of the parent directory's pathname), and some markers - * indicating how to get back to the parent (via chdir("..") for a - * regular dir or via fchdir(2) for a symlink). - */ - -#include <sys/stat.h> -#include <dirent.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "tree.h" - -/* - * TODO: - * 1) Loop checking. - * 3) Arbitrary logical traversals by closing/reopening intermediate fds. - */ - -struct tree_entry { - struct tree_entry *next; - char *name; - size_t dirname_length; - int fd; - int flags; -}; - -/* Definitions for tree_entry.flags bitmap. */ -#define isDir 1 /* This entry is a regular directory. */ -#define isDirLink 2 /* This entry is a symbolic link to a directory. */ -#define needsTraversal 4 /* This entry hasn't yet been traversed. */ - -/* - * Local data for this package. - */ -struct tree { - struct tree_entry *stack; - DIR *d; - int initialDirFd; - int flags; - - char *buff; - char *basename; - size_t buff_length; - size_t path_length; - size_t dirname_length; - - int depth; - int openCount; - int maxOpenCount; - - struct stat lst; - struct stat st; -}; - -/* Definitions for tree.flags bitmap. */ -#define needsReturn 8 /* Marks first entry as not having been returned yet. */ -#define hasStat 16 /* The st entry is set. */ -#define hasLstat 32 /* The lst entry is set. */ - - -#define HAVE_DIRENT_D_NAMLEN 1 -#ifdef HAVE_DIRENT_D_NAMLEN -/* BSD extension; avoids need for a strlen() call. */ -#define D_NAMELEN(dp) (dp)->d_namlen -#else -#define D_NAMELEN(dp) (strlen((dp)->d_name)) -#endif - -#if 0 -static void -dumpStack(struct tree *t) -{ - struct tree_entry *te; - - printf("\tbuff: %s\n", t->buff); - printf("\tpwd: "); fflush(stdout); system("pwd"); - printf("\tstack:\n"); - for (te = t->stack; te != NULL; te = te->next) { - printf("\t\tte->name: %s %s\n", te->name, te->flags & needsTraversal ? "" : "*"); - } -} -#endif - -/* - * Add a directory path to the current stack. - */ -static void -tree_add(struct tree *t, const char *path) -{ - struct tree_entry *te; - - te = malloc(sizeof(*te)); - memset(te, 0, sizeof(*te)); - te->next = t->stack; - t->stack = te; - te->fd = -1; - te->name = strdup(path); - te->flags = needsTraversal; - te->dirname_length = t->dirname_length; -} - -/* - * Append a name to the current path. - */ -static void -tree_append(struct tree *t, const char *name, size_t name_length) -{ - if (t->buff != NULL) - t->buff[t->dirname_length] = '\0'; - - /* Resize pathname buffer as needed. */ - while (name_length + 1 + t->dirname_length >= t->buff_length) { - t->buff_length *= 2; - if (t->buff_length < 1024) - t->buff_length = 1024; - t->buff = realloc(t->buff, t->buff_length); - } - t->basename = t->buff + t->dirname_length; - t->path_length = t->dirname_length + name_length; - if (t->dirname_length > 0) { - *t->basename++ = '/'; - t->path_length ++; - } - strcpy(t->basename, name); -} - -/* - * Open a directory tree for traversal. - */ -struct tree * -tree_open(const char *path) -{ - struct tree *t; - - t = malloc(sizeof(*t)); - memset(t, 0, sizeof(*t)); - tree_append(t, path, strlen(path)); - t->initialDirFd = open(".", O_RDONLY); - /* - * During most of the traversal, items are set up and then - * returned immediately from tree_next(). That doesn't work - * for the very first entry, so we set a flag for this special - * case. - */ - t->flags = needsReturn; - return (t); -} - -/* - * We've finished a directory; ascend back to the parent. - */ -static void -tree_ascend(struct tree *t) -{ - struct tree_entry *te; - - te = t->stack; - t->depth--; - if (te->flags & isDirLink) { - fchdir(te->fd); - close(te->fd); - t->openCount--; - } else { - chdir(".."); - } -} - -/* - * Pop the working stack. - */ -static void -tree_pop(struct tree *t) -{ - struct tree_entry *te; - - te = t->stack; - t->stack = te->next; - t->dirname_length = te->dirname_length; - free(te->name); - free(te); -} - -/* - * Get the next item in the tree traversal. - */ -int -tree_next(struct tree *t) -{ - struct dirent *de = NULL; - - /* Handle the startup case by returning the initial entry. */ - if (t->flags & needsReturn) { - t->flags &= ~needsReturn; - return (1); - } - - while (t->stack != NULL) { - /* If there's an open dir, get the next entry from there. */ - while (t->d != NULL) { - de = readdir(t->d); - if (de == NULL) { - closedir(t->d); - t->d = NULL; - } else if (de->d_name[0] == '.' - && de->d_name[1] == '\0') { - /* Skip '.' */ - } else if (de->d_name[0] == '.' - && de->d_name[1] == '.' - && de->d_name[2] == '\0') { - /* Skip '..' */ - } else { - /* - * Append the path to the current path - * and return it. - */ - tree_append(t, de->d_name, D_NAMELEN(de)); - t->flags &= ~hasLstat; - t->flags &= ~hasStat; - return (1); - } - } - - /* If the current dir needs to be traversed, set it up. */ - if (t->stack->flags & needsTraversal) { - tree_append(t, t->stack->name, strlen(t->stack->name)); - t->stack->flags &= ~needsTraversal; - /* If it is a link, set up fd for the ascent. */ - if (t->stack->flags & isDirLink) { - t->stack->fd = open(".", O_RDONLY); - t->openCount++; - if (t->openCount > t->maxOpenCount) - t->maxOpenCount = t->openCount; - } - if (chdir(t->stack->name) == 0) { - t->depth++; - t->dirname_length = t->path_length; - t->d = opendir("."); - } else - tree_pop(t); - continue; - } - - /* We've done everything necessary for the top stack entry. */ - tree_ascend(t); - tree_pop(t); - } - return (0); -} - -/* - * Called by the client to mark the directory just returned from - * tree_next() as needing to be visited. - */ -void -tree_descend(struct tree *t) -{ - const struct stat *s = tree_current_lstat(t); - - if (S_ISDIR(s->st_mode)) { - tree_add(t, t->basename); - t->stack->flags |= isDir; - } - - if (S_ISLNK(s->st_mode) && S_ISDIR(tree_current_stat(t)->st_mode)) { - tree_add(t, t->basename); - t->stack->flags |= isDirLink; - } -} - -/* - * Get the stat() data for the entry just returned from tree_next(). - */ -const struct stat * -tree_current_stat(struct tree *t) -{ - if (!(t->flags & hasStat)) { - stat(t->basename, &t->st); - t->flags |= hasStat; - } - return (&t->st); -} - -/* - * Get the lstat() data for the entry just returned from tree_next(). - */ -const struct stat * -tree_current_lstat(struct tree *t) -{ - if (!(t->flags & hasLstat)) { - lstat(t->basename, &t->lst); - t->flags |= hasLstat; - } - return (&t->lst); -} - -/* - * Return the access path for the entry just returned from tree_next(). - */ -const char * -tree_current_access_path(struct tree *t) -{ - return (t->basename); -} - -/* - * Return the full path for the entry just returned from tree_next(). - */ -const char * -tree_current_path(struct tree *t) -{ - return (t->buff); -} - -/* - * Return the length of the path for the entry just returned from tree_next(). - */ -size_t -tree_current_pathlen(struct tree *t) -{ - return (t->path_length); -} - -/* - * Return the nesting depth of the entry just returned from tree_next(). - */ -int -tree_current_depth(struct tree *t) -{ - return (t->depth); -} - -/* - * Terminate the traversal and release any resources. - */ -void -tree_close(struct tree *t) -{ - /* Release anything remaining in the stack. */ - while (t->stack != NULL) - tree_pop(t); - if (t->buff) - free(t->buff); - /* chdir() back to where we started. */ - if (t->initialDirFd >= 0) { - fchdir(t->initialDirFd); - close(t->initialDirFd); - t->initialDirFd = -1; - } - free(t); -} - - -#if 0 -/* Main function for testing. */ -#include <stdio.h> - -int main(int argc, char **argv) -{ - size_t max_path_len = 0; - int max_depth = 0; - - system("pwd"); - while (*++argv) { - struct tree *t = tree_open(*argv); - while (tree_next(t)) { - size_t path_len = tree_current_pathlen(t); - int depth = tree_current_depth(t); - if (path_len > max_path_len) - max_path_len = path_len; - if (depth > max_depth) - max_depth = depth; - printf("%s\n", tree_current_path(t)); - if (S_ISDIR(tree_current_lstat(t)->st_mode)) - tree_descend(t); /* Descend into every dir. */ - } - tree_close(t); - printf("Max path length: %d\n", max_path_len); - printf("Max depth: %d\n", max_depth); - printf("Final open count: %d\n", t->openCount); - printf("Max open count: %d\n", t->maxOpenCount); - fflush(stdout); - system("pwd"); - } - return (0); -} -#endif diff --git a/archivers/libarchive/files/examples/minitar/tree.h b/archivers/libarchive/files/examples/minitar/tree.h deleted file mode 100644 index 554e6c2da21..00000000000 --- a/archivers/libarchive/files/examples/minitar/tree.h +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright (c) 2003-2004 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 - * in this position and unchanged. - * 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. - */ - -/*- - * A set of routines for traversing directory trees. - * Similar in concept to the fts library, but with a few - * important differences: - * * Uses less memory. In particular, fts stores an entire directory - * in memory at a time. This package only keeps enough subdirectory - * information in memory to track the traversal. Information - * about non-directories is discarded as soon as possible. - * * Supports very deep logical traversals. The fts package - * uses "non-chdir" approach for logical traversals. This - * package does use a chdir approach for logical traversals - * and can therefore handle pathnames much longer than - * PATH_MAX. - * * Supports deep physical traversals "out of the box." - * Due to the memory optimizations above, there's no need to - * limit dir names to 32k. - */ - -#include <sys/stat.h> - -struct tree; - -struct tree *tree_open(const char *); -/* Returns TRUE if there is a next entry. Zero if there is no next entry. */ -int tree_next(struct tree *); -/* Return information about the current entry. */ -int tree_current_depth(struct tree *); -/* - * The current full pathname, length of the full pathname, - * and a name that can be used to access the file. - * Because tree does use chdir extensively, the access path is - * almost never the same as the full current path. - */ -const char *tree_current_path(struct tree *); -size_t tree_current_pathlen(struct tree *); -const char *tree_current_access_path(struct tree *); -/* - * Request the lstat() or stat() data for the current path. - * Since the tree package needs to do some of this anyway, - * you should take advantage of it here if you need it. - */ -const struct stat *tree_current_stat(struct tree *); -const struct stat *tree_current_lstat(struct tree *); -/* - * Request that current entry be visited. If you invoke it on every - * directory, you'll get a physical traversal. This is ignored if the - * current entry isn't a directory or a link to a directory. So, if - * you invoke this on every returned path, you'll get a full logical - * traversal. - */ -void tree_descend(struct tree *); -void tree_close(struct tree *); diff --git a/archivers/libarchive/files/libarchive/archive_hash.h b/archivers/libarchive/files/libarchive/archive_hash.h deleted file mode 100644 index b180da6714f..00000000000 --- a/archivers/libarchive/files/libarchive/archive_hash.h +++ /dev/null @@ -1,281 +0,0 @@ -/*- - * Copyright (c) 2009 Joerg Sonnenberger - * 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: head/lib/libarchive/archive_hash.h 201171 2009-12-29 06:39:07Z kientzle $ - */ - -#ifndef __LIBARCHIVE_BUILD -#error This header is only to be used internally to libarchive. -#endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -/* - * Hash function support in various Operating Systems: - * - * NetBSD: - * - MD5 and SHA1 in libc: without _ after algorithm name - * - SHA2 in libc: with _ after algorithm name - * - * OpenBSD: - * - MD5, SHA1 and SHA2 in libc: without _ after algorithm name - * - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name - * - * DragonFly and FreeBSD (XXX not used yet): - * - MD5 and SHA1 in libmd: without _ after algorithm name - * - SHA256: with _ after algorithm name - * - * Mac OS X (10.4 and later): - * - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm name - * - * OpenSSL: - * - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name - * - * Windows: - * - MD5, SHA1 and SHA2 in archive_windows.c: without algorithm name - * and with __la_ prefix. - */ -#if defined(ARCHIVE_HASH_MD5_WIN) ||\ - defined(ARCHIVE_HASH_SHA1_WIN) || defined(ARCHIVE_HASH_SHA256_WIN) ||\ - defined(ARCHIVE_HASH_SHA384_WIN) || defined(ARCHIVE_HASH_SHA512_WIN) -#include <wincrypt.h> -typedef struct { - int valid; - HCRYPTPROV cryptProv; - HCRYPTHASH hash; -} Digest_CTX; -extern void __la_hash_Init(Digest_CTX *, ALG_ID); -extern void __la_hash_Final(unsigned char *, size_t, Digest_CTX *); -extern void __la_hash_Update(Digest_CTX *, const unsigned char *, size_t); -#endif - -#if defined(ARCHIVE_HASH_MD5_LIBC) -# include <md5.h> -# define ARCHIVE_HAS_MD5 -typedef MD5_CTX archive_md5_ctx; -# define archive_md5_init(ctx) MD5Init(ctx) -# define archive_md5_final(ctx, buf) MD5Final(buf, ctx) -# define archive_md5_update(ctx, buf, n) MD5Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_MD5_LIBSYSTEM) -# include <CommonCrypto/CommonDigest.h> -# define ARCHIVE_HAS_MD5 -typedef CC_MD5_CTX archive_md5_ctx; -# define archive_md5_init(ctx) CC_MD5_Init(ctx) -# define archive_md5_final(ctx, buf) CC_MD5_Final(buf, ctx) -# define archive_md5_update(ctx, buf, n) CC_MD5_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_MD5_OPENSSL) -# include <openssl/md5.h> -# define ARCHIVE_HAS_MD5 -typedef MD5_CTX archive_md5_ctx; -# define archive_md5_init(ctx) MD5_Init(ctx) -# define archive_md5_final(ctx, buf) MD5_Final(buf, ctx) -# define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_MD5_WIN) -# define ARCHIVE_HAS_MD5 -# define MD5_DIGEST_LENGTH 16 -typedef Digest_CTX archive_md5_ctx; -# define archive_md5_init(ctx) __la_hash_Init(ctx, CALG_MD5) -# define archive_md5_final(ctx, buf) __la_hash_Final(buf, MD5_DIGEST_LENGTH, ctx) -# define archive_md5_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) -#endif - -#if defined(ARCHIVE_HASH_RMD160_LIBC) -# include <rmd160.h> -# define ARCHIVE_HAS_RMD160 -typedef RMD160_CTX archive_rmd160_ctx; -# define archive_rmd160_init(ctx) RMD160Init(ctx) -# define archive_rmd160_final(ctx, buf) RMD160Final(buf, ctx) -# define archive_rmd160_update(ctx, buf, n) RMD160Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_RMD160_OPENSSL) -# include <openssl/ripemd.h> -# define ARCHIVE_HAS_RMD160 -typedef RIPEMD160_CTX archive_rmd160_ctx; -# define archive_rmd160_init(ctx) RIPEMD160_Init(ctx) -# define archive_rmd160_final(ctx, buf) RIPEMD160_Final(buf, ctx) -# define archive_rmd160_update(ctx, buf, n) RIPEMD160_Update(ctx, buf, n) -#endif - -#if defined(ARCHIVE_HASH_SHA1_LIBC) -# include <sha1.h> -# define ARCHIVE_HAS_SHA1 -typedef SHA1_CTX archive_sha1_ctx; -# define archive_sha1_init(ctx) SHA1Init(ctx) -# define archive_sha1_final(ctx, buf) SHA1Final(buf, ctx) -# define archive_sha1_update(ctx, buf, n) SHA1Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA1_LIBSYSTEM) -# include <CommonCrypto/CommonDigest.h> -# define ARCHIVE_HAS_SHA1 -typedef CC_SHA1_CTX archive_sha1_ctx; -# define archive_sha1_init(ctx) CC_SHA1_Init(ctx) -# define archive_sha1_final(ctx, buf) CC_SHA1_Final(buf, ctx) -# define archive_sha1_update(ctx, buf, n) CC_SHA1_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA1_OPENSSL) -# include <openssl/sha.h> -# define ARCHIVE_HAS_SHA1 -typedef SHA_CTX archive_sha1_ctx; -# define archive_sha1_init(ctx) SHA1_Init(ctx) -# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx) -# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA1_WIN) -# define ARCHIVE_HAS_SHA1 -# define SHA1_DIGEST_LENGTH 20 -typedef Digest_CTX archive_sha1_ctx; -# define archive_sha1_init(ctx) __la_hash_Init(ctx, CALG_SHA1) -# define archive_sha1_final(ctx, buf) __la_hash_Final(buf, SHA1_DIGEST_LENGTH, ctx) -# define archive_sha1_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) -#endif - -#if defined(ARCHIVE_HASH_SHA256_LIBC) -# include <sha2.h> -# define ARCHIVE_HAS_SHA256 -typedef SHA256_CTX archive_sha256_ctx; -# define archive_sha256_init(ctx) SHA256_Init(ctx) -# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx) -# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA256_LIBC2) -# include <sha2.h> -# define ARCHIVE_HAS_SHA256 -typedef SHA256_CTX archive_sha256_ctx; -# define archive_sha256_init(ctx) SHA256Init(ctx) -# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx) -# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA256_LIBC3) -# include <sha2.h> -# define ARCHIVE_HAS_SHA256 -typedef SHA2_CTX archive_sha256_ctx; -# define archive_sha256_init(ctx) SHA256Init(ctx) -# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx) -# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA256_LIBSYSTEM) -# include <CommonCrypto/CommonDigest.h> -# define ARCHIVE_HAS_SHA256 -typedef CC_SHA256_CTX archive_shs256_ctx; -# define archive_shs256_init(ctx) CC_SHA256_Init(ctx) -# define archive_shs256_final(ctx, buf) CC_SHA256_Final(buf, ctx) -# define archive_shs256_update(ctx, buf, n) CC_SHA256_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA256_OPENSSL) -# include <openssl/sha.h> -# define ARCHIVE_HAS_SHA256 -typedef SHA256_CTX archive_sha256_ctx; -# define archive_sha256_init(ctx) SHA256_Init(ctx) -# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx) -# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA256_WIN) -# define ARCHIVE_HAS_SHA256 -# define SHA256_DIGEST_LENGTH 32 -typedef Digest_CTX archive_sha256_ctx; -# define archive_sha256_init(ctx) __la_hash_Init(ctx, CALG_SHA_256) -# define archive_sha256_final(ctx, buf) __la_hash_Final(buf, SHA256_DIGEST_LENGTH, ctx) -# define archive_sha256_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) -#endif - -#if defined(ARCHIVE_HASH_SHA384_LIBC) -# include <sha2.h> -# define ARCHIVE_HAS_SHA384 -typedef SHA384_CTX archive_sha384_ctx; -# define archive_sha384_init(ctx) SHA384_Init(ctx) -# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx) -# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA384_LIBC2) -# include <sha2.h> -# define ARCHIVE_HAS_SHA384 -typedef SHA384_CTX archive_sha384_ctx; -# define archive_sha384_init(ctx) SHA384Init(ctx) -# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx) -# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA384_LIBC3) -# include <sha2.h> -# define ARCHIVE_HAS_SHA384 -typedef SHA2_CTX archive_sha384_ctx; -# define archive_sha384_init(ctx) SHA384Init(ctx) -# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx) -# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA384_LIBSYSTEM) -# include <CommonCrypto/CommonDigest.h> -# define ARCHIVE_HAS_SHA384 -typedef CC_SHA512_CTX archive_shs384_ctx; -# define archive_shs384_init(ctx) CC_SHA384_Init(ctx) -# define archive_shs384_final(ctx, buf) CC_SHA384_Final(buf, ctx) -# define archive_shs384_update(ctx, buf, n) CC_SHA384_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA384_OPENSSL) -# include <openssl/sha.h> -# define ARCHIVE_HAS_SHA384 -typedef SHA512_CTX archive_sha384_ctx; -# define archive_sha384_init(ctx) SHA384_Init(ctx) -# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx) -# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA384_WIN) -# define ARCHIVE_HAS_SHA384 -# define SHA384_DIGEST_LENGTH 48 -typedef Digest_CTX archive_sha384_ctx; -# define archive_sha384_init(ctx) __la_hash_Init(ctx, CALG_SHA_384) -# define archive_sha384_final(ctx, buf) __la_hash_Final(buf, SHA384_DIGEST_LENGTH, ctx) -# define archive_sha384_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) -#endif - -#if defined(ARCHIVE_HASH_SHA512_LIBC) -# include <sha2.h> -# define ARCHIVE_HAS_SHA512 -typedef SHA512_CTX archive_sha512_ctx; -# define archive_sha512_init(ctx) SHA512_Init(ctx) -# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx) -# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA512_LIBC2) -# include <sha2.h> -# define ARCHIVE_HAS_SHA512 -typedef SHA512_CTX archive_sha512_ctx; -# define archive_sha512_init(ctx) SHA512Init(ctx) -# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx) -# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA512_LIBC3) -# include <sha2.h> -# define ARCHIVE_HAS_SHA512 -typedef SHA2_CTX archive_sha512_ctx; -# define archive_sha512_init(ctx) SHA512Init(ctx) -# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx) -# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA512_LIBSYSTEM) -# include <CommonCrypto/CommonDigest.h> -# define ARCHIVE_HAS_SHA512 -typedef CC_SHA512_CTX archive_shs512_ctx; -# define archive_shs512_init(ctx) CC_SHA512_Init(ctx) -# define archive_shs512_final(ctx, buf) CC_SHA512_Final(buf, ctx) -# define archive_shs512_update(ctx, buf, n) CC_SHA512_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA512_OPENSSL) -# include <openssl/sha.h> -# define ARCHIVE_HAS_SHA512 -typedef SHA512_CTX archive_sha512_ctx; -# define archive_sha512_init(ctx) SHA512_Init(ctx) -# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx) -# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n) -#elif defined(ARCHIVE_HASH_SHA512_WIN) -# define ARCHIVE_HAS_SHA512 -# define SHA512_DIGEST_LENGTH 64 -typedef Digest_CTX archive_sha512_ctx; -# define archive_sha512_init(ctx) __la_hash_Init(ctx, CALG_SHA_512) -# define archive_sha512_final(ctx, buf) __la_hash_Final(buf, SHA512_DIGEST_LENGTH, ctx) -# define archive_sha512_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) -#endif diff --git a/archivers/libarchive/files/libarchive/archive_read_disk.c b/archivers/libarchive/files/libarchive/archive_read_disk.c deleted file mode 100644 index 8fad7f13733..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_disk.c +++ /dev/null @@ -1,198 +0,0 @@ -/*- - * Copyright (c) 2003-2009 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 - * in this position and unchanged. - * 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" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk.c 189429 2009-03-06 04:35:31Z kientzle $"); - -#include "archive.h" -#include "archive_string.h" -#include "archive_entry.h" -#include "archive_private.h" -#include "archive_read_disk_private.h" - -static int _archive_read_finish(struct archive *); -static int _archive_read_close(struct archive *); -static const char *trivial_lookup_gname(void *, gid_t gid); -static const char *trivial_lookup_uname(void *, uid_t uid); - -static struct archive_vtable * -archive_read_disk_vtable(void) -{ - static struct archive_vtable av; - static int inited = 0; - - if (!inited) { - av.archive_finish = _archive_read_finish; - av.archive_close = _archive_read_close; - } - return (&av); -} - -const char * -archive_read_disk_gname(struct archive *_a, gid_t gid) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - if (a->lookup_gname != NULL) - return ((*a->lookup_gname)(a->lookup_gname_data, gid)); - return (NULL); -} - -const char * -archive_read_disk_uname(struct archive *_a, uid_t uid) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - if (a->lookup_uname != NULL) - return ((*a->lookup_uname)(a->lookup_uname_data, uid)); - return (NULL); -} - -int -archive_read_disk_set_gname_lookup(struct archive *_a, - void *private_data, - const char * (*lookup_gname)(void *private, gid_t gid), - void (*cleanup_gname)(void *private)) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - __archive_check_magic(&a->archive, ARCHIVE_READ_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_read_disk_set_gname_lookup"); - - if (a->cleanup_gname != NULL && a->lookup_gname_data != NULL) - (a->cleanup_gname)(a->lookup_gname_data); - - a->lookup_gname = lookup_gname; - a->cleanup_gname = cleanup_gname; - a->lookup_gname_data = private_data; - return (ARCHIVE_OK); -} - -int -archive_read_disk_set_uname_lookup(struct archive *_a, - void *private_data, - const char * (*lookup_uname)(void *private, uid_t uid), - void (*cleanup_uname)(void *private)) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - __archive_check_magic(&a->archive, ARCHIVE_READ_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_read_disk_set_uname_lookup"); - - if (a->cleanup_uname != NULL && a->lookup_uname_data != NULL) - (a->cleanup_uname)(a->lookup_uname_data); - - a->lookup_uname = lookup_uname; - a->cleanup_uname = cleanup_uname; - a->lookup_uname_data = private_data; - return (ARCHIVE_OK); -} - -/* - * Create a new archive_read_disk object and initialize it with global state. - */ -struct archive * -archive_read_disk_new(void) -{ - struct archive_read_disk *a; - - a = (struct archive_read_disk *)malloc(sizeof(*a)); - if (a == NULL) - return (NULL); - memset(a, 0, sizeof(*a)); - a->archive.magic = ARCHIVE_READ_DISK_MAGIC; - /* We're ready to write a header immediately. */ - a->archive.state = ARCHIVE_STATE_HEADER; - a->archive.vtable = archive_read_disk_vtable(); - a->lookup_uname = trivial_lookup_uname; - a->lookup_gname = trivial_lookup_gname; - return (&a->archive); -} - -static int -_archive_read_finish(struct archive *_a) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - - if (a->cleanup_gname != NULL && a->lookup_gname_data != NULL) - (a->cleanup_gname)(a->lookup_gname_data); - if (a->cleanup_uname != NULL && a->lookup_uname_data != NULL) - (a->cleanup_uname)(a->lookup_uname_data); - archive_string_free(&a->archive.error_string); - free(a); - return (ARCHIVE_OK); -} - -static int -_archive_read_close(struct archive *_a) -{ - (void)_a; /* UNUSED */ - return (ARCHIVE_OK); -} - -int -archive_read_disk_set_symlink_logical(struct archive *_a) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - a->symlink_mode = 'L'; - a->follow_symlinks = 1; - return (ARCHIVE_OK); -} - -int -archive_read_disk_set_symlink_physical(struct archive *_a) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - a->symlink_mode = 'P'; - a->follow_symlinks = 0; - return (ARCHIVE_OK); -} - -int -archive_read_disk_set_symlink_hybrid(struct archive *_a) -{ - struct archive_read_disk *a = (struct archive_read_disk *)_a; - a->symlink_mode = 'H'; - a->follow_symlinks = 1; /* Follow symlinks initially. */ - return (ARCHIVE_OK); -} - -/* - * Trivial implementations of gname/uname lookup functions. - * These are normally overridden by the client, but these stub - * versions ensure that we always have something that works. - */ -static const char * -trivial_lookup_gname(void *private_data, gid_t gid) -{ - (void)private_data; /* UNUSED */ - (void)gid; /* UNUSED */ - return (NULL); -} - -static const char * -trivial_lookup_uname(void *private_data, uid_t uid) -{ - (void)private_data; /* UNUSED */ - (void)uid; /* UNUSED */ - return (NULL); -} diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c deleted file mode 100644 index a6db7364d09..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * 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 "archive_platform.h" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_all.c 201248 2009-12-30 06:12:03Z kientzle $"); - -#include "archive.h" - -int -archive_read_support_compression_all(struct archive *a) -{ - /* Bzip falls back to "bunzip2" command-line */ - archive_read_support_compression_bzip2(a); - /* The decompress code doesn't use an outside library. */ - archive_read_support_compression_compress(a); - /* Gzip decompress falls back to "gunzip" command-line. */ - archive_read_support_compression_gzip(a); - /* The LZMA file format has a very weak signature, so it - * may not be feasible to keep this here, but we'll try. - * This will come back out if there are problems. */ - /* Lzma falls back to "unlzma" command-line program. */ - archive_read_support_compression_lzma(a); - /* Xz falls back to "unxz" command-line program. */ - archive_read_support_compression_xz(a); - /* The decode code doesn't use an outside library. */ - archive_read_support_compression_uu(a); - /* The decode code doesn't use an outside library. */ - archive_read_support_compression_rpm(a); - - /* Note: We always return ARCHIVE_OK here, even if some of the - * above return ARCHIVE_WARN. The intent here is to enable - * "as much as possible." Clients who need specific - * compression should enable those individually so they can - * verify the level of support. */ - /* Clear any warning messages set by the above functions. */ - archive_clear_error(a); - return (ARCHIVE_OK); -} diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c deleted file mode 100644 index 8381c9a578c..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c +++ /dev/null @@ -1,353 +0,0 @@ -/*- - * 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 "archive_platform.h" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_bzip2.c 201108 2009-12-28 03:28:21Z kientzle $"); - -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#include <stdio.h> -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_BZLIB_H -#include <bzlib.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_read_private.h" - -#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) -struct private_data { - bz_stream stream; - char *out_block; - size_t out_block_size; - char valid; /* True = decompressor is initialized */ - char eof; /* True = found end of compressed data. */ -}; - -/* Bzip2 filter */ -static ssize_t bzip2_filter_read(struct archive_read_filter *, const void **); -static int bzip2_filter_close(struct archive_read_filter *); -#endif - -/* - * Note that we can detect bzip2 archives even if we can't decompress - * them. (In fact, we like detecting them because we can give better - * error messages.) So the bid framework here gets compiled even - * if bzlib is unavailable. - */ -static int bzip2_reader_bid(struct archive_read_filter_bidder *, struct archive_read_filter *); -static int bzip2_reader_init(struct archive_read_filter *); -static int bzip2_reader_free(struct archive_read_filter_bidder *); - -int -archive_read_support_compression_bzip2(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *reader = __archive_read_get_bidder(a); - - if (reader == NULL) - return (ARCHIVE_FATAL); - - reader->data = NULL; - reader->bid = bzip2_reader_bid; - reader->init = bzip2_reader_init; - reader->options = NULL; - reader->free = bzip2_reader_free; -#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) - return (ARCHIVE_OK); -#else - archive_set_error(_a, ARCHIVE_ERRNO_MISC, - "Using external bunzip2 program"); - return (ARCHIVE_WARN); -#endif -} - -static int -bzip2_reader_free(struct archive_read_filter_bidder *self){ - (void)self; /* UNUSED */ - return (ARCHIVE_OK); -} - -/* - * Test whether we can handle this data. - * - * This logic returns zero if any part of the signature fails. It - * also tries to Do The Right Thing if a very short buffer prevents us - * from verifying as much as we would like. - */ -static int -bzip2_reader_bid(struct archive_read_filter_bidder *self, struct archive_read_filter *filter) -{ - const unsigned char *buffer; - ssize_t avail; - int bits_checked; - - (void)self; /* UNUSED */ - - /* Minimal bzip2 archive is 14 bytes. */ - buffer = __archive_read_filter_ahead(filter, 14, &avail); - if (buffer == NULL) - return (0); - - /* First three bytes must be "BZh" */ - bits_checked = 0; - if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h') - return (0); - bits_checked += 24; - - /* Next follows a compression flag which must be an ASCII digit. */ - if (buffer[3] < '1' || buffer[3] > '9') - return (0); - bits_checked += 5; - - /* After BZh[1-9], there must be either a data block - * which begins with 0x314159265359 or an end-of-data - * marker of 0x177245385090. */ - if (memcmp(buffer + 4, "\x31\x41\x59\x26\x53\x59", 6) == 0) - bits_checked += 48; - else if (memcmp(buffer + 4, "\x17\x72\x45\x38\x50\x90", 6) == 0) - bits_checked += 48; - else - return (0); - - return (bits_checked); -} - -#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) - -/* - * If we don't have the library on this system, we can't actually do the - * decompression. We can, however, still detect compressed archives - * and emit a useful message. - */ -static int -bzip2_reader_init(struct archive_read_filter *self) -{ - int r; - - r = __archive_read_program(self, "bunzip2"); - /* Note: We set the format here even if __archive_read_program() - * above fails. We do, after all, know what the format is - * even if we weren't able to read it. */ - self->code = ARCHIVE_COMPRESSION_BZIP2; - self->name = "bzip2"; - return (r); -} - - -#else - -/* - * Setup the callbacks. - */ -static int -bzip2_reader_init(struct archive_read_filter *self) -{ - static const size_t out_block_size = 64 * 1024; - void *out_block; - struct private_data *state; - - self->code = ARCHIVE_COMPRESSION_BZIP2; - self->name = "bzip2"; - - state = (struct private_data *)calloc(sizeof(*state), 1); - out_block = (unsigned char *)malloc(out_block_size); - if (self == NULL || state == NULL || out_block == NULL) { - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for bzip2 decompression"); - free(out_block); - free(state); - return (ARCHIVE_FATAL); - } - - self->data = state; - state->out_block_size = out_block_size; - state->out_block = out_block; - self->read = bzip2_filter_read; - self->skip = NULL; /* not supported */ - self->close = bzip2_filter_close; - - return (ARCHIVE_OK); -} - -/* - * Return the next block of decompressed data. - */ -static ssize_t -bzip2_filter_read(struct archive_read_filter *self, const void **p) -{ - struct private_data *state; - size_t decompressed; - const char *read_buf; - ssize_t ret; - - state = (struct private_data *)self->data; - - if (state->eof) { - *p = NULL; - return (0); - } - - /* Empty our output buffer. */ - state->stream.next_out = state->out_block; - state->stream.avail_out = state->out_block_size; - - /* Try to fill the output buffer. */ - for (;;) { - if (!state->valid) { - if (bzip2_reader_bid(self->bidder, self->upstream) == 0) { - state->eof = 1; - *p = state->out_block; - decompressed = state->stream.next_out - - state->out_block; - return (decompressed); - } - /* Initialize compression library. */ - ret = BZ2_bzDecompressInit(&(state->stream), - 0 /* library verbosity */, - 0 /* don't use low-mem algorithm */); - - /* If init fails, try low-memory algorithm instead. */ - if (ret == BZ_MEM_ERROR) - ret = BZ2_bzDecompressInit(&(state->stream), - 0 /* library verbosity */, - 1 /* do use low-mem algo */); - - if (ret != BZ_OK) { - const char *detail = NULL; - int err = ARCHIVE_ERRNO_MISC; - switch (ret) { - case BZ_PARAM_ERROR: - detail = "invalid setup parameter"; - break; - case BZ_MEM_ERROR: - err = ENOMEM; - detail = "out of memory"; - break; - case BZ_CONFIG_ERROR: - detail = "mis-compiled library"; - break; - } - archive_set_error(&self->archive->archive, err, - "Internal error initializing decompressor%s%s", - detail == NULL ? "" : ": ", - detail); - return (ARCHIVE_FATAL); - } - state->valid = 1; - } - - /* stream.next_in is really const, but bzlib - * doesn't declare it so. <sigh> */ - read_buf = - __archive_read_filter_ahead(self->upstream, 1, &ret); - if (read_buf == NULL) - return (ARCHIVE_FATAL); - state->stream.next_in = (char *)(uintptr_t)read_buf; - state->stream.avail_in = ret; - /* There is no more data, return whatever we have. */ - if (ret == 0) { - state->eof = 1; - *p = state->out_block; - decompressed = state->stream.next_out - - state->out_block; - return (decompressed); - } - - /* Decompress as much as we can in one pass. */ - ret = BZ2_bzDecompress(&(state->stream)); - __archive_read_filter_consume(self->upstream, - state->stream.next_in - read_buf); - - switch (ret) { - case BZ_STREAM_END: /* Found end of stream. */ - switch (BZ2_bzDecompressEnd(&(state->stream))) { - case BZ_OK: - break; - default: - archive_set_error(&(self->archive->archive), - ARCHIVE_ERRNO_MISC, - "Failed to clean up decompressor"); - return (ARCHIVE_FATAL); - } - state->valid = 0; - /* FALLTHROUGH */ - case BZ_OK: /* Decompressor made some progress. */ - /* If we filled our buffer, update stats and return. */ - if (state->stream.avail_out == 0) { - *p = state->out_block; - decompressed = state->stream.next_out - - state->out_block; - return (decompressed); - } - break; - default: /* Return an error. */ - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, "bzip decompression failed"); - return (ARCHIVE_FATAL); - } - } -} - -/* - * Clean up the decompressor. - */ -static int -bzip2_filter_close(struct archive_read_filter *self) -{ - struct private_data *state; - int ret = ARCHIVE_OK; - - state = (struct private_data *)self->data; - - if (state->valid) { - switch (BZ2_bzDecompressEnd(&state->stream)) { - case BZ_OK: - break; - default: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Failed to clean up decompressor"); - ret = ARCHIVE_FATAL; - } - } - - free(state->out_block); - free(state); - return (ret); -} - -#endif /* HAVE_BZLIB_H && BZ_CONFIG_ERROR */ diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c deleted file mode 100644 index 2461975e59b..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c +++ /dev/null @@ -1,444 +0,0 @@ -/*- - * 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. - */ - -/* - * This code borrows heavily from "compress" source code, which is - * protected by the following copyright. (Clause 3 dropped by request - * of the Regents.) - */ - -/*- - * Copyright (c) 1985, 1986, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Diomidis Spinellis and James A. Woods, derived from original - * work by Spencer Thomas and Joseph Orost. - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - - -#include "archive_platform.h" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_compress.c 201094 2009-12-28 02:29:21Z kientzle $"); - -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_read_private.h" - -/* - * Because LZW decompression is pretty simple, I've just implemented - * the whole decompressor here (cribbing from "compress" source code, - * of course), rather than relying on an external library. I have - * made an effort to clarify and simplify the algorithm, so the - * names and structure here don't exactly match those used by compress. - */ - -struct private_data { - /* Input variables. */ - const unsigned char *next_in; - size_t avail_in; - int bit_buffer; - int bits_avail; - size_t bytes_in_section; - - /* Output variables. */ - size_t out_block_size; - void *out_block; - - /* Decompression status variables. */ - int use_reset_code; - int end_of_stream; /* EOF status. */ - int maxcode; /* Largest code. */ - int maxcode_bits; /* Length of largest code. */ - int section_end_code; /* When to increase bits. */ - int bits; /* Current code length. */ - int oldcode; /* Previous code. */ - int finbyte; /* Last byte of prev code. */ - - /* Dictionary. */ - int free_ent; /* Next dictionary entry. */ - unsigned char suffix[65536]; - uint16_t prefix[65536]; - - /* - * Scratch area for expanding dictionary entries. Note: - * "worst" case here comes from compressing /dev/zero: the - * last code in the dictionary will code a sequence of - * 65536-256 zero bytes. Thus, we need stack space to expand - * a 65280-byte dictionary entry. (Of course, 32640:1 - * compression could also be considered the "best" case. ;-) - */ - unsigned char *stackp; - unsigned char stack[65300]; -}; - -static int compress_bidder_bid(struct archive_read_filter_bidder *, struct archive_read_filter *); -static int compress_bidder_init(struct archive_read_filter *); -static int compress_bidder_free(struct archive_read_filter_bidder *); - -static ssize_t compress_filter_read(struct archive_read_filter *, const void **); -static int compress_filter_close(struct archive_read_filter *); - -static int getbits(struct archive_read_filter *, int n); -static int next_code(struct archive_read_filter *); - -int -archive_read_support_compression_compress(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a); - - if (bidder == NULL) - return (ARCHIVE_FATAL); - - bidder->data = NULL; - bidder->bid = compress_bidder_bid; - bidder->init = compress_bidder_init; - bidder->options = NULL; - bidder->free = compress_bidder_free; - return (ARCHIVE_OK); -} - -/* - * Test whether we can handle this data. - * - * This logic returns zero if any part of the signature fails. It - * also tries to Do The Right Thing if a very short buffer prevents us - * from verifying as much as we would like. - */ -static int -compress_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *filter) -{ - const unsigned char *buffer; - ssize_t avail; - int bits_checked; - - (void)self; /* UNUSED */ - - buffer = __archive_read_filter_ahead(filter, 2, &avail); - - if (buffer == NULL) - return (0); - - bits_checked = 0; - if (buffer[0] != 037) /* Verify first ID byte. */ - return (0); - bits_checked += 8; - - if (buffer[1] != 0235) /* Verify second ID byte. */ - return (0); - bits_checked += 8; - - /* - * TODO: Verify more. - */ - - return (bits_checked); -} - -/* - * Setup the callbacks. - */ -static int -compress_bidder_init(struct archive_read_filter *self) -{ - struct private_data *state; - static const size_t out_block_size = 64 * 1024; - void *out_block; - int code; - - self->code = ARCHIVE_COMPRESSION_COMPRESS; - self->name = "compress (.Z)"; - - state = (struct private_data *)calloc(sizeof(*state), 1); - out_block = malloc(out_block_size); - if (state == NULL || out_block == NULL) { - free(out_block); - free(state); - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for %s decompression", - self->name); - return (ARCHIVE_FATAL); - } - - self->data = state; - state->out_block_size = out_block_size; - state->out_block = out_block; - self->read = compress_filter_read; - self->skip = NULL; /* not supported */ - self->close = compress_filter_close; - - /* XXX MOVE THE FOLLOWING OUT OF INIT() XXX */ - - (void)getbits(self, 8); /* Skip first signature byte. */ - (void)getbits(self, 8); /* Skip second signature byte. */ - - code = getbits(self, 8); - state->maxcode_bits = code & 0x1f; - state->maxcode = (1 << state->maxcode_bits); - state->use_reset_code = code & 0x80; - - /* Initialize decompressor. */ - state->free_ent = 256; - state->stackp = state->stack; - if (state->use_reset_code) - state->free_ent++; - state->bits = 9; - state->section_end_code = (1<<state->bits) - 1; - state->oldcode = -1; - for (code = 255; code >= 0; code--) { - state->prefix[code] = 0; - state->suffix[code] = code; - } - next_code(self); - - return (ARCHIVE_OK); -} - -/* - * Return a block of data from the decompression buffer. Decompress more - * as necessary. - */ -static ssize_t -compress_filter_read(struct archive_read_filter *self, const void **pblock) -{ - struct private_data *state; - unsigned char *p, *start, *end; - int ret; - - state = (struct private_data *)self->data; - if (state->end_of_stream) { - *pblock = NULL; - return (0); - } - p = start = (unsigned char *)state->out_block; - end = start + state->out_block_size; - - while (p < end && !state->end_of_stream) { - if (state->stackp > state->stack) { - *p++ = *--state->stackp; - } else { - ret = next_code(self); - if (ret == -1) - state->end_of_stream = ret; - else if (ret != ARCHIVE_OK) - return (ret); - } - } - - *pblock = start; - return (p - start); -} - -/* - * Clean up the reader. - */ -static int -compress_bidder_free(struct archive_read_filter_bidder *self) -{ - self->data = NULL; - return (ARCHIVE_OK); -} - -/* - * Close and release the filter. - */ -static int -compress_filter_close(struct archive_read_filter *self) -{ - struct private_data *state = (struct private_data *)self->data; - - free(state->out_block); - free(state); - return (ARCHIVE_OK); -} - -/* - * Process the next code and fill the stack with the expansion - * of the code. Returns ARCHIVE_FATAL if there is a fatal I/O or - * format error, ARCHIVE_EOF if we hit end of data, ARCHIVE_OK otherwise. - */ -static int -next_code(struct archive_read_filter *self) -{ - struct private_data *state = (struct private_data *)self->data; - int code, newcode; - - static int debug_buff[1024]; - static unsigned debug_index; - - code = newcode = getbits(self, state->bits); - if (code < 0) - return (code); - - debug_buff[debug_index++] = code; - if (debug_index >= sizeof(debug_buff)/sizeof(debug_buff[0])) - debug_index = 0; - - /* If it's a reset code, reset the dictionary. */ - if ((code == 256) && state->use_reset_code) { - /* - * The original 'compress' implementation blocked its - * I/O in a manner that resulted in junk bytes being - * inserted after every reset. The next section skips - * this junk. (Yes, the number of *bytes* to skip is - * a function of the current *bit* length.) - */ - int skip_bytes = state->bits - - (state->bytes_in_section % state->bits); - skip_bytes %= state->bits; - state->bits_avail = 0; /* Discard rest of this byte. */ - while (skip_bytes-- > 0) { - code = getbits(self, 8); - if (code < 0) - return (code); - } - /* Now, actually do the reset. */ - state->bytes_in_section = 0; - state->bits = 9; - state->section_end_code = (1 << state->bits) - 1; - state->free_ent = 257; - state->oldcode = -1; - return (next_code(self)); - } - - if (code > state->free_ent) { - /* An invalid code is a fatal error. */ - archive_set_error(&(self->archive->archive), -1, - "Invalid compressed data"); - return (ARCHIVE_FATAL); - } - - /* Special case for KwKwK string. */ - if (code >= state->free_ent) { - *state->stackp++ = state->finbyte; - code = state->oldcode; - } - - /* Generate output characters in reverse order. */ - while (code >= 256) { - *state->stackp++ = state->suffix[code]; - code = state->prefix[code]; - } - *state->stackp++ = state->finbyte = code; - - /* Generate the new entry. */ - code = state->free_ent; - if (code < state->maxcode && state->oldcode >= 0) { - state->prefix[code] = state->oldcode; - state->suffix[code] = state->finbyte; - ++state->free_ent; - } - if (state->free_ent > state->section_end_code) { - state->bits++; - state->bytes_in_section = 0; - if (state->bits == state->maxcode_bits) - state->section_end_code = state->maxcode; - else - state->section_end_code = (1 << state->bits) - 1; - } - - /* Remember previous code. */ - state->oldcode = newcode; - return (ARCHIVE_OK); -} - -/* - * Return next 'n' bits from stream. - * - * -1 indicates end of available data. - */ -static int -getbits(struct archive_read_filter *self, int n) -{ - struct private_data *state = (struct private_data *)self->data; - int code; - ssize_t ret; - static const int mask[] = { - 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, - 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff - }; - - while (state->bits_avail < n) { - if (state->avail_in <= 0) { - state->next_in - = __archive_read_filter_ahead(self->upstream, - 1, &ret); - if (ret == 0) - return (-1); - if (ret < 0 || state->next_in == NULL) - return (ARCHIVE_FATAL); - state->avail_in = ret; - __archive_read_filter_consume(self->upstream, ret); - } - state->bit_buffer |= *state->next_in++ << state->bits_avail; - state->avail_in--; - state->bits_avail += 8; - state->bytes_in_section++; - } - - code = state->bit_buffer; - state->bit_buffer >>= n; - state->bits_avail -= n; - - return (code & mask[n]); -} diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c deleted file mode 100644 index 8cc924c9fc1..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c +++ /dev/null @@ -1,465 +0,0 @@ -/*- - * 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 "archive_platform.h" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_gzip.c 201082 2009-12-28 02:05:28Z kientzle $"); - - -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_ZLIB_H -#include <zlib.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_read_private.h" - -#ifdef HAVE_ZLIB_H -struct private_data { - z_stream stream; - char in_stream; - unsigned char *out_block; - size_t out_block_size; - int64_t total_out; - unsigned long crc; - char eof; /* True = found end of compressed data. */ -}; - -/* Gzip Filter. */ -static ssize_t gzip_filter_read(struct archive_read_filter *, const void **); -static int gzip_filter_close(struct archive_read_filter *); -#endif - -/* - * Note that we can detect gzip archives even if we can't decompress - * them. (In fact, we like detecting them because we can give better - * error messages.) So the bid framework here gets compiled even - * if zlib is unavailable. - * - * TODO: If zlib is unavailable, gzip_bidder_init() should - * use the compress_program framework to try to fire up an external - * gunzip program. - */ -static int gzip_bidder_bid(struct archive_read_filter_bidder *, - struct archive_read_filter *); -static int gzip_bidder_init(struct archive_read_filter *); - -int -archive_read_support_compression_gzip(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a); - - if (bidder == NULL) - return (ARCHIVE_FATAL); - - bidder->data = NULL; - bidder->bid = gzip_bidder_bid; - bidder->init = gzip_bidder_init; - bidder->options = NULL; - bidder->free = NULL; /* No data, so no cleanup necessary. */ - /* Signal the extent of gzip support with the return value here. */ -#if HAVE_ZLIB_H - return (ARCHIVE_OK); -#else - archive_set_error(_a, ARCHIVE_ERRNO_MISC, - "Using external gunzip program"); - return (ARCHIVE_WARN); -#endif -} - -/* - * Read and verify the header. - * - * Returns zero if the header couldn't be validated, else returns - * number of bytes in header. If pbits is non-NULL, it receives a - * count of bits verified, suitable for use by bidder. - */ -static int -peek_at_header(struct archive_read_filter *filter, int *pbits) -{ - const unsigned char *p; - ssize_t avail, len; - int bits = 0; - int header_flags; - - /* Start by looking at the first ten bytes of the header, which - * is all fixed layout. */ - len = 10; - p = __archive_read_filter_ahead(filter, len, &avail); - if (p == NULL || avail == 0) - return (0); - if (p[0] != 037) - return (0); - bits += 8; - if (p[1] != 0213) - return (0); - bits += 8; - if (p[2] != 8) /* We only support deflation. */ - return (0); - bits += 8; - if ((p[3] & 0xE0)!= 0) /* No reserved flags set. */ - return (0); - bits += 3; - header_flags = p[3]; - /* Bytes 4-7 are mod time. */ - /* Byte 8 is deflate flags. */ - /* XXXX TODO: return deflate flags back to consume_header for use - in initializing the decompressor. */ - /* Byte 9 is OS. */ - - /* Optional extra data: 2 byte length plus variable body. */ - if (header_flags & 4) { - p = __archive_read_filter_ahead(filter, len + 2, &avail); - if (p == NULL) - return (0); - len += ((int)p[len + 1] << 8) | (int)p[len]; - len += 2; - } - - /* Null-terminated optional filename. */ - if (header_flags & 8) { - do { - ++len; - if (avail < len) - p = __archive_read_filter_ahead(filter, - len, &avail); - if (p == NULL) - return (0); - } while (p[len - 1] != 0); - } - - /* Null-terminated optional comment. */ - if (header_flags & 16) { - do { - ++len; - if (avail < len) - p = __archive_read_filter_ahead(filter, - len, &avail); - if (p == NULL) - return (0); - } while (p[len - 1] != 0); - } - - /* Optional header CRC */ - if ((header_flags & 2)) { - p = __archive_read_filter_ahead(filter, len + 2, &avail); - if (p == NULL) - return (0); -#if 0 - int hcrc = ((int)p[len + 1] << 8) | (int)p[len]; - int crc = /* XXX TODO: Compute header CRC. */; - if (crc != hcrc) - return (0); - bits += 16; -#endif - len += 2; - } - - if (pbits != NULL) - *pbits = bits; - return (len); -} - -/* - * Bidder just verifies the header and returns the number of verified bits. - */ -static int -gzip_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *filter) -{ - int bits_checked; - - (void)self; /* UNUSED */ - - if (peek_at_header(filter, &bits_checked)) - return (bits_checked); - return (0); -} - - -#ifndef HAVE_ZLIB_H - -/* - * If we don't have the library on this system, we can't do the - * decompression directly. We can, however, try to run gunzip - * in case that's available. - */ -static int -gzip_bidder_init(struct archive_read_filter *self) -{ - int r; - - r = __archive_read_program(self, "gunzip"); - /* Note: We set the format here even if __archive_read_program() - * above fails. We do, after all, know what the format is - * even if we weren't able to read it. */ - self->code = ARCHIVE_COMPRESSION_GZIP; - self->name = "gzip"; - return (r); -} - -#else - -/* - * Initialize the filter object. - */ -static int -gzip_bidder_init(struct archive_read_filter *self) -{ - struct private_data *state; - static const size_t out_block_size = 64 * 1024; - void *out_block; - - self->code = ARCHIVE_COMPRESSION_GZIP; - self->name = "gzip"; - - state = (struct private_data *)calloc(sizeof(*state), 1); - out_block = (unsigned char *)malloc(out_block_size); - if (state == NULL || out_block == NULL) { - free(out_block); - free(state); - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for gzip decompression"); - return (ARCHIVE_FATAL); - } - - self->data = state; - state->out_block_size = out_block_size; - state->out_block = out_block; - self->read = gzip_filter_read; - self->skip = NULL; /* not supported */ - self->close = gzip_filter_close; - - state->in_stream = 0; /* We're not actually within a stream yet. */ - - return (ARCHIVE_OK); -} - -static int -consume_header(struct archive_read_filter *self) -{ - struct private_data *state; - ssize_t avail; - size_t len; - int ret; - - state = (struct private_data *)self->data; - - /* If this is a real header, consume it. */ - len = peek_at_header(self->upstream, NULL); - if (len == 0) - return (ARCHIVE_EOF); - __archive_read_filter_consume(self->upstream, len); - - /* Initialize CRC accumulator. */ - state->crc = crc32(0L, NULL, 0); - - /* Initialize compression library. */ - state->stream.next_in = (unsigned char *)(uintptr_t) - __archive_read_filter_ahead(self->upstream, 1, &avail); - state->stream.avail_in = avail; - ret = inflateInit2(&(state->stream), - -15 /* Don't check for zlib header */); - - /* Decipher the error code. */ - switch (ret) { - case Z_OK: - state->in_stream = 1; - return (ARCHIVE_OK); - case Z_STREAM_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "invalid setup parameter"); - break; - case Z_MEM_ERROR: - archive_set_error(&self->archive->archive, ENOMEM, - "Internal error initializing compression library: " - "out of memory"); - break; - case Z_VERSION_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "invalid library version"); - break; - default: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - " Zlib error %d", ret); - break; - } - return (ARCHIVE_FATAL); -} - -static int -consume_trailer(struct archive_read_filter *self) -{ - struct private_data *state; - const unsigned char *p; - ssize_t avail; - - state = (struct private_data *)self->data; - - state->in_stream = 0; - switch (inflateEnd(&(state->stream))) { - case Z_OK: - break; - default: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Failed to clean up gzip decompressor"); - return (ARCHIVE_FATAL); - } - - /* GZip trailer is a fixed 8 byte structure. */ - p = __archive_read_filter_ahead(self->upstream, 8, &avail); - if (p == NULL || avail == 0) - return (ARCHIVE_FATAL); - - /* XXX TODO: Verify the length and CRC. */ - - /* We've verified the trailer, so consume it now. */ - __archive_read_filter_consume(self->upstream, 8); - - return (ARCHIVE_OK); -} - -static ssize_t -gzip_filter_read(struct archive_read_filter *self, const void **p) -{ - struct private_data *state; - size_t decompressed; - ssize_t avail_in; - int ret; - - state = (struct private_data *)self->data; - - /* Empty our output buffer. */ - state->stream.next_out = state->out_block; - state->stream.avail_out = state->out_block_size; - - /* Try to fill the output buffer. */ - while (state->stream.avail_out > 0 && !state->eof) { - /* If we're not in a stream, read a header - * and initialize the decompression library. */ - if (!state->in_stream) { - ret = consume_header(self); - if (ret == ARCHIVE_EOF) { - state->eof = 1; - break; - } - if (ret < ARCHIVE_OK) - return (ret); - } - - /* Peek at the next available data. */ - /* ZLib treats stream.next_in as const but doesn't declare - * it so, hence this ugly cast. */ - state->stream.next_in = (unsigned char *)(uintptr_t) - __archive_read_filter_ahead(self->upstream, 1, &avail_in); - if (state->stream.next_in == NULL) - return (ARCHIVE_FATAL); - state->stream.avail_in = avail_in; - - /* Decompress and consume some of that data. */ - ret = inflate(&(state->stream), 0); - switch (ret) { - case Z_OK: /* Decompressor made some progress. */ - __archive_read_filter_consume(self->upstream, - avail_in - state->stream.avail_in); - break; - case Z_STREAM_END: /* Found end of stream. */ - __archive_read_filter_consume(self->upstream, - avail_in - state->stream.avail_in); - /* Consume the stream trailer; release the - * decompression library. */ - ret = consume_trailer(self); - if (ret < ARCHIVE_OK) - return (ret); - break; - default: - /* Return an error. */ - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "gzip decompression failed"); - return (ARCHIVE_FATAL); - } - } - - /* We've read as much as we can. */ - decompressed = state->stream.next_out - state->out_block; - state->total_out += decompressed; - if (decompressed == 0) - *p = NULL; - else - *p = state->out_block; - return (decompressed); -} - -/* - * Clean up the decompressor. - */ -static int -gzip_filter_close(struct archive_read_filter *self) -{ - struct private_data *state; - int ret; - - state = (struct private_data *)self->data; - ret = ARCHIVE_OK; - - if (state->in_stream) { - switch (inflateEnd(&(state->stream))) { - case Z_OK: - break; - default: - archive_set_error(&(self->archive->archive), - ARCHIVE_ERRNO_MISC, - "Failed to clean up gzip compressor"); - ret = ARCHIVE_FATAL; - } - } - - free(state->out_block); - free(state); - return (ret); -} - -#endif /* HAVE_ZLIB_H */ diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c deleted file mode 100644 index 955d06d9aa1..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * 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 "archive_platform.h" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_none.c 185679 2008-12-06 06:45:15Z kientzle $"); - -#include "archive.h" - -/* - * Uncompressed streams are handled implicitly by the read core, - * so this is now a no-op. - */ -int -archive_read_support_compression_none(struct archive *a) -{ - (void)a; /* UNUSED */ - return (ARCHIVE_OK); -} diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c deleted file mode 100644 index 0c63f2e8312..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c +++ /dev/null @@ -1,459 +0,0 @@ -/*- - * Copyright (c) 2007 Joerg Sonnenberger - * 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" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_program.c 201112 2009-12-28 06:59:35Z kientzle $"); - -#ifdef HAVE_SYS_WAIT_H -# include <sys/wait.h> -#endif -#ifdef HAVE_ERRNO_H -# include <errno.h> -#endif -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif -#ifdef HAVE_LIMITS_H -# include <limits.h> -#endif -#ifdef HAVE_SIGNAL_H -# include <signal.h> -#endif -#ifdef HAVE_STDLIB_H -# include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -# include <string.h> -#endif -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_read_private.h" - -int -archive_read_support_compression_program(struct archive *a, const char *cmd) -{ - return (archive_read_support_compression_program_signature(a, cmd, NULL, 0)); -} - - -/* This capability is only available on POSIX systems. */ -#if (!defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \ - !(defined(HAVE_FORK) || defined(HAVE_VFORK))) && (!defined(_WIN32) || defined(__CYGWIN__)) - -/* - * On non-Posix systems, allow the program to build, but choke if - * this function is actually invoked. - */ -int -archive_read_support_compression_program_signature(struct archive *_a, - const char *cmd, void *signature, size_t signature_len) -{ - (void)_a; /* UNUSED */ - (void)cmd; /* UNUSED */ - (void)signature; /* UNUSED */ - (void)signature_len; /* UNUSED */ - - archive_set_error(_a, -1, - "External compression programs not supported on this platform"); - return (ARCHIVE_FATAL); -} - -int -__archive_read_program(struct archive_read_filter *self, const char *cmd) -{ - (void)self; /* UNUSED */ - (void)cmd; /* UNUSED */ - - archive_set_error(&self->archive->archive, -1, - "External compression programs not supported on this platform"); - return (ARCHIVE_FATAL); -} - -#else - -#include "filter_fork.h" - -/* - * The bidder object stores the command and the signature to watch for. - * The 'inhibit' entry here is used to ensure that unchecked filters never - * bid twice in the same pipeline. - */ -struct program_bidder { - char *cmd; - void *signature; - size_t signature_len; - int inhibit; -}; - -static int program_bidder_bid(struct archive_read_filter_bidder *, - struct archive_read_filter *upstream); -static int program_bidder_init(struct archive_read_filter *); -static int program_bidder_free(struct archive_read_filter_bidder *); - -/* - * The actual filter needs to track input and output data. - */ -struct program_filter { - char *description; - pid_t child; - int exit_status; - int waitpid_return; - int child_stdin, child_stdout; - - char *out_buf; - size_t out_buf_len; -}; - -static ssize_t program_filter_read(struct archive_read_filter *, - const void **); -static int program_filter_close(struct archive_read_filter *); - -int -archive_read_support_compression_program_signature(struct archive *_a, - const char *cmd, const void *signature, size_t signature_len) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder; - struct program_bidder *state; - - /* - * Get a bidder object from the read core. - */ - bidder = __archive_read_get_bidder(a); - if (bidder == NULL) - return (ARCHIVE_FATAL); - - /* - * Allocate our private state. - */ - state = (struct program_bidder *)calloc(sizeof (*state), 1); - if (state == NULL) - return (ARCHIVE_FATAL); - state->cmd = strdup(cmd); - if (signature != NULL && signature_len > 0) { - state->signature_len = signature_len; - state->signature = malloc(signature_len); - memcpy(state->signature, signature, signature_len); - } - - /* - * Fill in the bidder object. - */ - bidder->data = state; - bidder->bid = program_bidder_bid; - bidder->init = program_bidder_init; - bidder->options = NULL; - bidder->free = program_bidder_free; - return (ARCHIVE_OK); -} - -static int -program_bidder_free(struct archive_read_filter_bidder *self) -{ - struct program_bidder *state = (struct program_bidder *)self->data; - free(state->cmd); - free(state->signature); - free(self->data); - return (ARCHIVE_OK); -} - -/* - * If we do have a signature, bid only if that matches. - * - * If there's no signature, we bid INT_MAX the first time - * we're called, then never bid again. - */ -static int -program_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *upstream) -{ - struct program_bidder *state = self->data; - const char *p; - - /* If we have a signature, use that to match. */ - if (state->signature_len > 0) { - p = __archive_read_filter_ahead(upstream, - state->signature_len, NULL); - if (p == NULL) - return (0); - /* No match, so don't bid. */ - if (memcmp(p, state->signature, state->signature_len) != 0) - return (0); - return ((int)state->signature_len * 8); - } - - /* Otherwise, bid once and then never bid again. */ - if (state->inhibit) - return (0); - state->inhibit = 1; - return (INT_MAX); -} - -/* - * Shut down the child, return ARCHIVE_OK if it exited normally. - * - * Note that the return value is sticky; if we're called again, - * we won't reap the child again, but we will return the same status - * (including error message if the child came to a bad end). - */ -static int -child_stop(struct archive_read_filter *self, struct program_filter *state) -{ - /* Close our side of the I/O with the child. */ - if (state->child_stdin != -1) { - close(state->child_stdin); - state->child_stdin = -1; - } - if (state->child_stdout != -1) { - close(state->child_stdout); - state->child_stdout = -1; - } - - if (state->child != 0) { - /* Reap the child. */ - do { - state->waitpid_return - = waitpid(state->child, &state->exit_status, 0); - } while (state->waitpid_return == -1 && errno == EINTR); - state->child = 0; - } - - if (state->waitpid_return < 0) { - /* waitpid() failed? This is ugly. */ - archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC, - "Child process exited badly"); - return (ARCHIVE_WARN); - } - -#if !defined(_WIN32) || defined(__CYGWIN__) - if (WIFSIGNALED(state->exit_status)) { -#ifdef SIGPIPE - /* If the child died because we stopped reading before - * it was done, that's okay. Some archive formats - * have padding at the end that we routinely ignore. */ - /* The alternative to this would be to add a step - * before close(child_stdout) above to read from the - * child until the child has no more to write. */ - if (WTERMSIG(state->exit_status) == SIGPIPE) - return (ARCHIVE_OK); -#endif - archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC, - "Child process exited with signal %d", - WTERMSIG(state->exit_status)); - return (ARCHIVE_WARN); - } -#endif /* !_WIN32 || __CYGWIN__ */ - - if (WIFEXITED(state->exit_status)) { - if (WEXITSTATUS(state->exit_status) == 0) - return (ARCHIVE_OK); - - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Child process exited with status %d", - WEXITSTATUS(state->exit_status)); - return (ARCHIVE_WARN); - } - - return (ARCHIVE_WARN); -} - -/* - * Use select() to decide whether the child is ready for read or write. - */ -static ssize_t -child_read(struct archive_read_filter *self, char *buf, size_t buf_len) -{ - struct program_filter *state = self->data; - ssize_t ret, requested, avail; - const char *p; - - requested = buf_len > SSIZE_MAX ? SSIZE_MAX : buf_len; - - for (;;) { - do { - ret = read(state->child_stdout, buf, requested); - } while (ret == -1 && errno == EINTR); - - if (ret > 0) - return (ret); - if (ret == 0 || (ret == -1 && errno == EPIPE)) - /* Child has closed its output; reap the child - * and return the status. */ - return (child_stop(self, state)); - if (ret == -1 && errno != EAGAIN) - return (-1); - - if (state->child_stdin == -1) { - /* Block until child has some I/O ready. */ - __archive_check_child(state->child_stdin, - state->child_stdout); - continue; - } - - /* Get some more data from upstream. */ - p = __archive_read_filter_ahead(self->upstream, 1, &avail); - if (p == NULL) { - close(state->child_stdin); - state->child_stdin = -1; - fcntl(state->child_stdout, F_SETFL, 0); - if (avail < 0) - return (avail); - continue; - } - - do { - ret = write(state->child_stdin, p, avail); - } while (ret == -1 && errno == EINTR); - - if (ret > 0) { - /* Consume whatever we managed to write. */ - __archive_read_filter_consume(self->upstream, ret); - } else if (ret == -1 && errno == EAGAIN) { - /* Block until child has some I/O ready. */ - __archive_check_child(state->child_stdin, - state->child_stdout); - } else { - /* Write failed. */ - close(state->child_stdin); - state->child_stdin = -1; - fcntl(state->child_stdout, F_SETFL, 0); - /* If it was a bad error, we're done; otherwise - * it was EPIPE or EOF, and we can still read - * from the child. */ - if (ret == -1 && errno != EPIPE) - return (-1); - } - } -} - -int -__archive_read_program(struct archive_read_filter *self, const char *cmd) -{ - struct program_filter *state; - static const size_t out_buf_len = 65536; - char *out_buf; - char *description; - const char *prefix = "Program: "; - - state = (struct program_filter *)calloc(1, sizeof(*state)); - out_buf = (char *)malloc(out_buf_len); - description = (char *)malloc(strlen(prefix) + strlen(cmd) + 1); - if (state == NULL || out_buf == NULL || description == NULL) { - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate input data"); - free(state); - free(out_buf); - free(description); - return (ARCHIVE_FATAL); - } - - self->code = ARCHIVE_COMPRESSION_PROGRAM; - state->description = description; - strcpy(state->description, prefix); - strcat(state->description, cmd); - self->name = state->description; - - state->out_buf = out_buf; - state->out_buf_len = out_buf_len; - - if ((state->child = __archive_create_child(cmd, - &state->child_stdin, &state->child_stdout)) == -1) { - free(state->out_buf); - free(state); - archive_set_error(&self->archive->archive, EINVAL, - "Can't initialise filter"); - return (ARCHIVE_FATAL); - } - - self->data = state; - self->read = program_filter_read; - self->skip = NULL; - self->close = program_filter_close; - - /* XXX Check that we can read at least one byte? */ - return (ARCHIVE_OK); -} - -static int -program_bidder_init(struct archive_read_filter *self) -{ - struct program_bidder *bidder_state; - - bidder_state = (struct program_bidder *)self->bidder->data; - return (__archive_read_program(self, bidder_state->cmd)); -} - -static ssize_t -program_filter_read(struct archive_read_filter *self, const void **buff) -{ - struct program_filter *state; - ssize_t bytes; - size_t total; - char *p; - - state = (struct program_filter *)self->data; - - total = 0; - p = state->out_buf; - while (state->child_stdout != -1 && total < state->out_buf_len) { - bytes = child_read(self, p, state->out_buf_len - total); - if (bytes < 0) - /* No recovery is possible if we can no longer - * read from the child. */ - return (ARCHIVE_FATAL); - if (bytes == 0) - /* We got EOF from the child. */ - break; - total += bytes; - p += bytes; - } - - *buff = state->out_buf; - return (total); -} - -static int -program_filter_close(struct archive_read_filter *self) -{ - struct program_filter *state; - int e; - - state = (struct program_filter *)self->data; - e = child_stop(self, state); - - /* Release our private data. */ - free(state->out_buf); - free(state->description); - free(state); - - return (e); -} - -#endif /* !defined(HAVE_PIPE) || !defined(HAVE_VFORK) || !defined(HAVE_FCNTL) */ diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c deleted file mode 100644 index 051baa5e122..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c +++ /dev/null @@ -1,287 +0,0 @@ -/*- - * Copyright (c) 2009 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_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#include "archive.h" -#include "archive_endian.h" -#include "archive_private.h" -#include "archive_read_private.h" - -struct rpm { - int64_t total_in; - size_t hpos; - size_t hlen; - unsigned char header[16]; - enum { - ST_LEAD, /* Skipping 'Lead' section. */ - ST_HEADER, /* Reading 'Header' section; - * first 16 bytes. */ - ST_HEADER_DATA, /* Skipping 'Header' section. */ - ST_PADDING, /* Skipping padding data after the - * 'Header' section. */ - ST_ARCHIVE /* Reading 'Archive' section. */ - } state; - int first_header; -}; -#define RPM_LEAD_SIZE 96 /* Size of 'Lead' section. */ - -static int rpm_bidder_bid(struct archive_read_filter_bidder *, - struct archive_read_filter *); -static int rpm_bidder_init(struct archive_read_filter *); - -static ssize_t rpm_filter_read(struct archive_read_filter *, - const void **); -static int rpm_filter_close(struct archive_read_filter *); - -int -archive_read_support_compression_rpm(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder; - - bidder = __archive_read_get_bidder(a); - archive_clear_error(_a); - if (bidder == NULL) - return (ARCHIVE_FATAL); - - bidder->data = NULL; - bidder->bid = rpm_bidder_bid; - bidder->init = rpm_bidder_init; - bidder->options = NULL; - bidder->free = NULL; - return (ARCHIVE_OK); -} - -static int -rpm_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *filter) -{ - const unsigned char *b; - ssize_t avail; - int bits_checked; - - (void)self; /* UNUSED */ - - b = __archive_read_filter_ahead(filter, 8, &avail); - if (b == NULL) - return (0); - - bits_checked = 0; - /* - * Verify Header Magic Bytes : 0xed 0xab 0xee 0xdb - */ - if (b[0] != 0xed) - return (0); - bits_checked += 8; - if (b[1] != 0xab) - return (0); - bits_checked += 8; - if (b[2] != 0xee) - return (0); - bits_checked += 8; - if (b[3] != 0xdb) - return (0); - bits_checked += 8; - /* - * Check major version. - */ - if (b[4] != 3 && b[4] != 4) - return (0); - bits_checked += 8; - /* - * Check package type; binary or source. - */ - if (b[6] != 0) - return (0); - bits_checked += 8; - if (b[7] != 0 && b[7] != 1) - return (0); - bits_checked += 8; - - return (bits_checked); -} - -static int -rpm_bidder_init(struct archive_read_filter *self) -{ - struct rpm *rpm; - - self->code = ARCHIVE_COMPRESSION_RPM; - self->name = "rpm"; - self->read = rpm_filter_read; - self->skip = NULL; /* not supported */ - self->close = rpm_filter_close; - - rpm = (struct rpm *)calloc(sizeof(*rpm), 1); - if (rpm == NULL) { - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for rpm"); - return (ARCHIVE_FATAL); - } - - self->data = rpm; - rpm->state = ST_LEAD; - - return (ARCHIVE_OK); -} - -static ssize_t -rpm_filter_read(struct archive_read_filter *self, const void **buff) -{ - struct rpm *rpm; - const unsigned char *b; - ssize_t avail_in, total; - size_t used, n; - uint32_t section; - uint32_t bytes; - - rpm = (struct rpm *)self->data; - *buff = NULL; - total = avail_in = 0; - b = NULL; - used = 0; - do { - if (b == NULL) { - b = __archive_read_filter_ahead(self->upstream, 1, - &avail_in); - if (b == NULL) { - if (avail_in < 0) - return (ARCHIVE_FATAL); - else - break; - } - } - - switch (rpm->state) { - case ST_LEAD: - if (rpm->total_in + avail_in < RPM_LEAD_SIZE) - used += avail_in; - else { - n = RPM_LEAD_SIZE - rpm->total_in; - used += n; - b += n; - rpm->state = ST_HEADER; - rpm->hpos = 0; - rpm->hlen = 0; - rpm->first_header = 1; - } - break; - case ST_HEADER: - n = 16 - rpm->hpos; - if (n > avail_in - used) - n = avail_in - used; - memcpy(rpm->header+rpm->hpos, b, n); - b += n; - used += n; - rpm->hpos += n; - - if (rpm->hpos == 16) { - if (rpm->header[0] != 0x8e || - rpm->header[1] != 0xad || - rpm->header[2] != 0xe8 || - rpm->header[3] != 0x01) { - if (rpm->first_header) { - archive_set_error( - &self->archive->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Unrecoginized rpm header"); - return (ARCHIVE_FATAL); - } - rpm->state = ST_ARCHIVE; - *buff = rpm->header; - total = rpm->hpos; - break; - } - /* Calculate 'Header' length. */ - section = archive_be32dec(rpm->header+8); - bytes = archive_be32dec(rpm->header+12); - rpm->hlen = 16 + section * 16 + bytes; - rpm->state = ST_HEADER_DATA; - rpm->first_header = 0; - } - break; - case ST_HEADER_DATA: - n = rpm->hlen - rpm->hpos; - if (n > avail_in - used) - n = avail_in - used; - b += n; - used += n; - rpm->hpos += n; - if (rpm->hpos == rpm->hlen) - rpm->state = ST_PADDING; - break; - case ST_PADDING: - while (used < (size_t)avail_in) { - if (*b != 0) { - /* Read next header. */ - rpm->state = ST_HEADER; - rpm->hpos = 0; - rpm->hlen = 0; - break; - } - b++; - used++; - } - break; - case ST_ARCHIVE: - *buff = b; - total = avail_in; - used = avail_in; - break; - } - if (used == (size_t)avail_in) { - rpm->total_in += used; - __archive_read_filter_consume(self->upstream, used); - b = NULL; - used = 0; - } - } while (total == 0 && avail_in > 0); - - if (used > 0 && b != NULL) { - rpm->total_in += used; - __archive_read_filter_consume(self->upstream, used); - } - return (total); -} - -static int -rpm_filter_close(struct archive_read_filter *self) -{ - struct rpm *rpm; - - rpm = (struct rpm *)self->data; - free(rpm); - - return (ARCHIVE_OK); -} - diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c deleted file mode 100644 index 1e3052097dc..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c +++ /dev/null @@ -1,627 +0,0 @@ -/*- - * Copyright (c) 2009 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" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_uu.c 201248 2009-12-30 06:12:03Z kientzle $"); - -#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 "archive.h" -#include "archive_private.h" -#include "archive_read_private.h" - -struct uudecode { - int64_t total; - unsigned char *in_buff; -#define IN_BUFF_SIZE (1024) - int in_cnt; - size_t in_allocated; - unsigned char *out_buff; -#define OUT_BUFF_SIZE (64 * 1024) - int state; -#define ST_FIND_HEAD 0 -#define ST_READ_UU 1 -#define ST_UUEND 2 -#define ST_READ_BASE64 3 -}; - -static int uudecode_bidder_bid(struct archive_read_filter_bidder *, - struct archive_read_filter *filter); -static int uudecode_bidder_init(struct archive_read_filter *); - -static ssize_t uudecode_filter_read(struct archive_read_filter *, - const void **); -static int uudecode_filter_close(struct archive_read_filter *); - -int -archive_read_support_compression_uu(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder; - - bidder = __archive_read_get_bidder(a); - archive_clear_error(_a); - if (bidder == NULL) - return (ARCHIVE_FATAL); - - bidder->data = NULL; - bidder->bid = uudecode_bidder_bid; - bidder->init = uudecode_bidder_init; - bidder->options = NULL; - bidder->free = NULL; - return (ARCHIVE_OK); -} - -static const unsigned char ascii[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\n', 0, 0, '\r', 0, 0, /* 00 - 0F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 - 1F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 - 2F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 30 - 3F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40 - 4F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 50 - 5F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 60 - 6F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, /* 70 - 7F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 - 8F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90 - 9F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A0 - AF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* B0 - BF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* C0 - CF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* D0 - DF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* E0 - EF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F0 - FF */ -}; - -static const unsigned char uuchar[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00 - 0F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 - 1F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 - 2F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 30 - 3F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40 - 4F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 50 - 5F */ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 - 7F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 - 8F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90 - 9F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A0 - AF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* B0 - BF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* C0 - CF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* D0 - DF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* E0 - EF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F0 - FF */ -}; - -static const unsigned char base64[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00 - 0F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 - 1F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, /* 20 - 2F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 30 - 3F */ - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40 - 4F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 50 - 5F */ - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 60 - 6F */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 70 - 7F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 - 8F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90 - 9F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A0 - AF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* B0 - BF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* C0 - CF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* D0 - DF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* E0 - EF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F0 - FF */ -}; - -static const int base64num[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, /* 00 - 0F */ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, /* 10 - 1F */ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 62, 0, 0, 0, 63, /* 20 - 2F */ - 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 0, 0, 0, 0, 0, 0, /* 30 - 3F */ - 0, 0, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, /* 40 - 4F */ - 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 0, 0, 0, 0, 0, /* 50 - 5F */ - 0, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, /* 60 - 6F */ - 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 0, 0, 0, 0, 0, /* 70 - 7F */ -}; - -static ssize_t -get_line(const unsigned char *b, ssize_t avail, ssize_t *nlsize) -{ - ssize_t len; - - len = 0; - while (len < avail) { - switch (ascii[*b]) { - case 0: /* Non-ascii character or control character. */ - if (nlsize != NULL) - *nlsize = 0; - return (-1); - case '\r': - if (avail-len > 1 && b[1] == '\n') { - if (nlsize != NULL) - *nlsize = 2; - return (len+2); - } - /* FALL THROUGH */ - case '\n': - if (nlsize != NULL) - *nlsize = 1; - return (len+1); - case 1: - b++; - len++; - break; - } - } - if (nlsize != NULL) - *nlsize = 0; - return (avail); -} - -static ssize_t -bid_get_line(struct archive_read_filter *filter, - const unsigned char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl) -{ - ssize_t len; - int quit; - - quit = 0; - if (*avail == 0) { - *nl = 0; - len = 0; - } else - len = get_line(*b, *avail, nl); - /* - * Read bytes more while it does not reach the end of line. - */ - while (*nl == 0 && len == *avail && !quit) { - ssize_t diff = *ravail - *avail; - - *b = __archive_read_filter_ahead(filter, 160 + *ravail, avail); - if (*b == NULL) { - if (*ravail >= *avail) - return (0); - /* Reading bytes reaches the end of file. */ - *b = __archive_read_filter_ahead(filter, *avail, avail); - quit = 1; - } - *ravail = *avail; - *b += diff; - *avail -= diff; - len = get_line(*b, *avail, nl); - } - return (len); -} - -#define UUDECODE(c) (((c) - 0x20) & 0x3f) - -static int -uudecode_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *filter) -{ - const unsigned char *b; - ssize_t avail, ravail; - ssize_t len, nl; - int l; - int firstline; - - (void)self; /* UNUSED */ - - b = __archive_read_filter_ahead(filter, 1, &avail); - if (b == NULL) - return (0); - - firstline = 20; - ravail = avail; - for (;;) { - len = bid_get_line(filter, &b, &avail, &ravail, &nl); - if (len < 0 || nl == 0) - return (0);/* Binary data. */ - if (memcmp(b, "begin ", 6) == 0 && len - nl >= 11) - l = 6; - else if (memcmp(b, "begin-base64 ", 13) == 0 && len - nl >= 18) - l = 13; - else - l = 0; - - if (l > 0 && (b[l] < '0' || b[l] > '7' || - b[l+1] < '0' || b[l+1] > '7' || - b[l+2] < '0' || b[l+2] > '7' || b[l+3] != ' ')) - l = 0; - - b += len; - avail -= len; - if (l) - break; - firstline = 0; - } - if (!avail) - return (0); - len = bid_get_line(filter, &b, &avail, &ravail, &nl); - if (len < 0 || nl == 0) - return (0);/* There are non-ascii characters. */ - avail -= len; - - if (l == 6) { - if (!uuchar[*b]) - return (0); - /* Get a length of decoded bytes. */ - l = UUDECODE(*b++); len--; - if (l > 45) - /* Normally, maximum length is 45(character 'M'). */ - return (0); - while (l && len-nl > 0) { - if (l > 0) { - if (!uuchar[*b++]) - return (0); - if (!uuchar[*b++]) - return (0); - len -= 2; - --l; - } - if (l > 0) { - if (!uuchar[*b++]) - return (0); - --len; - --l; - } - if (l > 0) { - if (!uuchar[*b++]) - return (0); - --len; - --l; - } - } - if (len-nl < 0) - return (0); - if (len-nl == 1 && - (uuchar[*b] || /* Check sum. */ - (*b >= 'a' && *b <= 'z'))) {/* Padding data(MINIX). */ - ++b; - --len; - } - b += nl; - if (avail && uuchar[*b]) - return (firstline+30); - } - if (l == 13) { - while (len-nl > 0) { - if (!base64[*b++]) - return (0); - --len; - } - b += nl; - - if (avail >= 5 && memcmp(b, "====\n", 5) == 0) - return (firstline+40); - if (avail >= 6 && memcmp(b, "====\r\n", 6) == 0) - return (firstline+40); - if (avail > 0 && base64[*b]) - return (firstline+30); - } - - return (0); -} - -static int -uudecode_bidder_init(struct archive_read_filter *self) -{ - struct uudecode *uudecode; - void *out_buff; - void *in_buff; - - self->code = ARCHIVE_COMPRESSION_UU; - self->name = "uu"; - self->read = uudecode_filter_read; - self->skip = NULL; /* not supported */ - self->close = uudecode_filter_close; - - uudecode = (struct uudecode *)calloc(sizeof(*uudecode), 1); - out_buff = malloc(OUT_BUFF_SIZE); - in_buff = malloc(IN_BUFF_SIZE); - if (uudecode == NULL || out_buff == NULL || in_buff == NULL) { - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for uudecode"); - free(uudecode); - free(out_buff); - free(in_buff); - return (ARCHIVE_FATAL); - } - - self->data = uudecode; - uudecode->in_buff = in_buff; - uudecode->in_cnt = 0; - uudecode->in_allocated = IN_BUFF_SIZE; - uudecode->out_buff = out_buff; - uudecode->state = ST_FIND_HEAD; - - return (ARCHIVE_OK); -} - -static int -ensure_in_buff_size(struct archive_read_filter *self, - struct uudecode *uudecode, size_t size) -{ - - if (size > uudecode->in_allocated) { - unsigned char *ptr; - size_t newsize; - - newsize = uudecode->in_allocated << 1; - ptr = malloc(newsize); - if (ptr == NULL || - newsize < uudecode->in_allocated) { - free(ptr); - archive_set_error(&self->archive->archive, - ENOMEM, - "Can't allocate data for uudecode"); - return (ARCHIVE_FATAL); - } - if (uudecode->in_cnt) - memmove(ptr, uudecode->in_buff, - uudecode->in_cnt); - free(uudecode->in_buff); - uudecode->in_buff = ptr; - uudecode->in_allocated = newsize; - } - return (ARCHIVE_OK); -} - -static ssize_t -uudecode_filter_read(struct archive_read_filter *self, const void **buff) -{ - struct uudecode *uudecode; - const unsigned char *b, *d; - unsigned char *out; - ssize_t avail_in, ravail; - ssize_t used; - ssize_t total; - ssize_t len, llen, nl; - - uudecode = (struct uudecode *)self->data; - -read_more: - d = __archive_read_filter_ahead(self->upstream, 1, &avail_in); - if (d == NULL && avail_in < 0) - return (ARCHIVE_FATAL); - /* Quiet a code analyzer; make sure avail_in must be zero - * when d is NULL. */ - if (d == NULL) - avail_in = 0; - used = 0; - total = 0; - out = uudecode->out_buff; - ravail = avail_in; - if (uudecode->in_cnt) { - /* - * If there is remaining data which is saved by - * previous calling, use it first. - */ - if (ensure_in_buff_size(self, uudecode, - avail_in + uudecode->in_cnt) != ARCHIVE_OK) - return (ARCHIVE_FATAL); - memcpy(uudecode->in_buff + uudecode->in_cnt, - d, avail_in); - d = uudecode->in_buff; - avail_in += uudecode->in_cnt; - uudecode->in_cnt = 0; - } - for (;used < avail_in; d += llen, used += llen) { - int l, body; - - b = d; - len = get_line(b, avail_in - used, &nl); - if (len < 0) { - /* Non-ascii character is found. */ - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - } - llen = len; - if (nl == 0) { - /* - * Save remaining data which does not contain - * NL('\n','\r'). - */ - if (ensure_in_buff_size(self, uudecode, len) - != ARCHIVE_OK) - return (ARCHIVE_FATAL); - if (uudecode->in_buff != b) - memmove(uudecode->in_buff, b, len); - uudecode->in_cnt = len; - if (total == 0) { - /* Do not return 0; it means end-of-file. - * We should try to read bytes more. */ - __archive_read_filter_consume( - self->upstream, ravail); - goto read_more; - } - break; - } - if (total + len * 2 > OUT_BUFF_SIZE) - break; - switch (uudecode->state) { - default: - case ST_FIND_HEAD: - if (len - nl > 13 && memcmp(b, "begin ", 6) == 0) - l = 6; - else if (len - nl > 18 && - memcmp(b, "begin-base64 ", 13) == 0) - l = 13; - else - l = 0; - if (l != 0 && b[l] >= '0' && b[l] <= '7' && - b[l+1] >= '0' && b[l+1] <= '7' && - b[l+2] >= '0' && b[l+2] <= '7' && b[l+3] == ' ') { - if (l == 6) - uudecode->state = ST_READ_UU; - else - uudecode->state = ST_READ_BASE64; - } - break; - case ST_READ_UU: - body = len - nl; - if (!uuchar[*b] || body <= 0) { - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - } - /* Get length of undecoded bytes of curent line. */ - l = UUDECODE(*b++); - body--; - if (l > body) { - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - } - if (l == 0) { - uudecode->state = ST_UUEND; - break; - } - while (l > 0) { - int n = 0; - - if (l > 0) { - if (!uuchar[b[0]] || !uuchar[b[1]]) - break; - n = UUDECODE(*b++) << 18; - n |= UUDECODE(*b++) << 12; - *out++ = n >> 16; total++; - --l; - } - if (l > 0) { - if (!uuchar[b[0]]) - break; - n |= UUDECODE(*b++) << 6; - *out++ = (n >> 8) & 0xFF; total++; - --l; - } - if (l > 0) { - if (!uuchar[b[0]]) - break; - n |= UUDECODE(*b++); - *out++ = n & 0xFF; total++; - --l; - } - } - if (l) { - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - } - break; - case ST_UUEND: - if (len - nl == 3 && memcmp(b, "end ", 3) == 0) - uudecode->state = ST_FIND_HEAD; - else { - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - } - break; - case ST_READ_BASE64: - l = len - nl; - if (l >= 3 && b[0] == '=' && b[1] == '=' && - b[2] == '=') { - uudecode->state = ST_FIND_HEAD; - break; - } - while (l > 0) { - int n = 0; - - if (l > 0) { - if (!base64[b[0]] || !base64[b[1]]) - break; - n = base64num[*b++] << 18; - n |= base64num[*b++] << 12; - *out++ = n >> 16; total++; - l -= 2; - } - if (l > 0) { - if (*b == '=') - break; - if (!base64[*b]) - break; - n |= base64num[*b++] << 6; - *out++ = (n >> 8) & 0xFF; total++; - --l; - } - if (l > 0) { - if (*b == '=') - break; - if (!base64[*b]) - break; - n |= base64num[*b++]; - *out++ = n & 0xFF; total++; - --l; - } - } - if (l && *b != '=') { - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - } - break; - } - } - - __archive_read_filter_consume(self->upstream, ravail); - - *buff = uudecode->out_buff; - uudecode->total += total; - return (total); -} - -static int -uudecode_filter_close(struct archive_read_filter *self) -{ - struct uudecode *uudecode; - - uudecode = (struct uudecode *)self->data; - free(uudecode->in_buff); - free(uudecode->out_buff); - free(uudecode); - - return (ARCHIVE_OK); -} - diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c deleted file mode 100644 index 28c4e2d9fc5..00000000000 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c +++ /dev/null @@ -1,708 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * Copyright (c) 2003-2008 Tim Kientzle and Miklos Vajna - * 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" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_xz.c 201167 2009-12-29 06:06:20Z kientzle $"); - -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#include <stdio.h> -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#if HAVE_LZMA_H -#include <lzma.h> -#elif HAVE_LZMADEC_H -#include <lzmadec.h> -#endif - -#include "archive.h" -#include "archive_endian.h" -#include "archive_private.h" -#include "archive_read_private.h" - -#if HAVE_LZMA_H && HAVE_LIBLZMA - -struct private_data { - lzma_stream stream; - unsigned char *out_block; - size_t out_block_size; - int64_t total_out; - char eof; /* True = found end of compressed data. */ -}; - -/* Combined lzma/xz filter */ -static ssize_t xz_filter_read(struct archive_read_filter *, const void **); -static int xz_filter_close(struct archive_read_filter *); -static int xz_lzma_bidder_init(struct archive_read_filter *); - -#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC - -struct private_data { - lzmadec_stream stream; - unsigned char *out_block; - size_t out_block_size; - int64_t total_out; - char eof; /* True = found end of compressed data. */ -}; - -/* Lzma-only filter */ -static ssize_t lzma_filter_read(struct archive_read_filter *, const void **); -static int lzma_filter_close(struct archive_read_filter *); -#endif - -/* - * Note that we can detect xz and lzma compressed files even if we - * can't decompress them. (In fact, we like detecting them because we - * can give better error messages.) So the bid framework here gets - * compiled even if no lzma library is available. - */ -static int xz_bidder_bid(struct archive_read_filter_bidder *, - struct archive_read_filter *); -static int xz_bidder_init(struct archive_read_filter *); -static int lzma_bidder_bid(struct archive_read_filter_bidder *, - struct archive_read_filter *); -static int lzma_bidder_init(struct archive_read_filter *); - -int -archive_read_support_compression_xz(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a); - - archive_clear_error(_a); - if (bidder == NULL) - return (ARCHIVE_FATAL); - - bidder->data = NULL; - bidder->bid = xz_bidder_bid; - bidder->init = xz_bidder_init; - bidder->options = NULL; - bidder->free = NULL; -#if HAVE_LZMA_H && HAVE_LIBLZMA - return (ARCHIVE_OK); -#else - archive_set_error(_a, ARCHIVE_ERRNO_MISC, - "Using external unxz program for xz decompression"); - return (ARCHIVE_WARN); -#endif -} - -int -archive_read_support_compression_lzma(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a); - - archive_clear_error(_a); - if (bidder == NULL) - return (ARCHIVE_FATAL); - - bidder->data = NULL; - bidder->bid = lzma_bidder_bid; - bidder->init = lzma_bidder_init; - bidder->options = NULL; - bidder->free = NULL; -#if HAVE_LZMA_H && HAVE_LIBLZMA - return (ARCHIVE_OK); -#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC - return (ARCHIVE_OK); -#else - archive_set_error(_a, ARCHIVE_ERRNO_MISC, - "Using external unlzma program for lzma decompression"); - return (ARCHIVE_WARN); -#endif -} - -/* - * Test whether we can handle this data. - */ -static int -xz_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *filter) -{ - const unsigned char *buffer; - ssize_t avail; - int bits_checked; - - (void)self; /* UNUSED */ - - buffer = __archive_read_filter_ahead(filter, 6, &avail); - if (buffer == NULL) - return (0); - - /* - * Verify Header Magic Bytes : FD 37 7A 58 5A 00 - */ - bits_checked = 0; - if (buffer[0] != 0xFD) - return (0); - bits_checked += 8; - if (buffer[1] != 0x37) - return (0); - bits_checked += 8; - if (buffer[2] != 0x7A) - return (0); - bits_checked += 8; - if (buffer[3] != 0x58) - return (0); - bits_checked += 8; - if (buffer[4] != 0x5A) - return (0); - bits_checked += 8; - if (buffer[5] != 0x00) - return (0); - bits_checked += 8; - - return (bits_checked); -} - -/* - * Test whether we can handle this data. - * - * <sigh> LZMA has a rather poor file signature. Zeros do not - * make good signature bytes as a rule, and the only non-zero byte - * here is an ASCII character. For example, an uncompressed tar - * archive whose first file is ']' would satisfy this check. It may - * be necessary to exclude LZMA from compression_all() because of - * this. Clients of libarchive would then have to explicitly enable - * LZMA checking instead of (or in addition to) compression_all() when - * they have other evidence (file name, command-line option) to go on. - */ -static int -lzma_bidder_bid(struct archive_read_filter_bidder *self, - struct archive_read_filter *filter) -{ - const unsigned char *buffer; - ssize_t avail; - uint32_t dicsize; - uint64_t uncompressed_size; - int bits_checked; - - (void)self; /* UNUSED */ - - buffer = __archive_read_filter_ahead(filter, 14, &avail); - if (buffer == NULL) - return (0); - - /* First byte of raw LZMA stream is commonly 0x5d. - * The first byte is a special number, which consists of - * three parameters of LZMA compression, a number of literal - * context bits(which is from 0 to 8, default is 3), a number - * of literal pos bits(which is from 0 to 4, default is 0), - * a number of pos bits(which is from 0 to 4, default is 2). - * The first byte is made by - * (pos bits * 5 + literal pos bit) * 9 + * literal contest bit, - * and so the default value in this field is - * (2 * 5 + 0) * 9 + 3 = 0x5d. - * lzma of LZMA SDK has options to change those parameters. - * It means a range of this field is from 0 to 224. And lzma of - * XZ Utils with option -e records 0x5e in this field. */ - /* NOTE: If this checking of the first byte increases false - * recognition, we should allow only 0x5d and 0x5e for the first - * byte of LZMA stream. */ - bits_checked = 0; - if (buffer[0] > (4 * 5 + 4) * 9 + 8) - return (0); - /* Most likely value in the first byte of LZMA stream. */ - if (buffer[0] == 0x5d || buffer[0] == 0x5e) - bits_checked += 8; - - /* Sixth through fourteenth bytes are uncompressed size, - * stored in little-endian order. `-1' means uncompressed - * size is unknown and lzma of XZ Utils always records `-1' - * in this field. */ - uncompressed_size = archive_le64dec(buffer+5); - if (uncompressed_size == (uint64_t)ARCHIVE_LITERAL_LL(-1)) - bits_checked += 64; - - /* Second through fifth bytes are dictionary size, stored in - * little-endian order. The minimum dictionary size is - * 1 << 12(4KiB) which the lzma of LZMA SDK uses with option - * -d12 and the maxinam dictionary size is 1 << 27(128MiB) - * which the one uses with option -d27. - * NOTE: A comment of LZMA SDK source code says this dictionary - * range is from 1 << 12 to 1 << 30. */ - dicsize = archive_le32dec(buffer+1); - switch (dicsize) { - case 0x00001000:/* lzma of LZMA SDK option -d12. */ - case 0x00002000:/* lzma of LZMA SDK option -d13. */ - case 0x00004000:/* lzma of LZMA SDK option -d14. */ - case 0x00008000:/* lzma of LZMA SDK option -d15. */ - case 0x00010000:/* lzma of XZ Utils option -0 and -1. - * lzma of LZMA SDK option -d16. */ - case 0x00020000:/* lzma of LZMA SDK option -d17. */ - case 0x00040000:/* lzma of LZMA SDK option -d18. */ - case 0x00080000:/* lzma of XZ Utils option -2. - * lzma of LZMA SDK option -d19. */ - case 0x00100000:/* lzma of XZ Utils option -3. - * lzma of LZMA SDK option -d20. */ - case 0x00200000:/* lzma of XZ Utils option -4. - * lzma of LZMA SDK option -d21. */ - case 0x00400000:/* lzma of XZ Utils option -5. - * lzma of LZMA SDK option -d22. */ - case 0x00800000:/* lzma of XZ Utils option -6. - * lzma of LZMA SDK option -d23. */ - case 0x01000000:/* lzma of XZ Utils option -7. - * lzma of LZMA SDK option -d24. */ - case 0x02000000:/* lzma of XZ Utils option -8. - * lzma of LZMA SDK option -d25. */ - case 0x04000000:/* lzma of XZ Utils option -9. - * lzma of LZMA SDK option -d26. */ - case 0x08000000:/* lzma of LZMA SDK option -d27. */ - bits_checked += 32; - break; - default: - /* If a memory usage for encoding was not enough on - * the platform where LZMA stream was made, lzma of - * XZ Utils automatically decreased the dictionary - * size to enough memory for encoding by 1Mi bytes - * (1 << 20).*/ - if (dicsize <= 0x03F00000 && dicsize >= 0x00300000 && - (dicsize & ((1 << 20)-1)) == 0 && - bits_checked == 8 + 64) { - bits_checked += 32; - break; - } - /* Otherwise dictionary size is unlikely. But it is - * possible that someone makes lzma stream with - * liblzma/LZMA SDK in one's dictionary size. */ - return (0); - } - - /* TODO: The above test is still very weak. It would be - * good to do better. */ - - return (bits_checked); -} - -#if HAVE_LZMA_H && HAVE_LIBLZMA - -/* - * liblzma 4.999.7 and later support both lzma and xz streams. - */ -static int -xz_bidder_init(struct archive_read_filter *self) -{ - self->code = ARCHIVE_COMPRESSION_XZ; - self->name = "xz"; - return (xz_lzma_bidder_init(self)); -} - -static int -lzma_bidder_init(struct archive_read_filter *self) -{ - self->code = ARCHIVE_COMPRESSION_LZMA; - self->name = "lzma"; - return (xz_lzma_bidder_init(self)); -} - -/* - * Setup the callbacks. - */ -static int -xz_lzma_bidder_init(struct archive_read_filter *self) -{ - static const size_t out_block_size = 64 * 1024; - void *out_block; - struct private_data *state; - int ret; - - state = (struct private_data *)calloc(sizeof(*state), 1); - out_block = (unsigned char *)malloc(out_block_size); - if (state == NULL || out_block == NULL) { - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for xz decompression"); - free(out_block); - free(state); - return (ARCHIVE_FATAL); - } - - self->data = state; - state->out_block_size = out_block_size; - state->out_block = out_block; - self->read = xz_filter_read; - self->skip = NULL; /* not supported */ - self->close = xz_filter_close; - - state->stream.avail_in = 0; - - state->stream.next_out = state->out_block; - state->stream.avail_out = state->out_block_size; - - /* Initialize compression library. - * TODO: I don't know what value is best for memlimit. - * maybe, it needs to check memory size which - * running system has. - */ - if (self->code == ARCHIVE_COMPRESSION_XZ) - ret = lzma_stream_decoder(&(state->stream), - (1U << 30),/* memlimit */ - LZMA_CONCATENATED); - else - ret = lzma_alone_decoder(&(state->stream), - (1U << 30));/* memlimit */ - - if (ret == LZMA_OK) - return (ARCHIVE_OK); - - /* Library setup failed: Choose an error message and clean up. */ - switch (ret) { - case LZMA_MEM_ERROR: - archive_set_error(&self->archive->archive, ENOMEM, - "Internal error initializing compression library: " - "Cannot allocate memory"); - break; - case LZMA_OPTIONS_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "Invalid or unsupported options"); - break; - default: - archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing lzma library"); - break; - } - - free(state->out_block); - free(state); - self->data = NULL; - return (ARCHIVE_FATAL); -} - -/* - * Return the next block of decompressed data. - */ -static ssize_t -xz_filter_read(struct archive_read_filter *self, const void **p) -{ - struct private_data *state; - size_t decompressed; - ssize_t avail_in; - int ret; - - state = (struct private_data *)self->data; - - /* Empty our output buffer. */ - state->stream.next_out = state->out_block; - state->stream.avail_out = state->out_block_size; - - /* Try to fill the output buffer. */ - while (state->stream.avail_out > 0 && !state->eof) { - state->stream.next_in = - __archive_read_filter_ahead(self->upstream, 1, &avail_in); - if (state->stream.next_in == NULL && avail_in < 0) - return (ARCHIVE_FATAL); - state->stream.avail_in = avail_in; - - /* Decompress as much as we can in one pass. */ - ret = lzma_code(&(state->stream), - (state->stream.avail_in == 0)? LZMA_FINISH: LZMA_RUN); - switch (ret) { - case LZMA_STREAM_END: /* Found end of stream. */ - state->eof = 1; - /* FALL THROUGH */ - case LZMA_OK: /* Decompressor made some progress. */ - __archive_read_filter_consume(self->upstream, - avail_in - state->stream.avail_in); - break; - case LZMA_MEM_ERROR: - archive_set_error(&self->archive->archive, ENOMEM, - "Lzma library error: Cannot allocate memory"); - return (ARCHIVE_FATAL); - case LZMA_MEMLIMIT_ERROR: - archive_set_error(&self->archive->archive, ENOMEM, - "Lzma library error: Out of memory"); - return (ARCHIVE_FATAL); - case LZMA_FORMAT_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Lzma library error: format not recognized"); - return (ARCHIVE_FATAL); - case LZMA_OPTIONS_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Lzma library error: Invalid options"); - return (ARCHIVE_FATAL); - case LZMA_DATA_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Lzma library error: Corrupted input data"); - return (ARCHIVE_FATAL); - case LZMA_BUF_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Lzma library error: No progress is possible"); - return (ARCHIVE_FATAL); - default: - /* Return an error. */ - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Lzma decompression failed: Unknown error"); - return (ARCHIVE_FATAL); - } - } - - decompressed = state->stream.next_out - state->out_block; - state->total_out += decompressed; - if (decompressed == 0) - *p = NULL; - else - *p = state->out_block; - return (decompressed); -} - -/* - * Clean up the decompressor. - */ -static int -xz_filter_close(struct archive_read_filter *self) -{ - struct private_data *state; - - state = (struct private_data *)self->data; - lzma_end(&(state->stream)); - free(state->out_block); - free(state); - return (ARCHIVE_OK); -} - -#else - -#if HAVE_LZMADEC_H && HAVE_LIBLZMADEC - -/* - * If we have the older liblzmadec library, then we can handle - * LZMA streams but not XZ streams. - */ - -/* - * Setup the callbacks. - */ -static int -lzma_bidder_init(struct archive_read_filter *self) -{ - static const size_t out_block_size = 64 * 1024; - void *out_block; - struct private_data *state; - ssize_t ret, avail_in; - - self->code = ARCHIVE_COMPRESSION_LZMA; - self->name = "lzma"; - - state = (struct private_data *)calloc(sizeof(*state), 1); - out_block = (unsigned char *)malloc(out_block_size); - if (state == NULL || out_block == NULL) { - archive_set_error(&self->archive->archive, ENOMEM, - "Can't allocate data for lzma decompression"); - free(out_block); - free(state); - return (ARCHIVE_FATAL); - } - - self->data = state; - state->out_block_size = out_block_size; - state->out_block = out_block; - self->read = lzma_filter_read; - self->skip = NULL; /* not supported */ - self->close = lzma_filter_close; - - /* Prime the lzma library with 18 bytes of input. */ - state->stream.next_in = (unsigned char *)(uintptr_t) - __archive_read_filter_ahead(self->upstream, 18, &avail_in); - if (state->stream.next_in == NULL) - return (ARCHIVE_FATAL); - state->stream.avail_in = avail_in; - state->stream.next_out = state->out_block; - state->stream.avail_out = state->out_block_size; - - /* Initialize compression library. */ - ret = lzmadec_init(&(state->stream)); - __archive_read_filter_consume(self->upstream, - avail_in - state->stream.avail_in); - if (ret == LZMADEC_OK) - return (ARCHIVE_OK); - - /* Library setup failed: Clean up. */ - archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing lzma library"); - - /* Override the error message if we know what really went wrong. */ - switch (ret) { - case LZMADEC_HEADER_ERROR: - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "invalid header"); - break; - case LZMADEC_MEM_ERROR: - archive_set_error(&self->archive->archive, ENOMEM, - "Internal error initializing compression library: " - "out of memory"); - break; - } - - free(state->out_block); - free(state); - self->data = NULL; - return (ARCHIVE_FATAL); -} - -/* - * Return the next block of decompressed data. - */ -static ssize_t -lzma_filter_read(struct archive_read_filter *self, const void **p) -{ - struct private_data *state; - size_t decompressed; - ssize_t avail_in, ret; - - state = (struct private_data *)self->data; - - /* Empty our output buffer. */ - state->stream.next_out = state->out_block; - state->stream.avail_out = state->out_block_size; - - /* Try to fill the output buffer. */ - while (state->stream.avail_out > 0 && !state->eof) { - state->stream.next_in = (unsigned char *)(uintptr_t) - __archive_read_filter_ahead(self->upstream, 1, &avail_in); - if (state->stream.next_in == NULL && avail_in < 0) - return (ARCHIVE_FATAL); - state->stream.avail_in = avail_in; - - /* Decompress as much as we can in one pass. */ - ret = lzmadec_decode(&(state->stream), avail_in == 0); - switch (ret) { - case LZMADEC_STREAM_END: /* Found end of stream. */ - state->eof = 1; - /* FALL THROUGH */ - case LZMADEC_OK: /* Decompressor made some progress. */ - __archive_read_filter_consume(self->upstream, - avail_in - state->stream.avail_in); - break; - case LZMADEC_BUF_ERROR: /* Insufficient input data? */ - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Insufficient compressed data"); - return (ARCHIVE_FATAL); - default: - /* Return an error. */ - archive_set_error(&self->archive->archive, - ARCHIVE_ERRNO_MISC, - "Lzma decompression failed"); - return (ARCHIVE_FATAL); - } - } - - decompressed = state->stream.next_out - state->out_block; - state->total_out += decompressed; - if (decompressed == 0) - *p = NULL; - else - *p = state->out_block; - return (decompressed); -} - -/* - * Clean up the decompressor. - */ -static int -lzma_filter_close(struct archive_read_filter *self) -{ - struct private_data *state; - int ret; - - state = (struct private_data *)self->data; - ret = ARCHIVE_OK; - switch (lzmadec_end(&(state->stream))) { - case LZMADEC_OK: - break; - default: - archive_set_error(&(self->archive->archive), - ARCHIVE_ERRNO_MISC, - "Failed to clean up %s compressor", - self->archive->archive.compression_name); - ret = ARCHIVE_FATAL; - } - - free(state->out_block); - free(state); - return (ret); -} - -#else - -/* - * - * If we have no suitable library on this system, we can't actually do - * the decompression. We can, however, still detect compressed - * archives and emit a useful message. - * - */ -static int -lzma_bidder_init(struct archive_read_filter *self) -{ - int r; - - r = __archive_read_program(self, "unlzma"); - /* Note: We set the format here even if __archive_read_program() - * above fails. We do, after all, know what the format is - * even if we weren't able to read it. */ - self->code = ARCHIVE_COMPRESSION_LZMA; - self->name = "lzma"; - return (r); -} - -#endif /* HAVE_LZMADEC_H */ - - -static int -xz_bidder_init(struct archive_read_filter *self) -{ - int r; - - r = __archive_read_program(self, "unxz"); - /* Note: We set the format here even if __archive_read_program() - * above fails. We do, after all, know what the format is - * even if we weren't able to read it. */ - self->code = ARCHIVE_COMPRESSION_XZ; - self->name = "xz"; - return (r); -} - - -#endif /* HAVE_LZMA_H */ diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.c b/archivers/libarchive/files/libarchive/archive_write_disk.c deleted file mode 100644 index caf958e79a3..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_disk.c +++ /dev/null @@ -1,2628 +0,0 @@ -/*- - * 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 - * in this position and unchanged. - * 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" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 05:35:40Z kientzle $"); - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_ACL_H -#include <sys/acl.h> -#endif -#ifdef HAVE_SYS_EXTATTR_H -#include <sys/extattr.h> -#endif -#ifdef HAVE_SYS_XATTR_H -#include <sys/xattr.h> -#endif -#ifdef HAVE_ATTR_XATTR_H -#include <attr/xattr.h> -#endif -#ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#ifdef HAVE_SYS_UTIME_H -#include <sys/utime.h> -#endif -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_GRP_H -#include <grp.h> -#endif -#ifdef HAVE_LINUX_FS_H -#include <linux/fs.h> /* for Linux file flags */ -#endif -/* - * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h. - * As the include guards don't agree, the order of include is important. - */ -#ifdef HAVE_LINUX_EXT2_FS_H -#include <linux/ext2_fs.h> /* for Linux file flags */ -#endif -#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__) -#include <ext2fs/ext2_fs.h> /* Linux file flags, broken on Cygwin */ -#endif -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif -#ifdef HAVE_PWD_H -#include <pwd.h> -#endif -#include <stdio.h> -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_UTIME_H -#include <utime.h> -#endif - -#include "archive.h" -#include "archive_string.h" -#include "archive_entry.h" -#include "archive_private.h" - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -struct fixup_entry { - struct fixup_entry *next; - mode_t mode; - int64_t atime; - int64_t birthtime; - int64_t mtime; - unsigned long atime_nanos; - unsigned long birthtime_nanos; - unsigned long mtime_nanos; - unsigned long fflags_set; - int fixup; /* bitmask of what needs fixing */ - char *name; -}; - -/* - * We use a bitmask to track which operations remain to be done for - * this file. In particular, this helps us avoid unnecessary - * operations when it's possible to take care of one step as a - * side-effect of another. For example, mkdir() can specify the mode - * for the newly-created object but symlink() cannot. This means we - * can skip chmod() if mkdir() succeeded, but we must explicitly - * chmod() if we're trying to create a directory that already exists - * (mkdir() failed) or if we're restoring a symlink. Similarly, we - * need to verify UID/GID before trying to restore SUID/SGID bits; - * that verification can occur explicitly through a stat() call or - * implicitly because of a successful chown() call. - */ -#define TODO_MODE_FORCE 0x40000000 -#define TODO_MODE_BASE 0x20000000 -#define TODO_SUID 0x10000000 -#define TODO_SUID_CHECK 0x08000000 -#define TODO_SGID 0x04000000 -#define TODO_SGID_CHECK 0x02000000 -#define TODO_MODE (TODO_MODE_BASE|TODO_SUID|TODO_SGID) -#define TODO_TIMES ARCHIVE_EXTRACT_TIME -#define TODO_OWNER ARCHIVE_EXTRACT_OWNER -#define TODO_FFLAGS ARCHIVE_EXTRACT_FFLAGS -#define TODO_ACLS ARCHIVE_EXTRACT_ACL -#define TODO_XATTR ARCHIVE_EXTRACT_XATTR - -struct archive_write_disk { - struct archive archive; - - mode_t user_umask; - struct fixup_entry *fixup_list; - struct fixup_entry *current_fixup; - uid_t user_uid; - dev_t skip_file_dev; - ino_t skip_file_ino; - time_t start_time; - - gid_t (*lookup_gid)(void *private, const char *gname, gid_t gid); - void (*cleanup_gid)(void *private); - void *lookup_gid_data; - uid_t (*lookup_uid)(void *private, const char *gname, gid_t gid); - void (*cleanup_uid)(void *private); - void *lookup_uid_data; - - /* - * Full path of last file to satisfy symlink checks. - */ - struct archive_string path_safe; - - /* - * Cached stat data from disk for the current entry. - * If this is valid, pst points to st. Otherwise, - * pst is null. - */ - struct stat st; - struct stat *pst; - - /* Information about the object being restored right now. */ - struct archive_entry *entry; /* Entry being extracted. */ - char *name; /* Name of entry, possibly edited. */ - struct archive_string _name_data; /* backing store for 'name' */ - /* Tasks remaining for this object. */ - int todo; - /* Tasks deferred until end-of-archive. */ - int deferred; - /* Options requested by the client. */ - int flags; - /* Handle for the file we're restoring. */ - int fd; - /* Current offset for writing data to the file. */ - off_t offset; - /* Last offset actually written to disk. */ - off_t fd_offset; - /* Maximum size of file, -1 if unknown. */ - off_t filesize; - /* Dir we were in before this restore; only for deep paths. */ - int restore_pwd; - /* Mode we should use for this entry; affected by _PERM and umask. */ - mode_t mode; - /* UID/GID to use in restoring this entry. */ - uid_t uid; - gid_t gid; -}; - -/* - * Default mode for dirs created automatically (will be modified by umask). - * Note that POSIX specifies 0777 for implicity-created dirs, "modified - * by the process' file creation mask." - */ -#define DEFAULT_DIR_MODE 0777 -/* - * Dir modes are restored in two steps: During the extraction, the permissions - * in the archive are modified to match the following limits. During - * the post-extract fixup pass, the permissions from the archive are - * applied. - */ -#define MINIMUM_DIR_MODE 0700 -#define MAXIMUM_DIR_MODE 0775 - -static int check_symlinks(struct archive_write_disk *); -static int create_filesystem_object(struct archive_write_disk *); -static struct fixup_entry *current_fixup(struct archive_write_disk *, const char *pathname); -#ifdef HAVE_FCHDIR -static void edit_deep_directories(struct archive_write_disk *ad); -#endif -static int cleanup_pathname(struct archive_write_disk *); -static int create_dir(struct archive_write_disk *, char *); -static int create_parent_dir(struct archive_write_disk *, char *); -static int older(struct stat *, struct archive_entry *); -static int restore_entry(struct archive_write_disk *); -#ifdef HAVE_POSIX_ACL -static int set_acl(struct archive_write_disk *, int fd, struct archive_entry *, - acl_type_t, int archive_entry_acl_type, const char *tn); -#endif -static int set_acls(struct archive_write_disk *); -static int set_xattrs(struct archive_write_disk *); -static int set_fflags(struct archive_write_disk *); -static int set_fflags_platform(struct archive_write_disk *, int fd, - const char *name, mode_t mode, - unsigned long fflags_set, unsigned long fflags_clear); -static int set_ownership(struct archive_write_disk *); -static int set_mode(struct archive_write_disk *, int mode); -static int set_time(int, int, const char *, time_t, long, time_t, long); -static int set_times(struct archive_write_disk *); -static struct fixup_entry *sort_dir_list(struct fixup_entry *p); -static gid_t trivial_lookup_gid(void *, const char *, gid_t); -static uid_t trivial_lookup_uid(void *, const char *, uid_t); -static ssize_t write_data_block(struct archive_write_disk *, - const char *, size_t); - -static struct archive_vtable *archive_write_disk_vtable(void); - -static int _archive_write_close(struct archive *); -static int _archive_write_finish(struct archive *); -static int _archive_write_header(struct archive *, struct archive_entry *); -static int _archive_write_finish_entry(struct archive *); -static ssize_t _archive_write_data(struct archive *, const void *, size_t); -static ssize_t _archive_write_data_block(struct archive *, const void *, size_t, off_t); - -static int -_archive_write_disk_lazy_stat(struct archive_write_disk *a) -{ - if (a->pst != NULL) { - /* Already have stat() data available. */ - return (ARCHIVE_OK); - } -#ifdef HAVE_FSTAT - if (a->fd >= 0 && fstat(a->fd, &a->st) == 0) { - a->pst = &a->st; - return (ARCHIVE_OK); - } -#endif - /* - * XXX At this point, symlinks should not be hit, otherwise - * XXX a race occured. Do we want to check explicitly for that? - */ - if (lstat(a->name, &a->st) == 0) { - a->pst = &a->st; - return (ARCHIVE_OK); - } - archive_set_error(&a->archive, errno, "Couldn't stat file"); - return (ARCHIVE_WARN); -} - -static struct archive_vtable * -archive_write_disk_vtable(void) -{ - static struct archive_vtable av; - static int inited = 0; - - if (!inited) { - av.archive_close = _archive_write_close; - av.archive_finish = _archive_write_finish; - av.archive_write_header = _archive_write_header; - av.archive_write_finish_entry = _archive_write_finish_entry; - av.archive_write_data = _archive_write_data; - av.archive_write_data_block = _archive_write_data_block; - } - return (&av); -} - - -int -archive_write_disk_set_options(struct archive *_a, int flags) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - - a->flags = flags; - return (ARCHIVE_OK); -} - - -/* - * Extract this entry to disk. - * - * TODO: Validate hardlinks. According to the standards, we're - * supposed to check each extracted hardlink and squawk if it refers - * to a file that we didn't restore. I'm not entirely convinced this - * is a good idea, but more importantly: Is there any way to validate - * hardlinks without keeping a complete list of filenames from the - * entire archive?? Ugh. - * - */ -static int -_archive_write_header(struct archive *_a, struct archive_entry *entry) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - struct fixup_entry *fe; - int ret, r; - - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, - "archive_write_disk_header"); - archive_clear_error(&a->archive); - if (a->archive.state & ARCHIVE_STATE_DATA) { - r = _archive_write_finish_entry(&a->archive); - if (r == ARCHIVE_FATAL) - return (r); - } - - /* Set up for this particular entry. */ - a->pst = NULL; - a->current_fixup = NULL; - a->deferred = 0; - if (a->entry) { - archive_entry_free(a->entry); - a->entry = NULL; - } - a->entry = archive_entry_clone(entry); - a->fd = -1; - a->fd_offset = 0; - a->offset = 0; - a->uid = a->user_uid; - a->mode = archive_entry_mode(a->entry); - if (archive_entry_size_is_set(a->entry)) - a->filesize = archive_entry_size(a->entry); - else - a->filesize = -1; - archive_strcpy(&(a->_name_data), archive_entry_pathname(a->entry)); - a->name = a->_name_data.s; - archive_clear_error(&a->archive); - - /* - * Clean up the requested path. This is necessary for correct - * dir restores; the dir restore logic otherwise gets messed - * up by nonsense like "dir/.". - */ - ret = cleanup_pathname(a); - if (ret != ARCHIVE_OK) - return (ret); - - /* - * Set the umask to zero so we get predictable mode settings. - * This gets done on every call to _write_header in case the - * user edits their umask during the extraction for some - * reason. This will be reset before we return. Note that we - * don't need to do this in _finish_entry, as the chmod(), etc, - * system calls don't obey umask. - */ - a->user_umask = umask(0); - /* From here on, early exit requires "goto done" to clean up. */ - - /* Figure out what we need to do for this entry. */ - a->todo = TODO_MODE_BASE; - if (a->flags & ARCHIVE_EXTRACT_PERM) { - a->todo |= TODO_MODE_FORCE; /* Be pushy about permissions. */ - /* - * SGID requires an extra "check" step because we - * cannot easily predict the GID that the system will - * assign. (Different systems assign GIDs to files - * based on a variety of criteria, including process - * credentials and the gid of the enclosing - * directory.) We can only restore the SGID bit if - * the file has the right GID, and we only know the - * GID if we either set it (see set_ownership) or if - * we've actually called stat() on the file after it - * was restored. Since there are several places at - * which we might verify the GID, we need a TODO bit - * to keep track. - */ - if (a->mode & S_ISGID) - a->todo |= TODO_SGID | TODO_SGID_CHECK; - /* - * Verifying the SUID is simpler, but can still be - * done in multiple ways, hence the separate "check" bit. - */ - if (a->mode & S_ISUID) - a->todo |= TODO_SUID | TODO_SUID_CHECK; - } else { - /* - * User didn't request full permissions, so don't - * restore SUID, SGID bits and obey umask. - */ - a->mode &= ~S_ISUID; - a->mode &= ~S_ISGID; - a->mode &= ~S_ISVTX; - a->mode &= ~a->user_umask; - } -#if !defined(_WIN32) || defined(__CYGWIN__) - if (a->flags & ARCHIVE_EXTRACT_OWNER) - a->todo |= TODO_OWNER; -#endif - if (a->flags & ARCHIVE_EXTRACT_TIME) - a->todo |= TODO_TIMES; - if (a->flags & ARCHIVE_EXTRACT_ACL) - a->todo |= TODO_ACLS; - if (a->flags & ARCHIVE_EXTRACT_XATTR) - a->todo |= TODO_XATTR; - if (a->flags & ARCHIVE_EXTRACT_FFLAGS) - a->todo |= TODO_FFLAGS; - if (a->flags & ARCHIVE_EXTRACT_SECURE_SYMLINKS) { - ret = check_symlinks(a); - if (ret != ARCHIVE_OK) - goto done; - } -#ifdef HAVE_FCHDIR - /* If path exceeds PATH_MAX, shorten the path. */ - edit_deep_directories(a); -#endif - - ret = restore_entry(a); - - /* - * TODO: There are rumours that some extended attributes must - * be restored before file data is written. If this is true, - * then we either need to write all extended attributes both - * before and after restoring the data, or find some rule for - * determining which must go first and which last. Due to the - * many ways people are using xattrs, this may prove to be an - * intractable problem. - */ - -#ifdef HAVE_FCHDIR - /* If we changed directory above, restore it here. */ - if (a->restore_pwd >= 0) { - r = fchdir(a->restore_pwd); - if (r != 0) { - archive_set_error(&a->archive, errno, "chdir() failure"); - ret = ARCHIVE_FATAL; - } - close(a->restore_pwd); - a->restore_pwd = -1; - } -#endif - - /* - * Fixup uses the unedited pathname from archive_entry_pathname(), - * because it is relative to the base dir and the edited path - * might be relative to some intermediate dir as a result of the - * deep restore logic. - */ - if (a->deferred & TODO_MODE) { - fe = current_fixup(a, archive_entry_pathname(entry)); - fe->fixup |= TODO_MODE_BASE; - fe->mode = a->mode; - } - - if ((a->deferred & TODO_TIMES) - && (archive_entry_mtime_is_set(entry) - || archive_entry_atime_is_set(entry))) { - fe = current_fixup(a, archive_entry_pathname(entry)); - fe->fixup |= TODO_TIMES; - if (archive_entry_atime_is_set(entry)) { - fe->atime = archive_entry_atime(entry); - fe->atime_nanos = archive_entry_atime_nsec(entry); - } else { - /* If atime is unset, use start time. */ - fe->atime = a->start_time; - fe->atime_nanos = 0; - } - if (archive_entry_mtime_is_set(entry)) { - fe->mtime = archive_entry_mtime(entry); - fe->mtime_nanos = archive_entry_mtime_nsec(entry); - } else { - /* If mtime is unset, use start time. */ - fe->mtime = a->start_time; - fe->mtime_nanos = 0; - } - if (archive_entry_birthtime_is_set(entry)) { - fe->birthtime = archive_entry_birthtime(entry); - fe->birthtime_nanos = archive_entry_birthtime_nsec(entry); - } else { - /* If birthtime is unset, use mtime. */ - fe->birthtime = fe->mtime; - fe->birthtime_nanos = fe->mtime_nanos; - } - } - - if (a->deferred & TODO_FFLAGS) { - fe = current_fixup(a, archive_entry_pathname(entry)); - fe->fixup |= TODO_FFLAGS; - /* TODO: Complete this.. defer fflags from below. */ - } - - /* We've created the object and are ready to pour data into it. */ - if (ret >= ARCHIVE_WARN) - a->archive.state = ARCHIVE_STATE_DATA; - /* - * If it's not open, tell our client not to try writing. - * In particular, dirs, links, etc, don't get written to. - */ - if (a->fd < 0) { - archive_entry_set_size(entry, 0); - a->filesize = 0; - } -done: - /* Restore the user's umask before returning. */ - umask(a->user_umask); - - return (ret); -} - -int -archive_write_disk_set_skip_file(struct archive *_a, dev_t d, ino_t i) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_write_disk_set_skip_file"); - a->skip_file_dev = d; - a->skip_file_ino = i; - return (ARCHIVE_OK); -} - -static ssize_t -write_data_block(struct archive_write_disk *a, const char *buff, size_t size) -{ - uint64_t start_size = size; - ssize_t bytes_written = 0; - ssize_t block_size = 0, bytes_to_write; - - if (size == 0) - return (ARCHIVE_OK); - - if (a->filesize == 0 || a->fd < 0) { - archive_set_error(&a->archive, 0, - "Attempt to write to an empty file"); - return (ARCHIVE_WARN); - } - - if (a->flags & ARCHIVE_EXTRACT_SPARSE) { -#if HAVE_STRUCT_STAT_ST_BLKSIZE - int r; - if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK) - return (r); - block_size = a->pst->st_blksize; -#else - /* XXX TODO XXX Is there a more appropriate choice here ? */ - /* This needn't match the filesystem allocation size. */ - block_size = 16*1024; -#endif - } - - /* If this write would run beyond the file size, truncate it. */ - if (a->filesize >= 0 && (off_t)(a->offset + size) > a->filesize) - start_size = size = (size_t)(a->filesize - a->offset); - - /* Write the data. */ - while (size > 0) { - if (block_size == 0) { - bytes_to_write = size; - } else { - /* We're sparsifying the file. */ - const char *p, *end; - off_t block_end; - - /* Skip leading zero bytes. */ - for (p = buff, end = buff + size; p < end; ++p) { - if (*p != '\0') - break; - } - a->offset += p - buff; - size -= p - buff; - buff = p; - if (size == 0) - break; - - /* Calculate next block boundary after offset. */ - block_end - = (a->offset / block_size + 1) * block_size; - - /* If the adjusted write would cross block boundary, - * truncate it to the block boundary. */ - bytes_to_write = size; - if (a->offset + bytes_to_write > block_end) - bytes_to_write = block_end - a->offset; - } - /* Seek if necessary to the specified offset. */ - if (a->offset != a->fd_offset) { - if (lseek(a->fd, a->offset, SEEK_SET) < 0) { - archive_set_error(&a->archive, errno, - "Seek failed"); - return (ARCHIVE_FATAL); - } - a->fd_offset = a->offset; - a->archive.file_position = a->offset; - a->archive.raw_position = a->offset; - } - bytes_written = write(a->fd, buff, bytes_to_write); - if (bytes_written < 0) { - archive_set_error(&a->archive, errno, "Write failed"); - return (ARCHIVE_WARN); - } - buff += bytes_written; - size -= bytes_written; - a->offset += bytes_written; - a->archive.file_position += bytes_written; - a->archive.raw_position += bytes_written; - a->fd_offset = a->offset; - } - return (start_size - size); -} - -static ssize_t -_archive_write_data_block(struct archive *_a, - const void *buff, size_t size, off_t offset) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - ssize_t r; - - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_DATA, "archive_write_disk_block"); - - a->offset = offset; - r = write_data_block(a, buff, size); - if (r < ARCHIVE_OK) - return (r); - if ((size_t)r < size) { - archive_set_error(&a->archive, 0, - "Write request too large"); - return (ARCHIVE_WARN); - } - return (ARCHIVE_OK); -} - -static ssize_t -_archive_write_data(struct archive *_a, const void *buff, size_t size) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_DATA, "archive_write_data"); - - return (write_data_block(a, buff, size)); -} - -static int -_archive_write_finish_entry(struct archive *_a) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - int ret = ARCHIVE_OK; - - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, - "archive_write_finish_entry"); - if (a->archive.state & ARCHIVE_STATE_HEADER) - return (ARCHIVE_OK); - archive_clear_error(&a->archive); - - /* Pad or truncate file to the right size. */ - if (a->fd < 0) { - /* There's no file. */ - } else if (a->filesize < 0) { - /* File size is unknown, so we can't set the size. */ - } else if (a->fd_offset == a->filesize) { - /* Last write ended at exactly the filesize; we're done. */ - /* Hopefully, this is the common case. */ - } else { -#if HAVE_FTRUNCATE - if (ftruncate(a->fd, a->filesize) == -1 && - a->filesize == 0) { - archive_set_error(&a->archive, errno, - "File size could not be restored"); - return (ARCHIVE_FAILED); - } -#endif - /* - * Not all platforms implement the XSI option to - * extend files via ftruncate. Stat() the file again - * to see what happened. - */ - a->pst = NULL; - if ((ret = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK) - return (ret); - /* We can use lseek()/write() to extend the file if - * ftruncate didn't work or isn't available. */ - if (a->st.st_size < a->filesize) { - const char nul = '\0'; - if (lseek(a->fd, a->filesize - 1, SEEK_SET) < 0) { - archive_set_error(&a->archive, errno, - "Seek failed"); - return (ARCHIVE_FATAL); - } - if (write(a->fd, &nul, 1) < 0) { - archive_set_error(&a->archive, errno, - "Write to restore size failed"); - return (ARCHIVE_FATAL); - } - a->pst = NULL; - } - } - - /* Restore metadata. */ - - /* - * Look up the "real" UID only if we're going to need it. - * TODO: the TODO_SGID condition can be dropped here, can't it? - */ - if (a->todo & (TODO_OWNER | TODO_SUID | TODO_SGID)) { - a->uid = a->lookup_uid(a->lookup_uid_data, - archive_entry_uname(a->entry), - archive_entry_uid(a->entry)); - } - /* Look up the "real" GID only if we're going to need it. */ - /* TODO: the TODO_SUID condition can be dropped here, can't it? */ - if (a->todo & (TODO_OWNER | TODO_SGID | TODO_SUID)) { - a->gid = a->lookup_gid(a->lookup_gid_data, - archive_entry_gname(a->entry), - archive_entry_gid(a->entry)); - } - /* - * If restoring ownership, do it before trying to restore suid/sgid - * bits. If we set the owner, we know what it is and can skip - * a stat() call to examine the ownership of the file on disk. - */ - if (a->todo & TODO_OWNER) - ret = set_ownership(a); - if (a->todo & TODO_MODE) { - int r2 = set_mode(a, a->mode); - if (r2 < ret) ret = r2; - } - if (a->todo & TODO_ACLS) { - int r2 = set_acls(a); - if (r2 < ret) ret = r2; - } - - /* - * Security-related extended attributes (such as - * security.capability on Linux) have to be restored last, - * since they're implicitly removed by other file changes. - */ - if (a->todo & TODO_XATTR) { - int r2 = set_xattrs(a); - if (r2 < ret) ret = r2; - } - - /* - * Some flags prevent file modification; they must be restored after - * file contents are written. - */ - if (a->todo & TODO_FFLAGS) { - int r2 = set_fflags(a); - if (r2 < ret) ret = r2; - } - /* - * Time has to be restored after all other metadata; - * otherwise atime will get changed. - */ - if (a->todo & TODO_TIMES) { - int r2 = set_times(a); - if (r2 < ret) ret = r2; - } - - /* If there's an fd, we can close it now. */ - if (a->fd >= 0) { - close(a->fd); - a->fd = -1; - } - /* If there's an entry, we can release it now. */ - if (a->entry) { - archive_entry_free(a->entry); - a->entry = NULL; - } - a->archive.state = ARCHIVE_STATE_HEADER; - return (ret); -} - -int -archive_write_disk_set_group_lookup(struct archive *_a, - void *private_data, - gid_t (*lookup_gid)(void *private, const char *gname, gid_t gid), - void (*cleanup_gid)(void *private)) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_write_disk_set_group_lookup"); - - a->lookup_gid = lookup_gid; - a->cleanup_gid = cleanup_gid; - a->lookup_gid_data = private_data; - return (ARCHIVE_OK); -} - -int -archive_write_disk_set_user_lookup(struct archive *_a, - void *private_data, - uid_t (*lookup_uid)(void *private, const char *uname, uid_t uid), - void (*cleanup_uid)(void *private)) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_ANY, "archive_write_disk_set_user_lookup"); - - a->lookup_uid = lookup_uid; - a->cleanup_uid = cleanup_uid; - a->lookup_uid_data = private_data; - return (ARCHIVE_OK); -} - - -/* - * Create a new archive_write_disk object and initialize it with global state. - */ -struct archive * -archive_write_disk_new(void) -{ - struct archive_write_disk *a; - - a = (struct archive_write_disk *)malloc(sizeof(*a)); - if (a == NULL) - return (NULL); - memset(a, 0, sizeof(*a)); - a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC; - /* We're ready to write a header immediately. */ - a->archive.state = ARCHIVE_STATE_HEADER; - a->archive.vtable = archive_write_disk_vtable(); - a->lookup_uid = trivial_lookup_uid; - a->lookup_gid = trivial_lookup_gid; - a->start_time = time(NULL); -#ifdef HAVE_GETEUID - a->user_uid = geteuid(); -#endif /* HAVE_GETEUID */ - if (archive_string_ensure(&a->path_safe, 512) == NULL) { - free(a); - return (NULL); - } - return (&a->archive); -} - - -/* - * If pathname is longer than PATH_MAX, chdir to a suitable - * intermediate dir and edit the path down to a shorter suffix. Note - * that this routine never returns an error; if the chdir() attempt - * fails for any reason, we just go ahead with the long pathname. The - * object creation is likely to fail, but any error will get handled - * at that time. - */ -#ifdef HAVE_FCHDIR -static void -edit_deep_directories(struct archive_write_disk *a) -{ - int ret; - char *tail = a->name; - - a->restore_pwd = -1; - - /* If path is short, avoid the open() below. */ - if (strlen(tail) <= PATH_MAX) - return; - - /* Try to record our starting dir. */ - a->restore_pwd = open(".", O_RDONLY | O_BINARY); - if (a->restore_pwd < 0) - return; - - /* As long as the path is too long... */ - while (strlen(tail) > PATH_MAX) { - /* Locate a dir prefix shorter than PATH_MAX. */ - tail += PATH_MAX - 8; - while (tail > a->name && *tail != '/') - tail--; - /* Exit if we find a too-long path component. */ - if (tail <= a->name) - return; - /* Create the intermediate dir and chdir to it. */ - *tail = '\0'; /* Terminate dir portion */ - ret = create_dir(a, a->name); - if (ret == ARCHIVE_OK && chdir(a->name) != 0) - ret = ARCHIVE_FAILED; - *tail = '/'; /* Restore the / we removed. */ - if (ret != ARCHIVE_OK) - return; - tail++; - /* The chdir() succeeded; we've now shortened the path. */ - a->name = tail; - } - return; -} -#endif - -/* - * The main restore function. - */ -static int -restore_entry(struct archive_write_disk *a) -{ - int ret = ARCHIVE_OK, en; - - if (a->flags & ARCHIVE_EXTRACT_UNLINK && !S_ISDIR(a->mode)) { - /* - * TODO: Fix this. Apparently, there are platforms - * that still allow root to hose the entire filesystem - * by unlinking a dir. The S_ISDIR() test above - * prevents us from using unlink() here if the new - * object is a dir, but that doesn't mean the old - * object isn't a dir. - */ - if (unlink(a->name) == 0) { - /* We removed it, reset cached stat. */ - a->pst = NULL; - } else if (errno == ENOENT) { - /* File didn't exist, that's just as good. */ - } else if (rmdir(a->name) == 0) { - /* It was a dir, but now it's gone. */ - a->pst = NULL; - } else { - /* We tried, but couldn't get rid of it. */ - archive_set_error(&a->archive, errno, - "Could not unlink"); - return(ARCHIVE_FAILED); - } - } - - /* Try creating it first; if this fails, we'll try to recover. */ - en = create_filesystem_object(a); - - if ((en == ENOTDIR || en == ENOENT) - && !(a->flags & ARCHIVE_EXTRACT_NO_AUTODIR)) { - /* If the parent dir doesn't exist, try creating it. */ - create_parent_dir(a, a->name); - /* Now try to create the object again. */ - en = create_filesystem_object(a); - } - - if ((en == EISDIR || en == EEXIST) - && (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) { - /* If we're not overwriting, we're done. */ - archive_set_error(&a->archive, en, "Already exists"); - return (ARCHIVE_FAILED); - } - - /* - * Some platforms return EISDIR if you call - * open(O_WRONLY | O_EXCL | O_CREAT) on a directory, some - * return EEXIST. POSIX is ambiguous, requiring EISDIR - * for open(O_WRONLY) on a dir and EEXIST for open(O_EXCL | O_CREAT) - * on an existing item. - */ - if (en == EISDIR) { - /* A dir is in the way of a non-dir, rmdir it. */ - if (rmdir(a->name) != 0) { - archive_set_error(&a->archive, errno, - "Can't remove already-existing dir"); - return (ARCHIVE_FAILED); - } - a->pst = NULL; - /* Try again. */ - en = create_filesystem_object(a); - } else if (en == EEXIST) { - /* - * We know something is in the way, but we don't know what; - * we need to find out before we go any further. - */ - int r = 0; - /* - * The SECURE_SYMLINK logic has already removed a - * symlink to a dir if the client wants that. So - * follow the symlink if we're creating a dir. - */ - if (S_ISDIR(a->mode)) - r = stat(a->name, &a->st); - /* - * If it's not a dir (or it's a broken symlink), - * then don't follow it. - */ - if (r != 0 || !S_ISDIR(a->mode)) - r = lstat(a->name, &a->st); - if (r != 0) { - archive_set_error(&a->archive, errno, - "Can't stat existing object"); - return (ARCHIVE_FAILED); - } - - /* - * NO_OVERWRITE_NEWER doesn't apply to directories. - */ - if ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER) - && !S_ISDIR(a->st.st_mode)) { - if (!older(&(a->st), a->entry)) { - archive_set_error(&a->archive, 0, - "File on disk is not older; skipping."); - return (ARCHIVE_FAILED); - } - } - - /* If it's our archive, we're done. */ - if (a->skip_file_dev > 0 && - a->skip_file_ino > 0 && - a->st.st_dev == a->skip_file_dev && - a->st.st_ino == a->skip_file_ino) { - archive_set_error(&a->archive, 0, "Refusing to overwrite archive"); - return (ARCHIVE_FAILED); - } - - if (!S_ISDIR(a->st.st_mode)) { - /* A non-dir is in the way, unlink it. */ - if (unlink(a->name) != 0) { - archive_set_error(&a->archive, errno, - "Can't unlink already-existing object"); - return (ARCHIVE_FAILED); - } - a->pst = NULL; - /* Try again. */ - en = create_filesystem_object(a); - } else if (!S_ISDIR(a->mode)) { - /* A dir is in the way of a non-dir, rmdir it. */ - if (rmdir(a->name) != 0) { - archive_set_error(&a->archive, errno, - "Can't remove already-existing dir"); - return (ARCHIVE_FAILED); - } - /* Try again. */ - en = create_filesystem_object(a); - } else { - /* - * There's a dir in the way of a dir. Don't - * waste time with rmdir()/mkdir(), just fix - * up the permissions on the existing dir. - * Note that we don't change perms on existing - * dirs unless _EXTRACT_PERM is specified. - */ - if ((a->mode != a->st.st_mode) - && (a->todo & TODO_MODE_FORCE)) - a->deferred |= (a->todo & TODO_MODE); - /* Ownership doesn't need deferred fixup. */ - en = 0; /* Forget the EEXIST. */ - } - } - - if (en) { - /* Everything failed; give up here. */ - archive_set_error(&a->archive, en, "Can't create '%s'", - a->name); - return (ARCHIVE_FAILED); - } - - a->pst = NULL; /* Cached stat data no longer valid. */ - return (ret); -} - -/* - * Returns 0 if creation succeeds, or else returns errno value from - * the failed system call. Note: This function should only ever perform - * a single system call. - */ -static int -create_filesystem_object(struct archive_write_disk *a) -{ - /* Create the entry. */ - const char *linkname; - mode_t final_mode, mode; - int r; - - /* We identify hard/symlinks according to the link names. */ - /* Since link(2) and symlink(2) don't handle modes, we're done here. */ - linkname = archive_entry_hardlink(a->entry); - if (linkname != NULL) { -#if !HAVE_LINK - return (EPERM); -#else - r = link(linkname, a->name) ? errno : 0; - /* - * New cpio and pax formats allow hardlink entries - * to carry data, so we may have to open the file - * for hardlink entries. - * - * If the hardlink was successfully created and - * the archive doesn't have carry data for it, - * consider it to be non-authoritive for meta data. - * This is consistent with GNU tar and BSD pax. - * If the hardlink does carry data, let the last - * archive entry decide ownership. - */ - if (r == 0 && a->filesize <= 0) { - a->todo = 0; - a->deferred = 0; - } if (r == 0 && a->filesize > 0) { - a->fd = open(a->name, O_WRONLY | O_TRUNC | O_BINARY); - if (a->fd < 0) - r = errno; - } - return (r); -#endif - } - linkname = archive_entry_symlink(a->entry); - if (linkname != NULL) { -#if HAVE_SYMLINK - return symlink(linkname, a->name) ? errno : 0; -#else - return (EPERM); -#endif - } - - /* - * The remaining system calls all set permissions, so let's - * try to take advantage of that to avoid an extra chmod() - * call. (Recall that umask is set to zero right now!) - */ - - /* Mode we want for the final restored object (w/o file type bits). */ - final_mode = a->mode & 07777; - /* - * The mode that will actually be restored in this step. Note - * that SUID, SGID, etc, require additional work to ensure - * security, so we never restore them at this point. - */ - mode = final_mode & 0777; - - switch (a->mode & AE_IFMT) { - default: - /* POSIX requires that we fall through here. */ - /* FALLTHROUGH */ - case AE_IFREG: - a->fd = open(a->name, - O_WRONLY | O_CREAT | O_EXCL | O_BINARY, mode); - r = (a->fd < 0); - break; - case AE_IFCHR: -#ifdef HAVE_MKNOD - /* Note: we use AE_IFCHR for the case label, and - * S_IFCHR for the mknod() call. This is correct. */ - r = mknod(a->name, mode | S_IFCHR, - archive_entry_rdev(a->entry)); - break; -#else - /* TODO: Find a better way to warn about our inability - * to restore a char device node. */ - return (EINVAL); -#endif /* HAVE_MKNOD */ - case AE_IFBLK: -#ifdef HAVE_MKNOD - r = mknod(a->name, mode | S_IFBLK, - archive_entry_rdev(a->entry)); - break; -#else - /* TODO: Find a better way to warn about our inability - * to restore a block device node. */ - return (EINVAL); -#endif /* HAVE_MKNOD */ - case AE_IFDIR: - mode = (mode | MINIMUM_DIR_MODE) & MAXIMUM_DIR_MODE; - r = mkdir(a->name, mode); - if (r == 0) { - /* Defer setting dir times. */ - a->deferred |= (a->todo & TODO_TIMES); - a->todo &= ~TODO_TIMES; - /* Never use an immediate chmod(). */ - /* We can't avoid the chmod() entirely if EXTRACT_PERM - * because of SysV SGID inheritance. */ - if ((mode != final_mode) - || (a->flags & ARCHIVE_EXTRACT_PERM)) - a->deferred |= (a->todo & TODO_MODE); - a->todo &= ~TODO_MODE; - } - break; - case AE_IFIFO: -#ifdef HAVE_MKFIFO - r = mkfifo(a->name, mode); - break; -#else - /* TODO: Find a better way to warn about our inability - * to restore a fifo. */ - return (EINVAL); -#endif /* HAVE_MKFIFO */ - } - - /* All the system calls above set errno on failure. */ - if (r) - return (errno); - - /* If we managed to set the final mode, we've avoided a chmod(). */ - if (mode == final_mode) - a->todo &= ~TODO_MODE; - return (0); -} - -/* - * Cleanup function for archive_extract. Mostly, this involves processing - * the fixup list, which is used to address a number of problems: - * * Dir permissions might prevent us from restoring a file in that - * dir, so we restore the dir with minimum 0700 permissions first, - * then correct the mode at the end. - * * Similarly, the act of restoring a file touches the directory - * and changes the timestamp on the dir, so we have to touch-up dir - * timestamps at the end as well. - * * Some file flags can interfere with the restore by, for example, - * preventing the creation of hardlinks to those files. - * - * Note that tar/cpio do not require that archives be in a particular - * order; there is no way to know when the last file has been restored - * within a directory, so there's no way to optimize the memory usage - * here by fixing up the directory any earlier than the - * end-of-archive. - * - * XXX TODO: Directory ACLs should be restored here, for the same - * reason we set directory perms here. XXX - */ -static int -_archive_write_close(struct archive *_a) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - struct fixup_entry *next, *p; - int ret; - - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, - "archive_write_disk_close"); - ret = _archive_write_finish_entry(&a->archive); - - /* Sort dir list so directories are fixed up in depth-first order. */ - p = sort_dir_list(a->fixup_list); - - while (p != NULL) { - a->pst = NULL; /* Mark stat cache as out-of-date. */ - if (p->fixup & TODO_TIMES) { -#ifdef HAVE_UTIMES - /* {f,l,}utimes() are preferred, when available. */ -#if defined(_WIN32) && !defined(__CYGWIN__) - struct __timeval times[2]; -#else - struct timeval times[2]; -#endif - times[0].tv_sec = p->atime; - times[0].tv_usec = p->atime_nanos / 1000; -#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME - /* if it's valid and not mtime, push the birthtime first */ - if (((times[1].tv_sec = p->birthtime) < p->mtime) && - (p->birthtime > 0)) - { - times[1].tv_usec = p->birthtime_nanos / 1000; - utimes(p->name, times); - } -#endif - times[1].tv_sec = p->mtime; - times[1].tv_usec = p->mtime_nanos / 1000; -#ifdef HAVE_LUTIMES - lutimes(p->name, times); -#else - utimes(p->name, times); -#endif -#else - /* utime() is more portable, but less precise. */ - struct utimbuf times; - times.modtime = p->mtime; - times.actime = p->atime; - - utime(p->name, ×); -#endif - } - if (p->fixup & TODO_MODE_BASE) - chmod(p->name, p->mode); - - if (p->fixup & TODO_FFLAGS) - set_fflags_platform(a, -1, p->name, - p->mode, p->fflags_set, 0); - - next = p->next; - free(p->name); - free(p); - p = next; - } - a->fixup_list = NULL; - return (ret); -} - -static int -_archive_write_finish(struct archive *_a) -{ - struct archive_write_disk *a = (struct archive_write_disk *)_a; - int ret; - ret = _archive_write_close(&a->archive); - if (a->cleanup_gid != NULL && a->lookup_gid_data != NULL) - (a->cleanup_gid)(a->lookup_gid_data); - if (a->cleanup_uid != NULL && a->lookup_uid_data != NULL) - (a->cleanup_uid)(a->lookup_uid_data); - if (a->entry) - archive_entry_free(a->entry); - archive_string_free(&a->_name_data); - archive_string_free(&a->archive.error_string); - archive_string_free(&a->path_safe); - free(a); - return (ret); -} - -/* - * Simple O(n log n) merge sort to order the fixup list. In - * particular, we want to restore dir timestamps depth-first. - */ -static struct fixup_entry * -sort_dir_list(struct fixup_entry *p) -{ - struct fixup_entry *a, *b, *t; - - if (p == NULL) - return (NULL); - /* A one-item list is already sorted. */ - if (p->next == NULL) - return (p); - - /* Step 1: split the list. */ - t = p; - a = p->next->next; - while (a != NULL) { - /* Step a twice, t once. */ - a = a->next; - if (a != NULL) - a = a->next; - t = t->next; - } - /* Now, t is at the mid-point, so break the list here. */ - b = t->next; - t->next = NULL; - a = p; - - /* Step 2: Recursively sort the two sub-lists. */ - a = sort_dir_list(a); - b = sort_dir_list(b); - - /* Step 3: Merge the returned lists. */ - /* Pick the first element for the merged list. */ - if (strcmp(a->name, b->name) > 0) { - t = p = a; - a = a->next; - } else { - t = p = b; - b = b->next; - } - - /* Always put the later element on the list first. */ - while (a != NULL && b != NULL) { - if (strcmp(a->name, b->name) > 0) { - t->next = a; - a = a->next; - } else { - t->next = b; - b = b->next; - } - t = t->next; - } - - /* Only one list is non-empty, so just splice it on. */ - if (a != NULL) - t->next = a; - if (b != NULL) - t->next = b; - - return (p); -} - -/* - * Returns a new, initialized fixup entry. - * - * TODO: Reduce the memory requirements for this list by using a tree - * structure rather than a simple list of names. - */ -static struct fixup_entry * -new_fixup(struct archive_write_disk *a, const char *pathname) -{ - struct fixup_entry *fe; - - fe = (struct fixup_entry *)malloc(sizeof(struct fixup_entry)); - if (fe == NULL) - return (NULL); - fe->next = a->fixup_list; - a->fixup_list = fe; - fe->fixup = 0; - fe->name = strdup(pathname); - return (fe); -} - -/* - * Returns a fixup structure for the current entry. - */ -static struct fixup_entry * -current_fixup(struct archive_write_disk *a, const char *pathname) -{ - if (a->current_fixup == NULL) - a->current_fixup = new_fixup(a, pathname); - return (a->current_fixup); -} - -/* TODO: Make this work. */ -/* - * TODO: The deep-directory support bypasses this; disable deep directory - * support if we're doing symlink checks. - */ -/* - * TODO: Someday, integrate this with the deep dir support; they both - * scan the path and both can be optimized by comparing against other - * recent paths. - */ -/* TODO: Extend this to support symlinks on Windows Vista and later. */ -static int -check_symlinks(struct archive_write_disk *a) -{ -#if !defined(HAVE_LSTAT) - /* Platform doesn't have lstat, so we can't look for symlinks. */ - (void)a; /* UNUSED */ - return (ARCHIVE_OK); -#else - char *pn, *p; - char c; - int r; - struct stat st; - - /* - * Guard against symlink tricks. Reject any archive entry whose - * destination would be altered by a symlink. - */ - /* Whatever we checked last time doesn't need to be re-checked. */ - pn = a->name; - p = a->path_safe.s; - while ((*pn != '\0') && (*p == *pn)) - ++p, ++pn; - c = pn[0]; - /* Keep going until we've checked the entire name. */ - while (pn[0] != '\0' && (pn[0] != '/' || pn[1] != '\0')) { - /* Skip the next path element. */ - while (*pn != '\0' && *pn != '/') - ++pn; - c = pn[0]; - pn[0] = '\0'; - /* Check that we haven't hit a symlink. */ - r = lstat(a->name, &st); - if (r != 0) { - /* We've hit a dir that doesn't exist; stop now. */ - if (errno == ENOENT) - break; - } else if (S_ISLNK(st.st_mode)) { - if (c == '\0') { - /* - * Last element is symlink; remove it - * so we can overwrite it with the - * item being extracted. - */ - if (unlink(a->name)) { - archive_set_error(&a->archive, errno, - "Could not remove symlink %s", - a->name); - pn[0] = c; - return (ARCHIVE_FAILED); - } - a->pst = NULL; - /* - * Even if we did remove it, a warning - * is in order. The warning is silly, - * though, if we're just replacing one - * symlink with another symlink. - */ - if (!S_ISLNK(a->mode)) { - archive_set_error(&a->archive, 0, - "Removing symlink %s", - a->name); - } - /* Symlink gone. No more problem! */ - pn[0] = c; - return (0); - } else if (a->flags & ARCHIVE_EXTRACT_UNLINK) { - /* User asked us to remove problems. */ - if (unlink(a->name) != 0) { - archive_set_error(&a->archive, 0, - "Cannot remove intervening symlink %s", - a->name); - pn[0] = c; - return (ARCHIVE_FAILED); - } - a->pst = NULL; - } else { - archive_set_error(&a->archive, 0, - "Cannot extract through symlink %s", - a->name); - pn[0] = c; - return (ARCHIVE_FAILED); - } - } - } - pn[0] = c; - /* We've checked and/or cleaned the whole path, so remember it. */ - archive_strcpy(&a->path_safe, a->name); - return (ARCHIVE_OK); -#endif -} - -#if defined(_WIN32) || defined(__CYGWIN__) -/* - * 1. Convert a path separator from '\' to '/' . - * We shouldn't check multi-byte character directly because some - * character-set have been using the '\' character for a part of - * its multibyte character code. - * 2. Replace unusable characters in Windows with underscore('_'). - * See also : http://msdn.microsoft.com/en-us/library/aa365247.aspx - */ -static void -cleanup_pathname_win(struct archive_write_disk *a) -{ - wchar_t wc; - char *p; - size_t alen, l; - - alen = 0; - l = 0; - for (p = a->name; *p != '\0'; p++) { - ++alen; - if (*p == '\\') - l = 1; - /* Rewrite the path name if its character is a unusable. */ - if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || - *p == '<' || *p == '>' || *p == '|') - *p = '_'; - } - if (alen == 0 || l == 0) - return; - /* - * Convert path separator. - */ - p = a->name; - while (*p != '\0' && alen) { - l = mbtowc(&wc, p, alen); - if (l == -1) { - while (*p != '\0') { - if (*p == '\\') - *p = '/'; - ++p; - } - break; - } - if (l == 1 && wc == L'\\') - *p = '/'; - p += l; - alen -= l; - } -} -#endif - -/* - * Canonicalize the pathname. In particular, this strips duplicate - * '/' characters, '.' elements, and trailing '/'. It also raises an - * error for an empty path, a trailing '..' or (if _SECURE_NODOTDOT is - * set) any '..' in the path. - */ -static int -cleanup_pathname(struct archive_write_disk *a) -{ - char *dest, *src; - char separator = '\0'; - - dest = src = a->name; - if (*src == '\0') { - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Invalid empty pathname"); - return (ARCHIVE_FAILED); - } - -#if defined(_WIN32) || defined(__CYGWIN__) - cleanup_pathname_win(a); -#endif - /* Skip leading '/'. */ - if (*src == '/') - separator = *src++; - - /* Scan the pathname one element at a time. */ - for (;;) { - /* src points to first char after '/' */ - if (src[0] == '\0') { - break; - } else if (src[0] == '/') { - /* Found '//', ignore second one. */ - src++; - continue; - } else if (src[0] == '.') { - if (src[1] == '\0') { - /* Ignore trailing '.' */ - break; - } else if (src[1] == '/') { - /* Skip './'. */ - src += 2; - continue; - } else if (src[1] == '.') { - if (src[2] == '/' || src[2] == '\0') { - /* Conditionally warn about '..' */ - if (a->flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "Path contains '..'"); - return (ARCHIVE_FAILED); - } - } - /* - * Note: Under no circumstances do we - * remove '..' elements. In - * particular, restoring - * '/foo/../bar/' should create the - * 'foo' dir as a side-effect. - */ - } - } - - /* Copy current element, including leading '/'. */ - if (separator) - *dest++ = '/'; - while (*src != '\0' && *src != '/') { - *dest++ = *src++; - } - - if (*src == '\0') - break; - - /* Skip '/' separator. */ - separator = *src++; - } - /* - * We've just copied zero or more path elements, not including the - * final '/'. - */ - if (dest == a->name) { - /* - * Nothing got copied. The path must have been something - * like '.' or '/' or './' or '/././././/./'. - */ - if (separator) - *dest++ = '/'; - else - *dest++ = '.'; - } - /* Terminate the result. */ - *dest = '\0'; - return (ARCHIVE_OK); -} - -/* - * Create the parent directory of the specified path, assuming path - * is already in mutable storage. - */ -static int -create_parent_dir(struct archive_write_disk *a, char *path) -{ - char *slash; - int r; - - /* Remove tail element to obtain parent name. */ - slash = strrchr(path, '/'); - if (slash == NULL) - return (ARCHIVE_OK); - *slash = '\0'; - r = create_dir(a, path); - *slash = '/'; - return (r); -} - -/* - * Create the specified dir, recursing to create parents as necessary. - * - * Returns ARCHIVE_OK if the path exists when we're done here. - * Otherwise, returns ARCHIVE_FAILED. - * Assumes path is in mutable storage; path is unchanged on exit. - */ -static int -create_dir(struct archive_write_disk *a, char *path) -{ - struct stat st; - struct fixup_entry *le; - char *slash, *base; - mode_t mode_final, mode; - int r; - - /* Check for special names and just skip them. */ - slash = strrchr(path, '/'); - if (slash == NULL) - base = path; - else - base = slash + 1; - - if (base[0] == '\0' || - (base[0] == '.' && base[1] == '\0') || - (base[0] == '.' && base[1] == '.' && base[2] == '\0')) { - /* Don't bother trying to create null path, '.', or '..'. */ - if (slash != NULL) { - *slash = '\0'; - r = create_dir(a, path); - *slash = '/'; - return (r); - } - return (ARCHIVE_OK); - } - - /* - * Yes, this should be stat() and not lstat(). Using lstat() - * here loses the ability to extract through symlinks. Also note - * that this should not use the a->st cache. - */ - if (stat(path, &st) == 0) { - if (S_ISDIR(st.st_mode)) - return (ARCHIVE_OK); - if ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) { - archive_set_error(&a->archive, EEXIST, - "Can't create directory '%s'", path); - return (ARCHIVE_FAILED); - } - if (unlink(path) != 0) { - archive_set_error(&a->archive, errno, - "Can't create directory '%s': " - "Conflicting file cannot be removed"); - return (ARCHIVE_FAILED); - } - } else if (errno != ENOENT && errno != ENOTDIR) { - /* Stat failed? */ - archive_set_error(&a->archive, errno, "Can't test directory '%s'", path); - return (ARCHIVE_FAILED); - } else if (slash != NULL) { - *slash = '\0'; - r = create_dir(a, path); - *slash = '/'; - if (r != ARCHIVE_OK) - return (r); - } - - /* - * Mode we want for the final restored directory. Per POSIX, - * implicitly-created dirs must be created obeying the umask. - * There's no mention whether this is different for privileged - * restores (which the rest of this code handles by pretending - * umask=0). I've chosen here to always obey the user's umask for - * implicit dirs, even if _EXTRACT_PERM was specified. - */ - mode_final = DEFAULT_DIR_MODE & ~a->user_umask; - /* Mode we want on disk during the restore process. */ - mode = mode_final; - mode |= MINIMUM_DIR_MODE; - mode &= MAXIMUM_DIR_MODE; - if (mkdir(path, mode) == 0) { - if (mode != mode_final) { - le = new_fixup(a, path); - le->fixup |=TODO_MODE_BASE; - le->mode = mode_final; - } - return (ARCHIVE_OK); - } - - /* - * Without the following check, a/b/../b/c/d fails at the - * second visit to 'b', so 'd' can't be created. Note that we - * don't add it to the fixup list here, as it's already been - * added. - */ - if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) - return (ARCHIVE_OK); - - archive_set_error(&a->archive, errno, "Failed to create dir '%s'", - path); - return (ARCHIVE_FAILED); -} - -/* - * Note: Although we can skip setting the user id if the desired user - * id matches the current user, we cannot skip setting the group, as - * many systems set the gid based on the containing directory. So - * we have to perform a chown syscall if we want to set the SGID - * bit. (The alternative is to stat() and then possibly chown(); it's - * more efficient to skip the stat() and just always chown().) Note - * that a successful chown() here clears the TODO_SGID_CHECK bit, which - * allows set_mode to skip the stat() check for the GID. - */ -static int -set_ownership(struct archive_write_disk *a) -{ -#ifndef __CYGWIN__ -/* unfortunately, on win32 there is no 'root' user with uid 0, - so we just have to try the chown and see if it works */ - - /* If we know we can't change it, don't bother trying. */ - if (a->user_uid != 0 && a->user_uid != a->uid) { - archive_set_error(&a->archive, errno, - "Can't set UID=%d", a->uid); - return (ARCHIVE_WARN); - } -#endif - -#ifdef HAVE_FCHOWN - /* If we have an fd, we can avoid a race. */ - if (a->fd >= 0 && fchown(a->fd, a->uid, a->gid) == 0) { - /* We've set owner and know uid/gid are correct. */ - a->todo &= ~(TODO_OWNER | TODO_SGID_CHECK | TODO_SUID_CHECK); - return (ARCHIVE_OK); - } -#endif - - /* We prefer lchown() but will use chown() if that's all we have. */ - /* Of course, if we have neither, this will always fail. */ -#ifdef HAVE_LCHOWN - if (lchown(a->name, a->uid, a->gid) == 0) { - /* We've set owner and know uid/gid are correct. */ - a->todo &= ~(TODO_OWNER | TODO_SGID_CHECK | TODO_SUID_CHECK); - return (ARCHIVE_OK); - } -#elif HAVE_CHOWN - if (!S_ISLNK(a->mode) && chown(a->name, a->uid, a->gid) == 0) { - /* We've set owner and know uid/gid are correct. */ - a->todo &= ~(TODO_OWNER | TODO_SGID_CHECK | TODO_SUID_CHECK); - return (ARCHIVE_OK); - } -#endif - - archive_set_error(&a->archive, errno, - "Can't set user=%d/group=%d for %s", a->uid, a->gid, - a->name); - return (ARCHIVE_WARN); -} - - -#if defined(HAVE_UTIMENSAT) && defined(HAVE_FUTIMENS) -/* - * utimensat() and futimens() are defined in POSIX.1-2008. They provide ns - * resolution and setting times on fd and on symlinks, too. - */ -static int -set_time(int fd, int mode, const char *name, - time_t atime, long atime_nsec, - time_t mtime, long mtime_nsec) -{ - struct timespec ts[2]; - ts[0].tv_sec = atime; - ts[0].tv_nsec = atime_nsec; - ts[1].tv_sec = mtime; - ts[1].tv_nsec = mtime_nsec; - if (fd >= 0) - return futimens(fd, ts); - return utimensat(AT_FDCWD, name, ts, AT_SYMLINK_NOFOLLOW); -} -#elif HAVE_UTIMES -/* - * The utimes()-family functions provide µs-resolution and - * a way to set time on an fd or a symlink. We prefer them - * when they're available and utimensat/futimens aren't there. - */ -static int -set_time(int fd, int mode, const char *name, - time_t atime, long atime_nsec, - time_t mtime, long mtime_nsec) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - struct __timeval times[2]; -#else - struct timeval times[2]; -#endif - - times[0].tv_sec = atime; - times[0].tv_usec = atime_nsec / 1000; - times[1].tv_sec = mtime; - times[1].tv_usec = mtime_nsec / 1000; - -#ifdef HAVE_FUTIMES - if (fd >= 0) - return (futimes(fd, times)); -#else - (void)fd; /* UNUSED */ -#endif -#ifdef HAVE_LUTIMES - (void)mode; /* UNUSED */ - return (lutimes(name, times)); -#else - if (S_ISLNK(mode)) - return (0); - return (utimes(name, times)); -#endif -} -#elif defined(HAVE_UTIME) -/* - * utime() is an older, more standard interface that we'll use - * if utimes() isn't available. - */ -static int -set_time(int fd, int mode, const char *name, - time_t atime, long atime_nsec, - time_t mtime, long mtime_nsec) -{ - struct utimbuf times; - (void)fd; /* UNUSED */ - (void)name; /* UNUSED */ - (void)atime_nsec; /* UNUSED */ - (void)mtime_nsec; /* UNUSED */ - times.actime = atime; - times.modtime = mtime; - if (S_ISLNK(mode)) - return (ARCHIVE_OK); - return (utime(name, ×)); -} -#else -static int -set_time(int fd, int mode, const char *name, - time_t atime, long atime_nsec, - time_t mtime, long mtime_nsec) -{ - return (ARCHIVE_WARN); -} -#endif - -static int -set_times(struct archive_write_disk *a) -{ - time_t atime = a->start_time, mtime = a->start_time; - long atime_nsec = 0, mtime_nsec = 0; - - /* If no time was provided, we're done. */ - if (!archive_entry_atime_is_set(a->entry) -#if HAVE_STRUCT_STAT_ST_BIRTHTIME - && !archive_entry_birthtime_is_set(a->entry) -#endif - && !archive_entry_mtime_is_set(a->entry)) - return (ARCHIVE_OK); - - /* If no atime was specified, use start time instead. */ - /* In theory, it would be marginally more correct to use - * time(NULL) here, but that would cost us an extra syscall - * for little gain. */ - if (archive_entry_atime_is_set(a->entry)) { - atime = archive_entry_atime(a->entry); - atime_nsec = archive_entry_atime_nsec(a->entry); - } - - /* - * If you have struct stat.st_birthtime, we assume BSD birthtime - * semantics, in which {f,l,}utimes() updates birthtime to earliest - * mtime. So we set the time twice, first using the birthtime, - * then using the mtime. - */ -#if HAVE_STRUCT_STAT_ST_BIRTHTIME - /* If birthtime is set, flush that through to disk first. */ - if (archive_entry_birthtime_is_set(a->entry)) - if (set_time(a->fd, a->mode, a->name, atime, atime_nsec, - archive_entry_birthtime(a->entry), - archive_entry_birthtime_nsec(a->entry))) { - archive_set_error(&a->archive, errno, - "Can't update time for %s", - a->name); - return (ARCHIVE_WARN); - } -#endif - - if (archive_entry_mtime_is_set(a->entry)) { - mtime = archive_entry_mtime(a->entry); - mtime_nsec = archive_entry_mtime_nsec(a->entry); - } - if (set_time(a->fd, a->mode, a->name, - atime, atime_nsec, mtime, mtime_nsec)) { - archive_set_error(&a->archive, errno, - "Can't update time for %s", - a->name); - return (ARCHIVE_WARN); - } - - /* - * Note: POSIX does not provide a portable way to restore ctime. - * (Apart from resetting the system clock, which is distasteful.) - * So, any restoration of ctime will necessarily be OS-specific. - */ - - return (ARCHIVE_OK); -} - -static int -set_mode(struct archive_write_disk *a, int mode) -{ - int r = ARCHIVE_OK; - mode &= 07777; /* Strip off file type bits. */ - - if (a->todo & TODO_SGID_CHECK) { - /* - * If we don't know the GID is right, we must stat() - * to verify it. We can't just check the GID of this - * process, since systems sometimes set GID from - * the enclosing dir or based on ACLs. - */ - if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK) - return (r); - if (a->pst->st_gid != a->gid) { - mode &= ~ S_ISGID; -#if !defined(_WIN32) || defined(__CYGWIN__) - if (a->flags & ARCHIVE_EXTRACT_OWNER) { - /* - * This is only an error if you - * requested owner restore. If you - * didn't, we'll try to restore - * sgid/suid, but won't consider it a - * problem if we can't. - */ - archive_set_error(&a->archive, -1, - "Can't restore SGID bit"); - r = ARCHIVE_WARN; - } -#endif - } - /* While we're here, double-check the UID. */ - if (a->pst->st_uid != a->uid - && (a->todo & TODO_SUID)) { - mode &= ~ S_ISUID; -#if !defined(_WIN32) || defined(__CYGWIN__) - if (a->flags & ARCHIVE_EXTRACT_OWNER) { - archive_set_error(&a->archive, -1, - "Can't restore SUID bit"); - r = ARCHIVE_WARN; - } -#endif - } - a->todo &= ~TODO_SGID_CHECK; - a->todo &= ~TODO_SUID_CHECK; - } else if (a->todo & TODO_SUID_CHECK) { - /* - * If we don't know the UID is right, we can just check - * the user, since all systems set the file UID from - * the process UID. - */ - if (a->user_uid != a->uid) { - mode &= ~ S_ISUID; -#if !defined(_WIN32) || defined(__CYGWIN__) - if (a->flags & ARCHIVE_EXTRACT_OWNER) { - archive_set_error(&a->archive, -1, - "Can't make file SUID"); - r = ARCHIVE_WARN; - } -#endif - } - a->todo &= ~TODO_SUID_CHECK; - } - - if (S_ISLNK(a->mode)) { -#ifdef HAVE_LCHMOD - /* - * If this is a symlink, use lchmod(). If the - * platform doesn't support lchmod(), just skip it. A - * platform that doesn't provide a way to set - * permissions on symlinks probably ignores - * permissions on symlinks, so a failure here has no - * impact. - */ - if (lchmod(a->name, mode) != 0) { - archive_set_error(&a->archive, errno, - "Can't set permissions to 0%o", (int)mode); - r = ARCHIVE_WARN; - } -#endif - } else if (!S_ISDIR(a->mode)) { - /* - * If it's not a symlink and not a dir, then use - * fchmod() or chmod(), depending on whether we have - * an fd. Dirs get their perms set during the - * post-extract fixup, which is handled elsewhere. - */ -#ifdef HAVE_FCHMOD - if (a->fd >= 0) { - if (fchmod(a->fd, mode) != 0) { - archive_set_error(&a->archive, errno, - "Can't set permissions to 0%o", (int)mode); - r = ARCHIVE_WARN; - } - } else -#endif - /* If this platform lacks fchmod(), then - * we'll just use chmod(). */ - if (chmod(a->name, mode) != 0) { - archive_set_error(&a->archive, errno, - "Can't set permissions to 0%o", (int)mode); - r = ARCHIVE_WARN; - } - } - return (r); -} - -static int -set_fflags(struct archive_write_disk *a) -{ - struct fixup_entry *le; - unsigned long set, clear; - int r; - int critical_flags; - mode_t mode = archive_entry_mode(a->entry); - - /* - * Make 'critical_flags' hold all file flags that can't be - * immediately restored. For example, on BSD systems, - * SF_IMMUTABLE prevents hardlinks from being created, so - * should not be set until after any hardlinks are created. To - * preserve some semblance of portability, this uses #ifdef - * extensively. Ugly, but it works. - * - * Yes, Virginia, this does create a security race. It's mitigated - * somewhat by the practice of creating dirs 0700 until the extract - * is done, but it would be nice if we could do more than that. - * People restoring critical file systems should be wary of - * other programs that might try to muck with files as they're - * being restored. - */ - /* Hopefully, the compiler will optimize this mess into a constant. */ - critical_flags = 0; -#ifdef SF_IMMUTABLE - critical_flags |= SF_IMMUTABLE; -#endif -#ifdef UF_IMMUTABLE - critical_flags |= UF_IMMUTABLE; -#endif -#ifdef SF_APPEND - critical_flags |= SF_APPEND; -#endif -#ifdef UF_APPEND - critical_flags |= UF_APPEND; -#endif -#ifdef EXT2_APPEND_FL - critical_flags |= EXT2_APPEND_FL; -#endif -#ifdef EXT2_IMMUTABLE_FL - critical_flags |= EXT2_IMMUTABLE_FL; -#endif - - if (a->todo & TODO_FFLAGS) { - archive_entry_fflags(a->entry, &set, &clear); - - /* - * The first test encourages the compiler to eliminate - * all of this if it's not necessary. - */ - if ((critical_flags != 0) && (set & critical_flags)) { - le = current_fixup(a, a->name); - le->fixup |= TODO_FFLAGS; - le->fflags_set = set; - /* Store the mode if it's not already there. */ - if ((le->fixup & TODO_MODE) == 0) - le->mode = mode; - } else { - r = set_fflags_platform(a, a->fd, - a->name, mode, set, clear); - if (r != ARCHIVE_OK) - return (r); - } - } - return (ARCHIVE_OK); -} - - -#if ( defined(HAVE_LCHFLAGS) || defined(HAVE_CHFLAGS) || defined(HAVE_FCHFLAGS) ) && defined(HAVE_STRUCT_STAT_ST_FLAGS) -/* - * BSD reads flags using stat() and sets them with one of {f,l,}chflags() - */ -static int -set_fflags_platform(struct archive_write_disk *a, int fd, const char *name, - mode_t mode, unsigned long set, unsigned long clear) -{ - int r; - - (void)mode; /* UNUSED */ - if (set == 0 && clear == 0) - return (ARCHIVE_OK); - - /* - * XXX Is the stat here really necessary? Or can I just use - * the 'set' flags directly? In particular, I'm not sure - * about the correct approach if we're overwriting an existing - * file that already has flags on it. XXX - */ - if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK) - return (r); - - a->st.st_flags &= ~clear; - a->st.st_flags |= set; -#ifdef HAVE_FCHFLAGS - /* If platform has fchflags() and we were given an fd, use it. */ - if (fd >= 0 && fchflags(fd, a->st.st_flags) == 0) - return (ARCHIVE_OK); -#endif - /* - * If we can't use the fd to set the flags, we'll use the - * pathname to set flags. We prefer lchflags() but will use - * chflags() if we must. - */ -#ifdef HAVE_LCHFLAGS - if (lchflags(name, a->st.st_flags) == 0) - return (ARCHIVE_OK); -#elif defined(HAVE_CHFLAGS) - if (S_ISLNK(a->st.st_mode)) { - archive_set_error(&a->archive, errno, - "Can't set file flags on symlink."); - return (ARCHIVE_WARN); - } - if (chflags(name, a->st.st_flags) == 0) - return (ARCHIVE_OK); -#endif - archive_set_error(&a->archive, errno, - "Failed to set file flags"); - return (ARCHIVE_WARN); -} - -#elif defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS) -/* - * Linux uses ioctl() to read and write file flags. - */ -static int -set_fflags_platform(struct archive_write_disk *a, int fd, const char *name, - mode_t mode, unsigned long set, unsigned long clear) -{ - int ret; - int myfd = fd; - unsigned long newflags, oldflags; - unsigned long sf_mask = 0; - - if (set == 0 && clear == 0) - return (ARCHIVE_OK); - /* Only regular files and dirs can have flags. */ - if (!S_ISREG(mode) && !S_ISDIR(mode)) - return (ARCHIVE_OK); - - /* If we weren't given an fd, open it ourselves. */ - if (myfd < 0) - myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY); - if (myfd < 0) - return (ARCHIVE_OK); - - /* - * Linux has no define for the flags that are only settable by - * the root user. This code may seem a little complex, but - * there seem to be some Linux systems that lack these - * defines. (?) The code below degrades reasonably gracefully - * if sf_mask is incomplete. - */ -#ifdef EXT2_IMMUTABLE_FL - sf_mask |= EXT2_IMMUTABLE_FL; -#endif -#ifdef EXT2_APPEND_FL - sf_mask |= EXT2_APPEND_FL; -#endif - /* - * XXX As above, this would be way simpler if we didn't have - * to read the current flags from disk. XXX - */ - ret = ARCHIVE_OK; - /* Try setting the flags as given. */ - if (ioctl(myfd, EXT2_IOC_GETFLAGS, &oldflags) >= 0) { - newflags = (oldflags & ~clear) | set; - if (ioctl(myfd, EXT2_IOC_SETFLAGS, &newflags) >= 0) - goto cleanup; - if (errno != EPERM) - goto fail; - } - /* If we couldn't set all the flags, try again with a subset. */ - if (ioctl(myfd, EXT2_IOC_GETFLAGS, &oldflags) >= 0) { - newflags &= ~sf_mask; - oldflags &= sf_mask; - newflags |= oldflags; - if (ioctl(myfd, EXT2_IOC_SETFLAGS, &newflags) >= 0) - goto cleanup; - } - /* We couldn't set the flags, so report the failure. */ -fail: - archive_set_error(&a->archive, errno, - "Failed to set file flags"); - ret = ARCHIVE_WARN; -cleanup: - if (fd < 0) - close(myfd); - return (ret); -} - -#else - -/* - * Of course, some systems have neither BSD chflags() nor Linux' flags - * support through ioctl(). - */ -static int -set_fflags_platform(struct archive_write_disk *a, int fd, const char *name, - mode_t mode, unsigned long set, unsigned long clear) -{ - (void)a; /* UNUSED */ - (void)fd; /* UNUSED */ - (void)name; /* UNUSED */ - (void)mode; /* UNUSED */ - (void)set; /* UNUSED */ - (void)clear; /* UNUSED */ - return (ARCHIVE_OK); -} - -#endif /* __linux */ - -#ifndef HAVE_POSIX_ACL -/* Default empty function body to satisfy mainline code. */ -static int -set_acls(struct archive_write_disk *a) -{ - (void)a; /* UNUSED */ - return (ARCHIVE_OK); -} - -#else - -/* - * XXX TODO: What about ACL types other than ACCESS and DEFAULT? - */ -static int -set_acls(struct archive_write_disk *a) -{ - int ret; - - ret = set_acl(a, a->fd, a->entry, ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access"); - if (ret != ARCHIVE_OK) - return (ret); - ret = set_acl(a, a->fd, a->entry, ACL_TYPE_DEFAULT, - ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default"); - return (ret); -} - - -static int -set_acl(struct archive_write_disk *a, int fd, struct archive_entry *entry, - acl_type_t acl_type, int ae_requested_type, const char *tname) -{ - acl_t acl; - acl_entry_t acl_entry; - acl_permset_t acl_permset; - int ret; - int ae_type, ae_permset, ae_tag, ae_id; - uid_t ae_uid; - gid_t ae_gid; - const char *ae_name; - int entries; - const char *name; - - ret = ARCHIVE_OK; - entries = archive_entry_acl_reset(entry, ae_requested_type); - if (entries == 0) - return (ARCHIVE_OK); - acl = acl_init(entries); - while (archive_entry_acl_next(entry, ae_requested_type, &ae_type, - &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) { - acl_create_entry(&acl, &acl_entry); - - switch (ae_tag) { - case ARCHIVE_ENTRY_ACL_USER: - acl_set_tag_type(acl_entry, ACL_USER); - ae_uid = a->lookup_uid(a->lookup_uid_data, - ae_name, ae_id); - acl_set_qualifier(acl_entry, &ae_uid); - break; - case ARCHIVE_ENTRY_ACL_GROUP: - acl_set_tag_type(acl_entry, ACL_GROUP); - ae_gid = a->lookup_gid(a->lookup_gid_data, - ae_name, ae_id); - acl_set_qualifier(acl_entry, &ae_gid); - break; - case ARCHIVE_ENTRY_ACL_USER_OBJ: - acl_set_tag_type(acl_entry, ACL_USER_OBJ); - break; - case ARCHIVE_ENTRY_ACL_GROUP_OBJ: - acl_set_tag_type(acl_entry, ACL_GROUP_OBJ); - break; - case ARCHIVE_ENTRY_ACL_MASK: - acl_set_tag_type(acl_entry, ACL_MASK); - break; - case ARCHIVE_ENTRY_ACL_OTHER: - acl_set_tag_type(acl_entry, ACL_OTHER); - break; - default: - /* XXX */ - break; - } - - acl_get_permset(acl_entry, &acl_permset); - acl_clear_perms(acl_permset); - if (ae_permset & ARCHIVE_ENTRY_ACL_EXECUTE) - acl_add_perm(acl_permset, ACL_EXECUTE); - if (ae_permset & ARCHIVE_ENTRY_ACL_WRITE) - acl_add_perm(acl_permset, ACL_WRITE); - if (ae_permset & ARCHIVE_ENTRY_ACL_READ) - acl_add_perm(acl_permset, ACL_READ); - } - - name = archive_entry_pathname(entry); - - /* Try restoring the ACL through 'fd' if we can. */ -#if HAVE_ACL_SET_FD - if (fd >= 0 && acl_type == ACL_TYPE_ACCESS && acl_set_fd(fd, acl) == 0) - ret = ARCHIVE_OK; - else -#else -#if HAVE_ACL_SET_FD_NP - if (fd >= 0 && acl_set_fd_np(fd, acl, acl_type) == 0) - ret = ARCHIVE_OK; - else -#endif -#endif - if (acl_set_file(name, acl_type, acl) != 0) { - archive_set_error(&a->archive, errno, "Failed to set %s acl", tname); - ret = ARCHIVE_WARN; - } - acl_free(acl); - return (ret); -} -#endif - -#if HAVE_LSETXATTR -/* - * Restore extended attributes - Linux implementation - */ -static int -set_xattrs(struct archive_write_disk *a) -{ - struct archive_entry *entry = a->entry; - static int warning_done = 0; - int ret = ARCHIVE_OK; - int i = archive_entry_xattr_reset(entry); - - while (i--) { - const char *name; - const void *value; - size_t size; - archive_entry_xattr_next(entry, &name, &value, &size); - if (name != NULL && - strncmp(name, "xfsroot.", 8) != 0 && - strncmp(name, "system.", 7) != 0) { - int e; -#if HAVE_FSETXATTR - if (a->fd >= 0) - e = fsetxattr(a->fd, name, value, size, 0); - else -#endif - { - e = lsetxattr(archive_entry_pathname(entry), - name, value, size, 0); - } - if (e == -1) { - if (errno == ENOTSUP) { - if (!warning_done) { - warning_done = 1; - archive_set_error(&a->archive, errno, - "Cannot restore extended " - "attributes on this file " - "system"); - } - } else - archive_set_error(&a->archive, errno, - "Failed to set extended attribute"); - ret = ARCHIVE_WARN; - } - } else { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Invalid extended attribute encountered"); - ret = ARCHIVE_WARN; - } - } - return (ret); -} -#elif HAVE_EXTATTR_SET_FILE && HAVE_DECL_EXTATTR_NAMESPACE_USER -/* - * Restore extended attributes - FreeBSD implementation - */ -static int -set_xattrs(struct archive_write_disk *a) -{ - struct archive_entry *entry = a->entry; - static int warning_done = 0; - int ret = ARCHIVE_OK; - int i = archive_entry_xattr_reset(entry); - - while (i--) { - const char *name; - const void *value; - size_t size; - archive_entry_xattr_next(entry, &name, &value, &size); - if (name != NULL) { - int e; - int namespace; - - if (strncmp(name, "user.", 5) == 0) { - /* "user." attributes go to user namespace */ - name += 5; - namespace = EXTATTR_NAMESPACE_USER; - } else { - /* Warn about other extended attributes. */ - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Can't restore extended attribute ``%s''", - name); - ret = ARCHIVE_WARN; - continue; - } - errno = 0; -#if HAVE_EXTATTR_SET_FD - if (a->fd >= 0) - e = extattr_set_fd(a->fd, namespace, name, value, size); - else -#endif - /* TODO: should we use extattr_set_link() instead? */ - { - e = extattr_set_file(archive_entry_pathname(entry), - namespace, name, value, size); - } - if (e != (int)size) { - if (errno == ENOTSUP) { - if (!warning_done) { - warning_done = 1; - archive_set_error(&a->archive, errno, - "Cannot restore extended " - "attributes on this file " - "system"); - } - } else { - archive_set_error(&a->archive, errno, - "Failed to set extended attribute"); - } - - ret = ARCHIVE_WARN; - } - } - } - return (ret); -} -#else -/* - * Restore extended attributes - stub implementation for unsupported systems - */ -static int -set_xattrs(struct archive_write_disk *a) -{ - static int warning_done = 0; - - /* If there aren't any extended attributes, then it's okay not - * to extract them, otherwise, issue a single warning. */ - if (archive_entry_xattr_count(a->entry) != 0 && !warning_done) { - warning_done = 1; - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Cannot restore extended attributes on this system"); - return (ARCHIVE_WARN); - } - /* Warning was already emitted; suppress further warnings. */ - return (ARCHIVE_OK); -} -#endif - - -/* - * Trivial implementations of gid/uid lookup functions. - * These are normally overridden by the client, but these stub - * versions ensure that we always have something that works. - */ -static gid_t -trivial_lookup_gid(void *private_data, const char *gname, gid_t gid) -{ - (void)private_data; /* UNUSED */ - (void)gname; /* UNUSED */ - return (gid); -} - -static uid_t -trivial_lookup_uid(void *private_data, const char *uname, uid_t uid) -{ - (void)private_data; /* UNUSED */ - (void)uname; /* UNUSED */ - return (uid); -} - -/* - * Test if file on disk is older than entry. - */ -static int -older(struct stat *st, struct archive_entry *entry) -{ - /* First, test the seconds and return if we have a definite answer. */ - /* Definitely older. */ - if (st->st_mtime < archive_entry_mtime(entry)) - return (1); - /* Definitely younger. */ - if (st->st_mtime > archive_entry_mtime(entry)) - return (0); - /* If this platform supports fractional seconds, try those. */ -#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - /* Definitely older. */ - if (st->st_mtimespec.tv_nsec < archive_entry_mtime_nsec(entry)) - return (1); -#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - /* Definitely older. */ - if (st->st_mtim.tv_nsec < archive_entry_mtime_nsec(entry)) - return (1); -#elif HAVE_STRUCT_STAT_ST_MTIME_N - /* older. */ - if (st->st_mtime_n < archive_entry_mtime_nsec(entry)) - return (1); -#elif HAVE_STRUCT_STAT_ST_UMTIME - /* older. */ - if (st->st_umtime * 1000 < archive_entry_mtime_nsec(entry)) - return (1); -#elif HAVE_STRUCT_STAT_ST_MTIME_USEC - /* older. */ - if (st->st_mtime_usec * 1000 < archive_entry_mtime_nsec(entry)) - return (1); -#else - /* This system doesn't have high-res timestamps. */ -#endif - /* Same age or newer, so not older. */ - return (0); -} diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c deleted file mode 100644 index 626bbbc16ec..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c +++ /dev/null @@ -1,408 +0,0 @@ -/*- - * 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 "archive_platform.h" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_bzip2.c 201091 2009-12-28 02:22:41Z kientzle $"); - -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#include <stdio.h> -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_BZLIB_H -#include <bzlib.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_write_private.h" - -#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) -int -archive_write_set_compression_bzip2(struct archive *a) -{ - archive_set_error(a, ARCHIVE_ERRNO_MISC, - "bzip2 compression not supported on this platform"); - return (ARCHIVE_FATAL); -} -#else -/* Don't compile this if we don't have bzlib. */ - -struct private_data { - bz_stream stream; - int64_t total_in; - char *compressed; - size_t compressed_buffer_size; -}; - -struct private_config { - int compression_level; -}; - -/* - * Yuck. bzlib.h is not const-correct, so I need this one bit - * of ugly hackery to convert a const * pointer to a non-const pointer. - */ -#define SET_NEXT_IN(st,src) \ - (st)->stream.next_in = (char *)(uintptr_t)(const void *)(src) - -static int archive_compressor_bzip2_finish(struct archive_write *); -static int archive_compressor_bzip2_init(struct archive_write *); -static int archive_compressor_bzip2_options(struct archive_write *, - const char *, const char *); -static int archive_compressor_bzip2_write(struct archive_write *, - const void *, size_t); -static int drive_compressor(struct archive_write *, struct private_data *, - int finishing); - -/* - * Allocate, initialize and return an archive object. - */ -int -archive_write_set_compression_bzip2(struct archive *_a) -{ - struct archive_write *a = (struct archive_write *)_a; - struct private_config *config; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW, "archive_write_set_compression_bzip2"); - config = malloc(sizeof(*config)); - if (config == NULL) { - archive_set_error(&a->archive, ENOMEM, "Out of memory"); - return (ARCHIVE_FATAL); - } - a->compressor.config = config; - a->compressor.finish = archive_compressor_bzip2_finish; - config->compression_level = 9; /* default */ - a->compressor.init = &archive_compressor_bzip2_init; - a->compressor.options = &archive_compressor_bzip2_options; - a->archive.compression_code = ARCHIVE_COMPRESSION_BZIP2; - a->archive.compression_name = "bzip2"; - return (ARCHIVE_OK); -} - -/* - * Setup callback. - */ -static int -archive_compressor_bzip2_init(struct archive_write *a) -{ - int ret; - struct private_data *state; - struct private_config *config; - - config = (struct private_config *)a->compressor.config; - if (a->client_opener != NULL) { - ret = (a->client_opener)(&a->archive, a->client_data); - if (ret != 0) - return (ret); - } - - state = (struct private_data *)malloc(sizeof(*state)); - if (state == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression"); - return (ARCHIVE_FATAL); - } - memset(state, 0, sizeof(*state)); - - state->compressed_buffer_size = a->bytes_per_block; - state->compressed = (char *)malloc(state->compressed_buffer_size); - - if (state->compressed == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression buffer"); - free(state); - return (ARCHIVE_FATAL); - } - - state->stream.next_out = state->compressed; - state->stream.avail_out = state->compressed_buffer_size; - a->compressor.write = archive_compressor_bzip2_write; - - /* Initialize compression library */ - ret = BZ2_bzCompressInit(&(state->stream), - config->compression_level, 0, 30); - if (ret == BZ_OK) { - a->compressor.data = state; - return (ARCHIVE_OK); - } - - /* Library setup failed: clean up. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library"); - free(state->compressed); - free(state); - - /* Override the error message if we know what really went wrong. */ - switch (ret) { - case BZ_PARAM_ERROR: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "invalid setup parameter"); - break; - case BZ_MEM_ERROR: - archive_set_error(&a->archive, ENOMEM, - "Internal error initializing compression library: " - "out of memory"); - break; - case BZ_CONFIG_ERROR: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "mis-compiled library"); - break; - } - - return (ARCHIVE_FATAL); - -} - -/* - * Set write options. - */ -static int -archive_compressor_bzip2_options(struct archive_write *a, const char *key, - const char *value) -{ - struct private_config *config; - - config = (struct private_config *)a->compressor.config; - if (strcmp(key, "compression-level") == 0) { - if (value == NULL || !(value[0] >= '0' && value[0] <= '9') || - value[1] != '\0') - return (ARCHIVE_WARN); - config->compression_level = value[0] - '0'; - /* Make '0' be a synonym for '1'. */ - /* This way, bzip2 compressor supports the same 0..9 - * range of levels as gzip. */ - if (config->compression_level < 1) - config->compression_level = 1; - return (ARCHIVE_OK); - } - - return (ARCHIVE_WARN); -} - -/* - * Write data to the compressed stream. - * - * Returns ARCHIVE_OK if all data written, error otherwise. - */ -static int -archive_compressor_bzip2_write(struct archive_write *a, const void *buff, - size_t length) -{ - struct private_data *state; - - state = (struct private_data *)a->compressor.data; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - /* Update statistics */ - state->total_in += length; - - /* Compress input data to output buffer */ - SET_NEXT_IN(state, buff); - state->stream.avail_in = length; - if (drive_compressor(a, state, 0)) - return (ARCHIVE_FATAL); - a->archive.file_position += length; - return (ARCHIVE_OK); -} - - -/* - * Finish the compression. - */ -static int -archive_compressor_bzip2_finish(struct archive_write *a) -{ - ssize_t block_length; - int ret; - struct private_data *state; - ssize_t target_block_length; - ssize_t bytes_written; - unsigned tocopy; - - ret = ARCHIVE_OK; - state = (struct private_data *)a->compressor.data; - if (state != NULL) { - if (a->client_writer == NULL) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered?\n" - "This is probably an internal programming error."); - ret = ARCHIVE_FATAL; - goto cleanup; - } - - /* By default, always pad the uncompressed data. */ - if (a->pad_uncompressed) { - tocopy = a->bytes_per_block - - (state->total_in % a->bytes_per_block); - while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) { - SET_NEXT_IN(state, a->nulls); - state->stream.avail_in = tocopy < a->null_length ? - tocopy : a->null_length; - state->total_in += state->stream.avail_in; - tocopy -= state->stream.avail_in; - ret = drive_compressor(a, state, 0); - if (ret != ARCHIVE_OK) - goto cleanup; - } - } - - /* Finish compression cycle. */ - if ((ret = drive_compressor(a, state, 1))) - goto cleanup; - - /* Optionally, pad the final compressed block. */ - block_length = state->stream.next_out - state->compressed; - - /* Tricky calculation to determine size of last block. */ - if (a->bytes_in_last_block <= 0) - /* Default or Zero: pad to full block */ - target_block_length = a->bytes_per_block; - else - /* Round length to next multiple of bytes_in_last_block. */ - target_block_length = a->bytes_in_last_block * - ( (block_length + a->bytes_in_last_block - 1) / - a->bytes_in_last_block); - if (target_block_length > a->bytes_per_block) - target_block_length = a->bytes_per_block; - if (block_length < target_block_length) { - memset(state->stream.next_out, 0, - target_block_length - block_length); - block_length = target_block_length; - } - - /* Write the last block */ - bytes_written = (a->client_writer)(&a->archive, a->client_data, - state->compressed, block_length); - - /* TODO: Handle short write of final block. */ - if (bytes_written <= 0) - ret = ARCHIVE_FATAL; - else { - a->archive.raw_position += ret; - ret = ARCHIVE_OK; - } - - /* Cleanup: shut down compressor, release memory, etc. */ -cleanup: - switch (BZ2_bzCompressEnd(&(state->stream))) { - case BZ_OK: - break; - default: - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "Failed to clean up compressor"); - ret = ARCHIVE_FATAL; - } - - free(state->compressed); - free(state); - } - /* Free configuration data even if we were never fully initialized. */ - free(a->compressor.config); - a->compressor.config = NULL; - return (ret); -} - -/* - * Utility function to push input data through compressor, writing - * full output blocks as necessary. - * - * Note that this handles both the regular write case (finishing == - * false) and the end-of-archive case (finishing == true). - */ -static int -drive_compressor(struct archive_write *a, struct private_data *state, int finishing) -{ - ssize_t bytes_written; - int ret; - - for (;;) { - if (state->stream.avail_out == 0) { - bytes_written = (a->client_writer)(&a->archive, - a->client_data, state->compressed, - state->compressed_buffer_size); - if (bytes_written <= 0) { - /* TODO: Handle this write failure */ - return (ARCHIVE_FATAL); - } else if ((size_t)bytes_written < state->compressed_buffer_size) { - /* Short write: Move remainder to - * front and keep filling */ - memmove(state->compressed, - state->compressed + bytes_written, - state->compressed_buffer_size - bytes_written); - } - - a->archive.raw_position += bytes_written; - state->stream.next_out = state->compressed + - state->compressed_buffer_size - bytes_written; - state->stream.avail_out = bytes_written; - } - - /* If there's nothing to do, we're done. */ - if (!finishing && state->stream.avail_in == 0) - return (ARCHIVE_OK); - - ret = BZ2_bzCompress(&(state->stream), - finishing ? BZ_FINISH : BZ_RUN); - - switch (ret) { - case BZ_RUN_OK: - /* In non-finishing case, did compressor - * consume everything? */ - if (!finishing && state->stream.avail_in == 0) - return (ARCHIVE_OK); - break; - case BZ_FINISH_OK: /* Finishing: There's more work to do */ - break; - case BZ_STREAM_END: /* Finishing: all done */ - /* Only occurs in finishing case */ - return (ARCHIVE_OK); - default: - /* Any other return value indicates an error */ - archive_set_error(&a->archive, - ARCHIVE_ERRNO_PROGRAMMER, - "Bzip2 compression failed;" - " BZ2_bzCompress() returned %d", - ret); - return (ARCHIVE_FATAL); - } - } -} - -#endif /* HAVE_BZLIB_H && BZ_CONFIG_ERROR */ diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c deleted file mode 100644 index 77c73ee5f27..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c +++ /dev/null @@ -1,492 +0,0 @@ -/*- - * Copyright (c) 2008 Joerg Sonnenberger - * 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. - */ - -/*- - * Copyright (c) 1985, 1986, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Diomidis Spinellis and James A. Woods, derived from original - * work by Spencer Thomas and Joseph Orost. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include "archive_platform.h" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_compress.c 201111 2009-12-28 03:33:05Z kientzle $"); - -#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 "archive.h" -#include "archive_private.h" -#include "archive_write_private.h" - -#define HSIZE 69001 /* 95% occupancy */ -#define HSHIFT 8 /* 8 - trunc(log2(HSIZE / 65536)) */ -#define CHECK_GAP 10000 /* Ratio check interval. */ - -#define MAXCODE(bits) ((1 << (bits)) - 1) - -/* - * the next two codes should not be changed lightly, as they must not - * lie within the contiguous general code space. - */ -#define FIRST 257 /* First free entry. */ -#define CLEAR 256 /* Table clear output code. */ - -struct private_data { - off_t in_count, out_count, checkpoint; - - int code_len; /* Number of bits/code. */ - int cur_maxcode; /* Maximum code, given n_bits. */ - int max_maxcode; /* Should NEVER generate this code. */ - int hashtab [HSIZE]; - unsigned short codetab [HSIZE]; - int first_free; /* First unused entry. */ - int compress_ratio; - - int cur_code, cur_fcode; - - int bit_offset; - unsigned char bit_buf; - - unsigned char *compressed; - size_t compressed_buffer_size; - size_t compressed_offset; -}; - -static int archive_compressor_compress_finish(struct archive_write *); -static int archive_compressor_compress_init(struct archive_write *); -static int archive_compressor_compress_write(struct archive_write *, - const void *, size_t); - -/* - * Allocate, initialize and return a archive object. - */ -int -archive_write_set_compression_compress(struct archive *_a) -{ - struct archive_write *a = (struct archive_write *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW, "archive_write_set_compression_compress"); - a->compressor.init = &archive_compressor_compress_init; - a->archive.compression_code = ARCHIVE_COMPRESSION_COMPRESS; - a->archive.compression_name = "compress"; - return (ARCHIVE_OK); -} - -/* - * Setup callback. - */ -static int -archive_compressor_compress_init(struct archive_write *a) -{ - int ret; - struct private_data *state; - - a->archive.compression_code = ARCHIVE_COMPRESSION_COMPRESS; - a->archive.compression_name = "compress"; - - if (a->bytes_per_block < 4) { - archive_set_error(&a->archive, EINVAL, - "Can't write Compress header as single block"); - return (ARCHIVE_FATAL); - } - - if (a->client_opener != NULL) { - ret = (a->client_opener)(&a->archive, a->client_data); - if (ret != ARCHIVE_OK) - return (ret); - } - - state = (struct private_data *)malloc(sizeof(*state)); - if (state == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression"); - return (ARCHIVE_FATAL); - } - memset(state, 0, sizeof(*state)); - - state->compressed_buffer_size = a->bytes_per_block; - state->compressed = malloc(state->compressed_buffer_size); - - if (state->compressed == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression buffer"); - free(state); - return (ARCHIVE_FATAL); - } - - a->compressor.write = archive_compressor_compress_write; - a->compressor.finish = archive_compressor_compress_finish; - - state->max_maxcode = 0x10000; /* Should NEVER generate this code. */ - state->in_count = 0; /* Length of input. */ - state->bit_buf = 0; - state->bit_offset = 0; - state->out_count = 3; /* Includes 3-byte header mojo. */ - state->compress_ratio = 0; - state->checkpoint = CHECK_GAP; - state->code_len = 9; - state->cur_maxcode = MAXCODE(state->code_len); - state->first_free = FIRST; - - memset(state->hashtab, 0xff, sizeof(state->hashtab)); - - /* Prime output buffer with a gzip header. */ - state->compressed[0] = 0x1f; /* Compress */ - state->compressed[1] = 0x9d; - state->compressed[2] = 0x90; /* Block mode, 16bit max */ - state->compressed_offset = 3; - - a->compressor.data = state; - return (0); -} - -/*- - * Output the given code. - * Inputs: - * code: A n_bits-bit integer. If == -1, then EOF. This assumes - * that n_bits =< (long)wordsize - 1. - * Outputs: - * Outputs code to the file. - * Assumptions: - * Chars are 8 bits long. - * Algorithm: - * Maintain a BITS character long buffer (so that 8 codes will - * fit in it exactly). Use the VAX insv instruction to insert each - * code in turn. When the buffer fills up empty it and start over. - */ - -static unsigned char rmask[9] = - {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; - -static int -output_byte(struct archive_write *a, unsigned char c) -{ - struct private_data *state = a->compressor.data; - ssize_t bytes_written; - - state->compressed[state->compressed_offset++] = c; - ++state->out_count; - - if (state->compressed_buffer_size == state->compressed_offset) { - bytes_written = (a->client_writer)(&a->archive, - a->client_data, - state->compressed, state->compressed_buffer_size); - if (bytes_written <= 0) - return ARCHIVE_FATAL; - a->archive.raw_position += bytes_written; - state->compressed_offset = 0; - } - - return ARCHIVE_OK; -} - -static int -output_code(struct archive_write *a, int ocode) -{ - struct private_data *state = a->compressor.data; - int bits, ret, clear_flg, bit_offset; - - clear_flg = ocode == CLEAR; - - /* - * Since ocode is always >= 8 bits, only need to mask the first - * hunk on the left. - */ - bit_offset = state->bit_offset % 8; - state->bit_buf |= (ocode << bit_offset) & 0xff; - output_byte(a, state->bit_buf); - - bits = state->code_len - (8 - bit_offset); - ocode >>= 8 - bit_offset; - /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ - if (bits >= 8) { - output_byte(a, ocode & 0xff); - ocode >>= 8; - bits -= 8; - } - /* Last bits. */ - state->bit_offset += state->code_len; - state->bit_buf = ocode & rmask[bits]; - if (state->bit_offset == state->code_len * 8) - state->bit_offset = 0; - - /* - * If the next entry is going to be too big for the ocode size, - * then increase it, if possible. - */ - if (clear_flg || state->first_free > state->cur_maxcode) { - /* - * Write the whole buffer, because the input side won't - * discover the size increase until after it has read it. - */ - if (state->bit_offset > 0) { - while (state->bit_offset < state->code_len * 8) { - ret = output_byte(a, state->bit_buf); - if (ret != ARCHIVE_OK) - return ret; - state->bit_offset += 8; - state->bit_buf = 0; - } - } - state->bit_buf = 0; - state->bit_offset = 0; - - if (clear_flg) { - state->code_len = 9; - state->cur_maxcode = MAXCODE(state->code_len); - } else { - state->code_len++; - if (state->code_len == 16) - state->cur_maxcode = state->max_maxcode; - else - state->cur_maxcode = MAXCODE(state->code_len); - } - } - - return (ARCHIVE_OK); -} - -static int -output_flush(struct archive_write *a) -{ - struct private_data *state = a->compressor.data; - int ret; - - /* At EOF, write the rest of the buffer. */ - if (state->bit_offset % 8) { - state->code_len = (state->bit_offset % 8 + 7) / 8; - ret = output_byte(a, state->bit_buf); - if (ret != ARCHIVE_OK) - return ret; - } - - return (ARCHIVE_OK); -} - -/* - * Write data to the compressed stream. - */ -static int -archive_compressor_compress_write(struct archive_write *a, const void *buff, - size_t length) -{ - struct private_data *state; - int i; - int ratio; - int c, disp, ret; - const unsigned char *bp; - - state = (struct private_data *)a->compressor.data; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - if (length == 0) - return ARCHIVE_OK; - - bp = buff; - - if (state->in_count == 0) { - state->cur_code = *bp++; - ++state->in_count; - --length; - } - - while (length--) { - c = *bp++; - state->in_count++; - state->cur_fcode = (c << 16) + state->cur_code; - i = ((c << HSHIFT) ^ state->cur_code); /* Xor hashing. */ - - if (state->hashtab[i] == state->cur_fcode) { - state->cur_code = state->codetab[i]; - continue; - } - if (state->hashtab[i] < 0) /* Empty slot. */ - goto nomatch; - /* Secondary hash (after G. Knott). */ - if (i == 0) - disp = 1; - else - disp = HSIZE - i; - probe: - if ((i -= disp) < 0) - i += HSIZE; - - if (state->hashtab[i] == state->cur_fcode) { - state->cur_code = state->codetab[i]; - continue; - } - if (state->hashtab[i] >= 0) - goto probe; - nomatch: - ret = output_code(a, state->cur_code); - if (ret != ARCHIVE_OK) - return ret; - state->cur_code = c; - if (state->first_free < state->max_maxcode) { - state->codetab[i] = state->first_free++; /* code -> hashtable */ - state->hashtab[i] = state->cur_fcode; - continue; - } - if (state->in_count < state->checkpoint) - continue; - - state->checkpoint = state->in_count + CHECK_GAP; - - if (state->in_count <= 0x007fffff) - ratio = state->in_count * 256 / state->out_count; - else if ((ratio = state->out_count / 256) == 0) - ratio = 0x7fffffff; - else - ratio = state->in_count / ratio; - - if (ratio > state->compress_ratio) - state->compress_ratio = ratio; - else { - state->compress_ratio = 0; - memset(state->hashtab, 0xff, sizeof(state->hashtab)); - state->first_free = FIRST; - ret = output_code(a, CLEAR); - if (ret != ARCHIVE_OK) - return ret; - } - } - - return (ARCHIVE_OK); -} - - -/* - * Finish the compression... - */ -static int -archive_compressor_compress_finish(struct archive_write *a) -{ - ssize_t block_length, target_block_length, bytes_written; - int ret; - struct private_data *state; - size_t tocopy; - - state = (struct private_data *)a->compressor.data; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - ret = ARCHIVE_FATAL; - goto cleanup; - } - - /* By default, always pad the uncompressed data. */ - if (a->pad_uncompressed) { - while (state->in_count % a->bytes_per_block != 0) { - tocopy = a->bytes_per_block - - (state->in_count % a->bytes_per_block); - if (tocopy > a->null_length) - tocopy = a->null_length; - ret = archive_compressor_compress_write(a, a->nulls, - tocopy); - if (ret != ARCHIVE_OK) - goto cleanup; - } - } - - ret = output_code(a, state->cur_code); - if (ret != ARCHIVE_OK) - goto cleanup; - ret = output_flush(a); - if (ret != ARCHIVE_OK) - goto cleanup; - - /* Optionally, pad the final compressed block. */ - block_length = state->compressed_offset; - - /* Tricky calculation to determine size of last block. */ - if (a->bytes_in_last_block <= 0) - /* Default or Zero: pad to full block */ - target_block_length = a->bytes_per_block; - else - /* Round length to next multiple of bytes_in_last_block. */ - target_block_length = a->bytes_in_last_block * - ( (block_length + a->bytes_in_last_block - 1) / - a->bytes_in_last_block); - if (target_block_length > a->bytes_per_block) - target_block_length = a->bytes_per_block; - if (block_length < target_block_length) { - memset(state->compressed + state->compressed_offset, 0, - target_block_length - block_length); - block_length = target_block_length; - } - - /* Write the last block */ - bytes_written = (a->client_writer)(&a->archive, a->client_data, - state->compressed, block_length); - if (bytes_written <= 0) - ret = ARCHIVE_FATAL; - else - a->archive.raw_position += bytes_written; - -cleanup: - free(state->compressed); - free(state); - return (ret); -} diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c deleted file mode 100644 index f0176e25f74..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c +++ /dev/null @@ -1,477 +0,0 @@ -/*- - * 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 "archive_platform.h" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_gzip.c 201081 2009-12-28 02:04:42Z kientzle $"); - -#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 <time.h> -#ifdef HAVE_ZLIB_H -#include <zlib.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_write_private.h" - -#ifndef HAVE_ZLIB_H -int -archive_write_set_compression_gzip(struct archive *a) -{ - archive_set_error(a, ARCHIVE_ERRNO_MISC, - "gzip compression not supported on this platform"); - return (ARCHIVE_FATAL); -} -#else -/* Don't compile this if we don't have zlib. */ - -struct private_data { - z_stream stream; - int64_t total_in; - unsigned char *compressed; - size_t compressed_buffer_size; - unsigned long crc; -}; - -struct private_config { - int compression_level; -}; - - -/* - * Yuck. zlib.h is not const-correct, so I need this one bit - * of ugly hackery to convert a const * pointer to a non-const pointer. - */ -#define SET_NEXT_IN(st,src) \ - (st)->stream.next_in = (Bytef *)(uintptr_t)(const void *)(src) - -static int archive_compressor_gzip_finish(struct archive_write *); -static int archive_compressor_gzip_init(struct archive_write *); -static int archive_compressor_gzip_options(struct archive_write *, - const char *, const char *); -static int archive_compressor_gzip_write(struct archive_write *, - const void *, size_t); -static int drive_compressor(struct archive_write *, struct private_data *, - int finishing); - - -/* - * Allocate, initialize and return a archive object. - */ -int -archive_write_set_compression_gzip(struct archive *_a) -{ - struct archive_write *a = (struct archive_write *)_a; - struct private_config *config; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW, "archive_write_set_compression_gzip"); - config = malloc(sizeof(*config)); - if (config == NULL) { - archive_set_error(&a->archive, ENOMEM, "Out of memory"); - return (ARCHIVE_FATAL); - } - a->compressor.config = config; - a->compressor.finish = &archive_compressor_gzip_finish; - config->compression_level = Z_DEFAULT_COMPRESSION; - a->compressor.init = &archive_compressor_gzip_init; - a->compressor.options = &archive_compressor_gzip_options; - a->archive.compression_code = ARCHIVE_COMPRESSION_GZIP; - a->archive.compression_name = "gzip"; - return (ARCHIVE_OK); -} - -/* - * Setup callback. - */ -static int -archive_compressor_gzip_init(struct archive_write *a) -{ - int ret; - struct private_data *state; - struct private_config *config; - time_t t; - - config = (struct private_config *)a->compressor.config; - - if (a->client_opener != NULL) { - ret = (a->client_opener)(&a->archive, a->client_data); - if (ret != ARCHIVE_OK) - return (ret); - } - - /* - * The next check is a temporary workaround until the gzip - * code can be overhauled some. The code should not require - * that compressed_buffer_size == bytes_per_block. Removing - * this assumption will allow us to compress larger chunks at - * a time, which should improve overall performance - * marginally. As a minor side-effect, such a cleanup would - * allow us to support truly arbitrary block sizes. - */ - if (a->bytes_per_block < 10) { - archive_set_error(&a->archive, EINVAL, - "GZip compressor requires a minimum 10 byte block size"); - return (ARCHIVE_FATAL); - } - - state = (struct private_data *)malloc(sizeof(*state)); - if (state == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression"); - return (ARCHIVE_FATAL); - } - memset(state, 0, sizeof(*state)); - - /* - * See comment above. We should set compressed_buffer_size to - * max(bytes_per_block, 65536), but the code can't handle that yet. - */ - state->compressed_buffer_size = a->bytes_per_block; - state->compressed = (unsigned char *)malloc(state->compressed_buffer_size); - state->crc = crc32(0L, NULL, 0); - - if (state->compressed == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression buffer"); - free(state); - return (ARCHIVE_FATAL); - } - - state->stream.next_out = state->compressed; - state->stream.avail_out = state->compressed_buffer_size; - - /* Prime output buffer with a gzip header. */ - t = time(NULL); - state->compressed[0] = 0x1f; /* GZip signature bytes */ - state->compressed[1] = 0x8b; - state->compressed[2] = 0x08; /* "Deflate" compression */ - state->compressed[3] = 0; /* No options */ - state->compressed[4] = (t)&0xff; /* Timestamp */ - state->compressed[5] = (t>>8)&0xff; - state->compressed[6] = (t>>16)&0xff; - state->compressed[7] = (t>>24)&0xff; - state->compressed[8] = 0; /* No deflate options */ - state->compressed[9] = 3; /* OS=Unix */ - state->stream.next_out += 10; - state->stream.avail_out -= 10; - - a->compressor.write = archive_compressor_gzip_write; - - /* Initialize compression library. */ - ret = deflateInit2(&(state->stream), - config->compression_level, - Z_DEFLATED, - -15 /* < 0 to suppress zlib header */, - 8, - Z_DEFAULT_STRATEGY); - - if (ret == Z_OK) { - a->compressor.data = state; - return (0); - } - - /* Library setup failed: clean up. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Internal error " - "initializing compression library"); - free(state->compressed); - free(state); - - /* Override the error message if we know what really went wrong. */ - switch (ret) { - case Z_STREAM_ERROR: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing " - "compression library: invalid setup parameter"); - break; - case Z_MEM_ERROR: - archive_set_error(&a->archive, ENOMEM, "Internal error initializing " - "compression library"); - break; - case Z_VERSION_ERROR: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing " - "compression library: invalid library version"); - break; - } - - return (ARCHIVE_FATAL); -} - -/* - * Set write options. - */ -static int -archive_compressor_gzip_options(struct archive_write *a, const char *key, - const char *value) -{ - struct private_config *config; - - config = (struct private_config *)a->compressor.config; - if (strcmp(key, "compression-level") == 0) { - if (value == NULL || !(value[0] >= '0' && value[0] <= '9') || - value[1] != '\0') - return (ARCHIVE_WARN); - config->compression_level = value[0] - '0'; - return (ARCHIVE_OK); - } - - return (ARCHIVE_WARN); -} - -/* - * Write data to the compressed stream. - */ -static int -archive_compressor_gzip_write(struct archive_write *a, const void *buff, - size_t length) -{ - struct private_data *state; - int ret; - - state = (struct private_data *)a->compressor.data; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - /* Update statistics */ - state->crc = crc32(state->crc, (const Bytef *)buff, length); - state->total_in += length; - - /* Compress input data to output buffer */ - SET_NEXT_IN(state, buff); - state->stream.avail_in = length; - if ((ret = drive_compressor(a, state, 0)) != ARCHIVE_OK) - return (ret); - - a->archive.file_position += length; - return (ARCHIVE_OK); -} - -/* - * Finish the compression... - */ -static int -archive_compressor_gzip_finish(struct archive_write *a) -{ - ssize_t block_length, target_block_length, bytes_written; - int ret; - struct private_data *state; - unsigned tocopy; - unsigned char trailer[8]; - - state = (struct private_data *)a->compressor.data; - ret = 0; - if (state != NULL) { - if (a->client_writer == NULL) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - ret = ARCHIVE_FATAL; - goto cleanup; - } - - /* By default, always pad the uncompressed data. */ - if (a->pad_uncompressed) { - tocopy = a->bytes_per_block - - (state->total_in % a->bytes_per_block); - while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) { - SET_NEXT_IN(state, a->nulls); - state->stream.avail_in = tocopy < a->null_length ? - tocopy : a->null_length; - state->crc = crc32(state->crc, a->nulls, - state->stream.avail_in); - state->total_in += state->stream.avail_in; - tocopy -= state->stream.avail_in; - ret = drive_compressor(a, state, 0); - if (ret != ARCHIVE_OK) - goto cleanup; - } - } - - /* Finish compression cycle */ - if (((ret = drive_compressor(a, state, 1))) != ARCHIVE_OK) - goto cleanup; - - /* Build trailer: 4-byte CRC and 4-byte length. */ - trailer[0] = (state->crc)&0xff; - trailer[1] = (state->crc >> 8)&0xff; - trailer[2] = (state->crc >> 16)&0xff; - trailer[3] = (state->crc >> 24)&0xff; - trailer[4] = (state->total_in)&0xff; - trailer[5] = (state->total_in >> 8)&0xff; - trailer[6] = (state->total_in >> 16)&0xff; - trailer[7] = (state->total_in >> 24)&0xff; - - /* Add trailer to current block. */ - tocopy = 8; - if (tocopy > state->stream.avail_out) - tocopy = state->stream.avail_out; - memcpy(state->stream.next_out, trailer, tocopy); - state->stream.next_out += tocopy; - state->stream.avail_out -= tocopy; - - /* If it overflowed, flush and start a new block. */ - if (tocopy < 8) { - bytes_written = (a->client_writer)(&a->archive, a->client_data, - state->compressed, state->compressed_buffer_size); - if (bytes_written <= 0) { - ret = ARCHIVE_FATAL; - goto cleanup; - } - a->archive.raw_position += bytes_written; - state->stream.next_out = state->compressed; - state->stream.avail_out = state->compressed_buffer_size; - memcpy(state->stream.next_out, trailer + tocopy, 8-tocopy); - state->stream.next_out += 8-tocopy; - state->stream.avail_out -= 8-tocopy; - } - - /* Optionally, pad the final compressed block. */ - block_length = state->stream.next_out - state->compressed; - - /* Tricky calculation to determine size of last block. */ - if (a->bytes_in_last_block <= 0) - /* Default or Zero: pad to full block */ - target_block_length = a->bytes_per_block; - else - /* Round length to next multiple of bytes_in_last_block. */ - target_block_length = a->bytes_in_last_block * - ( (block_length + a->bytes_in_last_block - 1) / - a->bytes_in_last_block); - if (target_block_length > a->bytes_per_block) - target_block_length = a->bytes_per_block; - if (block_length < target_block_length) { - memset(state->stream.next_out, 0, - target_block_length - block_length); - block_length = target_block_length; - } - - /* Write the last block */ - bytes_written = (a->client_writer)(&a->archive, a->client_data, - state->compressed, block_length); - if (bytes_written <= 0) { - ret = ARCHIVE_FATAL; - goto cleanup; - } - a->archive.raw_position += bytes_written; - - /* Cleanup: shut down compressor, release memory, etc. */ - cleanup: - switch (deflateEnd(&(state->stream))) { - case Z_OK: - break; - default: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Failed to clean up compressor"); - ret = ARCHIVE_FATAL; - } - free(state->compressed); - free(state); - } - /* Clean up config area even if we never initialized. */ - free(a->compressor.config); - a->compressor.config = NULL; - return (ret); -} - -/* - * Utility function to push input data through compressor, - * writing full output blocks as necessary. - * - * Note that this handles both the regular write case (finishing == - * false) and the end-of-archive case (finishing == true). - */ -static int -drive_compressor(struct archive_write *a, struct private_data *state, int finishing) -{ - ssize_t bytes_written; - int ret; - - for (;;) { - if (state->stream.avail_out == 0) { - bytes_written = (a->client_writer)(&a->archive, - a->client_data, state->compressed, - state->compressed_buffer_size); - if (bytes_written <= 0) { - /* TODO: Handle this write failure */ - return (ARCHIVE_FATAL); - } else if ((size_t)bytes_written < state->compressed_buffer_size) { - /* Short write: Move remaining to - * front of block and keep filling */ - memmove(state->compressed, - state->compressed + bytes_written, - state->compressed_buffer_size - bytes_written); - } - a->archive.raw_position += bytes_written; - state->stream.next_out - = state->compressed + - state->compressed_buffer_size - bytes_written; - state->stream.avail_out = bytes_written; - } - - /* If there's nothing to do, we're done. */ - if (!finishing && state->stream.avail_in == 0) - return (ARCHIVE_OK); - - ret = deflate(&(state->stream), - finishing ? Z_FINISH : Z_NO_FLUSH ); - - switch (ret) { - case Z_OK: - /* In non-finishing case, check if compressor - * consumed everything */ - if (!finishing && state->stream.avail_in == 0) - return (ARCHIVE_OK); - /* In finishing case, this return always means - * there's more work */ - break; - case Z_STREAM_END: - /* This return can only occur in finishing case. */ - return (ARCHIVE_OK); - default: - /* Any other return value indicates an error. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "GZip compression failed:" - " deflate() call returned status %d", - ret); - return (ARCHIVE_FATAL); - } - } -} - -#endif /* HAVE_ZLIB_H */ diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c deleted file mode 100644 index e0216d9e122..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * 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 "archive_platform.h" -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_none.c 201080 2009-12-28 02:03:54Z kientzle $"); - -#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 "archive.h" -#include "archive_private.h" -#include "archive_write_private.h" - -static int archive_compressor_none_finish(struct archive_write *a); -static int archive_compressor_none_init(struct archive_write *); -static int archive_compressor_none_write(struct archive_write *, - const void *, size_t); - -struct archive_none { - char *buffer; - ssize_t buffer_size; - char *next; /* Current insert location */ - ssize_t avail; /* Free space left in buffer */ -}; - -int -archive_write_set_compression_none(struct archive *_a) -{ - struct archive_write *a = (struct archive_write *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW, "archive_write_set_compression_none"); - a->compressor.init = &archive_compressor_none_init; - return (0); -} - -/* - * Setup callback. - */ -static int -archive_compressor_none_init(struct archive_write *a) -{ - int ret; - struct archive_none *state; - - a->archive.compression_code = ARCHIVE_COMPRESSION_NONE; - a->archive.compression_name = "none"; - - if (a->client_opener != NULL) { - ret = (a->client_opener)(&a->archive, a->client_data); - if (ret != 0) - return (ret); - } - - state = (struct archive_none *)malloc(sizeof(*state)); - if (state == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for output buffering"); - return (ARCHIVE_FATAL); - } - memset(state, 0, sizeof(*state)); - - state->buffer_size = a->bytes_per_block; - if (state->buffer_size != 0) { - state->buffer = (char *)malloc(state->buffer_size); - if (state->buffer == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate output buffer"); - free(state); - return (ARCHIVE_FATAL); - } - } - - state->next = state->buffer; - state->avail = state->buffer_size; - - a->compressor.data = state; - a->compressor.write = archive_compressor_none_write; - a->compressor.finish = archive_compressor_none_finish; - return (ARCHIVE_OK); -} - -/* - * Write data to the stream. - */ -static int -archive_compressor_none_write(struct archive_write *a, const void *vbuff, - size_t length) -{ - const char *buff; - ssize_t remaining, to_copy; - ssize_t bytes_written; - struct archive_none *state; - - state = (struct archive_none *)a->compressor.data; - buff = (const char *)vbuff; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - remaining = length; - - /* - * If there is no buffer for blocking, just pass the data - * straight through to the client write callback. In - * particular, this supports "no write delay" operation for - * special applications. Just set the block size to zero. - */ - if (state->buffer_size == 0) { - while (remaining > 0) { - bytes_written = (a->client_writer)(&a->archive, - a->client_data, buff, remaining); - if (bytes_written <= 0) - return (ARCHIVE_FATAL); - a->archive.raw_position += bytes_written; - remaining -= bytes_written; - buff += bytes_written; - } - a->archive.file_position += length; - return (ARCHIVE_OK); - } - - /* If the copy buffer isn't empty, try to fill it. */ - if (state->avail < state->buffer_size) { - /* If buffer is not empty... */ - /* ... copy data into buffer ... */ - to_copy = (remaining > state->avail) ? - state->avail : remaining; - memcpy(state->next, buff, to_copy); - state->next += to_copy; - state->avail -= to_copy; - buff += to_copy; - remaining -= to_copy; - /* ... if it's full, write it out. */ - if (state->avail == 0) { - bytes_written = (a->client_writer)(&a->archive, - a->client_data, state->buffer, state->buffer_size); - if (bytes_written <= 0) - return (ARCHIVE_FATAL); - /* XXX TODO: if bytes_written < state->buffer_size */ - a->archive.raw_position += bytes_written; - state->next = state->buffer; - state->avail = state->buffer_size; - } - } - - while (remaining > state->buffer_size) { - /* Write out full blocks directly to client. */ - bytes_written = (a->client_writer)(&a->archive, - a->client_data, buff, state->buffer_size); - if (bytes_written <= 0) - return (ARCHIVE_FATAL); - a->archive.raw_position += bytes_written; - buff += bytes_written; - remaining -= bytes_written; - } - - if (remaining > 0) { - /* Copy last bit into copy buffer. */ - memcpy(state->next, buff, remaining); - state->next += remaining; - state->avail -= remaining; - } - - a->archive.file_position += length; - return (ARCHIVE_OK); -} - - -/* - * Finish the compression. - */ -static int -archive_compressor_none_finish(struct archive_write *a) -{ - ssize_t block_length; - ssize_t target_block_length; - ssize_t bytes_written; - int ret; - struct archive_none *state; - - state = (struct archive_none *)a->compressor.data; - ret = ARCHIVE_OK; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - /* If there's pending data, pad and write the last block */ - if (state->next != state->buffer) { - block_length = state->buffer_size - state->avail; - - /* Tricky calculation to determine size of last block */ - if (a->bytes_in_last_block <= 0) - /* Default or Zero: pad to full block */ - target_block_length = a->bytes_per_block; - else - /* Round to next multiple of bytes_in_last_block. */ - target_block_length = a->bytes_in_last_block * - ( (block_length + a->bytes_in_last_block - 1) / - a->bytes_in_last_block); - if (target_block_length > a->bytes_per_block) - target_block_length = a->bytes_per_block; - if (block_length < target_block_length) { - memset(state->next, 0, - target_block_length - block_length); - block_length = target_block_length; - } - bytes_written = (a->client_writer)(&a->archive, - a->client_data, state->buffer, block_length); - if (bytes_written <= 0) - ret = ARCHIVE_FATAL; - else { - a->archive.raw_position += bytes_written; - ret = ARCHIVE_OK; - } - } - if (state->buffer) - free(state->buffer); - free(state); - a->compressor.data = NULL; - - return (ret); -} diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c deleted file mode 100644 index 475ba354032..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c +++ /dev/null @@ -1,347 +0,0 @@ -/*- - * Copyright (c) 2007 Joerg Sonnenberger - * 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" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_program.c 201104 2009-12-28 03:14:30Z kientzle $"); - -/* This capability is only available on POSIX systems. */ -#if (!defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \ - !(defined(HAVE_FORK) || defined(HAVE_VFORK))) && (!defined(_WIN32) || defined(__CYGWIN__)) -#include "archive.h" - -/* - * On non-Posix systems, allow the program to build, but choke if - * this function is actually invoked. - */ -int -archive_write_set_compression_program(struct archive *_a, const char *cmd) -{ - archive_set_error(_a, -1, - "External compression programs not supported on this platform"); - return (ARCHIVE_FATAL); -} - -#else - -#ifdef HAVE_SYS_WAIT_H -# include <sys/wait.h> -#endif -#ifdef HAVE_ERRNO_H -# include <errno.h> -#endif -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif -#ifdef HAVE_STDLIB_H -# include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -# include <string.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_write_private.h" - -#include "filter_fork.h" - -struct private_data { - char *description; - pid_t child; - int child_stdin, child_stdout; - - char *child_buf; - size_t child_buf_len, child_buf_avail; -}; - -static int archive_compressor_program_finish(struct archive_write *); -static int archive_compressor_program_init(struct archive_write *); -static int archive_compressor_program_write(struct archive_write *, - const void *, size_t); - -/* - * Allocate, initialize and return a archive object. - */ -int -archive_write_set_compression_program(struct archive *_a, const char *cmd) -{ - struct archive_write *a = (struct archive_write *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW, "archive_write_set_compression_program"); - a->compressor.init = &archive_compressor_program_init; - a->compressor.config = strdup(cmd); - return (ARCHIVE_OK); -} - -/* - * Setup callback. - */ -static int -archive_compressor_program_init(struct archive_write *a) -{ - int ret; - struct private_data *state; - static const char *prefix = "Program: "; - char *cmd = a->compressor.config; - - if (a->client_opener != NULL) { - ret = (a->client_opener)(&a->archive, a->client_data); - if (ret != ARCHIVE_OK) - return (ret); - } - - state = (struct private_data *)malloc(sizeof(*state)); - if (state == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression"); - return (ARCHIVE_FATAL); - } - memset(state, 0, sizeof(*state)); - - a->archive.compression_code = ARCHIVE_COMPRESSION_PROGRAM; - state->description = (char *)malloc(strlen(prefix) + strlen(cmd) + 1); - strcpy(state->description, prefix); - strcat(state->description, cmd); - a->archive.compression_name = state->description; - - state->child_buf_len = a->bytes_per_block; - state->child_buf_avail = 0; - state->child_buf = malloc(state->child_buf_len); - - if (state->child_buf == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression buffer"); - free(state); - return (ARCHIVE_FATAL); - } - - if ((state->child = __archive_create_child(cmd, - &state->child_stdin, &state->child_stdout)) == -1) { - archive_set_error(&a->archive, EINVAL, - "Can't initialise filter"); - free(state->child_buf); - free(state); - return (ARCHIVE_FATAL); - } - - a->compressor.write = archive_compressor_program_write; - a->compressor.finish = archive_compressor_program_finish; - - a->compressor.data = state; - return (0); -} - -static ssize_t -child_write(struct archive_write *a, const char *buf, size_t buf_len) -{ - struct private_data *state = a->compressor.data; - ssize_t ret; - - if (state->child_stdin == -1) - return (-1); - - if (buf_len == 0) - return (-1); - -restart_write: - do { - ret = write(state->child_stdin, buf, buf_len); - } while (ret == -1 && errno == EINTR); - - if (ret > 0) - return (ret); - if (ret == 0) { - close(state->child_stdin); - state->child_stdin = -1; - fcntl(state->child_stdout, F_SETFL, 0); - return (0); - } - if (ret == -1 && errno != EAGAIN) - return (-1); - - if (state->child_stdout == -1) { - fcntl(state->child_stdin, F_SETFL, 0); - __archive_check_child(state->child_stdin, state->child_stdout); - goto restart_write; - } - - do { - ret = read(state->child_stdout, - state->child_buf + state->child_buf_avail, - state->child_buf_len - state->child_buf_avail); - } while (ret == -1 && errno == EINTR); - - if (ret == 0 || (ret == -1 && errno == EPIPE)) { - close(state->child_stdout); - state->child_stdout = -1; - fcntl(state->child_stdin, F_SETFL, 0); - goto restart_write; - } - if (ret == -1 && errno == EAGAIN) { - __archive_check_child(state->child_stdin, state->child_stdout); - goto restart_write; - } - if (ret == -1) - return (-1); - - state->child_buf_avail += ret; - - ret = (a->client_writer)(&a->archive, a->client_data, - state->child_buf, state->child_buf_avail); - if (ret <= 0) - return (-1); - - if ((size_t)ret < state->child_buf_avail) { - memmove(state->child_buf, state->child_buf + ret, - state->child_buf_avail - ret); - } - state->child_buf_avail -= ret; - a->archive.raw_position += ret; - goto restart_write; -} - -/* - * Write data to the compressed stream. - */ -static int -archive_compressor_program_write(struct archive_write *a, const void *buff, - size_t length) -{ - ssize_t ret; - const char *buf; - - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - buf = buff; - while (length > 0) { - ret = child_write(a, buf, length); - if (ret == -1 || ret == 0) { - archive_set_error(&a->archive, EIO, - "Can't write to filter"); - return (ARCHIVE_FATAL); - } - length -= ret; - buf += ret; - } - - a->archive.file_position += length; - return (ARCHIVE_OK); -} - - -/* - * Finish the compression... - */ -static int -archive_compressor_program_finish(struct archive_write *a) -{ - int ret, status; - ssize_t bytes_read, bytes_written; - struct private_data *state; - - state = (struct private_data *)a->compressor.data; - ret = 0; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - ret = ARCHIVE_FATAL; - goto cleanup; - } - - /* XXX pad compressed data. */ - - close(state->child_stdin); - state->child_stdin = -1; - fcntl(state->child_stdout, F_SETFL, 0); - - for (;;) { - do { - bytes_read = read(state->child_stdout, - state->child_buf + state->child_buf_avail, - state->child_buf_len - state->child_buf_avail); - } while (bytes_read == -1 && errno == EINTR); - - if (bytes_read == 0 || (bytes_read == -1 && errno == EPIPE)) - break; - - if (bytes_read == -1) { - archive_set_error(&a->archive, errno, - "Read from filter failed unexpectedly."); - ret = ARCHIVE_FATAL; - goto cleanup; - } - state->child_buf_avail += bytes_read; - - bytes_written = (a->client_writer)(&a->archive, a->client_data, - state->child_buf, state->child_buf_avail); - if (bytes_written <= 0) { - ret = ARCHIVE_FATAL; - goto cleanup; - } - if ((size_t)bytes_written < state->child_buf_avail) { - memmove(state->child_buf, - state->child_buf + bytes_written, - state->child_buf_avail - bytes_written); - } - state->child_buf_avail -= bytes_written; - a->archive.raw_position += bytes_written; - } - - /* XXX pad final compressed block. */ - -cleanup: - /* Shut down the child. */ - if (state->child_stdin != -1) - close(state->child_stdin); - if (state->child_stdout != -1) - close(state->child_stdout); - while (waitpid(state->child, &status, 0) == -1 && errno == EINTR) - continue; - - if (status != 0) { - archive_set_error(&a->archive, EIO, - "Filter exited with failure."); - ret = ARCHIVE_FATAL; - } - - /* Release our configuration data. */ - free(a->compressor.config); - a->compressor.config = NULL; - - /* Release our private state data. */ - free(state->child_buf); - free(state->description); - free(state); - return (ret); -} - -#endif /* !defined(HAVE_PIPE) || !defined(HAVE_VFORK) || !defined(HAVE_FCNTL) */ diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c deleted file mode 100644 index f82f6db62e2..00000000000 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c +++ /dev/null @@ -1,438 +0,0 @@ -/*- - * Copyright (c) 2009 Michihiro NAKAJIMA - * 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 "archive_platform.h" - -__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_xz.c 201108 2009-12-28 03:28:21Z kientzle $"); - -#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 <time.h> -#ifdef HAVE_LZMA_H -#include <lzma.h> -#endif - -#include "archive.h" -#include "archive_private.h" -#include "archive_write_private.h" - -#ifndef HAVE_LZMA_H -int -archive_write_set_compression_xz(struct archive *a) -{ - archive_set_error(a, ARCHIVE_ERRNO_MISC, - "xz compression not supported on this platform"); - return (ARCHIVE_FATAL); -} - -int -archive_write_set_compression_lzma(struct archive *a) -{ - archive_set_error(a, ARCHIVE_ERRNO_MISC, - "lzma compression not supported on this platform"); - return (ARCHIVE_FATAL); -} -#else -/* Don't compile this if we don't have liblzma. */ - -struct private_data { - lzma_stream stream; - lzma_filter lzmafilters[2]; - lzma_options_lzma lzma_opt; - int64_t total_in; - unsigned char *compressed; - size_t compressed_buffer_size; -}; - -struct private_config { - int compression_level; -}; - -static int archive_compressor_xz_init(struct archive_write *); -static int archive_compressor_xz_options(struct archive_write *, - const char *, const char *); -static int archive_compressor_xz_finish(struct archive_write *); -static int archive_compressor_xz_write(struct archive_write *, - const void *, size_t); -static int drive_compressor(struct archive_write *, struct private_data *, - int finishing); - - -/* - * Allocate, initialize and return a archive object. - */ -int -archive_write_set_compression_xz(struct archive *_a) -{ - struct private_config *config; - struct archive_write *a = (struct archive_write *)_a; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW, "archive_write_set_compression_xz"); - config = calloc(1, sizeof(*config)); - if (config == NULL) { - archive_set_error(&a->archive, ENOMEM, "Out of memory"); - return (ARCHIVE_FATAL); - } - a->compressor.config = config; - a->compressor.finish = archive_compressor_xz_finish; - config->compression_level = LZMA_PRESET_DEFAULT; - a->compressor.init = &archive_compressor_xz_init; - a->compressor.options = &archive_compressor_xz_options; - a->archive.compression_code = ARCHIVE_COMPRESSION_XZ; - a->archive.compression_name = "xz"; - return (ARCHIVE_OK); -} - -/* LZMA is handled identically, we just need a different compression - * code set. (The liblzma setup looks at the code to determine - * the one place that XZ and LZMA require different handling.) */ -int -archive_write_set_compression_lzma(struct archive *_a) -{ - struct archive_write *a = (struct archive_write *)_a; - int r = archive_write_set_compression_xz(_a); - if (r != ARCHIVE_OK) - return (r); - a->archive.compression_code = ARCHIVE_COMPRESSION_LZMA; - a->archive.compression_name = "lzma"; - return (ARCHIVE_OK); -} - -static int -archive_compressor_xz_init_stream(struct archive_write *a, - struct private_data *state) -{ - int ret; - - state->stream = (lzma_stream)LZMA_STREAM_INIT; - state->stream.next_out = state->compressed; - state->stream.avail_out = state->compressed_buffer_size; - if (a->archive.compression_code == ARCHIVE_COMPRESSION_XZ) - ret = lzma_stream_encoder(&(state->stream), - state->lzmafilters, LZMA_CHECK_CRC64); - else - ret = lzma_alone_encoder(&(state->stream), &state->lzma_opt); - if (ret == LZMA_OK) - return (ARCHIVE_OK); - - switch (ret) { - case LZMA_MEM_ERROR: - archive_set_error(&a->archive, ENOMEM, - "Internal error initializing compression library: " - "Cannot allocate memory"); - break; - default: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library: " - "It's a bug in liblzma"); - break; - } - return (ARCHIVE_FATAL); -} - -/* - * Setup callback. - */ -static int -archive_compressor_xz_init(struct archive_write *a) -{ - int ret; - struct private_data *state; - struct private_config *config; - - if (a->client_opener != NULL) { - ret = (a->client_opener)(&a->archive, a->client_data); - if (ret != ARCHIVE_OK) - return (ret); - } - - state = (struct private_data *)malloc(sizeof(*state)); - if (state == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression"); - return (ARCHIVE_FATAL); - } - memset(state, 0, sizeof(*state)); - config = a->compressor.config; - - /* - * See comment above. We should set compressed_buffer_size to - * max(bytes_per_block, 65536), but the code can't handle that yet. - */ - state->compressed_buffer_size = a->bytes_per_block; - state->compressed = (unsigned char *)malloc(state->compressed_buffer_size); - if (state->compressed == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate data for compression buffer"); - free(state); - return (ARCHIVE_FATAL); - } - a->compressor.write = archive_compressor_xz_write; - - /* Initialize compression library. */ - if (lzma_lzma_preset(&state->lzma_opt, config->compression_level)) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Internal error initializing compression library"); - free(state->compressed); - free(state); - } - state->lzmafilters[0].id = LZMA_FILTER_LZMA2; - state->lzmafilters[0].options = &state->lzma_opt; - state->lzmafilters[1].id = LZMA_VLI_UNKNOWN;/* Terminate */ - ret = archive_compressor_xz_init_stream(a, state); - if (ret == LZMA_OK) { - a->compressor.data = state; - return (0); - } - /* Library setup failed: clean up. */ - free(state->compressed); - free(state); - - return (ARCHIVE_FATAL); -} - -/* - * Set write options. - */ -static int -archive_compressor_xz_options(struct archive_write *a, const char *key, - const char *value) -{ - struct private_config *config; - - config = (struct private_config *)a->compressor.config; - if (strcmp(key, "compression-level") == 0) { - if (value == NULL || !(value[0] >= '0' && value[0] <= '9') || - value[1] != '\0') - return (ARCHIVE_WARN); - config->compression_level = value[0] - '0'; - if (config->compression_level > 6) - config->compression_level = 6; - return (ARCHIVE_OK); - } - - return (ARCHIVE_WARN); -} - -/* - * Write data to the compressed stream. - */ -static int -archive_compressor_xz_write(struct archive_write *a, const void *buff, - size_t length) -{ - struct private_data *state; - int ret; - - state = (struct private_data *)a->compressor.data; - if (a->client_writer == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - return (ARCHIVE_FATAL); - } - - /* Update statistics */ - state->total_in += length; - - /* Compress input data to output buffer */ - state->stream.next_in = buff; - state->stream.avail_in = length; - if ((ret = drive_compressor(a, state, 0)) != ARCHIVE_OK) - return (ret); - - a->archive.file_position += length; - return (ARCHIVE_OK); -} - - -/* - * Finish the compression... - */ -static int -archive_compressor_xz_finish(struct archive_write *a) -{ - ssize_t block_length, target_block_length, bytes_written; - int ret; - struct private_data *state; - unsigned tocopy; - - ret = ARCHIVE_OK; - state = (struct private_data *)a->compressor.data; - if (state != NULL) { - if (a->client_writer == NULL) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_PROGRAMMER, - "No write callback is registered? " - "This is probably an internal programming error."); - ret = ARCHIVE_FATAL; - goto cleanup; - } - - /* By default, always pad the uncompressed data. */ - if (a->pad_uncompressed) { - tocopy = a->bytes_per_block - - (state->total_in % a->bytes_per_block); - while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) { - state->stream.next_in = a->nulls; - state->stream.avail_in = tocopy < a->null_length ? - tocopy : a->null_length; - state->total_in += state->stream.avail_in; - tocopy -= state->stream.avail_in; - ret = drive_compressor(a, state, 0); - if (ret != ARCHIVE_OK) - goto cleanup; - } - } - - /* Finish compression cycle */ - if (((ret = drive_compressor(a, state, 1))) != ARCHIVE_OK) - goto cleanup; - - /* Optionally, pad the final compressed block. */ - block_length = state->stream.next_out - state->compressed; - - /* Tricky calculation to determine size of last block. */ - if (a->bytes_in_last_block <= 0) - /* Default or Zero: pad to full block */ - target_block_length = a->bytes_per_block; - else - /* Round length to next multiple of bytes_in_last_block. */ - target_block_length = a->bytes_in_last_block * - ( (block_length + a->bytes_in_last_block - 1) / - a->bytes_in_last_block); - if (target_block_length > a->bytes_per_block) - target_block_length = a->bytes_per_block; - if (block_length < target_block_length) { - memset(state->stream.next_out, 0, - target_block_length - block_length); - block_length = target_block_length; - } - - /* Write the last block */ - bytes_written = (a->client_writer)(&a->archive, a->client_data, - state->compressed, block_length); - if (bytes_written <= 0) { - ret = ARCHIVE_FATAL; - goto cleanup; - } - a->archive.raw_position += bytes_written; - - /* Cleanup: shut down compressor, release memory, etc. */ - cleanup: - lzma_end(&(state->stream)); - free(state->compressed); - free(state); - } - free(a->compressor.config); - a->compressor.config = NULL; - return (ret); -} - -/* - * Utility function to push input data through compressor, - * writing full output blocks as necessary. - * - * Note that this handles both the regular write case (finishing == - * false) and the end-of-archive case (finishing == true). - */ -static int -drive_compressor(struct archive_write *a, struct private_data *state, int finishing) -{ - ssize_t bytes_written; - int ret; - - for (;;) { - if (state->stream.avail_out == 0) { - bytes_written = (a->client_writer)(&a->archive, - a->client_data, state->compressed, - state->compressed_buffer_size); - if (bytes_written <= 0) { - /* TODO: Handle this write failure */ - return (ARCHIVE_FATAL); - } else if ((size_t)bytes_written < state->compressed_buffer_size) { - /* Short write: Move remaining to - * front of block and keep filling */ - memmove(state->compressed, - state->compressed + bytes_written, - state->compressed_buffer_size - bytes_written); - } - a->archive.raw_position += bytes_written; - state->stream.next_out - = state->compressed + - state->compressed_buffer_size - bytes_written; - state->stream.avail_out = bytes_written; - } - - /* If there's nothing to do, we're done. */ - if (!finishing && state->stream.avail_in == 0) - return (ARCHIVE_OK); - - ret = lzma_code(&(state->stream), - finishing ? LZMA_FINISH : LZMA_RUN ); - - switch (ret) { - case LZMA_OK: - /* In non-finishing case, check if compressor - * consumed everything */ - if (!finishing && state->stream.avail_in == 0) - return (ARCHIVE_OK); - /* In finishing case, this return always means - * there's more work */ - break; - case LZMA_STREAM_END: - /* This return can only occur in finishing case. */ - if (finishing) - return (ARCHIVE_OK); - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "lzma compression data error"); - return (ARCHIVE_FATAL); - case LZMA_MEMLIMIT_ERROR: - archive_set_error(&a->archive, ENOMEM, - "lzma compression error: " - "%ju MiB would have been needed", - (lzma_memusage(&(state->stream)) + 1024 * 1024 -1) - / (1024 * 1024)); - return (ARCHIVE_FATAL); - default: - /* Any other return value indicates an error. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "lzma compression failed:" - " lzma_code() call returned status %d", - ret); - return (ARCHIVE_FATAL); - } - } -} - -#endif /* HAVE_LZMA_H */ diff --git a/archivers/libarchive/files/libarchive/filter_fork.c b/archivers/libarchive/files/libarchive/filter_fork.c deleted file mode 100644 index d160524b097..00000000000 --- a/archivers/libarchive/files/libarchive/filter_fork.c +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * Copyright (c) 2007 Joerg Sonnenberger - * 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" - -/* This capability is only available on POSIX systems. */ -#if defined(HAVE_PIPE) && defined(HAVE_FCNTL) && \ - (defined(HAVE_FORK) || defined(HAVE_VFORK)) - -__FBSDID("$FreeBSD: head/lib/libarchive/filter_fork.c 182958 2008-09-12 05:33:00Z kientzle $"); - -#if defined(HAVE_POLL) && (defined(HAVE_POLL_H) || defined(HAVE_SYS_POLL_H)) -# if defined(HAVE_POLL_H) -# include <poll.h> -# elif defined(HAVE_SYS_POLL_H) -# include <sys/poll.h> -# endif -#elif defined(HAVE_SELECT) -# if defined(HAVE_SYS_SELECT_H) -# include <sys/select.h> -# elif defined(HAVE_UNISTD_H) -# include <unistd.h> -# endif -#endif -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#include "filter_fork.h" - -pid_t -__archive_create_child(const char *path, int *child_stdin, int *child_stdout) -{ - pid_t child; - int stdin_pipe[2], stdout_pipe[2], tmp; - - if (pipe(stdin_pipe) == -1) - goto state_allocated; - if (stdin_pipe[0] == 1 /* stdout */) { - if ((tmp = dup(stdin_pipe[0])) == -1) - goto stdin_opened; - close(stdin_pipe[0]); - stdin_pipe[0] = tmp; - } - if (pipe(stdout_pipe) == -1) - goto stdin_opened; - if (stdout_pipe[1] == 0 /* stdin */) { - if ((tmp = dup(stdout_pipe[1])) == -1) - goto stdout_opened; - close(stdout_pipe[1]); - stdout_pipe[1] = tmp; - } - -#if HAVE_VFORK - switch ((child = vfork())) { -#else - switch ((child = fork())) { -#endif - case -1: - goto stdout_opened; - case 0: - close(stdin_pipe[1]); - close(stdout_pipe[0]); - if (dup2(stdin_pipe[0], 0 /* stdin */) == -1) - _exit(254); - if (stdin_pipe[0] != 0 /* stdin */) - close(stdin_pipe[0]); - if (dup2(stdout_pipe[1], 1 /* stdout */) == -1) - _exit(254); - if (stdout_pipe[1] != 1 /* stdout */) - close(stdout_pipe[1]); - execlp(path, path, (char *)NULL); - _exit(254); - default: - close(stdin_pipe[0]); - close(stdout_pipe[1]); - - *child_stdin = stdin_pipe[1]; - fcntl(*child_stdin, F_SETFL, O_NONBLOCK); - *child_stdout = stdout_pipe[0]; - fcntl(*child_stdout, F_SETFL, O_NONBLOCK); - } - - return child; - -stdout_opened: - close(stdout_pipe[0]); - close(stdout_pipe[1]); -stdin_opened: - close(stdin_pipe[0]); - close(stdin_pipe[1]); -state_allocated: - return -1; -} - -void -__archive_check_child(int in, int out) -{ -#if defined(HAVE_POLL) && (defined(HAVE_POLL_H) || defined(HAVE_SYS_POLL_H)) - struct pollfd fds[2]; - int idx; - - idx = 0; - if (in != -1) { - fds[idx].fd = in; - fds[idx].events = POLLOUT; - ++idx; - } - if (out != -1) { - fds[idx].fd = out; - fds[idx].events = POLLIN; - ++idx; - } - - poll(fds, idx, -1); /* -1 == INFTIM, wait forever */ -#elif defined(HAVE_SELECT) - fd_set fds_in, fds_out, fds_error; - - FD_ZERO(&fds_in); - FD_ZERO(&fds_out); - FD_ZERO(&fds_error); - if (out != -1) { - FD_SET(out, &fds_in); - FD_SET(out, &fds_error); - } - if (in != -1) { - FD_SET(in, &fds_out); - FD_SET(in, &fds_error); - } - select(in < out ? out + 1 : in + 1, &fds_in, &fds_out, &fds_error, NULL); -#else - sleep(1); -#endif -} - -#endif /* defined(HAVE_PIPE) && defined(HAVE_VFORK) && defined(HAVE_FCNTL) */ diff --git a/archivers/libarchive/files/libarchive/test/test_acl_basic.c b/archivers/libarchive/files/libarchive/test/test_acl_basic.c deleted file mode 100644 index f66014cdd31..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_acl_basic.c +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_basic.c,v 1.6 2008/10/19 00:13:57 kientzle Exp $"); - -/* - * Exercise the system-independent portion of the ACL support. - * Check that archive_entry objects can save and restore ACL data. - * - * This should work on all systems, regardless of whether local - * filesystems support ACLs or not. - */ - -struct acl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct acl_t acls0[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, - ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, -}; - -static struct acl_t acls1[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, -}; - -static struct acl_t acls2[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, - ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, - ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, -}; - -static void -set_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; i < n; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} - -static int -acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) -{ - if (type != acl->type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_OTHER) - return (1); - if (qual != acl->qual) - return (0); - if (name == NULL) { - if (acl->name == NULL || acl->name[0] == '\0') - return (1); - } - if (acl->name == NULL) { - if (name[0] == '\0') - return (1); - } - return (0 == strcmp(name, acl->name)); -} - -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, qual, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { - if (!matched) printf("No match for user_obj perm\n"); - failure("USER_OBJ permset (%02o) != user mode (%02o)", - permset, 07 & (mode >> 6)); - assert((permset << 6) == (mode & 0700)); - } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { - if (!matched) printf("No match for group_obj perm\n"); - failure("GROUP_OBJ permset %02o != group mode %02o", - permset, 07 & (mode >> 3)); - assert((permset << 3) == (mode & 0070)); - } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { - if (!matched) printf("No match for other perm\n"); - failure("OTHER permset (%02o) != other mode (%02o)", - permset, mode & 07); - assert((permset << 0) == (mode & 0007)); - } else { - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - type, permset, tag, qual, name); - assert(matched == 1); - } - } -#if ARCHIVE_VERSION_NUMBER < 1009000 - /* Known broken before 1.9.0. */ - skipping("archive_entry_acl_next() exits with ARCHIVE_EOF"); -#else - assertEqualInt(ARCHIVE_EOF, r); -#endif - assert((mode & 0777) == (archive_entry_mode(ae) & 0777)); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); - assert(n == 0); /* Number of ACLs not matched should == 0 */ - free(marker); -} - -DEFINE_TEST(test_acl_basic) -{ - struct archive_entry *ae; - - /* Create a simple archive_entry. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0777); - - /* Basic owner/owning group should just update mode bits. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); - failure("Basic ACLs shouldn't be stored as extended ACLs"); - assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - - /* With any extended ACL entry, we should read back a full set. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); - failure("One extended ACL should flag all ACLs to be returned."); - assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - - /* A more extensive set of ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); - assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); - failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0543); - - /* - * Check that clearing ACLs gets rid of them all by repeating - * the first test. - */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); - failure("Basic ACLs shouldn't be stored as extended ACLs"); - assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - archive_entry_free(ae); -} diff --git a/archivers/libarchive/files/libarchive/test/test_acl_freebsd.c b/archivers/libarchive/files/libarchive/test/test_acl_freebsd.c deleted file mode 100644 index be502067f5f..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_acl_freebsd.c +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * 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. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_freebsd.c 189427 2009-03-06 04:21:23Z kientzle $"); - -#if defined(__FreeBSD__) && __FreeBSD__ > 4 -#include <sys/acl.h> - -struct myacl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct myacl_t acls2[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, - ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, - ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_MASK, -1, "" }, - { 0, 0, 0, 0, NULL } -}; - -static void -set_acls(struct archive_entry *ae, struct myacl_t *acls) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; acls[i].name != NULL; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} - -static int -acl_match(acl_entry_t aclent, struct myacl_t *myacl) -{ - gid_t g, *gp; - uid_t u, *up; - acl_tag_t tag_type; - acl_permset_t opaque_ps; - int permset = 0; - - acl_get_tag_type(aclent, &tag_type); - - /* translate the silly opaque permset to a bitmap */ - acl_get_permset(aclent, &opaque_ps); - if (acl_get_perm_np(opaque_ps, ACL_EXECUTE)) - permset |= ARCHIVE_ENTRY_ACL_EXECUTE; - if (acl_get_perm_np(opaque_ps, ACL_WRITE)) - permset |= ARCHIVE_ENTRY_ACL_WRITE; - if (acl_get_perm_np(opaque_ps, ACL_READ)) - permset |= ARCHIVE_ENTRY_ACL_READ; - - if (permset != myacl->permset) - return (0); - - switch (tag_type) { - case ACL_USER_OBJ: - if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0); - break; - case ACL_USER: - if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) - return (0); - up = acl_get_qualifier(aclent); - u = *up; - acl_free(up); - if ((uid_t)myacl->qual != u) - return (0); - break; - case ACL_GROUP_OBJ: - if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0); - break; - case ACL_GROUP: - if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) - return (0); - gp = acl_get_qualifier(aclent); - g = *gp; - acl_free(gp); - if ((gid_t)myacl->qual != g) - return (0); - break; - case ACL_MASK: - if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0); - break; - case ACL_OTHER: - if (myacl->tag != ARCHIVE_ENTRY_ACL_OTHER) return (0); - break; - } - return (1); -} - -static void -compare_acls(acl_t acl, struct myacl_t *myacls) -{ - int *marker; - int entry_id = ACL_FIRST_ENTRY; - int matched; - int i, n; - acl_entry_t acl_entry; - - /* Count ACL entries in myacls array and allocate an indirect array. */ - for (n = 0; myacls[n].name != NULL; ++n) - continue; - marker = malloc(sizeof(marker[0]) * n); - for (i = 0; i < n; i++) - marker[i] = i; - - /* - * Iterate over acls in system acl object, try to match each - * one with an item in the myacls array. - */ - while (1 == acl_get_entry(acl, entry_id, &acl_entry)) { - /* After the first time... */ - entry_id = ACL_NEXT_ENTRY; - - /* Search for a matching entry (tag and qualifier) */ - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(acl_entry, &myacls[marker[i]])) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - - /* TODO: Print out more details in this case. */ - failure("ACL entry on file that shouldn't be there"); - assert(matched == 1); - } - - /* Dump entries in the myacls array that weren't in the system acl. */ - for (i = 0; i < n; ++i) { - failure(" ACL entry missing from file: " - "type=%d,permset=%d,tag=%d,qual=%d,name=``%s''\n", - myacls[marker[i]].type, myacls[marker[i]].permset, - myacls[marker[i]].tag, myacls[marker[i]].qual, - myacls[marker[i]].name); - assert(0); /* Record this as a failure. */ - } - free(marker); -} - -#endif - - -/* - * Verify ACL restore-to-disk. This test is FreeBSD-specific. - */ - -DEFINE_TEST(test_acl_freebsd) -{ -#if !defined(__FreeBSD__) - skipping("FreeBSD-specific ACL restore test"); -#elif __FreeBSD__ < 5 - skipping("ACL restore supported only on FreeBSD 5.0 and later"); -#else - struct stat st; - struct archive *a; - struct archive_entry *ae; - int n, fd; - acl_t acl; - - /* - * First, do a quick manual set/read of ACL data to - * verify that the local filesystem does support ACLs. - * If it doesn't, we'll simply skip the remaining tests. - */ - acl = acl_from_text("u::rwx,u:1:rw,g::rwx,g:15:rx,o::rwx,m::rwx"); - assert((void *)acl != NULL); - /* Create a test file and try to set an ACL on it. */ - fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777); - failure("Could not create test file?!"); - if (!assert(fd >= 0)) { - acl_free(acl); - return; - } - - n = acl_set_fd(fd, acl); - acl_free(acl); - if (n != 0 && errno == EOPNOTSUPP) { - close(fd); - skipping("ACL tests require that ACL support be enabled on the filesystem"); - return; - } - failure("acl_set_fd(): errno = %d (%s)", - errno, strerror(errno)); - assertEqualInt(0, n); - close(fd); - - /* Create a write-to-disk object. */ - assert(NULL != (a = archive_write_disk_new())); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL); - - /* Populate an archive entry with some metadata, including ACL info */ - ae = archive_entry_new(); - assert(ae != NULL); - archive_entry_set_pathname(ae, "test0"); - archive_entry_set_mtime(ae, 123456, 7890); - archive_entry_set_size(ae, 0); - set_acls(ae, acls2); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Close the archive. */ - assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - /* Verify the data on disk. */ - assertEqualInt(0, stat("test0", &st)); - assertEqualInt(st.st_mtime, 123456); - acl = acl_get_file("test0", ACL_TYPE_ACCESS); - assert(acl != (acl_t)NULL); - compare_acls(acl, acls2); - acl_free(acl); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_compress_program.c b/archivers/libarchive/files/libarchive/test/test_read_compress_program.c deleted file mode 100644 index 4e6c610de25..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_compress_program.c +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_compress_program.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static unsigned char archive[] = { -31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U', -0,210,134,230,166,6,200,'4',28,'(',24,26,24,27,155,24,152,24,154,27,155,')', -24,24,26,152,154,25,'2','(',152,210,193,'m',12,165,197,'%',137,'E','@',167, -148,'d',230,226,'U','G','H',30,234,15,'8','=',10,'F',193,'(',24,5,131,28, -0,0,29,172,5,240,0,6,0,0}; - -DEFINE_TEST(test_read_compress_program) -{ - int r; - struct archive_entry *ae; - struct archive *a; - - /* - * First, test handling when a non-existent compression - * program is requested. - */ - assert((a = archive_read_new()) != NULL); - r = archive_read_support_compression_program(a, "nonexistent"); - if (r == ARCHIVE_FATAL) { - skipping("archive_read_support_compression_program() " - "unsupported on this platform"); - return; - } - assertEqualIntA(a, ARCHIVE_OK, r); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_FATAL, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * If we have "gzip -d", try using that. - */ - if (!canGunzip()) { - skipping("Can't run gunzip program on this platform"); - return; - } - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_none(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_program(a, "gunzip")); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_PROGRAM); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c deleted file mode 100644 index 822b969e335..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_iso_gz.c 201247 2009-12-30 05:59:21Z kientzle $"); - -DEFINE_TEST(test_read_format_iso_gz) -{ - struct archive_entry *ae; - struct archive *a; - const char *name = "test_read_format_iso.iso.Z"; - - extract_reference_file(name); - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_filename(a, name, 512)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_COMPRESS); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_uu.c b/archivers/libarchive/files/libarchive/test/test_read_uu.c deleted file mode 100644 index a5de09af740..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_uu.c +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * Copyright (c) 2009 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: head/lib/libarchive/test/test_read_uu.c 201248 2009-12-30 06:12:03Z kientzle $"); - -static const char archive[] = { -"begin 644 test_read_uu.Z\n" -"M'YV0+@`('$BPH,&#\"!,J7,BP(4(8$&_4J`$\"`,08$F%4O)AQ(\\2/(#7&@#%C\n" -"M!@T8-##.L`$\"QL@:-F(``%'#H<V;.'/J!%!G#ITP<BS\"H).FS<Z$1(T>/1A2\n" -"IHU\"0%9=*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW9P$`\n" -"`\n" -"end\n" -}; - -static const char archive64[] = { -"begin-base64 644 test_read_uu.Z\n" -"H52QLgAIHEiwoMGDCBMqXMiwIUIYEG/UqAECAMQYEmFUvJhxI8SPIDXGgDFjBg0YNDDOsAECxsga\n" -"NmIAAFHDoc2bOHPqBFBnDp0wcizCoJOmzc6ERI0ePRhSo1CQFZdKnUq1qtWrWLNq3cq1q9evYMOK\n" -"HUu2rNmzaNOqXcu2rdu3ZwE=\n" -"====\n" -}; - -static const char extradata[] = { -"From uudecode@libarchive Mon Jun 2 03:03:31 2008\n" -"Return-Path: <uudecode@libarchive>\n" -"Received: from libarchive (localhost [127.0.0.1])\n" -" by libarchive (8.14.2/8.14.2) with ESMTP id m5233UT1006448\n" -" for <uudecode@libarchive>; Mon, 2 Jun 2008 03:03:31 GMT\n" -" (envelope-from uudecode@libarchive)\n" -"Received: (from uudecode@localhost)\n" -" by libarchive (8.14.2/8.14.2/Submit) id m5233U3e006406\n" -" for uudecode; Mon, 2 Jun 2008 03:03:30 GMT\n" -" (envelope-from root)\n" -"Date: Mon, 2 Jun 2008 03:03:30 GMT\n" -"From: Libarchive Test <uudecode@libarchive>\n" -"Message-Id: <200806020303.m5233U3e006406@libarchive>\n" -"To: uudecode@libarchive\n" -"Subject: Libarchive uudecode test\n" -"\n" -"* Redistribution and use in source and binary forms, with or without\n" -"* modification, are permitted provided that the following conditions\n" -"* are met:\n" -"\n" -"01234567890abcdeghijklmnopqrstuvwxyz\n" -"01234567890ABCEFGHIJKLMNOPQRSTUVWXYZ\n" -"\n" -}; - -static void -test_read_uu_sub(const char *uudata, size_t uusize) -{ - struct archive_entry *ae; - struct archive *a; - char *buff; - int extra; - - assert(NULL != (buff = malloc(uusize + 64 * 1024))); - if (buff == NULL) - return; - for (extra = 0; extra <= 64; extra = extra==0?1:extra*2) { - size_t size = extra * 1024; - char *p = buff; - - /* Add extra text size of which is from 1K bytes to - * 64Kbytes before uuencoded data. */ - while (size) { - if (size > sizeof(extradata)-1) { - memcpy(p, extradata, sizeof(extradata)-1); - p += sizeof(extradata)-1; - size -= sizeof(extradata)-1; - } else { - memcpy(p, extradata, size-1); - p += size-1; - *p++ = '\n';/* the last of extra text must have - * '\n' character. */ - break; - } - } - memcpy(p, uudata, uusize); - size = extra * 1024 + uusize; - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - read_open_memory(a, buff, size, 2)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae)); - failure("archive_compression_name(a)=\"%s\"", - archive_compression_name(a)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_COMPRESS); - failure("archive_format_name(a)=\"%s\"", - archive_format_name(a)); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - } - free(buff); -} - -DEFINE_TEST(test_read_uu) -{ - /* Read the traditional uuencoded data. */ - test_read_uu_sub(archive, sizeof(archive)-1); - /* Read the Base64 uuencoded data. */ - test_read_uu_sub(archive64, sizeof(archive64)-1); -} - diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress.c b/archivers/libarchive/files/libarchive/test/test_write_compress.c deleted file mode 100644 index aa590de8a91..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress.c +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * Copyright (c) 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 - * in this position and unchanged. - * 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: head/lib/libarchive/test/test_write_compress.c 189308 2009-03-03 17:02:51Z kientzle $"); - -/* - * A basic exercise of compress reading and writing. - * - * TODO: Add a reference file and make sure we can decompress that. - */ - -DEFINE_TEST(test_write_compress) -{ - struct archive_entry *ae; - struct archive* a; - char *buff, *data; - size_t buffsize, datasize; - char path[16]; - size_t used; - int i; - - buffsize = 1000000; - assert(NULL != (buff = (char *)malloc(buffsize))); - - datasize = 10000; - assert(NULL != (data = (char *)malloc(datasize))); - memset(data, 0, datasize); - - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertA(0 == archive_write_set_compression_compress(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used)); - - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize == (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - - - archive_write_close(a); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(0, archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - free(data); - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c b/archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c deleted file mode 100644 index ee6954022aa..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * Copyright (c) 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 - * in this position and unchanged. - * 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: head/lib/libarchive/test/test_write_compress_bzip2.c 191183 2009-04-17 01:06:31Z kientzle $"); - -/* - * A basic exercise of bzip2 reading and writing. - * - * TODO: Add a reference file and make sure we can decompress that. - */ - -DEFINE_TEST(test_write_compress_bzip2) -{ - struct archive_entry *ae; - struct archive* a; - char *buff, *data; - size_t buffsize, datasize; - char path[16]; - size_t used1, used2; - int i, r; - - buffsize = 2000000; - assert(NULL != (buff = (char *)malloc(buffsize))); - - datasize = 10000; - assert(NULL != (data = (char *)malloc(datasize))); - memset(data, 0, datasize); - - /* - * Write a 100 files and read them all back. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - r = archive_write_set_compression_bzip2(a); - if (r == ARCHIVE_FATAL) { - skipping("bzip2 writing not supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - return; - } - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertEqualInt(ARCHIVE_COMPRESSION_BZIP2, archive_compression(a)); - assertEqualString("bzip2", archive_compression_name(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1)); - assertEqualInt(ARCHIVE_COMPRESSION_BZIP2, archive_compression(a)); - assertEqualString("bzip2", archive_compression_name(a)); - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, datasize); - for (i = 0; i < 999; i++) { - sprintf(path, "file%03d", i); - archive_entry_copy_pathname(ae, path); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize - == (size_t)archive_write_data(a, data, datasize)); - } - archive_entry_free(ae); - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used1)); - for (i = 0; i < 999; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(0, archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assert(0 == archive_read_close(a)); - assert(0 == archive_read_finish(a)); - - /* - * Repeat the cycle again, this time setting some compression - * options. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_bzip2(a)); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "nonexistent-option=0")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=abc")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=99")); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=9")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 999; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize == (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Curiously, this test fails; the test data above compresses - * better at default compression than at level 9. */ - /* - failure("compression-level=9 wrote %d bytes, default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 < used1); - */ - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 999; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(0, archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assert(0 == archive_read_close(a)); - assert(0 == archive_read_finish(a)); - - /* - * Repeat again, with much lower compression. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_bzip2(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=1")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 999; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - failure("Writing file %s", path); - assertEqualIntA(a, datasize, - (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Level 0 really does result in larger data. */ - failure("Compression-level=0 wrote %d bytes; default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 > used1); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 999; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(0, archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assert(0 == archive_read_close(a)); - assert(0 == archive_read_finish(a)); - - /* - * Test various premature shutdown scenarios to make sure we - * don't crash or leak memory. - */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - /* - * Clean up. - */ - free(data); - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c b/archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c deleted file mode 100644 index ec55c8db646..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * Copyright (c) 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 - * in this position and unchanged. - * 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: head/lib/libarchive/test/test_write_compress_gzip.c 191183 2009-04-17 01:06:31Z kientzle $"); - -/* - * A basic exercise of gzip reading and writing. - * - * TODO: Add a reference file and make sure we can decompress that. - */ - -DEFINE_TEST(test_write_compress_gzip) -{ - struct archive_entry *ae; - struct archive* a; - char *buff, *data; - size_t buffsize, datasize; - char path[16]; - size_t used1, used2; - int i, r; - - buffsize = 2000000; - assert(NULL != (buff = (char *)malloc(buffsize))); - - datasize = 10000; - assert(NULL != (data = (char *)malloc(datasize))); - memset(data, 0, datasize); - - /* - * Write a 100 files and read them all back. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - r = archive_write_set_compression_gzip(a); - if (r == ARCHIVE_FATAL) { - skipping("gzip writing not supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - return; - } - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertEqualInt(ARCHIVE_COMPRESSION_GZIP, archive_compression(a)); - assertEqualString("gzip", archive_compression_name(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1)); - assertEqualInt(ARCHIVE_COMPRESSION_GZIP, archive_compression(a)); - assertEqualString("gzip", archive_compression_name(a)); - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, datasize); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - archive_entry_copy_pathname(ae, path); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize - == (size_t)archive_write_data(a, data, datasize)); - } - archive_entry_free(ae); - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("Can't verify gzip writing by reading back;" - " gzip reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used1)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Repeat the cycle again, this time setting some compression - * options. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_gzip(a)); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "nonexistent-option=0")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=abc")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=99")); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=9")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize == (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Curiously, this test fails; the test data above compresses - * better at default compression than at level 9. */ - /* - failure("compression-level=9 wrote %d bytes, default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 < used1); - */ - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("gzip reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Repeat again, with much lower compression. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_gzip(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=0")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - failure("Writing file %s", path); - assertEqualIntA(a, datasize, - (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Level 0 really does result in larger data. */ - failure("Compression-level=0 wrote %d bytes; default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 > used1); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("gzip reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Test various premature shutdown scenarios to make sure we - * don't crash or leak memory. - */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - /* - * Clean up. - */ - free(data); - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c b/archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c deleted file mode 100644 index 0b456910dae..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c +++ /dev/null @@ -1,245 +0,0 @@ -/*- - * Copyright (c) 2007-2009 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 - * in this position and unchanged. - * 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: head/lib/libarchive/test/test_write_compress_lzma.c 191183 2009-04-17 01:06:31Z kientzle $"); - -/* - * A basic exercise of lzma reading and writing. - * - */ - -DEFINE_TEST(test_write_compress_lzma) -{ - struct archive_entry *ae; - struct archive* a; - char *buff, *data; - size_t buffsize, datasize; - char path[16]; - size_t used1, used2; - int i, r; - - buffsize = 2000000; - assert(NULL != (buff = (char *)malloc(buffsize))); - - datasize = 10000; - assert(NULL != (data = (char *)malloc(datasize))); - memset(data, 0, datasize); - - /* - * Write a 100 files and read them all back. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - r = archive_write_set_compression_lzma(a); - if (r == ARCHIVE_FATAL) { - skipping("lzma writing not supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - return; - } - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertEqualInt(ARCHIVE_COMPRESSION_LZMA, archive_compression(a)); - assertEqualString("lzma", archive_compression_name(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1)); - assertEqualInt(ARCHIVE_COMPRESSION_LZMA, archive_compression(a)); - assertEqualString("lzma", archive_compression_name(a)); - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, datasize); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - archive_entry_copy_pathname(ae, path); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize - == (size_t)archive_write_data(a, data, datasize)); - } - archive_entry_free(ae); - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - r = archive_read_support_compression_lzma(a); - if (r == ARCHIVE_WARN) { - skipping("Can't verify lzma writing by reading back;" - " lzma reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used1)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Repeat the cycle again, this time setting some compression - * options. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_lzma(a)); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "nonexistent-option=0")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=abc")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=99")); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=9")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize == (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - r = archive_read_support_compression_lzma(a); - if (r == ARCHIVE_WARN) { - skipping("lzma reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - failure("Trying to read %s", path); - if (!assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Repeat again, with much lower compression. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_lzma(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=0")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - failure("Writing file %s", path); - assertEqualIntA(a, datasize, - (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Level 0 really does result in larger data. */ - failure("Compression-level=0 wrote %d bytes; default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 > used1); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - r = archive_read_support_compression_lzma(a); - if (r == ARCHIVE_WARN) { - skipping("lzma reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Test various premature shutdown scenarios to make sure we - * don't crash or leak memory. - */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - /* - * Clean up. - */ - free(data); - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_program.c b/archivers/libarchive/files/libarchive/test/test_write_compress_program.c deleted file mode 100644 index bae77e5341b..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress_program.c +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_compress_program.c 201247 2009-12-30 05:59:21Z kientzle $"); - -char buff[1000000]; -char buff2[64]; - -DEFINE_TEST(test_write_compress_program) -{ -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("archive_write_set_compress_program()"); -#else - struct archive_entry *ae; - struct archive *a; - size_t used; - int blocksize = 1024; - int r; - - if (!canGzip()) { - skipping("Cannot run 'gzip'"); - return; - } - - /* Create a new archive in memory. */ - /* Write it through an external "gzip" program. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - r = archive_write_set_compression_program(a, "gzip"); - if (r == ARCHIVE_FATAL) { - skipping("Write compression via external " - "program unsupported on this platform"); - archive_write_finish(a); - return; - } - assertA(0 == archive_write_set_bytes_per_block(a, blocksize)); - assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize)); - assertA(blocksize == archive_write_get_bytes_in_last_block(a)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - assertA(blocksize == archive_write_get_bytes_in_last_block(a)); - - /* - * Write a file to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 1, 10); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, 8); - - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA(8 == archive_write_data(a, "12345678", 9)); - - /* Close out the archive. */ - assertA(0 == archive_write_close(a)); - assertA(0 == archive_write_finish(a)); - - /* - * Now, read the data back through the built-in gzip support. - */ - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - /* The compression_gzip() handler will fall back to gunzip - * automatically, but if we know gunzip isn't available, then - * skip the rest. */ - if (r != ARCHIVE_OK && !canGunzip()) { - skipping("No libz and no gunzip program, " - "unable to verify gzip compression"); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - return; - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used)); - - if (!assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae))) { - archive_read_finish(a); - return; - } - - assertEqualInt(1, archive_entry_mtime(ae)); - assertEqualInt(0, archive_entry_atime(ae)); - assertEqualInt(0, archive_entry_ctime(ae)); - assertEqualString("file", archive_entry_pathname(ae)); - assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); - assertEqualInt(8, archive_entry_size(ae)); - assertEqualIntA(a, 8, archive_read_data(a, buff2, 10)); - assertEqualMem(buff2, "12345678", 8); - - /* Verify the end of the archive. */ - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_xz.c b/archivers/libarchive/files/libarchive/test/test_write_compress_xz.c deleted file mode 100644 index 88db2e66898..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress_xz.c +++ /dev/null @@ -1,253 +0,0 @@ -/*- - * Copyright (c) 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 - * in this position and unchanged. - * 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: head/lib/libarchive/test/test_write_compress_xz.c 191183 2009-04-17 01:06:31Z kientzle $"); - -/* - * A basic exercise of xz reading and writing. - * - * TODO: Add a reference file and make sure we can decompress that. - */ - -DEFINE_TEST(test_write_compress_xz) -{ - struct archive_entry *ae; - struct archive* a; - char *buff, *data; - size_t buffsize, datasize; - char path[16]; - size_t used1, used2; - int i, r; - - buffsize = 2000000; - assert(NULL != (buff = (char *)malloc(buffsize))); - - datasize = 10000; - assert(NULL != (data = (char *)malloc(datasize))); - memset(data, 0, datasize); - - /* - * Write a 100 files and read them all back. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - r = archive_write_set_compression_xz(a); - if (r == ARCHIVE_FATAL) { - skipping("xz writing not supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - return; - } - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertEqualInt(ARCHIVE_COMPRESSION_XZ, archive_compression(a)); - assertEqualString("xz", archive_compression_name(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1)); - assertEqualInt(ARCHIVE_COMPRESSION_XZ, archive_compression(a)); - assertEqualString("xz", archive_compression_name(a)); - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, datasize); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - archive_entry_copy_pathname(ae, path); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize - == (size_t)archive_write_data(a, data, datasize)); - } - archive_entry_free(ae); - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - r = archive_read_support_compression_xz(a); - if (r == ARCHIVE_WARN) { - skipping("Can't verify xz writing by reading back;" - " xz reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used1)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Repeat the cycle again, this time setting some compression - * options. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_xz(a)); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "nonexistent-option=0")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=abc")); - assertEqualIntA(a, ARCHIVE_WARN, - archive_write_set_compressor_options(a, "compression-level=99")); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=9")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize == (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Curiously, this test fails; the test data above compresses - * better at default compression than at level 9. */ - /* - failure("compression-level=9 wrote %d bytes, default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 < used1); - */ - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - r = archive_read_support_compression_xz(a); - if (r == ARCHIVE_WARN) { - skipping("xz reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - failure("Trying to read %s", path); - if (!assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Repeat again, with much lower compression. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_bytes_per_block(a, 10)); - assertA(0 == archive_write_set_compression_xz(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_set_compressor_options(a, "compression-level=0")); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - failure("Writing file %s", path); - assertEqualIntA(a, datasize, - (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - archive_write_close(a); - assert(0 == archive_write_finish(a)); - - /* Level 0 really does result in larger data. */ - failure("Compression-level=0 wrote %d bytes; default wrote %d bytes", - (int)used2, (int)used1); - assert(used2 > used1); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - r = archive_read_support_compression_xz(a); - if (r == ARCHIVE_WARN) { - skipping("xz reading not fully supported on this platform"); - } else { - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, buff, used2)); - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(ARCHIVE_OK, - archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - } - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * Test various premature shutdown scenarios to make sure we - * don't crash or leak memory. - */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2)); - assertEqualInt(ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_finish(a)); - - /* - * Clean up. - */ - free(data); - free(buff); -} diff --git a/archivers/libarchive/files/libarchive_fe/matching.c b/archivers/libarchive/files/libarchive_fe/matching.c deleted file mode 100644 index f774ac773ca..00000000000 --- a/archivers/libarchive/files/libarchive_fe/matching.c +++ /dev/null @@ -1,284 +0,0 @@ -/*- - * 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 "lafe_platform.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/matching.c,v 1.2 2008/06/21 02:20:20 kientzle Exp $"); - -#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 "err.h" -#include "line_reader.h" -#include "matching.h" -#include "pathmatch.h" - -struct match { - struct match *next; - int matches; - char pattern[1]; -}; - -struct lafe_matching { - struct match *exclusions; - int exclusions_count; - struct match *inclusions; - int inclusions_count; - int inclusions_unmatched_count; -}; - -static void add_pattern(struct match **list, const char *pattern); -static void initialize_matching(struct lafe_matching **); -static int match_exclusion(struct match *, const char *pathname); -static int match_inclusion(struct match *, const char *pathname); - -/* - * The matching logic here needs to be re-thought. I started out to - * try to mimic gtar's matching logic, but it's not entirely - * consistent. In particular 'tar -t' and 'tar -x' interpret patterns - * on the command line as anchored, but --exclude doesn't. - */ - -/* - * Utility functions to manage exclusion/inclusion patterns - */ - -int -lafe_exclude(struct lafe_matching **matching, const char *pattern) -{ - - if (*matching == NULL) - initialize_matching(matching); - add_pattern(&((*matching)->exclusions), pattern); - (*matching)->exclusions_count++; - return (0); -} - -int -lafe_exclude_from_file(struct lafe_matching **matching, const char *pathname) -{ - struct lafe_line_reader *lr; - const char *p; - int ret = 0; - - lr = lafe_line_reader(pathname, 0); - while ((p = lafe_line_reader_next(lr)) != NULL) { - if (lafe_exclude(matching, p) != 0) - ret = -1; - } - lafe_line_reader_free(lr); - return (ret); -} - -int -lafe_include(struct lafe_matching **matching, const char *pattern) -{ - - if (*matching == NULL) - initialize_matching(matching); - add_pattern(&((*matching)->inclusions), pattern); - (*matching)->inclusions_count++; - (*matching)->inclusions_unmatched_count++; - return (0); -} - -int -lafe_include_from_file(struct lafe_matching **matching, const char *pathname, - int nullSeparator) -{ - struct lafe_line_reader *lr; - const char *p; - int ret = 0; - - lr = lafe_line_reader(pathname, nullSeparator); - while ((p = lafe_line_reader_next(lr)) != NULL) { - if (lafe_include(matching, p) != 0) - ret = -1; - } - lafe_line_reader_free(lr); - return (ret); -} - -static void -add_pattern(struct match **list, const char *pattern) -{ - struct match *match; - size_t len; - - len = strlen(pattern); - match = malloc(sizeof(*match) + len + 1); - if (match == NULL) - lafe_errc(1, errno, "Out of memory"); - strcpy(match->pattern, pattern); - /* Both "foo/" and "foo" should match "foo/bar". */ - if (len && match->pattern[len - 1] == '/') - match->pattern[strlen(match->pattern)-1] = '\0'; - match->next = *list; - *list = match; - match->matches = 0; -} - - -int -lafe_excluded(struct lafe_matching *matching, const char *pathname) -{ - struct match *match; - struct match *matched; - - if (matching == NULL) - return (0); - - /* Exclusions take priority */ - for (match = matching->exclusions; match != NULL; match = match->next){ - if (match_exclusion(match, pathname)) - return (1); - } - - /* Then check for inclusions */ - matched = NULL; - for (match = matching->inclusions; match != NULL; match = match->next){ - if (match_inclusion(match, pathname)) { - /* - * If this pattern has never been matched, - * then we're done. - */ - if (match->matches == 0) { - match->matches++; - matching->inclusions_unmatched_count--; - return (0); - } - /* - * Otherwise, remember the match but keep checking - * in case we can tick off an unmatched pattern. - */ - matched = match; - } - } - /* - * We didn't find a pattern that had never been matched, but - * we did find a match, so count it and exit. - */ - if (matched != NULL) { - matched->matches++; - return (0); - } - - /* If there were inclusions, default is to exclude. */ - if (matching->inclusions != NULL) - return (1); - - /* No explicit inclusions, default is to match. */ - return (0); -} - -/* - * This is a little odd, but it matches the default behavior of - * gtar. In particular, 'a*b' will match 'foo/a1111/222b/bar' - * - */ -static int -match_exclusion(struct match *match, const char *pathname) -{ - return (lafe_pathmatch(match->pattern, - pathname, - PATHMATCH_NO_ANCHOR_START | PATHMATCH_NO_ANCHOR_END)); -} - -/* - * Again, mimic gtar: inclusions are always anchored (have to match - * the beginning of the path) even though exclusions are not anchored. - */ -static int -match_inclusion(struct match *match, const char *pathname) -{ -#if 0 - return (lafe_pathmatch(match->pattern, pathname, 0)); -#else - return (lafe_pathmatch(match->pattern, pathname, PATHMATCH_NO_ANCHOR_END)); -#endif -} - -void -lafe_cleanup_exclusions(struct lafe_matching **matching) -{ - struct match *p, *q; - - if (*matching == NULL) - return; - - for (p = (*matching)->inclusions; p != NULL; ) { - q = p; - p = p->next; - free(q); - } - - for (p = (*matching)->exclusions; p != NULL; ) { - q = p; - p = p->next; - free(q); - } - - free(*matching); - *matching = NULL; -} - -static void -initialize_matching(struct lafe_matching **matching) -{ - *matching = calloc(sizeof(**matching), 1); - if (*matching == NULL) - lafe_errc(1, errno, "No memory"); -} - -int -lafe_unmatched_inclusions(struct lafe_matching *matching) -{ - - if (matching == NULL) - return (0); - return (matching->inclusions_unmatched_count); -} - -int -lafe_unmatched_inclusions_warn(struct lafe_matching *matching, const char *msg) -{ - struct match *p; - - if (matching == NULL) - return (0); - - for (p = matching->inclusions; p != NULL; p = p->next) { - if (p->matches == 0) - lafe_warnc(0, "%s: %s", p->pattern, msg); - } - - return (matching->inclusions_unmatched_count); -} diff --git a/archivers/libarchive/files/libarchive_fe/matching.h b/archivers/libarchive/files/libarchive_fe/matching.h deleted file mode 100644 index f4edebd4399..00000000000 --- a/archivers/libarchive/files/libarchive_fe/matching.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * 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 - * in this position and unchanged. - * 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$ - */ - -#ifndef MATCHING_H -#define MATCHING_H - -struct lafe_matching; - -int lafe_exclude(struct lafe_matching **matching, const char *pattern); -int lafe_exclude_from_file(struct lafe_matching **matching, - const char *pathname); -int lafe_include(struct lafe_matching **matching, const char *pattern); -int lafe_include_from_file(struct lafe_matching **matching, - const char *pathname, int nullSeparator); - -int lafe_excluded(struct lafe_matching *, const char *pathname); -void lafe_cleanup_exclusions(struct lafe_matching **); -int lafe_unmatched_inclusions(struct lafe_matching *); -int lafe_unmatched_inclusions_warn(struct lafe_matching *, const char *msg); - -#endif diff --git a/archivers/libarchive/files/libarchive_fe/pathmatch.c b/archivers/libarchive/files/libarchive_fe/pathmatch.c deleted file mode 100644 index 85074bdb30b..00000000000 --- a/archivers/libarchive/files/libarchive_fe/pathmatch.c +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * 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 - * in this position and unchanged. - * 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 "lafe_platform.h" -__FBSDID("$FreeBSD$"); - -#ifdef HAVE_STRING_H -#include <string.h> -#endif - -#include "pathmatch.h" - -/* - * Check whether a character 'c' is matched by a list specification [...]: - * * Leading '!' negates the class. - * * <char>-<char> is a range of characters - * * \<char> removes any special meaning for <char> - * - * Some interesting boundary cases: - * a-d-e is one range (a-d) followed by two single characters - and e. - * \a-\d is same as a-d - * a\-d is three single characters: a, d, - - * Trailing - is not special (so [a-] is two characters a and -). - * Initial - is not special ([a-] is same as [-a] is same as [\\-a]) - * This function never sees a trailing \. - * [] always fails - * [!] always succeeds - */ -static int -pm_list(const char *start, const char *end, const char c, int flags) -{ - const char *p = start; - char rangeStart = '\0', nextRangeStart; - int match = 1, nomatch = 0; - - /* This will be used soon... */ - (void)flags; /* UNUSED */ - - /* If this is a negated class, return success for nomatch. */ - if (*p == '!' && p < end) { - match = 0; - nomatch = 1; - ++p; - } - - while (p < end) { - nextRangeStart = '\0'; - switch (*p) { - case '-': - /* Trailing or initial '-' is not special. */ - if ((rangeStart == '\0') || (p == end - 1)) { - if (*p == c) - return (match); - } else { - char rangeEnd = *++p; - if (rangeEnd == '\\') - rangeEnd = *++p; - if ((rangeStart <= c) && (c <= rangeEnd)) - return (match); - } - break; - case '\\': - ++p; - /* Fall through */ - default: - if (*p == c) - return (match); - nextRangeStart = *p; /* Possible start of range. */ - } - rangeStart = nextRangeStart; - ++p; - } - return (nomatch); -} - -/* - * If s is pointing to "./", ".//", "./././" or the like, skip it. - */ -static const char * -pm_slashskip(const char *s) { - while ((*s == '/') - || (s[0] == '.' && s[1] == '/') - || (s[0] == '.' && s[1] == '\0')) - ++s; - return (s); -} - -static int -pm(const char *p, const char *s, int flags) -{ - const char *end; - - /* - * Ignore leading './', './/', '././', etc. - */ - if (s[0] == '.' && s[1] == '/') - s = pm_slashskip(s + 1); - if (p[0] == '.' && p[1] == '/') - p = pm_slashskip(p + 1); - - for (;;) { - switch (*p) { - case '\0': - if (s[0] == '/') { - if (flags & PATHMATCH_NO_ANCHOR_END) - return (1); - /* "dir" == "dir/" == "dir/." */ - s = pm_slashskip(s); - } - return (*s == '\0'); - case '?': - /* ? always succeds, unless we hit end of 's' */ - if (*s == '\0') - return (0); - break; - case '*': - /* "*" == "**" == "***" ... */ - while (*p == '*') - ++p; - /* Trailing '*' always succeeds. */ - if (*p == '\0') - return (1); - while (*s) { - if (lafe_pathmatch(p, s, flags)) - return (1); - ++s; - } - return (0); - case '[': - /* - * Find the end of the [...] character class, - * ignoring \] that might occur within the class. - */ - end = p + 1; - while (*end != '\0' && *end != ']') { - if (*end == '\\' && end[1] != '\0') - ++end; - ++end; - } - if (*end == ']') { - /* We found [...], try to match it. */ - if (!pm_list(p + 1, end, *s, flags)) - return (0); - p = end; /* Jump to trailing ']' char. */ - break; - } else - /* No final ']', so just match '['. */ - if (*p != *s) - return (0); - break; - case '\\': - /* Trailing '\\' matches itself. */ - if (p[1] == '\0') { - if (*s != '\\') - return (0); - } else { - ++p; - if (*p != *s) - return (0); - } - break; - case '/': - if (*s != '/' && *s != '\0') - return (0); - /* Note: pattern "/\./" won't match "/"; - * pm_slashskip() correctly stops at backslash. */ - p = pm_slashskip(p); - s = pm_slashskip(s); - if (*p == '\0' && (flags & PATHMATCH_NO_ANCHOR_END)) - return (1); - --p; /* Counteract the increment below. */ - --s; - break; - case '$': - /* '$' is special only at end of pattern and only - * if PATHMATCH_NO_ANCHOR_END is specified. */ - if (p[1] == '\0' && (flags & PATHMATCH_NO_ANCHOR_END)){ - /* "dir" == "dir/" == "dir/." */ - return (*pm_slashskip(s) == '\0'); - } - /* Otherwise, '$' is not special. */ - /* FALL THROUGH */ - default: - if (*p != *s) - return (0); - break; - } - ++p; - ++s; - } -} - -/* Main entry point. */ -int -lafe_pathmatch(const char *p, const char *s, int flags) -{ - /* Empty pattern only matches the empty string. */ - if (p == NULL || *p == '\0') - return (s == NULL || *s == '\0'); - - /* Leading '^' anchors the start of the pattern. */ - if (*p == '^') { - ++p; - flags &= ~PATHMATCH_NO_ANCHOR_START; - } - - if (*p == '/' && *s != '/') - return (0); - - /* Certain patterns and file names anchor implicitly. */ - if (*p == '*' || *p == '/' || *p == '/') { - while (*p == '/') - ++p; - while (*s == '/') - ++s; - return (pm(p, s, flags)); - } - - /* If start is unanchored, try to match start of each path element. */ - if (flags & PATHMATCH_NO_ANCHOR_START) { - for ( ; s != NULL; s = strchr(s, '/')) { - if (*s == '/') - s++; - if (pm(p, s, flags)) - return (1); - } - return (0); - } - - /* Default: Match from beginning. */ - return (pm(p, s, flags)); -} diff --git a/archivers/libarchive/files/libarchive_fe/pathmatch.h b/archivers/libarchive/files/libarchive_fe/pathmatch.h deleted file mode 100644 index a92f3aef215..00000000000 --- a/archivers/libarchive/files/libarchive_fe/pathmatch.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * 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 - * in this position and unchanged. - * 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$ - */ - -#ifndef LAFE_PATHMATCH_H -#define LAFE_PATHMATCH_H - -/* Don't anchor at beginning unless the pattern starts with "^" */ -#define PATHMATCH_NO_ANCHOR_START 1 -/* Don't anchor at end unless the pattern ends with "$" */ -#define PATHMATCH_NO_ANCHOR_END 2 - -/* Note that "^" and "$" are not special unless you set the corresponding - * flag above. */ - -int lafe_pathmatch(const char *p, const char *s, int flags); - -#endif diff --git a/archivers/libarchive/files/tar/getdate.c b/archivers/libarchive/files/tar/getdate.c deleted file mode 100644 index ffaa679ba1a..00000000000 --- a/archivers/libarchive/files/tar/getdate.c +++ /dev/null @@ -1,1037 +0,0 @@ -/* - * This code is in the public domain and has no copyright. - * - * This is a plain C recursive-descent translation of an old - * public-domain YACC grammar that has been used for parsing dates in - * very many open-source projects. - * - * Since the original authors were generous enough to donate their - * work to the public domain, I feel compelled to match their - * generosity. - * - * Tim Kientzle, February 2009. - */ - -/* - * Header comment from original getdate.y: - */ - -/* -** Originally written by Steven M. Bellovin <smb@research.att.com> while -** at the University of North Carolina at Chapel Hill. Later tweaked by -** a couple of people on Usenet. Completely overhauled by Rich $alz -** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990; -** -** This grammar has 10 shift/reduce conflicts. -** -** This code is in the public domain and has no copyright. -*/ - -#ifdef __FreeBSD__ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); -#endif - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -/* This file defines a single public function. */ -time_t get_date(time_t now, char *); - -/* Basic time units. */ -#define EPOCH 1970 -#define MINUTE (60L) -#define HOUR (60L * MINUTE) -#define DAY (24L * HOUR) - -/* Daylight-savings mode: on, off, or not yet known. */ -enum DSTMODE { DSTon, DSToff, DSTmaybe }; -/* Meridian: am or pm. */ -enum { tAM, tPM }; -/* Token types returned by nexttoken() */ -enum { tAGO = 260, tDAY, tDAYZONE, tAMPM, tMONTH, tMONTH_UNIT, tSEC_UNIT, - tUNUMBER, tZONE, tDST }; -struct token { int token; time_t value; }; - -/* - * Parser state. - */ -struct gdstate { - struct token *tokenp; /* Pointer to next token. */ - /* HaveXxxx counts how many of this kind of phrase we've seen; - * it's a fatal error to have more than one time, zone, day, - * or date phrase. */ - int HaveYear; - int HaveMonth; - int HaveDay; - int HaveWeekDay; /* Day of week */ - int HaveTime; /* Hour/minute/second */ - int HaveZone; /* timezone and/or DST info */ - int HaveRel; /* time offset; we can have more than one */ - /* Absolute time values. */ - time_t Timezone; /* Seconds offset from GMT */ - time_t Day; - time_t Hour; - time_t Minutes; - time_t Month; - time_t Seconds; - time_t Year; - /* DST selection */ - enum DSTMODE DSTmode; - /* Day of week accounting, e.g., "3rd Tuesday" */ - time_t DayOrdinal; /* "3" in "3rd Tuesday" */ - time_t DayNumber; /* "Tuesday" in "3rd Tuesday" */ - /* Relative time values: hour/day/week offsets are measured in - * seconds, month/year are counted in months. */ - time_t RelMonth; - time_t RelSeconds; -}; - -/* - * A series of functions that recognize certain common time phrases. - * Each function returns 1 if it managed to make sense of some of the - * tokens, zero otherwise. - */ - -/* - * hour:minute or hour:minute:second with optional AM, PM, or numeric - * timezone offset - */ -static int -timephrase(struct gdstate *gds) -{ - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == ':' - && gds->tokenp[2].token == tUNUMBER - && gds->tokenp[3].token == ':' - && gds->tokenp[4].token == tUNUMBER) { - /* "12:14:18" or "22:08:07" */ - ++gds->HaveTime; - gds->Hour = gds->tokenp[0].value; - gds->Minutes = gds->tokenp[2].value; - gds->Seconds = gds->tokenp[4].value; - gds->tokenp += 5; - } - else if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == ':' - && gds->tokenp[2].token == tUNUMBER) { - /* "12:14" or "22:08" */ - ++gds->HaveTime; - gds->Hour = gds->tokenp[0].value; - gds->Minutes = gds->tokenp[2].value; - gds->Seconds = 0; - gds->tokenp += 3; - } - else if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == tAMPM) { - /* "7" is a time if it's followed by "am" or "pm" */ - ++gds->HaveTime; - gds->Hour = gds->tokenp[0].value; - gds->Minutes = gds->Seconds = 0; - /* We'll handle the AM/PM below. */ - gds->tokenp += 1; - } else { - /* We can't handle this. */ - return 0; - } - - if (gds->tokenp[0].token == tAMPM) { - /* "7:12pm", "12:20:13am" */ - if (gds->Hour == 12) - gds->Hour = 0; - if (gds->tokenp[0].value == tPM) - gds->Hour += 12; - gds->tokenp += 1; - } - if (gds->tokenp[0].token == '+' - && gds->tokenp[1].token == tUNUMBER) { - /* "7:14+0700" */ - gds->HaveZone++; - gds->DSTmode = DSToff; - gds->Timezone = - ((gds->tokenp[1].value / 100) * HOUR - + (gds->tokenp[1].value % 100) * MINUTE); - gds->tokenp += 2; - } - if (gds->tokenp[0].token == '-' - && gds->tokenp[1].token == tUNUMBER) { - /* "19:14:12-0530" */ - gds->HaveZone++; - gds->DSTmode = DSToff; - gds->Timezone = + ((gds->tokenp[1].value / 100) * HOUR - + (gds->tokenp[1].value % 100) * MINUTE); - gds->tokenp += 2; - } - return 1; -} - -/* - * Timezone name, possibly including DST. - */ -static int -zonephrase(struct gdstate *gds) -{ - if (gds->tokenp[0].token == tZONE - && gds->tokenp[1].token == tDST) { - gds->HaveZone++; - gds->Timezone = gds->tokenp[0].value; - gds->DSTmode = DSTon; - gds->tokenp += 1; - return 1; - } - - if (gds->tokenp[0].token == tZONE) { - gds->HaveZone++; - gds->Timezone = gds->tokenp[0].value; - gds->DSTmode = DSToff; - gds->tokenp += 1; - return 1; - } - - if (gds->tokenp[0].token == tDAYZONE) { - gds->HaveZone++; - gds->Timezone = gds->tokenp[0].value; - gds->DSTmode = DSTon; - gds->tokenp += 1; - return 1; - } - return 0; -} - -/* - * Year/month/day in various combinations. - */ -static int -datephrase(struct gdstate *gds) -{ - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == '/' - && gds->tokenp[2].token == tUNUMBER - && gds->tokenp[3].token == '/' - && gds->tokenp[4].token == tUNUMBER) { - gds->HaveYear++; - gds->HaveMonth++; - gds->HaveDay++; - if (gds->tokenp[0].value >= 13) { - /* First number is big: 2004/01/29, 99/02/17 */ - gds->Year = gds->tokenp[0].value; - gds->Month = gds->tokenp[2].value; - gds->Day = gds->tokenp[4].value; - } else if ((gds->tokenp[4].value >= 13) - || (gds->tokenp[2].value >= 13)) { - /* Last number is big: 01/07/98 */ - /* Middle number is big: 01/29/04 */ - gds->Month = gds->tokenp[0].value; - gds->Day = gds->tokenp[2].value; - gds->Year = gds->tokenp[4].value; - } else { - /* No significant clues: 02/03/04 */ - gds->Month = gds->tokenp[0].value; - gds->Day = gds->tokenp[2].value; - gds->Year = gds->tokenp[4].value; - } - gds->tokenp += 5; - return 1; - } - - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == '/' - && gds->tokenp[2].token == tUNUMBER) { - /* "1/15" */ - gds->HaveMonth++; - gds->HaveDay++; - gds->Month = gds->tokenp[0].value; - gds->Day = gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == '-' - && gds->tokenp[2].token == tUNUMBER - && gds->tokenp[3].token == '-' - && gds->tokenp[4].token == tUNUMBER) { - /* ISO 8601 format. yyyy-mm-dd. */ - gds->HaveYear++; - gds->HaveMonth++; - gds->HaveDay++; - gds->Year = gds->tokenp[0].value; - gds->Month = gds->tokenp[2].value; - gds->Day = gds->tokenp[4].value; - gds->tokenp += 5; - return 1; - } - - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == '-' - && gds->tokenp[2].token == tMONTH - && gds->tokenp[3].token == '-' - && gds->tokenp[4].token == tUNUMBER) { - gds->HaveYear++; - gds->HaveMonth++; - gds->HaveDay++; - if (gds->tokenp[0].value > 31) { - /* e.g. 1992-Jun-17 */ - gds->Year = gds->tokenp[0].value; - gds->Month = gds->tokenp[2].value; - gds->Day = gds->tokenp[4].value; - } else { - /* e.g. 17-JUN-1992. */ - gds->Day = gds->tokenp[0].value; - gds->Month = gds->tokenp[2].value; - gds->Year = gds->tokenp[4].value; - } - gds->tokenp += 5; - return 1; - } - - if (gds->tokenp[0].token == tMONTH - && gds->tokenp[1].token == tUNUMBER - && gds->tokenp[2].token == ',' - && gds->tokenp[3].token == tUNUMBER) { - /* "June 17, 2001" */ - gds->HaveYear++; - gds->HaveMonth++; - gds->HaveDay++; - gds->Month = gds->tokenp[0].value; - gds->Day = gds->tokenp[1].value; - gds->Year = gds->tokenp[3].value; - gds->tokenp += 4; - return 1; - } - - if (gds->tokenp[0].token == tMONTH - && gds->tokenp[1].token == tUNUMBER) { - /* "May 3" */ - gds->HaveMonth++; - gds->HaveDay++; - gds->Month = gds->tokenp[0].value; - gds->Day = gds->tokenp[1].value; - gds->tokenp += 2; - return 1; - } - - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == tMONTH - && gds->tokenp[2].token == tUNUMBER) { - /* "12 Sept 1997" */ - gds->HaveYear++; - gds->HaveMonth++; - gds->HaveDay++; - gds->Day = gds->tokenp[0].value; - gds->Month = gds->tokenp[1].value; - gds->Year = gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == tMONTH) { - /* "12 Sept" */ - gds->HaveMonth++; - gds->HaveDay++; - gds->Day = gds->tokenp[0].value; - gds->Month = gds->tokenp[1].value; - gds->tokenp += 2; - return 1; - } - - return 0; -} - -/* - * Relative time phrase: "tomorrow", "yesterday", "+1 hour", etc. - */ -static int -relunitphrase(struct gdstate *gds) -{ - if (gds->tokenp[0].token == '-' - && gds->tokenp[1].token == tUNUMBER - && gds->tokenp[2].token == tSEC_UNIT) { - /* "-3 hours" */ - gds->HaveRel++; - gds->RelSeconds -= gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - if (gds->tokenp[0].token == '+' - && gds->tokenp[1].token == tUNUMBER - && gds->tokenp[2].token == tSEC_UNIT) { - /* "+1 minute" */ - gds->HaveRel++; - gds->RelSeconds += gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == tSEC_UNIT) { - /* "1 day" */ - gds->HaveRel++; - gds->RelSeconds += gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - if (gds->tokenp[0].token == '-' - && gds->tokenp[1].token == tUNUMBER - && gds->tokenp[2].token == tMONTH_UNIT) { - /* "-3 months" */ - gds->HaveRel++; - gds->RelMonth -= gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - if (gds->tokenp[0].token == '+' - && gds->tokenp[1].token == tUNUMBER - && gds->tokenp[2].token == tMONTH_UNIT) { - /* "+5 years" */ - gds->HaveRel++; - gds->RelMonth += gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; - return 1; - } - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == tMONTH_UNIT) { - /* "2 years" */ - gds->HaveRel++; - gds->RelMonth += gds->tokenp[0].value * gds->tokenp[1].value; - gds->tokenp += 2; - return 1; - } - if (gds->tokenp[0].token == tSEC_UNIT) { - /* "now", "tomorrow" */ - gds->HaveRel++; - gds->RelSeconds += gds->tokenp[0].value; - ++gds->tokenp; - return 1; - } - if (gds->tokenp[0].token == tMONTH_UNIT) { - /* "month" */ - gds->HaveRel++; - gds->RelMonth += gds->tokenp[0].value; - gds->tokenp += 1; - return 1; - } - return 0; -} - -/* - * Day of the week specification. - */ -static int -dayphrase(struct gdstate *gds) -{ - if (gds->tokenp[0].token == tDAY) { - /* "tues", "wednesday," */ - gds->HaveWeekDay++; - gds->DayOrdinal = 1; - gds->DayNumber = gds->tokenp[0].value; - gds->tokenp += 1; - if (gds->tokenp[0].token == ',') - gds->tokenp += 1; - return 1; - } - if (gds->tokenp[0].token == tUNUMBER - && gds->tokenp[1].token == tDAY) { - /* "second tues" "3 wed" */ - gds->HaveWeekDay++; - gds->DayOrdinal = gds->tokenp[0].value; - gds->DayNumber = gds->tokenp[1].value; - gds->tokenp += 2; - return 1; - } - return 0; -} - -/* - * Try to match a phrase using one of the above functions. - * This layer also deals with a couple of generic issues. - */ -static int -phrase(struct gdstate *gds) -{ - if (timephrase(gds)) - return 1; - if (zonephrase(gds)) - return 1; - if (datephrase(gds)) - return 1; - if (dayphrase(gds)) - return 1; - if (relunitphrase(gds)) { - if (gds->tokenp[0].token == tAGO) { - gds->RelSeconds = -gds->RelSeconds; - gds->RelMonth = -gds->RelMonth; - gds->tokenp += 1; - } - return 1; - } - - /* Bare numbers sometimes have meaning. */ - if (gds->tokenp[0].token == tUNUMBER) { - if (gds->HaveTime && !gds->HaveYear && !gds->HaveRel) { - gds->HaveYear++; - gds->Year = gds->tokenp[0].value; - gds->tokenp += 1; - return 1; - } - - if(gds->tokenp[0].value > 10000) { - /* "20040301" */ - gds->HaveYear++; - gds->HaveMonth++; - gds->HaveDay++; - gds->Day= (gds->tokenp[0].value)%100; - gds->Month= (gds->tokenp[0].value/100)%100; - gds->Year = gds->tokenp[0].value/10000; - gds->tokenp += 1; - return 1; - } - - if (gds->tokenp[0].value < 24) { - gds->HaveTime++; - gds->Hour = gds->tokenp[0].value; - gds->Minutes = 0; - gds->Seconds = 0; - gds->tokenp += 1; - return 1; - } - - if ((gds->tokenp[0].value / 100 < 24) - && (gds->tokenp[0].value % 100 < 60)) { - /* "513" is same as "5:13" */ - gds->Hour = gds->tokenp[0].value / 100; - gds->Minutes = gds->tokenp[0].value % 100; - gds->Seconds = 0; - gds->tokenp += 1; - return 1; - } - } - - return 0; -} - -/* - * A dictionary of time words. - */ -static struct LEXICON { - size_t abbrev; - const char *name; - int type; - time_t value; -} const TimeWords[] = { - /* am/pm */ - { 0, "am", tAMPM, tAM }, - { 0, "pm", tAMPM, tPM }, - - /* Month names. */ - { 3, "january", tMONTH, 1 }, - { 3, "february", tMONTH, 2 }, - { 3, "march", tMONTH, 3 }, - { 3, "april", tMONTH, 4 }, - { 3, "may", tMONTH, 5 }, - { 3, "june", tMONTH, 6 }, - { 3, "july", tMONTH, 7 }, - { 3, "august", tMONTH, 8 }, - { 3, "september", tMONTH, 9 }, - { 3, "october", tMONTH, 10 }, - { 3, "november", tMONTH, 11 }, - { 3, "december", tMONTH, 12 }, - - /* Days of the week. */ - { 2, "sunday", tDAY, 0 }, - { 3, "monday", tDAY, 1 }, - { 2, "tuesday", tDAY, 2 }, - { 3, "wednesday", tDAY, 3 }, - { 2, "thursday", tDAY, 4 }, - { 2, "friday", tDAY, 5 }, - { 2, "saturday", tDAY, 6 }, - - /* Timezones: Offsets are in seconds. */ - { 0, "gmt", tZONE, 0*HOUR }, /* Greenwich Mean */ - { 0, "ut", tZONE, 0*HOUR }, /* Universal (Coordinated) */ - { 0, "utc", tZONE, 0*HOUR }, - { 0, "wet", tZONE, 0*HOUR }, /* Western European */ - { 0, "bst", tDAYZONE, 0*HOUR }, /* British Summer */ - { 0, "wat", tZONE, 1*HOUR }, /* West Africa */ - { 0, "at", tZONE, 2*HOUR }, /* Azores */ - /* { 0, "bst", tZONE, 3*HOUR }, */ /* Brazil Standard: Conflict */ - /* { 0, "gst", tZONE, 3*HOUR }, */ /* Greenland Standard: Conflict*/ - { 0, "nft", tZONE, 3*HOUR+30*MINUTE }, /* Newfoundland */ - { 0, "nst", tZONE, 3*HOUR+30*MINUTE }, /* Newfoundland Standard */ - { 0, "ndt", tDAYZONE, 3*HOUR+30*MINUTE }, /* Newfoundland Daylight */ - { 0, "ast", tZONE, 4*HOUR }, /* Atlantic Standard */ - { 0, "adt", tDAYZONE, 4*HOUR }, /* Atlantic Daylight */ - { 0, "est", tZONE, 5*HOUR }, /* Eastern Standard */ - { 0, "edt", tDAYZONE, 5*HOUR }, /* Eastern Daylight */ - { 0, "cst", tZONE, 6*HOUR }, /* Central Standard */ - { 0, "cdt", tDAYZONE, 6*HOUR }, /* Central Daylight */ - { 0, "mst", tZONE, 7*HOUR }, /* Mountain Standard */ - { 0, "mdt", tDAYZONE, 7*HOUR }, /* Mountain Daylight */ - { 0, "pst", tZONE, 8*HOUR }, /* Pacific Standard */ - { 0, "pdt", tDAYZONE, 8*HOUR }, /* Pacific Daylight */ - { 0, "yst", tZONE, 9*HOUR }, /* Yukon Standard */ - { 0, "ydt", tDAYZONE, 9*HOUR }, /* Yukon Daylight */ - { 0, "hst", tZONE, 10*HOUR }, /* Hawaii Standard */ - { 0, "hdt", tDAYZONE, 10*HOUR }, /* Hawaii Daylight */ - { 0, "cat", tZONE, 10*HOUR }, /* Central Alaska */ - { 0, "ahst", tZONE, 10*HOUR }, /* Alaska-Hawaii Standard */ - { 0, "nt", tZONE, 11*HOUR }, /* Nome */ - { 0, "idlw", tZONE, 12*HOUR }, /* Intl Date Line West */ - { 0, "cet", tZONE, -1*HOUR }, /* Central European */ - { 0, "met", tZONE, -1*HOUR }, /* Middle European */ - { 0, "mewt", tZONE, -1*HOUR }, /* Middle European Winter */ - { 0, "mest", tDAYZONE, -1*HOUR }, /* Middle European Summer */ - { 0, "swt", tZONE, -1*HOUR }, /* Swedish Winter */ - { 0, "sst", tDAYZONE, -1*HOUR }, /* Swedish Summer */ - { 0, "fwt", tZONE, -1*HOUR }, /* French Winter */ - { 0, "fst", tDAYZONE, -1*HOUR }, /* French Summer */ - { 0, "eet", tZONE, -2*HOUR }, /* Eastern Eur, USSR Zone 1 */ - { 0, "bt", tZONE, -3*HOUR }, /* Baghdad, USSR Zone 2 */ - { 0, "it", tZONE, -3*HOUR-30*MINUTE },/* Iran */ - { 0, "zp4", tZONE, -4*HOUR }, /* USSR Zone 3 */ - { 0, "zp5", tZONE, -5*HOUR }, /* USSR Zone 4 */ - { 0, "ist", tZONE, -5*HOUR-30*MINUTE },/* Indian Standard */ - { 0, "zp6", tZONE, -6*HOUR }, /* USSR Zone 5 */ - /* { 0, "nst", tZONE, -6.5*HOUR }, */ /* North Sumatra: Conflict */ - /* { 0, "sst", tZONE, -7*HOUR }, */ /* So Sumatra, USSR 6: Conflict */ - { 0, "wast", tZONE, -7*HOUR }, /* West Australian Standard */ - { 0, "wadt", tDAYZONE, -7*HOUR }, /* West Australian Daylight */ - { 0, "jt", tZONE, -7*HOUR-30*MINUTE },/* Java (3pm in Cronusland!)*/ - { 0, "cct", tZONE, -8*HOUR }, /* China Coast, USSR Zone 7 */ - { 0, "jst", tZONE, -9*HOUR }, /* Japan Std, USSR Zone 8 */ - { 0, "cast", tZONE, -9*HOUR-30*MINUTE },/* Ctrl Australian Std */ - { 0, "cadt", tDAYZONE, -9*HOUR-30*MINUTE },/* Ctrl Australian Daylt */ - { 0, "east", tZONE, -10*HOUR }, /* Eastern Australian Std */ - { 0, "eadt", tDAYZONE, -10*HOUR }, /* Eastern Australian Daylt */ - { 0, "gst", tZONE, -10*HOUR }, /* Guam Std, USSR Zone 9 */ - { 0, "nzt", tZONE, -12*HOUR }, /* New Zealand */ - { 0, "nzst", tZONE, -12*HOUR }, /* New Zealand Standard */ - { 0, "nzdt", tDAYZONE, -12*HOUR }, /* New Zealand Daylight */ - { 0, "idle", tZONE, -12*HOUR }, /* Intl Date Line East */ - - { 0, "dst", tDST, 0 }, - - /* Time units. */ - { 4, "years", tMONTH_UNIT, 12 }, - { 5, "months", tMONTH_UNIT, 1 }, - { 9, "fortnights", tSEC_UNIT, 14 * DAY }, - { 4, "weeks", tSEC_UNIT, 7 * DAY }, - { 3, "days", tSEC_UNIT, DAY }, - { 4, "hours", tSEC_UNIT, HOUR }, - { 3, "minutes", tSEC_UNIT, MINUTE }, - { 3, "seconds", tSEC_UNIT, 1 }, - - /* Relative-time words. */ - { 0, "tomorrow", tSEC_UNIT, DAY }, - { 0, "yesterday", tSEC_UNIT, -DAY }, - { 0, "today", tSEC_UNIT, 0 }, - { 0, "now", tSEC_UNIT, 0 }, - { 0, "last", tUNUMBER, -1 }, - { 0, "this", tSEC_UNIT, 0 }, - { 0, "next", tUNUMBER, 2 }, - { 0, "first", tUNUMBER, 1 }, - { 0, "1st", tUNUMBER, 1 }, -/* { 0, "second", tUNUMBER, 2 }, */ - { 0, "2nd", tUNUMBER, 2 }, - { 0, "third", tUNUMBER, 3 }, - { 0, "3rd", tUNUMBER, 3 }, - { 0, "fourth", tUNUMBER, 4 }, - { 0, "4th", tUNUMBER, 4 }, - { 0, "fifth", tUNUMBER, 5 }, - { 0, "5th", tUNUMBER, 5 }, - { 0, "sixth", tUNUMBER, 6 }, - { 0, "seventh", tUNUMBER, 7 }, - { 0, "eighth", tUNUMBER, 8 }, - { 0, "ninth", tUNUMBER, 9 }, - { 0, "tenth", tUNUMBER, 10 }, - { 0, "eleventh", tUNUMBER, 11 }, - { 0, "twelfth", tUNUMBER, 12 }, - { 0, "ago", tAGO, 1 }, - - /* Military timezones. */ - { 0, "a", tZONE, 1*HOUR }, - { 0, "b", tZONE, 2*HOUR }, - { 0, "c", tZONE, 3*HOUR }, - { 0, "d", tZONE, 4*HOUR }, - { 0, "e", tZONE, 5*HOUR }, - { 0, "f", tZONE, 6*HOUR }, - { 0, "g", tZONE, 7*HOUR }, - { 0, "h", tZONE, 8*HOUR }, - { 0, "i", tZONE, 9*HOUR }, - { 0, "k", tZONE, 10*HOUR }, - { 0, "l", tZONE, 11*HOUR }, - { 0, "m", tZONE, 12*HOUR }, - { 0, "n", tZONE, -1*HOUR }, - { 0, "o", tZONE, -2*HOUR }, - { 0, "p", tZONE, -3*HOUR }, - { 0, "q", tZONE, -4*HOUR }, - { 0, "r", tZONE, -5*HOUR }, - { 0, "s", tZONE, -6*HOUR }, - { 0, "t", tZONE, -7*HOUR }, - { 0, "u", tZONE, -8*HOUR }, - { 0, "v", tZONE, -9*HOUR }, - { 0, "w", tZONE, -10*HOUR }, - { 0, "x", tZONE, -11*HOUR }, - { 0, "y", tZONE, -12*HOUR }, - { 0, "z", tZONE, 0*HOUR }, - - /* End of table. */ - { 0, NULL, 0, 0 } -}; - -/* - * Year is either: - * = A number from 0 to 99, which means a year from 1970 to 2069, or - * = The actual year (>=100). - */ -static time_t -Convert(time_t Month, time_t Day, time_t Year, - time_t Hours, time_t Minutes, time_t Seconds, - time_t Timezone, enum DSTMODE DSTmode) -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t Julian; - int i; - - if (Year < 69) - Year += 2000; - else if (Year < 100) - Year += 1900; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - /* Checking for 2038 bogusly assumes that time_t is 32 bits. But - I'm too lazy to try to check for time_t overflow in another way. */ - if (Year < EPOCH || Year > 2038 - || Month < 1 || Month > 12 - /* Lint fluff: "conversion from long may lose accuracy" */ - || Day < 1 || Day > DaysInMonth[(int)--Month] - || Hours < 0 || Hours > 23 - || Minutes < 0 || Minutes > 59 - || Seconds < 0 || Seconds > 59) - return -1; - - Julian = Day - 1; - for (i = 0; i < Month; i++) - Julian += DaysInMonth[i]; - for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); - Julian *= DAY; - Julian += Timezone; - Julian += Hours * HOUR + Minutes * MINUTE + Seconds; - if (DSTmode == DSTon - || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) - Julian -= HOUR; - return Julian; -} - - -static time_t -DSTcorrect(time_t Start, time_t Future) -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * HOUR; -} - - -static time_t -RelativeDate(time_t Start, time_t zone, int dstmode, - time_t DayOrdinal, time_t DayNumber) -{ - struct tm *tm; - time_t t, now; - - t = Start - zone; - tm = gmtime(&t); - now = Start; - now += DAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * DAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - if (dstmode == DSTmaybe) - return DSTcorrect(Start, now); - return now - Start; -} - - -static time_t -RelativeMonth(time_t Start, time_t Timezone, time_t RelMonth) -{ - struct tm *tm; - time_t Month; - time_t Year; - - if (RelMonth == 0) - return 0; - tm = localtime(&Start); - Month = 12 * (tm->tm_year + 1900) + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - Timezone, DSTmaybe)); -} - -/* - * Tokenizer. - */ -static int -nexttoken(char **in, time_t *value) -{ - char c; - char buff[64]; - - for ( ; ; ) { - while (isspace((unsigned char)**in)) - ++*in; - - /* Skip parenthesized comments. */ - if (**in == '(') { - int Count = 0; - do { - c = *(*in)++; - if (c == '\0') - return c; - if (c == '(') - Count++; - else if (c == ')') - Count--; - } while (Count > 0); - continue; - } - - /* Try the next token in the word table first. */ - /* This allows us to match "2nd", for example. */ - { - char *src = *in; - const struct LEXICON *tp; - unsigned i = 0; - - /* Force to lowercase and strip '.' characters. */ - while (*src != '\0' - && (isalnum((unsigned char)*src) || *src == '.') - && i < sizeof(buff)-1) { - if (*src != '.') { - if (isupper((unsigned char)*src)) - buff[i++] = tolower((unsigned char)*src); - else - buff[i++] = *src; - } - src++; - } - buff[i] = '\0'; - - /* - * Find the first match. If the word can be - * abbreviated, make sure we match at least - * the minimum abbreviation. - */ - for (tp = TimeWords; tp->name; tp++) { - size_t abbrev = tp->abbrev; - if (abbrev == 0) - abbrev = strlen(tp->name); - if (strlen(buff) >= abbrev - && strncmp(tp->name, buff, strlen(buff)) - == 0) { - /* Skip over token. */ - *in = src; - /* Return the match. */ - *value = tp->value; - return tp->type; - } - } - } - - /* - * Not in the word table, maybe it's a number. Note: - * Because '-' and '+' have other special meanings, I - * don't deal with signed numbers here. - */ - if (isdigit((unsigned char)(c = **in))) { - for (*value = 0; isdigit((unsigned char)(c = *(*in)++)); ) - *value = 10 * *value + c - '0'; - (*in)--; - return (tUNUMBER); - } - - return *(*in)++; - } -} - -#define TM_YEAR_ORIGIN 1900 - -/* Yield A - B, measured in seconds. */ -static long -difftm (struct tm *a, struct tm *b) -{ - int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); - int by = b->tm_year + (TM_YEAR_ORIGIN - 1); - int days = ( - /* difference in day of year */ - a->tm_yday - b->tm_yday - /* + intervening leap days */ - + ((ay >> 2) - (by >> 2)) - - (ay/100 - by/100) - + ((ay/100 >> 2) - (by/100 >> 2)) - /* + difference in years * 365 */ - + (long)(ay-by) * 365 - ); - return (days * DAY + (a->tm_hour - b->tm_hour) * HOUR - + (a->tm_min - b->tm_min) * MINUTE - + (a->tm_sec - b->tm_sec)); -} - -/* - * - * The public function. - * - * TODO: tokens[] array should be dynamically sized. - */ -time_t -get_date(time_t now, char *p) -{ - struct token tokens[256]; - struct gdstate _gds; - struct token *lasttoken; - struct gdstate *gds; - struct tm local, *tm; - struct tm gmt, *gmt_ptr; - time_t Start; - time_t tod; - long tzone; - - /* Clear out the parsed token array. */ - memset(tokens, 0, sizeof(tokens)); - /* Initialize the parser state. */ - memset(&_gds, 0, sizeof(_gds)); - gds = &_gds; - - /* Look up the current time. */ - memset(&local, 0, sizeof(local)); - tm = localtime (&now); - if (tm == NULL) - return -1; - local = *tm; - - /* Look up UTC if we can and use that to determine the current - * timezone offset. */ - memset(&gmt, 0, sizeof(gmt)); - gmt_ptr = gmtime (&now); - if (gmt_ptr != NULL) { - /* Copy, in case localtime and gmtime use the same buffer. */ - gmt = *gmt_ptr; - } - if (gmt_ptr != NULL) - tzone = difftm (&gmt, &local); - else - /* This system doesn't understand timezones; fake it. */ - tzone = 0; - if(local.tm_isdst) - tzone += HOUR; - - /* Tokenize the input string. */ - lasttoken = tokens; - while ((lasttoken->token = nexttoken(&p, &lasttoken->value)) != 0) { - ++lasttoken; - if (lasttoken > tokens + 255) - return -1; - } - gds->tokenp = tokens; - - /* Match phrases until we run out of input tokens. */ - while (gds->tokenp < lasttoken) { - if (!phrase(gds)) - return -1; - } - - /* Use current local timezone if none was specified. */ - if (!gds->HaveZone) { - gds->Timezone = tzone; - gds->DSTmode = DSTmaybe; - } - - /* If a timezone was specified, use that for generating the default - * time components instead of the local timezone. */ - if (gds->HaveZone && gmt_ptr != NULL) { - now -= gds->Timezone; - gmt_ptr = gmtime (&now); - if (gmt_ptr != NULL) - local = *gmt_ptr; - now += gds->Timezone; - } - - if (!gds->HaveYear) - gds->Year = local.tm_year + 1900; - if (!gds->HaveMonth) - gds->Month = local.tm_mon + 1; - if (!gds->HaveDay) - gds->Day = local.tm_mday; - /* Note: No default for hour/min/sec; a specifier that just - * gives date always refers to 00:00 on that date. */ - - /* If we saw more than one time, timezone, weekday, year, month, - * or day, then give up. */ - if (gds->HaveTime > 1 || gds->HaveZone > 1 || gds->HaveWeekDay > 1 - || gds->HaveYear > 1 || gds->HaveMonth > 1 || gds->HaveDay > 1) - return -1; - - /* Compute an absolute time based on whatever absolute information - * we collected. */ - if (gds->HaveYear || gds->HaveMonth || gds->HaveDay - || gds->HaveTime || gds->HaveWeekDay) { - Start = Convert(gds->Month, gds->Day, gds->Year, - gds->Hour, gds->Minutes, gds->Seconds, - gds->Timezone, gds->DSTmode); - if (Start < 0) - return -1; - } else { - Start = now; - if (!gds->HaveRel) - Start -= local.tm_hour * HOUR + local.tm_min * MINUTE - + local.tm_sec; - } - - /* Add the relative offset. */ - Start += gds->RelSeconds; - Start += RelativeMonth(Start, gds->Timezone, gds->RelMonth); - - /* Adjust for day-of-week offsets. */ - if (gds->HaveWeekDay - && !(gds->HaveYear || gds->HaveMonth || gds->HaveDay)) { - tod = RelativeDate(Start, gds->Timezone, - gds->DSTmode, gds->DayOrdinal, gds->DayNumber); - Start += tod; - } - - /* -1 is an error indicator, so return 0 instead of -1 if - * that's the actual time. */ - return Start == -1 ? 0 : Start; -} - - -#if defined(TEST) - -/* ARGSUSED */ -int -main(int argc, char **argv) -{ - time_t d; - - while (*++argv != NULL) { - (void)printf("Input: %s\n", *argv); - d = get_date(*argv); - if (d == -1) - (void)printf("Bad format - couldn't convert.\n"); - else - (void)printf("Output: %s\n", ctime(&d)); - } - exit(0); - /* NOTREACHED */ -} -#endif /* defined(TEST) */ diff --git a/archivers/libarchive/files/tar/test/config.sh b/archivers/libarchive/files/tar/test/config.sh deleted file mode 100755 index 2d884f84096..00000000000 --- a/archivers/libarchive/files/tar/test/config.sh +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright (c) 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: src/usr.bin/tar/test/config.sh,v 1.2 2007/03/11 19:33:45 kientzle Exp $ - -THISDIR=`cd \`dirname $0\`;/bin/pwd` - -# TESTDIR defaults to /tmp/bsdtar- + the name of the script -if [ -z "$TESTDIR" ]; then - TESTDIR=/tmp/bsdtar-`echo $0 | sed -e 's|.*/||' -e 's|\.sh||' -e 's/[^a-z0-9_-]/_/g'` -fi - -# Find bsdtar -# The first three paths here are the usual locations of a bsdtar -# that has just been built. The remaining paths might find a bsdtar -# installed on the local system somewhere. -if [ -z "$BSDTAR" ]; then - for T in "$THISDIR/../bsdtar" "$THISDIR/../../bsdtar" \ - "/usr/obj`dirname $THISDIR`/bsdtar" "/usr/local/bin/bsdtar" \ - "/usr/bin/bsdtar" "/usr/bin/tar" "bsdtar" "tar" - do - if ( /bin/sh -c "$T --version" | grep "bsdtar" ) >/dev/null 2>&1; then - BSDTAR="$T" - break - fi - done -fi - -# Find GNU tar -if [ -z "$GTAR" ]; then - for T in gtar gnutar tar /usr/local/bin/gtar* /usr/local/bin/gnutar* /usr/bin/gtar* /usr/bin/gnutar* - do - if ( /bin/sh -c "$T --version" | grep "GNU tar" ) >/dev/null 2>&1; then - GTAR="$T" - break - fi - done -fi - -# Find CPIO -if [ -z "$CPIO" ]; then - CPIO=cpio -fi - -echo BSDTAR=$BSDTAR '('`$BSDTAR --version`')' -echo GTAR=$GTAR '('`$GTAR --version | head -n 1`')' -echo CPIO=$CPIO '('`$CPIO --version`')' - -# Remove and recreate the directory we'll use for these tests -rm -rf $TESTDIR -mkdir -p $TESTDIR || exit 1 -cd $TESTDIR || exit 1 -echo TESTDIR=$TESTDIR - diff --git a/archivers/libarchive/files/tar/test/test-acl.sh b/archivers/libarchive/files/tar/test/test-acl.sh deleted file mode 100755 index 818607dcd13..00000000000 --- a/archivers/libarchive/files/tar/test/test-acl.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-acl.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $ - -# Exercise copying of ACLs -echo "ACL handling" -# Basic test configuration -TESTDIR=/mnt/da0/acl-test -. `dirname $0`/config.sh - -# Create some files with ACLs -mkdir original -cd original -touch a -chmod 664 a -setfacl -m user:bin:rw- -m group:78:r-x a \ - || echo XXX failed to set access ACL on a XXX -mkdir d -chmod 775 d -setfacl -m user:daemon:rw- -m group:78:r-x d \ - || echo XXX failed to set access ACL on d XXX -setfacl -d -m user::rw- -m group::rw- -m other::rw- -m group:79:r-- d \ - || echo XXX failed to set default ACL on d XXX -cd .. - -# Copy the dir with -p -echo " -p preserves ACLs" -mkdir copy -(cd original && ${BSDTAR} -cf - .) | (cd copy; ${BSDTAR} -xpf -) - -# Verify the ACLs -cd copy -if [ "user::rw- user:bin:rw- group::rw- group:78:r-x mask::rwx other::r--" \ - = "`echo \`getfacl -q a\``" ]; then - # It matches!! -else - echo XXX a has wrong ACL XXX `getfacl -q a` -fi - -if [ "user::rwx user:daemon:rw- group::rwx group:78:r-x mask::rwx other::r-x" \ - = "`echo \`getfacl -q d\``" ]; then - # It matches!! -else - echo XXX d has wrong ACL XXX `getfacl -q d` -fi - - -if [ "user::rw- group::rw- group:79:r-- mask::rw- other::rw-" \ - = "`echo \`getfacl -q -d d\``" ]; then - # It matches!! -else - echo XXX d has wrong ACL XXX `getfacl -q -d d` -fi - diff --git a/archivers/libarchive/files/tar/test/test-basic.sh b/archivers/libarchive/files/tar/test/test-basic.sh deleted file mode 100755 index 0564bc7220b..00000000000 --- a/archivers/libarchive/files/tar/test/test-basic.sh +++ /dev/null @@ -1,432 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-basic.sh,v 1.5 2007/04/18 04:35:17 kientzle Exp $ - -# Generate a dir tree with various data and copy it using -# a variety of tools and flags. This mostly checks that -# we can read archives we write and those written by gtar -# and cpio. - -echo "Basic archiving/copy interoperability tests" -# Basic configuration -. `dirname $0`/config.sh - -# We need some files to archive; generate some random files and files -# with very long names and other special attributes -mkdir -p original -cd original -# Create some long files with random text data -for f in f0 f1 f2 f3 f4 f5 f6 f7 f8 f9; do - dd if=/dev/urandom bs=1k count=100 2>/dev/null | od > $f -done -# A sparse file -dd if=/dev/zero of=sparse bs=1 count=1 oseek=100000 2>/dev/null -# Files with long names -touch a -touch ab -touch abc -touch abcd -touch abcde -touch abcdef -touch abcdefg -touch abcdefgh -touch abcdefghi -touch abcdefghij -touch abcdefghijk -touch abcdefghijkl -touch abcdefghijklm -touch abcdefghijklmn -touch abcdefghijklmno -touch abcdefghijklmnop -touch abcdefghijklmnopq -touch abcdefghijklmnopqr -touch abcdefghijklmnopqrs -touch abcdefghijklmnopqrst -touch abcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy -touch abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz - -# A file with a long pathname -mkdir -p 1abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz -cd .. - -# Basic test of archiving/dearchiving -echo " bsdtar -c | bsdtar -x" -mkdir copy-default -(cd original && ${BSDTAR} -cf - .) | (cd copy-default; ${BSDTAR} -xf -) -(diff -r original copy-default || echo XXX FAILED XXX 1>&2) | head - -# Exercise gzip compression (test compressed output with gunzip -t -echo " bsdtar -cz | gunzip -t" -(cd original && ${BSDTAR} -czf - .) | gunzip -tq - -# Ensure our compression works with gunzip program -echo " bsdtar -cz | gunzip | bsdtar -x" -mkdir copy-gzip2 -(cd original && ${BSDTAR} -czf - .) | gunzip -q | (cd copy-gzip2; ${BSDTAR} -xf -) -(diff -r original copy-gzip2 || echo XXX FAILED XXX 1>&2) | head - -# Ensure our decompression works with gzip program -echo " bsdtar -c | gzip | bsdtar -x" -mkdir copy-gunzip -(cd original && ${BSDTAR} -cf - .) | gzip | (cd copy-gunzip; ${BSDTAR} -xf -) -(diff -r original copy-gunzip || echo XXX FAILED XXX 1>&2) | head - -# Ensure our gzip compression/decompression work with each other -echo " bsdtar -cz | bsdtar -x" -mkdir copy-gzip-gunzip -(cd original && ${BSDTAR} -czf - .) | (cd copy-gzip-gunzip; ${BSDTAR} -xf -) -(diff -r original copy-gzip-gunzip || echo XXX FAILED XXX 1>&2) | head - -# Ensure our decompression works with bzip2 program -echo " bsdtar -c | bzip2 | bsdtar -x" -mkdir copy-bunzip -(cd original && ${BSDTAR} -cf - .) | bzip2 | (cd copy-bunzip; ${BSDTAR} -xf -) -(diff -r original copy-bunzip || echo XXX FAILED XXX 1>&2) | head - -# Ensure our compression works with bunzip2 program -echo " bsdtar -cy | bunzip2 | bsdtar -x" -mkdir copy-bzip2 -(cd original && ${BSDTAR} -cyf - .) | bunzip2 -q | (cd copy-bzip2; ${BSDTAR} -xf -) -(diff -r original copy-bzip2 || echo XXX FAILED XXX 1>&2) | head - -# Ensure our bzip2 compression/decompression work with each other -echo " bsdtar -cy | bsdtar -x" -mkdir copy-bzip2-bunzip2 -(cd original && ${BSDTAR} -cyf - .) | (cd copy-bzip2-bunzip2; ${BSDTAR} -xf -) -(diff -r original copy-bzip2-bunzip2 || echo XXX FAILED XXX 1>&2) | head - -# Ensure that archive listing works -echo " bsdtar -c | bsdtar -t" -(cd original && find .) | sort > list-original -(cd original && ${BSDTAR} -cf - .) | ${BSDTAR} -tf - | sed 's|/$||' | sort > list-default -(diff list-original list-default || echo XXX FAILED XXX 1>&2) | head - -# Ensure that listing of deflated archives works -echo " bsdtar -cz | bsdtar -t" -(cd original && ${BSDTAR} -czf - .) | ${BSDTAR} -tf - | sed 's|/$||' | sort > list-gzip -(diff list-original list-gzip || echo XXX FAILED XXX 1>&2) | head - -# Ensure that listing of bzip2ed archives works -echo " bsdtar -cy | bsdtar -t" -(cd original && ${BSDTAR} -cyf - .) | ${BSDTAR} -tf - | sed 's|/$||' | sort > list-bzip2 -(diff list-original list-bzip2 || echo XXX FAILED XXX 1>&2) | head - -# Filtering exercises different areas of the library. -echo " Convert tar archive to a tar archive" -mkdir filter-tar-tar -(cd original && ${BSDTAR} -cf - .) | ${BSDTAR} -cf - @- | (cd filter-tar-tar; ${BSDTAR} -xf -) -(diff -r original filter-tar-tar || echo XXX FAILED XXX 1>&2) | head - -# Make sure that reading and writing a tar archive doesn't change it. -echo " bsdtar -cf- @- | cmp" -(cd original && ${BSDTAR} -cf - .) > original.tar -${BSDTAR} -cf - @- < original.tar | cmp - original.tar || echo XXX FAILED XXX - -# Filtering as format conversion -echo " Convert tar archive to cpio archive" -mkdir filter-tar-cpio -(cd original && ${BSDTAR} -cf - .) | ${BSDTAR} -cf - --format=cpio @- | (cd filter-tar-cpio; ${BSDTAR} -xf -) -(diff -r original filter-tar-cpio || echo XXX FAILED XXX 1>&2) | head - -# Test basic --include selection logic -echo " Convert tar to cpio with selection" -mkdir filter-tar-selected -(cd original && ${BSDTAR} -cf - .) | ${BSDTAR} -cf - --format=cpio --include=./f3 @- | (cd filter-tar-selected; ${BSDTAR} -xf -) -(diff -r original/f3 filter-tar-selected/f3 || echo XXX FAILED XXX 1>&2) | head -# Should be no files in copy except for 'f3' -(cd filter-tar-selected ; ls | grep -v f3 | grep .) && echo XXX FAILED XXX - -# Test --include with wildcards -echo " Convert tar to cpio selecting with wildcards" -mkdir filter-tar-selected2 -(cd original && ${BSDTAR} -cf - .) | ${BSDTAR} -cf - --format=cpio --include='./f*' @- | (cd filter-tar-selected2; ${BSDTAR} -xf -) -for f in f1 f2 f3 f4 f5 f6 f7 f8 f9; do - (diff -r original/$f filter-tar-selected2/$f || echo XXX FAILED XXX 1>&2) | head -done -# Should be no files in copy except for 'f[0-9]' -(cd filter-tar-selected2 ; ls | grep -v 'f[0-9]' | grep .) && echo XXX FAILED XXX - -# Check read/write of basic odc cpio format -echo " bsdtar -c --format=cpio | bsdtar -x" -mkdir copy-cpio -(cd original && ${BSDTAR} -cf - --format cpio .) | (cd copy-cpio; ${BSDTAR} -xf -) -(diff -r original copy-cpio || echo XXX FAILED XXX 1>&2) | head - -# Ensure we can read gtar archives -echo " gtar -c | bsdtar -x" -mkdir copy-gtar -(cd original && ${GTAR} -cf - .) | (cd copy-gtar; ${BSDTAR} -xf -) -(diff -r original copy-gtar || echo XXX FAILED XXX 1>&2) | head - -# Ensure we can read svr4crc cpio archives -echo " cpio -H crc | bsdtar -x" -mkdir copy-svr4crc -(cd original && find . | ${CPIO} -o -H crc 2>/dev/null) | (cd copy-svr4crc; ${BSDTAR} -xf -) -(diff -r original copy-svr4crc || echo XXX FAILED XXX 1>&2) | head - -# Ensure we generate proper shar output -echo " bsdtar -c --format=shar | /bin/sh" -mkdir copy-shar -(cd original && ${BSDTAR} -cf - --format=shar --exclude=sparse .) | (cd copy-shar; /bin/sh >/dev/null) -(diff -r --exclude=sparse original copy-shar || echo XXX FAILED XXX 1>&2) | head - -# Check that -u (update) picks up no new files -echo " bsdtar -u doesn't pick up unchanged files" -(cd original && ${BSDTAR} -cf ../test-u.tar -b 1 .) -cp test-u.tar test-u1.tar -(cd original && ${BSDTAR} -uf ../test-u1.tar .) -(diff test-u.tar test-u1.tar || echo XXX FAILED XXX 1>&2) | head - -# Check that -u (update) does pick up actual changed files -echo " bsdtar -u does pick up changed files" -(cd original && echo hello >>f0) -cp test-u.tar test-u2.tar -(cd original && ${BSDTAR} -uf ../test-u2.tar .) -# All this really tests is that the archive did change. -cmp -s test-u.tar test-u2.tar && echo XXX FAILED XXX -# Now, unpack the archive and verify the contents (including the change to f0) -mkdir copy-u-test2 -(cd copy-u-test2 && ${BSDTAR} -xf ../test-u2.tar) -(diff -r original copy-u-test2 || echo XXX FAILED XXX 1>&2) | head diff --git a/archivers/libarchive/files/tar/test/test-deep-dir.sh b/archivers/libarchive/files/tar/test/test-deep-dir.sh deleted file mode 100755 index 22cf1c8f826..00000000000 --- a/archivers/libarchive/files/tar/test/test-deep-dir.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-deep-dir.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $ - -# Stress the deep directory logic; the actual depth here seems to -# be limited by the shell. This should be restructured to get around -# that limit (possibly by using perl to build the deep tree?) -echo Deep directory tests - -# Basic test configuration -. `dirname $0`/config.sh - -# Create a deep dir (shell seems to be limited by PATH_MAX) -mkdir original -cd original -I=0 -while [ $I -lt 200 ] -do - mkdir a$I - cd a$I - I=$(($I + 1)) -done -while [ $I -gt 0 ] ; do cd ..; I=$(($I - 1)); done -cd .. - -# Copy this using bsdtar -echo " tar -c | tar -x" -mkdir copy -(cd original; ${BSDTAR} -cf - .) | (cd copy; ${BSDTAR} -xf -) -diff -r original copy || echo XXX FAILURE XXX - -# Copy gtar->bsdtar -echo " gtar -c | tar -x" -mkdir copy-gtar -(cd original; ${GTAR} -cf - .) | (cd copy-gtar; ${BSDTAR} -xf -) -diff -r original copy-gtar || echo XXX FAILURE XXX -cd .. - diff --git a/archivers/libarchive/files/tar/test/test-flags.sh b/archivers/libarchive/files/tar/test/test-flags.sh deleted file mode 100755 index bfbf542163c..00000000000 --- a/archivers/libarchive/files/tar/test/test-flags.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-flags.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $ - -# Exercise copying of file flags -echo "File Flag handling" -# Basic test configuration -. `dirname $0`/config.sh - -# Create some files with various flags set -mkdir original -FLAGS='uchg opaque nodump uappnd' -for f in $FLAGS; do - touch original/test.$f - chflags $f original/test.$f -done -#ls -ol ${TESTDIR}/original - -# Copy the dir with -p -echo " -p preserves flags" -mkdir copy -(cd original && ${BSDTAR} -cf - .) | (cd copy; ${BSDTAR} -xpf -) -# Verify that the flags are set -for f in $FLAGS; do - [ "$f" = `ls -ol copy/test.$f | awk '{print $5}'` ] \ - || echo XXX FAIL: $f not preserved with -p XXX -done -#ls -ol ${TESTDIR}/copy - -# Copy the dir without -p -echo " flags omitted without -p" -mkdir copy2 -(cd original && ${BSDTAR} -cf - .) | (cd copy2; ${BSDTAR} -xf -) -# Verify that the flags are not set -for f in $FLAGS; do - [ "$f" = `ls -ol copy2/test.$f | awk '{print $5}'` ] \ - && echo XXX FAIL: $f copied without -p XXX -done -#ls -ol ${TESTDIR}/copy2 - -# Strip off the flags so we can clean this directory on the next test -for f in $FLAGS; do - if [ $f = 'nodump' ]; then - chflags dump original/test.$f - chflags dump copy/test.$f - else - chflags no$f original/test.$f - chflags no$f copy/test.$f - fi -done -cd .. - diff --git a/archivers/libarchive/files/tar/test/test-nodump.sh b/archivers/libarchive/files/tar/test/test-nodump.sh deleted file mode 100755 index 1d21b49032d..00000000000 --- a/archivers/libarchive/files/tar/test/test-nodump.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-nodump.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $ - -# Test that archiving obeys the 'nodump' flag -echo "Verify 'nodump'" -# Basic test configuration -. `dirname $0`/config.sh - -# Create some sample files, 'b' is marked nodump -mkdir original -cd original -touch a -touch b -touch c -# 'chflags' on FreeBSD, 'chattr' on Linux -( chflags nodump b || chattr +d b ) >/dev/null 2>&1 || echo XXX NO chflags/chattr command XXX - -# Copy files with --nodump -cd .. -mkdir copy -(cd original && ${BSDTAR} -cf - --nodump .) | (cd copy; ${BSDTAR} -xf -) - -# Verify that 'b' wasn't copied -echo " File marked nodump wasn't copied" -if [ -e copy/b ] ; then echo XXX Copied nodump file XXX; fi -echo " File not marked nodump was copied" -if [ \! -e copy/a ] ; then echo XXX Failed to copy non-nodump file a XXX; fi -diff -r --exclude=b original copy || echo XXX FAILURE XXX -cd .. diff --git a/archivers/libarchive/files/tar/test/test-overwrite.sh b/archivers/libarchive/files/tar/test/test-overwrite.sh deleted file mode 100755 index b9208905b57..00000000000 --- a/archivers/libarchive/files/tar/test/test-overwrite.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-overwrite.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $ - -echo "Test overwrite avoidance" -. `dirname $0`/config.sh - -# Create a file with some data. -# This ensures that test.tar actually has some data in it -# by the time tar tries to add it to itself. -dd if=/dev/urandom of=a bs=1k count=100 >/dev/null 2>&1 - -# Now try to implicitly add archive to itself -${BSDTAR} -cf test.tar . || echo XXX FAILED XXX - -# Create another file -dd if=/dev/urandom of=b bs=1k count=100 >/dev/null 2>&1 - -# Try again. -${BSDTAR} -cf test.tar . || echo XXX FAILED XXX - -# Extract the archive and check that the two files got archived, despite the warning -mkdir compare -cd compare -${BSDTAR} -xf ../test.tar -cmp a ../a || echo XXX a didn't archive correctly XXX -cmp b ../b || echo XXX b didn't archive correctly XXX - -# TODO: Test overwrite avoidance on extract diff --git a/archivers/libarchive/files/tar/test/test-utf8.sh b/archivers/libarchive/files/tar/test/test-utf8.sh deleted file mode 100755 index c1b18a69048..00000000000 --- a/archivers/libarchive/files/tar/test/test-utf8.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Copyright (c) 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: src/usr.bin/tar/test/test-utf8.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $ - -echo "Test UTF8 filenames" -. `dirname $0`/config.sh - -# Create some files with names in UTF8 -export LC_ALL=en_US.UTF-8 -touch "Greek: Γειά σας" -touch "Hebrew: שלום" -touch "Russian: Здравствуйте!" -touch "Japanese: �����, コンニチハ" -touch "Chinese: ��" - -tar -cf test.tar . - -# TODO: Verify the resulting archive
\ No newline at end of file diff --git a/archivers/libarchive/files/tar/test/test_getdate.c b/archivers/libarchive/files/tar/test/test_getdate.c deleted file mode 100644 index eac571049fe..00000000000 --- a/archivers/libarchive/files/tar/test/test_getdate.c +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * 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" -__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_getdate.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $"); - -#include <time.h> - -/* - * Verify that the getdate() function works. - */ - -time_t get_date(time_t, const char *); - -DEFINE_TEST(test_getdate) -{ - time_t now = time(NULL); - - assertEqualInt(get_date(now, "Jan 1, 1970 UTC"), 0); - assertEqualInt(get_date(now, "7:12:18-0530 4 May 1983"), 420900138); - assertEqualInt(get_date(now, "2004/01/29 513 mest"), 1075345980); - assertEqualInt(get_date(now, "99/02/17 7pm utc"), 919278000); - assertEqualInt(get_date(now, "02/17/99 7:11am est"), 919253460); - /* It's important that we handle ctime() format. */ - assertEqualInt(get_date(now, "Sun Feb 22 17:38:26 PST 2009"), - 1235353106); - /* Basic relative offsets. */ - /* If we use the actual current time as the reference, then - * these tests break around DST changes, so it's actually - * important to use a specific reference time here. */ - assertEqualInt(get_date(0, "tomorrow"), 24 * 60 * 60); - assertEqualInt(get_date(0, "yesterday"), - 24 * 60 * 60); - assertEqualInt(get_date(0, "now + 1 hour"), 60 * 60); - assertEqualInt(get_date(0, "now + 1 hour + 1 minute"), 60 * 60 + 60); - /* Repeat the above for a different start time. */ - now = 1231113600; /* Jan 5, 2009 00:00 UTC */ - assertEqualInt(get_date(0, "Jan 5, 2009 00:00 UTC"), now); - assertEqualInt(get_date(now, "tomorrow"), now + 24 * 60 * 60); - assertEqualInt(get_date(now, "yesterday"), now - 24 * 60 * 60); - assertEqualInt(get_date(now, "now + 1 hour"), now + 60 * 60); - assertEqualInt(get_date(now, "now + 1 hour + 1 minute"), - now + 60 * 60 + 60); - assertEqualInt(get_date(now, "tomorrow 5:16am UTC"), - now + 24 * 60 * 60 + 5 * 60 * 60 + 16 * 60); - assertEqualInt(get_date(now, "UTC 5:16am tomorrow"), - now + 24 * 60 * 60 + 5 * 60 * 60 + 16 * 60); - - /* Jan 5, 2009 was a Monday. */ - assertEqualInt(get_date(now, "monday UTC"), now); - assertEqualInt(get_date(now, "sunday UTC"), now + 6 * 24 * 60 * 60); - assertEqualInt(get_date(now, "tuesday UTC"), now + 24 * 60 * 60); - /* "next tuesday" is one week after "tuesday" */ - assertEqualInt(get_date(now, "UTC next tuesday"), - now + 8 * 24 * 60 * 60); - /* "last tuesday" is one week before "tuesday" */ - assertEqualInt(get_date(now, "last tuesday UTC"), - now - 6 * 24 * 60 * 60); - /* TODO: Lots more tests here. */ -} diff --git a/archivers/libarchive/files/tar/tree.c b/archivers/libarchive/files/tar/tree.c deleted file mode 100644 index 6504ebf7d06..00000000000 --- a/archivers/libarchive/files/tar/tree.c +++ /dev/null @@ -1,821 +0,0 @@ -/*- - * 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. - */ - -/*- - * This is a new directory-walking system that addresses a number - * of problems I've had with fts(3). In particular, it has no - * pathname-length limits (other than the size of 'int'), handles - * deep logical traversals, uses considerably less memory, and has - * an opaque interface (easier to modify in the future). - * - * Internally, it keeps a single list of "tree_entry" items that - * represent filesystem objects that require further attention. - * Non-directories are not kept in memory: they are pulled from - * readdir(), returned to the client, then freed as soon as possible. - * Any directory entry to be traversed gets pushed onto the stack. - * - * There is surprisingly little information that needs to be kept for - * each item on the stack. Just the name, depth (represented here as the - * string length of the parent directory's pathname), and some markers - * indicating how to get back to the parent (via chdir("..") for a - * regular dir or via fchdir(2) for a symlink). - */ -#include "bsdtar_platform.h" -__FBSDID("$FreeBSD: src/usr.bin/tar/tree.c,v 1.9 2008/11/27 05:49:52 kientzle Exp $"); - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_DIRECT_H -#include <direct.h> -#endif -#ifdef HAVE_DIRENT_H -#include <dirent.h> -#endif -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__) -#include <windows.h> -#endif - -#include "tree.h" - -/* - * TODO: - * 1) Loop checking. - * 3) Arbitrary logical traversals by closing/reopening intermediate fds. - */ - -struct tree_entry { - int depth; - struct tree_entry *next; - struct tree_entry *parent; - char *name; - size_t dirname_length; - dev_t dev; - ino_t ino; - int flags; - /* How to return back to the parent of a symlink. */ -#ifdef HAVE_FCHDIR - int symlink_parent_fd; -#elif defined(_WIN32) && !defined(__CYGWIN__) - char *symlink_parent_path; -#else -#error fchdir function required. -#endif -}; - -/* Definitions for tree_entry.flags bitmap. */ -#define isDir 1 /* This entry is a regular directory. */ -#define isDirLink 2 /* This entry is a symbolic link to a directory. */ -#define needsFirstVisit 4 /* This is an initial entry. */ -#define needsDescent 8 /* This entry needs to be previsited. */ -#define needsOpen 16 /* This is a directory that needs to be opened. */ -#define needsAscent 32 /* This entry needs to be postvisited. */ - -/* - * On Windows, "first visit" is handled as a pattern to be handed to - * _findfirst(). This is consistent with Windows conventions that - * file patterns are handled within the application. On Posix, - * "first visit" is just returned to the client. - */ - -/* - * Local data for this package. - */ -struct tree { - struct tree_entry *stack; - struct tree_entry *current; -#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__) - HANDLE d; - BY_HANDLE_FILE_INFORMATION fileInfo; -#define INVALID_DIR_HANDLE INVALID_HANDLE_VALUE - WIN32_FIND_DATA _findData; - WIN32_FIND_DATA *findData; -#else - DIR *d; -#define INVALID_DIR_HANDLE NULL - struct dirent *de; -#endif - int flags; - int visit_type; - int tree_errno; /* Error code from last failed operation. */ - - /* Dynamically-sized buffer for holding path */ - char *buff; - size_t buff_length; - - const char *basename; /* Last path element */ - size_t dirname_length; /* Leading dir length */ - size_t path_length; /* Total path length */ - - int depth; - int openCount; - int maxOpenCount; - - struct stat lst; - struct stat st; -}; - -/* Definitions for tree.flags bitmap. */ -#define hasStat 16 /* The st entry is valid. */ -#define hasLstat 32 /* The lst entry is valid. */ -#define hasFileInfo 64 /* The Windows fileInfo entry is valid. */ - -#if defined(_WIN32) && !defined(__CYGWIN__) -static int -tree_dir_next_windows(struct tree *t, const char *pattern); -#else -static int -tree_dir_next_posix(struct tree *t); -#endif - -#ifdef HAVE_DIRENT_D_NAMLEN -/* BSD extension; avoids need for a strlen() call. */ -#define D_NAMELEN(dp) (dp)->d_namlen -#else -#define D_NAMELEN(dp) (strlen((dp)->d_name)) -#endif - -#include <stdio.h> -void -tree_dump(struct tree *t, FILE *out) -{ - char buff[300]; - struct tree_entry *te; - - fprintf(out, "\tdepth: %d\n", t->depth); - fprintf(out, "\tbuff: %s\n", t->buff); - fprintf(out, "\tpwd: %s\n", getcwd(buff, sizeof(buff))); - fprintf(out, "\tbasename: %s\n", t->basename); - fprintf(out, "\tstack:\n"); - for (te = t->stack; te != NULL; te = te->next) { - fprintf(out, "\t\t%s%d:\"%s\" %s%s%s%s%s%s\n", - t->current == te ? "*" : " ", - te->depth, - te->name, - te->flags & needsFirstVisit ? "V" : "", - te->flags & needsDescent ? "D" : "", - te->flags & needsOpen ? "O" : "", - te->flags & needsAscent ? "A" : "", - te->flags & isDirLink ? "L" : "", - (t->current == te && t->d) ? "+" : "" - ); - } -} - -/* - * Add a directory path to the current stack. - */ -static void -tree_push(struct tree *t, const char *path) -{ - struct tree_entry *te; - - te = malloc(sizeof(*te)); - memset(te, 0, sizeof(*te)); - te->next = t->stack; - te->parent = t->current; - if (te->parent) - te->depth = te->parent->depth + 1; - t->stack = te; -#ifdef HAVE_FCHDIR - te->symlink_parent_fd = -1; - te->name = strdup(path); -#elif defined(_WIN32) && !defined(__CYGWIN__) - te->symlink_parent_path = NULL; - te->name = strdup(path); -#endif - te->flags = needsDescent | needsOpen | needsAscent; - te->dirname_length = t->dirname_length; -} - -/* - * Append a name to the current dir path. - */ -static void -tree_append(struct tree *t, const char *name, size_t name_length) -{ - char *p; - size_t size_needed; - - if (t->buff != NULL) - t->buff[t->dirname_length] = '\0'; - /* Strip trailing '/' from name, unless entire name is "/". */ - while (name_length > 1 && name[name_length - 1] == '/') - name_length--; - - /* Resize pathname buffer as needed. */ - size_needed = name_length + 1 + t->dirname_length; - if (t->buff_length < size_needed) { - if (t->buff_length < 1024) - t->buff_length = 1024; - while (t->buff_length < size_needed) - t->buff_length *= 2; - t->buff = realloc(t->buff, t->buff_length); - } - if (t->buff == NULL) - abort(); - p = t->buff + t->dirname_length; - t->path_length = t->dirname_length + name_length; - /* Add a separating '/' if it's needed. */ - if (t->dirname_length > 0 && p[-1] != '/') { - *p++ = '/'; - t->path_length ++; - } -#if HAVE_STRNCPY_S - strncpy_s(p, t->buff_length - (p - t->buff), name, name_length); -#else - strncpy(p, name, name_length); -#endif - p[name_length] = '\0'; - t->basename = p; -} - -/* - * Open a directory tree for traversal. - */ -struct tree * -tree_open(const char *path) -{ -#ifdef HAVE_FCHDIR - struct tree *t; - - t = malloc(sizeof(*t)); - memset(t, 0, sizeof(*t)); - /* First item is set up a lot like a symlink traversal. */ - tree_push(t, path); - t->stack->flags = needsFirstVisit | isDirLink | needsAscent; - t->stack->symlink_parent_fd = open(".", O_RDONLY); - t->openCount++; - t->d = INVALID_DIR_HANDLE; - return (t); -#elif defined(_WIN32) && !defined(__CYGWIN__) - struct tree *t; - char *cwd = _getcwd(NULL, 0); - char *pathname = strdup(path), *p, *base; - - if (pathname == NULL) - abort(); - for (p = pathname; *p != '\0'; ++p) { - if (*p == '\\') - *p = '/'; - } - base = pathname; - - t = malloc(sizeof(*t)); - memset(t, 0, sizeof(*t)); - /* First item is set up a lot like a symlink traversal. */ - /* printf("Looking for wildcard in %s\n", path); */ - /* TODO: wildcard detection here screws up on \\?\c:\ UNC names */ - if (strchr(base, '*') || strchr(base, '?')) { - // It has a wildcard in it... - // Separate the last element. - p = strrchr(base, '/'); - if (p != NULL) { - *p = '\0'; - chdir(base); - tree_append(t, base, p - base); - t->dirname_length = t->path_length; - base = p + 1; - } - } - tree_push(t, base); - free(pathname); - t->stack->flags = needsFirstVisit | isDirLink | needsAscent; - t->stack->symlink_parent_path = cwd; - t->d = INVALID_DIR_HANDLE; - return (t); -#endif -} - -/* - * We've finished a directory; ascend back to the parent. - */ -static int -tree_ascend(struct tree *t) -{ - struct tree_entry *te; - int r = 0; - - te = t->stack; - t->depth--; - if (te->flags & isDirLink) { -#ifdef HAVE_FCHDIR - if (fchdir(te->symlink_parent_fd) != 0) { - t->tree_errno = errno; - r = TREE_ERROR_FATAL; - } - close(te->symlink_parent_fd); -#elif defined(_WIN32) && !defined(__CYGWIN__) - if (SetCurrentDirectory(te->symlink_parent_path) == 0) { - t->tree_errno = errno; - r = TREE_ERROR_FATAL; - } - free(te->symlink_parent_path); - te->symlink_parent_path = NULL; -#endif - t->openCount--; - } else { -#if defined(_WIN32) && !defined(__CYGWIN__) - if (SetCurrentDirectory("..") == 0) { -#else - if (chdir("..") != 0) { -#endif - t->tree_errno = errno; - r = TREE_ERROR_FATAL; - } - } - return (r); -} - -/* - * Pop the working stack. - */ -static void -tree_pop(struct tree *t) -{ - struct tree_entry *te; - - if (t->buff) - t->buff[t->dirname_length] = '\0'; - if (t->stack == t->current && t->current != NULL) - t->current = t->current->parent; - te = t->stack; - t->stack = te->next; - t->dirname_length = te->dirname_length; - if (t->buff) { - t->basename = t->buff + t->dirname_length; - while (t->basename[0] == '/') - t->basename++; - } - free(te->name); - free(te); -} - -/* - * Get the next item in the tree traversal. - */ -int -tree_next(struct tree *t) -{ - int r; - - /* If we're called again after a fatal error, that's an API - * violation. Just crash now. */ - if (t->visit_type == TREE_ERROR_FATAL) { - fprintf(stderr, "Unable to continue traversing" - " directory heirarchy after a fatal error."); - abort(); - } - - while (t->stack != NULL) { - /* If there's an open dir, get the next entry from there. */ - if (t->d != INVALID_DIR_HANDLE) { -#if defined(_WIN32) && !defined(__CYGWIN__) - r = tree_dir_next_windows(t, NULL); -#else - r = tree_dir_next_posix(t); -#endif - if (r == 0) - continue; - return (r); - } - - if (t->stack->flags & needsFirstVisit) { -#if defined(_WIN32) && !defined(__CYGWIN__) - char *d = t->stack->name; - t->stack->flags &= ~needsFirstVisit; - if (strchr(d, '*') || strchr(d, '?')) { - r = tree_dir_next_windows(t, d); - if (r == 0) - continue; - return (r); - } - // Not a pattern, handle it as-is... -#endif - /* Top stack item needs a regular visit. */ - t->current = t->stack; - tree_append(t, t->stack->name, strlen(t->stack->name)); - //t->dirname_length = t->path_length; - //tree_pop(t); - t->stack->flags &= ~needsFirstVisit; - return (t->visit_type = TREE_REGULAR); - } else if (t->stack->flags & needsDescent) { - /* Top stack item is dir to descend into. */ - t->current = t->stack; - tree_append(t, t->stack->name, strlen(t->stack->name)); - t->stack->flags &= ~needsDescent; - /* If it is a link, set up fd for the ascent. */ - if (t->stack->flags & isDirLink) { -#ifdef HAVE_FCHDIR - t->stack->symlink_parent_fd = open(".", O_RDONLY); - t->openCount++; - if (t->openCount > t->maxOpenCount) - t->maxOpenCount = t->openCount; -#elif defined(_WIN32) && !defined(__CYGWIN__) - t->stack->symlink_parent_path = _getcwd(NULL, 0); -#endif - } - t->dirname_length = t->path_length; -#if defined(_WIN32) && !defined(__CYGWIN__) - if (t->path_length == 259 || !SetCurrentDirectory(t->stack->name) != 0) -#else - if (chdir(t->stack->name) != 0) -#endif - { - /* chdir() failed; return error */ - tree_pop(t); - t->tree_errno = errno; - return (t->visit_type = TREE_ERROR_DIR); - } - t->depth++; - return (t->visit_type = TREE_POSTDESCENT); - } else if (t->stack->flags & needsOpen) { - t->stack->flags &= ~needsOpen; -#if defined(_WIN32) && !defined(__CYGWIN__) - r = tree_dir_next_windows(t, "*"); -#else - r = tree_dir_next_posix(t); -#endif - if (r == 0) - continue; - return (r); - } else if (t->stack->flags & needsAscent) { - /* Top stack item is dir and we're done with it. */ - r = tree_ascend(t); - tree_pop(t); - t->visit_type = r != 0 ? r : TREE_POSTASCENT; - return (t->visit_type); - } else { - /* Top item on stack is dead. */ - tree_pop(t); - t->flags &= ~hasLstat; - t->flags &= ~hasStat; - } - } - return (t->visit_type = 0); -} - -#if defined(_WIN32) && !defined(__CYGWIN__) -static int -tree_dir_next_windows(struct tree *t, const char *pattern) -{ - const char *name; - size_t namelen; - int r; - - for (;;) { - if (pattern != NULL) { - t->d = FindFirstFile(pattern, &t->_findData); - if (t->d == INVALID_DIR_HANDLE) { - r = tree_ascend(t); /* Undo "chdir" */ - tree_pop(t); - t->tree_errno = errno; - t->visit_type = r != 0 ? r : TREE_ERROR_DIR; - return (t->visit_type); - } - t->findData = &t->_findData; - pattern = NULL; - } else if (!FindNextFile(t->d, &t->_findData)) { - FindClose(t->d); - t->d = INVALID_DIR_HANDLE; - t->findData = NULL; - return (0); - } - name = t->findData->cFileName; - namelen = strlen(name); - t->flags &= ~hasLstat; - t->flags &= ~hasStat; - if (name[0] == '.' && name[1] == '\0') - continue; - if (name[0] == '.' && name[1] == '.' && name[2] == '\0') - continue; - tree_append(t, name, namelen); - return (t->visit_type = TREE_REGULAR); - } -} -#else -static int -tree_dir_next_posix(struct tree *t) -{ - int r; - const char *name; - size_t namelen; - - if (t->d == NULL) { - if ((t->d = opendir(".")) == NULL) { - r = tree_ascend(t); /* Undo "chdir" */ - tree_pop(t); - t->tree_errno = errno; - t->visit_type = r != 0 ? r : TREE_ERROR_DIR; - return (t->visit_type); - } - } - for (;;) { - t->de = readdir(t->d); - if (t->de == NULL) { - closedir(t->d); - t->d = INVALID_DIR_HANDLE; - return (0); - } - name = t->de->d_name; - namelen = D_NAMELEN(t->de); - t->flags &= ~hasLstat; - t->flags &= ~hasStat; - if (name[0] == '.' && name[1] == '\0') - continue; - if (name[0] == '.' && name[1] == '.' && name[2] == '\0') - continue; - tree_append(t, name, namelen); - return (t->visit_type = TREE_REGULAR); - } -} -#endif - -/* - * Return error code. - */ -int -tree_errno(struct tree *t) -{ - return (t->tree_errno); -} - -/* - * Called by the client to mark the directory just returned from - * tree_next() as needing to be visited. - */ -void -tree_descend(struct tree *t) -{ - if (t->visit_type != TREE_REGULAR) - return; - - if (tree_current_is_physical_dir(t)) { - tree_push(t, t->basename); - t->stack->flags |= isDir; - } else if (tree_current_is_dir(t)) { - tree_push(t, t->basename); - t->stack->flags |= isDirLink; - } -} - -/* - * Get the stat() data for the entry just returned from tree_next(). - */ -const struct stat * -tree_current_stat(struct tree *t) -{ - if (!(t->flags & hasStat)) { - if (stat(tree_current_access_path(t), &t->st) != 0) - return NULL; - t->flags |= hasStat; - } - return (&t->st); -} - -#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__) -const BY_HANDLE_FILE_INFORMATION * -tree_current_file_information(struct tree *t) -{ - if (!(t->flags & hasFileInfo)) { - HANDLE h = CreateFile(tree_current_access_path(t), - 0, 0, NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, - NULL); - if (h == INVALID_HANDLE_VALUE) - return NULL; - if (!GetFileInformationByHandle(h, &t->fileInfo)) { - CloseHandle(h); - return NULL; - } - CloseHandle(h); - t->flags |= hasFileInfo; - } - return (&t->fileInfo); -} -#endif -/* - * Get the lstat() data for the entry just returned from tree_next(). - */ -const struct stat * -tree_current_lstat(struct tree *t) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - return (tree_current_stat(t)); -#else - if (!(t->flags & hasLstat)) { - if (lstat(tree_current_access_path(t), &t->lst) != 0) - return NULL; - t->flags |= hasLstat; - } - return (&t->lst); -#endif -} - -/* - * Test whether current entry is a dir or link to a dir. - */ -int -tree_current_is_dir(struct tree *t) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - if (t->findData) - return (t->findData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - if (tree_current_file_information(t)) - return (t->fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - return (0); -#else - const struct stat *st; - /* - * If we already have lstat() info, then try some - * cheap tests to determine if this is a dir. - */ - if (t->flags & hasLstat) { - /* If lstat() says it's a dir, it must be a dir. */ - if (S_ISDIR(tree_current_lstat(t)->st_mode)) - return 1; - /* Not a dir; might be a link to a dir. */ - /* If it's not a link, then it's not a link to a dir. */ - if (!S_ISLNK(tree_current_lstat(t)->st_mode)) - return 0; - /* - * It's a link, but we don't know what it's a link to, - * so we'll have to use stat(). - */ - } - - st = tree_current_stat(t); - /* If we can't stat it, it's not a dir. */ - if (st == NULL) - return 0; - /* Use the definitive test. Hopefully this is cached. */ - return (S_ISDIR(st->st_mode)); -#endif -} - -/* - * Test whether current entry is a physical directory. Usually, we - * already have at least one of stat() or lstat() in memory, so we - * use tricks to try to avoid an extra trip to the disk. - */ -int -tree_current_is_physical_dir(struct tree *t) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - if (tree_current_is_physical_link(t)) - return (0); - return (tree_current_is_dir(t)); -#else - const struct stat *st; - - /* - * If stat() says it isn't a dir, then it's not a dir. - * If stat() data is cached, this check is free, so do it first. - */ - if ((t->flags & hasStat) - && (!S_ISDIR(tree_current_stat(t)->st_mode))) - return 0; - - /* - * Either stat() said it was a dir (in which case, we have - * to determine whether it's really a link to a dir) or - * stat() info wasn't available. So we use lstat(), which - * hopefully is already cached. - */ - - st = tree_current_lstat(t); - /* If we can't stat it, it's not a dir. */ - if (st == NULL) - return 0; - /* Use the definitive test. Hopefully this is cached. */ - return (S_ISDIR(st->st_mode)); -#endif -} - -/* - * Test whether current entry is a symbolic link. - */ -int -tree_current_is_physical_link(struct tree *t) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) -#ifndef IO_REPARSE_TAG_SYMLINK -/* Old SDKs do not provide IO_REPARSE_TAG_SYMLINK */ -#define IO_REPARSE_TAG_SYMLINK 0xA000000CL -#endif - if (t->findData) - return ((t->findData->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) - && (t->findData->dwReserved0 == IO_REPARSE_TAG_SYMLINK)); - return (0); -#else - const struct stat *st = tree_current_lstat(t); - if (st == NULL) - return 0; - return (S_ISLNK(st->st_mode)); -#endif -} - -/* - * Return the access path for the entry just returned from tree_next(). - */ -const char * -tree_current_access_path(struct tree *t) -{ - return (t->basename); -} - -/* - * Return the full path for the entry just returned from tree_next(). - */ -const char * -tree_current_path(struct tree *t) -{ - return (t->buff); -} - -/* - * Return the length of the path for the entry just returned from tree_next(). - */ -size_t -tree_current_pathlen(struct tree *t) -{ - return (t->path_length); -} - -/* - * Return the nesting depth of the entry just returned from tree_next(). - */ -int -tree_current_depth(struct tree *t) -{ - return (t->depth); -} - -/* - * Terminate the traversal and release any resources. - */ -void -tree_close(struct tree *t) -{ - /* Release anything remaining in the stack. */ - while (t->stack != NULL) - tree_pop(t); - free(t->buff); - /* TODO: Ensure that premature close() resets cwd */ -#if 0 -#ifdef HAVE_FCHDIR - if (t->initialDirFd >= 0) { - int s = fchdir(t->initialDirFd); - (void)s; /* UNUSED */ - close(t->initialDirFd); - t->initialDirFd = -1; - } -#elif defined(_WIN32) && !defined(__CYGWIN__) - if (t->initialDir != NULL) { - SetCurrentDir(t->initialDir); - free(t->initialDir); - t->initialDir = NULL; - } -#endif -#endif - free(t); -} diff --git a/archivers/libarchive/files/tar/tree.h b/archivers/libarchive/files/tar/tree.h deleted file mode 100644 index 9a7e0d30744..00000000000 --- a/archivers/libarchive/files/tar/tree.h +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * 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: src/usr.bin/tar/tree.h,v 1.4 2008/11/27 05:49:52 kientzle Exp $ - */ - -/*- - * A set of routines for traversing directory trees. - * Similar in concept to the fts library, but with a few - * important differences: - * * Uses less memory. In particular, fts stores an entire directory - * in memory at a time. This package only keeps enough subdirectory - * information in memory to track the traversal. Information - * about non-directories is discarded as soon as possible. - * * Supports very deep logical traversals. The fts package - * uses "non-chdir" approach for logical traversals. This - * package does use a chdir approach for logical traversals - * and can therefore handle pathnames much longer than PATH_MAX. - * * Supports deep physical traversals "out of the box." - * Due to the memory optimizations above, there's no need to - * limit dir names to 32k. - */ - -#include <sys/stat.h> -#include <stdio.h> - -struct tree; - -/* Initiate/terminate a tree traversal. */ -struct tree *tree_open(const char * /* pathname */); -void tree_close(struct tree *); - -/* - * tree_next() returns Zero if there is no next entry, non-zero if - * there is. Note that directories are visited three times. - * Directories are always visited first as part of enumerating their - * parent; that is a "regular" visit. If tree_descend() is invoked at - * that time, the directory is added to a work list and will - * subsequently be visited two more times: once just after descending - * into the directory ("postdescent") and again just after ascending - * back to the parent ("postascent"). - * - * TREE_ERROR_DIR is returned if the descent failed (because the - * directory couldn't be opened, for instance). This is returned - * instead of TREE_POSTDESCENT/TREE_POSTASCENT. TREE_ERROR_DIR is not a - * fatal error, but it does imply that the relevant subtree won't be - * visited. TREE_ERROR_FATAL is returned for an error that left the - * traversal completely hosed. Right now, this is only returned for - * chdir() failures during ascent. - */ -#define TREE_REGULAR 1 -#define TREE_POSTDESCENT 2 -#define TREE_POSTASCENT 3 -#define TREE_ERROR_DIR -1 -#define TREE_ERROR_FATAL -2 - -int tree_next(struct tree *); - -/* Errno value associated with the last traversal error. */ -int tree_errno(struct tree *); - -/* - * Request that current entry be visited. If you invoke it on every - * directory, you'll get a physical traversal. This is ignored if the - * current entry isn't a directory or a link to a directory. So, if - * you invoke this on every returned path, you'll get a full logical - * traversal. - */ -void tree_descend(struct tree *); - -/* - * Return information about the current entry. - */ - -/* Current depth in the traversal. */ -int tree_current_depth(struct tree *); - -/* - * The current full pathname, length of the full pathname, and a name - * that can be used to access the file. Because tree does use chdir - * extensively, the access path is almost never the same as the full - * current path. - * - * TODO: Flesh out this interface to provide other information. In - * particular, Windows can provide file size, mode, and some permission - * information without invoking stat() at all. - * - * TODO: On platforms that support it, use openat()-style operations - * to eliminate the chdir() operations entirely while still supporting - * arbitrarily deep traversals. This makes access_path troublesome to - * support, of course, which means we'll need a rich enough interface - * that clients can function without it. (In particular, we'll need - * tree_current_open() that returns an open file descriptor.) - * - * TODO: Provide tree_current_archive_entry(). - */ -const char *tree_current_path(struct tree *); -size_t tree_current_pathlen(struct tree *); -const char *tree_current_access_path(struct tree *); - -/* - * Request the lstat() or stat() data for the current path. Since the - * tree package needs to do some of this anyway, and caches the - * results, you should take advantage of it here if you need it rather - * than make a redundant stat() or lstat() call of your own. - */ -const struct stat *tree_current_stat(struct tree *); -const struct stat *tree_current_lstat(struct tree *); - -/* The following functions use tricks to avoid a certain number of - * stat()/lstat() calls. */ -/* "is_physical_dir" is equivalent to S_ISDIR(tree_current_lstat()->st_mode) */ -int tree_current_is_physical_dir(struct tree *); -/* "is_physical_link" is equivalent to S_ISLNK(tree_current_lstat()->st_mode) */ -int tree_current_is_physical_link(struct tree *); -/* "is_dir" is equivalent to S_ISDIR(tree_current_stat()->st_mode) */ -int tree_current_is_dir(struct tree *); - -/* For testing/debugging: Dump the internal status to the given filehandle. */ -void tree_dump(struct tree *, FILE *); |