summaryrefslogtreecommitdiff
path: root/libarchive/libarchive-2.7.1/tar
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2010-02-05 11:06:31 +0100
committerTomas Bzatek <tbzatek@redhat.com>2010-02-05 11:06:31 +0100
commitbaea7d877d3cf69679a39e8512a120658a478073 (patch)
tree37c9a98cb3d3a322f3f91c8ca656ccd6bd2eaebe /libarchive/libarchive-2.7.1/tar
parente42a4ff3031aa1c1aaf27aa34d9395fec185924b (diff)
downloadtuxcmd-modules-baea7d877d3cf69679a39e8512a120658a478073.tar.xz
Rebase libarchive to 2.8.0
Diffstat (limited to 'libarchive/libarchive-2.7.1/tar')
-rw-r--r--libarchive/libarchive-2.7.1/tar/CMakeLists.txt50
-rw-r--r--libarchive/libarchive-2.7.1/tar/COPYING62
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar.1898
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar.c711
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar.h174
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.c141
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.h44
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar_platform.h175
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar_windows.c1213
-rw-r--r--libarchive/libarchive-2.7.1/tar/bsdtar_windows.h59
-rw-r--r--libarchive/libarchive-2.7.1/tar/cmdline.c380
-rw-r--r--libarchive/libarchive-2.7.1/tar/config_freebsd.h108
-rw-r--r--libarchive/libarchive-2.7.1/tar/getdate.c1050
-rw-r--r--libarchive/libarchive-2.7.1/tar/matching.c478
-rw-r--r--libarchive/libarchive-2.7.1/tar/read.c418
-rw-r--r--libarchive/libarchive-2.7.1/tar/siginfo.c151
-rw-r--r--libarchive/libarchive-2.7.1/tar/subst.c287
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/CMakeLists.txt52
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/list.h14
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/main.c1132
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test.h164
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_0.c67
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_basic.c185
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_copy.c420
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_getdate.c80
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_help.c81
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_option_T.c153
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_option_q.c125
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_option_s.c106
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_patterns.c183
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_patterns_2.tar.uu231
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_patterns_3.tar.uu231
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_patterns_4.tar.uu641
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_stdio.c124
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_strip_components.c110
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_symlink_dir.c193
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_version.c96
-rw-r--r--libarchive/libarchive-2.7.1/tar/test/test_windows.c322
-rw-r--r--libarchive/libarchive-2.7.1/tar/tree.c602
-rw-r--r--libarchive/libarchive-2.7.1/tar/tree.h127
-rw-r--r--libarchive/libarchive-2.7.1/tar/util.c630
-rw-r--r--libarchive/libarchive-2.7.1/tar/write.c1063
42 files changed, 0 insertions, 13531 deletions
diff --git a/libarchive/libarchive-2.7.1/tar/CMakeLists.txt b/libarchive/libarchive-2.7.1/tar/CMakeLists.txt
deleted file mode 100644
index 2d60f79..0000000
--- a/libarchive/libarchive-2.7.1/tar/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-############################################
-#
-# How to build bsdtar
-#
-############################################
-IF (ENABLE_TAR)
- SET(bsdtar_SOURCES
- bsdtar.c
- bsdtar.h
- bsdtar_platform.h
- cmdline.c
- getdate.c
- matching.c
- read.c
- siginfo.c
- subst.c
- tree.c
- tree.h
- util.c
- write.c
- )
- IF(WIN32 AND NOT CYGWIN)
- LIST(APPEND bsdtar_SOURCES bsdtar_windows.c)
- LIST(APPEND bsdtar_SOURCES bsdtar_windows.h)
- ENDIF(WIN32 AND NOT CYGWIN)
-
- SET(bsdtar_MANS bsdtar.1)
-
- #
- # Register target
- #
- ADD_EXECUTABLE(bsdtar ${bsdtar_SOURCES})
- IF(ENABLE_TAR_SHARED)
- TARGET_LINK_LIBRARIES(bsdtar archive ${ADDITIONAL_LIBS})
- ELSE(ENABLE_TAR_SHARED)
- TARGET_LINK_LIBRARIES(bsdtar archive_static ${ADDITIONAL_LIBS})
- ENDIF(ENABLE_TAR_SHARED)
- IF(WIN32 AND NOT CYGWIN)
- SET_TARGET_PROPERTIES(bsdtar PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
- SET(BSDTAR ${CMAKE_BINARY_DIR}/debug/bsdtar.exe)
- ELSE(WIN32 AND NOT CYGWIN)
- SET(BSDTAR ${CMAKE_CURRENT_BINARY_DIR}/bsdtar)
- ENDIF(WIN32 AND NOT CYGWIN)
- #
- INSTALL(TARGETS bsdtar RUNTIME DESTINATION bin)
- INSTALL_MAN(${bsdtar_MANS})
-ENDIF(ENABLE_TAR)
-
-add_subdirectory(test)
diff --git a/libarchive/libarchive-2.7.1/tar/COPYING b/libarchive/libarchive-2.7.1/tar/COPYING
deleted file mode 100644
index 9c14fd2..0000000
--- a/libarchive/libarchive-2.7.1/tar/COPYING
+++ /dev/null
@@ -1,62 +0,0 @@
-$FreeBSD: src/usr.bin/tar/COPYING,v 1.3 2008/01/02 00:19:49 kientzle Exp $
-
-All of the C source code and documentation in this package is subject
-to the following:
-
-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.
-
-Some of the filename pattern matching code is based on code subject
-to the following license:
-
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * 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.
- */
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar.1 b/libarchive/libarchive-2.7.1/tar/bsdtar.1
deleted file mode 100644
index ec2d61c..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar.1
+++ /dev/null
@@ -1,898 +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 AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/usr.bin/tar/bsdtar.1,v 1.46 2008/12/06 07:37:55 kientzle Exp $
-.\"
-.Dd March 25, 2009
-.Dt BSDTAR 1
-.Os
-.Sh NAME
-.Nm tar
-.Nd manipulate tape archives
-.Sh SYNOPSIS
-.Nm
-.Op Ar bundled-flags Ao args Ac
-.Op Ao Ar file Ac | Ao Ar pattern Ac ...
-.Nm
-.Brq Fl c
-.Op Ar options
-.Op Ar files | Ar directories
-.Nm
-.Brq Fl r | Fl u
-.Fl f Ar archive-file
-.Op Ar options
-.Op Ar files | Ar directories
-.Nm
-.Brq Fl t | Fl x
-.Op Ar options
-.Op Ar patterns
-.Sh DESCRIPTION
-.Nm
-creates and manipulates streaming archive files.
-This implementation can extract from tar, pax, cpio, zip, jar, ar,
-and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
-and shar archives.
-.Pp
-The first synopsis form shows a
-.Dq bundled
-option word.
-This usage is provided for compatibility with historical implementations.
-See COMPATIBILITY below for details.
-.Pp
-The other synopsis forms show the preferred usage.
-The first option to
-.Nm
-is a mode indicator from the following list:
-.Bl -tag -compact -width indent
-.It Fl c
-Create a new archive containing the specified items.
-.It Fl r
-Like
-.Fl c ,
-but new entries are appended to the archive.
-Note that this only works on uncompressed archives stored in regular files.
-The
-.Fl f
-option is required.
-.It Fl t
-List archive contents to stdout.
-.It Fl u
-Like
-.Fl r ,
-but new entries are added only if they have a modification date
-newer than the corresponding entry in the archive.
-Note that this only works on uncompressed archives stored in regular files.
-The
-.Fl f
-option is required.
-.It Fl x
-Extract to disk from the archive.
-If a file with the same name appears more than once in the archive,
-each copy will be extracted, with later copies overwriting (replacing)
-earlier copies.
-.El
-.Pp
-In
-.Fl c ,
-.Fl r ,
-or
-.Fl u
-mode, each specified file or directory is added to the
-archive in the order specified on the command line.
-By default, the contents of each directory are also archived.
-.Pp
-In extract or list mode, the entire command line
-is read and parsed before the archive is opened.
-The pathnames or patterns on the command line indicate
-which items in the archive should be processed.
-Patterns are shell-style globbing patterns as
-documented in
-.Xr tcsh 1 .
-.Sh OPTIONS
-Unless specifically stated otherwise, options are applicable in
-all operating modes.
-.Bl -tag -width indent
-.It Cm @ Ns Pa archive
-(c and r mode only)
-The specified archive is opened and the entries
-in it will be appended to the current archive.
-As a simple example,
-.Dl Nm Fl c Fl f Pa - Pa newfile Cm @ Ns Pa original.tar
-writes a new archive to standard output containing a file
-.Pa newfile
-and all of the entries from
-.Pa original.tar .
-In contrast,
-.Dl Nm Fl c Fl f Pa - Pa newfile Pa original.tar
-creates a new archive with only two entries.
-Similarly,
-.Dl Nm Fl czf Pa - Fl -format Cm pax Cm @ Ns Pa -
-reads an archive from standard input (whose format will be determined
-automatically) and converts it into a gzip-compressed
-pax-format archive on stdout.
-In this way,
-.Nm
-can be used to convert archives from one format to another.
-.It Fl b Ar blocksize
-Specify the block size, in 512-byte records, for tape drive I/O.
-As a rule, this argument is only needed when reading from or writing
-to tape drives, and usually not even then as the default block size of
-20 records (10240 bytes) is very common.
-.It Fl C Ar directory
-In c and r mode, this changes the directory before adding
-the following files.
-In x mode, change directories after opening the archive
-but before extracting entries from the archive.
-.It Fl -check-links
-(c and r modes only)
-Issue a warning message unless all links to each file are archived.
-.It Fl -chroot
-(x mode only)
-.Fn chroot
-to the current directory after processing any
-.Fl C
-options and before extracting any files.
-.It Fl -exclude Ar pattern
-Do not process files or directories that match the
-specified pattern.
-Note that exclusions take precedence over patterns or filenames
-specified on the command line.
-.It Fl -format Ar format
-(c, r, u mode only)
-Use the specified format for the created archive.
-Supported formats include
-.Dq cpio ,
-.Dq pax ,
-.Dq shar ,
-and
-.Dq ustar .
-Other formats may also be supported; see
-.Xr libarchive-formats 5
-for more information about currently-supported formats.
-In r and u modes, when extending an existing archive, the format specified
-here must be compatible with the format of the existing archive on disk.
-.It Fl f Ar file
-Read the archive from or write the archive to the specified file.
-The filename can be
-.Pa -
-for standard input or standard output.
-If not specified, the default tape device will be used.
-(On
-.Fx ,
-the default tape device is
-.Pa /dev/sa0 . )
-.It Fl H
-(c and r mode only)
-Symbolic links named on the command line will be followed; the
-target of the link will be archived, not the link itself.
-.It Fl h
-(c and r mode only)
-Synonym for
-.Fl L .
-.It Fl I
-Synonym for
-.Fl T .
-.It Fl -include Ar pattern
-Process only files or directories that match the specified pattern.
-Note that exclusions specified with
-.Fl -exclude
-take precedence over inclusions.
-If no inclusions are explicitly specified, all entries are processed by
-default.
-The
-.Fl -include
-option is especially useful when filtering archives.
-For example, the command
-.Dl Nm Fl c Fl f Pa new.tar Fl -include='*foo*' Cm @ Ns Pa old.tgz
-creates a new archive
-.Pa new.tar
-containing only the entries from
-.Pa old.tgz
-containing the string
-.Sq foo .
-.It Fl j
-(c mode only)
-Compress the resulting archive with
-.Xr bzip2 1 .
-In extract or list modes, this option is ignored.
-Note that, unlike other
-.Nm tar
-implementations, this implementation recognizes bzip2 compression
-automatically when reading archives.
-.It Fl k
-(x mode only)
-Do not overwrite existing files.
-In particular, if a file appears more than once in an archive,
-later copies will not overwrite earlier copies.
-.It Fl -keep-newer-files
-(x mode only)
-Do not overwrite existing files that are newer than the
-versions appearing in the archive being extracted.
-.It Fl L
-(c and r mode only)
-All symbolic links will be followed.
-Normally, symbolic links are archived as such.
-With this option, the target of the link will be archived instead.
-.It Fl l
-This is a synonym for the
-.Fl -check-links
-option.
-.It Fl m
-(x mode only)
-Do not extract modification time.
-By default, the modification time is set to the time stored in the archive.
-.It Fl n
-(c, r, u modes only)
-Do not recursively archive the contents of directories.
-.It Fl -newer Ar date
-(c, r, u modes only)
-Only include files and directories newer than the specified date.
-This compares ctime entries.
-.It Fl -newer-mtime Ar date
-(c, r, u modes only)
-Like
-.Fl -newer ,
-except it compares mtime entries instead of ctime entries.
-.It Fl -newer-than Pa file
-(c, r, u modes only)
-Only include files and directories newer than the specified file.
-This compares ctime entries.
-.It Fl -newer-mtime-than Pa file
-(c, r, u modes only)
-Like
-.Fl -newer-than ,
-except it compares mtime entries instead of ctime entries.
-.It Fl -nodump
-(c and r modes only)
-Honor the nodump file flag by skipping this file.
-.It Fl -null
-(use with
-.Fl I ,
-.Fl T ,
-or
-.Fl X )
-Filenames or patterns are separated by null characters,
-not by newlines.
-This is often used to read filenames output by the
-.Fl print0
-option to
-.Xr find 1 .
-.It Fl -numeric-owner
-(x mode only)
-Ignore symbolic user and group names when restoring archives to disk,
-only numeric uid and gid values will be obeyed.
-.It Fl O
-(x, t modes only)
-In extract (-x) mode, files will be written to standard out rather than
-being extracted to disk.
-In list (-t) mode, the file listing will be written to stderr rather than
-the usual stdout.
-.It Fl o
-(x mode)
-Use the user and group of the user running the program rather
-than those specified in the archive.
-Note that this has no significance unless
-.Fl p
-is specified, and the program is being run by the root user.
-In this case, the file modes and flags from
-the archive will be restored, but ACLs or owner information in
-the archive will be discarded.
-.It Fl o
-(c, r, u mode)
-A synonym for
-.Fl -format Ar ustar
-.It Fl -one-file-system
-(c, r, and u modes)
-Do not cross mount points.
-.It Fl -options Ar options
-Select optional behaviors for particular modules.
-The argument is a text string containing comma-separated
-keywords and values.
-These are passed to the modules that handle particular
-formats to control how those formats will behave.
-Each option has one of the following forms:
-.Bl -tag -compact -width indent
-.It Ar key=value
-The key will be set to the specified value in every module that supports it.
-Modules that do not support this key will ignore it.
-.It Ar key
-The key will be enabled in every module that supports it.
-This is equivalent to
-.Ar key Ns Cm =1 .
-.It Ar !key
-The key will be disabled in every module that supports it.
-.It Ar module:key=value , Ar module:key , Ar module:!key
-As above, but the corresponding key and value will be provided
-only to modules whose name matches
-.Ar module .
-.El
-The currently supported modules and keys are:
-.Bl -tag -compact -width indent
-.It Cm iso9660:joliet
-Support Joliet extensions.
-This is enabled by default, use
-.Cm !joliet
-or
-.Cm iso9660:!joliet
-to disable.
-.It Cm gzip:compression-level
-A decimal integer from 0 to 9 specifying the gzip compression level.
-.It Cm xz:compression-level
-A decimal integer from 0 to 9 specifying the xz compression level.
-.It Cm mtree: Ns Ar keyword
-The mtree writer module allows you to specify which mtree keywords
-will be included in the output.
-Supported keywords include:
-.Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent ,
-.Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 ,
-.Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname .
-The default is equivalent to:
-.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
-.It Cm mtree:all
-Enables all of the above keywords.
-You can also use
-.Cm mtree:!all
-to disable all keywords.
-.It Cm mtree:use-set
-Enable generation of
-.Cm /set
-lines in the output.
-.It Cm mtree:indent
-XXX need explanation XXX
-.El
-If a provided option is not supported by any module, that
-is a fatal error.
-.It Fl P
-Preserve pathnames.
-By default, absolute pathnames (those that begin with a /
-character) have the leading slash removed both when creating archives
-and extracting from them.
-Also,
-.Nm
-will refuse to extract archive entries whose pathnames contain
-.Pa ..
-or whose target directory would be altered by a symlink.
-This option suppresses these behaviors.
-.It Fl p
-(x mode only)
-Preserve file permissions.
-Attempt to restore the full permissions, including owner, file modes, file
-flags and ACLs, if available, for each item extracted from the archive.
-By default, newly-created files are owned by the user running
-.Nm ,
-the file mode is restored for newly-created regular files, and
-all other types of entries receive default permissions.
-If
-.Nm
-is being run by root, the default is to restore the owner unless the
-.Fl o
-option is also specified.
-.It Fl q ( Fl -fast-read )
-(x and t mode only)
-Extract or list only the first archive entry that matches each pattern
-or filename operand.
-Exit as soon as each specified pattern or filename has been matched.
-By default, the archive is always read to the very end, since
-there can be multiple entries with the same name and, by convention,
-later entries overwrite earlier entries.
-This option is provided as a performance optimization.
-.It Fl S
-(x mode only)
-Extract files as sparse files.
-For every block on disk, check first if it contains only NULL bytes and seek
-over it otherwise.
-This works similiar to the conv=sparse option of dd.
-.It Fl -strip-components Ar count
-(x mode only)
-Remove the specified number of leading path elements.
-Pathnames with fewer elements will be silently skipped.
-Note that the pathname is edited after checking inclusion/exclusion patterns
-but before security checks.
-.It Fl s Ar pattern
-Modify file or archive member names according to
-.Pa pattern .
-The pattern has the format /old/new/[gps].
-old is a basic regular expression.
-If it doesn't apply, the pattern is skipped.
-new is the replacement string of the matched part.
-~ is substituted with the match, \1 to \9 with the content of
-the corresponding captured group.
-The optional trailing g specifies that matching should continue
-after the matched part and stopped on the first unmatched pattern.
-The optional trailing s specifies that the pattern applies to the value
-of symbolic links.
-The optional trailing p specifies that after a successful substitution
-the original path name and the new path name should be printed to
-standard error.
-.It Fl T Ar filename
-In x or t mode,
-.Nm
-will read the list of names to be extracted from
-.Pa filename .
-In c mode,
-.Nm
-will read names to be archived from
-.Pa filename .
-The special name
-.Dq -C
-on a line by itself will cause the current directory to be changed to
-the directory specified on the following line.
-Names are terminated by newlines unless
-.Fl -null
-is specified.
-Note that
-.Fl -null
-also disables the special handling of lines containing
-.Dq -C .
-.It Fl U
-(x mode only)
-Unlink files before creating them.
-Without this option,
-.Nm
-overwrites existing files, which preserves existing hardlinks.
-With this option, existing hardlinks will be broken, as will any
-symlink that would affect the location of an extracted file.
-.It Fl -use-compress-program Ar program
-Pipe the input (in x or t mode) or the output (in c mode) through
-.Pa program
-instead of using the builtin compression support.
-.It Fl v
-Produce verbose output.
-In create and extract modes,
-.Nm
-will list each file name as it is read from or written to
-the archive.
-In list mode,
-.Nm
-will produce output similar to that of
-.Xr ls 1 .
-Additional
-.Fl v
-options will provide additional detail.
-.It Fl -version
-Print version of
-.Nm
-and
-.Nm libarchive ,
-and exit.
-.It Fl w
-Ask for confirmation for every action.
-.It Fl X Ar filename
-Read a list of exclusion patterns from the specified file.
-See
-.Fl -exclude
-for more information about the handling of exclusions.
-.It Fl y
-(c mode only)
-Compress the resulting archive with
-.Xr bzip2 1 .
-In extract or list modes, this option is ignored.
-Note that, unlike other
-.Nm tar
-implementations, this implementation recognizes bzip2 compression
-automatically when reading archives.
-.It Fl z
-(c mode only)
-Compress the resulting archive with
-.Xr gzip 1 .
-In extract or list modes, this option is ignored.
-Note that, unlike other
-.Nm tar
-implementations, this implementation recognizes gzip compression
-automatically when reading archives.
-.It Fl Z
-(c mode only)
-Compress the resulting archive with
-.Xr compress 1 .
-In extract or list modes, this option is ignored.
-Note that, unlike other
-.Nm tar
-implementations, this implementation recognizes compress compression
-automatically when reading archives.
-.El
-.Sh ENVIRONMENT
-The following environment variables affect the execution of
-.Nm :
-.Bl -tag -width ".Ev BLOCKSIZE"
-.It Ev LANG
-The locale to use.
-See
-.Xr environ 7
-for more information.
-.It Ev TAPE
-The default tape device.
-The
-.Fl f
-option overrides this.
-.It Ev TZ
-The timezone to use when displaying dates.
-See
-.Xr environ 7
-for more information.
-.El
-.Sh FILES
-.Bl -tag -width ".Ev BLOCKSIZE"
-.It Pa /dev/sa0
-The default tape device, if not overridden by the
-.Ev TAPE
-environment variable or the
-.Fl f
-option.
-.El
-.Sh EXIT STATUS
-.Ex -std
-.Sh EXAMPLES
-The following creates a new archive
-called
-.Ar file.tar.gz
-that contains two files
-.Ar source.c
-and
-.Ar source.h :
-.Dl Nm Fl czf Pa file.tar.gz Pa source.c Pa source.h
-.Pp
-To view a detailed table of contents for this
-archive:
-.Dl Nm Fl tvf Pa file.tar.gz
-.Pp
-To extract all entries from the archive on
-the default tape drive:
-.Dl Nm Fl x
-.Pp
-To examine the contents of an ISO 9660 cdrom image:
-.Dl Nm Fl tf Pa image.iso
-.Pp
-To move file hierarchies, invoke
-.Nm
-as
-.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
-or more traditionally
-.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
-.Pp
-In create mode, the list of files and directories to be archived
-can also include directory change instructions of the form
-.Cm -C Ns Pa foo/baz
-and archive inclusions of the form
-.Cm @ Ns Pa archive-file .
-For example, the command line
-.Dl Nm Fl c Fl f Pa new.tar Pa foo1 Cm @ Ns Pa old.tgz Cm -C Ns Pa /tmp Pa foo2
-will create a new archive
-.Pa new.tar .
-.Nm
-will read the file
-.Pa foo1
-from the current directory and add it to the output archive.
-It will then read each entry from
-.Pa old.tgz
-and add those entries to the output archive.
-Finally, it will switch to the
-.Pa /tmp
-directory and add
-.Pa foo2
-to the output archive.
-.Pp
-An input file in
-.Xr mtree 5
-format can be used to create an output archive with arbitrary ownership,
-permissions, or names that differ from existing data on disk:
-.Pp
-.Dl $ cat input.mtree
-.Dl #mtree
-.Dl usr/bin uid=0 gid=0 mode=0755 type=dir
-.Dl usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls
-.Dl $ tar -cvf output.tar @input.mtree
-.Pp
-The
-.Fl -newer
-and
-.Fl -newer-mtime
-switches accept a variety of common date and time specifications, including
-.Dq 12 Mar 2005 7:14:29pm ,
-.Dq 2005-03-12 19:14 ,
-.Dq 5 minutes ago ,
-and
-.Dq 19:14 PST May 1 .
-.Pp
-The
-.Fl -options
-argument can be used to control various details of archive generation
-or reading.
-For example, you can generate mtree output which only contains
-.Cm type , Cm time ,
-and
-.Cm uid
-keywords:
-.Dl Nm Fl cf Pa file.tar Fl -format=mtree Fl -options='!all,type,time,uid' Pa dir
-or you can set the compression level used by gzip or xz compression:
-.Dl Nm Fl czf Pa file.tar Fl -options='compression-level=9' .
-For more details, see the explanation of the
-.Fn archive_read_set_options
-and
-.Fn archive_write_set_options
-API calls that are described in
-.Xr archive_read 3
-and
-.Xr archive_write 3 .
-.Sh COMPATIBILITY
-The bundled-arguments format is supported for compatibility
-with historic implementations.
-It consists of an initial word (with no leading - character) in which
-each character indicates an option.
-Arguments follow as separate words.
-The order of the arguments must match the order
-of the corresponding characters in the bundled command word.
-For example,
-.Dl Nm Cm tbf 32 Pa file.tar
-specifies three flags
-.Cm t ,
-.Cm b ,
-and
-.Cm f .
-The
-.Cm b
-and
-.Cm f
-flags both require arguments,
-so there must be two additional items
-on the command line.
-The
-.Ar 32
-is the argument to the
-.Cm b
-flag, and
-.Ar file.tar
-is the argument to the
-.Cm f
-flag.
-.Pp
-The mode options c, r, t, u, and x and the options
-b, f, l, m, o, v, and w comply with SUSv2.
-.Pp
-For maximum portability, scripts that invoke
-.Nm tar
-should use the bundled-argument format above, should limit
-themselves to the
-.Cm c ,
-.Cm t ,
-and
-.Cm x
-modes, and the
-.Cm b ,
-.Cm f ,
-.Cm m ,
-.Cm v ,
-and
-.Cm w
-options.
-.Pp
-Additional long options are provided to improve compatibility with other
-tar implementations.
-.Sh SECURITY
-Certain security issues are common to many archiving programs, including
-.Nm .
-In particular, carefully-crafted archives can request that
-.Nm
-extract files to locations outside of the target directory.
-This can potentially be used to cause unwitting users to overwrite
-files they did not intend to overwrite.
-If the archive is being extracted by the superuser, any file
-on the system can potentially be overwritten.
-There are three ways this can happen.
-Although
-.Nm
-has mechanisms to protect against each one,
-savvy users should be aware of the implications:
-.Bl -bullet -width indent
-.It
-Archive entries can have absolute pathnames.
-By default,
-.Nm
-removes the leading
-.Pa /
-character from filenames before restoring them to guard against this problem.
-.It
-Archive entries can have pathnames that include
-.Pa ..
-components.
-By default,
-.Nm
-will not extract files containing
-.Pa ..
-components in their pathname.
-.It
-Archive entries can exploit symbolic links to restore
-files to other directories.
-An archive can restore a symbolic link to another directory,
-then use that link to restore a file into that directory.
-To guard against this,
-.Nm
-checks each extracted path for symlinks.
-If the final path element is a symlink, it will be removed
-and replaced with the archive entry.
-If
-.Fl U
-is specified, any intermediate symlink will also be unconditionally removed.
-If neither
-.Fl U
-nor
-.Fl P
-is specified,
-.Nm
-will refuse to extract the entry.
-.El
-To protect yourself, you should be wary of any archives that
-come from untrusted sources.
-You should examine the contents of an archive with
-.Dl Nm Fl tf Pa filename
-before extraction.
-You should use the
-.Fl k
-option to ensure that
-.Nm
-will not overwrite any existing files or the
-.Fl U
-option to remove any pre-existing files.
-You should generally not extract archives while running with super-user
-privileges.
-Note that the
-.Fl P
-option to
-.Nm
-disables the security checks above and allows you to extract
-an archive while preserving any absolute pathnames,
-.Pa ..
-components, or symlinks to other directories.
-.Sh SEE ALSO
-.Xr bzip2 1 ,
-.Xr compress 1 ,
-.Xr cpio 1 ,
-.Xr gzip 1 ,
-.Xr mt 1 ,
-.Xr pax 1 ,
-.Xr shar 1 ,
-.Xr libarchive 3 ,
-.Xr libarchive-formats 5 ,
-.Xr tar 5
-.Sh STANDARDS
-There is no current POSIX standard for the tar command; it appeared
-in
-.St -p1003.1-96
-but was dropped from
-.St -p1003.1-2001 .
-The options used by this implementation were developed by surveying a
-number of existing tar implementations as well as the old POSIX specification
-for tar and the current POSIX specification for pax.
-.Pp
-The ustar and pax interchange file formats are defined by
-.St -p1003.1-2001
-for the pax command.
-.Sh HISTORY
-A
-.Nm tar
-command appeared in Seventh Edition Unix, which was released in January, 1979.
-There have been numerous other implementations,
-many of which extended the file format.
-John Gilmore's
-.Nm pdtar
-public-domain implementation (circa November, 1987)
-was quite influential, and formed the basis of GNU tar.
-GNU tar was included as the standard system tar
-in
-.Fx
-beginning with
-.Fx 1.0 .
-.Pp
-This is a complete re-implementation based on the
-.Xr libarchive 3
-library.
-.Sh BUGS
-This program follows
-.St -p1003.1-96
-for the definition of the
-.Fl l
-option.
-Note that GNU tar prior to version 1.15 treated
-.Fl l
-as a synonym for the
-.Fl -one-file-system
-option.
-.Pp
-The
-.Fl C Pa dir
-option may differ from historic implementations.
-.Pp
-All archive output is written in correctly-sized blocks, even
-if the output is being compressed.
-Whether or not the last output block is padded to a full
-block size varies depending on the format and the
-output device.
-For tar and cpio formats, the last block of output is padded
-to a full block size if the output is being
-written to standard output or to a character or block device such as
-a tape drive.
-If the output is being written to a regular file, the last block
-will not be padded.
-Many compressors, including
-.Xr gzip 1
-and
-.Xr bzip2 1 ,
-complain about the null padding when decompressing an archive created by
-.Nm ,
-although they still extract it correctly.
-.Pp
-The compression and decompression is implemented internally, so
-there may be insignificant differences between the compressed output
-generated by
-.Dl Nm Fl czf Pa - file
-and that generated by
-.Dl Nm Fl cf Pa - file | Nm gzip
-.Pp
-The default should be to read and write archives to the standard I/O paths,
-but tradition (and POSIX) dictates otherwise.
-.Pp
-The
-.Cm r
-and
-.Cm u
-modes require that the archive be uncompressed
-and located in a regular file on disk.
-Other archives can be modified using
-.Cm c
-mode with the
-.Pa @archive-file
-extension.
-.Pp
-To archive a file called
-.Pa @foo
-or
-.Pa -foo
-you must specify it as
-.Pa ./@foo
-or
-.Pa ./-foo ,
-respectively.
-.Pp
-In create mode, a leading
-.Pa ./
-is always removed.
-A leading
-.Pa /
-is stripped unless the
-.Fl P
-option is specified.
-.Pp
-There needs to be better support for file selection on both create
-and extract.
-.Pp
-There is not yet any support for multi-volume archives or for archiving
-sparse files.
-.Pp
-Converting between dissimilar archive formats (such as tar and cpio) using the
-.Cm @ Ns Pa -
-convention can cause hard link information to be lost.
-(This is a consequence of the incompatible ways that different archive
-formats store hardlink information.)
-.Pp
-There are alternative long options for many of the short options that
-are deliberately not documented.
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar.c b/libarchive/libarchive-2.7.1/tar/bsdtar.c
deleted file mode 100644
index 81b9b61..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar.c
+++ /dev/null
@@ -1,711 +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 "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/bsdtar.c,v 1.93 2008/11/08 04:43:24 kientzle Exp $");
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#endif
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_ZLIB_H
-#include <zlib.h>
-#endif
-
-#include "bsdtar.h"
-
-/*
- * Per POSIX.1-1988, tar defaults to reading/writing archives to/from
- * the default tape device for the system. Pick something reasonable here.
- */
-#ifdef __linux
-#define _PATH_DEFTAPE "/dev/st0"
-#endif
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define _PATH_DEFTAPE "\\\\.\\tape0"
-#endif
-
-#ifndef _PATH_DEFTAPE
-#define _PATH_DEFTAPE "/dev/tape"
-#endif
-
-/* External function to parse a date/time string (from getdate.y) */
-time_t get_date(time_t, const char *);
-
-static void long_help(struct bsdtar *);
-static void only_mode(struct bsdtar *, const char *opt,
- const char *valid);
-static void set_mode(struct bsdtar *, char opt);
-static void version(void);
-
-/* A basic set of security flags to request from libarchive. */
-#define SECURITY \
- (ARCHIVE_EXTRACT_SECURE_SYMLINKS \
- | ARCHIVE_EXTRACT_SECURE_NODOTDOT)
-
-int
-main(int argc, char **argv)
-{
- struct bsdtar *bsdtar, bsdtar_storage;
- int opt, t;
- char option_o;
- char possible_help_request;
- char buff[16];
- time_t now;
-
- /*
- * Use a pointer for consistency, but stack-allocated storage
- * for ease of cleanup.
- */
- bsdtar = &bsdtar_storage;
- memset(bsdtar, 0, sizeof(*bsdtar));
- bsdtar->fd = -1; /* Mark as "unused" */
- option_o = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /* Make sure open() function will be used with a binary mode. */
- /* on cygwin, we need something similar, but instead link against */
- /* a special startup object, binmode.o */
- _set_fmode(_O_BINARY);
-#endif
-
- /* Need bsdtar->progname before calling bsdtar_warnc. */
- if (*argv == NULL)
- bsdtar->progname = "bsdtar";
- else {
-#if defined(_WIN32) && !defined(__CYGWIN__)
- bsdtar->progname = strrchr(*argv, '\\');
-#else
- bsdtar->progname = strrchr(*argv, '/');
-#endif
- if (bsdtar->progname != NULL)
- bsdtar->progname++;
- else
- bsdtar->progname = *argv;
- }
-
- time(&now);
-
- if (setlocale(LC_ALL, "") == NULL)
- bsdtar_warnc(bsdtar, 0, "Failed to set default locale");
-#if defined(HAVE_NL_LANGINFO) && defined(HAVE_D_MD_ORDER)
- bsdtar->day_first = (*nl_langinfo(D_MD_ORDER) == 'd');
-#endif
- possible_help_request = 0;
-
- /* Look up uid of current user for future reference */
- bsdtar->user_uid = geteuid();
-
- /* Default: open tape drive. */
- bsdtar->filename = getenv("TAPE");
- if (bsdtar->filename == NULL)
- bsdtar->filename = _PATH_DEFTAPE;
-
- /* Default: preserve mod time on extract */
- bsdtar->extract_flags = ARCHIVE_EXTRACT_TIME;
-
- /* Default: Perform basic security checks. */
- bsdtar->extract_flags |= SECURITY;
-
- /* Defaults for root user: */
- if (bsdtar_is_privileged(bsdtar)) {
- /* --same-owner */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
- /* -p */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_PERM;
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_ACL;
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
- }
-
- bsdtar->argv = argv;
- bsdtar->argc = argc;
-
- /*
- * Comments following each option indicate where that option
- * originated: SUSv2, POSIX, GNU tar, star, etc. If there's
- * no such comment, then I don't know of anyone else who
- * implements that option.
- */
- while ((opt = bsdtar_getopt(bsdtar)) != -1) {
- switch (opt) {
- case 'B': /* GNU tar */
- /* libarchive doesn't need this; just ignore it. */
- break;
- case 'b': /* SUSv2 */
- t = atoi(bsdtar->optarg);
- if (t <= 0 || t > 1024)
- bsdtar_errc(bsdtar, 1, 0,
- "Argument to -b is out of range (1..1024)");
- bsdtar->bytes_per_block = 512 * t;
- break;
- case 'C': /* GNU tar */
- set_chdir(bsdtar, bsdtar->optarg);
- break;
- case 'c': /* SUSv2 */
- set_mode(bsdtar, opt);
- break;
- case OPTION_CHECK_LINKS: /* GNU tar */
- bsdtar->option_warn_links = 1;
- break;
- case OPTION_CHROOT: /* NetBSD */
- bsdtar->option_chroot = 1;
- break;
- case OPTION_EXCLUDE: /* GNU tar */
- if (exclude(bsdtar, bsdtar->optarg))
- bsdtar_errc(bsdtar, 1, 0,
- "Couldn't exclude %s\n", bsdtar->optarg);
- break;
- case OPTION_FORMAT: /* GNU tar, others */
- bsdtar->create_format = bsdtar->optarg;
- break;
- case OPTION_OPTIONS:
- bsdtar->option_options = bsdtar->optarg;
- break;
- case 'f': /* SUSv2 */
- bsdtar->filename = bsdtar->optarg;
- if (strcmp(bsdtar->filename, "-") == 0)
- bsdtar->filename = NULL;
- break;
- case 'H': /* BSD convention */
- bsdtar->symlink_mode = 'H';
- break;
- case 'h': /* Linux Standards Base, gtar; synonym for -L */
- bsdtar->symlink_mode = 'L';
- /* Hack: -h by itself is the "help" command. */
- possible_help_request = 1;
- break;
- case OPTION_HELP: /* GNU tar, others */
- long_help(bsdtar);
- exit(0);
- break;
- case 'I': /* GNU tar */
- /*
- * TODO: Allow 'names' to come from an archive,
- * not just a text file. Design a good UI for
- * allowing names and mode/owner to be read
- * from an archive, with contents coming from
- * disk. This can be used to "refresh" an
- * archive or to design archives with special
- * permissions without having to create those
- * permissions on disk.
- */
- bsdtar->names_from_file = bsdtar->optarg;
- break;
- case OPTION_INCLUDE:
- /*
- * Noone else has the @archive extension, so
- * noone else needs this to filter entries
- * when transforming archives.
- */
- if (include(bsdtar, bsdtar->optarg))
- bsdtar_errc(bsdtar, 1, 0,
- "Failed to add %s to inclusion list",
- bsdtar->optarg);
- break;
- case 'j': /* GNU tar */
-#if HAVE_LIBBZ2
- if (bsdtar->create_compression != '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt,
- bsdtar->create_compression);
- bsdtar->create_compression = opt;
-#else
- bsdtar_warnc(bsdtar, 0,
- "bzip2 compression not supported by this version of bsdtar");
- usage(bsdtar);
-#endif
- break;
- case 'J': /* GNU tar 1.21 and later */
-#if HAVE_LIBLZMA
- if (bsdtar->create_compression != '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt,
- bsdtar->create_compression);
- bsdtar->create_compression = opt;
-#else
- bsdtar_warnc(bsdtar, 0,
- "xz compression not supported by this version of bsdtar");
- usage(bsdtar);
-#endif
- break;
- case 'k': /* GNU tar */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE;
- break;
- case OPTION_KEEP_NEWER_FILES: /* GNU tar */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
- break;
- case 'L': /* BSD convention */
- bsdtar->symlink_mode = 'L';
- break;
- case 'l': /* SUSv2 and GNU tar beginning with 1.16 */
- /* GNU tar 1.13 used -l for --one-file-system */
- bsdtar->option_warn_links = 1;
- break;
- case OPTION_LZMA:
-#if HAVE_LIBLZMA
- if (bsdtar->create_compression != '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt,
- bsdtar->create_compression);
- bsdtar->create_compression = opt;
-#else
- bsdtar_warnc(bsdtar, 0,
- "lzma compression not supported by this version of bsdtar");
- usage(bsdtar);
-#endif
- break;
- case 'm': /* SUSv2 */
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_TIME;
- break;
- case 'n': /* GNU tar */
- bsdtar->option_no_subdirs = 1;
- break;
- /*
- * Selecting files by time:
- * --newer-?time='date' Only files newer than 'date'
- * --newer-?time-than='file' Only files newer than time
- * on specified file (useful for incremental backups)
- * TODO: Add corresponding "older" options to reverse these.
- */
- case OPTION_NEWER_CTIME: /* GNU tar */
- bsdtar->newer_ctime_sec = get_date(now, bsdtar->optarg);
- break;
- case OPTION_NEWER_CTIME_THAN:
- {
- struct stat st;
- if (stat(bsdtar->optarg, &st) != 0)
- bsdtar_errc(bsdtar, 1, 0,
- "Can't open file %s", bsdtar->optarg);
- bsdtar->newer_ctime_sec = st.st_ctime;
- bsdtar->newer_ctime_nsec =
- ARCHIVE_STAT_CTIME_NANOS(&st);
- }
- break;
- case OPTION_NEWER_MTIME: /* GNU tar */
- bsdtar->newer_mtime_sec = get_date(now, bsdtar->optarg);
- break;
- case OPTION_NEWER_MTIME_THAN:
- {
- struct stat st;
- if (stat(bsdtar->optarg, &st) != 0)
- bsdtar_errc(bsdtar, 1, 0,
- "Can't open file %s", bsdtar->optarg);
- bsdtar->newer_mtime_sec = st.st_mtime;
- bsdtar->newer_mtime_nsec =
- ARCHIVE_STAT_MTIME_NANOS(&st);
- }
- break;
- case OPTION_NODUMP: /* star */
- bsdtar->option_honor_nodump = 1;
- break;
- case OPTION_NO_SAME_OWNER: /* GNU tar */
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
- break;
- case OPTION_NO_SAME_PERMISSIONS: /* GNU tar */
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_PERM;
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_ACL;
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_XATTR;
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_FFLAGS;
- break;
- case OPTION_NULL: /* GNU tar */
- bsdtar->option_null++;
- break;
- case OPTION_NUMERIC_OWNER: /* GNU tar */
- bsdtar->option_numeric_owner++;
- break;
- case 'O': /* GNU tar */
- bsdtar->option_stdout = 1;
- break;
- case 'o': /* SUSv2 and GNU conflict here, but not fatally */
- option_o = 1; /* Record it and resolve it later. */
- break;
- case OPTION_ONE_FILE_SYSTEM: /* GNU tar */
- bsdtar->option_dont_traverse_mounts = 1;
- break;
-#if 0
- /*
- * The common BSD -P option is not necessary, since
- * our default is to archive symlinks, not follow
- * them. This is convenient, as -P conflicts with GNU
- * tar anyway.
- */
- case 'P': /* BSD convention */
- /* Default behavior, no option necessary. */
- break;
-#endif
- case 'P': /* GNU tar */
- bsdtar->extract_flags &= ~SECURITY;
- bsdtar->option_absolute_paths = 1;
- break;
- case 'p': /* GNU tar, star */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_PERM;
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_ACL;
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
- break;
- case OPTION_POSIX: /* GNU tar */
- bsdtar->create_format = "pax";
- break;
- case 'q': /* FreeBSD GNU tar --fast-read, NetBSD -q */
- bsdtar->option_fast_read = 1;
- break;
- case 'r': /* SUSv2 */
- set_mode(bsdtar, opt);
- break;
- case 'S': /* NetBSD pax-as-tar */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_SPARSE;
- break;
- case 's': /* NetBSD pax-as-tar */
-#if HAVE_REGEX_H
- add_substitution(bsdtar, bsdtar->optarg);
-#else
- bsdtar_warnc(bsdtar, 0,
- "-s is not supported by this version of bsdtar");
- usage(bsdtar);
-#endif
- break;
- case OPTION_SAME_OWNER: /* GNU tar */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
- break;
- case OPTION_STRIP_COMPONENTS: /* GNU tar 1.15 */
- bsdtar->strip_components = atoi(bsdtar->optarg);
- break;
- case 'T': /* GNU tar */
- bsdtar->names_from_file = bsdtar->optarg;
- break;
- case 't': /* SUSv2 */
- set_mode(bsdtar, opt);
- bsdtar->verbose++;
- break;
- case OPTION_TOTALS: /* GNU tar */
- bsdtar->option_totals++;
- break;
- case 'U': /* GNU tar */
- bsdtar->extract_flags |= ARCHIVE_EXTRACT_UNLINK;
- bsdtar->option_unlink_first = 1;
- break;
- case 'u': /* SUSv2 */
- set_mode(bsdtar, opt);
- break;
- case 'v': /* SUSv2 */
- bsdtar->verbose++;
- break;
- case OPTION_VERSION: /* GNU convention */
- version();
- break;
-#if 0
- /*
- * The -W longopt feature is handled inside of
- * bsdtar_getopt(), so -W is not available here.
- */
- case 'W': /* Obscure GNU convention. */
- break;
-#endif
- case 'w': /* SUSv2 */
- bsdtar->option_interactive = 1;
- break;
- case 'X': /* GNU tar */
- if (exclude_from_file(bsdtar, bsdtar->optarg))
- bsdtar_errc(bsdtar, 1, 0,
- "failed to process exclusions from file %s",
- bsdtar->optarg);
- break;
- case 'x': /* SUSv2 */
- set_mode(bsdtar, opt);
- break;
- case 'y': /* FreeBSD version of GNU tar */
-#if HAVE_LIBBZ2
- if (bsdtar->create_compression != '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt,
- bsdtar->create_compression);
- bsdtar->create_compression = opt;
-#else
- bsdtar_warnc(bsdtar, 0,
- "bzip2 compression not supported by this version of bsdtar");
- usage(bsdtar);
-#endif
- break;
- case 'Z': /* GNU tar */
- if (bsdtar->create_compression != '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt,
- bsdtar->create_compression);
- bsdtar->create_compression = opt;
- break;
- case 'z': /* GNU tar, star, many others */
-#if HAVE_LIBZ
- if (bsdtar->create_compression != '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt,
- bsdtar->create_compression);
- bsdtar->create_compression = opt;
-#else
- bsdtar_warnc(bsdtar, 0,
- "gzip compression not supported by this version of bsdtar");
- usage(bsdtar);
-#endif
- break;
- case OPTION_USE_COMPRESS_PROGRAM:
- bsdtar->compress_program = bsdtar->optarg;
- break;
- default:
- usage(bsdtar);
- }
- }
-
- /*
- * Sanity-check options.
- */
-
- /* If no "real" mode was specified, treat -h as --help. */
- if ((bsdtar->mode == '\0') && possible_help_request) {
- long_help(bsdtar);
- exit(0);
- }
-
- /* Otherwise, a mode is required. */
- if (bsdtar->mode == '\0')
- bsdtar_errc(bsdtar, 1, 0,
- "Must specify one of -c, -r, -t, -u, -x");
-
- /* Check boolean options only permitted in certain modes. */
- if (bsdtar->option_dont_traverse_mounts)
- only_mode(bsdtar, "--one-file-system", "cru");
- if (bsdtar->option_fast_read)
- only_mode(bsdtar, "--fast-read", "xt");
- if (bsdtar->option_honor_nodump)
- only_mode(bsdtar, "--nodump", "cru");
- if (option_o > 0) {
- switch (bsdtar->mode) {
- case 'c':
- /*
- * In GNU tar, -o means "old format." The
- * "ustar" format is the closest thing
- * supported by libarchive.
- */
- bsdtar->create_format = "ustar";
- /* TODO: bsdtar->create_format = "v7"; */
- break;
- case 'x':
- /* POSIX-compatible behavior. */
- bsdtar->option_no_owner = 1;
- bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
- break;
- default:
- only_mode(bsdtar, "-o", "xc");
- break;
- }
- }
- if (bsdtar->option_no_subdirs)
- only_mode(bsdtar, "-n", "cru");
- if (bsdtar->option_stdout)
- only_mode(bsdtar, "-O", "xt");
- if (bsdtar->option_unlink_first)
- only_mode(bsdtar, "-U", "x");
- if (bsdtar->option_warn_links)
- only_mode(bsdtar, "--check-links", "cr");
-
- /* Check other parameters only permitted in certain modes. */
- if (bsdtar->create_compression != '\0') {
- strcpy(buff, "-?");
- buff[1] = bsdtar->create_compression;
- only_mode(bsdtar, buff, "cxt");
- }
- if (bsdtar->create_format != NULL)
- only_mode(bsdtar, "--format", "cru");
- if (bsdtar->symlink_mode != '\0') {
- strcpy(buff, "-?");
- buff[1] = bsdtar->symlink_mode;
- only_mode(bsdtar, buff, "cru");
- }
- if (bsdtar->strip_components != 0)
- only_mode(bsdtar, "--strip-components", "xt");
-
- switch(bsdtar->mode) {
- case 'c':
- tar_mode_c(bsdtar);
- break;
- case 'r':
- tar_mode_r(bsdtar);
- break;
- case 't':
- tar_mode_t(bsdtar);
- break;
- case 'u':
- tar_mode_u(bsdtar);
- break;
- case 'x':
- tar_mode_x(bsdtar);
- break;
- }
-
- cleanup_exclusions(bsdtar);
-#if HAVE_REGEX_H
- cleanup_substitution(bsdtar);
-#endif
-
- if (bsdtar->return_value != 0)
- bsdtar_warnc(bsdtar, 0,
- "Error exit delayed from previous errors.");
- return (bsdtar->return_value);
-}
-
-static void
-set_mode(struct bsdtar *bsdtar, char opt)
-{
- if (bsdtar->mode != '\0' && bsdtar->mode != opt)
- bsdtar_errc(bsdtar, 1, 0,
- "Can't specify both -%c and -%c", opt, bsdtar->mode);
- bsdtar->mode = opt;
-}
-
-/*
- * Verify that the mode is correct.
- */
-static void
-only_mode(struct bsdtar *bsdtar, const char *opt, const char *valid_modes)
-{
- if (strchr(valid_modes, bsdtar->mode) == NULL)
- bsdtar_errc(bsdtar, 1, 0,
- "Option %s is not permitted in mode -%c",
- opt, bsdtar->mode);
-}
-
-
-void
-usage(struct bsdtar *bsdtar)
-{
- const char *p;
-
- p = bsdtar->progname;
-
- fprintf(stderr, "Usage:\n");
- fprintf(stderr, " List: %s -tf <archive-filename>\n", p);
- fprintf(stderr, " Extract: %s -xf <archive-filename>\n", p);
- fprintf(stderr, " Create: %s -cf <archive-filename> [filenames...]\n", p);
- fprintf(stderr, " Help: %s --help\n", p);
- exit(1);
-}
-
-static void
-version(void)
-{
- printf("bsdtar %s - %s\n",
- BSDTAR_VERSION_STRING,
- archive_version());
- exit(0);
-}
-
-static const char *long_help_msg =
- "First option must be a mode specifier:\n"
- " -c Create -r Add/Replace -t List -u Update -x Extract\n"
- "Common Options:\n"
- " -b # Use # 512-byte records per I/O block\n"
- " -f <filename> Location of archive (default " _PATH_DEFTAPE ")\n"
- " -v Verbose\n"
- " -w Interactive\n"
- "Create: %p -c [options] [<file> | <dir> | @<archive> | -C <dir> ]\n"
- " <file>, <dir> add these items to archive\n"
- " -z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma\n"
- " --format {ustar|pax|cpio|shar} Select archive format\n"
- " --exclude <pattern> Skip files that match pattern\n"
- " -C <dir> Change to <dir> before processing remaining files\n"
- " @<archive> Add entries from <archive> to output\n"
- "List: %p -t [options] [<patterns>]\n"
- " <patterns> If specified, list only entries that match\n"
- "Extract: %p -x [options] [<patterns>]\n"
- " <patterns> If specified, extract only entries that match\n"
- " -k Keep (don't overwrite) existing files\n"
- " -m Don't restore modification times\n"
- " -O Write entries to stdout, don't restore to disk\n"
- " -p Restore permissions (including ACLs, owner, file flags)\n";
-
-
-/*
- * Note that the word 'bsdtar' will always appear in the first line
- * of output.
- *
- * In particular, /bin/sh scripts that need to test for the presence
- * of bsdtar can use the following template:
- *
- * if (tar --help 2>&1 | grep bsdtar >/dev/null 2>&1 ) then \
- * echo bsdtar; else echo not bsdtar; fi
- */
-static void
-long_help(struct bsdtar *bsdtar)
-{
- const char *prog;
- const char *p;
-
- prog = bsdtar->progname;
-
- fflush(stderr);
-
- p = (strcmp(prog,"bsdtar") != 0) ? "(bsdtar)" : "";
- printf("%s%s: manipulate archive files\n", prog, p);
-
- for (p = long_help_msg; *p != '\0'; p++) {
- if (*p == '%') {
- if (p[1] == 'p') {
- fputs(prog, stdout);
- p++;
- } else
- putchar('%');
- } else
- putchar(*p);
- }
- version();
-}
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar.h b/libarchive/libarchive-2.7.1/tar/bsdtar.h
deleted file mode 100644
index 26fe0d3..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar.h
+++ /dev/null
@@ -1,174 +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/bsdtar.h,v 1.37 2008/12/06 07:37:14 kientzle Exp $
- */
-
-#include "bsdtar_platform.h"
-#include <stdio.h>
-
-#define DEFAULT_BYTES_PER_BLOCK (20*512)
-
-/*
- * The internal state for the "bsdtar" program.
- *
- * Keeping all of the state in a structure like this simplifies memory
- * leak testing (at exit, anything left on the heap is suspect). A
- * pointer to this structure is passed to most bsdtar internal
- * functions.
- */
-struct bsdtar {
- /* Options */
- const char *filename; /* -f filename */
- const char *create_format; /* -F format */
- char *pending_chdir; /* -C dir */
- const char *names_from_file; /* -T file */
- time_t newer_ctime_sec; /* --newer/--newer-than */
- long newer_ctime_nsec; /* --newer/--newer-than */
- time_t newer_mtime_sec; /* --newer-mtime */
- long newer_mtime_nsec; /* --newer-mtime-than */
- int bytes_per_block; /* -b block_size */
- int verbose; /* -v */
- int extract_flags; /* Flags for extract operation */
- int strip_components; /* Remove this many leading dirs */
- char mode; /* Program mode: 'c', 't', 'r', 'u', 'x' */
- char symlink_mode; /* H or L, per BSD conventions */
- char create_compression; /* j, y, or z */
- const char *compress_program;
- char option_absolute_paths; /* -P */
- char option_chroot; /* --chroot */
- char option_dont_traverse_mounts; /* --one-file-system */
- char option_fast_read; /* --fast-read */
- const char *option_options; /* --options */
- char option_honor_nodump; /* --nodump */
- char option_interactive; /* -w */
- char option_no_owner; /* -o */
- char option_no_subdirs; /* -n */
- char option_null; /* --null */
- char option_numeric_owner; /* --numeric-owner */
- char option_stdout; /* -O */
- char option_totals; /* --totals */
- char option_unlink_first; /* -U */
- char option_warn_links; /* --check-links */
- char day_first; /* show day before month in -tv output */
-
- /* If >= 0, then close this when done. */
- int fd;
-
- /* Miscellaneous state information */
- struct archive *archive;
- const char *progname;
- int argc;
- char **argv;
- const char *optarg;
- size_t gs_width; /* For 'list_item' in read.c */
- size_t u_width; /* for 'list_item' in read.c */
- uid_t user_uid; /* UID running this program */
- int return_value; /* Value returned by main() */
- char warned_lead_slash; /* Already displayed warning */
- char next_line_is_dir; /* Used for -C parsing in -cT */
-
- /*
- * Data for various subsystems. Full definitions are located in
- * the file where they are used.
- */
- struct archive *diskreader; /* for write.c */
- struct archive_entry_linkresolver *resolver; /* for write.c */
- struct archive_dir *archive_dir; /* for write.c */
- struct name_cache *gname_cache; /* for write.c */
- char *buff; /* for write.c */
- struct matching *matching; /* for matching.c */
- struct security *security; /* for read.c */
- struct name_cache *uname_cache; /* for write.c */
- struct siginfo_data *siginfo; /* for siginfo.c */
- struct substitution *substitution; /* for subst.c */
-};
-
-/* Fake short equivalents for long options that otherwise lack them. */
-enum {
- OPTION_CHECK_LINKS = 1,
- OPTION_CHROOT,
- OPTION_EXCLUDE,
- OPTION_FORMAT,
- OPTION_OPTIONS,
- OPTION_HELP,
- OPTION_INCLUDE,
- OPTION_KEEP_NEWER_FILES,
- OPTION_LZMA,
- OPTION_NEWER_CTIME,
- OPTION_NEWER_CTIME_THAN,
- OPTION_NEWER_MTIME,
- OPTION_NEWER_MTIME_THAN,
- OPTION_NODUMP,
- OPTION_NO_SAME_OWNER,
- OPTION_NO_SAME_PERMISSIONS,
- OPTION_NULL,
- OPTION_NUMERIC_OWNER,
- OPTION_ONE_FILE_SYSTEM,
- OPTION_POSIX,
- OPTION_SAME_OWNER,
- OPTION_STRIP_COMPONENTS,
- OPTION_TOTALS,
- OPTION_USE_COMPRESS_PROGRAM,
- OPTION_VERSION
-};
-
-
-void bsdtar_errc(struct bsdtar *, int _eval, int _code,
- const char *fmt, ...) __LA_DEAD;
-int bsdtar_getopt(struct bsdtar *);
-void bsdtar_warnc(struct bsdtar *, int _code, const char *fmt, ...);
-void cleanup_exclusions(struct bsdtar *);
-void do_chdir(struct bsdtar *);
-int edit_pathname(struct bsdtar *, struct archive_entry *);
-int exclude(struct bsdtar *, const char *pattern);
-int exclude_from_file(struct bsdtar *, const char *pathname);
-int excluded(struct bsdtar *, const char *pathname);
-int include(struct bsdtar *, const char *pattern);
-int include_from_file(struct bsdtar *, const char *pathname);
-int pathcmp(const char *a, const char *b);
-int process_lines(struct bsdtar *bsdtar, const char *pathname,
- int (*process)(struct bsdtar *, const char *));
-void safe_fprintf(FILE *, const char *fmt, ...);
-void set_chdir(struct bsdtar *, const char *newdir);
-void siginfo_init(struct bsdtar *);
-void siginfo_setinfo(struct bsdtar *, const char * oper,
- const char * path, int64_t size);
-void siginfo_printinfo(struct bsdtar *, off_t progress);
-void siginfo_done(struct bsdtar *);
-void tar_mode_c(struct bsdtar *bsdtar);
-void tar_mode_r(struct bsdtar *bsdtar);
-void tar_mode_t(struct bsdtar *bsdtar);
-void tar_mode_u(struct bsdtar *bsdtar);
-void tar_mode_x(struct bsdtar *bsdtar);
-int unmatched_inclusions(struct bsdtar *bsdtar);
-int unmatched_inclusions_warn(struct bsdtar *bsdtar, const char *msg);
-void usage(struct bsdtar *);
-int yes(const char *fmt, ...);
-
-#if HAVE_REGEX_H
-void add_substitution(struct bsdtar *, const char *);
-int apply_substitution(struct bsdtar *, const char *, char **, int);
-void cleanup_substitution(struct bsdtar *);
-#endif
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.c b/libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.c
deleted file mode 100644
index d31f112..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.c
+++ /dev/null
@@ -1,141 +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.
- *
- * $FreeBSD$
- */
-
-#if defined(__CYGWIN__)
-#define _WIN32_WINNT 0x0500
-#define WINVER 0x0500
-
-#include "bsdtar_platform.h"
-#include <errno.h>
-#include <stddef.h>
-#include <sys/utime.h>
-#include <sys/stat.h>
-#include <process.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <windows.h>
-#include <sddl.h>
-
-#include "bsdtar.h"
-
-#ifndef LIST_H
-static int
-_is_privileged(HANDLE thandle, const char *sidlist[])
-{
- TOKEN_USER *tuser;
- TOKEN_GROUPS *tgrp;
- DWORD bytes;
- PSID psid;
- DWORD i, g;
- int member;
-
- psid = NULL;
- tuser = NULL;
- tgrp = NULL;
- member = 0;
- for (i = 0; sidlist[i] != NULL && member == 0; i++) {
- if (psid != NULL)
- LocalFree(psid);
- /* mingw/cygwin: incorrectly prototypes arg 1 as LPSTR
- * instead of LPCSTR. Work around it here
- */
- if (ConvertStringSidToSidA((char *)sidlist[i], &psid) == 0) {
- errno = EPERM;
- return (-1);
- }
- if (tuser == NULL) {
- GetTokenInformation(thandle, TokenUser, NULL, 0, &bytes);
- tuser = malloc(bytes);
- if (tuser == NULL) {
- errno = ENOMEM;
- member = -1;
- break;
- }
- if (GetTokenInformation(thandle, TokenUser, tuser, bytes, &bytes) == 0) {
- errno = EPERM;
- member = -1;
- break;
- }
- }
- member = EqualSid(tuser->User.Sid, psid);
- if (member)
- break;
- if (tgrp == NULL) {
- GetTokenInformation(thandle, TokenGroups, NULL, 0, &bytes);
- tgrp = malloc(bytes);
- if (tgrp == NULL) {
- errno = ENOMEM;
- member = -1;
- break;
- }
- if (GetTokenInformation(thandle, TokenGroups, tgrp, bytes, &bytes) == 0) {
- errno = EPERM;
- member = -1;
- break;
- }
- }
- for (g = 0; g < tgrp->GroupCount; g++) {
- member = EqualSid(tgrp->Groups[g].Sid, psid);
- if (member)
- break;
- }
- }
- LocalFree(psid);
- free(tuser);
- free(tgrp);
-
- return (member);
-}
-
-int
-bsdtar_is_privileged(struct bsdtar *bsdtar)
-{
- HANDLE thandle;
- int ret;
- const char *sidlist[] = {
- "S-1-5-32-544", /* Administrators */
- "S-1-5-32-551", /* Backup Operators */
- NULL
- };
-
- (void)bsdtar;/* UNUSED */
- if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &thandle) == 0) {
- bsdtar_warnc(bsdtar, EPERM, "Failed to check privilege");
- return (0);
- }
- ret = _is_privileged(thandle, sidlist);
- if (ret < 0) {
- bsdtar_warnc(bsdtar, errno, "Failed to check privilege");
- return (0);
- }
- return (ret);
-}
-
-
-#endif /* LIST_H */
-
-#endif
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.h b/libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.h
deleted file mode 100644
index dde4c8c..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar_cygwin.h
+++ /dev/null
@@ -1,44 +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.
- *
- * $FreeBSD$
- */
-
-#ifndef BSDTAR_CYGWIN_H
-#define BSDTAR_CYGWIN_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* a foward declaration, of sorts */
-typedef struct bsdtar * struct_bsdtar_p;
-
-extern int bsdtar_is_privileged(struct bsdtar *bsdtar);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BSDTAR_CYGWIN_H */
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar_platform.h b/libarchive/libarchive-2.7.1/tar/bsdtar_platform.h
deleted file mode 100644
index 86f3442..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar_platform.h
+++ /dev/null
@@ -1,175 +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/bsdtar_platform.h,v 1.26 2008/12/06 07:37:14 kientzle Exp $
- */
-
-/*
- * This header is the first thing included in any of the bsdtar
- * source files. As far as possible, platform-specific issues should
- * be dealt with here and not within individual source files.
- */
-
-#ifndef BSDTAR_PLATFORM_H_INCLUDED
-#define BSDTAR_PLATFORM_H_INCLUDED
-
-#if defined(PLATFORM_CONFIG_H)
-/* Use hand-built config.h in environments that need it. */
-#include PLATFORM_CONFIG_H
-#elif defined(HAVE_CONFIG_H)
-/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "config.h"
-#else
-/* Warn if bsdtar hasn't been (automatically or manually) configured. */
-#error Oops: No config.h and no built-in configuration in bsdtar_platform.h.
-#endif /* !HAVE_CONFIG_H */
-
-/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
-#ifdef __FreeBSD__
-#include <sys/cdefs.h> /* For __FBSDID */
-#else
-/* Just leaving this macro replacement empty leads to a dangling semicolon. */
-#define __FBSDID(a) struct _undefined_hack
-#endif
-
-#ifdef HAVE_LIBARCHIVE
-/* If we're using the platform libarchive, include system headers. */
-#include <archive.h>
-#include <archive_entry.h>
-#else
-/* Otherwise, include user headers. */
-#include "archive.h"
-#include "archive_entry.h"
-#endif
-
-/*
- * Does this platform have complete-looking POSIX-style ACL support,
- * including some variant of the acl_get_perm() function (which was
- * omitted from the POSIX.1e draft)?
- */
-#if HAVE_SYS_ACL_H && HAVE_ACL_PERMSET_T && HAVE_ACL_USER
-#if HAVE_ACL_GET_PERM || HAVE_ACL_GET_PERM_NP
-#define HAVE_POSIX_ACL 1
-#endif
-#endif
-
-#ifdef HAVE_LIBACL
-#include <acl/libacl.h>
-#endif
-
-#if HAVE_ACL_GET_PERM
-#define ACL_GET_PERM acl_get_perm
-#else
-#if HAVE_ACL_GET_PERM_NP
-#define ACL_GET_PERM acl_get_perm_np
-#endif
-#endif
-
-/*
- * Include "dirent.h" (or it's equivalent on several different platforms).
- *
- * This is slightly modified from the GNU autoconf recipe.
- * In particular, FreeBSD includes d_namlen in it's dirent structure,
- * so my configure script includes an explicit test for the d_namlen
- * field.
- */
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# if HAVE_DIRENT_D_NAMLEN
-# define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
-# else
-# define DIRENT_NAMLEN(dirent) strlen((dirent)->d_name)
-# endif
-#else
-# define dirent direct
-# define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
-# endif
-#endif
-
-
-/*
- * We need to be able to display a filesize using printf(). The type
- * and format string here must be compatible with one another and
- * large enough for any file.
- */
-#if HAVE_UINTMAX_T
-#define BSDTAR_FILESIZE_TYPE uintmax_t
-#define BSDTAR_FILESIZE_PRINTF "%ju"
-#else
-#if HAVE_UNSIGNED_LONG_LONG
-#define BSDTAR_FILESIZE_TYPE unsigned long long
-#define BSDTAR_FILESIZE_PRINTF "%llu"
-#else
-#define BSDTAR_FILESIZE_TYPE unsigned long
-#define BSDTAR_FILESIZE_PRINTF "%lu"
-#endif
-#endif
-
-#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctimespec.tv_nsec
-#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtimespec.tv_nsec
-#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctim.tv_nsec
-#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtim.tv_nsec
-#elif HAVE_STRUCT_STAT_ST_MTIME_N
-#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_n
-#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_n
-#elif HAVE_STRUCT_STAT_ST_UMTIME
-#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_uctime * 1000
-#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_umtime * 1000
-#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
-#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_usec * 1000
-#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_usec * 1000
-#else
-#define ARCHIVE_STAT_CTIME_NANOS(st) (0)
-#define ARCHIVE_STAT_MTIME_NANOS(st) (0)
-#endif
-
-/* How to mark functions that don't return. */
-/* This facilitates use of some newer static code analysis tools. */
-#undef __LA_DEAD
-#if defined(__GNUC__) && (__GNUC__ > 2 || \
- (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define __LA_DEAD __attribute__((__noreturn__))
-#else
-#define __LA_DEAD
-#endif
-
-#if defined(__CYGWIN__)
-#include "bsdtar_cygwin.h"
-#elif defined(_WIN32) /* && !__CYGWIN__ */
-#include "bsdtar_windows.h"
-#else
-#define bsdtar_is_privileged(bsdtar) (bsdtar->user_uid == 0)
-#endif
-
-#endif /* !BSDTAR_PLATFORM_H_INCLUDED */
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar_windows.c b/libarchive/libarchive-2.7.1/tar/bsdtar_windows.c
deleted file mode 100644
index c4e77b4..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar_windows.c
+++ /dev/null
@@ -1,1213 +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.
- *
- * $FreeBSD$
- */
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define _WIN32_WINNT 0x0500
-#define WINVER 0x0500
-
-#include "bsdtar_platform.h"
-#include <errno.h>
-#include <stddef.h>
-#include <sys/utime.h>
-#include <sys/stat.h>
-#include <process.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <windows.h>
-#include <sddl.h>
-
-#include "bsdtar.h"
-
-#define EPOC_TIME (116444736000000000ULL)
-
-struct ustat {
- int64_t st_atime;
- uint32_t st_atime_nsec;
- int64_t st_ctime;
- uint32_t st_ctime_nsec;
- int64_t st_mtime;
- uint32_t st_mtime_nsec;
- gid_t st_gid;
- /* 64bits ino */
- int64_t st_ino;
- mode_t st_mode;
- uint32_t st_nlink;
- uint64_t st_size;
- uid_t st_uid;
- dev_t st_dev;
- dev_t st_rdev;
-};
-
-struct __DIR {
- HANDLE handle;
- WIN32_FIND_DATAW fileData;
- struct dirent de;
- int first;
- BOOL finished;
-};
-
-/* Transform 64-bits ino into 32-bits by hashing.
- * You do not forget that really unique number size is 64-bits.
- */
-#define INOSIZE (8*sizeof(ino_t)) /* 32 */
-static __inline ino_t
-getino(struct ustat *ub)
-{
- ULARGE_INTEGER ino64;
-
- ino64.QuadPart = ub->st_ino;
- /* I don't know this hashing is correct way */
- return (ino64.LowPart ^ (ino64.LowPart >> INOSIZE));
-}
-
-/*
- * Prepend "\\?\" to the path name and convert it to unicode to permit
- * an extended-length path for a maximum total path length of 32767
- * characters.
- * see also http://msdn.microsoft.com/en-us/library/aa365247.aspx
- */
-static wchar_t *
-permissive_name(const char *name)
-{
- wchar_t *wn, *wnp;
- wchar_t *ws, *wsp;
- size_t l, len, slen;
- int unc;
-
- len = strlen(name);
- wn = malloc((len + 1) * sizeof(wchar_t));
- if (wn == NULL)
- return (NULL);
- l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len);
- if (l == 0) {
- free(wn);
- return (NULL);
- }
- wn[l] = L'\0';
-
- /* Get a full path names */
- l = GetFullPathNameW(wn, 0, NULL, NULL);
- if (l == 0) {
- free(wn);
- return (NULL);
- }
- wnp = malloc(l * sizeof(wchar_t));
- if (wnp == NULL) {
- free(wn);
- return (NULL);
- }
- len = GetFullPathNameW(wn, l, wnp, NULL);
- free(wn);
- wn = wnp;
-
- if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
- wnp[2] == L'?' && wnp[3] == L'\\')
- /* We have already permissive names. */
- return (wn);
-
- if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
- wnp[2] == L'.' && wnp[3] == L'\\') {
- /* Device names */
- if (((wnp[4] >= L'a' && wnp[4] <= L'z') ||
- (wnp[4] >= L'A' && wnp[4] <= L'Z')) &&
- wnp[5] == L':' && wnp[6] == L'\\')
- wnp[2] = L'?';/* Not device names. */
- return (wn);
- }
-
- unc = 0;
- if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') {
- wchar_t *p = &wnp[2];
-
- /* Skip server-name letters. */
- while (*p != L'\\' && *p != L'\0')
- ++p;
- if (*p == L'\\') {
- wchar_t *rp = ++p;
- /* Skip share-name letters. */
- while (*p != L'\\' && *p != L'\0')
- ++p;
- if (*p == L'\\' && p != rp) {
- /* Now, match patterns such as
- * "\\server-name\share-name\" */
- wnp += 2;
- len -= 2;
- unc = 1;
- }
- }
- }
-
- slen = 4 + (unc * 4) + len + 1;
- ws = wsp = malloc(slen * sizeof(wchar_t));
- if (ws == NULL) {
- free(wn);
- return (NULL);
- }
- /* prepend "\\?\" */
- wcsncpy(wsp, L"\\\\?\\", 4);
- wsp += 4;
- slen -= 4;
- if (unc) {
- /* append "UNC\" ---> "\\?\UNC\" */
- wcsncpy(wsp, L"UNC\\", 4);
- wsp += 4;
- slen -= 4;
- }
- wcsncpy_s(wsp, slen, wnp, _TRUNCATE);
- free(wn);
- return (ws);
-}
-
-static HANDLE
-la_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
- LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
- DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
-{
- wchar_t *wpath;
- HANDLE handle;
-
- handle = CreateFileA(path, dwDesiredAccess, dwShareMode,
- lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
- hTemplateFile);
- if (handle != INVALID_HANDLE_VALUE)
- return (handle);
- if (GetLastError() != ERROR_PATH_NOT_FOUND)
- return (handle);
- wpath = permissive_name(path);
- if (wpath == NULL)
- return (handle);
- handle = CreateFileW(wpath, dwDesiredAccess, dwShareMode,
- lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
- hTemplateFile);
- free(wpath);
- return (handle);
-}
-
-static size_t
-wequallen(const wchar_t *s1, const wchar_t *s2)
-{
- size_t i = 0;
-
- while (*s1 != L'\0' && *s2 != L'\0' && *s1 == *s2) {
- ++s1; ++s2; ++i;
- }
- return (i);
-}
-
-/* Check that path1 and path2 can be hard-linked by each other.
- * Both arguments must be made by permissive_name function.
- */
-static int
-canHardLinkW(const wchar_t *path1, const wchar_t *path2)
-{
- wchar_t root[MAX_PATH];
- wchar_t fs[32];
- const wchar_t *s;
- int r;
-
- r = wequallen(path1, path2);
- /* Is volume-name the same? */
- if (r < 7)
- return (0);
- if (wcsncmp(path1, L"\\\\?\\UNC\\", 8) == 0) {
- int len;
-
- s = path1 + 8;
- if (*s == L'\\')
- return (0);
- /* 012345678
- * Name : "\\?\UNC\Server\Share\"
- * ^ search
- */
- s = wcschr(++s, L'\\');
- if (s == NULL)
- return (0);
- if (*++s == L'\\')
- return (0);
- /* 012345678
- * Name : "\\?\UNC\Server\Share\"
- * ^ search
- */
- s = wcschr(++s, L'\\');
- if (s == NULL)
- return (0);
- s++;
- /* 012345678
- * Name : "\\?\UNC\Server\Share\xxxx"
- * ^--- len ----^
- */
- len = (int)(s - path1 - 8);
- /* Is volume-name the same? */
- if (r < len + 8)
- return (0);
- /* Is volume-name too long? */
- if (sizeof(root) -3 < len)
- return (0);
- root[0] = root[1] = L'\\';
- wcsncpy(root + 2, path1 + 8 , len);
- /* root : "\\Server\Share\" */
- root[2 + len] = L'\0';
- } else if (wcsncmp(path1, L"\\\\?\\", 4) == 0) {
- s = path1 + 4;
- if ((!iswalpha(*s)) || s[1] != L':' || s[2] != L'\\')
- return (0);
- wcsncpy(root, path1 + 4, 3);
- root[3] = L'\0';
- } else
- return (0);
- if (!GetVolumeInformationW(root, NULL, 0, NULL, NULL, NULL, fs, sizeof(fs)))
- return (0);
- if (wcscmp(fs, L"NTFS") == 0)
- return (1);
- else
- return (0);
-}
-
-/* Make a link to src called dst. */
-static int
-__link(const char *src, const char *dst, int sym)
-{
- wchar_t *wsrc, *wdst;
- int res, retval;
- DWORD attr;
-
- if (src == NULL || dst == NULL) {
- set_errno (EINVAL);
- return -1;
- }
-
- wsrc = permissive_name(src);
- wdst = permissive_name(dst);
- if (wsrc == NULL || wdst == NULL) {
- if (wsrc != NULL)
- free(wsrc);
- if (wdst != NULL)
- free(wdst);
- set_errno (EINVAL);
- return -1;
- }
-
- if ((attr = GetFileAttributesW(wsrc)) != -1) {
- if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- errno = EPERM;
- retval = -1;
- goto exit;
- }
- if (!sym && canHardLinkW(wsrc, wdst))
- res = CreateHardLinkW(wdst, wsrc, NULL);
- else
- res = CopyFileW(wsrc, wdst, FALSE);
- } else {
- /* wsrc does not exist; try src prepend it with the dirname of wdst */
- wchar_t *wnewsrc, *slash;
- int i, n, slen, wlen;
-
- if (strlen(src) >= 3 && isalpha((unsigned char)src[0]) &&
- src[1] == ':' && src[2] == '\\') {
- /* Original src name is already full-path */
- retval = -1;
- goto exit;
- }
- if (src[0] == '\\') {
- /* Original src name is almost full-path
- * (maybe src name is without drive) */
- retval = -1;
- goto exit;
- }
-
- wnewsrc = malloc ((wcslen(wsrc) + wcslen(wdst) + 1) * sizeof(wchar_t));
- if (wnewsrc == NULL) {
- errno = ENOMEM;
- retval = -1;
- goto exit;
- }
- /* Copying a dirname of wdst */
- wcscpy(wnewsrc, wdst);
- slash = wcsrchr(wnewsrc, L'\\');
- if (slash != NULL)
- *++slash = L'\0';
- else
- wcscat(wnewsrc, L"\\");
- /* Converting multi-byte src to wide-char src */
- wlen = wcslen(wsrc);
- slen = strlen(src);
- n = MultiByteToWideChar(CP_ACP, 0, src, slen, wsrc, slen);
- if (n == 0) {
- free (wnewsrc);
- retval = -1;
- goto exit;
- }
- for (i = 0; i < n; i++)
- if (wsrc[i] == L'/')
- wsrc[i] = L'\\';
- wcsncat(wnewsrc, wsrc, n);
- /* Check again */
- attr = GetFileAttributesW(wnewsrc);
- if (attr == -1 || (attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- if (attr == -1)
- _dosmaperr(GetLastError());
- else
- errno = EPERM;
- free (wnewsrc);
- retval = -1;
- goto exit;
- }
- if (!sym && canHardLinkW(wnewsrc, wdst))
- res = CreateHardLinkW(wdst, wnewsrc, NULL);
- else
- res = CopyFileW(wnewsrc, wdst, FALSE);
- free (wnewsrc);
- }
- if (res == 0) {
- _dosmaperr(GetLastError());
- retval = -1;
- } else
- retval = 0;
-exit:
- free(wsrc);
- free(wdst);
- return (retval);
-}
-
-/* Make a hard link to src called dst. */
-int
-link(const char *src, const char *dst)
-{
- return __link (src, dst, 0);
-}
-
-/* Make a symbolic link to FROM called TO. */
-int symlink (from, to)
- const char *from;
- const char *to;
-{
- return __link (from, to, 1);
-}
-
-int
-ftruncate(int fd, off_t length)
-{
- LARGE_INTEGER distance;
- HANDLE handle;
-
- if (fd < 0) {
- errno = EBADF;
- return (-1);
- }
- handle = (HANDLE)_get_osfhandle(fd);
- if (GetFileType(handle) != FILE_TYPE_DISK) {
- errno = EBADF;
- return (-1);
- }
- distance.QuadPart = length;
- if (!SetFilePointerEx(handle, distance, NULL, FILE_BEGIN)) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- if (!SetEndOfFile(handle)) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- return (0);
-}
-
-DIR *
-__opendir(const char *path, int ff)
-{
- DIR *dir;
- wchar_t *wpath, *wfname;
- size_t wlen;
-
- dir = malloc(sizeof(*dir));
- if (dir == NULL) {
- errno = ENOMEM;
- return (NULL);
- }
-
- wpath = permissive_name(path);
- if (wpath == NULL) {
- errno = EINVAL;
- free(dir);
- return (NULL);
- }
- if (ff) {
- wfname = wpath;
- wpath = NULL;
- } else {
- wlen = wcslen(wpath);
- wfname = malloc((wlen + 3) * sizeof(wchar_t));
- if (wfname == NULL) {
- errno = ENOMEM;
- free(dir);
- free(wpath);
- return (NULL);
- }
- wcscpy(wfname, wpath);
- wcscat(wfname, L"\\*");
- free(wpath);
- }
-
- dir->handle = FindFirstFileW(wfname, &dir->fileData);
- if (dir->handle == INVALID_HANDLE_VALUE) {
- _dosmaperr(GetLastError());
- free(dir);
- free(wfname);
- return (NULL);
- }
- dir->first = 1;
- dir->finished = FALSE;
- free(wfname);
-
- return (dir);
-}
-
-static DIR *
-opendir_findfile(const char *path)
-{
- return (__opendir(path, 1));
-}
-
-DIR *
-opendir(const char *path)
-{
- return (__opendir(path, 0));
-}
-
-struct dirent *
-readdir(DIR *dirp)
-{
- size_t len;
-
- while (!dirp->finished) {
- if (!dirp->first && !FindNextFileW(dirp->handle, &dirp->fileData)) {
- if (GetLastError() != ERROR_NO_MORE_FILES)
- _dosmaperr(GetLastError());
- dirp->finished = TRUE;
- break;
- }
- dirp->first = 0;
- len = wcstombs(dirp->de.d_name, dirp->fileData.cFileName,
- sizeof(dirp->de.d_name) -1);
- if (len == -1) {
- errno = EINVAL;
- dirp->finished = TRUE;
- break;
- }
- dirp->de.d_name[len] = '\0';
- dirp->de.d_nameln = strlen(dirp->de.d_name);
- return (&dirp->de);
- }
-
- return (NULL);
-}
-
-int
-closedir(DIR *dirp)
-{
- BOOL ret;
-
- ret = FindClose(dirp->handle);
- free(dirp);
- if (ret == 0) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- return (0);
-}
-
-int
-la_chdir(const char *path)
-{
- wchar_t *ws;
- int r;
-
- r = SetCurrentDirectoryA(path);
- if (r == 0) {
- if (GetLastError() != ERROR_FILE_NOT_FOUND) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- } else
- return (0);
- ws = permissive_name(path);
- if (ws == NULL) {
- errno = EINVAL;
- return (-1);
- }
- r = SetCurrentDirectoryW(ws);
- free(ws);
- if (r == 0) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- return (0);
-}
-
-__int64
-la_lseek(int fd, __int64 offset, int whence)
-{
- LARGE_INTEGER distance;
- LARGE_INTEGER newpointer;
- HANDLE handle;
-
- if (fd < 0) {
- errno = EBADF;
- return (-1);
- }
- handle = (HANDLE)_get_osfhandle(fd);
- if (GetFileType(handle) != FILE_TYPE_DISK) {
- errno = EBADF;
- return (-1);
- }
- distance.QuadPart = offset;
- if (!SetFilePointerEx(handle, distance, &newpointer, whence)) {
- DWORD lasterr;
-
- lasterr = GetLastError();
- if (lasterr == ERROR_BROKEN_PIPE)
- return (0);
- if (lasterr == ERROR_ACCESS_DENIED)
- errno = EBADF;
- else
- _dosmaperr(lasterr);
- return (-1);
- }
- return (newpointer.QuadPart);
-}
-
-int
-la_mkdir(const char *path, mode_t mode)
-{
- wchar_t *ws;
- int r;
-
- (void)mode;/* UNUSED */
- r = CreateDirectoryA(path, NULL);
- if (r == 0) {
- DWORD lasterr = GetLastError();
- if (lasterr != ERROR_FILENAME_EXCED_RANGE &&
- lasterr != ERROR_PATH_NOT_FOUND) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- } else
- return (0);
- ws = permissive_name(path);
- if (ws == NULL) {
- errno = EINVAL;
- return (-1);
- }
- r = CreateDirectoryW(ws, NULL);
- free(ws);
- if (r == 0) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- return (0);
-}
-
-/* Windows' mbstowcs is differrent error handling from other unix mbstowcs.
- * That one is using MultiByteToWideChar function with MB_PRECOMPOSED and
- * MB_ERR_INVALID_CHARS flags.
- * This implements for only to pass libarchive_test.
- */
-size_t
-la_mbstowcs(wchar_t *wcstr, const char *mbstr, size_t nwchars)
-{
-
- return (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
- mbstr, (int)strlen(mbstr), wcstr,
- (int)nwchars));
-}
-
-int
-la_open(const char *path, int flags, ...)
-{
- va_list ap;
- wchar_t *ws;
- int r, pmode;
- DWORD attr;
-
- va_start(ap, flags);
- pmode = va_arg(ap, int);
- va_end(ap);
- ws = NULL;
- if ((flags & ~O_BINARY) == O_RDONLY) {
- /*
- * When we open a directory, _open function returns
- * "Permission denied" error.
- */
- attr = GetFileAttributesA(path);
- if (attr == -1 && GetLastError() == ERROR_PATH_NOT_FOUND) {
- ws = permissive_name(path);
- if (ws == NULL) {
- errno = EINVAL;
- return (-1);
- }
- attr = GetFileAttributesW(ws);
- }
- if (attr == -1) {
- _dosmaperr(GetLastError());
- free(ws);
- return (-1);
- }
- if (attr & FILE_ATTRIBUTE_DIRECTORY) {
- HANDLE handle;
-
- if (ws != NULL)
- handle = CreateFileW(ws, 0, 0, NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS |
- FILE_ATTRIBUTE_READONLY,
- NULL);
- else
- handle = CreateFileA(path, 0, 0, NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS |
- FILE_ATTRIBUTE_READONLY,
- NULL);
- free(ws);
- if (handle == INVALID_HANDLE_VALUE) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- r = _open_osfhandle((intptr_t)handle, _O_RDONLY);
- return (r);
- }
- }
- if (ws == NULL) {
- r = _open(path, flags, pmode);
- if (r < 0 && errno == EACCES && (flags & O_CREAT) != 0) {
- /* simular other POSIX system action to pass a test */
- attr = GetFileAttributesA(path);
- if (attr == -1)
- _dosmaperr(GetLastError());
- else if (attr & FILE_ATTRIBUTE_DIRECTORY)
- errno = EISDIR;
- else
- errno = EACCES;
- return (-1);
- }
- if (r >= 0 || errno != ENOENT)
- return (r);
- ws = permissive_name(path);
- if (ws == NULL) {
- errno = EINVAL;
- return (-1);
- }
- }
- r = _wopen(ws, flags, pmode);
- if (r < 0 && errno == EACCES && (flags & O_CREAT) != 0) {
- /* simular other POSIX system action to pass a test */
- attr = GetFileAttributesW(ws);
- if (attr == -1)
- _dosmaperr(GetLastError());
- else if (attr & FILE_ATTRIBUTE_DIRECTORY)
- errno = EISDIR;
- else
- errno = EACCES;
- }
- free(ws);
- return (r);
-}
-
-ssize_t
-la_read(int fd, void *buf, size_t nbytes)
-{
- HANDLE handle;
- DWORD bytes_read, lasterr;
- int r;
-
-#ifdef _WIN64
- if (nbytes > UINT32_MAX)
- nbytes = UINT32_MAX;
-#endif
- if (fd < 0) {
- errno = EBADF;
- return (-1);
- }
- handle = (HANDLE)_get_osfhandle(fd);
- if (GetFileType(handle) == FILE_TYPE_PIPE) {
- DWORD sta;
- if (GetNamedPipeHandleState(
- handle, &sta, NULL, NULL, NULL, NULL, 0) != 0 &&
- (sta & PIPE_NOWAIT) == 0) {
- DWORD avail = -1;
- int cnt = 3;
-
- while (PeekNamedPipe(
- handle, NULL, 0, NULL, &avail, NULL) != 0 &&
- avail == 0 && --cnt)
- Sleep(100);
- if (avail == 0)
- return (0);
- }
- }
- r = ReadFile(handle, buf, (uint32_t)nbytes,
- &bytes_read, NULL);
- if (r == 0) {
- lasterr = GetLastError();
- if (lasterr == ERROR_NO_DATA) {
- errno = EAGAIN;
- return (-1);
- }
- if (lasterr == ERROR_BROKEN_PIPE)
- return (0);
- if (lasterr == ERROR_ACCESS_DENIED)
- errno = EBADF;
- else
- _dosmaperr(lasterr);
- return (-1);
- }
- return ((ssize_t)bytes_read);
-}
-
-/* Remove directory */
-int
-la_rmdir(const char *path)
-{
- wchar_t *ws;
- int r;
-
- r = _rmdir(path);
- if (r >= 0 || errno != ENOENT)
- return (r);
- ws = permissive_name(path);
- if (ws == NULL) {
- errno = EINVAL;
- return (-1);
- }
- r = _wrmdir(ws);
- free(ws);
- return (r);
-}
-
-/* Convert Windows FILETIME to UTC */
-__inline static void
-fileTimeToUTC(const FILETIME *filetime, time_t *time, long *ns)
-{
- ULARGE_INTEGER utc;
-
- utc.HighPart = filetime->dwHighDateTime;
- utc.LowPart = filetime->dwLowDateTime;
- if (utc.QuadPart >= EPOC_TIME) {
- utc.QuadPart -= EPOC_TIME;
- *time = (time_t)(utc.QuadPart / 10000000); /* milli seconds base */
- *ns = (long)(utc.QuadPart % 10000000) * 100;/* nano seconds base */
- } else {
- *time = 0;
- *ns = 0;
- }
-}
-
-/* Stat by handle
- * Windows' stat() does not accept path which is added "\\?\" especially "?"
- * character.
- * It means we cannot access a long name path(which is longer than MAX_PATH).
- * So I've implemented simular Windows' stat() to access the long name path.
- * And I've added some feature.
- * 1. set st_ino by nFileIndexHigh and nFileIndexLow of
- * BY_HANDLE_FILE_INFORMATION.
- * 2. set st_nlink by nNumberOfLinks of BY_HANDLE_FILE_INFORMATION.
- * 3. set st_dev by dwVolumeSerialNumber by BY_HANDLE_FILE_INFORMATION.
- */
-static int
-__hstat(HANDLE handle, struct ustat *st)
-{
- BY_HANDLE_FILE_INFORMATION info;
- ULARGE_INTEGER ino64;
- DWORD ftype;
- mode_t mode;
- time_t time;
- long ns;
-
- switch (ftype = GetFileType(handle)) {
- case FILE_TYPE_UNKNOWN:
- errno = EBADF;
- return (-1);
- case FILE_TYPE_CHAR:
- case FILE_TYPE_PIPE:
- if (ftype == FILE_TYPE_CHAR) {
- st->st_mode = S_IFCHR;
- st->st_size = 0;
- } else {
- DWORD avail;
-
- st->st_mode = S_IFIFO;
- if (PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL))
- st->st_size = avail;
- else
- st->st_size = 0;
- }
- st->st_atime = 0;
- st->st_atime_nsec = 0;
- st->st_mtime = 0;
- st->st_mtime_nsec = 0;
- st->st_ctime = 0;
- st->st_ctime_nsec = 0;
- st->st_ino = 0;
- st->st_nlink = 1;
- st->st_uid = 0;
- st->st_gid = 0;
- st->st_rdev = 0;
- st->st_dev = 0;
- return (0);
- case FILE_TYPE_DISK:
- break;
- default:
- /* This ftype is undocumented type. */
- _dosmaperr(GetLastError());
- return (-1);
- }
-
- ZeroMemory(&info, sizeof(info));
- if (!GetFileInformationByHandle (handle, &info)) {
- _dosmaperr(GetLastError());
- return (-1);
- }
-
- mode = S_IRUSR | S_IRGRP | S_IROTH;
- if ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0)
- mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
- else
- mode |= S_IFREG;
- st->st_mode = mode;
-
- fileTimeToUTC(&info.ftLastAccessTime, &time, &ns);
- st->st_atime = time;
- st->st_atime_nsec = ns;
- fileTimeToUTC(&info.ftLastWriteTime, &time, &ns);
- st->st_mtime = time;
- st->st_mtime_nsec = ns;
- fileTimeToUTC(&info.ftCreationTime, &time, &ns);
- st->st_ctime = time;
- st->st_ctime_nsec = ns;
- st->st_size =
- ((int64_t)(info.nFileSizeHigh) * ((int64_t)MAXDWORD + 1))
- + (int64_t)(info.nFileSizeLow);
-#ifdef SIMULATE_WIN_STAT
- st->st_ino = 0;
- st->st_nlink = 1;
- st->st_dev = 0;
-#else
- /* Getting FileIndex as i-node. We have to remove a sequence which
- * is high-16-bits of nFileIndexHigh. */
- ino64.HighPart = info.nFileIndexHigh & 0x0000FFFFUL;
- ino64.LowPart = info.nFileIndexLow;
- st->st_ino = ino64.QuadPart;
- st->st_nlink = info.nNumberOfLinks;
- if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- ++st->st_nlink;/* Add parent directory. */
- st->st_dev = info.dwVolumeSerialNumber;
-#endif
- st->st_uid = 0;
- st->st_gid = 0;
- st->st_rdev = 0;
- return (0);
-}
-
-static void
-copy_stat(struct stat *st, struct ustat *us)
-{
- st->st_atime = us->st_atime;
- st->st_ctime = us->st_ctime;
- st->st_mtime = us->st_mtime;
- st->st_gid = us->st_gid;
- st->st_ino = getino(us);
- st->st_mode = us->st_mode;
- st->st_nlink = us->st_nlink;
- st->st_size = us->st_size;
- st->st_uid = us->st_uid;
- st->st_dev = us->st_dev;
- st->st_rdev = us->st_rdev;
-}
-
-int
-la_fstat(int fd, struct stat *st)
-{
- struct ustat u;
- int ret;
-
- if (fd < 0) {
- errno = EBADF;
- return (-1);
- }
- ret = __hstat((HANDLE)_get_osfhandle(fd), &u);
- if (ret >= 0) {
- copy_stat(st, &u);
- if (u.st_mode & (S_IFCHR | S_IFIFO)) {
- st->st_dev = fd;
- st->st_rdev = fd;
- }
- }
- return (ret);
-}
-
-int
-la_stat(const char *path, struct stat *st)
-{
- HANDLE handle;
- struct ustat u;
- int ret;
-
- handle = la_CreateFile(path, 0, 0, NULL, OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_READONLY,
- NULL);
- if (handle == INVALID_HANDLE_VALUE) {
- _dosmaperr(GetLastError());
- return (-1);
- }
- ret = __hstat(handle, &u);
- CloseHandle(handle);
- if (ret >= 0) {
- char *p;
-
- copy_stat(st, &u);
- p = strrchr(path, '.');
- if (p != NULL && strlen(p) == 4) {
- char exttype[4];
-
- ++ p;
- exttype[0] = toupper(*p++);
- exttype[1] = toupper(*p++);
- exttype[2] = toupper(*p++);
- exttype[3] = '\0';
- if (!strcmp(exttype, "EXE") || !strcmp(exttype, "CMD") ||
- !strcmp(exttype, "BAT") || !strcmp(exttype, "COM"))
- st->st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
- }
- }
- return (ret);
-}
-
-ssize_t
-la_write(int fd, const void *buf, size_t nbytes)
-{
- uint32_t bytes_written;
-
-#ifdef _WIN64
- if (nbytes > UINT32_MAX)
- nbytes = UINT32_MAX;
-#endif
- if (fd < 0) {
- errno = EBADF;
- return (-1);
- }
- if (!WriteFile((HANDLE)_get_osfhandle(fd), buf, (uint32_t)nbytes,
- &bytes_written, NULL)) {
- DWORD lasterr;
-
- lasterr = GetLastError();
- if (lasterr == ERROR_ACCESS_DENIED)
- errno = EBADF;
- else
- _dosmaperr(lasterr);
- return (-1);
- }
- return (bytes_written);
-}
-
-#ifndef LIST_H
-static int
-_is_privileged(HANDLE thandle, const char *sidlist[])
-{
- TOKEN_USER *tuser;
- TOKEN_GROUPS *tgrp;
- DWORD bytes;
- PSID psid;
- DWORD i, g;
- int member;
-
- psid = NULL;
- tuser = NULL;
- tgrp = NULL;
- member = 0;
- for (i = 0; sidlist[i] != NULL && member == 0; i++) {
- if (psid != NULL)
- LocalFree(psid);
- if (ConvertStringSidToSidA(sidlist[i], &psid) == 0) {
- errno = EPERM;
- return (-1);
- }
- if (tuser == NULL) {
- GetTokenInformation(thandle, TokenUser, NULL, 0, &bytes);
- tuser = malloc(bytes);
- if (tuser == NULL) {
- errno = ENOMEM;
- member = -1;
- break;
- }
- if (GetTokenInformation(thandle, TokenUser, tuser, bytes, &bytes) == 0) {
- errno = EPERM;
- member = -1;
- break;
- }
- }
- member = EqualSid(tuser->User.Sid, psid);
- if (member)
- break;
- if (tgrp == NULL) {
- GetTokenInformation(thandle, TokenGroups, NULL, 0, &bytes);
- tgrp = malloc(bytes);
- if (tgrp == NULL) {
- errno = ENOMEM;
- member = -1;
- break;
- }
- if (GetTokenInformation(thandle, TokenGroups, tgrp, bytes, &bytes) == 0) {
- errno = EPERM;
- member = -1;
- break;
- }
- }
- for (g = 0; g < tgrp->GroupCount; g++) {
- member = EqualSid(tgrp->Groups[g].Sid, psid);
- if (member)
- break;
- }
- }
- LocalFree(psid);
- free(tuser);
- free(tgrp);
-
- return (member);
-}
-
-int
-bsdtar_is_privileged(struct bsdtar *bsdtar)
-{
- HANDLE thandle;
- int ret;
- const char *sidlist[] = {
- "S-1-5-32-544", /* Administrators */
- "S-1-5-32-551", /* Backup Operators */
- NULL
- };
-
- (void)bsdtar;/* UNUSED */
- if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &thandle) == 0) {
- bsdtar_warnc(bsdtar, EPERM, "Failed to check privilege");
- return (0);
- }
- ret = _is_privileged(thandle, sidlist);
- if (ret < 0) {
- bsdtar_warnc(bsdtar, errno, "Failed to check privilege");
- return (0);
- }
- return (ret);
-}
-
-/*
- * Note: We should use wide-character for findng '\' character,
- * a directory separator on Windows, because some character-set have
- * been using the '\' character for a part of its multibyte character
- * code.
- */
-static size_t
-dir_len_w(const char *path)
-{
- wchar_t wc;
- const char *p, *rp;
- size_t al, l, size;
-
- al = l = -1;
- for (p = path; *p != '\0'; ++p) {
- if (*p == '\\')
- al = l = p - path;
- else if (*p == '/')
- al = p - path;
- }
- if (l == -1)
- goto alen;
- size = p - path;
- rp = p = path;
- while (*p != '\0') {
- l = mbtowc(&wc, p, size);
- if (l == -1)
- goto alen;
- if (l == 1 && (wc == L'/' || wc == L'\\'))
- rp = p;
- p += l;
- size -= l;
- }
- return (rp - path + 1);
-alen:
- if (al == -1)
- return (0);
- return (al + 1);
-}
-
-/*
- * Find file names and call write_hierarchy function.
- */
-void
-write_hierarchy_win(struct bsdtar *bsdtar, struct archive *a,
- const char *path, void (*write_hierarchy)(struct bsdtar *bsdtar,
- struct archive *a, const char *path))
-{
- DIR *dir;
- struct dirent *ent;
- const char *r;
- char *xpath;
- size_t dl;
-
- r = path;
- while (*r != '\0' && *r != '*' && *r != '?')
- ++r;
- if (*r == '\0')
- /* There aren't meta-characters '*' and '?' in path */
- goto try_plain;
- dir = opendir_findfile(path);
- if (dir == NULL)
- goto try_plain;
- dl = dir_len_w(path);
- xpath = malloc(dl + MAX_PATH);
- if (xpath == NULL)
- goto try_plain;
- strncpy(xpath, path, dl);
- while ((ent = readdir(dir)) != NULL) {
- if (ent->d_name[0] == '.' && ent->d_name[1] == '\0')
- continue;
- if (ent->d_name[0] == '.' && ent->d_name[1] == '.' &&
- ent->d_name[2] == '\0')
- continue;
- strcpy(&xpath[dl], ent->d_name);
- write_hierarchy(bsdtar, a, xpath);
- }
- free(xpath);
- closedir(dir);
- return;
-
-try_plain:
- write_hierarchy(bsdtar, a, path);
-}
-
-#endif /* LIST_H */
-
-#endif
diff --git a/libarchive/libarchive-2.7.1/tar/bsdtar_windows.h b/libarchive/libarchive-2.7.1/tar/bsdtar_windows.h
deleted file mode 100644
index 5dfe02c..0000000
--- a/libarchive/libarchive-2.7.1/tar/bsdtar_windows.h
+++ /dev/null
@@ -1,59 +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.
- *
- * $FreeBSD$
- */
-
-#ifndef BSDTAR_WINDOWS_H
-#define BSDTAR_WINDOWS_H 1
-
-#define PRId64 "I64"
-#define geteuid() 0
-
-struct __DIR;
-typedef struct __DIR DIR;
-struct direct {
- unsigned char d_nameln;
- char d_name[MAX_PATH];
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern DIR *opendir(const char *path);
-extern struct dirent *readdir(DIR *dirp);
-extern int closedir(DIR *dirp);
-
-extern int bsdtar_is_privileged(struct bsdtar *bsdtar);
-extern void write_hierarchy_win(struct bsdtar *bsdtar, struct archive *a,
- const char *path,
- void (*write_hierarchy)(struct bsdtar *bsdtar,
- struct archive *a, const char *path));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BSDTAR_WINDOWS_H */
diff --git a/libarchive/libarchive-2.7.1/tar/cmdline.c b/libarchive/libarchive-2.7.1/tar/cmdline.c
deleted file mode 100644
index efaeafd..0000000
--- a/libarchive/libarchive-2.7.1/tar/cmdline.c
+++ /dev/null
@@ -1,380 +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.
- */
-
-/*
- * Command line parser for tar.
- */
-
-#include "bsdtar_platform.h"
-__FBSDID("$FreeBSD$");
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include "bsdtar.h"
-
-/*
- * Short options for tar. Please keep this sorted.
- */
-static const char *short_options
- = "Bb:C:cf:HhI:JjkLlmnOoPpqrSs:T:tUuvW:wX:xyZz";
-
-/*
- * Long options for tar. Please keep this list sorted.
- *
- * The symbolic names for options that lack a short equivalent are
- * defined in bsdtar.h. Also note that so far I've found no need
- * to support optional arguments to long options. That would be
- * a small change to the code below.
- */
-
-static struct option {
- const char *name;
- int required; /* 1 if this option requires an argument. */
- int equivalent; /* Equivalent short option. */
-} tar_longopts[] = {
- { "absolute-paths", 0, 'P' },
- { "append", 0, 'r' },
- { "block-size", 1, 'b' },
- { "bunzip2", 0, 'j' },
- { "bzip", 0, 'j' },
- { "bzip2", 0, 'j' },
- { "cd", 1, 'C' },
- { "check-links", 0, OPTION_CHECK_LINKS },
- { "chroot", 0, OPTION_CHROOT },
- { "compress", 0, 'Z' },
- { "confirmation", 0, 'w' },
- { "create", 0, 'c' },
- { "dereference", 0, 'L' },
- { "directory", 1, 'C' },
- { "exclude", 1, OPTION_EXCLUDE },
- { "exclude-from", 1, 'X' },
- { "extract", 0, 'x' },
- { "fast-read", 0, 'q' },
- { "file", 1, 'f' },
- { "files-from", 1, 'T' },
- { "format", 1, OPTION_FORMAT },
- { "options", 1, OPTION_OPTIONS },
- { "gunzip", 0, 'z' },
- { "gzip", 0, 'z' },
- { "help", 0, OPTION_HELP },
- { "include", 1, OPTION_INCLUDE },
- { "interactive", 0, 'w' },
- { "insecure", 0, 'P' },
- { "keep-newer-files", 0, OPTION_KEEP_NEWER_FILES },
- { "keep-old-files", 0, 'k' },
- { "list", 0, 't' },
- { "lzma", 0, OPTION_LZMA },
- { "modification-time", 0, 'm' },
- { "newer", 1, OPTION_NEWER_CTIME },
- { "newer-ctime", 1, OPTION_NEWER_CTIME },
- { "newer-ctime-than", 1, OPTION_NEWER_CTIME_THAN },
- { "newer-mtime", 1, OPTION_NEWER_MTIME },
- { "newer-mtime-than", 1, OPTION_NEWER_MTIME_THAN },
- { "newer-than", 1, OPTION_NEWER_CTIME_THAN },
- { "nodump", 0, OPTION_NODUMP },
- { "norecurse", 0, 'n' },
- { "no-recursion", 0, 'n' },
- { "no-same-owner", 0, OPTION_NO_SAME_OWNER },
- { "no-same-permissions", 0, OPTION_NO_SAME_PERMISSIONS },
- { "null", 0, OPTION_NULL },
- { "numeric-owner", 0, OPTION_NUMERIC_OWNER },
- { "one-file-system", 0, OPTION_ONE_FILE_SYSTEM },
- { "posix", 0, OPTION_POSIX },
- { "preserve-permissions", 0, 'p' },
- { "read-full-blocks", 0, 'B' },
- { "same-owner", 0, OPTION_SAME_OWNER },
- { "same-permissions", 0, 'p' },
- { "strip-components", 1, OPTION_STRIP_COMPONENTS },
- { "to-stdout", 0, 'O' },
- { "totals", 0, OPTION_TOTALS },
- { "uncompress", 0, 'Z' },
- { "unlink", 0, 'U' },
- { "unlink-first", 0, 'U' },
- { "update", 0, 'u' },
- { "use-compress-program", 1, OPTION_USE_COMPRESS_PROGRAM },
- { "verbose", 0, 'v' },
- { "version", 0, OPTION_VERSION },
- { "xz", 0, 'J' },
- { NULL, 0, 0 }
-};
-
-/*
- * This getopt implementation has two key features that common
- * getopt_long() implementations lack. Apart from those, it's a
- * straightforward option parser, considerably simplified by not
- * needing to support the wealth of exotic getopt_long() features. It
- * has, of course, been shamelessly tailored for bsdtar. (If you're
- * looking for a generic getopt_long() implementation for your
- * project, I recommend Gregory Pietsch's public domain getopt_long()
- * implementation.) The two additional features are:
- *
- * Old-style tar arguments: The original tar implementation treated
- * the first argument word as a list of single-character option
- * letters. All arguments follow as separate words. For example,
- * tar xbf 32 /dev/tape
- * Here, the "xbf" is three option letters, "32" is the argument for
- * "b" and "/dev/tape" is the argument for "f". We support this usage
- * if the first command-line argument does not begin with '-'. We
- * also allow regular short and long options to follow, e.g.,
- * tar xbf 32 /dev/tape -P --format=pax
- *
- * -W long options: There's an obscure GNU convention (only rarely
- * supported even there) that allows "-W option=argument" as an
- * alternative way to support long options. This was supported in
- * early bsdtar as a way to access long options on platforms that did
- * not support getopt_long() and is preserved here for backwards
- * compatibility. (Of course, if I'd started with a custom
- * command-line parser from the beginning, I would have had normal
- * long option support on every platform so that hack wouldn't have
- * been necessary. Oh, well. Some mistakes you just have to live
- * with.)
- *
- * TODO: We should be able to use this to pull files and intermingled
- * options (such as -C) from the command line in write mode. That
- * will require a little rethinking of the argument handling in
- * bsdtar.c.
- *
- * TODO: If we want to support arbitrary command-line options from -T
- * input (as GNU tar does), we may need to extend this to handle option
- * words from sources other than argv/arc. I'm not really sure if I
- * like that feature of GNU tar, so it's certainly not a priority.
- */
-
-int
-bsdtar_getopt(struct bsdtar *bsdtar)
-{
- enum { state_start = 0, state_old_tar, state_next_word,
- state_short, state_long };
- static int state = state_start;
- static char *opt_word;
-
- const struct option *popt, *match = NULL, *match2 = NULL;
- const char *p, *long_prefix = "--";
- size_t optlength;
- int opt = '?';
- int required = 0;
-
- bsdtar->optarg = NULL;
-
- /* First time through, initialize everything. */
- if (state == state_start) {
- /* Skip program name. */
- ++bsdtar->argv;
- --bsdtar->argc;
- if (*bsdtar->argv == NULL)
- return (-1);
- /* Decide between "new style" and "old style" arguments. */
- if (bsdtar->argv[0][0] == '-') {
- state = state_next_word;
- } else {
- state = state_old_tar;
- opt_word = *bsdtar->argv++;
- --bsdtar->argc;
- }
- }
-
- /*
- * We're parsing old-style tar arguments
- */
- if (state == state_old_tar) {
- /* Get the next option character. */
- opt = *opt_word++;
- if (opt == '\0') {
- /* New-style args can follow old-style. */
- state = state_next_word;
- } else {
- /* See if it takes an argument. */
- p = strchr(short_options, opt);
- if (p == NULL)
- return ('?');
- if (p[1] == ':') {
- bsdtar->optarg = *bsdtar->argv;
- if (bsdtar->optarg == NULL) {
- bsdtar_warnc(bsdtar, 0,
- "Option %c requires an argument",
- opt);
- return ('?');
- }
- ++bsdtar->argv;
- --bsdtar->argc;
- }
- }
- }
-
- /*
- * We're ready to look at the next word in argv.
- */
- if (state == state_next_word) {
- /* No more arguments, so no more options. */
- if (bsdtar->argv[0] == NULL)
- return (-1);
- /* Doesn't start with '-', so no more options. */
- if (bsdtar->argv[0][0] != '-')
- return (-1);
- /* "--" marks end of options; consume it and return. */
- if (strcmp(bsdtar->argv[0], "--") == 0) {
- ++bsdtar->argv;
- --bsdtar->argc;
- return (-1);
- }
- /* Get next word for parsing. */
- opt_word = *bsdtar->argv++;
- --bsdtar->argc;
- if (opt_word[1] == '-') {
- /* Set up long option parser. */
- state = state_long;
- opt_word += 2; /* Skip leading '--' */
- } else {
- /* Set up short option parser. */
- state = state_short;
- ++opt_word; /* Skip leading '-' */
- }
- }
-
- /*
- * We're parsing a group of POSIX-style single-character options.
- */
- if (state == state_short) {
- /* Peel next option off of a group of short options. */
- opt = *opt_word++;
- if (opt == '\0') {
- /* End of this group; recurse to get next option. */
- state = state_next_word;
- return bsdtar_getopt(bsdtar);
- }
-
- /* Does this option take an argument? */
- p = strchr(short_options, opt);
- if (p == NULL)
- return ('?');
- if (p[1] == ':')
- required = 1;
-
- /* If it takes an argument, parse that. */
- if (required) {
- /* If arg is run-in, opt_word already points to it. */
- if (opt_word[0] == '\0') {
- /* Otherwise, pick up the next word. */
- opt_word = *bsdtar->argv;
- if (opt_word == NULL) {
- bsdtar_warnc(bsdtar, 0,
- "Option -%c requires an argument",
- opt);
- return ('?');
- }
- ++bsdtar->argv;
- --bsdtar->argc;
- }
- if (opt == 'W') {
- state = state_long;
- long_prefix = "-W "; /* For clearer errors. */
- } else {
- state = state_next_word;
- bsdtar->optarg = opt_word;
- }
- }
- }
-
- /* We're reading a long option, including -W long=arg convention. */
- if (state == state_long) {
- /* After this long option, we'll be starting a new word. */
- state = state_next_word;
-
- /* Option name ends at '=' if there is one. */
- p = strchr(opt_word, '=');
- if (p != NULL) {
- optlength = (size_t)(p - opt_word);
- bsdtar->optarg = (char *)(uintptr_t)(p + 1);
- } else {
- optlength = strlen(opt_word);
- }
-
- /* Search the table for an unambiguous match. */
- for (popt = tar_longopts; popt->name != NULL; popt++) {
- /* Short-circuit if first chars don't match. */
- if (popt->name[0] != opt_word[0])
- continue;
- /* If option is a prefix of name in table, record it.*/
- if (strncmp(opt_word, popt->name, optlength) == 0) {
- match2 = match; /* Record up to two matches. */
- match = popt;
- /* If it's an exact match, we're done. */
- if (strlen(popt->name) == optlength) {
- match2 = NULL; /* Forget the others. */
- break;
- }
- }
- }
-
- /* Fail if there wasn't a unique match. */
- if (match == NULL) {
- bsdtar_warnc(bsdtar, 0,
- "Option %s%s is not supported",
- long_prefix, opt_word);
- return ('?');
- }
- if (match2 != NULL) {
- bsdtar_warnc(bsdtar, 0,
- "Ambiguous option %s%s (matches --%s and --%s)",
- long_prefix, opt_word, match->name, match2->name);
- return ('?');
- }
-
- /* We've found a unique match; does it need an argument? */
- if (match->required) {
- /* Argument required: get next word if necessary. */
- if (bsdtar->optarg == NULL) {
- bsdtar->optarg = *bsdtar->argv;
- if (bsdtar->optarg == NULL) {
- bsdtar_warnc(bsdtar, 0,
- "Option %s%s requires an argument",
- long_prefix, match->name);
- return ('?');
- }
- ++bsdtar->argv;
- --bsdtar->argc;
- }
- } else {
- /* Argument forbidden: fail if there is one. */
- if (bsdtar->optarg != NULL) {
- bsdtar_warnc(bsdtar, 0,
- "Option %s%s does not allow an argument",
- long_prefix, match->name);
- return ('?');
- }
- }
- return (match->equivalent);
- }
-
- return (opt);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/config_freebsd.h b/libarchive/libarchive-2.7.1/tar/config_freebsd.h
deleted file mode 100644
index 16f2b39..0000000
--- a/libarchive/libarchive-2.7.1/tar/config_freebsd.h
+++ /dev/null
@@ -1,108 +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/config_freebsd.h,v 1.8 2008/11/29 20:06:53 kientzle Exp $
- */
-
-/* A default configuration for FreeBSD, used if there is no config.h. */
-
-#include <sys/param.h> /* __FreeBSD_version */
-
-#if __FreeBSD__ > 4
-#define HAVE_ACL_GET_PERM 0
-#define HAVE_ACL_GET_PERM_NP 1
-#define HAVE_ACL_PERMSET_T 1
-#define HAVE_ACL_USER 1
-#endif
-#undef HAVE_ATTR_XATTR_H
-#define HAVE_BZLIB_H 1
-#define HAVE_CHFLAGS 1
-#define HAVE_CHROOT 1
-#define HAVE_DECL_OPTARG 1
-#define HAVE_DECL_OPTIND 1
-#define HAVE_DIRENT_D_NAMLEN 1
-#define HAVE_DIRENT_H 1
-#define HAVE_D_MD_ORDER 1
-#define HAVE_ERRNO_H 1
-#undef HAVE_EXT2FS_EXT2_FS_H
-#define HAVE_FCHDIR 1
-#define HAVE_FCNTL_H 1
-#define HAVE_FNMATCH 1
-#define HAVE_FNMATCH_H 1
-#define HAVE_FNM_LEADING_DIR 1
-#define HAVE_FTRUNCATE 1
-#undef HAVE_GETXATTR
-#define HAVE_GRP_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_LANGINFO_H 1
-#undef HAVE_LGETXATTR
-#undef HAVE_LIBACL
-#define HAVE_LIBARCHIVE 1
-#define HAVE_LIBBZ2 1
-#define HAVE_LIBZ 1
-#define HAVE_LIMITS_H 1
-#undef HAVE_LINUX_EXT2_FS_H
-#undef HAVE_LINUX_FS_H
-#undef HAVE_LISTXATTR
-#undef HAVE_LLISTXATTR
-#define HAVE_LOCALE_H 1
-#define HAVE_MALLOC 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MEMORY_H 1
-#define HAVE_MEMSET 1
-#if __FreeBSD_version >= 450002 /* nl_langinfo introduced */
-#define HAVE_NL_LANGINFO 1
-#endif
-#define HAVE_PATHS_H 1
-#define HAVE_PWD_H 1
-#define HAVE_REGEX_H 1
-#define HAVE_SETLOCALE 1
-#define HAVE_STDARG_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRCHR 1
-#define HAVE_STRDUP 1
-#define HAVE_STRERROR 1
-#define HAVE_STRFTIME 1
-#define HAVE_STRINGS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRUCT_STAT_ST_FLAGS 1
-#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
-#define HAVE_SYS_ACL_H 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_PARAM_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_UINTMAX_T 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UNSIGNED_LONG_LONG
-#define HAVE_VPRINTF 1
-#define HAVE_WCTYPE_H 1
-#define HAVE_ZLIB_H 1
-#undef MAJOR_IN_MKDEV
-#define STDC_HEADERS 1
-
diff --git a/libarchive/libarchive-2.7.1/tar/getdate.c b/libarchive/libarchive-2.7.1/tar/getdate.c
deleted file mode 100644
index 8df1e26..0000000
--- a/libarchive/libarchive-2.7.1/tar/getdate.c
+++ /dev/null
@@ -1,1050 +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 }
-};
-
-/*
- * Convert hour/minute/second to count of seconds.
- */
-static time_t
-ToSeconds(time_t Hours, time_t Minutes, time_t Seconds)
-{
- if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
- return -1;
- if (Hours < 0 || Hours > 23)
- return -1;
- return Hours * HOUR + Minutes * MINUTE + Seconds;
-}
-
-
-/*
- * 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 tod;
- 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])
- 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;
- if ((tod = ToSeconds(Hours, Minutes, Seconds)) < 0)
- return -1;
- Julian += tod;
- 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/libarchive/libarchive-2.7.1/tar/matching.c b/libarchive/libarchive-2.7.1/tar/matching.c
deleted file mode 100644
index acc60db..0000000
--- a/libarchive/libarchive-2.7.1/tar/matching.c
+++ /dev/null
@@ -1,478 +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 "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/matching.c,v 1.16 2008/08/18 18:13:40 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 "bsdtar.h"
-
-struct match {
- struct match *next;
- int matches;
- char pattern[1];
-};
-
-struct matching {
- struct match *exclusions;
- int exclusions_count;
- struct match *inclusions;
- int inclusions_count;
- int inclusions_unmatched_count;
-};
-
-
-static void add_pattern(struct bsdtar *, struct match **list,
- const char *pattern);
-static int bsdtar_fnmatch(const char *p, const char *s);
-static void initialize_matching(struct bsdtar *);
-static int match_exclusion(struct match *, const char *pathname);
-static int match_inclusion(struct match *, const char *pathname);
-static int pathmatch(const char *p, const char *s);
-
-/*
- * 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
-exclude(struct bsdtar *bsdtar, const char *pattern)
-{
- struct matching *matching;
-
- if (bsdtar->matching == NULL)
- initialize_matching(bsdtar);
- matching = bsdtar->matching;
- add_pattern(bsdtar, &(matching->exclusions), pattern);
- matching->exclusions_count++;
- return (0);
-}
-
-int
-exclude_from_file(struct bsdtar *bsdtar, const char *pathname)
-{
- return (process_lines(bsdtar, pathname, &exclude));
-}
-
-int
-include(struct bsdtar *bsdtar, const char *pattern)
-{
- struct matching *matching;
-
- if (bsdtar->matching == NULL)
- initialize_matching(bsdtar);
- matching = bsdtar->matching;
- add_pattern(bsdtar, &(matching->inclusions), pattern);
- matching->inclusions_count++;
- matching->inclusions_unmatched_count++;
- return (0);
-}
-
-int
-include_from_file(struct bsdtar *bsdtar, const char *pathname)
-{
- return (process_lines(bsdtar, pathname, &include));
-}
-
-static void
-add_pattern(struct bsdtar *bsdtar, struct match **list, const char *pattern)
-{
- struct match *match;
-
- match = malloc(sizeof(*match) + strlen(pattern) + 1);
- if (match == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- strcpy(match->pattern, pattern);
- /* Both "foo/" and "foo" should match "foo/bar". */
- if (match->pattern[strlen(match->pattern)-1] == '/')
- match->pattern[strlen(match->pattern)-1] = '\0';
- match->next = *list;
- *list = match;
- match->matches = 0;
-}
-
-
-int
-excluded(struct bsdtar *bsdtar, const char *pathname)
-{
- struct matching *matching;
- struct match *match;
- struct match *matched;
-
- matching = bsdtar->matching;
- 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)
-{
- const char *p;
-
- if (*match->pattern == '*' || *match->pattern == '/')
- return (pathmatch(match->pattern, pathname) == 0);
-
- for (p = pathname; p != NULL; p = strchr(p, '/')) {
- if (*p == '/')
- p++;
- if (pathmatch(match->pattern, p) == 0)
- return (1);
- }
- return (0);
-}
-
-/*
- * Again, mimic gtar: inclusions are always anchored (have to match
- * the beginning of the path) even though exclusions are not anchored.
- */
-int
-match_inclusion(struct match *match, const char *pathname)
-{
- return (pathmatch(match->pattern, pathname) == 0);
-}
-
-void
-cleanup_exclusions(struct bsdtar *bsdtar)
-{
- struct match *p, *q;
-
- if (bsdtar->matching) {
- p = bsdtar->matching->inclusions;
- while (p != NULL) {
- q = p;
- p = p->next;
- free(q);
- }
- p = bsdtar->matching->exclusions;
- while (p != NULL) {
- q = p;
- p = p->next;
- free(q);
- }
- free(bsdtar->matching);
- }
-}
-
-static void
-initialize_matching(struct bsdtar *bsdtar)
-{
- bsdtar->matching = malloc(sizeof(*bsdtar->matching));
- if (bsdtar->matching == NULL)
- bsdtar_errc(bsdtar, 1, errno, "No memory");
- memset(bsdtar->matching, 0, sizeof(*bsdtar->matching));
-}
-
-int
-unmatched_inclusions(struct bsdtar *bsdtar)
-{
- struct matching *matching;
-
- matching = bsdtar->matching;
- if (matching == NULL)
- return (0);
- return (matching->inclusions_unmatched_count);
-}
-
-
-int
-unmatched_inclusions_warn(struct bsdtar *bsdtar, const char *msg)
-{
- struct matching *matching;
- struct match *p;
-
- matching = bsdtar->matching;
- if (matching == NULL)
- return (0);
-
- p = matching->inclusions;
- while (p != NULL) {
- if (p->matches == 0) {
- bsdtar->return_value = 1;
- bsdtar_warnc(bsdtar, 0, "%s: %s",
- p->pattern, msg);
- }
- p = p->next;
- }
- return (matching->inclusions_unmatched_count);
-}
-
-/*
- * TODO: Extend this so that the following matches work:
- * "foo//bar" == "foo/bar"
- * "foo/./bar" == "foo/bar"
- * "./foo" == "foo"
- *
- * The POSIX fnmatch() function doesn't handle any of these, but
- * all are common situations that arise when paths are generated within
- * large scripts. E.g., the following is quite common:
- * MYPATH=foo/ TARGET=$MYPATH/bar
- * It may be worthwhile to edit such paths at write time as well,
- * especially when such editing may avoid the need for long pathname
- * extensions.
- */
-static int
-pathmatch(const char *pattern, const char *string)
-{
- /*
- * Strip leading "./" or ".//" so that, e.g.,
- * "foo" matches "./foo". In particular, this
- * opens up an optimization for the writer to
- * elide leading "./".
- */
- if (pattern[0] == '.' && pattern[1] == '/') {
- pattern += 2;
- while (pattern[0] == '/')
- ++pattern;
- }
- if (string[0] == '.' && string[1] == '/') {
- string += 2;
- while (string[0] == '/')
- ++string;
- }
- return (bsdtar_fnmatch(pattern, string));
-}
-
-
-#if defined(HAVE_FNMATCH) && defined(HAVE_FNM_LEADING_DIR)
-
-/* Use system fnmatch() if it suits our needs. */
-/* On Linux, _GNU_SOURCE must be defined to get FNM_LEADING_DIR. */
-#define _GNU_SOURCE
-#include <fnmatch.h>
-static int
-bsdtar_fnmatch(const char *pattern, const char *string)
-{
- return (fnmatch(pattern, string, FNM_LEADING_DIR));
-}
-
-#else
-/*
- * The following was hacked from BSD C library
- * code: src/lib/libc/gen/fnmatch.c,v 1.15 2002/02/01
- *
- * In particular, most of the flags were ripped out: this always
- * behaves like FNM_LEADING_DIR is set and other flags specified
- * by POSIX are unset.
- *
- * Normally, I would not conditionally compile something like this: If
- * I have to support it anyway, everyone may as well use it. ;-)
- * However, the full POSIX spec for fnmatch() includes a lot of
- * advanced character handling that I'm not ready to put in here, so
- * it's probably best if people use a local version when it's available.
- */
-
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * 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.
- */
-
-static int
-bsdtar_fnmatch(const char *pattern, const char *string)
-{
- const char *saved_pattern;
- int negate, matched;
- char c;
-
- for (;;) {
- switch (c = *pattern++) {
- case '\0':
- if (*string == '/' || *string == '\0')
- return (0);
- return (1);
- case '?':
- if (*string == '\0')
- return (1);
- ++string;
- break;
- case '*':
- c = *pattern;
- /* Collapse multiple stars. */
- while (c == '*')
- c = *++pattern;
-
- /* Optimize for pattern with * at end. */
- if (c == '\0')
- return (0);
-
- /* General case, use recursion. */
- while (*string != '\0') {
- if (!bsdtar_fnmatch(pattern, string))
- return (0);
- ++string;
- }
- return (1);
- case '[':
- if (*string == '\0')
- return (1);
- saved_pattern = pattern;
- if (*pattern == '!' || *pattern == '^') {
- negate = 1;
- ++pattern;
- } else
- negate = 0;
- matched = 0;
- c = *pattern++;
- do {
- if (c == '\\')
- c = *pattern++;
- if (c == '\0') {
- pattern = saved_pattern;
- c = '[';
- goto norm;
- }
- if (*pattern == '-') {
- char c2 = *(pattern + 1);
- if (c2 == '\0') {
- pattern = saved_pattern;
- c = '[';
- goto norm;
- }
- if (c2 == ']') {
- /* [a-] is not a range. */
- if (c == *string
- || '-' == *string)
- matched = 1;
- pattern ++;
- } else {
- if (c <= *string
- && *string <= c2)
- matched = 1;
- pattern += 2;
- }
- } else if (c == *string)
- matched = 1;
- c = *pattern++;
- } while (c != ']');
- if (matched == negate)
- return (1);
- ++string;
- break;
- case '\\':
- if ((c = *pattern++) == '\0') {
- c = '\\';
- --pattern;
- }
- /* FALLTHROUGH */
- default:
- norm:
- if (c != *string)
- return (1);
- string++;
- break;
- }
- }
- /* NOTREACHED */
-}
-
-#endif
diff --git a/libarchive/libarchive-2.7.1/tar/read.c b/libarchive/libarchive-2.7.1/tar/read.c
deleted file mode 100644
index 642c548..0000000
--- a/libarchive/libarchive-2.7.1/tar/read.c
+++ /dev/null
@@ -1,418 +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 "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/read.c,v 1.40 2008/08/21 06:41:14 kientzle Exp $");
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef MAJOR_IN_MKDEV
-#include <sys/mkdev.h>
-#elif defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#endif
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#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_TIME_H
-#include <time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "bsdtar.h"
-
-static void list_item_verbose(struct bsdtar *, FILE *,
- struct archive_entry *);
-static void read_archive(struct bsdtar *bsdtar, char mode);
-
-void
-tar_mode_t(struct bsdtar *bsdtar)
-{
- read_archive(bsdtar, 't');
- unmatched_inclusions_warn(bsdtar, "Not found in archive");
-}
-
-void
-tar_mode_x(struct bsdtar *bsdtar)
-{
- /* We want to catch SIGINFO and SIGUSR1. */
- siginfo_init(bsdtar);
-
- read_archive(bsdtar, 'x');
-
- unmatched_inclusions_warn(bsdtar, "Not found in archive");
- /* Restore old SIGINFO + SIGUSR1 handlers. */
- siginfo_done(bsdtar);
-}
-
-static void
-progress_func(void * cookie)
-{
- struct bsdtar * bsdtar = cookie;
-
- siginfo_printinfo(bsdtar, 0);
-}
-
-/*
- * Handle 'x' and 't' modes.
- */
-static void
-read_archive(struct bsdtar *bsdtar, char mode)
-{
- FILE *out;
- struct archive *a;
- struct archive_entry *entry;
- const struct stat *st;
- int r;
-
- while (*bsdtar->argv) {
- include(bsdtar, *bsdtar->argv);
- bsdtar->argv++;
- }
-
- if (bsdtar->names_from_file != NULL)
- include_from_file(bsdtar, bsdtar->names_from_file);
-
- a = archive_read_new();
- if (bsdtar->compress_program != NULL)
- archive_read_support_compression_program(a, bsdtar->compress_program);
- else
- archive_read_support_compression_all(a);
- archive_read_support_format_all(a);
- if (ARCHIVE_OK != archive_read_set_options(a, bsdtar->option_options))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
- if (archive_read_open_file(a, bsdtar->filename,
- bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block :
- DEFAULT_BYTES_PER_BLOCK))
- bsdtar_errc(bsdtar, 1, 0, "Error opening archive: %s",
- archive_error_string(a));
-
- do_chdir(bsdtar);
-
- if (mode == 'x') {
- /* Set an extract callback so that we can handle SIGINFO. */
- archive_read_extract_set_progress_callback(a, progress_func,
- bsdtar);
- }
-
- if (mode == 'x' && bsdtar->option_chroot) {
-#if HAVE_CHROOT
- if (chroot(".") != 0)
- bsdtar_errc(bsdtar, 1, errno, "Can't chroot to \".\"");
-#else
- bsdtar_errc(bsdtar, 1, 0,
- "chroot isn't supported on this platform");
-#endif
- }
-
- for (;;) {
- /* Support --fast-read option */
- if (bsdtar->option_fast_read &&
- unmatched_inclusions(bsdtar) == 0)
- break;
-
- r = archive_read_next_header(a, &entry);
- if (r == ARCHIVE_EOF)
- break;
- if (r < ARCHIVE_OK)
- bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
- if (r <= ARCHIVE_WARN)
- bsdtar->return_value = 1;
- if (r == ARCHIVE_RETRY) {
- /* Retryable error: try again */
- bsdtar_warnc(bsdtar, 0, "Retrying...");
- continue;
- }
- if (r == ARCHIVE_FATAL)
- break;
-
- if (bsdtar->option_numeric_owner) {
- archive_entry_set_uname(entry, NULL);
- archive_entry_set_gname(entry, NULL);
- }
-
- /*
- * Exclude entries that are too old.
- */
- st = archive_entry_stat(entry);
- if (bsdtar->newer_ctime_sec > 0) {
- if (st->st_ctime < bsdtar->newer_ctime_sec)
- continue; /* Too old, skip it. */
- if (st->st_ctime == bsdtar->newer_ctime_sec
- && ARCHIVE_STAT_CTIME_NANOS(st)
- <= bsdtar->newer_ctime_nsec)
- continue; /* Too old, skip it. */
- }
- if (bsdtar->newer_mtime_sec > 0) {
- if (st->st_mtime < bsdtar->newer_mtime_sec)
- continue; /* Too old, skip it. */
- if (st->st_mtime == bsdtar->newer_mtime_sec
- && ARCHIVE_STAT_MTIME_NANOS(st)
- <= bsdtar->newer_mtime_nsec)
- continue; /* Too old, skip it. */
- }
-
- /*
- * Note that pattern exclusions are checked before
- * pathname rewrites are handled. This gives more
- * control over exclusions, since rewrites always lose
- * information. (For example, consider a rewrite
- * s/foo[0-9]/foo/. If we check exclusions after the
- * rewrite, there would be no way to exclude foo1/bar
- * while allowing foo2/bar.)
- */
- if (excluded(bsdtar, archive_entry_pathname(entry)))
- continue; /* Excluded by a pattern test. */
-
- if (mode == 't') {
- /* Perversely, gtar uses -O to mean "send to stderr"
- * when used with -t. */
- out = bsdtar->option_stdout ? stderr : stdout;
-
- /*
- * TODO: Provide some reasonable way to
- * preview rewrites. gtar always displays
- * the unedited path in -t output, which means
- * you cannot easily preview rewrites.
- */
- if (bsdtar->verbose < 2)
- safe_fprintf(out, "%s",
- archive_entry_pathname(entry));
- else
- list_item_verbose(bsdtar, out, entry);
- fflush(out);
- r = archive_read_data_skip(a);
- if (r == ARCHIVE_WARN) {
- fprintf(out, "\n");
- bsdtar_warnc(bsdtar, 0, "%s",
- archive_error_string(a));
- }
- if (r == ARCHIVE_RETRY) {
- fprintf(out, "\n");
- bsdtar_warnc(bsdtar, 0, "%s",
- archive_error_string(a));
- }
- if (r == ARCHIVE_FATAL) {
- fprintf(out, "\n");
- bsdtar_warnc(bsdtar, 0, "%s",
- archive_error_string(a));
- bsdtar->return_value = 1;
- break;
- }
- fprintf(out, "\n");
- } else {
- /* Note: some rewrite failures prevent extraction. */
- if (edit_pathname(bsdtar, entry))
- continue; /* Excluded by a rewrite failure. */
-
- if (bsdtar->option_interactive &&
- !yes("extract '%s'", archive_entry_pathname(entry)))
- continue;
-
- /*
- * Format here is from SUSv2, including the
- * deferred '\n'.
- */
- if (bsdtar->verbose) {
- safe_fprintf(stderr, "x %s",
- archive_entry_pathname(entry));
- fflush(stderr);
- }
-
- /* Tell the SIGINFO-handler code what we're doing. */
- siginfo_setinfo(bsdtar, "extracting",
- archive_entry_pathname(entry), 0);
- siginfo_printinfo(bsdtar, 0);
-
- if (bsdtar->option_stdout)
- r = archive_read_data_into_fd(a, 1);
- else
- r = archive_read_extract(a, entry,
- bsdtar->extract_flags);
- if (r != ARCHIVE_OK) {
- if (!bsdtar->verbose)
- safe_fprintf(stderr, "%s",
- archive_entry_pathname(entry));
- safe_fprintf(stderr, ": %s",
- archive_error_string(a));
- if (!bsdtar->verbose)
- fprintf(stderr, "\n");
- bsdtar->return_value = 1;
- }
- if (bsdtar->verbose)
- fprintf(stderr, "\n");
- if (r == ARCHIVE_FATAL)
- break;
- }
- }
-
-
- r = archive_read_close(a);
- if (r != ARCHIVE_OK)
- bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
- if (r <= ARCHIVE_WARN)
- bsdtar->return_value = 1;
-
- if (bsdtar->verbose > 2)
- fprintf(stdout, "Archive Format: %s, Compression: %s\n",
- archive_format_name(a), archive_compression_name(a));
-
- archive_read_finish(a);
-}
-
-
-/*
- * Display information about the current file.
- *
- * The format here roughly duplicates the output of 'ls -l'.
- * This is based on SUSv2, where 'tar tv' is documented as
- * listing additional information in an "unspecified format,"
- * and 'pax -l' is documented as using the same format as 'ls -l'.
- */
-static void
-list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
-{
- const struct stat *st;
- char tmp[100];
- size_t w;
- const char *p;
- const char *fmt;
- time_t tim;
- static time_t now;
-
- st = archive_entry_stat(entry);
-
- /*
- * We avoid collecting the entire list in memory at once by
- * listing things as we see them. However, that also means we can't
- * just pre-compute the field widths. Instead, we start with guesses
- * and just widen them as necessary. These numbers are completely
- * arbitrary.
- */
- if (!bsdtar->u_width) {
- bsdtar->u_width = 6;
- bsdtar->gs_width = 13;
- }
- if (!now)
- time(&now);
- fprintf(out, "%s %d ",
- archive_entry_strmode(entry),
- (int)(st->st_nlink));
-
- /* Use uname if it's present, else uid. */
- p = archive_entry_uname(entry);
- if ((p == NULL) || (*p == '\0')) {
- sprintf(tmp, "%lu ", (unsigned long)st->st_uid);
- p = tmp;
- }
- w = strlen(p);
- if (w > bsdtar->u_width)
- bsdtar->u_width = w;
- fprintf(out, "%-*s ", (int)bsdtar->u_width, p);
-
- /* Use gname if it's present, else gid. */
- p = archive_entry_gname(entry);
- if (p != NULL && p[0] != '\0') {
- fprintf(out, "%s", p);
- w = strlen(p);
- } else {
- sprintf(tmp, "%lu", (unsigned long)st->st_gid);
- w = strlen(tmp);
- fprintf(out, "%s", tmp);
- }
-
- /*
- * Print device number or file size, right-aligned so as to make
- * total width of group and devnum/filesize fields be gs_width.
- * If gs_width is too small, grow it.
- */
- if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
- sprintf(tmp, "%lu,%lu",
- (unsigned long)major(st->st_rdev),
- (unsigned long)minor(st->st_rdev)); /* ls(1) also casts here. */
- } else {
- /*
- * Note the use of platform-dependent macros to format
- * the filesize here. We need the format string and the
- * corresponding type for the cast.
- */
- sprintf(tmp, BSDTAR_FILESIZE_PRINTF,
- (BSDTAR_FILESIZE_TYPE)st->st_size);
- }
- if (w + strlen(tmp) >= bsdtar->gs_width)
- bsdtar->gs_width = w+strlen(tmp)+1;
- fprintf(out, "%*s", (int)(bsdtar->gs_width - w), tmp);
-
- /* Format the time using 'ls -l' conventions. */
- tim = (time_t)st->st_mtime;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /* Windows' strftime function does not support %e format. */
- if (abs(tim - now) > (365/2)*86400)
- fmt = bsdtar->day_first ? "%d %b %Y" : "%b %d %Y";
- else
- fmt = bsdtar->day_first ? "%d %b %H:%M" : "%b %d %H:%M";
-#else
- if (abs(tim - now) > (365/2)*86400)
- fmt = bsdtar->day_first ? "%e %b %Y" : "%b %e %Y";
- else
- fmt = bsdtar->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
-#endif
- strftime(tmp, sizeof(tmp), fmt, localtime(&tim));
- fprintf(out, " %s ", tmp);
- safe_fprintf(out, "%s", archive_entry_pathname(entry));
-
- /* Extra information for links. */
- if (archive_entry_hardlink(entry)) /* Hard link */
- safe_fprintf(out, " link to %s",
- archive_entry_hardlink(entry));
- else if (S_ISLNK(st->st_mode)) /* Symbolic link */
- safe_fprintf(out, " -> %s", archive_entry_symlink(entry));
-}
diff --git a/libarchive/libarchive-2.7.1/tar/siginfo.c b/libarchive/libarchive-2.7.1/tar/siginfo.c
deleted file mode 100644
index 5f28e23..0000000
--- a/libarchive/libarchive-2.7.1/tar/siginfo.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * Copyright 2008 Colin Percival
- * 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 "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/siginfo.c,v 1.2 2008/05/22 21:08:36 cperciva Exp $");
-
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "bsdtar.h"
-
-/* Is there a pending SIGINFO or SIGUSR1? */
-static volatile sig_atomic_t siginfo_received = 0;
-
-struct siginfo_data {
- /* What sort of operation are we doing? */
- char * oper;
-
- /* What path are we handling? */
- char * path;
-
- /* How large is the archive entry? */
- int64_t size;
-
- /* Old signal handlers. */
-#ifdef SIGINFO
- void (*siginfo_old)(int);
-#endif
- void (*sigusr1_old)(int);
-};
-
-static void siginfo_handler(int sig);
-
-/* Handler for SIGINFO / SIGUSR1. */
-static void
-siginfo_handler(int sig)
-{
-
- (void)sig; /* UNUSED */
-
- /* Record that SIGINFO or SIGUSR1 has been received. */
- siginfo_received = 1;
-}
-
-void
-siginfo_init(struct bsdtar *bsdtar)
-{
-
- /* Allocate space for internal structure. */
- if ((bsdtar->siginfo = malloc(sizeof(struct siginfo_data))) == NULL)
- bsdtar_errc(bsdtar, 1, errno, "malloc failed");
-
- /* Set the strings to NULL so that free() is safe. */
- bsdtar->siginfo->path = bsdtar->siginfo->oper = NULL;
-
-#ifdef SIGINFO
- /* We want to catch SIGINFO, if it exists. */
- bsdtar->siginfo->siginfo_old = signal(SIGINFO, siginfo_handler);
-#endif
-#ifdef SIGUSR1
- /* ... and treat SIGUSR1 the same way as SIGINFO. */
- bsdtar->siginfo->sigusr1_old = signal(SIGUSR1, siginfo_handler);
-#endif
-}
-
-void
-siginfo_setinfo(struct bsdtar *bsdtar, const char * oper, const char * path,
- int64_t size)
-{
-
- /* Free old operation and path strings. */
- free(bsdtar->siginfo->oper);
- free(bsdtar->siginfo->path);
-
- /* Duplicate strings and store entry size. */
- if ((bsdtar->siginfo->oper = strdup(oper)) == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Cannot strdup");
- if ((bsdtar->siginfo->path = strdup(path)) == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Cannot strdup");
- bsdtar->siginfo->size = size;
-}
-
-void
-siginfo_printinfo(struct bsdtar *bsdtar, off_t progress)
-{
-
- /* If there's a signal to handle and we know what we're doing... */
- if ((siginfo_received == 1) &&
- (bsdtar->siginfo->path != NULL) &&
- (bsdtar->siginfo->oper != NULL)) {
- if (bsdtar->verbose)
- fprintf(stderr, "\n");
- if (bsdtar->siginfo->size > 0) {
- safe_fprintf(stderr, "%s %s (%ju / %" PRId64 ")",
- bsdtar->siginfo->oper, bsdtar->siginfo->path,
- (uintmax_t)progress, bsdtar->siginfo->size);
- } else {
- safe_fprintf(stderr, "%s %s",
- bsdtar->siginfo->oper, bsdtar->siginfo->path);
- }
- if (!bsdtar->verbose)
- fprintf(stderr, "\n");
- siginfo_received = 0;
- }
-}
-
-void
-siginfo_done(struct bsdtar *bsdtar)
-{
-
-#ifdef SIGINFO
- /* Restore old SIGINFO handler. */
- signal(SIGINFO, bsdtar->siginfo->siginfo_old);
-#endif
-#ifdef SIGUSR1
- /* And the old SIGUSR1 handler, too. */
- signal(SIGUSR1, bsdtar->siginfo->sigusr1_old);
-#endif
-
- /* Free strings. */
- free(bsdtar->siginfo->path);
- free(bsdtar->siginfo->oper);
-
- /* Free internal data structure. */
- free(bsdtar->siginfo);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/subst.c b/libarchive/libarchive-2.7.1/tar/subst.c
deleted file mode 100644
index 9e86498..0000000
--- a/libarchive/libarchive-2.7.1/tar/subst.c
+++ /dev/null
@@ -1,287 +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.
- */
-
-#include "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/subst.c,v 1.4 2008/06/15 10:08:16 kientzle Exp $");
-
-#if HAVE_REGEX_H
-#include "bsdtar.h"
-
-#include <errno.h>
-#include <regex.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef REG_BASIC
-#define REG_BASIC 0
-#endif
-
-struct subst_rule {
- struct subst_rule *next;
- regex_t re;
- char *result;
- unsigned int global:1, print:1, symlink:1;
-};
-
-struct substitution {
- struct subst_rule *first_rule, *last_rule;
-};
-
-static void
-init_substitution(struct bsdtar *bsdtar)
-{
- struct substitution *subst;
-
- bsdtar->substitution = subst = malloc(sizeof(*subst));
- if (subst == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- subst->first_rule = subst->last_rule = NULL;
-}
-
-void
-add_substitution(struct bsdtar *bsdtar, const char *rule_text)
-{
- struct subst_rule *rule;
- struct substitution *subst;
- const char *end_pattern, *start_subst;
- char *pattern;
- int r;
-
- if ((subst = bsdtar->substitution) == NULL) {
- init_substitution(bsdtar);
- subst = bsdtar->substitution;
- }
-
- rule = malloc(sizeof(*rule));
- if (rule == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- rule->next = NULL;
-
- if (subst->last_rule == NULL)
- subst->first_rule = rule;
- else
- subst->last_rule->next = rule;
- subst->last_rule = rule;
-
- if (*rule_text == '\0')
- bsdtar_errc(bsdtar, 1, 0, "Empty replacement string");
- end_pattern = strchr(rule_text + 1, *rule_text);
- if (end_pattern == NULL)
- bsdtar_errc(bsdtar, 1, 0, "Invalid replacement string");
-
- pattern = malloc(end_pattern - rule_text);
- if (pattern == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- memcpy(pattern, rule_text + 1, end_pattern - rule_text - 1);
- pattern[end_pattern - rule_text - 1] = '\0';
-
- if ((r = regcomp(&rule->re, pattern, REG_BASIC)) != 0) {
- char buf[80];
- regerror(r, &rule->re, buf, sizeof(buf));
- bsdtar_errc(bsdtar, 1, 0, "Invalid regular expression: %s", buf);
- }
- free(pattern);
-
- start_subst = end_pattern + 1;
- end_pattern = strchr(start_subst, *rule_text);
- if (end_pattern == NULL)
- bsdtar_errc(bsdtar, 1, 0, "Invalid replacement string");
-
- rule->result = malloc(end_pattern - start_subst + 1);
- if (rule->result == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- memcpy(rule->result, start_subst, end_pattern - start_subst);
- rule->result[end_pattern - start_subst] = '\0';
-
- rule->global = 0;
- rule->print = 0;
- rule->symlink = 0;
-
- while (*++end_pattern) {
- switch (*end_pattern) {
- case 'g':
- case 'G':
- rule->global = 1;
- break;
- case 'p':
- case 'P':
- rule->print = 1;
- break;
- case 's':
- case 'S':
- rule->symlink = 1;
- break;
- default:
- bsdtar_errc(bsdtar, 1, 0, "Invalid replacement flag %c", *end_pattern);
- }
- }
-}
-
-static void
-realloc_strncat(struct bsdtar *bsdtar, char **str, const char *append, size_t len)
-{
- char *new_str;
- size_t old_len;
-
- if (*str == NULL)
- old_len = 0;
- else
- old_len = strlen(*str);
-
- new_str = malloc(old_len + len + 1);
- if (new_str == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- memcpy(new_str, *str, old_len);
- memcpy(new_str + old_len, append, len);
- new_str[old_len + len] = '\0';
- free(*str);
- *str = new_str;
-}
-
-static void
-realloc_strcat(struct bsdtar *bsdtar, char **str, const char *append)
-{
- char *new_str;
- size_t old_len;
-
- if (*str == NULL)
- old_len = 0;
- else
- old_len = strlen(*str);
-
- new_str = malloc(old_len + strlen(append) + 1);
- if (new_str == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Out of memory");
- memcpy(new_str, *str, old_len);
- strcpy(new_str + old_len, append);
- free(*str);
- *str = new_str;
-}
-
-int
-apply_substitution(struct bsdtar *bsdtar, const char *name, char **result, int symlink_only)
-{
- const char *path = name;
- regmatch_t matches[10];
- size_t i, j;
- struct subst_rule *rule;
- struct substitution *subst;
- int c, got_match, print_match;
-
- *result = NULL;
-
- if ((subst = bsdtar->substitution) == NULL)
- return 0;
-
- got_match = 0;
- print_match = 0;
-
- for (rule = subst->first_rule; rule != NULL; rule = rule->next) {
- if (symlink_only && !rule->symlink)
- continue;
- if (regexec(&rule->re, name, 10, matches, 0))
- continue;
-
- got_match = 1;
- print_match |= rule->print;
- realloc_strncat(bsdtar, result, name, matches[0].rm_so);
-
- for (i = 0, j = 0; rule->result[i] != '\0'; ++i) {
- if (rule->result[i] == '~') {
- realloc_strncat(bsdtar, result, rule->result + j, i - j);
- realloc_strncat(bsdtar, result, name, matches[0].rm_eo);
- j = i + 1;
- continue;
- }
- if (rule->result[i] != '\\')
- continue;
-
- ++i;
- c = rule->result[i];
- switch (c) {
- case '~':
- case '\\':
- realloc_strncat(bsdtar, result, rule->result + j, i - j - 1);
- j = i;
- break;
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- realloc_strncat(bsdtar, result, rule->result + j, i - j - 1);
- if ((size_t)(c - '0') > (size_t)(rule->re.re_nsub)) {
- free(*result);
- *result = NULL;
- return -1;
- }
- realloc_strncat(bsdtar, result, name + matches[c - '0'].rm_so, matches[c - '0'].rm_eo - matches[c - '0'].rm_so);
- j = i + 1;
- break;
- default:
- /* Just continue; */
- break;
- }
-
- }
-
- realloc_strcat(bsdtar, result, rule->result + j);
-
- name += matches[0].rm_eo;
-
- if (!rule->global)
- break;
- }
-
- if (got_match)
- realloc_strcat(bsdtar, result, name);
-
- if (print_match)
- fprintf(stderr, "%s >> %s\n", path, *result);
-
- return got_match;
-}
-
-void
-cleanup_substitution(struct bsdtar *bsdtar)
-{
- struct subst_rule *rule;
- struct substitution *subst;
-
- if ((subst = bsdtar->substitution) == NULL)
- return;
-
- while ((rule = subst->first_rule) != NULL) {
- subst->first_rule = rule->next;
- free(rule->result);
- free(rule);
- }
- free(subst);
-}
-#endif /* HAVE_REGEX_H */
diff --git a/libarchive/libarchive-2.7.1/tar/test/CMakeLists.txt b/libarchive/libarchive-2.7.1/tar/test/CMakeLists.txt
deleted file mode 100644
index 530fbb3..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-############################################
-#
-# How to build bsdtar_test
-#
-############################################
-IF(ENABLE_TAR AND ENABLE_TEST)
- SET(bsdtar_test_SOURCES
- ../getdate.c
- main.c
- test.h
- test_0.c
- test_basic.c
- test_copy.c
- test_getdate.c
- test_help.c
- test_option_T.c
- test_option_q.c
- test_option_s.c
- test_patterns.c
- test_stdio.c
- test_strip_components.c
- test_symlink_dir.c
- test_version.c
- test_windows.c
- )
- IF(WIN32 AND NOT CYGWIN)
- LIST(APPEND bsdtar_test_SOURCES ../bsdtar_windows.c)
- LIST(APPEND bsdtar_test_SOURCES ../bsdtar_windows.h)
- ENDIF(WIN32 AND NOT CYGWIN)
-
- #
- # Generate the list.h
- #
- GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
- ${CMAKE_CURRENT_LIST_FILE} ${bsdtar_test_SOURCES})
- SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
- ${CMAKE_CURRENT_BINARY_DIR})
- #
- # Register target
- #
- ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES})
- SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H)
- SET(num 0)
- FOREACH(test ${bsdtar_test_SOURCES})
- IF(test MATCHES "^test_[^/]+[.]c$")
- STRING(REGEX REPLACE "^(test_[^/]+)[.]c$" "\\1" testname ${test})
- ADD_TEST("bsdtar_${testname}" bsdtar_test
- -q -v -p ${BSDTAR} -r ${CMAKE_CURRENT_SOURCE_DIR} ${num})
- MATH(EXPR num "${num} + 1")
- ENDIF(test MATCHES "^test_[^/]+[.]c$")
- ENDFOREACH(test)
-ENDIF (ENABLE_TAR AND ENABLE_TEST)
diff --git a/libarchive/libarchive-2.7.1/tar/test/list.h b/libarchive/libarchive-2.7.1/tar/test/list.h
deleted file mode 100644
index 180bc9b..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/list.h
+++ /dev/null
@@ -1,14 +0,0 @@
-DEFINE_TEST(test_0)
-DEFINE_TEST(test_basic)
-DEFINE_TEST(test_copy)
-DEFINE_TEST(test_getdate)
-DEFINE_TEST(test_help)
-DEFINE_TEST(test_option_T)
-DEFINE_TEST(test_option_q)
-DEFINE_TEST(test_option_s)
-DEFINE_TEST(test_patterns)
-DEFINE_TEST(test_stdio)
-DEFINE_TEST(test_strip_components)
-DEFINE_TEST(test_symlink_dir)
-DEFINE_TEST(test_version)
-DEFINE_TEST(test_windows)
diff --git a/libarchive/libarchive-2.7.1/tar/test/main.c b/libarchive/libarchive-2.7.1/tar/test/main.c
deleted file mode 100644
index b564638..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/main.c
+++ /dev/null
@@ -1,1132 +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.
- */
-
-/*
- * Various utility routines useful for test programs.
- * Each test program is linked against this file.
- */
-#include "test.h"
-
-#include <errno.h>
-#include <locale.h>
-#include <stdarg.h>
-#include <time.h>
-
-/*
- * This same file is used pretty much verbatim for all test harnesses.
- *
- * The next few lines are the only differences.
- */
-#define PROGRAM "bsdtar" /* Name of program being tested. */
-#define ENVBASE "BSDTAR" /* Prefix for environment variables. */
-#undef EXTRA_DUMP /* How to dump extra data */
-/* How to generate extra version info. */
-#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
-__FBSDID("$FreeBSD: src/usr.bin/tar/test/main.c,v 1.6 2008/11/05 06:40:53 kientzle Exp $");
-
-/*
- * "list.h" is simply created by "grep DEFINE_TEST"; it has
- * a line like
- * DEFINE_TEST(test_function)
- * for each test.
- * Include it here with a suitable DEFINE_TEST to declare all of the
- * test functions.
- */
-#undef DEFINE_TEST
-#define DEFINE_TEST(name) void name(void);
-#include "list.h"
-
-/* Interix doesn't define these in a standard header. */
-#if __INTERIX__
-extern char *optarg;
-extern int optind;
-#endif
-
-/* Enable core dump on failure. */
-static int dump_on_failure = 0;
-/* Default is to remove temp dirs for successful tests. */
-static int keep_temp_files = 0;
-/* Default is to print some basic information about each test. */
-static int quiet_flag = 0;
-/* Default is to summarize repeated failures. */
-static int verbose = 0;
-/* Cumulative count of component failures. */
-static int failures = 0;
-/* Cumulative count of skipped component tests. */
-static int skips = 0;
-/* Cumulative count of assertions. */
-static int assertions = 0;
-
-/* Directory where uuencoded reference files can be found. */
-static const char *refdir;
-
-/*
- * My own implementation of the standard assert() macro emits the
- * message in the same format as GCC (file:line: message).
- * It also includes some additional useful information.
- * This makes it a lot easier to skim through test failures in
- * Emacs. ;-)
- *
- * It also supports a few special features specifically to simplify
- * test harnesses:
- * failure(fmt, args) -- Stores a text string that gets
- * printed if the following assertion fails, good for
- * explaining subtle tests.
- */
-static char msg[4096];
-
-/*
- * For each test source file, we remember how many times each
- * failure was reported.
- */
-static const char *failed_filename = NULL;
-static struct line {
- int line;
- int count;
-} failed_lines[1000];
-
-/*
- * Count this failure; return the number of previous failures.
- */
-static int
-previous_failures(const char *filename, int line)
-{
- unsigned int i;
- int count;
-
- if (failed_filename == NULL || strcmp(failed_filename, filename) != 0)
- memset(failed_lines, 0, sizeof(failed_lines));
- failed_filename = filename;
-
- for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
- if (failed_lines[i].line == line) {
- count = failed_lines[i].count;
- failed_lines[i].count++;
- return (count);
- }
- if (failed_lines[i].line == 0) {
- failed_lines[i].line = line;
- failed_lines[i].count = 1;
- return (0);
- }
- }
- return (0);
-}
-
-/*
- * Copy arguments into file-local variables.
- */
-static const char *test_filename;
-static int test_line;
-static void *test_extra;
-void test_setup(const char *filename, int line)
-{
- test_filename = filename;
- test_line = line;
-}
-
-/*
- * Inform user that we're skipping a test.
- */
-void
-test_skipping(const char *fmt, ...)
-{
- va_list ap;
-
- if (previous_failures(test_filename, test_line))
- return;
-
- va_start(ap, fmt);
- fprintf(stderr, " *** SKIPPING: ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
- ++skips;
-}
-
-/* Common handling of failed tests. */
-static void
-report_failure(void *extra)
-{
- if (msg[0] != '\0') {
- fprintf(stderr, " Description: %s\n", msg);
- msg[0] = '\0';
- }
-
-#ifdef EXTRA_DUMP
- if (extra != NULL)
- fprintf(stderr, " detail: %s\n", EXTRA_DUMP(extra));
-#else
- (void)extra; /* UNUSED */
-#endif
-
- if (dump_on_failure) {
- fprintf(stderr,
- " *** forcing core dump so failure can be debugged ***\n");
- *(char *)(NULL) = 0;
- exit(1);
- }
-}
-
-/*
- * Summarize repeated failures in the just-completed test file.
- * The reports above suppress multiple failures from the same source
- * line; this reports on any tests that did fail multiple times.
- */
-static int
-summarize_comparator(const void *a0, const void *b0)
-{
- const struct line *a = a0, *b = b0;
- if (a->line == 0 && b->line == 0)
- return (0);
- if (a->line == 0)
- return (1);
- if (b->line == 0)
- return (-1);
- return (a->line - b->line);
-}
-
-static void
-summarize(void)
-{
- unsigned int i;
-
- qsort(failed_lines, sizeof(failed_lines)/sizeof(failed_lines[0]),
- sizeof(failed_lines[0]), summarize_comparator);
- for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
- if (failed_lines[i].line == 0)
- break;
- if (failed_lines[i].count > 1)
- fprintf(stderr, "%s:%d: Failed %d times\n",
- failed_filename, failed_lines[i].line,
- failed_lines[i].count);
- }
- /* Clear the failure history for the next file. */
- memset(failed_lines, 0, sizeof(failed_lines));
-}
-
-/* Set up a message to display only after a test fails. */
-void
-failure(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vsprintf(msg, fmt, ap);
- va_end(ap);
-}
-
-/* Generic assert() just displays the failed condition. */
-int
-test_assert(const char *file, int line, int value, const char *condition, void *extra)
-{
- ++assertions;
- if (value) {
- msg[0] = '\0';
- return (value);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (value);
- fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
- fprintf(stderr, " Condition: %s\n", condition);
- report_failure(extra);
- return (value);
-}
-
-/* assertEqualInt() displays the values of the two integers. */
-int
-test_assert_equal_int(const char *file, int line,
- int v1, const char *e1, int v2, const char *e2, void *extra)
-{
- ++assertions;
- if (v1 == v2) {
- msg[0] = '\0';
- return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n",
- file, line);
- fprintf(stderr, " %s=%d\n", e1, v1);
- fprintf(stderr, " %s=%d\n", e2, v2);
- report_failure(extra);
- return (0);
-}
-
-static void strdump(const char *p)
-{
- if (p == NULL) {
- fprintf(stderr, "(null)");
- return;
- }
- fprintf(stderr, "\"");
- while (*p != '\0') {
- unsigned int c = 0xff & *p++;
- switch (c) {
- case '\a': fprintf(stderr, "\a"); break;
- case '\b': fprintf(stderr, "\b"); break;
- case '\n': fprintf(stderr, "\n"); break;
- case '\r': fprintf(stderr, "\r"); break;
- default:
- if (c >= 32 && c < 127)
- fprintf(stderr, "%c", c);
- else
- fprintf(stderr, "\\x%02X", c);
- }
- }
- fprintf(stderr, "\"");
-}
-
-/* assertEqualString() displays the values of the two strings. */
-int
-test_assert_equal_string(const char *file, int line,
- const char *v1, const char *e1,
- const char *v2, const char *e2,
- void *extra)
-{
- ++assertions;
- if (v1 == NULL || v2 == NULL) {
- if (v1 == v2) {
- msg[0] = '\0';
- return (1);
- }
- } else if (strcmp(v1, v2) == 0) {
- msg[0] = '\0';
- return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n",
- file, line);
- fprintf(stderr, " %s = ", e1);
- strdump(v1);
- fprintf(stderr, " (length %d)\n", v1 == NULL ? 0 : (int)strlen(v1));
- fprintf(stderr, " %s = ", e2);
- strdump(v2);
- fprintf(stderr, " (length %d)\n", v2 == NULL ? 0 : (int)strlen(v2));
- report_failure(extra);
- return (0);
-}
-
-static void wcsdump(const wchar_t *w)
-{
- if (w == NULL) {
- fprintf(stderr, "(null)");
- return;
- }
- fprintf(stderr, "\"");
- while (*w != L'\0') {
- unsigned int c = *w++;
- if (c >= 32 && c < 127)
- fprintf(stderr, "%c", c);
- else if (c < 256)
- fprintf(stderr, "\\x%02X", c);
- else if (c < 0x10000)
- fprintf(stderr, "\\u%04X", c);
- else
- fprintf(stderr, "\\U%08X", c);
- }
- fprintf(stderr, "\"");
-}
-
-/* assertEqualWString() displays the values of the two strings. */
-int
-test_assert_equal_wstring(const char *file, int line,
- const wchar_t *v1, const char *e1,
- const wchar_t *v2, const char *e2,
- void *extra)
-{
- ++assertions;
- if (v1 == NULL) {
- if (v2 == NULL) {
- msg[0] = '\0';
- return (1);
- }
- } else if (v2 == NULL) {
- if (v1 == NULL) {
- msg[0] = '\0';
- return (1);
- }
- } else if (wcscmp(v1, v2) == 0) {
- msg[0] = '\0';
- return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n",
- file, line);
- fprintf(stderr, " %s = ", e1);
- wcsdump(v1);
- fprintf(stderr, "\n");
- fprintf(stderr, " %s = ", e2);
- wcsdump(v2);
- fprintf(stderr, "\n");
- report_failure(extra);
- return (0);
-}
-
-/*
- * Pretty standard hexdump routine. As a bonus, if ref != NULL, then
- * any bytes in p that differ from ref will be highlighted with '_'
- * before and after the hex value.
- */
-static void
-hexdump(const char *p, const char *ref, size_t l, size_t offset)
-{
- size_t i, j;
- char sep;
-
- for(i=0; i < l; i+=16) {
- fprintf(stderr, "%04x", (int)(i + offset));
- sep = ' ';
- for (j = 0; j < 16 && i + j < l; j++) {
- if (ref != NULL && p[i + j] != ref[i + j])
- sep = '_';
- fprintf(stderr, "%c%02x", sep, 0xff & (int)p[i+j]);
- if (ref != NULL && p[i + j] == ref[i + j])
- sep = ' ';
- }
- for (; j < 16; j++) {
- fprintf(stderr, "%c ", sep);
- sep = ' ';
- }
- fprintf(stderr, "%c", sep);
- for (j=0; j < 16 && i + j < l; j++) {
- int c = p[i + j];
- if (c >= ' ' && c <= 126)
- fprintf(stderr, "%c", c);
- else
- fprintf(stderr, ".");
- }
- fprintf(stderr, "\n");
- }
-}
-
-/* assertEqualMem() displays the values of the two memory blocks. */
-/* TODO: For long blocks, hexdump the first bytes that actually differ. */
-int
-test_assert_equal_mem(const char *file, int line,
- const char *v1, const char *e1,
- const char *v2, const char *e2,
- size_t l, const char *ld, void *extra)
-{
- ++assertions;
- if (v1 == NULL || v2 == NULL) {
- if (v1 == v2) {
- msg[0] = '\0';
- return (1);
- }
- } else if (memcmp(v1, v2, l) == 0) {
- msg[0] = '\0';
- return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n",
- file, line);
- fprintf(stderr, " size %s = %d\n", ld, (int)l);
- fprintf(stderr, " Dump of %s\n", e1);
- hexdump(v1, v2, l < 32 ? l : 32, 0);
- fprintf(stderr, " Dump of %s\n", e2);
- hexdump(v2, v1, l < 32 ? l : 32, 0);
- fprintf(stderr, "\n");
- report_failure(extra);
- return (0);
-}
-
-int
-test_assert_empty_file(const char *f1fmt, ...)
-{
- char buff[1024];
- char f1[1024];
- struct stat st;
- va_list ap;
- ssize_t s;
- int fd;
-
-
- va_start(ap, f1fmt);
- vsprintf(f1, f1fmt, ap);
- va_end(ap);
-
- if (stat(f1, &st) != 0) {
- fprintf(stderr, "%s:%d: Could not stat: %s\n",
- test_filename, test_line, f1);
- failures ++;
- report_failure(NULL);
- return (0);
- }
- if (st.st_size == 0)
- return (1);
-
- failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
- return (0);
-
- fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
- fprintf(stderr, " File size: %d\n", (int)st.st_size);
- fprintf(stderr, " Contents:\n");
- fd = open(f1, O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, " Unable to open %s\n", f1);
- } else {
- s = ((off_t)sizeof(buff) < st.st_size) ?
- (ssize_t)sizeof(buff) : (ssize_t)st.st_size;
- s = read(fd, buff, s);
- hexdump(buff, NULL, s, 0);
- close(fd);
- }
- report_failure(NULL);
- return (0);
-}
-
-int
-test_assert_non_empty_file(const char *f1fmt, ...)
-{
- char f1[1024];
- struct stat st;
- va_list ap;
-
-
- va_start(ap, f1fmt);
- vsprintf(f1, f1fmt, ap);
- va_end(ap);
-
- if (stat(f1, &st) != 0) {
- fprintf(stderr, "%s:%d: Could not stat: %s\n",
- test_filename, test_line, f1);
- report_failure(NULL);
- failures++;
- return (0);
- }
- if (st.st_size != 0)
- return (1);
-
- failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
- return (0);
-
- fprintf(stderr, "%s:%d: File empty: %s\n",
- test_filename, test_line, f1);
- report_failure(NULL);
- return (0);
-}
-
-/* assertEqualFile() asserts that two files have the same contents. */
-/* TODO: hexdump the first bytes that actually differ. */
-int
-test_assert_equal_file(const char *f1, const char *f2pattern, ...)
-{
- char f2[1024];
- va_list ap;
- char buff1[1024];
- char buff2[1024];
- int fd1, fd2;
- int n1, n2;
-
- va_start(ap, f2pattern);
- vsprintf(f2, f2pattern, ap);
- va_end(ap);
-
- fd1 = open(f1, O_RDONLY);
- fd2 = open(f2, O_RDONLY);
- for (;;) {
- n1 = read(fd1, buff1, sizeof(buff1));
- n2 = read(fd2, buff2, sizeof(buff2));
- if (n1 != n2)
- break;
- if (n1 == 0 && n2 == 0) {
- close(fd1);
- close(fd2);
- return (1);
- }
- if (memcmp(buff1, buff2, n1) != 0)
- break;
- }
- close(fd1);
- close(fd2);
- failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
- return (0);
- fprintf(stderr, "%s:%d: Files are not identical\n",
- test_filename, test_line);
- fprintf(stderr, " file1=\"%s\"\n", f1);
- fprintf(stderr, " file2=\"%s\"\n", f2);
- report_failure(test_extra);
- return (0);
-}
-
-int
-test_assert_file_exists(const char *fpattern, ...)
-{
- char f[1024];
- va_list ap;
-
- va_start(ap, fpattern);
- vsprintf(f, fpattern, ap);
- va_end(ap);
-
- if (!access(f, F_OK))
- return (1);
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File doesn't exist\n",
- test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
- report_failure(test_extra);
- }
- return (0);
-}
-
-int
-test_assert_file_not_exists(const char *fpattern, ...)
-{
- char f[1024];
- va_list ap;
-
- va_start(ap, fpattern);
- vsprintf(f, fpattern, ap);
- va_end(ap);
-
- if (access(f, F_OK))
- return (1);
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File exists and shouldn't\n",
- test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
- report_failure(test_extra);
- }
- return (0);
-}
-
-/* assertFileContents() asserts the contents of a file. */
-int
-test_assert_file_contents(const void *buff, int s, const char *fpattern, ...)
-{
- char f[1024];
- va_list ap;
- char *contents;
- int fd;
- int n;
-
- va_start(ap, fpattern);
- vsprintf(f, fpattern, ap);
- va_end(ap);
-
- fd = open(f, O_RDONLY);
- if (fd < 0) {
- failures ++;
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File doesn't exist: %s\n",
- test_filename, test_line, f);
- report_failure(test_extra);
- }
- return (0);
- }
- contents = malloc(s * 2);
- n = read(fd, contents, s * 2);
- close(fd);
- if (n == s && memcmp(buff, contents, s) == 0) {
- free(contents);
- return (1);
- }
- failures ++;
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File contents don't match\n",
- test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
- if (n > 0)
- hexdump(contents, buff, n, 0);
- else {
- fprintf(stderr, " File empty, contents should be:\n");
- hexdump(buff, NULL, s, 0);
- }
- report_failure(test_extra);
- }
- free(contents);
- return (0);
-}
-
-/*
- * Call standard system() call, but build up the command line using
- * sprintf() conventions.
- */
-int
-systemf(const char *fmt, ...)
-{
- char buff[8192];
- va_list ap;
- int r;
-
- va_start(ap, fmt);
- vsprintf(buff, fmt, ap);
- r = system(buff);
- va_end(ap);
- return (r);
-}
-
-/*
- * Slurp a file into memory for ease of comparison and testing.
- * Returns size of file in 'sizep' if non-NULL, null-terminates
- * data in memory for ease of use.
- */
-char *
-slurpfile(size_t * sizep, const char *fmt, ...)
-{
- char filename[8192];
- struct stat st;
- va_list ap;
- char *p;
- ssize_t bytes_read;
- int fd;
- int r;
-
- va_start(ap, fmt);
- vsprintf(filename, fmt, ap);
- va_end(ap);
-
- fd = open(filename, O_RDONLY);
- if (fd < 0) {
- /* Note: No error; non-existent file is okay here. */
- return (NULL);
- }
- r = fstat(fd, &st);
- if (r != 0) {
- fprintf(stderr, "Can't stat file %s\n", filename);
- close(fd);
- return (NULL);
- }
- p = malloc(st.st_size + 1);
- if (p == NULL) {
- fprintf(stderr, "Can't allocate %ld bytes of memory to read file %s\n", (long int)st.st_size, filename);
- close(fd);
- return (NULL);
- }
- bytes_read = read(fd, p, st.st_size);
- if (bytes_read < st.st_size) {
- fprintf(stderr, "Can't read file %s\n", filename);
- close(fd);
- free(p);
- return (NULL);
- }
- p[st.st_size] = '\0';
- if (sizep != NULL)
- *sizep = (size_t)st.st_size;
- close(fd);
- return (p);
-}
-
-/*
- * "list.h" is automatically generated; it just has a lot of lines like:
- * DEFINE_TEST(function_name)
- * It's used above to declare all of the test functions.
- * We reuse it here to define a list of all tests (functions and names).
- */
-#undef DEFINE_TEST
-#define DEFINE_TEST(n) { n, #n },
-struct { void (*func)(void); const char *name; } tests[] = {
- #include "list.h"
-};
-
-/*
- * Each test is run in a private work dir. Those work dirs
- * do have consistent and predictable names, in case a group
- * of tests need to collaborate. However, there is no provision
- * for requiring that tests run in a certain order.
- */
-static int test_run(int i, const char *tmpdir)
-{
- int failures_before = failures;
-
- if (!quiet_flag) {
- printf("%d: %s\n", i, tests[i].name);
- fflush(stdout);
- }
-
- /*
- * Always explicitly chdir() in case the last test moved us to
- * a strange place.
- */
- if (chdir(tmpdir)) {
- fprintf(stderr,
- "ERROR: Couldn't chdir to temp dir %s\n",
- tmpdir);
- exit(1);
- }
- /* Create a temp directory for this specific test. */
- if (mkdir(tests[i].name, 0755)) {
- fprintf(stderr,
- "ERROR: Couldn't create temp dir ``%s''\n",
- tests[i].name);
- exit(1);
- }
- /* Chdir() to that work directory. */
- if (chdir(tests[i].name)) {
- fprintf(stderr,
- "ERROR: Couldn't chdir to temp dir ``%s''\n",
- tests[i].name);
- exit(1);
- }
- /* Explicitly reset the locale before each test. */
- setlocale(LC_ALL, "C");
- /* Run the actual test. */
- (*tests[i].func)();
- /* Summarize the results of this test. */
- summarize();
- /* If there were no failures, we can remove the work dir. */
- if (failures == failures_before) {
- if (!keep_temp_files && chdir(tmpdir) == 0) {
-#if defined(_WIN32) && !defined(__CYGWIN__)
- systemf("rmdir /S /Q %s", tests[i].name);
-#else
- systemf("rm -rf %s", tests[i].name);
-#endif
- }
- }
- /* Return appropriate status. */
- return (failures == failures_before ? 0 : 1);
-}
-
-static void usage(const char *program)
-{
- static const int limit = sizeof(tests) / sizeof(tests[0]);
- int i;
-
- printf("Usage: %s [options] <test> <test> ...\n", program);
- printf("Default is to run all tests.\n");
- printf("Otherwise, specify the numbers of the tests you wish to run.\n");
- printf("Options:\n");
- printf(" -d Dump core after any failure, for debugging.\n");
- printf(" -k Keep all temp files.\n");
- printf(" Default: temp files for successful tests deleted.\n");
-#ifdef PROGRAM
- printf(" -p <path> Path to executable to be tested.\n");
- printf(" Default: path taken from " ENVBASE " environment variable.\n");
-#endif
- printf(" -q Quiet.\n");
- printf(" -r <dir> Path to dir containing reference files.\n");
- printf(" Default: Current directory.\n");
- printf(" -v Verbose.\n");
- printf("Available tests:\n");
- for (i = 0; i < limit; i++)
- printf(" %d: %s\n", i, tests[i].name);
- exit(1);
-}
-
-#define UUDECODE(c) (((c) - 0x20) & 0x3f)
-
-void
-extract_reference_file(const char *name)
-{
- char buff[1024];
- FILE *in, *out;
-
- sprintf(buff, "%s/%s.uu", refdir, name);
- in = fopen(buff, "r");
- failure("Couldn't open reference file %s", buff);
- assert(in != NULL);
- if (in == NULL)
- return;
- /* Read up to and including the 'begin' line. */
- for (;;) {
- if (fgets(buff, sizeof(buff), in) == NULL) {
- /* TODO: This is a failure. */
- return;
- }
- if (memcmp(buff, "begin ", 6) == 0)
- break;
- }
- /* Now, decode the rest and write it. */
- /* Not a lot of error checking here; the input better be right. */
- out = fopen(name, "w");
- while (fgets(buff, sizeof(buff), in) != NULL) {
- char *p = buff;
- int bytes;
-
- if (memcmp(buff, "end", 3) == 0)
- break;
-
- bytes = UUDECODE(*p++);
- while (bytes > 0) {
- int n = 0;
- /* Write out 1-3 bytes from that. */
- if (bytes > 0) {
- n = UUDECODE(*p++) << 18;
- n |= UUDECODE(*p++) << 12;
- fputc(n >> 16, out);
- --bytes;
- }
- if (bytes > 0) {
- n |= UUDECODE(*p++) << 6;
- fputc((n >> 8) & 0xFF, out);
- --bytes;
- }
- if (bytes > 0) {
- n |= UUDECODE(*p++);
- fputc(n & 0xFF, out);
- --bytes;
- }
- }
- }
- fclose(out);
- fclose(in);
-}
-
-
-int main(int argc, char **argv)
-{
- static const int limit = sizeof(tests) / sizeof(tests[0]);
- int i, tests_run = 0, tests_failed = 0, opt;
- time_t now;
- char *refdir_alloc = NULL;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- char *testprg;
-#endif
- const char *tmp, *opt_arg, *progname, *p;
- char tmpdir[256];
- char tmpdir_timestamp[256];
-
- (void)argc; /* UNUSED */
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /* Make sure open() function will be used with a binary mode. */
- /* on cygwin, we need something similar, but instead link against */
- /* a special startup object, binmode.o */
- _set_fmode(_O_BINARY);
-#endif
- /*
- * Name of this program, used to build root of our temp directory
- * tree.
- */
- progname = p = argv[0];
- while (*p != '\0') {
- /* Support \ or / dir separators for Windows compat. */
- if (*p == '/' || *p == '\\')
- progname = p + 1;
- ++p;
- }
-
-#ifdef PROGRAM
- /* Get the target program from environment, if available. */
- testprog = getenv(ENVBASE);
-#endif
-
- if (getenv("TMPDIR") != NULL)
- tmp = getenv("TMPDIR");
- else if (getenv("TMP") != NULL)
- tmp = getenv("TMP");
- else if (getenv("TEMP") != NULL)
- tmp = getenv("TEMP");
- else if (getenv("TEMPDIR") != NULL)
- tmp = getenv("TEMPDIR");
- else
- tmp = "/tmp";
-
- /* Allow -d to be controlled through the environment. */
- if (getenv(ENVBASE "_DEBUG") != NULL)
- dump_on_failure = 1;
-
- /* Get the directory holding test files from environment. */
- refdir = getenv(ENVBASE "_TEST_FILES");
-
- /*
- * Parse options, without using getopt(), which isn't available
- * on all platforms.
- */
- ++argv; /* Skip program name */
- while (*argv != NULL) {
- if (**argv != '-')
- break;
- p = *argv++;
- ++p; /* Skip '-' */
- while (*p != '\0') {
- opt = *p++;
- opt_arg = NULL;
- /* If 'opt' takes an argument, parse that. */
- if (opt == 'p' || opt == 'r') {
- if (*p != '\0')
- opt_arg = p;
- else if (*argv == NULL) {
- fprintf(stderr,
- "Option -%c requires argument.\n",
- opt);
- usage(progname);
- } else
- opt_arg = *argv++;
- p = ""; /* End of this option word. */
- }
-
- /* Now, handle the option. */
- switch (opt) {
- case 'd':
- dump_on_failure = 1;
- break;
- case 'k':
- keep_temp_files = 1;
- break;
- case 'p':
-#ifdef PROGRAM
- testprog = opt_arg;
-#else
- usage(progname);
-#endif
- break;
- case 'q':
- quiet_flag++;
- break;
- case 'r':
- refdir = opt_arg;
- break;
- case 'v':
- verbose = 1;
- break;
- case '?':
- default:
- usage(progname);
- }
- }
- }
-
- /*
- * Sanity-check that our options make sense.
- */
-#ifdef PROGRAM
- if (testprog == NULL)
- usage(progname);
-#endif
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /*
- * command.com cannot accept the command used '/' with drive
- * name such as c:/xxx/command.exe when use '|' pipe handling.
- */
- testprg = strdup(testprog);
- for (i = 0; testprg[i] != '\0'; i++) {
- if (testprg[i] == '/')
- testprg[i] = '\\';
- }
- testprog = testprg;
-#endif
-
- /*
- * Create a temp directory for the following tests.
- * Include the time the tests started as part of the name,
- * to make it easier to track the results of multiple tests.
- */
- now = time(NULL);
- for (i = 0; i < 1000; i++) {
- strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
- "%Y-%m-%dT%H.%M.%S",
- localtime(&now));
- sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
- tmpdir_timestamp, i);
- if (mkdir(tmpdir,0755) == 0)
- break;
- if (errno == EEXIST)
- continue;
- fprintf(stderr, "ERROR: Unable to create temp directory %s\n",
- tmpdir);
- exit(1);
- }
-
- /*
- * If the user didn't specify a directory for locating
- * reference files, use the current directory for that.
- */
- if (refdir == NULL) {
- char *q;
- systemf("/bin/pwd > %s/refdir", tmpdir);
- q = slurpfile(NULL, "%s/refdir", tmpdir);
- refdir = refdir_alloc = q;
- q += strlen(refdir);
- while (q[-1] == '\n') {
- --q;
- *q = '\0';
- }
- systemf("rm %s/refdir", tmpdir);
- }
-
- /*
- * Banner with basic information.
- */
- if (!quiet_flag) {
- printf("Running tests in: %s\n", tmpdir);
- printf("Reference files will be read from: %s\n", refdir);
-#ifdef PROGRAM
- printf("Running tests on: %s\n", testprog);
-#endif
- printf("Exercising: ");
- fflush(stdout);
- printf("%s\n", EXTRA_VERSION);
- }
-
- /*
- * Run some or all of the individual tests.
- */
- if (*argv == NULL) {
- /* Default: Run all tests. */
- for (i = 0; i < limit; i++) {
- if (test_run(i, tmpdir))
- tests_failed++;
- tests_run++;
- }
- } else {
- while (*(argv) != NULL) {
- i = atoi(*argv);
- if (**argv < '0' || **argv > '9' || i < 0 || i >= limit) {
- printf("*** INVALID Test %s\n", *argv);
- usage(progname);
- } else {
- if (test_run(i, tmpdir))
- tests_failed++;
- tests_run++;
- }
- argv++;
- }
- }
-
- /*
- * Report summary statistics.
- */
- if (!quiet_flag) {
- printf("\n");
- printf("%d of %d tests reported failures\n",
- tests_failed, tests_run);
- printf(" Total of %d assertions checked.\n", assertions);
- printf(" Total of %d assertions failed.\n", failures);
- printf(" Total of %d assertions skipped.\n", skips);
- }
-
- free(refdir_alloc);
-
- /* If the final tmpdir is empty, we can remove it. */
- /* This should be the usual case when all tests succeed. */
- chdir("..");
- rmdir(tmpdir);
-
- return (tests_failed);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test.h b/libarchive/libarchive-2.7.1/tar/test/test.h
deleted file mode 100644
index c2b40c0..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2003-2006 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/usr.bin/tar/test/test.h,v 1.4 2008/08/21 07:04:57 kientzle Exp $
- */
-
-/* Every test program should #include "test.h" as the first thing. */
-
-/*
- * The goal of this file (and the matching test.c) is to
- * simplify the very repetitive test-*.c test programs.
- */
-#if defined(HAVE_CONFIG_H)
-/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "config.h"
-#elif defined(__FreeBSD__)
-/* Building as part of FreeBSD system requires a pre-built config.h. */
-#include "config_freebsd.h"
-#elif defined(_WIN32) && !defined(__CYGWIN__)
-/* Win32 can't run the 'configure' script. */
-#include "config_windows.h"
-#else
-/* Warn if the library hasn't been (automatically or manually) configured. */
-#error Oops: No config.h and no pre-built configuration in test.h.
-#endif
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#include <dirent.h>
-#else
-#define dirent direct
-#include "../bsdtar_windows.h"
-#include <direct.h>
-#endif
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#include <unistd.h>
-#endif
-#include <wchar.h>
-
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
-#endif
-
-#ifdef __FreeBSD__
-#include <sys/cdefs.h> /* For __FBSDID */
-#else
-/* Some non-FreeBSD platforms such as newlib-derived ones like
- * cygwin, have __FBSDID, so this definition must be guarded.
- */
-#ifndef __FBSDID
-#define __FBSDID(a) /* null */
-#endif
-#endif
-
-/*
- * Redefine DEFINE_TEST for use in defining the test functions.
- */
-#undef DEFINE_TEST
-#define DEFINE_TEST(name) void name(void); void name(void)
-
-/* An implementation of the standard assert() macro */
-#define assert(e) test_assert(__FILE__, __LINE__, (e), #e, NULL)
-
-/* Assert two integers are the same. Reports value of each one if not. */
-#define assertEqualInt(v1,v2) \
- test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-
-/* Assert two strings are the same. Reports value of each one if not. */
-#define assertEqualString(v1,v2) \
- test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-/* As above, but v1 and v2 are wchar_t * */
-#define assertEqualWString(v1,v2) \
- test_assert_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-/* As above, but raw blocks of bytes. */
-#define assertEqualMem(v1, v2, l) \
- test_assert_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
-/* Assert two files are the same; allow printf-style expansion of second name.
- * See below for comments about variable arguments here...
- */
-#define assertEqualFile \
- test_setup(__FILE__, __LINE__);test_assert_equal_file
-/* Assert that a file is empty; supports printf-style arguments. */
-#define assertEmptyFile \
- test_setup(__FILE__, __LINE__);test_assert_empty_file
-/* Assert that a file is not empty; supports printf-style arguments. */
-#define assertNonEmptyFile \
- test_setup(__FILE__, __LINE__);test_assert_non_empty_file
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileExists \
- test_setup(__FILE__, __LINE__);test_assert_file_exists
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileNotExists \
- test_setup(__FILE__, __LINE__);test_assert_file_not_exists
-/* Assert that file contents match a string; supports printf-style arguments. */
-#define assertFileContents \
- test_setup(__FILE__, __LINE__);test_assert_file_contents
-
-/*
- * This would be simple with C99 variadic macros, but I don't want to
- * require that. Instead, I insert a function call before each
- * skipping() call to pass the file and line information down. Crude,
- * but effective.
- */
-#define skipping \
- test_setup(__FILE__, __LINE__);test_skipping
-
-/* Function declarations. These are defined in test_utility.c. */
-void failure(const char *fmt, ...);
-void test_setup(const char *, int);
-void test_skipping(const char *fmt, ...);
-int test_assert(const char *, int, int, const char *, void *);
-int test_assert_empty_file(const char *, ...);
-int test_assert_non_empty_file(const char *, ...);
-int test_assert_equal_file(const char *, const char *, ...);
-int test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *);
-int test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
-int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
-int test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
-int test_assert_file_contents(const void *, int, const char *, ...);
-int test_assert_file_exists(const char *, ...);
-int test_assert_file_not_exists(const char *, ...);
-
-/* Like sprintf, then system() */
-int systemf(const char * fmt, ...);
-
-/* Suck file into string allocated via malloc(). Call free() when done. */
-/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
-char *slurpfile(size_t *, const char *fmt, ...);
-
-/* Extracts named reference file to the current directory. */
-void extract_reference_file(const char *);
-
-/*
- * Special interfaces for program test harness.
- */
-
-/* Pathname of exe to be tested. */
-const char *testprog;
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_0.c b/libarchive/libarchive-2.7.1/tar/test/test_0.c
deleted file mode 100644
index e7f0001..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_0.c
+++ /dev/null
@@ -1,67 +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_0.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
-
-/*
- * This first test does basic sanity checks on the environment. For
- * most of these, we just exit on failure.
- */
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#define DEV_NULL "/dev/null"
-#else
-#define DEV_NULL "NUL"
-#endif
-
-DEFINE_TEST(test_0)
-{
- struct stat st;
-
- failure("File %s does not exist?!", testprog);
- if (!assertEqualInt(0, stat(testprog, &st)))
- exit(1);
-
- failure("%s is not executable?!", testprog);
- if (!assert((st.st_mode & 0111) != 0))
- exit(1);
-
- /*
- * Try to succesfully run the program; this requires that
- * we know some option that will succeed.
- */
- if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
- /* This worked. */
- } else if (0 == systemf("%s -W version >" DEV_NULL, testprog)) {
- /* This worked. */
- } else {
- failure("Unable to successfully run any of the following:\n"
- " * %s --version\n"
- " * %s -W version\n",
- testprog, testprog);
- assert(0);
- }
-
- /* TODO: Ensure that our reference files are available. */
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_basic.c b/libarchive/libarchive-2.7.1/tar/test/test_basic.c
deleted file mode 100644
index f57123d..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_basic.c
+++ /dev/null
@@ -1,185 +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_basic.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
-
-
-static void
-basic_tar(const char *target, const char *pack_options,
- const char *unpack_options, const char *flist)
-{
- struct stat st, st2;
-#if !defined(_WIN32) || defined(__CYGWIN__)
- char buff[128];
-#endif
- int r;
-
- assertEqualInt(0, mkdir(target, 0775));
-
- /* Use the tar program to create an archive. */
-#if !defined(_WIN32) || defined(__CYGWIN__)
- r = systemf("%s cf - %s `cat %s` >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target);
-#else
- r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target);
-#endif
- failure("Error invoking %s cf -", testprog, pack_options);
- assertEqualInt(r, 0);
-
- chdir(target);
-
- /* Verify that nothing went to stderr. */
- assertEmptyFile("pack.err");
-
- /*
- * Use tar to unpack the archive into another directory.
- */
- r = systemf("%s xf archive %s >unpack.out 2>unpack.err", testprog, unpack_options);
- failure("Error invoking %s xf archive %s", testprog, unpack_options);
- assertEqualInt(r, 0);
-
- /* Verify that nothing went to stderr. */
- assertEmptyFile("unpack.err");
-
- /*
- * Verify unpacked files.
- */
-
- /* Regular file with 2 links. */
- r = lstat("file", &st);
- failure("Failed to stat file %s/file, errno=%d", target, errno);
- assertEqualInt(r, 0);
- if (r == 0) {
- assert(S_ISREG(st.st_mode));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- assertEqualInt(0644, st.st_mode & 0777);
-#else
- assertEqualInt(0600, st.st_mode & 0700);
-#endif
- assertEqualInt(10, st.st_size);
- failure("file %s/file", target);
- assertEqualInt(2, st.st_nlink);
- }
-
- /* Another name for the same file. */
- r = lstat("linkfile", &st2);
- failure("Failed to stat file %s/linkfile, errno=%d", target, errno);
- assertEqualInt(r, 0);
- if (r == 0) {
- assert(S_ISREG(st2.st_mode));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- assertEqualInt(0644, st2.st_mode & 0777);
-#else
- assertEqualInt(0600, st2.st_mode & 0700);
-#endif
- assertEqualInt(10, st2.st_size);
- failure("file %s/linkfile", target);
- assertEqualInt(2, st2.st_nlink);
- /* Verify that the two are really hardlinked. */
- assertEqualInt(st.st_dev, st2.st_dev);
- failure("%s/linkfile and %s/file aren't really hardlinks", target, target);
- assertEqualInt(st.st_ino, st2.st_ino);
- }
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /* Symlink */
- r = lstat("symlink", &st);
- failure("Failed to stat file %s/symlink, errno=%d", target, errno);
- assertEqualInt(r, 0);
- if (r == 0) {
- failure("symlink should be a symlink; actual mode is %o",
- st.st_mode);
- assert(S_ISLNK(st.st_mode));
- if (S_ISLNK(st.st_mode)) {
- r = readlink("symlink", buff, sizeof(buff));
- assertEqualInt(r, 4);
- buff[r] = '\0';
- assertEqualString(buff, "file");
- }
- }
-#endif
-
- /* dir */
- r = lstat("dir", &st);
- if (r == 0) {
- assertEqualInt(r, 0);
- assert(S_ISDIR(st.st_mode));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- assertEqualInt(0775, st.st_mode & 0777);
-#else
- assertEqualInt(0700, st.st_mode & 0700);
-#endif
- }
-
- chdir("..");
-}
-
-DEFINE_TEST(test_basic)
-{
- int fd;
- int filelist;
- int oldumask;
- const char *flist;
-
- oldumask = umask(0);
-
- /*
- * Create an assortment of files on disk.
- */
- filelist = open("filelist", O_CREAT | O_WRONLY, 0644);
-
- /* File with 10 bytes content. */
- fd = open("file", O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(10, write(fd, "123456789", 10));
- close(fd);
- write(filelist, "file\n", 5);
-
- /* hardlink to above file. */
- assertEqualInt(0, link("file", "linkfile"));
- write(filelist, "linkfile\n", 9);
-
- /* Symlink to above file. */
- assertEqualInt(0, symlink("file", "symlink"));
- write(filelist, "symlink\n", 8);
-
- /* Directory. */
- assertEqualInt(0, mkdir("dir", 0775));
- write(filelist, "dir\n", 4);
- /* All done. */
- close(filelist);
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
- flist = "filelist";
-#else
- flist = "file linkfile symlink dir";
-#endif
- /* Archive/dearchive with a variety of options. */
- basic_tar("copy", "", "", flist);
- /* tar doesn't handle cpio symlinks correctly */
- /* basic_tar("copy_odc", "--format=odc", ""); */
- basic_tar("copy_ustar", "--format=ustar", "", flist);
-
- umask(oldumask);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_copy.c b/libarchive/libarchive-2.7.1/tar/test/test_copy.c
deleted file mode 100644
index d459458..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_copy.c
+++ /dev/null
@@ -1,420 +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_copy.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
-
-#if defined(__CYGWIN__)
-# include <limits.h>
-# include <sys/cygwin.h>
-#endif
-
-/* assumes that cwd is the top of the test tree. Furthermore,
- * assumes that this function is first called with the "longest"
- * cwd involved in the tests. That is, from
- * <testdir>/original
- * as opposed to
- * <testdir>/plain or <testdir>/ustar
- */
-static int
-compute_loop_max(void)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- static int LOOP_MAX = 0;
- char buf[MAX_PATH];
- size_t cwdlen;
-
- if (LOOP_MAX == 0) {
- assert(_getcwd(buf, MAX_PATH) != NULL);
- cwdlen = strlen(buf);
- /* on windows, can't create a directory in which there is not
- * enough room left in MAX_PATH to /also/ create an 8.3 file.
- * Thus, max path len for mkdir is MAX_PATH - 12 ("12345678.123")
- * It is possible also that windows counts the length of cwd against
- * the MAX_PATH maximum, so account for that. Next, account also for
- * "/". And lastly, account for the fact that the relative path
- * has 4 characters when the loop count i = 0.
- */
- LOOP_MAX = MAX_PATH - 12 - (int)cwdlen - 1 - 4;
- }
- return LOOP_MAX;
-#elif defined(__CYGWIN__) && !defined(HAVE_CYGWIN_CONV_PATH)
- static int LOOP_MAX = 0;
- if (LOOP_MAX == 0) {
- char wbuf[PATH_MAX];
- char pbuf[PATH_MAX];
- size_t wcwdlen;
- size_t pcwdlen;
- size_t cwdlen;
- assert(getcwd(pbuf, PATH_MAX) != NULL);
- pcwdlen = strlen(pbuf);
- cygwin_conv_to_full_win32_path(pbuf, wbuf);
- wcwdlen = strlen(wbuf);
- cwdlen = ((wcwdlen > pcwdlen) ? wcwdlen : pcwdlen);
- /* on windows, can't create a directory in which there is not
- * enough room left in PATH_MAX to /also/ create an 8.3 file.
- * Thus, max path len for mkdir is PATH_MAX - 12 ("12345678.123")
- * Then, because cygwin treats even relative paths as if they were
- * absolute, and cwd counts against the PATH_MAX maximum, we must
- * account for that (using worst case of posix or win32 equivalents).
- * Next, account also for "/../" (as used in symlink creation test).
- * And lastly, account for the fact that the relative path has 4
- * characters when the loop count i = 0. These calculations do not
- * apply to cygwin-1.7, because unlike older cygwin, it uses the "wide"
- * functions of the win32 system for all file and directory access.
- */
- LOOP_MAX = PATH_MAX - 12 - (int)cwdlen - 4 - 4;
- }
- return LOOP_MAX;
-#else
- /* cygwin-1.7 ends up here, along with "normal" unix */
- return 200; /* restore pre-r278 depth */
-#endif
-}
-
-static void
-create_tree(void)
-{
- char buff[260];
- char buff2[260];
- int i;
- int fd;
- int LOOP_MAX;
-
- assertEqualInt(0, mkdir("original", 0775));
- chdir("original");
- LOOP_MAX = compute_loop_max();
-
- assertEqualInt(0, mkdir("f", 0775));
- assertEqualInt(0, mkdir("l", 0775));
- assertEqualInt(0, mkdir("m", 0775));
- assertEqualInt(0, mkdir("s", 0775));
- assertEqualInt(0, mkdir("d", 0775));
-
- for (i = 0; i < LOOP_MAX; i++) {
- buff[0] = 'f';
- buff[1] = '/';
- /* Create a file named "f/abcdef..." */
- buff[i + 2] = 'a' + (i % 26);
- buff[i + 3] = '\0';
- fd = open(buff, O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(i + 3, write(fd, buff, strlen(buff)));
- close(fd);
-
- /* Create a link named "l/abcdef..." to the above. */
- strcpy(buff2, buff);
- buff2[0] = 'l';
- assertEqualInt(0, link(buff, buff2));
-
- /* Create a link named "m/abcdef..." to the above. */
- strcpy(buff2, buff);
- buff2[0] = 'm';
- assertEqualInt(0, link(buff, buff2));
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /* Create a symlink named "s/abcdef..." to the above. */
- strcpy(buff2 + 3, buff);
- buff[0] = 's';
- buff2[0] = '.';
- buff2[1] = '.';
- buff2[2] = '/';
- assertEqualInt(0, symlink(buff2, buff));
-#else
- skipping("create a symlink to the above");
-#endif
- /* Create a dir named "d/abcdef...". */
- buff[0] = 'd';
- assertEqualInt(0, mkdir(buff, 0775));
- }
-
- chdir("..");
-}
-
-#define LIMIT_NONE 0
-#define LIMIT_USTAR 1
-
-static void
-verify_tree(int limit)
-{
- struct stat st, st2;
- char filename[260];
- char name1[260];
- char name2[260];
- char contents[260];
- int i, j, r, LOOP_MAX;
- int fd;
- int len;
- const char *p, *dp;
- DIR *d;
- struct dirent *de;
-
- LOOP_MAX = compute_loop_max();
-
- /* Generate the names we know should be there and verify them. */
- for (i = 1; i < LOOP_MAX; i++) {
- /* Generate a base name of the correct length. */
- for (j = 0; j < i; ++j)
- filename[j] = 'a' + (j % 26);
-#if 0
- for (n = i; n > 0; n /= 10)
- filename[--j] = '0' + (n % 10);
-#endif
- filename[i] = '\0';
-
- /* Verify a file named "f/abcdef..." */
- strcpy(name1, "f/");
- strcat(name1, filename);
- if (limit != LIMIT_USTAR || strlen(filename) <= 100) {
- fd = open(name1, O_RDONLY);
- failure("Couldn't open \"%s\": %s",
- name1, strerror(errno));
- if (assert(fd >= 0)) {
- len = read(fd, contents, i + 10);
- close(fd);
- assertEqualInt(len, i + 2);
- /* Verify contents of 'contents' */
- contents[len] = '\0';
- failure("Each test file contains its own name");
- assertEqualString(name1, contents);
- /* stat() for dev/ino for next check */
- assertEqualInt(0, lstat(name1, &st));
- }
- }
-
- /*
- * ustar allows 100 chars for links, and we have
- * "original/" as part of the name, so the link
- * names here can't exceed 91 chars.
- */
- strcpy(name2, "l/");
- strcat(name2, filename);
- if (limit != LIMIT_USTAR || strlen(name2) <= 100) {
- /* Verify hardlink "l/abcdef..." */
- assertEqualInt(0, (r = lstat(name2, &st2)));
- if (r == 0) {
- assertEqualInt(st2.st_dev, st.st_dev);
- assertEqualInt(st2.st_ino, st.st_ino);
- }
-
- /* Verify hardlink "m_abcdef..." */
- name2[0] = 'm';
- assertEqualInt(0, (r = lstat(name2, &st2)));
- if (r == 0) {
- assertEqualInt(st2.st_dev, st.st_dev);
- assertEqualInt(st2.st_ino, st.st_ino);
- }
- }
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /*
- * Symlink text doesn't include the 'original/' prefix,
- * so the limit here is 100 characters.
- */
- /* Verify symlink "s/abcdef..." */
- strcpy(name2, "../s/");
- strcat(name2, filename);
- if (limit != LIMIT_USTAR || strlen(name2) <= 100) {
- /* This is a symlink. */
- failure("Couldn't stat %s (length %d)",
- filename, strlen(filename));
- if (assertEqualInt(0, lstat(name2 + 3, &st2))) {
- assert(S_ISLNK(st2.st_mode));
- /* This is a symlink to the file above. */
- failure("Couldn't stat %s", name2 + 3);
- if (assertEqualInt(0, stat(name2 + 3, &st2))) {
- assertEqualInt(st2.st_dev, st.st_dev);
- assertEqualInt(st2.st_ino, st.st_ino);
- }
- }
- }
-#else
- skipping("verify symlink");
-#endif
- /* Verify dir "d/abcdef...". */
- strcpy(name1, "d/");
- strcat(name1, filename);
- if (limit != LIMIT_USTAR || strlen(filename) < 100) {
- /* This is a dir. */
- failure("Couldn't stat %s (length %d)",
- name1, strlen(filename));
- if (assertEqualInt(0, lstat(name1, &st2))) {
- if (assert(S_ISDIR(st2.st_mode))) {
- /* TODO: opendir/readdir this
- * directory and make sure
- * it's empty.
- */
- }
- }
- }
- }
-
- /* Now make sure nothing is there that shouldn't be. */
- for (dp = "dflms"; *dp != '\0'; ++dp) {
- char dir[2];
- dir[0] = *dp; dir[1] = '\0';
- d = opendir(dir);
- failure("Unable to open dir '%s'", dir);
- if (!assert(d != NULL))
- continue;
- while ((de = readdir(d)) != NULL) {
- p = de->d_name;
- switch(dp[0]) {
- case 'l': case 'm':
- if (limit == LIMIT_USTAR) {
- failure("strlen(p) = %d", strlen(p));
- assert(strlen(p) <= 100);
- }
- case 'd':
- if (limit == LIMIT_USTAR) {
- failure("strlen(p)=%d", strlen(p));
- assert(strlen(p) < 100);
- }
- case 'f': case 's':
- if (limit == LIMIT_USTAR) {
- failure("strlen(p)=%d", strlen(p));
- assert(strlen(p) < 101);
- }
- /* Our files have very particular filename patterns. */
- if (p[0] != '.' || (p[1] != '.' && p[1] != '\0')) {
- for (i = 0; p[i] != '\0' && i < LOOP_MAX; i++) {
- failure("i=%d, p[i]='%c' 'a'+(i%%26)='%c'", i, p[i], 'a' + (i % 26));
- assertEqualInt(p[i], 'a' + (i % 26));
- }
- assert(p[i] == '\0');
- }
- break;
- case '.':
- assert(p[1] == '\0' || (p[1] == '.' && p[2] == '\0'));
- break;
- default:
- failure("File %s shouldn't be here", p);
- assert(0);
- }
- }
- closedir(d);
- }
-}
-
-static void
-copy_basic(void)
-{
- int r;
-
- /* NOTE: for proper operation on cygwin-1.5 and windows, the
- * length of the name of the directory below, "plain", must be
- * less than or equal to the lengthe of the name of the original
- * directory, "original" This restriction derives from the
- * extremely limited pathname lengths on those platforms.
- */
- assertEqualInt(0, mkdir("plain", 0775));
- assertEqualInt(0, chdir("plain"));
-
- /*
- * Use the tar program to create an archive.
- */
- r = systemf("%s cf archive -C ../original f d l m s >pack.out 2>pack.err",
- testprog);
- failure("Error invoking \"%s cf\"", testprog);
- assertEqualInt(r, 0);
-
- /* Verify that nothing went to stdout or stderr. */
- assertEmptyFile("pack.err");
- assertEmptyFile("pack.out");
-
- /*
- * Use tar to unpack the archive into another directory.
- */
- r = systemf("%s xf archive >unpack.out 2>unpack.err", testprog);
- failure("Error invoking %s xf archive", testprog);
- assertEqualInt(r, 0);
-
- /* Verify that nothing went to stdout or stderr. */
- assertEmptyFile("unpack.err");
- assertEmptyFile("unpack.out");
-
- verify_tree(LIMIT_NONE);
- assertEqualInt(0, chdir(".."));
-}
-
-static void
-copy_ustar(void)
-{
- const char *target = "ustar";
- int r;
-
- /* NOTE: for proper operation on cygwin-1.5 and windows, the
- * length of the name of the directory below, "ustar", must be
- * less than or equal to the lengthe of the name of the original
- * directory, "original" This restriction derives from the
- * extremely limited pathname lengths on those platforms.
- */
- assertEqualInt(0, mkdir(target, 0775));
- assertEqualInt(0, chdir(target));
-
- /*
- * Use the tar program to create an archive.
- */
- r = systemf("%s cf archive --format=ustar -C ../original f d l m s >pack.out 2>pack.err",
- testprog);
- failure("Error invoking \"%s cf archive --format=ustar\"", testprog);
- assertEqualInt(r, 0);
-
- /* Verify that nothing went to stdout. */
- assertEmptyFile("pack.out");
- /* Stderr is non-empty, since there are a bunch of files
- * with filenames too long to archive. */
-
- /*
- * Use tar to unpack the archive into another directory.
- */
- r = systemf("%s xf archive >unpack.out 2>unpack.err", testprog);
- failure("Error invoking %s xf archive", testprog);
- assertEqualInt(r, 0);
-
- /* Verify that nothing went to stdout or stderr. */
- assertEmptyFile("unpack.err");
- assertEmptyFile("unpack.out");
-
- chdir("original");
- verify_tree(LIMIT_USTAR);
- chdir("../..");
-}
-
-DEFINE_TEST(test_copy)
-{
- int oldumask;
-
- oldumask = umask(0);
-
- create_tree(); /* Create sample files in "original" dir. */
-
- /* Test simple "tar -c | tar -x" pipeline copy. */
- copy_basic();
-
- /* Same, but constrain to ustar format. */
- copy_ustar();
-
- umask(oldumask);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_getdate.c b/libarchive/libarchive-2.7.1/tar/test/test_getdate.c
deleted file mode 100644
index eac5710..0000000
--- a/libarchive/libarchive-2.7.1/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/libarchive/libarchive-2.7.1/tar/test/test_help.c b/libarchive/libarchive-2.7.1/tar/test/test_help.c
deleted file mode 100644
index 163e212..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_help.c
+++ /dev/null
@@ -1,81 +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_help.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
-
-/*
- * Test that "--help", "-h", and "-W help" options all work and
- * generate reasonable output.
- */
-
-static int
-in_first_line(const char *p, const char *substring)
-{
- size_t l = strlen(substring);
-
- while (*p != '\0' && *p != '\n') {
- if (memcmp(p, substring, l) == 0)
- return (1);
- ++p;
- }
- return (0);
-}
-
-DEFINE_TEST(test_help)
-{
- int r;
- char *p;
- size_t plen;
-
- /* Exercise --help option. */
- r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
- failure("--help should generate nothing to stderr.");
- assertEmptyFile("help.stderr");
- /* Help message should start with name of program. */
- p = slurpfile(&plen, "help.stdout");
- failure("Help output should be long enough.");
- assert(plen >= 6);
- failure("First line of help output should contain 'bsdtar': %s", p);
- assert(in_first_line(p, "bsdtar"));
- /*
- * 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);
- failure("-h should generate nothing to stderr.");
- assertEmptyFile("h.stderr");
- failure("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);
- failure("-W help should generate nothing to stderr.");
- assertEmptyFile("Whelp.stderr");
- failure("stdout should be same for -W help and --help");
- assertEqualFile("Whelp.stdout", "help.stdout");
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_option_T.c b/libarchive/libarchive-2.7.1/tar/test/test_option_T.c
deleted file mode 100644
index 36fe1ef..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_option_T.c
+++ /dev/null
@@ -1,153 +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: src/usr.bin/tar/test/test_option_T.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
-
-static int
-touch(const char *fn)
-{
- int fd = open(fn, O_RDWR | O_CREAT, 0644);
- failure("Couldn't create file '%s', fd=%d, errno=%d (%s)\n",
- fn, fd, errno, strerror(errno));
- if (!assert(fd > 0))
- return (0); /* Failure. */
- close(fd);
- return (1); /* Success */
-}
-
-DEFINE_TEST(test_option_T)
-{
- FILE *f;
- int r;
- struct stat st;
-
- /* Create a simple dir heirarchy; bail if anything fails. */
- if (!assertEqualInt(0, mkdir("d1", 0755))) return;
- if (!assertEqualInt(0, mkdir("d1/d2", 0755))) return;
- if (!touch("d1/f1")) return;
- if (!touch("d1/f2")) return;
- if (!touch("d1/d2/f3")) return;
- if (!touch("d1/d2/f4")) return;
- if (!touch("d1/d2/f5")) return;
-
- /* Populate a file list */
- f = fopen("filelist", "w+");
- if (!assert(f != NULL))
- return;
- fprintf(f, "d1/f1\n");
- fprintf(f, "d1/d2/f4\n");
- fclose(f);
-
- /* Populate a second file list */
- f = fopen("filelist2", "w+");
- if (!assert(f != NULL))
- return;
- fprintf(f, "d1/d2/f3\n");
- fprintf(f, "d1/d2/f5\n");
- fclose(f);
-
- /* Use -c -T to archive up the files. */
- r = systemf("%s -c -f test1.tar -T filelist > test1.out 2> test1.err",
- testprog);
- failure("Failure here probably means that tar can't archive zero-length files without reading them");
- assert(r == 0);
- assertEmptyFile("test1.out");
- assertEmptyFile("test1.err");
-
- /* Use -x -T to dearchive the files */
- if (!assertEqualInt(0, mkdir("test1", 0755))) return;
- systemf("%s -x -f test1.tar -T filelist -C test1"
- " > test1b.out 2> test1b.err", testprog);
- assertEmptyFile("test1b.out");
- assertEmptyFile("test1b.err");
-
- /* Verify the files were extracted. */
- assertFileExists("test1/d1/f1");
- assertFileNotExists("test1/d1/f2");
- assertFileNotExists("test1/d1/d2/f3");
- assertFileExists("test1/d1/d2/f4");
- assertFileNotExists("test1/d1/d2/f5");
-
- /* Use -r -T to add more files to the archive. */
- systemf("%s -r -f test1.tar -T filelist2 > test2.out 2> test2.err",
- testprog);
- assertEmptyFile("test2.out");
- assertEmptyFile("test2.err");
-
- /* Use -x without -T to dearchive the files (ensure -r worked) */
- if (!assertEqualInt(0, mkdir("test3", 0755))) return;
- systemf("%s -x -f test1.tar -C test3"
- " > test3.out 2> test3.err", testprog);
- assertEmptyFile("test3.out");
- assertEmptyFile("test3.err");
- /* Verify the files were extracted.*/
- assertFileExists("test3/d1/f1");
- assertFileNotExists("test3/d1/f2");
- assertFileExists("test3/d1/d2/f3");
- assertFileExists("test3/d1/d2/f4");
- assertFileExists("test3/d1/d2/f5");
-
- /* Use -x -T to dearchive the files (verify -x -T together) */
- if (!assertEqualInt(0, mkdir("test2", 0755))) return;
- systemf("%s -x -f test1.tar -T filelist -C test2"
- " > test2b.out 2> test2b.err", testprog);
- assertEmptyFile("test2b.out");
- assertEmptyFile("test2b.err");
- /* Verify the files were extracted.*/
- assertFileExists("test2/d1/f1");
- assertFileNotExists("test2/d1/f2");
- assertFileNotExists("test2/d1/d2/f3");
- assertFileExists("test2/d1/d2/f4");
- assertFileNotExists("test2/d1/d2/f5");
-
- assertEqualInt(0, mkdir("test4", 0755));
- assertEqualInt(0, mkdir("test4_out", 0755));
- assertEqualInt(0, mkdir("test4_out2", 0755));
- assertEqualInt(0, mkdir("test4/d1", 0755));
- assertEqualInt(1, touch("test4/d1/foo"));
-
- /* Does bsdtar support -s option ? */
- systemf("%s -cf - -s /foo/bar/ test4/d1/foo > NUL 2> check.err",
- testprog);
- assertEqualInt(0, stat("check.err", &st));
- if (st.st_size == 0) {
- systemf("%s -cf - -s /foo/bar/ test4/d1/foo | %s -xf - -C test4_out",
- testprog, testprog);
- assertEmptyFile("test4_out/test4/d1/bar");
- systemf("%s -cf - -s /d1/d2/ test4/d1/foo | %s -xf - -C test4_out",
- testprog, testprog);
- assertEmptyFile("test4_out/test4/d2/foo");
- systemf("%s -cf - -s ,test4/d1/foo,, test4/d1/foo | %s -tvf - > test4.lst",
- testprog, testprog);
- assertEmptyFile("test4.lst");
- systemf("%s -cf - test4/d1/foo | %s -xf - -s /foo/bar/ -C test4_out2",
- testprog, testprog);
- assertEmptyFile("test4_out2/test4/d1/bar");
- } else {
- skipping("bsdtar does not support -s option on this platform");
- }
- /* TODO: Include some use of -C directory-changing within the filelist. */
- /* I'm pretty sure -C within the filelist is broken on extract. */
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_option_q.c b/libarchive/libarchive-2.7.1/tar/test/test_option_q.c
deleted file mode 100644
index d7011c3..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_option_q.c
+++ /dev/null
@@ -1,125 +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_option_q.c,v 1.3 2008/08/22 01:35:08 kientzle Exp $");
-
-DEFINE_TEST(test_option_q)
-{
- int fd;
-
- /*
- * Create an archive with several different versions of the
- * same files. By default, the last version will overwrite
- * any earlier versions. The -q/--fast-read option will
- * stop early, so we can verify -q/--fast-read by seeing
- * which version of each file actually ended up being
- * extracted. This also exercises -r mode, since that's
- * what we use to build up the test archive.
- */
-
- fd = open("foo", O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(4, write(fd, "foo1", 4));
- close(fd);
-
- assertEqualInt(0, systemf("%s -cf archive.tar foo", testprog));
-
- fd = open("foo", O_TRUNC | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(4, write(fd, "foo2", 4));
- close(fd);
-
- assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
-
- fd = open("bar", O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(4, write(fd, "bar1", 4));
- close(fd);
-
- assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
-
- fd = open("foo", O_TRUNC | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(4, write(fd, "foo3", 4));
- close(fd);
-
- assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
-
- fd = open("bar", O_TRUNC | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(4, write(fd, "bar2", 4));
- close(fd);
-
- assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
-
- /*
- * Now, try extracting from the test archive with various
- * combinations of -q.
- */
-
- /* Test 1: -q foo should only extract the first foo. */
- assertEqualInt(0, mkdir("test1", 0755));
- assertEqualInt(0, chdir("test1"));
- assertEqualInt(0,
- systemf("%s -xf ../archive.tar -q foo >test.out 2>test.err",
- testprog));
- assertFileContents("foo1", 4, "foo");
- assertEmptyFile("test.out");
- assertEmptyFile("test.err");
- assertEqualInt(0, chdir(".."));
-
- /* Test 2: -q foo bar should extract up to the first bar. */
- assertEqualInt(0, mkdir("test2", 0755));
- assertEqualInt(0, chdir("test2"));
- assertEqualInt(0,
- systemf("%s -xf ../archive.tar -q foo bar >test.out 2>test.err", testprog));
- assertFileContents("foo2", 4, "foo");
- assertFileContents("bar1", 4, "bar");
- assertEmptyFile("test.out");
- assertEmptyFile("test.err");
- assertEqualInt(0, chdir(".."));
-
- /* Test 3: Same as test 2, but use --fast-read spelling. */
- assertEqualInt(0, mkdir("test3", 0755));
- assertEqualInt(0, chdir("test3"));
- assertEqualInt(0,
- systemf("%s -xf ../archive.tar --fast-read foo bar >test.out 2>test.err", testprog));
- assertFileContents("foo2", 4, "foo");
- assertFileContents("bar1", 4, "bar");
- assertEmptyFile("test.out");
- assertEmptyFile("test.err");
- assertEqualInt(0, chdir(".."));
-
- /* Test 4: Without -q, should extract everything. */
- assertEqualInt(0, mkdir("test4", 0755));
- assertEqualInt(0, chdir("test4"));
- assertEqualInt(0,
- systemf("%s -xf ../archive.tar foo bar >test.out 2>test.err", testprog));
- assertFileContents("foo3", 4, "foo");
- assertFileContents("bar2", 4, "bar");
- assertEmptyFile("test.out");
- assertEmptyFile("test.err");
- assertEqualInt(0, chdir(".."));
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_option_s.c b/libarchive/libarchive-2.7.1/tar/test/test_option_s.c
deleted file mode 100644
index 0dc0f1a..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_option_s.c
+++ /dev/null
@@ -1,106 +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: src/usr.bin/tar/test/test_option_T.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
-
-static int
-mkfile(const char *fn, const char *contents)
-{
- int fd = open(fn, O_RDWR | O_CREAT, 0644);
- failure("Couldn't create file '%s', fd=%d, errno=%d (%s)\n",
- fn, fd, errno, strerror(errno));
- if (!assert(fd > 0))
- return (1); /* Failure. */
- if (contents != NULL)
- assertEqualInt(strlen(contents),
- write(fd, contents, strlen(contents)));
- assertEqualInt(0, close(fd));
- return (0); /* Success */
-}
-
-DEFINE_TEST(test_option_s)
-{
- struct stat st;
-
- /* Create a sample file heirarchy. */
- assertEqualInt(0, mkdir("in", 0755));
- assertEqualInt(0, mkdir("in/d1", 0755));
- assertEqualInt(0, mkfile("in/d1/foo", "foo"));
- assertEqualInt(0, mkfile("in/d1/bar", "bar"));
-
- /* Does bsdtar support -s option ? */
- systemf("%s -cf - -s /foo/bar/ in/d1/foo > NUL 2> check.err",
- testprog);
- assertEqualInt(0, stat("check.err", &st));
- if (st.st_size != 0) {
- skipping("bsdtar does not support -s option on this platform");
- return;
- }
-
- /*
- * Test 1: Filename substitution when creating archives.
- */
- assertEqualInt(0, mkdir("test1", 0755));
- systemf("%s -cf - -s /foo/bar/ in/d1/foo | %s -xf - -C test1",
- testprog, testprog);
- assertFileContents("foo", 3, "test1/in/d1/bar");
- systemf("%s -cf - -s /d1/d2/ in/d1/foo | %s -xf - -C test1",
- testprog, testprog);
- assertFileContents("foo", 3, "test1/in/d2/foo");
-
-
- /*
- * Test 2: Basic substitution when extracting archive.
- */
- assertEqualInt(0, mkdir("test2", 0755));
- systemf("%s -cf - in/d1/foo | %s -xf - -s /foo/bar/ -C test2",
- testprog, testprog);
- assertFileContents("foo", 3, "test2/in/d1/bar");
-
- /*
- * Test 3: Files with empty names shouldn't be archived.
- */
- systemf("%s -cf - -s ,in/d1/foo,, in/d1/foo | %s -tvf - > in.lst",
- testprog, testprog);
- assertEmptyFile("in.lst");
-
- /*
- * Test 4: Multiple substitutions when extracting archive.
- */
- assertEqualInt(0, mkdir("test4", 0755));
- systemf("%s -cf - in/d1/foo in/d1/bar | %s -xf - -s /foo/bar/ -s }bar}baz} -C test4",
- testprog, testprog);
- assertFileContents("foo", 3, "test4/in/d1/bar");
- assertFileContents("bar", 3, "test4/in/d1/baz");
-
- /*
- * Test 5: Name-switching substitutions when extracting archive.
- */
- assertEqualInt(0, mkdir("test5", 0755));
- systemf("%s -cf - in/d1/foo in/d1/bar | %s -xf - -s /foo/bar/ -s }bar}foo} -C test5",
- testprog, testprog);
- assertFileContents("foo", 3, "test5/in/d1/bar");
- assertFileContents("bar", 3, "test5/in/d1/foo");
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_patterns.c b/libarchive/libarchive-2.7.1/tar/test/test_patterns.c
deleted file mode 100644
index 24664fd..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_patterns.c
+++ /dev/null
@@ -1,183 +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 "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_patterns.c,v 1.6 2008/08/21 22:28:00 kientzle Exp $");
-
-DEFINE_TEST(test_patterns)
-{
- int fd, r;
- const char *reffile2 = "test_patterns_2.tar";
- const char *reffile3 = "test_patterns_3.tar";
- const char *reffile4 = "test_patterns_4.tar";
- const char *p;
-
- /*
- * Test basic command-line pattern handling.
- */
-
- /*
- * Test 1: Files on the command line that don't get matched
- * didn't produce an error.
- *
- * John Baldwin reported this problem in PR bin/121598
- */
- fd = open("foo", O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- close(fd);
- r = systemf("%s cfv tar1.tgz foo > tar1a.out 2> tar1a.err", testprog);
- assertEqualInt(r, 0);
- r = systemf("%s xv --no-same-owner -f tar1.tgz foo bar > tar1b.out 2> tar1b.err", testprog);
- failure("tar should return non-zero because a file was given on the command line that's not in the archive");
- assert(r != 0);
-
- /*
- * Test 2: Check basic matching of full paths that start with /
- */
- extract_reference_file(reffile2);
-
- r = systemf("%s tf %s /tmp/foo/bar > tar2a.out 2> tar2a.err",
- testprog, reffile2);
- assertEqualInt(r, 0);
-#if !defined(_WIN32) || defined(__CYGWIN__)
- p = "/tmp/foo/bar/\n/tmp/foo/bar/baz\n";
-#else
- p = "/tmp/foo/bar/\r\n/tmp/foo/bar/baz\r\n";
-#endif
- assertFileContents(p, strlen(p), "tar2a.out");
- assertEmptyFile("tar2a.err");
-
- /*
- * Test 3 archive has some entries starting with '/' and some not.
- */
- extract_reference_file(reffile3);
-
- /* Test 3a: Pattern tmp/foo/bar should not match /tmp/foo/bar */
- r = systemf("%s x --no-same-owner -f %s tmp/foo/bar > tar3a.out 2> tar3a.err",
- testprog, reffile3);
- assert(r != 0);
- assertEmptyFile("tar3a.out");
-
- /* Test 3b: Pattern /tmp/foo/baz should not match tmp/foo/baz */
- assertNonEmptyFile("tar3a.err");
- /* Again, with the '/' */
- r = systemf("%s x --no-same-owner -f %s /tmp/foo/baz > tar3b.out 2> tar3b.err",
- testprog, reffile3);
- assert(r != 0);
- assertEmptyFile("tar3b.out");
- assertNonEmptyFile("tar3b.err");
-
- /* Test 3c: ./tmp/foo/bar should not match /tmp/foo/bar */
- r = systemf("%s x --no-same-owner -f %s ./tmp/foo/bar > tar3c.out 2> tar3c.err",
- testprog, reffile3);
- assert(r != 0);
- assertEmptyFile("tar3c.out");
- assertNonEmptyFile("tar3c.err");
-
- /* Test 3d: ./tmp/foo/baz should match tmp/foo/baz */
- r = systemf("%s x --no-same-owner -f %s ./tmp/foo/baz > tar3d.out 2> tar3d.err",
- testprog, reffile3);
- assertEqualInt(r, 0);
- assertEmptyFile("tar3d.out");
- assertEmptyFile("tar3d.err");
- assertEqualInt(0, access("tmp/foo/baz/bar", F_OK));
-
- /*
- * Test 4 archive has some entries starting with windows drive letters
- * such as 'c:\', '//./c:/' or '//?/c:/'.
- */
- extract_reference_file(reffile4);
-
- r = systemf("%s x --no-same-owner -f %s -C tmp > tar4.out 2> tar4.err",
- testprog, reffile4);
- assert(r != 0);
- assertEmptyFile("tar4.out");
- assertNonEmptyFile("tar4.err");
-
- for (r = 1; r <= 54; r++) {
- char file_a[] = "tmp/fileXX";
- char file_b1[] = "tmp/server/share/fileXX";
- char file_b2[] = "tmp/server\\share\\fileXX";
- char file_c[] = "tmp/../fileXX";
- char *filex;
- int xsize;
-
- switch (r) {
- case 15: case 18:
- /*
- * Including server and share names.
- * //?/UNC/server/share/file15
- * //?/unc/server/share/file18
- */
- filex = file_b1;
- xsize = sizeof(file_b1);
- break;
- case 35: case 38: case 52:
- /*
- * Including server and share names.
- * \\?\UNC\server\share\file35
- * \\?\unc\server\share\file38
- * \/?/uNc/server\share\file52
- */
- filex = file_b2;
- xsize = sizeof(file_b2);
- break;
- default:
- filex = file_a;
- xsize = sizeof(file_a);
- break;
- }
- filex[xsize-3] = '0' + r / 10;
- filex[xsize-2] = '0' + r % 10;
- switch (r) {
- case 5: case 6: case 17: case 20: case 25:
- case 26: case 37: case 40: case 43: case 54:
- /*
- * Not extracted patterns.
- * D:../file05
- * c:../../file06
- * //?/UNC/../file17
- * //?/unc/../file20
- * z:..\file25
- * c:..\..\file26
- * \\?\UNC\..\file37
- * \\?\unc\..\file40
- * c:../..\file43
- * \/?\UnC\../file54
- */
- assertEqualInt(-1, access(filex, F_OK));
- filex = file_c;
- xsize = sizeof(file_c);
- filex[xsize-3] = '0' + r / 10;
- filex[xsize-2] = '0' + r % 10;
- assertEqualInt(-1, access(filex, F_OK));
- break;
- default:
- /* Extracted patterns. */
- assertEqualInt(0, access(filex, F_OK));
- break;
- }
- }
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_patterns_2.tar.uu b/libarchive/libarchive-2.7.1/tar/test/test_patterns_2.tar.uu
deleted file mode 100644
index eba2dae..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_patterns_2.tar.uu
+++ /dev/null
@@ -1,231 +0,0 @@
-begin 644 test_patterns_2.tar
-M+W1M<"]F;V\O````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P
-M(#$Q,#4Q,C$R-C4V(#`Q,C0T,0`@-0``````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
-M````````````````````````````````````=VAE96P`````````````````
-M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````O=&UP+V9O;R]B87(O````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````,#`P-S4U(``P,#$W-3`@`#`P
-M,#`P,"``,#`P,#`P,#`P,#`@,3$P-3$R,3(V-3,@,#$S,C`R`"`U````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````'5S=&%R`#`P=&EM``````````````````````````````````````!W
-M:&5E;````````````````````````````````````#`P,#`P,"``,#`P,#`P
-M(```````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````"]T;7`O9F]O+V)A
-M>@``````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`V-#0@`#`P,3<U,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,3`U,3(Q,C8U
-M-B`P,3,Q,C8`(#``````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````=7-T87(`,#!T:6T`````````````````
-M`````````````````````'=H965L````````````````````````````````
-M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````+W1M<"]F;V\O8F%R+V)A>@``````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#8T-"``,#`Q-S4P(``P,#`P,#`@`#`P,#`P
-M,#`P,#`P(#$Q,#4Q,C$R-C4S(#`Q,S8V-P`@,```````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!U<W1A<@`P
-M,'1I;0``````````````````````````````````````=VAE96P`````````
-M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-9````````````````````````````````````
-`
-end
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_patterns_3.tar.uu b/libarchive/libarchive-2.7.1/tar/test/test_patterns_3.tar.uu
deleted file mode 100644
index de60b8d..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_patterns_3.tar.uu
+++ /dev/null
@@ -1,231 +0,0 @@
-begin 644 test_patterns_3.tar
-M+W1M<"]F;V\O8F%R+P``````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P
-M(#$Q,#4S,C`W-34R(#`Q,S(P-@`@-0``````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
-M````````````````````````````````````=VAE96P`````````````````
-M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````O=&UP+V9O;R]B87(O8F%Z+P``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````,#`P-S4U(``P,#$W-3`@`#`P
-M,#`P,"``,#`P,#`P,#`P,#`@,3$P-3,R,#<U-3(@,#$S-S8R`"`U````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````'5S=&%R`#`P=&EM``````````````````````````````````````!W
-M:&5E;````````````````````````````````````#`P,#`P,"``,#`P,#`P
-M(```````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````'1M<"]F;V\O8F%Z
-M+P``````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`W-34@`#`P,3<U,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,3`U,S(P-S4V
-M,"`P,3,Q,S8`(#4`````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````=7-T87(`,#!T:6T`````````````````
-M`````````````````````'=H965L````````````````````````````````
-M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````=&UP+V9O;R]B87HO8F%R+P``````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P
-M,#`P,#`P(#$Q,#4S,C`W-38P(#`Q,S<P,@`@-0``````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!U<W1A<@`P
-M,'1I;0``````````````````````````````````````=VAE96P`````````
-M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-9````````````````````````````````````
-`
-end
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_patterns_4.tar.uu b/libarchive/libarchive-2.7.1/tar/test/test_patterns_4.tar.uu
deleted file mode 100644
index 240af20..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_patterns_4.tar.uu
+++ /dev/null
@@ -1,641 +0,0 @@
-begin 644 test_patterns_4.tar
-M+V9I;&4P,0``````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P
-M(#$Q,34P-C<T-C0R(#`Q,#,S-@`@,```````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,```````
-M````````````````````````````````````````````````````````````
-M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````O+BXO9FEL93`R````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P
-M,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$P-34R`"`P````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````'5S=&%R`#`P````````````````````````````````````````````
-M`````````````````````````````````````````#`P,#`P,"``,#`P,#`P
-M(```````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````"\N+B\N+B]F:6QE
-M,#,`````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T
-M,B`P,3`W-C8`(#``````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````=7-T87(`,#``````````````````````
-M````````````````````````````````````````````````````````````
-M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````8SHO9FEL93`T````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P
-M,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,#4W-@`@,```````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!U<W1A<@`P
-M,```````````````````````````````````````````````````````````
-M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````!$.BXN+V9I;&4P-0``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````,#`P-C0T(``P,#$W
-M-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$P-C<T`"`P
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````'5S=&%R`#`P````````````````````````````````````
-M`````````````````````````````````````````````````#`P,#`P,"``
-M,#`P,#`P(```````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````&,Z+BXO
-M+BXO9FEL93`V````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U
-M,#8W-#8T,B`P,3$Q-#<`(#``````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````=7-T87(`,#``````````````
-M````````````````````````````````````````````````````````````
-M````````````,#`P,#`P(``P,#`P,#`@````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````0SHO+BXO9FEL93`W````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@
-M`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,#<U-``@,```````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````````````!U
-M<W1A<@`P,```````````````````````````````````````````````````
-M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````!A.B\N+B\N+B]F:6QE,#@`
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````,#`P-C0T
-M(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q
-M,C(V`"`P````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````'5S=&%R`#`P````````````````````````````
-M`````````````````````````````````````````````````````````#`P
-M,#`P,"``,#`P,#`P(```````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`"\O+B]C.B]F:6QE,#D`````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P
-M,"`Q,3$U,#8W-#8T,B`P,3$P-S8`(#``````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````=7-T87(`,#``````
-M````````````````````````````````````````````````````````````
-M````````````````````,#`P,#`P(``P,#`P,#`@````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````+R\N+T,Z+RXN+V9I;&4Q,```````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P
-M,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,3(T,0`@,```````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````!U<W1A<@`P,```````````````````````````````````````````
-M```````````````````````````````````````````P,#`P,#`@`#`P,#`P
-M,"``````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````````O+S\O8SHO9FEL
-M93$Q````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V
-M-#(@,#$Q,3$P`"`P````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````'5S=&%R`#`P````````````````````
-M````````````````````````````````````````````````````````````
-M`````#`P,#`P,"``,#`P,#`P(```````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````"\O/R]#.B\N+B]F:6QE,3(`````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P
-M,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$R-C0`(#``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````=7-T87(`
-M,#``````````````````````````````````````````````````````````
-M````````````````````````````,#`P,#`P(``P,#`P,#`@````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````+R\O+V,Z+V9I;&4Q,P``````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````#`P,#8T-"``,#`Q
-M-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,3`W,@`@
-M,```````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````!U<W1A<@`P,```````````````````````````````````
-M```````````````````````````````````````````````````P,#`P,#`@
-M`#`P,#`P,"``````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````O+R\O
-M0SHO+R\O+V9I;&4Q-```````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q
-M-3`V-S0V-#(@,#$Q,S(W`"`P````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````'5S=&%R`#`P````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#`P,"``,#`P,#`P(```````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````"\O/R]53D,O<V5R=F5R+W-H87)E+V9I;&4Q-0``````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q
-M(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3,V,S4`(#``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M=7-T87(`,#``````````````````````````````````````````````````
-M````````````````````````````````````,#`P,#`P(``P,#`P,#`@````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````+R\_+U5.0R]F:6QE,38`
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````#`P,#8T
-M-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q
-M,3(R-@`@,```````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````!U<W1A<@`P,```````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`P,#`@`#`P,#`P,"``````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```O+S\O54Y#+RXN+V9I;&4Q-P``````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P
-M,#`@,3$Q-3`V-S0V-#(@,#$Q-#0R`"`P````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````'5S=&%R`#`P````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#`P,"``,#`P,#`P(```````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````"\O/R]U;F,O<V5R=F5R+W-H87)E+V9I;&4Q
-M.```````````````````````````````````````````````````````````
-M```````````````````````````````````````P,#`V-#0@`#`P,3<U,2``
-M,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,30P,#``(#``````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````=7-T87(`,#``````````````````````````````````````````
-M````````````````````````````````````````````,#`P,#`P(``P,#`P
-M,#`@````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````+R\_+W5N8R]F
-M:6QE,3D`````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T
-M-C0R(#`Q,3,W,0`@,```````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````!U<W1A<@`P,```````````````````
-M````````````````````````````````````````````````````````````
-M```````P,#`P,#`@`#`P,#`P,"``````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````O+S\O=6YC+RXN+V9I;&4R,```````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P
-M,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q-3<T`"`P````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````'5S=&%R
-M`#`P````````````````````````````````````````````````````````
-M`````````````````````````````#`P,#`P,"``,#`P,#`P(```````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````%QF:6QE,C$`````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````````P,#`V-#0@`#`P
-M,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3`T,34`
-M(#``````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````=7-T87(`,#``````````````````````````````````
-M````````````````````````````````````````````````````,#`P,#`P
-M(``P,#`P,#`@````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````7"XN
-M7&9I;&4R,@``````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q
-M,34P-C<T-C0R(#`Q,#<P-@`@,```````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````!U<W1A<@`P,```````````
-M````````````````````````````````````````````````````````````
-M```````````````P,#`P,#`@`#`P,#`P,"``````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````!<+BY<+BY<9FEL93(S````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U
-M,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,3<W`"`P````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`'5S=&%R`#`P````````````````````````````````````````````````
-M`````````````````````````````````````#`P,#`P,"``,#`P,#`P(```
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````$,Z7&9I;&4R-```````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````P,#`V
-M-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P
-M,3`V,34`(#``````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````=7-T87(`,#``````````````````````````
-M````````````````````````````````````````````````````````````
-M,#`P,#`P(``P,#`P,#`@````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````>CHN+EQF:6QE,C4`````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P
-M,#`P(#$Q,34P-C<T-C0R(#`Q,3`T,0`@,```````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````!U<W1A<@`P,```
-M````````````````````````````````````````````````````````````
-M```````````````````````P,#`P,#`@`#`P,#`P,"``````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````!C.BXN7"XN7&9I;&4R-@``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````,#`P-C0T(``P,#$W-3$@
-M`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,S`S`"`P````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````'5S=&%R`#`P````````````````````````````````````````
-M`````````````````````````````````````````````#`P,#`P,"``,#`P
-M,#`P(```````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````%HZ7"XN7&9I
-M;&4R-P``````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W
-M-#8T,B`P,3$Q,S<`(#``````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````=7-T87(`,#``````````````````
-M````````````````````````````````````````````````````````````
-M````````,#`P,#`P(``P,#`P,#`@````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````0SI<+BY<+BY<9FEL93(X````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P
-M,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,30P,0`@,```````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````````!U<W1A
-M<@`P,```````````````````````````````````````````````````````
-M```````````````````````````````P,#`P,#`@`#`P,#`P,"``````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````!<7"Y<8SI<9FEL93(Y````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````,#`P-C0T(``P
-M,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,S8T
-M`"`P````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````'5S=&%R`#`P````````````````````````````````
-M`````````````````````````````````````````````````````#`P,#`P
-M,"``,#`P,#`P(```````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````````%Q<
-M+EQ#.EPN+EQF:6QE,S``````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q
-M,3$U,#8W-#8T,B`P,3$V,#0`(#``````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````=7-T87(`,#``````````
-M````````````````````````````````````````````````````````````
-M````````````````,#`P,#`P(``P,#`P,#`@````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````7%P_7&,Z7&9I;&4S,0``````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W
-M-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,3,W-@`@,```````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``!U<W1A<@`P,```````````````````````````````````````````````
-M```````````````````````````````````````P,#`P,#`@`#`P,#`P,"``
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!<7#]<1#I<+BY<9FEL
-M93,R````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````,#`P
-M-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@
-M,#$Q-C,P`"`P````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````'5S=&%R`#`P````````````````````````
-M````````````````````````````````````````````````````````````
-M`#`P,#`P,"``,#`P,#`P(```````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````%Q<7%QC.EQF:6QE,S,`````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P
-M,#`P,"`Q,3$U,#8W-#8T,B`P,3$T,S4`(#``````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````=7-T87(`,#``
-M````````````````````````````````````````````````````````````
-M````````````````````````,#`P,#`P(``P,#`P,#`@````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````7%Q<7$,Z7%Q<7%QF:6QE,S0`````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````#`P,#8T-"``,#`Q-S4Q
-M(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,C$U-@`@,```
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````!U<W1A<@`P,```````````````````````````````````````
-M```````````````````````````````````````````````P,#`P,#`@`#`P
-M,#`P,"``````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!<7#]<54Y#
-M7'-E<G9E<EQS:&%R95QF:6QE,S4`````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V
-M-S0V-#(@,#$T,C4U`"`P````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````'5S=&%R`#`P````````````````
-M````````````````````````````````````````````````````````````
-M`````````#`P,#`P,"``,#`P,#`P(```````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````%Q</UQ53D-<9FEL93,V````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P
-M,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$U,30`(#``````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````=7-T
-M87(`,#``````````````````````````````````````````````````````
-M````````````````````````````````,#`P,#`P(``P,#`P,#`@````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````7%P_7%5.0UPN+EQF:6QE,S<`
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````#`P,#8T-"``
-M,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,C`P
-M-0`@,```````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````!U<W1A<@`P,```````````````````````````````
-M```````````````````````````````````````````````````````P,#`P
-M,#`@`#`P,#`P,"``````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````````````!<
-M7#]<=6YC7'-E<G9E<EQS:&%R95QF:6QE,S@`````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@
-M,3$Q-3`V-S0V-#(@,#$T-#(P`"`P````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````'5S=&%R`#`P````````
-M````````````````````````````````````````````````````````````
-M`````````````````#`P,#`P,"``,#`P,#`P(```````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````%Q</UQU;F-<9FEL93,Y````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q
-M-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$V-3<`(#``````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````=7-T87(`,#``````````````````````````````````````````````
-M````````````````````````````````````````,#`P,#`P(``P,#`P,#`@
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````7%P_7'5N8UPN+EQF
-M:6QE-#``````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````````#`P
-M,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R
-M(#`Q,C$S-P`@,```````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````!U<W1A<@`P,```````````````````````
-M````````````````````````````````````````````````````````````
-M```P,#`P,#`@`#`P,#`P,"``````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````!<+BXO9FEL930Q````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P
-M,#`P,#`@,3$Q-3`V-S0V-#(@,#$P-C,R`"`P````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````'5S=&%R`#`P
-M````````````````````````````````````````````````````````````
-M`````````````````````````#`P,#`P,"``,#`P,#`P(```````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````%PN+B\N+EQF:6QE-#(`````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````P,#`V-#0@`#`P,3<U
-M,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$Q,C,`(#``
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````=7-T87(`,#``````````````````````````````````````
-M````````````````````````````````````````````````,#`P,#`P(``P
-M,#`P,#`@````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````8SHN+B\N
-M+EQF:6QE-#,`````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P
-M-C<T-C0R(#`Q,3(R-0`@,```````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````!U<W1A<@`P,```````````````
-M````````````````````````````````````````````````````````````
-M```````````P,#`P,#`@`#`P,#`P,"``````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````!#.B\N+EQF:6QE-#0`````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``
-M,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,#,R`"`P````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````````'5S
-M=&%R`#`P````````````````````````````````````````````````````
-M`````````````````````````````````#`P,#`P,"``,#`P,#`P(```````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````$0Z7"XN+RXN7&9I;&4T-0``
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````P,#`V-#0@
-M`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$S
-M,C0`(#``````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````=7-T87(`,#``````````````````````````````
-M````````````````````````````````````````````````````````,#`P
-M,#`P(``P,#`P,#`@````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M7"\N+V,Z7&9I;&4T-@``````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P
-M(#$Q,34P-C<T-C0R(#`Q,3(S,0`@,```````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,```````
-M````````````````````````````````````````````````````````````
-M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````!<7"XO0SI<+BY<9FEL930W````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P
-M,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q-3,W`"`P````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````'5S=&%R`#`P````````````````````````````````````````````
-M`````````````````````````````````````````#`P,#`P,"``,#`P,#`P
-M(```````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````%PO/UQC.B]F:6QE
-M-#@`````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T
-M,B`P,3$R-30`(#``````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````=7-T87(`,#``````````````````````
-M````````````````````````````````````````````````````````````
-M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````7%P_+T0Z+RXN7&9I;&4T.0``````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P
-M,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,34P-@`@,```````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!U<W1A<@`P
-M,```````````````````````````````````````````````````````````
-M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````!<+R]<1#I<9FEL934P````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````,#`P-C0T(``P,#$W
-M-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,C0S`"`P
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````'5S=&%R`#`P````````````````````````````````````
-M`````````````````````````````````````````````````#`P,#`P,"``
-M,#`P,#`P(```````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````````````%Q<+R]C
-M.EPO+UQ<9FEL934Q````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U
-M,#8W-#8T,B`P,3$W,S$`(#``````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````=7-T87(`,#``````````````
-M````````````````````````````````````````````````````````````
-M````````````,#`P,#`P(``P,#`P,#`@````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````7"\_+W5.8R]S97)V97)<<VAA<F5<9FEL934R````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@
-M`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q-#$T-0`@,```````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````````````!U
-M<W1A<@`P,```````````````````````````````````````````````````
-M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````!<7#\O54YC7&9I;&4U,P``
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````,#`P-C0T
-M(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q
-M-#<V`"`P````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````'5S=&%R`#`P````````````````````````````
-M`````````````````````````````````````````````````````````#`P
-M,#`P,"``,#`P,#`P(```````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`%PO/UQ5;D-<+BXO9FEL934T````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P
-M,"`Q,3$U,#8W-#8T,B`P,3$W,3(`(#``````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````=7-T87(`,#``````
-M````````````````````````````````````````````````````````````
-M````````````````````,#`P,#`P(``P,#`P,#`@````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-'````````````
-`
-end
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_stdio.c b/libarchive/libarchive-2.7.1/tar/test/test_stdio.c
deleted file mode 100644
index d770cf1..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_stdio.c
+++ /dev/null
@@ -1,124 +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_stdio.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
-
-DEFINE_TEST(test_stdio)
-{
- int fd;
- int filelist;
- int oldumask;
- int r;
-
- oldumask = umask(0);
-
- /*
- * Create a couple of files on disk.
- */
- filelist = open("filelist", O_CREAT | O_WRONLY, 0644);
- /* File */
- fd = open("f", O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- write(fd, "f\n", 2);
- close(fd);
- write(filelist, "f\n", 2);
- /* Link to above file. */
- assertEqualInt(0, link("f", "l"));
- write(filelist, "l\n", 2);
- close(filelist);
-
- /*
- * Archive/dearchive with a variety of options, verifying
- * stdio paths.
- */
-
- /* 'cf' should generate no output unless there's an error. */
- r = systemf("%s cf archive f l >cf.out 2>cf.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("cf.out");
- assertEmptyFile("cf.err");
-
- /* 'cvf' should generate file list on stderr, empty stdout. */
- r = systemf("%s cvf archive f l >cvf.out 2>cvf.err", testprog);
- assertEqualInt(r, 0);
- failure("'cv' writes filenames to stderr, nothing to stdout (SUSv2)\n"
- "Note that GNU tar writes the file list to stdout by default.");
- assertEmptyFile("cvf.out");
- /* TODO: Verify cvf.err has file list in SUSv2-prescribed format. */
-
- /* 'cvf -' should generate file list on stderr, archive on stdout. */
- r = systemf("%s cvf - f l >cvf-.out 2>cvf-.err", testprog);
- assertEqualInt(r, 0);
- failure("cvf - should write archive to stdout");
- /* TODO: Verify cvf-.out has archive. */
- failure("cvf - should write file list to stderr (SUSv2)");
- /* TODO: Verify cvf-.err has verbose file list. */
-
- /* 'tf' should generate file list on stdout, empty stderr. */
- r = systemf("%s tf archive >tf.out 2>tf.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("tf.err");
- failure("'t' mode should write results to stdout");
- /* TODO: Verify tf.out has file list. */
-
- /* 'tvf' should generate file list on stdout, empty stderr. */
- r = systemf("%s tvf archive >tvf.out 2>tvf.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("tvf.err");
- failure("'tv' mode should write results to stdout");
- /* TODO: Verify tvf.out has file list. */
-
- /* 'tvf -' uses stdin, file list on stdout, empty stderr. */
- r = systemf("%s tvf - < archive >tvf-.out 2>tvf-.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("tvf-.err");
- /* TODO: Verify tvf-.out has file list. */
-
- /* Basic 'xf' should generate no output on stdout or stderr. */
- r = systemf("%s xf archive >xf.out 2>xf.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("xf.err");
- assertEmptyFile("xf.out");
-
- /* 'xvf' should generate list on stderr, empty stdout. */
- r = systemf("%s xvf archive >xvf.out 2>xvf.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("xvf.out");
- /* TODO: Verify xvf.err */
-
- /* 'xvOf' should generate list on stderr, file contents on stdout. */
- r = systemf("%s xvOf archive >xvOf.out 2>xvOf.err", testprog);
- assertEqualInt(r, 0);
- /* TODO: Verify xvOf.out */
- /* TODO: Verify xvf.err */
-
- /* 'xvf -' should generate list on stderr, empty stdout. */
- r = systemf("%s xvf - < archive >xvf-.out 2>xvf-.err", testprog);
- assertEqualInt(r, 0);
- assertEmptyFile("xvf-.out");
- /* TODO: Verify xvf-.err */
-
- umask(oldumask);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_strip_components.c b/libarchive/libarchive-2.7.1/tar/test/test_strip_components.c
deleted file mode 100644
index 8b386dd..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_strip_components.c
+++ /dev/null
@@ -1,110 +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_strip_components.c,v 1.2 2008/11/10 05:24:13 kientzle Exp $");
-
-static int
-touch(const char *fn)
-{
- int fd = open(fn, O_RDWR | O_CREAT, 0644);
- failure("Couldn't create file '%s', fd=%d, errno=%d (%s)\n",
- fn, fd, errno, strerror(errno));
- if (!assert(fd > 0))
- return (0); /* Failure. */
- close(fd);
- return (1); /* Success */
-}
-
-DEFINE_TEST(test_strip_components)
-{
- struct stat st;
-
- assertEqualInt(0, mkdir("d0", 0755));
- assertEqualInt(0, chdir("d0"));
- assertEqualInt(0, mkdir("d1", 0755));
- assertEqualInt(0, mkdir("d1/d2", 0755));
- assertEqualInt(0, mkdir("d1/d2/d3", 0755));
- assertEqualInt(1, touch("d1/d2/f1"));
- assertEqualInt(0, link("d1/d2/f1", "l1"));
- assertEqualInt(0, link("d1/d2/f1", "d1/l2"));
- assertEqualInt(0, symlink("d1/d2/f1", "s1"));
- assertEqualInt(0, symlink("d2/f1", "d1/s2"));
- assertEqualInt(0, chdir(".."));
-
- assertEqualInt(0, systemf("%s -cf test.tar d0", testprog));
-
- assertEqualInt(0, mkdir("target", 0755));
- assertEqualInt(0, systemf("%s -x -C target --strip-components 2 "
- "-f test.tar", testprog));
-
- failure("d0/ is too short and should not get restored");
- assertEqualInt(-1, lstat("target/d0", &st));
- failure("d0/d1/ is too short and should not get restored");
- assertEqualInt(-1, lstat("target/d1", &st));
- failure("d0/d1/s2 is a symlink to something that won't be extracted");
-#if !defined(_WIN32) || defined(__CYGWIN__)
- assertEqualInt(-1, stat("target/s2", &st));
-#else
- skipping("symlink with stat()");
-#endif
- assertEqualInt(0, lstat("target/s2", &st));
- failure("d0/d1/d2 should be extracted");
- assertEqualInt(0, lstat("target/d2", &st));
-
- /*
- * This next is a complicated case. d0/l1, d0/d1/l2, and
- * d0/d1/d2/f1 are all hardlinks to the same file; d0/l1 can't
- * be extracted with --strip-components=2 and the other two
- * can. Remember that tar normally stores the first file with
- * a body and the other as hardlink entries to the first
- * appearance. So the final result depends on the order in
- * which these three names get archived. If d0/l1 is first,
- * none of the three can be restored. If either of the longer
- * names are first, then the two longer ones can both be
- * restored.
- *
- * The tree-walking code used by bsdtar always visits files
- * before subdirectories, so bsdtar's behavior is fortunately
- * deterministic: d0/l1 will always get stored first and the
- * other two will be stored as hardlinks to d0/l1. Since
- * d0/l1 can't be extracted, none of these three will be
- * extracted.
- *
- * It may be worth extending this test to force a particular
- * archiving order so as to exercise both of the cases described
- * above.
- *
- * Of course, this is all totally different for cpio and newc
- * formats because the hardlink management is different.
- * TODO: Rename this to test_strip_components_tar and create
- * parallel tests for cpio and newc formats.
- */
- failure("d0/l1 is too short and should not get restored");
- assertEqualInt(-1, lstat("target/l1", &st));
- failure("d0/d1/l2 is a hardlink to file whose name was too short");
- assertEqualInt(-1, lstat("target/l2", &st));
- failure("d0/d1/d2/f1 is a hardlink to file whose name was too short");
- assertEqualInt(-1, lstat("target/d2/f1", &st));
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_symlink_dir.c b/libarchive/libarchive-2.7.1/tar/test/test_symlink_dir.c
deleted file mode 100644
index 7c5ef13..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_symlink_dir.c
+++ /dev/null
@@ -1,193 +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_symlink_dir.c,v 1.1 2008/09/14 02:16:04 kientzle Exp $");
-
-/*
- * tar -x -P should follow existing symlinks for dirs, but not other
- * content. Plain tar -x should remove symlinks when they're in the
- * way of a dir extraction.
- */
-
-static int
-mkfile(const char *name, int mode, const char *contents, ssize_t size)
-{
- int fd = open(name, O_CREAT | O_WRONLY, mode);
- if (fd < 0)
- return (-1);
- if (size != write(fd, contents, size)) {
- close(fd);
- return (-1);
- }
- close(fd);
- return (0);
-}
-
-DEFINE_TEST(test_symlink_dir)
-{
- struct stat st;
-#if !defined(_WIN32) || defined(__CYGWIN__)
- struct stat st2;
-#endif
- int oldumask;
-
- oldumask = umask(0);
-
- assertEqualInt(0, mkdir("source", 0755));
- assertEqualInt(0, mkfile("source/file", 0755, "a", 1));
- assertEqualInt(0, mkfile("source/file2", 0755, "ab", 2));
- assertEqualInt(0, mkdir("source/dir", 0755));
- assertEqualInt(0, mkdir("source/dir/d", 0755));
- assertEqualInt(0, mkfile("source/dir/f", 0755, "abc", 3));
- assertEqualInt(0, mkdir("source/dir2", 0755));
- assertEqualInt(0, mkdir("source/dir2/d2", 0755));
- assertEqualInt(0, mkfile("source/dir2/f2", 0755, "abcd", 4));
- assertEqualInt(0, mkdir("source/dir3", 0755));
- assertEqualInt(0, mkdir("source/dir3/d3", 0755));
- assertEqualInt(0, mkfile("source/dir3/f3", 0755, "abcde", 5));
-
- assertEqualInt(0,
- systemf("%s -cf test.tar -C source dir dir2 dir3 file file2",
- testprog));
-
- /*
- * Extract with -x and without -P.
- */
- assertEqualInt(0, mkdir("dest1", 0755));
- /* "dir" is a symlink to an existing "real_dir" */
- assertEqualInt(0, mkdir("dest1/real_dir", 0755));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- assertEqualInt(0, symlink("real_dir", "dest1/dir"));
- /* "dir2" is a symlink to a non-existing "real_dir2" */
- assertEqualInt(0, symlink("real_dir2", "dest1/dir2"));
-#else
- skipping("symlink does not work on this platform");
-#endif
- /* "dir3" is a symlink to an existing "non_dir3" */
- assertEqualInt(0, mkfile("dest1/non_dir3", 0755, "abcdef", 6));
- assertEqualInt(0, symlink("non_dir3", "dest1/dir3"));
- /* "file" is a symlink to existing "real_file" */
- assertEqualInt(0, mkfile("dest1/real_file", 0755, "abcdefg", 7));
- assertEqualInt(0, symlink("real_file", "dest1/file"));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /* "file2" is a symlink to non-existing "real_file2" */
- assertEqualInt(0, symlink("real_file2", "dest1/file2"));
-#else
- skipping("symlink does not work on this platform");
-#endif
- assertEqualInt(0, systemf("%s -xf test.tar -C dest1", testprog));
-
- /* dest1/dir symlink should be removed */
- assertEqualInt(0, lstat("dest1/dir", &st));
- failure("symlink to dir was followed when it shouldn't be");
- assert(S_ISDIR(st.st_mode));
- /* dest1/dir2 symlink should be removed */
- assertEqualInt(0, lstat("dest1/dir2", &st));
- failure("Broken symlink wasn't replaced with dir");
- assert(S_ISDIR(st.st_mode));
- /* dest1/dir3 symlink should be removed */
- assertEqualInt(0, lstat("dest1/dir3", &st));
- failure("Symlink to non-dir wasn't replaced with dir");
- assert(S_ISDIR(st.st_mode));
- /* dest1/file symlink should be removed */
- assertEqualInt(0, lstat("dest1/file", &st));
- failure("Symlink to existing file should be removed");
- assert(S_ISREG(st.st_mode));
- /* dest1/file2 symlink should be removed */
- assertEqualInt(0, lstat("dest1/file2", &st));
- failure("Symlink to non-existing file should be removed");
- assert(S_ISREG(st.st_mode));
-
- /*
- * Extract with both -x and -P
- */
- assertEqualInt(0, mkdir("dest2", 0755));
- /* "dir" is a symlink to existing "real_dir" */
- assertEqualInt(0, mkdir("dest2/real_dir", 0755));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- assertEqualInt(0, symlink("real_dir", "dest2/dir"));
- /* "dir2" is a symlink to a non-existing "real_dir2" */
- assertEqualInt(0, symlink("real_dir2", "dest2/dir2"));
-#else
- skipping("symlink does not work on this platform");
-#endif
- /* "dir3" is a symlink to an existing "non_dir3" */
- assertEqualInt(0, mkfile("dest2/non_dir3", 0755, "abcdefgh", 8));
- assertEqualInt(0, symlink("non_dir3", "dest2/dir3"));
- /* "file" is a symlink to existing "real_file" */
- assertEqualInt(0, mkfile("dest2/real_file", 0755, "abcdefghi", 9));
- assertEqualInt(0, symlink("real_file", "dest2/file"));
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /* "file2" is a symlink to non-existing "real_file2" */
- assertEqualInt(0, symlink("real_file2", "dest2/file2"));
-#else
- skipping("symlink does not work on this platform");
-#endif
- assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog));
-
- /* dest2/dir symlink should be followed */
- assertEqualInt(0, lstat("dest2/dir", &st));
- failure("tar -xP removed symlink instead of following it");
-#if !defined(_WIN32) || defined(__CYGWIN__)
- if (assert(S_ISLNK(st.st_mode))) {
- /* Only verify what the symlink points to if it
- * really is a symlink. */
- failure("The symlink should point to a directory");
- assertEqualInt(0, stat("dest2/dir", &st));
- assert(S_ISDIR(st.st_mode));
- failure("The pre-existing directory should still be there");
- assertEqualInt(0, lstat("dest2/real_dir", &st2));
- assert(S_ISDIR(st2.st_mode));
- assertEqualInt(st.st_dev, st2.st_dev);
- failure("symlink should still point to the existing directory");
- assertEqualInt(st.st_ino, st2.st_ino);
- }
-#else
- skipping("symlink does not work on this platform");
-#endif
- /* Contents of 'dir' should be restored */
- assertEqualInt(0, lstat("dest2/dir/d", &st));
- assert(S_ISDIR(st.st_mode));
- assertEqualInt(0, lstat("dest2/dir/f", &st));
- assert(S_ISREG(st.st_mode));
- assertEqualInt(3, st.st_size);
- /* dest2/dir2 symlink should be removed */
- assertEqualInt(0, lstat("dest2/dir2", &st));
- failure("Broken symlink wasn't replaced with dir");
- assert(S_ISDIR(st.st_mode));
- /* dest2/dir3 symlink should be removed */
- assertEqualInt(0, lstat("dest2/dir3", &st));
- failure("Symlink to non-dir wasn't replaced with dir");
- assert(S_ISDIR(st.st_mode));
- /* dest2/file symlink should be removed;
- * even -P shouldn't follow symlinks for files */
- assertEqualInt(0, lstat("dest2/file", &st));
- failure("Symlink to existing file should be removed");
- assert(S_ISREG(st.st_mode));
- /* dest2/file2 symlink should be removed */
- assertEqualInt(0, lstat("dest2/file2", &st));
- failure("Symlink to non-existing file should be removed");
- assert(S_ISREG(st.st_mode));
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_version.c b/libarchive/libarchive-2.7.1/tar/test/test_version.c
deleted file mode 100644
index 68eb685..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_version.c
+++ /dev/null
@@ -1,96 +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_version.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
-
-/*
- * 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);
- if (r != 0)
- r = systemf("%s -W version >version.stdout 2>version.stderr",
- testprog);
- failure("Unable to run either %s --version or %s -W version",
- testprog, testprog);
- if (!assert(r == 0))
- return;
-
- /* --version should generate nothing to stdout. */
- assertEmptyFile("version.stderr");
- /* Verify format of version message. */
- q = p = slurpfile(&s, "version.stdout");
- /* Version message should start with name of program, then space. */
- assert(s > 6);
- failure("Version must start with 'bsdtar': ``%s''", p);
- assertEqualMem(q, "bsdtar ", 7);
- q += 7; s -= 7;
- /* Version number is a series of digits and periods. */
- while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
- ++q;
- --s;
- }
- /* Version number terminated by space. */
- failure("No space after bsdtar version: ``%s''", p);
- assert(s > 1);
- /* Skip a single trailing a,b,c, or d. */
- if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
- ++q;
- failure("No space after bsdtar version: ``%s''", p);
- assert(*q == ' ');
- ++q; --s;
- /* Separator. */
- failure("No `-' between bsdtar and libarchive versions: ``%s''", p);
- assertEqualMem(q, "- ", 2);
- q += 2; s -= 2;
- /* libarchive name and version number */
- failure("Not long enough for libarchive version: ``%s''", p);
- assert(s > 11);
- failure("Libarchive version must start with `libarchive': ``%s''", p);
- assertEqualMem(q, "libarchive ", 11);
- q += 11; s -= 11;
- /* Version number is a series of digits and periods. */
- while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
- ++q;
- --s;
- }
- /* Skip a single trailing a,b,c, or d. */
- if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
- ++q;
- /* All terminated by end-of-line. */
- assert(s >= 1);
- /* Skip an optional CR character (e.g., Windows) */
- failure("Version output must end with \\n or \\r\\n");
- if (*q == '\r') { ++q; --s; }
- assertEqualMem(q, "\n", 1);
- free(p);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/test/test_windows.c b/libarchive/libarchive-2.7.1/tar/test/test_windows.c
deleted file mode 100644
index 5295e5e..0000000
--- a/libarchive/libarchive-2.7.1/tar/test/test_windows.c
+++ /dev/null
@@ -1,322 +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 "test.h"
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-static void
-mkfile(const char *name)
-{
- int fd;
-
- fd = open(name, O_CREAT | O_WRONLY, 0644);
- assert(fd >= 0);
- assertEqualInt(5, write(fd, "01234", 5));
- close(fd);
-}
-
-static void
-mkfullpath(char **path1, char **path2, const char *tpath, int type)
-{
- char *fp1, *fp2, *p1, *p2;
- size_t l;
-
- /*
- * Get full path name of "tpath"
- */
- l = GetFullPathNameA(tpath, 0, NULL, NULL);
- assert(0 != l);
- fp1 = malloc(l);
- assert(NULL != fp1);
- fp2 = malloc(l*2);
- assert(NULL != fp2);
- l = GetFullPathNameA(tpath, l, fp1, NULL);
- if ((type & 0x01) == 0) {
- for (p1 = fp1; *p1 != '\0'; p1++)
- if (*p1 == '\\')
- *p1 = '/';
- }
-
- switch(type) {
- case 0: /* start with "/" */
- case 1: /* start with "\" */
- /* strip "c:" */
- memmove(fp1, fp1 + 2, l - 2);
- fp1[l -2] = '\0';
- p1 = fp1 + 1;
- break;
- case 2: /* start with "c:/" */
- case 3: /* start with "c:\" */
- p1 = fp1 + 3;
- break;
- case 4: /* start with "//./c:/" */
- case 5: /* start with "\\.\c:\" */
- case 6: /* start with "//?/c:/" */
- case 7: /* start with "\\?\c:\" */
- p1 = malloc(l + 4 + 1);
- assert(NULL != p1);
- if (type & 0x1)
- memcpy(p1, "\\\\.\\", 4);
- else
- memcpy(p1, "//./", 4);
- if (type == 6 || type == 7)
- p1[2] = '?';
- memcpy(p1 + 4, fp1, l);
- p1[l + 4] = '\0';
- free(fp1);
- fp1 = p1;
- p1 = fp1 + 7;
- break;
- }
-
- /*
- * Strip leading drive names and converting "\" to "\\"
- */
- p2 = fp2;
- while (*p1 != '\0') {
- if (*p1 == '\\')
- *p2++ = *p1;
- *p2++ = *p1++;
- }
- *p2++ = '\r';
- *p2++ = '\n';
- *p2 = '\0';
-
- *path1 = fp1;
- *path2 = fp2;
-}
-
-static const char list1[] =
- "aaa/\r\naaa/file1\r\naaa/xxa/\r\naaa/xxb/\r\naaa/zzc/\r\n"
- "aaa/zzc/file1\r\naaa/xxb/file1\r\naaa/xxa/file1\r\naab/\r\n"
- "aac/\r\nabb/\r\nabc/\r\nabd/\r\n";
-static const char list2[] =
- "bbb/\r\nbbb/file1\r\nbbb/xxa/\r\nbbb/xxb/\r\nbbb/zzc/\r\n"
- "bbb/zzc/file1\r\nbbb/xxb/file1\r\nbbb/xxa/file1\r\nbbc/\r\n"
- "bbd/\r\nbcc/\r\nbcd/\r\nbce/\r\n";
-static const char list3[] =
- "aac/\r\nabc/\r\nbbc/\r\nbcc/\r\nccc/\r\n";
-static const char list4[] =
- "fff/abca\r\nfff/acca\r\n";
-static const char list5[] =
- "aaa\\\\file1\r\naaa\\\\xxa/\r\naaa\\\\xxa/file1\r\naaa\\\\xxb/\r\n"
- "aaa\\\\xxb/file1\r\naaa\\\\zzc/\r\naaa\\\\zzc/file1\r\n";
-static const char list6[] =
- "fff\\\\abca\r\nfff\\\\acca\r\naaa\\\\xxa/\r\naaa\\\\xxa/file1\r\n"
- "aaa\\\\xxb/\r\naaa\\\\xxb/file1\r\n";
-#endif /* _WIN32 && !__CYGWIN__ */
-
-DEFINE_TEST(test_windows)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- char *fp1, *fp2;
-
- /*
- * Preparre tests.
- * Create directories and files.
- */
- assertEqualInt(0, mkdir("tmp", 0775));
- assertEqualInt(0, chdir("tmp"));
-
- assertEqualInt(0, mkdir("aaa", 0775));
- assertEqualInt(0, mkdir("aaa/xxa", 0775));
- assertEqualInt(0, mkdir("aaa/xxb", 0775));
- assertEqualInt(0, mkdir("aaa/zzc", 0775));
- mkfile("aaa/file1");
- mkfile("aaa/xxa/file1");
- mkfile("aaa/xxb/file1");
- mkfile("aaa/zzc/file1");
- assertEqualInt(0, mkdir("aab", 0775));
- assertEqualInt(0, mkdir("aac", 0775));
- assertEqualInt(0, mkdir("abb", 0775));
- assertEqualInt(0, mkdir("abc", 0775));
- assertEqualInt(0, mkdir("abd", 0775));
- assertEqualInt(0, mkdir("bbb", 0775));
- assertEqualInt(0, mkdir("bbb/xxa", 0775));
- assertEqualInt(0, mkdir("bbb/xxb", 0775));
- assertEqualInt(0, mkdir("bbb/zzc", 0775));
- mkfile("bbb/file1");
- mkfile("bbb/xxa/file1");
- mkfile("bbb/xxb/file1");
- mkfile("bbb/zzc/file1");
- assertEqualInt(0, mkdir("bbc", 0775));
- assertEqualInt(0, mkdir("bbd", 0775));
- assertEqualInt(0, mkdir("bcc", 0775));
- assertEqualInt(0, mkdir("bcd", 0775));
- assertEqualInt(0, mkdir("bce", 0775));
- assertEqualInt(0, mkdir("ccc", 0775));
- assertEqualInt(0, mkdir("fff", 0775));
- mkfile("fff/aaaa");
- mkfile("fff/abba");
- mkfile("fff/abca");
- mkfile("fff/acba");
- mkfile("fff/acca");
-
- /*
- * Test1: Command line pattern matching.
- */
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar a*", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list1, sizeof(list1)-1, "../list");
-
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar b*", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list2, sizeof(list2)-1, "../list");
-
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar ??c", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list3, sizeof(list3)-1, "../list");
-
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar *c", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list3, sizeof(list3)-1, "../list");
-
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar fff/a?ca", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list4, sizeof(list4)-1, "../list");
-
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar aaa\\*", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list5, sizeof(list5)-1, "../list");
-
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar fff\\a?ca aaa\\xx*", testprog));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- assertFileContents(list6, sizeof(list6)-1, "../list");
-
- /*
- * Test2: Archive the file start with drive letters.
- */
- /* Test2a: start with "/" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 0);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2b: start with "\" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 1);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2c: start with "c:/" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 2);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2d: start with "c:\" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 3);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2e: start with "//./c:/" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 4);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2f: start with "\\.\c:\" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 5);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2g: start with "//?/c:/" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 6);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-
- /* Test2h: start with "\\?\c:\" */
- mkfullpath(&fp1, &fp2, "aaa/file1", 7);
- assertEqualInt(0,
- systemf("%s -cf ../archive.tar %s > ../out 2> ../err",
- testprog, fp1));
- assertEqualInt(0,
- systemf("%s -tf ../archive.tar > ../list", testprog));
- /* Check drive letters have been striped. */
- assertFileContents(fp2, strlen(fp2), "../list");
- free(fp1);
- free(fp2);
-#else
- skipping("Windows specific test");
-#endif /* _WIN32 && !__CYGWIN__ */
-}
diff --git a/libarchive/libarchive-2.7.1/tar/tree.c b/libarchive/libarchive-2.7.1/tar/tree.c
deleted file mode 100644
index bebfb79..0000000
--- a/libarchive/libarchive-2.7.1/tar/tree.c
+++ /dev/null
@@ -1,602 +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_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
-
-#include "tree.h"
-
-/*
- * TODO:
- * 1) Loop checking.
- * 3) Arbitrary logical traversals by closing/reopening intermediate fds.
- */
-
-struct tree_entry {
- struct tree_entry *next;
- struct tree_entry *parent;
- char *name;
- size_t dirname_length;
- dev_t dev;
- ino_t ino;
-#ifdef HAVE_FCHDIR
- int fd;
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- char *fullpath;
-#else
-#error fchdir function required.
-#endif
- 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 needsPreVisit 4 /* This entry needs to be previsited. */
-#define needsPostVisit 8 /* This entry needs to be postvisited. */
-
-/*
- * Local data for this package.
- */
-struct tree {
- struct tree_entry *stack;
- struct tree_entry *current;
- DIR *d;
-#ifdef HAVE_FCHDIR
- int initialDirFd;
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- char *initialDir;
-#endif
- int flags;
- int visit_type;
- int tree_errno; /* Error code from last failed operation. */
-
- char *buff;
- const 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. */
-
-
-#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
-#include <stdio.h>
-void
-tree_dump(struct tree *t, FILE *out)
-{
- struct tree_entry *te;
-
- fprintf(out, "\tdepth: %d\n", t->depth);
- fprintf(out, "\tbuff: %s\n", t->buff);
- fprintf(out, "\tpwd: "); fflush(stdout); system("pwd");
- fprintf(out, "\taccess: %s\n", t->basename);
- fprintf(out, "\tstack:\n");
- for (te = t->stack; te != NULL; te = te->next) {
- fprintf(out, "\t\tte->name: %s%s%s\n", te->name,
- te->flags & needsPreVisit ? "" : " *",
- t->current == te ? " (current)" : "");
- }
-}
-#endif
-
-/*
- * 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;
- t->stack = te;
-#ifdef HAVE_FCHDIR
- te->fd = -1;
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- te->fullpath = NULL;
-#endif
- te->name = strdup(path);
- te->flags = needsPreVisit | needsPostVisit;
- 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)
-{
- char *p;
-
- 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. */
- 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);
- }
- 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 ++;
- }
- strncpy(p, name, name_length);
- p[name_length] = '\0';
- t->basename = p;
-}
-
-/*
- * 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));
-#ifdef HAVE_FCHDIR
- t->initialDirFd = open(".", O_RDONLY);
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- t->initialDir = getcwd(NULL, 0);
-#endif
- /*
- * 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 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->fd) != 0) {
- t->tree_errno = errno;
- r = TREE_ERROR_FATAL;
- }
- close(te->fd);
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- if (chdir(te->fullpath) != 0) {
- t->tree_errno = errno;
- r = TREE_ERROR_FATAL;
- }
- free(te->fullpath);
- te->fullpath = NULL;
-#endif
- t->openCount--;
- } else {
- if (chdir("..") != 0) {
- 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;
-
- 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;
- t->basename = t->buff + t->dirname_length;
- /* Special case: starting dir doesn't skip leading '/'. */
- if (t->dirname_length > 0)
- t->basename++;
- free(te->name);
- free(te);
-}
-
-/*
- * Get the next item in the tree traversal.
- */
-int
-tree_next(struct tree *t)
-{
- struct dirent *de = NULL;
- 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) {
- const char *msg = "Unable to continue traversing"
- " directory heirarchy after a fatal error.";
- write(2, msg, strlen(msg));
- *(int *)0 = 1; /* Deliberate SEGV; NULL pointer dereference. */
- exit(1); /* In case the SEGV didn't work. */
- }
-
- /* Handle the startup case by returning the initial entry. */
- if (t->flags & needsReturn) {
- t->flags &= ~needsReturn;
- return (t->visit_type = TREE_REGULAR);
- }
-
- 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 (t->visit_type = TREE_REGULAR);
- }
- }
-
- /* If the current dir needs to be visited, set it up. */
- if (t->stack->flags & needsPreVisit) {
- t->current = t->stack;
- tree_append(t, t->stack->name, strlen(t->stack->name));
- t->stack->flags &= ~needsPreVisit;
- /* If it is a link, set up fd for the ascent. */
- if (t->stack->flags & isDirLink) {
-#ifdef HAVE_FCHDIR
- t->stack->fd = open(".", O_RDONLY);
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- t->stack->fullpath = getcwd(NULL, 0);
-#endif
- t->openCount++;
- if (t->openCount > t->maxOpenCount)
- t->maxOpenCount = t->openCount;
- }
- t->dirname_length = t->path_length;
- if (chdir(t->stack->name) != 0) {
- /* chdir() failed; return error */
- tree_pop(t);
- t->tree_errno = errno;
- return (t->visit_type = TREE_ERROR_DIR);
- }
- t->depth++;
- t->d = opendir(".");
- if (t->d == 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);
- }
- t->flags &= ~hasLstat;
- t->flags &= ~hasStat;
- t->basename = ".";
- return (t->visit_type = TREE_POSTDESCENT);
- }
-
- /* We've done everything necessary for the top stack entry. */
- if (t->stack->flags & needsPostVisit) {
- r = tree_ascend(t);
- tree_pop(t);
- t->flags &= ~hasLstat;
- t->flags &= ~hasStat;
- t->visit_type = r != 0 ? r : TREE_POSTASCENT;
- return (t->visit_type);
- }
- }
- return (t->visit_type = 0);
-}
-
-/*
- * 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(t->basename, &t->st) != 0)
- return NULL;
- 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)) {
- if (lstat(t->basename, &t->lst) != 0)
- return NULL;
- t->flags |= hasLstat;
- }
- return (&t->lst);
-}
-
-/*
- * Test whether current entry is a dir or link to a dir.
- */
-int
-tree_current_is_dir(struct tree *t)
-{
- 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));
-}
-
-/*
- * 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)
-{
- 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));
-}
-
-/*
- * Test whether current entry is a symbolic link.
- */
-int
-tree_current_is_physical_link(struct tree *t)
-{
- const struct stat *st = tree_current_lstat(t);
- if (st == NULL)
- return 0;
- return (S_ISLNK(st->st_mode));
-}
-
-/*
- * 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. */
-#ifdef HAVE_FCHDIR
- if (t->initialDirFd >= 0) {
- fchdir(t->initialDirFd);
- close(t->initialDirFd);
- t->initialDirFd = -1;
- }
-#elif defined(_WIN32) && !defined(__CYGWIN__)
- if (t->initialDir != NULL) {
- chdir(t->initialDir);
- free(t->initialDir);
- t->initialDir = NULL;
- }
-#endif
- free(t);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/tree.h b/libarchive/libarchive-2.7.1/tar/tree.h
deleted file mode 100644
index 30d96fe..0000000
--- a/libarchive/libarchive-2.7.1/tar/tree.h
+++ /dev/null
@@ -1,127 +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 potentially visited three
- * times. Directories are always visited first as part of enumerating
- * their parent. 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 and
- * again just after ascending back to the parent.
- *
- * TREE_ERROR_DIR is returned if the descent failed (because the
- * directory couldn't be opened, for instance). This is returned
- * instead of TREE_PREVISIT/TREE_POSTVISIT. 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.
- */
-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 *);
diff --git a/libarchive/libarchive-2.7.1/tar/util.c b/libarchive/libarchive-2.7.1/tar/util.c
deleted file mode 100644
index 274ff03..0000000
--- a/libarchive/libarchive-2.7.1/tar/util.c
+++ /dev/null
@@ -1,630 +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 "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/util.c,v 1.23 2008/12/15 06:00:25 kientzle Exp $");
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h> /* Linux doesn't define mode_t, etc. in sys/stat.h. */
-#endif
-#include <ctype.h>
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_WCTYPE_H
-#include <wctype.h>
-#else
-/* If we don't have wctype, we need to hack up some version of iswprint(). */
-#define iswprint isprint
-#endif
-
-#include "bsdtar.h"
-
-static void bsdtar_vwarnc(struct bsdtar *, int code,
- const char *fmt, va_list ap);
-static size_t bsdtar_expand_char(char *, size_t, char);
-static const char *strip_components(const char *path, int elements);
-
-/* TODO: Hack up a version of mbtowc for platforms with no wide
- * character support at all. I think the following might suffice,
- * but it needs careful testing.
- * #if !HAVE_MBTOWC
- * #define mbtowc(wcp, p, n) ((*wcp = *p), 1)
- * #endif
- */
-
-/*
- * Print a string, taking care with any non-printable characters.
- *
- * Note that we use a stack-allocated buffer to receive the formatted
- * string if we can. This is partly performance (avoiding a call to
- * malloc()), partly out of expedience (we have to call vsnprintf()
- * before malloc() anyway to find out how big a buffer we need; we may
- * as well point that first call at a small local buffer in case it
- * works), but mostly for safety (so we can use this to print messages
- * about out-of-memory conditions).
- */
-
-void
-safe_fprintf(FILE *f, const char *fmt, ...)
-{
- char fmtbuff_stack[256]; /* Place to format the printf() string. */
- char outbuff[256]; /* Buffer for outgoing characters. */
- char *fmtbuff_heap; /* If fmtbuff_stack is too small, we use malloc */
- char *fmtbuff; /* Pointer to fmtbuff_stack or fmtbuff_heap. */
- int fmtbuff_length;
- int length;
- va_list ap;
- const char *p;
- unsigned i;
- wchar_t wc;
- char try_wc;
-
- /* Use a stack-allocated buffer if we can, for speed and safety. */
- fmtbuff_heap = NULL;
- fmtbuff_length = sizeof(fmtbuff_stack);
- fmtbuff = fmtbuff_stack;
-
- /* Try formatting into the stack buffer. */
- va_start(ap, fmt);
- length = vsnprintf(fmtbuff, fmtbuff_length, fmt, ap);
- va_end(ap);
-
- /* If the result was too large, allocate a buffer on the heap. */
- if (length >= fmtbuff_length) {
- fmtbuff_length = length+1;
- fmtbuff_heap = malloc(fmtbuff_length);
-
- /* Reformat the result into the heap buffer if we can. */
- if (fmtbuff_heap != NULL) {
- fmtbuff = fmtbuff_heap;
- va_start(ap, fmt);
- length = vsnprintf(fmtbuff, fmtbuff_length, fmt, ap);
- va_end(ap);
- } else {
- /* Leave fmtbuff pointing to the truncated
- * string in fmtbuff_stack. */
- length = sizeof(fmtbuff_stack) - 1;
- }
- }
-
- /* Note: mbrtowc() has a cleaner API, but mbtowc() seems a bit
- * more portable, so we use that here instead. */
- mbtowc(NULL, NULL, 0); /* Reset the shift state. */
-
- /* Write data, expanding unprintable characters. */
- p = fmtbuff;
- i = 0;
- try_wc = 1;
- while (*p != '\0') {
- int n;
-
- /* Convert to wide char, test if the wide
- * char is printable in the current locale. */
- if (try_wc && (n = mbtowc(&wc, p, length)) != -1) {
- length -= n;
- if (iswprint(wc) && wc != L'\\') {
- /* Printable, copy the bytes through. */
- while (n-- > 0)
- outbuff[i++] = *p++;
- } else {
- /* Not printable, format the bytes. */
- while (n-- > 0)
- i += bsdtar_expand_char(
- outbuff, i, *p++);
- }
- } else {
- /* After any conversion failure, don't bother
- * trying to convert the rest. */
- i += bsdtar_expand_char(outbuff, i, *p++);
- try_wc = 0;
- }
-
- /* If our output buffer is full, dump it and keep going. */
- if (i > (sizeof(outbuff) - 20)) {
- outbuff[i++] = '\0';
- fprintf(f, "%s", outbuff);
- i = 0;
- }
- }
- outbuff[i++] = '\0';
- fprintf(f, "%s", outbuff);
-
- /* If we allocated a heap-based formatting buffer, free it now. */
- if (fmtbuff_heap != NULL)
- free(fmtbuff_heap);
-}
-
-/*
- * Render an arbitrary sequence of bytes into printable ASCII characters.
- */
-static size_t
-bsdtar_expand_char(char *buff, size_t offset, char c)
-{
- size_t i = offset;
-
- if (isprint((unsigned char)c) && c != '\\')
- buff[i++] = c;
- else {
- buff[i++] = '\\';
- switch (c) {
- case '\a': buff[i++] = 'a'; break;
- case '\b': buff[i++] = 'b'; break;
- case '\f': buff[i++] = 'f'; break;
- case '\n': buff[i++] = 'n'; break;
-#if '\r' != '\n'
- /* On some platforms, \n and \r are the same. */
- case '\r': buff[i++] = 'r'; break;
-#endif
- case '\t': buff[i++] = 't'; break;
- case '\v': buff[i++] = 'v'; break;
- case '\\': buff[i++] = '\\'; break;
- default:
- sprintf(buff + i, "%03o", 0xFF & (int)c);
- i += 3;
- }
- }
-
- return (i - offset);
-}
-
-static void
-bsdtar_vwarnc(struct bsdtar *bsdtar, int code, const char *fmt, va_list ap)
-{
- fprintf(stderr, "%s: ", bsdtar->progname);
- vfprintf(stderr, fmt, ap);
- if (code != 0)
- fprintf(stderr, ": %s", strerror(code));
- fprintf(stderr, "\n");
-}
-
-void
-bsdtar_warnc(struct bsdtar *bsdtar, int code, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- bsdtar_vwarnc(bsdtar, code, fmt, ap);
- va_end(ap);
-}
-
-void
-bsdtar_errc(struct bsdtar *bsdtar, int eval, int code, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- bsdtar_vwarnc(bsdtar, code, fmt, ap);
- va_end(ap);
- exit(eval);
-}
-
-int
-yes(const char *fmt, ...)
-{
- char buff[32];
- char *p;
- ssize_t l;
-
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, " (y/N)? ");
- fflush(stderr);
-
- l = read(2, buff, sizeof(buff) - 1);
- if (l <= 0)
- return (0);
- buff[l] = 0;
-
- for (p = buff; *p != '\0'; p++) {
- if (isspace((unsigned char)*p))
- continue;
- switch(*p) {
- case 'y': case 'Y':
- return (1);
- case 'n': case 'N':
- return (0);
- default:
- return (0);
- }
- }
-
- return (0);
-}
-
-/*
- * Read lines from file and do something with each one. If option_null
- * is set, lines are terminated with zero bytes; otherwise, they're
- * terminated with newlines.
- *
- * This uses a self-sizing buffer to handle arbitrarily-long lines.
- * If the "process" function returns non-zero for any line, this
- * function will return non-zero after attempting to process all
- * remaining lines.
- */
-int
-process_lines(struct bsdtar *bsdtar, const char *pathname,
- int (*process)(struct bsdtar *, const char *))
-{
- FILE *f;
- char *buff, *buff_end, *line_start, *line_end, *p;
- size_t buff_length, new_buff_length, bytes_read, bytes_wanted;
- int separator;
- int ret;
-
- separator = bsdtar->option_null ? '\0' : '\n';
- ret = 0;
-
- if (strcmp(pathname, "-") == 0)
- f = stdin;
- else
- f = fopen(pathname, "r");
- if (f == NULL)
- bsdtar_errc(bsdtar, 1, errno, "Couldn't open %s", pathname);
- buff_length = 8192;
- buff = malloc(buff_length);
- if (buff == NULL)
- bsdtar_errc(bsdtar, 1, ENOMEM, "Can't read %s", pathname);
- line_start = line_end = buff_end = buff;
- for (;;) {
- /* Get some more data into the buffer. */
- bytes_wanted = buff + buff_length - buff_end;
- bytes_read = fread(buff_end, 1, bytes_wanted, f);
- buff_end += bytes_read;
- /* Process all complete lines in the buffer. */
- while (line_end < buff_end) {
- if (*line_end == separator) {
- *line_end = '\0';
- if ((*process)(bsdtar, line_start) != 0)
- ret = -1;
- line_start = line_end + 1;
- line_end = line_start;
- } else
- line_end++;
- }
- if (feof(f))
- break;
- if (ferror(f))
- bsdtar_errc(bsdtar, 1, errno,
- "Can't read %s", pathname);
- if (line_start > buff) {
- /* Move a leftover fractional line to the beginning. */
- memmove(buff, line_start, buff_end - line_start);
- buff_end -= line_start - buff;
- line_end -= line_start - buff;
- line_start = buff;
- } else {
- /* Line is too big; enlarge the buffer. */
- new_buff_length = buff_length * 2;
- if (new_buff_length <= buff_length)
- bsdtar_errc(bsdtar, 1, ENOMEM,
- "Line too long in %s", pathname);
- buff_length = new_buff_length;
- p = realloc(buff, buff_length);
- if (p == NULL)
- bsdtar_errc(bsdtar, 1, ENOMEM,
- "Line too long in %s", pathname);
- buff_end = p + (buff_end - buff);
- line_end = p + (line_end - buff);
- line_start = buff = p;
- }
- }
- /* At end-of-file, handle the final line. */
- if (line_end > line_start) {
- *line_end = '\0';
- if ((*process)(bsdtar, line_start) != 0)
- ret = -1;
- }
- free(buff);
- if (f != stdin)
- fclose(f);
- return (ret);
-}
-
-/*-
- * The logic here for -C <dir> attempts to avoid
- * chdir() as long as possible. For example:
- * "-C /foo -C /bar file" needs chdir("/bar") but not chdir("/foo")
- * "-C /foo -C bar file" needs chdir("/foo/bar")
- * "-C /foo -C bar /file1" does not need chdir()
- * "-C /foo -C bar /file1 file2" needs chdir("/foo/bar") before file2
- *
- * The only correct way to handle this is to record a "pending" chdir
- * request and combine multiple requests intelligently until we
- * need to process a non-absolute file. set_chdir() adds the new dir
- * to the pending list; do_chdir() actually executes any pending chdir.
- *
- * This way, programs that build tar command lines don't have to worry
- * about -C with non-existent directories; such requests will only
- * fail if the directory must be accessed.
- */
-void
-set_chdir(struct bsdtar *bsdtar, const char *newdir)
-{
- if (newdir[0] == '/') {
- /* The -C /foo -C /bar case; dump first one. */
- free(bsdtar->pending_chdir);
- bsdtar->pending_chdir = NULL;
- }
- if (bsdtar->pending_chdir == NULL)
- /* Easy case: no previously-saved dir. */
- bsdtar->pending_chdir = strdup(newdir);
- else {
- /* The -C /foo -C bar case; concatenate */
- char *old_pending = bsdtar->pending_chdir;
- size_t old_len = strlen(old_pending);
- bsdtar->pending_chdir = malloc(old_len + strlen(newdir) + 2);
- if (old_pending[old_len - 1] == '/')
- old_pending[old_len - 1] = '\0';
- if (bsdtar->pending_chdir != NULL)
- sprintf(bsdtar->pending_chdir, "%s/%s",
- old_pending, newdir);
- free(old_pending);
- }
- if (bsdtar->pending_chdir == NULL)
- bsdtar_errc(bsdtar, 1, errno, "No memory");
-}
-
-void
-do_chdir(struct bsdtar *bsdtar)
-{
- if (bsdtar->pending_chdir == NULL)
- return;
-
- if (chdir(bsdtar->pending_chdir) != 0) {
- bsdtar_errc(bsdtar, 1, 0, "could not chdir to '%s'\n",
- bsdtar->pending_chdir);
- }
- free(bsdtar->pending_chdir);
- bsdtar->pending_chdir = NULL;
-}
-
-const char *
-strip_components(const char *path, int elements)
-{
- const char *p = path;
-
- while (elements > 0) {
- switch (*p++) {
- case '/':
- elements--;
- path = p;
- break;
- case '\0':
- /* Path is too short, skip it. */
- return (NULL);
- }
- }
-
- while (*path == '/')
- ++path;
- if (*path == '\0')
- return (NULL);
-
- return (path);
-}
-
-/*
- * Handle --strip-components and any future path-rewriting options.
- * Returns non-zero if the pathname should not be extracted.
- *
- * TODO: Support pax-style regex path rewrites.
- */
-int
-edit_pathname(struct bsdtar *bsdtar, struct archive_entry *entry)
-{
- const char *name = archive_entry_pathname(entry);
-#if HAVE_REGEX_H
- char *subst_name;
- int r;
-#endif
-
-#if HAVE_REGEX_H
- r = apply_substitution(bsdtar, name, &subst_name, 0);
- if (r == -1) {
- bsdtar_warnc(bsdtar, 0, "Invalid substitution, skipping entry");
- return 1;
- }
- if (r == 1) {
- archive_entry_copy_pathname(entry, subst_name);
- if (*subst_name == '\0') {
- free(subst_name);
- return -1;
- } else
- free(subst_name);
- name = archive_entry_pathname(entry);
- }
-
- if (archive_entry_hardlink(entry)) {
- r = apply_substitution(bsdtar, archive_entry_hardlink(entry), &subst_name, 1);
- if (r == -1) {
- bsdtar_warnc(bsdtar, 0, "Invalid substitution, skipping entry");
- return 1;
- }
- if (r == 1) {
- archive_entry_copy_hardlink(entry, subst_name);
- free(subst_name);
- }
- }
- if (archive_entry_symlink(entry) != NULL) {
- r = apply_substitution(bsdtar, archive_entry_symlink(entry), &subst_name, 1);
- if (r == -1) {
- bsdtar_warnc(bsdtar, 0, "Invalid substitution, skipping entry");
- return 1;
- }
- if (r == 1) {
- archive_entry_copy_symlink(entry, subst_name);
- free(subst_name);
- }
- }
-#endif
-
- /* Strip leading dir names as per --strip-components option. */
- if (bsdtar->strip_components > 0) {
- const char *linkname = archive_entry_hardlink(entry);
-
- name = strip_components(name, bsdtar->strip_components);
- if (name == NULL)
- return (1);
-
- if (linkname != NULL) {
- linkname = strip_components(linkname,
- bsdtar->strip_components);
- if (linkname == NULL)
- return (1);
- archive_entry_copy_hardlink(entry, linkname);
- }
- }
-
- /* By default, don't write or restore absolute pathnames. */
- if (!bsdtar->option_absolute_paths) {
- const char *rp, *p = name;
- int slashonly = 1;
-
- /* Remove leading "//./" or "//?/" or "//?/UNC/"
- * (absolute path prefixes used by Windows API) */
- if ((p[0] == '/' || p[0] == '\\') &&
- (p[1] == '/' || p[1] == '\\') &&
- (p[2] == '.' || p[2] == '?') &&
- (p[3] == '/' || p[3] == '\\'))
- {
- if (p[2] == '?' &&
- (p[4] == 'U' || p[4] == 'u') &&
- (p[5] == 'N' || p[5] == 'n') &&
- (p[6] == 'C' || p[6] == 'c') &&
- (p[7] == '/' || p[7] == '\\'))
- p += 8;
- else
- p += 4;
- slashonly = 0;
- }
- do {
- rp = p;
- /* Remove leading drive letter from archives created
- * on Windows. */
- if (((p[0] >= 'a' && p[0] <= 'z') ||
- (p[0] >= 'A' && p[0] <= 'Z')) &&
- p[1] == ':') {
- p += 2;
- slashonly = 0;
- }
- /* Remove leading "/../", "//", etc. */
- while (p[0] == '/' || p[0] == '\\') {
- if (p[1] == '.' && p[2] == '.' &&
- (p[3] == '/' || p[3] == '\\')) {
- p += 3; /* Remove "/..", leave "/"
- * for next pass. */
- slashonly = 0;
- } else
- p += 1; /* Remove "/". */
- }
- } while (rp != p);
-
- if (p != name && !bsdtar->warned_lead_slash) {
- /* Generate a warning the first time this happens. */
- if (slashonly)
- bsdtar_warnc(bsdtar, 0,
- "Removing leading '%c' from member names",
- name[0]);
- else
- bsdtar_warnc(bsdtar, 0,
- "Removing leading drive letter from "
- "member names");
- bsdtar->warned_lead_slash = 1;
- }
-
- /* Special case: Stripping everything yields ".". */
- if (*p == '\0')
- name = ".";
- else
- name = p;
- } else {
- /* Strip redundant leading '/' characters. */
- while (name[0] == '/' && name[1] == '/')
- name++;
- }
-
- /* Safely replace name in archive_entry. */
- if (name != archive_entry_pathname(entry)) {
- char *q = strdup(name);
- archive_entry_copy_pathname(entry, q);
- free(q);
- }
- return (0);
-}
-
-/*
- * Like strcmp(), but try to be a little more aware of the fact that
- * we're comparing two paths. Right now, it just handles leading
- * "./" and trailing '/' specially, so that "a/b/" == "./a/b"
- *
- * TODO: Make this better, so that "./a//b/./c/" == "a/b/c"
- * TODO: After this works, push it down into libarchive.
- * TODO: Publish the path normalization routines in libarchive so
- * that bsdtar can normalize paths and use fast strcmp() instead
- * of this.
- */
-
-int
-pathcmp(const char *a, const char *b)
-{
- /* Skip leading './' */
- if (a[0] == '.' && a[1] == '/' && a[2] != '\0')
- a += 2;
- if (b[0] == '.' && b[1] == '/' && b[2] != '\0')
- b += 2;
- /* Find the first difference, or return (0) if none. */
- while (*a == *b) {
- if (*a == '\0')
- return (0);
- a++;
- b++;
- }
- /*
- * If one ends in '/' and the other one doesn't,
- * they're the same.
- */
- if (a[0] == '/' && a[1] == '\0' && b[0] == '\0')
- return (0);
- if (a[0] == '\0' && b[0] == '/' && b[1] == '\0')
- return (0);
- /* They're really different, return the correct sign. */
- return (*(const unsigned char *)a - *(const unsigned char *)b);
-}
diff --git a/libarchive/libarchive-2.7.1/tar/write.c b/libarchive/libarchive-2.7.1/tar/write.c
deleted file mode 100644
index f328fe4..0000000
--- a/libarchive/libarchive-2.7.1/tar/write.c
+++ /dev/null
@@ -1,1063 +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 "bsdtar_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/write.c,v 1.79 2008/11/27 05:49:52 kientzle Exp $");
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_ACL_H
-#include <sys/acl.h>
-#endif
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
-#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-#ifdef HAVE_LIMITS_H
-#include <limits.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__)
-/* This header exists but is broken on Cygwin. */
-#include <ext2fs/ext2_fs.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
-
-#include "bsdtar.h"
-#include "tree.h"
-
-/* Size of buffer for holding file data prior to writing. */
-#define FILEDATABUFLEN 65536
-
-/* Fixed size of uname/gname caches. */
-#define name_cache_size 101
-
-static const char * const NO_NAME = "(noname)";
-
-struct archive_dir_entry {
- struct archive_dir_entry *next;
- time_t mtime_sec;
- int mtime_nsec;
- char *name;
-};
-
-struct archive_dir {
- struct archive_dir_entry *head, *tail;
-};
-
-struct name_cache {
- int probes;
- int hits;
- size_t size;
- struct {
- id_t id;
- const char *name;
- } cache[name_cache_size];
-};
-
-static void add_dir_list(struct bsdtar *bsdtar, const char *path,
- time_t mtime_sec, int mtime_nsec);
-static int append_archive(struct bsdtar *, struct archive *,
- struct archive *ina);
-static int append_archive_filename(struct bsdtar *,
- struct archive *, const char *fname);
-static void archive_names_from_file(struct bsdtar *bsdtar,
- struct archive *a);
-static int archive_names_from_file_helper(struct bsdtar *bsdtar,
- const char *line);
-static int copy_file_data(struct bsdtar *bsdtar,
- struct archive *a, struct archive *ina);
-static int new_enough(struct bsdtar *, const char *path,
- const struct stat *);
-static void test_for_append(struct bsdtar *);
-static void write_archive(struct archive *, struct bsdtar *);
-static void write_entry_backend(struct bsdtar *, struct archive *,
- struct archive_entry *);
-static int write_file_data(struct bsdtar *, struct archive *,
- struct archive_entry *, int fd);
-static void write_hierarchy(struct bsdtar *, struct archive *,
- const char *);
-
-void
-tar_mode_c(struct bsdtar *bsdtar)
-{
- struct archive *a;
- int r;
-
- if (*bsdtar->argv == NULL && bsdtar->names_from_file == NULL)
- bsdtar_errc(bsdtar, 1, 0, "no files or directories specified");
-
- a = archive_write_new();
-
- /* Support any format that the library supports. */
- if (bsdtar->create_format == NULL) {
- r = archive_write_set_format_pax_restricted(a);
- bsdtar->create_format = "pax restricted";
- } else {
- r = archive_write_set_format_by_name(a, bsdtar->create_format);
- }
- if (r != ARCHIVE_OK) {
- fprintf(stderr, "Can't use format %s: %s\n",
- bsdtar->create_format,
- archive_error_string(a));
- usage(bsdtar);
- }
-
- /*
- * If user explicitly set the block size, then assume they
- * want the last block padded as well. Otherwise, use the
- * default block size and accept archive_write_open_file()'s
- * default padding decisions.
- */
- if (bsdtar->bytes_per_block != 0) {
- archive_write_set_bytes_per_block(a, bsdtar->bytes_per_block);
- archive_write_set_bytes_in_last_block(a,
- bsdtar->bytes_per_block);
- } else
- archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK);
-
- if (bsdtar->compress_program) {
- archive_write_set_compression_program(a, bsdtar->compress_program);
- } else {
- switch (bsdtar->create_compression) {
- case 0:
- archive_write_set_compression_none(a);
- break;
-#ifdef HAVE_LIBBZ2
- case 'j': case 'y':
- archive_write_set_compression_bzip2(a);
- break;
-#endif
-#ifdef HAVE_LIBLZMA
- case 'J':
- archive_write_set_compression_xz(a);
- break;
- case OPTION_LZMA:
- archive_write_set_compression_lzma(a);
- break;
-#endif
-#ifdef HAVE_LIBZ
- case 'z':
- archive_write_set_compression_gzip(a);
- break;
-#endif
- case 'Z':
- archive_write_set_compression_compress(a);
- break;
- default:
- bsdtar_errc(bsdtar, 1, 0,
- "Unrecognized compression option -%c",
- bsdtar->create_compression);
- }
- }
-
- if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
- if (ARCHIVE_OK != archive_write_open_file(a, bsdtar->filename))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
- write_archive(a, bsdtar);
-}
-
-/*
- * Same as 'c', except we only support tar or empty formats in
- * uncompressed files on disk.
- */
-void
-tar_mode_r(struct bsdtar *bsdtar)
-{
- off_t end_offset;
- int format;
- struct archive *a;
- struct archive_entry *entry;
- int r;
-
- /* Sanity-test some arguments and the file. */
- test_for_append(bsdtar);
-
- format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
-
- bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT, 0666);
- if (bsdtar->fd < 0)
- bsdtar_errc(bsdtar, 1, errno,
- "Cannot open %s", bsdtar->filename);
-
- a = archive_read_new();
- archive_read_support_compression_all(a);
- archive_read_support_format_tar(a);
- archive_read_support_format_gnutar(a);
- r = archive_read_open_fd(a, bsdtar->fd, 10240);
- if (r != ARCHIVE_OK)
- bsdtar_errc(bsdtar, 1, archive_errno(a),
- "Can't read archive %s: %s", bsdtar->filename,
- archive_error_string(a));
- while (0 == archive_read_next_header(a, &entry)) {
- if (archive_compression(a) != ARCHIVE_COMPRESSION_NONE) {
- archive_read_finish(a);
- close(bsdtar->fd);
- bsdtar_errc(bsdtar, 1, 0,
- "Cannot append to compressed archive.");
- }
- /* Keep going until we hit end-of-archive */
- format = archive_format(a);
- }
-
- end_offset = archive_read_header_position(a);
- archive_read_finish(a);
-
- /* Re-open archive for writing */
- a = archive_write_new();
- archive_write_set_compression_none(a);
- /*
- * Set the format to be used for writing. To allow people to
- * extend empty files, we need to allow them to specify the format,
- * which opens the possibility that they will specify a format that
- * doesn't match the existing format. Hence, the following bit
- * of arcane ugliness.
- */
-
- if (bsdtar->create_format != NULL) {
- /* If the user requested a format, use that, but ... */
- archive_write_set_format_by_name(a,
- bsdtar->create_format);
- /* ... complain if it's not compatible. */
- format &= ARCHIVE_FORMAT_BASE_MASK;
- if (format != (int)(archive_format(a) & ARCHIVE_FORMAT_BASE_MASK)
- && format != ARCHIVE_FORMAT_EMPTY) {
- bsdtar_errc(bsdtar, 1, 0,
- "Format %s is incompatible with the archive %s.",
- bsdtar->create_format, bsdtar->filename);
- }
- } else {
- /*
- * Just preserve the current format, with a little care
- * for formats that libarchive can't write.
- */
- if (format == ARCHIVE_FORMAT_TAR_GNUTAR)
- /* TODO: When gtar supports pax, use pax restricted. */
- format = ARCHIVE_FORMAT_TAR_USTAR;
- if (format == ARCHIVE_FORMAT_EMPTY)
- format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
- archive_write_set_format(a, format);
- }
- lseek(bsdtar->fd, end_offset, SEEK_SET); /* XXX check return val XXX */
- if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
- if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
-
- write_archive(a, bsdtar); /* XXX check return val XXX */
-
- close(bsdtar->fd);
- bsdtar->fd = -1;
-}
-
-void
-tar_mode_u(struct bsdtar *bsdtar)
-{
- off_t end_offset;
- struct archive *a;
- struct archive_entry *entry;
- int format;
- struct archive_dir_entry *p;
- struct archive_dir archive_dir;
-
- bsdtar->archive_dir = &archive_dir;
- memset(&archive_dir, 0, sizeof(archive_dir));
-
- format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
-
- /* Sanity-test some arguments and the file. */
- test_for_append(bsdtar);
-
- bsdtar->fd = open(bsdtar->filename, O_RDWR);
- if (bsdtar->fd < 0)
- bsdtar_errc(bsdtar, 1, errno,
- "Cannot open %s", bsdtar->filename);
-
- a = archive_read_new();
- archive_read_support_compression_all(a);
- archive_read_support_format_tar(a);
- archive_read_support_format_gnutar(a);
- if (archive_read_open_fd(a, bsdtar->fd,
- bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block :
- DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
- bsdtar_errc(bsdtar, 1, 0,
- "Can't open %s: %s", bsdtar->filename,
- archive_error_string(a));
- }
-
- /* Build a list of all entries and their recorded mod times. */
- while (0 == archive_read_next_header(a, &entry)) {
- if (archive_compression(a) != ARCHIVE_COMPRESSION_NONE) {
- archive_read_finish(a);
- close(bsdtar->fd);
- bsdtar_errc(bsdtar, 1, 0,
- "Cannot append to compressed archive.");
- }
- add_dir_list(bsdtar, archive_entry_pathname(entry),
- archive_entry_mtime(entry),
- archive_entry_mtime_nsec(entry));
- /* Record the last format determination we see */
- format = archive_format(a);
- /* Keep going until we hit end-of-archive */
- }
-
- end_offset = archive_read_header_position(a);
- archive_read_finish(a);
-
- /* Re-open archive for writing. */
- a = archive_write_new();
- archive_write_set_compression_none(a);
- /*
- * Set format to same one auto-detected above, except that
- * we don't write GNU tar format, so use ustar instead.
- */
- if (format == ARCHIVE_FORMAT_TAR_GNUTAR)
- format = ARCHIVE_FORMAT_TAR_USTAR;
- archive_write_set_format(a, format);
- if (bsdtar->bytes_per_block != 0) {
- archive_write_set_bytes_per_block(a, bsdtar->bytes_per_block);
- archive_write_set_bytes_in_last_block(a,
- bsdtar->bytes_per_block);
- } else
- archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK);
- lseek(bsdtar->fd, end_offset, SEEK_SET);
- ftruncate(bsdtar->fd, end_offset);
- if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
- if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd))
- bsdtar_errc(bsdtar, 1, 0, archive_error_string(a));
-
- write_archive(a, bsdtar);
-
- close(bsdtar->fd);
- bsdtar->fd = -1;
-
- while (bsdtar->archive_dir->head != NULL) {
- p = bsdtar->archive_dir->head->next;
- free(bsdtar->archive_dir->head->name);
- free(bsdtar->archive_dir->head);
- bsdtar->archive_dir->head = p;
- }
- bsdtar->archive_dir->tail = NULL;
-}
-
-
-/*
- * Write user-specified files/dirs to opened archive.
- */
-static void
-write_archive(struct archive *a, struct bsdtar *bsdtar)
-{
- const char *arg;
- struct archive_entry *entry, *sparse_entry;
-
- /* We want to catch SIGINFO and SIGUSR1. */
- siginfo_init(bsdtar);
-
- /* Allocate a buffer for file data. */
- if ((bsdtar->buff = malloc(FILEDATABUFLEN)) == NULL)
- bsdtar_errc(bsdtar, 1, 0, "cannot allocate memory");
-
- if ((bsdtar->resolver = archive_entry_linkresolver_new()) == NULL)
- bsdtar_errc(bsdtar, 1, 0, "cannot create link resolver");
- archive_entry_linkresolver_set_strategy(bsdtar->resolver,
- archive_format(a));
- if ((bsdtar->diskreader = archive_read_disk_new()) == NULL)
- bsdtar_errc(bsdtar, 1, 0, "Cannot create read_disk object");
- archive_read_disk_set_standard_lookup(bsdtar->diskreader);
-
- if (bsdtar->names_from_file != NULL)
- archive_names_from_file(bsdtar, a);
-
- while (*bsdtar->argv) {
- arg = *bsdtar->argv;
- if (arg[0] == '-' && arg[1] == 'C') {
- arg += 2;
- if (*arg == '\0') {
- bsdtar->argv++;
- arg = *bsdtar->argv;
- if (arg == NULL) {
- bsdtar_warnc(bsdtar, 1, 0,
- "Missing argument for -C");
- bsdtar->return_value = 1;
- goto cleanup;
- }
- }
- set_chdir(bsdtar, arg);
- } else {
- if (*arg != '/' && (arg[0] != '@' || arg[1] != '/'))
- do_chdir(bsdtar); /* Handle a deferred -C */
- if (*arg == '@') {
- if (append_archive_filename(bsdtar, a,
- arg + 1) != 0)
- break;
- } else
-#if defined(_WIN32) && !defined(__CYGWIN__)
- write_hierarchy_win(bsdtar, a, arg,
- write_hierarchy);
-#else
- write_hierarchy(bsdtar, a, arg);
-#endif
- }
- bsdtar->argv++;
- }
-
- entry = NULL;
- archive_entry_linkify(bsdtar->resolver, &entry, &sparse_entry);
- while (entry != NULL) {
- write_entry_backend(bsdtar, a, entry);
- archive_entry_free(entry);
- entry = NULL;
- archive_entry_linkify(bsdtar->resolver, &entry, &sparse_entry);
- }
-
- if (archive_write_close(a)) {
- bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
- bsdtar->return_value = 1;
- }
-
-cleanup:
- /* Free file data buffer. */
- free(bsdtar->buff);
- archive_entry_linkresolver_free(bsdtar->resolver);
- bsdtar->resolver = NULL;
- archive_read_finish(bsdtar->diskreader);
- bsdtar->diskreader = NULL;
-
- if (bsdtar->option_totals) {
- fprintf(stderr, "Total bytes written: " BSDTAR_FILESIZE_PRINTF "\n",
- (BSDTAR_FILESIZE_TYPE)archive_position_compressed(a));
- }
-
- archive_write_finish(a);
-
- /* Restore old SIGINFO + SIGUSR1 handlers. */
- siginfo_done(bsdtar);
-}
-
-/*
- * Archive names specified in file.
- *
- * Unless --null was specified, a line containing exactly "-C" will
- * cause the next line to be a directory to pass to chdir(). If
- * --null is specified, then a line "-C" is just another filename.
- */
-void
-archive_names_from_file(struct bsdtar *bsdtar, struct archive *a)
-{
- bsdtar->archive = a;
-
- bsdtar->next_line_is_dir = 0;
- process_lines(bsdtar, bsdtar->names_from_file,
- archive_names_from_file_helper);
- if (bsdtar->next_line_is_dir)
- bsdtar_errc(bsdtar, 1, errno,
- "Unexpected end of filename list; "
- "directory expected after -C");
-}
-
-static int
-archive_names_from_file_helper(struct bsdtar *bsdtar, const char *line)
-{
- if (bsdtar->next_line_is_dir) {
- set_chdir(bsdtar, line);
- bsdtar->next_line_is_dir = 0;
- } else if (!bsdtar->option_null && strcmp(line, "-C") == 0)
- bsdtar->next_line_is_dir = 1;
- else {
- if (*line != '/')
- do_chdir(bsdtar); /* Handle a deferred -C */
- write_hierarchy(bsdtar, bsdtar->archive, line);
- }
- return (0);
-}
-
-/*
- * Copy from specified archive to current archive. Returns non-zero
- * for write errors (which force us to terminate the entire archiving
- * operation). If there are errors reading the input archive, we set
- * bsdtar->return_value but return zero, so the overall archiving
- * operation will complete and return non-zero.
- */
-static int
-append_archive_filename(struct bsdtar *bsdtar, struct archive *a,
- const char *filename)
-{
- struct archive *ina;
- int rc;
-
- if (strcmp(filename, "-") == 0)
- filename = NULL; /* Library uses NULL for stdio. */
-
- ina = archive_read_new();
- archive_read_support_format_all(ina);
- archive_read_support_compression_all(ina);
- if (archive_read_open_file(ina, filename, 10240)) {
- bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(ina));
- bsdtar->return_value = 1;
- return (0);
- }
-
- rc = append_archive(bsdtar, a, ina);
-
- if (archive_errno(ina)) {
- bsdtar_warnc(bsdtar, 0, "Error reading archive %s: %s",
- filename, archive_error_string(ina));
- bsdtar->return_value = 1;
- }
- archive_read_finish(ina);
-
- return (rc);
-}
-
-static int
-append_archive(struct bsdtar *bsdtar, struct archive *a, struct archive *ina)
-{
- struct archive_entry *in_entry;
- int e;
-
- while (0 == archive_read_next_header(ina, &in_entry)) {
- if (!new_enough(bsdtar, archive_entry_pathname(in_entry),
- archive_entry_stat(in_entry)))
- continue;
- if (excluded(bsdtar, archive_entry_pathname(in_entry)))
- continue;
- if (bsdtar->option_interactive &&
- !yes("copy '%s'", archive_entry_pathname(in_entry)))
- continue;
- if (bsdtar->verbose)
- safe_fprintf(stderr, "a %s",
- archive_entry_pathname(in_entry));
- siginfo_setinfo(bsdtar, "copying",
- archive_entry_pathname(in_entry),
- archive_entry_size(in_entry));
- siginfo_printinfo(bsdtar, 0);
-
- e = archive_write_header(a, in_entry);
- if (e != ARCHIVE_OK) {
- if (!bsdtar->verbose)
- bsdtar_warnc(bsdtar, 0, "%s: %s",
- archive_entry_pathname(in_entry),
- archive_error_string(a));
- else
- fprintf(stderr, ": %s", archive_error_string(a));
- }
- if (e == ARCHIVE_FATAL)
- exit(1);
-
- if (e >= ARCHIVE_WARN) {
- if (archive_entry_size(in_entry) == 0)
- archive_read_data_skip(ina);
- else if (copy_file_data(bsdtar, a, ina))
- exit(1);
- }
-
- if (bsdtar->verbose)
- fprintf(stderr, "\n");
- }
-
- /* Note: If we got here, we saw no write errors, so return success. */
- return (0);
-}
-
-/* Helper function to copy data between archives. */
-static int
-copy_file_data(struct bsdtar *bsdtar, struct archive *a, struct archive *ina)
-{
- ssize_t bytes_read;
- ssize_t bytes_written;
- off_t progress = 0;
-
- bytes_read = archive_read_data(ina, bsdtar->buff, FILEDATABUFLEN);
- while (bytes_read > 0) {
- siginfo_printinfo(bsdtar, progress);
-
- bytes_written = archive_write_data(a, bsdtar->buff,
- bytes_read);
- if (bytes_written < bytes_read) {
- bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
- return (-1);
- }
- progress += bytes_written;
- bytes_read = archive_read_data(ina, bsdtar->buff,
- FILEDATABUFLEN);
- }
-
- return (0);
-}
-
-/*
- * Add the file or dir hierarchy named by 'path' to the archive
- */
-static void
-write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
-{
- struct archive_entry *entry = NULL, *spare_entry = NULL;
- struct tree *tree;
- char symlink_mode = bsdtar->symlink_mode;
- dev_t first_dev = 0;
- int dev_recorded = 0;
- int tree_ret;
-
- tree = tree_open(path);
-
- if (!tree) {
- bsdtar_warnc(bsdtar, errno, "%s: Cannot open", path);
- bsdtar->return_value = 1;
- return;
- }
-
- while ((tree_ret = tree_next(tree))) {
- int r;
- const char *name = tree_current_path(tree);
- const struct stat *st = NULL; /* info to use for this entry */
- const struct stat *lst = NULL; /* lstat() information */
- int descend;
-
- if (tree_ret == TREE_ERROR_FATAL)
- bsdtar_errc(bsdtar, 1, tree_errno(tree),
- "%s: Unable to continue traversing directory tree",
- name);
- if (tree_ret == TREE_ERROR_DIR) {
- bsdtar_warnc(bsdtar, errno,
- "%s: Couldn't visit directory", name);
- bsdtar->return_value = 1;
- }
- if (tree_ret != TREE_REGULAR)
- continue;
-
- /*
- * If this file/dir is excluded by a filename
- * pattern, skip it.
- */
- if (excluded(bsdtar, name))
- continue;
-
- /*
- * Get lstat() info from the tree library.
- */
- lst = tree_current_lstat(tree);
- if (lst == NULL) {
- /* Couldn't lstat(); must not exist. */
- bsdtar_warnc(bsdtar, errno, "%s: Cannot stat", name);
- /* Return error if files disappear during traverse. */
- bsdtar->return_value = 1;
- continue;
- }
-
- /*
- * Distinguish 'L'/'P'/'H' symlink following.
- */
- switch(symlink_mode) {
- case 'H':
- /* 'H': After the first item, rest like 'P'. */
- symlink_mode = 'P';
- /* 'H': First item (from command line) like 'L'. */
- /* FALLTHROUGH */
- case 'L':
- /* 'L': Do descend through a symlink to dir. */
- descend = tree_current_is_dir(tree);
- /* 'L': Follow symlinks to files. */
- archive_read_disk_set_symlink_logical(bsdtar->diskreader);
- /* 'L': Archive symlinks as targets, if we can. */
- st = tree_current_stat(tree);
- if (st != NULL)
- break;
- /* If stat fails, we have a broken symlink;
- * in that case, don't follow the link. */
- /* FALLTHROUGH */
- default:
- /* 'P': Don't descend through a symlink to dir. */
- descend = tree_current_is_physical_dir(tree);
- /* 'P': Don't follow symlinks to files. */
- archive_read_disk_set_symlink_physical(bsdtar->diskreader);
- /* 'P': Archive symlinks as symlinks. */
- st = lst;
- break;
- }
-
- /*
- * If user has asked us not to cross mount points,
- * then don't descend into into a dir on a different
- * device.
- */
- if (!dev_recorded) {
- first_dev = lst->st_dev;
- dev_recorded = 1;
- }
- if (bsdtar->option_dont_traverse_mounts) {
- if (lst->st_dev != first_dev)
- descend = 0;
- }
-
- /*
- * In -u mode, check that the file is newer than what's
- * already in the archive; in all modes, obey --newerXXX flags.
- */
- if (!new_enough(bsdtar, name, st))
- continue;
-
- archive_entry_free(entry);
- entry = archive_entry_new();
-
- archive_entry_set_pathname(entry, name);
- archive_entry_copy_sourcepath(entry,
- tree_current_access_path(tree));
-
- /* Populate the archive_entry with metadata from the disk. */
- /* XXX TODO: Arrange to open a regular file before
- * calling this so we can pass in an fd and shorten
- * the race to query metadata. The linkify dance
- * makes this more complex than it might sound. */
- r = archive_read_disk_entry_from_file(bsdtar->diskreader,
- entry, -1, st);
- if (r != ARCHIVE_OK)
- bsdtar_warnc(bsdtar, archive_errno(bsdtar->diskreader),
- archive_error_string(bsdtar->diskreader));
- if (r < ARCHIVE_WARN)
- continue;
-
- /* XXX TODO: Just use flag data from entry; avoid the
- * duplicate check here. */
-
- /*
- * If this file/dir is flagged "nodump" and we're
- * honoring such flags, skip this file/dir.
- */
-#ifdef HAVE_STRUCT_STAT_ST_FLAGS
- /* BSD systems store flags in struct stat */
- if (bsdtar->option_honor_nodump &&
- (lst->st_flags & UF_NODUMP))
- continue;
-#endif
-
-#if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_NODUMP_FL)
- /* Linux uses ioctl to read flags. */
- if (bsdtar->option_honor_nodump) {
- int fd = open(name, O_RDONLY | O_NONBLOCK);
- if (fd >= 0) {
- unsigned long fflags;
- int r = ioctl(fd, EXT2_IOC_GETFLAGS, &fflags);
- close(fd);
- if (r >= 0 && (fflags & EXT2_NODUMP_FL))
- continue;
- }
- }
-#endif
-
- /*
- * If the user vetoes this file/directory, skip it.
- * We want this to be fairly late; if some other
- * check would veto this file, we shouldn't bother
- * the user with it.
- */
- if (bsdtar->option_interactive &&
- !yes("add '%s'", name))
- continue;
-
- /* Note: if user vetoes, we won't descend. */
- if (descend && !bsdtar->option_no_subdirs)
- tree_descend(tree);
-
- /*
- * Rewrite the pathname to be archived. If rewrite
- * fails, skip the entry.
- */
- if (edit_pathname(bsdtar, entry))
- continue;
-
- /* Display entry as we process it.
- * This format is required by SUSv2. */
- if (bsdtar->verbose)
- safe_fprintf(stderr, "a %s",
- archive_entry_pathname(entry));
-
- /* Non-regular files get archived with zero size. */
- if (!S_ISREG(st->st_mode))
- archive_entry_set_size(entry, 0);
-
- /* Record what we're doing, for SIGINFO / SIGUSR1. */
- siginfo_setinfo(bsdtar, "adding",
- archive_entry_pathname(entry), archive_entry_size(entry));
- archive_entry_linkify(bsdtar->resolver, &entry, &spare_entry);
-
- /* Handle SIGINFO / SIGUSR1 request if one was made. */
- siginfo_printinfo(bsdtar, 0);
-
- while (entry != NULL) {
- write_entry_backend(bsdtar, a, entry);
- archive_entry_free(entry);
- entry = spare_entry;
- spare_entry = NULL;
- }
-
- if (bsdtar->verbose)
- fprintf(stderr, "\n");
- }
- archive_entry_free(entry);
- tree_close(tree);
-}
-
-/*
- * Backend for write_entry.
- */
-static void
-write_entry_backend(struct bsdtar *bsdtar, struct archive *a,
- struct archive_entry *entry)
-{
- int fd = -1;
- int e;
-
- if (archive_entry_size(entry) > 0) {
- const char *pathname = archive_entry_sourcepath(entry);
- fd = open(pathname, O_RDONLY);
- if (fd == -1) {
- if (!bsdtar->verbose)
- bsdtar_warnc(bsdtar, errno,
- "%s: could not open file", pathname);
- else
- fprintf(stderr, ": %s", strerror(errno));
- return;
- }
- }
-
- e = archive_write_header(a, entry);
- if (e != ARCHIVE_OK) {
- if (!bsdtar->verbose)
- bsdtar_warnc(bsdtar, 0, "%s: %s",
- archive_entry_pathname(entry),
- archive_error_string(a));
- else
- fprintf(stderr, ": %s", archive_error_string(a));
- }
-
- if (e == ARCHIVE_FATAL)
- exit(1);
-
- /*
- * If we opened a file earlier, write it out now. Note that
- * the format handler might have reset the size field to zero
- * to inform us that the archive body won't get stored. In
- * that case, just skip the write.
- */
- if (e >= ARCHIVE_WARN && fd >= 0 && archive_entry_size(entry) > 0) {
- if (write_file_data(bsdtar, a, entry, fd))
- exit(1);
- }
-
- /*
- * If we opened a file, close it now even if there was an error
- * which made us decide not to write the archive body.
- */
- if (fd >= 0)
- close(fd);
-}
-
-
-/* Helper function to copy file to archive. */
-static int
-write_file_data(struct bsdtar *bsdtar, struct archive *a,
- struct archive_entry *entry, int fd)
-{
- ssize_t bytes_read;
- ssize_t bytes_written;
- off_t progress = 0;
-
- bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
- while (bytes_read > 0) {
- siginfo_printinfo(bsdtar, progress);
-
- bytes_written = archive_write_data(a, bsdtar->buff,
- bytes_read);
- if (bytes_written < 0) {
- /* Write failed; this is bad */
- bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a));
- return (-1);
- }
- if (bytes_written < bytes_read) {
- /* Write was truncated; warn but continue. */
- bsdtar_warnc(bsdtar, 0,
- "%s: Truncated write; file may have grown while being archived.",
- archive_entry_pathname(entry));
- return (0);
- }
- progress += bytes_written;
- bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
- }
- return 0;
-}
-
-/*
- * Test if the specified file is new enough to include in the archive.
- */
-int
-new_enough(struct bsdtar *bsdtar, const char *path, const struct stat *st)
-{
- struct archive_dir_entry *p;
-
- /*
- * If this file/dir is excluded by a time comparison, skip it.
- */
- if (bsdtar->newer_ctime_sec > 0) {
- if (st->st_ctime < bsdtar->newer_ctime_sec)
- return (0); /* Too old, skip it. */
- if (st->st_ctime == bsdtar->newer_ctime_sec
- && ARCHIVE_STAT_CTIME_NANOS(st)
- <= bsdtar->newer_ctime_nsec)
- return (0); /* Too old, skip it. */
- }
- if (bsdtar->newer_mtime_sec > 0) {
- if (st->st_mtime < bsdtar->newer_mtime_sec)
- return (0); /* Too old, skip it. */
- if (st->st_mtime == bsdtar->newer_mtime_sec
- && ARCHIVE_STAT_MTIME_NANOS(st)
- <= bsdtar->newer_mtime_nsec)
- return (0); /* Too old, skip it. */
- }
-
- /*
- * In -u mode, we only write an entry if it's newer than
- * what was already in the archive.
- */
- if (bsdtar->archive_dir != NULL &&
- bsdtar->archive_dir->head != NULL) {
- for (p = bsdtar->archive_dir->head; p != NULL; p = p->next) {
- if (pathcmp(path, p->name)==0)
- return (p->mtime_sec < st->st_mtime ||
- (p->mtime_sec == st->st_mtime &&
- p->mtime_nsec
- < ARCHIVE_STAT_MTIME_NANOS(st)));
- }
- }
-
- /* If the file wasn't rejected, include it. */
- return (1);
-}
-
-/*
- * Add an entry to the dir list for 'u' mode.
- *
- * XXX TODO: Make this fast.
- */
-static void
-add_dir_list(struct bsdtar *bsdtar, const char *path,
- time_t mtime_sec, int mtime_nsec)
-{
- struct archive_dir_entry *p;
-
- /*
- * Search entire list to see if this file has appeared before.
- * If it has, override the timestamp data.
- */
- p = bsdtar->archive_dir->head;
- while (p != NULL) {
- if (strcmp(path, p->name)==0) {
- p->mtime_sec = mtime_sec;
- p->mtime_nsec = mtime_nsec;
- return;
- }
- p = p->next;
- }
-
- p = malloc(sizeof(*p));
- if (p == NULL)
- bsdtar_errc(bsdtar, 1, ENOMEM, "Can't read archive directory");
-
- p->name = strdup(path);
- if (p->name == NULL)
- bsdtar_errc(bsdtar, 1, ENOMEM, "Can't read archive directory");
- p->mtime_sec = mtime_sec;
- p->mtime_nsec = mtime_nsec;
- p->next = NULL;
- if (bsdtar->archive_dir->tail == NULL) {
- bsdtar->archive_dir->head = bsdtar->archive_dir->tail = p;
- } else {
- bsdtar->archive_dir->tail->next = p;
- bsdtar->archive_dir->tail = p;
- }
-}
-
-void
-test_for_append(struct bsdtar *bsdtar)
-{
- struct stat s;
-
- if (*bsdtar->argv == NULL && bsdtar->names_from_file == NULL)
- bsdtar_errc(bsdtar, 1, 0, "no files or directories specified");
- if (bsdtar->filename == NULL)
- bsdtar_errc(bsdtar, 1, 0, "Cannot append to stdout.");
-
- if (bsdtar->create_compression != 0)
- bsdtar_errc(bsdtar, 1, 0,
- "Cannot append to %s with compression", bsdtar->filename);
-
- if (stat(bsdtar->filename, &s) != 0)
- return;
-
- if (!S_ISREG(s.st_mode) && !S_ISBLK(s.st_mode))
- bsdtar_errc(bsdtar, 1, 0,
- "Cannot append to %s: not a regular file.",
- bsdtar->filename);
-}