aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2016-05-11 10:19:44 +0000
committerMartin Matuska <mm@FreeBSD.org>2016-05-11 10:19:44 +0000
commit4e579f6c9425c995106fbf72667f4ec7e5d5db85 (patch)
treed298bb9fa3cf4f58e328e696a77fadf758a534eb
parent8c8f03ca5b7f1f0d07c23e7c354a45b7c95335f0 (diff)
downloadsrc-4e579f6c9425c995106fbf72667f4ec7e5d5db85.tar.gz
src-4e579f6c9425c995106fbf72667f4ec7e5d5db85.zip
Update vendor/libarchive/dist to git commit 61c56e5 (post 3.2.0)vendor/libarchive/3.2.0
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=299425 svn path=/vendor/libarchive/3.2.0/; revision=299528; tag=vendor/libarchive/3.2.0
-rw-r--r--.gitignore23
-rw-r--r--.travis.yml20
-rw-r--r--CMakeLists.txt274
-rw-r--r--CONTRIBUTING.md98
-rw-r--r--COPYING5
-rw-r--r--INSTALL2
-rw-r--r--Makefile.am1711
-rw-r--r--NEWS32
-rw-r--r--README24
-rw-r--r--build/autoconf/ax_append_compile_flags.m467
-rw-r--r--build/autoconf/ax_append_flag.m471
-rw-r--r--build/autoconf/ax_check_compile_flag.m474
-rw-r--r--build/autoconf/ax_require_defined.m437
-rw-r--r--build/autoconf/iconv.m463
-rwxr-xr-xbuild/autogen.sh2
-rwxr-xr-xbuild/clean.sh2
-rw-r--r--build/cmake/CreatePkgConfigFile.cmake33
-rw-r--r--build/cmake/LibarchiveCheckCSourceCompiles.cmake106
-rw-r--r--build/cmake/LibarchiveCheckCSourceRuns.cmake102
-rw-r--r--build/cmake/LibarchiveCodeCoverage.cmake68
-rw-r--r--build/cmake/config.h.in83
-rw-r--r--build/version2
-rw-r--r--cat/CMakeLists.txt37
-rw-r--r--cat/bsdcat.162
-rw-r--r--cat/bsdcat.c146
-rw-r--r--cat/bsdcat.h56
-rw-r--r--cat/bsdcat_platform.h75
-rw-r--r--cat/cmdline.c283
-rw-r--r--cat/test/CMakeLists.txt65
-rw-r--r--cat/test/main.c2969
-rw-r--r--cat/test/test.h344
-rw-r--r--cat/test/test_0.c67
-rw-r--r--cat/test/test_empty.gz.uu4
-rw-r--r--cat/test/test_empty.lz4.uu4
-rw-r--r--cat/test/test_empty.xz.uu4
-rw-r--r--cat/test/test_empty_gz.c41
-rw-r--r--cat/test/test_empty_lz4.c41
-rw-r--r--cat/test/test_empty_xz.c41
-rw-r--r--cat/test/test_error.c36
-rw-r--r--cat/test/test_error_mixed.c43
-rw-r--r--cat/test/test_expand.Z.uu3
-rw-r--r--cat/test/test_expand.bz2.uu5
-rw-r--r--cat/test/test_expand.gz.uu4
-rw-r--r--cat/test/test_expand.lz4.uu5
-rw-r--r--cat/test/test_expand.plain.uu3
-rw-r--r--cat/test/test_expand.xz.uu4
-rw-r--r--cat/test/test_expand_Z.c36
-rw-r--r--cat/test/test_expand_bz2.c42
-rw-r--r--cat/test/test_expand_gz.c42
-rw-r--r--cat/test/test_expand_lz4.c42
-rw-r--r--cat/test/test_expand_mixed.c41
-rw-r--r--cat/test/test_expand_plain.c36
-rw-r--r--cat/test/test_expand_xz.c42
-rw-r--r--cat/test/test_help.c75
-rw-r--r--cat/test/test_version.c97
-rw-r--r--configure.ac139
-rw-r--r--contrib/android/Android.mk306
-rw-r--r--contrib/android/config/android.h184
-rw-r--r--contrib/android/config/linux_host.h189
-rw-r--r--contrib/android/config/windows_host.h1062
-rw-r--r--contrib/android/include/Bcrypt.h1
-rw-r--r--contrib/android/include/Windows.h1
-rw-r--r--contrib/android/include/android_lf.h47
-rw-r--r--contrib/libarchive.spec90
-rw-r--r--contrib/untar.c10
-rw-r--r--cpio/CMakeLists.txt5
-rw-r--r--cpio/bsdcpio.125
-rw-r--r--cpio/cmdline.c2
-rw-r--r--cpio/cpio.c90
-rw-r--r--cpio/cpio.h4
-rw-r--r--cpio/cpio_platform.h8
-rw-r--r--cpio/cpio_windows.h7
-rw-r--r--cpio/test/CMakeLists.txt8
-rw-r--r--cpio/test/main.c155
-rw-r--r--cpio/test/test.h31
-rw-r--r--cpio/test/test_basic.c2
-rw-r--r--cpio/test/test_extract.cpio.lz4.uu7
-rw-r--r--cpio/test/test_extract_cpio_lz4.c48
-rw-r--r--cpio/test/test_extract_cpio_lzo.c2
-rw-r--r--cpio/test/test_option_c.c10
-rw-r--r--cpio/test/test_option_lz4.c74
-rw-r--r--cpio/test/test_option_passphrase.c43
-rw-r--r--cpio/test/test_option_passphrase.zip.uu12
-rw-r--r--cpio/test/test_option_version.c5
-rwxr-xr-xdoc/mdoc2wiki.awk193
-rw-r--r--examples/minitar/Makefile8
-rw-r--r--examples/minitar/minitar.c34
-rw-r--r--examples/untar.c6
-rw-r--r--libarchive/CMakeLists.txt43
-rw-r--r--libarchive/archive.h271
-rw-r--r--libarchive/archive_cryptor.c448
-rw-r--r--libarchive/archive_cryptor_private.h163
-rw-r--r--libarchive/archive_digest.c (renamed from libarchive/archive_crypto.c)10
-rw-r--r--libarchive/archive_digest_private.h (renamed from libarchive/archive_crypto_private.h)42
-rw-r--r--libarchive/archive_endian.h44
-rw-r--r--libarchive/archive_entry.32
-rw-r--r--libarchive/archive_entry.c171
-rw-r--r--libarchive/archive_entry.h69
-rw-r--r--libarchive/archive_entry_acl.32
-rw-r--r--libarchive/archive_entry_copy_stat.c4
-rw-r--r--libarchive/archive_entry_paths.32
-rw-r--r--libarchive/archive_entry_perms.32
-rw-r--r--libarchive/archive_entry_private.h5
-rw-r--r--libarchive/archive_entry_sparse.c2
-rw-r--r--libarchive/archive_entry_stat.34
-rw-r--r--libarchive/archive_entry_time.32
-rw-r--r--libarchive/archive_entry_xattr.c5
-rw-r--r--libarchive/archive_getdate.c19
-rw-r--r--libarchive/archive_getdate.h39
-rw-r--r--libarchive/archive_hmac.c248
-rw-r--r--libarchive/archive_hmac_private.h106
-rw-r--r--libarchive/archive_match.c13
-rw-r--r--libarchive/archive_options.c6
-rw-r--r--libarchive/archive_pack_dev.c329
-rw-r--r--libarchive/archive_pack_dev.h49
-rw-r--r--libarchive/archive_pathmatch.c8
-rw-r--r--libarchive/archive_platform.h22
-rw-r--r--libarchive/archive_private.h19
-rw-r--r--libarchive/archive_random.c269
-rw-r--r--libarchive/archive_random_private.h36
-rw-r--r--libarchive/archive_read.34
-rw-r--r--libarchive/archive_read.c141
-rw-r--r--libarchive/archive_read_add_passphrase.374
-rw-r--r--libarchive/archive_read_add_passphrase.c186
-rw-r--r--libarchive/archive_read_append_filter.c6
-rw-r--r--libarchive/archive_read_data.32
-rw-r--r--libarchive/archive_read_disk_entry_from_file.c60
-rw-r--r--libarchive/archive_read_disk_posix.c58
-rw-r--r--libarchive/archive_read_disk_private.h5
-rw-r--r--libarchive/archive_read_disk_set_standard_lookup.c2
-rw-r--r--libarchive/archive_read_disk_windows.c29
-rw-r--r--libarchive/archive_read_extract.c147
-rw-r--r--libarchive/archive_read_extract2.c156
-rw-r--r--libarchive/archive_read_filter.323
-rw-r--r--libarchive/archive_read_open.34
-rw-r--r--libarchive/archive_read_open_fd.c29
-rw-r--r--libarchive/archive_read_open_file.c10
-rw-r--r--libarchive/archive_read_open_filename.c6
-rw-r--r--libarchive/archive_read_open_memory.c12
-rw-r--r--libarchive/archive_read_private.h76
-rw-r--r--libarchive/archive_read_set_options.322
-rw-r--r--libarchive/archive_read_set_options.c39
-rw-r--r--libarchive/archive_read_support_filter_all.c2
-rw-r--r--libarchive/archive_read_support_filter_compress.c24
-rw-r--r--libarchive/archive_read_support_filter_lz4.c737
-rw-r--r--libarchive/archive_read_support_filter_lzop.c16
-rw-r--r--libarchive/archive_read_support_filter_uu.c3
-rw-r--r--libarchive/archive_read_support_filter_xz.c4
-rw-r--r--libarchive/archive_read_support_format_7zip.c212
-rw-r--r--libarchive/archive_read_support_format_all.c1
-rw-r--r--libarchive/archive_read_support_format_ar.c25
-rw-r--r--libarchive/archive_read_support_format_cab.c4
-rw-r--r--libarchive/archive_read_support_format_cpio.c4
-rw-r--r--libarchive/archive_read_support_format_empty.c2
-rw-r--r--libarchive/archive_read_support_format_iso9660.c76
-rw-r--r--libarchive/archive_read_support_format_lha.c481
-rw-r--r--libarchive/archive_read_support_format_mtree.c623
-rw-r--r--libarchive/archive_read_support_format_rar.c158
-rw-r--r--libarchive/archive_read_support_format_raw.c4
-rw-r--r--libarchive/archive_read_support_format_tar.c210
-rw-r--r--libarchive/archive_read_support_format_warc.c795
-rw-r--r--libarchive/archive_read_support_format_xar.c73
-rw-r--r--libarchive/archive_read_support_format_zip.c3581
-rw-r--r--libarchive/archive_string.c94
-rw-r--r--libarchive/archive_util.c198
-rw-r--r--libarchive/archive_virtual.c16
-rw-r--r--libarchive/archive_windows.c10
-rw-r--r--libarchive/archive_windows.h14
-rw-r--r--libarchive/archive_write.315
-rw-r--r--libarchive/archive_write.c29
-rw-r--r--libarchive/archive_write_add_filter.c1
-rw-r--r--libarchive/archive_write_add_filter_by_name.c1
-rw-r--r--libarchive/archive_write_add_filter_bzip2.c2
-rw-r--r--libarchive/archive_write_add_filter_grzip.c2
-rw-r--r--libarchive/archive_write_add_filter_gzip.c2
-rw-r--r--libarchive/archive_write_add_filter_lrzip.c9
-rw-r--r--libarchive/archive_write_add_filter_lz4.c707
-rw-r--r--libarchive/archive_write_add_filter_lzop.c4
-rw-r--r--libarchive/archive_write_add_filter_program.c16
-rw-r--r--libarchive/archive_write_add_filter_xz.c44
-rw-r--r--libarchive/archive_write_data.314
-rw-r--r--libarchive/archive_write_disk.310
-rw-r--r--libarchive/archive_write_disk_acl.c16
-rw-r--r--libarchive/archive_write_disk_posix.c122
-rw-r--r--libarchive/archive_write_disk_set_standard_lookup.c7
-rw-r--r--libarchive/archive_write_disk_windows.c8
-rw-r--r--libarchive/archive_write_filter.331
-rw-r--r--libarchive/archive_write_finish_entry.32
-rw-r--r--libarchive/archive_write_format.3124
-rw-r--r--libarchive/archive_write_open.32
-rw-r--r--libarchive/archive_write_open_filename.c5
-rw-r--r--libarchive/archive_write_private.h17
-rw-r--r--libarchive/archive_write_set_format.c4
-rw-r--r--libarchive/archive_write_set_format_7zip.c4
-rw-r--r--libarchive/archive_write_set_format_by_name.c2
-rw-r--r--libarchive/archive_write_set_format_filter_by_ext.c142
-rw-r--r--libarchive/archive_write_set_format_gnutar.c12
-rw-r--r--libarchive/archive_write_set_format_iso9660.c20
-rw-r--r--libarchive/archive_write_set_format_mtree.c43
-rw-r--r--libarchive/archive_write_set_format_pax.c37
-rw-r--r--libarchive/archive_write_set_format_raw.c125
-rw-r--r--libarchive/archive_write_set_format_shar.c1
-rw-r--r--libarchive/archive_write_set_format_warc.c445
-rw-r--r--libarchive/archive_write_set_format_xar.c68
-rw-r--r--libarchive/archive_write_set_format_zip.c1644
-rw-r--r--libarchive/archive_write_set_options.361
-rw-r--r--libarchive/archive_write_set_passphrase.374
-rw-r--r--libarchive/archive_write_set_passphrase.c95
-rw-r--r--libarchive/archive_xxhash.h47
-rw-r--r--libarchive/filter_fork_windows.c2
-rw-r--r--libarchive/libarchive-formats.555
-rw-r--r--libarchive/libarchive.34
-rw-r--r--libarchive/libarchive_internals.32
-rw-r--r--libarchive/mtree.596
-rw-r--r--libarchive/tar.52
-rw-r--r--libarchive/test/CMakeLists.txt57
-rw-r--r--libarchive/test/README14
-rw-r--r--libarchive/test/main.c134
-rw-r--r--libarchive/test/read_open_memory.c18
-rw-r--r--libarchive/test/test.h27
-rw-r--r--libarchive/test/test_archive_digest.c (renamed from libarchive/test/test_archive_crypto.c)4
-rw-r--r--libarchive/test/test_archive_getdate.c10
-rw-r--r--libarchive/test/test_archive_match_time.c3
-rw-r--r--libarchive/test/test_archive_pathmatch.c41
-rw-r--r--libarchive/test/test_archive_read_add_passphrase.c260
-rw-r--r--libarchive/test/test_archive_string.c63
-rw-r--r--libarchive/test/test_archive_write_add_filter_by_name.c17
-rw-r--r--libarchive/test/test_archive_write_set_format_by_name.c5
-rw-r--r--libarchive/test/test_archive_write_set_format_filter_by_ext.c211
-rw-r--r--libarchive/test/test_archive_write_set_passphrase.c95
-rw-r--r--libarchive/test/test_compat_lz4.c120
-rw-r--r--libarchive/test/test_compat_lz4_1.tar.lz4.uu12
-rw-r--r--libarchive/test/test_compat_lz4_2.tar.lz4.uu13
-rw-r--r--libarchive/test/test_compat_lz4_3.tar.lz4.uu9
-rw-r--r--libarchive/test/test_compat_lz4_B4.tar.lz4.uu6739
-rw-r--r--libarchive/test/test_compat_lz4_B4BD.tar.lz4.uu6739
-rw-r--r--libarchive/test/test_compat_lz4_B4BDBX.tar.lz4.uu6744
-rw-r--r--libarchive/test/test_compat_lz4_B5.tar.lz4.uu2310
-rw-r--r--libarchive/test/test_compat_lz4_B5BD.tar.lz4.uu2310
-rw-r--r--libarchive/test/test_compat_lz4_B6.tar.lz4.uu1197
-rw-r--r--libarchive/test/test_compat_lz4_B6BD.tar.lz4.uu1197
-rw-r--r--libarchive/test/test_compat_lz4_B7.tar.lz4.uu918
-rw-r--r--libarchive/test/test_compat_lz4_B7BD.tar.lz4.uu918
-rw-r--r--libarchive/test/test_compat_mac.c2
-rw-r--r--libarchive/test/test_compat_pax_libarchive_2x.c11
-rw-r--r--libarchive/test/test_compat_uudecode_large.c54
-rw-r--r--libarchive/test/test_compat_uudecode_large.tar.Z.uu1087
-rw-r--r--libarchive/test/test_compat_zip.c56
-rw-r--r--libarchive/test/test_fuzz.c202
-rw-r--r--libarchive/test/test_gnutar_filename_encoding.c39
-rw-r--r--libarchive/test/test_pax_filename_encoding.c24
-rw-r--r--libarchive/test/test_read_data_large.c6
-rw-r--r--libarchive/test/test_read_disk_directory_traversals.c18
-rw-r--r--libarchive/test/test_read_filter_compress.c80
-rw-r--r--libarchive/test/test_read_format_7zip.c81
-rw-r--r--libarchive/test/test_read_format_7zip_encryption.7z.uu7
-rw-r--r--libarchive/test/test_read_format_7zip_encryption_data.c70
-rw-r--r--libarchive/test/test_read_format_7zip_encryption_header.7z.uu8
-rw-r--r--libarchive/test/test_read_format_7zip_encryption_header.c73
-rw-r--r--libarchive/test/test_read_format_7zip_encryption_partially.7z.uu8
-rw-r--r--libarchive/test/test_read_format_7zip_encryption_partially.c82
-rw-r--r--libarchive/test/test_read_format_7zip_malformed.7z.uu5
-rw-r--r--libarchive/test/test_read_format_7zip_malformed.c67
-rw-r--r--libarchive/test/test_read_format_7zip_malformed2.7z.uu5
-rw-r--r--libarchive/test/test_read_format_ar.c6
-rw-r--r--libarchive/test/test_read_format_cab.c32
-rw-r--r--libarchive/test/test_read_format_cab_filename.c8
-rw-r--r--libarchive/test/test_read_format_cpio_afio.c4
-rw-r--r--libarchive/test/test_read_format_cpio_bin.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_Z.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_be.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_bz2.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_gz.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_le.c57
-rw-r--r--libarchive/test/test_read_format_cpio_bin_le.cpio.uu7
-rw-r--r--libarchive/test/test_read_format_cpio_bin_lzip.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_lzma.c2
-rw-r--r--libarchive/test/test_read_format_cpio_bin_xz.c2
-rw-r--r--libarchive/test/test_read_format_cpio_filename.c120
-rw-r--r--libarchive/test/test_read_format_cpio_odc.c2
-rw-r--r--libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c6
-rw-r--r--libarchive/test/test_read_format_cpio_svr4_gzip.c2
-rw-r--r--libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c2
-rw-r--r--libarchive/test/test_read_format_cpio_svr4c_Z.c2
-rw-r--r--libarchive/test/test_read_format_empty.c2
-rw-r--r--libarchive/test/test_read_format_gtar_filename.c69
-rw-r--r--libarchive/test/test_read_format_gtar_gz.c2
-rw-r--r--libarchive/test/test_read_format_gtar_lzma.c2
-rw-r--r--libarchive/test/test_read_format_gtar_sparse.c2
-rw-r--r--libarchive/test/test_read_format_gtar_sparse_skip_entry.c9
-rw-r--r--libarchive/test/test_read_format_iso_Z.c4
-rw-r--r--libarchive/test/test_read_format_iso_multi_extent.c2
-rw-r--r--libarchive/test/test_read_format_iso_xorriso.c3
-rw-r--r--libarchive/test/test_read_format_isojoliet_bz2.c6
-rw-r--r--libarchive/test/test_read_format_isojoliet_long.c8
-rw-r--r--libarchive/test/test_read_format_isojoliet_rr.c10
-rw-r--r--libarchive/test/test_read_format_isojoliet_versioned.c4
-rw-r--r--libarchive/test/test_read_format_isorr_bz2.c3
-rw-r--r--libarchive/test/test_read_format_isorr_ce.c3
-rw-r--r--libarchive/test/test_read_format_isorr_new_bz2.c3
-rw-r--r--libarchive/test/test_read_format_isorr_rr_moved.c3
-rw-r--r--libarchive/test/test_read_format_isozisofs_bz2.c3
-rw-r--r--libarchive/test/test_read_format_lha.c16
-rw-r--r--libarchive/test/test_read_format_lha_bugfix_0.c76
-rw-r--r--libarchive/test/test_read_format_lha_bugfix_0.lzh.uu19
-rw-r--r--libarchive/test/test_read_format_lha_filename.c5
-rw-r--r--libarchive/test/test_read_format_mtree.c122
-rw-r--r--libarchive/test/test_read_format_mtree.mtree.uu20
-rw-r--r--libarchive/test/test_read_format_pax_bz2.c2
-rw-r--r--libarchive/test/test_read_format_rar.c160
-rw-r--r--libarchive/test/test_read_format_rar_encryption_data.c79
-rw-r--r--libarchive/test/test_read_format_rar_encryption_data.rar.uu8
-rw-r--r--libarchive/test/test_read_format_rar_encryption_header.c71
-rw-r--r--libarchive/test/test_read_format_rar_encryption_header.rar.uu8
-rw-r--r--libarchive/test/test_read_format_rar_encryption_partially.c79
-rw-r--r--libarchive/test/test_read_format_rar_encryption_partially.rar.uu7
-rw-r--r--libarchive/test/test_read_format_raw.c4
-rw-r--r--libarchive/test/test_read_format_tar.c4
-rw-r--r--libarchive/test/test_read_format_tar_concatenated.c86
-rw-r--r--libarchive/test/test_read_format_tar_concatenated.tar.uu72
-rw-r--r--libarchive/test/test_read_format_tar_empty_filename.c2
-rw-r--r--libarchive/test/test_read_format_tar_empty_pax.c58
-rw-r--r--libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu10
-rw-r--r--libarchive/test/test_read_format_tar_filename.c31
-rw-r--r--libarchive/test/test_read_format_tbz.c2
-rw-r--r--libarchive/test/test_read_format_tgz.c2
-rw-r--r--libarchive/test/test_read_format_tlz.c2
-rw-r--r--libarchive/test/test_read_format_txz.c2
-rw-r--r--libarchive/test/test_read_format_tz.c2
-rw-r--r--libarchive/test/test_read_format_ustar_filename.c37
-rw-r--r--libarchive/test/test_read_format_warc.c82
-rw-r--r--libarchive/test/test_read_format_warc.warc.uu23
-rw-r--r--libarchive/test/test_read_format_xar.c2
-rw-r--r--libarchive/test/test_read_format_zip.c34
-rw-r--r--libarchive/test/test_read_format_zip_comment_stored.c6
-rw-r--r--libarchive/test/test_read_format_zip_encryption_data.c79
-rw-r--r--libarchive/test/test_read_format_zip_encryption_data.zip.uu25
-rw-r--r--libarchive/test/test_read_format_zip_encryption_header.c71
-rw-r--r--libarchive/test/test_read_format_zip_encryption_header.zip.uu32
-rw-r--r--libarchive/test/test_read_format_zip_encryption_partially.c79
-rw-r--r--libarchive/test/test_read_format_zip_encryption_partially.zip.uu18
-rw-r--r--libarchive/test/test_read_format_zip_filename.c218
-rw-r--r--libarchive/test/test_read_format_zip_mac_metadata.c13
-rw-r--r--libarchive/test/test_read_format_zip_malformed.c61
-rw-r--r--libarchive/test/test_read_format_zip_malformed1.zip.uu5
-rw-r--r--libarchive/test/test_read_format_zip_msdos.c116
-rw-r--r--libarchive/test/test_read_format_zip_msdos.zip.uu23
-rw-r--r--libarchive/test/test_read_format_zip_nested.c85
-rw-r--r--libarchive/test/test_read_format_zip_nested.zip.uu16
-rw-r--r--libarchive/test/test_read_format_zip_nofiletype.c66
-rw-r--r--libarchive/test/test_read_format_zip_nofiletype.zip.uu8
-rw-r--r--libarchive/test/test_read_format_zip_padded.c90
-rw-r--r--libarchive/test/test_read_format_zip_padded1.zip.uu12
-rw-r--r--libarchive/test/test_read_format_zip_padded2.zip.uu15
-rw-r--r--libarchive/test/test_read_format_zip_padded3.zip.uu17
-rw-r--r--libarchive/test/test_read_format_zip_sfx.c4
-rw-r--r--libarchive/test/test_read_format_zip_traditional_encryption_data.c168
-rw-r--r--libarchive/test/test_read_format_zip_traditional_encryption_data.zip.uu12
-rw-r--r--libarchive/test/test_read_format_zip_winzip_aes.c152
-rw-r--r--libarchive/test/test_read_format_zip_winzip_aes128.zip.uu66
-rw-r--r--libarchive/test/test_read_format_zip_winzip_aes256.zip.uu66
-rw-r--r--libarchive/test/test_read_format_zip_winzip_aes256_large.zip.uu2184
-rw-r--r--libarchive/test/test_read_format_zip_winzip_aes256_stored.zip.uu159
-rw-r--r--libarchive/test/test_read_format_zip_winzip_aes_large.c217
-rw-r--r--libarchive/test/test_read_format_zip_zip64.c130
-rw-r--r--libarchive/test/test_read_format_zip_zip64a.zip.uu7
-rw-r--r--libarchive/test/test_read_format_zip_zip64b.zip.uu7
-rw-r--r--libarchive/test/test_read_too_many_filters.c49
-rw-r--r--libarchive/test/test_read_too_many_filters.gz.uu15
-rw-r--r--libarchive/test/test_read_truncated.c4
-rw-r--r--libarchive/test/test_sparse_basic.c178
-rw-r--r--libarchive/test/test_ustar_filename_encoding.c39
-rw-r--r--libarchive/test/test_warn_missing_hardlink_target.c45
-rw-r--r--libarchive/test/test_write_disk_appledouble.c39
-rw-r--r--libarchive/test/test_write_disk_hfs_compression.c4
-rw-r--r--libarchive/test/test_write_disk_mac_metadata.c39
-rw-r--r--libarchive/test/test_write_disk_no_hfs_compression.c4
-rw-r--r--libarchive/test/test_write_disk_perms.c110
-rw-r--r--libarchive/test/test_write_disk_secure.c66
-rw-r--r--libarchive/test/test_write_filter_lz4.c409
-rw-r--r--libarchive/test/test_write_filter_lzop.c17
-rw-r--r--libarchive/test/test_write_filter_program.c4
-rw-r--r--libarchive/test/test_write_format_ar.c4
-rw-r--r--libarchive/test/test_write_format_cpio_newc.c2
-rw-r--r--libarchive/test/test_write_format_gnutar.c26
-rw-r--r--libarchive/test/test_write_format_iso9660.c2
-rw-r--r--libarchive/test/test_write_format_iso9660_boot.c2
-rw-r--r--libarchive/test/test_write_format_mtree.c123
-rw-r--r--libarchive/test/test_write_format_pax.c2
-rw-r--r--libarchive/test/test_write_format_raw.c123
-rw-r--r--libarchive/test/test_write_format_raw_b64.c77
-rw-r--r--libarchive/test/test_write_format_tar.c4
-rw-r--r--libarchive/test/test_write_format_tar_sparse.c2
-rw-r--r--libarchive/test/test_write_format_warc.c132
-rw-r--r--libarchive/test/test_write_format_warc_empty.c117
-rw-r--r--libarchive/test/test_write_format_zip.c862
-rw-r--r--libarchive/test/test_write_format_zip_compression_store.c (renamed from libarchive/test/test_write_format_zip_no_compression.c)263
-rw-r--r--libarchive/test/test_write_format_zip_empty_zip64.c103
-rw-r--r--libarchive/test/test_write_format_zip_file.c251
-rw-r--r--libarchive/test/test_write_format_zip_file_zip64.c285
-rw-r--r--libarchive/test/test_write_format_zip_large.c474
-rw-r--r--libarchive/test/test_write_format_zip_zip64.c67
-rw-r--r--libarchive/test/test_write_read_format_zip.c751
-rw-r--r--libarchive/test/test_write_zip_set_compression_store.c308
-rw-r--r--libarchive/test/test_zip_filename_encoding.c28
-rw-r--r--libarchive/xxhash.c514
-rw-r--r--libarchive_fe/err.c24
-rw-r--r--libarchive_fe/err.h5
-rw-r--r--libarchive_fe/passphrase.c317
-rw-r--r--libarchive_fe/passphrase.h31
-rw-r--r--tar/CMakeLists.txt3
-rw-r--r--tar/bsdtar.170
-rw-r--r--tar/bsdtar.c42
-rw-r--r--tar/bsdtar.h12
-rw-r--r--tar/bsdtar_platform.h8
-rw-r--r--tar/bsdtar_windows.h6
-rw-r--r--tar/cmdline.c5
-rw-r--r--tar/creation_set.c2
-rw-r--r--tar/read.c153
-rw-r--r--tar/subst.c106
-rw-r--r--tar/test/CMakeLists.txt9
-rw-r--r--tar/test/main.c154
-rw-r--r--tar/test/test.h29
-rw-r--r--tar/test/test_extract.tar.lz4.uu8
-rw-r--r--tar/test/test_extract_tar_lz4.c48
-rw-r--r--tar/test/test_leading_slash.c49
-rw-r--r--tar/test/test_leading_slash.tar.uu60
-rw-r--r--tar/test/test_option_X_upper.c14
-rw-r--r--tar/test/test_option_b.c19
-rw-r--r--tar/test/test_option_lz4.c74
-rw-r--r--tar/test/test_option_passphrase.c43
-rw-r--r--tar/test/test_option_passphrase.zip.uu12
-rw-r--r--tar/test/test_option_s.c23
-rw-r--r--tar/test/test_version.c5
-rw-r--r--tar/util.c312
-rw-r--r--tar/write.c40
436 files changed, 65124 insertions, 5618 deletions
diff --git a/.gitignore b/.gitignore
index 3609145920ca..a766c3cf7f77 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*~
*.o
*.exe
*.lo
@@ -7,6 +8,8 @@ Makefile
Makefile.in
aclocal.m4
autom4te.cache/
+bsdcat
+bsdcat_test
bsdcpio
bsdcpio_test
bsdtar
@@ -24,9 +27,13 @@ build/autoconf/ltversion.m4
build/autoconf/lt~obsolete.m4
build/autoconf/missing
build/pkgconfig/libarchive.pc
+cat/.deps/
+cat/.dirstamp
+cat/test/.deps/
+cat/test/.dirstamp
+cat/test/list.h
config.h
config.h.in
-config.h.in~
config.log
config.status
configure
@@ -82,3 +89,17 @@ libarchive/libarchive.so
libarchive/libarchive.so.*
.DS_Store
+
+bsdcat_test.log
+bsdcat_test.trs
+bsdcpio_test.log
+bsdcpio_test.trs
+bsdtar_test.log
+bsdtar_test.trs
+build/autoconf/test-driver
+libarchive_test.log
+libarchive_test.trs
+test-suite.log
+
+.sw?
+.*.sw?
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000000..c9323986a92d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,20 @@
+language: C
+sudo: true
+compiler:
+ - gcc
+ - clang
+before_install:
+ - sudo add-apt-repository ppa:kubuntu-ppa/backports -y
+ - sudo apt-get update -qq
+install:
+ - sudo apt-get install -y cmake=2.8.12.2-0ubuntu1~ubuntu12.04.1~ppa2
+ - sudo apt-get install -y libbz2-dev libzip-dev liblzma-dev
+before_script:
+ - BUILD_DIR=`pwd`/BUILD
+ - mkdir -p ${BUILD_DIR}
+ - cd ${BUILD_DIR}
+ - cmake ..
+script:
+ - cd ${BUILD_DIR}
+ - make
+ - make test
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cdb9fb48585..68e94a6ac0e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
#
PROJECT(libarchive C)
#
@@ -15,7 +15,7 @@ endif()
# RelWithDebInfo : Release build with Debug Info
# MinSizeRel : Release Min Size build
IF(NOT CMAKE_BUILD_TYPE)
- SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
+ SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# Set a value type to properly display CMAKE_BUILD_TYPE on GUI if the
# value type is "UNINITIALIZED".
@@ -35,6 +35,9 @@ ENDIF(NOT "${CMAKE_BUILD_TYPE}"
# On MacOS, prefer MacPorts libraries to system libraries.
# I haven't come up with a compelling argument for this to be conditional.
list(APPEND CMAKE_PREFIX_PATH /opt/local)
+# Enable @rpath in the install name.
+# detail in "cmake --help-policy CMP0042"
+SET(CMAKE_MACOSX_RPATH ON)
#
# Version - read from 'version' file.
@@ -55,11 +58,12 @@ STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision})
SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}")
SET(BSDCPIO_VERSION_STRING "${VERSION}")
SET(BSDTAR_VERSION_STRING "${VERSION}")
+SET(BSDCAT_VERSION_STRING "${VERSION}")
SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}")
SET(LIBARCHIVE_VERSION_STRING "${VERSION}")
# INTERFACE_VERSION increments with every release
-# libarchive 2.7 == interface version 9 = 2 + 7
+# libarchive 2.7 == interface version 9 = 2 + 7
# libarchive 2.8 == interface version 10 = 2 + 8
# libarchive 2.9 == interface version 11 = 2 + 9
# libarchive 3.0 == interface version 12
@@ -84,7 +88,7 @@ SET(CMAKE_REQUIRED_FLAGS)
# Especially for early development, we want to be a little
# aggressive about diagnosing build problems; this can get
# relaxed somewhat in final shipping versions.
-IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
+IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$")
SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
#################################################################
# Set compile flags for all build types.
@@ -92,11 +96,43 @@ IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
#################################################################
# Set compile flags for debug build.
# This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -Wextra -Wunused")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
-ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
+ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$")
+IF (CMAKE_C_COMPILER_ID MATCHES "^Clang$")
+ SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
+ #################################################################
+ # Set compile flags for all build types.
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security")
+ #################################################################
+ # Set compile flags for debug build.
+ # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
+ENDIF (CMAKE_C_COMPILER_ID MATCHES "^Clang$")
+IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
+ SET(CMAKE_C_COMPILER "xlc_r")
+ SET(CMAKE_REQUIRED_FLAGS "-qflag=e:e -qformat=sec")
+ #################################################################
+ # Set compile flags for all build types.
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qflag=e:e -qformat=sec")
+ #################################################################
+ # Set compile flags for debug build.
+ # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qhalt=w")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qflag=w:w")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -qinfo=pro:use")
+ENDIF(CMAKE_C_COMPILER_ID MATCHES "^XL$")
IF (MSVC)
#################################################################
# Set compile flags for debug build.
@@ -143,17 +179,36 @@ include(CTest)
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
+OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON)
+OPTION(ENABLE_ZLIB "Enable the use of the system found ZLIB library if found" ON)
+OPTION(ENABLE_BZip2 "Enable the use of the system found BZip2 library if found" ON)
+OPTION(ENABLE_LIBXML2 "Enable the use of the system found libxml2 library if found" ON)
+OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" ON)
+OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON)
+OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON)
+# CNG is used for encrypt/decrypt Zip archives on Windows.
+OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON)
+
OPTION(ENABLE_TAR "Enable tar building" ON)
OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE)
OPTION(ENABLE_CPIO "Enable cpio building" ON)
OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE)
+OPTION(ENABLE_CAT "Enable cat building" ON)
+OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE)
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
OPTION(ENABLE_ACL "Enable ACL support" ON)
OPTION(ENABLE_ICONV "Enable iconv support" ON)
OPTION(ENABLE_TEST "Enable unit and regression tests" ON)
+OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE)
+OPTION(ENABLE_INSTALL "Enable installing of libraries" ON)
+
SET(POSIX_REGEX_LIB "AUTO" CACHE STRING "Choose what library should provide POSIX regular expression support")
SET(ENABLE_SAFESEH "AUTO" CACHE STRING "Enable use of /SAFESEH linker flag (MSVC only)")
-SET(WINDOWS_VERSION "" CACHE STRING "Set Windows version to use (Windows only)")
+SET(WINDOWS_VERSION "WIN7" CACHE STRING "Set Windows version to use (Windows only)")
+
+IF(ENABLE_COVERAGE)
+ include(LibarchiveCodeCoverage)
+ENDIF(ENABLE_COVERAGE)
IF(ENABLE_TEST)
ENABLE_TESTING()
@@ -161,22 +216,35 @@ ENDIF(ENABLE_TEST)
IF(WIN32)
IF(WINDOWS_VERSION STREQUAL "WIN8")
+ SET(NTDDI_VERSION 0x06020000)
+ SET(_WIN32_WINNT 0x0602)
SET(WINVER 0x0602)
ELSEIF(WINDOWS_VERSION STREQUAL "WIN7")
+ SET(NTDDI_VERSION 0x06010000)
+ SET(_WIN32_WINNT 0x0601)
SET(WINVER 0x0601)
ELSEIF(WINDOWS_VERSION STREQUAL "WS08")
+ SET(NTDDI_VERSION 0x06000100)
+ SET(_WIN32_WINNT 0x0600)
SET(WINVER 0x0600)
ELSEIF(WINDOWS_VERSION STREQUAL "VISTA")
+ SET(NTDDI_VERSION 0x06000000)
+ SET(_WIN32_WINNT 0x0600)
SET(WINVER 0x0600)
ELSEIF(WINDOWS_VERSION STREQUAL "WS03")
+ SET(NTDDI_VERSION 0x05020000)
+ SET(_WIN32_WINNT 0x0502)
SET(WINVER 0x0502)
ELSEIF(WINDOWS_VERSION STREQUAL "WINXP")
+ SET(NTDDI_VERSION 0x05010000)
+ SET(_WIN32_WINNT 0x0501)
SET(WINVER 0x0501)
ELSE(WINDOWS_VERSION STREQUAL "WIN8")
- # The default is to use Windows 2000 API.
- SET(WINVER 0x0500)
+ # Default to Windows Server 2003 API if we don't recognize the specifier
+ SET(NTDDI_VERSION 0x05020000)
+ SET(_WIN32_WINNT 0x0502)
+ SET(WINVER 0x0502)
ENDIF(WINDOWS_VERSION STREQUAL "WIN8")
- SET(_WIN32_WINNT ${WINVER})
ENDIF(WIN32)
IF(MSVC)
@@ -184,12 +252,12 @@ IF(MSVC)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH")
- SET(CMAKE_REQUIRED_LINKER_FLAGS "/SAFESEH")
+ SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH")
ELSEIF(ENABLE_SAFESEH STREQUAL "NO")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
- SET(CMAKE_REQUIRED_LINKER_FLAGS "/SAFESEH:NO")
+ SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH:NO")
ENDIF(ENABLE_SAFESEH STREQUAL "YES")
ENDIF(MSVC)
@@ -198,8 +266,8 @@ IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$")
ENDIF()
#
-INCLUDE(LibarchiveCheckCSourceCompiles)
-INCLUDE(LibarchiveCheckCSourceRuns)
+INCLUDE(CheckCSourceCompiles)
+INCLUDE(CheckCSourceRuns)
INCLUDE(CheckFileOffsetBits)
INCLUDE(CheckFuncs)
INCLUDE(CheckHeaderDirent)
@@ -263,9 +331,9 @@ MACRO (TRY_MACRO_FOR_LIBRARY INCLUDES LIBRARIES
ENDIF(NOT "${PREV_VAR_WITH_LIB}" STREQUAL "${LIBRARIES}")
# Check if the library can be used with the macro.
IF("${TRY_TYPE}" MATCHES "COMPILES")
- LIBARCHIVE_CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR})
+ CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR})
ELSEIF("${TRY_TYPE}" MATCHES "RUNS")
- LIBARCHIVE_CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR})
+ CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR})
ELSE("${TRY_TYPE}" MATCHES "COMPILES")
MESSAGE(FATAL_ERROR "UNKNOWN KEYWORD \"${TRY_TYPE}\" FOR TRY_TYPE")
ENDIF("${TRY_TYPE}" MATCHES "COMPILES")
@@ -297,11 +365,11 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
# e.g.
# cmake -DCMAKE_PREFIX_PATH=<your-GnuWin32-path> <path-to-source>
#
- # If compiling error occured in zconf.h, You may need patch to zconf.h.
+ # If compiling error occurred in zconf.h, You may need patch to zconf.h.
#--- zconf.h.orig 2005-07-21 00:40:26.000000000
#+++ zconf.h 2009-01-19 11:39:10.093750000
#@@ -286,7 +286,7 @@
- #
+ #
# #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */
# # include <sys/types.h> /* for off_t */
#-# include <unistd.h> /* for SEEK_* and off_t */
@@ -315,7 +383,11 @@ SET(ADDITIONAL_LIBS "")
#
# Find ZLIB
#
-FIND_PACKAGE(ZLIB)
+IF(ENABLE_ZLIB)
+ FIND_PACKAGE(ZLIB)
+ELSE()
+ SET(ZLIB_FOUND FALSE) # Override cached value
+ENDIF()
IF(ZLIB_FOUND)
SET(HAVE_LIBZ 1)
SET(HAVE_ZLIB_H 1)
@@ -350,7 +422,11 @@ MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY)
#
# Find BZip2
#
-FIND_PACKAGE(BZip2)
+IF(ENABLE_BZip2)
+ FIND_PACKAGE(BZip2)
+ELSE()
+ SET(BZIP2_FOUND FALSE) # Override cached value
+ENDIF()
IF(BZIP2_FOUND)
SET(HAVE_LIBBZ2 1)
SET(HAVE_BZLIB_H 1)
@@ -370,10 +446,18 @@ IF(BZIP2_FOUND)
ENDIF(BZIP2_FOUND)
MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
+
+
#
# Find LZMA
#
-FIND_PACKAGE(LZMA)
+IF(ENABLE_LZMA)
+ FIND_PACKAGE(LZMA)
+ELSE()
+ SET(LZMA_FOUND FALSE) # Override cached value
+ SET(LZMADEC_FOUND FALSE) # Override cached value
+ENDIF()
+
IF(LZMA_FOUND)
SET(HAVE_LIBLZMA 1)
SET(HAVE_LZMA_H 1)
@@ -393,6 +477,8 @@ ELSEIF(LZMADEC_FOUND)
SET(HAVE_LZMADEC_H 1)
INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES})
+ELSE(LZMA_FOUND)
+# LZMA not found and will not be used.
ENDIF(LZMA_FOUND)
#
# Find LZO2
@@ -418,6 +504,33 @@ IF(LZO2_FOUND)
ENDIF(LZO2_FOUND)
MARK_AS_ADVANCED(CLEAR LZO2_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR LZO2_LIBRARY)
+#
+# Find LZ4
+#
+IF (LZ4_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(LZ4_FIND_QUIETLY TRUE)
+ENDIF (LZ4_INCLUDE_DIR)
+
+FIND_PATH(LZ4_INCLUDE_DIR lz4.h)
+FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4)
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)
+IF(LZ4_FOUND)
+ SET(HAVE_LIBLZ4 1)
+ SET(HAVE_LZ4_H 1)
+ CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
+ SET(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR})
+ CHECK_INCLUDE_FILES("lz4hc.h" HAVE_LZ4HC_H)
+ CMAKE_POP_CHECK_STATE() # Restore the state of the variables
+ INCLUDE_DIRECTORIES(${LZ4_INCLUDE_DIR})
+ LIST(APPEND ADDITIONAL_LIBS ${LZ4_LIBRARY})
+ #
+ # TODO: test for static library.
+ #
+ENDIF(LZ4_FOUND)
+MARK_AS_ADVANCED(CLEAR LZ4_INCLUDE_DIR)
+MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY)
#
# Check headers
@@ -444,7 +557,7 @@ LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H)
-LIBARCHIVE_CHECK_C_SOURCE_COMPILES("#include <sys/ioctl.h>
+CHECK_C_SOURCE_COMPILES("#include <sys/ioctl.h>
#include <ext2fs/ext2_fs.h>
int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS)
@@ -463,7 +576,9 @@ LA_CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
LA_CHECK_INCLUDE_FILE("paths.h" HAVE_PATHS_H)
LA_CHECK_INCLUDE_FILE("poll.h" HAVE_POLL_H)
LA_CHECK_INCLUDE_FILE("process.h" HAVE_PROCESS_H)
+LA_CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H)
LA_CHECK_INCLUDE_FILE("pwd.h" HAVE_PWD_H)
+LA_CHECK_INCLUDE_FILE("readpassphrase.h" HAVE_READPASSPHRASE_H)
LA_CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H)
LA_CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
LA_CHECK_INCLUDE_FILE("spawn.h" HAVE_SPAWN_H)
@@ -494,6 +609,11 @@ LA_CHECK_INCLUDE_FILE("utime.h" HAVE_UTIME_H)
LA_CHECK_INCLUDE_FILE("wchar.h" HAVE_WCHAR_H)
LA_CHECK_INCLUDE_FILE("wctype.h" HAVE_WCTYPE_H)
LA_CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
+IF(ENABLE_CNG)
+ LA_CHECK_INCLUDE_FILE("Bcrypt.h" HAVE_BCRYPT_H)
+ELSE(ENABLE_CNG)
+ UNSET(HAVE_BCRYPT_H CACHE)
+ENDIF(ENABLE_CNG)
# Following files need windwos.h, so we should test it after windows.h test.
LA_CHECK_INCLUDE_FILE("wincrypt.h" HAVE_WINCRYPT_H)
LA_CHECK_INCLUDE_FILE("winioctl.h" HAVE_WINIOCTL_H)
@@ -507,7 +627,7 @@ FOREACH (it ${_HEADER})
SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
ENDFOREACH (it)
-LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
+CHECK_C_SOURCE_COMPILES(
"#define __EXTENSIONS__ 1
${_INCLUDE_FILES}
int main() { return 0;}"
@@ -520,11 +640,17 @@ IF(ENABLE_NETTLE)
FIND_PACKAGE(Nettle)
IF(NETTLE_FOUND)
SET(HAVE_LIBNETTLE 1)
- SET(HAVE_NETTLE_MD5_H 1)
- SET(HAVE_NETTLE_RIPEMD160_H 1)
- SET(HAVE_NETTLE_SHA_H 1)
- INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES})
+ INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR})
+
+ LIST(APPEND CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIR})
+ LA_CHECK_INCLUDE_FILE("nettle/aes.h" HAVE_NETTLE_AES_H)
+ LA_CHECK_INCLUDE_FILE("nettle/hmac.h" HAVE_NETTLE_HMAC_H)
+ LA_CHECK_INCLUDE_FILE("nettle/md5.h" HAVE_NETTLE_MD5_H)
+ LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H)
+ LA_CHECK_INCLUDE_FILE("nettle/ripemd160.h" HAVE_NETTLE_RIPEMD160_H)
+ LA_CHECK_INCLUDE_FILE("nettle/sha.h" HAVE_NETTLE_SHA_H)
+
ENDIF(NETTLE_FOUND)
MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES)
@@ -536,6 +662,11 @@ ENDIF(ENABLE_NETTLE)
#
IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
FIND_PACKAGE(OpenSSL)
+ IF(OPENSSL_FOUND)
+ SET(HAVE_LIBCRYPTO 1)
+ INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
+ LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_CRYPTO_LIBRARY})
+ ENDIF(OPENSSL_FOUND)
ELSE()
SET(OPENSSL_FOUND FALSE) # Override cached value
ENDIF()
@@ -554,7 +685,7 @@ ENDIF(NOT OPENSSL_FOUND)
#
# How to prove that CRYPTO functions, which have several names on various
-# platforms, just see if archive_crypto.c can compile and link against
+# platforms, just see if archive_digest.c can compile and link against
# required libraries.
#
MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION)
@@ -593,7 +724,7 @@ MACRO(CHECK_CRYPTO ALGORITHMS IMPLEMENTATION)
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h)
FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/confdefs.h"
CONFDEFS_H)
- FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/libarchive/archive_crypto.c"
+ FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/libarchive/archive_digest.c"
ARCHIVE_CRYPTO_C)
SET(SOURCE "${CONFDEFS_H}
@@ -619,16 +750,10 @@ main(int argc, char **argv)
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c" "${SOURCE}")
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}")
- IF(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_ADD_LINKER_FLAGS
- "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
- ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_ADD_LINKER_FLAGS)
- ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
TRY_COMPILE(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c
- CMAKE_FLAGS ${CHECK_CRYPTO_ADD_LINKER_FLAGS}
+ CMAKE_FLAGS
"${TRY_CRYPTO_REQUIRED_LIBS}"
"${TRY_CRYPTO_REQUIRED_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
@@ -713,16 +838,10 @@ main(int argc, char **argv)
FILE(WRITE "${SOURCE_FILE}" "${SOURCE}")
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN")
- IF(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS
- "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
- ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS)
- ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN
${CMAKE_BINARY_DIR}
${SOURCE_FILE}
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" ${CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS}
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive"
OUTPUT_VARIABLE OUTPUT)
IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
@@ -755,20 +874,25 @@ ENDMACRO(CHECK_CRYPTO_WIN CRYPTO_LIST)
MACRO(CHECK_ICONV LIB TRY_ICONV_CONST)
IF(NOT HAVE_ICONV)
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
- IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
+ IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
+ CMAKE_C_COMPILER_ID MATCHES "^Clang$")
#
# During checking iconv proto type, we should use -Werror to avoid the
# success of iconv detection with a warnig which success is a miss
# detection. So this needs for all build mode(even it's a release mode).
#
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
- ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
+ ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
+ CMAKE_C_COMPILER_ID MATCHES "^Clang$")
+ IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
+ SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -qhalt=w -qflag=w:w")
+ ENDIF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
IF (MSVC)
# NOTE: /WX option is the same as gcc's -Werror option.
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX")
ENDIF (MSVC)
#
- LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
+ CHECK_C_SOURCE_COMPILES(
"#include <stdlib.h>
#include <iconv.h>
int main() {
@@ -884,7 +1008,11 @@ ENDIF(ENABLE_ICONV)
#
# Find Libxml2
#
-FIND_PACKAGE(LibXml2)
+IF(ENABLE_LIBXML2)
+ FIND_PACKAGE(LibXml2)
+ELSE()
+ SET(LIBXML2_FOUND FALSE)
+ENDIF()
IF(LIBXML2_FOUND)
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
@@ -909,7 +1037,11 @@ ELSE(LIBXML2_FOUND)
#
# Find Expat
#
- FIND_PACKAGE(EXPAT)
+ IF(ENABLE_EXPAT)
+ FIND_PACKAGE(EXPAT)
+ ELSE()
+ SET(EXPAT_FOUND FALSE)
+ ENDIF()
IF(EXPAT_FOUND)
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR})
@@ -979,8 +1111,16 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$"
#
# If requested, try finding library for PCREPOSIX
#
- FIND_PACKAGE(LibGCC)
- FIND_PACKAGE(PCREPOSIX)
+ IF(ENABLE_LibGCC)
+ FIND_PACKAGE(LibGCC)
+ ELSE()
+ SET(LIBGCC_FOUND FALSE) # Override cached value
+ ENDIF()
+ IF(ENABLE_PCREPOSIX)
+ FIND_PACKAGE(PCREPOSIX)
+ ELSE()
+ SET(PCREPOSIX_FOUND FALSE) # Override cached value
+ ENDIF()
IF(PCREPOSIX_FOUND)
INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${PCREPOSIX_LIBRARIES})
@@ -1032,15 +1172,18 @@ ENDIF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX
# Check functions
#
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
-IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
+IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
+ CMAKE_C_COMPILER_ID MATCHES "^Clang$")
#
# During checking functions, we should use -fno-builtin to avoid the
# failure of function detection which failure is an error "conflicting
# types for built-in function" caused by using -Werror option.
#
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-builtin")
-ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
+ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
+ CMAKE_C_COMPILER_ID MATCHES "^Clang$")
CHECK_SYMBOL_EXISTS(_CrtSetReportMode "crtdbg.h" HAVE__CrtSetReportMode)
+CHECK_FUNCTION_EXISTS_GLIBC(arc4random_buf HAVE_ARC4RANDOM_BUF)
CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
@@ -1088,6 +1231,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(pipe HAVE_PIPE)
CHECK_FUNCTION_EXISTS_GLIBC(poll HAVE_POLL)
CHECK_FUNCTION_EXISTS_GLIBC(posix_spawnp HAVE_POSIX_SPAWNP)
CHECK_FUNCTION_EXISTS_GLIBC(readlink HAVE_READLINK)
+CHECK_FUNCTION_EXISTS_GLIBC(readpassphrase HAVE_READPASSPHRASE)
CHECK_FUNCTION_EXISTS_GLIBC(select HAVE_SELECT)
CHECK_FUNCTION_EXISTS_GLIBC(setenv HAVE_SETENV)
CHECK_FUNCTION_EXISTS_GLIBC(setlocale HAVE_SETLOCALE)
@@ -1126,19 +1270,20 @@ CHECK_FUNCTION_EXISTS(strftime HAVE_STRFTIME)
CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF)
CHECK_FUNCTION_EXISTS(wmemcmp HAVE_WMEMCMP)
CHECK_FUNCTION_EXISTS(wmemcpy HAVE_WMEMCPY)
+CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE)
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
# Make sure we have the POSIX version of readdir_r, not the
# older 2-argument version.
-LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
+CHECK_C_SOURCE_COMPILES(
"#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}"
HAVE_READDIR_R)
# Only detect readlinkat() if we also have AT_FDCWD in unistd.h.
# NOTE: linux requires fcntl.h for AT_FDCWD.
-LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
+CHECK_C_SOURCE_COMPILES(
"#include <fcntl.h>\n#include <unistd.h>\nint main() {char buf[10]; return readlinkat(AT_FDCWD, \"\", buf, 0);}"
HAVE_READLINKAT)
@@ -1147,10 +1292,10 @@ LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
# of interest and verify that the result can be linked.
# CHECK_FUNCTION_EXISTS doesn't accept a header argument,
# CHECK_SYMBOL_EXISTS doesn't test linkage.
-LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
+CHECK_C_SOURCE_COMPILES(
"#include <sys/mkdev.h>\nint main() { return major(256); }"
MAJOR_IN_MKDEV)
-LIBARCHIVE_CHECK_C_SOURCE_COMPILES(
+CHECK_C_SOURCE_COMPILES(
"#include <sys/sysmacros.h>\nint main() { return major(256); }"
MAJOR_IN_SYSMACROS)
@@ -1171,10 +1316,15 @@ ENDIF(HAVE_INTTYPES_H)
CHECK_SYMBOL_EXISTS(EFTYPE "errno.h" HAVE_EFTYPE)
CHECK_SYMBOL_EXISTS(EILSEQ "errno.h" HAVE_EILSEQ)
CHECK_SYMBOL_EXISTS(D_MD_ORDER "langinfo.h" HAVE_D_MD_ORDER)
+CHECK_SYMBOL_EXISTS(INT32_MAX "${headers}" HAVE_DECL_INT32_MAX)
+CHECK_SYMBOL_EXISTS(INT32_MIN "${headers}" HAVE_DECL_INT32_MIN)
CHECK_SYMBOL_EXISTS(INT64_MAX "${headers}" HAVE_DECL_INT64_MAX)
CHECK_SYMBOL_EXISTS(INT64_MIN "${headers}" HAVE_DECL_INT64_MIN)
+CHECK_SYMBOL_EXISTS(INTMAX_MAX "${headers}" HAVE_DECL_INTMAX_MAX)
+CHECK_SYMBOL_EXISTS(INTMAX_MIN "${headers}" HAVE_DECL_INTMAX_MIN)
CHECK_SYMBOL_EXISTS(UINT32_MAX "${headers}" HAVE_DECL_UINT32_MAX)
CHECK_SYMBOL_EXISTS(UINT64_MAX "${headers}" HAVE_DECL_UINT64_MAX)
+CHECK_SYMBOL_EXISTS(UINTMAX_MAX "${headers}" HAVE_DECL_UINTMAX_MAX)
CHECK_SYMBOL_EXISTS(SIZE_MAX "${headers}" HAVE_DECL_SIZE_MAX)
CHECK_SYMBOL_EXISTS(SSIZE_MAX "limits.h" HAVE_DECL_SSIZE_MAX)
@@ -1242,13 +1392,13 @@ CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG)
CHECK_TYPE_SIZE("__int64" __INT64)
CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64)
-CHECK_TYPE_SIZE(int16_t INT16_T)
+CHECK_TYPE_SIZE(int16_t INT16_T)
CHECK_TYPE_SIZE(int32_t INT32_T)
CHECK_TYPE_SIZE(int64_t INT64_T)
CHECK_TYPE_SIZE(intmax_t INTMAX_T)
-CHECK_TYPE_SIZE(uint8_t UINT8_T)
-CHECK_TYPE_SIZE(uint16_t UINT16_T)
-CHECK_TYPE_SIZE(uint32_t UINT32_T)
+CHECK_TYPE_SIZE(uint8_t UINT8_T)
+CHECK_TYPE_SIZE(uint16_t UINT16_T)
+CHECK_TYPE_SIZE(uint32_t UINT32_T)
CHECK_TYPE_SIZE(uint64_t UINT64_T)
CHECK_TYPE_SIZE(uintmax_t UINTMAX_T)
@@ -1491,6 +1641,9 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+# Handle generation of the libarchive.pc file for pkg-config
+INCLUDE(CreatePkgConfigFile)
+
#
# Register installation of PDF documents.
#
@@ -1521,5 +1674,6 @@ IF(ENABLE_TEST)
ENDIF(ENABLE_TEST)
add_subdirectory(libarchive)
+add_subdirectory(cat)
add_subdirectory(tar)
add_subdirectory(cpio)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000000..9ccc45c3d185
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -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.
+
diff --git a/COPYING b/COPYING
index b25880600230..93952b77ae25 100644
--- a/COPYING
+++ b/COPYING
@@ -17,12 +17,11 @@ the actual statements in the files are controlling.
files for details:
libarchive/archive_entry.c
libarchive/archive_read_support_filter_compress.c
- libarchive/archive_write_set_filter_compress.c
+ libarchive/archive_write_add_filter_compress.c
libarchive/mtree.5
- tar/matching.c
* The following source files are in the public domain:
- tar/getdate.c
+ libarchive/archive_getdate.c
* The build files---including Makefiles, configure scripts,
and auxiliary scripts used as part of the compile process---have
diff --git a/INSTALL b/INSTALL
index 33c58b7ed454..2fafbd5046d8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
More complete build documentation is available on the libarchive
-Wiki: http://libarchive.googlecode.com/
+Wiki: https://github.com/libarchive/libarchive/wiki
On most Unix-like systems, you should be able to install libarchive,
bsdtar, and bsdcpio using the following common steps:
diff --git a/Makefile.am b/Makefile.am
index 3fa2d22b6de6..c5250184a71e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,24 +8,23 @@ ACLOCAL_AMFLAGS = -I build/autoconf
#
lib_LTLIBRARIES= libarchive.la
noinst_LTLIBRARIES= libarchive_fe.la
-bin_PROGRAMS= $(bsdtar_programs) $(bsdcpio_programs)
-man_MANS= $(libarchive_man_MANS) $(bsdtar_man_MANS) $(bsdcpio_man_MANS)
-BUILT_SOURCES= libarchive/test/list.h tar/test/list.h cpio/test/list.h
+bin_PROGRAMS= $(bsdtar_programs) $(bsdcpio_programs) $(bsdcat_programs)
+man_MANS= $(libarchive_man_MANS) $(bsdtar_man_MANS) $(bsdcpio_man_MANS) $(bsdcat_man_MANS)
+BUILT_SOURCES= libarchive/test/list.h tar/test/list.h cpio/test/list.h cat/test/list.h
#
# What to test: We always test libarchive, test bsdtar and bsdcpio only
# if we built them.
#
-check_PROGRAMS= libarchive_test $(bsdtar_test_programs) $(bsdcpio_test_programs)
-TESTS= libarchive_test $(bsdtar_test_programs) $(bsdcpio_test_programs)
-TESTS_ENVIRONMENT= $(libarchive_TESTS_ENVIRONMENT) $(bsdtar_TESTS_ENVIRONMENT) $(bsdcpio_TESTS_ENVIRONMENT)
+check_PROGRAMS= libarchive_test $(bsdtar_test_programs) $(bsdcpio_test_programs) $(bsdcat_test_programs)
+TESTS= libarchive_test $(bsdtar_test_programs) $(bsdcpio_test_programs) $(bsdcat_test_programs)
+TESTS_ENVIRONMENT= $(libarchive_TESTS_ENVIRONMENT) $(bsdtar_TESTS_ENVIRONMENT) $(bsdcpio_TESTS_ENVIRONMENT) $(bsdcat_TESTS_ENVIRONMENT)
# Always build and test both bsdtar and bsdcpio as part of 'distcheck'
DISTCHECK_CONFIGURE_FLAGS = --enable-bsdtar --enable-bsdcpio
-COMMON_CFLAGS=-Wall -Wformat -Wformat-security
# The next line is commented out by default in shipping libarchive releases.
# It is uncommented by default in trunk.
-# DEV_CFLAGS=-Werror -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual
-AM_CFLAGS=$(COMMON_CFLAGS) $(DEV_CFLAGS)
+DEV_CFLAGS=-Werror -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -g
+AM_CFLAGS=$(DEV_CFLAGS)
PLATFORMCPPFLAGS = @PLATFORMCPPFLAGS@
AM_CPPFLAGS=$(PLATFORMCPPFLAGS)
@@ -33,21 +32,23 @@ AM_CPPFLAGS=$(PLATFORMCPPFLAGS)
# What to include in the distribution
#
EXTRA_DIST= \
- CMakeLists.txt \
- build/autogen.sh \
- build/bump-version.sh \
- build/clean.sh \
- build/cmake \
- build/version \
- contrib \
- doc \
- examples \
- $(libarchive_EXTRA_DIST) \
- $(libarchive_test_EXTRA_DIST) \
- $(bsdtar_EXTRA_DIST) \
- $(bsdtar_test_EXTRA_DIST) \
- $(bsdcpio_EXTRA_DIST) \
- $(bsdcpio_test_EXTRA_DIST)
+ CMakeLists.txt \
+ build/autogen.sh \
+ build/bump-version.sh \
+ build/clean.sh \
+ build/cmake \
+ build/version \
+ contrib \
+ doc \
+ examples \
+ $(libarchive_EXTRA_DIST) \
+ $(libarchive_test_EXTRA_DIST) \
+ $(bsdtar_EXTRA_DIST) \
+ $(bsdtar_test_EXTRA_DIST) \
+ $(bsdcpio_EXTRA_DIST) \
+ $(bsdcpio_test_EXTRA_DIST) \
+ $(bsdcat_EXTRA_DIST) \
+ $(bsdcat_test_EXTRA_DIST)
# a) Clean out some unneeded files and directories
# b) Collect all documentation and format it for distribution.
@@ -63,10 +64,11 @@ dist-hook:
#
# Extra rules for cleanup
#
-DISTCLEANFILES= \
- libarchive/test/list.h \
- tar/test/list.h \
- cpio/test/list.h
+DISTCLEANFILES= \
+ libarchive/test/list.h \
+ tar/test/list.h \
+ cpio/test/list.h \
+ cat/test/list.h
distclean-local:
-rm -rf .ref
@@ -78,6 +80,8 @@ distclean-local:
-[ -f tar/test/Makefile ] && cd tar/test && make clean
-[ -f cpio/Makefile ] && cd cpio && make clean
-[ -f cpio/test/Makefile ] && cd cpio/test && make clean
+ -[ -f cat/Makefile ] && cd cat && make clean
+ -[ -f cpio/test/Makefile ] && cd cat/test && make clean
#
# Libarchive headers, source, etc.
@@ -86,137 +90,157 @@ distclean-local:
include_HEADERS= libarchive/archive.h libarchive/archive_entry.h
-libarchive_la_SOURCES= \
- libarchive/archive_acl.c \
- libarchive/archive_acl_private.h \
- libarchive/archive_check_magic.c \
- libarchive/archive_cmdline.c \
- libarchive/archive_cmdline_private.h \
- libarchive/archive_crc32.h \
- libarchive/archive_crypto.c \
- libarchive/archive_crypto_private.h \
- libarchive/archive_endian.h \
- libarchive/archive_entry.c \
- libarchive/archive_entry.h \
- libarchive/archive_entry_copy_stat.c \
- libarchive/archive_entry_link_resolver.c \
- libarchive/archive_entry_locale.h \
- libarchive/archive_entry_private.h \
- libarchive/archive_entry_sparse.c \
- libarchive/archive_entry_stat.c \
- libarchive/archive_entry_strmode.c \
- libarchive/archive_entry_xattr.c \
- libarchive/archive_getdate.c \
- libarchive/archive_match.c \
- libarchive/archive_options.c \
- libarchive/archive_options_private.h \
- libarchive/archive_pathmatch.c \
- libarchive/archive_pathmatch.h \
- libarchive/archive_platform.h \
- libarchive/archive_ppmd_private.h \
- libarchive/archive_ppmd7.c \
- libarchive/archive_ppmd7_private.h \
- libarchive/archive_private.h \
- libarchive/archive_rb.c \
- libarchive/archive_rb.h \
- libarchive/archive_read.c \
- libarchive/archive_read_append_filter.c \
- libarchive/archive_read_data_into_fd.c \
- libarchive/archive_read_disk_entry_from_file.c \
- libarchive/archive_read_disk_posix.c \
- libarchive/archive_read_disk_private.h \
- libarchive/archive_read_disk_set_standard_lookup.c \
- libarchive/archive_read_extract.c \
- libarchive/archive_read_open_fd.c \
- libarchive/archive_read_open_file.c \
- libarchive/archive_read_open_filename.c \
- libarchive/archive_read_open_memory.c \
- libarchive/archive_read_private.h \
- libarchive/archive_read_set_format.c \
- libarchive/archive_read_set_options.c \
- libarchive/archive_read_support_filter_all.c \
- libarchive/archive_read_support_filter_bzip2.c \
- libarchive/archive_read_support_filter_compress.c \
- libarchive/archive_read_support_filter_grzip.c \
- libarchive/archive_read_support_filter_gzip.c \
- libarchive/archive_read_support_filter_lrzip.c \
- libarchive/archive_read_support_filter_lzop.c \
- libarchive/archive_read_support_filter_none.c \
- libarchive/archive_read_support_filter_program.c \
- libarchive/archive_read_support_filter_rpm.c \
- libarchive/archive_read_support_filter_uu.c \
- libarchive/archive_read_support_filter_xz.c \
- libarchive/archive_read_support_format_7zip.c \
- libarchive/archive_read_support_format_all.c \
- libarchive/archive_read_support_format_ar.c \
- libarchive/archive_read_support_format_by_code.c \
- libarchive/archive_read_support_format_cab.c \
- libarchive/archive_read_support_format_cpio.c \
- libarchive/archive_read_support_format_empty.c \
- libarchive/archive_read_support_format_iso9660.c \
- libarchive/archive_read_support_format_lha.c \
- libarchive/archive_read_support_format_mtree.c \
- libarchive/archive_read_support_format_rar.c \
- libarchive/archive_read_support_format_raw.c \
- libarchive/archive_read_support_format_tar.c \
- libarchive/archive_read_support_format_xar.c \
- libarchive/archive_read_support_format_zip.c \
- libarchive/archive_string.c \
- libarchive/archive_string.h \
- libarchive/archive_string_composition.h \
- libarchive/archive_string_sprintf.c \
- libarchive/archive_util.c \
- libarchive/archive_virtual.c \
- libarchive/archive_write.c \
- libarchive/archive_write_disk_acl.c \
- libarchive/archive_write_disk_posix.c \
- libarchive/archive_write_disk_private.h \
- libarchive/archive_write_disk_set_standard_lookup.c \
- libarchive/archive_write_open_fd.c \
- libarchive/archive_write_open_file.c \
- libarchive/archive_write_open_filename.c \
- libarchive/archive_write_open_memory.c \
- libarchive/archive_write_private.h \
- libarchive/archive_write_add_filter.c \
- libarchive/archive_write_add_filter_b64encode.c \
- libarchive/archive_write_add_filter_by_name.c \
- libarchive/archive_write_add_filter_bzip2.c \
- libarchive/archive_write_add_filter_compress.c \
- libarchive/archive_write_add_filter_grzip.c \
- libarchive/archive_write_add_filter_gzip.c \
- libarchive/archive_write_add_filter_lrzip.c \
- libarchive/archive_write_add_filter_lzop.c \
- libarchive/archive_write_add_filter_none.c \
- libarchive/archive_write_add_filter_program.c \
- libarchive/archive_write_add_filter_uuencode.c \
- libarchive/archive_write_add_filter_xz.c \
- libarchive/archive_write_set_format.c \
- libarchive/archive_write_set_format_7zip.c \
- libarchive/archive_write_set_format_ar.c \
- libarchive/archive_write_set_format_by_name.c \
- libarchive/archive_write_set_format_cpio.c \
- libarchive/archive_write_set_format_cpio_newc.c \
- libarchive/archive_write_set_format_iso9660.c \
- libarchive/archive_write_set_format_mtree.c \
- libarchive/archive_write_set_format_pax.c \
- libarchive/archive_write_set_format_shar.c \
- libarchive/archive_write_set_format_ustar.c \
- libarchive/archive_write_set_format_v7tar.c \
- libarchive/archive_write_set_format_gnutar.c \
- libarchive/archive_write_set_format_xar.c \
- libarchive/archive_write_set_format_zip.c \
- libarchive/archive_write_set_options.c \
- libarchive/config_freebsd.h \
- libarchive/filter_fork_posix.c \
- libarchive/filter_fork.h
+libarchive_la_SOURCES= \
+ libarchive/archive_acl.c \
+ libarchive/archive_acl_private.h \
+ libarchive/archive_check_magic.c \
+ libarchive/archive_cmdline.c \
+ libarchive/archive_cmdline_private.h \
+ libarchive/archive_crc32.h \
+ libarchive/archive_cryptor.c \
+ libarchive/archive_cryptor_private.h \
+ libarchive/archive_digest.c \
+ libarchive/archive_digest_private.h \
+ libarchive/archive_endian.h \
+ libarchive/archive_entry.c \
+ libarchive/archive_entry.h \
+ libarchive/archive_entry_copy_stat.c \
+ libarchive/archive_entry_link_resolver.c \
+ libarchive/archive_entry_locale.h \
+ libarchive/archive_entry_private.h \
+ libarchive/archive_entry_sparse.c \
+ libarchive/archive_entry_stat.c \
+ libarchive/archive_entry_strmode.c \
+ libarchive/archive_entry_xattr.c \
+ libarchive/archive_getdate.c \
+ libarchive/archive_getdate.h \
+ libarchive/archive_hmac.c \
+ libarchive/archive_hmac_private.h \
+ libarchive/archive_match.c \
+ libarchive/archive_options.c \
+ libarchive/archive_options_private.h \
+ libarchive/archive_pack_dev.h \
+ libarchive/archive_pack_dev.c \
+ libarchive/archive_pathmatch.c \
+ libarchive/archive_pathmatch.h \
+ libarchive/archive_platform.h \
+ libarchive/archive_ppmd_private.h \
+ libarchive/archive_ppmd7.c \
+ libarchive/archive_ppmd7_private.h \
+ libarchive/archive_private.h \
+ libarchive/archive_random.c \
+ libarchive/archive_random_private.h \
+ libarchive/archive_rb.c \
+ libarchive/archive_rb.h \
+ libarchive/archive_read.c \
+ libarchive/archive_read_add_passphrase.c \
+ libarchive/archive_read_append_filter.c \
+ libarchive/archive_read_data_into_fd.c \
+ libarchive/archive_read_disk_entry_from_file.c \
+ libarchive/archive_read_disk_posix.c \
+ libarchive/archive_read_disk_private.h \
+ libarchive/archive_read_disk_set_standard_lookup.c \
+ libarchive/archive_read_extract.c \
+ libarchive/archive_read_extract2.c \
+ libarchive/archive_read_open_fd.c \
+ libarchive/archive_read_open_file.c \
+ libarchive/archive_read_open_filename.c \
+ libarchive/archive_read_open_memory.c \
+ libarchive/archive_read_private.h \
+ libarchive/archive_read_set_format.c \
+ libarchive/archive_read_set_options.c \
+ libarchive/archive_read_support_filter_all.c \
+ libarchive/archive_read_support_filter_bzip2.c \
+ libarchive/archive_read_support_filter_compress.c \
+ libarchive/archive_read_support_filter_grzip.c \
+ libarchive/archive_read_support_filter_gzip.c \
+ libarchive/archive_read_support_filter_lrzip.c \
+ libarchive/archive_read_support_filter_lz4.c \
+ libarchive/archive_read_support_filter_lzop.c \
+ libarchive/archive_read_support_filter_none.c \
+ libarchive/archive_read_support_filter_program.c \
+ libarchive/archive_read_support_filter_rpm.c \
+ libarchive/archive_read_support_filter_uu.c \
+ libarchive/archive_read_support_filter_xz.c \
+ libarchive/archive_read_support_format_7zip.c \
+ libarchive/archive_read_support_format_all.c \
+ libarchive/archive_read_support_format_ar.c \
+ libarchive/archive_read_support_format_by_code.c \
+ libarchive/archive_read_support_format_cab.c \
+ libarchive/archive_read_support_format_cpio.c \
+ libarchive/archive_read_support_format_empty.c \
+ libarchive/archive_read_support_format_iso9660.c \
+ libarchive/archive_read_support_format_lha.c \
+ libarchive/archive_read_support_format_mtree.c \
+ libarchive/archive_read_support_format_rar.c \
+ libarchive/archive_read_support_format_raw.c \
+ libarchive/archive_read_support_format_tar.c \
+ libarchive/archive_read_support_format_warc.c \
+ libarchive/archive_read_support_format_xar.c \
+ libarchive/archive_read_support_format_zip.c \
+ libarchive/archive_string.c \
+ libarchive/archive_string.h \
+ libarchive/archive_string_composition.h \
+ libarchive/archive_string_sprintf.c \
+ libarchive/archive_util.c \
+ libarchive/archive_virtual.c \
+ libarchive/archive_write.c \
+ libarchive/archive_write_disk_acl.c \
+ libarchive/archive_write_disk_posix.c \
+ libarchive/archive_write_disk_private.h \
+ libarchive/archive_write_disk_set_standard_lookup.c \
+ libarchive/archive_write_open_fd.c \
+ libarchive/archive_write_open_file.c \
+ libarchive/archive_write_open_filename.c \
+ libarchive/archive_write_open_memory.c \
+ libarchive/archive_write_private.h \
+ libarchive/archive_write_add_filter.c \
+ libarchive/archive_write_add_filter_b64encode.c \
+ libarchive/archive_write_add_filter_by_name.c \
+ libarchive/archive_write_add_filter_bzip2.c \
+ libarchive/archive_write_add_filter_compress.c \
+ libarchive/archive_write_add_filter_grzip.c \
+ libarchive/archive_write_add_filter_gzip.c \
+ libarchive/archive_write_add_filter_lrzip.c \
+ libarchive/archive_write_add_filter_lz4.c \
+ libarchive/archive_write_add_filter_lzop.c \
+ libarchive/archive_write_add_filter_none.c \
+ libarchive/archive_write_add_filter_program.c \
+ libarchive/archive_write_add_filter_uuencode.c \
+ libarchive/archive_write_add_filter_xz.c \
+ libarchive/archive_write_set_format.c \
+ libarchive/archive_write_set_format_7zip.c \
+ libarchive/archive_write_set_format_ar.c \
+ libarchive/archive_write_set_format_by_name.c \
+ libarchive/archive_write_set_format_cpio.c \
+ libarchive/archive_write_set_format_cpio_newc.c \
+ libarchive/archive_write_set_format_filter_by_ext.c \
+ libarchive/archive_write_set_format_iso9660.c \
+ libarchive/archive_write_set_format_mtree.c \
+ libarchive/archive_write_set_format_pax.c \
+ libarchive/archive_write_set_format_raw.c \
+ libarchive/archive_write_set_format_shar.c \
+ libarchive/archive_write_set_format_ustar.c \
+ libarchive/archive_write_set_format_v7tar.c \
+ libarchive/archive_write_set_format_gnutar.c \
+ libarchive/archive_write_set_format_warc.c \
+ libarchive/archive_write_set_format_xar.c \
+ libarchive/archive_write_set_format_zip.c \
+ libarchive/archive_write_set_options.c \
+ libarchive/archive_write_set_passphrase.c \
+ libarchive/archive_xxhash.h \
+ libarchive/config_freebsd.h \
+ libarchive/filter_fork_posix.c \
+ libarchive/filter_fork.h \
+ libarchive/xxhash.c
if INC_WINDOWS_FILES
-libarchive_la_SOURCES+= \
- libarchive/archive_entry_copy_bhfi.c \
- libarchive/archive_read_disk_windows.c \
- libarchive/archive_windows.h \
- libarchive/archive_windows.c \
- libarchive/archive_write_disk_windows.c \
+libarchive_la_SOURCES+= \
+ libarchive/archive_entry_copy_bhfi.c \
+ libarchive/archive_read_disk_windows.c \
+ libarchive/archive_windows.h \
+ libarchive/archive_windows.c \
+ libarchive/archive_write_disk_windows.c \
libarchive/filter_fork_windows.c
endif
@@ -226,52 +250,54 @@ libarchive_la_LDFLAGS= -no-undefined -version-info $(ARCHIVE_LIBTOOL_VERSION)
libarchive_la_LIBADD= $(LTLIBICONV)
# Manpages to install
-libarchive_man_MANS= \
- libarchive/archive_entry.3 \
- libarchive/archive_entry_acl.3 \
- libarchive/archive_entry_linkify.3 \
- libarchive/archive_entry_paths.3 \
- libarchive/archive_entry_perms.3 \
- libarchive/archive_entry_stat.3 \
- libarchive/archive_entry_time.3 \
- libarchive/archive_read.3 \
- libarchive/archive_read_data.3 \
- libarchive/archive_read_disk.3 \
- libarchive/archive_read_extract.3 \
- libarchive/archive_read_filter.3 \
- libarchive/archive_read_format.3 \
- libarchive/archive_read_free.3 \
- libarchive/archive_read_header.3 \
- libarchive/archive_read_new.3 \
- libarchive/archive_read_open.3 \
- libarchive/archive_read_set_options.3 \
- libarchive/archive_util.3 \
- libarchive/archive_write.3 \
- libarchive/archive_write_blocksize.3 \
- libarchive/archive_write_data.3 \
- libarchive/archive_write_disk.3 \
- libarchive/archive_write_filter.3 \
- libarchive/archive_write_finish_entry.3 \
- libarchive/archive_write_format.3 \
- libarchive/archive_write_free.3 \
- libarchive/archive_write_header.3 \
- libarchive/archive_write_new.3 \
- libarchive/archive_write_open.3 \
- libarchive/archive_write_set_options.3 \
- libarchive/cpio.5 \
- libarchive/libarchive.3 \
- libarchive/libarchive_changes.3 \
- libarchive/libarchive_internals.3 \
- libarchive/libarchive-formats.5 \
- libarchive/mtree.5 \
+libarchive_man_MANS= \
+ libarchive/archive_entry.3 \
+ libarchive/archive_entry_acl.3 \
+ libarchive/archive_entry_linkify.3 \
+ libarchive/archive_entry_paths.3 \
+ libarchive/archive_entry_perms.3 \
+ libarchive/archive_entry_stat.3 \
+ libarchive/archive_entry_time.3 \
+ libarchive/archive_read.3 \
+ libarchive/archive_read_add_passphrase.3 \
+ libarchive/archive_read_data.3 \
+ libarchive/archive_read_disk.3 \
+ libarchive/archive_read_extract.3 \
+ libarchive/archive_read_filter.3 \
+ libarchive/archive_read_format.3 \
+ libarchive/archive_read_free.3 \
+ libarchive/archive_read_header.3 \
+ libarchive/archive_read_new.3 \
+ libarchive/archive_read_open.3 \
+ libarchive/archive_read_set_options.3 \
+ libarchive/archive_util.3 \
+ libarchive/archive_write.3 \
+ libarchive/archive_write_blocksize.3 \
+ libarchive/archive_write_data.3 \
+ libarchive/archive_write_disk.3 \
+ libarchive/archive_write_filter.3 \
+ libarchive/archive_write_finish_entry.3 \
+ libarchive/archive_write_format.3 \
+ libarchive/archive_write_free.3 \
+ libarchive/archive_write_header.3 \
+ libarchive/archive_write_new.3 \
+ libarchive/archive_write_open.3 \
+ libarchive/archive_write_set_options.3 \
+ libarchive/archive_write_set_passphrase.3 \
+ libarchive/cpio.5 \
+ libarchive/libarchive.3 \
+ libarchive/libarchive_changes.3 \
+ libarchive/libarchive_internals.3 \
+ libarchive/libarchive-formats.5 \
+ libarchive/mtree.5 \
libarchive/tar.5
# Additional libarchive files to include in the distribution
-libarchive_EXTRA_DIST= \
- libarchive/archive_windows.c \
- libarchive/archive_windows.h \
- libarchive/filter_fork_windows.c \
- libarchive/CMakeLists.txt \
+libarchive_EXTRA_DIST= \
+ libarchive/archive_windows.c \
+ libarchive/archive_windows.h \
+ libarchive/filter_fork_windows.c \
+ libarchive/CMakeLists.txt \
$(libarchive_man_MANS)
# pkgconfig
@@ -288,217 +314,260 @@ test_utils_SOURCES= \
# libarchive_test program
#
#
-libarchive_test_SOURCES= \
- $(libarchive_la_SOURCES) \
- $(test_utils_SOURCES) \
- libarchive/test/main.c \
- libarchive/test/read_open_memory.c \
- libarchive/test/test.h \
- libarchive/test/test_acl_freebsd_posix1e.c \
- libarchive/test/test_acl_freebsd_nfs4.c \
- libarchive/test/test_acl_nfs4.c \
- libarchive/test/test_acl_pax.c \
- libarchive/test/test_acl_posix1e.c \
- libarchive/test/test_archive_api_feature.c \
- libarchive/test/test_archive_clear_error.c \
- libarchive/test/test_archive_cmdline.c \
- libarchive/test/test_archive_crypto.c \
- libarchive/test/test_archive_getdate.c \
- libarchive/test/test_archive_match_owner.c \
- libarchive/test/test_archive_match_path.c \
- libarchive/test/test_archive_match_time.c \
- libarchive/test/test_archive_pathmatch.c \
- libarchive/test/test_archive_read_close_twice.c \
- libarchive/test/test_archive_read_close_twice_open_fd.c \
- libarchive/test/test_archive_read_close_twice_open_filename.c \
- libarchive/test/test_archive_read_multiple_data_objects.c \
- libarchive/test/test_archive_read_next_header_empty.c \
- libarchive/test/test_archive_read_next_header_raw.c \
- libarchive/test/test_archive_read_open2.c \
- libarchive/test/test_archive_read_set_filter_option.c \
- libarchive/test/test_archive_read_set_format_option.c \
- libarchive/test/test_archive_read_set_option.c \
- libarchive/test/test_archive_read_set_options.c \
- libarchive/test/test_archive_read_support.c \
- libarchive/test/test_archive_set_error.c \
- libarchive/test/test_archive_string.c \
- libarchive/test/test_archive_string_conversion.c \
- libarchive/test/test_archive_write_add_filter_by_name.c \
- libarchive/test/test_archive_write_set_filter_option.c \
- libarchive/test/test_archive_write_set_format_by_name.c \
- libarchive/test/test_archive_write_set_format_option.c \
- libarchive/test/test_archive_write_set_option.c \
- libarchive/test/test_archive_write_set_options.c \
- libarchive/test/test_bad_fd.c \
- libarchive/test/test_compat_bzip2.c \
- libarchive/test/test_compat_cpio.c \
- libarchive/test/test_compat_gtar.c \
- libarchive/test/test_compat_gzip.c \
- libarchive/test/test_compat_lzip.c \
- libarchive/test/test_compat_lzma.c \
- libarchive/test/test_compat_lzop.c \
- libarchive/test/test_compat_mac.c \
- libarchive/test/test_compat_pax_libarchive_2x.c \
- libarchive/test/test_compat_solaris_tar_acl.c \
- libarchive/test/test_compat_solaris_pax_sparse.c \
- libarchive/test/test_compat_tar_hardlink.c \
- libarchive/test/test_compat_uudecode.c \
- libarchive/test/test_compat_xz.c \
- libarchive/test/test_compat_zip.c \
- libarchive/test/test_empty_write.c \
- libarchive/test/test_entry.c \
- libarchive/test/test_entry_strmode.c \
- libarchive/test/test_extattr_freebsd.c \
- libarchive/test/test_filter_count.c \
- libarchive/test/test_fuzz.c \
- libarchive/test/test_gnutar_filename_encoding.c \
- libarchive/test/test_link_resolver.c \
- libarchive/test/test_open_failure.c \
- libarchive/test/test_open_fd.c \
- libarchive/test/test_open_file.c \
- libarchive/test/test_open_filename.c \
- libarchive/test/test_pax_filename_encoding.c \
- libarchive/test/test_read_data_large.c \
- libarchive/test/test_read_disk.c \
- libarchive/test/test_read_disk_directory_traversals.c \
- libarchive/test/test_read_disk_entry_from_file.c \
- libarchive/test/test_read_extract.c \
- libarchive/test/test_read_file_nonexistent.c \
- libarchive/test/test_read_filter_grzip.c \
- libarchive/test/test_read_filter_lrzip.c \
- libarchive/test/test_read_filter_lzop.c \
- libarchive/test/test_read_filter_lzop_multiple_parts.c \
- libarchive/test/test_read_filter_program.c \
- libarchive/test/test_read_filter_program_signature.c \
- libarchive/test/test_read_filter_uudecode.c \
- libarchive/test/test_read_format_7zip.c \
- libarchive/test/test_read_format_ar.c \
- libarchive/test/test_read_format_cab.c \
- libarchive/test/test_read_format_cab_filename.c \
- libarchive/test/test_read_format_cpio_afio.c \
- libarchive/test/test_read_format_cpio_bin.c \
- libarchive/test/test_read_format_cpio_bin_Z.c \
- libarchive/test/test_read_format_cpio_bin_be.c \
- libarchive/test/test_read_format_cpio_bin_bz2.c \
- libarchive/test/test_read_format_cpio_bin_gz.c \
- libarchive/test/test_read_format_cpio_bin_lzip.c \
- libarchive/test/test_read_format_cpio_bin_lzma.c \
- libarchive/test/test_read_format_cpio_bin_xz.c \
- libarchive/test/test_read_format_cpio_filename.c \
- libarchive/test/test_read_format_cpio_odc.c \
- libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c \
- libarchive/test/test_read_format_cpio_svr4_gzip.c \
- libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c \
- libarchive/test/test_read_format_cpio_svr4c_Z.c \
- libarchive/test/test_read_format_empty.c \
- libarchive/test/test_read_format_gtar_filename.c \
- libarchive/test/test_read_format_gtar_gz.c \
- libarchive/test/test_read_format_gtar_lzma.c \
- libarchive/test/test_read_format_gtar_sparse.c \
- libarchive/test/test_read_format_iso_Z.c \
- libarchive/test/test_read_format_iso_multi_extent.c \
- libarchive/test/test_read_format_iso_xorriso.c \
- libarchive/test/test_read_format_isojoliet_bz2.c \
- libarchive/test/test_read_format_isojoliet_long.c \
- libarchive/test/test_read_format_isojoliet_rr.c \
- libarchive/test/test_read_format_isojoliet_versioned.c \
- libarchive/test/test_read_format_isorr_bz2.c \
- libarchive/test/test_read_format_isorr_ce.c \
- libarchive/test/test_read_format_isorr_new_bz2.c \
- libarchive/test/test_read_format_isorr_rr_moved.c \
- libarchive/test/test_read_format_isozisofs_bz2.c \
- libarchive/test/test_read_format_lha.c \
- libarchive/test/test_read_format_lha_filename.c \
- libarchive/test/test_read_format_mtree.c \
- libarchive/test/test_read_format_pax_bz2.c \
- libarchive/test/test_read_format_rar.c \
- libarchive/test/test_read_format_raw.c \
- libarchive/test/test_read_format_tar.c \
- libarchive/test/test_read_format_tar_empty_filename.c \
- libarchive/test/test_read_format_tar_filename.c \
- libarchive/test/test_read_format_tbz.c \
- libarchive/test/test_read_format_tgz.c \
- libarchive/test/test_read_format_tlz.c \
- libarchive/test/test_read_format_txz.c \
- libarchive/test/test_read_format_tz.c \
- libarchive/test/test_read_format_ustar_filename.c \
- libarchive/test/test_read_format_xar.c \
- libarchive/test/test_read_format_zip.c \
- libarchive/test/test_read_format_zip_comment_stored.c \
- libarchive/test/test_read_format_zip_filename.c \
- libarchive/test/test_read_format_zip_mac_metadata.c \
- libarchive/test/test_read_format_zip_sfx.c \
- libarchive/test/test_read_large.c \
- libarchive/test/test_read_pax_truncated.c \
- libarchive/test/test_read_position.c \
- libarchive/test/test_read_set_format.c \
- libarchive/test/test_read_truncated.c \
- libarchive/test/test_read_truncated_filter.c \
- libarchive/test/test_sparse_basic.c \
- libarchive/test/test_tar_filenames.c \
- libarchive/test/test_tar_large.c \
- libarchive/test/test_ustar_filenames.c \
- libarchive/test/test_ustar_filename_encoding.c \
- libarchive/test/test_write_disk.c \
- libarchive/test/test_write_disk_appledouble.c \
- libarchive/test/test_write_disk_failures.c \
- libarchive/test/test_write_disk_hardlink.c \
- libarchive/test/test_write_disk_hfs_compression.c \
- libarchive/test/test_write_disk_lookup.c \
- libarchive/test/test_write_disk_mac_metadata.c \
- libarchive/test/test_write_disk_no_hfs_compression.c \
- libarchive/test/test_write_disk_perms.c \
- libarchive/test/test_write_disk_secure.c \
- libarchive/test/test_write_disk_sparse.c \
- libarchive/test/test_write_disk_symlink.c \
- libarchive/test/test_write_disk_times.c \
- libarchive/test/test_write_filter_b64encode.c \
- libarchive/test/test_write_filter_bzip2.c \
- libarchive/test/test_write_filter_compress.c \
- libarchive/test/test_write_filter_gzip.c \
- libarchive/test/test_write_filter_gzip_timestamp.c \
- libarchive/test/test_write_filter_lrzip.c \
- libarchive/test/test_write_filter_lzip.c \
- libarchive/test/test_write_filter_lzma.c \
- libarchive/test/test_write_filter_lzop.c \
- libarchive/test/test_write_filter_program.c \
- libarchive/test/test_write_filter_uuencode.c \
- libarchive/test/test_write_filter_xz.c \
- libarchive/test/test_write_format_7zip.c \
- libarchive/test/test_write_format_7zip_empty.c \
- libarchive/test/test_write_format_7zip_large.c \
- libarchive/test/test_write_format_ar.c \
- libarchive/test/test_write_format_cpio.c \
- libarchive/test/test_write_format_cpio_empty.c \
- libarchive/test/test_write_format_cpio_newc.c \
- libarchive/test/test_write_format_cpio_odc.c \
- libarchive/test/test_write_format_gnutar.c \
- libarchive/test/test_write_format_iso9660.c \
- libarchive/test/test_write_format_iso9660_boot.c \
- libarchive/test/test_write_format_iso9660_empty.c \
- libarchive/test/test_write_format_iso9660_filename.c \
- libarchive/test/test_write_format_iso9660_zisofs.c \
- libarchive/test/test_write_format_mtree.c \
- libarchive/test/test_write_format_mtree_absolute_path.c \
- libarchive/test/test_write_format_mtree_classic.c \
+libarchive_test_SOURCES= \
+ $(libarchive_la_SOURCES) \
+ $(test_utils_SOURCES) \
+ libarchive/test/main.c \
+ libarchive/test/read_open_memory.c \
+ libarchive/test/test.h \
+ libarchive/test/test_acl_freebsd_posix1e.c \
+ libarchive/test/test_acl_freebsd_nfs4.c \
+ libarchive/test/test_acl_nfs4.c \
+ libarchive/test/test_acl_pax.c \
+ libarchive/test/test_acl_posix1e.c \
+ libarchive/test/test_archive_api_feature.c \
+ libarchive/test/test_archive_clear_error.c \
+ libarchive/test/test_archive_cmdline.c \
+ libarchive/test/test_archive_digest.c \
+ libarchive/test/test_archive_getdate.c \
+ libarchive/test/test_archive_match_owner.c \
+ libarchive/test/test_archive_match_path.c \
+ libarchive/test/test_archive_match_time.c \
+ libarchive/test/test_archive_pathmatch.c \
+ libarchive/test/test_archive_read_add_passphrase.c \
+ libarchive/test/test_archive_read_close_twice.c \
+ libarchive/test/test_archive_read_close_twice_open_fd.c \
+ libarchive/test/test_archive_read_close_twice_open_filename.c \
+ libarchive/test/test_archive_read_multiple_data_objects.c \
+ libarchive/test/test_archive_read_next_header_empty.c \
+ libarchive/test/test_archive_read_next_header_raw.c \
+ libarchive/test/test_archive_read_open2.c \
+ libarchive/test/test_archive_read_set_filter_option.c \
+ libarchive/test/test_archive_read_set_format_option.c \
+ libarchive/test/test_archive_read_set_option.c \
+ libarchive/test/test_archive_read_set_options.c \
+ libarchive/test/test_archive_read_support.c \
+ libarchive/test/test_archive_set_error.c \
+ libarchive/test/test_archive_string.c \
+ libarchive/test/test_archive_string_conversion.c \
+ libarchive/test/test_archive_write_add_filter_by_name.c \
+ libarchive/test/test_archive_write_set_filter_option.c \
+ libarchive/test/test_archive_write_set_format_by_name.c \
+ libarchive/test/test_archive_write_set_format_filter_by_ext.c \
+ libarchive/test/test_archive_write_set_format_option.c \
+ libarchive/test/test_archive_write_set_option.c \
+ libarchive/test/test_archive_write_set_options.c \
+ libarchive/test/test_archive_write_set_passphrase.c \
+ libarchive/test/test_bad_fd.c \
+ libarchive/test/test_compat_bzip2.c \
+ libarchive/test/test_compat_cpio.c \
+ libarchive/test/test_compat_gtar.c \
+ libarchive/test/test_compat_gzip.c \
+ libarchive/test/test_compat_lz4.c \
+ libarchive/test/test_compat_lzip.c \
+ libarchive/test/test_compat_lzma.c \
+ libarchive/test/test_compat_lzop.c \
+ libarchive/test/test_compat_mac.c \
+ libarchive/test/test_compat_pax_libarchive_2x.c \
+ libarchive/test/test_compat_solaris_tar_acl.c \
+ libarchive/test/test_compat_solaris_pax_sparse.c \
+ libarchive/test/test_compat_tar_hardlink.c \
+ libarchive/test/test_compat_uudecode.c \
+ libarchive/test/test_compat_uudecode_large.c \
+ libarchive/test/test_compat_xz.c \
+ libarchive/test/test_compat_zip.c \
+ libarchive/test/test_empty_write.c \
+ libarchive/test/test_entry.c \
+ libarchive/test/test_entry_strmode.c \
+ libarchive/test/test_extattr_freebsd.c \
+ libarchive/test/test_filter_count.c \
+ libarchive/test/test_fuzz.c \
+ libarchive/test/test_gnutar_filename_encoding.c \
+ libarchive/test/test_link_resolver.c \
+ libarchive/test/test_open_failure.c \
+ libarchive/test/test_open_fd.c \
+ libarchive/test/test_open_file.c \
+ libarchive/test/test_open_filename.c \
+ libarchive/test/test_pax_filename_encoding.c \
+ libarchive/test/test_read_data_large.c \
+ libarchive/test/test_read_disk.c \
+ libarchive/test/test_read_disk_directory_traversals.c \
+ libarchive/test/test_read_disk_entry_from_file.c \
+ libarchive/test/test_read_extract.c \
+ libarchive/test/test_read_file_nonexistent.c \
+ libarchive/test/test_read_filter_compress.c \
+ libarchive/test/test_read_filter_grzip.c \
+ libarchive/test/test_read_filter_lrzip.c \
+ libarchive/test/test_read_filter_lzop.c \
+ libarchive/test/test_read_filter_lzop_multiple_parts.c \
+ libarchive/test/test_read_filter_program.c \
+ libarchive/test/test_read_filter_program_signature.c \
+ libarchive/test/test_read_filter_uudecode.c \
+ libarchive/test/test_read_format_7zip.c \
+ libarchive/test/test_read_format_7zip_encryption_data.c \
+ libarchive/test/test_read_format_7zip_encryption_partially.c \
+ libarchive/test/test_read_format_7zip_encryption_header.c \
+ libarchive/test/test_read_format_7zip_malformed.c \
+ libarchive/test/test_read_format_ar.c \
+ libarchive/test/test_read_format_cab.c \
+ libarchive/test/test_read_format_cab_filename.c \
+ libarchive/test/test_read_format_cpio_afio.c \
+ libarchive/test/test_read_format_cpio_bin.c \
+ libarchive/test/test_read_format_cpio_bin_Z.c \
+ libarchive/test/test_read_format_cpio_bin_be.c \
+ libarchive/test/test_read_format_cpio_bin_bz2.c \
+ libarchive/test/test_read_format_cpio_bin_gz.c \
+ libarchive/test/test_read_format_cpio_bin_le.c \
+ libarchive/test/test_read_format_cpio_bin_lzip.c \
+ libarchive/test/test_read_format_cpio_bin_lzma.c \
+ libarchive/test/test_read_format_cpio_bin_xz.c \
+ libarchive/test/test_read_format_cpio_filename.c \
+ libarchive/test/test_read_format_cpio_odc.c \
+ libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c \
+ libarchive/test/test_read_format_cpio_svr4_gzip.c \
+ libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c \
+ libarchive/test/test_read_format_cpio_svr4c_Z.c \
+ libarchive/test/test_read_format_empty.c \
+ libarchive/test/test_read_format_gtar_filename.c \
+ libarchive/test/test_read_format_gtar_gz.c \
+ libarchive/test/test_read_format_gtar_lzma.c \
+ libarchive/test/test_read_format_gtar_sparse.c \
+ libarchive/test/test_read_format_gtar_sparse_skip_entry.c \
+ libarchive/test/test_read_format_iso_Z.c \
+ libarchive/test/test_read_format_iso_multi_extent.c \
+ libarchive/test/test_read_format_iso_xorriso.c \
+ libarchive/test/test_read_format_isojoliet_bz2.c \
+ libarchive/test/test_read_format_isojoliet_long.c \
+ libarchive/test/test_read_format_isojoliet_rr.c \
+ libarchive/test/test_read_format_isojoliet_versioned.c \
+ libarchive/test/test_read_format_isorr_bz2.c \
+ libarchive/test/test_read_format_isorr_ce.c \
+ libarchive/test/test_read_format_isorr_new_bz2.c \
+ libarchive/test/test_read_format_isorr_rr_moved.c \
+ libarchive/test/test_read_format_isozisofs_bz2.c \
+ libarchive/test/test_read_format_lha.c \
+ libarchive/test/test_read_format_lha_bugfix_0.c \
+ libarchive/test/test_read_format_lha_filename.c \
+ libarchive/test/test_read_format_mtree.c \
+ libarchive/test/test_read_format_pax_bz2.c \
+ libarchive/test/test_read_format_rar.c \
+ libarchive/test/test_read_format_rar_encryption_data.c \
+ libarchive/test/test_read_format_rar_encryption_partially.c \
+ libarchive/test/test_read_format_rar_encryption_header.c \
+ libarchive/test/test_read_format_raw.c \
+ libarchive/test/test_read_format_tar.c \
+ libarchive/test/test_read_format_tar_concatenated.c \
+ libarchive/test/test_read_format_tar_empty_pax.c \
+ libarchive/test/test_read_format_tar_empty_filename.c \
+ libarchive/test/test_read_format_tar_filename.c \
+ libarchive/test/test_read_format_tbz.c \
+ libarchive/test/test_read_format_tgz.c \
+ libarchive/test/test_read_format_tlz.c \
+ libarchive/test/test_read_format_txz.c \
+ libarchive/test/test_read_format_tz.c \
+ libarchive/test/test_read_format_ustar_filename.c \
+ libarchive/test/test_read_format_warc.c \
+ libarchive/test/test_read_format_xar.c \
+ libarchive/test/test_read_format_zip.c \
+ libarchive/test/test_read_format_zip_comment_stored.c \
+ libarchive/test/test_read_format_zip_encryption_data.c \
+ libarchive/test/test_read_format_zip_encryption_partially.c \
+ libarchive/test/test_read_format_zip_encryption_header.c \
+ libarchive/test/test_read_format_zip_filename.c \
+ libarchive/test/test_read_format_zip_mac_metadata.c \
+ libarchive/test/test_read_format_zip_malformed.c \
+ libarchive/test/test_read_format_zip_msdos.c \
+ libarchive/test/test_read_format_zip_nested.c \
+ libarchive/test/test_read_format_zip_nofiletype.c \
+ libarchive/test/test_read_format_zip_padded.c \
+ libarchive/test/test_read_format_zip_sfx.c \
+ libarchive/test/test_read_format_zip_traditional_encryption_data.c \
+ libarchive/test/test_read_format_zip_winzip_aes.c \
+ libarchive/test/test_read_format_zip_winzip_aes_large.c \
+ libarchive/test/test_read_format_zip_zip64.c \
+ libarchive/test/test_read_large.c \
+ libarchive/test/test_read_pax_truncated.c \
+ libarchive/test/test_read_position.c \
+ libarchive/test/test_read_set_format.c \
+ libarchive/test/test_read_too_many_filters.c \
+ libarchive/test/test_read_truncated.c \
+ libarchive/test/test_read_truncated_filter.c \
+ libarchive/test/test_sparse_basic.c \
+ libarchive/test/test_tar_filenames.c \
+ libarchive/test/test_tar_large.c \
+ libarchive/test/test_ustar_filenames.c \
+ libarchive/test/test_ustar_filename_encoding.c \
+ libarchive/test/test_warn_missing_hardlink_target.c \
+ libarchive/test/test_write_disk.c \
+ libarchive/test/test_write_disk_appledouble.c \
+ libarchive/test/test_write_disk_failures.c \
+ libarchive/test/test_write_disk_hardlink.c \
+ libarchive/test/test_write_disk_hfs_compression.c \
+ libarchive/test/test_write_disk_lookup.c \
+ libarchive/test/test_write_disk_mac_metadata.c \
+ libarchive/test/test_write_disk_no_hfs_compression.c \
+ libarchive/test/test_write_disk_perms.c \
+ libarchive/test/test_write_disk_secure.c \
+ libarchive/test/test_write_disk_sparse.c \
+ libarchive/test/test_write_disk_symlink.c \
+ libarchive/test/test_write_disk_times.c \
+ libarchive/test/test_write_filter_b64encode.c \
+ libarchive/test/test_write_filter_bzip2.c \
+ libarchive/test/test_write_filter_compress.c \
+ libarchive/test/test_write_filter_gzip.c \
+ libarchive/test/test_write_filter_gzip_timestamp.c \
+ libarchive/test/test_write_filter_lrzip.c \
+ libarchive/test/test_write_filter_lz4.c \
+ libarchive/test/test_write_filter_lzip.c \
+ libarchive/test/test_write_filter_lzma.c \
+ libarchive/test/test_write_filter_lzop.c \
+ libarchive/test/test_write_filter_program.c \
+ libarchive/test/test_write_filter_uuencode.c \
+ libarchive/test/test_write_filter_xz.c \
+ libarchive/test/test_write_format_7zip.c \
+ libarchive/test/test_write_format_7zip_empty.c \
+ libarchive/test/test_write_format_7zip_large.c \
+ libarchive/test/test_write_format_ar.c \
+ libarchive/test/test_write_format_cpio.c \
+ libarchive/test/test_write_format_cpio_empty.c \
+ libarchive/test/test_write_format_cpio_newc.c \
+ libarchive/test/test_write_format_cpio_odc.c \
+ libarchive/test/test_write_format_gnutar.c \
+ libarchive/test/test_write_format_iso9660.c \
+ libarchive/test/test_write_format_iso9660_boot.c \
+ libarchive/test/test_write_format_iso9660_empty.c \
+ libarchive/test/test_write_format_iso9660_filename.c \
+ libarchive/test/test_write_format_iso9660_zisofs.c \
+ libarchive/test/test_write_format_mtree.c \
+ libarchive/test/test_write_format_mtree_absolute_path.c \
+ libarchive/test/test_write_format_mtree_classic.c \
libarchive/test/test_write_format_mtree_classic_indent.c\
- libarchive/test/test_write_format_mtree_fflags.c \
- libarchive/test/test_write_format_mtree_no_separator.c \
+ libarchive/test/test_write_format_mtree_fflags.c \
+ libarchive/test/test_write_format_mtree_no_separator.c \
libarchive/test/test_write_format_mtree_quoted_filename.c\
- libarchive/test/test_write_format_pax.c \
- libarchive/test/test_write_format_shar_empty.c \
- libarchive/test/test_write_format_tar.c \
- libarchive/test/test_write_format_tar_empty.c \
- libarchive/test/test_write_format_tar_sparse.c \
- libarchive/test/test_write_format_tar_ustar.c \
- libarchive/test/test_write_format_tar_v7tar.c \
- libarchive/test/test_write_format_xar.c \
- libarchive/test/test_write_format_xar_empty.c \
- libarchive/test/test_write_format_zip.c \
- libarchive/test/test_write_format_zip_empty.c \
- libarchive/test/test_write_format_zip_no_compression.c \
- libarchive/test/test_write_open_memory.c \
- libarchive/test/test_write_zip_set_compression_store.c \
+ libarchive/test/test_write_format_pax.c \
+ libarchive/test/test_write_format_raw.c \
+ libarchive/test/test_write_format_raw_b64.c \
+ libarchive/test/test_write_format_shar_empty.c \
+ libarchive/test/test_write_format_tar.c \
+ libarchive/test/test_write_format_tar_empty.c \
+ libarchive/test/test_write_format_tar_sparse.c \
+ libarchive/test/test_write_format_tar_ustar.c \
+ libarchive/test/test_write_format_tar_v7tar.c \
+ libarchive/test/test_write_format_warc.c \
+ libarchive/test/test_write_format_warc_empty.c \
+ libarchive/test/test_write_format_xar.c \
+ libarchive/test/test_write_format_xar_empty.c \
+ libarchive/test/test_write_format_zip.c \
+ libarchive/test/test_write_format_zip_compression_store.c \
+ libarchive/test/test_write_format_zip_empty.c \
+ libarchive/test/test_write_format_zip_empty_zip64.c \
+ libarchive/test/test_write_format_zip_file.c \
+ libarchive/test/test_write_format_zip_file_zip64.c \
+ libarchive/test/test_write_format_zip_large.c \
+ libarchive/test/test_write_format_zip_zip64.c \
+ libarchive/test/test_write_open_memory.c \
+ libarchive/test/test_write_read_format_zip.c \
libarchive/test/test_zip_filename_encoding.c
libarchive_test_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/test_utils -I$(top_builddir)/libarchive/test -DLIBARCHIVE_STATIC $(PLATFORMCPPFLAGS)
@@ -508,56 +577,70 @@ libarchive_test_LDADD= $(LTLIBICONV)
# Building it automatically provides a sanity-check on libarchive_test_SOURCES
# above.
libarchive/test/list.h: Makefile
- cat $(top_srcdir)/libarchive/test/test_*.c | grep DEFINE_TEST > libarchive/test/list.h
+ $(MKDIR_P) libarchive/test
+ cat $(top_srcdir)/libarchive/test/test_*.c | grep '^DEFINE_TEST' > libarchive/test/list.h
libarchive_TESTS_ENVIRONMENT= LIBARCHIVE_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/libarchive/test LRZIP=NOCONFIG
libarchive_test_EXTRA_DIST=\
- libarchive/test/list.h \
- libarchive/test/test_acl_pax.tar.uu \
- libarchive/test/test_archive_string_conversion.txt.Z.uu \
- libarchive/test/test_compat_bzip2_1.tbz.uu \
- libarchive/test/test_compat_bzip2_2.tbz.uu \
- libarchive/test/test_compat_cpio_1.cpio.uu \
- libarchive/test/test_compat_gtar_1.tar.uu \
- libarchive/test/test_compat_gzip_1.tgz.uu \
- libarchive/test/test_compat_gzip_2.tgz.uu \
- libarchive/test/test_compat_lzip_1.tlz.uu \
- libarchive/test/test_compat_lzip_2.tlz.uu \
- libarchive/test/test_compat_lzma_1.tlz.uu \
- libarchive/test/test_compat_lzma_2.tlz.uu \
- libarchive/test/test_compat_lzma_3.tlz.uu \
- libarchive/test/test_compat_lzop_1.tar.lzo.uu \
- libarchive/test/test_compat_lzop_2.tar.lzo.uu \
- libarchive/test/test_compat_lzop_3.tar.lzo.uu \
- libarchive/test/test_compat_mac-1.tar.Z.uu \
- libarchive/test/test_compat_mac-2.tar.Z.uu \
- libarchive/test/test_compat_pax_libarchive_2x.tar.Z.uu \
- libarchive/test/test_compat_solaris_tar_acl.tar.uu \
- libarchive/test/test_compat_solaris_pax_sparse_1.pax.Z.uu \
- libarchive/test/test_compat_solaris_pax_sparse_2.pax.Z.uu \
- libarchive/test/test_compat_tar_hardlink_1.tar.uu \
- libarchive/test/test_compat_xz_1.txz.uu \
- libarchive/test/test_compat_zip_1.zip.uu \
- libarchive/test/test_compat_zip_2.zip.uu \
- libarchive/test/test_compat_zip_3.zip.uu \
- libarchive/test/test_compat_zip_4.zip.uu \
- libarchive/test/test_compat_zip_5.zip.uu \
- libarchive/test/test_compat_zip_6.zip.uu \
- libarchive/test/test_compat_zip_7.xps.uu \
- libarchive/test/test_fuzz_1.iso.Z.uu \
- libarchive/test/test_fuzz.cab.uu \
- libarchive/test/test_fuzz.lzh.uu \
- libarchive/test/test_pax_filename_encoding.tar.uu \
+ libarchive/test/list.h \
+ libarchive/test/test_acl_pax.tar.uu \
+ libarchive/test/test_archive_string_conversion.txt.Z.uu \
+ libarchive/test/test_compat_bzip2_1.tbz.uu \
+ libarchive/test/test_compat_bzip2_2.tbz.uu \
+ libarchive/test/test_compat_cpio_1.cpio.uu \
+ libarchive/test/test_compat_gtar_1.tar.uu \
+ libarchive/test/test_compat_gzip_1.tgz.uu \
+ libarchive/test/test_compat_gzip_2.tgz.uu \
+ libarchive/test/test_compat_lz4_1.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_2.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_3.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B4.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B4BD.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B4BDBX.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B5.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B5BD.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B6.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B6BD.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B7.tar.lz4.uu \
+ libarchive/test/test_compat_lz4_B7BD.tar.lz4.uu \
+ libarchive/test/test_compat_lzip_1.tlz.uu \
+ libarchive/test/test_compat_lzip_2.tlz.uu \
+ libarchive/test/test_compat_lzma_1.tlz.uu \
+ libarchive/test/test_compat_lzma_2.tlz.uu \
+ libarchive/test/test_compat_lzma_3.tlz.uu \
+ libarchive/test/test_compat_lzop_1.tar.lzo.uu \
+ libarchive/test/test_compat_lzop_2.tar.lzo.uu \
+ libarchive/test/test_compat_lzop_3.tar.lzo.uu \
+ libarchive/test/test_compat_mac-1.tar.Z.uu \
+ libarchive/test/test_compat_mac-2.tar.Z.uu \
+ libarchive/test/test_compat_pax_libarchive_2x.tar.Z.uu \
+ libarchive/test/test_compat_solaris_pax_sparse_1.pax.Z.uu \
+ libarchive/test/test_compat_solaris_pax_sparse_2.pax.Z.uu \
+ libarchive/test/test_compat_solaris_tar_acl.tar.uu \
+ libarchive/test/test_compat_tar_hardlink_1.tar.uu \
+ libarchive/test/test_compat_uudecode_large.tar.Z.uu \
+ libarchive/test/test_compat_xz_1.txz.uu \
+ libarchive/test/test_compat_zip_1.zip.uu \
+ libarchive/test/test_compat_zip_2.zip.uu \
+ libarchive/test/test_compat_zip_3.zip.uu \
+ libarchive/test/test_compat_zip_4.zip.uu \
+ libarchive/test/test_compat_zip_5.zip.uu \
+ libarchive/test/test_compat_zip_6.zip.uu \
+ libarchive/test/test_compat_zip_7.xps.uu \
+ libarchive/test/test_fuzz.cab.uu \
+ libarchive/test/test_fuzz.lzh.uu \
+ libarchive/test/test_fuzz_1.iso.Z.uu \
+ libarchive/test/test_pax_filename_encoding.tar.uu \
libarchive/test/test_rar_multivolume_multiple_files.part1.rar.uu \
libarchive/test/test_rar_multivolume_multiple_files.part2.rar.uu \
libarchive/test/test_rar_multivolume_multiple_files.part3.rar.uu \
libarchive/test/test_rar_multivolume_multiple_files.part4.rar.uu \
libarchive/test/test_rar_multivolume_multiple_files.part5.rar.uu \
libarchive/test/test_rar_multivolume_multiple_files.part6.rar.uu \
- libarchive/test/test_rar_multivolume_single_file.part1.rar.uu \
- libarchive/test/test_rar_multivolume_single_file.part2.rar.uu \
- libarchive/test/test_rar_multivolume_single_file.part3.rar.uu \
+ libarchive/test/test_rar_multivolume_single_file.part1.rar.uu \
+ libarchive/test/test_rar_multivolume_single_file.part2.rar.uu \
+ libarchive/test/test_rar_multivolume_single_file.part3.rar.uu \
libarchive/test/test_rar_multivolume_uncompressed_files.part01.rar.uu \
libarchive/test/test_rar_multivolume_uncompressed_files.part02.rar.uu \
libarchive/test/test_rar_multivolume_uncompressed_files.part03.rar.uu \
@@ -568,150 +651,184 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_rar_multivolume_uncompressed_files.part08.rar.uu \
libarchive/test/test_rar_multivolume_uncompressed_files.part09.rar.uu \
libarchive/test/test_rar_multivolume_uncompressed_files.part10.rar.uu \
- libarchive/test/test_read_filter_grzip.tar.grz.uu \
- libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
- libarchive/test/test_read_filter_lzop.tar.lzo.uu \
- libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
- libarchive/test/test_read_format_7zip_bcj_bzip2.7z.uu \
- libarchive/test/test_read_format_7zip_bcj_copy.7z.uu \
- libarchive/test/test_read_format_7zip_bcj_deflate.7z.uu \
- libarchive/test/test_read_format_7zip_bcj_lzma1.7z.uu \
- libarchive/test/test_read_format_7zip_bcj_lzma2.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_bzip2.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_copy_1.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_copy_2.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_copy_lzma.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_deflate.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_lzma1_1.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_lzma1_2.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_lzma2_1.7z.uu \
- libarchive/test/test_read_format_7zip_bcj2_lzma2_2.7z.uu \
- libarchive/test/test_read_format_7zip_bzip2.7z.uu \
- libarchive/test/test_read_format_7zip_copy.7z.uu \
- libarchive/test/test_read_format_7zip_copy_2.7z.uu \
- libarchive/test/test_read_format_7zip_deflate.7z.uu \
- libarchive/test/test_read_format_7zip_delta_lzma1.7z.uu \
- libarchive/test/test_read_format_7zip_delta_lzma2.7z.uu \
- libarchive/test/test_read_format_7zip_empty_archive.7z.uu \
- libarchive/test/test_read_format_7zip_empty_file.7z.uu \
- libarchive/test/test_read_format_7zip_lzma1.7z.uu \
- libarchive/test/test_read_format_7zip_lzma1_2.7z.uu \
- libarchive/test/test_read_format_7zip_lzma1_lzma2.7z.uu \
- libarchive/test/test_read_format_7zip_lzma2.7z.uu \
- libarchive/test/test_read_format_7zip_ppmd.7z.uu \
- libarchive/test/test_read_format_7zip_symbolic_name.7z.uu \
- libarchive/test/test_read_format_ar.ar.uu \
- libarchive/test/test_read_format_cab_1.cab.uu \
- libarchive/test/test_read_format_cab_2.cab.uu \
- libarchive/test/test_read_format_cab_3.cab.uu \
- libarchive/test/test_read_format_cab_filename_cp932.cab.uu \
- libarchive/test/test_read_format_cpio_bin_be.cpio.uu \
- libarchive/test/test_read_format_cpio_filename_cp866.cpio.uu \
- libarchive/test/test_read_format_cpio_filename_eucjp.cpio.uu \
- libarchive/test/test_read_format_cpio_filename_koi8r.cpio.uu \
- libarchive/test/test_read_format_cpio_filename_utf8_jp.cpio.uu \
- libarchive/test/test_read_format_cpio_filename_utf8_ru.cpio.uu \
- libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu \
- libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu \
- libarchive/test/test_read_format_gtar_filename_cp866.tar.Z.uu \
- libarchive/test/test_read_format_gtar_filename_eucjp.tar.Z.uu \
- libarchive/test/test_read_format_gtar_filename_koi8r.tar.Z.uu \
- libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu \
- libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu \
+ libarchive/test/test_read_filter_grzip.tar.grz.uu \
+ libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
+ libarchive/test/test_read_filter_lzop.tar.lzo.uu \
+ libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
+ libarchive/test/test_read_format_7zip_bcj2_bzip2.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_copy_1.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_copy_2.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_copy_lzma.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_deflate.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_lzma1_1.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_lzma1_2.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_lzma2_1.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj2_lzma2_2.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj_bzip2.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj_copy.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj_deflate.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj_lzma1.7z.uu \
+ libarchive/test/test_read_format_7zip_bcj_lzma2.7z.uu \
+ libarchive/test/test_read_format_7zip_bzip2.7z.uu \
+ libarchive/test/test_read_format_7zip_copy.7z.uu \
+ libarchive/test/test_read_format_7zip_copy_2.7z.uu \
+ libarchive/test/test_read_format_7zip_deflate.7z.uu \
+ libarchive/test/test_read_format_7zip_delta_lzma1.7z.uu \
+ libarchive/test/test_read_format_7zip_delta_lzma2.7z.uu \
+ libarchive/test/test_read_format_7zip_empty_archive.7z.uu \
+ libarchive/test/test_read_format_7zip_empty_file.7z.uu \
+ libarchive/test/test_read_format_7zip_encryption.7z.uu \
+ libarchive/test/test_read_format_7zip_encryption_header.7z.uu \
+ libarchive/test/test_read_format_7zip_encryption_partially.7z.uu \
+ libarchive/test/test_read_format_7zip_lzma1.7z.uu \
+ libarchive/test/test_read_format_7zip_lzma1_2.7z.uu \
+ libarchive/test/test_read_format_7zip_lzma1_lzma2.7z.uu \
+ libarchive/test/test_read_format_7zip_lzma2.7z.uu \
+ libarchive/test/test_read_format_7zip_malformed.7z.uu \
+ libarchive/test/test_read_format_7zip_malformed2.7z.uu \
+ libarchive/test/test_read_format_7zip_ppmd.7z.uu \
+ libarchive/test/test_read_format_7zip_symbolic_name.7z.uu \
+ libarchive/test/test_read_format_ar.ar.uu \
+ libarchive/test/test_read_format_cab_1.cab.uu \
+ libarchive/test/test_read_format_cab_2.cab.uu \
+ libarchive/test/test_read_format_cab_3.cab.uu \
+ libarchive/test/test_read_format_cab_filename_cp932.cab.uu \
+ libarchive/test/test_read_format_cpio_bin_be.cpio.uu \
+ libarchive/test/test_read_format_cpio_bin_le.cpio.uu \
+ libarchive/test/test_read_format_cpio_filename_cp866.cpio.uu \
+ libarchive/test/test_read_format_cpio_filename_eucjp.cpio.uu \
+ libarchive/test/test_read_format_cpio_filename_koi8r.cpio.uu \
+ libarchive/test/test_read_format_cpio_filename_utf8_jp.cpio.uu \
+ libarchive/test/test_read_format_cpio_filename_utf8_ru.cpio.uu \
+ libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu \
+ libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu \
+ libarchive/test/test_read_format_gtar_filename_cp866.tar.Z.uu \
+ libarchive/test/test_read_format_gtar_filename_eucjp.tar.Z.uu \
+ libarchive/test/test_read_format_gtar_filename_koi8r.tar.Z.uu \
+ libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu \
+ libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu \
- libarchive/test/test_read_format_iso.iso.Z.uu \
- libarchive/test/test_read_format_iso_2.iso.Z.uu \
- libarchive/test/test_read_format_iso_joliet.iso.Z.uu \
- libarchive/test/test_read_format_iso_joliet_by_nero.iso.Z.uu \
- libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu \
- libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu \
- libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu \
- libarchive/test/test_read_format_iso_rockridge.iso.Z.uu \
- libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu \
- libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu \
- libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu\
- libarchive/test/test_read_format_iso_xorriso.iso.Z.uu \
- libarchive/test/test_read_format_iso_zisofs.iso.Z.uu \
- libarchive/test/test_read_format_lha_filename_cp932.lzh.uu \
- libarchive/test/test_read_format_lha_header0.lzh.uu \
- libarchive/test/test_read_format_lha_header1.lzh.uu \
- libarchive/test/test_read_format_lha_header2.lzh.uu \
- libarchive/test/test_read_format_lha_header3.lzh.uu \
- libarchive/test/test_read_format_lha_lh0.lzh.uu \
- libarchive/test/test_read_format_lha_lh6.lzh.uu \
- libarchive/test/test_read_format_lha_lh7.lzh.uu \
- libarchive/test/test_read_format_lha_withjunk.lzh.uu \
- libarchive/test/test_read_format_mtree.mtree.uu \
- libarchive/test/test_read_format_mtree_nomagic.mtree.uu \
- libarchive/test/test_read_format_mtree_nomagic2.mtree.uu \
- libarchive/test/test_read_format_mtree_nomagic3.mtree.uu \
- libarchive/test/test_read_format_rar.rar.uu \
- libarchive/test/test_read_format_rar_binary_data.rar.uu \
- libarchive/test/test_read_format_rar_compress_best.rar.uu \
- libarchive/test/test_read_format_rar_compress_normal.rar.uu \
- libarchive/test/test_read_format_rar_multi_lzss_blocks.rar.uu \
- libarchive/test/test_read_format_rar_multivolume.part0001.rar.uu\
- libarchive/test/test_read_format_rar_multivolume.part0002.rar.uu\
- libarchive/test/test_read_format_rar_multivolume.part0003.rar.uu\
- libarchive/test/test_read_format_rar_multivolume.part0004.rar.uu\
- libarchive/test/test_read_format_rar_noeof.rar.uu \
- libarchive/test/test_read_format_rar_ppmd_lzss_conversion.rar.uu\
- libarchive/test/test_read_format_rar_sfx.exe.uu \
- libarchive/test/test_read_format_rar_subblock.rar.uu \
- libarchive/test/test_read_format_rar_unicode.rar.uu \
- libarchive/test/test_read_format_rar_windows.rar.uu \
- libarchive/test/test_read_format_raw.data.Z.uu \
- libarchive/test/test_read_format_raw.data.uu \
- libarchive/test/test_read_format_tar_empty_filename.tar.uu \
- libarchive/test/test_read_format_tar_filename_koi8r.tar.Z.uu \
- libarchive/test/test_read_format_ustar_filename_cp866.tar.Z.uu \
- libarchive/test/test_read_format_ustar_filename_eucjp.tar.Z.uu \
- libarchive/test/test_read_format_ustar_filename_koi8r.tar.Z.uu \
- libarchive/test/test_read_format_zip.zip.uu \
- libarchive/test/test_read_format_zip_comment_stored_1.zip.uu \
- libarchive/test/test_read_format_zip_comment_stored_2.zip.uu \
- libarchive/test/test_read_format_zip_filename_cp866.zip.uu \
- libarchive/test/test_read_format_zip_filename_cp932.zip.uu \
- libarchive/test/test_read_format_zip_filename_koi8r.zip.uu \
- libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \
- libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
- libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \
- libarchive/test/test_read_format_zip_length_at_end.zip.uu \
- libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
- libarchive/test/test_read_format_zip_sfx.uu \
- libarchive/test/test_read_format_zip_symlink.zip.uu \
- libarchive/test/test_read_format_zip_ux.zip.uu \
- libarchive/test/test_read_large_splitted_rar_aa.uu \
- libarchive/test/test_read_large_splitted_rar_ab.uu \
- libarchive/test/test_read_large_splitted_rar_ac.uu \
- libarchive/test/test_read_large_splitted_rar_ad.uu \
- libarchive/test/test_read_large_splitted_rar_ae.uu \
- libarchive/test/test_read_splitted_rar_aa.uu \
- libarchive/test/test_read_splitted_rar_ab.uu \
- libarchive/test/test_read_splitted_rar_ac.uu \
- libarchive/test/test_read_splitted_rar_ad.uu \
- libarchive/test/test_splitted_rar_seek_support_aa.uu \
- libarchive/test/test_splitted_rar_seek_support_ab.uu \
- libarchive/test/test_splitted_rar_seek_support_ac.uu \
- libarchive/test/test_write_disk_appledouble.cpio.gz.uu \
- libarchive/test/test_write_disk_hfs_compression.tgz.uu \
- libarchive/test/test_write_disk_mac_metadata.tar.gz.uu \
- libarchive/test/test_write_disk_no_hfs_compression.tgz.uu \
- libarchive/test/CMakeLists.txt \
+ libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu \
+ libarchive/test/test_read_format_iso.iso.Z.uu \
+ libarchive/test/test_read_format_iso_2.iso.Z.uu \
+ libarchive/test/test_read_format_iso_joliet.iso.Z.uu \
+ libarchive/test/test_read_format_iso_joliet_by_nero.iso.Z.uu \
+ libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu \
+ libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu \
+ libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu \
+ libarchive/test/test_read_format_iso_rockridge.iso.Z.uu \
+ libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu \
+ libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu \
+ libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu \
+ libarchive/test/test_read_format_iso_xorriso.iso.Z.uu \
+ libarchive/test/test_read_format_iso_zisofs.iso.Z.uu \
+ libarchive/test/test_read_format_lha_bugfix_0.lzh.uu \
+ libarchive/test/test_read_format_lha_filename_cp932.lzh.uu \
+ libarchive/test/test_read_format_lha_header0.lzh.uu \
+ libarchive/test/test_read_format_lha_header1.lzh.uu \
+ libarchive/test/test_read_format_lha_header2.lzh.uu \
+ libarchive/test/test_read_format_lha_header3.lzh.uu \
+ libarchive/test/test_read_format_lha_lh0.lzh.uu \
+ libarchive/test/test_read_format_lha_lh6.lzh.uu \
+ libarchive/test/test_read_format_lha_lh7.lzh.uu \
+ libarchive/test/test_read_format_lha_withjunk.lzh.uu \
+ libarchive/test/test_read_format_mtree.mtree.uu \
+ libarchive/test/test_read_format_mtree_nomagic.mtree.uu \
+ libarchive/test/test_read_format_mtree_nomagic2.mtree.uu \
+ libarchive/test/test_read_format_mtree_nomagic3.mtree.uu \
+ libarchive/test/test_read_format_rar.rar.uu \
+ libarchive/test/test_read_format_rar_binary_data.rar.uu \
+ libarchive/test/test_read_format_rar_compress_best.rar.uu \
+ libarchive/test/test_read_format_rar_compress_normal.rar.uu \
+ libarchive/test/test_read_format_rar_encryption_data.rar.uu \
+ libarchive/test/test_read_format_rar_encryption_header.rar.uu \
+ libarchive/test/test_read_format_rar_encryption_partially.rar.uu \
+ libarchive/test/test_read_format_rar_multi_lzss_blocks.rar.uu \
+ libarchive/test/test_read_format_rar_multivolume.part0001.rar.uu \
+ libarchive/test/test_read_format_rar_multivolume.part0002.rar.uu \
+ libarchive/test/test_read_format_rar_multivolume.part0003.rar.uu \
+ libarchive/test/test_read_format_rar_multivolume.part0004.rar.uu \
+ libarchive/test/test_read_format_rar_noeof.rar.uu \
+ libarchive/test/test_read_format_rar_ppmd_lzss_conversion.rar.uu \
+ libarchive/test/test_read_format_rar_sfx.exe.uu \
+ libarchive/test/test_read_format_rar_subblock.rar.uu \
+ libarchive/test/test_read_format_rar_unicode.rar.uu \
+ libarchive/test/test_read_format_rar_windows.rar.uu \
+ libarchive/test/test_read_format_raw.data.Z.uu \
+ libarchive/test/test_read_format_raw.data.uu \
+ libarchive/test/test_read_format_tar_concatenated.tar.uu \
+ libarchive/test/test_read_format_tar_empty_filename.tar.uu \
+ libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu \
+ libarchive/test/test_read_format_tar_filename_koi8r.tar.Z.uu \
+ libarchive/test/test_read_format_ustar_filename_cp866.tar.Z.uu \
+ libarchive/test/test_read_format_ustar_filename_eucjp.tar.Z.uu \
+ libarchive/test/test_read_format_ustar_filename_koi8r.tar.Z.uu \
+ libarchive/test/test_read_format_warc.warc.uu \
+ libarchive/test/test_read_format_zip.zip.uu \
+ libarchive/test/test_read_format_zip_comment_stored_1.zip.uu \
+ libarchive/test/test_read_format_zip_comment_stored_2.zip.uu \
+ libarchive/test/test_read_format_zip_encryption_data.zip.uu \
+ libarchive/test/test_read_format_zip_encryption_header.zip.uu \
+ libarchive/test/test_read_format_zip_encryption_partially.zip.uu \
+ libarchive/test/test_read_format_zip_filename_cp866.zip.uu \
+ libarchive/test/test_read_format_zip_filename_cp932.zip.uu \
+ libarchive/test/test_read_format_zip_filename_koi8r.zip.uu \
+ libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \
+ libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \
+ libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
+ libarchive/test/test_read_format_zip_length_at_end.zip.uu \
+ libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
+ libarchive/test/test_read_format_zip_malformed1.zip.uu \
+ libarchive/test/test_read_format_zip_msdos.zip.uu \
+ libarchive/test/test_read_format_zip_nested.zip.uu \
+ libarchive/test/test_read_format_zip_nofiletype.zip.uu \
+ libarchive/test/test_read_format_zip_padded1.zip.uu \
+ libarchive/test/test_read_format_zip_padded2.zip.uu \
+ libarchive/test/test_read_format_zip_padded3.zip.uu \
+ libarchive/test/test_read_format_zip_sfx.uu \
+ libarchive/test/test_read_format_zip_symlink.zip.uu \
+ libarchive/test/test_read_format_zip_traditional_encryption_data.zip.uu \
+ libarchive/test/test_read_format_zip_ux.zip.uu \
+ libarchive/test/test_read_format_zip_winzip_aes128.zip.uu \
+ libarchive/test/test_read_format_zip_winzip_aes256.zip.uu \
+ libarchive/test/test_read_format_zip_winzip_aes256_large.zip.uu \
+ libarchive/test/test_read_format_zip_winzip_aes256_stored.zip.uu \
+ libarchive/test/test_read_format_zip_zip64a.zip.uu \
+ libarchive/test/test_read_format_zip_zip64b.zip.uu \
+ libarchive/test/test_read_large_splitted_rar_aa.uu \
+ libarchive/test/test_read_large_splitted_rar_ab.uu \
+ libarchive/test/test_read_large_splitted_rar_ac.uu \
+ libarchive/test/test_read_large_splitted_rar_ad.uu \
+ libarchive/test/test_read_large_splitted_rar_ae.uu \
+ libarchive/test/test_read_splitted_rar_aa.uu \
+ libarchive/test/test_read_splitted_rar_ab.uu \
+ libarchive/test/test_read_splitted_rar_ac.uu \
+ libarchive/test/test_read_splitted_rar_ad.uu \
+ libarchive/test/test_read_too_many_filters.gz.uu \
+ libarchive/test/test_splitted_rar_seek_support_aa.uu \
+ libarchive/test/test_splitted_rar_seek_support_ab.uu \
+ libarchive/test/test_splitted_rar_seek_support_ac.uu \
+ libarchive/test/test_write_disk_appledouble.cpio.gz.uu \
+ libarchive/test/test_write_disk_hfs_compression.tgz.uu \
+ libarchive/test/test_write_disk_mac_metadata.tar.gz.uu \
+ libarchive/test/test_write_disk_no_hfs_compression.tgz.uu \
+ libarchive/test/CMakeLists.txt \
libarchive/test/README
#
# Common code for libarchive frontends (cpio, tar)
#
-libarchive_fe_la_SOURCES= \
- libarchive_fe/err.c \
- libarchive_fe/err.h \
- libarchive_fe/lafe_platform.h \
- libarchive_fe/line_reader.c \
- libarchive_fe/line_reader.h
+libarchive_fe_la_SOURCES= \
+ libarchive_fe/err.c \
+ libarchive_fe/err.h \
+ libarchive_fe/lafe_platform.h \
+ libarchive_fe/line_reader.c \
+ libarchive_fe/line_reader.h \
+ libarchive_fe/passphrase.c \
+ libarchive_fe/passphrase.h
libarchive_fe_la_CPPFLAGS= -I$(top_srcdir)/libarchive
#
@@ -720,20 +837,20 @@ libarchive_fe_la_CPPFLAGS= -I$(top_srcdir)/libarchive
#
#
-bsdtar_SOURCES= \
- tar/bsdtar.c \
- tar/bsdtar.h \
- tar/bsdtar_platform.h \
- tar/cmdline.c \
- tar/creation_set.c \
- tar/read.c \
- tar/subst.c \
- tar/util.c \
+bsdtar_SOURCES= \
+ tar/bsdtar.c \
+ tar/bsdtar.h \
+ tar/bsdtar_platform.h \
+ tar/cmdline.c \
+ tar/creation_set.c \
+ tar/read.c \
+ tar/subst.c \
+ tar/util.c \
tar/write.c
if INC_WINDOWS_FILES
-bsdtar_SOURCES+= \
- tar/bsdtar_windows.h \
+bsdtar_SOURCES+= \
+ tar/bsdtar_windows.h \
tar/bsdtar_windows.c
endif
@@ -751,11 +868,11 @@ bsdtar_LDADD= libarchive.la libarchive_fe.la $(LTLIBICONV)
bsdtar_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdtar_ccstatic) $(PLATFORMCPPFLAGS)
bsdtar_LDFLAGS= $(bsdtar_ldstatic)
-bsdtar_EXTRA_DIST= \
- tar/bsdtar.1 \
- tar/bsdtar_windows.h \
- tar/bsdtar_windows.c \
- tar/CMakeLists.txt \
+bsdtar_EXTRA_DIST= \
+ tar/bsdtar.1 \
+ tar/bsdtar_windows.h \
+ tar/bsdtar_windows.c \
+ tar/CMakeLists.txt \
tar/config_freebsd.h
@@ -771,61 +888,65 @@ endif
# bsdtar_test
#
-bsdtar_test_SOURCES= \
- $(test_utils_SOURCES) \
- tar/test/main.c \
- tar/test/test.h \
- tar/test/test_0.c \
- tar/test/test_basic.c \
- tar/test/test_copy.c \
- tar/test/test_empty_mtree.c \
- tar/test/test_extract_tar_Z.c \
- tar/test/test_extract_tar_bz2.c \
- tar/test/test_extract_tar_grz.c \
- tar/test/test_extract_tar_gz.c \
- tar/test/test_extract_tar_lrz.c \
- tar/test/test_extract_tar_lz.c \
- tar/test/test_extract_tar_lzma.c \
- tar/test/test_extract_tar_lzo.c \
- tar/test/test_extract_tar_xz.c \
- tar/test/test_format_newc.c \
- tar/test/test_help.c \
- tar/test/test_option_C_upper.c \
- tar/test/test_option_H_upper.c \
- tar/test/test_option_L_upper.c \
- tar/test/test_option_O_upper.c \
- tar/test/test_option_T_upper.c \
- tar/test/test_option_U_upper.c \
- tar/test/test_option_X_upper.c \
- tar/test/test_option_a.c \
- tar/test/test_option_b.c \
- tar/test/test_option_b64encode.c \
- tar/test/test_option_exclude.c \
- tar/test/test_option_gid_gname.c \
- tar/test/test_option_grzip.c \
- tar/test/test_option_j.c \
- tar/test/test_option_k.c \
- tar/test/test_option_keep_newer_files.c \
- tar/test/test_option_lrzip.c \
- tar/test/test_option_lzma.c \
- tar/test/test_option_lzop.c \
- tar/test/test_option_n.c \
- tar/test/test_option_newer_than.c \
- tar/test/test_option_nodump.c \
- tar/test/test_option_older_than.c \
- tar/test/test_option_q.c \
- tar/test/test_option_r.c \
- tar/test/test_option_s.c \
- tar/test/test_option_uid_uname.c \
- tar/test/test_option_uuencode.c \
- tar/test/test_option_xz.c \
- tar/test/test_option_z.c \
- tar/test/test_patterns.c \
- tar/test/test_print_longpath.c \
- tar/test/test_stdio.c \
- tar/test/test_strip_components.c \
- tar/test/test_symlink_dir.c \
- tar/test/test_version.c \
+bsdtar_test_SOURCES= \
+ $(test_utils_SOURCES) \
+ tar/test/main.c \
+ tar/test/test.h \
+ tar/test/test_0.c \
+ tar/test/test_basic.c \
+ tar/test/test_copy.c \
+ tar/test/test_empty_mtree.c \
+ tar/test/test_extract_tar_Z.c \
+ tar/test/test_extract_tar_bz2.c \
+ tar/test/test_extract_tar_grz.c \
+ tar/test/test_extract_tar_gz.c \
+ tar/test/test_extract_tar_lrz.c \
+ tar/test/test_extract_tar_lz.c \
+ tar/test/test_extract_tar_lz4.c \
+ tar/test/test_extract_tar_lzma.c \
+ tar/test/test_extract_tar_lzo.c \
+ tar/test/test_extract_tar_xz.c \
+ tar/test/test_format_newc.c \
+ tar/test/test_help.c \
+ tar/test/test_leading_slash.c \
+ tar/test/test_option_C_upper.c \
+ tar/test/test_option_H_upper.c \
+ tar/test/test_option_L_upper.c \
+ tar/test/test_option_O_upper.c \
+ tar/test/test_option_T_upper.c \
+ tar/test/test_option_U_upper.c \
+ tar/test/test_option_X_upper.c \
+ tar/test/test_option_a.c \
+ tar/test/test_option_b.c \
+ tar/test/test_option_b64encode.c \
+ tar/test/test_option_exclude.c \
+ tar/test/test_option_gid_gname.c \
+ tar/test/test_option_grzip.c \
+ tar/test/test_option_j.c \
+ tar/test/test_option_k.c \
+ tar/test/test_option_keep_newer_files.c \
+ tar/test/test_option_lrzip.c \
+ tar/test/test_option_lz4.c \
+ tar/test/test_option_lzma.c \
+ tar/test/test_option_lzop.c \
+ tar/test/test_option_n.c \
+ tar/test/test_option_newer_than.c \
+ tar/test/test_option_nodump.c \
+ tar/test/test_option_older_than.c \
+ tar/test/test_option_passphrase.c \
+ tar/test/test_option_q.c \
+ tar/test/test_option_r.c \
+ tar/test/test_option_s.c \
+ tar/test/test_option_uid_uname.c \
+ tar/test/test_option_uuencode.c \
+ tar/test/test_option_xz.c \
+ tar/test/test_option_z.c \
+ tar/test/test_patterns.c \
+ tar/test/test_print_longpath.c \
+ tar/test/test_stdio.c \
+ tar/test/test_strip_components.c \
+ tar/test/test_symlink_dir.c \
+ tar/test/test_version.c \
tar/test/test_windows.c
bsdtar_test_CPPFLAGS=\
@@ -835,7 +956,8 @@ bsdtar_test_CPPFLAGS=\
$(PLATFORMCPPFLAGS)
tar/test/list.h: Makefile
- cat $(top_srcdir)/tar/test/test_*.c | grep DEFINE_TEST > tar/test/list.h
+ $(MKDIR_P) tar/test
+ cat $(top_srcdir)/tar/test/test_*.c | grep '^DEFINE_TEST' > tar/test/list.h
if BUILD_BSDTAR
bsdtar_test_programs= bsdtar_test
@@ -845,22 +967,25 @@ bsdtar_test_programs=
bsdtar_TESTS_ENVIRONMENT=
endif
-bsdtar_test_EXTRA_DIST= \
+bsdtar_test_EXTRA_DIST= \
tar/test/list.h \
- tar/test/test_extract.tar.Z.uu \
+ tar/test/test_extract.tar.Z.uu \
tar/test/test_extract.tar.bz2.uu \
tar/test/test_extract.tar.grz.uu \
- tar/test/test_extract.tar.gz.uu \
+ tar/test/test_extract.tar.gz.uu \
tar/test/test_extract.tar.lrz.uu \
- tar/test/test_extract.tar.lz.uu \
+ tar/test/test_extract.tar.lz.uu \
+ tar/test/test_extract.tar.lz4.uu \
tar/test/test_extract.tar.lzma.uu \
tar/test/test_extract.tar.lzo.uu \
tar/test/test_extract.tar.xz.uu \
+ tar/test/test_leading_slash.tar.uu \
tar/test/test_option_keep_newer_files.tar.Z.uu \
+ tar/test/test_option_passphrase.zip.uu \
tar/test/test_option_s.tar.Z.uu \
- tar/test/test_patterns_2.tar.uu \
- tar/test/test_patterns_3.tar.uu \
- tar/test/test_patterns_4.tar.uu \
+ tar/test/test_patterns_2.tar.uu \
+ tar/test/test_patterns_3.tar.uu \
+ tar/test/test_patterns_4.tar.uu \
tar/test/test_print_longpath.tar.Z.uu \
tar/test/CMakeLists.txt
@@ -871,15 +996,15 @@ bsdtar_test_EXTRA_DIST= \
#
#
-bsdcpio_SOURCES= \
- cpio/cmdline.c \
- cpio/cpio.c \
- cpio/cpio.h \
+bsdcpio_SOURCES= \
+ cpio/cmdline.c \
+ cpio/cpio.c \
+ cpio/cpio.h \
cpio/cpio_platform.h
if INC_WINDOWS_FILES
-bsdcpio_SOURCES+= \
- cpio/cpio_windows.h \
+bsdcpio_SOURCES+= \
+ cpio/cpio_windows.h \
cpio/cpio_windows.c
endif
@@ -898,11 +1023,11 @@ bsdcpio_LDADD= libarchive_fe.la libarchive.la $(LTLIBICONV)
bsdcpio_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdcpio_ccstatic) $(PLATFORMCPPFLAGS)
bsdcpio_LDFLAGS= $(bsdcpio_ldstatic)
-bsdcpio_EXTRA_DIST= \
- cpio/bsdcpio.1 \
- cpio/cpio_windows.h \
- cpio/cpio_windows.c \
- cpio/CMakeLists.txt \
+bsdcpio_EXTRA_DIST= \
+ cpio/bsdcpio.1 \
+ cpio/cpio_windows.h \
+ cpio/cpio_windows.c \
+ cpio/CMakeLists.txt \
cpio/config_freebsd.h
@@ -919,52 +1044,55 @@ endif
# bsdcpio_test
#
-bsdcpio_test_SOURCES= \
- $(test_utils_SOURCES) \
- cpio/cmdline.c \
- cpio/test/main.c \
- cpio/test/test.h \
- cpio/test/test_0.c \
- cpio/test/test_basic.c \
- cpio/test/test_cmdline.c \
- cpio/test/test_extract_cpio_Z.c \
- cpio/test/test_extract_cpio_bz2.c \
- cpio/test/test_extract_cpio_grz.c \
- cpio/test/test_extract_cpio_gz.c \
- cpio/test/test_extract_cpio_lrz.c \
- cpio/test/test_extract_cpio_lz.c \
- cpio/test/test_extract_cpio_lzma.c \
- cpio/test/test_extract_cpio_lzo.c \
- cpio/test/test_extract_cpio_xz.c \
- cpio/test/test_format_newc.c \
- cpio/test/test_gcpio_compat.c \
- cpio/test/test_option_0.c \
- cpio/test/test_option_B_upper.c \
- cpio/test/test_option_C_upper.c \
- cpio/test/test_option_J_upper.c \
- cpio/test/test_option_L_upper.c \
- cpio/test/test_option_Z_upper.c \
- cpio/test/test_option_a.c \
- cpio/test/test_option_b64encode.c \
- cpio/test/test_option_c.c \
- cpio/test/test_option_d.c \
- cpio/test/test_option_f.c \
- cpio/test/test_option_grzip.c \
- cpio/test/test_option_help.c \
- cpio/test/test_option_l.c \
- cpio/test/test_option_lrzip.c \
- cpio/test/test_option_lzma.c \
- cpio/test/test_option_lzop.c \
- cpio/test/test_option_m.c \
- cpio/test/test_option_t.c \
- cpio/test/test_option_u.c \
- cpio/test/test_option_uuencode.c \
- cpio/test/test_option_version.c \
- cpio/test/test_option_xz.c \
- cpio/test/test_option_y.c \
- cpio/test/test_option_z.c \
- cpio/test/test_owner_parse.c \
- cpio/test/test_passthrough_dotdot.c \
+bsdcpio_test_SOURCES= \
+ $(test_utils_SOURCES) \
+ cpio/cmdline.c \
+ cpio/test/main.c \
+ cpio/test/test.h \
+ cpio/test/test_0.c \
+ cpio/test/test_basic.c \
+ cpio/test/test_cmdline.c \
+ cpio/test/test_extract_cpio_Z.c \
+ cpio/test/test_extract_cpio_bz2.c \
+ cpio/test/test_extract_cpio_grz.c \
+ cpio/test/test_extract_cpio_gz.c \
+ cpio/test/test_extract_cpio_lrz.c \
+ cpio/test/test_extract_cpio_lz.c \
+ cpio/test/test_extract_cpio_lz4.c \
+ cpio/test/test_extract_cpio_lzma.c \
+ cpio/test/test_extract_cpio_lzo.c \
+ cpio/test/test_extract_cpio_xz.c \
+ cpio/test/test_format_newc.c \
+ cpio/test/test_gcpio_compat.c \
+ cpio/test/test_option_0.c \
+ cpio/test/test_option_B_upper.c \
+ cpio/test/test_option_C_upper.c \
+ cpio/test/test_option_J_upper.c \
+ cpio/test/test_option_L_upper.c \
+ cpio/test/test_option_Z_upper.c \
+ cpio/test/test_option_a.c \
+ cpio/test/test_option_b64encode.c \
+ cpio/test/test_option_c.c \
+ cpio/test/test_option_d.c \
+ cpio/test/test_option_f.c \
+ cpio/test/test_option_grzip.c \
+ cpio/test/test_option_help.c \
+ cpio/test/test_option_l.c \
+ cpio/test/test_option_lrzip.c \
+ cpio/test/test_option_lz4.c \
+ cpio/test/test_option_lzma.c \
+ cpio/test/test_option_lzop.c \
+ cpio/test/test_option_m.c \
+ cpio/test/test_option_passphrase.c \
+ cpio/test/test_option_t.c \
+ cpio/test/test_option_u.c \
+ cpio/test/test_option_uuencode.c \
+ cpio/test/test_option_version.c \
+ cpio/test/test_option_xz.c \
+ cpio/test/test_option_y.c \
+ cpio/test/test_option_z.c \
+ cpio/test/test_owner_parse.c \
+ cpio/test/test_passthrough_dotdot.c \
cpio/test/test_passthrough_reverse.c
bsdcpio_test_CPPFLAGS= \
@@ -975,7 +1103,8 @@ bsdcpio_test_CPPFLAGS= \
bsdcpio_test_LDADD=libarchive_fe.la
cpio/test/list.h: Makefile
- cat $(top_srcdir)/cpio/test/test_*.c | grep DEFINE_TEST > cpio/test/list.h
+ $(MKDIR_P) cpio/test
+ cat $(top_srcdir)/cpio/test/test_*.c | grep '^DEFINE_TEST' > cpio/test/list.h
if BUILD_BSDCPIO
bsdcpio_test_programs= bsdcpio_test
@@ -985,28 +1114,130 @@ bsdcpio_test_programs=
bsdcpio_TESTS_ENVIRONMENT=
endif
-bsdcpio_test_EXTRA_DIST= \
- cpio/test/list.h \
- cpio/test/test_extract.cpio.Z.uu \
- cpio/test/test_extract.cpio.bz2.uu \
- cpio/test/test_extract.cpio.grz.uu \
- cpio/test/test_extract.cpio.gz.uu \
- cpio/test/test_extract.cpio.lrz.uu \
- cpio/test/test_extract.cpio.lz.uu \
- cpio/test/test_extract.cpio.lzma.uu \
- cpio/test/test_extract.cpio.lzo.uu \
- cpio/test/test_extract.cpio.xz.uu \
- cpio/test/test_gcpio_compat_ref.bin.uu \
- cpio/test/test_gcpio_compat_ref.crc.uu \
- cpio/test/test_gcpio_compat_ref.newc.uu \
+bsdcpio_test_EXTRA_DIST= \
+ cpio/test/list.h \
+ cpio/test/test_extract.cpio.Z.uu \
+ cpio/test/test_extract.cpio.bz2.uu \
+ cpio/test/test_extract.cpio.grz.uu \
+ cpio/test/test_extract.cpio.gz.uu \
+ cpio/test/test_extract.cpio.lrz.uu \
+ cpio/test/test_extract.cpio.lz.uu \
+ cpio/test/test_extract.cpio.lz4.uu \
+ cpio/test/test_extract.cpio.lzma.uu \
+ cpio/test/test_extract.cpio.lzo.uu \
+ cpio/test/test_extract.cpio.xz.uu \
+ cpio/test/test_gcpio_compat_ref.bin.uu \
+ cpio/test/test_gcpio_compat_ref.crc.uu \
+ cpio/test/test_gcpio_compat_ref.newc.uu \
cpio/test/test_gcpio_compat_ref.ustar.uu \
cpio/test/test_gcpio_compat_ref_nosym.bin.uu \
cpio/test/test_gcpio_compat_ref_nosym.crc.uu \
cpio/test/test_gcpio_compat_ref_nosym.newc.uu \
cpio/test/test_gcpio_compat_ref_nosym.ustar.uu \
- cpio/test/test_option_f.cpio.uu \
- cpio/test/test_option_m.cpio.uu \
- cpio/test/test_option_t.cpio.uu \
- cpio/test/test_option_t.stdout.uu \
- cpio/test/test_option_tv.stdout.uu \
+ cpio/test/test_option_f.cpio.uu \
+ cpio/test/test_option_m.cpio.uu \
+ cpio/test/test_option_passphrase.zip.uu \
+ cpio/test/test_option_t.cpio.uu \
+ cpio/test/test_option_t.stdout.uu \
+ cpio/test/test_option_tv.stdout.uu \
cpio/test/CMakeLists.txt
+
+#
+#
+# bsdcat source, docs, etc.
+#
+#
+
+bsdcat_SOURCES= \
+ cat/bsdcat.c \
+ cat/bsdcat.h \
+ cat/bsdcat_platform.h \
+ cat/cmdline.c
+
+if INC_WINDOWS_FILES
+bsdcat_SOURCES+=
+endif
+
+bsdcat_DEPENDENCIES = libarchive.la libarchive_fe.la
+
+
+if STATIC_BSDCAT
+bsdcat_ldstatic= -static
+bsdcat_ccstatic= -DLIBARCHIVE_STATIC
+else
+bsdcat_ldstatic=
+bsdcat_ccstatic=
+endif
+
+bsdcat_LDADD= libarchive_fe.la libarchive.la $(LTLIBICONV)
+bsdcat_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdcat_ccstatic) $(PLATFORMCPPFLAGS)
+bsdcat_LDFLAGS= $(bsdcat_ldstatic)
+
+bsdcat_EXTRA_DIST= \
+ cat/bsdcat.1 \
+ cat/CMakeLists.txt
+
+
+if BUILD_BSDCAT
+# Manpages to install
+bsdcat_man_MANS= cat/bsdcat.1
+bsdcat_programs= bsdcat
+else
+bsdcat_man_MANS=
+bsdcat_programs=
+endif
+
+#
+# bsdcat_test
+#
+
+bsdcat_test_SOURCES= \
+ $(test_utils_SOURCES) \
+ cat/test/main.c \
+ cat/test/test.h \
+ cat/test/test_0.c \
+ cat/test/test_empty_gz.c \
+ cat/test/test_empty_lz4.c \
+ cat/test/test_empty_xz.c \
+ cat/test/test_error.c \
+ cat/test/test_error_mixed.c \
+ cat/test/test_expand_Z.c \
+ cat/test/test_expand_bz2.c \
+ cat/test/test_expand_gz.c \
+ cat/test/test_expand_lz4.c \
+ cat/test/test_expand_mixed.c \
+ cat/test/test_expand_plain.c \
+ cat/test/test_expand_xz.c \
+ cat/test/test_help.c \
+ cat/test/test_version.c
+
+bsdcat_test_CPPFLAGS= \
+ -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
+ -I$(top_srcdir)/test_utils \
+ -I$(top_srcdir)/cat -I$(top_builddir)/cat/test \
+ $(PLATFORMCPPFLAGS)
+bsdcat_test_LDADD=libarchive_fe.la
+
+cat/test/list.h: Makefile
+ cat $(top_srcdir)/cat/test/test_*.c | grep '^DEFINE_TEST' > cat/test/list.h
+
+if BUILD_BSDCAT
+bsdcat_test_programs= bsdcat_test
+bsdcat_TESTS_ENVIRONMENT= BSDCAT=`cd $(top_builddir);/bin/pwd`/bsdcat$(EXEEXT) BSDCAT_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/cat/test
+else
+bsdcat_test_programs=
+bsdcat_TESTS_ENVIRONMENT=
+endif
+
+bsdcat_test_EXTRA_DIST= \
+ cat/test/list.h \
+ cat/test/test_empty.gz.uu \
+ cat/test/test_empty.lz4.uu \
+ cat/test/test_empty.xz.uu \
+ cat/test/test_expand.Z.uu \
+ cat/test/test_expand.bz2.uu \
+ cat/test/test_expand.gz.uu \
+ cat/test/test_expand.lz4.uu \
+ cat/test/test_expand.plain.uu \
+ cat/test/test_expand.xz.uu \
+ cat/test/CMakeLists.txt
diff --git a/NEWS b/NEWS
index 107d4da0f11e..5bf877606244 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,35 @@
+Apr 09, 2016: libarchive 3.1.901a released
+ Another test release in preparation for 3.2.0
+
+Feb 13, 2016: libarchive 3.1.900a released
+ This is a test release in preparation for 3.2.0
+
+Oct 21, 2015: Preliminary port to OSF
+
+Apr 11, 2015: libarchive's issue tracker is now hosted at GitHub.
+ https://github.com/libarchive/libarchive/issues
+
+Early 2015: Many fixes to crash and overflow bugs thanks to Hanno Boeck
+
+Oct 13, 2014: Zip encryption and decryption support
+
+Aug 13, 2014: Add support for lz4 compression.
+
+Jun 10, 2014: Add warc format support
+
+May 3, 2014: Add experimental Zip streaming extension
+
+Apr 6, 2014: Add bsdcat command-line tool
+
+Jan 12, 2014: Add Zip64 support
+
+Dec 1, 2013: Rewrite Zip write logic
+
+Jul 1, 2013: Add ability to detect encrypted entries for many formats
+ (This does not add the ability to *decrypt* those entries, however)
+
+Feb 23, 2013: "raw" write support added
+
Feb 09, 2013: libarchive 3.1.2 released
Jan 28, 2013: libarchive's new website moved to http://www.libarchive.org.
diff --git a/README b/README
index 1c974fde2202..180d28459e5f 100644
--- a/README
+++ b/README
@@ -5,7 +5,7 @@ Questions? Issues?
libarchive development, including documentation, and
links to the libarchive mailing lists.
* To report an issue, use the issue tracker at
- http://code.google.com/p/libarchive/issues/list
+ https://github.com/libarchive/libarchive/issues
* To submit an enhancement to libarchive, please submit
a pull request via GitHub.
https://github.com/libarchive/libarchive/pulls
@@ -13,9 +13,11 @@ Questions? Issues?
This distribution bundle includes the following components:
* libarchive: a library for reading and writing streaming archives
* tar: the 'bsdtar' program is a full-featured 'tar'
- replacement built on libarchive
+ implementation built on libarchive
* cpio: the 'bsdcpio' program is a different interface to
essentially the same functionality
+ * cat: the 'bsdcat' program is a simple replacement tool for
+ zcat, bzcat, xzcat, and such
* examples: Some small example programs that you may find useful.
* examples/minitar: a compact sample demonstrating use of libarchive.
* contrib: Various items sent to me by third parties;
@@ -39,6 +41,7 @@ The following files in the top-level directory are used by the
Guide to Documentation installed by this system:
* bsdtar.1 explains the use of the bsdtar program
* bsdcpio.1 explains the use of the bsdcpio program
+ * bsdcat.1 explains the use of the bsdcat program
* libarchive.3 gives an overview of the library as a whole
* archive_read.3, archive_write.3, archive_write_disk.3, and
archive_read_disk.3 provide detailed calling sequences for the read
@@ -84,6 +87,8 @@ The library also detects and handles any of the following before evaluating the
* bzip2 compression
* compress/LZW compression
* lzma, lzip, and xz compression
+ * lz4 compression
+ * lzop compression
The library can create archives in any of the following formats:
* POSIX ustar
@@ -91,6 +96,7 @@ The library can create archives in any of the following formats:
* "restricted" pax format, which will create ustar archives except for
entries that require pax extensions (for long filenames, ACLs, etc).
* Old GNU tar format
+ * Old V7 tar format
* POSIX octet-oriented cpio
* SVR4 "newc" cpio
* shar archives
@@ -107,6 +113,8 @@ When creating archives, the result can be filtered with any of the following:
* bzip2 compression
* compress/LZW compression
* lzma, lzip, and xz compression
+ * lz4 compression
+ * lzop compression
Notes about the library architecture:
@@ -123,12 +131,12 @@ Notes about the library architecture:
* I've attempted to minimize static link pollution. If you don't
explicitly invoke a particular feature (such as support for a
- particular compression or format), it won't get pulled in.
- In particular, if you don't explicitly enable a particular
- compression or decompression support, you won't need to link
- against the corresponding compression or decompression libraries.
- This also reduces the size of statically-linked binaries in
- environments where that matters.
+ particular compression or format), it won't get pulled in to
+ statically-linked programs. In particular, if you don't explicitly
+ enable a particular compression or decompression support, you won't
+ need to link against the corresponding compression or decompression
+ libraries. This also reduces the size of statically-linked
+ binaries in environments where that matters.
* On read, the library accepts whatever blocks you hand it.
Your read callback is free to pass the library a byte at a time
diff --git a/build/autoconf/ax_append_compile_flags.m4 b/build/autoconf/ax_append_compile_flags.m4
new file mode 100644
index 000000000000..2bb27ef2b1b4
--- /dev/null
+++ b/build/autoconf/ax_append_compile_flags.m4
@@ -0,0 +1,67 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+# For every FLAG1, FLAG2 it is checked whether the compiler works with the
+# flag. If it does, the flag is added FLAGS-VARIABLE
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. During the check the flag is always added to the
+# current language's flags.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+# NOTE: This macro depends on the AX_APPEND_FLAG and
+# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
+# AX_APPEND_LINK_FLAGS.
+#
+# LICENSE
+#
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 5
+
+AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+for flag in $1; do
+ AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
+done
+])dnl AX_APPEND_COMPILE_FLAGS
diff --git a/build/autoconf/ax_append_flag.m4 b/build/autoconf/ax_append_flag.m4
new file mode 100644
index 000000000000..08f2e07ec61b
--- /dev/null
+++ b/build/autoconf/ax_append_flag.m4
@@ -0,0 +1,71 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+# added in between.
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
+# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+# FLAG.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 6
+
+AC_DEFUN([AX_APPEND_FLAG],
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+ AS_CASE([" AS_VAR_GET(FLAGS) "],
+ [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
+ [
+ AS_VAR_APPEND(FLAGS,[" $1"])
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+ ],
+ [
+ AS_VAR_SET(FLAGS,[$1])
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/build/autoconf/ax_check_compile_flag.m4 b/build/autoconf/ax_check_compile_flag.m4
new file mode 100644
index 000000000000..ca3639715e72
--- /dev/null
+++ b/build/autoconf/ax_check_compile_flag.m4
@@ -0,0 +1,74 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/build/autoconf/ax_require_defined.m4 b/build/autoconf/ax_require_defined.m4
new file mode 100644
index 000000000000..cae11112d901
--- /dev/null
+++ b/build/autoconf/ax_require_defined.m4
@@ -0,0 +1,37 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+# been defined and thus are available for use. This avoids random issues
+# where a macro isn't expanded. Instead the configure script emits a
+# non-fatal:
+#
+# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+# It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+# Here's an example:
+#
+# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+ m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
diff --git a/build/autoconf/iconv.m4 b/build/autoconf/iconv.m4
index 98fcd64d313c..4e3736315662 100644
--- a/build/autoconf/iconv.m4
+++ b/build/autoconf/iconv.m4
@@ -1,5 +1,5 @@
-# iconv.m4 serial 18 (gettext-0.18.2)
-dnl Copyright (C) 2000-2002, 2007-2011 Free Software Foundation, Inc.
+# iconv.m4 serial 19 (gettext-0.18.2)
+dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -72,27 +72,33 @@ AC_DEFUN([AM_ICONV_LINK],
if test $am_cv_lib_iconv = yes; then
LIBS="$LIBS $LIBICONV"
fi
- AC_RUN_IFELSE(
- [AC_LANG_SOURCE([[
+ am_cv_func_iconv_works=no
+ for ac_iconv_const in '' 'const'; do
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
#include <iconv.h>
#include <string.h>
-int main ()
-{
- int result = 0;
+
+#ifndef ICONV_CONST
+# define ICONV_CONST $ac_iconv_const
+#endif
+ ]],
+ [[int result = 0;
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
{
- static const char input[] = "\342\202\254"; /* EURO SIGN */
+ static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
char buf[10];
- const char *inptr = input;
+ ICONV_CONST char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
- (char **) &inptr, &inbytesleft,
+ &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
result |= 1;
@@ -105,14 +111,14 @@ int main ()
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
if (cd_ascii_to_88591 != (iconv_t)(-1))
{
- static const char input[] = "\263";
+ static ICONV_CONST char input[] = "\263";
char buf[10];
- const char *inptr = input;
+ ICONV_CONST char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_ascii_to_88591,
- (char **) &inptr, &inbytesleft,
+ &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
result |= 2;
@@ -124,14 +130,14 @@ int main ()
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
- static const char input[] = "\304";
+ static ICONV_CONST char input[] = "\304";
static char buf[2] = { (char)0xDE, (char)0xAD };
- const char *inptr = input;
+ ICONV_CONST char *inptr = input;
size_t inbytesleft = 1;
char *outptr = buf;
size_t outbytesleft = 1;
size_t res = iconv (cd_88591_to_utf8,
- (char **) &inptr, &inbytesleft,
+ &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
result |= 4;
@@ -144,14 +150,14 @@ int main ()
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
- static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+ static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
char buf[50];
- const char *inptr = input;
+ ICONV_CONST char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_88591_to_utf8,
- (char **) &inptr, &inbytesleft,
+ &inptr, &inbytesleft,
&outptr, &outbytesleft);
if ((int)res > 0)
result |= 8;
@@ -171,17 +177,14 @@ int main ()
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
result |= 16;
return result;
-}]])],
- [am_cv_func_iconv_works=yes],
- [am_cv_func_iconv_works=no],
- [
-changequote(,)dnl
- case "$host_os" in
- aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
- *) am_cv_func_iconv_works="guessing yes" ;;
- esac
-changequote([,])dnl
- ])
+]])],
+ [am_cv_func_iconv_works=yes], ,
+ [case "$host_os" in
+ aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
+ *) am_cv_func_iconv_works="guessing yes" ;;
+ esac])
+ test "$am_cv_func_iconv_works" = no || break
+ done
LIBS="$am_save_LIBS"
])
case "$am_cv_func_iconv_works" in
diff --git a/build/autogen.sh b/build/autogen.sh
index e73162465d2a..64767b6ee6ca 100755
--- a/build/autogen.sh
+++ b/build/autogen.sh
@@ -43,7 +43,7 @@ cd ..
# Substitute the versions into Libarchive's archive.h and archive_entry.h
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive.h
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive_entry.h
-perl -p -i -e "s/^(#define\tARCHIVE_VERSION_STRING).*/\$1 \"libarchive $VS\"/" libarchive/archive.h
+perl -p -i -e "s/^(#define\tARCHIVE_VERSION_ONLY_STRING).*/\$1 \"$VS\"/" libarchive/archive.h
# Substitute versions into configure.ac as well
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' configure.ac
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac
diff --git a/build/clean.sh b/build/clean.sh
index e4465f8a786c..b669426ccb5e 100755
--- a/build/clean.sh
+++ b/build/clean.sh
@@ -62,8 +62,10 @@ rm -f build/autoconf/ltsugar.m4
rm -f build/autoconf/ltversion.m4
rm -f build/autoconf/lt~obsolete.m4
rm -f build/autoconf/missing
+rm -f build/autoconf/test-driver
rm -f build/pkgconfig/libarchive.pc
rm -f build/version.old
+rm -f cat/test/list.h
rm -f config.h
rm -f config.h.in
rm -f config.log
diff --git a/build/cmake/CreatePkgConfigFile.cmake b/build/cmake/CreatePkgConfigFile.cmake
new file mode 100644
index 000000000000..fc8529a571f2
--- /dev/null
+++ b/build/cmake/CreatePkgConfigFile.cmake
@@ -0,0 +1,33 @@
+# - Generate a libarchive.pc like autotools for pkg-config
+#
+
+# Set the required variables (we use the same input file as autotools)
+SET(prefix ${CMAKE_INSTALL_PREFIX})
+SET(exec_prefix \${prefix})
+SET(libdir \${exec_prefix}/lib)
+SET(includedir \${prefix}/include)
+# Now, this is not particularly pretty, nor is it terribly accurate...
+# Loop over all our additional libs
+FOREACH(mylib ${ADDITIONAL_LIBS})
+ # Extract the filename from the absolute path
+ GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE)
+ # Strip the lib prefix
+ STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name})
+ # Append it to our LIBS string
+ SET(LIBS "${LIBS} -l${mylib_name}")
+ENDFOREACH()
+# libxml2 is easier, since it's already using pkg-config
+FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS})
+ SET(LIBS "${LIBS} ${mylib}")
+ENDFOREACH()
+# FIXME: The order of the libraries doesn't take dependencies into account,
+# thus there's a good chance it'll make some binutils versions unhappy...
+# This only affects Libs.private (looked up for static builds) though.
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+ @ONLY)
+# And install it, of course ;).
+IF(ENABLE_INSTALL)
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+ DESTINATION "lib/pkgconfig")
+ENDIF()
diff --git a/build/cmake/LibarchiveCheckCSourceCompiles.cmake b/build/cmake/LibarchiveCheckCSourceCompiles.cmake
deleted file mode 100644
index 6b6f59334da4..000000000000
--- a/build/cmake/LibarchiveCheckCSourceCompiles.cmake
+++ /dev/null
@@ -1,106 +0,0 @@
-# - Check if given C source compiles and links into an executable
-# CHECK_C_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
-# <code> - source code to try to compile, must define 'main'
-# <var> - variable to store whether the source code compiled
-# <fail-regex> - fail if test output matches this regex
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-
-#=============================================================================
-# Copyright 2005-2009 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-#
-# Extra arguments added by libarchive
-# CMAKE_REQUIRED_LINKER_FLAGS = string of linker command line flags
-#
-
-include(CMakeExpandImportedTargets)
-
-
-macro(LIBARCHIVE_CHECK_C_SOURCE_COMPILES SOURCE VAR)
- if("${VAR}" MATCHES "^${VAR}$")
- set(_FAIL_REGEX)
- set(_key)
- foreach(arg ${ARGN})
- if("${arg}" MATCHES "^(FAIL_REGEX)$")
- set(_key "${arg}")
- elseif(_key)
- list(APPEND _${_key} "${arg}")
- else()
- message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
- endif()
- endforeach()
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
- if(CMAKE_REQUIRED_LIBRARIES)
- # this one translates potentially used imported library targets to their files on disk
- CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
- set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
- "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
- else()
- set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
- endif()
- if(CMAKE_REQUIRED_INCLUDES)
- set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
- "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
- else()
- set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
- endif()
- if(CMAKE_REQUIRED_LINKER_FLAGS)
- set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS
- "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
- else()
- set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS)
- endif()
- file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
- "${SOURCE}\n")
-
- message(STATUS "Performing Test ${VAR}")
- try_compile(${VAR}
- ${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS}
- "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
- "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
- OUTPUT_VARIABLE OUTPUT)
-
- foreach(_regex ${_FAIL_REGEX})
- if("${OUTPUT}" MATCHES "${_regex}")
- set(${VAR} 0)
- endif()
- endforeach()
-
- if(${VAR})
- set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- message(STATUS "Performing Test ${VAR} - Success")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
- "${OUTPUT}\n"
- "Source file was:\n${SOURCE}\n")
- else()
- message(STATUS "Performing Test ${VAR} - Failed")
- set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
- "${OUTPUT}\n"
- "Source file was:\n${SOURCE}\n")
- endif()
- endif()
-endmacro()
-
diff --git a/build/cmake/LibarchiveCheckCSourceRuns.cmake b/build/cmake/LibarchiveCheckCSourceRuns.cmake
deleted file mode 100644
index 498f52265aca..000000000000
--- a/build/cmake/LibarchiveCheckCSourceRuns.cmake
+++ /dev/null
@@ -1,102 +0,0 @@
-# - Check if the given C source code compiles and runs.
-# CHECK_C_SOURCE_RUNS(<code> <var>)
-# <code> - source code to try to compile
-# <var> - variable to store the result
-# (1 for success, empty for failure)
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-
-#=============================================================================
-# Copyright 2006-2009 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-#
-# Extra arguments added by libarchive
-# CMAKE_REQUIRED_LINKER_FLAGS = string of linker command line flags
-#
-
-include(CMakeExpandImportedTargets)
-
-
-macro(LIBARCHIVE_CHECK_C_SOURCE_RUNS SOURCE VAR)
- if("${VAR}" MATCHES "^${VAR}$")
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
- if(CMAKE_REQUIRED_LIBRARIES)
- # this one translates potentially used imported library targets to their files on disk
- CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
- set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
- "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
- else()
- set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
- endif()
- if(CMAKE_REQUIRED_INCLUDES)
- set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
- "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
- else()
- set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
- endif()
- if(CMAKE_REQUIRED_LINKER_FLAGS)
- set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS
- "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
- else()
- set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS)
- endif()
- file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
- "${SOURCE}\n")
-
- message(STATUS "Performing Test ${VAR}")
- try_run(${VAR}_EXITCODE ${VAR}_COMPILED
- ${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS}
- -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
- "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
- "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
- COMPILE_OUTPUT_VARIABLE OUTPUT)
- # if it did not compile make the return value fail code of 1
- if(NOT ${VAR}_COMPILED)
- set(${VAR}_EXITCODE 1)
- endif()
- # if the return value was 0 then it worked
- if("${${VAR}_EXITCODE}" EQUAL 0)
- set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- message(STATUS "Performing Test ${VAR} - Success")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
- "${OUTPUT}\n"
- "Return value: ${${VAR}}\n"
- "Source file was:\n${SOURCE}\n")
- else()
- if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
- set(${VAR} "${${VAR}_EXITCODE}")
- else()
- set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
- endif()
-
- message(STATUS "Performing Test ${VAR} - Failed")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
- "${OUTPUT}\n"
- "Return value: ${${VAR}_EXITCODE}\n"
- "Source file was:\n${SOURCE}\n")
-
- endif()
- endif()
-endmacro()
-
diff --git a/build/cmake/LibarchiveCodeCoverage.cmake b/build/cmake/LibarchiveCodeCoverage.cmake
new file mode 100644
index 000000000000..297b886ccf05
--- /dev/null
+++ b/build/cmake/LibarchiveCodeCoverage.cmake
@@ -0,0 +1,68 @@
+#################################################################
+# Adds a build target called "coverage" for code coverage.
+#
+# This compiles the code using special GCC flags, run the tests,
+# and then generates a nice HTML output. This new "coverage" make
+# target will only be available if you build using GCC in Debug
+# mode. If any of the required programs (lcov and genhtml) were
+# not found, a FATAL_ERROR message is printed.
+#
+# If not already done, this code will set ENABLE_TEST to ON.
+#
+# To build the code coverage and open it in your browser do this:
+#
+# mkdir debug
+# cd debug
+# cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
+# make -j4
+# make coverage
+# xdg-open coverage/index.html
+#################################################################
+
+# Find programs we need
+FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable")
+FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable")
+MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
+
+# Check, compiler, build types and programs are available
+IF(NOT CMAKE_COMPILER_IS_GNUCC)
+MESSAGE(FATAL_ERROR "Coverage can only be built on GCC")
+ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode")
+ELSEIF(NOT LCOV_EXECUTABLE)
+MESSAGE(FATAL_ERROR "lcov executable not found")
+ELSEIF(NOT GENHTML_EXECUTABLE)
+MESSAGE(FATAL_ERROR "genhtml executable not found")
+ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
+
+# Enable testing if not already done
+SET(ENABLE_TEST ON)
+
+#################################################################
+# Set special compiler and linker flags for test coverage
+#################################################################
+# 0. Enable debug: -g
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+# 1. Disable optimizations: -O0
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
+# 2. Enable all kind of warnings:
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W")
+# 3. Enable special coverage flag (HINT: --coverage is a synonym for -fprofile-arcs -ftest-coverage)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
+#################################################################
+
+ADD_CUSTOM_TARGET(coverage
+COMMAND ${CMAKE_COMMAND} -E echo "Beginning test coverage. Output is written to coverage.log."
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-1/5: Reset all execution counts to zero"
+COMMAND ${LCOV_EXECUTABLE} --directory . --zerocounters > coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-2/5: Run testrunner"
+COMMAND ${CMAKE_CTEST_COMMAND} >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-3/5: Collect coverage data"
+COMMAND ${LCOV_EXECUTABLE} --capture --directory . --output-file "./coverage.info" >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-4/5: Generate HTML from coverage data"
+COMMAND ${GENHTML_EXECUTABLE} "coverage.info" --title="libarchive-${LIBARCHIVE_VERSION_STRING}" --show-details --legend --output-directory "./coverage" >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-5/5: Open test coverage HTML output in browser: xdg-open ./coverage/index.html"
+COMMENT "Runs testrunner and generates coverage output (formats: .info and .html)")
+
diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in
index c04314ee5e32..64f4d4df1789 100644
--- a/build/cmake/config.h.in
+++ b/build/cmake/config.h.in
@@ -63,7 +63,7 @@ typedef long long int64_t;
* Similarly for int32_t
*/
#if !defined(HAVE_INT32_T) && SIZE_OF_INT == 4
-typedef long int32_t;
+typedef int int32_t;
#define HAVE_INT32_T
#endif
@@ -170,8 +170,6 @@ typedef unsigned char uint8_t;
/* Define intmax_t and uintmax_t if they are not already defined. */
#if !defined(HAVE_INTMAX_T)
typedef int64_t intmax_t;
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
#endif
#if !defined(HAVE_UINTMAX_T)
@@ -289,6 +287,9 @@ typedef uint64_t uintmax_t;
/* Version number of bsdtar */
#cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}"
+/* Version number of bsdcat */
+#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}"
+
/* Define to 1 if you have the `acl_create_entry' function. */
#cmakedefine HAVE_ACL_CREATE_ENTRY 1
@@ -325,9 +326,15 @@ typedef uint64_t uintmax_t;
/* True for systems with POSIX ACL support */
#cmakedefine HAVE_ACL_USER 1
+/* Define to 1 if you have the `arc4random_buf' function. */
+#cmakedefine HAVE_ARC4RANDOM_BUF 1
+
/* Define to 1 if you have the <attr/xattr.h> header file. */
#cmakedefine HAVE_ATTR_XATTR_H 1
+/* Define to 1 if you have the <Bcrypt.h> header file. */
+#cmakedefine HAVE_BCRYPT_H 1
+
/* Define to 1 if you have the <bsdxml.h> header file. */
#cmakedefine HAVE_BSDXML_H 1
@@ -355,6 +362,14 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `cygwin_conv_path' function. */
#cmakedefine HAVE_CYGWIN_CONV_PATH 1
+/* Define to 1 if you have the declaration of `INT32_MAX', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_INT32_MAX 1
+
+/* Define to 1 if you have the declaration of `INT32_MIN', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_INT32_MIN 1
+
/* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you
don't. */
#cmakedefine HAVE_DECL_INT64_MAX 1
@@ -363,6 +378,14 @@ typedef uint64_t uintmax_t;
don't. */
#cmakedefine HAVE_DECL_INT64_MIN 1
+/* Define to 1 if you have the declaration of `INTMAX_MAX', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_INTMAX_MAX 1
+
+/* Define to 1 if you have the declaration of `INTMAX_MIN', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_INTMAX_MIN 1
+
/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you
don't. */
#cmakedefine HAVE_DECL_SIZE_MAX 1
@@ -383,6 +406,10 @@ typedef uint64_t uintmax_t;
don't. */
#cmakedefine HAVE_DECL_UINT64_MAX 1
+/* Define to 1 if you have the declaration of `UINTMAX_MAX', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_UINTMAX_MAX 1
+
/* Define to 1 if you have the <direct.h> header file. */
#cmakedefine HAVE_DIRECT_H 1
@@ -576,12 +603,21 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `bz2' library (-lbz2). */
#cmakedefine HAVE_LIBBZ2 1
+/* Define to 1 if you have the `charset' library (-lcharset). */
+#cmakedefine HAVE_LIBCHARSET 1
+
+/* Define to 1 if you have the `crypto' library (-lcrypto). */
+#cmakedefine HAVE_LIBCRYPTO 1
+
/* Define to 1 if you have the `expat' library (-lexpat). */
#cmakedefine HAVE_LIBEXPAT 1
/* Define to 1 if you have the `gcc' library (-lgcc). */
#cmakedefine HAVE_LIBGCC 1
+/* Define to 1 if you have the `lz4' library (-llz4). */
+#cmakedefine HAVE_LIBLZ4 1
+
/* Define to 1 if you have the `lzma' library (-llzma). */
#cmakedefine HAVE_LIBLZMA 1
@@ -673,6 +709,12 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `lutimes' function. */
#cmakedefine HAVE_LUTIMES 1
+/* Define to 1 if you have the <lz4hc.h> header file. */
+#cmakedefine HAVE_LZ4HC_H 1
+
+/* Define to 1 if you have the <lz4.h> header file. */
+#cmakedefine HAVE_LZ4_H 1
+
/* Define to 1 if you have the <lzmadec.h> header file. */
#cmakedefine HAVE_LZMADEC_H 1
@@ -709,9 +751,18 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#cmakedefine HAVE_NDIR_H 1
+/* Define to 1 if you have the <nettle/aes.h> header file. */
+#cmakedefine HAVE_NETTLE_AES_H 1
+
+/* Define to 1 if you have the <nettle/hmac.h> header file. */
+#cmakedefine HAVE_NETTLE_HMAC_H 1
+
/* Define to 1 if you have the <nettle/md5.h> header file. */
#cmakedefine HAVE_NETTLE_MD5_H 1
+/* Define to 1 if you have the <nettle/pbkdf2.h> header file. */
+#cmakedefine HAVE_NETTLE_PBKDF2_H 1
+
/* Define to 1 if you have the <nettle/ripemd160.h> header file. */
#cmakedefine HAVE_NETTLE_RIPEMD160_H 1
@@ -733,6 +784,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `pipe' function. */
#cmakedefine HAVE_PIPE 1
+/* Define to 1 if you have the `PKCS5_PBKDF2_HMAC_SHA1' function. */
+#cmakedefine HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
+
/* Define to 1 if you have the `poll' function. */
#cmakedefine HAVE_POLL 1
@@ -745,6 +799,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <process.h> header file. */
#cmakedefine HAVE_PROCESS_H 1
+/* Define to 1 if you have the <pthread.h> header file. */
+#cmakedefine HAVE_PTHREAD_H 1
+
/* Define to 1 if you have the <pwd.h> header file. */
#cmakedefine HAVE_PWD_H 1
@@ -757,6 +814,12 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `readlinkat' function. */
#cmakedefine HAVE_READLINKAT 1
+/* Define to 1 if you have the `readpassphrase' function. */
+#cmakedefine HAVE_READPASSPHRASE 1
+
+/* Define to 1 if you have the <readpassphrase.h> header file. */
+#cmakedefine HAVE_READPASSPHRASE_H 1
+
/* Define to 1 if you have the <regex.h> header file. */
#cmakedefine HAVE_REGEX_H 1
@@ -1012,6 +1075,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `wmemcpy' function. */
#cmakedefine HAVE_WMEMCPY 1
+/* Define to 1 if you have the `wmemmove' function. */
+#cmakedefine HAVE_WMEMMOVE 1
+
/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */
#cmakedefine HAVE_WORKING_EXT2_IOC_GETFLAGS 1
@@ -1105,9 +1171,18 @@ typedef uint64_t uintmax_t;
/* Define for large files, on AIX-style hosts. */
#cmakedefine _LARGE_FILES ${_LARGE_FILES}
-/* Define for Windows to use Windows 2000+ APIs. */
+/* Define to control Windows SDK version */
+#ifndef NTDDI_VERSION
+#cmakedefine NTDDI_VERSION ${NTDDI_VERSION}
+#endif // NTDDI_VERSION
+
+#ifndef _WIN32_WINNT
#cmakedefine _WIN32_WINNT ${_WIN32_WINNT}
+#endif // _WIN32_WINNT
+
+#ifndef WINVER
#cmakedefine WINVER ${WINVER}
+#endif // WINVER
/* Define to empty if `const' does not conform to ANSI C. */
#cmakedefine const ${const}
diff --git a/build/version b/build/version
index 937b126a2ede..595378f1050c 100644
--- a/build/version
+++ b/build/version
@@ -1 +1 @@
-3001002
+3002000
diff --git a/cat/CMakeLists.txt b/cat/CMakeLists.txt
new file mode 100644
index 000000000000..4fe6354b3131
--- /dev/null
+++ b/cat/CMakeLists.txt
@@ -0,0 +1,37 @@
+############################################
+#
+# How to build bsdcat
+#
+############################################
+IF(ENABLE_CAT)
+
+ SET(bsdcat_SOURCES
+ bsdcat.c
+ bsdcat.h
+ bsdcat_platform.h
+ cmdline.c
+ ../libarchive_fe/err.c
+ ../libarchive_fe/err.h
+ ../libarchive_fe/lafe_platform.h
+ )
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
+
+ # bsdcat documentation
+ SET(bsdcat_MANS bsdcat.1)
+
+ # How to build bsdcat
+ ADD_EXECUTABLE(bsdcat ${bsdcat_SOURCES})
+ IF(ENABLE_CAT_SHARED)
+ TARGET_LINK_LIBRARIES(bsdcat archive ${ADDITIONAL_LIBS})
+ ELSE(ENABLE_CAT_SHARED)
+ TARGET_LINK_LIBRARIES(bsdcat archive_static ${ADDITIONAL_LIBS})
+ SET_TARGET_PROPERTIES(bsdcat PROPERTIES COMPILE_DEFINITIONS
+ LIBARCHIVE_STATIC)
+ ENDIF(ENABLE_CAT_SHARED)
+
+ # Installation rules
+ INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
+ INSTALL_MAN(${bsdcat_MANS})
+ENDIF(ENABLE_CAT)
+
+add_subdirectory(test)
diff --git a/cat/bsdcat.1 b/cat/bsdcat.1
new file mode 100644
index 000000000000..4f82b1e57c06
--- /dev/null
+++ b/cat/bsdcat.1
@@ -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 ,
diff --git a/cat/bsdcat.c b/cat/bsdcat.c
new file mode 100644
index 000000000000..af140e0001c7
--- /dev/null
+++ b/cat/bsdcat.c
@@ -0,0 +1,146 @@
+/*-
+ * Copyright (c) 2011-2014, Mike Kazantsev
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bsdcat_platform.h"
+__FBSDID("$FreeBSD$");
+
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "bsdcat.h"
+#include "err.h"
+
+#define BYTES_PER_BLOCK (20*512)
+
+struct archive *a;
+struct archive_entry *ae;
+char *bsdcat_current_path;
+int exit_status = 0;
+
+
+void
+usage(FILE *stream, int eval)
+{
+ const char *p;
+ p = lafe_getprogname();
+ fprintf(stream,
+ "Usage: %s [-h] [--help] [--version] [--] [filenames...]\n", p);
+ exit(eval);
+}
+
+static void
+version(void)
+{
+ printf("bsdcat %s - %s\n",
+ BSDCAT_VERSION_STRING,
+ archive_version_details());
+ exit(0);
+}
+
+void
+bsdcat_next()
+{
+ a = archive_read_new();
+ archive_read_support_filter_all(a);
+ archive_read_support_format_empty(a);
+ archive_read_support_format_raw(a);
+}
+
+void
+bsdcat_print_error(void)
+{
+ lafe_warnc(0, "%s: %s",
+ bsdcat_current_path, archive_error_string(a));
+ exit_status = 1;
+}
+
+void
+bsdcat_read_to_stdout(char* filename)
+{
+ int r;
+
+ if (archive_read_open_filename(a, filename, BYTES_PER_BLOCK)
+ != ARCHIVE_OK)
+ bsdcat_print_error();
+ else if (r = archive_read_next_header(a, &ae),
+ r != ARCHIVE_OK && r != ARCHIVE_EOF)
+ bsdcat_print_error();
+ else if (r == ARCHIVE_EOF)
+ /* for empty payloads don't try and read data */
+ ;
+ else if (archive_read_data_into_fd(a, 1) != ARCHIVE_OK)
+ bsdcat_print_error();
+ if (archive_read_free(a) != ARCHIVE_OK)
+ bsdcat_print_error();
+}
+
+int
+main(int argc, char **argv)
+{
+ struct bsdcat *bsdcat, bsdcat_storage;
+ int c;
+
+ bsdcat = &bsdcat_storage;
+ memset(bsdcat, 0, sizeof(*bsdcat));
+
+ lafe_setprogname(*argv, "bsdcat");
+
+ bsdcat->argv = argv;
+ bsdcat->argc = argc;
+
+ while ((c = bsdcat_getopt(bsdcat)) != -1) {
+ switch (c) {
+ case 'h':
+ usage(stdout, 0);
+ break;
+ case OPTION_VERSION:
+ version();
+ break;
+ default:
+ usage(stderr, 1);
+ }
+ }
+
+ bsdcat_next();
+ if (*bsdcat->argv == NULL) {
+ bsdcat_current_path = "<stdin>";
+ bsdcat_read_to_stdout(NULL);
+ } else
+ while (*bsdcat->argv) {
+ bsdcat_current_path = *bsdcat->argv++;
+ bsdcat_read_to_stdout(bsdcat_current_path);
+ bsdcat_next();
+ }
+
+ exit(exit_status);
+}
diff --git a/cat/bsdcat.h b/cat/bsdcat.h
new file mode 100644
index 000000000000..ca603d3d6f89
--- /dev/null
+++ b/cat/bsdcat.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2014, Mike Kazantsev
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if defined(PLATFORM_CONFIG_H)
+/* Use hand-built config.h in environments that need it. */
+#include PLATFORM_CONFIG_H
+#else
+/* Not having a config.h of some sort is a serious problem. */
+#include "config.h"
+#endif
+
+#include <archive.h>
+#include <archive_entry.h>
+
+struct bsdcat {
+ /* Option parser state */
+ int getopt_state;
+ char *getopt_word;
+
+ /* Miscellaneous state information */
+ int argc;
+ char **argv;
+ const char *argument;
+};
+
+enum {
+ OPTION_VERSION
+};
+
+int bsdcat_getopt(struct bsdcat *);
+void usage(FILE *stream, int eval);
+void bsdcat_next(void);
+void bsdcat_print_error(void);
+void bsdcat_read_to_stdout(char* filename);
diff --git a/cat/bsdcat_platform.h b/cat/bsdcat_platform.h
new file mode 100644
index 000000000000..ff9245e84811
--- /dev/null
+++ b/cat/bsdcat_platform.h
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * This header is the first thing included in any of the bsdtar
+ * source files. As far as possible, platform-specific issues should
+ * be dealt with here and not within individual source files.
+ */
+
+#ifndef BSDCAT_PLATFORM_H_INCLUDED
+#define BSDCAT_PLATFORM_H_INCLUDED
+
+#if defined(PLATFORM_CONFIG_H)
+/* Use hand-built config.h in environments that need it. */
+#include PLATFORM_CONFIG_H
+#else
+/* Not having a config.h of some sort is a serious problem. */
+#include "config.h"
+#endif
+
+/* Get a real definition for __FBSDID if we can */
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+
+/* If not, define it so as to avoid dangling semicolons. */
+#ifndef __FBSDID
+#define __FBSDID(a) struct _undefined_hack
+#endif
+
+#ifdef HAVE_LIBARCHIVE
+/* If we're using the platform libarchive, include system headers. */
+#include <archive.h>
+#include <archive_entry.h>
+#else
+/* Otherwise, include user headers. */
+#include "archive.h"
+#include "archive_entry.h"
+#endif
+
+/* How to mark functions that don't return. */
+/* This facilitates use of some newer static code analysis tools. */
+#undef __LA_DEAD
+#if defined(__GNUC__) && (__GNUC__ > 2 || \
+ (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_DEAD __attribute__((__noreturn__))
+#else
+#define __LA_DEAD
+#endif
+
+#endif /* !BSDCAT_PLATFORM_H_INCLUDED */
diff --git a/cat/cmdline.c b/cat/cmdline.c
new file mode 100644
index 000000000000..cae19beb7d4c
--- /dev/null
+++ b/cat/cmdline.c
@@ -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);
+}
diff --git a/cat/test/CMakeLists.txt b/cat/test/CMakeLists.txt
new file mode 100644
index 000000000000..0990bcf272a7
--- /dev/null
+++ b/cat/test/CMakeLists.txt
@@ -0,0 +1,65 @@
+############################################
+#
+# How to build bsdtar_test
+#
+############################################
+IF(ENABLE_CAT AND ENABLE_TEST)
+ SET(bsdcat_test_SOURCES
+ ../../test_utils/test_utils.c
+ main.c
+ test.h
+ test_0.c
+ test_empty_gz.c
+ test_empty_lz4.c
+ test_empty_xz.c
+ test_error.c
+ test_error_mixed.c
+ test_expand_Z.c
+ test_expand_bz2.c
+ test_expand_gz.c
+ test_expand_lz4.c
+ test_expand_mixed.c
+ test_expand_plain.c
+ test_expand_xz.c
+ test_help.c
+ test_version.c
+ )
+
+ #
+ # Register target
+ #
+ ADD_EXECUTABLE(bsdcat_test ${bsdcat_test_SOURCES})
+ SET_PROPERTY(TARGET bsdcat_test PROPERTY COMPILE_DEFINITIONS LIST_H)
+
+ #
+ # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
+ #
+ GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
+ ${CMAKE_CURRENT_LIST_FILE} ${bsdcat_test_SOURCES})
+ SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
+ ${CMAKE_CURRENT_BINARY_DIR})
+
+ # list.h has a line DEFINE_TEST(testname) for every
+ # test. We can use that to define the tests for cmake by
+ # defining a DEFINE_TEST macro and reading list.h in.
+ MACRO (DEFINE_TEST _testname)
+ ADD_TEST(
+ NAME bsdcat_${_testname}
+ COMMAND bsdcat_test -vv
+ -p $<TARGET_FILE:bsdcat>
+ -r ${CMAKE_CURRENT_SOURCE_DIR}
+ ${_testname})
+ ENDMACRO (DEFINE_TEST _testname)
+
+ INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
+
+ # Experimental new test handling
+ ADD_CUSTOM_TARGET(run_bsdcat_test
+ COMMAND bsdcat_test -p $<TARGET_FILE:bsdcat>
+ -r ${CMAKE_CURRENT_SOURCE_DIR})
+ ADD_DEPENDENCIES(run_bsdcat_test bsdcat)
+ ADD_DEPENDENCIES(run_all_tests run_bsdcat_test)
+
+ENDIF(ENABLE_CAT AND ENABLE_TEST)
diff --git a/cat/test/main.c b/cat/test/main.c
new file mode 100644
index 000000000000..319f68c774f0
--- /dev/null
+++ b/cat/test/main.c
@@ -0,0 +1,2969 @@
+/*
+ * Copyright (c) 2003-2009 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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"
+#include "test_utils.h"
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <errno.h>
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+/*
+ * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
+ * As the include guards don't agree, the order of include is important.
+ */
+#ifdef HAVE_LINUX_EXT2_FS_H
+#include <linux/ext2_fs.h> /* for Linux file flags */
+#endif
+#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__)
+#include <ext2fs/ext2_fs.h> /* Linux file flags, broken on Cygwin */
+#endif
+#include <limits.h>
+#include <locale.h>
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+#include <stdarg.h>
+#include <time.h>
+
+/*
+ * This same file is used pretty much verbatim for all test harnesses.
+ *
+ * The next few lines are the only differences.
+ * TODO: Move this into a separate configuration header, have all test
+ * suites share one copy of this file.
+ */
+#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) ? "" : "")
+
+/*
+ *
+ * Windows support routines
+ *
+ * Note: Configuration is a tricky issue. Using HAVE_* feature macros
+ * in the test harness is dangerous because they cover up
+ * configuration errors. The classic example of this is omitting a
+ * configure check. If libarchive and libarchive_test both look for
+ * the same feature macro, such errors are hard to detect. Platform
+ * macros (e.g., _WIN32 or __GNUC__) are a little better, but can
+ * easily lead to very messy code. It's best to limit yourself
+ * to only the most generic programming techniques in the test harness
+ * and thus avoid conditionals altogether. Where that's not possible,
+ * try to minimize conditionals by grouping platform-specific tests in
+ * one place (e.g., test_acl_freebsd) or by adding new assert()
+ * functions (e.g., assertMakeHardlink()) to cover up platform
+ * differences. Platform-specific coding in libarchive_test is often
+ * a symptom that some capability is missing from libarchive itself.
+ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <io.h>
+#include <direct.h>
+#include <windows.h>
+#ifndef F_OK
+#define F_OK (0)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(m) ((m) & _S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m) ((m) & _S_IFREG)
+#endif
+#if !defined(__BORLANDC__)
+#define access _access
+#undef chdir
+#define chdir _chdir
+#endif
+#ifndef fileno
+#define fileno _fileno
+#endif
+/*#define fstat _fstat64*/
+#if !defined(__BORLANDC__)
+#define getcwd _getcwd
+#endif
+#define lstat stat
+/*#define lstat _stat64*/
+/*#define stat _stat64*/
+#define rmdir _rmdir
+#if !defined(__BORLANDC__)
+#define strdup _strdup
+#define umask _umask
+#endif
+#define int64_t __int64
+#endif
+
+#if defined(HAVE__CrtSetReportMode)
+# include <crtdbg.h>
+#endif
+
+/* Path to working directory for current test */
+const char *testworkdir;
+#ifdef PROGRAM
+/* Pathname of exe to be tested. */
+const char *testprogfile;
+/* Name of exe to use in printf-formatted command strings. */
+/* On Windows, this includes leading/trailing quotes. */
+const char *testprog;
+#endif
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static void *GetFunctionKernel32(const char *);
+static int my_CreateSymbolicLinkA(const char *, const char *, int);
+static int my_CreateHardLinkA(const char *, const char *);
+static int my_GetFileInformationByName(const char *,
+ BY_HANDLE_FILE_INFORMATION *);
+
+static void *
+GetFunctionKernel32(const char *name)
+{
+ static HINSTANCE lib;
+ static int set;
+ if (!set) {
+ set = 1;
+ lib = LoadLibrary("kernel32.dll");
+ }
+ if (lib == NULL) {
+ fprintf(stderr, "Can't load kernel32.dll?!\n");
+ exit(1);
+ }
+ return (void *)GetProcAddress(lib, name);
+}
+
+static int
+my_CreateSymbolicLinkA(const char *linkname, const char *target, int flags)
+{
+ static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, DWORD);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = GetFunctionKernel32("CreateSymbolicLinkA");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, flags);
+}
+
+static int
+my_CreateHardLinkA(const char *linkname, const char *target)
+{
+ static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = GetFunctionKernel32("CreateHardLinkA");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, NULL);
+}
+
+static int
+my_GetFileInformationByName(const char *path, BY_HANDLE_FILE_INFORMATION *bhfi)
+{
+ HANDLE h;
+ int r;
+
+ memset(bhfi, 0, sizeof(*bhfi));
+ h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
+ OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ return (0);
+ r = GetFileInformationByHandle(h, bhfi);
+ CloseHandle(h);
+ return (r);
+}
+#endif
+
+#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__)
+static void
+invalid_parameter_handler(const wchar_t * expression,
+ const wchar_t * function, const wchar_t * file,
+ unsigned int line, uintptr_t pReserved)
+{
+ /* nop */
+}
+#endif
+
+/*
+ *
+ * OPTIONS FLAGS
+ *
+ */
+
+/* Enable core dump on failure. */
+static int dump_on_failure = 0;
+/* Default is to remove temp dirs and log data for successful tests. */
+static int keep_temp_files = 0;
+/* Default is to run the specified tests once and report errors. */
+static int until_failure = 0;
+/* Default is to just report pass/fail for each test. */
+static int verbosity = 0;
+#define VERBOSITY_SUMMARY_ONLY -1 /* -q */
+#define VERBOSITY_PASSFAIL 0 /* Default */
+#define VERBOSITY_LIGHT_REPORT 1 /* -v */
+#define VERBOSITY_FULL 2 /* -vv */
+/* A few places generate even more output for verbosity > VERBOSITY_FULL,
+ * mostly for debugging the test harness itself. */
+/* Cumulative count of assertion failures. */
+static int failures = 0;
+/* Cumulative count of reported skips. */
+static int skips = 0;
+/* Cumulative count of assertions checked. */
+static int assertions = 0;
+
+/* Directory where uuencoded reference files can be found. */
+static const char *refdir;
+
+/*
+ * Report log information selectively to console and/or disk log.
+ */
+static int log_console = 0;
+static FILE *logfile;
+static void
+vlogprintf(const char *fmt, va_list ap)
+{
+#ifdef va_copy
+ va_list lfap;
+ va_copy(lfap, ap);
+#endif
+ if (log_console)
+ vfprintf(stdout, fmt, ap);
+ if (logfile != NULL)
+#ifdef va_copy
+ vfprintf(logfile, fmt, lfap);
+ va_end(lfap);
+#else
+ vfprintf(logfile, fmt, ap);
+#endif
+}
+
+static void
+logprintf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vlogprintf(fmt, ap);
+ va_end(ap);
+}
+
+/* Set up a message to display only if next assertion fails. */
+static char msgbuff[4096];
+static const char *msg, *nextmsg;
+void
+failure(const char *fmt, ...)
+{
+ va_list ap;
+ if (fmt == NULL) {
+ nextmsg = NULL;
+ } else {
+ va_start(ap, fmt);
+ vsprintf(msgbuff, fmt, ap);
+ va_end(ap);
+ nextmsg = msgbuff;
+ }
+}
+
+/*
+ * Copy arguments into file-local variables.
+ * This was added to permit vararg assert() functions without needing
+ * variadic wrapper macros. Turns out that the vararg capability is almost
+ * never used, so almost all of the vararg assertions can be simplified
+ * by removing the vararg capability and reworking the wrapper macro to
+ * pass __FILE__, __LINE__ directly into the function instead of using
+ * this hook. I suspect this machinery is used so rarely that we
+ * would be better off just removing it entirely. That would simplify
+ * the code here noticeably.
+ */
+static const char *skipping_filename;
+static int skipping_line;
+void skipping_setup(const char *filename, int line)
+{
+ skipping_filename = filename;
+ skipping_line = line;
+}
+
+/* Called at the beginning of each assert() function. */
+static void
+assertion_count(const char *file, int line)
+{
+ (void)file; /* UNUSED */
+ (void)line; /* UNUSED */
+ ++assertions;
+ /* Proper handling of "failure()" message. */
+ msg = nextmsg;
+ nextmsg = NULL;
+ /* Uncomment to print file:line after every assertion.
+ * Verbose, but occasionally useful in tracking down crashes. */
+ /* printf("Checked %s:%d\n", file, line); */
+}
+
+/*
+ * For each test source file, we remember how many times each
+ * assertion was reported. Cleared before each new test,
+ * used by test_summarize().
+ */
+static struct line {
+ int count;
+ int skip;
+} failed_lines[10000];
+const char *failed_filename;
+
+/* Count this failure, setup up log destination and handle initial report. */
+static void
+failure_start(const char *filename, int line, const char *fmt, ...)
+{
+ va_list ap;
+
+ /* Record another failure for this line. */
+ ++failures;
+ failed_filename = filename;
+ failed_lines[line].count++;
+
+ /* Determine whether to log header to console. */
+ switch (verbosity) {
+ case VERBOSITY_LIGHT_REPORT:
+ log_console = (failed_lines[line].count < 2);
+ break;
+ default:
+ log_console = (verbosity >= VERBOSITY_FULL);
+ }
+
+ /* Log file:line header for this failure */
+ va_start(ap, fmt);
+#if _MSC_VER
+ logprintf("%s(%d): ", filename, line);
+#else
+ logprintf("%s:%d: ", filename, line);
+#endif
+ vlogprintf(fmt, ap);
+ va_end(ap);
+ logprintf("\n");
+
+ if (msg != NULL && msg[0] != '\0') {
+ logprintf(" Description: %s\n", msg);
+ msg = NULL;
+ }
+
+ /* Determine whether to log details to console. */
+ if (verbosity == VERBOSITY_LIGHT_REPORT)
+ log_console = 0;
+}
+
+/* Complete reporting of failed tests. */
+/*
+ * The 'extra' hook here is used by libarchive to include libarchive
+ * error messages with assertion failures. It could also be used
+ * to add strerror() output, for example. Just define the EXTRA_DUMP()
+ * macro appropriately.
+ */
+static void
+failure_finish(void *extra)
+{
+ (void)extra; /* UNUSED (maybe) */
+#ifdef EXTRA_DUMP
+ if (extra != NULL) {
+ logprintf(" errno: %d\n", EXTRA_ERRNO(extra));
+ logprintf(" detail: %s\n", EXTRA_DUMP(extra));
+ }
+#endif
+
+ if (dump_on_failure) {
+ fprintf(stderr,
+ " *** forcing core dump so failure can be debugged ***\n");
+ abort();
+ }
+}
+
+/* Inform user that we're skipping some checks. */
+void
+test_skipping(const char *fmt, ...)
+{
+ char buff[1024];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsprintf(buff, fmt, ap);
+ va_end(ap);
+ /* Use failure() message if set. */
+ msg = nextmsg;
+ nextmsg = NULL;
+ /* failure_start() isn't quite right, but is awfully convenient. */
+ failure_start(skipping_filename, skipping_line, "SKIPPING: %s", buff);
+ --failures; /* Undo failures++ in failure_start() */
+ /* Don't failure_finish() here. */
+ /* Mark as skip, so doesn't count as failed test. */
+ failed_lines[skipping_line].skip = 1;
+ ++skips;
+}
+
+/*
+ *
+ * ASSERTIONS
+ *
+ */
+
+/* Generic assert() just displays the failed condition. */
+int
+assertion_assert(const char *file, int line, int value,
+ const char *condition, void *extra)
+{
+ assertion_count(file, line);
+ if (!value) {
+ failure_start(file, line, "Assertion failed: %s", condition);
+ failure_finish(extra);
+ }
+ return (value);
+}
+
+/* chdir() and report any errors */
+int
+assertion_chdir(const char *file, int line, const char *pathname)
+{
+ assertion_count(file, line);
+ if (chdir(pathname) == 0)
+ return (1);
+ failure_start(file, line, "chdir(\"%s\")", pathname);
+ failure_finish(NULL);
+ return (0);
+
+}
+
+/* Verify two integers are equal. */
+int
+assertion_equal_int(const char *file, int line,
+ long long v1, const char *e1, long long v2, const char *e2, void *extra)
+{
+ assertion_count(file, line);
+ if (v1 == v2)
+ return (1);
+ failure_start(file, line, "%s != %s", e1, e2);
+ logprintf(" %s=%lld (0x%llx, 0%llo)\n", e1, v1, v1, v1);
+ logprintf(" %s=%lld (0x%llx, 0%llo)\n", e2, v2, v2, v2);
+ failure_finish(extra);
+ return (0);
+}
+
+/*
+ * Utility to convert a single UTF-8 sequence.
+ */
+static int
+_utf8_to_unicode(uint32_t *pwc, const char *s, size_t n)
+{
+ static const char utf8_count[256] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 30 - 3F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 40 - 4F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 50 - 5F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 60 - 6F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 70 - 7F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 80 - 8F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* 90 - 9F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* A0 - AF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,/* B0 - BF */
+ 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* C0 - CF */
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,/* D0 - DF */
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,/* E0 - EF */
+ 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
+ };
+ int ch;
+ int cnt;
+ uint32_t wc;
+
+ *pwc = 0;
+
+ /* Sanity check. */
+ if (n == 0)
+ return (0);
+ /*
+ * Decode 1-4 bytes depending on the value of the first byte.
+ */
+ ch = (unsigned char)*s;
+ if (ch == 0)
+ return (0); /* Standard: return 0 for end-of-string. */
+ cnt = utf8_count[ch];
+
+ /* Invalide sequence or there are not plenty bytes. */
+ if (n < (size_t)cnt)
+ return (-1);
+
+ /* Make a Unicode code point from a single UTF-8 sequence. */
+ switch (cnt) {
+ case 1: /* 1 byte sequence. */
+ *pwc = ch & 0x7f;
+ return (cnt);
+ case 2: /* 2 bytes sequence. */
+ if ((s[1] & 0xc0) != 0x80) return (-1);
+ *pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
+ return (cnt);
+ case 3: /* 3 bytes sequence. */
+ if ((s[1] & 0xc0) != 0x80) return (-1);
+ if ((s[2] & 0xc0) != 0x80) return (-1);
+ wc = ((ch & 0x0f) << 12)
+ | ((s[1] & 0x3f) << 6)
+ | (s[2] & 0x3f);
+ if (wc < 0x800)
+ return (-1);/* Overlong sequence. */
+ break;
+ case 4: /* 4 bytes sequence. */
+ if (n < 4)
+ return (-1);
+ if ((s[1] & 0xc0) != 0x80) return (-1);
+ if ((s[2] & 0xc0) != 0x80) return (-1);
+ if ((s[3] & 0xc0) != 0x80) return (-1);
+ wc = ((ch & 0x07) << 18)
+ | ((s[1] & 0x3f) << 12)
+ | ((s[2] & 0x3f) << 6)
+ | (s[3] & 0x3f);
+ if (wc < 0x10000)
+ return (-1);/* Overlong sequence. */
+ break;
+ default:
+ return (-1);
+ }
+
+ /* The code point larger than 0x10FFFF is not leagal
+ * Unicode values. */
+ if (wc > 0x10FFFF)
+ return (-1);
+ /* Correctly gets a Unicode, returns used bytes. */
+ *pwc = wc;
+ return (cnt);
+}
+
+static void strdump(const char *e, const char *p, int ewidth, int utf8)
+{
+ const char *q = p;
+
+ logprintf(" %*s = ", ewidth, e);
+ if (p == NULL) {
+ logprintf("NULL\n");
+ return;
+ }
+ logprintf("\"");
+ while (*p != '\0') {
+ unsigned int c = 0xff & *p++;
+ switch (c) {
+ case '\a': logprintf("\\a"); break;
+ case '\b': logprintf("\\b"); break;
+ case '\n': logprintf("\\n"); break;
+ case '\r': logprintf("\\r"); break;
+ default:
+ if (c >= 32 && c < 127)
+ logprintf("%c", c);
+ else
+ logprintf("\\x%02X", c);
+ }
+ }
+ logprintf("\"");
+ logprintf(" (length %d)", q == NULL ? -1 : (int)strlen(q));
+
+ /*
+ * If the current string is UTF-8, dump its code points.
+ */
+ if (utf8) {
+ size_t len;
+ uint32_t uc;
+ int n;
+ int cnt = 0;
+
+ p = q;
+ len = strlen(p);
+ logprintf(" [");
+ while ((n = _utf8_to_unicode(&uc, p, len)) > 0) {
+ if (p != q)
+ logprintf(" ");
+ logprintf("%04X", uc);
+ p += n;
+ len -= n;
+ cnt++;
+ }
+ logprintf("]");
+ logprintf(" (count %d", cnt);
+ if (n < 0) {
+ logprintf(",unknown %d bytes", len);
+ }
+ logprintf(")");
+
+ }
+ logprintf("\n");
+}
+
+/* Verify two strings are equal, dump them if not. */
+int
+assertion_equal_string(const char *file, int line,
+ const char *v1, const char *e1,
+ const char *v2, const char *e2,
+ void *extra, int utf8)
+{
+ int l1, l2;
+
+ assertion_count(file, line);
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
+ return (1);
+ failure_start(file, line, "%s != %s", e1, e2);
+ l1 = (int)strlen(e1);
+ l2 = (int)strlen(e2);
+ if (l1 < l2)
+ l1 = l2;
+ strdump(e1, v1, l1, utf8);
+ strdump(e2, v2, l1, utf8);
+ failure_finish(extra);
+ return (0);
+}
+
+static void
+wcsdump(const char *e, const wchar_t *w)
+{
+ logprintf(" %s = ", e);
+ if (w == NULL) {
+ logprintf("(null)");
+ return;
+ }
+ logprintf("\"");
+ while (*w != L'\0') {
+ unsigned int c = *w++;
+ if (c >= 32 && c < 127)
+ logprintf("%c", c);
+ else if (c < 256)
+ logprintf("\\x%02X", c);
+ else if (c < 0x10000)
+ logprintf("\\u%04X", c);
+ else
+ logprintf("\\U%08X", c);
+ }
+ logprintf("\"\n");
+}
+
+#ifndef HAVE_WCSCMP
+static int
+wcscmp(const wchar_t *s1, const wchar_t *s2)
+{
+
+ while (*s1 == *s2++) {
+ if (*s1++ == L'\0')
+ return 0;
+ }
+ if (*s1 > *--s2)
+ return 1;
+ else
+ return -1;
+}
+#endif
+
+/* Verify that two wide strings are equal, dump them if not. */
+int
+assertion_equal_wstring(const char *file, int line,
+ const wchar_t *v1, const char *e1,
+ const wchar_t *v2, const char *e2,
+ void *extra)
+{
+ assertion_count(file, line);
+ if (v1 == v2)
+ return (1);
+ if (v1 != NULL && v2 != NULL && wcscmp(v1, v2) == 0)
+ return (1);
+ failure_start(file, line, "%s != %s", e1, e2);
+ wcsdump(e1, v1);
+ wcsdump(e2, v2);
+ failure_finish(extra);
+ return (0);
+}
+
+/*
+ * Pretty standard hexdump routine. As a bonus, if ref != NULL, then
+ * any bytes in p that differ from ref will be highlighted with '_'
+ * before and after the hex value.
+ */
+static void
+hexdump(const char *p, const char *ref, size_t l, size_t offset)
+{
+ size_t i, j;
+ char sep;
+
+ if (p == NULL) {
+ logprintf("(null)\n");
+ return;
+ }
+ for(i=0; i < l; i+=16) {
+ logprintf("%04x", (unsigned)(i + offset));
+ sep = ' ';
+ for (j = 0; j < 16 && i + j < l; j++) {
+ if (ref != NULL && p[i + j] != ref[i + j])
+ sep = '_';
+ logprintf("%c%02x", sep, 0xff & (int)p[i+j]);
+ if (ref != NULL && p[i + j] == ref[i + j])
+ sep = ' ';
+ }
+ for (; j < 16; j++) {
+ logprintf("%c ", sep);
+ sep = ' ';
+ }
+ logprintf("%c", sep);
+ for (j=0; j < 16 && i + j < l; j++) {
+ int c = p[i + j];
+ if (c >= ' ' && c <= 126)
+ logprintf("%c", c);
+ else
+ logprintf(".");
+ }
+ logprintf("\n");
+ }
+}
+
+/* Verify that two blocks of memory are the same, display the first
+ * block of differences if they're not. */
+int
+assertion_equal_mem(const char *file, int line,
+ const void *_v1, const char *e1,
+ const void *_v2, const char *e2,
+ size_t l, const char *ld, void *extra)
+{
+ const char *v1 = (const char *)_v1;
+ const char *v2 = (const char *)_v2;
+ size_t offset;
+
+ assertion_count(file, line);
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
+ return (1);
+ if (v1 == NULL || v2 == NULL)
+ return (0);
+
+ failure_start(file, line, "%s != %s", e1, e2);
+ logprintf(" size %s = %d\n", ld, (int)l);
+ /* Dump 48 bytes (3 lines) so that the first difference is
+ * in the second line. */
+ offset = 0;
+ while (l > 64 && memcmp(v1, v2, 32) == 0) {
+ /* Two lines agree, so step forward one line. */
+ v1 += 16;
+ v2 += 16;
+ l -= 16;
+ offset += 16;
+ }
+ logprintf(" Dump of %s\n", e1);
+ hexdump(v1, v2, l < 128 ? l : 128, offset);
+ logprintf(" Dump of %s\n", e2);
+ hexdump(v2, v1, l < 128 ? l : 128, offset);
+ logprintf("\n");
+ failure_finish(extra);
+ return (0);
+}
+
+/* Verify that a block of memory is filled with the specified byte. */
+int
+assertion_memory_filled_with(const char *file, int line,
+ const void *_v1, const char *vd,
+ size_t l, const char *ld,
+ char b, const char *bd, void *extra)
+{
+ const char *v1 = (const char *)_v1;
+ size_t c = 0;
+ size_t i;
+ (void)ld; /* UNUSED */
+
+ assertion_count(file, line);
+
+ for (i = 0; i < l; ++i) {
+ if (v1[i] == b) {
+ ++c;
+ }
+ }
+ if (c == l)
+ return (1);
+
+ failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
+ logprintf(" Only %d bytes were correct\n", (int)c);
+ failure_finish(extra);
+ return (0);
+}
+
+/* Verify that the named file exists and is empty. */
+int
+assertion_empty_file(const char *filename, int line, const char *f1)
+{
+ char buff[1024];
+ struct stat st;
+ ssize_t s;
+ FILE *f;
+
+ assertion_count(filename, line);
+
+ if (stat(f1, &st) != 0) {
+ failure_start(filename, line, "Stat failed: %s", f1);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (st.st_size == 0)
+ return (1);
+
+ failure_start(filename, line, "File should be empty: %s", f1);
+ logprintf(" File size: %d\n", (int)st.st_size);
+ logprintf(" Contents:\n");
+ f = fopen(f1, "rb");
+ if (f == NULL) {
+ logprintf(" Unable to open %s\n", f1);
+ } else {
+ s = ((off_t)sizeof(buff) < st.st_size) ?
+ (ssize_t)sizeof(buff) : (ssize_t)st.st_size;
+ s = fread(buff, 1, s, f);
+ hexdump(buff, NULL, s, 0);
+ fclose(f);
+ }
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Verify that the named file exists and is not empty. */
+int
+assertion_non_empty_file(const char *filename, int line, const char *f1)
+{
+ struct stat st;
+
+ assertion_count(filename, line);
+
+ if (stat(f1, &st) != 0) {
+ failure_start(filename, line, "Stat failed: %s", f1);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (st.st_size == 0) {
+ failure_start(filename, line, "File empty: %s", f1);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (1);
+}
+
+/* Verify that two files have the same contents. */
+/* TODO: hexdump the first bytes that actually differ. */
+int
+assertion_equal_file(const char *filename, int line, const char *fn1, const char *fn2)
+{
+ char buff1[1024];
+ char buff2[1024];
+ FILE *f1, *f2;
+ int n1, n2;
+
+ assertion_count(filename, line);
+
+ f1 = fopen(fn1, "rb");
+ f2 = fopen(fn2, "rb");
+ if (f1 == NULL || f2 == NULL) {
+ if (f1) fclose(f1);
+ if (f2) fclose(f2);
+ return (0);
+ }
+ for (;;) {
+ n1 = (int)fread(buff1, 1, sizeof(buff1), f1);
+ n2 = (int)fread(buff2, 1, sizeof(buff2), f2);
+ if (n1 != n2)
+ break;
+ if (n1 == 0 && n2 == 0) {
+ fclose(f1);
+ fclose(f2);
+ return (1);
+ }
+ if (memcmp(buff1, buff2, n1) != 0)
+ break;
+ }
+ fclose(f1);
+ fclose(f2);
+ failure_start(filename, line, "Files not identical");
+ logprintf(" file1=\"%s\"\n", fn1);
+ logprintf(" file2=\"%s\"\n", fn2);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Verify that the named file does exist. */
+int
+assertion_file_exists(const char *filename, int line, const char *f)
+{
+ assertion_count(filename, line);
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if (!_access(f, 0))
+ return (1);
+#else
+ if (!access(f, F_OK))
+ return (1);
+#endif
+ failure_start(filename, line, "File should exist: %s", f);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Verify that the named file doesn't exist. */
+int
+assertion_file_not_exists(const char *filename, int line, const char *f)
+{
+ assertion_count(filename, line);
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if (_access(f, 0))
+ return (1);
+#else
+ if (access(f, F_OK))
+ return (1);
+#endif
+ failure_start(filename, line, "File should not exist: %s", f);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Compare the contents of a file to a block of memory. */
+int
+assertion_file_contents(const char *filename, int line, const void *buff, int s, const char *fn)
+{
+ char *contents;
+ FILE *f;
+ int n;
+
+ assertion_count(filename, line);
+
+ f = fopen(fn, "rb");
+ if (f == NULL) {
+ failure_start(filename, line,
+ "File should exist: %s", fn);
+ failure_finish(NULL);
+ return (0);
+ }
+ contents = malloc(s * 2);
+ n = (int)fread(contents, 1, s * 2, f);
+ fclose(f);
+ if (n == s && memcmp(buff, contents, s) == 0) {
+ free(contents);
+ return (1);
+ }
+ failure_start(filename, line, "File contents don't match");
+ logprintf(" file=\"%s\"\n", fn);
+ if (n > 0)
+ hexdump(contents, buff, n > 512 ? 512 : n, 0);
+ else {
+ logprintf(" File empty, contents should be:\n");
+ hexdump(buff, NULL, s > 512 ? 512 : s, 0);
+ }
+ failure_finish(NULL);
+ free(contents);
+ return (0);
+}
+
+/* Check the contents of a text file, being tolerant of line endings. */
+int
+assertion_text_file_contents(const char *filename, int line, const char *buff, const char *fn)
+{
+ char *contents;
+ const char *btxt, *ftxt;
+ FILE *f;
+ int n, s;
+
+ assertion_count(filename, line);
+ f = fopen(fn, "r");
+ if (f == NULL) {
+ failure_start(filename, line,
+ "File doesn't exist: %s", fn);
+ failure_finish(NULL);
+ return (0);
+ }
+ s = (int)strlen(buff);
+ contents = malloc(s * 2 + 128);
+ n = (int)fread(contents, 1, s * 2 + 128 - 1, f);
+ if (n >= 0)
+ contents[n] = '\0';
+ fclose(f);
+ /* Compare texts. */
+ btxt = buff;
+ ftxt = (const char *)contents;
+ while (*btxt != '\0' && *ftxt != '\0') {
+ if (*btxt == *ftxt) {
+ ++btxt;
+ ++ftxt;
+ continue;
+ }
+ if (btxt[0] == '\n' && ftxt[0] == '\r' && ftxt[1] == '\n') {
+ /* Pass over different new line characters. */
+ ++btxt;
+ ftxt += 2;
+ continue;
+ }
+ break;
+ }
+ if (*btxt == '\0' && *ftxt == '\0') {
+ free(contents);
+ return (1);
+ }
+ failure_start(filename, line, "Contents don't match");
+ logprintf(" file=\"%s\"\n", fn);
+ if (n > 0) {
+ hexdump(contents, buff, n, 0);
+ logprintf(" expected\n", fn);
+ hexdump(buff, contents, s, 0);
+ } else {
+ logprintf(" File empty, contents should be:\n");
+ hexdump(buff, NULL, s, 0);
+ }
+ failure_finish(NULL);
+ free(contents);
+ return (0);
+}
+
+/* Verify that a text file contains the specified lines, regardless of order */
+/* This could be more efficient if we sorted both sets of lines, etc, but
+ * since this is used only for testing and only ever deals with a dozen or so
+ * lines at a time, this relatively crude approach is just fine. */
+int
+assertion_file_contains_lines_any_order(const char *file, int line,
+ const char *pathname, const char *lines[])
+{
+ char *buff;
+ size_t buff_size;
+ size_t expected_count, actual_count, i, j;
+ char **expected = NULL;
+ char *p, **actual = NULL;
+ char c;
+ int expected_failure = 0, actual_failure = 0;
+
+ assertion_count(file, line);
+
+ buff = slurpfile(&buff_size, "%s", pathname);
+ if (buff == NULL) {
+ failure_start(pathname, line, "Can't read file: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+
+ /* Make a copy of the provided lines and count up the expected
+ * file size. */
+ for (i = 0; lines[i] != NULL; ++i) {
+ }
+ expected_count = i;
+ if (expected_count) {
+ expected = malloc(sizeof(char *) * expected_count);
+ if (expected == NULL) {
+ failure_start(pathname, line, "Can't allocate memory");
+ failure_finish(NULL);
+ free(expected);
+ return (0);
+ }
+ for (i = 0; lines[i] != NULL; ++i) {
+ expected[i] = strdup(lines[i]);
+ }
+ }
+
+ /* Break the file into lines */
+ actual_count = 0;
+ for (c = '\0', p = buff; p < buff + buff_size; ++p) {
+ if (*p == '\x0d' || *p == '\x0a')
+ *p = '\0';
+ if (c == '\0' && *p != '\0')
+ ++actual_count;
+ c = *p;
+ }
+ if (actual_count) {
+ actual = calloc(sizeof(char *), actual_count);
+ if (actual == NULL) {
+ failure_start(pathname, line, "Can't allocate memory");
+ failure_finish(NULL);
+ free(expected);
+ return (0);
+ }
+ for (j = 0, p = buff; p < buff + buff_size;
+ p += 1 + strlen(p)) {
+ if (*p != '\0') {
+ actual[j] = p;
+ ++j;
+ }
+ }
+ }
+
+ /* Erase matching lines from both lists */
+ for (i = 0; i < expected_count; ++i) {
+ if (expected[i] == NULL)
+ continue;
+ for (j = 0; j < actual_count; ++j) {
+ if (actual[j] == NULL)
+ continue;
+ if (strcmp(expected[i], actual[j]) == 0) {
+ free(expected[i]);
+ expected[i] = NULL;
+ actual[j] = NULL;
+ break;
+ }
+ }
+ }
+
+ /* If there's anything left, it's a failure */
+ for (i = 0; i < expected_count; ++i) {
+ if (expected[i] != NULL)
+ ++expected_failure;
+ }
+ for (j = 0; j < actual_count; ++j) {
+ if (actual[j] != NULL)
+ ++actual_failure;
+ }
+ if (expected_failure == 0 && actual_failure == 0) {
+ free(buff);
+ free(expected);
+ free(actual);
+ return (1);
+ }
+ failure_start(file, line, "File doesn't match: %s", pathname);
+ for (i = 0; i < expected_count; ++i) {
+ if (expected[i] != NULL) {
+ logprintf(" Expected but not present: %s\n", expected[i]);
+ free(expected[i]);
+ }
+ }
+ for (j = 0; j < actual_count; ++j) {
+ if (actual[j] != NULL)
+ logprintf(" Present but not expected: %s\n", actual[j]);
+ }
+ failure_finish(NULL);
+ free(buff);
+ free(expected);
+ free(actual);
+ return (0);
+}
+
+/* Test that two paths point to the same file. */
+/* As a side-effect, asserts that both files exist. */
+static int
+is_hardlink(const char *file, int line,
+ const char *path1, const char *path2)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ BY_HANDLE_FILE_INFORMATION bhfi1, bhfi2;
+ int r;
+
+ assertion_count(file, line);
+ r = my_GetFileInformationByName(path1, &bhfi1);
+ if (r == 0) {
+ failure_start(file, line, "File %s can't be inspected?", path1);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = my_GetFileInformationByName(path2, &bhfi2);
+ if (r == 0) {
+ failure_start(file, line, "File %s can't be inspected?", path2);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (bhfi1.dwVolumeSerialNumber == bhfi2.dwVolumeSerialNumber
+ && bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh
+ && bhfi1.nFileIndexLow == bhfi2.nFileIndexLow);
+#else
+ struct stat st1, st2;
+ int r;
+
+ assertion_count(file, line);
+ r = lstat(path1, &st1);
+ if (r != 0) {
+ failure_start(file, line, "File should exist: %s", path1);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = lstat(path2, &st2);
+ if (r != 0) {
+ failure_start(file, line, "File should exist: %s", path2);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (st1.st_ino == st2.st_ino && st1.st_dev == st2.st_dev);
+#endif
+}
+
+int
+assertion_is_hardlink(const char *file, int line,
+ const char *path1, const char *path2)
+{
+ if (is_hardlink(file, line, path1, path2))
+ return (1);
+ failure_start(file, line,
+ "Files %s and %s are not hardlinked", path1, path2);
+ failure_finish(NULL);
+ return (0);
+}
+
+int
+assertion_is_not_hardlink(const char *file, int line,
+ const char *path1, const char *path2)
+{
+ if (!is_hardlink(file, line, path1, path2))
+ return (1);
+ failure_start(file, line,
+ "Files %s and %s should not be hardlinked", path1, path2);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Verify a/b/mtime of 'pathname'. */
+/* If 'recent', verify that it's within last 10 seconds. */
+static int
+assertion_file_time(const char *file, int line,
+ const char *pathname, long t, long nsec, char type, int recent)
+{
+ long long filet, filet_nsec;
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define EPOC_TIME (116444736000000000ULL)
+ FILETIME fxtime, fbirthtime, fatime, fmtime;
+ ULARGE_INTEGER wintm;
+ HANDLE h;
+ fxtime.dwLowDateTime = 0;
+ fxtime.dwHighDateTime = 0;
+
+ assertion_count(file, line);
+ /* Note: FILE_FLAG_BACKUP_SEMANTICS applies to open
+ * a directory file. If not, CreateFile() will fail when
+ * the pathname is a directory. */
+ h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL,
+ OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ failure_start(file, line, "Can't access %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = GetFileTime(h, &fbirthtime, &fatime, &fmtime);
+ switch (type) {
+ case 'a': fxtime = fatime; break;
+ case 'b': fxtime = fbirthtime; break;
+ case 'm': fxtime = fmtime; break;
+ }
+ CloseHandle(h);
+ if (r == 0) {
+ failure_start(file, line, "Can't GetFileTime %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ wintm.LowPart = fxtime.dwLowDateTime;
+ wintm.HighPart = fxtime.dwHighDateTime;
+ filet = (wintm.QuadPart - EPOC_TIME) / 10000000;
+ filet_nsec = ((wintm.QuadPart - EPOC_TIME) % 10000000) * 100;
+ nsec = (nsec / 100) * 100; /* Round the request */
+#else
+ struct stat st;
+
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0) {
+ failure_start(file, line, "Can't stat %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ switch (type) {
+ case 'a': filet = st.st_atime; break;
+ case 'm': filet = st.st_mtime; break;
+ case 'b': filet = 0; break;
+ default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
+ exit(1);
+ }
+#if defined(__FreeBSD__)
+ switch (type) {
+ case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
+ case 'b': filet = st.st_birthtime;
+ filet_nsec = st.st_birthtimespec.tv_nsec; break;
+ case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
+ default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
+ exit(1);
+ }
+ /* FreeBSD generally only stores to microsecond res, so round. */
+ filet_nsec = (filet_nsec / 1000) * 1000;
+ nsec = (nsec / 1000) * 1000;
+#else
+ filet_nsec = nsec = 0; /* Generic POSIX only has whole seconds. */
+ if (type == 'b') return (1); /* Generic POSIX doesn't have birthtime */
+#if defined(__HAIKU__)
+ if (type == 'a') return (1); /* Haiku doesn't have atime. */
+#endif
+#endif
+#endif
+ if (recent) {
+ /* Check that requested time is up-to-date. */
+ time_t now = time(NULL);
+ if (filet < now - 10 || filet > now + 1) {
+ failure_start(file, line,
+ "File %s has %ctime %lld, %lld seconds ago\n",
+ pathname, type, filet, now - filet);
+ failure_finish(NULL);
+ return (0);
+ }
+ } else if (filet != t || filet_nsec != nsec) {
+ failure_start(file, line,
+ "File %s has %ctime %lld.%09lld, expected %lld.%09lld",
+ pathname, type, filet, filet_nsec, t, nsec);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (1);
+}
+
+/* Verify atime of 'pathname'. */
+int
+assertion_file_atime(const char *file, int line,
+ const char *pathname, long t, long nsec)
+{
+ return assertion_file_time(file, line, pathname, t, nsec, 'a', 0);
+}
+
+/* Verify atime of 'pathname' is up-to-date. */
+int
+assertion_file_atime_recent(const char *file, int line, const char *pathname)
+{
+ return assertion_file_time(file, line, pathname, 0, 0, 'a', 1);
+}
+
+/* Verify birthtime of 'pathname'. */
+int
+assertion_file_birthtime(const char *file, int line,
+ const char *pathname, long t, long nsec)
+{
+ return assertion_file_time(file, line, pathname, t, nsec, 'b', 0);
+}
+
+/* Verify birthtime of 'pathname' is up-to-date. */
+int
+assertion_file_birthtime_recent(const char *file, int line,
+ const char *pathname)
+{
+ return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
+}
+
+/* Verify mtime of 'pathname'. */
+int
+assertion_file_mtime(const char *file, int line,
+ const char *pathname, long t, long nsec)
+{
+ return assertion_file_time(file, line, pathname, t, nsec, 'm', 0);
+}
+
+/* Verify mtime of 'pathname' is up-to-date. */
+int
+assertion_file_mtime_recent(const char *file, int line, const char *pathname)
+{
+ return assertion_file_time(file, line, pathname, 0, 0, 'm', 1);
+}
+
+/* Verify number of links to 'pathname'. */
+int
+assertion_file_nlinks(const char *file, int line,
+ const char *pathname, int nlinks)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ int r;
+
+ assertion_count(file, line);
+ r = my_GetFileInformationByName(pathname, &bhfi);
+ if (r != 0 && bhfi.nNumberOfLinks == (DWORD)nlinks)
+ return (1);
+ failure_start(file, line, "File %s has %d links, expected %d",
+ pathname, bhfi.nNumberOfLinks, nlinks);
+ failure_finish(NULL);
+ return (0);
+#else
+ struct stat st;
+ int r;
+
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r == 0 && (int)st.st_nlink == nlinks)
+ return (1);
+ failure_start(file, line, "File %s has %d links, expected %d",
+ pathname, st.st_nlink, nlinks);
+ failure_finish(NULL);
+ return (0);
+#endif
+}
+
+/* Verify size of 'pathname'. */
+int
+assertion_file_size(const char *file, int line, const char *pathname, long size)
+{
+ int64_t filesize;
+ int r;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ {
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ r = !my_GetFileInformationByName(pathname, &bhfi);
+ filesize = ((int64_t)bhfi.nFileSizeHigh << 32) + bhfi.nFileSizeLow;
+ }
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ filesize = st.st_size;
+ }
+#endif
+ if (r == 0 && filesize == size)
+ return (1);
+ failure_start(file, line, "File %s has size %ld, expected %ld",
+ pathname, (long)filesize, (long)size);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */
+int
+assertion_is_dir(const char *file, int line, const char *pathname, int mode)
+{
+ struct stat st;
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)mode; /* UNUSED */
+#endif
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0) {
+ failure_start(file, line, "Dir should exist: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (!S_ISDIR(st.st_mode)) {
+ failure_start(file, line, "%s is not a dir", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ /* Windows doesn't handle permissions the same way as POSIX,
+ * so just ignore the mode tests. */
+ /* TODO: Can we do better here? */
+ if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
+ failure_start(file, line, "Dir %s has wrong mode", pathname);
+ logprintf(" Expected: 0%3o\n", mode);
+ logprintf(" Found: 0%3o\n", st.st_mode & 07777);
+ failure_finish(NULL);
+ return (0);
+ }
+#endif
+ return (1);
+}
+
+/* Verify that 'pathname' is a regular file. If 'mode' is >= 0,
+ * verify that too. */
+int
+assertion_is_reg(const char *file, int line, const char *pathname, int mode)
+{
+ struct stat st;
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)mode; /* UNUSED */
+#endif
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0 || !S_ISREG(st.st_mode)) {
+ failure_start(file, line, "File should exist: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ /* Windows doesn't handle permissions the same way as POSIX,
+ * so just ignore the mode tests. */
+ /* TODO: Can we do better here? */
+ if (mode >= 0 && (mode_t)mode != (st.st_mode & 07777)) {
+ failure_start(file, line, "File %s has wrong mode", pathname);
+ logprintf(" Expected: 0%3o\n", mode);
+ logprintf(" Found: 0%3o\n", st.st_mode & 07777);
+ failure_finish(NULL);
+ return (0);
+ }
+#endif
+ return (1);
+}
+
+/* Check whether 'pathname' is a symbolic link. If 'contents' is
+ * non-NULL, verify that the symlink has those contents. */
+static int
+is_symlink(const char *file, int line,
+ const char *pathname, const char *contents)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)pathname; /* UNUSED */
+ (void)contents; /* UNUSED */
+ assertion_count(file, line);
+ /* Windows sort-of has real symlinks, but they're only usable
+ * by privileged users and are crippled even then, so there's
+ * really not much point in bothering with this. */
+ return (0);
+#else
+ char buff[300];
+ struct stat st;
+ ssize_t linklen;
+ int r;
+
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0) {
+ failure_start(file, line,
+ "Symlink should exist: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (!S_ISLNK(st.st_mode))
+ return (0);
+ if (contents == NULL)
+ return (1);
+ linklen = readlink(pathname, buff, sizeof(buff));
+ if (linklen < 0) {
+ failure_start(file, line, "Can't read symlink %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ buff[linklen] = '\0';
+ if (strcmp(buff, contents) != 0)
+ return (0);
+ return (1);
+#endif
+}
+
+/* Assert that path is a symlink that (optionally) contains contents. */
+int
+assertion_is_symlink(const char *file, int line,
+ const char *path, const char *contents)
+{
+ if (is_symlink(file, line, path, contents))
+ return (1);
+ if (contents)
+ failure_start(file, line, "File %s is not a symlink to %s",
+ path, contents);
+ else
+ failure_start(file, line, "File %s is not a symlink", path);
+ failure_finish(NULL);
+ return (0);
+}
+
+
+/* Create a directory and report any errors. */
+int
+assertion_make_dir(const char *file, int line, const char *dirname, int mode)
+{
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)mode; /* UNUSED */
+ if (0 == _mkdir(dirname))
+ return (1);
+#else
+ if (0 == mkdir(dirname, mode))
+ return (1);
+#endif
+ failure_start(file, line, "Could not create directory %s", dirname);
+ failure_finish(NULL);
+ return(0);
+}
+
+/* Create a file with the specified contents and report any failures. */
+int
+assertion_make_file(const char *file, int line,
+ const char *path, int mode, int csize, const void *contents)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* TODO: Rework this to set file mode as well. */
+ FILE *f;
+ (void)mode; /* UNUSED */
+ assertion_count(file, line);
+ f = fopen(path, "wb");
+ if (f == NULL) {
+ failure_start(file, line, "Could not create file %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (contents != NULL) {
+ size_t wsize;
+
+ if (csize < 0)
+ wsize = strlen(contents);
+ else
+ wsize = (size_t)csize;
+ if (wsize != fwrite(contents, 1, wsize, f)) {
+ fclose(f);
+ failure_start(file, line,
+ "Could not write file %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ }
+ fclose(f);
+ return (1);
+#else
+ int fd;
+ assertion_count(file, line);
+ fd = open(path, O_CREAT | O_WRONLY, mode >= 0 ? mode : 0644);
+ if (fd < 0) {
+ failure_start(file, line, "Could not create %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (contents != NULL) {
+ ssize_t wsize;
+
+ if (csize < 0)
+ wsize = (ssize_t)strlen(contents);
+ else
+ wsize = (ssize_t)csize;
+ if (wsize != write(fd, contents, wsize)) {
+ close(fd);
+ failure_start(file, line,
+ "Could not write to %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ }
+ close(fd);
+ return (1);
+#endif
+}
+
+/* Create a hardlink and report any failures. */
+int
+assertion_make_hardlink(const char *file, int line,
+ const char *newpath, const char *linkto)
+{
+ int succeeded;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ succeeded = my_CreateHardLinkA(newpath, linkto);
+#elif HAVE_LINK
+ succeeded = !link(linkto, newpath);
+#else
+ succeeded = 0;
+#endif
+ if (succeeded)
+ return (1);
+ failure_start(file, line, "Could not create hardlink");
+ logprintf(" New link: %s\n", newpath);
+ logprintf(" Old name: %s\n", linkto);
+ failure_finish(NULL);
+ return(0);
+}
+
+/* Create a symlink and report any failures. */
+int
+assertion_make_symlink(const char *file, int line,
+ const char *newpath, const char *linkto)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ int targetIsDir = 0; /* TODO: Fix this */
+ assertion_count(file, line);
+ if (my_CreateSymbolicLinkA(newpath, linkto, targetIsDir))
+ return (1);
+#elif HAVE_SYMLINK
+ assertion_count(file, line);
+ if (0 == symlink(linkto, newpath))
+ return (1);
+#endif
+ failure_start(file, line, "Could not create symlink");
+ logprintf(" New link: %s\n", newpath);
+ logprintf(" Old name: %s\n", linkto);
+ failure_finish(NULL);
+ return(0);
+}
+
+/* Set umask, report failures. */
+int
+assertion_umask(const char *file, int line, int mask)
+{
+ assertion_count(file, line);
+ (void)file; /* UNUSED */
+ (void)line; /* UNUSED */
+ umask(mask);
+ return (1);
+}
+
+/* Set times, report failures. */
+int
+assertion_utimes(const char *file, int line,
+ const char *pathname, long at, long at_nsec, long mt, long mt_nsec)
+{
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define WINTIME(sec, nsec) ((Int32x32To64(sec, 10000000) + EPOC_TIME)\
+ + (((nsec)/1000)*10))
+ HANDLE h;
+ ULARGE_INTEGER wintm;
+ FILETIME fatime, fmtime;
+ FILETIME *pat, *pmt;
+
+ assertion_count(file, line);
+ h = CreateFileA(pathname,GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ failure_start(file, line, "Can't access %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+
+ if (at > 0 || at_nsec > 0) {
+ wintm.QuadPart = WINTIME(at, at_nsec);
+ fatime.dwLowDateTime = wintm.LowPart;
+ fatime.dwHighDateTime = wintm.HighPart;
+ pat = &fatime;
+ } else
+ pat = NULL;
+ if (mt > 0 || mt_nsec > 0) {
+ wintm.QuadPart = WINTIME(mt, mt_nsec);
+ fmtime.dwLowDateTime = wintm.LowPart;
+ fmtime.dwHighDateTime = wintm.HighPart;
+ pmt = &fmtime;
+ } else
+ pmt = NULL;
+ if (pat != NULL || pmt != NULL)
+ r = SetFileTime(h, NULL, pat, pmt);
+ else
+ r = 1;
+ CloseHandle(h);
+ if (r == 0) {
+ failure_start(file, line, "Can't SetFileTime %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (1);
+#else /* defined(_WIN32) && !defined(__CYGWIN__) */
+ struct stat st;
+ struct timeval times[2];
+
+#if !defined(__FreeBSD__)
+ mt_nsec = at_nsec = 0; /* Generic POSIX only has whole seconds. */
+#endif
+ if (mt == 0 && mt_nsec == 0 && at == 0 && at_nsec == 0)
+ return (1);
+
+ r = lstat(pathname, &st);
+ if (r < 0) {
+ failure_start(file, line, "Can't stat %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+
+ if (mt == 0 && mt_nsec == 0) {
+ mt = st.st_mtime;
+#if defined(__FreeBSD__)
+ mt_nsec = st.st_mtimespec.tv_nsec;
+ /* FreeBSD generally only stores to microsecond res, so round. */
+ mt_nsec = (mt_nsec / 1000) * 1000;
+#endif
+ }
+ if (at == 0 && at_nsec == 0) {
+ at = st.st_atime;
+#if defined(__FreeBSD__)
+ at_nsec = st.st_atimespec.tv_nsec;
+ /* FreeBSD generally only stores to microsecond res, so round. */
+ at_nsec = (at_nsec / 1000) * 1000;
+#endif
+ }
+
+ times[1].tv_sec = mt;
+ times[1].tv_usec = mt_nsec / 1000;
+
+ times[0].tv_sec = at;
+ times[0].tv_usec = at_nsec / 1000;
+
+#ifdef HAVE_LUTIMES
+ r = lutimes(pathname, times);
+#else
+ r = utimes(pathname, times);
+#endif
+ if (r < 0) {
+ failure_start(file, line, "Can't utimes %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (1);
+#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+}
+
+/* Set nodump, report failures. */
+int
+assertion_nodump(const char *file, int line, const char *pathname)
+{
+#if defined(HAVE_STRUCT_STAT_ST_FLAGS) && defined(UF_NODUMP)
+ int r;
+
+ assertion_count(file, line);
+ r = chflags(pathname, UF_NODUMP);
+ if (r < 0) {
+ failure_start(file, line, "Can't set nodump %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+#elif defined(EXT2_IOC_GETFLAGS) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS)\
+ && defined(EXT2_NODUMP_FL)
+ int fd, r, flags;
+
+ assertion_count(file, line);
+ fd = open(pathname, O_RDONLY | O_NONBLOCK);
+ if (fd < 0) {
+ failure_start(file, line, "Can't open %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = ioctl(fd, EXT2_IOC_GETFLAGS, &flags);
+ if (r < 0) {
+ failure_start(file, line, "Can't get flags %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ flags |= EXT2_NODUMP_FL;
+ r = ioctl(fd, EXT2_IOC_SETFLAGS, &flags);
+ if (r < 0) {
+ failure_start(file, line, "Can't set nodump %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ close(fd);
+#else
+ (void)pathname; /* UNUSED */
+ assertion_count(file, line);
+#endif
+ return (1);
+}
+
+/*
+ *
+ * UTILITIES for use by tests.
+ *
+ */
+
+/*
+ * Check whether platform supports symlinks. This is intended
+ * for tests to use in deciding whether to bother testing symlink
+ * support; if the platform doesn't support symlinks, there's no point
+ * in checking whether the program being tested can create them.
+ *
+ * Note that the first time this test is called, we actually go out to
+ * disk to create and verify a symlink. This is necessary because
+ * symlink support is actually a property of a particular filesystem
+ * and can thus vary between directories on a single system. After
+ * the first call, this returns the cached result from memory, so it's
+ * safe to call it as often as you wish.
+ */
+int
+canSymlink(void)
+{
+ /* Remember the test result */
+ static int value = 0, tested = 0;
+ if (tested)
+ return (value);
+
+ ++tested;
+ assertion_make_file(__FILE__, __LINE__, "canSymlink.0", 0644, 1, "a");
+ /* Note: Cygwin has its own symlink() emulation that does not
+ * use the Win32 CreateSymbolicLink() function. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ value = my_CreateSymbolicLinkA("canSymlink.1", "canSymlink.0", 0)
+ && is_symlink(__FILE__, __LINE__, "canSymlink.1", "canSymlink.0");
+#elif HAVE_SYMLINK
+ value = (0 == symlink("canSymlink.0", "canSymlink.1"))
+ && is_symlink(__FILE__, __LINE__, "canSymlink.1","canSymlink.0");
+#endif
+ return (value);
+}
+
+/* Platform-dependent options for hiding the output of a subcommand. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static const char *redirectArgs = ">NUL 2>NUL"; /* Win32 cmd.exe */
+#else
+static const char *redirectArgs = ">/dev/null 2>/dev/null"; /* POSIX 'sh' */
+#endif
+/*
+ * Can this platform run the bzip2 program?
+ */
+int
+canBzip2(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("bzip2 -d -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the grzip program?
+ */
+int
+canGrzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("grzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the gzip program?
+ */
+int
+canGzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("gzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lrzip program?
+ */
+int
+canRunCommand(const char *cmd)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("%s %s", cmd, redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+int
+canLrzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lrzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lz4 program?
+ */
+int
+canLz4(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lz4 -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lzip program?
+ */
+int
+canLzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lzma program?
+ */
+int
+canLzma(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lzma -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lzop program?
+ */
+int
+canLzop(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lzop -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the xz program?
+ */
+int
+canXz(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("xz -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this filesystem handle nodump flags.
+ */
+#if defined(HAVE_STRUCT_STAT_ST_FLAGS) && defined(UF_NODUMP)
+
+int
+canNodump(void)
+{
+ const char *path = "cannodumptest";
+ struct stat sb;
+
+ assertion_make_file(__FILE__, __LINE__, path, 0644, 0, NULL);
+ if (chflags(path, UF_NODUMP) < 0)
+ return (0);
+ if (stat(path, &sb) < 0)
+ return (0);
+ if (sb.st_flags & UF_NODUMP)
+ return (1);
+ return (0);
+}
+
+#elif defined(EXT2_IOC_GETFLAGS) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS)\
+ && defined(EXT2_NODUMP_FL)
+
+int
+canNodump(void)
+{
+ const char *path = "cannodumptest";
+ int fd, r, flags;
+
+ assertion_make_file(__FILE__, __LINE__, path, 0644, 0, NULL);
+ fd = open(path, O_RDONLY | O_NONBLOCK);
+ if (fd < 0)
+ return (0);
+ r = ioctl(fd, EXT2_IOC_GETFLAGS, &flags);
+ if (r < 0)
+ return (0);
+ flags |= EXT2_NODUMP_FL;
+ r = ioctl(fd, EXT2_IOC_SETFLAGS, &flags);
+ if (r < 0)
+ return (0);
+ close(fd);
+ fd = open(path, O_RDONLY | O_NONBLOCK);
+ if (fd < 0)
+ return (0);
+ r = ioctl(fd, EXT2_IOC_GETFLAGS, &flags);
+ if (r < 0)
+ return (0);
+ close(fd);
+ if (flags & EXT2_NODUMP_FL)
+ return (1);
+ return (0);
+}
+
+#else
+
+int
+canNodump()
+{
+ return (0);
+}
+
+#endif
+
+/*
+ * Sleep as needed; useful for verifying disk timestamp changes by
+ * ensuring that the wall-clock time has actually changed before we
+ * go back to re-read something from disk.
+ */
+void
+sleepUntilAfter(time_t t)
+{
+ while (t >= time(NULL))
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ Sleep(500);
+#else
+ sleep(1);
+#endif
+}
+
+/*
+ * Call standard system() call, but build up the command line using
+ * sprintf() conventions.
+ */
+int
+systemf(const char *fmt, ...)
+{
+ char buff[8192];
+ va_list ap;
+ int r;
+
+ va_start(ap, fmt);
+ vsprintf(buff, fmt, ap);
+ if (verbosity > VERBOSITY_FULL)
+ logprintf("Cmd: %s\n", buff);
+ r = system(buff);
+ va_end(ap);
+ return (r);
+}
+
+/*
+ * Slurp a file into memory for ease of comparison and testing.
+ * Returns size of file in 'sizep' if non-NULL, null-terminates
+ * data in memory for ease of use.
+ */
+char *
+slurpfile(size_t * sizep, const char *fmt, ...)
+{
+ char filename[8192];
+ struct stat st;
+ va_list ap;
+ char *p;
+ ssize_t bytes_read;
+ FILE *f;
+ int r;
+
+ va_start(ap, fmt);
+ vsprintf(filename, fmt, ap);
+ va_end(ap);
+
+ f = fopen(filename, "rb");
+ if (f == NULL) {
+ /* Note: No error; non-existent file is okay here. */
+ return (NULL);
+ }
+ r = fstat(fileno(f), &st);
+ if (r != 0) {
+ logprintf("Can't stat file %s\n", filename);
+ fclose(f);
+ return (NULL);
+ }
+ p = malloc((size_t)st.st_size + 1);
+ if (p == NULL) {
+ logprintf("Can't allocate %ld bytes of memory to read file %s\n",
+ (long int)st.st_size, filename);
+ fclose(f);
+ return (NULL);
+ }
+ bytes_read = fread(p, 1, (size_t)st.st_size, f);
+ if (bytes_read < st.st_size) {
+ logprintf("Can't read file %s\n", filename);
+ fclose(f);
+ free(p);
+ return (NULL);
+ }
+ p[st.st_size] = '\0';
+ if (sizep != NULL)
+ *sizep = (size_t)st.st_size;
+ fclose(f);
+ return (p);
+}
+
+/*
+ * Slurp a file into memory for ease of comparison and testing.
+ * Returns size of file in 'sizep' if non-NULL, null-terminates
+ * data in memory for ease of use.
+ */
+void
+dumpfile(const char *filename, void *data, size_t len)
+{
+ ssize_t bytes_written;
+ FILE *f;
+
+ f = fopen(filename, "wb");
+ if (f == NULL) {
+ logprintf("Can't open file %s for writing\n", filename);
+ return;
+ }
+ bytes_written = fwrite(data, 1, len, f);
+ if (bytes_written < (ssize_t)len)
+ logprintf("Can't write file %s\n", filename);
+ fclose(f);
+}
+
+/* Read a uuencoded file from the reference directory, decode, and
+ * write the result into the current directory. */
+#define VALID_UUDECODE(c) (c >= 32 && c <= 96)
+#define UUDECODE(c) (((c) - 0x20) & 0x3f)
+void
+extract_reference_file(const char *name)
+{
+ char buff[1024];
+ FILE *in, *out;
+
+ sprintf(buff, "%s/%s.uu", refdir, name);
+ in = fopen(buff, "r");
+ failure("Couldn't open reference file %s", buff);
+ assert(in != NULL);
+ if (in == NULL)
+ return;
+ /* Read up to and including the 'begin' line. */
+ for (;;) {
+ if (fgets(buff, sizeof(buff), in) == NULL) {
+ /* TODO: This is a failure. */
+ return;
+ }
+ if (memcmp(buff, "begin ", 6) == 0)
+ break;
+ }
+ /* Now, decode the rest and write it. */
+ out = fopen(name, "wb");
+ while (fgets(buff, sizeof(buff), in) != NULL) {
+ char *p = buff;
+ int bytes;
+
+ if (memcmp(buff, "end", 3) == 0)
+ break;
+
+ bytes = UUDECODE(*p++);
+ while (bytes > 0) {
+ int n = 0;
+ /* Write out 1-3 bytes from that. */
+ if (bytes > 0) {
+ assert(VALID_UUDECODE(p[0]));
+ assert(VALID_UUDECODE(p[1]));
+ n = UUDECODE(*p++) << 18;
+ n |= UUDECODE(*p++) << 12;
+ fputc(n >> 16, out);
+ --bytes;
+ }
+ if (bytes > 0) {
+ assert(VALID_UUDECODE(p[0]));
+ n |= UUDECODE(*p++) << 6;
+ fputc((n >> 8) & 0xFF, out);
+ --bytes;
+ }
+ if (bytes > 0) {
+ assert(VALID_UUDECODE(p[0]));
+ n |= UUDECODE(*p++);
+ fputc(n & 0xFF, out);
+ --bytes;
+ }
+ }
+ }
+ fclose(out);
+ fclose(in);
+}
+
+void
+copy_reference_file(const char *name)
+{
+ char buff[1024];
+ FILE *in, *out;
+ size_t rbytes;
+
+ sprintf(buff, "%s/%s", refdir, name);
+ in = fopen(buff, "rb");
+ failure("Couldn't open reference file %s", buff);
+ assert(in != NULL);
+ if (in == NULL)
+ return;
+ /* Now, decode the rest and write it. */
+ /* Not a lot of error checking here; the input better be right. */
+ out = fopen(name, "wb");
+ while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
+ if (fwrite(buff, 1, rbytes, out) != rbytes) {
+ logprintf("Error: fwrite\n");
+ break;
+ }
+ }
+ fclose(out);
+ fclose(in);
+}
+
+int
+is_LargeInode(const char *file)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ int r;
+
+ r = my_GetFileInformationByName(file, &bhfi);
+ if (r != 0)
+ return (0);
+ return (bhfi.nFileIndexHigh & 0x0000FFFFUL);
+#else
+ struct stat st;
+ int64_t ino;
+
+ if (stat(file, &st) < 0)
+ return (0);
+ ino = (int64_t)st.st_ino;
+ return (ino > 0xffffffff);
+#endif
+}
+
+void
+extract_reference_files(const char **names)
+{
+ while (names && *names)
+ extract_reference_file(*names++);
+}
+
+/*
+ *
+ * TEST management
+ *
+ */
+
+/*
+ * "list.h" is simply created by "grep DEFINE_TEST test_*.c"; it has
+ * a line like
+ * DEFINE_TEST(test_function)
+ * for each test.
+ */
+
+/* Use "list.h" to declare all of the test functions. */
+#undef DEFINE_TEST
+#define DEFINE_TEST(name) void name(void);
+#include "list.h"
+
+/* Use "list.h" to create a list of all tests (functions and names). */
+#undef DEFINE_TEST
+#define DEFINE_TEST(n) { n, #n, 0 },
+struct test_list_t tests[] = {
+ #include "list.h"
+};
+
+/*
+ * Summarize repeated failures in the just-completed test.
+ */
+static void
+test_summarize(int failed, int skips_num)
+{
+ unsigned int i;
+
+ switch (verbosity) {
+ case VERBOSITY_SUMMARY_ONLY:
+ printf(failed ? "E" : ".");
+ fflush(stdout);
+ break;
+ case VERBOSITY_PASSFAIL:
+ printf(failed ? "FAIL\n" : skips_num ? "ok (S)\n" : "ok\n");
+ break;
+ }
+
+ log_console = (verbosity == VERBOSITY_LIGHT_REPORT);
+
+ for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
+ if (failed_lines[i].count > 1 && !failed_lines[i].skip)
+ logprintf("%s:%d: Summary: Failed %d times\n",
+ failed_filename, i, failed_lines[i].count);
+ }
+ /* Clear the failure history for the next file. */
+ failed_filename = NULL;
+ memset(failed_lines, 0, sizeof(failed_lines));
+}
+
+/*
+ * Actually run a single test, with appropriate setup and cleanup.
+ */
+static int
+test_run(int i, const char *tmpdir)
+{
+ char workdir[1024];
+ char logfilename[64];
+ int failures_before = failures;
+ int skips_before = skips;
+ int oldumask;
+
+ switch (verbosity) {
+ case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */
+ break;
+ case VERBOSITY_PASSFAIL: /* rest of line will include ok/FAIL marker */
+ printf("%3d: %-64s", i, tests[i].name);
+ fflush(stdout);
+ break;
+ default: /* Title of test, details will follow */
+ printf("%3d: %s\n", i, tests[i].name);
+ }
+
+ /* Chdir to the top-level work directory. */
+ if (!assertChdir(tmpdir)) {
+ fprintf(stderr,
+ "ERROR: Can't chdir to top work dir %s\n", tmpdir);
+ exit(1);
+ }
+ /* Create a log file for this test. */
+ sprintf(logfilename, "%s.log", tests[i].name);
+ logfile = fopen(logfilename, "w");
+ fprintf(logfile, "%s\n\n", tests[i].name);
+ /* Chdir() to a work dir for this specific test. */
+ snprintf(workdir, sizeof(workdir), "%s/%s", tmpdir, tests[i].name);
+ testworkdir = workdir;
+ if (!assertMakeDir(testworkdir, 0755)
+ || !assertChdir(testworkdir)) {
+ fprintf(stderr,
+ "ERROR: Can't chdir to work dir %s\n", testworkdir);
+ exit(1);
+ }
+ /* Explicitly reset the locale before each test. */
+ setlocale(LC_ALL, "C");
+ /* Record the umask before we run the test. */
+ umask(oldumask = umask(0));
+ /*
+ * Run the actual test.
+ */
+ (*tests[i].func)();
+ /*
+ * Clean up and report afterwards.
+ */
+ testworkdir = NULL;
+ /* Restore umask */
+ umask(oldumask);
+ /* Reset locale. */
+ setlocale(LC_ALL, "C");
+ /* Reset directory. */
+ if (!assertChdir(tmpdir)) {
+ fprintf(stderr, "ERROR: Couldn't chdir to temp dir %s\n",
+ tmpdir);
+ exit(1);
+ }
+ /* Report per-test summaries. */
+ tests[i].failures = failures - failures_before;
+ test_summarize(tests[i].failures, skips - skips_before);
+ /* Close the per-test log file. */
+ fclose(logfile);
+ logfile = NULL;
+ /* If there were no failures, we can remove the work dir and logfile. */
+ if (tests[i].failures == 0) {
+ if (!keep_temp_files && assertChdir(tmpdir)) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* Make sure not to leave empty directories.
+ * Sometimes a processing of closing files used by tests
+ * is not done, then rmdir will be failed and it will
+ * leave a empty test directory. So we should wait a few
+ * seconds and retry rmdir. */
+ int r, t;
+ for (t = 0; t < 10; t++) {
+ if (t > 0)
+ Sleep(1000);
+ r = systemf("rmdir /S /Q %s", tests[i].name);
+ if (r == 0)
+ break;
+ }
+ systemf("del %s", logfilename);
+#else
+ systemf("rm -rf %s", tests[i].name);
+ systemf("rm %s", logfilename);
+#endif
+ }
+ }
+ /* Return appropriate status. */
+ return (tests[i].failures);
+}
+
+/*
+ *
+ *
+ * MAIN and support routines.
+ *
+ *
+ */
+
+static void
+usage(const char *program)
+{
+ static const int limit = sizeof(tests) / sizeof(tests[0]);
+ int i;
+
+ printf("Usage: %s [options] <test> <test> ...\n", program);
+ printf("Default is to run all tests.\n");
+ printf("Otherwise, specify the numbers of the tests you wish to run.\n");
+ printf("Options:\n");
+ printf(" -d Dump core after any failure, for debugging.\n");
+ printf(" -k Keep all temp files.\n");
+ printf(" Default: temp files for successful tests deleted.\n");
+#ifdef PROGRAM
+ printf(" -p <path> Path to executable to be tested.\n");
+ printf(" Default: path taken from " ENVBASE " environment variable.\n");
+#endif
+ printf(" -q Quiet.\n");
+ printf(" -r <dir> Path to dir containing reference files.\n");
+ printf(" Default: Current directory.\n");
+ printf(" -u Keep running specifies tests until one fails.\n");
+ printf(" -v Verbose.\n");
+ printf("Available tests:\n");
+ for (i = 0; i < limit; i++)
+ printf(" %d: %s\n", i, tests[i].name);
+ exit(1);
+}
+
+static char *
+get_refdir(const char *d)
+{
+ char tried[512] = { '\0' };
+ char buff[128];
+ char *pwd, *p;
+
+ /* If a dir was specified, try that */
+ if (d != NULL) {
+ pwd = NULL;
+ snprintf(buff, sizeof(buff), "%s", d);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+ goto failure;
+ }
+
+ /* Get the current dir. */
+#ifdef PATH_MAX
+ pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
+ pwd = getcwd(NULL, 0);
+#endif
+ while (pwd[strlen(pwd) - 1] == '\n')
+ pwd[strlen(pwd) - 1] = '\0';
+
+ /* Look for a known file. */
+ snprintf(buff, sizeof(buff), "%s", pwd);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ snprintf(buff, sizeof(buff), "%s/test", pwd);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+#if defined(LIBRARY)
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY);
+#else
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM);
+#endif
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+#if defined(PROGRAM_ALIAS)
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM_ALIAS);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+#endif
+
+ if (memcmp(pwd, "/usr/obj", 8) == 0) {
+ snprintf(buff, sizeof(buff), "%s", pwd + 8);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ snprintf(buff, sizeof(buff), "%s/test", pwd + 8);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+ }
+
+failure:
+ printf("Unable to locate known reference file %s\n", KNOWNREF);
+ printf(" Checked following directories:\n%s\n", tried);
+ printf("Use -r option to specify full path to reference directory\n");
+#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
+ DebugBreak();
+#endif
+ exit(1);
+
+success:
+ free(p);
+ free(pwd);
+ return strdup(buff);
+}
+
+int
+main(int argc, char **argv)
+{
+ static const int limit = sizeof(tests) / sizeof(tests[0]);
+ int test_set[sizeof(tests) / sizeof(tests[0])];
+ int i = 0, j = 0, tests_run = 0, tests_failed = 0, option;
+ time_t now;
+ char *refdir_alloc = NULL;
+ const char *progname;
+ char **saved_argv;
+ const char *tmp, *option_arg, *p;
+ char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL, *vlevel = NULL;
+ char tmpdir_timestamp[256];
+
+ (void)argc; /* UNUSED */
+
+ /* Get the current dir. */
+#ifdef PATH_MAX
+ pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
+#else
+ pwd = getcwd(NULL, 0);
+#endif
+ while (pwd[strlen(pwd) - 1] == '\n')
+ pwd[strlen(pwd) - 1] = '\0';
+
+#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__)
+ /* To stop to run the default invalid parameter handler. */
+ _set_invalid_parameter_handler(invalid_parameter_handler);
+ /* Disable annoying assertion message box. */
+ _CrtSetReportMode(_CRT_ASSERT, 0);
+#endif
+
+ /*
+ * Name of this program, used to build root of our temp directory
+ * tree.
+ */
+ progname = p = argv[0];
+ if ((testprogdir = (char *)malloc(strlen(progname) + 1)) == NULL)
+ {
+ fprintf(stderr, "ERROR: Out of memory.");
+ exit(1);
+ }
+ strcpy(testprogdir, progname);
+ while (*p != '\0') {
+ /* Support \ or / dir separators for Windows compat. */
+ if (*p == '/' || *p == '\\')
+ {
+ progname = p + 1;
+ i = j;
+ }
+ ++p;
+ j++;
+ }
+ testprogdir[i] = '\0';
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if (testprogdir[0] != '/' && testprogdir[0] != '\\' &&
+ !(((testprogdir[0] >= 'a' && testprogdir[0] <= 'z') ||
+ (testprogdir[0] >= 'A' && testprogdir[0] <= 'Z')) &&
+ testprogdir[1] == ':' &&
+ (testprogdir[2] == '/' || testprogdir[2] == '\\')))
+#else
+ if (testprogdir[0] != '/')
+#endif
+ {
+ /* Fixup path for relative directories. */
+ if ((testprogdir = (char *)realloc(testprogdir,
+ strlen(pwd) + 1 + strlen(testprogdir) + 1)) == NULL)
+ {
+ fprintf(stderr, "ERROR: Out of memory.");
+ exit(1);
+ }
+ memmove(testprogdir + strlen(pwd) + 1, testprogdir,
+ strlen(testprogdir) + 1);
+ memcpy(testprogdir, pwd, strlen(pwd));
+ testprogdir[strlen(pwd)] = '/';
+ }
+
+#ifdef PROGRAM
+ /* Get the target program from environment, if available. */
+ testprogfile = getenv(ENVBASE);
+#endif
+
+ if (getenv("TMPDIR") != NULL)
+ tmp = getenv("TMPDIR");
+ else if (getenv("TMP") != NULL)
+ tmp = getenv("TMP");
+ else if (getenv("TEMP") != NULL)
+ tmp = getenv("TEMP");
+ else if (getenv("TEMPDIR") != NULL)
+ tmp = getenv("TEMPDIR");
+ else
+ tmp = "/tmp";
+
+ /* Allow -d to be controlled through the environment. */
+ if (getenv(ENVBASE "_DEBUG") != NULL)
+ dump_on_failure = 1;
+
+ /* Allow -v to be controlled through the environment. */
+ if (getenv("_VERBOSITY_LEVEL") != NULL)
+ {
+ vlevel = getenv("_VERBOSITY_LEVEL");
+ verbosity = atoi(vlevel);
+ if (verbosity < VERBOSITY_SUMMARY_ONLY || verbosity > VERBOSITY_FULL)
+ {
+ /* Unsupported verbosity levels are silently ignored */
+ vlevel = NULL;
+ verbosity = VERBOSITY_PASSFAIL;
+ }
+ }
+
+ /* Get the directory holding test files from environment. */
+ refdir = getenv(ENVBASE "_TEST_FILES");
+
+ /*
+ * Parse options, without using getopt(), which isn't available
+ * on all platforms.
+ */
+ ++argv; /* Skip program name */
+ while (*argv != NULL) {
+ if (**argv != '-')
+ break;
+ p = *argv++;
+ ++p; /* Skip '-' */
+ while (*p != '\0') {
+ option = *p++;
+ option_arg = NULL;
+ /* If 'opt' takes an argument, parse that. */
+ if (option == 'p' || option == 'r') {
+ if (*p != '\0')
+ option_arg = p;
+ else if (*argv == NULL) {
+ fprintf(stderr,
+ "Option -%c requires argument.\n",
+ option);
+ usage(progname);
+ } else
+ option_arg = *argv++;
+ p = ""; /* End of this option word. */
+ }
+
+ /* Now, handle the option. */
+ switch (option) {
+ case 'd':
+ dump_on_failure = 1;
+ break;
+ case 'k':
+ keep_temp_files = 1;
+ break;
+ case 'p':
+#ifdef PROGRAM
+ testprogfile = option_arg;
+#else
+ fprintf(stderr, "-p option not permitted\n");
+ usage(progname);
+#endif
+ break;
+ case 'q':
+ if (!vlevel)
+ verbosity--;
+ break;
+ case 'r':
+ refdir = option_arg;
+ break;
+ case 'u':
+ until_failure++;
+ break;
+ case 'v':
+ if (!vlevel)
+ verbosity++;
+ break;
+ default:
+ fprintf(stderr, "Unrecognized option '%c'\n",
+ option);
+ usage(progname);
+ }
+ }
+ }
+
+ /*
+ * Sanity-check that our options make sense.
+ */
+#ifdef PROGRAM
+ if (testprogfile == NULL)
+ {
+ if ((tmp2 = (char *)malloc(strlen(testprogdir) + 1 +
+ strlen(PROGRAM) + 1)) == NULL)
+ {
+ fprintf(stderr, "ERROR: Out of memory.");
+ exit(1);
+ }
+ strcpy(tmp2, testprogdir);
+ strcat(tmp2, "/");
+ strcat(tmp2, PROGRAM);
+ testprogfile = tmp2;
+ }
+
+ {
+ char *testprg;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* Command.com sometimes rejects '/' separators. */
+ testprg = strdup(testprogfile);
+ for (i = 0; testprg[i] != '\0'; i++) {
+ if (testprg[i] == '/')
+ testprg[i] = '\\';
+ }
+ testprogfile = testprg;
+#endif
+ /* Quote the name that gets put into shell command lines. */
+ testprg = malloc(strlen(testprogfile) + 3);
+ strcpy(testprg, "\"");
+ strcat(testprg, testprogfile);
+ strcat(testprg, "\"");
+ testprog = testprg;
+ }
+#endif
+
+#if !defined(_WIN32) && defined(SIGPIPE)
+ { /* Ignore SIGPIPE signals */
+ struct sigaction sa;
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sigaction(SIGPIPE, &sa, NULL);
+ }
+#endif
+
+ /*
+ * Create a temp directory for the following tests.
+ * Include the time the tests started as part of the name,
+ * to make it easier to track the results of multiple tests.
+ */
+ now = time(NULL);
+ for (i = 0; ; i++) {
+ strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
+ "%Y-%m-%dT%H.%M.%S",
+ localtime(&now));
+ sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
+ tmpdir_timestamp, i);
+ if (assertMakeDir(tmpdir,0755))
+ break;
+ if (i >= 999) {
+ fprintf(stderr,
+ "ERROR: Unable to create temp directory %s\n",
+ tmpdir);
+ exit(1);
+ }
+ }
+
+ /*
+ * If the user didn't specify a directory for locating
+ * reference files, try to find the reference files in
+ * the "usual places."
+ */
+ refdir = refdir_alloc = get_refdir(refdir);
+
+ /*
+ * Banner with basic information.
+ */
+ printf("\n");
+ printf("If tests fail or crash, details will be in:\n");
+ printf(" %s\n", tmpdir);
+ printf("\n");
+ if (verbosity > VERBOSITY_SUMMARY_ONLY) {
+ printf("Reference files will be read from: %s\n", refdir);
+#ifdef PROGRAM
+ printf("Running tests on: %s\n", testprog);
+#endif
+ printf("Exercising: ");
+ fflush(stdout);
+ printf("%s\n", EXTRA_VERSION);
+ } else {
+ printf("Running ");
+ fflush(stdout);
+ }
+
+ /*
+ * Run some or all of the individual tests.
+ */
+ saved_argv = argv;
+ do {
+ argv = saved_argv;
+ do {
+ int test_num;
+
+ test_num = get_test_set(test_set, limit, *argv, tests);
+ if (test_num < 0) {
+ printf("*** INVALID Test %s\n", *argv);
+ free(refdir_alloc);
+ free(testprogdir);
+ usage(progname);
+ return (1);
+ }
+ for (i = 0; i < test_num; i++) {
+ tests_run++;
+ if (test_run(test_set[i], tmpdir)) {
+ tests_failed++;
+ if (until_failure)
+ goto finish;
+ }
+ }
+ if (*argv != NULL)
+ argv++;
+ } while (*argv != NULL);
+ } while (until_failure);
+
+finish:
+ /* Must be freed after all tests run */
+ free(tmp2);
+ free(testprogdir);
+ free(pwd);
+
+ /*
+ * Report summary statistics.
+ */
+ if (verbosity > VERBOSITY_SUMMARY_ONLY) {
+ printf("\n");
+ printf("Totals:\n");
+ printf(" Tests run: %8d\n", tests_run);
+ printf(" Tests failed: %8d\n", tests_failed);
+ printf(" Assertions checked:%8d\n", assertions);
+ printf(" Assertions failed: %8d\n", failures);
+ printf(" Skips reported: %8d\n", skips);
+ }
+ if (failures) {
+ printf("\n");
+ printf("Failing tests:\n");
+ for (i = 0; i < limit; ++i) {
+ if (tests[i].failures)
+ printf(" %d: %s (%d failures)\n", i,
+ tests[i].name, tests[i].failures);
+ }
+ printf("\n");
+ printf("Details for failing tests: %s\n", tmpdir);
+ printf("\n");
+ } else {
+ if (verbosity == VERBOSITY_SUMMARY_ONLY)
+ printf("\n");
+ printf("%d tests passed, no failures\n", tests_run);
+ }
+
+ free(refdir_alloc);
+
+ /* If the final tmpdir is empty, we can remove it. */
+ /* This should be the usual case when all tests succeed. */
+ assertChdir("..");
+ rmdir(tmpdir);
+
+ return (tests_failed ? 1 : 0);
+}
diff --git a/cat/test/test.h b/cat/test/test.h
new file mode 100644
index 000000000000..c5d2363040f8
--- /dev/null
+++ b/cat/test/test.h
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) 2003-2006 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/* Every test program should #include "test.h" as the first thing. */
+
+/*
+ * The goal of this file (and the matching test.c) is to
+ * simplify the very repetitive test-*.c test programs.
+ */
+#if defined(HAVE_CONFIG_H)
+/* Most POSIX platforms use the 'configure' script to build config.h */
+#include "config.h"
+#elif defined(__FreeBSD__)
+/* Building as part of FreeBSD system requires a pre-built config.h. */
+#include "config_freebsd.h"
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+/* Win32 can't run the 'configure' script. */
+#include "config_windows.h"
+#else
+/* Warn if the library hasn't been (automatically or manually) configured. */
+#error Oops: No config.h and no pre-built configuration in test.h.
+#endif
+
+#include <sys/types.h> /* Windows requires this before sys/stat.h */
+#include <sys/stat.h>
+
+#if HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#define dirent direct
+#endif
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <wchar.h>
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+/*
+ * System-specific tweaks. We really want to minimize these
+ * as much as possible, since they make it harder to understand
+ * the mainline code.
+ */
+
+/* Windows (including Visual Studio and MinGW but not Cygwin) */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(__BORLANDC__)
+#undef chdir
+#define chdir _chdir
+#define strdup _strdup
+#endif
+#endif
+
+/* Visual Studio */
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#define snprintf sprintf_s
+#endif
+
+#if defined(__BORLANDC__)
+#pragma warn -8068 /* Constant out of range in comparison. */
+#endif
+
+/* Haiku OS and QNX */
+#if defined(__HAIKU__) || defined(__QNXNTO__)
+/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
+#include <stdint.h>
+#endif
+
+/* Get a real definition for __FBSDID if we can */
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+
+/* If not, define it so as to avoid dangling semicolons. */
+#ifndef __FBSDID
+#define __FBSDID(a) struct _undefined_hack
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+/*
+ * Redefine DEFINE_TEST for use in defining the test functions.
+ */
+#undef DEFINE_TEST
+#define DEFINE_TEST(name) void name(void); void name(void)
+
+/* An implementation of the standard assert() macro */
+#define assert(e) assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
+/* chdir() and error if it fails */
+#define assertChdir(path) \
+ assertion_chdir(__FILE__, __LINE__, path)
+/* Assert two integers are the same. Reports value of each one if not. */
+#define assertEqualInt(v1,v2) \
+ assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+/* Assert two strings are the same. Reports value of each one if not. */
+#define assertEqualString(v1,v2) \
+ assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0)
+#define assertEqualUTF8String(v1,v2) \
+ assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
+/* As above, but v1 and v2 are wchar_t * */
+#define assertEqualWString(v1,v2) \
+ assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+/* As above, but raw blocks of bytes. */
+#define assertEqualMem(v1, v2, l) \
+ assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
+/* Assert that memory is full of a specified byte */
+#define assertMemoryFilledWith(v1, l, b) \
+ assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL)
+/* Assert two files are the same. */
+#define assertEqualFile(f1, f2) \
+ assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
+/* Assert that a file is empty. */
+#define assertEmptyFile(pathname) \
+ assertion_empty_file(__FILE__, __LINE__, (pathname))
+/* Assert that a file is not empty. */
+#define assertNonEmptyFile(pathname) \
+ assertion_non_empty_file(__FILE__, __LINE__, (pathname))
+#define assertFileAtime(pathname, sec, nsec) \
+ assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
+#define assertFileAtimeRecent(pathname) \
+ assertion_file_atime_recent(__FILE__, __LINE__, pathname)
+#define assertFileBirthtime(pathname, sec, nsec) \
+ assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
+#define assertFileBirthtimeRecent(pathname) \
+ assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
+/* Assert that a file exists; supports printf-style arguments. */
+#define assertFileExists(pathname) \
+ assertion_file_exists(__FILE__, __LINE__, pathname)
+/* Assert that a file exists. */
+#define assertFileNotExists(pathname) \
+ assertion_file_not_exists(__FILE__, __LINE__, pathname)
+/* Assert that file contents match a string. */
+#define assertFileContents(data, data_size, pathname) \
+ assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
+#define assertFileMtime(pathname, sec, nsec) \
+ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
+#define assertFileMtimeRecent(pathname) \
+ assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
+#define assertFileNLinks(pathname, nlinks) \
+ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
+#define assertFileSize(pathname, size) \
+ assertion_file_size(__FILE__, __LINE__, pathname, size)
+#define assertTextFileContents(text, pathname) \
+ assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
+#define assertFileContainsLinesAnyOrder(pathname, lines) \
+ assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
+#define assertIsDir(pathname, mode) \
+ assertion_is_dir(__FILE__, __LINE__, pathname, mode)
+#define assertIsHardlink(path1, path2) \
+ assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
+#define assertIsNotHardlink(path1, path2) \
+ assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
+#define assertIsReg(pathname, mode) \
+ assertion_is_reg(__FILE__, __LINE__, pathname, mode)
+#define assertIsSymlink(pathname, contents) \
+ assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
+/* Create a directory, report error if it fails. */
+#define assertMakeDir(dirname, mode) \
+ assertion_make_dir(__FILE__, __LINE__, dirname, mode)
+#define assertMakeFile(path, mode, contents) \
+ assertion_make_file(__FILE__, __LINE__, path, mode, -1, contents)
+#define assertMakeBinFile(path, mode, csize, contents) \
+ assertion_make_file(__FILE__, __LINE__, path, mode, csize, contents)
+#define assertMakeHardlink(newfile, oldfile) \
+ assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
+#define assertMakeSymlink(newfile, linkto) \
+ assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
+#define assertNodump(path) \
+ assertion_nodump(__FILE__, __LINE__, path)
+#define assertUmask(mask) \
+ assertion_umask(__FILE__, __LINE__, mask)
+#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec) \
+ assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
+
+/*
+ * This would be simple with C99 variadic macros, but I don't want to
+ * require that. Instead, I insert a function call before each
+ * skipping() call to pass the file and line information down. Crude,
+ * but effective.
+ */
+#define skipping \
+ skipping_setup(__FILE__, __LINE__);test_skipping
+
+/* Function declarations. These are defined in test_utility.c. */
+void failure(const char *fmt, ...);
+int assertion_assert(const char *, int, int, const char *, void *);
+int assertion_chdir(const char *, int, const char *);
+int assertion_empty_file(const char *, int, const char *);
+int assertion_equal_file(const char *, int, const char *, const char *);
+int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
+int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
+int assertion_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *);
+int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
+int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
+int assertion_file_atime(const char *, int, const char *, long, long);
+int assertion_file_atime_recent(const char *, int, const char *);
+int assertion_file_birthtime(const char *, int, const char *, long, long);
+int assertion_file_birthtime_recent(const char *, int, const char *);
+int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contents(const char *, int, const void *, int, const char *);
+int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mtime(const char *, int, const char *, long, long);
+int assertion_file_mtime_recent(const char *, int, const char *);
+int assertion_file_nlinks(const char *, int, const char *, int);
+int assertion_file_not_exists(const char *, int, const char *);
+int assertion_file_size(const char *, int, const char *, long);
+int assertion_is_dir(const char *, int, const char *, int);
+int assertion_is_hardlink(const char *, int, const char *, const char *);
+int assertion_is_not_hardlink(const char *, int, const char *, const char *);
+int assertion_is_reg(const char *, int, const char *, int);
+int assertion_is_symlink(const char *, int, const char *, const char *);
+int assertion_make_dir(const char *, int, const char *, int);
+int assertion_make_file(const char *, int, const char *, int, int, const void *);
+int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
+int assertion_make_symlink(const char *, int, const char *newpath, const char *);
+int assertion_nodump(const char *, int, const char *);
+int assertion_non_empty_file(const char *, int, const char *);
+int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
+int assertion_umask(const char *, int, int);
+int assertion_utimes(const char *, int, const char *, long, long, long, long );
+
+void skipping_setup(const char *, int);
+void test_skipping(const char *fmt, ...);
+
+/* Like sprintf, then system() */
+int systemf(const char * fmt, ...);
+
+/* Delay until time() returns a value after this. */
+void sleepUntilAfter(time_t);
+
+/* Return true if this platform can create symlinks. */
+int canSymlink(void);
+
+/* Return true if this platform can run the "bzip2" program. */
+int canBzip2(void);
+
+/* Return true if this platform can run the "grzip" program. */
+int canGrzip(void);
+
+/* Return true if this platform can run the "gzip" program. */
+int canGzip(void);
+
+/* Return true if this platform can run the specified command. */
+int canRunCommand(const char *);
+
+/* Return true if this platform can run the "lrzip" program. */
+int canLrzip(void);
+
+/* Return true if this platform can run the "lz4" program. */
+int canLz4(void);
+
+/* Return true if this platform can run the "lzip" program. */
+int canLzip(void);
+
+/* Return true if this platform can run the "lzma" program. */
+int canLzma(void);
+
+/* Return true if this platform can run the "lzop" program. */
+int canLzop(void);
+
+/* Return true if this platform can run the "xz" program. */
+int canXz(void);
+
+/* Return true if this filesystem can handle nodump flags. */
+int canNodump(void);
+
+/* Return true if the file has large i-node number(>0xffffffff). */
+int is_LargeInode(const char *);
+
+/* Suck file into string allocated via malloc(). Call free() when done. */
+/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
+char *slurpfile(size_t *, const char *fmt, ...);
+
+/* Dump block of bytes to a file. */
+void dumpfile(const char *filename, void *, size_t);
+
+/* Extracts named reference file to the current directory. */
+void extract_reference_file(const char *);
+/* Copies named reference file to the current directory. */
+void copy_reference_file(const char *);
+
+/* Extracts a list of files to the current directory.
+ * List must be NULL terminated.
+ */
+void extract_reference_files(const char **);
+
+/* Path to working directory for current test */
+extern const char *testworkdir;
+
+/*
+ * Special interfaces for program test harness.
+ */
+
+/* Pathname of exe to be tested. */
+extern const char *testprogfile;
+/* Name of exe to use in printf-formatted command strings. */
+/* On Windows, this includes leading/trailing quotes. */
+extern const char *testprog;
+
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#endif
diff --git a/cat/test/test_0.c b/cat/test/test_0.c
new file mode 100644
index 000000000000..f9fe5d8473f9
--- /dev/null
+++ b/cat/test/test_0.c
@@ -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. */
+}
diff --git a/cat/test/test_empty.gz.uu b/cat/test/test_empty.gz.uu
new file mode 100644
index 000000000000..22b52308e5fa
--- /dev/null
+++ b/cat/test/test_empty.gz.uu
@@ -0,0 +1,4 @@
+begin 644 test_empty.gz
+?'XL(""\MZE,``W1E<W1?96UP='D``P``````````````
+`
+end
diff --git a/cat/test/test_empty.lz4.uu b/cat/test/test_empty.lz4.uu
new file mode 100644
index 000000000000..8491afbd8cbb
--- /dev/null
+++ b/cat/test/test_empty.lz4.uu
@@ -0,0 +1,4 @@
+begin 644 test_empty.lz4
+/!")-&&1PN0`````%7<P"
+`
+end
diff --git a/cat/test/test_empty.xz.uu b/cat/test/test_empty.xz.uu
new file mode 100644
index 000000000000..c85f627bf66f
--- /dev/null
+++ b/cat/test/test_empty.xz.uu
@@ -0,0 +1,4 @@
+begin 644 test_empty.xz
+@_3=Z6%H```3FUK1&`````!S?1"$?MO-]`0`````$65H`
+`
+end
diff --git a/cat/test/test_empty_gz.c b/cat/test/test_empty_gz.c
new file mode 100644
index 000000000000..6181f93b4d28
--- /dev/null
+++ b/cat/test/test_empty_gz.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_empty_lz4.c b/cat/test/test_empty_lz4.c
new file mode 100644
index 000000000000..9d98e9cfd390
--- /dev/null
+++ b/cat/test/test_empty_lz4.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_empty_xz.c b/cat/test/test_empty_xz.c
new file mode 100644
index 000000000000..368ffb574e50
--- /dev/null
+++ b/cat/test/test_empty_xz.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_error.c b/cat/test/test_error.c
new file mode 100644
index 000000000000..918af01be2dc
--- /dev/null
+++ b/cat/test/test_error.c
@@ -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");
+}
diff --git a/cat/test/test_error_mixed.c b/cat/test/test_error_mixed.c
new file mode 100644
index 000000000000..7d94fce467aa
--- /dev/null
+++ b/cat/test/test_error_mixed.c
@@ -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");
+}
diff --git a/cat/test/test_expand.Z.uu b/cat/test/test_expand.Z.uu
new file mode 100644
index 000000000000..b65efc1a2adf
--- /dev/null
+++ b/cat/test/test_expand.Z.uu
@@ -0,0 +1,3 @@
+begin 664 test_expand.Z
+@'YV08]ZXH5-FX!P0;\R`(#B'SI<R>."$<4/&A187"@`
+end
diff --git a/cat/test/test_expand.bz2.uu b/cat/test/test_expand.bz2.uu
new file mode 100644
index 000000000000..344c1cbaa7d0
--- /dev/null
+++ b/cat/test/test_expand.bz2.uu
@@ -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
diff --git a/cat/test/test_expand.gz.uu b/cat/test/test_expand.gz.uu
new file mode 100644
index 000000000000..528167c6f447
--- /dev/null
+++ b/cat/test/test_expand.gz.uu
@@ -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
diff --git a/cat/test/test_expand.lz4.uu b/cat/test/test_expand.lz4.uu
new file mode 100644
index 000000000000..78306eaae350
--- /dev/null
+++ b/cat/test/test_expand.lz4.uu
@@ -0,0 +1,5 @@
+begin 644 test_expand.lz4
+M!")-&&1PN1T``(!C;VYT96YT<R!O9B!T97-T7V5X<&%N9"YL>C0N"@`````Y
+#!E9+
+`
+end
diff --git a/cat/test/test_expand.plain.uu b/cat/test/test_expand.plain.uu
new file mode 100644
index 000000000000..ab83c9cb4302
--- /dev/null
+++ b/cat/test/test_expand.plain.uu
@@ -0,0 +1,3 @@
+begin 664 test_expand.plain
+?8V]N=&5N=',@;V8@=&5S=%]E>'!A;F0N<&QA:6XN"@
+end
diff --git a/cat/test/test_expand.xz.uu b/cat/test/test_expand.xz.uu
new file mode 100644
index 000000000000..8a92980c0e7c
--- /dev/null
+++ b/cat/test/test_expand.xz.uu
@@ -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
diff --git a/cat/test/test_expand_Z.c b/cat/test/test_expand_Z.c
new file mode 100644
index 000000000000..d48d4972ebee
--- /dev/null
+++ b/cat/test/test_expand_Z.c
@@ -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");
+}
diff --git a/cat/test/test_expand_bz2.c b/cat/test/test_expand_bz2.c
new file mode 100644
index 000000000000..82f074b341c8
--- /dev/null
+++ b/cat/test/test_expand_bz2.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_expand_gz.c b/cat/test/test_expand_gz.c
new file mode 100644
index 000000000000..18b715c66ebb
--- /dev/null
+++ b/cat/test/test_expand_gz.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_expand_lz4.c b/cat/test/test_expand_lz4.c
new file mode 100644
index 000000000000..1b1d2106459d
--- /dev/null
+++ b/cat/test/test_expand_lz4.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_expand_mixed.c b/cat/test/test_expand_mixed.c
new file mode 100644
index 000000000000..fa2235719df6
--- /dev/null
+++ b/cat/test/test_expand_mixed.c
@@ -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");
+}
diff --git a/cat/test/test_expand_plain.c b/cat/test/test_expand_plain.c
new file mode 100644
index 000000000000..8b2276982885
--- /dev/null
+++ b/cat/test/test_expand_plain.c
@@ -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");
+}
diff --git a/cat/test/test_expand_xz.c b/cat/test/test_expand_xz.c
new file mode 100644
index 000000000000..99f87bf4c66b
--- /dev/null
+++ b/cat/test/test_expand_xz.c
@@ -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");
+ }
+}
diff --git a/cat/test/test_help.c b/cat/test/test_help.c
new file mode 100644
index 000000000000..4ed47a076b29
--- /dev/null
+++ b/cat/test/test_help.c
@@ -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");
+}
diff --git a/cat/test/test_version.c b/cat/test/test_version.c
new file mode 100644
index 000000000000..e7c93630b499
--- /dev/null
+++ b/cat/test/test_version.c
@@ -0,0 +1,97 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+
+/*
+ * Test that --version option works and generates reasonable output.
+ */
+
+DEFINE_TEST(test_version)
+{
+ int r;
+ char *p, *q;
+ size_t s;
+
+
+ r = systemf("%s --version >version.stdout 2>version.stderr", testprog);
+ failure("Unable to run %s --version", testprog);
+ if (!assert(r == 0))
+ return;
+
+ /* --version should generate nothing to stdout. */
+ assertEmptyFile("version.stderr");
+ /* Verify format of version message. */
+ q = p = slurpfile(&s, "version.stdout");
+ /* Version message should start with name of program, then space. */
+ assert(s > 6);
+ failure("Version must start with 'bsdcat': ``%s''", p);
+ if (!assertEqualMem(q, "bsdcat ", 7))
+ return;
+ q += 7; s -= 7;
+ /* Version number is a series of digits and periods. */
+ while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
+ ++q;
+ --s;
+ }
+ /* Version number terminated by space. */
+ failure("No space after bsdcat version: ``%s''", p);
+ assert(s > 1);
+ /* Skip a single trailing a,b,c, or d. */
+ if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
+ ++q;
+ failure("No space after bsdcat version: ``%s''", p);
+ assert(*q == ' ');
+ ++q; --s;
+ /* Separator. */
+ failure("No `-' between bsdcat and libarchive versions: ``%s''", p);
+ assertEqualMem(q, "- ", 2);
+ q += 2; s -= 2;
+ /* libarchive name and version number */
+ failure("Not long enough for libarchive version: ``%s''", p);
+ assert(s > 11);
+ failure("Libarchive version must start with `libarchive': ``%s''", p);
+ assertEqualMem(q, "libarchive ", 11);
+ q += 11; s -= 11;
+ /* Version number is a series of digits and periods. */
+ while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
+ ++q;
+ --s;
+ }
+ /* Skip a single trailing a,b,c, or d. */
+ if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
+ ++q;
+ /* Skip arbitrary third-party version numbers. */
+ while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
+ ++q;
+ --s;
+ }
+ /* All terminated by end-of-line. */
+ assert(s >= 1);
+ /* Skip an optional CR character (e.g., Windows) */
+ failure("Version output must end with \\n or \\r\\n");
+ if (*q == '\r') { ++q; --s; }
+ assertEqualMem(q, "\n", 1);
+ free(p);
+}
diff --git a/configure.ac b/configure.ac
index 73944d3e0754..cb6943fa7f73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,20 +4,21 @@ dnl First, define all of the version numbers up front.
dnl In particular, this allows the version macro to be used in AC_INIT
dnl These first two version numbers are updated automatically on each release.
-m4_define([LIBARCHIVE_VERSION_S],[3.1.2])
-m4_define([LIBARCHIVE_VERSION_N],[3001002])
+m4_define([LIBARCHIVE_VERSION_S],[3.2.0])
+m4_define([LIBARCHIVE_VERSION_N],[3002000])
dnl bsdtar and bsdcpio versioning tracks libarchive
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())
+m4_define([BSDCAT_VERSION_S],LIBARCHIVE_VERSION_S())
-AC_PREREQ(2.65)
+AC_PREREQ([2.69])
#
# Now starts the "real" configure script.
#
-AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[libarchive-discuss@googlegroups.com])
+AC_INIT([libarchive],[LIBARCHIVE_VERSION_S()],[libarchive-discuss@googlegroups.com])
# Make sure the srcdir contains "libarchive" directory
AC_CONFIG_SRCDIR([libarchive])
# Use auxiliary subscripts from this subdirectory (cleans up root)
@@ -53,12 +54,15 @@ AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
[Version number of bsdcpio])
AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
[Version number of bsdtar])
+AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
+ [Version number of bsdcat])
# The shell variables here must be the same as the AC_SUBST() variables
# below, but the shell variable names apparently cannot be the same as
# the m4 macro names above. Why? Ask autoconf.
BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
+BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
@@ -68,6 +72,7 @@ LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
AC_SUBST(BSDCPIO_VERSION_STRING)
AC_SUBST(BSDTAR_VERSION_STRING)
+AC_SUBST(BSDCAT_VERSION_STRING)
AC_SUBST(LIBARCHIVE_VERSION_STRING)
AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
@@ -102,6 +107,7 @@ AC_USE_SYSTEM_EXTENSIONS
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_CHECK_TOOL([STRIP],[strip])
+AC_PROG_MKDIR_P
#
# Options for building bsdtar.
@@ -148,6 +154,50 @@ AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
#
+# Options for building bsdcat.
+#
+# Default is to build bsdcat, but allow people to override that.
+#
+AC_ARG_ENABLE([bsdcat],
+ [AS_HELP_STRING([--enable-bsdcat], [enable build of bsdcat (default)])
+ AS_HELP_STRING([--enable-bsdcat=static], [force static build of bsdcat])
+ AS_HELP_STRING([--enable-bsdcat=shared], [force dynamic build of bsdcat])
+AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
+ [], [enable_bsdcat=yes])
+
+case "$enable_bsdcat" in
+yes)
+ if test "$enable_static" = "no"; then
+ static_bsdcat=no
+ else
+ static_bsdcat=yes
+ fi
+ build_bsdcat=yes
+ ;;
+dynamic|shared)
+ if test "$enable_shared" = "no"; then
+ AC_MSG_FAILURE([Shared linking of bsdcat requires shared libarchive])
+ fi
+ build_bsdcat=yes
+ static_bsdcat=no
+ ;;
+static)
+ build_bsdcat=yes
+ static_bsdcat=yes
+ ;;
+no)
+ build_bsdcat=no
+ static_bsdcat=no
+ ;;
+*)
+ AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
+ ;;
+esac
+
+AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
+AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
+
+#
# Options for building bsdcpio.
#
# Default is not to build bsdcpio, but that can be overridden.
@@ -193,8 +243,9 @@ AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
# Set up defines needed before including any headers
case $host in
*mingw* | *cygwin* )
- AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
- AC_DEFINE([WINVER], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
+ AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
+ AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
+ AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
;;
esac
@@ -218,7 +269,8 @@ AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
-AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h signal.h spawn.h])
+AC_CHECK_HEADERS([locale.h paths.h poll.h pthread.h pwd.h])
+AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/extattr.h])
AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
@@ -226,6 +278,7 @@ AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/statfs.h sys/statvfs.h
AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h])
AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
AC_CHECK_HEADERS([windows.h])
+AC_CHECK_HEADERS([Bcrypt.h])
# check windows.h first; the other headers require it.
AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
[[#ifdef HAVE_WINDOWS_H
@@ -299,12 +352,34 @@ if test "x$with_iconv" != "xno"; then
fi
fi
+AC_ARG_WITH([lz4],
+ AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
+
+if test "x$with_lz4" != "xno"; then
+ AC_CHECK_HEADERS([lz4.h lz4hc.h])
+ AC_CHECK_LIB(lz4,LZ4_decompress_safe)
+fi
+
AC_ARG_WITH([lzma],
AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
if test "x$with_lzma" != "xno"; then
AC_CHECK_HEADERS([lzma.h])
AC_CHECK_LIB(lzma,lzma_stream_decoder)
+ # Some pre-release (but widely distributed) versions of liblzma
+ # included a disabled version of lzma_stream_encoder_mt that
+ # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
+ # to do something more complex here:
+ AC_CACHE_CHECK(
+ [whether we have multithread support in lzma],
+ ac_cv_lzma_has_mt,
+ [AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[#include <lzma.h>]],
+ [[lzma_stream_encoder_mt(0, 0);]])],
+ [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
+ if test "x$ac_cv_lzma_has_mt" != xno; then
+ AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
+ fi
fi
AC_ARG_WITH([lzo2],
@@ -329,14 +404,14 @@ AC_ARG_WITH([expat],
AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
if test "x$with_xml2" != "xno"; then
- AC_PATH_PROG([XML2_CONFIG], [xml2-config],, [${PATH}])
- if test "x$XML2_CONFIG" != "x"; then
- CPPFLAGS="${CPPFLAGS} `${XML2_CONFIG} --cflags`"
- LIBS="${LIBS} `${XML2_CONFIG} --libs`"
+ PKG_PROG_PKG_CONFIG
+ PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
+ CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
+ LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
- else
+ ], [
AC_CHECK_LIB(xml2,xmlInitParser)
- fi
+ ])
AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
fi
if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
@@ -411,9 +486,12 @@ fi
# -larchive in that case.
#AC_CHECK_LIB(archive,archive_version)
+# Checks for supported compiler flags
+AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
+
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
-# AC_TYPE_UID_T defaults to "int", which is incorrect for MinGW
+# la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
# and MSVC. Use a customized version.
la_TYPE_UID_T
AC_TYPE_MODE_T
@@ -475,7 +553,9 @@ AC_TYPE_INT16_T
AC_TYPE_UINT16_T
AC_TYPE_UINT8_T
-AC_CHECK_DECLS([SIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
+AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
+AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
+AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
AC_CHECK_DECL([SSIZE_MAX],
[AC_DEFINE(HAVE_DECL_SSIZE_MAX, 1, [Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you don't.])],
@@ -512,7 +592,7 @@ AC_FUNC_VPRINTF
# To avoid necessity for including windows.h or special forward declaration
# workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
-AC_CHECK_FUNCS([chflags chown chroot ctime_r dirfd])
+AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r dirfd])
AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
AC_CHECK_FUNCS([futimens futimes futimesat])
@@ -522,10 +602,11 @@ AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat lutimes])
AC_CHECK_FUNCS([mbrtowc memmove memset])
AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
+AC_CHECK_FUNCS([readpassphrase])
AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
-AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy])
+AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
AC_CHECK_FUNCS([_ctime64_s _fseeki64])
AC_CHECK_FUNCS([_get_timezone _localtime64_s _mkgmtime64])
# detects cygwin-1.7, as opposed to older versions
@@ -568,7 +649,7 @@ AC_ARG_ENABLE([xattr],
if test "x$enable_xattr" != "xno"; then
AC_CHECK_HEADERS([attr/xattr.h])
AC_CHECK_HEADERS([sys/xattr.h sys/ea.h])
- AC_CHECK_LIB(attr,setxattr)
+ AC_SEARCH_LIBS([setxattr], [attr])
AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
AC_CHECK_FUNCS([fgetxattr flistxattr fsetxattr getxattr])
@@ -642,7 +723,7 @@ AC_DEFUN([CRYPTO_CHECK], [
#define ARCHIVE_CRYPTO_$1_$2
#define PLATFORM_CONFIG_H "check_crypto_md.h"
-$(cat "$srcdir/libarchive/archive_crypto.c")
+$(cat "$srcdir/libarchive/archive_digest.c")
int
main(int argc, char **argv)
@@ -717,8 +798,9 @@ esac
if test "x$with_nettle" != "xno"; then
AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
+ AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
saved_LIBS=$LIBS
- AC_CHECK_LIB(nettle,main)
+ AC_CHECK_LIB(nettle,nettle_sha1_init)
CRYPTO_CHECK(MD5, NETTLE, md5)
CRYPTO_CHECK(RMD160, NETTLE, rmd160)
CRYPTO_CHECK(SHA1, NETTLE, sha1)
@@ -729,6 +811,7 @@ if test "x$with_nettle" != "xno"; then
LIBS=$saved_LIBS
fi
fi
+
if test "x$with_openssl" != "xno"; then
AC_CHECK_HEADERS([openssl/evp.h])
saved_LIBS=$LIBS
@@ -736,18 +819,18 @@ if test "x$with_openssl" != "xno"; then
*mingw* | *cygwin*)
case "$host_cpu" in
x86_64)
- AC_CHECK_LIB(eay64,main)
+ AC_CHECK_LIB(eay64,OPENSSL_config)
if test "x$ac_cv_lib_eay64_main" != "xyes"; then
- AC_CHECK_LIB(eay32,main)
+ AC_CHECK_LIB(eay32,OPENSSL_config)
fi
;;
*)
- AC_CHECK_LIB(eay32,main)
+ AC_CHECK_LIB(eay32,OPENSSL_config)
;;
esac
;;
*)
- AC_CHECK_LIB(crypto,main)
+ AC_CHECK_LIB(crypto,OPENSSL_config)
;;
esac
CRYPTO_CHECK(MD5, OPENSSL, md5)
@@ -758,6 +841,8 @@ if test "x$with_openssl" != "xno"; then
CRYPTO_CHECK(SHA512, OPENSSL, sha512)
if test "x$found_OPENSSL" != "xyes"; then
LIBS=$saved_LIBS
+ else
+ AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
fi
fi
@@ -765,7 +850,7 @@ fi
# The two are incompatible and OpenSSL is more complete.
AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
saved_LIBS=$LIBS
-AC_CHECK_LIB(md,main)
+AC_CHECK_LIB(md,MD5Init)
CRYPTO_CHECK(MD5, LIBMD, md5)
CRYPTO_CHECK(RMD160, LIBMD, rmd160)
CRYPTO_CHECK(SHA1, LIBMD, sha1)
@@ -785,4 +870,8 @@ case "$host_os" in
;;
esac
+# Ensure test directories are present if building out-of-tree
+AC_CONFIG_COMMANDS([mkdirs],
+ [mkdir -p libarchive/test tar/test cat/test cpio/test])
+
AC_OUTPUT
diff --git a/contrib/android/Android.mk b/contrib/android/Android.mk
new file mode 100644
index 000000000000..b82beab4a6d2
--- /dev/null
+++ b/contrib/android/Android.mk
@@ -0,0 +1,306 @@
+#
+# Copyright (C) 2014 Trevor Drake
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+
+# A bit of a non-standard LOCAL_PATH declaration here
+# The Android.mk lives below the top source directory
+# but LOCAL_PATH needs to point to the top of the module
+# source tree to maintain the integrity of the intermediates
+# directories
+LOCAL_PATH := $(subst /contrib/android,,$(call my-dir))
+
+libarchive_target_config := contrib/android/config/android.h
+
+libarchive_src_files := libarchive/archive_acl.c \
+ libarchive/archive_check_magic.c \
+ libarchive/archive_cmdline.c \
+ libarchive/archive_cryptor.c \
+ libarchive/archive_digest.c \
+ libarchive/archive_entry.c \
+ libarchive/archive_entry_copy_stat.c \
+ libarchive/archive_entry_link_resolver.c \
+ libarchive/archive_entry_sparse.c \
+ libarchive/archive_entry_stat.c \
+ libarchive/archive_entry_strmode.c \
+ libarchive/archive_entry_xattr.c \
+ libarchive/archive_getdate.c \
+ libarchive/archive_hmac.c \
+ libarchive/archive_match.c \
+ libarchive/archive_options.c \
+ libarchive/archive_pack_dev.c \
+ libarchive/archive_pathmatch.c \
+ libarchive/archive_ppmd7.c \
+ libarchive/archive_random.c \
+ libarchive/archive_rb.c \
+ libarchive/archive_read.c \
+ libarchive/archive_read_add_passphrase.c \
+ libarchive/archive_read_append_filter.c \
+ libarchive/archive_read_data_into_fd.c \
+ libarchive/archive_read_disk_entry_from_file.c \
+ libarchive/archive_read_disk_posix.c \
+ libarchive/archive_read_disk_set_standard_lookup.c \
+ libarchive/archive_read_extract.c \
+ libarchive/archive_read_extract2.c \
+ libarchive/archive_read_open_fd.c \
+ libarchive/archive_read_open_file.c \
+ libarchive/archive_read_open_filename.c \
+ libarchive/archive_read_open_memory.c \
+ libarchive/archive_read_set_format.c \
+ libarchive/archive_read_set_options.c \
+ libarchive/archive_read_support_filter_all.c \
+ libarchive/archive_read_support_filter_bzip2.c \
+ libarchive/archive_read_support_filter_compress.c \
+ libarchive/archive_read_support_filter_grzip.c \
+ libarchive/archive_read_support_filter_gzip.c \
+ libarchive/archive_read_support_filter_lrzip.c \
+ libarchive/archive_read_support_filter_lz4.c \
+ libarchive/archive_read_support_filter_lzop.c \
+ libarchive/archive_read_support_filter_none.c \
+ libarchive/archive_read_support_filter_program.c \
+ libarchive/archive_read_support_filter_rpm.c \
+ libarchive/archive_read_support_filter_uu.c \
+ libarchive/archive_read_support_filter_xz.c \
+ libarchive/archive_read_support_format_7zip.c \
+ libarchive/archive_read_support_format_all.c \
+ libarchive/archive_read_support_format_ar.c \
+ libarchive/archive_read_support_format_by_code.c \
+ libarchive/archive_read_support_format_cab.c \
+ libarchive/archive_read_support_format_cpio.c \
+ libarchive/archive_read_support_format_empty.c \
+ libarchive/archive_read_support_format_iso9660.c \
+ libarchive/archive_read_support_format_lha.c \
+ libarchive/archive_read_support_format_mtree.c \
+ libarchive/archive_read_support_format_rar.c \
+ libarchive/archive_read_support_format_raw.c \
+ libarchive/archive_read_support_format_tar.c \
+ libarchive/archive_read_support_format_warc.c \
+ libarchive/archive_read_support_format_xar.c \
+ libarchive/archive_read_support_format_zip.c \
+ libarchive/archive_string.c \
+ libarchive/archive_string_sprintf.c \
+ libarchive/archive_util.c \
+ libarchive/archive_virtual.c \
+ libarchive/archive_write.c \
+ libarchive/archive_write_disk_acl.c \
+ libarchive/archive_write_disk_posix.c \
+ libarchive/archive_write_disk_set_standard_lookup.c \
+ libarchive/archive_write_open_fd.c \
+ libarchive/archive_write_open_file.c \
+ libarchive/archive_write_open_filename.c \
+ libarchive/archive_write_open_memory.c \
+ libarchive/archive_write_add_filter.c \
+ libarchive/archive_write_add_filter_b64encode.c \
+ libarchive/archive_write_add_filter_by_name.c \
+ libarchive/archive_write_add_filter_bzip2.c \
+ libarchive/archive_write_add_filter_compress.c \
+ libarchive/archive_write_add_filter_grzip.c \
+ libarchive/archive_write_add_filter_gzip.c \
+ libarchive/archive_write_add_filter_lrzip.c \
+ libarchive/archive_write_add_filter_lz4.c \
+ libarchive/archive_write_add_filter_lzop.c \
+ libarchive/archive_write_add_filter_none.c \
+ libarchive/archive_write_add_filter_program.c \
+ libarchive/archive_write_add_filter_uuencode.c \
+ libarchive/archive_write_add_filter_xz.c \
+ libarchive/archive_write_set_format.c \
+ libarchive/archive_write_set_format_7zip.c \
+ libarchive/archive_write_set_format_ar.c \
+ libarchive/archive_write_set_format_by_name.c \
+ libarchive/archive_write_set_format_cpio.c \
+ libarchive/archive_write_set_format_cpio_newc.c \
+ libarchive/archive_write_set_format_iso9660.c \
+ libarchive/archive_write_set_format_mtree.c \
+ libarchive/archive_write_set_format_pax.c \
+ libarchive/archive_write_set_format_raw.c \
+ libarchive/archive_write_set_format_shar.c \
+ libarchive/archive_write_set_format_ustar.c \
+ libarchive/archive_write_set_format_v7tar.c \
+ libarchive/archive_write_set_format_gnutar.c \
+ libarchive/archive_write_set_format_warc.c \
+ libarchive/archive_write_set_format_xar.c \
+ libarchive/archive_write_set_format_zip.c \
+ libarchive/archive_write_set_options.c \
+ libarchive/archive_write_set_passphrase.c \
+ libarchive/filter_fork_posix.c \
+ libarchive/xxhash.c
+
+ifeq ($(HOST_OS),windows)
+libarchive_host_src_files := \
+ libarchive/archive_entry_copy_bhfi.c \
+ libarchive/archive_read_disk_windows.c \
+ libarchive/archive_write_disk_windows.c \
+ libarchive/filter_fork_windows.c \
+ libarchive/archive_windows.c
+else
+libarchive_host_src_files :=
+endif
+
+libarchive_fe_src_files := libarchive_fe/err.c \
+ libarchive_fe/line_reader.c \
+ libarchive_fe/passphrase.c
+
+bsdtar_src_files := tar/bsdtar.c \
+ tar/bsdtar_windows.c \
+ tar/cmdline.c \
+ tar/creation_set.c \
+ tar/read.c \
+ tar/subst.c \
+ tar/util.c \
+ tar/write.c
+
+bsdcpio_src_files := cpio/cmdline.c \
+ cpio/cpio.c
+
+bsdcat_src_files := cat/cmdline.c \
+ cat/bsdcat.c
+
+
+ifeq ($(HOST_OS),darwin)
+$(warning Host : $(HOST_OS) Not Supported. Host Build Will Be Skipped )
+else
+libarchive_host_config := contrib/android/config/$(HOST_OS)_host.h
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libarchive
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(libarchive_src_files) $(libarchive_host_src_files)
+LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libarchive
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
+LOCAL_SHARED_LIBRARIES := libz-host
+LOCAL_WHOLE_STATIC_LIBRARIES := libarchive
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libarchive_fe
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
+LOCAL_SRC_FILES := $(libarchive_fe_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive_fe
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+endif
+
+
+# Do not build target binaries if we are not targeting linux
+# on the host
+ifeq ($(HOST_OS),linux)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bsdtar
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DBSDTAR_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
+LOCAL_SHARED_LIBRARIES := libz-host
+LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
+LOCAL_SRC_FILES := $(bsdtar_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+include $(BUILD_HOST_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bsdcpio
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DBSDCPIO_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
+LOCAL_SHARED_LIBRARIES := libz-host
+LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
+LOCAL_SRC_FILES := $(bsdcpio_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+include $(BUILD_HOST_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bsdcat
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DBSDCAT_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_host_config)\"
+LOCAL_SHARED_LIBRARIES := libz-host
+LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
+LOCAL_SRC_FILES := $(bsdcat_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+include $(BUILD_HOST_EXECUTABLE)
+
+
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libarchive
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(libarchive_src_files)
+LOCAL_STATIC_LIBRARIES := libz liblz4
+LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
+include $(BUILD_STATIC_LIBRARY)
+
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libarchive
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES :=
+LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
+LOCAL_SHARED_LIBRARIES := libz
+LOCAL_WHOLE_STATIC_LIBRARIES := libarchive
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libarchive_fe
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
+LOCAL_SRC_FILES := $(libarchive_fe_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/contrib/android/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/libarchive_fe
+include $(BUILD_STATIC_LIBRARY)
+
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bsdtar
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DBSDTAR_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
+LOCAL_SHARED_LIBRARIES := libz
+LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
+LOCAL_SRC_FILES := $(bsdtar_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bsdcpio
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DBSDCPIO_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
+LOCAL_SHARED_LIBRARIES := libz
+LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
+LOCAL_SRC_FILES := $(bsdcpio_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bsdcat
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -DBSDCAT_VERSION_STRING=ARCHIVE_VERSION_ONLY_STRING -DPLATFORM_CONFIG_H=\"$(libarchive_target_config)\"
+LOCAL_SHARED_LIBRARIES := libz
+LOCAL_STATIC_LIBRARIES := libarchive libarchive_fe
+LOCAL_SRC_FILES := $(bsdcat_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/libarchive $(LOCAL_PATH)/libarchive_fe $(LOCAL_PATH)/contrib/android/include
+include $(BUILD_EXECUTABLE)
+
+endif
diff --git a/contrib/android/config/android.h b/contrib/android/config/android.h
new file mode 100644
index 000000000000..8e18312449ed
--- /dev/null
+++ b/contrib/android/config/android.h
@@ -0,0 +1,184 @@
+/*-
+ * Copyright (c) 2014 Trevor Drake
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
+#define ARCHIVE_PLATFORM_H_ANDROID_INCLUDED
+
+#include <android/api-level.h>
+#ifdef __ANDROID_API__
+#if __ANDROID_API__ > 20
+#define HAVE_FSTATVFS 1
+#define HAVE_STATVFS 1
+#define HAVE_TIMEGM 1
+#define HAVE_SYS_XATTR_H 1
+#define HAVE_LINUX_FIEMAP_H 1
+#define HAVE_SYS_STATVFS_H 1
+#endif
+#endif
+
+#define HAVE_CHOWN 1
+#define HAVE_CHROOT 1
+#define HAVE_CTIME_R 1
+#define HAVE_CTYPE_H 1
+#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
+#define HAVE_DECL_INTMAX_MIN 1
+#define HAVE_DECL_INTMAX_MAX 1
+#define HAVE_DECL_INT64_MAX 1
+#define HAVE_DECL_INT64_MIN 1
+#define HAVE_DECL_SIZE_MAX 1
+#define HAVE_DECL_SSIZE_MAX 1
+#define HAVE_DECL_STRERROR_R 1
+#define HAVE_DECL_UINTMAX_MAX 1
+#define HAVE_DECL_UINT32_MAX 1
+#define HAVE_DECL_UINT64_MAX 1
+#define HAVE_DIRENT_H 1
+#define HAVE_DIRFD 1
+#define HAVE_DLFCN_H 1
+#define HAVE_EILSEQ 1
+#define HAVE_ERRNO_H 1
+#define HAVE_FCHDIR 1
+#define HAVE_FCHMOD 1
+#define HAVE_FCHOWN 1
+#define HAVE_FCNTL 1
+#define HAVE_FCNTL_H 1
+#define HAVE_FDOPENDIR 1
+#define HAVE_FGETXATTR 1
+#define HAVE_FLISTXATTR 1
+#define HAVE_FORK 1
+#define HAVE_FSEEKO 1
+#define HAVE_FSETXATTR 1
+#define HAVE_FSTAT 1
+#define HAVE_FSTATAT 1
+#define HAVE_FSTATFS 1
+#define HAVE_FTRUNCATE 1
+#define HAVE_GETEUID 1
+#define HAVE_GETPID 1
+#define HAVE_GETPWNAM_R 1
+#define HAVE_GETPWUID_R 1
+#define HAVE_GETXATTR 1
+#define HAVE_GMTIME_R 1
+#define HAVE_GRP_H 1
+#define HAVE_INTMAX_T 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LCHOWN 1
+#define HAVE_LGETXATTR 1
+#define HAVE_LIBLZMA 1
+#define HAVE_LIBZ 1
+#define HAVE_LIMITS_H 1
+#define HAVE_LINK 1
+#define HAVE_LINUX_FS_H 1
+#define HAVE_LINUX_MAGIC_H 1
+#define HAVE_LINUX_TYPES_H 1
+#define HAVE_LISTXATTR 1
+#define HAVE_LLISTXATTR 1
+#define HAVE_LOCALE_H 1
+#define HAVE_LOCALTIME_R 1
+#define HAVE_LONG_LONG_INT 1
+#define HAVE_LSETXATTR 1
+#define HAVE_LSTAT 1
+#define HAVE_MBRTOWC 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMORY_H 1
+#define HAVE_MEMSET 1
+#define HAVE_MKDIR 1
+#define HAVE_MKFIFO 1
+#define HAVE_MKNOD 1
+#define HAVE_MKSTEMP 1
+#define HAVE_OPENAT 1
+#define HAVE_PATHS_H 1
+#define HAVE_PIPE 1
+#define HAVE_POLL 1
+#define HAVE_POLL_H 1
+#define HAVE_PTHREAD_H 1
+#define HAVE_PWD_H 1
+#define HAVE_READDIR_R 1
+#define HAVE_READLINK 1
+#define HAVE_READLINKAT 1
+#define HAVE_REGEX_H 1
+#define HAVE_SELECT 1
+#define HAVE_SETENV 1
+#define HAVE_SETLOCALE 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_STATFS 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRCHR 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRERROR_R 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+#define HAVE_STRUCT_STAT_ST_MTIME_NSEC 1
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
+#define HAVE_SYMLINK 1
+#define HAVE_SYS_CDEFS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_MOUNT_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_POLL_H 1
+#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_STATFS_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_SYS_VFS_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_TIME_H 1
+#define HAVE_TZSET 1
+#define HAVE_UINTMAX_T 1
+#define HAVE_UNISTD_H 1
+#define HAVE_UNSETENV 1
+#define HAVE_UNSIGNED_LONG_LONG 1
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#define HAVE_UTIME 1
+#define HAVE_UTIMENSAT 1
+#define HAVE_UTIMES 1
+#define HAVE_UTIME_H 1
+#define HAVE_VFORK 1
+#define HAVE_VPRINTF 1
+#define HAVE_WCHAR_H 1
+#define HAVE_WCHAR_T 1
+#define HAVE_WCRTOMB 1
+#define HAVE_WCSCMP 1
+#define HAVE_WCSCPY 1
+#define HAVE_WCSLEN 1
+#define HAVE_WCTOMB 1
+#define HAVE_WCTYPE_H 1
+#define HAVE_WMEMCMP 1
+#define HAVE_WMEMCPY 1
+#define HAVE_ARC4RANDOM_BUF 1
+#define HAVE_ZLIB_H 1
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
+#define SIZEOF_WCHAR_T 4
+#define STDC_HEADERS 1
+#define STRERROR_R_CHAR_P 1
+#define TIME_WITH_SYS_TIME 1
+#endif
diff --git a/contrib/android/config/linux_host.h b/contrib/android/config/linux_host.h
new file mode 100644
index 000000000000..709b657c9da7
--- /dev/null
+++ b/contrib/android/config/linux_host.h
@@ -0,0 +1,189 @@
+/*-
+ * Copyright (c) 2014 Trevor Drake
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef ARCHIVE_PLATFORM_H_ANDROID_LINUX_HOST_INCLUDED
+#define ARCHIVE_PLATFORM_H_ANDROID_LINUX_HOST_INCLUDED
+
+#define HAVE_CHOWN 1
+#define HAVE_CHROOT 1
+#define HAVE_CTIME_R 1
+#define HAVE_CTYPE_H 1
+#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
+#define HAVE_DECL_INT64_MAX 1
+#define HAVE_DECL_INT64_MIN 1
+#define HAVE_DECL_SIZE_MAX 1
+#define HAVE_DECL_SSIZE_MAX 1
+#define HAVE_DECL_STRERROR_R 1
+#define HAVE_DECL_UINT32_MAX 1
+#define HAVE_DECL_UINT64_MAX 1
+#define HAVE_DIRENT_H 1
+#define HAVE_DIRFD 1
+#define HAVE_DLFCN_H 1
+#define HAVE_EILSEQ 1
+#define HAVE_ERRNO_H 1
+#define HAVE_FCHDIR 1
+#define HAVE_FCHMOD 1
+#define HAVE_FCHOWN 1
+#define HAVE_FCNTL 1
+#define HAVE_FCNTL_H 1
+#define HAVE_FDOPENDIR 1
+#define HAVE_FGETXATTR 1
+#define HAVE_FLISTXATTR 1
+#define HAVE_FORK 1
+#define HAVE_FSEEKO 1
+#define HAVE_FSETXATTR 1
+#define HAVE_FSTAT 1
+#define HAVE_FSTATAT 1
+#define HAVE_FSTATFS 1
+#define HAVE_FSTATVFS 1
+#define HAVE_FTRUNCATE 1
+#define HAVE_FUTIMENS 1
+#define HAVE_FUTIMES 1
+#define HAVE_FUTIMESAT 1
+#define HAVE_GETEUID 1
+#define HAVE_GETGRGID_R 1
+#define HAVE_GETGRNAM_R 1
+#define HAVE_GETPID 1
+#define HAVE_GETPWNAM_R 1
+#define HAVE_GETPWUID_R 1
+#define HAVE_GETXATTR 1
+#define HAVE_GMTIME_R 1
+#define HAVE_GRP_H 1
+#define HAVE_ICONV 1
+#define HAVE_ICONV_H 1
+#define HAVE_INTMAX_T 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LANGINFO_H 1
+#define HAVE_LCHOWN 1
+#define HAVE_LGETXATTR 1
+#define HAVE_LIBLZMA 1
+#define HAVE_LIBZ 1
+#define HAVE_LIMITS_H 1
+#define HAVE_LINK 1
+#define HAVE_LINUX_FIEMAP_H 1
+#define HAVE_LINUX_FS_H 1
+#define HAVE_LINUX_MAGIC_H 1
+#define HAVE_LINUX_TYPES_H 1
+#define HAVE_LISTXATTR 1
+#define HAVE_LLISTXATTR 1
+#define HAVE_LOCALE_H 1
+#define HAVE_LOCALTIME_R 1
+#define HAVE_LONG_LONG_INT 1
+#define HAVE_LSETXATTR 1
+#define HAVE_LSTAT 1
+#define HAVE_LUTIMES 1
+#define HAVE_MBRTOWC 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMORY_H 1
+#define HAVE_MEMSET 1
+#define HAVE_MKDIR 1
+#define HAVE_MKFIFO 1
+#define HAVE_MKNOD 1
+#define HAVE_MKSTEMP 1
+#define HAVE_NL_LANGINFO 1
+#define HAVE_OPENAT 1
+#define HAVE_PATHS_H 1
+#define HAVE_PIPE 1
+#define HAVE_POLL 1
+#define HAVE_POLL_H 1
+#define HAVE_POSIX_SPAWNP 1
+#define HAVE_PTHREAD_H 1
+#define HAVE_PWD_H 1
+#define HAVE_READDIR_R 1
+#define HAVE_READLINK 1
+#define HAVE_READLINKAT 1
+#define HAVE_REGEX_H 1
+#define HAVE_SELECT 1
+#define HAVE_SETENV 1
+#define HAVE_SETLOCALE 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_SPAWN_H 1
+#define HAVE_STATFS 1
+#define HAVE_STATVFS 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRCHR 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRERROR_R 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
+#define HAVE_SYMLINK 1
+#define HAVE_SYS_CDEFS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_MOUNT_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_POLL_H 1
+#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_STATFS_H 1
+#define HAVE_SYS_STATVFS_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_SYS_VFS_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_SYS_XATTR_H 1
+#define HAVE_TIMEGM 1
+#define HAVE_TIME_H 1
+#define HAVE_TZSET 1
+#define HAVE_UINTMAX_T 1
+#define HAVE_UNISTD_H 1
+#define HAVE_UNSETENV 1
+#define HAVE_UNSIGNED_LONG_LONG 1
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#define HAVE_UTIME 1
+#define HAVE_UTIMENSAT 1
+#define HAVE_UTIMES 1
+#define HAVE_UTIME_H 1
+#define HAVE_VFORK 1
+#define HAVE_VPRINTF 1
+#define HAVE_WCHAR_H 1
+#define HAVE_WCHAR_T 1
+#define HAVE_WCRTOMB 1
+#define HAVE_WCSCMP 1
+#define HAVE_WCSCPY 1
+#define HAVE_WCSLEN 1
+#define HAVE_WCTOMB 1
+#define HAVE_WCTYPE_H 1
+#define HAVE_WMEMCMP 1
+#define HAVE_WMEMCPY 1
+#define HAVE_ZLIB_H 1
+#define ICONV_CONST
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
+#define SIZEOF_WCHAR_T 4
+#define STDC_HEADERS 1
+#define STRERROR_R_CHAR_P 1
+#define TIME_WITH_SYS_TIME 1
+#define _GNU_SOURCE 1
+
+#endif
diff --git a/contrib/android/config/windows_host.h b/contrib/android/config/windows_host.h
new file mode 100644
index 000000000000..decc87f2a361
--- /dev/null
+++ b/contrib/android/config/windows_host.h
@@ -0,0 +1,1062 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_LIBC supported. */
+/* #undef ARCHIVE_CRYPTO_MD5_LIBC */
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_LIBMD supported. */
+/* #undef ARCHIVE_CRYPTO_MD5_LIBMD */
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_LIBSYSTEM supported. */
+/* #undef ARCHIVE_CRYPTO_MD5_LIBSYSTEM */
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_NETTLE supported. */
+/* #undef ARCHIVE_CRYPTO_MD5_NETTLE */
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_OPENSSL supported. */
+/* #undef ARCHIVE_CRYPTO_MD5_OPENSSL */
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_WIN supported. */
+#define ARCHIVE_CRYPTO_MD5_WIN 1
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_LIBC supported. */
+/* #undef ARCHIVE_CRYPTO_RMD160_LIBC */
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_LIBMD supported. */
+/* #undef ARCHIVE_CRYPTO_RMD160_LIBMD */
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_NETTLE supported. */
+/* #undef ARCHIVE_CRYPTO_RMD160_NETTLE */
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_OPENSSL supported. */
+/* #undef ARCHIVE_CRYPTO_RMD160_OPENSSL */
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBC supported. */
+/* #undef ARCHIVE_CRYPTO_SHA1_LIBC */
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBMD supported. */
+/* #undef ARCHIVE_CRYPTO_SHA1_LIBMD */
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBSYSTEM supported. */
+/* #undef ARCHIVE_CRYPTO_SHA1_LIBSYSTEM */
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_NETTLE supported. */
+/* #undef ARCHIVE_CRYPTO_SHA1_NETTLE */
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_OPENSSL supported. */
+/* #undef ARCHIVE_CRYPTO_SHA1_OPENSSL */
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_WIN supported. */
+#define ARCHIVE_CRYPTO_SHA1_WIN 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_LIBC */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC2 supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_LIBC2 */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC3 supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_LIBC3 */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBMD supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_LIBMD */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBSYSTEM supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_LIBSYSTEM */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_NETTLE supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_NETTLE */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_OPENSSL supported. */
+/* #undef ARCHIVE_CRYPTO_SHA256_OPENSSL */
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_WIN supported. */
+#define ARCHIVE_CRYPTO_SHA256_WIN 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC supported. */
+/* #undef ARCHIVE_CRYPTO_SHA384_LIBC */
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC2 supported. */
+/* #undef ARCHIVE_CRYPTO_SHA384_LIBC2 */
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC3 supported. */
+/* #undef ARCHIVE_CRYPTO_SHA384_LIBC3 */
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBSYSTEM supported. */
+/* #undef ARCHIVE_CRYPTO_SHA384_LIBSYSTEM */
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_NETTLE supported. */
+/* #undef ARCHIVE_CRYPTO_SHA384_NETTLE */
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_OPENSSL supported. */
+/* #undef ARCHIVE_CRYPTO_SHA384_OPENSSL */
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_WIN supported. */
+#define ARCHIVE_CRYPTO_SHA384_WIN 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_LIBC */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC2 supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_LIBC2 */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC3 supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_LIBC3 */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBMD supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_LIBMD */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBSYSTEM supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_LIBSYSTEM */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_NETTLE supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_NETTLE */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_OPENSSL supported. */
+/* #undef ARCHIVE_CRYPTO_SHA512_OPENSSL */
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_WIN supported. */
+#define ARCHIVE_CRYPTO_SHA512_WIN 1
+
+/* Define to 1 if you have the `acl_create_entry' function. */
+/* #undef HAVE_ACL_CREATE_ENTRY */
+
+/* Define to 1 if you have the `acl_get_link' function. */
+/* #undef HAVE_ACL_GET_LINK */
+
+/* Define to 1 if you have the `acl_get_link_np' function. */
+/* #undef HAVE_ACL_GET_LINK_NP */
+
+/* Define to 1 if you have the `acl_get_perm' function. */
+/* #undef HAVE_ACL_GET_PERM */
+
+/* Define to 1 if you have the `acl_get_perm_np' function. */
+/* #undef HAVE_ACL_GET_PERM_NP */
+
+/* Define to 1 if you have the `acl_init' function. */
+/* #undef HAVE_ACL_INIT */
+
+/* Define to 1 if you have the <acl/libacl.h> header file. */
+/* #undef HAVE_ACL_LIBACL_H */
+
+/* Define to 1 if the system has the type `acl_permset_t'. */
+/* #undef HAVE_ACL_PERMSET_T */
+
+/* Define to 1 if you have the `acl_set_fd' function. */
+/* #undef HAVE_ACL_SET_FD */
+
+/* Define to 1 if you have the `acl_set_fd_np' function. */
+/* #undef HAVE_ACL_SET_FD_NP */
+
+/* Define to 1 if you have the `acl_set_file' function. */
+/* #undef HAVE_ACL_SET_FILE */
+
+/* True for systems with POSIX ACL support */
+/* #undef HAVE_ACL_USER */
+
+/* Define to 1 if you have the `arc4random_buf' function. */
+/* #undef HAVE_ARC4RANDOM_BUF */
+
+/* Define to 1 if you have the <attr/xattr.h> header file. */
+/* #undef HAVE_ATTR_XATTR_H */
+
+/* Define to 1 if you have the <Bcrypt.h> header file. */
+#define HAVE_BCRYPT_H
+
+/* Define to 1 if you have the <bzlib.h> header file. */
+/* #undef HAVE_BZLIB_H */
+
+/* Define to 1 if you have the `chflags' function. */
+/* #undef HAVE_CHFLAGS */
+
+/* Define to 1 if you have the `chown' function. */
+/* #undef HAVE_CHOWN */
+
+/* Define to 1 if you have the `chroot' function. */
+/* #undef HAVE_CHROOT */
+
+/* Define to 1 if you have the <copyfile.h> header file. */
+/* #undef HAVE_COPYFILE_H */
+
+/* Define to 1 if you have the `ctime_r' function. */
+/* #undef HAVE_CTIME_R */
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define to 1 if you have the `cygwin_conv_path' function. */
+/* #undef HAVE_CYGWIN_CONV_PATH */
+
+/* Define to 1 if you have the declaration of `EXTATTR_NAMESPACE_USER', and to
+ 0 if you don't. */
+#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0
+
+/* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you
+ don't. */
+#define HAVE_DECL_INT64_MAX 1
+
+/* Define to 1 if you have the declaration of `INT64_MIN', and to 0 if you
+ don't. */
+#define HAVE_DECL_INT64_MIN 1
+
+/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you
+ don't. */
+#define HAVE_DECL_SIZE_MAX 1
+
+/* Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you
+ don't. */
+#define HAVE_DECL_SSIZE_MAX 1
+
+/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
+ don't. */
+#define HAVE_DECL_STRERROR_R 0
+
+/* Define to 1 if you have the declaration of `UINT32_MAX', and to 0 if you
+ don't. */
+#define HAVE_DECL_UINT32_MAX 1
+
+/* Define to 1 if you have the declaration of `UINT64_MAX', and to 0 if you
+ don't. */
+#define HAVE_DECL_UINT64_MAX 1
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the `dirfd' function. */
+/* #undef HAVE_DIRFD */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if nl_langinfo supports D_MD_ORDER */
+/* #undef HAVE_D_MD_ORDER */
+
+/* A possible errno value for invalid file format errors */
+/* #undef HAVE_EFTYPE */
+
+/* A possible errno value for invalid file format errors */
+#define HAVE_EILSEQ 1
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the <expat.h> header file. */
+/* #undef HAVE_EXPAT_H */
+
+/* Define to 1 if you have the <ext2fs/ext2_fs.h> header file. */
+/* #undef HAVE_EXT2FS_EXT2_FS_H */
+
+/* Define to 1 if you have the `extattr_get_file' function. */
+/* #undef HAVE_EXTATTR_GET_FILE */
+
+/* Define to 1 if you have the `extattr_list_file' function. */
+/* #undef HAVE_EXTATTR_LIST_FILE */
+
+/* Define to 1 if you have the `extattr_set_fd' function. */
+/* #undef HAVE_EXTATTR_SET_FD */
+
+/* Define to 1 if you have the `extattr_set_file' function. */
+/* #undef HAVE_EXTATTR_SET_FILE */
+
+/* Define to 1 if you have the `fchdir' function. */
+/* #undef HAVE_FCHDIR */
+
+/* Define to 1 if you have the `fchflags' function. */
+/* #undef HAVE_FCHFLAGS */
+
+/* Define to 1 if you have the `fchmod' function. */
+/* #undef HAVE_FCHMOD */
+
+/* Define to 1 if you have the `fchown' function. */
+/* #undef HAVE_FCHOWN */
+
+/* Define to 1 if you have the `fcntl' function. */
+/* #undef HAVE_FCNTL */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fdopendir' function. */
+/* #undef HAVE_FDOPENDIR */
+
+/* Define to 1 if you have the `fgetea' function. */
+/* #undef HAVE_FGETEA */
+
+/* Define to 1 if you have the `fgetxattr' function. */
+/* #undef HAVE_FGETXATTR */
+
+/* Define to 1 if you have the `flistea' function. */
+/* #undef HAVE_FLISTEA */
+
+/* Define to 1 if you have the `flistxattr' function. */
+/* #undef HAVE_FLISTXATTR */
+
+/* Define to 1 if you have the `fork' function. */
+/* #undef HAVE_FORK */
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#define HAVE_FSEEKO 1
+
+/* Define to 1 if you have the `fsetea' function. */
+/* #undef HAVE_FSETEA */
+
+/* Define to 1 if you have the `fsetxattr' function. */
+/* #undef HAVE_FSETXATTR */
+
+/* Define to 1 if you have the `fstat' function. */
+#define HAVE_FSTAT 1
+
+/* Define to 1 if you have the `fstatat' function. */
+/* #undef HAVE_FSTATAT */
+
+/* Define to 1 if you have the `fstatfs' function. */
+/* #undef HAVE_FSTATFS */
+
+/* Define to 1 if you have the `fstatvfs' function. */
+/* #undef HAVE_FSTATVFS */
+
+/* Define to 1 if you have the `ftruncate' function. */
+#define HAVE_FTRUNCATE 1
+
+/* Define to 1 if you have the `futimens' function. */
+/* #undef HAVE_FUTIMENS */
+
+/* Define to 1 if you have the `futimes' function. */
+/* #undef HAVE_FUTIMES */
+
+/* Define to 1 if you have the `futimesat' function. */
+/* #undef HAVE_FUTIMESAT */
+
+/* Define to 1 if you have the `getea' function. */
+/* #undef HAVE_GETEA */
+
+/* Define to 1 if you have the `geteuid' function. */
+/* #undef HAVE_GETEUID */
+
+/* Define to 1 if you have the `getgrgid_r' function. */
+/* #undef HAVE_GETGRGID_R */
+
+/* Define to 1 if you have the `getgrnam_r' function. */
+/* #undef HAVE_GETGRNAM_R */
+
+/* Define to 1 if you have the `getpid' function. */
+#define HAVE_GETPID 1
+
+/* Define to 1 if you have the `getpwnam_r' function. */
+/* #undef HAVE_GETPWNAM_R */
+
+/* Define to 1 if you have the `getpwuid_r' function. */
+/* #undef HAVE_GETPWUID_R */
+
+/* Define to 1 if you have the `getvfsbyname' function. */
+/* #undef HAVE_GETVFSBYNAME */
+
+/* Define to 1 if you have the `getxattr' function. */
+/* #undef HAVE_GETXATTR */
+
+/* Define to 1 if you have the `gmtime_r' function. */
+/* #undef HAVE_GMTIME_R */
+
+/* Define to 1 if you have the <grp.h> header file. */
+/* #undef HAVE_GRP_H */
+
+/* Define if you have the iconv() function and it works. */
+/* #undef HAVE_ICONV */
+
+/* Define to 1 if you have the <iconv.h> header file. */
+/* #undef HAVE_ICONV_H */
+
+/* Define to 1 if the system has the type `intmax_t'. */
+#define HAVE_INTMAX_T 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <io.h> header file. */
+#define HAVE_IO_H 1
+
+/* Define to 1 if you have the <langinfo.h> header file. */
+/* #undef HAVE_LANGINFO_H */
+
+/* Define to 1 if you have the `lchflags' function. */
+/* #undef HAVE_LCHFLAGS */
+
+/* Define to 1 if you have the `lchmod' function. */
+/* #undef HAVE_LCHMOD */
+
+/* Define to 1 if you have the `lchown' function. */
+/* #undef HAVE_LCHOWN */
+
+/* Define to 1 if you have the `lgetea' function. */
+/* #undef HAVE_LGETEA */
+
+/* Define to 1 if you have the `lgetxattr' function. */
+/* #undef HAVE_LGETXATTR */
+
+/* Define to 1 if you have the `acl' library (-lacl). */
+/* #undef HAVE_LIBACL */
+
+/* Define to 1 if you have the `attr' library (-lattr). */
+/* #undef HAVE_LIBATTR */
+
+/* Define to 1 if you have the `bz2' library (-lbz2). */
+/* #undef HAVE_LIBBZ2 */
+
+/* Define to 1 if you have the `charset' library (-lcharset). */
+/* #undef HAVE_LIBCHARSET */
+
+/* Define to 1 if you have the `crypto' library (-lcrypto). */
+/* #undef HAVE_LIBCRYPTO */
+
+/* Define to 1 if you have the `eay32' library (-leay32). */
+/* #undef HAVE_LIBEAY32 */
+
+/* Define to 1 if you have the `eay64' library (-leay64). */
+/* #undef HAVE_LIBEAY64 */
+
+/* Define to 1 if you have the `expat' library (-lexpat). */
+/* #undef HAVE_LIBEXPAT */
+
+/* Define to 1 if you have the `lz4' library (-llz4). */
+/* #undef HAVE_LIBLZ4 */
+
+/* Define to 1 if you have the `lzma' library (-llzma). */
+/* #undef HAVE_LIBLZMA */
+
+/* Define to 1 if you have the `lzmadec' library (-llzmadec). */
+/* #undef HAVE_LIBLZMADEC */
+
+/* Define to 1 if you have the `lzo2' library (-llzo2). */
+/* #undef HAVE_LIBLZO2 */
+
+/* Define to 1 if you have the `md' library (-lmd). */
+/* #undef HAVE_LIBMD */
+
+/* Define to 1 if you have the `nettle' library (-lnettle). */
+/* #undef HAVE_LIBNETTLE */
+
+/* Define to 1 if you have the `pcre' library (-lpcre). */
+/* #undef HAVE_LIBPCRE */
+
+/* Define to 1 if you have the `pcreposix' library (-lpcreposix). */
+/* #undef HAVE_LIBPCREPOSIX */
+
+/* Define to 1 if you have the `regex' library (-lregex). */
+/* #undef HAVE_LIBREGEX */
+
+/* Define to 1 if you have the `xml2' library (-lxml2). */
+/* #undef HAVE_LIBXML2 */
+
+/* Define to 1 if you have the <libxml/xmlreader.h> header file. */
+/* #undef HAVE_LIBXML_XMLREADER_H */
+
+/* Define to 1 if you have the <libxml/xmlwriter.h> header file. */
+/* #undef HAVE_LIBXML_XMLWRITER_H */
+
+/* Define to 1 if you have the `z' library (-lz). */
+/* #undef HAVE_LIBZ */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the `link' function. */
+/* #undef HAVE_LINK */
+
+/* Define to 1 if you have the <linux/fiemap.h> header file. */
+/* #undef HAVE_LINUX_FIEMAP_H */
+
+/* Define to 1 if you have the <linux/fs.h> header file. */
+/* #undef HAVE_LINUX_FS_H */
+
+/* Define to 1 if you have the <linux/magic.h> header file. */
+/* #undef HAVE_LINUX_MAGIC_H */
+
+/* Define to 1 if you have the <linux/types.h> header file. */
+/* #undef HAVE_LINUX_TYPES_H */
+
+/* Define to 1 if you have the `listea' function. */
+/* #undef HAVE_LISTEA */
+
+/* Define to 1 if you have the `listxattr' function. */
+/* #undef HAVE_LISTXATTR */
+
+/* Define to 1 if you have the `llistea' function. */
+/* #undef HAVE_LLISTEA */
+
+/* Define to 1 if you have the `llistxattr' function. */
+/* #undef HAVE_LLISTXATTR */
+
+/* Define to 1 if you have the <localcharset.h> header file. */
+/* #undef HAVE_LOCALCHARSET_H */
+
+/* Define to 1 if you have the `locale_charset' function. */
+/* #undef HAVE_LOCALE_CHARSET */
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if you have the `localtime_r' function. */
+/* #undef HAVE_LOCALTIME_R */
+
+/* Define to 1 if the system has the type `long long int'. */
+#define HAVE_LONG_LONG_INT 1
+
+/* Define to 1 if you have the `lsetea' function. */
+/* #undef HAVE_LSETEA */
+
+/* Define to 1 if you have the `lsetxattr' function. */
+/* #undef HAVE_LSETXATTR */
+
+/* Define to 1 if you have the `lstat' function. */
+/* #undef HAVE_LSTAT */
+
+/* Define to 1 if `lstat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#define HAVE_LSTAT_EMPTY_STRING_BUG 1
+
+/* Define to 1 if you have the `lutimes' function. */
+/* #undef HAVE_LUTIMES */
+
+/* Define to 1 if you have the <lz4hc.h> header file. */
+/* #undef HAVE_LZ4HC_H */
+
+/* Define to 1 if you have the <lz4.h> header file. */
+/* #undef HAVE_LZ4_H */
+
+/* Define to 1 if you have the <lzmadec.h> header file. */
+/* #undef HAVE_LZMADEC_H */
+
+/* Define to 1 if you have the <lzma.h> header file. */
+/* #undef HAVE_LZMA_H */
+
+/* Define to 1 if you have the <lzo/lzo1x.h> header file. */
+/* #undef HAVE_LZO_LZO1X_H */
+
+/* Define to 1 if you have the <lzo/lzoconf.h> header file. */
+/* #undef HAVE_LZO_LZOCONF_H */
+
+/* Define to 1 if you have the `mbrtowc' function. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if you have the <md5.h> header file. */
+/* #undef HAVE_MD5_H */
+
+/* Define to 1 if you have the `memmove' function. */
+#define HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkdir' function. */
+#define HAVE_MKDIR 1
+
+/* Define to 1 if you have the `mkfifo' function. */
+/* #undef HAVE_MKFIFO */
+
+/* Define to 1 if you have the `mknod' function. */
+/* #undef HAVE_MKNOD */
+
+/* Define to 1 if you have the `mkstemp' function. */
+/* #undef HAVE_MKSTEMP */
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+/* #undef HAVE_NDIR_H */
+
+/* Define to 1 if you have the <nettle/md5.h> header file. */
+/* #undef HAVE_NETTLE_MD5_H */
+
+/* Define to 1 if you have the <nettle/pbkdf2.h> header file. */
+/* #undef HAVE_NETTLE_PBKDF2_H */
+
+/* Define to 1 if you have the <nettle/ripemd160.h> header file. */
+/* #undef HAVE_NETTLE_RIPEMD160_H */
+
+/* Define to 1 if you have the <nettle/sha.h> header file. */
+/* #undef HAVE_NETTLE_SHA_H */
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+/* #undef HAVE_NL_LANGINFO */
+
+/* Define to 1 if you have the `openat' function. */
+/* #undef HAVE_OPENAT */
+
+/* Define to 1 if you have the <openssl/evp.h> header file. */
+/* #undef HAVE_OPENSSL_EVP_H */
+
+/* Define to 1 if you have the <paths.h> header file. */
+/* #undef HAVE_PATHS_H */
+
+/* Define to 1 if you have the <pcreposix.h> header file. */
+/* #undef HAVE_PCREPOSIX_H */
+
+/* Define to 1 if you have the `pipe' function. */
+/* #undef HAVE_PIPE */
+
+/* Define to 1 if you have the `PKCS5_PBKDF2_HMAC_SHA1' function. */
+/* #undef HAVE_PKCS5_PBKDF2_HMAC_SHA1 */
+
+/* Define to 1 if you have the `poll' function. */
+/* #undef HAVE_POLL */
+
+/* Define to 1 if you have the <poll.h> header file. */
+/* #undef HAVE_POLL_H */
+
+/* Define to 1 if you have the `posix_spawnp' function. */
+/* #undef HAVE_POSIX_SPAWNP */
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#define HAVE_PTHREAD_H 1
+
+/* Define to 1 if you have the <pwd.h> header file. */
+/* #undef HAVE_PWD_H */
+
+/* Define to 1 if you have a POSIX compatible readdir_r */
+#define HAVE_READDIR_R 1
+
+/* Define to 1 if you have the `readlink' function. */
+/* #undef HAVE_READLINK */
+
+/* Define to 1 if you have the `readlinkat' function. */
+/* #undef HAVE_READLINKAT */
+
+/* Define to 1 if you have the `readpassphrase' function. */
+/* #undef HAVE_READPASSPHRASE */
+
+/* Define to 1 if you have the <readpassphrase.h> header file. */
+/* #undef HAVE_READPASSPHRASE_H */
+
+/* Define to 1 if you have the <regex.h> header file. */
+/* #undef HAVE_REGEX_H */
+
+/* Define to 1 if you have the <ripemd.h> header file. */
+/* #undef HAVE_RIPEMD_H */
+
+/* Define to 1 if you have the `select' function. */
+/* #undef HAVE_SELECT */
+
+/* Define to 1 if you have the `setenv' function. */
+/* #undef HAVE_SETENV */
+
+/* Define to 1 if you have the `setlocale' function. */
+#define HAVE_SETLOCALE 1
+
+/* Define to 1 if you have the <sha256.h> header file. */
+/* #undef HAVE_SHA256_H */
+
+/* Define to 1 if you have the <sha512.h> header file. */
+/* #undef HAVE_SHA512_H */
+
+/* Define to 1 if you have the <sha.h> header file. */
+/* #undef HAVE_SHA_H */
+
+/* Define to 1 if you have the `sigaction' function. */
+/* #undef HAVE_SIGACTION */
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the <spawn.h> header file. */
+/* #undef HAVE_SPAWN_H */
+
+/* Define to 1 if you have the `statfs' function. */
+/* #undef HAVE_STATFS */
+
+/* Define to 1 if you have the `statvfs' function. */
+/* #undef HAVE_STATVFS */
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#define HAVE_STAT_EMPTY_STRING_BUG 1
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the `strerror_r' function. */
+/* #undef HAVE_STRERROR_R */
+
+/* Define to 1 if you have the `strftime' function. */
+#define HAVE_STRFTIME 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strncpy_s' function. */
+#define HAVE_STRNCPY_S 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if `f_namemax' is a member of `struct statfs'. */
+/* #undef HAVE_STRUCT_STATFS_F_NAMEMAX */
+
+/* Define to 1 if `f_iosize' is a member of `struct statvfs'. */
+/* #undef HAVE_STRUCT_STATVFS_F_IOSIZE */
+
+/* Define to 1 if `st_birthtime' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */
+
+/* Define to 1 if `st_birthtimespec.tv_nsec' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC */
+
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_BLKSIZE */
+
+/* Define to 1 if `st_flags' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_FLAGS */
+
+/* Define to 1 if `st_mtimespec.tv_nsec' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */
+
+/* Define to 1 if `st_mtime_n' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_MTIME_N */
+
+/* Define to 1 if `st_mtime_usec' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_MTIME_USEC */
+
+/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
+
+/* Define to 1 if `st_umtime' is a member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_UMTIME */
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_GMTOFF */
+
+/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM___TM_GMTOFF */
+
+/* Define to 1 if you have the `symlink' function. */
+/* #undef HAVE_SYMLINK */
+
+/* Define to 1 if you have the <sys/acl.h> header file. */
+/* #undef HAVE_SYS_ACL_H */
+
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#define HAVE_SYS_CDEFS_H 1
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define to 1 if you have the <sys/ea.h> header file. */
+/* #undef HAVE_SYS_EA_H */
+
+/* Define to 1 if you have the <sys/extattr.h> header file. */
+/* #undef HAVE_SYS_EXTATTR_H */
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+/* #undef HAVE_SYS_IOCTL_H */
+
+/* Define to 1 if you have the <sys/mkdev.h> header file. */
+/* #undef HAVE_SYS_MKDEV_H */
+
+/* Define to 1 if you have the <sys/mount.h> header file. */
+/* #undef HAVE_SYS_MOUNT_H */
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/poll.h> header file. */
+/* #undef HAVE_SYS_POLL_H */
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+/* #undef HAVE_SYS_SELECT_H */
+
+/* Define to 1 if you have the <sys/statfs.h> header file. */
+/* #undef HAVE_SYS_STATFS_H */
+
+/* Define to 1 if you have the <sys/statvfs.h> header file. */
+/* #undef HAVE_SYS_STATVFS_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utime.h> header file. */
+#define HAVE_SYS_UTIME_H 1
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+/* #undef HAVE_SYS_UTSNAME_H */
+
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+/* #undef HAVE_SYS_VFS_H */
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+/* #undef HAVE_SYS_WAIT_H */
+
+/* Define to 1 if you have the <sys/xattr.h> header file. */
+/* #undef HAVE_SYS_XATTR_H */
+
+/* Define to 1 if you have the `timegm' function. */
+/* #undef HAVE_TIMEGM */
+
+/* Define to 1 if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define to 1 if you have the `tzset' function. */
+#define HAVE_TZSET 1
+
+/* Define to 1 if the system has the type `uintmax_t'. */
+#define HAVE_UINTMAX_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `unsetenv' function. */
+/* #undef HAVE_UNSETENV */
+
+/* Define to 1 if the system has the type `unsigned long long'. */
+#define HAVE_UNSIGNED_LONG_LONG 1
+
+/* Define to 1 if the system has the type `unsigned long long int'. */
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 if you have the `utimensat' function. */
+/* #undef HAVE_UTIMENSAT */
+
+/* Define to 1 if you have the `utimes' function. */
+/* #undef HAVE_UTIMES */
+
+/* Define to 1 if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define to 1 if you have the `vfork' function. */
+/* #undef HAVE_VFORK */
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if the system has the type `wchar_t'. */
+#define HAVE_WCHAR_T 1
+
+/* Define to 1 if you have the `wcrtomb' function. */
+#define HAVE_WCRTOMB 1
+
+/* Define to 1 if you have the `wcscmp' function. */
+#define HAVE_WCSCMP 1
+
+/* Define to 1 if you have the `wcscpy' function. */
+#define HAVE_WCSCPY 1
+
+/* Define to 1 if you have the `wcslen' function. */
+#define HAVE_WCSLEN 1
+
+/* Define to 1 if you have the `wctomb' function. */
+#define HAVE_WCTOMB 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if you have the <wincrypt.h> header file. */
+#define HAVE_WINCRYPT_H 1
+
+/* Define to 1 if you have the <windows.h> header file. */
+#define HAVE_WINDOWS_H 1
+
+/* Define to 1 if you have the <winioctl.h> header file. */
+#define HAVE_WINIOCTL_H 1
+
+/* Define to 1 if you have the `wmemcmp' function. */
+#define HAVE_WMEMCMP 1
+
+/* Define to 1 if you have the `wmemcpy' function. */
+#define HAVE_WMEMCPY 1
+
+/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */
+/* #undef HAVE_WORKING_EXT2_IOC_GETFLAGS */
+
+/* Define to 1 if you have the <zlib.h> header file. */
+/* #undef HAVE_ZLIB_H */
+
+/* Define to 1 if you have the `_ctime64_s' function. */
+#define HAVE__CTIME64_S 1
+
+/* Define to 1 if you have the `_fseeki64' function. */
+#define HAVE__FSEEKI64 1
+
+/* Define to 1 if you have the `_get_timezone' function. */
+/* #undef HAVE__GET_TIMEZONE */
+
+/* Define to 1 if you have the `_localtime64_s' function. */
+#define HAVE__LOCALTIME64_S 1
+
+/* Define to 1 if you have the `_mkgmtime64' function. */
+/* #define HAVE__MKGMTIME64 1 */
+
+/* Define as const if the declaration of iconv() needs const. */
+/* #undef ICONV_CONST */
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+ slash. */
+/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+ */
+/* #undef MAJOR_IN_MKDEV */
+
+/* Define to 1 if `major', `minor', and `makedev' are declared in
+ <sysmacros.h>. */
+/* #undef MAJOR_IN_SYSMACROS */
+
+
+/* Define to 1 if PCRE_STATIC needs to be defined. */
+/* #undef PCRE_STATIC */
+
+/* The size of `wchar_t', as computed by sizeof. */
+#define SIZEOF_WCHAR_T 2
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if strerror_r returns char *. */
+/* #undef STRERROR_R_CHAR_P */
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+
+
+/* Define to '0x0500' for Windows 2000 APIs. */
+#define WINVER 0x0500
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#define _FILE_OFFSET_BITS 64
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT32_T */
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT64_T */
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT8_T */
+
+/* Define to '0x0500' for Windows 2000 APIs. */
+#define _WIN32_WINNT 0x0500
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to match typeof st_gid field of struct stat if <sys/types.h> doesn't
+ define. */
+#define gid_t short
+
+/* Define to `unsigned long' if <sys/types.h> does not define. */
+#define id_t unsigned long
+
+/* Define to the type of a signed integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int16_t */
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int32_t */
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef int64_t */
+
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+ not define. */
+/* #undef intmax_t */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef mode_t */
+
+/* Define to `long long' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to match typeof st_uid field of struct stat if <sys/types.h> doesn't
+ define. */
+#define uid_t short
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint16_t */
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint32_t */
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint64_t */
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint8_t */
+
+/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
+ do not define. */
+/* #undef uintmax_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef uintptr_t */
diff --git a/contrib/android/include/Bcrypt.h b/contrib/android/include/Bcrypt.h
new file mode 100644
index 000000000000..df295990292b
--- /dev/null
+++ b/contrib/android/include/Bcrypt.h
@@ -0,0 +1 @@
+#include <bcrypt.h>
diff --git a/contrib/android/include/Windows.h b/contrib/android/include/Windows.h
new file mode 100644
index 000000000000..776a87ce358d
--- /dev/null
+++ b/contrib/android/include/Windows.h
@@ -0,0 +1 @@
+#include <windows.h>
diff --git a/contrib/android/include/android_lf.h b/contrib/android/include/android_lf.h
new file mode 100644
index 000000000000..2a18f5142033
--- /dev/null
+++ b/contrib/android/include/android_lf.h
@@ -0,0 +1,47 @@
+/*
+ * Macros for file64 functions
+ *
+ * Android does not support the macro _FILE_OFFSET_BITS=64
+ * As of android-21 it does however support many file64 functions
+*/
+
+#ifndef ARCHIVE_ANDROID_LF_H_INCLUDED
+#define ARCHIVE_ANDROID_LF_H_INCLUDED
+
+#if __ANDROID_API__ > 20
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/statvfs.h>
+#include <sys/types.h>
+#include <sys/vfs.h>
+
+//dirent.h
+#define readdir_r readdir64_r
+#define readdir readdir64
+#define dirent dirent64
+//fcntl.h
+#define openat openat64
+#define open open64
+#define mkstemp mkstemp64
+//unistd.h
+#define lseek lseek64
+#define ftruncate ftruncate64
+//sys/stat.h
+#define fstatat fstatat64
+#define fstat fstat64
+#define lstat lstat64
+#define stat stat64
+//sys/statvfs.h
+#define fstatvfs fstatvfs64
+#define statvfs statvfs64
+//sys/types.h
+#define off_t off64_t
+//sys/vfs.h
+#define fstatfs fstatfs64
+#define statfs statfs64
+#endif
+
+#endif /* ARCHIVE_ANDROID_LF_H_INCLUDED */
diff --git a/contrib/libarchive.spec b/contrib/libarchive.spec
index b5b658a874b1..f4ed359721a0 100644
--- a/contrib/libarchive.spec
+++ b/contrib/libarchive.spec
@@ -1,14 +1,11 @@
-# $LastChangedRevision$, $LastChangedDate$
Summary: Library to create and read several different archive formats
-Summary(pl): Biblioteka do tworzenia i odczytu różnych formatów archiwów
Name: libarchive
-Version: 2.0a3
+Version: 3.1.2
Release: 1
License: BSD
Group: Libraries
-Source0: http://people.freebsd.org/~kientzle/libarchive/src/%{name}-%{version}.tar.gz
-Patch: %{name}-0123457890.patch
-URL: http://people.freebsd.org/~kientzle/libarchive/
+Source0: http://libarchive.org/downloads/%{name}-%{version}.tar.gz
+URL: http:/libarchive.org/
Requires: glibc
Requires: zlib
Requires: bzip2
@@ -24,57 +21,47 @@ Libarchive is a programming library that can create and read several
different streaming archive formats, including most popular TAR
variants and several CPIO formats. It can also write SHAR archives.
-%description -l pl
-Libarchive jest biblioteką służacą to tworzenia i odczytu wielu
-różnych strumieniowych formatów archiwów, włączając w to popularne
-odmiany TAR oraz wiele formatów CPIO. Biblioteka ta potrafi także
-zapisywać archiwa SHAR.
-
%package devel
Summary: Header files for libarchive library
-Summary(pl): Pliki nagłówkowe biblioteki libarchive
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
Header files for libarchive library.
-%description devel -l pl
-Pliki nagłówkowe biblioteki libarchive.
-
%package static
Summary: Static libarchive library
-Summary(pl): Statyczna biblioteka libarchive
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
%description static
Static libarchive library.
-%description static -l pl
-Statyczna biblioteka libarchive.
-
%package -n bsdtar
Summary: bsdtar - tar(1) implementation based on libarchive
-Summary(pl): bsdtar - implementacja programu tar(1) oparta na libarchive
Group: Applications/Archiving
Requires: %{name} = %{version}-%{release}
%description -n bsdtar
bsdtar - tar(1) implementation based on libarchive.
-%description -n bsdtar -l pl
-bsdtar - implementacja programu tar(1), oparta na libarchive.
+%package -n bsdcpio
+Summary: bsdcpio - cpio(1) implementation based on libarchive
+Group: Applications/Archiving
+Requires: %{name} = %{version}-%{release}
+
+%description -n bsdcpio
+bsdcpio - cpio(1) implementation based on libarchive
%prep
%setup -q
-%patch0 -p1
%build
mkdir -p %{buildroot}
./configure \
--prefix=%{_prefix} \
--libexecdir=%{_libexecdir} \
+--libdir=%{_libdir} \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--enable-shared=yes \
@@ -85,63 +72,34 @@ make | tee %{buildroot}/make.log
%install
[ "%buildroot" != "/" ] && [ -d %buildroot ] && rm -rf %buildroot;
make DESTDIR=%buildroot install
-# original install builds, but does install bsdtar
-cp .libs/%{name}.a %{buildroot}%{_libdir}
-cp bsdtar %{buildroot}%{_bindir}
-cp tar/bsdtar.1 %{buildroot}%{_mandir}/man1
%clean
rm -fr %buildroot
%files
-%defattr(644,root,root,755)
+%{_libdir}/libarchive.so*
+
+%files static
%{_libdir}/libarchive.a
%files devel
-%defattr(644,root,root,755)
+%{_libdir}/pkgconfig/libarchive.pc
%{_libdir}/libarchive.la
%{_includedir}/*.h
%doc %{_mandir}/man3/*
%doc %{_mandir}/man5/*
%files -n bsdtar
-%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/bsdtar
%doc %{_mandir}/man1/bsdtar.1*
-%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
+%files -n bsdcpio
+%attr(755,root,root) %{_bindir}/bsdcpio
+%doc %{_mandir}/man1/bsdcpio.1*
+
%changelog
-* %{date} PLD Team <feedback@pld-linux.org>
-All persons listed below can be reached at <cvs_login>@pld-linux.org
-
-$Log: libarchive.spec,v $
-Release 1 2006/12/12 rm1023@dcx.com
-- added libarchive-0123457890.patch for "0123457890" error
-- replaced libarchive-1.3.1.tar.gz with libarchive-2.0a3.tar.gz
-- removed obsolete -CVE-2006-5680.patch and -man_progname.patch
-
-Revision 1.6 2006/11/15 10:41:28 qboosh
-- BR: acl-devel,attr-devel
-- devel deps
-
-Revision 1.5 2006/11/08 22:22:25 twittner
-- up to 1.3.1
-- added BR: e2fsprogs-devel
-- added -CVE-2006-5680.patch against entering an infinite
-loop in corrupt archives
-- added bsdtar package (bsdtar is included now in libarchive
-sources)
-- rel. 0.1 for testing
-
-Revision 1.4 2005/12/15 18:26:36 twittner
-- up to 1.2.37
-- removed -shared.patch (no longer needed)
-
-Revision 1.3 2005/10/05 17:00:12 arekm
-- up to 1.02.034
-
-Revision 1.2 2005/07/27 20:17:21 qboosh
-- typo
-
-Revision 1.1 2005/07/27 08:36:03 adamg
-- new
+* Wed May 01 2013 Nikolai Lifanov <lifanov@mail.lifanov.com> - 3.1.2-1
+- Initial package
+- contrib/libarchive.spec by PLD team overhaul
+- Added "bsdcpio" package
+- Fixed build on x86_64 platform
diff --git a/contrib/untar.c b/contrib/untar.c
index c4cc2bf9bea2..3d954f638be0 100644
--- a/contrib/untar.c
+++ b/contrib/untar.c
@@ -1,4 +1,8 @@
/*
+ * This file is in the public domain. Use it as you see fit.
+ */
+
+/*
* "untar" is an extremely simple tar extractor:
* * A single C source file, so it should be easy to compile
* and run on any system with a C compiler.
@@ -95,7 +99,7 @@ static FILE *
create_file(char *pathname, int mode)
{
FILE *f;
- f = fopen(pathname, "w+");
+ f = fopen(pathname, "wb+");
if (f == NULL) {
/* Try creating parent dir and then creating file. */
char *p = strrchr(pathname, '/');
@@ -103,7 +107,7 @@ create_file(char *pathname, int mode)
*p = '\0';
create_dir(pathname, 0755);
*p = '/';
- f = fopen(pathname, "w+");
+ f = fopen(pathname, "wb+");
}
}
return (f);
@@ -213,7 +217,7 @@ main(int argc, char **argv)
++argv; /* Skip program name */
for ( ;*argv != NULL; ++argv) {
- a = fopen(*argv, "r");
+ a = fopen(*argv, "rb");
if (a == NULL)
fprintf(stderr, "Unable to open %s\n", *argv);
else {
diff --git a/cpio/CMakeLists.txt b/cpio/CMakeLists.txt
index cc4aa14cb54b..85fda7782800 100644
--- a/cpio/CMakeLists.txt
+++ b/cpio/CMakeLists.txt
@@ -15,7 +15,10 @@ IF(ENABLE_CPIO)
../libarchive_fe/lafe_platform.h
../libarchive_fe/line_reader.c
../libarchive_fe/line_reader.h
+ ../libarchive_fe/passphrase.c
+ ../libarchive_fe/passphrase.h
)
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
IF(WIN32 AND NOT CYGWIN)
LIST(APPEND bsdcpio_SOURCES cpio_windows.c)
@@ -34,8 +37,6 @@ IF(ENABLE_CPIO)
SET_TARGET_PROPERTIES(bsdcpio PROPERTIES COMPILE_DEFINITIONS
LIBARCHIVE_STATIC)
ENDIF(ENABLE_CPIO_SHARED)
- # Full path to the compiled executable (used by test suite)
- GET_TARGET_PROPERTY(BSDCPIO bsdcpio LOCATION)
# Installation rules
INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin)
diff --git a/cpio/bsdcpio.1 b/cpio/bsdcpio.1
index b3d0d40a21ad..e52546e6f761 100644
--- a/cpio/bsdcpio.1
+++ b/cpio/bsdcpio.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 7, 2012
+.Dd September 16, 2014
.Dt CPIO 1
.Os
.Sh NAME
@@ -32,17 +32,17 @@
.Nd copy files to and from archives
.Sh SYNOPSIS
.Nm
-.Brq Fl i
+.Fl i
.Op Ar options
.Op Ar pattern ...
.Op Ar < archive
.Nm
-.Brq Fl o
+.Fl o
.Op Ar options
.Ar < name-list
.Op Ar > archive
.Nm
-.Brq Fl p
+.Fl p
.Op Ar options
.Ar dest-dir
.Ar < name-list
@@ -156,7 +156,8 @@ See above for description.
.It Fl Fl insecure
(i and p mode only)
Disable security checks during extraction or copying.
-This allows extraction via symbolic links and path names containing
+This allows extraction via symbolic links, absolute paths,
+and path names containing
.Sq ..
in the name.
.It Fl J , Fl Fl xz
@@ -181,6 +182,11 @@ instead of copying.
Compress the resulting archive with
.Xr lrzip 1 .
In input mode, this option is ignored.
+.It Fl Fl lz4
+(o mode only)
+Compress the archive with lz4-compatible compression before writing it.
+In input mode, this option is ignored; lz4 compression is recognized
+automatically on input.
.It Fl Fl lzma
(o mode only)
Compress the file with lzma-compatible compression before writing it.
@@ -191,6 +197,15 @@ automatically on input.
Compress the resulting archive with
.Xr lzop 1 .
In input mode, this option is ignored.
+.It Fl Fl passphrase Ar passphrase
+The
+.Pa passphrase
+is used to extract or create an encrypted archive.
+Currently, zip is only a format that
+.Nm
+can handle encrypted archives.
+You shouldn't use this option unless you realize how insecure
+use of this option is.
.It Fl m , Fl Fl preserve-modification-time
(i and p modes)
Set file modification time on created files to match
diff --git a/cpio/cmdline.c b/cpio/cmdline.c
index 0121fd13937f..7e59536957a4 100644
--- a/cpio/cmdline.c
+++ b/cpio/cmdline.c
@@ -73,6 +73,7 @@ static const struct option {
{ "link", 0, 'l' },
{ "list", 0, 't' },
{ "lrzip", 0, OPTION_LRZIP },
+ { "lz4", 0, OPTION_LZ4 },
{ "lzma", 0, OPTION_LZMA },
{ "lzop", 0, OPTION_LZOP },
{ "make-directories", 0, 'd' },
@@ -80,6 +81,7 @@ static const struct option {
{ "null", 0, '0' },
{ "numeric-uid-gid", 0, 'n' },
{ "owner", 1, 'R' },
+ { "passphrase", 1, OPTION_PASSPHRASE },
{ "pass-through", 0, 'p' },
{ "preserve-modification-time", 0, 'm' },
{ "preserve-owner", 0, OPTION_PRESERVE_OWNER },
diff --git a/cpio/cpio.c b/cpio/cpio.c
index 6f57d95d616e..b267e9b8a744 100644
--- a/cpio/cpio.c
+++ b/cpio/cpio.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle
#include "cpio.h"
#include "err.h"
#include "line_reader.h"
+#include "passphrase.h"
/* Fixed size of uname/gname caches. */
#define name_cache_size 101
@@ -123,6 +124,8 @@ static int restore_time(struct cpio *, struct archive_entry *,
const char *, int fd);
static void usage(void);
static void version(void);
+static const char * passphrase_callback(struct archive *, void *);
+static void passphrase_free(char *);
int
main(int argc, char *argv[])
@@ -149,20 +152,9 @@ main(int argc, char *argv[])
}
#endif
- /* Need lafe_progname before calling lafe_warnc. */
- if (*argv == NULL)
- lafe_progname = "bsdcpio";
- else {
-#if defined(_WIN32) && !defined(__CYGWIN__)
- lafe_progname = strrchr(*argv, '\\');
- if (strrchr(*argv, '/') > lafe_progname)
-#endif
- lafe_progname = strrchr(*argv, '/');
- if (lafe_progname != NULL)
- lafe_progname++;
- else
- lafe_progname = *argv;
- }
+ /* Set lafe_progname before calling lafe_warnc. */
+ lafe_setprogname(*argv, "bsdcpio");
+
#if HAVE_SETLOCALE
if (setlocale(LC_ALL, "") == NULL)
lafe_warnc(0, "Failed to set default locale");
@@ -179,6 +171,7 @@ main(int argc, char *argv[])
cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS;
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
+ cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
cpio->extract_flags |= ARCHIVE_EXTRACT_PERM;
cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
cpio->extract_flags |= ARCHIVE_EXTRACT_ACL;
@@ -264,6 +257,7 @@ main(int argc, char *argv[])
case OPTION_INSECURE:
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS;
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
+ cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
break;
case 'L': /* GNU cpio */
cpio->option_follow_links = 1;
@@ -272,6 +266,7 @@ main(int argc, char *argv[])
cpio->option_link = 1;
break;
case OPTION_LRZIP:
+ case OPTION_LZ4:
case OPTION_LZMA: /* GNU tar, others */
case OPTION_LZOP: /* GNU tar, others */
cpio->compress = opt;
@@ -301,6 +296,9 @@ main(int argc, char *argv[])
cpio->mode = opt;
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
break;
+ case OPTION_PASSPHRASE:
+ cpio->passphrase = cpio->argument;
+ break;
case OPTION_PRESERVE_OWNER:
cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
break;
@@ -429,6 +427,7 @@ main(int argc, char *argv[])
free_cache(cpio->gname_cache);
free_cache(cpio->uname_cache);
free(cpio->destdir);
+ passphrase_free(cpio->ppbuff);
return (cpio->return_value);
}
@@ -437,7 +436,7 @@ usage(void)
{
const char *p;
- p = lafe_progname;
+ p = lafe_getprogname();
fprintf(stderr, "Brief Usage:\n");
fprintf(stderr, " List: %s -it < archive\n", p);
@@ -475,7 +474,7 @@ long_help(void)
const char *prog;
const char *p;
- prog = lafe_progname;
+ prog = lafe_getprogname();
fflush(stderr);
@@ -500,7 +499,7 @@ version(void)
{
fprintf(stdout,"bsdcpio %s -- %s\n",
BSDCPIO_VERSION_STRING,
- archive_version_string());
+ archive_version_details());
exit(0);
}
@@ -537,6 +536,9 @@ mode_out(struct cpio *cpio)
case OPTION_LRZIP:
r = archive_write_add_filter_lrzip(cpio->archive);
break;
+ case OPTION_LZ4:
+ r = archive_write_add_filter_lz4(cpio->archive);
+ break;
case OPTION_LZMA:
r = archive_write_add_filter_lzma(cpio->archive);
break;
@@ -578,6 +580,14 @@ mode_out(struct cpio *cpio)
cpio->linkresolver = archive_entry_linkresolver_new();
archive_entry_linkresolver_set_strategy(cpio->linkresolver,
archive_format(cpio->archive));
+ if (cpio->passphrase != NULL)
+ r = archive_write_set_passphrase(cpio->archive,
+ cpio->passphrase);
+ else
+ r = archive_write_set_passphrase_callback(cpio->archive, cpio,
+ &passphrase_callback);
+ if (r != ARCHIVE_OK)
+ lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
/*
* The main loop: Copy each file into the output archive.
@@ -944,6 +954,13 @@ mode_in(struct cpio *cpio)
lafe_errc(1, 0, "Couldn't allocate archive object");
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
+ if (cpio->passphrase != NULL)
+ r = archive_read_add_passphrase(a, cpio->passphrase);
+ else
+ r = archive_read_set_passphrase_callback(a, cpio,
+ &passphrase_callback);
+ if (r != ARCHIVE_OK)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
if (archive_read_open_filename(a, cpio->filename,
cpio->bytes_per_block))
@@ -1047,6 +1064,13 @@ mode_list(struct cpio *cpio)
lafe_errc(1, 0, "Couldn't allocate archive object");
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
+ if (cpio->passphrase != NULL)
+ r = archive_read_add_passphrase(a, cpio->passphrase);
+ else
+ r = archive_read_set_passphrase_callback(a, cpio,
+ &passphrase_callback);
+ if (r != ARCHIVE_OK)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
if (archive_read_open_filename(a, cpio->filename,
cpio->bytes_per_block))
@@ -1140,7 +1164,8 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
else
fmt = cpio->day_first ? "%d %b %H:%M" : "%b %d %H:%M";
#else
- if (abs(mtime - now) > (365/2)*86400)
+ if (mtime - now > 365*86400/2
+ || mtime - now < -365*86400/2)
fmt = cpio->day_first ? "%e %b %Y" : "%b %e %Y";
else
fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
@@ -1235,8 +1260,10 @@ cpio_rename(const char *name)
if (t == NULL)
return (name);
to = fopen("CONOUT$", "w");
- if (to == NULL)
+ if (to == NULL) {
+ fclose(t);
return (name);
+ }
fprintf(to, "%s (Enter/./(new name))? ", name);
fclose(to);
#else
@@ -1416,3 +1443,28 @@ cpio_i64toa(int64_t n0)
*--p = '-';
return p;
}
+
+#define PPBUFF_SIZE 1024
+static const char *
+passphrase_callback(struct archive *a, void *_client_data)
+{
+ struct cpio *cpio = (struct cpio *)_client_data;
+ (void)a; /* UNUSED */
+
+ if (cpio->ppbuff == NULL) {
+ cpio->ppbuff = malloc(PPBUFF_SIZE);
+ if (cpio->ppbuff == NULL)
+ lafe_errc(1, errno, "Out of memory");
+ }
+ return lafe_readpassphrase("Enter passphrase:",
+ cpio->ppbuff, PPBUFF_SIZE);
+}
+
+static void
+passphrase_free(char *ppbuff)
+{
+ if (ppbuff != NULL) {
+ memset(ppbuff, 0, PPBUFF_SIZE);
+ free(ppbuff);
+ }
+}
diff --git a/cpio/cpio.h b/cpio/cpio.h
index 3e951ce7403e..1036dece93b0 100644
--- a/cpio/cpio.h
+++ b/cpio/cpio.h
@@ -71,6 +71,7 @@ struct cpio {
int gid_override;
char *gname_override;
int day_first; /* true if locale prefers day/mon */
+ const char *passphrase;
/* If >= 0, then close this when done. */
int fd;
@@ -90,6 +91,7 @@ struct cpio {
struct archive *matching;
char *buff;
size_t buff_size;
+ char *ppbuff;
};
const char *owner_parse(const char *, int *, int *);
@@ -101,8 +103,10 @@ enum {
OPTION_GRZIP,
OPTION_INSECURE,
OPTION_LRZIP,
+ OPTION_LZ4,
OPTION_LZMA,
OPTION_LZOP,
+ OPTION_PASSPHRASE,
OPTION_NO_PRESERVE_OWNER,
OPTION_PRESERVE_OWNER,
OPTION_QUIET,
diff --git a/cpio/cpio_platform.h b/cpio/cpio_platform.h
index 31d9a738fcb0..58d2edbcd7a4 100644
--- a/cpio/cpio_platform.h
+++ b/cpio/cpio_platform.h
@@ -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 */
diff --git a/cpio/cpio_windows.h b/cpio/cpio_windows.h
index 105bf69991de..970a63df663d 100644
--- a/cpio/cpio_windows.h
+++ b/cpio/cpio_windows.h
@@ -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
diff --git a/cpio/test/CMakeLists.txt b/cpio/test/CMakeLists.txt
index 09ca2c7d96b3..f2c27540813d 100644
--- a/cpio/test/CMakeLists.txt
+++ b/cpio/test/CMakeLists.txt
@@ -19,6 +19,7 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
test_extract_cpio_gz
test_extract_cpio_lrz
test_extract_cpio_lz
+ test_extract_cpio_lz4
test_extract_cpio_lzma
test_extract_cpio_lzo
test_extract_cpio_xz
@@ -39,9 +40,11 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
test_option_help.c
test_option_l.c
test_option_lrzip.c
+ test_option_lz4.c
test_option_lzma.c
test_option_lzop.c
test_option_m.c
+ test_option_passphrase.c
test_option_t.c
test_option_u.c
test_option_uuencode.c
@@ -82,11 +85,12 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test_utils)
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdcpio_test
- COMMAND bsdcpio_test -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR})
+ COMMAND bsdcpio_test -p $<TARGET_FILE:bsdcpio>
+ -r ${CMAKE_CURRENT_SOURCE_DIR})
ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
ENDIF(ENABLE_CPIO AND ENABLE_TEST)
diff --git a/cpio/test/main.c b/cpio/test/main.c
index d4c6e5c3388c..fa22adfbc81a 100644
--- a/cpio/test/main.c
+++ b/cpio/test/main.c
@@ -130,6 +130,16 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.3 2008/08/24 04:58:22 kient
# include <crtdbg.h>
#endif
+/* Path to working directory for current test */
+const char *testworkdir;
+#ifdef PROGRAM
+/* Pathname of exe to be tested. */
+const char *testprogfile;
+/* Name of exe to use in printf-formatted command strings. */
+/* On Windows, this includes leading/trailing quotes. */
+const char *testprog;
+#endif
+
#if defined(_WIN32) && !defined(__CYGWIN__)
static void *GetFunctionKernel32(const char *);
static int my_CreateSymbolicLinkA(const char *, const char *, int);
@@ -194,7 +204,7 @@ my_GetFileInformationByName(const char *path, BY_HANDLE_FILE_INFORMATION *bhfi)
}
#endif
-#if defined(HAVE__CrtSetReportMode)
+#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__)
static void
invalid_parameter_handler(const wchar_t * expression,
const wchar_t * function, const wchar_t * file,
@@ -565,10 +575,10 @@ static void strdump(const char *e, const char *p, int ewidth, int utf8)
while (*p != '\0') {
unsigned int c = 0xff & *p++;
switch (c) {
- case '\a': printf("\a"); break;
- case '\b': printf("\b"); break;
- case '\n': printf("\n"); break;
- case '\r': printf("\r"); break;
+ case '\a': logprintf("\\a"); break;
+ case '\b': logprintf("\\b"); break;
+ case '\n': logprintf("\\n"); break;
+ case '\r': logprintf("\\r"); break;
default:
if (c >= 32 && c < 127)
logprintf("%c", c);
@@ -771,6 +781,34 @@ assertion_equal_mem(const char *file, int line,
return (0);
}
+/* Verify that a block of memory is filled with the specified byte. */
+int
+assertion_memory_filled_with(const char *file, int line,
+ const void *_v1, const char *vd,
+ size_t l, const char *ld,
+ char b, const char *bd, void *extra)
+{
+ const char *v1 = (const char *)_v1;
+ size_t c = 0;
+ size_t i;
+ (void)ld; /* UNUSED */
+
+ assertion_count(file, line);
+
+ for (i = 0; i < l; ++i) {
+ if (v1[i] == b) {
+ ++c;
+ }
+ }
+ if (c == l)
+ return (1);
+
+ failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
+ logprintf(" Only %d bytes were correct\n", (int)c);
+ failure_finish(extra);
+ return (0);
+}
+
/* Verify that the named file exists and is empty. */
int
assertion_empty_file(const char *filename, int line, const char *f1)
@@ -1036,6 +1074,7 @@ assertion_file_contains_lines_any_order(const char *file, int line,
if (expected == NULL) {
failure_start(pathname, line, "Can't allocate memory");
failure_finish(NULL);
+ free(expected);
return (0);
}
for (i = 0; lines[i] != NULL; ++i) {
@@ -1060,7 +1099,8 @@ assertion_file_contains_lines_any_order(const char *file, int line,
free(expected);
return (0);
}
- for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
+ for (j = 0, p = buff; p < buff + buff_size;
+ p += 1 + strlen(p)) {
if (*p != '\0') {
actual[j] = p;
++j;
@@ -1912,6 +1952,18 @@ canGzip(void)
* Can this platform run the lrzip program?
*/
int
+canRunCommand(const char *cmd)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("%s %s", cmd, redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+int
canLrzip(void)
{
static int tested = 0, value = 0;
@@ -1924,6 +1976,21 @@ canLrzip(void)
}
/*
+ * Can this platform run the lz4 program?
+ */
+int
+canLz4(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lz4 -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
* Can this platform run the lzip program?
*/
int
@@ -2135,8 +2202,31 @@ slurpfile(size_t * sizep, const char *fmt, ...)
return (p);
}
+/*
+ * Slurp a file into memory for ease of comparison and testing.
+ * Returns size of file in 'sizep' if non-NULL, null-terminates
+ * data in memory for ease of use.
+ */
+void
+dumpfile(const char *filename, void *data, size_t len)
+{
+ ssize_t bytes_written;
+ FILE *f;
+
+ f = fopen(filename, "wb");
+ if (f == NULL) {
+ logprintf("Can't open file %s for writing\n", filename);
+ return;
+ }
+ bytes_written = fwrite(data, 1, len, f);
+ if (bytes_written < (ssize_t)len)
+ logprintf("Can't write file %s\n", filename);
+ fclose(f);
+}
+
/* Read a uuencoded file from the reference directory, decode, and
* write the result into the current directory. */
+#define VALID_UUDECODE(c) (c >= 32 && c <= 96)
#define UUDECODE(c) (((c) - 0x20) & 0x3f)
void
extract_reference_file(const char *name)
@@ -2160,7 +2250,6 @@ extract_reference_file(const char *name)
break;
}
/* Now, decode the rest and write it. */
- /* Not a lot of error checking here; the input better be right. */
out = fopen(name, "wb");
while (fgets(buff, sizeof(buff), in) != NULL) {
char *p = buff;
@@ -2174,17 +2263,21 @@ extract_reference_file(const char *name)
int n = 0;
/* Write out 1-3 bytes from that. */
if (bytes > 0) {
+ assert(VALID_UUDECODE(p[0]));
+ assert(VALID_UUDECODE(p[1]));
n = UUDECODE(*p++) << 18;
n |= UUDECODE(*p++) << 12;
fputc(n >> 16, out);
--bytes;
}
if (bytes > 0) {
+ assert(VALID_UUDECODE(p[0]));
n |= UUDECODE(*p++) << 6;
fputc((n >> 8) & 0xFF, out);
--bytes;
}
if (bytes > 0) {
+ assert(VALID_UUDECODE(p[0]));
n |= UUDECODE(*p++);
fputc(n & 0xFF, out);
--bytes;
@@ -2195,6 +2288,32 @@ extract_reference_file(const char *name)
fclose(in);
}
+void
+copy_reference_file(const char *name)
+{
+ char buff[1024];
+ FILE *in, *out;
+ size_t rbytes;
+
+ sprintf(buff, "%s/%s", refdir, name);
+ in = fopen(buff, "rb");
+ failure("Couldn't open reference file %s", buff);
+ assert(in != NULL);
+ if (in == NULL)
+ return;
+ /* Now, decode the rest and write it. */
+ /* Not a lot of error checking here; the input better be right. */
+ out = fopen(name, "wb");
+ while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
+ if (fwrite(buff, 1, rbytes, out) != rbytes) {
+ logprintf("Error: fwrite\n");
+ break;
+ }
+ }
+ fclose(out);
+ fclose(in);
+}
+
int
is_LargeInode(const char *file)
{
@@ -2216,6 +2335,14 @@ is_LargeInode(const char *file)
return (ino > 0xffffffff);
#endif
}
+
+void
+extract_reference_files(const char **names)
+{
+ while (names && *names)
+ extract_reference_file(*names++);
+}
+
/*
*
* TEST management
@@ -2245,7 +2372,7 @@ struct test_list_t tests[] = {
* Summarize repeated failures in the just-completed test.
*/
static void
-test_summarize(int failed)
+test_summarize(int failed, int skips_num)
{
unsigned int i;
@@ -2255,7 +2382,7 @@ test_summarize(int failed)
fflush(stdout);
break;
case VERBOSITY_PASSFAIL:
- printf(failed ? "FAIL\n" : "ok\n");
+ printf(failed ? "FAIL\n" : skips_num ? "ok (S)\n" : "ok\n");
break;
}
@@ -2280,13 +2407,14 @@ test_run(int i, const char *tmpdir)
char workdir[1024];
char logfilename[64];
int failures_before = failures;
+ int skips_before = skips;
int oldumask;
switch (verbosity) {
case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */
break;
case VERBOSITY_PASSFAIL: /* rest of line will include ok/FAIL marker */
- printf("%3d: %-50s", i, tests[i].name);
+ printf("%3d: %-64s", i, tests[i].name);
fflush(stdout);
break;
default: /* Title of test, details will follow */
@@ -2336,7 +2464,7 @@ test_run(int i, const char *tmpdir)
}
/* Report per-test summaries. */
tests[i].failures = failures - failures_before;
- test_summarize(tests[i].failures);
+ test_summarize(tests[i].failures, skips - skips_before);
/* Close the per-test log file. */
fclose(logfile);
logfile = NULL;
@@ -2479,6 +2607,7 @@ get_refdir(const char *d)
failure:
printf("Unable to locate known reference file %s\n", KNOWNREF);
printf(" Checked following directories:\n%s\n", tried);
+ printf("Use -r option to specify full path to reference directory\n");
#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
DebugBreak();
#endif
@@ -2515,7 +2644,7 @@ main(int argc, char **argv)
while (pwd[strlen(pwd) - 1] == '\n')
pwd[strlen(pwd) - 1] = '\0';
-#if defined(HAVE__CrtSetReportMode)
+#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__)
/* To stop to run the default invalid parameter handler. */
_set_invalid_parameter_handler(invalid_parameter_handler);
/* Disable annoying assertion message box. */
@@ -2562,7 +2691,7 @@ main(int argc, char **argv)
exit(1);
}
memmove(testprogdir + strlen(pwd) + 1, testprogdir,
- strlen(testprogdir));
+ strlen(testprogdir) + 1);
memcpy(testprogdir, pwd, strlen(pwd));
testprogdir[strlen(pwd)] = '/';
}
diff --git a/cpio/test/test.h b/cpio/test/test.h
index 666bba0e8b30..606b121bba6e 100644
--- a/cpio/test/test.h
+++ b/cpio/test/test.h
@@ -66,6 +66,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -84,12 +85,14 @@
/* Windows (including Visual Studio and MinGW but not Cygwin) */
#if defined(_WIN32) && !defined(__CYGWIN__)
#if !defined(__BORLANDC__)
+#undef chdir
+#define chdir _chdir
#define strdup _strdup
#endif
#endif
/* Visual Studio */
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf sprintf_s
#endif
@@ -142,6 +145,9 @@
/* As above, but raw blocks of bytes. */
#define assertEqualMem(v1, v2, l) \
assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
+/* Assert that memory is full of a specified byte */
+#define assertMemoryFilledWith(v1, l, b) \
+ assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL)
/* Assert two files are the same. */
#define assertEqualFile(f1, f2) \
assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
@@ -225,6 +231,7 @@ int assertion_empty_file(const char *, int, const char *);
int assertion_equal_file(const char *, int, const char *, const char *);
int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
+int assertion_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *);
int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
int assertion_file_atime(const char *, int, const char *, long, long);
@@ -275,9 +282,15 @@ int canGrzip(void);
/* Return true if this platform can run the "gzip" program. */
int canGzip(void);
+/* Return true if this platform can run the specified command. */
+int canRunCommand(const char *);
+
/* Return true if this platform can run the "lrzip" program. */
int canLrzip(void);
+/* Return true if this platform can run the "lz4" program. */
+int canLz4(void);
+
/* Return true if this platform can run the "lzip" program. */
int canLzip(void);
@@ -300,21 +313,31 @@ int is_LargeInode(const char *);
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
char *slurpfile(size_t *, const char *fmt, ...);
+/* Dump block of bytes to a file. */
+void dumpfile(const char *filename, void *, size_t);
+
/* Extracts named reference file to the current directory. */
void extract_reference_file(const char *);
+/* Copies named reference file to the current directory. */
+void copy_reference_file(const char *);
+
+/* Extracts a list of files to the current directory.
+ * List must be NULL terminated.
+ */
+void extract_reference_files(const char **);
/* Path to working directory for current test */
-const char *testworkdir;
+extern const char *testworkdir;
/*
* Special interfaces for program test harness.
*/
/* Pathname of exe to be tested. */
-const char *testprogfile;
+extern const char *testprogfile;
/* Name of exe to use in printf-formatted command strings. */
/* On Windows, this includes leading/trailing quotes. */
-const char *testprog;
+extern const char *testprog;
#ifdef USE_DMALLOC
#include <dmalloc.h>
diff --git a/cpio/test/test_basic.c b/cpio/test/test_basic.c
index 7213062e8d20..f3a048002a55 100644
--- a/cpio/test/test_basic.c
+++ b/cpio/test/test_basic.c
@@ -72,7 +72,7 @@ basic_cpio(const char *target,
return;
/* Use the cpio program to create an archive. */
- r = systemf("%s -o %s < filelist >%s/archive 2>%s/pack.err",
+ r = systemf("%s -R 1000:1000 -o %s < filelist >%s/archive 2>%s/pack.err",
testprog, pack_options, target, target);
failure("Error invoking %s -o %s", testprog, pack_options);
assertEqualInt(r, 0);
diff --git a/cpio/test/test_extract.cpio.lz4.uu b/cpio/test/test_extract.cpio.lz4.uu
new file mode 100644
index 000000000000..0adc7bbcc484
--- /dev/null
+++ b/cpio/test/test_extract.cpio.lz4.uu
@@ -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
diff --git a/cpio/test/test_extract_cpio_lz4.c b/cpio/test/test_extract_cpio_lz4.c
new file mode 100644
index 000000000000..c16247be2bef
--- /dev/null
+++ b/cpio/test/test_extract_cpio_lz4.c
@@ -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");
+ }
+}
diff --git a/cpio/test/test_extract_cpio_lzo.c b/cpio/test/test_extract_cpio_lzo.c
index f351ba7a79aa..99476af95318 100644
--- a/cpio/test/test_extract_cpio_lzo.c
+++ b/cpio/test/test_extract_cpio_lzo.c
@@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_extract_cpio_lzo)
{
- const char *reffile = "test_extract.cpio.lrz";
+ const char *reffile = "test_extract.cpio.lzo";
int f;
extract_reference_file(reffile);
diff --git a/cpio/test/test_option_c.c b/cpio/test/test_option_c.c
index a634be10ba7c..fa47b7e277d8 100644
--- a/cpio/test/test_option_c.c
+++ b/cpio/test/test_option_c.c
@@ -65,18 +65,14 @@ DEFINE_TEST(test_option_c)
{
FILE *filelist;
int r;
- int uid = -1;
- int dev, ino, gid;
+ int uid = 1000;
+ int dev, ino, gid = 1000;
time_t t, now;
char *p, *e;
size_t s;
assertUmask(0);
-#if !defined(_WIN32)
- uid = getuid();
-#endif
-
/*
* Create an assortment of files.
* TODO: Extend this to cover more filetypes.
@@ -101,7 +97,7 @@ DEFINE_TEST(test_option_c)
/* Use the cpio program to create an archive. */
fclose(filelist);
- r = systemf("%s -oc <filelist >basic.out 2>basic.err", testprog);
+ r = systemf("%s -R 1000:1000 -oc <filelist >basic.out 2>basic.err", testprog);
/* Verify that nothing went to stderr. */
assertTextFileContents("1 block\n", "basic.err");
diff --git a/cpio/test/test_option_lz4.c b/cpio/test/test_option_lz4.c
new file mode 100644
index 000000000000..d430ac755f4f
--- /dev/null
+++ b/cpio/test/test_option_lz4.c
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2014 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_lz4)
+{
+ char *p;
+ int r;
+ size_t s;
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with lz4 compression. */
+ r = systemf("echo f | %s -o --lz4 >archive.out 2>archive.err",
+ testprog);
+ p = slurpfile(&s, "archive.err");
+ p[s] = '\0';
+ if (r != 0) {
+ if (strstr(p, "compression not available") != NULL) {
+ skipping("This version of bsdcpio was compiled "
+ "without lz4 support");
+ return;
+ }
+ /* POSIX permits different handling of the spawnp
+ * system call used to launch the subsidiary
+ * program: */
+ /* Some systems fail immediately to spawn the new process. */
+ if (strstr(p, "Can't launch") != NULL && !canLz4()) {
+ skipping("This version of bsdcpio uses an external lz4 program "
+ "but no such program is available on this system.");
+ return;
+ }
+ /* Some systems successfully spawn the new process,
+ * but fail to exec a program within that process.
+ * This results in failure at the first attempt to
+ * write. */
+ if (strstr(p, "Can't write") != NULL && !canLz4()) {
+ skipping("This version of bsdcpio uses an external lz4 program "
+ "but no such program is available on this system.");
+ return;
+ }
+ failure("--lz4 option is broken: %s", p);
+ assertEqualInt(r, 0);
+ return;
+ }
+ /* Check that the archive file has an lz4 signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "\x04\x22\x4d\x18", 4);
+}
diff --git a/cpio/test/test_option_passphrase.c b/cpio/test/test_option_passphrase.c
new file mode 100644
index 000000000000..ae77a23fcb74
--- /dev/null
+++ b/cpio/test/test_option_passphrase.c
@@ -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");
+}
diff --git a/cpio/test/test_option_passphrase.zip.uu b/cpio/test/test_option_passphrase.zip.uu
new file mode 100644
index 000000000000..021ae8585fe8
--- /dev/null
+++ b/cpio/test/test_option_passphrase.zip.uu
@@ -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
diff --git a/cpio/test/test_option_version.c b/cpio/test/test_option_version.c
index 7345da1e5157..2f2c40901700 100644
--- a/cpio/test/test_option_version.c
+++ b/cpio/test/test_option_version.c
@@ -74,6 +74,11 @@ verify(const char *p, size_t s)
/* Skip a single trailing a,b,c, or d. */
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
++q;
+ /* Skip arbitrary third-party version numbers. */
+ while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
+ ++q;
+ --s;
+ }
/* All terminated by end-of-line: \r, \r\n, or \n */
assert(s >= 1);
failure("Version: %s", p);
diff --git a/doc/mdoc2wiki.awk b/doc/mdoc2wiki.awk
index 5fee29c32952..eb89ba09028b 100755
--- a/doc/mdoc2wiki.awk
+++ b/doc/mdoc2wiki.awk
@@ -93,14 +93,44 @@ function breakline() {
linecmd("<br>")
}
+function crossref(name, sect, other) {
+ if (name == "cpio" && sect == 1) {
+ n = "ManPageBsdcpio1"
+ } else if (name == "cpio" && sect == 5) {
+ n = "ManPageCpio5"
+ } else if (name == "mtree" && sect == 5) {
+ n = "ManPageMtree5"
+ } else if (name == "tar" && sect == 1) {
+ n = "ManPageBsdtar1"
+ } else if (name == "tar" && sect == 5) {
+ n = "ManPageTar5"
+ } else if (!match(name, "^archive") && !match(name, "^libarchive")) {
+ n = name "(" sect ")|http://www.freebsd.org/cgi/man.cgi?query=" name "&sektion=" sect
+ } else {
+ n = "ManPage"
+ numbits = split(name, namebits, "[_-]")
+ for (i = 1; i <= numbits; ++i) {
+ p = namebits[i]
+ n = n toupper(substr(p, 0, 1)) substr(p, 2)
+ }
+ n = n sect
+ }
+ n = "[[" n "]]"
+ if (length other > 0)
+ n = n other
+ return n
+}
+
# Start an indented display
function dispstart() {
- linecmd("```text")
+ endline()
+ print "```text"
}
# End an indented display
function dispend() {
- linecmd("```")
+ endline()
+ print "```"
}
# Collect rest of input line
@@ -123,22 +153,22 @@ function splitwords(l, dest, n, o, w) {
l = substr(l, 2)
o = index(l, "\"")
if (o > 0) {
- w = substr(l, 1, o-1)
- l = substr(l, o+1)
- dest[n++] = w
+ w = substr(l, 1, o-1)
+ l = substr(l, o+1)
+ dest[n++] = w
} else {
- dest[n++] = l
- l = ""
+ dest[n++] = l
+ l = ""
}
} else {
o = match(l, "[ \t]")
if (o > 0) {
- w = substr(l, 1, o-1)
- l = substr(l, o+1)
- dest[n++] = w
+ w = substr(l, 1, o-1)
+ l = substr(l, o+1)
+ dest[n++] = w
} else {
- dest[n++] = l
- l = ""
+ dest[n++] = l
+ l = ""
}
}
}
@@ -154,6 +184,7 @@ function splitwords(l, dest, n, o, w) {
/^\.\\"/ { next }
{
+ gsub("\\\\e", "\\")
sub("^\\.","")
nwords=splitwords($0, words)
# TODO: Instead of iterating 'w' over the array, have a separate
@@ -170,8 +201,8 @@ function splitwords(l, dest, n, o, w) {
STATE = PRETAG_STATE
if(match(words[w+1],"-literal")) {
dispstart()
- displaylines=10000
- w=nwords
+ displaylines=10000
+ w=nwords
}
} else if(match(words[w],"^Ed$")) { # End display
displaylines = 0
@@ -185,7 +216,7 @@ function splitwords(l, dest, n, o, w) {
addopen("\"")
add(words[++w])
while(w<nwords&&!match(words[w+1],"^[\\.,]"))
- add(words[++w])
+ add(words[++w])
addclose("\"")
} else if(match(words[w],"^Do$")) {
addopen("\"")
@@ -241,16 +272,17 @@ function splitwords(l, dest, n, o, w) {
section=wtail()
linecmd("== " section " ==")
} else if(match(words[w],"^Xr$")) {
- add("'''" words[++w] "'''(" words[++w] ")" words[++w])
+ add(crossref(words[w+1], words[w+2], words[w+3]))
+ w = w + 3
} else if(match(words[w],"^Nm$")) {
if(match(section,"SYNOPSIS"))
breakline()
if(w >= nwords)
- n=name
+ n=name
else if (match(words[w+1], "^[A-Z][a-z]$"))
- n=name
+ n=name
else if (match(words[w+1], "^[.,;:]$"))
- n=name
+ n=name
else {
n=words[++w]
if(!length(name))
@@ -259,27 +291,30 @@ function splitwords(l, dest, n, o, w) {
if(!length(n))
n=name
if (displaylines == 0)
- add("'''" n "'''")
+ add("'''" n "'''")
else
- add(n)
+ add(n)
} else if(match(words[w],"^Nd$")) {
add("- " wtail())
} else if(match(words[w],"^Fl$")) {
addopen("-")
} else if(match(words[w],"^Ar$")) {
if(w==nwords)
- add("''file ...''")
+ add("''file ...''")
else {
- ++w
- gsub("<", "&lt;", words[w])
- add("''" words[w] "''")
+ ++w
+ gsub("<", "\\&lt;", words[w])
+ if (displaylines > 0)
+ add(words[w])
+ else
+ add("''" words[w] "''")
}
} else if(match(words[w],"^Cm$")) {
++w
if (displaylines == 0) {
- add("'''" words[w] "'''")
+ add("'''" words[w] "'''")
} else
- add(words[w])
+ add(words[w])
} else if(match(words[w],"^Op$")) {
addopen("<nowiki>[</nowiki>")
option=1
@@ -290,36 +325,36 @@ function splitwords(l, dest, n, o, w) {
print ""
} else if(match(words[w],"^An$")) {
if (match(words[w+1],"-nosplit"))
- ++w
+ ++w
endline()
} else if(match(words[w],"^Ss$")) {
add("===")
trailer="==="
} else if(match(words[w],"^Ft$")) {
if (match(section, "SYNOPSIS")) {
- breakline()
+ breakline()
}
l = wtail()
- add("'''" l "'''")
+ add("''" l "''")
if (match(section, "SYNOPSIS")) {
- breakline()
+ breakline()
}
} else if(match(words[w],"^Fn$")) {
++w
F = "'''" words[w] "'''("
Fsep = ""
while(w<nwords) {
- ++w
- if (match(words[w], "^[.,:]$")) {
- --w
- break
- }
- F = F Fsep "''" words[w] "''"
- Fsep = ", "
+ ++w
+ if (match(words[w], "^[.,:]$")) {
+ --w
+ break
+ }
+ F = F Fsep "''" words[w] "''"
+ Fsep = ", "
}
add(F ")")
if (match(section, "SYNOPSIS")) {
- addclose(";")
+ addclose(";")
}
} else if(match(words[w],"^Fo$")) {
w++
@@ -332,7 +367,7 @@ function splitwords(l, dest, n, o, w) {
} else if(match(words[w],"^Fc$")) {
add(F ")")
if (match(section, "SYNOPSIS")) {
- addclose(";")
+ addclose(";")
}
} else if(match(words[w],"^Va$")) {
w++
@@ -343,11 +378,11 @@ function splitwords(l, dest, n, o, w) {
} else if(match(words[w],"^Pa$")) {
w++
# if(match(words[w],"^\\."))
-# add("\\&")
+# add("\\&")
if (displaylines == 0)
- add("''" words[w] "''")
+ add("''" words[w] "''")
else
- add(words[w])
+ add(words[w])
} else if(match(words[w],"^Dv$")) {
linecmd()
} else if(match(words[w],"^Em|Ev$")) {
@@ -373,22 +408,22 @@ function splitwords(l, dest, n, o, w) {
++listdepth
listnext[listdepth]=""
if(match(words[w+1],"-bullet")) {
- optlist[listdepth]=1
- addopen("<ul>")
- listclose[listdepth]="</ul>"
+ optlist[listdepth]=1
+ addopen("<ul>")
+ listclose[listdepth]="</ul>"
} else if(match(words[w+1],"-enum")) {
- optlist[listdepth]=2
- enum=0
- addopen("<ol>")
- listclose[listdepth]="</ol>"
+ optlist[listdepth]=2
+ enum=0
+ addopen("<ol>")
+ listclose[listdepth]="</ol>"
} else if(match(words[w+1],"-tag")) {
- optlist[listdepth]=3
- addopen("<dl>")
- listclose[listdepth]="</dl>"
+ optlist[listdepth]=3
+ addopen("<dl>")
+ listclose[listdepth]="</dl>"
} else if(match(words[w+1],"-item")) {
- optlist[listdepth]=4
- addopen("<ul>")
- listclose[listdepth]="</ul>"
+ optlist[listdepth]=4
+ addopen("<ul>")
+ listclose[listdepth]="</ul>"
}
w=nwords
} else if(match(words[w],"^El$")) {
@@ -399,28 +434,30 @@ function splitwords(l, dest, n, o, w) {
} else if(match(words[w],"^It$")) {
addclose(listnext[listdepth])
if(optlist[listdepth]==1) {
- addpunct("<li>")
- listnext[listdepth] = "</li>"
+ addpunct("<li>")
+ listnext[listdepth] = "</li>"
} else if(optlist[listdepth]==2) {
- addpunct("<li>")
- listnext[listdepth] = "</li>"
+ addpunct("<li>")
+ listnext[listdepth] = "</li>"
} else if(optlist[listdepth]==3) {
- addpunct("<dt>")
- listnext[listdepth] = "</dt>"
- if(match(words[w+1],"^Xo$")) {
- # Suppress trailer
- w++
- } else if(match(words[w+1],"^Pa$|^Ev$")) {
- addopen("'''")
- w++
- add(words[++w] "'''")
- } else {
- trailer = listnext[listdepth] "<dd>" trailer
- listnext[listdepth] = "</dd>"
- }
+ addpunct("<dt>")
+ listnext[listdepth] = "</dt>"
+ if(match(words[w+1],"^Xo$")) {
+ # Suppress trailer
+ w++
+ } else if(match(words[w+1],"^Pa$|^Ev$")) {
+ addopen("'''")
+ w++
+ add(words[++w] "'''")
+ trailer = listnext[listdepth] "<dd>" trailer
+ listnext[listdepth] = "</dd>"
+ } else {
+ trailer = listnext[listdepth] "<dd>" trailer
+ listnext[listdepth] = "</dd>"
+ }
} else if(optlist[listdepth]==4) {
- addpunct("<li>")
- listnext[listdepth] = "</li>"
+ addpunct("<li>")
+ listnext[listdepth] = "</li>"
}
} else if(match(words[w], "^Vt$")) {
w++
@@ -430,9 +467,9 @@ function splitwords(l, dest, n, o, w) {
} else if(match(words[w],"^Xc$")) {
# TODO: Figure out how to handle this
if (optlist[listdepth] == 3) {
- addclose(listnext[listdepth])
- addopen("<dd>")
- listnext[listdepth] = "</dd>"
+ addclose(listnext[listdepth])
+ addopen("<dd>")
+ listnext[listdepth] = "</dd>"
}
} else if(match(words[w],"^[=]$")) {
addpunct(words[w])
diff --git a/examples/minitar/Makefile b/examples/minitar/Makefile
index 1ec4593df66b..e2cc0899fbba 100644
--- a/examples/minitar/Makefile
+++ b/examples/minitar/Makefile
@@ -8,13 +8,19 @@ CFLAGS= \
-I../../libarchive \
-g
+#
+# You may need to add additional libraries or link options here
+# For example, many Linux systems require -lacl
+#
+LIBS= -lz -lbz2
+
# How to link against libarchive.
LIBARCHIVE= ../../libarchive/libarchive.a
all: minitar
minitar: minitar.o
- cc -g -o minitar minitar.o $(LIBARCHIVE) -lz -lbz2
+ cc -g -o minitar minitar.o $(LIBARCHIVE) $(LIBS)
strip minitar
ls -l minitar
diff --git a/examples/minitar/minitar.c b/examples/minitar/minitar.c
index 0ff6263ebf84..81e5e11c7985 100644
--- a/examples/minitar/minitar.c
+++ b/examples/minitar/minitar.c
@@ -249,7 +249,7 @@ create(const char *filename, int compress, const char **argv)
break;
}
archive_write_set_format_ustar(a);
- if (strcmp(filename, "-") == 0)
+ if (filename != NULL && strcmp(filename, "-") == 0)
filename = NULL;
archive_write_open_filename(a, filename);
@@ -367,6 +367,7 @@ extract(const char *filename, int do_extract, int flags)
exit(r);
}
for (;;) {
+ int needcr = 0;
r = archive_read_next_header(a, &entry);
if (r == ARCHIVE_EOF)
break;
@@ -377,16 +378,24 @@ extract(const char *filename, int do_extract, int flags)
}
if (verbose && do_extract)
msg("x ");
- if (verbose || !do_extract)
+ if (verbose || !do_extract) {
msg(archive_entry_pathname(entry));
+ msg(" ");
+ needcr = 1;
+ }
if (do_extract) {
r = archive_write_header(ext, entry);
- if (r != ARCHIVE_OK)
+ if (r != ARCHIVE_OK) {
errmsg(archive_error_string(a));
- else
- copy_data(a, ext);
+ needcr = 1;
+ }
+ else {
+ r = copy_data(a, ext);
+ if (r != ARCHIVE_OK)
+ needcr = 1;
+ }
}
- if (verbose || !do_extract)
+ if (needcr)
msg("\n");
}
archive_read_close(a);
@@ -400,16 +409,16 @@ copy_data(struct archive *ar, struct archive *aw)
int r;
const void *buff;
size_t size;
- off_t offset;
+ int64_t offset;
for (;;) {
r = archive_read_data_block(ar, &buff, &size, &offset);
- if (r == ARCHIVE_EOF) {
- errmsg(archive_error_string(ar));
+ if (r == ARCHIVE_EOF)
return (ARCHIVE_OK);
- }
- if (r != ARCHIVE_OK)
+ if (r != ARCHIVE_OK) {
+ errmsg(archive_error_string(ar));
return (r);
+ }
r = archive_write_data_block(aw, buff, size, offset);
if (r != ARCHIVE_OK) {
errmsg(archive_error_string(ar));
@@ -427,6 +436,9 @@ msg(const char *m)
static void
errmsg(const char *m)
{
+ if (m == NULL) {
+ m = "Error: No error description provided.\n";
+ }
write(2, m, strlen(m));
}
diff --git a/examples/untar.c b/examples/untar.c
index b22d8361a012..dab75d2ede53 100644
--- a/examples/untar.c
+++ b/examples/untar.c
@@ -53,7 +53,6 @@
*/
#include <sys/types.h>
-__FBSDID("$FreeBSD$");
#include <sys/stat.h>
@@ -191,6 +190,9 @@ extract(const char *filename, int do_extract, int flags)
}
archive_read_close(a);
archive_read_free(a);
+
+ archive_write_close(ext);
+ archive_write_free(ext);
exit(0);
}
@@ -200,7 +202,7 @@ copy_data(struct archive *ar, struct archive *aw)
int r;
const void *buff;
size_t size;
-#if ARCHIVE_VERSION >= 3000000
+#if ARCHIVE_VERSION_NUMBER >= 3000000
int64_t offset;
#else
off_t offset;
diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt
index ecb0409bd9d8..4cc9a2ca2c17 100644
--- a/libarchive/CMakeLists.txt
+++ b/libarchive/CMakeLists.txt
@@ -18,8 +18,10 @@ SET(libarchive_SOURCES
archive_cmdline.c
archive_cmdline_private.h
archive_crc32.h
- archive_crypto.c
- archive_crypto_private.h
+ archive_cryptor.c
+ archive_cryptor_private.h
+ archive_digest.c
+ archive_digest_private.h
archive_endian.h
archive_entry.c
archive_entry.h
@@ -32,9 +34,14 @@ SET(libarchive_SOURCES
archive_entry_strmode.c
archive_entry_xattr.c
archive_getdate.c
+ archive_getdate.h
+ archive_hmac.c
+ archive_hmac_private.h
archive_match.c
archive_options.c
archive_options_private.h
+ archive_pack_dev.h
+ archive_pack_dev.c
archive_pathmatch.c
archive_pathmatch.h
archive_platform.h
@@ -42,9 +49,12 @@ SET(libarchive_SOURCES
archive_ppmd7.c
archive_ppmd7_private.h
archive_private.h
+ archive_random.c
+ archive_random_private.h
archive_rb.c
archive_rb.h
archive_read.c
+ archive_read_add_passphrase.c
archive_read_append_filter.c
archive_read_data_into_fd.c
archive_read_disk_entry_from_file.c
@@ -52,6 +62,7 @@ SET(libarchive_SOURCES
archive_read_disk_private.h
archive_read_disk_set_standard_lookup.c
archive_read_extract.c
+ archive_read_extract2.c
archive_read_open_fd.c
archive_read_open_file.c
archive_read_open_filename.c
@@ -65,6 +76,7 @@ SET(libarchive_SOURCES
archive_read_support_filter_gzip.c
archive_read_support_filter_grzip.c
archive_read_support_filter_lrzip.c
+ archive_read_support_filter_lz4.c
archive_read_support_filter_lzop.c
archive_read_support_filter_none.c
archive_read_support_filter_program.c
@@ -84,6 +96,7 @@ SET(libarchive_SOURCES
archive_read_support_format_rar.c
archive_read_support_format_raw.c
archive_read_support_format_tar.c
+ archive_read_support_format_warc.c
archive_read_support_format_xar.c
archive_read_support_format_zip.c
archive_string.c
@@ -110,6 +123,7 @@ SET(libarchive_SOURCES
archive_write_add_filter_grzip.c
archive_write_add_filter_gzip.c
archive_write_add_filter_lrzip.c
+ archive_write_add_filter_lz4.c
archive_write_add_filter_lzop.c
archive_write_add_filter_none.c
archive_write_add_filter_program.c
@@ -121,18 +135,24 @@ SET(libarchive_SOURCES
archive_write_set_format_by_name.c
archive_write_set_format_cpio.c
archive_write_set_format_cpio_newc.c
+ archive_write_set_format_filter_by_ext.c
archive_write_set_format_gnutar.c
archive_write_set_format_iso9660.c
archive_write_set_format_mtree.c
archive_write_set_format_pax.c
+ archive_write_set_format_raw.c
archive_write_set_format_shar.c
archive_write_set_format_ustar.c
archive_write_set_format_v7tar.c
+ archive_write_set_format_warc.c
archive_write_set_format_xar.c
archive_write_set_format_zip.c
archive_write_set_options.c
+ archive_write_set_passphrase.c
+ archive_xxhash.h
filter_fork_posix.c
filter_fork.h
+ xxhash.c
)
# Man pages
@@ -145,12 +165,14 @@ SET(libarchive_MANS
archive_entry_stat.3
archive_entry_time.3
archive_read.3
+ archive_read_add_passphrase.3
archive_read_disk.3
archive_read_set_options.3
archive_util.3
archive_write.3
archive_write_disk.3
archive_write_set_options.3
+ archive_write_set_passphrase.3
cpio.5
libarchive.3
libarchive_internals.3
@@ -175,6 +197,7 @@ SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION})
# archive_static is a static library
ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS})
+TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS})
SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS
LIBARCHIVE_STATIC)
# On Posix systems, libarchive.so and libarchive.a can co-exist.
@@ -182,12 +205,14 @@ IF(NOT WIN32 OR CYGWIN)
SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive)
ENDIF(NOT WIN32 OR CYGWIN)
-# How to install the libraries
-INSTALL(TARGETS archive archive_static
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib)
-INSTALL_MAN(${libarchive_MANS})
-INSTALL(FILES ${include_HEADERS} DESTINATION include)
+IF(ENABLE_INSTALL)
+ # How to install the libraries
+ INSTALL(TARGETS archive archive_static
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+ INSTALL_MAN(${libarchive_MANS})
+ INSTALL(FILES ${include_HEADERS} DESTINATION include)
+ENDIF()
add_subdirectory(test)
diff --git a/libarchive/archive.h b/libarchive/archive.h
index f56bc38e5b43..59e9ef15eb60 100644
--- a/libarchive/archive.h
+++ b/libarchive/archive.h
@@ -28,9 +28,20 @@
#ifndef ARCHIVE_H_INCLUDED
#define ARCHIVE_H_INCLUDED
+/*
+ * The version number is expressed as a single integer that makes it
+ * easy to compare versions at build time: for version a.b.c, the
+ * version number is printf("%d%03d%03d",a,b,c). For example, if you
+ * know your application requires version 2.12.108 or later, you can
+ * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
+ */
+/* Note: Compiler will complain if this does not match archive_entry.h! */
+#define ARCHIVE_VERSION_NUMBER 3002000
+
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
#include <stdio.h> /* For FILE * */
+#include <time.h> /* For time_t */
/*
* Note: archive.h is for use outside of libarchive; the configuration
@@ -41,29 +52,53 @@
*/
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
# include <stdint.h>
-#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS)
+#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
# include <inttypes.h>
#endif
-/* Get appropriate definitions of standard POSIX-style types. */
-/* These should match the types used in 'struct stat' */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-# define __LA_INT64_T __int64
-# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
-# define __LA_SSIZE_T ssize_t
-# elif defined(_WIN64)
-# define __LA_SSIZE_T __int64
-# else
-# define __LA_SSIZE_T long
+/* Get appropriate definitions of 64-bit integer */
+#if !defined(__LA_INT64_T_DEFINED)
+/* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
+# if ARCHIVE_VERSION_NUMBER < 4000000
+#define __LA_INT64_T la_int64_t
# endif
-#else
+#define __LA_INT64_T_DEFINED
+# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
+typedef __int64 la_int64_t;
+# else
# include <unistd.h> /* ssize_t */
-# if defined(_SCO_DS)
-# define __LA_INT64_T long long
+# if defined(_SCO_DS) || defined(__osf__)
+typedef long long la_int64_t;
+# else
+typedef int64_t la_int64_t;
+# endif
+# endif
+#endif
+
+/* The la_ssize_t should match the type used in 'struct stat' */
+#if !defined(__LA_SSIZE_T_DEFINED)
+/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
+# if ARCHIVE_VERSION_NUMBER < 4000000
+#define __LA_SSIZE_T la_ssize_t
+# endif
+#define __LA_SSIZE_T_DEFINED
+# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
+# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
+typedef ssize_t la_ssize_t;
+# elif defined(_WIN64)
+typedef __int64 la_ssize_t;
+# else
+typedef long la_ssize_t;
+# endif
# else
-# define __LA_INT64_T int64_t
+# include <unistd.h> /* ssize_t */
+typedef ssize_t la_ssize_t;
# endif
-# define __LA_SSIZE_T ssize_t
+#endif
+
+/* Large file support for Android */
+#ifdef __ANDROID__
+#include "android_lf.h"
#endif
/*
@@ -115,24 +150,34 @@ extern "C" {
* header and library are very different, you should expect some
* strangeness. Don't do that.
*/
-
-/*
- * The version number is expressed as a single integer that makes it
- * easy to compare versions at build time: for version a.b.c, the
- * version number is printf("%d%03d%03d",a,b,c). For example, if you
- * know your application requires version 2.12.108 or later, you can
- * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
- */
-/* Note: Compiler will complain if this does not match archive_entry.h! */
-#define ARCHIVE_VERSION_NUMBER 3001002
__LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_VERSION_STRING "libarchive 3.1.2"
+#define ARCHIVE_VERSION_ONLY_STRING "3.2.0"
+#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);
+/*
+ * Detailed textual name/version of the library and its dependencies.
+ * This has the form:
+ * "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
+ * the list of libraries described here will vary depending on how
+ * libarchive was compiled.
+ */
+__LA_DECL const char * archive_version_details(void);
+
+/*
+ * Returns NULL if libarchive was compiled without the associated library.
+ * Otherwise, returns the version number that libarchive was compiled
+ * against.
+ */
+__LA_DECL const char * archive_zlib_version(void);
+__LA_DECL const char * archive_liblzma_version(void);
+__LA_DECL const char * archive_bzlib_version(void);
+__LA_DECL const char * archive_liblz4_version(void);
+
/* Declare our basic types. */
struct archive;
struct archive_entry;
@@ -173,7 +218,7 @@ struct archive_entry;
*/
/* Returns pointer and size of next block of data from archive. */
-typedef __LA_SSIZE_T archive_read_callback(struct archive *,
+typedef la_ssize_t archive_read_callback(struct archive *,
void *_client_data, const void **_buffer);
/* Skips at most request bytes from archive and returns the skipped amount.
@@ -181,18 +226,18 @@ typedef __LA_SSIZE_T archive_read_callback(struct archive *,
* If you do skip fewer bytes than requested, libarchive will invoke your
* read callback and discard data as necessary to make up the full skip.
*/
-typedef __LA_INT64_T archive_skip_callback(struct archive *,
- void *_client_data, __LA_INT64_T request);
+typedef la_int64_t archive_skip_callback(struct archive *,
+ void *_client_data, la_int64_t request);
/* Seeks to specified location in the file and returns the position.
* Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
* Return ARCHIVE_FATAL if the seek fails for any reason.
*/
-typedef __LA_INT64_T archive_seek_callback(struct archive *,
- void *_client_data, __LA_INT64_T offset, int whence);
+typedef la_int64_t archive_seek_callback(struct archive *,
+ void *_client_data, la_int64_t offset, int whence);
/* Returns size actually written, zero on EOF, -1 on error. */
-typedef __LA_SSIZE_T archive_write_callback(struct archive *,
+typedef la_ssize_t archive_write_callback(struct archive *,
void *_client_data,
const void *_buffer, size_t _length);
@@ -208,6 +253,13 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
void *_client_data2);
/*
+ * Returns a passphrase used for encryption or decryption, NULL on nothing
+ * to do and give it up.
+ */
+typedef const char *archive_passphrase_callback(struct archive *,
+ void *_client_data);
+
+/*
* Codes to identify various stream filters.
*/
#define ARCHIVE_FILTER_NONE 0
@@ -223,6 +275,7 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
#define ARCHIVE_FILTER_LRZIP 10
#define ARCHIVE_FILTER_LZOP 11
#define ARCHIVE_FILTER_GRZIP 12
+#define ARCHIVE_FILTER_LZ4 13
#if ARCHIVE_VERSION_NUMBER < 4000000
#define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE
@@ -284,6 +337,31 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
#define ARCHIVE_FORMAT_CAB 0xC0000
#define ARCHIVE_FORMAT_RAR 0xD0000
#define ARCHIVE_FORMAT_7ZIP 0xE0000
+#define ARCHIVE_FORMAT_WARC 0xF0000
+
+/*
+ * Codes returned by archive_read_format_capabilities().
+ *
+ * This list can be extended with values between 0 and 0xffff.
+ * The original purpose of this list was to let different archive
+ * format readers expose their general capabilities in terms of
+ * encryption.
+ */
+#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */
+
+/*
+ * Codes returned by archive_read_has_encrypted_entries().
+ *
+ * In case the archive does not support encryption detection at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
+ * for some other reason (e.g. not enough bytes read) cannot say if
+ * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
+ * is returned.
+ */
+#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
+#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
/*-
* Basic outline for reading an archive:
@@ -342,6 +420,7 @@ __LA_DECL int archive_read_support_filter_compress(struct archive *);
__LA_DECL int archive_read_support_filter_gzip(struct archive *);
__LA_DECL int archive_read_support_filter_grzip(struct archive *);
__LA_DECL int archive_read_support_filter_lrzip(struct archive *);
+__LA_DECL int archive_read_support_filter_lz4(struct archive *);
__LA_DECL int archive_read_support_filter_lzip(struct archive *);
__LA_DECL int archive_read_support_filter_lzma(struct archive *);
__LA_DECL int archive_read_support_filter_lzop(struct archive *);
@@ -369,8 +448,17 @@ __LA_DECL int archive_read_support_format_mtree(struct archive *);
__LA_DECL int archive_read_support_format_rar(struct archive *);
__LA_DECL int archive_read_support_format_raw(struct archive *);
__LA_DECL int archive_read_support_format_tar(struct archive *);
+__LA_DECL int archive_read_support_format_warc(struct archive *);
__LA_DECL int archive_read_support_format_xar(struct archive *);
+/* archive_read_support_format_zip() enables both streamable and seekable
+ * zip readers. */
__LA_DECL int archive_read_support_format_zip(struct archive *);
+/* Reads Zip archives as stream from beginning to end. Doesn't
+ * correctly handle SFX ZIP files or ZIP archives that have been modified
+ * in-place. */
+__LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
+/* Reads starting from central directory; requires seekable input. */
+__LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
/* Functions to manually set the format and filters to be used. This is
* useful to bypass the bidding process when the format and filters to use
@@ -441,9 +529,9 @@ __LA_DECL int archive_read_open_file(struct archive *,
const char *_filename, size_t _block_size) __LA_DEPRECATED;
/* Read an archive that's stored in memory. */
__LA_DECL int archive_read_open_memory(struct archive *,
- void * buff, size_t size);
+ const void * buff, size_t size);
/* A more involved version that is only used for internal testing. */
-__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff,
+__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
size_t size, size_t read_size);
/* Read an archive that's already open, using the file descriptor. */
__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
@@ -464,14 +552,40 @@ __LA_DECL int archive_read_next_header2(struct archive *,
* Retrieve the byte offset in UNCOMPRESSED data where last-read
* header started.
*/
-__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
+__LA_DECL la_int64_t archive_read_header_position(struct archive *);
+
+/*
+ * Returns 1 if the archive contains at least one encrypted entry.
+ * If the archive format not support encryption at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
+ * If for any other reason (e.g. not enough data read so far)
+ * we cannot say whether there are encrypted entries, then
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
+ * In general, this function will return values below zero when the
+ * reader is uncertain or totally uncapable of encryption support.
+ * When this function returns 0 you can be sure that the reader
+ * supports encryption detection but no encrypted entries have
+ * been found yet.
+ *
+ * NOTE: If the metadata/header of an archive is also encrypted, you
+ * cannot rely on the number of encrypted entries. That is why this
+ * function does not return the number of encrypted entries but#
+ * just shows that there are some.
+ */
+__LA_DECL int archive_read_has_encrypted_entries(struct archive *);
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+__LA_DECL int archive_read_format_capabilities(struct archive *);
/* Read data from the body of an entry. Similar to read(2). */
-__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
+__LA_DECL la_ssize_t archive_read_data(struct archive *,
void *, size_t);
/* Seek within the body of an entry. Similar to lseek(2). */
-__LA_DECL __LA_INT64_T archive_seek_data(struct archive *, __LA_INT64_T, int);
+__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);
/*
* A zero-copy version of archive_read_data that also exposes the file offset
@@ -480,7 +594,7 @@ __LA_DECL __LA_INT64_T archive_seek_data(struct archive *, __LA_INT64_T, int);
* be strictly increasing and that returned blocks will not overlap.
*/
__LA_DECL int archive_read_data_block(struct archive *a,
- const void **buff, size_t *size, __LA_INT64_T *offset);
+ const void **buff, size_t *size, la_int64_t *offset);
/*-
* Some convenience functions that are built on archive_read_data:
@@ -510,6 +624,14 @@ __LA_DECL int archive_read_set_option(struct archive *_a,
__LA_DECL int archive_read_set_options(struct archive *_a,
const char *opts);
+/*
+ * Add a decryption passphrase.
+ */
+__LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
+__LA_DECL int archive_read_set_passphrase_callback(struct archive *,
+ void *client_data, archive_passphrase_callback *);
+
+
/*-
* Convenience function to recreate the current entry (whose header
* has just been read) on disk.
@@ -562,6 +684,10 @@ __LA_DECL int archive_read_set_options(struct archive *_a,
/* Default: Do not use HFS+ compression if it was not compressed. */
/* This has no effect except on Mac OS v10.6 or later. */
#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000)
+/* Default: Do not reject entries with absolute paths */
+#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
+/* Default: Do not clear no-change flags when unlinking object */
+#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000)
__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
int flags);
@@ -573,7 +699,7 @@ __LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
/* Record the dev/ino of a file that will not be written. This is
* generally set to the dev/ino of the archive being read. */
__LA_DECL void archive_read_extract_set_skip_file(struct archive *,
- __LA_INT64_T, __LA_INT64_T);
+ la_int64_t, la_int64_t);
/* Close the file and release most resources. */
__LA_DECL int archive_read_close(struct archive *);
@@ -612,7 +738,7 @@ __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
/* The dev/ino of a file that won't be archived. This is used
* to avoid recursively adding an archive to itself. */
__LA_DECL int archive_write_set_skip_file(struct archive *,
- __LA_INT64_T, __LA_INT64_T);
+ la_int64_t, la_int64_t);
#if ARCHIVE_VERSION_NUMBER < 4000000
__LA_DECL int archive_write_set_compression_bzip2(struct archive *)
@@ -643,6 +769,7 @@ __LA_DECL int archive_write_add_filter_compress(struct archive *);
__LA_DECL int archive_write_add_filter_grzip(struct archive *);
__LA_DECL int archive_write_add_filter_gzip(struct archive *);
__LA_DECL int archive_write_add_filter_lrzip(struct archive *);
+__LA_DECL int archive_write_add_filter_lz4(struct archive *);
__LA_DECL int archive_write_add_filter_lzip(struct archive *);
__LA_DECL int archive_write_add_filter_lzma(struct archive *);
__LA_DECL int archive_write_add_filter_lzop(struct archive *);
@@ -670,12 +797,16 @@ __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
__LA_DECL int archive_write_set_format_pax(struct archive *);
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
+__LA_DECL int archive_write_set_format_raw(struct archive *);
__LA_DECL int archive_write_set_format_shar(struct archive *);
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
__LA_DECL int archive_write_set_format_ustar(struct archive *);
__LA_DECL int archive_write_set_format_v7tar(struct archive *);
+__LA_DECL int archive_write_set_format_warc(struct archive *);
__LA_DECL int archive_write_set_format_xar(struct archive *);
__LA_DECL int archive_write_set_format_zip(struct archive *);
+__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
+__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
__LA_DECL int archive_write_zip_set_compression_store(struct archive *);
__LA_DECL int archive_write_open(struct archive *, void *,
@@ -700,12 +831,12 @@ __LA_DECL int archive_write_open_memory(struct archive *,
*/
__LA_DECL int archive_write_header(struct archive *,
struct archive_entry *);
-__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *,
+__LA_DECL la_ssize_t archive_write_data(struct archive *,
const void *, size_t);
/* This interface is currently only available for archive_write_disk handles. */
-__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
- const void *, size_t, __LA_INT64_T);
+__LA_DECL la_ssize_t archive_write_data_block(struct archive *,
+ const void *, size_t, la_int64_t);
__LA_DECL int archive_write_finish_entry(struct archive *);
__LA_DECL int archive_write_close(struct archive *);
@@ -740,6 +871,13 @@ __LA_DECL int archive_write_set_option(struct archive *_a,
__LA_DECL int archive_write_set_options(struct archive *_a,
const char *opts);
+/*
+ * Set a encryption passphrase.
+ */
+__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
+__LA_DECL int archive_write_set_passphrase_callback(struct archive *,
+ void *client_data, archive_passphrase_callback *);
+
/*-
* ARCHIVE_WRITE_DISK API
*
@@ -759,7 +897,7 @@ __LA_DECL int archive_write_set_options(struct archive *_a,
__LA_DECL struct archive *archive_write_disk_new(void);
/* This file will not be overwritten. */
__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
- __LA_INT64_T, __LA_INT64_T);
+ la_int64_t, la_int64_t);
/* Set flags to control how the next item gets created.
* This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
__LA_DECL int archive_write_disk_set_options(struct archive *,
@@ -789,14 +927,14 @@ __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *);
*/
__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
void * /* private_data */,
- __LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
+ la_int64_t (*)(void *, const char *, la_int64_t),
void (* /* cleanup */)(void *));
__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
void * /* private_data */,
- __LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
+ la_int64_t (*)(void *, const char *, la_int64_t),
void (* /* cleanup */)(void *));
-__LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T);
-__LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T);
+__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t);
+__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t);
/*
* ARCHIVE_READ_DISK API
@@ -817,19 +955,19 @@ __LA_DECL int archive_read_disk_entry_from_file(struct archive *,
struct archive_entry *, int /* fd */, const struct stat *);
/* Look up gname for gid or uname for uid. */
/* Default implementations are very, very stupid. */
-__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T);
-__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T);
+__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t);
+__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t);
/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
* results for performance. */
__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
/* You can install your own lookups if you like. */
__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
void * /* private_data */,
- const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
+ const char *(* /* lookup_fn */)(void *, la_int64_t),
void (* /* cleanup_fn */)(void *));
__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
void * /* private_data */,
- const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
+ const char *(* /* lookup_fn */)(void *, la_int64_t),
void (* /* cleanup_fn */)(void *));
/* Start traversal. */
__LA_DECL int archive_read_disk_open(struct archive *, const char *);
@@ -859,8 +997,10 @@ __LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
/* Default: Skip a mac resource fork file whose prefix is "._" because of
* using copyfile. */
#define ARCHIVE_READDISK_MAC_COPYFILE (0x0004)
-/* Default: Do not traverse mount points. */
+/* Default: Traverse mount points. */
#define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008)
+/* Default: Xattrs are read from disk. */
+#define ARCHIVE_READDISK_NO_XATTR (0x0010)
__LA_DECL int archive_read_disk_set_behavior(struct archive *,
int flags);
@@ -879,6 +1019,10 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
int (*_metadata_filter_func)(struct archive *, void *,
struct archive_entry *), void *_client_data);
+/* Simplified cleanup interface;
+ * This calls archive_read_free() or archive_write_free() as needed. */
+__LA_DECL int archive_free(struct archive *);
+
/*
* Accessor functions to read/set various information in
* the struct archive object:
@@ -889,7 +1033,7 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
* last filter, which is always the pseudo-filter that wraps the
* client callbacks. */
__LA_DECL int archive_filter_count(struct archive *);
-__LA_DECL __LA_INT64_T archive_filter_bytes(struct archive *, int);
+__LA_DECL la_int64_t archive_filter_bytes(struct archive *, int);
__LA_DECL int archive_filter_code(struct archive *, int);
__LA_DECL const char * archive_filter_name(struct archive *, int);
@@ -897,10 +1041,10 @@ __LA_DECL const char * archive_filter_name(struct archive *, int);
/* These don't properly handle multiple filters, so are deprecated and
* will eventually be removed. */
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
-__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *)
+__LA_DECL la_int64_t archive_position_compressed(struct archive *)
__LA_DEPRECATED;
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
-__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *)
+__LA_DECL la_int64_t archive_position_uncompressed(struct archive *)
__LA_DEPRECATED;
/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
__LA_DECL const char *archive_compression_name(struct archive *)
@@ -1016,8 +1160,8 @@ __LA_DECL int archive_match_exclude_entry(struct archive *,
__LA_DECL int archive_match_owner_excluded(struct archive *,
struct archive_entry *);
/* Add inclusion uid, gid, uname and gname. */
-__LA_DECL int archive_match_include_uid(struct archive *, __LA_INT64_T);
-__LA_DECL int archive_match_include_gid(struct archive *, __LA_INT64_T);
+__LA_DECL int archive_match_include_uid(struct archive *, la_int64_t);
+__LA_DECL int archive_match_include_gid(struct archive *, la_int64_t);
__LA_DECL int archive_match_include_uname(struct archive *, const char *);
__LA_DECL int archive_match_include_uname_w(struct archive *,
const wchar_t *);
@@ -1025,6 +1169,10 @@ __LA_DECL int archive_match_include_gname(struct archive *, const char *);
__LA_DECL int archive_match_include_gname_w(struct archive *,
const wchar_t *);
+/* Utility functions */
+/* Convenience function to sort a NULL terminated list of strings */
+__LA_DECL int archive_utility_string_sort(char **);
+
#ifdef __cplusplus
}
#endif
@@ -1032,9 +1180,4 @@ __LA_DECL int archive_match_include_gname_w(struct archive *,
/* These are meaningless outside of this header. */
#undef __LA_DECL
-/* These need to remain defined because they're used in the
- * callback type definitions. XXX Fix this. This is ugly. XXX */
-/* #undef __LA_INT64_T */
-/* #undef __LA_SSIZE_T */
-
#endif /* !ARCHIVE_H_INCLUDED */
diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c
new file mode 100644
index 000000000000..0be30c601a94
--- /dev/null
+++ b/libarchive/archive_cryptor.c
@@ -0,0 +1,448 @@
+/*-
+* Copyright (c) 2014 Michihiro NAKAJIMA
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "archive_platform.h"
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include "archive.h"
+#include "archive_cryptor_private.h"
+
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * this file will normally define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist. This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_cryptor_build_hack(void) {
+ return 0;
+}
+
+#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
+
+static int
+pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
+ size_t derived_key_len)
+{
+ CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pw,
+ pw_len, salt, salt_len, kCCPRFHmacAlgSHA1, rounds,
+ derived_key, derived_key_len);
+ return 0;
+}
+
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#ifdef _MSC_VER
+#pragma comment(lib, "Bcrypt.lib")
+#endif
+
+static int
+pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
+ size_t derived_key_len)
+{
+ NTSTATUS status;
+ BCRYPT_ALG_HANDLE hAlg;
+
+ status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_SHA1_ALGORITHM,
+ MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG);
+ if (!BCRYPT_SUCCESS(status))
+ return -1;
+
+ status = BCryptDeriveKeyPBKDF2(hAlg,
+ (PUCHAR)(uintptr_t)pw, (ULONG)pw_len,
+ (PUCHAR)(uintptr_t)salt, (ULONG)salt_len, rounds,
+ (PUCHAR)derived_key, (ULONG)derived_key_len, 0);
+
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+
+ return (BCRYPT_SUCCESS(status)) ? 0: -1;
+}
+
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_PBKDF2_H)
+
+static int
+pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
+ size_t derived_key_len) {
+ pbkdf2_hmac_sha1((unsigned)pw_len, (const uint8_t *)pw, rounds,
+ salt_len, salt, derived_key_len, derived_key);
+ return 0;
+}
+
+#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_PKCS5_PBKDF2_HMAC_SHA1)
+
+static int
+pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
+ size_t derived_key_len) {
+
+ PKCS5_PBKDF2_HMAC_SHA1(pw, pw_len, salt, salt_len, rounds,
+ derived_key_len, derived_key);
+ return 0;
+}
+
+#else
+
+/* Stub */
+static int
+pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
+ size_t derived_key_len) {
+ (void)pw; /* UNUSED */
+ (void)pw_len; /* UNUSED */
+ (void)salt; /* UNUSED */
+ (void)salt_len; /* UNUSED */
+ (void)rounds; /* UNUSED */
+ (void)derived_key; /* UNUSED */
+ (void)derived_key_len; /* UNUSED */
+ return -1; /* UNSUPPORTED */
+}
+
+#endif
+
+#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
+# define kCCAlgorithmAES kCCAlgorithmAES128
+# endif
+
+static int
+aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
+{
+ CCCryptorStatus r;
+
+ ctx->key_len = key_len;
+ memcpy(ctx->key, key, key_len);
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
+ ctx->encr_pos = AES_BLOCK_SIZE;
+ r = CCCryptorCreateWithMode(kCCEncrypt, kCCModeECB, kCCAlgorithmAES,
+ ccNoPadding, NULL, key, key_len, NULL, 0, 0, 0, &ctx->ctx);
+ return (r == kCCSuccess)? 0: -1;
+}
+
+static int
+aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
+{
+ CCCryptorRef ref = ctx->ctx;
+ CCCryptorStatus r;
+
+ r = CCCryptorReset(ref, NULL);
+ if (r != kCCSuccess)
+ return -1;
+ r = CCCryptorUpdate(ref, ctx->nonce, AES_BLOCK_SIZE, ctx->encr_buf,
+ AES_BLOCK_SIZE, NULL);
+ return (r == kCCSuccess)? 0: -1;
+}
+
+static int
+aes_ctr_release(archive_crypto_ctx *ctx)
+{
+ memset(ctx->key, 0, ctx->key_len);
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
+ return 0;
+}
+
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+
+static int
+aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
+{
+ BCRYPT_ALG_HANDLE hAlg;
+ BCRYPT_KEY_HANDLE hKey;
+ DWORD keyObj_len, aes_key_len;
+ PBYTE keyObj;
+ ULONG result;
+ NTSTATUS status;
+ BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
+
+ ctx->hAlg = NULL;
+ ctx->hKey = NULL;
+ ctx->keyObj = NULL;
+ switch (key_len) {
+ case 16: aes_key_len = 128; break;
+ case 24: aes_key_len = 192; break;
+ case 32: aes_key_len = 256; break;
+ default: return -1;
+ }
+ status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_AES_ALGORITHM,
+ MS_PRIMITIVE_PROVIDER, 0);
+ if (!BCRYPT_SUCCESS(status))
+ return -1;
+ status = BCryptGetProperty(hAlg, BCRYPT_KEY_LENGTHS, (PUCHAR)&key_lengths,
+ sizeof(key_lengths), &result, 0);
+ if (!BCRYPT_SUCCESS(status)) {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ return -1;
+ }
+ if (key_lengths.dwMinLength > aes_key_len
+ || key_lengths.dwMaxLength < aes_key_len) {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ return -1;
+ }
+ status = BCryptGetProperty(hAlg, BCRYPT_OBJECT_LENGTH, (PUCHAR)&keyObj_len,
+ sizeof(keyObj_len), &result, 0);
+ if (!BCRYPT_SUCCESS(status)) {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ return -1;
+ }
+ keyObj = (PBYTE)HeapAlloc(GetProcessHeap(), 0, keyObj_len);
+ if (keyObj == NULL) {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ return -1;
+ }
+ status = BCryptSetProperty(hAlg, BCRYPT_CHAINING_MODE,
+ (PUCHAR)BCRYPT_CHAIN_MODE_ECB, sizeof(BCRYPT_CHAIN_MODE_ECB), 0);
+ if (!BCRYPT_SUCCESS(status)) {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ HeapFree(GetProcessHeap(), 0, keyObj);
+ return -1;
+ }
+ status = BCryptGenerateSymmetricKey(hAlg, &hKey,
+ keyObj, keyObj_len,
+ (PUCHAR)(uintptr_t)key, (ULONG)key_len, 0);
+ if (!BCRYPT_SUCCESS(status)) {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ HeapFree(GetProcessHeap(), 0, keyObj);
+ return -1;
+ }
+
+ ctx->hAlg = hAlg;
+ ctx->hKey = hKey;
+ ctx->keyObj = keyObj;
+ ctx->keyObj_len = keyObj_len;
+ ctx->encr_pos = AES_BLOCK_SIZE;
+
+ return 0;
+}
+
+static int
+aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
+{
+ NTSTATUS status;
+ ULONG result;
+
+ status = BCryptEncrypt(ctx->hKey, (PUCHAR)ctx->nonce, AES_BLOCK_SIZE,
+ NULL, NULL, 0, (PUCHAR)ctx->encr_buf, AES_BLOCK_SIZE,
+ &result, 0);
+ return BCRYPT_SUCCESS(status) ? 0 : -1;
+}
+
+static int
+aes_ctr_release(archive_crypto_ctx *ctx)
+{
+
+ if (ctx->hAlg != NULL) {
+ BCryptCloseAlgorithmProvider(ctx->hAlg, 0);
+ ctx->hAlg = NULL;
+ BCryptDestroyKey(ctx->hKey);
+ ctx->hKey = NULL;
+ HeapFree(GetProcessHeap(), 0, ctx->keyObj);
+ ctx->keyObj = NULL;
+ }
+ memset(ctx, 0, sizeof(*ctx));
+ return 0;
+}
+
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
+
+static int
+aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
+{
+ ctx->key_len = key_len;
+ memcpy(ctx->key, key, key_len);
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
+ ctx->encr_pos = AES_BLOCK_SIZE;
+ memset(&ctx->ctx, 0, sizeof(ctx->ctx));
+ return 0;
+}
+
+static int
+aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
+{
+ aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
+ aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
+ return 0;
+}
+
+static int
+aes_ctr_release(archive_crypto_ctx *ctx)
+{
+ memset(ctx, 0, sizeof(*ctx));
+ return 0;
+}
+
+#elif defined(HAVE_LIBCRYPTO)
+
+static int
+aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
+{
+
+ switch (key_len) {
+ case 16: ctx->type = EVP_aes_128_ecb(); break;
+ case 24: ctx->type = EVP_aes_192_ecb(); break;
+ case 32: ctx->type = EVP_aes_256_ecb(); break;
+ default: ctx->type = NULL; return -1;
+ }
+
+ ctx->key_len = key_len;
+ memcpy(ctx->key, key, key_len);
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
+ ctx->encr_pos = AES_BLOCK_SIZE;
+ EVP_CIPHER_CTX_init(&ctx->ctx);
+ return 0;
+}
+
+static int
+aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
+{
+ int outl = 0;
+ int r;
+
+ r = EVP_EncryptInit_ex(&ctx->ctx, ctx->type, NULL, ctx->key, NULL);
+ if (r == 0)
+ return -1;
+ r = EVP_EncryptUpdate(&ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
+ AES_BLOCK_SIZE);
+ if (r == 0 || outl != AES_BLOCK_SIZE)
+ return -1;
+ return 0;
+}
+
+static int
+aes_ctr_release(archive_crypto_ctx *ctx)
+{
+ EVP_CIPHER_CTX_cleanup(&ctx->ctx);
+ memset(ctx->key, 0, ctx->key_len);
+ memset(ctx->nonce, 0, sizeof(ctx->nonce));
+ return 0;
+}
+
+#else
+
+#define ARCHIVE_CRYPTOR_STUB
+/* Stub */
+static int
+aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
+{
+ (void)ctx; /* UNUSED */
+ (void)key; /* UNUSED */
+ (void)key_len; /* UNUSED */
+ return -1;
+}
+
+static int
+aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
+{
+ (void)ctx; /* UNUSED */
+ return -1;
+}
+
+static int
+aes_ctr_release(archive_crypto_ctx *ctx)
+{
+ (void)ctx; /* UNUSED */
+ return 0;
+}
+
+#endif
+
+#ifdef ARCHIVE_CRYPTOR_STUB
+static int
+aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
+ size_t in_len, uint8_t * const out, size_t *out_len)
+{
+ (void)ctx; /* UNUSED */
+ (void)in; /* UNUSED */
+ (void)in_len; /* UNUSED */
+ (void)out; /* UNUSED */
+ (void)out_len; /* UNUSED */
+ aes_ctr_encrypt_counter(ctx); /* UNUSED */ /* Fix unused function warning */
+ return -1;
+}
+
+#else
+static void
+aes_ctr_increase_counter(archive_crypto_ctx *ctx)
+{
+ uint8_t *const nonce = ctx->nonce;
+ int j;
+
+ for (j = 0; j < 8; j++) {
+ if (++nonce[j])
+ break;
+ }
+}
+
+static int
+aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
+ size_t in_len, uint8_t * const out, size_t *out_len)
+{
+ uint8_t *const ebuf = ctx->encr_buf;
+ unsigned pos = ctx->encr_pos;
+ unsigned max = (unsigned)((in_len < *out_len)? in_len: *out_len);
+ unsigned i;
+
+ for (i = 0; i < max; ) {
+ if (pos == AES_BLOCK_SIZE) {
+ aes_ctr_increase_counter(ctx);
+ if (aes_ctr_encrypt_counter(ctx) != 0)
+ return -1;
+ while (max -i >= AES_BLOCK_SIZE) {
+ for (pos = 0; pos < AES_BLOCK_SIZE; pos++)
+ out[i+pos] = in[i+pos] ^ ebuf[pos];
+ i += AES_BLOCK_SIZE;
+ aes_ctr_increase_counter(ctx);
+ if (aes_ctr_encrypt_counter(ctx) != 0)
+ return -1;
+ }
+ pos = 0;
+ if (i >= max)
+ break;
+ }
+ out[i] = in[i] ^ ebuf[pos++];
+ i++;
+ }
+ ctx->encr_pos = pos;
+ *out_len = i;
+
+ return 0;
+}
+#endif /* ARCHIVE_CRYPTOR_STUB */
+
+
+const struct archive_cryptor __archive_cryptor =
+{
+ &pbkdf2_sha1,
+ &aes_ctr_init,
+ &aes_ctr_update,
+ &aes_ctr_release,
+ &aes_ctr_init,
+ &aes_ctr_update,
+ &aes_ctr_release,
+};
diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h
new file mode 100644
index 000000000000..37eaad369dc7
--- /dev/null
+++ b/libarchive/archive_cryptor_private.h
@@ -0,0 +1,163 @@
+/*-
+* Copyright (c) 2014 Michihiro NAKAJIMA
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+#ifndef ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
+#define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
+
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_cryptor.c file will normally define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist. This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_cryptor_build_hack(void);
+
+#ifdef __APPLE__
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+# define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
+# endif
+#endif
+
+#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
+#include <CommonCrypto/CommonCryptor.h>
+#include <CommonCrypto/CommonKeyDerivation.h>
+#define AES_BLOCK_SIZE 16
+#define AES_MAX_KEY_SIZE kCCKeySizeAES256
+
+typedef struct {
+ CCCryptorRef ctx;
+ uint8_t key[AES_MAX_KEY_SIZE];
+ unsigned key_len;
+ uint8_t nonce[AES_BLOCK_SIZE];
+ uint8_t encr_buf[AES_BLOCK_SIZE];
+ unsigned encr_pos;
+} archive_crypto_ctx;
+
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#include <Bcrypt.h>
+
+/* Common in other bcrypt implementations, but missing from VS2008. */
+#ifndef BCRYPT_SUCCESS
+#define BCRYPT_SUCCESS(r) ((NTSTATUS)(r) == STATUS_SUCCESS)
+#endif
+
+#define AES_MAX_KEY_SIZE 32
+#define AES_BLOCK_SIZE 16
+typedef struct {
+ BCRYPT_ALG_HANDLE hAlg;
+ BCRYPT_KEY_HANDLE hKey;
+ PBYTE keyObj;
+ DWORD keyObj_len;
+ uint8_t nonce[AES_BLOCK_SIZE];
+ uint8_t encr_buf[AES_BLOCK_SIZE];
+ unsigned encr_pos;
+} archive_crypto_ctx;
+
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
+#if defined(HAVE_NETTLE_PBKDF2_H)
+#include <nettle/pbkdf2.h>
+#endif
+#include <nettle/aes.h>
+
+typedef struct {
+ struct aes_ctx ctx;
+ uint8_t key[AES_MAX_KEY_SIZE];
+ unsigned key_len;
+ uint8_t nonce[AES_BLOCK_SIZE];
+ uint8_t encr_buf[AES_BLOCK_SIZE];
+ unsigned encr_pos;
+} archive_crypto_ctx;
+
+#elif defined(HAVE_LIBCRYPTO)
+#include <openssl/evp.h>
+#define AES_BLOCK_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+
+typedef struct {
+ EVP_CIPHER_CTX ctx;
+ const EVP_CIPHER *type;
+ uint8_t key[AES_MAX_KEY_SIZE];
+ unsigned key_len;
+ uint8_t nonce[AES_BLOCK_SIZE];
+ uint8_t encr_buf[AES_BLOCK_SIZE];
+ unsigned encr_pos;
+} archive_crypto_ctx;
+
+#else
+
+#define AES_BLOCK_SIZE 16
+#define AES_MAX_KEY_SIZE 32
+typedef int archive_crypto_ctx;
+
+#endif
+
+/* defines */
+#define archive_pbkdf2_sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)\
+ __archive_cryptor.pbkdf2sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)
+
+#define archive_decrypto_aes_ctr_init(ctx, key, key_len) \
+ __archive_cryptor.decrypto_aes_ctr_init(ctx, key, key_len)
+#define archive_decrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
+ __archive_cryptor.decrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
+#define archive_decrypto_aes_ctr_release(ctx) \
+ __archive_cryptor.decrypto_aes_ctr_release(ctx)
+
+#define archive_encrypto_aes_ctr_init(ctx, key, key_len) \
+ __archive_cryptor.encrypto_aes_ctr_init(ctx, key, key_len)
+#define archive_encrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
+ __archive_cryptor.encrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
+#define archive_encrypto_aes_ctr_release(ctx) \
+ __archive_cryptor.encrypto_aes_ctr_release(ctx)
+
+/* Minimal interface to cryptographic functionality for internal use in
+ * libarchive */
+struct archive_cryptor
+{
+ /* PKCS5 PBKDF2 HMAC-SHA1 */
+ int (*pbkdf2sha1)(const char *pw, size_t pw_len, const uint8_t *salt,
+ size_t salt_len, unsigned rounds, uint8_t *derived_key,
+ size_t derived_key_len);
+ /* AES CTR mode(little endian version) */
+ int (*decrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
+ int (*decrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
+ size_t, uint8_t *, size_t *);
+ int (*decrypto_aes_ctr_release)(archive_crypto_ctx *);
+ int (*encrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
+ int (*encrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
+ size_t, uint8_t *, size_t *);
+ int (*encrypto_aes_ctr_release)(archive_crypto_ctx *);
+};
+
+extern const struct archive_cryptor __archive_cryptor;
+
+#endif
diff --git a/libarchive/archive_crypto.c b/libarchive/archive_digest.c
index 85aba3ae27cd..f009d317aeef 100644
--- a/libarchive/archive_crypto.c
+++ b/libarchive/archive_digest.c
@@ -28,7 +28,7 @@
#include "archive_platform.h"
#include "archive.h"
-#include "archive_crypto_private.h"
+#include "archive_digest_private.h"
/* In particular, force the configure probe to break if it tries
* to test a combination of OpenSSL and libmd. */
@@ -1216,8 +1216,8 @@ __archive_stub_sha512final(archive_sha512_ctx *ctx, void *md)
#endif
-/* NOTE: Crypto functions are set based on availability and by the following
- * order of preference.
+/* NOTE: Message Digest functions are set based on availability and by the
+ * following order of preference.
* 1. libc
* 2. libc2
* 3. libc3
@@ -1227,7 +1227,7 @@ __archive_stub_sha512final(archive_sha512_ctx *ctx, void *md)
* 7. libmd
* 8. Windows API
*/
-const struct archive_crypto __archive_crypto =
+const struct archive_digest __archive_digest =
{
/* MD5 */
#if defined(ARCHIVE_CRYPTO_MD5_LIBC)
@@ -1412,7 +1412,7 @@ const struct archive_crypto __archive_crypto =
#elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
&__archive_nettle_sha512init,
&__archive_nettle_sha512update,
- &__archive_nettle_sha512final,
+ &__archive_nettle_sha512final
#elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
&__archive_openssl_sha512init,
&__archive_openssl_sha512update,
diff --git a/libarchive/archive_crypto_private.h b/libarchive/archive_digest_private.h
index f8b1fb3c3f54..77fad5806fdd 100644
--- a/libarchive/archive_crypto_private.h
+++ b/libarchive/archive_digest_private.h
@@ -264,11 +264,11 @@ typedef unsigned char archive_sha512_ctx;
#define ARCHIVE_HAS_MD5
#endif
#define archive_md5_init(ctx)\
- __archive_crypto.md5init(ctx)
+ __archive_digest.md5init(ctx)
#define archive_md5_final(ctx, md)\
- __archive_crypto.md5final(ctx, md)
+ __archive_digest.md5final(ctx, md)
#define archive_md5_update(ctx, buf, n)\
- __archive_crypto.md5update(ctx, buf, n)
+ __archive_digest.md5update(ctx, buf, n)
#if defined(ARCHIVE_CRYPTO_RMD160_LIBC) ||\
defined(ARCHIVE_CRYPTO_RMD160_NETTLE) ||\
@@ -276,11 +276,11 @@ typedef unsigned char archive_sha512_ctx;
#define ARCHIVE_HAS_RMD160
#endif
#define archive_rmd160_init(ctx)\
- __archive_crypto.rmd160init(ctx)
+ __archive_digest.rmd160init(ctx)
#define archive_rmd160_final(ctx, md)\
- __archive_crypto.rmd160final(ctx, md)
+ __archive_digest.rmd160final(ctx, md)
#define archive_rmd160_update(ctx, buf, n)\
- __archive_crypto.rmd160update(ctx, buf, n)
+ __archive_digest.rmd160update(ctx, buf, n)
#if defined(ARCHIVE_CRYPTO_SHA1_LIBC) ||\
defined(ARCHIVE_CRYPTO_SHA1_LIBMD) || \
@@ -291,11 +291,11 @@ typedef unsigned char archive_sha512_ctx;
#define ARCHIVE_HAS_SHA1
#endif
#define archive_sha1_init(ctx)\
- __archive_crypto.sha1init(ctx)
+ __archive_digest.sha1init(ctx)
#define archive_sha1_final(ctx, md)\
- __archive_crypto.sha1final(ctx, md)
+ __archive_digest.sha1final(ctx, md)
#define archive_sha1_update(ctx, buf, n)\
- __archive_crypto.sha1update(ctx, buf, n)
+ __archive_digest.sha1update(ctx, buf, n)
#if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\
defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\
@@ -308,11 +308,11 @@ typedef unsigned char archive_sha512_ctx;
#define ARCHIVE_HAS_SHA256
#endif
#define archive_sha256_init(ctx)\
- __archive_crypto.sha256init(ctx)
+ __archive_digest.sha256init(ctx)
#define archive_sha256_final(ctx, md)\
- __archive_crypto.sha256final(ctx, md)
+ __archive_digest.sha256final(ctx, md)
#define archive_sha256_update(ctx, buf, n)\
- __archive_crypto.sha256update(ctx, buf, n)
+ __archive_digest.sha256update(ctx, buf, n)
#if defined(ARCHIVE_CRYPTO_SHA384_LIBC) ||\
defined(ARCHIVE_CRYPTO_SHA384_LIBC2) ||\
@@ -324,11 +324,11 @@ typedef unsigned char archive_sha512_ctx;
#define ARCHIVE_HAS_SHA384
#endif
#define archive_sha384_init(ctx)\
- __archive_crypto.sha384init(ctx)
+ __archive_digest.sha384init(ctx)
#define archive_sha384_final(ctx, md)\
- __archive_crypto.sha384final(ctx, md)
+ __archive_digest.sha384final(ctx, md)
#define archive_sha384_update(ctx, buf, n)\
- __archive_crypto.sha384update(ctx, buf, n)
+ __archive_digest.sha384update(ctx, buf, n)
#if defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\
defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\
@@ -341,14 +341,14 @@ typedef unsigned char archive_sha512_ctx;
#define ARCHIVE_HAS_SHA512
#endif
#define archive_sha512_init(ctx)\
- __archive_crypto.sha512init(ctx)
+ __archive_digest.sha512init(ctx)
#define archive_sha512_final(ctx, md)\
- __archive_crypto.sha512final(ctx, md)
+ __archive_digest.sha512final(ctx, md)
#define archive_sha512_update(ctx, buf, n)\
- __archive_crypto.sha512update(ctx, buf, n)
+ __archive_digest.sha512update(ctx, buf, n)
-/* Minimal interface to crypto functionality for internal use in libarchive */
-struct archive_crypto
+/* Minimal interface to digest functionality for internal use in libarchive */
+struct archive_digest
{
/* Message Digest */
int (*md5init)(archive_md5_ctx *ctx);
@@ -371,6 +371,6 @@ struct archive_crypto
int (*sha512final)(archive_sha512_ctx *, void *);
};
-extern const struct archive_crypto __archive_crypto;
+extern const struct archive_digest __archive_digest;
#endif
diff --git a/libarchive/archive_endian.h b/libarchive/archive_endian.h
index 68123b0dd6a3..1c48563b137d 100644
--- a/libarchive/archive_endian.h
+++ b/libarchive/archive_endian.h
@@ -44,10 +44,16 @@
* - Watcom C++ in C code. (For any version?)
* - SGI MIPSpro
* - Microsoft Visual C++ 6.0 (supposedly newer versions too)
+ * - IBM VisualAge 6 (XL v6)
+ * - Sun WorkShop C (SunPro) before 5.9
*/
#if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__)
#define inline
-#elif defined(_MSC_VER)
+#elif defined(__IBMC__) && __IBMC__ < 700
+#define inline
+#elif defined(__SUNPRO_C) && __SUNPRO_C < 0x590
+#define inline
+#elif defined(_MSC_VER) || defined(__osf__)
#define inline __inline
#endif
@@ -58,7 +64,13 @@ archive_be16dec(const void *pp)
{
unsigned char const *p = (unsigned char const *)pp;
- return ((p[0] << 8) | p[1]);
+ /* Store into unsigned temporaries before left shifting, to avoid
+ promotion to signed int and then left shifting into the sign bit,
+ which is undefined behaviour. */
+ unsigned int p1 = p[1];
+ unsigned int p0 = p[0];
+
+ return ((p0 << 8) | p1);
}
static inline uint32_t
@@ -66,7 +78,15 @@ archive_be32dec(const void *pp)
{
unsigned char const *p = (unsigned char const *)pp;
- return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
+ /* Store into unsigned temporaries before left shifting, to avoid
+ promotion to signed int and then left shifting into the sign bit,
+ which is undefined behaviour. */
+ unsigned int p3 = p[3];
+ unsigned int p2 = p[2];
+ unsigned int p1 = p[1];
+ unsigned int p0 = p[0];
+
+ return ((p0 << 24) | (p1 << 16) | (p2 << 8) | p3);
}
static inline uint64_t
@@ -82,7 +102,13 @@ archive_le16dec(const void *pp)
{
unsigned char const *p = (unsigned char const *)pp;
- return ((p[1] << 8) | p[0]);
+ /* Store into unsigned temporaries before left shifting, to avoid
+ promotion to signed int and then left shifting into the sign bit,
+ which is undefined behaviour. */
+ unsigned int p1 = p[1];
+ unsigned int p0 = p[0];
+
+ return ((p1 << 8) | p0);
}
static inline uint32_t
@@ -90,7 +116,15 @@ archive_le32dec(const void *pp)
{
unsigned char const *p = (unsigned char const *)pp;
- return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
+ /* Store into unsigned temporaries before left shifting, to avoid
+ promotion to signed int and then left shifting into the sign bit,
+ which is undefined behaviour. */
+ unsigned int p3 = p[3];
+ unsigned int p2 = p[2];
+ unsigned int p1 = p[1];
+ unsigned int p0 = p[0];
+
+ return ((p3 << 24) | (p2 << 16) | (p1 << 8) | p0);
}
static inline uint64_t
diff --git a/libarchive/archive_entry.3 b/libarchive/archive_entry.3
index f77f385f2e2c..f5e22af85122 100644
--- a/libarchive/archive_entry.3
+++ b/libarchive/archive_entry.3
@@ -131,11 +131,11 @@ be discarded in favor of the new data.
.\" .Sh RETURN VALUES
.\" .Sh ERRORS
.Sh SEE ALSO
-.Xr archive 3 ,
.Xr archive_entry_acl 3 ,
.Xr archive_entry_paths 3 ,
.Xr archive_entry_perms 3 ,
.Xr archive_entry_time 3
+.Xr libarchive 3 ,
.Sh HISTORY
The
.Nm libarchive
diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c
index 386e51d473e8..4ac196608938 100644
--- a/libarchive/archive_entry.c
+++ b/libarchive/archive_entry.c
@@ -201,6 +201,9 @@ archive_entry_clone(struct archive_entry *entry)
entry2->ae_set = entry->ae_set;
archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
+ /* Copy encryption status */
+ entry2->encryption = entry->encryption;
+
/* Copy ACL data over. */
archive_acl_copy(&entry2->acl, &entry->acl);
@@ -415,6 +418,18 @@ archive_entry_gname(struct archive_entry *entry)
return (NULL);
}
+const char *
+archive_entry_gname_utf8(struct archive_entry *entry)
+{
+ const char *p;
+ if (archive_mstring_get_utf8(entry->archive, &entry->ae_gname, &p) == 0)
+ return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (NULL);
+}
+
+
const wchar_t *
archive_entry_gname_w(struct archive_entry *entry)
{
@@ -447,6 +462,20 @@ archive_entry_hardlink(struct archive_entry *entry)
return (NULL);
}
+const char *
+archive_entry_hardlink_utf8(struct archive_entry *entry)
+{
+ const char *p;
+ if ((entry->ae_set & AE_SET_HARDLINK) == 0)
+ return (NULL);
+ if (archive_mstring_get_utf8(
+ entry->archive, &entry->ae_hardlink, &p) == 0)
+ return (p);
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (NULL);
+}
+</