external/bsd/libarchive: Update to 3.3.2pre from NetBSD-8
This commit is contained in:
parent
2529152f60
commit
6924b5ca1f
6
external/bsd/libarchive/Makefile.inc
vendored
6
external/bsd/libarchive/Makefile.inc
vendored
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.2 2010/02/20 02:55:53 joerg Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.3 2017/04/20 20:34:24 joerg Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
|
@ -12,4 +12,8 @@ CPPFLAGS+= -DPLATFORM_CONFIG_H=\"config_netbsd.h\"
|
|||
LIBARCHIVE_FE_DIR!= cd ${.PARSEDIR}/lib/libarchive_fe && ${PRINTOBJDIR}
|
||||
LIBARCHIVE_FE= ${LIBARCHIVE_FE_DIR}/libarchive_fe.a
|
||||
|
||||
# GCC applies the check even for same functions like strftime,
|
||||
# completely defeating the purpose.
|
||||
CWARNFLAGS.gcc+= -Wno-format-nonliteral
|
||||
|
||||
WARNS?= 4
|
||||
|
|
|
|||
6
external/bsd/libarchive/bin/Makefile.inc
vendored
6
external/bsd/libarchive/bin/Makefile.inc
vendored
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2010/11/02 19:14:53 joerg Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2017/04/20 13:11:04 joerg Exp $
|
||||
|
||||
.include "../Makefile.inc"
|
||||
|
||||
|
|
@ -8,6 +8,6 @@ BINDIR= /bin
|
|||
LDSTATIC?= -static
|
||||
.endif
|
||||
|
||||
DPADD= ${LIBARCHIVE_FE} ${LIBARCHIVE} ${LIBBZ2} ${LIBLZMA} ${LIBZ}
|
||||
LDADD= -L${LIBARCHIVE_FE_DIR} -larchive_fe -larchive -lbz2 -llzma -lz
|
||||
DPADD= ${LIBARCHIVE_FE} ${LIBARCHIVE} ${LIBEXPAT} ${LIBBZ2} ${LIBLZMA} ${LIBZ} ${LIBCRYPTO}
|
||||
LDADD= -L${LIBARCHIVE_FE_DIR} -larchive_fe -larchive -lexpat -lbz2 -llzma -lz -lcrypto
|
||||
CPPFLAGS+= -I${LIBARCHIVEDIR}/libarchive_fe
|
||||
|
|
|
|||
4
external/bsd/libarchive/bin/tar/Makefile
vendored
4
external/bsd/libarchive/bin/tar/Makefile
vendored
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile,v 1.4 2011/09/09 12:43:14 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.5 2017/04/20 13:11:04 joerg Exp $
|
||||
|
||||
PROG= tar
|
||||
SRCS= bsdtar.c cmdline.c getdate.c read.c subst.c tree.c util.c write.c
|
||||
SRCS= bsdtar.c cmdline.c creation_set.c read.c subst.c util.c write.c
|
||||
|
||||
.include <bsd.init.mk>
|
||||
|
||||
|
|
|
|||
98
external/bsd/libarchive/dist/CONTRIBUTING.md
vendored
Normal file
98
external/bsd/libarchive/dist/CONTRIBUTING.md
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
Thank you for helping us improve libarchive.
|
||||
The following guidelines will help ensure your contribution gets prompt attention.
|
||||
|
||||
# Bugs and other Issues
|
||||
|
||||
If you encounter any problems with libarchive,
|
||||
[please file an issue on our issue tracker](https://github.com/libarchive/libarchive/issues).
|
||||
|
||||
All bug reports should include the following information. You can copy the text below directly into the issue tracker to get started:
|
||||
|
||||
```
|
||||
Basic Information
|
||||
Version of libarchive:
|
||||
How you obtained it: (build from source, pre-packaged binary, etc)
|
||||
Operating system and version:
|
||||
What compiler and/or IDE you are using (include version):
|
||||
|
||||
If you are using a pre-packaged binary
|
||||
Exact package name and version:
|
||||
Repository you obtained it from:
|
||||
|
||||
Description of the problem you are seeing:
|
||||
What did you do?
|
||||
What did you expect to happen?
|
||||
What actually happened?
|
||||
What log files or error messages were produced?
|
||||
|
||||
How the libarchive developers can reproduce your problem:
|
||||
What other software was involved?
|
||||
What other files were involved?
|
||||
How can we obtain any of the above?
|
||||
```
|
||||
|
||||
Depending on the specific type of issue, other information will be helpful:
|
||||
|
||||
## Test Failures
|
||||
|
||||
If you see any test failures, please include the information above and also:
|
||||
|
||||
* Names of the tests that failed.
|
||||
|
||||
* Look for the .log files in the /tmp/libarchive_test_*date-and-time* directories. (On Mac OS, look in $TMPDIR which is different than /tmp.)
|
||||
|
||||
Please paste the .log files you will find there directly into your report.
|
||||
|
||||
|
||||
## Problems using libarchive in a program
|
||||
|
||||
If you are trying to write a program using libarchive, please include the information above and also:
|
||||
|
||||
* It will help us if we can actually run the program. This is easiest if you can provide source to a short program that illustrates your problem.
|
||||
|
||||
* If you have a sufficiently short program that shows the problem, you can either paste it into the report or [put it into a gist](https://gist.github.com).
|
||||
|
||||
|
||||
## Libarchive produced incorrect output
|
||||
|
||||
Please tell us what program you ran, any command-line arguments you provided, and details of the input files (`ls -l` output is helpful here). If the problem involved a command-line program, please copy the full terminal text into the report, including the command line and any error messages.
|
||||
|
||||
Please try to make the output file available to us. Unless it is very large, you can upload it into a fresh github repository and provide a link in your issue report.
|
||||
|
||||
|
||||
## Libarchive could not read a particular input file
|
||||
|
||||
Note: If you can provide a **very small** input file that reproduces the problem, we can add that to our test suite. This will ensure that the bug does not reappear in the future.
|
||||
|
||||
A link to the relevant file is usually sufficient.
|
||||
|
||||
If you cannot provide the input file or a link to the file, please let us know if there is some other way to obtain it.
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
We are always interested in improving the libarchive documentation. Please tell us about any errors you find, including:
|
||||
|
||||
* Typos or errors in the manpages provided with libarchive source.
|
||||
|
||||
* Mistakes in the [libarchive Wiki](https://github.com/libarchive/libarchive/wiki)
|
||||
|
||||
* Problems with the PDF or Wiki files that are automatically generated from the manpages.
|
||||
|
||||
|
||||
# Code Submissions
|
||||
|
||||
We welcome all code submissions. But of course, some code submissions are easier for us to respond to than others. The best code submissions:
|
||||
|
||||
* Address a single issue. There have been many cases where a simple fix to an obvious problem did not get handled for months because the patch that was provided also included an unrelated change affecting an especially complex area of the code.
|
||||
|
||||
* Follow existing libarchive code style and conventions. Libarchive generally follows [BSD KNF](https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9) for formatting code.
|
||||
|
||||
* Do not make unnecessary changes to existing whitespace, capitalization, or spelling.
|
||||
|
||||
* Include detailed instructions for reproducing the problem you're fixing. We do try to verify that a submission actually fixes a real problem. If we can't reproduce the problem, it will take us longer to evaluate the fix. For this reason, we encourage you to file an issue report first with details on reproducing the problem, then refer to that issue in your pull request.
|
||||
|
||||
* Includes a test case. The libarchive Wiki has [detailed documentation for adding new test cases](https://github.com/libarchive/libarchive/wiki/LibarchiveAddingTest).
|
||||
|
||||
* Are provided via Github pull requests. We welcome patches in almost any format, but github's pull request management makes it significantly easier for us to evaluate and test changes.
|
||||
|
||||
7
external/bsd/libarchive/dist/COPYING
vendored
7
external/bsd/libarchive/dist/COPYING
vendored
|
|
@ -16,13 +16,12 @@ the actual statements in the files are controlling.
|
|||
a 3-clause UC Regents copyright; please read the individual source
|
||||
files for details:
|
||||
libarchive/archive_entry.c
|
||||
libarchive/archive_read_support_compression_compress.c
|
||||
libarchive/archive_write_set_compression_compress.c
|
||||
libarchive/archive_read_support_filter_compress.c
|
||||
libarchive/archive_write_add_filter_compress.c
|
||||
libarchive/mtree.5
|
||||
tar/matching.c
|
||||
|
||||
* The following source files are in the public domain:
|
||||
tar/getdate.c
|
||||
libarchive/archive_getdate.c
|
||||
|
||||
* The build files---including Makefiles, configure scripts,
|
||||
and auxiliary scripts used as part of the compile process---have
|
||||
|
|
|
|||
172
external/bsd/libarchive/dist/NEWS
vendored
172
external/bsd/libarchive/dist/NEWS
vendored
|
|
@ -1,22 +1,162 @@
|
|||
Jun 30, 2010: libarchive 2.8.4 released
|
||||
Jun 30, 2010: Improved reliability of hash function detection
|
||||
Jun 30, 2010: Fix issues on ancient FreeBSD, QNX, ancient NetBSD and Minux
|
||||
Mar 16, 2017: NFSv4 ACL support for Linux (librichacl)
|
||||
|
||||
Mar 14, 2010: libarchive 2.8.3 released
|
||||
Mar 14, 2010: Symlink dereference fix for Linux broke the build there; corrected.
|
||||
Feb 26, 2017: libarchive 3.3.1 released
|
||||
Security & Feature release
|
||||
|
||||
Mar 14, 2010: libarchive 2.8.2 released
|
||||
Mar 12, 2010: Fix NULL deference for short self-extracting zip archives.
|
||||
Feb 19, 2017: libarchive 3.3.0 released
|
||||
Security & Feature release
|
||||
|
||||
Jan 29, 2017: Limited NFSv4 ACL support for Mac OS (Darwin)
|
||||
|
||||
Jan 10, 2017: POSIX.1e and NFSv4 ACL support for Solaris and derivates
|
||||
|
||||
Dec 27, 2016: NFSv4 ACL read and write support for pax
|
||||
Deprecated functions: archive_entry_acl_text(), archive_entry_acl_text_w()
|
||||
|
||||
Nov, 2016: libarchive is now being tested by the OSS-Fuzz project
|
||||
|
||||
Oct 26, 2016: Remove liblzmadec support
|
||||
|
||||
Oct 23, 2016: libarchive 3.2.2 released
|
||||
Security release
|
||||
|
||||
Jun 20, 2016: libarchive 3.2.1 released
|
||||
This fixes a handful of security and other critical issues with 3.2.0
|
||||
|
||||
May 01, 2016: libarchive 3.2.0 released
|
||||
|
||||
Apr 09, 2016: libarchive 3.1.901a released
|
||||
Another test release in preparation for 3.2.0
|
||||
|
||||
Feb 13, 2016: libarchive 3.1.900a released
|
||||
This is a test release in preparation for 3.2.0
|
||||
|
||||
Oct 21, 2015: Preliminary port to OSF
|
||||
|
||||
Apr 11, 2015: libarchive's issue tracker is now hosted at GitHub.
|
||||
https://github.com/libarchive/libarchive/issues
|
||||
|
||||
Early 2015: Many fixes to crash and overflow bugs thanks to Hanno Boeck
|
||||
|
||||
Oct 13, 2014: Zip encryption and decryption support
|
||||
|
||||
Aug 13, 2014: Add support for lz4 compression.
|
||||
|
||||
Jun 10, 2014: Add warc format support
|
||||
|
||||
May 3, 2014: Add experimental Zip streaming extension
|
||||
|
||||
Apr 6, 2014: Add bsdcat command-line tool
|
||||
|
||||
Jan 12, 2014: Add Zip64 support
|
||||
|
||||
Dec 1, 2013: Rewrite Zip write logic
|
||||
|
||||
Jul 1, 2013: Add ability to detect encrypted entries for many formats
|
||||
(This does not add the ability to *decrypt* those entries, however)
|
||||
|
||||
Feb 23, 2013: "raw" write support added
|
||||
|
||||
Feb 09, 2013: libarchive 3.1.2 released
|
||||
|
||||
Jan 28, 2013: libarchive's new website moved to http://www.libarchive.org.
|
||||
|
||||
Jan 13, 2013: libarchive 3.1.1 released
|
||||
|
||||
Jan 13, 2013: libarchive 3.1.0 released
|
||||
|
||||
Dec 07, 2012: Implement functions to manually set the format and filters used.
|
||||
|
||||
Nov 11, 2012: Add support for __MACOSX directory in Zip archives, which resource
|
||||
forks are stored in.
|
||||
|
||||
Oct 20, 2012: Add support for writing v7 tar format.
|
||||
|
||||
Oct 09, 2012: Add support for grzip compression.
|
||||
|
||||
Oct 07, 2012: Introduce b64encode filter.
|
||||
Oct 07, 2012: Introduce uuencode filter.
|
||||
|
||||
Oct 06, 2012: Add support for lzop.
|
||||
|
||||
Sep 27, 2012: Implement function used to seek within data blocks.
|
||||
(Currently only supported for uncompressed RAR archives).
|
||||
|
||||
Apr 22, 2012: Add basic archive read and write filter support for lrzip.
|
||||
|
||||
Mar 27, 2012: libarchive 3.0.4 released
|
||||
|
||||
Feb 05, 2012: libarchive development now hosted at GitHub.
|
||||
http://libarchive.github.com/
|
||||
Feb 05, 2012: libarchive's issue tracker remains at Google Code.
|
||||
http://code.google.com/p/libarchive/issues/list
|
||||
Feb 05, 2012: libarchive's mailing lists remain at Google Groups.
|
||||
|
||||
Dec 24, 2011: libarchive 3.0.2 released
|
||||
Dec 23, 2011: Various fixes merged from FreeBSD
|
||||
Dec 23, 2011: Symlink support in Zip reader and writer
|
||||
Dec 23, 2011: Robustness fixes to 7Zip reader
|
||||
|
||||
Nov 27, 2011: libarchive 3.0.1b released
|
||||
|
||||
Nov 26, 2011: 7Zip reader
|
||||
Nov 26, 2011: Small fixes to ISO and Zip to improve robustness with corrupted input
|
||||
Nov 24, 2011: Improve streaming Zip reader's support for uncompressed entries
|
||||
Nov 20, 2011: New seeking Zip reader supports SFX Zip archives
|
||||
Nov 20, 2011: Build fixes on Windows
|
||||
|
||||
Nov 13, 2011: libarchive 3.0.0a released
|
||||
|
||||
Nov 06, 2011: Update shared-library version calculations for libarchive 3.x
|
||||
Sep 04, 2011: Fix tar -s; follow GNU tar for controlling hardlink/symlink substitutions
|
||||
Aug 18, 2011: Fix reading ISO images built by NetBSD's mkisofs
|
||||
Aug 15, 2011: Old archive_read_support_compression_XXX functions are deprecated and
|
||||
will disappear in libarchive 4.0.
|
||||
Jun 26, 2011: RAR reader
|
||||
Jun 16, 2011: Add tar:compat-2x option to emulate broken libarchive 2.x
|
||||
handling of pax UTF-8 headers
|
||||
Apr 25, 2011: Refactor read_open() into a collection of single-item setters;
|
||||
support the old interfaces as wrappers
|
||||
Apr 12, 2011: Split disk writer into separate POSIX and Windows implementations
|
||||
Apr 10, 2011: Improvements to character translations on Windows.
|
||||
Mar 30, 2011: More work to return errors instead of calling abort()
|
||||
Mar 23, 2011: Add charset option to many writers to control MBCS filenames
|
||||
Mar 17, 2011: Overhauled support for per-format extension options
|
||||
Mar 17, 2011: Track character set used for mbcs strings, support
|
||||
translating to/from user-specified locale
|
||||
Mar 09, 2011: Recognize mtree files without requiring a signature
|
||||
Mar 06, 2011: Use iconv to convert to/from Unicode instead of making bad
|
||||
assumptions about the C90 character set translation functions
|
||||
Feb 17, 2011: Fixes for AIX, TRU64, and other platforms
|
||||
Dec 22, 2010: CAB reader
|
||||
Dec 20, 2010: LHA/LZH reader
|
||||
Jul 03, 2010: minitar example demonstrates archive_read_disk directory traversal
|
||||
Jun 29, 2010: Many improvements to ISO reader compatibility
|
||||
Jun 26, 2010: Use larger buffers when copy files into an archive
|
||||
Jun 18, 2010: Reimplement Mac OS extensions in libarchive
|
||||
Jun 09, 2010: archive_read_disk now supports traversals
|
||||
May 28, 2010: XAR writer
|
||||
May 16, 2010: Fix ^T handling; don't exit on interrupted reads and writes
|
||||
May 09, 2010: Improved detection of platform-specific crypto support
|
||||
May 04, 2010: lzip read and write filters
|
||||
May 01, 2010: New options: tar --gid --gname --uid --uname
|
||||
Apr 28, 2010: Use Red-black tree for ISO reader/writer to improve performance
|
||||
Apr 17, 2010: Minimal writer for legacy GNU tar format
|
||||
Mar 12, 2010: Don't dereference symlinks on Linux when reading ACLs.
|
||||
Mar 07, 2010: Better detection of SHA2 support for old OpenSSL versions.
|
||||
Mar 07, 2010: Fix parsing of input files for bsdtar -T.
|
||||
Mar 07, 2010: Do not leak setup_xattr into the global namespace.
|
||||
|
||||
Mar 06, 2010: libarchive 2.8.1 released
|
||||
Mar 06, 2010: Fix build when an older libarchive is already installed
|
||||
Mar 03, 2010: Use O_BINARY opening files in bsdtar
|
||||
Mar 02, 2010: Include missing archive_crc32.h
|
||||
Mar 01, 2010: Correctly include iconv.h required by libxml2.
|
||||
Feb 28, 2010: Relax handling of state failures; misuse by clients now generally
|
||||
results in a sticky ARCHIVE_FATAL rather than a visit to abort()
|
||||
Feb 25, 2010: ISO writer
|
||||
Feb 21, 2010: Split many man pages into smaller chunks.
|
||||
Feb 21, 2010: Performance: Cheat on block sizes when reading archives from disk.
|
||||
Feb 21, 2010: Use int64_t instead of off_t, dev_t, ino_t, uid_t, and gid_t
|
||||
Feb 20, 2010: Document new ACL functions.
|
||||
Feb 19, 2010: Support multiple write filters
|
||||
Feb 07, 2010: Remove some legacy libarchive 1.x APIs
|
||||
Feb 04, 2010: Read afio headers
|
||||
Feb 02, 2010: Archive sparse files compatibly with GNU tar
|
||||
Feb 01, 2010: Integrate Apple extensions for Mac OS extended attributes into bsdtar
|
||||
Jan 31, 2010: Support cpio -V
|
||||
|
||||
Feb 04, 2010: libarchive 2.8.0 released
|
||||
Jan 17, 2010: Fix error handling for 'echo nonexistent | cpio -o'
|
||||
|
|
@ -155,7 +295,7 @@ May 04, 2008: libarchive 2.5.3b released
|
|||
* libarchive: Mark which entry strings are set; be accurate about
|
||||
distinguishing empty strings ("") from unset ones (NULL)
|
||||
* tar: Don't crash reading entries with empty filenames
|
||||
* libarchive_test, bsdtar_test, bsdcpio_test: Better detaults:
|
||||
* libarchive_test, bsdtar_test, bsdcpio_test: Better defaults:
|
||||
run all tests, delete temp dirs, summarize repeated failures
|
||||
* -no-undefined to libtool for Cygwin
|
||||
* libarchive_test: Skip large file tests on systems with 32-bit off_t
|
||||
|
|
|
|||
137
external/bsd/libarchive/dist/README
vendored
137
external/bsd/libarchive/dist/README
vendored
|
|
@ -1,137 +0,0 @@
|
|||
README for libarchive bundle.
|
||||
|
||||
Questions? Issues?
|
||||
* http://libarchive.googlecode.com/ is the home for ongoing
|
||||
libarchive development, including issue tracker, additional
|
||||
documentation, and links to the libarchive mailing lists.
|
||||
|
||||
This distribution bundle includes the following components:
|
||||
* libarchive: a library for reading and writing streaming archives
|
||||
* tar: the 'bsdtar' program is a full-featured 'tar'
|
||||
replacement built on libarchive
|
||||
* cpio: the 'bsdcpio' program is a different interface to
|
||||
essentially the same functionality
|
||||
* examples: Some small example programs that you may find useful.
|
||||
* examples/minitar: a compact sample demonstrating use of libarchive.
|
||||
I use this for testing link pollution; it should produce a very
|
||||
small executable file on most systems.
|
||||
* contrib: Various items sent to me by third parties;
|
||||
please contact the authors with any questions.
|
||||
|
||||
The top-level directory contains the following information files:
|
||||
* NEWS - highlights of recent changes
|
||||
* COPYING - what you can do with this
|
||||
* INSTALL - installation instructions
|
||||
* README - this file
|
||||
* configure - configuration script, see INSTALL for details.
|
||||
* CMakeLists.txt - input for "cmake" build tool, see INSTALL
|
||||
|
||||
The following files in the top-level directory are used by the
|
||||
'configure' script:
|
||||
* Makefile.am, aclocal.m4, configure.ac
|
||||
- used to build this distribution, only needed by maintainers
|
||||
* Makefile.in, config.h.in
|
||||
- templates used by configure script
|
||||
|
||||
Guide to Documentation installed by this system:
|
||||
* bsdtar.1 explains the use of the bsdtar program
|
||||
* bsdcpio.1 explains the use of the bsdcpio program
|
||||
* libarchive.3 gives an overview of the library as a whole
|
||||
* archive_read.3, archive_write.3, archive_write_disk.3, and
|
||||
archive_read_disk.3 provide detailed calling sequences for the read
|
||||
and write APIs
|
||||
* archive_entry.3 details the "struct archive_entry" utility class
|
||||
* archive_internals.3 provides some insight into libarchive's
|
||||
internal structure and operation.
|
||||
* libarchive-formats.5 documents the file formats supported by the library
|
||||
* cpio.5, mtree.5, and tar.5 provide detailed information about these
|
||||
popular archive formats, including hard-to-find details about
|
||||
modern cpio and tar variants.
|
||||
The manual pages above are provided in the 'doc' directory in
|
||||
a number of different formats.
|
||||
|
||||
You should also read the copious comments in "archive.h" and the
|
||||
source code for the sample programs for more details. Please let me
|
||||
know about any errors or omissions you find.
|
||||
|
||||
Currently, the library automatically detects and reads the following:
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma and xz compression
|
||||
* GNU tar format (including GNU long filenames, long link names, and
|
||||
sparse files)
|
||||
* Solaris 9 extended tar format (including ACLs)
|
||||
* Old V7 tar archives
|
||||
* POSIX ustar
|
||||
* POSIX pax interchange format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 ASCII cpio
|
||||
* POSIX octet-oriented cpio
|
||||
* Binary cpio (big-endian or little-endian)
|
||||
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
|
||||
The library can write:
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma and xz compression
|
||||
* POSIX ustar
|
||||
* POSIX pax interchange format
|
||||
* "restricted" pax format, which will create ustar archives except for
|
||||
entries that require pax extensions (for long filenames, ACLs, etc).
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 "newc" cpio
|
||||
* shar archives
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
|
||||
Notes about the library architecture:
|
||||
|
||||
* This is a heavily stream-oriented system. There is no direct
|
||||
support for in-place modification or random access.
|
||||
|
||||
* The library is designed to be extended with new compression and
|
||||
archive formats. The only requirement is that the format be
|
||||
readable or writable as a stream and that each archive entry be
|
||||
independent. There are articles on the libarchive Wiki explaining
|
||||
how to extend libarchive.
|
||||
|
||||
* On read, compression and format are always detected automatically.
|
||||
|
||||
* I've attempted to minimize static link pollution. If you don't
|
||||
explicitly invoke a particular feature (such as support for a
|
||||
particular compression or format), it won't get pulled in.
|
||||
In particular, if you don't explicitly enable a particular
|
||||
compression or decompression support, you won't need to link
|
||||
against the corresponding compression or decompression libraries.
|
||||
This also reduces the size of statically-linked binaries in
|
||||
environments where that matters.
|
||||
|
||||
* On read, the library accepts whatever blocks you hand it.
|
||||
Your read callback is free to pass the library a byte at a time
|
||||
or mmap the entire archive and give it to the library at once.
|
||||
On write, the library always produces correctly-blocked output.
|
||||
|
||||
* The object-style approach allows you to have multiple archive streams
|
||||
open at once. bsdtar uses this in its "@archive" extension.
|
||||
|
||||
* The archive itself is read/written using callback functions.
|
||||
You can read an archive directly from an in-memory buffer or
|
||||
write it to a socket, if you wish. There are some utility
|
||||
functions to provide easy-to-use "open file," etc, capabilities.
|
||||
|
||||
* The read/write APIs are designed to allow individual entries
|
||||
to be read or written to any data source: You can create
|
||||
a block of data in memory and add it to a tar archive without
|
||||
first writing a temporary file. You can also read an entry from
|
||||
an archive and write the data directly to a socket. If you want
|
||||
to read/write entries to disk, there are convenience functions to
|
||||
make this especially easy.
|
||||
|
||||
* Note: "pax interchange format" is really an extended tar format,
|
||||
despite what the name says.
|
||||
222
external/bsd/libarchive/dist/README.md
vendored
Normal file
222
external/bsd/libarchive/dist/README.md
vendored
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
# Welcome to libarchive!
|
||||
|
||||
The libarchive project develops a portable, efficient C library that
|
||||
can read and write streaming archives in a variety of formats. It
|
||||
also includes implementations of the common `tar`, `cpio`, and `zcat`
|
||||
command-line tools that use the libarchive library.
|
||||
|
||||
## Questions? Issues?
|
||||
|
||||
* http://www.libarchive.org is the home for ongoing
|
||||
libarchive development, including documentation,
|
||||
and links to the libarchive mailing lists.
|
||||
* To report an issue, use the issue tracker at
|
||||
https://github.com/libarchive/libarchive/issues
|
||||
* To submit an enhancement to libarchive, please
|
||||
submit a pull request via GitHub: https://github.com/libarchive/libarchive/pulls
|
||||
|
||||
## Contents of the Distribution
|
||||
|
||||
This distribution bundle includes the following major components:
|
||||
|
||||
* **libarchive**: a library for reading and writing streaming archives
|
||||
* **tar**: the 'bsdtar' program is a full-featured 'tar' implementation built on libarchive
|
||||
* **cpio**: the 'bsdcpio' program is a different interface to essentially the same functionality
|
||||
* **cat**: the 'bsdcat' program is a simple replacement tool for zcat, bzcat, xzcat, and such
|
||||
* **examples**: Some small example programs that you may find useful.
|
||||
* **examples/minitar**: a compact sample demonstrating use of libarchive.
|
||||
* **contrib**: Various items sent to me by third parties; please contact the authors with any questions.
|
||||
|
||||
The top-level directory contains the following information files:
|
||||
|
||||
* **NEWS** - highlights of recent changes
|
||||
* **COPYING** - what you can do with this
|
||||
* **INSTALL** - installation instructions
|
||||
* **README** - this file
|
||||
* **CMakeLists.txt** - input for "cmake" build tool, see INSTALL
|
||||
* **configure** - configuration script, see INSTALL for details. If your copy of the source lacks a `configure` script, you can try to construct it by running the script in `build/autogen.sh` (or use `cmake`).
|
||||
|
||||
The following files in the top-level directory are used by the 'configure' script:
|
||||
* `Makefile.am`, `aclocal.m4`, `configure.ac` - used to build this distribution, only needed by maintainers
|
||||
* `Makefile.in`, `config.h.in` - templates used by configure script
|
||||
|
||||
## Documentation
|
||||
|
||||
In addition to the informational articles and documentation
|
||||
in the online [libarchive Wiki](https://github.com/libarchive/libarchive/wiki),
|
||||
the distribution also includes a number of manual pages:
|
||||
|
||||
* bsdtar.1 explains the use of the bsdtar program
|
||||
* bsdcpio.1 explains the use of the bsdcpio program
|
||||
* bsdcat.1 explains the use of the bsdcat program
|
||||
* libarchive.3 gives an overview of the library as a whole
|
||||
* archive_read.3, archive_write.3, archive_write_disk.3, and
|
||||
archive_read_disk.3 provide detailed calling sequences for the read
|
||||
and write APIs
|
||||
* archive_entry.3 details the "struct archive_entry" utility class
|
||||
* archive_internals.3 provides some insight into libarchive's
|
||||
internal structure and operation.
|
||||
* libarchive-formats.5 documents the file formats supported by the library
|
||||
* cpio.5, mtree.5, and tar.5 provide detailed information about these
|
||||
popular archive formats, including hard-to-find details about
|
||||
modern cpio and tar variants.
|
||||
|
||||
The manual pages above are provided in the 'doc' directory in
|
||||
a number of different formats.
|
||||
|
||||
You should also read the copious comments in `archive.h` and the
|
||||
source code for the sample programs for more details. Please let us
|
||||
know about any errors or omissions you find.
|
||||
|
||||
## Supported Formats
|
||||
|
||||
Currently, the library automatically detects and reads the following fomats:
|
||||
* Old V7 tar archives
|
||||
* POSIX ustar
|
||||
* GNU tar format (including GNU long filenames, long link names, and sparse files)
|
||||
* Solaris 9 extended tar format (including ACLs)
|
||||
* POSIX pax interchange format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 ASCII cpio
|
||||
* POSIX octet-oriented cpio
|
||||
* Binary cpio (big-endian or little-endian)
|
||||
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* 7-Zip archives
|
||||
* Microsoft CAB format
|
||||
* LHA and LZH archives
|
||||
* RAR archives (with some limitations due to RAR's proprietary status)
|
||||
* XAR archives
|
||||
|
||||
The library also detects and handles any of the following before evaluating the archive:
|
||||
* uuencoded files
|
||||
* files with RPM wrapper
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
The library can create archives in any of the following formats:
|
||||
* POSIX ustar
|
||||
* POSIX pax interchange format
|
||||
* "restricted" pax format, which will create ustar archives except for
|
||||
entries that require pax extensions (for long filenames, ACLs, etc).
|
||||
* Old GNU tar format
|
||||
* Old V7 tar format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 "newc" cpio
|
||||
* shar archives
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* ISO9660 format
|
||||
* 7-Zip archives
|
||||
* XAR archives
|
||||
|
||||
When creating archives, the result can be filtered with any of the following:
|
||||
* uuencode
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
## Notes about the Library Design
|
||||
|
||||
The following notes address many of the most common
|
||||
questions we are asked about libarchive:
|
||||
|
||||
* This is a heavily stream-oriented system. That means that
|
||||
it is optimized to read or write the archive in a single
|
||||
pass from beginning to end. For example, this allows
|
||||
libarchive to process archives too large to store on disk
|
||||
by processing them on-the-fly as they are read from or
|
||||
written to a network or tape drive. This also makes
|
||||
libarchive useful for tools that need to produce
|
||||
archives on-the-fly (such as webservers that provide
|
||||
archived contents of a users account).
|
||||
|
||||
* In-place modification and random access to the contents
|
||||
of an archive are not directly supported. For some formats,
|
||||
this is not an issue: For example, tar.gz archives are not
|
||||
designed for random access. In some other cases, libarchive
|
||||
can re-open an archive and scan it from the beginning quickly
|
||||
enough to provide the needed abilities even without true
|
||||
random access. Of course, some applications do require true
|
||||
random access; those applications should consider alternatives
|
||||
to libarchive.
|
||||
|
||||
* The library is designed to be extended with new compression and
|
||||
archive formats. The only requirement is that the format be
|
||||
readable or writable as a stream and that each archive entry be
|
||||
independent. There are articles on the libarchive Wiki explaining
|
||||
how to extend libarchive.
|
||||
|
||||
* On read, compression and format are always detected automatically.
|
||||
|
||||
* The same API is used for all formats; in particular, it's very
|
||||
easy for software using libarchive to transparently handle
|
||||
any of libarchive's archiving formats.
|
||||
|
||||
* Libarchive's automatic support for decompression can be used
|
||||
without archiving by explicitly selecting the "raw" and "empty"
|
||||
formats.
|
||||
|
||||
* I've attempted to minimize static link pollution. If you don't
|
||||
explicitly invoke a particular feature (such as support for a
|
||||
particular compression or format), it won't get pulled in to
|
||||
statically-linked programs. In particular, if you don't explicitly
|
||||
enable a particular compression or decompression support, you won't
|
||||
need to link against the corresponding compression or decompression
|
||||
libraries. This also reduces the size of statically-linked
|
||||
binaries in environments where that matters.
|
||||
|
||||
* The library is generally _thread safe_ depending on the platform:
|
||||
it does not define any global variables of its own. However, some
|
||||
platforms do not provide fully thread-safe versions of key C library
|
||||
functions. On those platforms, libarchive will use the non-thread-safe
|
||||
functions. Patches to improve this are of great interest to us.
|
||||
|
||||
* In particular, libarchive's modules to read or write a directory
|
||||
tree do use `chdir()` to optimize the directory traversals. This
|
||||
can cause problems for programs that expect to do disk access from
|
||||
multiple threads. Of course, those modules are completely
|
||||
optional and you can use the rest of libarchive without them.
|
||||
|
||||
* The library is _not_ thread aware, however. It does no locking
|
||||
or thread management of any kind. If you create a libarchive
|
||||
object and need to access it from multiple threads, you will
|
||||
need to provide your own locking.
|
||||
|
||||
* On read, the library accepts whatever blocks you hand it.
|
||||
Your read callback is free to pass the library a byte at a time
|
||||
or mmap the entire archive and give it to the library at once.
|
||||
On write, the library always produces correctly-blocked output.
|
||||
|
||||
* The object-style approach allows you to have multiple archive streams
|
||||
open at once. bsdtar uses this in its "@archive" extension.
|
||||
|
||||
* The archive itself is read/written using callback functions.
|
||||
You can read an archive directly from an in-memory buffer or
|
||||
write it to a socket, if you wish. There are some utility
|
||||
functions to provide easy-to-use "open file," etc, capabilities.
|
||||
|
||||
* The read/write APIs are designed to allow individual entries
|
||||
to be read or written to any data source: You can create
|
||||
a block of data in memory and add it to a tar archive without
|
||||
first writing a temporary file. You can also read an entry from
|
||||
an archive and write the data directly to a socket. If you want
|
||||
to read/write entries to disk, there are convenience functions to
|
||||
make this especially easy.
|
||||
|
||||
* Note: The "pax interchange format" is a POSIX standard extended tar
|
||||
format that should be used when the older _ustar_ format is not
|
||||
appropriate. It has many advantages over other tar formats
|
||||
(including the legacy GNU tar format) and is widely supported by
|
||||
current tar implementations.
|
||||
|
||||
62
external/bsd/libarchive/dist/cat/bsdcat.1
vendored
Normal file
62
external/bsd/libarchive/dist/cat/bsdcat.1
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
.\" Copyright (c) 2011-2014, Mike Kazantsev
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 1, 2014
|
||||
.Dt BSDCAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm bsdcat
|
||||
.Nd expand files to standard output
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op options
|
||||
.Op files
|
||||
.Pp
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
expands files to standard output.
|
||||
.Sh OPTIONS
|
||||
.Nm
|
||||
typically takes a filename as an argument or reads standard input when used in a
|
||||
pipe. In both cases decompressed data it written to standard output.
|
||||
.Sh EXAMPLES
|
||||
.Pp
|
||||
To decompress a file:
|
||||
.Pp
|
||||
.Dl bsdcat example.txt.gz > example.txt
|
||||
.Pp
|
||||
To decompress standard input in a pipe:
|
||||
.Pp
|
||||
.Dl cat example.txt.gz | bsdcat > example.txt
|
||||
.Pp
|
||||
Both examples achieve the same results - a decompressed file by redirecting
|
||||
output.
|
||||
.Sh SEE ALSO
|
||||
.Xr uncompress 1 ,
|
||||
.Xr zcat 1 ,
|
||||
.Xr bzcat 1 ,
|
||||
.Xr xzcat 1 ,
|
||||
.Xr libarchive-formats 5 ,
|
||||
149
external/bsd/libarchive/dist/cat/bsdcat.c
vendored
Normal file
149
external/bsd/libarchive/dist/cat/bsdcat.c
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*-
|
||||
* Copyright (c) 2011-2014, Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bsdcat_platform.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bsdcat.h"
|
||||
#include "err.h"
|
||||
|
||||
#define BYTES_PER_BLOCK (20*512)
|
||||
|
||||
static struct archive *a;
|
||||
static struct archive_entry *ae;
|
||||
static const char *bsdcat_current_path;
|
||||
static int exit_status = 0;
|
||||
|
||||
|
||||
void
|
||||
usage(FILE *stream, int eval)
|
||||
{
|
||||
const char *p;
|
||||
p = lafe_getprogname();
|
||||
fprintf(stream,
|
||||
"Usage: %s [-h] [--help] [--version] [--] [filenames...]\n", p);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
static void
|
||||
version(void)
|
||||
{
|
||||
printf("bsdcat %s - %s\n",
|
||||
BSDCAT_VERSION_STRING,
|
||||
archive_version_details());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
bsdcat_next(void)
|
||||
{
|
||||
a = archive_read_new();
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_empty(a);
|
||||
archive_read_support_format_raw(a);
|
||||
}
|
||||
|
||||
void
|
||||
bsdcat_print_error(void)
|
||||
{
|
||||
lafe_warnc(0, "%s: %s",
|
||||
bsdcat_current_path, archive_error_string(a));
|
||||
exit_status = 1;
|
||||
}
|
||||
|
||||
void
|
||||
bsdcat_read_to_stdout(const char* filename)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (archive_read_open_filename(a, filename, BYTES_PER_BLOCK)
|
||||
!= ARCHIVE_OK)
|
||||
bsdcat_print_error();
|
||||
else if (r = archive_read_next_header(a, &ae),
|
||||
r != ARCHIVE_OK && r != ARCHIVE_EOF)
|
||||
bsdcat_print_error();
|
||||
else if (r == ARCHIVE_EOF)
|
||||
/* for empty payloads don't try and read data */
|
||||
;
|
||||
else if (archive_read_data_into_fd(a, 1) != ARCHIVE_OK)
|
||||
bsdcat_print_error();
|
||||
if (archive_read_free(a) != ARCHIVE_OK)
|
||||
bsdcat_print_error();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct bsdcat *bsdcat, bsdcat_storage;
|
||||
int c;
|
||||
|
||||
bsdcat = &bsdcat_storage;
|
||||
memset(bsdcat, 0, sizeof(*bsdcat));
|
||||
|
||||
lafe_setprogname(*argv, "bsdcat");
|
||||
|
||||
bsdcat->argv = argv;
|
||||
bsdcat->argc = argc;
|
||||
|
||||
while ((c = bsdcat_getopt(bsdcat)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(stdout, 0);
|
||||
break;
|
||||
case OPTION_VERSION:
|
||||
version();
|
||||
break;
|
||||
default:
|
||||
usage(stderr, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bsdcat_next();
|
||||
if (*bsdcat->argv == NULL) {
|
||||
bsdcat_current_path = "<stdin>";
|
||||
bsdcat_read_to_stdout(NULL);
|
||||
} else
|
||||
while (*bsdcat->argv) {
|
||||
bsdcat_current_path = *bsdcat->argv++;
|
||||
bsdcat_read_to_stdout(bsdcat_current_path);
|
||||
bsdcat_next();
|
||||
}
|
||||
|
||||
if (a != NULL)
|
||||
archive_read_free(a);
|
||||
|
||||
exit(exit_status);
|
||||
}
|
||||
56
external/bsd/libarchive/dist/cat/bsdcat.h
vendored
Normal file
56
external/bsd/libarchive/dist/cat/bsdcat.h
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2014, Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(PLATFORM_CONFIG_H)
|
||||
/* Use hand-built config.h in environments that need it. */
|
||||
#include PLATFORM_CONFIG_H
|
||||
#else
|
||||
/* Not having a config.h of some sort is a serious problem. */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
|
||||
struct bsdcat {
|
||||
/* Option parser state */
|
||||
int getopt_state;
|
||||
char *getopt_word;
|
||||
|
||||
/* Miscellaneous state information */
|
||||
int argc;
|
||||
char **argv;
|
||||
const char *argument;
|
||||
};
|
||||
|
||||
enum {
|
||||
OPTION_VERSION
|
||||
};
|
||||
|
||||
int bsdcat_getopt(struct bsdcat *);
|
||||
void usage(FILE *stream, int eval);
|
||||
void bsdcat_next(void);
|
||||
void bsdcat_print_error(void);
|
||||
void bsdcat_read_to_stdout(const char* filename);
|
||||
75
external/bsd/libarchive/dist/cat/bsdcat_platform.h
vendored
Normal file
75
external/bsd/libarchive/dist/cat/bsdcat_platform.h
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: 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 BSDCAT_PLATFORM_H_INCLUDED
|
||||
#define BSDCAT_PLATFORM_H_INCLUDED
|
||||
|
||||
#if defined(PLATFORM_CONFIG_H)
|
||||
/* Use hand-built config.h in environments that need it. */
|
||||
#include PLATFORM_CONFIG_H
|
||||
#else
|
||||
/* Not having a config.h of some sort is a serious problem. */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
/* If we're using the platform libarchive, include system headers. */
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#else
|
||||
/* Otherwise, include user headers. */
|
||||
#include "archive.h"
|
||||
#include "archive_entry.h"
|
||||
#endif
|
||||
|
||||
/* How to mark functions that don't return. */
|
||||
/* This facilitates use of some newer static code analysis tools. */
|
||||
#undef __LA_DEAD
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2 || \
|
||||
(__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
|
||||
#define __LA_DEAD __attribute__((__noreturn__))
|
||||
#else
|
||||
#define __LA_DEAD
|
||||
#endif
|
||||
|
||||
#endif /* !BSDCAT_PLATFORM_H_INCLUDED */
|
||||
283
external/bsd/libarchive/dist/cat/cmdline.c
vendored
Normal file
283
external/bsd/libarchive/dist/cat/cmdline.c
vendored
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2008 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Command line parser for tar.
|
||||
*/
|
||||
|
||||
#include "bsdcat_platform.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bsdcat.h"
|
||||
#include "err.h"
|
||||
|
||||
/*
|
||||
* Short options for tar. Please keep this sorted.
|
||||
*/
|
||||
static const char *short_options = "h";
|
||||
|
||||
/*
|
||||
* Long options for tar. Please keep this list sorted.
|
||||
*
|
||||
* The symbolic names for options that lack a short equivalent are
|
||||
* defined in bsdcat.h. Also note that so far I've found no need
|
||||
* to support optional arguments to long options. That would be
|
||||
* a small change to the code below.
|
||||
*/
|
||||
|
||||
static const struct bsdcat_option {
|
||||
const char *name;
|
||||
int required; /* 1 if this option requires an argument. */
|
||||
int equivalent; /* Equivalent short option. */
|
||||
} tar_longopts[] = {
|
||||
{ "help", 0, 'h' },
|
||||
{ "version", 0, OPTION_VERSION },
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* This getopt implementation has two key features that common
|
||||
* getopt_long() implementations lack. Apart from those, it's a
|
||||
* straightforward option parser, considerably simplified by not
|
||||
* needing to support the wealth of exotic getopt_long() features. It
|
||||
* has, of course, been shamelessly tailored for bsdcat. (If you're
|
||||
* looking for a generic getopt_long() implementation for your
|
||||
* project, I recommend Gregory Pietsch's public domain getopt_long()
|
||||
* implementation.) The two additional features are:
|
||||
*
|
||||
* Old-style tar arguments: The original tar implementation treated
|
||||
* the first argument word as a list of single-character option
|
||||
* letters. All arguments follow as separate words. For example,
|
||||
* tar xbf 32 /dev/tape
|
||||
* Here, the "xbf" is three option letters, "32" is the argument for
|
||||
* "b" and "/dev/tape" is the argument for "f". We support this usage
|
||||
* if the first command-line argument does not begin with '-'. We
|
||||
* also allow regular short and long options to follow, e.g.,
|
||||
* tar xbf 32 /dev/tape -P --format=pax
|
||||
*
|
||||
* -W long options: There's an obscure GNU convention (only rarely
|
||||
* supported even there) that allows "-W option=argument" as an
|
||||
* alternative way to support long options. This was supported in
|
||||
* early bsdcat as a way to access long options on platforms that did
|
||||
* not support getopt_long() and is preserved here for backwards
|
||||
* compatibility. (Of course, if I'd started with a custom
|
||||
* command-line parser from the beginning, I would have had normal
|
||||
* long option support on every platform so that hack wouldn't have
|
||||
* been necessary. Oh, well. Some mistakes you just have to live
|
||||
* with.)
|
||||
*
|
||||
* TODO: We should be able to use this to pull files and intermingled
|
||||
* options (such as -C) from the command line in write mode. That
|
||||
* will require a little rethinking of the argument handling in
|
||||
* bsdcat.c.
|
||||
*
|
||||
* TODO: If we want to support arbitrary command-line options from -T
|
||||
* input (as GNU tar does), we may need to extend this to handle option
|
||||
* words from sources other than argv/argc. I'm not really sure if I
|
||||
* like that feature of GNU tar, so it's certainly not a priority.
|
||||
*/
|
||||
|
||||
int
|
||||
bsdcat_getopt(struct bsdcat *bsdcat)
|
||||
{
|
||||
enum { state_start = 0, state_old_tar, state_next_word,
|
||||
state_short, state_long };
|
||||
|
||||
const struct bsdcat_option *popt, *match = NULL, *match2 = NULL;
|
||||
const char *p, *long_prefix = "--";
|
||||
size_t optlength;
|
||||
int opt = '?';
|
||||
int required = 0;
|
||||
|
||||
bsdcat->argument = NULL;
|
||||
|
||||
/* First time through, initialize everything. */
|
||||
if (bsdcat->getopt_state == state_start) {
|
||||
/* Skip program name. */
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
if (*bsdcat->argv == NULL)
|
||||
return (-1);
|
||||
/* Decide between "new style" and "old style" arguments. */
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
}
|
||||
|
||||
/*
|
||||
* We're ready to look at the next word in argv.
|
||||
*/
|
||||
if (bsdcat->getopt_state == state_next_word) {
|
||||
/* No more arguments, so no more options. */
|
||||
if (bsdcat->argv[0] == NULL)
|
||||
return (-1);
|
||||
/* Doesn't start with '-', so no more options. */
|
||||
if (bsdcat->argv[0][0] != '-')
|
||||
return (-1);
|
||||
/* "--" marks end of options; consume it and return. */
|
||||
if (strcmp(bsdcat->argv[0], "--") == 0) {
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
return (-1);
|
||||
}
|
||||
/* Get next word for parsing. */
|
||||
bsdcat->getopt_word = *bsdcat->argv++;
|
||||
--bsdcat->argc;
|
||||
if (bsdcat->getopt_word[1] == '-') {
|
||||
/* Set up long option parser. */
|
||||
bsdcat->getopt_state = state_long;
|
||||
bsdcat->getopt_word += 2; /* Skip leading '--' */
|
||||
} else {
|
||||
/* Set up short option parser. */
|
||||
bsdcat->getopt_state = state_short;
|
||||
++bsdcat->getopt_word; /* Skip leading '-' */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're parsing a group of POSIX-style single-character options.
|
||||
*/
|
||||
if (bsdcat->getopt_state == state_short) {
|
||||
/* Peel next option off of a group of short options. */
|
||||
opt = *bsdcat->getopt_word++;
|
||||
if (opt == '\0') {
|
||||
/* End of this group; recurse to get next option. */
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
return bsdcat_getopt(bsdcat);
|
||||
}
|
||||
|
||||
/* Does this option take an argument? */
|
||||
p = strchr(short_options, opt);
|
||||
if (p == NULL)
|
||||
return ('?');
|
||||
if (p[1] == ':')
|
||||
required = 1;
|
||||
|
||||
/* If it takes an argument, parse that. */
|
||||
if (required) {
|
||||
/* If arg is run-in, bsdcat->getopt_word already points to it. */
|
||||
if (bsdcat->getopt_word[0] == '\0') {
|
||||
/* Otherwise, pick up the next word. */
|
||||
bsdcat->getopt_word = *bsdcat->argv;
|
||||
if (bsdcat->getopt_word == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option -%c requires an argument",
|
||||
opt);
|
||||
return ('?');
|
||||
}
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
}
|
||||
if (opt == 'W') {
|
||||
bsdcat->getopt_state = state_long;
|
||||
long_prefix = "-W "; /* For clearer errors. */
|
||||
} else {
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
bsdcat->argument = bsdcat->getopt_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We're reading a long option, including -W long=arg convention. */
|
||||
if (bsdcat->getopt_state == state_long) {
|
||||
/* After this long option, we'll be starting a new word. */
|
||||
bsdcat->getopt_state = state_next_word;
|
||||
|
||||
/* Option name ends at '=' if there is one. */
|
||||
p = strchr(bsdcat->getopt_word, '=');
|
||||
if (p != NULL) {
|
||||
optlength = (size_t)(p - bsdcat->getopt_word);
|
||||
bsdcat->argument = (char *)(uintptr_t)(p + 1);
|
||||
} else {
|
||||
optlength = strlen(bsdcat->getopt_word);
|
||||
}
|
||||
|
||||
/* Search the table for an unambiguous match. */
|
||||
for (popt = tar_longopts; popt->name != NULL; popt++) {
|
||||
/* Short-circuit if first chars don't match. */
|
||||
if (popt->name[0] != bsdcat->getopt_word[0])
|
||||
continue;
|
||||
/* If option is a prefix of name in table, record it.*/
|
||||
if (strncmp(bsdcat->getopt_word, popt->name, optlength) == 0) {
|
||||
match2 = match; /* Record up to two matches. */
|
||||
match = popt;
|
||||
/* If it's an exact match, we're done. */
|
||||
if (strlen(popt->name) == optlength) {
|
||||
match2 = NULL; /* Forget the others. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fail if there wasn't a unique match. */
|
||||
if (match == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s is not supported",
|
||||
long_prefix, bsdcat->getopt_word);
|
||||
return ('?');
|
||||
}
|
||||
if (match2 != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Ambiguous option %s%s (matches --%s and --%s)",
|
||||
long_prefix, bsdcat->getopt_word, match->name, match2->name);
|
||||
return ('?');
|
||||
}
|
||||
|
||||
/* We've found a unique match; does it need an argument? */
|
||||
if (match->required) {
|
||||
/* Argument required: get next word if necessary. */
|
||||
if (bsdcat->argument == NULL) {
|
||||
bsdcat->argument = *bsdcat->argv;
|
||||
if (bsdcat->argument == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s requires an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
++bsdcat->argv;
|
||||
--bsdcat->argc;
|
||||
}
|
||||
} else {
|
||||
/* Argument forbidden: fail if there is one. */
|
||||
if (bsdcat->argument != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s does not allow an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
}
|
||||
return (match->equivalent);
|
||||
}
|
||||
|
||||
return (opt);
|
||||
}
|
||||
40
external/bsd/libarchive/dist/cat/test/test.h
vendored
Normal file
40
external/bsd/libarchive/dist/cat/test/test.h
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2006 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* Every test program should #include "test.h" as the first thing. */
|
||||
|
||||
#define KNOWNREF "test_expand.Z.uu"
|
||||
#define ENVBASE "BSDCAT" /* Prefix for environment variables. */
|
||||
#define PROGRAM "bsdcat" /* Name of program being tested. */
|
||||
#define PROGRAM_ALIAS "cat" /* Generic alias for program */
|
||||
#undef LIBRARY /* Not testing a library. */
|
||||
#undef EXTRA_DUMP /* How to dump extra data */
|
||||
#undef EXTRA_ERRNO /* How to dump errno */
|
||||
/* How to generate extra version info. */
|
||||
#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
|
||||
|
||||
#include "test_common.h"
|
||||
67
external/bsd/libarchive/dist/cat/test/test_0.c
vendored
Normal file
67
external/bsd/libarchive/dist/cat/test/test_0.c
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* This first test does basic sanity checks on the environment. For
|
||||
* most of these, we just exit on failure.
|
||||
*/
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define DEV_NULL "/dev/null"
|
||||
#else
|
||||
#define DEV_NULL "NUL"
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_0)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
failure("File %s does not exist?!", testprog);
|
||||
if (!assertEqualInt(0, stat(testprogfile, &st))) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s does not exist; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
failure("%s is not executable?!", testprog);
|
||||
if (!assert((st.st_mode & 0111) != 0)) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s not executable; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to successfully run the program; this requires that
|
||||
* we know some option that will succeed.
|
||||
*/
|
||||
if (0 != systemf("%s --version >" DEV_NULL, testprog)) {
|
||||
failure("Unable to successfully run: %s --version\n", testprog, testprog);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/* TODO: Ensure that our reference files are available. */
|
||||
}
|
||||
4
external/bsd/libarchive/dist/cat/test/test_empty.gz.uu
vendored
Normal file
4
external/bsd/libarchive/dist/cat/test/test_empty.gz.uu
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
begin 644 test_empty.gz
|
||||
?'XL(""\MZE,``W1E<W1?96UP='D``P``````````````
|
||||
`
|
||||
end
|
||||
4
external/bsd/libarchive/dist/cat/test/test_empty.lz4.uu
vendored
Normal file
4
external/bsd/libarchive/dist/cat/test/test_empty.lz4.uu
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
begin 644 test_empty.lz4
|
||||
/!")-&&1PN0`````%7<P"
|
||||
`
|
||||
end
|
||||
4
external/bsd/libarchive/dist/cat/test/test_empty.xz.uu
vendored
Normal file
4
external/bsd/libarchive/dist/cat/test/test_empty.xz.uu
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
begin 644 test_empty.xz
|
||||
@_3=Z6%H```3FUK1&`````!S?1"$?MO-]`0`````$65H`
|
||||
`
|
||||
end
|
||||
41
external/bsd/libarchive/dist/cat/test/test_empty_gz.c
vendored
Normal file
41
external/bsd/libarchive/dist/cat/test/test_empty_gz.c
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Sebastian Freundt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_empty_gz)
|
||||
{
|
||||
const char *reffile = "test_empty.gz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGzip()) {
|
||||
assertEqualInt(0, f);
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems gzip is not supported on this platform");
|
||||
}
|
||||
}
|
||||
41
external/bsd/libarchive/dist/cat/test/test_empty_lz4.c
vendored
Normal file
41
external/bsd/libarchive/dist/cat/test/test_empty_lz4.c
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Sebastian Freundt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_empty_lz4)
|
||||
{
|
||||
const char *reffile = "test_empty.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, f);
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
||||
41
external/bsd/libarchive/dist/cat/test/test_empty_xz.c
vendored
Normal file
41
external/bsd/libarchive/dist/cat/test/test_empty_xz.c
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Sebastian Freundt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_empty_xz)
|
||||
{
|
||||
const char *reffile = "test_empty.xz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canXz()) {
|
||||
assertEqualInt(0, f);
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems xz is not supported on this platform");
|
||||
}
|
||||
}
|
||||
36
external/bsd/libarchive/dist/cat/test/test_error.c
vendored
Normal file
36
external/bsd/libarchive/dist/cat/test/test_error.c
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_error)
|
||||
{
|
||||
const char *reffile = "test_expand.error";
|
||||
|
||||
assertFileNotExists(reffile);
|
||||
assert(0 != systemf("%s %s >test.out 2>test.err", testprog, reffile));
|
||||
|
||||
assertEmptyFile("test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
}
|
||||
43
external/bsd/libarchive/dist/cat/test/test_error_mixed.c
vendored
Normal file
43
external/bsd/libarchive/dist/cat/test/test_error_mixed.c
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_error_mixed)
|
||||
{
|
||||
const char *reffile1 = "test_expand.plain";
|
||||
const char *reffile2 = "test_expand.error";
|
||||
const char *reffile3 = "test_expand.Z";
|
||||
|
||||
assertFileNotExists(reffile2);
|
||||
extract_reference_file(reffile1);
|
||||
extract_reference_file(reffile3);
|
||||
assert(0 != systemf("%s %s %s %s >test.out 2>test.err",
|
||||
testprog, reffile1, reffile2, reffile3));
|
||||
|
||||
assertTextFileContents(
|
||||
"contents of test_expand.plain.\n"
|
||||
"contents of test_expand.Z.\n", "test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
}
|
||||
3
external/bsd/libarchive/dist/cat/test/test_expand.Z.uu
vendored
Normal file
3
external/bsd/libarchive/dist/cat/test/test_expand.Z.uu
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin 664 test_expand.Z
|
||||
@'YV08]ZXH5-FX!P0;\R`(#B'SI<R>."$<4/&A187"@`
|
||||
end
|
||||
5
external/bsd/libarchive/dist/cat/test/test_expand.bz2.uu
vendored
Normal file
5
external/bsd/libarchive/dist/cat/test/test_expand.bz2.uu
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
begin 664 test_expand.bz2
|
||||
M0EIH.3%!62936=[T@^L [__N000(!!(#!@\P+(, !@4 1 @$" (0 80$
|
||||
M(!D0 " 5%)D::#( #0]0 9J%1Z@>H :!B:&33(!"X";"%C@I$+32H/(0MXG
|
||||
J,EA1G51 WG-"6JV7JKA;/&]$X 6MNH 8'N@3[\XCA_%W)%.%"0WO2#ZP
|
||||
end
|
||||
4
external/bsd/libarchive/dist/cat/test/test_expand.gz.uu
vendored
Normal file
4
external/bsd/libarchive/dist/cat/test/test_expand.gz.uu
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
begin 664 test_expand.gz
|
||||
M'XL("-UD1%,``V%S9`!+SL\K2<TK*5;(3U,H22TNB4^M*$C,2]%+K]+C`@`Z
|
||||
'PQU''```````
|
||||
end
|
||||
5
external/bsd/libarchive/dist/cat/test/test_expand.lz4.uu
vendored
Normal file
5
external/bsd/libarchive/dist/cat/test/test_expand.lz4.uu
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
begin 644 test_expand.lz4
|
||||
M!")-&&1PN1T``(!C;VYT96YT<R!O9B!T97-T7V5X<&%N9"YL>C0N"@`````Y
|
||||
#!E9+
|
||||
`
|
||||
end
|
||||
3
external/bsd/libarchive/dist/cat/test/test_expand.plain.uu
vendored
Normal file
3
external/bsd/libarchive/dist/cat/test/test_expand.plain.uu
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin 664 test_expand.plain
|
||||
?8V]N=&5N=',@;V8@=&5S=%]E>'!A;F0N<&QA:6XN"@
|
||||
end
|
||||
4
external/bsd/libarchive/dist/cat/test/test_expand.xz.uu
vendored
Normal file
4
external/bsd/libarchive/dist/cat/test/test_expand.xz.uu
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
begin 664 test_expand.xz
|
||||
M_3=Z6%H 3FUK1& @ A 18 !T+^6C 0 ;8V]N=&5N=',@;V8@=&5S=%]E
|
||||
G>'!A;F0N>'HN"@!S;^LVAO^3[ !-!R3&JV/'[;S?0$ !%E:
|
||||
end
|
||||
36
external/bsd/libarchive/dist/cat/test/test_expand_Z.c
vendored
Normal file
36
external/bsd/libarchive/dist/cat/test/test_expand_Z.c
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_Z)
|
||||
{
|
||||
const char *reffile = "test_expand.Z";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s %s >test.out 2>test.err", testprog, reffile));
|
||||
|
||||
assertTextFileContents("contents of test_expand.Z.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
||||
42
external/bsd/libarchive/dist/cat/test/test_expand_bz2.c
vendored
Normal file
42
external/bsd/libarchive/dist/cat/test/test_expand_bz2.c
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_bz2)
|
||||
{
|
||||
const char *reffile = "test_expand.bz2";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canBzip2()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.bz2.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems bzip2 is not supported on this platform");
|
||||
}
|
||||
}
|
||||
42
external/bsd/libarchive/dist/cat/test/test_expand_gz.c
vendored
Normal file
42
external/bsd/libarchive/dist/cat/test/test_expand_gz.c
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_gz)
|
||||
{
|
||||
const char *reffile = "test_expand.gz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGzip()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.gz.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems gzip is not supported on this platform");
|
||||
}
|
||||
}
|
||||
42
external/bsd/libarchive/dist/cat/test/test_expand_lz4.c
vendored
Normal file
42
external/bsd/libarchive/dist/cat/test/test_expand_lz4.c
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012, 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_lz4)
|
||||
{
|
||||
const char *reffile = "test_expand.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.lz4.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
||||
41
external/bsd/libarchive/dist/cat/test/test_expand_mixed.c
vendored
Normal file
41
external/bsd/libarchive/dist/cat/test/test_expand_mixed.c
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_mixed)
|
||||
{
|
||||
const char *reffile1 = "test_expand.Z";
|
||||
const char *reffile2 = "test_expand.plain";
|
||||
|
||||
extract_reference_file(reffile1);
|
||||
extract_reference_file(reffile2);
|
||||
assertEqualInt(0, systemf("%s %s %s >test.out 2>test.err",
|
||||
testprog, reffile1, reffile2));
|
||||
|
||||
assertTextFileContents(
|
||||
"contents of test_expand.Z.\n"
|
||||
"contents of test_expand.plain.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
||||
36
external/bsd/libarchive/dist/cat/test/test_expand_plain.c
vendored
Normal file
36
external/bsd/libarchive/dist/cat/test/test_expand_plain.c
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_plain)
|
||||
{
|
||||
const char *reffile = "test_expand.plain";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s %s >test.out 2>test.err", testprog, reffile));
|
||||
|
||||
assertTextFileContents("contents of test_expand.plain.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
||||
42
external/bsd/libarchive/dist/cat/test/test_expand_xz.c
vendored
Normal file
42
external/bsd/libarchive/dist/cat/test/test_expand_xz.c
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Mike Kazantsev
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_expand_xz)
|
||||
{
|
||||
const char *reffile = "test_expand.xz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canXz()) {
|
||||
assertEqualInt(0, f);
|
||||
assertTextFileContents("contents of test_expand.xz.\n", "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems xz is not supported on this platform");
|
||||
}
|
||||
}
|
||||
75
external/bsd/libarchive/dist/cat/test/test_help.c
vendored
Normal file
75
external/bsd/libarchive/dist/cat/test/test_help.c
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* Test that "--help", "-h", and "-W help" options all work and
|
||||
* generate reasonable output.
|
||||
*/
|
||||
|
||||
static int
|
||||
in_first_line(const char *p, const char *substring)
|
||||
{
|
||||
size_t l = strlen(substring);
|
||||
|
||||
while (*p != '\0' && *p != '\n') {
|
||||
if (memcmp(p, substring, l) == 0)
|
||||
return (1);
|
||||
++p;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_help)
|
||||
{
|
||||
int r;
|
||||
char *p;
|
||||
size_t plen;
|
||||
|
||||
/* Exercise --help option. */
|
||||
r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("--help should generate nothing to stderr.");
|
||||
assertEmptyFile("help.stderr");
|
||||
/* Help message should start with name of program. */
|
||||
p = slurpfile(&plen, "help.stdout");
|
||||
failure("Help output should be long enough.");
|
||||
assert(plen >= 6);
|
||||
failure("First line of help output should contain 'bsdcat': %s", p);
|
||||
assert(in_first_line(p, "bsdcat"));
|
||||
/*
|
||||
* TODO: Extend this check to further verify that --help output
|
||||
* looks approximately right.
|
||||
*/
|
||||
free(p);
|
||||
|
||||
/* -h option should generate the same output. */
|
||||
r = systemf("%s -h >h.stdout 2>h.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("-h should generate nothing to stderr.");
|
||||
assertEmptyFile("h.stderr");
|
||||
failure("stdout should be same for -h and --help");
|
||||
assertEqualFile("h.stdout", "help.stdout");
|
||||
}
|
||||
34
external/bsd/libarchive/dist/cat/test/test_version.c
vendored
Normal file
34
external/bsd/libarchive/dist/cat/test/test_version.c
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2017 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* Test that --version option works and generates reasonable output.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_version)
|
||||
{
|
||||
assertVersion(testprog, "bsdcat");
|
||||
}
|
||||
102
external/bsd/libarchive/dist/cpio/bsdcpio.1
vendored
102
external/bsd/libarchive/dist/cpio/bsdcpio.1
vendored
|
|
@ -24,25 +24,25 @@
|
|||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 21, 2007
|
||||
.Dt BSDCPIO 1
|
||||
.Dd September 16, 2014
|
||||
.Dt CPIO 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cpio
|
||||
.Nd copy files to and from archives
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Brq Fl i
|
||||
.Fl i
|
||||
.Op Ar options
|
||||
.Op Ar pattern ...
|
||||
.Op Ar < archive
|
||||
.Nm
|
||||
.Brq Fl o
|
||||
.Fl o
|
||||
.Op Ar options
|
||||
.Ar < name-list
|
||||
.Op Ar > archive
|
||||
.Nm
|
||||
.Brq Fl p
|
||||
.Fl p
|
||||
.Op Ar options
|
||||
.Ar dest-dir
|
||||
.Ar < name-list
|
||||
|
|
@ -59,7 +59,7 @@ is a mode indicator from the following list:
|
|||
.Bl -tag -compact -width indent
|
||||
.It Fl i
|
||||
Input.
|
||||
Read an archive from standard input (unless overriden) and extract the
|
||||
Read an archive from standard input (unless overridden) and extract the
|
||||
contents to disk or (if the
|
||||
.Fl t
|
||||
option is specified)
|
||||
|
|
@ -69,7 +69,7 @@ one of the patterns will be extracted.
|
|||
.It Fl o
|
||||
Output.
|
||||
Read a list of filenames from standard input and produce a new archive
|
||||
on standard output (unless overriden) containing the specified items.
|
||||
on standard output (unless overridden) containing the specified items.
|
||||
.It Fl p
|
||||
Pass-through.
|
||||
Read a list of filenames from standard input and copy the files to the
|
||||
|
|
@ -80,7 +80,7 @@ specified directory.
|
|||
Unless specifically stated otherwise, options are applicable in
|
||||
all operating modes.
|
||||
.Bl -tag -width indent
|
||||
.It Fl 0
|
||||
.It Fl 0 , Fl Fl null
|
||||
Read filenames separated by NUL characters instead of newlines.
|
||||
This is necessary if any of the filenames being read might contain newlines.
|
||||
.It Fl A
|
||||
|
|
@ -102,8 +102,8 @@ bytes.
|
|||
(o mode only)
|
||||
Use the old POSIX portable character format.
|
||||
Equivalent to
|
||||
.Fl -format Ar odc .
|
||||
.It Fl d
|
||||
.Fl Fl format Ar odc .
|
||||
.It Fl d , Fl Fl make-directories
|
||||
(i and p modes)
|
||||
Create directories as necessary.
|
||||
.It Fl E Ar file
|
||||
|
|
@ -111,14 +111,14 @@ Create directories as necessary.
|
|||
Read list of file name patterns from
|
||||
.Ar file
|
||||
to list and extract.
|
||||
.It Fl F Ar file
|
||||
.It Fl F Ar file , Fl Fl file Ar file
|
||||
Read archive from or write archive to
|
||||
.Ar file .
|
||||
.It Fl f Ar pattern
|
||||
(i mode only)
|
||||
Ignore files that match
|
||||
.Ar pattern .
|
||||
.It Fl -format Ar format
|
||||
.It Fl H Ar format , Fl Fl format Ar format
|
||||
(o mode only)
|
||||
Produce the output archive in the specified format.
|
||||
Supported formats include:
|
||||
|
|
@ -140,29 +140,27 @@ The POSIX.1 tar format.
|
|||
The default format is
|
||||
.Ar odc .
|
||||
See
|
||||
.Xr libarchive_formats 5
|
||||
.Xr libarchive-formats 5
|
||||
for more complete information about the
|
||||
formats currently supported by the underlying
|
||||
.Xr libarchive 3
|
||||
library.
|
||||
.It Fl H Ar format
|
||||
Synonym for
|
||||
.Fl -format .
|
||||
.It Fl h , Fl -help
|
||||
.It Fl h , Fl Fl help
|
||||
Print usage information.
|
||||
.It Fl I Ar file
|
||||
Read archive from
|
||||
.Ar file .
|
||||
.It Fl i
|
||||
.It Fl i , Fl Fl extract
|
||||
Input mode.
|
||||
See above for description.
|
||||
.It Fl -insecure
|
||||
.It Fl Fl insecure
|
||||
(i and p mode only)
|
||||
Disable security checks during extraction or copying.
|
||||
This allows extraction via symbolic links and path names containing
|
||||
This allows extraction via symbolic links, absolute paths,
|
||||
and path names containing
|
||||
.Sq ..
|
||||
in the name.
|
||||
.It Fl J
|
||||
.It Fl J , Fl Fl xz
|
||||
(o mode only)
|
||||
Compress the file with xz-compatible compression before writing it.
|
||||
In input mode, this option is ignored; xz compression is recognized
|
||||
|
|
@ -175,20 +173,44 @@ Synonym for
|
|||
All symbolic links will be followed.
|
||||
Normally, symbolic links are archived and copied as symbolic links.
|
||||
With this option, the target of the link will be archived or copied instead.
|
||||
.It Fl l
|
||||
.It Fl l , Fl Fl link
|
||||
(p mode only)
|
||||
Create links from the target directory to the original files,
|
||||
instead of copying.
|
||||
.It Fl lzma
|
||||
.It Fl Fl lrzip
|
||||
(o mode only)
|
||||
Compress the resulting archive with
|
||||
.Xr lrzip 1 .
|
||||
In input mode, this option is ignored.
|
||||
.It Fl Fl lz4
|
||||
(o mode only)
|
||||
Compress the archive with lz4-compatible compression before writing it.
|
||||
In input mode, this option is ignored; lz4 compression is recognized
|
||||
automatically on input.
|
||||
.It Fl Fl lzma
|
||||
(o mode only)
|
||||
Compress the file with lzma-compatible compression before writing it.
|
||||
In input mode, this option is ignored; lzma compression is recognized
|
||||
automatically on input.
|
||||
.It Fl m
|
||||
.It Fl Fl lzop
|
||||
(o mode only)
|
||||
Compress the resulting archive with
|
||||
.Xr lzop 1 .
|
||||
In input mode, this option is ignored.
|
||||
.It Fl Fl passphrase Ar passphrase
|
||||
The
|
||||
.Pa passphrase
|
||||
is used to extract or create an encrypted archive.
|
||||
Currently, zip is only a format that
|
||||
.Nm
|
||||
can handle encrypted archives.
|
||||
You shouldn't use this option unless you realize how insecure
|
||||
use of this option is.
|
||||
.It Fl m , Fl Fl preserve-modification-time
|
||||
(i and p modes)
|
||||
Set file modification time on created files to match
|
||||
those in the source.
|
||||
.It Fl n
|
||||
.It Fl n , Fl Fl numeric-uid-gid
|
||||
(i mode, only with
|
||||
.Fl t )
|
||||
Display numeric uid and gid.
|
||||
|
|
@ -197,26 +219,26 @@ By default,
|
|||
displays the user and group names when they are provided in the
|
||||
archive, or looks up the user and group names in the system
|
||||
password database.
|
||||
.It Fl no-preserve-owner
|
||||
.It Fl Fl no-preserve-owner
|
||||
(i mode only)
|
||||
Do not attempt to restore file ownership.
|
||||
This is the default when run by non-root users.
|
||||
.It Fl O Ar file
|
||||
Write archive to
|
||||
.Ar file .
|
||||
.It Fl o
|
||||
.It Fl o , Fl Fl create
|
||||
Output mode.
|
||||
See above for description.
|
||||
.It Fl p
|
||||
.It Fl p , Fl Fl pass-through
|
||||
Pass-through mode.
|
||||
See above for description.
|
||||
.It Fl preserve-owner
|
||||
.It Fl Fl preserve-owner
|
||||
(i mode only)
|
||||
Restore file ownership.
|
||||
This is the default when run by the root user.
|
||||
.It Fl -quiet
|
||||
.It Fl Fl quiet
|
||||
Suppress unnecessary messages.
|
||||
.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc
|
||||
.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc , Fl Fl owner Oo user Oc Ns Oo : Oc Ns Oo group Oc
|
||||
Set the owner and/or group on files in the output.
|
||||
If group is specified with no user
|
||||
(for example,
|
||||
|
|
@ -244,20 +266,24 @@ containing the name of the file and a line is read from
|
|||
If the line read is blank, the file is skipped.
|
||||
If the line contains a single period, the file is processed normally.
|
||||
Otherwise, the line is taken to be the new name of the file.
|
||||
.It Fl t
|
||||
.It Fl t , Fl Fl list
|
||||
(i mode only)
|
||||
List the contents of the archive to stdout;
|
||||
do not restore the contents to disk.
|
||||
.It Fl u
|
||||
.It Fl u , Fl Fl unconditional
|
||||
(i and p modes)
|
||||
Unconditionally overwrite existing files.
|
||||
Ordinarily, an older file will not overwrite a newer file on disk.
|
||||
.It Fl v
|
||||
.It Fl V , Fl Fl dot
|
||||
Print a dot to stderr for each file as it is processed.
|
||||
Superseded by
|
||||
.Fl v .
|
||||
.It Fl v , Fl Fl verbose
|
||||
Print the name of each file to stderr as it is processed.
|
||||
With
|
||||
.Fl t ,
|
||||
provide a detailed listing of each file.
|
||||
.It Fl -version
|
||||
.It Fl Fl version
|
||||
Print the program version information and exit.
|
||||
.It Fl y
|
||||
(o mode only)
|
||||
|
|
@ -275,6 +301,8 @@ Compress the archive with gzip-compatible compression before writing it.
|
|||
In input mode, this option is ignored;
|
||||
gzip compression is recognized automatically on input.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables affect the execution of
|
||||
.Nm :
|
||||
|
|
@ -290,12 +318,10 @@ See
|
|||
.Xr environ 7
|
||||
for more information.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh EXAMPLES
|
||||
The
|
||||
.Nm
|
||||
command is traditionally used to copy file heirarchies in conjunction
|
||||
command is traditionally used to copy file hierarchies in conjunction
|
||||
with the
|
||||
.Xr find 1
|
||||
command.
|
||||
|
|
|
|||
32
external/bsd/libarchive/dist/cpio/cmdline.c
vendored
32
external/bsd/libarchive/dist/cpio/cmdline.c
vendored
|
|
@ -51,7 +51,7 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.5 2008/12/06 07:30:40 kientzl
|
|||
/*
|
||||
* Short options for cpio. Please keep this sorted.
|
||||
*/
|
||||
static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuvW:yZz";
|
||||
static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuVvW:yZz";
|
||||
|
||||
/*
|
||||
* Long options for cpio. Please keep this sorted.
|
||||
|
|
@ -61,25 +61,34 @@ static const struct option {
|
|||
int required; /* 1 if this option requires an argument */
|
||||
int equivalent; /* Equivalent short option. */
|
||||
} cpio_longopts[] = {
|
||||
{ "b64encode", 0, OPTION_B64ENCODE },
|
||||
{ "create", 0, 'o' },
|
||||
{ "dereference", 0, 'L' },
|
||||
{ "dot", 0, 'V' },
|
||||
{ "extract", 0, 'i' },
|
||||
{ "file", 1, 'F' },
|
||||
{ "format", 1, 'H' },
|
||||
{ "grzip", 0, OPTION_GRZIP },
|
||||
{ "help", 0, 'h' },
|
||||
{ "insecure", 0, OPTION_INSECURE },
|
||||
{ "link", 0, 'l' },
|
||||
{ "list", 0, 't' },
|
||||
{ "lrzip", 0, OPTION_LRZIP },
|
||||
{ "lz4", 0, OPTION_LZ4 },
|
||||
{ "lzma", 0, OPTION_LZMA },
|
||||
{ "lzop", 0, OPTION_LZOP },
|
||||
{ "make-directories", 0, 'd' },
|
||||
{ "no-preserve-owner", 0, OPTION_NO_PRESERVE_OWNER },
|
||||
{ "null", 0, '0' },
|
||||
{ "numeric-uid-gid", 0, 'n' },
|
||||
{ "owner", 1, 'R' },
|
||||
{ "passphrase", 1, OPTION_PASSPHRASE },
|
||||
{ "pass-through", 0, 'p' },
|
||||
{ "preserve-modification-time", 0, 'm' },
|
||||
{ "preserve-owner", 0, OPTION_PRESERVE_OWNER },
|
||||
{ "quiet", 0, OPTION_QUIET },
|
||||
{ "unconditional", 0, 'u' },
|
||||
{ "uuencode", 0, OPTION_UUENCODE },
|
||||
{ "verbose", 0, 'v' },
|
||||
{ "version", 0, OPTION_VERSION },
|
||||
{ "xz", 0, 'J' },
|
||||
|
|
@ -109,7 +118,7 @@ cpio_getopt(struct cpio *cpio)
|
|||
int opt = '?';
|
||||
int required = 0;
|
||||
|
||||
cpio->optarg = NULL;
|
||||
cpio->argument = NULL;
|
||||
|
||||
/* First time through, initialize everything. */
|
||||
if (state == state_start) {
|
||||
|
|
@ -188,7 +197,7 @@ cpio_getopt(struct cpio *cpio)
|
|||
long_prefix = "-W "; /* For clearer errors. */
|
||||
} else {
|
||||
state = state_next_word;
|
||||
cpio->optarg = opt_word;
|
||||
cpio->argument = opt_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -202,7 +211,7 @@ cpio_getopt(struct cpio *cpio)
|
|||
p = strchr(opt_word, '=');
|
||||
if (p != NULL) {
|
||||
optlength = (size_t)(p - opt_word);
|
||||
cpio->optarg = (char *)(uintptr_t)(p + 1);
|
||||
cpio->argument = (char *)(uintptr_t)(p + 1);
|
||||
} else {
|
||||
optlength = strlen(opt_word);
|
||||
}
|
||||
|
|
@ -241,9 +250,9 @@ cpio_getopt(struct cpio *cpio)
|
|||
/* We've found a unique match; does it need an argument? */
|
||||
if (match->required) {
|
||||
/* Argument required: get next word if necessary. */
|
||||
if (cpio->optarg == NULL) {
|
||||
cpio->optarg = *cpio->argv;
|
||||
if (cpio->optarg == NULL) {
|
||||
if (cpio->argument == NULL) {
|
||||
cpio->argument = *cpio->argv;
|
||||
if (cpio->argument == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s requires an argument",
|
||||
long_prefix, match->name);
|
||||
|
|
@ -254,7 +263,7 @@ cpio_getopt(struct cpio *cpio)
|
|||
}
|
||||
} else {
|
||||
/* Argument forbidden: fail if there is one. */
|
||||
if (cpio->optarg != NULL) {
|
||||
if (cpio->argument != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s does not allow an argument",
|
||||
long_prefix, match->name);
|
||||
|
|
@ -285,6 +294,8 @@ cpio_getopt(struct cpio *cpio)
|
|||
* A period can be used instead of the colon.
|
||||
*
|
||||
* Sets uid/gid return as appropriate, -1 indicates uid/gid not specified.
|
||||
* TODO: If the spec uses uname/gname, then return those to the caller
|
||||
* as well. If the spec provides uid/gid, just return names as NULL.
|
||||
*
|
||||
* Returns NULL if no error, otherwise returns error string for display.
|
||||
*
|
||||
|
|
@ -338,11 +349,12 @@ owner_parse(const char *spec, int *uid, int *gid)
|
|||
} else {
|
||||
char *end;
|
||||
errno = 0;
|
||||
*uid = strtoul(user, &end, 10);
|
||||
*uid = (int)strtoul(user, &end, 10);
|
||||
if (errno || *end != '\0') {
|
||||
snprintf(errbuff, sizeof(errbuff),
|
||||
"Couldn't lookup user ``%s''", user);
|
||||
errbuff[sizeof(errbuff) - 1] = '\0';
|
||||
free(user);
|
||||
return (errbuff);
|
||||
}
|
||||
}
|
||||
|
|
@ -356,7 +368,7 @@ owner_parse(const char *spec, int *uid, int *gid)
|
|||
} else {
|
||||
char *end;
|
||||
errno = 0;
|
||||
*gid = strtoul(g, &end, 10);
|
||||
*gid = (int)strtoul(g, &end, 10);
|
||||
if (errno || *end != '\0') {
|
||||
snprintf(errbuff, sizeof(errbuff),
|
||||
"Couldn't lookup group ``%s''", g);
|
||||
|
|
|
|||
428
external/bsd/libarchive/dist/cpio/cpio.c
vendored
428
external/bsd/libarchive/dist/cpio/cpio.c
vendored
|
|
@ -50,9 +50,15 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle
|
|||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
|
@ -69,9 +75,6 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle
|
|||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
|
@ -79,7 +82,7 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle
|
|||
#include "cpio.h"
|
||||
#include "err.h"
|
||||
#include "line_reader.h"
|
||||
#include "matching.h"
|
||||
#include "passphrase.h"
|
||||
|
||||
/* Fixed size of uname/gname caches. */
|
||||
#define name_cache_size 101
|
||||
|
|
@ -105,21 +108,24 @@ static int entry_to_archive(struct cpio *, struct archive_entry *);
|
|||
static int file_to_archive(struct cpio *, const char *);
|
||||
static void free_cache(struct name_cache *cache);
|
||||
static void list_item_verbose(struct cpio *, struct archive_entry *);
|
||||
static void long_help(void);
|
||||
static void long_help(void) __LA_DEAD;
|
||||
static const char *lookup_gname(struct cpio *, gid_t gid);
|
||||
static int lookup_gname_helper(struct cpio *,
|
||||
const char **name, id_t gid);
|
||||
static const char *lookup_uname(struct cpio *, uid_t uid);
|
||||
static int lookup_uname_helper(struct cpio *,
|
||||
const char **name, id_t uid);
|
||||
static void mode_in(struct cpio *);
|
||||
static void mode_list(struct cpio *);
|
||||
static void mode_in(struct cpio *) __LA_DEAD;
|
||||
static void mode_list(struct cpio *) __LA_DEAD;
|
||||
static void mode_out(struct cpio *);
|
||||
static void mode_pass(struct cpio *, const char *);
|
||||
static const char *remove_leading_slash(const char *);
|
||||
static int restore_time(struct cpio *, struct archive_entry *,
|
||||
const char *, int fd);
|
||||
static void usage(void);
|
||||
static void version(void);
|
||||
static void usage(void) __LA_DEAD;
|
||||
static void version(void) __LA_DEAD;
|
||||
static const char * passphrase_callback(struct archive *, void *);
|
||||
static void passphrase_free(char *);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
|
@ -136,20 +142,23 @@ main(int argc, char *argv[])
|
|||
cpio->buff = buff;
|
||||
cpio->buff_size = sizeof(buff);
|
||||
|
||||
/* Need lafe_progname before calling lafe_warnc. */
|
||||
if (*argv == NULL)
|
||||
lafe_progname = "bsdcpio";
|
||||
else {
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
lafe_progname = strrchr(*argv, '\\');
|
||||
#else
|
||||
lafe_progname = strrchr(*argv, '/');
|
||||
#endif
|
||||
if (lafe_progname != NULL)
|
||||
lafe_progname++;
|
||||
else
|
||||
lafe_progname = *argv;
|
||||
#if defined(HAVE_SIGACTION) && defined(SIGPIPE)
|
||||
{ /* Ignore SIGPIPE signals. */
|
||||
struct sigaction sa;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &sa, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set lafe_progname before calling lafe_warnc. */
|
||||
lafe_setprogname(*argv, "bsdcpio");
|
||||
|
||||
#if HAVE_SETLOCALE
|
||||
if (setlocale(LC_ALL, "") == NULL)
|
||||
lafe_warnc(0, "Failed to set default locale");
|
||||
#endif
|
||||
|
||||
cpio->uid_override = -1;
|
||||
cpio->gid_override = -1;
|
||||
|
|
@ -162,6 +171,7 @@ main(int argc, char *argv[])
|
|||
cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_PERM;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_ACL;
|
||||
|
|
@ -172,6 +182,10 @@ main(int argc, char *argv[])
|
|||
cpio->bytes_per_block = 512;
|
||||
cpio->filename = NULL;
|
||||
|
||||
cpio->matching = archive_match_new();
|
||||
if (cpio->matching == NULL)
|
||||
lafe_errc(1, 0, "Out of memory");
|
||||
|
||||
while ((opt = cpio_getopt(cpio)) != -1) {
|
||||
switch (opt) {
|
||||
case '0': /* GNU convention: --null, -0 */
|
||||
|
|
@ -186,10 +200,13 @@ main(int argc, char *argv[])
|
|||
case 'B': /* POSIX 1997 */
|
||||
cpio->bytes_per_block = 5120;
|
||||
break;
|
||||
case OPTION_B64ENCODE:
|
||||
cpio->add_filter = opt;
|
||||
break;
|
||||
case 'C': /* NetBSD/OpenBSD */
|
||||
cpio->bytes_per_block = atoi(cpio->optarg);
|
||||
cpio->bytes_per_block = atoi(cpio->argument);
|
||||
if (cpio->bytes_per_block <= 0)
|
||||
lafe_errc(1, 0, "Invalid blocksize %s", cpio->optarg);
|
||||
lafe_errc(1, 0, "Invalid blocksize %s", cpio->argument);
|
||||
break;
|
||||
case 'c': /* POSIX 1997 */
|
||||
cpio->format = "odc";
|
||||
|
|
@ -198,23 +215,32 @@ main(int argc, char *argv[])
|
|||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_NO_AUTODIR;
|
||||
break;
|
||||
case 'E': /* NetBSD/OpenBSD */
|
||||
lafe_include_from_file(&cpio->matching,
|
||||
cpio->optarg, cpio->option_null);
|
||||
if (archive_match_include_pattern_from_file(
|
||||
cpio->matching, cpio->argument,
|
||||
cpio->option_null) != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "Error : %s",
|
||||
archive_error_string(cpio->matching));
|
||||
break;
|
||||
case 'F': /* NetBSD/OpenBSD/GNU cpio */
|
||||
cpio->filename = cpio->optarg;
|
||||
cpio->filename = cpio->argument;
|
||||
break;
|
||||
case 'f': /* POSIX 1997 */
|
||||
lafe_exclude(&cpio->matching, cpio->optarg);
|
||||
if (archive_match_exclude_pattern(cpio->matching,
|
||||
cpio->argument) != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "Error : %s",
|
||||
archive_error_string(cpio->matching));
|
||||
break;
|
||||
case OPTION_GRZIP:
|
||||
cpio->compress = opt;
|
||||
break;
|
||||
case 'H': /* GNU cpio (also --format) */
|
||||
cpio->format = cpio->optarg;
|
||||
cpio->format = cpio->argument;
|
||||
break;
|
||||
case 'h':
|
||||
long_help();
|
||||
break;
|
||||
case 'I': /* NetBSD/OpenBSD */
|
||||
cpio->filename = cpio->optarg;
|
||||
cpio->filename = cpio->argument;
|
||||
break;
|
||||
case 'i': /* POSIX 1997 */
|
||||
if (cpio->mode != '\0')
|
||||
|
|
@ -231,6 +257,7 @@ main(int argc, char *argv[])
|
|||
case OPTION_INSECURE:
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
|
||||
break;
|
||||
case 'L': /* GNU cpio */
|
||||
cpio->option_follow_links = 1;
|
||||
|
|
@ -238,7 +265,10 @@ main(int argc, char *argv[])
|
|||
case 'l': /* POSIX 1997 */
|
||||
cpio->option_link = 1;
|
||||
break;
|
||||
case OPTION_LRZIP:
|
||||
case OPTION_LZ4:
|
||||
case OPTION_LZMA: /* GNU tar, others */
|
||||
case OPTION_LZOP: /* GNU tar, others */
|
||||
cpio->compress = opt;
|
||||
break;
|
||||
case 'm': /* POSIX 1997 */
|
||||
|
|
@ -251,7 +281,7 @@ main(int argc, char *argv[])
|
|||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
|
||||
break;
|
||||
case 'O': /* GNU cpio */
|
||||
cpio->filename = cpio->optarg;
|
||||
cpio->filename = cpio->argument;
|
||||
break;
|
||||
case 'o': /* POSIX 1997 */
|
||||
if (cpio->mode != '\0')
|
||||
|
|
@ -265,6 +295,10 @@ main(int argc, char *argv[])
|
|||
"Cannot use both -p and -%c", cpio->mode);
|
||||
cpio->mode = opt;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
|
||||
break;
|
||||
case OPTION_PASSPHRASE:
|
||||
cpio->passphrase = cpio->argument;
|
||||
break;
|
||||
case OPTION_PRESERVE_OWNER:
|
||||
cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
|
||||
|
|
@ -273,15 +307,21 @@ main(int argc, char *argv[])
|
|||
cpio->quiet = 1;
|
||||
break;
|
||||
case 'R': /* GNU cpio, also --owner */
|
||||
errmsg = owner_parse(cpio->optarg, &uid, &gid);
|
||||
/* TODO: owner_parse should return uname/gname
|
||||
* also; use that to set [ug]name_override. */
|
||||
errmsg = owner_parse(cpio->argument, &uid, &gid);
|
||||
if (errmsg) {
|
||||
lafe_warnc(-1, "%s", errmsg);
|
||||
usage();
|
||||
}
|
||||
if (uid != -1)
|
||||
if (uid != -1) {
|
||||
cpio->uid_override = uid;
|
||||
if (gid != -1)
|
||||
cpio->uname_override = NULL;
|
||||
}
|
||||
if (gid != -1) {
|
||||
cpio->gid_override = gid;
|
||||
cpio->gname_override = NULL;
|
||||
}
|
||||
break;
|
||||
case 'r': /* POSIX 1997 */
|
||||
cpio->option_rename = 1;
|
||||
|
|
@ -293,9 +333,15 @@ main(int argc, char *argv[])
|
|||
cpio->extract_flags
|
||||
&= ~ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
|
||||
break;
|
||||
case OPTION_UUENCODE:
|
||||
cpio->add_filter = opt;
|
||||
break;
|
||||
case 'v': /* POSIX 1997 */
|
||||
cpio->verbose++;
|
||||
break;
|
||||
case 'V': /* GNU cpio */
|
||||
cpio->dot++;
|
||||
break;
|
||||
case OPTION_VERSION: /* GNU convention */
|
||||
version();
|
||||
break;
|
||||
|
|
@ -339,6 +385,9 @@ main(int argc, char *argv[])
|
|||
/* -l requires -p */
|
||||
if (cpio->option_link && cpio->mode != 'p')
|
||||
lafe_errc(1, 0, "Option -l requires -p");
|
||||
/* -v overrides -V */
|
||||
if (cpio->dot && cpio->verbose)
|
||||
cpio->dot = 0;
|
||||
/* TODO: Flag other nonsensical combinations. */
|
||||
|
||||
switch (cpio->mode) {
|
||||
|
|
@ -352,7 +401,10 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
case 'i':
|
||||
while (*cpio->argv != NULL) {
|
||||
lafe_include(&cpio->matching, *cpio->argv);
|
||||
if (archive_match_include_pattern(cpio->matching,
|
||||
*cpio->argv) != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "Error : %s",
|
||||
archive_error_string(cpio->matching));
|
||||
--cpio->argc;
|
||||
++cpio->argv;
|
||||
}
|
||||
|
|
@ -372,8 +424,11 @@ main(int argc, char *argv[])
|
|||
"Must specify at least one of -i, -o, or -p");
|
||||
}
|
||||
|
||||
archive_match_free(cpio->matching);
|
||||
free_cache(cpio->gname_cache);
|
||||
free_cache(cpio->uname_cache);
|
||||
free(cpio->destdir);
|
||||
passphrase_free(cpio->ppbuff);
|
||||
return (cpio->return_value);
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +437,7 @@ usage(void)
|
|||
{
|
||||
const char *p;
|
||||
|
||||
p = lafe_progname;
|
||||
p = lafe_getprogname();
|
||||
|
||||
fprintf(stderr, "Brief Usage:\n");
|
||||
fprintf(stderr, " List: %s -it < archive\n", p);
|
||||
|
|
@ -396,7 +451,7 @@ static const char *long_help_msg =
|
|||
"First option must be a mode specifier:\n"
|
||||
" -i Input -o Output -p Pass\n"
|
||||
"Common Options:\n"
|
||||
" -v Verbose\n"
|
||||
" -v Verbose filenames -V one dot per file\n"
|
||||
"Create: %p -o [options] < [list of files] > [archive]\n"
|
||||
" -J,-y,-z,--lzma Compress archive with xz/bzip2/gzip/lzma\n"
|
||||
" --format {odc|newc|ustar} Select archive format\n"
|
||||
|
|
@ -420,7 +475,7 @@ long_help(void)
|
|||
const char *prog;
|
||||
const char *p;
|
||||
|
||||
prog = lafe_progname;
|
||||
prog = lafe_getprogname();
|
||||
|
||||
fflush(stderr);
|
||||
|
||||
|
|
@ -443,9 +498,9 @@ long_help(void)
|
|||
static void
|
||||
version(void)
|
||||
{
|
||||
fprintf(stdout,"bsdcpio %s -- %s\n",
|
||||
fprintf(stdout,"bsdcpio %s - %s\n",
|
||||
BSDCPIO_VERSION_STRING,
|
||||
archive_version());
|
||||
archive_version_details());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -473,27 +528,52 @@ mode_out(struct cpio *cpio)
|
|||
if (cpio->archive == NULL)
|
||||
lafe_errc(1, 0, "Failed to allocate archive object");
|
||||
switch (cpio->compress) {
|
||||
case OPTION_GRZIP:
|
||||
r = archive_write_add_filter_grzip(cpio->archive);
|
||||
break;
|
||||
case 'J':
|
||||
r = archive_write_set_compression_xz(cpio->archive);
|
||||
r = archive_write_add_filter_xz(cpio->archive);
|
||||
break;
|
||||
case OPTION_LRZIP:
|
||||
r = archive_write_add_filter_lrzip(cpio->archive);
|
||||
break;
|
||||
case OPTION_LZ4:
|
||||
r = archive_write_add_filter_lz4(cpio->archive);
|
||||
break;
|
||||
case OPTION_LZMA:
|
||||
r = archive_write_set_compression_lzma(cpio->archive);
|
||||
r = archive_write_add_filter_lzma(cpio->archive);
|
||||
break;
|
||||
case OPTION_LZOP:
|
||||
r = archive_write_add_filter_lzop(cpio->archive);
|
||||
break;
|
||||
case 'j': case 'y':
|
||||
r = archive_write_set_compression_bzip2(cpio->archive);
|
||||
r = archive_write_add_filter_bzip2(cpio->archive);
|
||||
break;
|
||||
case 'z':
|
||||
r = archive_write_set_compression_gzip(cpio->archive);
|
||||
r = archive_write_add_filter_gzip(cpio->archive);
|
||||
break;
|
||||
case 'Z':
|
||||
r = archive_write_set_compression_compress(cpio->archive);
|
||||
r = archive_write_add_filter_compress(cpio->archive);
|
||||
break;
|
||||
default:
|
||||
r = archive_write_set_compression_none(cpio->archive);
|
||||
r = archive_write_add_filter_none(cpio->archive);
|
||||
break;
|
||||
}
|
||||
if (r < ARCHIVE_WARN)
|
||||
lafe_errc(1, 0, "Requested compression not available");
|
||||
switch (cpio->add_filter) {
|
||||
case 0:
|
||||
r = ARCHIVE_OK;
|
||||
break;
|
||||
case OPTION_B64ENCODE:
|
||||
r = archive_write_add_filter_b64encode(cpio->archive);
|
||||
break;
|
||||
case OPTION_UUENCODE:
|
||||
r = archive_write_add_filter_uuencode(cpio->archive);
|
||||
break;
|
||||
}
|
||||
if (r < ARCHIVE_WARN)
|
||||
lafe_errc(1, 0, "Requested filter not available");
|
||||
r = archive_write_set_format_by_name(cpio->archive, cpio->format);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
|
||||
|
|
@ -501,11 +581,19 @@ mode_out(struct cpio *cpio)
|
|||
cpio->linkresolver = archive_entry_linkresolver_new();
|
||||
archive_entry_linkresolver_set_strategy(cpio->linkresolver,
|
||||
archive_format(cpio->archive));
|
||||
if (cpio->passphrase != NULL)
|
||||
r = archive_write_set_passphrase(cpio->archive,
|
||||
cpio->passphrase);
|
||||
else
|
||||
r = archive_write_set_passphrase_callback(cpio->archive, cpio,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
|
||||
|
||||
/*
|
||||
* The main loop: Copy each file into the output archive.
|
||||
*/
|
||||
r = archive_write_open_file(cpio->archive, cpio->filename);
|
||||
r = archive_write_open_filename(cpio->archive, cpio->filename);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
|
||||
lr = lafe_line_reader("-", cpio->option_null);
|
||||
|
|
@ -527,17 +615,62 @@ mode_out(struct cpio *cpio)
|
|||
}
|
||||
|
||||
r = archive_write_close(cpio->archive);
|
||||
if (cpio->dot)
|
||||
fprintf(stderr, "\n");
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
|
||||
|
||||
if (!cpio->quiet) {
|
||||
int64_t blocks =
|
||||
(archive_position_uncompressed(cpio->archive) + 511)
|
||||
(archive_filter_bytes(cpio->archive, 0) + 511)
|
||||
/ 512;
|
||||
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
|
||||
blocks == 1 ? "block" : "blocks");
|
||||
}
|
||||
archive_write_finish(cpio->archive);
|
||||
archive_write_free(cpio->archive);
|
||||
}
|
||||
|
||||
static const char *
|
||||
remove_leading_slash(const char *p)
|
||||
{
|
||||
const char *rp;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* Remove leading "/../", "//", etc. */
|
||||
while (p[0] == '/' || p[0] == '\\') {
|
||||
if (p[1] == '.' && p[2] == '.' &&
|
||||
(p[3] == '/' || p[3] == '\\')) {
|
||||
p += 3; /* Remove "/..", leave "/"
|
||||
* for next pass. */
|
||||
} else
|
||||
p += 1; /* Remove "/". */
|
||||
}
|
||||
} while (rp != p);
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -551,7 +684,6 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
|
|||
const char *destpath;
|
||||
struct archive_entry *entry, *spare;
|
||||
size_t len;
|
||||
const char *p;
|
||||
int r;
|
||||
|
||||
/*
|
||||
|
|
@ -571,14 +703,19 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
|
|||
lafe_warnc(0, "%s",
|
||||
archive_error_string(cpio->archive_read_disk));
|
||||
if (r <= ARCHIVE_FAILED) {
|
||||
archive_entry_free(entry);
|
||||
cpio->return_value = 1;
|
||||
return (r);
|
||||
}
|
||||
|
||||
if (cpio->uid_override >= 0)
|
||||
if (cpio->uid_override >= 0) {
|
||||
archive_entry_set_uid(entry, cpio->uid_override);
|
||||
if (cpio->gid_override >= 0)
|
||||
archive_entry_set_uname(entry, cpio->uname_override);
|
||||
}
|
||||
if (cpio->gid_override >= 0) {
|
||||
archive_entry_set_gid(entry, cpio->gid_override);
|
||||
archive_entry_set_gname(entry, cpio->gname_override);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a destination path for this entry.
|
||||
|
|
@ -601,10 +738,7 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
|
|||
"Can't allocate path buffer");
|
||||
}
|
||||
strcpy(cpio->pass_destpath, cpio->destdir);
|
||||
p = srcpath;
|
||||
while (p[0] == '/')
|
||||
++p;
|
||||
strcat(cpio->pass_destpath, p);
|
||||
strcat(cpio->pass_destpath, remove_leading_slash(srcpath));
|
||||
destpath = cpio->pass_destpath;
|
||||
}
|
||||
if (cpio->option_rename)
|
||||
|
|
@ -646,6 +780,8 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
|
|||
/* Print out the destination name to the user. */
|
||||
if (cpio->verbose)
|
||||
fprintf(stderr,"%s", destpath);
|
||||
if (cpio->dot)
|
||||
fprintf(stderr, ".");
|
||||
|
||||
/*
|
||||
* Option_link only makes sense in pass mode and for
|
||||
|
|
@ -715,19 +851,22 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
|
|||
if (r == ARCHIVE_FATAL)
|
||||
exit(1);
|
||||
|
||||
if (r >= ARCHIVE_WARN && fd >= 0) {
|
||||
bytes_read = read(fd, cpio->buff, cpio->buff_size);
|
||||
if (r >= ARCHIVE_WARN && archive_entry_size(entry) > 0 && fd >= 0) {
|
||||
bytes_read = read(fd, cpio->buff, (unsigned)cpio->buff_size);
|
||||
while (bytes_read > 0) {
|
||||
r = archive_write_data(cpio->archive,
|
||||
ssize_t bytes_write;
|
||||
bytes_write = archive_write_data(cpio->archive,
|
||||
cpio->buff, bytes_read);
|
||||
if (r < 0)
|
||||
if (bytes_write < 0)
|
||||
lafe_errc(1, archive_errno(cpio->archive),
|
||||
"%s", archive_error_string(cpio->archive));
|
||||
if (r < bytes_read) {
|
||||
if (bytes_write < bytes_read) {
|
||||
lafe_warnc(0,
|
||||
"Truncated write; file may have grown while being archived.");
|
||||
"Truncated write; file may have "
|
||||
"grown while being archived.");
|
||||
}
|
||||
bytes_read = read(fd, cpio->buff, cpio->buff_size);
|
||||
bytes_read = read(fd, cpio->buff,
|
||||
(unsigned)cpio->buff_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -815,10 +954,18 @@ mode_in(struct cpio *cpio)
|
|||
a = archive_read_new();
|
||||
if (a == NULL)
|
||||
lafe_errc(1, 0, "Couldn't allocate archive object");
|
||||
archive_read_support_compression_all(a);
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
if (cpio->passphrase != NULL)
|
||||
r = archive_read_add_passphrase(a, cpio->passphrase);
|
||||
else
|
||||
r = archive_read_set_passphrase_callback(a, cpio,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
|
||||
if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
|
||||
if (archive_read_open_filename(a, cpio->filename,
|
||||
cpio->bytes_per_block))
|
||||
lafe_errc(1, archive_errno(a),
|
||||
"%s", archive_error_string(a));
|
||||
for (;;) {
|
||||
|
|
@ -829,7 +976,7 @@ mode_in(struct cpio *cpio)
|
|||
lafe_errc(1, archive_errno(a),
|
||||
"%s", archive_error_string(a));
|
||||
}
|
||||
if (lafe_excluded(cpio->matching, archive_entry_pathname(entry)))
|
||||
if (archive_match_path_excluded(cpio->matching, entry))
|
||||
continue;
|
||||
if (cpio->option_rename) {
|
||||
destpath = cpio_rename(archive_entry_pathname(entry));
|
||||
|
|
@ -839,7 +986,9 @@ mode_in(struct cpio *cpio)
|
|||
if (destpath == NULL)
|
||||
continue;
|
||||
if (cpio->verbose)
|
||||
fprintf(stdout, "%s\n", destpath);
|
||||
fprintf(stderr, "%s\n", destpath);
|
||||
if (cpio->dot)
|
||||
fprintf(stderr, ".");
|
||||
if (cpio->uid_override >= 0)
|
||||
archive_entry_set_uid(entry, cpio->uid_override);
|
||||
if (cpio->gid_override >= 0)
|
||||
|
|
@ -849,26 +998,29 @@ mode_in(struct cpio *cpio)
|
|||
fprintf(stderr, "%s: %s\n",
|
||||
archive_entry_pathname(entry),
|
||||
archive_error_string(ext));
|
||||
} else if (archive_entry_size(entry) > 0) {
|
||||
} else if (!archive_entry_size_is_set(entry)
|
||||
|| archive_entry_size(entry) > 0) {
|
||||
r = extract_data(a, ext);
|
||||
if (r != ARCHIVE_OK)
|
||||
cpio->return_value = 1;
|
||||
}
|
||||
}
|
||||
r = archive_read_close(a);
|
||||
if (cpio->dot)
|
||||
fprintf(stderr, "\n");
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
r = archive_write_close(ext);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(ext));
|
||||
if (!cpio->quiet) {
|
||||
int64_t blocks = (archive_position_uncompressed(a) + 511)
|
||||
int64_t blocks = (archive_filter_bytes(a, 0) + 511)
|
||||
/ 512;
|
||||
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
|
||||
blocks == 1 ? "block" : "blocks");
|
||||
}
|
||||
archive_read_finish(a);
|
||||
archive_write_finish(ext);
|
||||
archive_read_free(a);
|
||||
archive_write_free(ext);
|
||||
exit(cpio->return_value);
|
||||
}
|
||||
|
||||
|
|
@ -882,7 +1034,7 @@ extract_data(struct archive *ar, struct archive *aw)
|
|||
int r;
|
||||
size_t size;
|
||||
const void *block;
|
||||
off_t offset;
|
||||
int64_t offset;
|
||||
|
||||
for (;;) {
|
||||
r = archive_read_data_block(ar, &block, &size, &offset);
|
||||
|
|
@ -893,7 +1045,7 @@ extract_data(struct archive *ar, struct archive *aw)
|
|||
"%s", archive_error_string(ar));
|
||||
exit(1);
|
||||
}
|
||||
r = archive_write_data_block(aw, block, size, offset);
|
||||
r = (int)archive_write_data_block(aw, block, size, offset);
|
||||
if (r != ARCHIVE_OK) {
|
||||
lafe_warnc(archive_errno(aw),
|
||||
"%s", archive_error_string(aw));
|
||||
|
|
@ -912,10 +1064,18 @@ mode_list(struct cpio *cpio)
|
|||
a = archive_read_new();
|
||||
if (a == NULL)
|
||||
lafe_errc(1, 0, "Couldn't allocate archive object");
|
||||
archive_read_support_compression_all(a);
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
if (cpio->passphrase != NULL)
|
||||
r = archive_read_add_passphrase(a, cpio->passphrase);
|
||||
else
|
||||
r = archive_read_set_passphrase_callback(a, cpio,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
|
||||
if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
|
||||
if (archive_read_open_filename(a, cpio->filename,
|
||||
cpio->bytes_per_block))
|
||||
lafe_errc(1, archive_errno(a),
|
||||
"%s", archive_error_string(a));
|
||||
for (;;) {
|
||||
|
|
@ -926,7 +1086,7 @@ mode_list(struct cpio *cpio)
|
|||
lafe_errc(1, archive_errno(a),
|
||||
"%s", archive_error_string(a));
|
||||
}
|
||||
if (lafe_excluded(cpio->matching, archive_entry_pathname(entry)))
|
||||
if (archive_match_path_excluded(cpio->matching, entry))
|
||||
continue;
|
||||
if (cpio->verbose)
|
||||
list_item_verbose(cpio, entry);
|
||||
|
|
@ -937,12 +1097,12 @@ mode_list(struct cpio *cpio)
|
|||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
if (!cpio->quiet) {
|
||||
int64_t blocks = (archive_position_uncompressed(a) + 511)
|
||||
int64_t blocks = (archive_filter_bytes(a, 0) + 511)
|
||||
/ 512;
|
||||
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
|
||||
blocks == 1 ? "block" : "blocks");
|
||||
}
|
||||
archive_read_finish(a);
|
||||
archive_read_free(a);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -979,11 +1139,11 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
|
|||
/* Use uname if it's present, else lookup name from uid. */
|
||||
uname = archive_entry_uname(entry);
|
||||
if (uname == NULL)
|
||||
uname = lookup_uname(cpio, archive_entry_uid(entry));
|
||||
uname = lookup_uname(cpio, (uid_t)archive_entry_uid(entry));
|
||||
/* Use gname if it's present, else lookup name from gid. */
|
||||
gname = archive_entry_gname(entry);
|
||||
if (gname == NULL)
|
||||
gname = lookup_gname(cpio, archive_entry_gid(entry));
|
||||
gname = lookup_gname(cpio, (uid_t)archive_entry_gid(entry));
|
||||
}
|
||||
|
||||
/* Print device number or file size. */
|
||||
|
|
@ -1006,7 +1166,8 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
|
|||
else
|
||||
fmt = cpio->day_first ? "%d %b %H:%M" : "%b %d %H:%M";
|
||||
#else
|
||||
if (abs(mtime - now) > (365/2)*86400)
|
||||
if (mtime - now > 365*86400/2
|
||||
|| mtime - now < -365*86400/2)
|
||||
fmt = cpio->day_first ? "%e %b %Y" : "%b %e %Y";
|
||||
else
|
||||
fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
|
||||
|
|
@ -1065,18 +1226,20 @@ mode_pass(struct cpio *cpio, const char *destdir)
|
|||
|
||||
archive_entry_linkresolver_free(cpio->linkresolver);
|
||||
r = archive_write_close(cpio->archive);
|
||||
if (cpio->dot)
|
||||
fprintf(stderr, "\n");
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
|
||||
|
||||
if (!cpio->quiet) {
|
||||
int64_t blocks =
|
||||
(archive_position_uncompressed(cpio->archive) + 511)
|
||||
(archive_filter_bytes(cpio->archive, 0) + 511)
|
||||
/ 512;
|
||||
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
|
||||
blocks == 1 ? "block" : "blocks");
|
||||
}
|
||||
|
||||
archive_write_finish(cpio->archive);
|
||||
archive_write_free(cpio->archive);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1092,12 +1255,26 @@ cpio_rename(const char *name)
|
|||
static char buff[1024];
|
||||
FILE *t;
|
||||
char *p, *ret;
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
FILE *to;
|
||||
|
||||
t = fopen("CONIN$", "r");
|
||||
if (t == NULL)
|
||||
return (name);
|
||||
to = fopen("CONOUT$", "w");
|
||||
if (to == NULL) {
|
||||
fclose(t);
|
||||
return (name);
|
||||
}
|
||||
fprintf(to, "%s (Enter/./(new name))? ", name);
|
||||
fclose(to);
|
||||
#else
|
||||
t = fopen("/dev/tty", "r+");
|
||||
if (t == NULL)
|
||||
return (name);
|
||||
fprintf(t, "%s (Enter/./(new name))? ", name);
|
||||
fflush(t);
|
||||
#endif
|
||||
|
||||
p = fgets(buff, sizeof(buff), t);
|
||||
fclose(t);
|
||||
|
|
@ -1148,10 +1325,9 @@ lookup_name(struct cpio *cpio, struct name_cache **name_cache_variable,
|
|||
|
||||
|
||||
if (*name_cache_variable == NULL) {
|
||||
*name_cache_variable = malloc(sizeof(struct name_cache));
|
||||
*name_cache_variable = calloc(1, sizeof(struct name_cache));
|
||||
if (*name_cache_variable == NULL)
|
||||
lafe_errc(1, ENOMEM, "No more memory");
|
||||
memset(*name_cache_variable, 0, sizeof(struct name_cache));
|
||||
(*name_cache_variable)->size = name_cache_size;
|
||||
}
|
||||
|
||||
|
|
@ -1168,23 +1344,23 @@ lookup_name(struct cpio *cpio, struct name_cache **name_cache_variable,
|
|||
cache->cache[slot].name = NULL;
|
||||
}
|
||||
|
||||
if (lookup_fn(cpio, &name, id) == 0) {
|
||||
if (name == NULL || name[0] == '\0') {
|
||||
/* If lookup failed, format it as a number. */
|
||||
snprintf(asnum, sizeof(asnum), "%u", (unsigned)id);
|
||||
name = asnum;
|
||||
}
|
||||
cache->cache[slot].name = strdup(name);
|
||||
if (cache->cache[slot].name != NULL) {
|
||||
cache->cache[slot].id = id;
|
||||
return (cache->cache[slot].name);
|
||||
}
|
||||
/*
|
||||
* Conveniently, NULL marks an empty slot, so
|
||||
* if the strdup() fails, we've just failed to
|
||||
* cache it. No recovery necessary.
|
||||
*/
|
||||
if (lookup_fn(cpio, &name, id)) {
|
||||
/* If lookup failed, format it as a number. */
|
||||
snprintf(asnum, sizeof(asnum), "%u", (unsigned)id);
|
||||
name = asnum;
|
||||
}
|
||||
|
||||
cache->cache[slot].name = strdup(name);
|
||||
if (cache->cache[slot].name != NULL) {
|
||||
cache->cache[slot].id = id;
|
||||
return (cache->cache[slot].name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Conveniently, NULL marks an empty slot, so
|
||||
* if the strdup() fails, we've just failed to
|
||||
* cache it. No recovery necessary.
|
||||
*/
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1205,14 +1381,14 @@ lookup_uname_helper(struct cpio *cpio, const char **name, id_t id)
|
|||
errno = 0;
|
||||
pwent = getpwuid((uid_t)id);
|
||||
if (pwent == NULL) {
|
||||
*name = NULL;
|
||||
if (errno != 0 && errno != ENOENT)
|
||||
lafe_warnc(errno, "getpwuid(%d) failed", id);
|
||||
return (errno);
|
||||
if (errno && errno != ENOENT)
|
||||
lafe_warnc(errno, "getpwuid(%s) failed",
|
||||
cpio_i64toa((int64_t)id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
*name = pwent->pw_name;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -1232,14 +1408,14 @@ lookup_gname_helper(struct cpio *cpio, const char **name, id_t id)
|
|||
errno = 0;
|
||||
grent = getgrgid((gid_t)id);
|
||||
if (grent == NULL) {
|
||||
*name = NULL;
|
||||
if (errno != 0)
|
||||
lafe_warnc(errno, "getgrgid(%d) failed", id);
|
||||
return (errno);
|
||||
if (errno && errno != ENOENT)
|
||||
lafe_warnc(errno, "getgrgid(%s) failed",
|
||||
cpio_i64toa((int64_t)id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
*name = grent->gr_name;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1250,8 +1426,9 @@ lookup_gname_helper(struct cpio *cpio, const char **name, id_t id)
|
|||
const char *
|
||||
cpio_i64toa(int64_t n0)
|
||||
{
|
||||
// 2^64 =~ 1.8 * 10^19, so 20 decimal digits suffice.
|
||||
// We also need 1 byte for '-' and 1 for '\0'.
|
||||
/* 2^64 =~ 1.8 * 10^19, so 20 decimal digits suffice.
|
||||
* We also need 1 byte for '-' and 1 for '\0'.
|
||||
*/
|
||||
static char buff[22];
|
||||
int64_t n = n0 < 0 ? -n0 : n0;
|
||||
char *p = buff + sizeof(buff);
|
||||
|
|
@ -1265,3 +1442,28 @@ cpio_i64toa(int64_t n0)
|
|||
*--p = '-';
|
||||
return p;
|
||||
}
|
||||
|
||||
#define PPBUFF_SIZE 1024
|
||||
static const char *
|
||||
passphrase_callback(struct archive *a, void *_client_data)
|
||||
{
|
||||
struct cpio *cpio = (struct cpio *)_client_data;
|
||||
(void)a; /* UNUSED */
|
||||
|
||||
if (cpio->ppbuff == NULL) {
|
||||
cpio->ppbuff = malloc(PPBUFF_SIZE);
|
||||
if (cpio->ppbuff == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
}
|
||||
return lafe_readpassphrase("Enter passphrase:",
|
||||
cpio->ppbuff, PPBUFF_SIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
passphrase_free(char *ppbuff)
|
||||
{
|
||||
if (ppbuff != NULL) {
|
||||
memset(ppbuff, 0, PPBUFF_SIZE);
|
||||
free(ppbuff);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
external/bsd/libarchive/dist/cpio/cpio.h
vendored
26
external/bsd/libarchive/dist/cpio/cpio.h
vendored
|
|
@ -31,8 +31,6 @@
|
|||
#include "cpio_platform.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "matching.h"
|
||||
|
||||
/*
|
||||
* The internal state for the "cpio" program.
|
||||
*
|
||||
|
|
@ -43,18 +41,19 @@
|
|||
*/
|
||||
struct cpio {
|
||||
/* Option parsing */
|
||||
const char *optarg;
|
||||
const char *argument;
|
||||
|
||||
/* Options */
|
||||
int add_filter; /* --uuencode */
|
||||
const char *filename;
|
||||
char mode; /* -i -o -p */
|
||||
char compress; /* -j, -y, or -z */
|
||||
int mode; /* -i -o -p */
|
||||
int compress; /* -j, -y, or -z */
|
||||
const char *format; /* -H format */
|
||||
int bytes_per_block; /* -b block_size */
|
||||
int verbose; /* -v */
|
||||
int dot; /* -V */
|
||||
int quiet; /* --quiet */
|
||||
int extract_flags; /* Flags for extract operation */
|
||||
char symlink_mode; /* H or L, per BSD conventions */
|
||||
const char *compress_program;
|
||||
int option_append; /* -A, only relevant for -o */
|
||||
int option_atime_restore; /* -a */
|
||||
|
|
@ -68,8 +67,11 @@ struct cpio {
|
|||
size_t pass_destpath_alloc;
|
||||
char *pass_destpath;
|
||||
int uid_override;
|
||||
char *uname_override;
|
||||
int gid_override;
|
||||
char *gname_override;
|
||||
int day_first; /* true if locale prefers day/mon */
|
||||
const char *passphrase;
|
||||
|
||||
/* If >= 0, then close this when done. */
|
||||
int fd;
|
||||
|
|
@ -86,9 +88,10 @@ struct cpio {
|
|||
struct name_cache *gname_cache;
|
||||
|
||||
/* Work data. */
|
||||
struct lafe_matching *matching;
|
||||
struct archive *matching;
|
||||
char *buff;
|
||||
size_t buff_size;
|
||||
char *ppbuff;
|
||||
};
|
||||
|
||||
const char *owner_parse(const char *, int *, int *);
|
||||
|
|
@ -96,11 +99,18 @@ const char *owner_parse(const char *, int *, int *);
|
|||
|
||||
/* Fake short equivalents for long options that otherwise lack them. */
|
||||
enum {
|
||||
OPTION_INSECURE = 1,
|
||||
OPTION_B64ENCODE = 1,
|
||||
OPTION_GRZIP,
|
||||
OPTION_INSECURE,
|
||||
OPTION_LRZIP,
|
||||
OPTION_LZ4,
|
||||
OPTION_LZMA,
|
||||
OPTION_LZOP,
|
||||
OPTION_PASSPHRASE,
|
||||
OPTION_NO_PRESERVE_OWNER,
|
||||
OPTION_PRESERVE_OWNER,
|
||||
OPTION_QUIET,
|
||||
OPTION_UUENCODE,
|
||||
OPTION_VERSION
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "cpio_windows.h"
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
|
|
@ -70,8 +74,4 @@
|
|||
#define __LA_DEAD
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "cpio_windows.h"
|
||||
#endif
|
||||
|
||||
#endif /* !CPIO_PLATFORM_H_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ cpio_dosmaperr(unsigned long e)
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(doserrors); i++) {
|
||||
for (i = 0; i < (int)sizeof(doserrors); i++) {
|
||||
if (doserrors[i].winerr == e) {
|
||||
errno = doserrors[i].doserr;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
#ifndef CPIO_WINDOWS_H
|
||||
#define CPIO_WINDOWS_H 1
|
||||
#include <windows.h>
|
||||
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
|
|
@ -35,8 +36,10 @@
|
|||
#define getpwnam(name) NULL
|
||||
#define getpwuid(id) NULL
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER < 1900
|
||||
#define snprintf sprintf_s
|
||||
#endif // _MSC_VER < 1900
|
||||
#define strdup _strdup
|
||||
#define open _open
|
||||
#define read _read
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
############################################
|
||||
#
|
||||
# How to build bsdcpio_test
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
SET(bsdcpio_test_SOURCES
|
||||
../cmdline.c
|
||||
../../libarchive_fe/err.c
|
||||
../../libarchive_fe/pathmatch.c
|
||||
main.c
|
||||
test.h
|
||||
test_0.c
|
||||
test_basic.c
|
||||
test_cmdline.c
|
||||
test_format_newc.c
|
||||
test_gcpio_compat.c
|
||||
test_option_B_upper.c
|
||||
test_option_C_upper.c
|
||||
test_option_J_upper.c
|
||||
test_option_L_upper.c
|
||||
test_option_Z_upper.c
|
||||
test_option_a.c
|
||||
test_option_c.c
|
||||
test_option_d.c
|
||||
test_option_f.c
|
||||
test_option_help.c
|
||||
test_option_l.c
|
||||
test_option_lzma.c
|
||||
test_option_m.c
|
||||
test_option_t.c
|
||||
test_option_u.c
|
||||
test_option_version.c
|
||||
test_option_y.c
|
||||
test_option_z.c
|
||||
test_owner_parse.c
|
||||
test_passthrough_dotdot.c
|
||||
test_passthrough_reverse.c
|
||||
test_pathmatch.c
|
||||
)
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
LIST(APPEND bsdcpio_test_SOURCES ../cpio_windows.h)
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
|
||||
#
|
||||
# Register target
|
||||
#
|
||||
ADD_EXECUTABLE(bsdcpio_test ${bsdcpio_test_SOURCES})
|
||||
SET_PROPERTY(TARGET bsdcpio_test PROPERTY COMPILE_DEFINITIONS LIST_H)
|
||||
|
||||
#
|
||||
# Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
|
||||
#
|
||||
GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
|
||||
${CMAKE_CURRENT_LIST_FILE} ${bsdcpio_test_SOURCES})
|
||||
SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# list.h has a line DEFINE_TEST(testname) for every
|
||||
# test. We can use that to define the tests for cmake by
|
||||
# defining a DEFINE_TEST macro and reading list.h in.
|
||||
MACRO (DEFINE_TEST _testname)
|
||||
ADD_TEST_28(
|
||||
NAME bsdcpio_${_testname}
|
||||
COMMAND bsdcpio_test -vv
|
||||
-p $<TARGET_FILE:bsdcpio>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${_testname})
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
|
||||
# Experimental new test handling
|
||||
ADD_CUSTOM_TARGET(run_bsdcpio_test
|
||||
COMMAND bsdcpio_test -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
|
||||
ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
|
||||
ENDIF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
|
||||
27
external/bsd/libarchive/dist/cpio/test/list.h
vendored
27
external/bsd/libarchive/dist/cpio/test/list.h
vendored
|
|
@ -1,27 +0,0 @@
|
|||
DEFINE_TEST(test_0)
|
||||
DEFINE_TEST(test_basic)
|
||||
DEFINE_TEST(test_cmdline)
|
||||
DEFINE_TEST(test_format_newc)
|
||||
DEFINE_TEST(test_gcpio_compat)
|
||||
DEFINE_TEST(test_option_B_upper)
|
||||
DEFINE_TEST(test_option_C_upper)
|
||||
DEFINE_TEST(test_option_J_upper)
|
||||
DEFINE_TEST(test_option_L_upper)
|
||||
DEFINE_TEST(test_option_Z_upper)
|
||||
DEFINE_TEST(test_option_a)
|
||||
DEFINE_TEST(test_option_c)
|
||||
DEFINE_TEST(test_option_d)
|
||||
DEFINE_TEST(test_option_f)
|
||||
DEFINE_TEST(test_option_help)
|
||||
DEFINE_TEST(test_option_l)
|
||||
DEFINE_TEST(test_option_lzma)
|
||||
DEFINE_TEST(test_option_m)
|
||||
DEFINE_TEST(test_option_t)
|
||||
DEFINE_TEST(test_option_u)
|
||||
DEFINE_TEST(test_option_version)
|
||||
DEFINE_TEST(test_option_y)
|
||||
DEFINE_TEST(test_option_z)
|
||||
DEFINE_TEST(test_owner_parse)
|
||||
DEFINE_TEST(test_passthrough_dotdot)
|
||||
DEFINE_TEST(test_passthrough_reverse)
|
||||
DEFINE_TEST(test_pathmatch)
|
||||
2140
external/bsd/libarchive/dist/cpio/test/main.c
vendored
2140
external/bsd/libarchive/dist/cpio/test/main.c
vendored
File diff suppressed because it is too large
Load Diff
269
external/bsd/libarchive/dist/cpio/test/test.h
vendored
269
external/bsd/libarchive/dist/cpio/test/test.h
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2006 Tim Kientzle
|
||||
* Copyright (c) 2003-2017 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -22,264 +22,19 @@
|
|||
* (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/cpio/test/test.h,v 1.2 2008/06/21 02:17:18 kientzle Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* Every test program should #include "test.h" as the first thing. */
|
||||
|
||||
/*
|
||||
* The goal of this file (and the matching test.c) is to
|
||||
* simplify the very repetitive test-*.c test programs.
|
||||
*/
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
/* Most POSIX platforms use the 'configure' script to build config.h */
|
||||
#include "config.h"
|
||||
#elif defined(__FreeBSD__)
|
||||
/* Building as part of FreeBSD system requires a pre-built config.h. */
|
||||
#include "config_freebsd.h"
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Win32 can't run the 'configure' script. */
|
||||
#include "config_windows.h"
|
||||
#else
|
||||
/* Warn if the library hasn't been (automatically or manually) configured. */
|
||||
#error Oops: No config.h and no pre-built configuration in test.h.
|
||||
#endif
|
||||
#define KNOWNREF "test_option_f.cpio.uu"
|
||||
#define ENVBASE "BSDCPIO" /* Prefix for environment variables. */
|
||||
#define PROGRAM "bsdcpio" /* Name of program being tested. */
|
||||
#define PROGRAM_ALIAS "cpio" /* Generic alias for program */
|
||||
#undef LIBRARY /* Not testing a library. */
|
||||
#undef EXTRA_DUMP /* How to dump extra data */
|
||||
#undef EXTRA_ERRNO /* How to dump errno */
|
||||
/* How to generate extra version info. */
|
||||
#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
|
||||
|
||||
#include <sys/types.h> /* Windows requires this before sys/stat.h */
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef USE_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
#if HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#ifdef HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#define dirent direct
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* System-specific tweaks. We really want to minimize these
|
||||
* as much as possible, since they make it harder to understand
|
||||
* the mainline code.
|
||||
*/
|
||||
|
||||
/* Windows (including Visual Studio and MinGW but not Cygwin) */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "../cpio_windows.h"
|
||||
#if !defined(__BORLANDC__)
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#define LOCALE_DE "deu"
|
||||
#else
|
||||
#define LOCALE_DE "de_DE.UTF-8"
|
||||
#endif
|
||||
|
||||
/* Visual Studio */
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
/* Cygwin */
|
||||
#if defined(__CYGWIN__)
|
||||
/* Cygwin-1.7.x is lazy about populating nlinks, so don't
|
||||
* expect it to be accurate. */
|
||||
# define NLINKS_INACCURATE_FOR_DIRS
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__) || defined(__QNXNTO__)
|
||||
/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Redefine DEFINE_TEST for use in defining the test functions.
|
||||
*/
|
||||
#undef DEFINE_TEST
|
||||
#define DEFINE_TEST(name) void name(void); void name(void)
|
||||
|
||||
/* An implementation of the standard assert() macro */
|
||||
#define assert(e) assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
|
||||
/* chdir() and error if it fails */
|
||||
#define assertChdir(path) \
|
||||
assertion_chdir(__FILE__, __LINE__, path)
|
||||
/* Assert two integers are the same. Reports value of each one if not. */
|
||||
#define assertEqualInt(v1,v2) \
|
||||
assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* Assert two strings are the same. Reports value of each one if not. */
|
||||
#define assertEqualString(v1,v2) \
|
||||
assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* As above, but v1 and v2 are wchar_t * */
|
||||
#define assertEqualWString(v1,v2) \
|
||||
assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
|
||||
/* As above, but raw blocks of bytes. */
|
||||
#define assertEqualMem(v1, v2, l) \
|
||||
assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
|
||||
/* Assert two files are the same; allow printf-style expansion of second name.
|
||||
* See below for comments about variable arguments here...
|
||||
*/
|
||||
#define assertEqualFile \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_equal_file
|
||||
/* Assert that a file is empty; supports printf-style arguments. */
|
||||
#define assertEmptyFile \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_empty_file
|
||||
/* Assert that a file is not empty; supports printf-style arguments. */
|
||||
#define assertNonEmptyFile \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
|
||||
#define assertFileAtime(pathname, sec, nsec) \
|
||||
assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileAtimeRecent(pathname) \
|
||||
assertion_file_atime_recent(__FILE__, __LINE__, pathname)
|
||||
#define assertFileBirthtime(pathname, sec, nsec) \
|
||||
assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileBirthtimeRecent(pathname) \
|
||||
assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
|
||||
/* Assert that a file exists; supports printf-style arguments. */
|
||||
#define assertFileExists \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_file_exists
|
||||
/* Assert that a file exists; supports printf-style arguments. */
|
||||
#define assertFileNotExists \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
|
||||
/* Assert that file contents match a string; supports printf-style arguments. */
|
||||
#define assertFileContents \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_file_contents
|
||||
#define assertFileMtime(pathname, sec, nsec) \
|
||||
assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
|
||||
#define assertFileMtimeRecent(pathname) \
|
||||
assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
|
||||
#define assertFileNLinks(pathname, nlinks) \
|
||||
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
|
||||
#define assertFileSize(pathname, size) \
|
||||
assertion_file_size(__FILE__, __LINE__, pathname, size)
|
||||
#define assertTextFileContents \
|
||||
assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
|
||||
#define assertIsDir(pathname, mode) \
|
||||
assertion_is_dir(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertIsHardlink(path1, path2) \
|
||||
assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
|
||||
#define assertIsNotHardlink(path1, path2) \
|
||||
assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
|
||||
#define assertIsReg(pathname, mode) \
|
||||
assertion_is_reg(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertIsSymlink(pathname, contents) \
|
||||
assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
|
||||
/* Create a directory, report error if it fails. */
|
||||
#define assertMakeDir(dirname, mode) \
|
||||
assertion_make_dir(__FILE__, __LINE__, dirname, mode)
|
||||
#define assertMakeFile(path, mode, contents) \
|
||||
assertion_make_file(__FILE__, __LINE__, path, mode, contents)
|
||||
#define assertMakeHardlink(newfile, oldfile) \
|
||||
assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
|
||||
#define assertMakeSymlink(newfile, linkto) \
|
||||
assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
|
||||
#define assertUmask(mask) \
|
||||
assertion_umask(__FILE__, __LINE__, mask)
|
||||
|
||||
/*
|
||||
* 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 \
|
||||
assertion_setup(__FILE__, __LINE__);test_skipping
|
||||
|
||||
/* Function declarations. These are defined in test_utility.c. */
|
||||
void failure(const char *fmt, ...);
|
||||
int assertion_assert(const char *, int, int, const char *, void *);
|
||||
int assertion_chdir(const char *, int, const char *);
|
||||
int assertion_empty_file(const char *, ...);
|
||||
int assertion_equal_file(const char *, const char *, ...);
|
||||
int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
|
||||
int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
|
||||
int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
|
||||
int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
|
||||
int assertion_file_atime(const char *, int, const char *, long, long);
|
||||
int assertion_file_atime_recent(const char *, int, const char *);
|
||||
int assertion_file_birthtime(const char *, int, const char *, long, long);
|
||||
int assertion_file_birthtime_recent(const char *, int, const char *);
|
||||
int assertion_file_contents(const void *, int, const char *, ...);
|
||||
int assertion_file_exists(const char *, ...);
|
||||
int assertion_file_mtime(const char *, int, const char *, long, long);
|
||||
int assertion_file_mtime_recent(const char *, int, const char *);
|
||||
int assertion_file_nlinks(const char *, int, const char *, int);
|
||||
int assertion_file_not_exists(const char *, ...);
|
||||
int assertion_file_size(const char *, int, const char *, long);
|
||||
int assertion_is_dir(const char *, int, const char *, int);
|
||||
int assertion_is_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_not_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_reg(const char *, int, const char *, int);
|
||||
int assertion_is_symlink(const char *, int, const char *, const char *);
|
||||
int assertion_make_dir(const char *, int, const char *, int);
|
||||
int assertion_make_file(const char *, int, const char *, int, const char *);
|
||||
int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
|
||||
int assertion_make_symlink(const char *, int, const char *newpath, const char *);
|
||||
int assertion_non_empty_file(const char *, ...);
|
||||
int assertion_text_file_contents(const char *buff, const char *f);
|
||||
int assertion_umask(const char *, int, int);
|
||||
void assertion_setup(const char *, int);
|
||||
|
||||
void test_skipping(const char *fmt, ...);
|
||||
|
||||
/* Like sprintf, then system() */
|
||||
int systemf(const char * fmt, ...);
|
||||
|
||||
/* Delay until time() returns a value after this. */
|
||||
void sleepUntilAfter(time_t);
|
||||
|
||||
/* Return true if this platform can create symlinks. */
|
||||
int canSymlink(void);
|
||||
|
||||
/* Return true if this platform can run the "gzip" program. */
|
||||
int canGzip(void);
|
||||
|
||||
/* Return true if this platform can run the "gunzip" program. */
|
||||
int canGunzip(void);
|
||||
|
||||
/* 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 *testprogfile;
|
||||
/* Name of exe to use in printf-formatted command strings. */
|
||||
/* On Windows, this includes leading/trailing quotes. */
|
||||
const char *testprog;
|
||||
#include "test_common.h"
|
||||
|
|
|
|||
14
external/bsd/libarchive/dist/cpio/test/test_0.c
vendored
14
external/bsd/libarchive/dist/cpio/test/test_0.c
vendored
|
|
@ -40,15 +40,23 @@ DEFINE_TEST(test_0)
|
|||
struct stat st;
|
||||
|
||||
failure("File %s does not exist?!", testprogfile);
|
||||
if (!assertEqualInt(0, stat(testprogfile, &st)))
|
||||
if (!assertEqualInt(0, stat(testprogfile, &st))) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s does not exist; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
failure("%s is not executable?!", testprogfile);
|
||||
if (!assert((st.st_mode & 0111) != 0))
|
||||
if (!assert((st.st_mode & 0111) != 0)) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s not executable; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to succesfully run the program; this requires that
|
||||
* Try to successfully run the program; this requires that
|
||||
* we know some option that will succeed.
|
||||
*/
|
||||
if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
|
||||
|
|
|
|||
|
|
@ -33,12 +33,15 @@ verify_files(const char *msg)
|
|||
*/
|
||||
|
||||
/* Regular file with 2 links. */
|
||||
failure(msg);
|
||||
assertIsReg("file", 0644);
|
||||
failure(msg);
|
||||
assertFileSize("file", 10);
|
||||
failure(msg);
|
||||
assertFileNLinks("file", 2);
|
||||
|
||||
/* Another name for the same file. */
|
||||
failure(msg);
|
||||
assertIsHardlink("linkfile", "file");
|
||||
|
||||
/* Symlink */
|
||||
|
|
@ -46,8 +49,11 @@ verify_files(const char *msg)
|
|||
assertIsSymlink("symlink", "file");
|
||||
|
||||
/* Another file with 1 link and different permissions. */
|
||||
failure(msg);
|
||||
assertIsReg("file2", 0777);
|
||||
failure(msg);
|
||||
assertFileSize("file2", 10);
|
||||
failure(msg);
|
||||
assertFileNLinks("file2", 1);
|
||||
|
||||
/* dir */
|
||||
|
|
@ -58,7 +64,7 @@ static void
|
|||
basic_cpio(const char *target,
|
||||
const char *pack_options,
|
||||
const char *unpack_options,
|
||||
const char *se)
|
||||
const char *se, const char *se2)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
|
@ -66,7 +72,7 @@ basic_cpio(const char *target,
|
|||
return;
|
||||
|
||||
/* Use the cpio program to create an archive. */
|
||||
r = systemf("%s -o %s < filelist >%s/archive 2>%s/pack.err",
|
||||
r = systemf("%s -R 1000:1000 -o %s < filelist >%s/archive 2>%s/pack.err",
|
||||
testprog, pack_options, target, target);
|
||||
failure("Error invoking %s -o %s", testprog, pack_options);
|
||||
assertEqualInt(r, 0);
|
||||
|
|
@ -87,7 +93,7 @@ basic_cpio(const char *target,
|
|||
|
||||
/* Verify stderr. */
|
||||
failure("Error invoking %s -i %s in dir %s", testprog, unpack_options, target);
|
||||
assertTextFileContents(se, "unpack.err");
|
||||
assertTextFileContents(se2, "unpack.err");
|
||||
|
||||
verify_files(pack_options);
|
||||
|
||||
|
|
@ -125,6 +131,7 @@ DEFINE_TEST(test_basic)
|
|||
{
|
||||
FILE *filelist;
|
||||
const char *msg;
|
||||
char result[1024];
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
|
|
@ -132,28 +139,56 @@ DEFINE_TEST(test_basic)
|
|||
* Create an assortment of files on disk.
|
||||
*/
|
||||
filelist = fopen("filelist", "w");
|
||||
memset(result, 0, sizeof(result));
|
||||
|
||||
/* File with 10 bytes content. */
|
||||
assertMakeFile("file", 0644, "1234567890");
|
||||
fprintf(filelist, "file\n");
|
||||
if (is_LargeInode("file"))
|
||||
strncat(result,
|
||||
"bsdcpio: file: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
|
||||
/* hardlink to above file. */
|
||||
assertMakeHardlink("linkfile", "file");
|
||||
fprintf(filelist, "linkfile\n");
|
||||
if (is_LargeInode("linkfile"))
|
||||
strncat(result,
|
||||
"bsdcpio: linkfile: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
|
||||
/* Symlink to above file. */
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("symlink", "file");
|
||||
fprintf(filelist, "symlink\n");
|
||||
if (is_LargeInode("symlink"))
|
||||
strncat(result,
|
||||
"bsdcpio: symlink: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
}
|
||||
|
||||
/* Another file with different permissions. */
|
||||
assertMakeFile("file2", 0777, "1234567890");
|
||||
fprintf(filelist, "file2\n");
|
||||
if (is_LargeInode("file2"))
|
||||
strncat(result,
|
||||
"bsdcpio: file2: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
|
||||
/* Directory. */
|
||||
assertMakeDir("dir", 0775);
|
||||
fprintf(filelist, "dir\n");
|
||||
if (is_LargeInode("dir"))
|
||||
strncat(result,
|
||||
"bsdcpio: dir: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
|
||||
|
||||
/* All done. */
|
||||
fclose(filelist);
|
||||
|
||||
|
|
@ -161,12 +196,12 @@ DEFINE_TEST(test_basic)
|
|||
|
||||
/* Archive/dearchive with a variety of options. */
|
||||
msg = canSymlink() ? "2 blocks\n" : "1 block\n";
|
||||
basic_cpio("copy", "", "", msg);
|
||||
basic_cpio("copy_odc", "--format=odc", "", msg);
|
||||
basic_cpio("copy_newc", "-H newc", "", "2 blocks\n");
|
||||
basic_cpio("copy_cpio", "-H odc", "", msg);
|
||||
basic_cpio("copy", "", "", msg, msg);
|
||||
basic_cpio("copy_odc", "--format=odc", "", msg, msg);
|
||||
basic_cpio("copy_newc", "-H newc", "", result, "2 blocks\n");
|
||||
basic_cpio("copy_cpio", "-H odc", "", msg, msg);
|
||||
msg = canSymlink() ? "9 blocks\n" : "8 blocks\n";
|
||||
basic_cpio("copy_ustar", "-H ustar", "", msg);
|
||||
basic_cpio("copy_ustar", "-H ustar", "", msg, msg);
|
||||
|
||||
/* Copy in one step using -p */
|
||||
passthrough("passthrough");
|
||||
|
|
|
|||
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.Z.uu
vendored
Normal file
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.Z.uu
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.cpio.Z
|
||||
M'YV0,&X$'`B#!@P8,0XJC)$0A@T;!A'>J+%PHL*%%P_&D`%CAHP;!F7,B*C0
|
||||
M1L:+(LVD85,F!H`Q;]S0*2-S#H@W9D"H9!G#A8*!`@46U)A11L.'$6-8U+CT
|
||||
M8D.G'#V"A"&#!L6+)D\>3+FRC(R7,6?6O)ESIU>?0`EJ7<N6[=.V:V/,@$M%
|
||||
A2I`D3(I("<$7@-^_@`,+'DRXL.'#B!,K7LRXL>/'D!4#
|
||||
`
|
||||
end
|
||||
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.bz2.uu
vendored
Normal file
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.bz2.uu
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.cpio.bz2
|
||||
M0EIH.3%!629365?=.4@``#G_@G*0(`#@`7^`(B04``LEC```!"``E`E(>I,H
|
||||
M::'J&@_4C3:@E$AD#0&@&@%"E;V/1!XIP>#C9T[41`4PQ1A`@S*4F&BD@B0T
|
||||
MBA$$-:\/@BQGNKU1G@%#`G+N0R%$JTHG(XBRB%1$V8F4#F_IWT=S4+ERVL(?
|
||||
40V!'@1L4+AO_B[DBG"A(*^Z<I```
|
||||
`
|
||||
end
|
||||
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.grz.uu
vendored
Normal file
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.grz.uu
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin 644 test_extract.cpio.grz
|
||||
M1U)::7!)20`"!#HI``(``*P-```&`0``"````&X````B%2.02C`PK`#__..F
|
||||
MI;8=99?N!6`:IQJ:XU/T"`W`B"?N/D9-0K6VN/D\.2>0,#J&)3G"\^YE?X_'
|
||||
M_K._F':0[`DL%IQ=<,Z-JH>V$S,?.[`&42C7]J^XQ@9OY!Z$!$^JLQPKZU[:
|
||||
/!M,+.$MY:Y(HS<<]U`&`
|
||||
`
|
||||
end
|
||||
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.gz.uu
vendored
Normal file
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.gz.uu
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.cpio.gz
|
||||
M'XL("`5X<E```W1E<W1?97AT<F%C="YC<&EO`#,P-P!!`Q,#`T,#$#`$4F9F
|
||||
M(*ZYJ0&,-(#)&A@:&1@;F9L8&!F;@/EF!C!@9)R6F9-JR)"<GU>2FE=2K)"?
|
||||
MI@`6T>,R0+?$B$A+3$RQ6F*$88D1PA*"P!"[J#$2)R3(T=/'-4A149%AF`,`
|
||||
(305ZBP`"````
|
||||
`
|
||||
end
|
||||
8
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lrz.uu
vendored
Normal file
8
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lrz.uu
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
begin 664 test_extract.cpio.lrz
|
||||
M3%):20`&``(``````````%T````!`0```@$`$`,`````#@`#`````"\``QH`
|
||||
M&@````!W``$G`&4``#,``2(``0``#0$````U<-`Y!F$`MP$````8#=\$8#<1
|
||||
MR/BL39$D4M>["H7&@4%L/4*_(*VGB*YU>?RX.9]HL86'.A)H@Y;Z\^$?M^8_
|
||||
M!/-;62G.*7*A&A!_ENZ8$7]O-M7_.FTRC%BCGC95:6'9ZH3)QSCR4RX42P!`
|
||||
/-E>/7"L[:OY"/A924S4$
|
||||
`
|
||||
end
|
||||
6
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lz.uu
vendored
Normal file
6
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lz.uu
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
begin 664 test_extract.cpio.lz
|
||||
M3%I)4`$,`!@-WP1@-Q'(^*Q-D212U[L*A<:!06P]0K\@K:>(KG5Y_+@YGVBQ
|
||||
MA8<Z$FB#EOKSX1^WYC\$\UM9*<XI<J$:$'^B>;_>8N3MLP="$0SJ#QKYB?@8
|
||||
G]@'$$7\&W^T*+9?6B=?__M$G@$T%>HL``@```````($`````````
|
||||
`
|
||||
end
|
||||
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lz4.uu
vendored
Normal file
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lz4.uu
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin 644 test_extract.cpio.lz4
|
||||
M!")-&&1PN9$````A,#<"`&`P-#`P,3`!`&`Q,3`P-C8/`#0W-3`&```)``$&
|
||||
M`,$P,3(P,S(W-#`R,S01`!$V!@```@#Q!3(S9FEL93$`8V]N=&5N=',@;V8@
|
||||
M$@`A+@IC``AE`!\R90`4$#2#``YE`!TR90`6,F4`#P(`#@+H``P"`"<Q,Q(`
|
||||
=OU1204E,15(A(2$``0#'4````````````"BVD[$`
|
||||
`
|
||||
end
|
||||
6
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lzma.uu
vendored
Normal file
6
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lzma.uu
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
begin 664 test_extract.cpio.lzma
|
||||
M70``@`#__________P`8#=\$8#<1R/BL39$D4M>["H7&@4%L/4*_(*VGB*YU
|
||||
M>?RX.9]HL86'.A)H@Y;Z\^$?M^8_!/-;62G.*7*A&A!_HGF_WF+D[;.+!OW3
|
||||
:T_2I)V(;K[FNL#'W%T+L;ATS`A*3__[1Z```
|
||||
`
|
||||
end
|
||||
9
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lzo.uu
vendored
Normal file
9
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.lzo.uu
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
begin 664 test_extract.cpio.lzo
|
||||
MB4Q:3P`-"AH*$#`@8`E``04#```!``"!M%!R>-T`````$71E<W1?97AT<F%C
|
||||
M="YC<&EOOH$+9````@````"DIR,^[`HP-S`W,#<P,#0P,#$P8``#,3$P,#8V
|
||||
M>`$#-S4P,#`QE`!@`7`#"C`P,3(P,S(W-#`R,S2!`C:4`'````(R,V9I;&4Q
|
||||
M`&-O;G1E;G1S(&]F((8"+@HOD0$R(`:1`31J$#`P+I$!,B^1`3(HD`%L$3L,
|
||||
M`+P<+HH`,3,I1``(5%)!24Q%4B$A(0`@JP````$`````````````````````
|
||||
*````$0``````````
|
||||
`
|
||||
end
|
||||
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.xz.uu
vendored
Normal file
7
external/bsd/libarchive/dist/cpio/test/test_extract.cpio.xz.uu
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.cpio.xz
|
||||
M_3=Z6%H```3FUK1&`@`A`18```!T+^6CX`'_`&%=`!@-WP1@-Q'(^*Q-D212
|
||||
MU[L*A<:!06P]0K\@K:>(KG5Y_+@YGVBQA8<Z$FB#EOKSX1^WYC\$\UM9*<XI
|
||||
M<J$:$'^B>;_>8N3MLXL&_=/3]*DG8ANON:ZP,?<70NQN'3"CP@``````J9FA
|
||||
=#1$]4L<``7V`!`````?M;4JQQ&?[`@`````$65H`
|
||||
`
|
||||
end
|
||||
42
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_Z.c
vendored
Normal file
42
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_Z.c
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_Z)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.Z";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_bz2.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_bz2.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_bz2)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.bz2";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canBzip2()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems bzip2 is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_grz.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_grz.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_grz)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.grz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGrzip()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems grzip is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_gz.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_gz.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_gz)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.gz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGzip()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems gzip is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lrz.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lrz.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lrz)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lrz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLrzip()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems lrzip is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lz.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lz.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lz)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLzip()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems lzip is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lz4.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lz4.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012,2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lz4)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lzma.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lzma.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lzma)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lzma";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLzma()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems lzma is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lzo.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_lzo.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_lzo)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.lzo";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLzop()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems lzop is not supported on this platform");
|
||||
}
|
||||
}
|
||||
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_xz.c
vendored
Normal file
48
external/bsd/libarchive/dist/cpio/test/test_extract_cpio_xz.c
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_cpio_xz)
|
||||
{
|
||||
const char *reffile = "test_extract.cpio.xz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canXz()) {
|
||||
assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
} else {
|
||||
skipping("It seems xz is not supported on this platform");
|
||||
}
|
||||
}
|
||||
|
|
@ -68,6 +68,16 @@ from_hex(const char *p, size_t l)
|
|||
return (r);
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
static int
|
||||
nlinks(const char *p)
|
||||
{
|
||||
struct stat st;
|
||||
assertEqualInt(0, stat(p, &st));
|
||||
return st.st_nlink;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_format_newc)
|
||||
{
|
||||
FILE *list;
|
||||
|
|
@ -77,6 +87,7 @@ DEFINE_TEST(test_format_newc)
|
|||
time_t t, t2, now;
|
||||
char *p, *e;
|
||||
size_t s, fs, ns;
|
||||
char result[1024];
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
|
|
@ -111,6 +122,29 @@ DEFINE_TEST(test_format_newc)
|
|||
assertMakeDir("dir", 0775);
|
||||
fprintf(list, "dir\n");
|
||||
|
||||
/* Setup result message. */
|
||||
memset(result, 0, sizeof(result));
|
||||
if (is_LargeInode("file1"))
|
||||
strncat(result,
|
||||
"bsdcpio: file1: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
if (canSymlink() && is_LargeInode("symlink"))
|
||||
strncat(result,
|
||||
"bsdcpio: symlink: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
if (is_LargeInode("dir"))
|
||||
strncat(result,
|
||||
"bsdcpio: dir: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
if (is_LargeInode("hardlink"))
|
||||
strncat(result,
|
||||
"bsdcpio: hardlink: large inode number truncated: "
|
||||
"Numerical result out of range\n",
|
||||
sizeof(result) - strlen(result) -1);
|
||||
|
||||
/* Record some facts about what we just created: */
|
||||
now = time(NULL); /* They were all created w/in last two seconds. */
|
||||
|
||||
|
|
@ -123,10 +157,11 @@ DEFINE_TEST(test_format_newc)
|
|||
|
||||
/* Verify that nothing went to stderr. */
|
||||
if (canSymlink()) {
|
||||
assertTextFileContents("2 blocks\n", "newc.err");
|
||||
strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
|
||||
} else {
|
||||
assertTextFileContents("1 block\n", "newc.err");
|
||||
strncat(result, "1 block\n", sizeof(result) - strlen(result) -1);
|
||||
}
|
||||
assertTextFileContents(result, "newc.err");
|
||||
|
||||
/* Verify that stdout is a well-formed cpio file in "newc" format. */
|
||||
p = slurpfile(&s, "newc.out");
|
||||
|
|
@ -216,10 +251,10 @@ DEFINE_TEST(test_format_newc)
|
|||
/* Mode: sgid bit sometimes propagates from parent dirs, ignore it. */
|
||||
assertEqualInt(040775, from_hex(e + 14, 8) & ~02000);
|
||||
#endif
|
||||
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
||||
assertEqualInt(uid, from_hex(e + 22, 8)); /* uid */
|
||||
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
||||
#ifndef NLINKS_INACCURATE_FOR_DIRS
|
||||
assertEqualMem(e + 38, "00000002", 8); /* nlink */
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
assertEqualInt(nlinks("dir"), from_hex(e + 38, 8)); /* nlinks */
|
||||
#endif
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
||||
|
|
|
|||
52
external/bsd/libarchive/dist/cpio/test/test_missing_file.c
vendored
Normal file
52
external/bsd/libarchive/dist/cpio/test/test_missing_file.c
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*-
|
||||
* Copyright (c) 2016 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$");
|
||||
|
||||
DEFINE_TEST(test_missing_file)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
|
||||
assertMakeFile("filelist1", 0644, "file1\nfile2\n");
|
||||
r = systemf("%s -o <filelist1 >stdout1 2>stderr1", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "stderr1");
|
||||
|
||||
assertMakeFile("filelist2", 0644, "file1\nfile2\nfile3\n");
|
||||
r = systemf("%s -o <filelist2 >stdout2 2>stderr2", testprog);
|
||||
assert(r != 0);
|
||||
|
||||
assertMakeFile("filelist3", 0644, "");
|
||||
r = systemf("%s -o <filelist3 >stdout3 2>stderr3", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertTextFileContents("1 block\n", "stderr3");
|
||||
|
||||
assertMakeFile("filelist4", 0644, "file3\n");
|
||||
r = systemf("%s -o <filelist4 >stdout4 2>stderr4", testprog);
|
||||
assert(r != 0);
|
||||
}
|
||||
92
external/bsd/libarchive/dist/cpio/test/test_option_0.c
vendored
Normal file
92
external/bsd/libarchive/dist/cpio/test/test_option_0.c
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2010 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$");
|
||||
|
||||
DEFINE_TEST(test_option_0)
|
||||
{
|
||||
FILE *filelist;
|
||||
int r;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
/* Create a few files. */
|
||||
assertMakeFile("file1", 0644, "1234567890");
|
||||
assertMakeFile("file2", 0644, "1234567890");
|
||||
assertMakeFile("file3", 0644, "1234567890");
|
||||
assertMakeFile("file4", 0644, "1234567890");
|
||||
|
||||
/* Create a file list of filenames with varying end-of-line. */
|
||||
filelist = fopen("filelist", "wb");
|
||||
assertEqualInt(fwrite("file1\x0a", 1, 6, filelist), 6);
|
||||
assertEqualInt(fwrite("file2\x0d", 1, 6, filelist), 6);
|
||||
assertEqualInt(fwrite("file3\x0a\x0d", 1, 7, filelist), 7);
|
||||
assertEqualInt(fwrite("file4", 1, 5, filelist), 5);
|
||||
fclose(filelist);
|
||||
|
||||
/* Create a file list of null-delimited names. */
|
||||
filelist = fopen("filelistNull", "wb");
|
||||
assertEqualInt(fwrite("file1\0", 1, 6, filelist), 6);
|
||||
assertEqualInt(fwrite("file2\0", 1, 6, filelist), 6);
|
||||
assertEqualInt(fwrite("file3\0", 1, 6, filelist), 6);
|
||||
assertEqualInt(fwrite("file4", 1, 5, filelist), 5);
|
||||
fclose(filelist);
|
||||
|
||||
assertUmask(022);
|
||||
|
||||
/* Pack up using the file list with text line endings. */
|
||||
r = systemf("%s -o < filelist > archive 2> stderr1.txt", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract into a new dir. */
|
||||
assertMakeDir("copy", 0775);
|
||||
assertChdir("copy");
|
||||
r = systemf("%s -i < ../archive > stdout3.txt 2> stderr3.txt", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify the files. */
|
||||
assertIsReg("file1", 0644);
|
||||
assertIsReg("file2", 0644);
|
||||
assertIsReg("file3", 0644);
|
||||
assertIsReg("file4", 0644);
|
||||
|
||||
assertChdir("..");
|
||||
|
||||
/* Pack up using the file list with nulls. */
|
||||
r = systemf("%s -o0 < filelistNull > archiveNull 2> stderr2.txt", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract into a new dir. */
|
||||
assertMakeDir("copyNull", 0775);
|
||||
assertChdir("copyNull");
|
||||
r = systemf("%s -i < ../archiveNull > stdout4.txt 2> stderr4.txt", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify the files. */
|
||||
assertIsReg("file1", 0644);
|
||||
assertIsReg("file2", 0644);
|
||||
assertIsReg("file3", 0644);
|
||||
assertIsReg("file4", 0644);
|
||||
}
|
||||
|
|
@ -47,10 +47,13 @@ DEFINE_TEST(test_option_J_upper)
|
|||
}
|
||||
failure("-J option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has an xz signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\3757zXZ", 5);
|
||||
done:
|
||||
free(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,10 +47,13 @@ DEFINE_TEST(test_option_Z_upper)
|
|||
}
|
||||
failure("-Z option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x1f\x9d", 2);
|
||||
done:
|
||||
free(p);
|
||||
}
|
||||
|
|
|
|||
54
external/bsd/libarchive/dist/cpio/test/test_option_b64encode.c
vendored
Normal file
54
external/bsd/libarchive/dist/cpio/test/test_option_b64encode.c
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_b64encode)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with compress compression and uuencode. */
|
||||
assertEqualInt(0,
|
||||
systemf("echo f | %s -o -Z --b64encode >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin-base64 644", 16);
|
||||
|
||||
/* Archive it with uuencode only. */
|
||||
assertEqualInt(0,
|
||||
systemf("echo f | %s -o --b64encode >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin-base64 644", 16);
|
||||
}
|
||||
|
|
@ -51,22 +51,28 @@ from_octal(const char *p, size_t l)
|
|||
return (r);
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
static int
|
||||
nlinks(const char *p)
|
||||
{
|
||||
struct stat st;
|
||||
assertEqualInt(0, stat(p, &st));
|
||||
return st.st_nlink;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_option_c)
|
||||
{
|
||||
FILE *filelist;
|
||||
int r;
|
||||
int uid = -1;
|
||||
int dev, ino, gid;
|
||||
int uid = 1000;
|
||||
int dev, ino, gid = 1000;
|
||||
time_t t, now;
|
||||
char *p, *e;
|
||||
size_t s;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
uid = getuid();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create an assortment of files.
|
||||
* TODO: Extend this to cover more filetypes.
|
||||
|
|
@ -91,7 +97,7 @@ DEFINE_TEST(test_option_c)
|
|||
|
||||
/* Use the cpio program to create an archive. */
|
||||
fclose(filelist);
|
||||
r = systemf("%s -oc <filelist >basic.out 2>basic.err", testprog);
|
||||
r = systemf("%s -R 1000:1000 -oc <filelist >basic.out 2>basic.err", testprog);
|
||||
/* Verify that nothing went to stderr. */
|
||||
assertTextFileContents("1 block\n", "basic.err");
|
||||
|
||||
|
|
@ -176,22 +182,24 @@ DEFINE_TEST(test_option_c)
|
|||
assertEqualInt(dev, from_octal(e + 6, 6));
|
||||
/* Ino must be different from first entry. */
|
||||
assert(is_octal(e + 12, 6)); /* ino */
|
||||
assert(dev != from_octal(e + 12, 6));
|
||||
assert(ino != from_octal(e + 12, 6));
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualMem(e + 18, "040777", 6); /* Mode */
|
||||
#else
|
||||
/* Accept 042775 to accomodate systems where sgid bit propagates. */
|
||||
/* Accept 042775 to accommodate systems where sgid bit propagates. */
|
||||
if (memcmp(e + 18, "042775", 6) != 0)
|
||||
assertEqualMem(e + 18, "040775", 6); /* Mode */
|
||||
#endif
|
||||
assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
|
||||
assertEqualInt(uid, from_octal(e + 24, 6)); /* uid */
|
||||
/* Gid should be same as first entry. */
|
||||
assert(is_octal(e + 30, 6)); /* gid */
|
||||
assertEqualInt(gid, from_octal(e + 30, 6));
|
||||
#ifndef NLINKS_INACCURATE_FOR_DIRS
|
||||
assertEqualMem(e + 36, "000002", 6); /* Nlink */
|
||||
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
assertEqualInt(nlinks("dir"), from_octal(e + 36, 6)); /* Nlink */
|
||||
#endif
|
||||
|
||||
t = from_octal(e + 48, 11); /* mtime */
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
||||
|
|
|
|||
52
external/bsd/libarchive/dist/cpio/test/test_option_grzip.c
vendored
Normal file
52
external/bsd/libarchive/dist/cpio/test/test_option_grzip.c
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_grzip)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
if (!canGrzip()) {
|
||||
skipping("grzip is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with grzip compression. */
|
||||
assertEqualInt(0,
|
||||
systemf("echo f | %s -o --grzip >archive.out 2>archive.err",
|
||||
testprog));
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
/* Check that the archive file has an grzip signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12);
|
||||
}
|
||||
52
external/bsd/libarchive/dist/cpio/test/test_option_lrzip.c
vendored
Normal file
52
external/bsd/libarchive/dist/cpio/test/test_option_lrzip.c
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lrzip)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
if (!canLrzip()) {
|
||||
skipping("lrzip is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lrzip compression. */
|
||||
assertEqualInt(0,
|
||||
systemf("echo f | %s -o --lrzip >archive.out 2>archive.err",
|
||||
testprog));
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
/* Check that the archive file has an lzma signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "LRZI\x00", 5);
|
||||
}
|
||||
81
external/bsd/libarchive/dist/cpio/test/test_option_lz4.c
vendored
Normal file
81
external/bsd/libarchive/dist/cpio/test/test_option_lz4.c
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lz4)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lz4 compression. */
|
||||
r = systemf("echo f | %s -o --lz4 >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without lz4 support");
|
||||
return;
|
||||
}
|
||||
/* POSIX permits different handling of the spawnp
|
||||
* system call used to launch the subsidiary
|
||||
* program: */
|
||||
/* Some systems fail immediately to spawn the new process. */
|
||||
if (strstr(p, "Can't launch") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdcpio uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
/* Some systems successfully spawn the new process,
|
||||
* but fail to exec a program within that process.
|
||||
* This results in failure at the first attempt to
|
||||
* write. */
|
||||
if (strstr(p, "Can't write") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdcpio uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
/* On some systems the error won't be detected until closing
|
||||
time, by a 127 exit error returned by waitpid. */
|
||||
if (strstr(p, "Error closing") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdcpio uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
failure("--lz4 option is broken: %s", p);
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has an lz4 signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x04\x22\x4d\x18", 4);
|
||||
}
|
||||
56
external/bsd/libarchive/dist/cpio/test/test_option_lzop.c
vendored
Normal file
56
external/bsd/libarchive/dist/cpio/test/test_option_lzop.c
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lzop)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lzop compression. */
|
||||
r = systemf("echo f | %s -o --lzop >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (!canLzop()) {
|
||||
skipping("lzop is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
failure("--lzop option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has an lzma signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
|
||||
}
|
||||
43
external/bsd/libarchive/dist/cpio/test/test_option_passphrase.c
vendored
Normal file
43
external/bsd/libarchive/dist/cpio/test/test_option_passphrase.c
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_passphrase)
|
||||
{
|
||||
const char *reffile = "test_option_passphrase.zip";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -i --passphrase pass1 < %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertTextFileContents("1 block\n", "test.err");
|
||||
}
|
||||
12
external/bsd/libarchive/dist/cpio/test/test_option_passphrase.zip.uu
vendored
Normal file
12
external/bsd/libarchive/dist/cpio/test/test_option_passphrase.zip.uu
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
begin 644 test_option_passphrase.zip
|
||||
M4$L#!`H`"0```#B91$7D$C4,'P```!,````%`!P`9FEL93%55`D``VS'+U0"
|
||||
MQR]4=7@+``$$]0$```04````BHPD*"^*I04=XKI\_FQ*TE+#),TD7TTKSP/7
|
||||
MR6R35%!+!PCD$C4,'P```!,```!02P,$"@`)````09E$1;VL<PX?````$P``
|
||||
M``4`'`!F:6QE,E54"0`#><<O5`+'+U1U>`L``03U`0``!!0```!D#6Z\@CI8
|
||||
MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL<PX?````$P```%!+`0(>
|
||||
M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE
|
||||
M,554!0`#;,<O5'5X"P`!!/4!```$%````%!+`0(>`PH`"0```$&91$6]K',.
|
||||
M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><<O5'5X"P`!
|
||||
@!/4!```$%````%!+!08``````@`"`)8```#<````````
|
||||
`
|
||||
end
|
||||
|
|
@ -25,11 +25,17 @@
|
|||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_option_t)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
time_t mtime;
|
||||
char date[32];
|
||||
char date2[32];
|
||||
|
||||
/* List reference archive, make sure the TOC is correct. */
|
||||
extract_reference_file("test_option_t.cpio");
|
||||
|
|
@ -75,17 +81,20 @@ DEFINE_TEST(test_option_t)
|
|||
/* Since -n uses numeric UID/GID, this part should be the
|
||||
* same on every system. */
|
||||
assertEqualMem(p, "-rw-r--r-- 1 1000 1000 0 ",42);
|
||||
/* Date varies depending on local timezone. */
|
||||
if (memcmp(p + 42, "Dec 31 1969", 12) == 0) {
|
||||
/* East of Greenwich we get Dec 31, 1969. */
|
||||
} else {
|
||||
/* West of Greenwich get Jan 1, 1970 */
|
||||
assertEqualMem(p + 42, "Jan ", 4);
|
||||
/* Some systems format "Jan 01", some "Jan 1" */
|
||||
assert(p[46] == ' ' || p[46] == '0');
|
||||
assertEqualMem(p + 47, "1 1970 ", 8);
|
||||
}
|
||||
assertEqualMem(p + 54, " file", 5);
|
||||
|
||||
/* Date varies depending on local timezone and locale. */
|
||||
mtime = 1;
|
||||
#ifdef HAVE_LOCALE_H
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
strftime(date2, sizeof(date), "%b %d %Y", localtime(&mtime));
|
||||
_snprintf(date, sizeof(date)-1, "%12s file", date2);
|
||||
#else
|
||||
strftime(date2, sizeof(date), "%b %e %Y", localtime(&mtime));
|
||||
snprintf(date, sizeof(date)-1, "%12s file", date2);
|
||||
#endif
|
||||
assertEqualMem(p + 42, date, strlen(date));
|
||||
free(p);
|
||||
|
||||
/* But "-n" without "-t" is an error. */
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ DEFINE_TEST(test_option_u)
|
|||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Copy the file to the "copy" dir. */
|
||||
r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
|
||||
r = systemf("echo f| %s -pd copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
|
|
@ -49,6 +49,7 @@ DEFINE_TEST(test_option_u)
|
|||
p = slurpfile(&s, "copy/f");
|
||||
assertEqualInt(s, 1);
|
||||
assertEqualMem(p, "a", 1);
|
||||
free(p);
|
||||
|
||||
/* Recreate the file with a single "b" */
|
||||
assertMakeFile("f", 0644, "b");
|
||||
|
|
@ -60,7 +61,7 @@ DEFINE_TEST(test_option_u)
|
|||
assertEqualInt(0, utime("f", ×));
|
||||
|
||||
/* Copy the file to the "copy" dir. */
|
||||
r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
|
||||
r = systemf("echo f| %s -pd copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
|
|
@ -68,9 +69,10 @@ DEFINE_TEST(test_option_u)
|
|||
p = slurpfile(&s, "copy/f");
|
||||
assertEqualInt(s, 1);
|
||||
assertEqualMem(p, "a", 1);
|
||||
free(p);
|
||||
|
||||
/* Copy the file to the "copy" dir with -u (force) */
|
||||
r = systemf("echo f | %s -pud copy >copy.out 2>copy.err",
|
||||
r = systemf("echo f| %s -pud copy >copy.out 2>copy.err",
|
||||
testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
|
|
@ -78,4 +80,5 @@ DEFINE_TEST(test_option_u)
|
|||
p = slurpfile(&s, "copy/f");
|
||||
assertEqualInt(s, 1);
|
||||
assertEqualMem(p, "b", 1);
|
||||
free(p);
|
||||
}
|
||||
|
|
|
|||
54
external/bsd/libarchive/dist/cpio/test/test_option_uuencode.c
vendored
Normal file
54
external/bsd/libarchive/dist/cpio/test/test_option_uuencode.c
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_uuencode)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with compress compression and uuencode. */
|
||||
assertEqualInt(0,
|
||||
systemf("echo f | %s -o -Z --uuencode >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin 644", 9);
|
||||
|
||||
/* Archive it with uuencode only. */
|
||||
assertEqualInt(0,
|
||||
systemf("echo f | %s -o --uuencode >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin 644", 9);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2003-2017 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -23,87 +23,8 @@
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Test that --version option works and generates reasonable output.
|
||||
*/
|
||||
|
||||
static void
|
||||
verify(const char *p, size_t s)
|
||||
{
|
||||
const char *q = p;
|
||||
|
||||
/* Version message should start with name of program, then space. */
|
||||
failure("version message too short:", p);
|
||||
if (!assert(s > 6))
|
||||
return;
|
||||
failure("Version message should begin with 'bsdcpio': %s", p);
|
||||
if (!assertEqualMem(q, "bsdcpio ", 8))
|
||||
/* If we're not testing bsdcpio, don't keep going. */
|
||||
return;
|
||||
q += 8; s -= 8;
|
||||
/* Version number is a series of digits and periods. */
|
||||
while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
/* Version number terminated by space. */
|
||||
failure("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("Version: %s", p);
|
||||
assert(*q == ' ');
|
||||
++q; --s;
|
||||
/* Separator. */
|
||||
failure("Version: %s", p);
|
||||
assertEqualMem(q, "-- ", 3);
|
||||
q += 3; s -= 3;
|
||||
/* libarchive name and version number */
|
||||
assert(s > 11);
|
||||
failure("Version: %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: \r, \r\n, or \n */
|
||||
assert(s >= 1);
|
||||
failure("Version: %s", p);
|
||||
if (*q == '\x0d') {
|
||||
if (q[1] != '\0')
|
||||
assertEqualMem(q, "\x0d\x0a", 2);
|
||||
} else
|
||||
assertEqualMem(q, "\x0a", 1);
|
||||
}
|
||||
|
||||
|
||||
DEFINE_TEST(test_option_version)
|
||||
{
|
||||
int r;
|
||||
char *p;
|
||||
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 stderr. */
|
||||
assertEmptyFile("version.stderr");
|
||||
/* Verify format of version message. */
|
||||
p = slurpfile(&s, "version.stdout");
|
||||
verify(p, s);
|
||||
free(p);
|
||||
assertVersion(testprog, "bsdcpio");
|
||||
}
|
||||
|
|
|
|||
57
external/bsd/libarchive/dist/cpio/test/test_option_xz.c
vendored
Normal file
57
external/bsd/libarchive/dist/cpio/test/test_option_xz.c
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_xz)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with xz compression. */
|
||||
r = systemf("echo f | %s -o --xz >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without xz support");
|
||||
return;
|
||||
}
|
||||
failure("--xz option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
}
|
||||
/* Check that the archive file has an xz signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6);
|
||||
}
|
||||
|
|
@ -40,18 +40,20 @@ DEFINE_TEST(test_option_y)
|
|||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without bzip2 support");
|
||||
if (!canBzip2()) {
|
||||
skipping("bzip2 is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
failure("-y option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
assertTextFileContents("1 block\n", "archive.err");
|
||||
/* Check that the archive file has a bzip2 signature. */
|
||||
free(p);
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "BZh9", 4);
|
||||
done:
|
||||
free(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,8 @@ DEFINE_TEST(test_option_z)
|
|||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "compression not available") != NULL) {
|
||||
skipping("This version of bsdcpio was compiled "
|
||||
"without gzip support");
|
||||
if (!canGzip()) {
|
||||
skipping("gzip is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
failure("-z option is broken");
|
||||
|
|
|
|||
|
|
@ -30,26 +30,25 @@ __FBSDID("$FreeBSD$");
|
|||
|
||||
#if !defined(_WIN32)
|
||||
#define ROOT "root"
|
||||
static int root_uids[] = { 0 };
|
||||
/* Solaris 9 root has gid 1 (other) */
|
||||
static int root_gids[] = { 0, 1 };
|
||||
static const int root_uids[] = { 0 };
|
||||
static const int root_gids[] = { 0, 1 };
|
||||
#elif defined(__CYGWIN__)
|
||||
/* On cygwin, the Administrator user most likely exists (unless
|
||||
* it has been renamed or is in a non-English localization), but
|
||||
* its primary group membership depends on how the user set up
|
||||
* their /etc/passwd. Likely values are 513 (None), 545 (Users),
|
||||
* or 544 (Administrators). Just check for one of those...
|
||||
* TODO: Handle non-English localizations...e.g. French 'Administrateur'
|
||||
* TODO: Handle non-English localizations... e.g. French 'Administrateur'
|
||||
* Use CreateWellKnownSID() and LookupAccountName()?
|
||||
*/
|
||||
#define ROOT "Administrator"
|
||||
static int root_uids[] = { 500 };
|
||||
static int root_gids[] = { 513, 545, 544 };
|
||||
static const int root_uids[] = { 500 };
|
||||
static const int root_gids[] = { 513, 545, 544 };
|
||||
#endif
|
||||
|
||||
#if defined(ROOT)
|
||||
static int
|
||||
int_in_list(int i, int *l, size_t n)
|
||||
int_in_list(int i, const int *l, size_t n)
|
||||
{
|
||||
while (n-- > 0)
|
||||
if (*l++ == i)
|
||||
|
|
|
|||
|
|
@ -1,243 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "pathmatch.h"
|
||||
|
||||
/*
|
||||
* Verify that the pattern matcher implements the wildcard logic specified
|
||||
* in SUSv2 for the cpio command. This is essentially the
|
||||
* shell glob syntax:
|
||||
* * - matches any sequence of chars, including '/'
|
||||
* ? - matches any single char, including '/'
|
||||
* [...] - matches any of a set of chars, '-' specifies a range,
|
||||
* initial '!' is undefined
|
||||
*
|
||||
* The specification in SUSv2 is a bit incomplete, I assume the following:
|
||||
* Trailing '-' in [...] is not special.
|
||||
*
|
||||
* TODO: Figure out if there's a good way to extend this to handle
|
||||
* Windows paths that use '\' as a path separator. <sigh>
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_pathmatch)
|
||||
{
|
||||
assertEqualInt(1, lafe_pathmatch("a/b/c", "a/b/c", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/", "a/b/c", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b", "a/b/c", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b/", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b", 0));
|
||||
|
||||
/* Empty pattern only matches empty string. */
|
||||
assertEqualInt(1, lafe_pathmatch("","", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("","a", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*","", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*","a", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*","abcd", 0));
|
||||
/* SUSv2: * matches / */
|
||||
assertEqualInt(1, lafe_pathmatch("*","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd*efgh/ijkl","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd***efgh/ijkl","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd***/efgh/ijkl","abcd/efgh/ijkl", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("?", "", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("?", "\0", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("?", "a", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("?", "ab", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("?", ".", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("?", "?", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a", "a", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a", "ab", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a", "ab", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a?c", "abc", 0));
|
||||
/* SUSv2: ? matches / */
|
||||
assertEqualInt(1, lafe_pathmatch("a?c", "a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a?*c*", "a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*a*", "a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*a*", "/a/c", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("*a*", "defaaaaaaa", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a*", "defghi", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("*a*", "defghi", 0));
|
||||
|
||||
/* Character classes */
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def", "abc[def", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[def]", "abc[def", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[def", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[def]", "abcf", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[def]", "abcg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abc*", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d*f]", "abcdefghi", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d*", "abcdefghi", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d*", "abc[defghi", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcf", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-f]", "abcg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abca", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcf", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abch", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abci", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcj", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abck", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcl", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abc-", 0));
|
||||
|
||||
/* [] matches nothing, [!] is the same as ? */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcdefg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcqefg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcefg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcdefg", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcqefg", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!]efg", "abcefg", 0));
|
||||
|
||||
/* I assume: Trailing '-' is non-special. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d-fh-]", "abcl", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abch", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0));
|
||||
|
||||
/* ']' can be backslash-quoted within a character class. */
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\]]", "abc]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abc]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abc]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d]e]", "abcde]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\]e]", "abc]", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d\\]e]", "abcd]e", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d]e]", "abc]", 0));
|
||||
|
||||
/* backslash-quoted chars can appear as either end of a range. */
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\d-f]gh", "abcegh", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abcggh", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abc\\gh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d-\\f]gh", "abcegh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0));
|
||||
/* backslash-quoted '-' isn't special. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[d\\-f]gh", "abcegh", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[d\\-f]gh", "abc-gh", 0));
|
||||
|
||||
/* Leading '!' negates a character class. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!d]", "abcd", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!d]", "abce", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!d]", "abcc", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!d-z]", "abcq", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!d-gi-z]", "abch", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc[!fgijkl]", "abch", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc[!fghijkl]", "abch", 0));
|
||||
|
||||
/* Backslash quotes next character. */
|
||||
assertEqualInt(0, lafe_pathmatch("abc\\[def]", "abc\\d", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc\\[def]", "abc[def]", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc[def]", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc\\[def]", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc\\\\[def]", "abc\\d", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abcd\\", "abcd\\", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abcd\\", "abcd\\[", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abcd\\", "abcde", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("abcd\\[", "abcd\\", 0));
|
||||
|
||||
/*
|
||||
* Because '.' and '/' have special meanings, we can
|
||||
* identify many equivalent paths even if they're expressed
|
||||
* differently. (But quoting a character with '\\' suppresses
|
||||
* special meanings!)
|
||||
*/
|
||||
assertEqualInt(0, lafe_pathmatch("a/b/", "a/bc", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("a/./b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a\\/./b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/\\./b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a/.\\/b", "a/b", 0));
|
||||
assertEqualInt(0, lafe_pathmatch("a\\/\\.\\/b", "a/b", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def/", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc/def", "./././abc/./def", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("abc/def/././//", "./././abc/./def/", 0));
|
||||
assertEqualInt(1, lafe_pathmatch(".////abc/.//def", "./././abc/./def", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("./abc?def/", "abc/def/", 0));
|
||||
failure("\"?./\" is not the same as \"/./\"");
|
||||
assertEqualInt(0, lafe_pathmatch("./abc?./def/", "abc/def/", 0));
|
||||
failure("Trailing '/' should match no trailing '/'");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def", 0));
|
||||
failure("Trailing '/./' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/./", "abc/def", 0));
|
||||
failure("Trailing '/.' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def/.", "abc/def", 0));
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/", 0));
|
||||
failure("Trailing '/./' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/./", 0));
|
||||
failure("Trailing '/.' is still the same directory.");
|
||||
assertEqualInt(1, lafe_pathmatch("./abc*/./def", "abc/def/.", 0));
|
||||
|
||||
/* Matches not anchored at beginning. */
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("^bcd", "abcd", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("b/c/d", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("^b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
|
||||
|
||||
/* Matches not anchored at end. */
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd/", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("abcd", "abcd/.", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("abc", "abcd", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("a/b/c$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c$", "a/b/c", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c$", "a/b/c/", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c/", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("a/b/c/$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c/$", "a/b/c/", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(1,
|
||||
lafe_pathmatch("a/b/c/$", "a/b/c", PATHMATCH_NO_ANCHOR_END));
|
||||
assertEqualInt(0,
|
||||
lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
|
||||
}
|
||||
987
external/bsd/libarchive/dist/libarchive/archive.h
vendored
987
external/bsd/libarchive/dist/libarchive/archive.h
vendored
File diff suppressed because it is too large
Load Diff
2069
external/bsd/libarchive/dist/libarchive/archive_acl.c
vendored
Normal file
2069
external/bsd/libarchive/dist/libarchive/archive_acl.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
83
external/bsd/libarchive/dist/libarchive/archive_acl_private.h
vendored
Normal file
83
external/bsd/libarchive/dist/libarchive/archive_acl_private.h
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2010 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$
|
||||
*/
|
||||
|
||||
#ifndef __LIBARCHIVE_BUILD
|
||||
#error This header is only to be used internally to libarchive.
|
||||
#endif
|
||||
|
||||
#ifndef ARCHIVE_ACL_PRIVATE_H_INCLUDED
|
||||
#define ARCHIVE_ACL_PRIVATE_H_INCLUDED
|
||||
|
||||
#include "archive_string.h"
|
||||
|
||||
struct archive_acl_entry {
|
||||
struct archive_acl_entry *next;
|
||||
int type; /* E.g., access or default */
|
||||
int tag; /* E.g., user/group/other/mask */
|
||||
int permset; /* r/w/x bits */
|
||||
int id; /* uid/gid for user/group */
|
||||
struct archive_mstring name; /* uname/gname */
|
||||
};
|
||||
|
||||
struct archive_acl {
|
||||
mode_t mode;
|
||||
struct archive_acl_entry *acl_head;
|
||||
struct archive_acl_entry *acl_p;
|
||||
int acl_state; /* See acl_next for details. */
|
||||
wchar_t *acl_text_w;
|
||||
char *acl_text;
|
||||
int acl_types;
|
||||
};
|
||||
|
||||
void archive_acl_clear(struct archive_acl *);
|
||||
void archive_acl_copy(struct archive_acl *, struct archive_acl *);
|
||||
int archive_acl_count(struct archive_acl *, int);
|
||||
int archive_acl_types(struct archive_acl *);
|
||||
int archive_acl_reset(struct archive_acl *, int);
|
||||
int archive_acl_next(struct archive *, struct archive_acl *, int,
|
||||
int *, int *, int *, int *, const char **);
|
||||
|
||||
int archive_acl_add_entry(struct archive_acl *, int, int, int, int, const char *);
|
||||
int archive_acl_add_entry_w_len(struct archive_acl *,
|
||||
int, int, int, int, const wchar_t *, size_t);
|
||||
int archive_acl_add_entry_len(struct archive_acl *,
|
||||
int, int, int, int, const char *, size_t);
|
||||
|
||||
wchar_t *archive_acl_to_text_w(struct archive_acl *, ssize_t *, int,
|
||||
struct archive *);
|
||||
char *archive_acl_to_text_l(struct archive_acl *, ssize_t *, int,
|
||||
struct archive_string_conv *);
|
||||
|
||||
/*
|
||||
* ACL text parser.
|
||||
*/
|
||||
int archive_acl_from_text_w(struct archive_acl *, const wchar_t * /* wtext */,
|
||||
int /* type */);
|
||||
int archive_acl_from_text_l(struct archive_acl *, const char * /* text */,
|
||||
int /* type */, struct archive_string_conv *);
|
||||
|
||||
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2003-2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -62,7 +62,7 @@ errmsg(const char *m)
|
|||
}
|
||||
}
|
||||
|
||||
__dead static void
|
||||
static __LA_DEAD void
|
||||
diediedie(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
|
||||
|
|
@ -86,49 +86,90 @@ state_name(unsigned s)
|
|||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
archive_handle_type_name(unsigned m)
|
||||
{
|
||||
switch (m) {
|
||||
case ARCHIVE_WRITE_MAGIC: return ("archive_write");
|
||||
case ARCHIVE_READ_MAGIC: return ("archive_read");
|
||||
case ARCHIVE_WRITE_DISK_MAGIC: return ("archive_write_disk");
|
||||
case ARCHIVE_READ_DISK_MAGIC: return ("archive_read_disk");
|
||||
case ARCHIVE_MATCH_MAGIC: return ("archive_match");
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_all_states(unsigned int states)
|
||||
|
||||
static char *
|
||||
write_all_states(char *buff, unsigned int states)
|
||||
{
|
||||
unsigned int lowbit;
|
||||
|
||||
buff[0] = '\0';
|
||||
|
||||
/* A trick for computing the lowest set bit. */
|
||||
while ((lowbit = states & (1 + ~states)) != 0) {
|
||||
states &= ~lowbit; /* Clear the low bit. */
|
||||
errmsg(state_name(lowbit));
|
||||
strcat(buff, state_name(lowbit));
|
||||
if (states != 0)
|
||||
errmsg("/");
|
||||
strcat(buff, "/");
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check magic value and current state; bail if it isn't valid.
|
||||
* Check magic value and current state.
|
||||
* Magic value mismatches are fatal and result in calls to abort().
|
||||
* State mismatches return ARCHIVE_FATAL.
|
||||
* Otherwise, returns ARCHIVE_OK.
|
||||
*
|
||||
* This is designed to catch serious programming errors that violate
|
||||
* the libarchive API.
|
||||
*/
|
||||
void
|
||||
int
|
||||
__archive_check_magic(struct archive *a, unsigned int magic,
|
||||
unsigned int state, const char *function)
|
||||
{
|
||||
if (a->magic != magic) {
|
||||
errmsg("INTERNAL ERROR: Function ");
|
||||
char states1[64];
|
||||
char states2[64];
|
||||
const char *handle_type;
|
||||
|
||||
/*
|
||||
* If this isn't some form of archive handle,
|
||||
* then the library user has screwed up so bad that
|
||||
* we don't even have a reliable way to report an error.
|
||||
*/
|
||||
handle_type = archive_handle_type_name(a->magic);
|
||||
|
||||
if (!handle_type) {
|
||||
errmsg("PROGRAMMER ERROR: Function ");
|
||||
errmsg(function);
|
||||
errmsg(" invoked with invalid struct archive structure.\n");
|
||||
errmsg(" invoked with invalid archive handle.\n");
|
||||
diediedie();
|
||||
}
|
||||
|
||||
if (state == ARCHIVE_STATE_ANY)
|
||||
return;
|
||||
if (a->magic != magic) {
|
||||
archive_set_error(a, -1,
|
||||
"PROGRAMMER ERROR: Function '%s' invoked"
|
||||
" on '%s' archive object, which is not supported.",
|
||||
function,
|
||||
handle_type);
|
||||
a->state = ARCHIVE_STATE_FATAL;
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
if ((a->state & state) == 0) {
|
||||
errmsg("INTERNAL ERROR: Function '");
|
||||
errmsg(function);
|
||||
errmsg("' invoked with archive structure in state '");
|
||||
write_all_states(a->state);
|
||||
errmsg("', should be in state '");
|
||||
write_all_states(state);
|
||||
errmsg("'\n");
|
||||
diediedie();
|
||||
/* If we're already FATAL, don't overwrite the error. */
|
||||
if (a->state != ARCHIVE_STATE_FATAL)
|
||||
archive_set_error(a, -1,
|
||||
"INTERNAL ERROR: Function '%s' invoked with"
|
||||
" archive structure in state '%s',"
|
||||
" should be in state '%s'",
|
||||
function,
|
||||
write_all_states(states1, a->state),
|
||||
write_all_states(states2, state));
|
||||
a->state = ARCHIVE_STATE_FATAL;
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
|
|
|||
227
external/bsd/libarchive/dist/libarchive/archive_cmdline.c
vendored
Normal file
227
external/bsd/libarchive/dist/libarchive/archive_cmdline.c
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "archive_platform.h"
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "archive.h"
|
||||
#include "archive_cmdline_private.h"
|
||||
#include "archive_string.h"
|
||||
|
||||
static int cmdline_set_path(struct archive_cmdline *, const char *);
|
||||
static int cmdline_add_arg(struct archive_cmdline *, const char *);
|
||||
|
||||
static ssize_t
|
||||
extract_quotation(struct archive_string *as, const char *p)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
for (s = p + 1; *s;) {
|
||||
if (*s == '\\') {
|
||||
if (s[1] != '\0') {
|
||||
archive_strappend_char(as, s[1]);
|
||||
s += 2;
|
||||
} else
|
||||
s++;
|
||||
} else if (*s == '"')
|
||||
break;
|
||||
else {
|
||||
archive_strappend_char(as, s[0]);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
if (*s != '"')
|
||||
return (ARCHIVE_FAILED);/* Invalid sequence. */
|
||||
return ((ssize_t)(s + 1 - p));
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
get_argument(struct archive_string *as, const char *p)
|
||||
{
|
||||
const char *s = p;
|
||||
|
||||
archive_string_empty(as);
|
||||
|
||||
/* Skip beginning space characters. */
|
||||
while (*s != '\0' && *s == ' ')
|
||||
s++;
|
||||
/* Copy non-space characters. */
|
||||
while (*s != '\0' && *s != ' ') {
|
||||
if (*s == '\\') {
|
||||
if (s[1] != '\0') {
|
||||
archive_strappend_char(as, s[1]);
|
||||
s += 2;
|
||||
} else {
|
||||
s++;/* Ignore this character.*/
|
||||
break;
|
||||
}
|
||||
} else if (*s == '"') {
|
||||
ssize_t q = extract_quotation(as, s);
|
||||
if (q < 0)
|
||||
return (ARCHIVE_FAILED);/* Invalid sequence. */
|
||||
s += q;
|
||||
} else {
|
||||
archive_strappend_char(as, s[0]);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
return ((ssize_t)(s - p));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up command line arguments.
|
||||
* Returns ARChIVE_OK if everything okey.
|
||||
* Returns ARChIVE_FAILED if there is a lack of the `"' terminator or an
|
||||
* empty command line.
|
||||
* Returns ARChIVE_FATAL if no memory.
|
||||
*/
|
||||
int
|
||||
__archive_cmdline_parse(struct archive_cmdline *data, const char *cmd)
|
||||
{
|
||||
struct archive_string as;
|
||||
const char *p;
|
||||
ssize_t al;
|
||||
int r;
|
||||
|
||||
archive_string_init(&as);
|
||||
|
||||
/* Get first argument as a command path. */
|
||||
al = get_argument(&as, cmd);
|
||||
if (al < 0) {
|
||||
r = ARCHIVE_FAILED;/* Invalid sequence. */
|
||||
goto exit_function;
|
||||
}
|
||||
if (archive_strlen(&as) == 0) {
|
||||
r = ARCHIVE_FAILED;/* An empty command path. */
|
||||
goto exit_function;
|
||||
}
|
||||
r = cmdline_set_path(data, as.s);
|
||||
if (r != ARCHIVE_OK)
|
||||
goto exit_function;
|
||||
p = strrchr(as.s, '/');
|
||||
if (p == NULL)
|
||||
p = as.s;
|
||||
else
|
||||
p++;
|
||||
r = cmdline_add_arg(data, p);
|
||||
if (r != ARCHIVE_OK)
|
||||
goto exit_function;
|
||||
cmd += al;
|
||||
|
||||
for (;;) {
|
||||
al = get_argument(&as, cmd);
|
||||
if (al < 0) {
|
||||
r = ARCHIVE_FAILED;/* Invalid sequence. */
|
||||
goto exit_function;
|
||||
}
|
||||
if (al == 0)
|
||||
break;
|
||||
cmd += al;
|
||||
if (archive_strlen(&as) == 0 && *cmd == '\0')
|
||||
break;
|
||||
r = cmdline_add_arg(data, as.s);
|
||||
if (r != ARCHIVE_OK)
|
||||
goto exit_function;
|
||||
}
|
||||
r = ARCHIVE_OK;
|
||||
exit_function:
|
||||
archive_string_free(&as);
|
||||
return (r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the program path.
|
||||
*/
|
||||
static int
|
||||
cmdline_set_path(struct archive_cmdline *data, const char *path)
|
||||
{
|
||||
char *newptr;
|
||||
|
||||
newptr = realloc(data->path, strlen(path) + 1);
|
||||
if (newptr == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
data->path = newptr;
|
||||
strcpy(data->path, path);
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a argument for the program.
|
||||
*/
|
||||
static int
|
||||
cmdline_add_arg(struct archive_cmdline *data, const char *arg)
|
||||
{
|
||||
char **newargv;
|
||||
|
||||
if (data->path == NULL)
|
||||
return (ARCHIVE_FAILED);
|
||||
|
||||
newargv = realloc(data->argv, (data->argc + 2) * sizeof(char *));
|
||||
if (newargv == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
data->argv = newargv;
|
||||
data->argv[data->argc] = strdup(arg);
|
||||
if (data->argv[data->argc] == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
/* Set the terminator of argv. */
|
||||
data->argv[++data->argc] = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
struct archive_cmdline *
|
||||
__archive_cmdline_allocate(void)
|
||||
{
|
||||
return (struct archive_cmdline *)
|
||||
calloc(1, sizeof(struct archive_cmdline));
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the resources.
|
||||
*/
|
||||
int
|
||||
__archive_cmdline_free(struct archive_cmdline *data)
|
||||
{
|
||||
|
||||
if (data) {
|
||||
free(data->path);
|
||||
if (data->argv != NULL) {
|
||||
int i;
|
||||
for (i = 0; data->argv[i] != NULL; i++)
|
||||
free(data->argv[i]);
|
||||
free(data->argv);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
47
external/bsd/libarchive/dist/libarchive/archive_cmdline_private.h
vendored
Normal file
47
external/bsd/libarchive/dist/libarchive/archive_cmdline_private.h
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef __LIBARCHIVE_BUILD
|
||||
#ifndef __LIBARCHIVE_TEST
|
||||
#error This header is only to be used internally to libarchive.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ARCHIVE_CMDLINE_PRIVATE_H
|
||||
#define ARCHIVE_CMDLINE_PRIVATE_H
|
||||
|
||||
struct archive_cmdline {
|
||||
char *path;
|
||||
char **argv;
|
||||
int argc;
|
||||
};
|
||||
|
||||
struct archive_cmdline *__archive_cmdline_allocate(void);
|
||||
int __archive_cmdline_parse(struct archive_cmdline *, const char *);
|
||||
int __archive_cmdline_free(struct archive_cmdline *);
|
||||
|
||||
#endif
|
||||
|
|
@ -60,6 +60,18 @@ crc32(unsigned long crc, const void *_p, size_t len)
|
|||
}
|
||||
|
||||
crc = crc ^ 0xffffffffUL;
|
||||
/* A use of this loop is about 20% - 30% faster than
|
||||
* no use version in any optimization option of gcc. */
|
||||
for (;len >= 8; len -= 8) {
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
}
|
||||
while (len--)
|
||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
||||
return (crc ^ 0xffffffffUL);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user