Browse Source

Merge topic 'update-libarchive'

6c611c6 libarchive: Restore CMake 2.6.3 as minimum version
2f5b677 libarchive: Update README-CMake.txt for new snapshot
156cb3b Merge branch 'libarchive-upstream' into update-libarchive
fd42bf1 libarchive: Set .gitattributes to allow trailing whitespace
4f4fe6e libarchive 3.0.2-r4051 (reduced)
65b6e19 libarchive: Avoid bogus conversion warning from PGI compiler
9ccaeb1 libarchive: Suppress PathScale compiler warnings
2309438 libarchive: Rename isoent_rr_move_dir parameter isoent => curent
b6ca96e libarchive: Include linux/types.h before linux/fiemap.h
f293b73 libarchive: Define _XOPEN_SOURCE=500 on HP-UX
6781a09 libarchive: Cleanup after ZLIB_WINAPI check
f15d757 libarchive: Remove hard-coded build configuration
3a9f449 libarchive: Use Apple copyfile.h API only if available
6af6b96 libarchive: Do not use MNT_NOATIME if not defined
02d5e40 libarchive: Check for 'struct statvfs' member 'f_iosize'
8b7ee30 libarchive: Do not use ST_NOATIME if not defined
...
David Cole 14 years ago
parent
commit
5a5c32e1f2
100 changed files with 3600 additions and 15268 deletions
  1. 6 5
      CMakeLists.txt
  2. 4 0
      Source/cmSystemTools.cxx
  3. 2 0
      Utilities/cmlibarchive/.gitattributes
  4. 555 205
      Utilities/cmlibarchive/CMakeLists.txt
  5. 2 2
      Utilities/cmlibarchive/COPYING
  6. 11 0
      Utilities/cmlibarchive/CTestConfig.cmake
  7. 0 30
      Utilities/cmlibarchive/INSTALL
  8. 0 595
      Utilities/cmlibarchive/Makefile.am
  9. 0 499
      Utilities/cmlibarchive/NEWS
  10. 0 137
      Utilities/cmlibarchive/README
  11. 66 0
      Utilities/cmlibarchive/README-CMake.txt
  12. 0 51
      Utilities/cmlibarchive/build/autoconf/check_stdcall_func.m4
  13. 0 20
      Utilities/cmlibarchive/build/autoconf/la_uid_t.m4
  14. 0 25
      Utilities/cmlibarchive/build/autogen.sh
  15. 7 6
      Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake
  16. 20 18
      Utilities/cmlibarchive/build/cmake/CheckFuncs.cmake
  17. 1 5
      Utilities/cmlibarchive/build/cmake/FindLZMA.cmake
  18. 543 132
      Utilities/cmlibarchive/build/cmake/config.h.in
  19. 11 0
      Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in
  20. 0 63
      Utilities/cmlibarchive/build/release.sh
  21. 418 0
      Utilities/cmlibarchive/build/utils/gen_archive_string_composition_h.sh
  22. 1 1
      Utilities/cmlibarchive/build/version
  23. 0 448
      Utilities/cmlibarchive/configure.ac
  24. 0 32
      Utilities/cmlibarchive/contrib/README
  25. 0 160
      Utilities/cmlibarchive/contrib/libarchive.1aix53.spec
  26. 0 147
      Utilities/cmlibarchive/contrib/libarchive.spec
  27. 0 154
      Utilities/cmlibarchive/contrib/libarchive_autodetect-st_lib_archive.m4
  28. 0 122
      Utilities/cmlibarchive/contrib/psota-benchmark/results.txt
  29. 0 104
      Utilities/cmlibarchive/contrib/psota-benchmark/tcp.sh
  30. 0 128
      Utilities/cmlibarchive/contrib/shar/shar.1
  31. 0 314
      Utilities/cmlibarchive/contrib/shar/shar.c
  32. 0 542
      Utilities/cmlibarchive/contrib/shar/tree.c
  33. 0 115
      Utilities/cmlibarchive/contrib/shar/tree.h
  34. 0 78
      Utilities/cmlibarchive/contrib/shar/tree_config.h
  35. 0 225
      Utilities/cmlibarchive/contrib/untar.c
  36. 0 54
      Utilities/cmlibarchive/cpio/CMakeLists.txt
  37. 0 405
      Utilities/cmlibarchive/cpio/bsdcpio.1
  38. 0 369
      Utilities/cmlibarchive/cpio/cmdline.c
  39. 0 54
      Utilities/cmlibarchive/cpio/config_freebsd.h
  40. 0 1233
      Utilities/cmlibarchive/cpio/cpio.c
  41. 0 109
      Utilities/cmlibarchive/cpio/cpio.h
  42. 0 95
      Utilities/cmlibarchive/cpio/cpio_platform.h
  43. 0 336
      Utilities/cmlibarchive/cpio/cpio_windows.c
  44. 0 72
      Utilities/cmlibarchive/cpio/cpio_windows.h
  45. 0 75
      Utilities/cmlibarchive/cpio/test/CMakeLists.txt
  46. 0 2059
      Utilities/cmlibarchive/cpio/test/main.c
  47. 0 277
      Utilities/cmlibarchive/cpio/test/test.h
  48. 0 67
      Utilities/cmlibarchive/cpio/test/test_0.c
  49. 0 173
      Utilities/cmlibarchive/cpio/test/test_basic.c
  50. 0 107
      Utilities/cmlibarchive/cpio/test/test_cmdline.c
  51. 0 294
      Utilities/cmlibarchive/cpio/test/test_format_newc.c
  52. 0 108
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat.c
  53. 0 16
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.bin.uu
  54. 0 27
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.crc.uu
  55. 0 27
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.newc.uu
  56. 0 84
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.ustar.uu
  57. 0 15
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.bin.uu
  58. 0 15
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.crc.uu
  59. 0 15
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.newc.uu
  60. 0 72
      Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.ustar.uu
  61. 0 62
      Utilities/cmlibarchive/cpio/test/test_option_C_upper.c
  62. 0 56
      Utilities/cmlibarchive/cpio/test/test_option_J_upper.c
  63. 0 96
      Utilities/cmlibarchive/cpio/test/test_option_L_upper.c
  64. 0 56
      Utilities/cmlibarchive/cpio/test/test_option_Z_upper.c
  65. 0 154
      Utilities/cmlibarchive/cpio/test/test_option_a.c
  66. 0 221
      Utilities/cmlibarchive/cpio/test/test_option_c.c
  67. 0 64
      Utilities/cmlibarchive/cpio/test/test_option_d.c
  68. 0 76
      Utilities/cmlibarchive/cpio/test/test_option_f.c
  69. 0 16
      Utilities/cmlibarchive/cpio/test/test_option_f.cpio.uu
  70. 0 81
      Utilities/cmlibarchive/cpio/test/test_option_help.c
  71. 0 56
      Utilities/cmlibarchive/cpio/test/test_option_lzma.c
  72. 0 63
      Utilities/cmlibarchive/cpio/test/test_option_m.c
  73. 0 16
      Utilities/cmlibarchive/cpio/test/test_option_m.cpio.uu
  74. 0 95
      Utilities/cmlibarchive/cpio/test/test_option_t.c
  75. 0 16
      Utilities/cmlibarchive/cpio/test/test_option_t.cpio.uu
  76. 0 5
      Utilities/cmlibarchive/cpio/test/test_option_t.stdout.uu
  77. 0 6
      Utilities/cmlibarchive/cpio/test/test_option_tv.stdout.uu
  78. 0 81
      Utilities/cmlibarchive/cpio/test/test_option_u.c
  79. 0 109
      Utilities/cmlibarchive/cpio/test/test_option_version.c
  80. 0 57
      Utilities/cmlibarchive/cpio/test/test_option_y.c
  81. 0 56
      Utilities/cmlibarchive/cpio/test/test_option_z.c
  82. 0 121
      Utilities/cmlibarchive/cpio/test/test_owner_parse.c
  83. 0 76
      Utilities/cmlibarchive/cpio/test/test_passthrough_dotdot.c
  84. 0 85
      Utilities/cmlibarchive/cpio/test/test_passthrough_reverse.c
  85. 0 243
      Utilities/cmlibarchive/cpio/test/test_pathmatch.c
  86. 0 391
      Utilities/cmlibarchive/doc/mdoc2man.awk
  87. 0 448
      Utilities/cmlibarchive/doc/mdoc2wiki.awk
  88. 0 112
      Utilities/cmlibarchive/doc/update.sh
  89. 0 12
      Utilities/cmlibarchive/examples/minitar/README
  90. 0 421
      Utilities/cmlibarchive/examples/minitar/minitar.c
  91. 0 50
      Utilities/cmlibarchive/examples/minitar/notes
  92. 0 423
      Utilities/cmlibarchive/examples/minitar/tree.c
  93. 0 78
      Utilities/cmlibarchive/examples/minitar/tree.h
  94. 0 113
      Utilities/cmlibarchive/examples/tarfilter.c
  95. 0 262
      Utilities/cmlibarchive/examples/untar.c
  96. 55 49
      Utilities/cmlibarchive/libarchive/CMakeLists.txt
  97. 450 363
      Utilities/cmlibarchive/libarchive/archive.h
  98. 1264 0
      Utilities/cmlibarchive/libarchive/archive_acl.c
  99. 87 0
      Utilities/cmlibarchive/libarchive/archive_acl_private.h
  100. 97 58
      Utilities/cmlibarchive/libarchive/archive_check_magic.c

+ 6 - 5
CMakeLists.txt

@@ -270,7 +270,7 @@ MACRO (CMAKE_BUILD_UTILITIES)
     SET(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR})
     SET(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
   ELSE(CMAKE_USE_SYSTEM_ZLIB)
-    SET(CMAKE_ZLIB_INCLUDES)
+    SET(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities)
     SET(CMAKE_ZLIB_LIBRARIES cmzlib)
     ADD_SUBDIRECTORY(Utilities/cmzlib)
     CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty")
@@ -336,13 +336,14 @@ MACRO (CMAKE_BUILD_UTILITIES)
     SET(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS})
     SET(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES})
   ELSE(CMAKE_USE_SYSTEM_LIBARCHIVE)
-    SET(HAVE_LIBZ 1)
-    SET(HAVE_ZLIB_H 1)
     SET(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES})
-    SET(ZLIB_LIBRARIES ${CMAKE_ZLIB_LIBRARIES})
     SET(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES})
-    SET(BUILD_ARCHIVE_WITHIN_CMAKE TRUE)
     ADD_DEFINITIONS(-DLIBARCHIVE_STATIC)
+    SET(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
+    SET(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
+    SET(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
+    SET(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
+    SET(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
     ADD_SUBDIRECTORY(Utilities/cmlibarchive)
     CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty")
     SET(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES})

+ 4 - 0
Source/cmSystemTools.cxx

@@ -1866,7 +1866,11 @@ long copy_data(struct archive *ar, struct archive *aw)
   long r;
   const void *buff;
   size_t size;
+#if defined(ARCHIVE_VERSION_NUMBER) && ARCHIVE_VERSION_NUMBER >= 3000000
+  __LA_INT64_T offset;
+#else
   off_t offset;
+#endif
 
   for (;;)
     {

+ 2 - 0
Utilities/cmlibarchive/.gitattributes

@@ -0,0 +1,2 @@
+*.h              whitespace=indent-with-non-tab,-blank-at-eol
+*.c              whitespace=indent-with-non-tab,-blank-at-eol

File diff suppressed because it is too large
+ 555 - 205
Utilities/cmlibarchive/CMakeLists.txt


+ 2 - 2
Utilities/cmlibarchive/COPYING

@@ -16,8 +16,8 @@ the actual statements in the files are controlling.
   a 3-clause UC Regents copyright; please read the individual source
   files for details:
    libarchive/archive_entry.c
-   libarchive/archive_read_support_compression_compress.c
-   libarchive/archive_write_set_compression_compress.c
+   libarchive/archive_read_support_filter_compress.c
+   libarchive/archive_write_set_filter_compress.c
    libarchive/mtree.5
    tar/matching.c
 

+ 11 - 0
Utilities/cmlibarchive/CTestConfig.cmake

@@ -0,0 +1,11 @@
+# TODO: This file should be moved into the build/cmake directory...
+
+# The libarchive CDash page appears at
+#   http://my.cdash.org/index.php?project=libarchive
+set(CTEST_PROJECT_NAME "libarchive")
+set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=libarchive")
+set(CTEST_DROP_SITE_CDASH TRUE)

+ 0 - 30
Utilities/cmlibarchive/INSTALL

@@ -1,30 +0,0 @@
-More complete build documentation is available on the libarchive
-Wiki:  http://libarchive.googlecode.com/
-
-On most Unix-like systems, you should be able to install libarchive,
-bsdtar, and bsdcpio using the following common steps:
-    ./configure
-    make
-    make install
-
-If you need to customize the target directories or otherwise adjust
-the build setting, use
-    ./configure --help
-to list the configure options.
-
-If you are developing libarchive and need to update the
-configure script and other build files:
-    /bin/sh build/autogen.sh
-
-To create a distribution, please use the 'distcheck' target:
-    /bin/sh build/autogen.sh && ./configure && make distcheck
-
-On non-Unix-like systems, use the "cmake" utility (available from
-http://cmake.org/) to generate suitable build files for your platform.
-Cmake requires the name of the directory containing CmakeLists.txt and
-the "generator" to use for your build environment.  For example, to
-build with Xcode on Mac OS, you can use the following command:
-    cmake -G "Xcode" ~/libarchive-download-dir/
-The result will be appropriate makefiles, solution files, or project
-files that can be used with the corresponding development tool.
-See the libarchive Wiki or the cmake site for further documentation.

+ 0 - 595
Utilities/cmlibarchive/Makefile.am

@@ -1,595 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS= foreign subdir-objects
-ACLOCAL_AMFLAGS = -I build/autoconf
-
-#
-# What to build and install
-#
-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
-
-#
-# 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)
-# Always build and test both bsdtar and bsdcpio as part of 'distcheck'
-DISTCHECK_CONFIGURE_FLAGS = --enable-bsdtar --enable-bsdcpio
-# Especially for early development, we want to be a little
-# aggressive about diagnosing build problems; this can get
-# relaxed somewhat in final shipping versions.
-AM_CFLAGS=-Wall -Werror
-PLATFORMCPPFLAGS = @PLATFORMCPPFLAGS@
-AM_CPPFLAGS=$(PLATFORMCPPFLAGS)
-
-#
-# What to include in the distribution
-#
-EXTRA_DIST= \
-    CMakeLists.txt          \
-    build/autogen.sh        \
-    build/release.sh        \
-    build/cmake         \
-    build/version           \
-    build/windows           \
-    contrib             \
-    doc             \
-    examples            \
-    $(libarchive_EXTRA_DIST)    \
-    $(libarchive_test_EXTRA_DIST)   \
-    $(bsdtar_EXTRA_DIST)        \
-    $(bsdtar_test_EXTRA_DIST)   \
-    $(bsdcpio_EXTRA_DIST)       \
-    $(bsdcpio_test_EXTRA_DIST)
-
-# a) Clean out some unneeded files and directories
-# b) Collect all documentation and format it for distribution.
-dist-hook:
-    rm -rf `find $(distdir) -name CVS -type d`
-    rm -rf `find $(distdir) -name .svn -type d`
-    rm -f `find $(distdir) -name '*~'`
-    rm -f `find $(distdir) -name '*.out'`
-    rm -f `find $(distdir) -name '*.core'`
-    -rm -f $(distdir)/*/Makefile $(distdir)/*/*/Makefile
-    cd $(distdir)/doc && /bin/sh update.sh
-
-# Verify cmake builds as part of the acceptance
-distcheck-hook:
-    mkdir $(distdir)/_build/cmtest
-    cd $(distdir)/_build/cmtest && cmake ../.. && make && make test
-    rm -rf $(distdir)/_build/cmtest
-
-#
-# Extra rules for cleanup
-#
-DISTCLEANFILES=                 \
-    libarchive/test/list.h          \
-    tar/test/list.h             \
-    cpio/test/list.h
-
-distclean-local:
-    -rm -rf .ref
-    -rm -rf autom4te.cache/
-    -rm -f *~
-    -[ -f libarchive/Makefile ] && cd libarchive && make clean
-    -[ -f libarchive/test/Makefile ] && cd libarchive/test && make clean
-    -[ -f tar/Makefile ] && cd tar && make clean
-    -[ -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
-
-#
-# Libarchive headers, source, etc.
-#
-#
-
-include_HEADERS= libarchive/archive.h libarchive/archive_entry.h
-
-libarchive_la_SOURCES=                      \
-    libarchive/archive_check_magic.c            \
-    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_private.h          \
-    libarchive/archive_entry_stat.c             \
-    libarchive/archive_entry_strmode.c          \
-    libarchive/archive_entry_xattr.c            \
-    libarchive/archive_hash.h               \
-    libarchive/archive_platform.h               \
-    libarchive/archive_private.h                \
-    libarchive/archive_read.c               \
-    libarchive/archive_read_data_into_fd.c          \
-    libarchive/archive_read_disk.c              \
-    libarchive/archive_read_disk_entry_from_file.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_support_compression_all.c   \
-    libarchive/archive_read_support_compression_bzip2.c \
-    libarchive/archive_read_support_compression_compress.c  \
-    libarchive/archive_read_support_compression_gzip.c  \
-    libarchive/archive_read_support_compression_none.c  \
-    libarchive/archive_read_support_compression_program.c   \
-    libarchive/archive_read_support_compression_xz.c    \
-    libarchive/archive_read_support_format_all.c        \
-    libarchive/archive_read_support_format_ar.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_mtree.c      \
-    libarchive/archive_read_support_format_raw.c        \
-    libarchive/archive_read_support_format_tar.c        \
-    libarchive/archive_read_support_format_zip.c        \
-    libarchive/archive_string.c             \
-    libarchive/archive_string.h             \
-    libarchive/archive_string_sprintf.c         \
-    libarchive/archive_util.c               \
-    libarchive/archive_virtual.c                \
-    libarchive/archive_write.c              \
-    libarchive/archive_write_disk.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_set_compression_bzip2.c    \
-    libarchive/archive_write_set_compression_compress.c \
-    libarchive/archive_write_set_compression_gzip.c     \
-    libarchive/archive_write_set_compression_none.c     \
-    libarchive/archive_write_set_compression_program.c  \
-    libarchive/archive_write_set_compression_xz.c       \
-    libarchive/archive_write_set_format.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_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_zip.c       \
-    libarchive/config_freebsd.h             \
-    libarchive/config_windows.h             \
-    libarchive/filter_fork.c                \
-    libarchive/filter_fork.h
-
-if INC_WINDOWS_FILES
-libarchive_la_SOURCES+=                     \
-    libarchive/archive_entry_copy_bhfi.c            \
-    libarchive/archive_windows.h                \
-    libarchive/archive_windows.c                \
-    libarchive/filter_fork_windows.c
-endif
-
-# -no-undefined marks that libarchive doesn't rely on symbols
-# defined in the application.  This is mandatory for cygwin.
-libarchive_la_LDFLAGS= -no-undefined -version-info $(ARCHIVE_LIBTOOL_VERSION)
-
-# Manpages to install
-libarchive_man_MANS=                        \
-    libarchive/archive_entry.3              \
-    libarchive/archive_read.3               \
-    libarchive/archive_read_disk.3              \
-    libarchive/archive_util.3               \
-    libarchive/archive_write.3              \
-    libarchive/archive_write_disk.3             \
-    libarchive/cpio.5                   \
-    libarchive/libarchive.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/test/list.h      \
-    libarchive/archive_windows.c    \
-    libarchive/archive_windows.h    \
-    libarchive/filter_fork_windows.c    \
-    libarchive/CMakeLists.txt   \
-    $(libarchive_man_MANS)
-
-#
-#
-# libarchive_test program
-#
-#
-libarchive_test_SOURCES=                    \
-    $(libarchive_la_SOURCES)                \
-    libarchive/test/main.c                  \
-    libarchive/test/read_open_memory.c          \
-    libarchive/test/test.h                  \
-    libarchive/test/test_acl_basic.c            \
-    libarchive/test/test_acl_freebsd.c          \
-    libarchive/test/test_acl_pax.c              \
-    libarchive/test/test_archive_api_feature.c      \
-    libarchive/test/test_bad_fd.c               \
-    libarchive/test/test_compat_bzip2.c         \
-    libarchive/test/test_compat_gtar.c          \
-    libarchive/test/test_compat_gzip.c          \
-    libarchive/test/test_compat_solaris_tar_acl.c       \
-    libarchive/test/test_compat_tar_hardlink.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_extattr_freebsd.c          \
-    libarchive/test/test_fuzz.c             \
-    libarchive/test/test_entry_strmode.c            \
-    libarchive/test/test_link_resolver.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_compress_program.c        \
-    libarchive/test/test_read_data_large.c          \
-    libarchive/test/test_read_disk.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_format_ar.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_xz.c      \
-    libarchive/test/test_read_format_cpio_odc.c     \
-    libarchive/test/test_read_format_cpio_svr4_gzip.c   \
-    libarchive/test/test_read_format_cpio_svr4c_Z.c     \
-    libarchive/test/test_read_format_empty.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_gz.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_isorr_bz2.c        \
-    libarchive/test/test_read_format_isorr_new_bz2.c    \
-    libarchive/test/test_read_format_isozisofs_bz2.c    \
-    libarchive/test/test_read_format_mtree.c        \
-    libarchive/test/test_read_format_pax_bz2.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_tbz.c          \
-    libarchive/test/test_read_format_tgz.c          \
-    libarchive/test/test_read_format_txz.c          \
-    libarchive/test/test_read_format_tz.c           \
-    libarchive/test/test_read_format_zip.c          \
-    libarchive/test/test_read_large.c           \
-    libarchive/test/test_read_pax_truncated.c       \
-    libarchive/test/test_read_position.c            \
-    libarchive/test/test_read_truncated.c           \
-    libarchive/test/test_tar_filenames.c            \
-    libarchive/test/test_tar_large.c            \
-    libarchive/test/test_ustar_filenames.c          \
-    libarchive/test/test_write_compress.c           \
-    libarchive/test/test_write_compress_bzip2.c     \
-    libarchive/test/test_write_compress_gzip.c      \
-    libarchive/test/test_write_compress_lzma.c      \
-    libarchive/test/test_write_compress_program.c       \
-    libarchive/test/test_write_compress_xz.c        \
-    libarchive/test/test_write_disk.c           \
-    libarchive/test/test_write_disk_failures.c      \
-    libarchive/test/test_write_disk_hardlink.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_format_ar.c          \
-    libarchive/test/test_write_format_cpio.c        \
-    libarchive/test/test_write_format_cpio_empty.c      \
-    libarchive/test/test_write_format_cpio_odc.c        \
-    libarchive/test/test_write_format_cpio_newc.c       \
-    libarchive/test/test_write_format_mtree.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_ustar.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_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_builddir)/libarchive/test -DLIBARCHIVE_STATIC $(PLATFORMCPPFLAGS)
-
-# The "list.h" file just lists all of the tests defined in all of the sources.
-# 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
-
-libarchive_TESTS_ENVIRONMENT= LIBARCHIVE_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/libarchive/test
-
-libarchive_test_EXTRA_DIST=\
-    libarchive/test/test_compat_bzip2_1.tbz.uu          \
-    libarchive/test/test_compat_bzip2_2.tbz.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_solaris_tar_acl.tar.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_fuzz_1.iso.uu              \
-    libarchive/test/test_pax_filename_encoding.tar.uu       \
-    libarchive/test/test_read_format_cpio_bin_be.cpio.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_gz.iso.gz.uu       \
-    libarchive/test/test_read_format_isojoliet_bz2.iso.bz2.uu   \
-    libarchive/test/test_read_format_isojoliet_long.iso.bz2.uu  \
-    libarchive/test/test_read_format_isojoliet_rr.iso.bz2.uu    \
-    libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu       \
-    libarchive/test/test_read_format_isorr_new_bz2.iso.bz2.uu   \
-    libarchive/test/test_read_format_isozisofs_bz2.iso.bz2.uu   \
-    libarchive/test/test_read_format_raw.data.Z.uu          \
-    libarchive/test/test_read_format_raw.data.uu            \
-    libarchive/test/test_read_format_iso_gz.iso.gz.uu       \
-    libarchive/test/test_read_format_tar_empty_filename.tar.uu  \
-    libarchive/test/test_read_format_zip.zip.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/matching.c        \
-    libarchive_fe/matching.h        \
-    libarchive_fe/pathmatch.c       \
-    libarchive_fe/pathmatch.h
-
-#
-#
-# bsdtar source, docs, etc.
-#
-#
-
-bsdtar_SOURCES=             \
-        tar/bsdtar.c        \
-        tar/bsdtar.h        \
-        tar/bsdtar_platform.h   \
-        tar/cmdline.c       \
-        tar/getdate.c       \
-        tar/read.c      \
-        tar/subst.c     \
-        tar/tree.c      \
-        tar/tree.h      \
-        tar/util.c      \
-        tar/write.c
-
-if INC_WINDOWS_FILES
-bsdtar_SOURCES+=            \
-        tar/bsdtar_windows.h    \
-        tar/bsdtar_windows.c
-endif
-
-bsdtar_DEPENDENCIES= libarchive.la libarchive_fe.la
-
-if STATIC_BSDTAR
-bsdtar_ldstatic= -static
-bsdtar_ccstatic= -DLIBARCHIVE_STATIC
-else
-bsdtar_ldstatic=
-bsdtar_ccstatic=
-endif
-
-bsdtar_LDADD= libarchive.la libarchive_fe.la
-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  \
-    tar/config_freebsd.h    \
-    tar/test/list.h
-
-
-if BUILD_BSDTAR
-bsdtar_man_MANS= tar/bsdtar.1
-bsdtar_programs= bsdtar
-else
-bsdtar_man_MANS=
-bsdtar_programs=
-endif
-
-#
-# bsdtar_test
-#
-
-bsdtar_test_SOURCES=                        \
-    tar/getdate.c                       \
-    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_getdate.c                 \
-    tar/test/test_help.c                    \
-    tar/test/test_option_T_upper.c              \
-    tar/test/test_option_q.c                \
-    tar/test/test_option_r.c                \
-    tar/test/test_option_s.c                \
-    tar/test/test_patterns.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
-
-# For now, bsdtar_test uses Windows shims from tar/bsdtar_windows.*
-if INC_WINDOWS_FILES
-bsdtar_test_SOURCES+=           \
-        tar/bsdtar_windows.h    \
-        tar/bsdtar_windows.c
-endif
-
-bsdtar_test_CPPFLAGS=\
-    -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
-    -I$(top_srcdir)/tar -I$(top_builddir)/tar/test \
-    $(PLATFORMCPPFLAGS)
-
-tar/test/list.h: Makefile
-    cat $(top_srcdir)/tar/test/test_*.c | grep DEFINE_TEST > tar/test/list.h
-
-if BUILD_BSDTAR
-bsdtar_test_programs= bsdtar_test
-bsdtar_TESTS_ENVIRONMENT= BSDTAR=`cd $(top_builddir);/bin/pwd`/bsdtar$(EXEEXT) BSDTAR_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/tar/test
-else
-bsdtar_test_programs=
-bsdtar_TESTS_ENVIRONMENT=
-endif
-
-bsdtar_test_EXTRA_DIST=         \
-    tar/test/test_patterns_2.tar.uu \
-    tar/test/test_patterns_3.tar.uu \
-    tar/test/test_patterns_4.tar.uu \
-    tar/test/CMakeLists.txt
-
-
-#
-#
-# bsdcpio source, docs, etc.
-#
-#
-
-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 \
-        cpio/cpio_windows.c
-endif
-
-bsdcpio_DEPENDENCIES = libarchive.la libarchive_fe.la
-
-
-if STATIC_BSDCPIO
-bsdcpio_ldstatic= -static
-bsdcpio_ccstatic= -DLIBARCHIVE_STATIC
-else
-bsdcpio_ldstatic=
-bsdcpio_ccstatic=
-endif
-
-bsdcpio_LDADD= libarchive_fe.la libarchive.la
-bsdcpio_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdcpio_ccstatic) $(PLATFORMCPPFLAGS)
-bsdcpio_LDFLAGS= $(bsdcpio_ldstatic)
-
-bsdcpio_EXTRA_DIST=     \
-    cpio/test/list.h    \
-    cpio/bsdcpio.1      \
-    cpio/cpio_windows.h \
-    cpio/cpio_windows.c \
-    cpio/CMakeLists.txt \
-    cpio/config_freebsd.h
-
-
-if BUILD_BSDCPIO
-# Manpages to install
-bsdcpio_man_MANS= cpio/bsdcpio.1
-bsdcpio_programs= bsdcpio
-else
-bsdcpio_man_MANS=
-bsdcpio_programs=
-endif
-
-#
-# bsdcpio_test
-#
-
-bsdcpio_test_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_format_newc.c                \
-    cpio/test/test_gcpio_compat.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_c.c               \
-    cpio/test/test_option_d.c               \
-    cpio/test/test_option_f.c               \
-    cpio/test/test_option_help.c                \
-    cpio/test/test_option_l.c               \
-    cpio/test/test_option_lzma.c                \
-    cpio/test/test_option_m.c               \
-    cpio/test/test_option_t.c               \
-    cpio/test/test_option_u.c               \
-    cpio/test/test_option_version.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            \
-    cpio/test/test_pathmatch.c
-
-bsdcpio_test_CPPFLAGS= \
-    -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
-    -I$(top_srcdir)/cpio -I$(top_builddir)/cpio/test \
-    $(PLATFORMCPPFLAGS)
-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
-
-if BUILD_BSDCPIO
-bsdcpio_test_programs= bsdcpio_test
-bsdcpio_TESTS_ENVIRONMENT= BSDCPIO=`cd $(top_builddir);/bin/pwd`/bsdcpio$(EXEEXT) BSDCPIO_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/cpio/test
-else
-bsdcpio_test_programs=
-bsdcpio_TESTS_ENVIRONMENT=
-endif
-
-bsdcpio_test_EXTRA_DIST=            \
-    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_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/CMakeLists.txt

+ 0 - 499
Utilities/cmlibarchive/NEWS

@@ -1,499 +0,0 @@
-
-Apr 01, 2009: libarchive 2.6.990a released
-Apr 01, 2009: Use command-line gunzip, bunzip2, unxz, unlzma for
-    decompression if the library is built without suitable
-    libraries.  The setup functions return ARCHIVE_WARN
-    in this case so clients can adapt if necessary.
-Apr 01, 2009: Use getpw*_r and getgr*_r functions for thread-safety.
-Mar 24, 2009: Add archive_read_next_header2(), which is up to 25%
-    more efficient for some clients; from Brian Harring.
-Mar 22, 2009: PDF versions of manpages are now included in the distribution.
-Mar, 2009: Major work to improve Cygwin build by Charles Wilson.
-Feb/Mar, 2009: Major work on cmake build support, mostly by Michihiro NAKAJIMA.
-Feb/Mar, 2009: Major work on Visual Studio support by Michihiro NAKAJIMA.
-    All tests now pass.
-Feb 25, 2009: Fix Debian Bug #516577
-Feb 21, 2009: Yacc is no longer needed to build; date parser rewritten in C.
-Jan/Feb, 2009: Mtree work by Michihiro.
-Feb, 2009: Joliet support by Andreas Henriksson.
-Jan/Feb, 2009: New options framework by Michihiro.
-Feb, 2009: High-res timestamps on Tru64, AIX, and GNU Hurd, by Björn Jacke.
-Jan 18, 2009: Extended attributes work on FreeBSD and Linux now with pax format.
-Jan 07, 2009: New archive_read_disk_entry_from_file() knows about ACLs,
-    extended attributes, etc so that bsdtar and bsdcpio don't require
-    such system-specific knowledge.
-Jan 03, 2009: Read filter system extensively refactored.  In particular,
-    read filter pipelines are now built out automatically and individual
-    filters should be much easier to implement.  Documentation on the
-    Googlecode Wiki explains how to implement new filters.
-Dec 28, 2008: Many Windows/Visual Studio fixes from Michihiro NAKAJIMA.
-
-Dec 28, 2008: Main libarchive development moved from FreeBSD Perforce
-    server to Google Code.  This should make it easier for more
-    people to participate in libarchive development.
-
-Dec 28, 2008: libarchive 2.6.0 released
-Dec 25, 2008: libarchive 2.5.905a released
-Dec 10, 2008: libarchive 2.5.904a released
-Dec 04, 2008: libarchive 2.5.903a released
-Nov 09, 2008: libarchive 2.5.902a released
-Nov 08, 2008: libarchive 2.5.901a released
-Nov 08, 2008: Start of pre-release testing for libarchive 2.6
-
-Nov 07, 2008: Read filter refactor: The decompression routines just
-    consume and produce arbitrarily-sized blocks.  The reblocking
-    from read_support_compression_none() has been pulled into the
-    read core.  Also, the decompression bid now makes multiple
-    passes and stacks read filters.
-Oct 21, 2008: bsdcpio: New command-line parser.
-Oct 19, 2008: Internal read_ahead change: short reads are now an error
-Oct 06, 2008: bsdtar: option parser no longer uses getopt_long(),
-    gives consistent option parsing on all platforms.
-Sep 19, 2008: Jaakko Heinonen: shar utility built on libarchive
-Sep 17, 2008: Pedro Giffuni: birthtime support
-Sep 17, 2008: Miklos Vajna: lzma reader and test.  Note:  I still have
-    some concerns about the auto-detection (LZMA file format
-    doesn't support auto-detection well), so this is not yet
-    enabled under archive_read_support_compression_all().  For
-    now, you must call archive_read_support_compression_lzma() if
-    you want LZMA read support.
-Sep 11, 2008: Ivailo Petrov: Many fixes to Windows build, new solution files
-Jul 26, 2008: archive_entry now tracks which values have not been set.
-    This helps zip extraction (file size is often "unknown") and
-    time restores (tar usually doesn't know atime).
-Jul 26, 2008: Joerg Sonnenberger: Performance improvements to shar writer
-Jul 25, 2008: Joerg Sonnenberger: mtree write support
-
-Jul 02, 2008: libarchive 2.5.5 released
-
-Jul 02, 2008: libarchive 2.5.5b released
-Jul 01, 2008: bsdcpio is being used by enough people, we can call it 1.0.0 now
-Jun 20, 2008: bsdcpio: If a -l link fails with EXDEV, copy the file instead
-Jun 19, 2008: bsdcpio: additional long options for better GNU cpio compat
-Jun 15, 2008: Many small portability and bugfixes since 2.5.4b.
-
-May 25, 2008: libarchive 2.5.4b released
-May 21, 2008: Joerg Sonnenberger: fix bsdtar hardlink handling for newc format
-
-May 21, 2008: More progress on Windows building.  Thanks to "Scott"
-        for the Windows makefiles, thanks to Kees Zeelenberg for
-        code contributions.
-
-May 21, 2008: Fix a number of non-exploitable integer and buffer overflows,
-        thanks to David Remahl at Apple for pointing these out.
-
-May 21, 2008: Colin Percival: SIGINFO or SIGUSR1 to bsdtar prints progress info
-
-May 16, 2008: bsdtar's test harness no longer depends on file ordering.
-        This was causing spurious test failures on a lot of systems.
-        Thanks to Bernhard R. Link for the diagnosis.
-
-May 14, 2008: Joerg Sonnenberger: -s substitution support for bsdtar
-
-May 13, 2008: Joerg Sonnenberger: Many mtree improvements
-
-May 11, 2008: Joerg Sonnenberger: fix hardlink extraction when
-    hardlinks have different permissions from original file
-
-April 30, 2008: Primary libarchive work has been moved into the FreeBSD
-    project's Perforce repository:  http://perforce.freebsd.org/
-    The libarchive project can be browsed at
-        //depot/user/kientzle/libarchive-portable
-        Direct link: http://preview.tinyurl.com/46mdgr
-
-May 04, 2008: libarchive 2.5.3b released
-    * libarchive: Several fixes to link resolver to address bsdcpio crashes
-    * bsdcpio: -p hardlink handling fixes
-    * tar/pax: Ensure ustar dirnames end in '/'; be more careful about
-      measuring filenames when deciding what pathname fields to use
-    * libarchive: Mark which entry strings are set; be accurate about
-      distinguishing empty strings ("") from unset ones (NULL)
-    * tar: Don't crash reading entries with empty filenames
-    * libarchive_test, bsdtar_test, bsdcpio_test:  Better detaults:
-      run all tests, delete temp dirs, summarize repeated failures
-    * -no-undefined to libtool for Cygwin
-    * libarchive_test: Skip large file tests on systems with 32-bit off_t
-    * iso9660: Don't bother trying to find the body of an empty file;
-      this works around strange behavior from some ISO9660 writers
-    * tar: allow -r -T to be used together
-    * tar: allow --format with -r or -u
-    * libarchive: Don't build archive.h
-
-May 04, 2008: Simplified building: archive.h is no longer constructed
-    This may require additional #if conditionals on some platforms.
-
-Mar 30, 2008: libarchive 2.5.1b released
-
-Mar 15, 2008: libarchive 2.5.0b released
-Mar 15, 2008: bsdcpio now seems to correctly write hardlinks into newc,
-    ustar, and old cpio archives.  Just a little more testing before
-    bsdcpio 1.0 becomes a reality.
-Mar 15, 2008: I think the new linkify() interface is finally handling
-    all known hardlink strategies.
-Mar 15, 2008: Mtree read fixes from Joerg Sonnenberger.
-Mar 15, 2008: Many new bsdtar and bsdcpio options from Joerg Sonnenberger.
-Mar 15, 2008: test harnesses no longer require uudecode; they
-    now have built-in decoding logic that decodes the reference
-    files as they are needed.
-
-Mar 14, 2008: libarchive 2.4.14 released; identical to 2.4.13 except for
-    a point fix for gname/uname mixup in pax format that was introduced
-    with the UTF-8 fixes.
-
-Feb 26, 2008: libarchive 2.4.13 released
-Feb 25, 2008: Handle path, linkname, gname, or uname that can't be converted
-    to/from UTF-8.  Implement "hdrcharset" attribute from SUS-2008.
-Feb 25, 2008: Fix name clash on NetBSD.
-Feb 18, 2008: Fix writing empty 'ar' archives, per Kai Wang
-Feb 18, 2008: [bsdtar] Permit appending on block devices.
-Feb 09, 2008: New "linkify" resolver to help with newc hardlink writing;
-    bsdcpio still needs to be converted to use this.
-Feb 02, 2008: Windows compatibility fixes from Ivailo Petrov, Kees Zeelenberg
-Jan 30, 2008: Ignore hardlink size for non-POSIX tar archives.
-
-Jan 22, 2008: libarchive 2.4.12 released
-Jan 22, 2008: Fix bad padding when writing symlinks to newc cpio archives.
-Jan 22, 2008: Verify bsdcpio_test by getting it to work against GNU cpio 2.9.
-    bsdcpio_test complains about missing options (-y and -z), format
-    of informational messages (--version, --help), and a minor formatting
-    issue in odc format output.  After this update, bsdcpio_test uncovered
-    several more cosmetic issues in bsdcpio, all now fixed.
-Jan 22, 2008: Experimental support for self-extracting Zip archives.
-Jan 22, 2008: Extend hardlink restore strategy to work correctly with
-    hardlinks extracted from newc cpio files.  (Which store the body
-    only with the last occurrence of a link.)
-
-Dec 30, 2007: libarchive 2.4.11 released
-Dec 30, 2007: Fixed a compile error in bsdcpio on some systems.
-
-Dec 29, 2007: libarchive 2.4.10 released
-Dec 29, 2007: bsdcpio 0.9.0 is ready for wider use.
-Dec 29, 2007: Completed initial test harness for bsdcpio.
-
-Dec 22, 2007: libarchive 2.4.9 released
-Dec 22, 2007: Implement the remaining options for bsdcpio:  -a, -q, -L, -f,
-    pattern selection for -i and -it.
-
-Dec 13, 2007: libarchive 2.4.8 released
-Dec 13, 2007: gzip and bzip2 compression now handle zero-byte writes correctly,
-    Thanks to Damien Golding for bringing this to my attention.
-
-Dec 12, 2007: libarchive 2.4.7 released
-
-Dec 10, 2007: libarchive 2.4.6 released
-Dec 09, 2007: tar/test/test_copy.c verifies "tar -c | tar -x" copy pipeline
-Dec 07, 2007: Fix a couple of minor memory leaks.
-
-Dec 04, 2007: libarchive 2.4.5 released
-Dec 04, 2007: Fix cpio/test/test_write_odc by setting the umask first.
-
-Dec 03, 2007: libarchive 2.4.4 released
-Dec 03, 2007: New configure options --disable-xattr and --disable-acl,
-    thanks to Samuli Suominen.
-
-Dec 03, 2007: libarchive 2.4.3 released
-Dec 03, 2007: Thanks to Lapo Luchini for sending me a ZIP file that
-    libarchive couldn't handle.  Fixed a bug in handling of
-    "length at end" flags in ZIP files.
-Dec 03, 2007: Fixed bsdcpio -help, bsdtar -help tests.
-Dec 02, 2007: First cut at real bsdtar test harness.
-
-Dec 02, 2007: libarchive 2.4.2 released
-
-Dec 02, 2007: libarchive 2.4.1 released
-Dec 02, 2007: Minor fixes, rough cut of mdoc-to-man conversion for
-    man pages.
-
-Oct 30, 2007: libarchive 2.4.0 released
-Oct 30, 2007: Minor compile fix thanks to Joerg Schilling.
-Oct 30, 2007: Only run the format auction once at the beginning of the
-    archive.  This is simpler and supports better error recovery.
-Oct 29, 2007: Test support for very large entries in tar archives:
-    libarchive_test now exercises entries from 2GB up to 1TB.
-
-Oct 27, 2007: libarchive 2.3.5 released
-Oct 27, 2007: Correct some unnecessary internal data copying in the
-    "compression none" reader and writer; this reduces user time
-    by up to 2/3 in some tests.  (Thanks to Jan Psota for
-    publishing his performance test results to GNU tar's bug-tar
-    mailing list; those results pointed me towards this problem.)
-Oct 27, 2007: Fix for skipping archive entries that are exactly
-    a multiple of 4G on 32-bit platforms.
-Oct 25, 2007: Fix for reading very large (>8G) tar archives; this was
-    broken when I put in support for new GNU tar sparse formats.
-Oct 20, 2007: Initial work on new pattern-matching code for cpio; I
-    hope this eventually replaces the code currently in bsdtar.
-
-Oct 08, 2007: libarchive 2.3.4 released
-Oct 05, 2007: Continuing work on bsdcpio test suite.
-Oct 05, 2007: New cpio.5 manpage, updates to "History" of bsdcpio.1 and
-    bsdtar.1 manpages.
-Oct 05, 2007: Fix zip reader to immediately return EOF if you try
-    to read body of non-regular file.  In particular, this fixes
-    bsdtar extraction of zip archives.
-
-Sep 30, 2007: libarchive 2.3.3 released
-Sep 26, 2007: Rework Makefile.am so that the enable/disable options
-    actually do the right things.
-Sep 26, 2007: cpio-odc and cpio-newc archives no longer write bodies
-    for non-regular files.
-Sep 26, 2007: Test harness for bsdcpio is in place, needs more tests written.
-    This is much nicer than the ragtag collection of test scripts
-    that bsdtar has.
-
-Sep 20, 2007: libarchive 2.3.2 released
-Sep 20, 2007: libarchive 2.3.1 broke bsdtar because the archive_write_data()
-    fix was implemented incorrectly.
-
-Sep 16, 2007: libarchive 2.3.1 released
-Sep 16, 2007: Many fixes to bsdcpio 0.3:  handle hardlinks with -p, recognize
-    block size on writing, fix a couple of segfaults.
-Sep 16, 2007: Fixed return value from archive_write_data() when used
-    with archive_write_disk() to match the documentation and other
-    instances of this same function.
-Sep 15, 2007: Add archive_entry_link_resolver, archive_entry_strmode
-
-Sep 11, 2007: libarchive 2.2.8 released
-Sep 09, 2007: bsdcpio 0.2 supports most (not yet all) of the old POSIX spec.
-
-Sep 01, 2007: libarchive 2.2.7 released
-Aug 31, 2007: Support for reading mtree files, including an mtree.5 manpage
-    (A little experimental still.)
-Aug 18, 2007: Read gtar 1.17 --posix --sparse entries.
-Aug 13, 2007: Refined suid/sgid restore handling; it is no longer
-    an error if suid/sgid bits are dropped when you request
-    perm restore but don't request owner restore.
-Aug 06, 2007: Use --enable-bsdcpio if you want to try bsdcpio
-
-Aug 05, 2007: libarchive 2.2.6 released
-Aug 05, 2007: New configure option --disable-bsdtar, thanks to Joerg
-    Sonnenberger.
-Aug 05, 2007: Several bug fixes from FreeBSD CVS repo.
-
-Jul 13, 2007: libarchive 2.2.5 released
-
-Jul 12, 2007: libarchive 2.2.4 released
-Jul 12, 2007: Thanks to Colin Percival's help in diagnosing and
-    fixing several critical security bugs.  Details available at
-    http://security.freebsd.org/advisories/FreeBSD-SA-07:05.libarchive.asc
-
-May 26, 2007: libarchive 2.2.3 released
-May 26, 2007: Fix memory leaks in ZIP reader and shar writer, add some
-    missing system headers to archive_entry.h, dead code cleanup
-    from Colin Percival, more tests for gzip/bzip2, fix an
-    EOF anomaly in bzip2 decompression.
-
-May 12, 2007: libarchive 2.2.2 released
-May 12, 2007: Fix archive_write_disk permission restore by cloning
-    entry passed into write_header so that permission info is
-    still available at finish_entry time.  (archive_read_extract()
-    worked okay because it held onto the passed-in entry, but
-    direct consumers of archive_write_disk would break).  This
-    required fixing archive_entry_clone(), which now works and has
-    a reasonably complete test case.
-May 10, 2007: Skeletal cpio implementation.
-
-May 06, 2007: libarchive 2.2.1 released
-May 06, 2007: Flesh out a lot more of test_entry.c so as to catch
-    problems such as the device node breakage before releasing <sigh>.
-May 05, 2007: Fix a bad bug introduced in 2.1.9 that broke device
-    node entries in tar archives.
-May 03, 2007: Move 'struct stat' out of archive_entry core as well.
-    This removes some portability headaches and fixes a bunch
-    of corner cases that arise when manipulating archives on
-    dissimilar systems.
-
-Apr 30, 2007: libarchive 2.1.10 released
-Apr 31, 2007: Minor code cleanup.
-
-Apr 24, 2007: libarchive 2.1.9 released
-Apr 24, 2007: Fix some recently-introduced problems with libraries
-    (Just let automake handle it and it all works much better.)
-    Finish isolating major()/minor()/makedev() in archive_entry.c.
-
-Apr 23, 2007: libarchive 2.1.8 released
-Apr 23, 2007: Minor fixes found from building on MacOS X
-
-Apr 22, 2007: libarchive 2.1.7 released
-Apr 22, 2007: Eliminated all uses of 'struct stat' from the
-    format readers/writers.  This should improve portability;
-    'struct stat' is now only used in archive_entry and in
-    code that actually touches the disk.
-
-Apr 17, 2007: libarchive 2.1.6 released
-    Libarchive now compiles and passes all tests on Interix.
-
-Apr 16, 2007: libarchive 2.1.5 released
-
-Apr 15, 2007: libarchive 2.1b2 released
-Apr 15, 2007: New libarchive_internals.3 documentation of internal APIs.
-    Not complete, but should prove helpful.
-Apr 15, 2007: Experimental "read_compress_program" and "write_compress_program"
-    for using libarchive with external compression.  Not yet
-    well tested, and likely has portability issues.  Feedback
-    appreciated.
-
-Apr 14, 2007: libarchive 2.0.31 released
-Apr 14, 2007: More fixes for Interix, more 'ar' work
-
-Apr 14, 2007: libarchive 2.0.30 released
-Apr 13, 2007: libarchive now enforces trailing '/' on dirs
-    written to tar archives
-
-Apr 11, 2007: libarchive 2.0.29 released
-Apr 11, 2007: Make it easier to statically configure for different platforms.
-Apr 11, 2007: Updated config.guess, config.sub, libtool
-
-Apr 06, 2007: libarchive 2.0.28 released
-Apr 06, 2007: 'ar' format read/write support thanks to Kai Wang.
-
-Apr 01, 2007: libarchive 2.0.27 released
-Mar 31, 2007: Several minor fixes from Colin Percival and Joerg Sonnenberger.
-
-Mar 12, 2007: libarchive 2.0.25 released
-Mar 12, 2007: Fix broken --unlink flag.
-
-Mar 11, 2007: libarchive 2.0.24 released
-Mar 10, 2007: Correct an ACL blunder that causes any ACL with an entry
-    that refers to a non-existent user or group to not be restored correctly.
-    The fix both makes the parser more tolerant (so that archives created
-    with the buggy ACLs can be read now) and corrects the ACL formatter.
-Mar 10, 2007: More work on test portability to Linux.
-
-Mar 10, 2007: libarchive 2.0.22 released
-Mar 10, 2007: Header cleanups; added linux/fs.h, removed
-    some unnecessary headers, added #include guards in bsdtar.
-    If you see any obvious compile failures from this, let me know.
-Mar 10, 2007: Work on bsdtar test scripts: not yet robust enough
-    to enable as part of "make check", but getting better.
-Mar 10, 2007: libarchive now returns ARCHIVE_FAILED when
-    a header write fails in a way that only affects this item.
-    Less bad than ARCHIVE_FATAL, but worse than ARCHIVE_WARN.
-
-Mar 07, 2007: libarchive 2.0.21 released
-Mar 07, 2007: Add some ACL tests (only for the system-independent
-    portion of the ACL support for now).
-Mar 07, 2007: tar's ability to read ACLs off disk got
-    turned off for FreeBSD; re-enable it.  (ACL restores and
-    libarchive support for storing/reading ACLs from pax
-    archives was unaffected.)
-
-Mar 02, 2007: libarchive 2.0.20 released
-Mar 2, 2007:  It's not perfect, but it's pretty good.
-    Libarchive 2.0 is officially out of beta.
-
-Feb 28, 2007: libarchive 2.0b17 released
-Feb 27, 2007: Make the GID restore checks more robust by checking
-    whether the current user has too few or too many privileges.
-
-Feb 26, 2007: libarchive 2.0b15 released
-Feb 26, 2007: Don't lose symlinks when extracting from ISOs.
-    Thanks to Diego "Flameeyes" Pettenò for telling me about the
-    broken testcase on Gentoo that (finally!) led me to the cause
-    of this long-standing bug.
-
-Feb 26, 2007: libarchive 2.0b14 released
-Feb 26, 2007: Fix a broken test on platforms that lack lchmod().
-
-Feb 25, 2007: libarchive 2.0b13 released
-Feb 25, 2007: Empty archives were being written as empty files,
-    without a proper end-of-archive marker.  Fixed.
-
-Feb 23, 2007: libarchive 2.0b12 released
-Feb 22, 2007: Basic security checks added: _EXTRACT_SECURE_NODOTDOT
-    and _EXTRACT_SECURE_SYMLINK.  These checks used to be in bsdtar,
-    but they belong down in libarchive where they can be used by
-    other tools and where they can be better optimized.
-
-Feb 11, 2007: libarchive 2.0b11 released
-Feb 10, 2007: Fixed a bunch of errors in libarchive's handling
-    of EXTRACT_PERM and EXTRACT_OWNER, especially relating
-    to SUID and SGID bits.
-
-Jan 31, 2007: libarchive 2.0b9 released
-Jan 31, 2007: Added read support for "empty" archives as a
-    distinct archive format.  Bsdtar uses this to handle, e.g.,
-    "touch foo.tar; tar -rf foo.tar"
-
-Jan 22, 2007: libarchive 2.0b6 released
-Jan 22, 2007: archive_write_disk API is now in place.  It provides
-    a finer-grained interface than archive_read_extract.  In particular,
-    you can use it to create objects on disk without having an archive
-    around (just feed it archive_entry objects describing what you
-    want to create), you can override the uname/gname-to-uid/gid lookups
-    (minitar uses this to avoid getpwXXX() and getgrXXX() bloat).
-
-Jan 09, 2007: libarchive 2.0a3 released
-Jan 9, 2007: archive_extract is now much better; it handles the
-    most common cases with a minimal number of system calls.
-    Some features still need a lot of testing, especially corner
-    cases involving objects that already exist on disk.   I expect
-    the next round of API overhaul will simplify building test cases.
-Jan 9, 2007: a number of fixes thanks to Colin Percival, especially
-    corrections to the skip() framework and handling of large files.
-Jan 9, 2007: Fixes for large ISOs.  The code should correctly handle
-    very large ISOs with entries up to 4G.   Thanks to Robert Sciuk
-    for pointing out these issues.
-
-Sep 05, 2006: libarchive 1.3.1 released
-Sep 5, 2006: Bump version to 1.3 for new I/O wrappers.
-Sep 4, 2006: New memory and FILE read/write wrappers.
-Sep 4, 2006: libarchive test harness is now minimally functional;
-    it's located a few minor bugs in error-handling logic
-
-Aug 17, 2006: libarchive 1.2.54 released
-Aug 17, 2006: Outline ABI changes for libarchive 2.0; these
-   are protected behind #ifdef's until I think I've found everything
-   that needs to change.
-Aug 17, 2006: Fix error-handling in archive_read/write_close()
-   They weren't returning any errors before.
-Aug 17, 2006: Fix recursive-add logic to not trigger if it's not set
-   Fixes a bug adding files when writing archive to pipe or when
-   using archive_write_open() directly.
-Jul 2006: New "skip" handling improves performance extracting
-   single files from large uncompressed archives.
-
-Mar 21, 2006: 1.2.52 released
-Mar 21, 2006: Fix -p on platforms that don't have platform-specific
-   extended attribute code.
-Mar 20, 2006: Add NEWS file; fill in some older history from other
-   files.  I'll try to keep this file up-to-date from now on.
-
-OLDER NEWS SUMMARIES
-
-Mar 19, 2006: libarchive 1.2.51 released
-Mar 18, 2006: Many fixes to extended attribute support, including a redesign
-   of the storage format to simplify debugging.
-Mar 12, 2006: Remove 'tp' support; it was a fun idea, but not worth
-   spending much time on.
-Mar 11, 2006: Incorporated Jaakko Heinonen's still-experimental support
-   for extended attributes (Currently Linux-only.).
-Mar 11, 2006: Reorganized distribution package: There is now one tar.gz
-   file that builds both libarchive and bsdtar.
-Feb 13, 2006: Minor bug fixes: correctly read cpio device entries, write
-   Pax attribute entry names.
-Nov 7, 2005: Experimental 'tp' format support in libarchive.  Feedback
-   appreciated; this is not enabled by archive_read_support_format_all()
-   yet as I'm not quite content with the format detection heuristics.
-Nov 7, 2005: Some more portability improvements thanks to Darin Broady,
-   minor bugfixes.
-Oct 12, 2005: Use GNU libtool to build shared libraries on many systems.
-Aug 9, 2005: Correctly detect that MacOS X does not have POSIX ACLs.
-Apr 17, 2005: Kees Zeelenberg has ported libarchive and bsdtar to Windows:
-   http://gnuwin32.sourceforge.net/
-Apr 11, 2005: Extended Zip/Zip64 support thanks to Dan Nelson.  -L/-h
-   fix from Jaakko Heinonen.
-Mar 12, 2005: archive_read_extract can now handle very long
-   pathnames (I've tested with pathnames up to 1MB).
-Mar 12, 2005: Marcus Geiger has written an article about libarchive
-   http://xsnil.antbear.org/2005/02/05/archive-mit-libarchive-verarbeiten/
-   including examples of using it from Objective-C.  His MoinX
-   http://moinx.antbear.org/ desktop Wiki uses
-   libarchive for archiving and restoring Wiki pages.
-Jan 22, 2005: Preliminary ZIP extraction support,
-    new directory-walking code for bsdtar.
-Jan 16, 2005: ISO9660 extraction code added; manpage corrections.
-May 22, 2004: Many gtar-compatible long options have been added; almost
-    all FreeBSD ports extract correctly with bsdtar.
-May 18, 2004: bsdtar can read Solaris, HP-UX, Unixware, star, gtar,
-    and pdtar archives.

+ 0 - 137
Utilities/cmlibarchive/README

@@ -1,137 +0,0 @@
-README for libarchive bundle.
-
-Questions?  Issues?
-   * http://libarchive.googlecode.com/ is the home for ongoing
-     libarchive development, including issue tracker, additional
-     documentation, and links to the libarchive mailing lists.
-
-This distribution bundle includes the following components:
-   * libarchive: a library for reading and writing streaming archives
-   * tar: the 'bsdtar' program is a full-featured 'tar'
-          replacement built on libarchive
-   * cpio: the 'bsdcpio' program is a different interface to
-          essentially the same functionality
-   * examples: Some small example programs that you may find useful.
-   * examples/minitar: a compact sample demonstrating use of libarchive.
-          I use this for testing link pollution; it should produce a very
-          small executable file on most systems.
-   * contrib:  Various items sent to me by third parties;
-          please contact the authors with any questions.
-
-The top-level directory contains the following information files:
-   * NEWS - highlights of recent changes
-   * COPYING - what you can do with this
-   * INSTALL - installation instructions
-   * README - this file
-   * configure - configuration script, see INSTALL for details.
-   * CMakeLists.txt - input for "cmake" build tool, see INSTALL
-
-The following files in the top-level directory are used by the
-'configure' script:
-   * Makefile.am, aclocal.m4, configure.ac
-       - used to build this distribution, only needed by maintainers
-   * Makefile.in, config.h.in
-    - templates used by configure script
-
-Guide to Documentation installed by this system:
- * bsdtar.1 explains the use of the bsdtar program
- * bsdcpio.1 explains the use of the bsdcpio program
- * libarchive.3 gives an overview of the library as a whole
- * archive_read.3, archive_write.3, archive_write_disk.3, and
-   archive_read_disk.3 provide detailed calling sequences for the read
-   and write APIs
- * archive_entry.3 details the "struct archive_entry" utility class
- * archive_internals.3 provides some insight into libarchive's
-   internal structure and operation.
- * libarchive-formats.5 documents the file formats supported by the library
- * cpio.5, mtree.5, and tar.5 provide detailed information about these
-   popular archive formats, including hard-to-find details about
-   modern cpio and tar variants.
-The manual pages above are provided in the 'doc' directory in
-a number of different formats.
-
-You should also read the copious comments in "archive.h" and the
-source code for the sample programs for more details.  Please let me
-know about any errors or omissions you find.
-
-Currently, the library automatically detects and reads the following:
-  * gzip compression
-  * bzip2 compression
-  * compress/LZW compression
-  * lzma and xz compression
-  * GNU tar format (including GNU long filenames, long link names, and
-    sparse files)
-  * Solaris 9 extended tar format (including ACLs)
-  * Old V7 tar archives
-  * POSIX ustar
-  * POSIX pax interchange format
-  * POSIX octet-oriented cpio
-  * SVR4 ASCII cpio
-  * POSIX octet-oriented cpio
-  * Binary cpio (big-endian or little-endian)
-  * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
-  * ZIP archives (with uncompressed or "deflate" compressed entries)
-  * GNU and BSD 'ar' archives
-  * 'mtree' format
-
-The library can write:
-  * gzip compression
-  * bzip2 compression
-  * compress/LZW compression
-  * lzma and xz compression
-  * POSIX ustar
-  * POSIX pax interchange format
-  * "restricted" pax format, which will create ustar archives except for
-    entries that require pax extensions (for long filenames, ACLs, etc).
-  * POSIX octet-oriented cpio
-  * SVR4 "newc" cpio
-  * shar archives
-  * ZIP archives (with uncompressed or "deflate" compressed entries)
-  * GNU and BSD 'ar' archives
-  * 'mtree' format
-
-Notes about the library architecture:
-
- * This is a heavily stream-oriented system.  There is no direct
-   support for in-place modification or random access.
-
- * The library is designed to be extended with new compression and
-   archive formats.  The only requirement is that the format be
-   readable or writable as a stream and that each archive entry be
-   independent.  There are articles on the libarchive Wiki explaining
-   how to extend libarchive.
-
- * On read, compression and format are always detected automatically.
-
- * I've attempted to minimize static link pollution.  If you don't
-   explicitly invoke a particular feature (such as support for a
-   particular compression or format), it won't get pulled in.
-   In particular, if you don't explicitly enable a particular
-   compression or decompression support, you won't need to link
-   against the corresponding compression or decompression libraries.
-   This also reduces the size of statically-linked binaries in
-   environments where that matters.
-
- * On read, the library accepts whatever blocks you hand it.
-   Your read callback is free to pass the library a byte at a time
-   or mmap the entire archive and give it to the library at once.
-   On write, the library always produces correctly-blocked output.
-
- * The object-style approach allows you to have multiple archive streams
-   open at once.  bsdtar uses this in its "@archive" extension.
-
- * The archive itself is read/written using callback functions.
-   You can read an archive directly from an in-memory buffer or
-   write it to a socket, if you wish.  There are some utility
-   functions to provide easy-to-use "open file," etc, capabilities.
-
- * The read/write APIs are designed to allow individual entries
-   to be read or written to any data source:  You can create
-   a block of data in memory and add it to a tar archive without
-   first writing a temporary file.  You can also read an entry from
-   an archive and write the data directly to a socket.  If you want
-   to read/write entries to disk, there are convenience functions to
-   make this especially easy.
-
- * Note: "pax interchange format" is really an extended tar format,
-   despite what the name says.

+ 66 - 0
Utilities/cmlibarchive/README-CMake.txt

@@ -0,0 +1,66 @@
+The Utilities/cmlibarchive directory contains a reduced distribution
+of the libarchive source tree with only the library source code and
+CMake build system.  It is not a submodule; the actual content is part
+of our source tree and changes can be made and committed directly.
+
+We update from upstream using Git's "subtree" merge strategy.  A
+special branch contains commits of upstream libarchive snapshots and
+nothing else.  No Git ref points explicitly to the head of this
+branch, but it is merged into our history.
+
+Update libarchive from upstream as follows.  Create a local branch to
+explicitly reference the upstream snapshot branch head:
+
+ git branch libarchive-upstream 4f4fe6e5
+
+Use a temporary directory to checkout the branch:
+
+ mkdir libarchive-tmp
+ cd libarchive-tmp
+ git init
+ git pull .. libarchive-upstream
+ rm -rf *
+
+Now place the (reduced) libarchive content in this directory.  See
+instructions shown by
+
+ git log 4f4fe6e5
+
+for help extracting the content from the upstream svn repo.  Then run
+the following commands to commit the new version.  Substitute the
+appropriate date and version number:
+
+ git add --all
+
+ GIT_AUTHOR_NAME='LibArchive Upstream' \
+ GIT_AUTHOR_EMAIL='[email protected]' \
+ GIT_AUTHOR_DATE='2011-12-31 13:54:34 -0500' \
+ git commit -m 'libarchive 3.0.2-r4051 (reduced)' &&
+ git commit --amend
+
+Edit the commit message to describe the procedure used to obtain the
+content.  Then push the changes back up to the main local repository:
+
+ git push .. HEAD:libarchive-upstream
+ cd ..
+ rm -rf libarchive-tmp
+
+Create a topic in the main repository on which to perform the update:
+
+ git checkout -b update-libarchive master
+
+Merge the libarchive-upstream branch as a subtree:
+
+ git merge -s recursive -X subtree=Utilities/cmlibarchive \
+           libarchive-upstream
+
+If there are conflicts, resolve them and commit.  Build and test the
+tree.  Commit any additional changes needed to succeed.
+
+Finally, run
+
+ git rev-parse --short=8 libarchive-upstream
+
+to get the commit from which the libarchive-upstream branch must be started
+on the next update.  Edit the "git branch libarchive-upstream" line above to
+record it, and commit this file.

+ 0 - 51
Utilities/cmlibarchive/build/autoconf/check_stdcall_func.m4

@@ -1,51 +0,0 @@
-# AC_LANG_STDCALL_FUNC_LINK_TRY(FUNCTION, SIGNATURE)
-# -------------------------------
-# Produce a source which links correctly iff the FUNCTION exists.
-AC_DEFUN([AC_LANG_STDCALL_FUNC_LINK_TRY],
-[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
-
-# AC_CHECK_STDCALL_FUNC(FUNCTION, SIGNATURE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -----------------------------------------------------------------
-AC_DEFUN([AC_CHECK_STDCALL_FUNC],
-[AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
-AC_CACHE_CHECK([for $1], ac_var,
-[AC_LINK_IFELSE([AC_LANG_STDCALL_FUNC_LINK_TRY([$1],[$2])],
-                [AS_VAR_SET(ac_var, yes)],
-                [AS_VAR_SET(ac_var, no)])])
-AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl
-AS_VAR_POPDEF([ac_var])dnl
-])# AC_CHECK_FUNC
-
-# AC_LANG_STDCALL_FUNC_LINK_TRY(C)(FUNCTION, SIGNATURE)
-# ----------------------------------
-# Don't include <ctype.h> because on OSF/1 3.0 it includes
-# <sys/types.h> which includes <sys/select.h> which contains a
-# prototype for select.  Similarly for bzero.
-m4_define([AC_LANG_STDCALL_FUNC_LINK_TRY(C)],
-[AC_LANG_PROGRAM(
-[/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char __stdcall $1 ( $2 ) below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char __stdcall $1 ( $2 );
-char (*f) ( $2 );
-],
-[/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$1) || defined (__stub___$1)
-choke me
-#else
-f = $1;
-#endif
-])])
-
-# AC_LANG_STDCALL_FUNC_LINK_TRY(C++)(FUNCTION)
-# ------------------------------------
-m4_copy([AC_LANG_STDCALL_FUNC_LINK_TRY(C)], [AC_LANG_STDCALL_FUNC_LINK_TRY(C++)])
-

+ 0 - 20
Utilities/cmlibarchive/build/autoconf/la_uid_t.m4

@@ -1,20 +0,0 @@
-# la_TYPE_UID_T
-# -------------
-AC_DEFUN([la_TYPE_UID_T],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_CACHE_CHECK(for uid_t in sys/types.h, la_cv_type_uid_t,
-[AC_EGREP_HEADER(uid_t, sys/types.h,
-  la_cv_type_uid_t=yes, la_cv_type_uid_t=no)])
-if test $la_cv_type_uid_t = no; then
-  case $host in
-    *mingw*) def_uid_t=short ;;
-    *) def_uid_t=int ;;
-  esac
-  AC_DEFINE_UNQUOTED(uid_t, [$def_uid_t],
-    [Define to match typeof st_uid field of struct stat if <sys/types.h> doesn't define.])
-  AC_DEFINE_UNQUOTED(gid_t, [$def_uid_t],
-    [Define to match typeof st_gid field of struct stat if <sys/types.h> doesn't define.])
-fi
-])
-AU_ALIAS([AC_TYPE_UID_T], [la_TYPE_UID_T])
-

+ 0 - 25
Utilities/cmlibarchive/build/autogen.sh

@@ -1,25 +0,0 @@
-#!/bin/sh
-
-
-# Start from one level above the build directory
-if [ -f version ]; then
-    cd ..
-fi
-
-if [ \! -f build/version ]; then
-    echo "Can't find source directory"
-    exit 1
-fi
-
-set -xe
-aclocal -I build/autoconf
-
-# Note: --automake flag needed only for libtoolize from
-# libtool 1.5.x; in libtool 2.2.x it is a synonym for --quiet
-case `uname` in
-Darwin) glibtoolize --automake -c;;
-*) libtoolize --automake -c;;
-esac
-autoconf
-autoheader
-automake -a -c

+ 7 - 6
Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake

@@ -12,21 +12,22 @@
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-
 #INCLUDE(CheckCXXSourceCompiles)
 
-MACRO (CHECK_FILE_OFFSET_BITS)
+GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits
+	 "${CMAKE_CURRENT_LIST_FILE}" PATH)
 
+MACRO (CHECK_FILE_OFFSET_BITS)
   IF(NOT DEFINED _FILE_OFFSET_BITS)
     MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files")
     TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
-      ${CMAKE_BINARY_DIR}
-      ${libarchive_SOURCE_DIR}/build/cmake/CheckFileOffsetBits.c
+      ${CMAKE_CURRENT_BINARY_DIR}
+      ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
     IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
       TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
-        ${CMAKE_BINARY_DIR}
-        ${libarchive_SOURCE_DIR}/build/cmake/CheckFileOffsetBits.c
+        ${CMAKE_CURRENT_BINARY_DIR}
+        ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
         COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
     ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
 

+ 20 - 18
Utilities/cmlibarchive/build/cmake/CheckFuncs.cmake

@@ -23,25 +23,27 @@
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
 INCLUDE(CheckFunctionExists)
+GET_FILENAME_COMPONENT(_selfdir_CheckFunctionExistsGlibc
+	 "${CMAKE_CURRENT_LIST_FILE}" PATH)
 
 MACRO (CHECK_FUNCTION_EXISTS_GLIBC _FUNC _FUNCVAR)
-  IF(NOT DEFINED ${_FUNCVAR})
-   SET(CHECK_STUB_FUNC_1 "__stub_${_FUNC}")
-   SET(CHECK_STUB_FUNC_2 "__stub___${_FUNC}")
-   CONFIGURE_FILE( ${libarchive_SOURCE_DIR}/build/cmake/CheckFuncs_stub.c.in
-     ${CMAKE_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c IMMEDIATE)
-   TRY_COMPILE(__stub
-     ${CMAKE_BINARY_DIR}
-     ${CMAKE_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c
-     COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-     CMAKE_FLAGS
-     -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
-     "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}")
-   IF (__stub)
-     SET("${_FUNCVAR}" "" CACHE INTERNAL "Have function ${_FUNC}")
-   ELSE (__stub)
-     CHECK_FUNCTION_EXISTS("${_FUNC}" "${_FUNCVAR}")
-   ENDIF (__stub)
-   ENDIF(NOT DEFINED ${_FUNCVAR})
+   IF(NOT DEFINED ${_FUNCVAR})
+     SET(CHECK_STUB_FUNC_1 "__stub_${_FUNC}")
+     SET(CHECK_STUB_FUNC_2 "__stub___${_FUNC}")
+     CONFIGURE_FILE( ${_selfdir_CheckFunctionExistsGlibc}/CheckFuncs_stub.c.in
+       ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c IMMEDIATE)
+     TRY_COMPILE(__stub
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c
+       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+       CMAKE_FLAGS
+       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
+       "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}")
+     IF (__stub)
+       SET("${_FUNCVAR}" "" CACHE INTERNAL "Have function ${_FUNC}")
+     ELSE (__stub)
+       CHECK_FUNCTION_EXISTS("${_FUNC}" "${_FUNCVAR}")
+     ENDIF (__stub)
+  ENDIF(NOT DEFINED ${_FUNCVAR})
 ENDMACRO (CHECK_FUNCTION_EXISTS_GLIBC)
 

+ 1 - 5
Utilities/cmlibarchive/build/cmake/FindLZMA.cmake

@@ -14,7 +14,7 @@ IF (LZMA_INCLUDE_DIR)
 ENDIF (LZMA_INCLUDE_DIR)
 
 FIND_PATH(LZMA_INCLUDE_DIR lzma.h)
-FIND_LIBRARY(LZMA_LIBRARY NAMES lzma )
+FIND_LIBRARY(LZMA_LIBRARY NAMES lzma liblzma)
 
 # handle the QUIETLY and REQUIRED arguments and set LZMA_FOUND to TRUE if 
 # all listed variables are TRUE
@@ -46,7 +46,3 @@ ELSE(LZMA_FOUND)
     SET( LZMADEC_LIBRARIES )
   ENDIF(LZMADEC_FOUND)
 ENDIF(LZMA_FOUND)
-
-
-MARK_AS_ADVANCED( LZMA_LIBRARY LZMA_INCLUDE_DIR
-  LZMADEC_LIBRARY LZMADEC_INCLUDE_DIR )

+ 543 - 132
Utilities/cmlibarchive/build/cmake/config.h.in

@@ -1,8 +1,291 @@
-/* config.h.  Generated from config.h.cmake by cmake configure */
+/* config.h.  Generated from build/cmake/config.h.in by cmake configure */
 #if defined(__osf__)
 # define _OSF_SOURCE
 #endif
 
+/*
+ * Ensure we have C99-style int64_t, etc, all defined.
+ */
+
+/* First, we need to know if the system has already defined them. */
+#cmakedefine HAVE_INT16_T
+#cmakedefine HAVE_INT32_T
+#cmakedefine HAVE_INT64_T
+#cmakedefine HAVE_INTMAX_T
+
+#cmakedefine HAVE_UINT8_T
+#cmakedefine HAVE_UINT16_T
+#cmakedefine HAVE_UINT32_T
+#cmakedefine HAVE_UINT64_T
+#cmakedefine HAVE_UINTMAX_T
+
+/* We might have the types we want under other spellings. */
+#cmakedefine HAVE___INT64
+#cmakedefine HAVE_U_INT64_T
+#cmakedefine HAVE_UNSIGNED___INT64
+
+/* The sizes of various standard integer types. */
+@SIZE_OF_SHORT_CODE@
+@SIZE_OF_INT_CODE@
+@SIZE_OF_LONG_CODE@
+@SIZE_OF_LONG_LONG_CODE@
+@SIZE_OF_UNSIGNED_SHORT_CODE@
+@SIZE_OF_UNSIGNED_CODE@
+@SIZE_OF_UNSIGNED_LONG_CODE@
+@SIZE_OF_UNSIGNED_LONG_LONG_CODE@
+
+/*
+ * If we lack int64_t, define it to the first of __int64, int, long, and long long
+ * that exists and is the right size.
+ */
+#if !defined(HAVE_INT64_T) && defined(HAVE___INT64)
+typedef __int64 int64_t;
+#define HAVE_INT64_T
+#endif
+
+#if !defined(HAVE_INT64_T) && SIZE_OF_INT == 8
+typedef int int64_t;
+#define HAVE_INT64_T
+#endif
+
+#if !defined(HAVE_INT64_T) && SIZE_OF_LONG == 8
+typedef long int64_t;
+#define HAVE_INT64_T
+#endif
+
+#if !defined(HAVE_INT64_T) && SIZE_OF_LONG_LONG == 8
+typedef long long int64_t;
+#define HAVE_INT64_T
+#endif
+
+#if !defined(HAVE_INT64_T)
+#error No 64-bit integer type was found.
+#endif
+
+/*
+ * Similarly for int32_t
+ */
+#if !defined(HAVE_INT32_T) && SIZE_OF_INT == 4
+typedef long int32_t;
+#define HAVE_INT32_T
+#endif
+
+#if !defined(HAVE_INT32_T) && SIZE_OF_LONG == 4
+typedef long int32_t;
+#define HAVE_INT32_T
+#endif
+
+#if !defined(HAVE_INT32_T)
+#error No 32-bit integer type was found.
+#endif
+
+/*
+ * Similarly for int16_t
+ */
+#if !defined(HAVE_INT16_T) && SIZE_OF_INT == 2
+typedef int int16_t;
+#define HAVE_INT16_T
+#endif
+
+#if !defined(HAVE_INT16_T) && SIZE_OF_SHORT == 2
+typedef short int16_t;
+#define HAVE_INT16_T
+#endif
+
+#if !defined(HAVE_INT16_T)
+#error No 16-bit integer type was found.
+#endif
+
+/*
+ * Similarly for uint64_t
+ */
+#if !defined(HAVE_UINT64_T) && defined(HAVE_UNSIGNED___INT64)
+typedef unsigned __int64 uint64_t;
+#define HAVE_UINT64_T
+#endif
+
+#if !defined(HAVE_UINT64_T) && SIZE_OF_UNSIGNED == 8
+typedef unsigned uint64_t;
+#define HAVE_UINT64_T
+#endif
+
+#if !defined(HAVE_UINT64_T) && SIZE_OF_UNSIGNED_LONG == 8
+typedef unsigned long uint64_t;
+#define HAVE_UINT64_T
+#endif
+
+#if !defined(HAVE_UINT64_T) && SIZE_OF_UNSIGNED_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#define HAVE_UINT64_T
+#endif
+
+#if !defined(HAVE_UINT64_T)
+#error No 64-bit unsigned integer type was found.
+#endif
+
+
+/*
+ * Similarly for uint32_t
+ */
+#if !defined(HAVE_UINT32_T) && SIZE_OF_UNSIGNED == 4
+typedef unsigned uint32_t;
+#define HAVE_UINT32_T
+#endif
+
+#if !defined(HAVE_UINT32_T) && SIZE_OF_UNSIGNED_LONG == 4
+typedef unsigned long uint32_t;
+#define HAVE_UINT32_T
+#endif
+
+#if !defined(HAVE_UINT32_T)
+#error No 32-bit unsigned integer type was found.
+#endif
+
+/*
+ * Similarly for uint16_t
+ */
+#if !defined(HAVE_UINT16_T) && SIZE_OF_UNSIGNED == 2
+typedef unsigned uint16_t;
+#define HAVE_UINT16_T
+#endif
+
+#if !defined(HAVE_UINT16_T) && SIZE_OF_UNSIGNED_SHORT == 2
+typedef unsigned short uint16_t;
+#define HAVE_UINT16_T
+#endif
+
+#if !defined(HAVE_UINT16_T)
+#error No 16-bit unsigned integer type was found.
+#endif
+
+/*
+ * Similarly for uint8_t
+ */
+#if !defined(HAVE_UINT8_T)
+typedef unsigned char uint8_t;
+#define HAVE_UINT8_T
+#endif
+
+#if !defined(HAVE_UINT16_T)
+#error No 8-bit unsigned integer type was found.
+#endif
+
+/* 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)
+typedef uint64_t uintmax_t;
+#endif
+
+/* Define ZLIB_WINAPI if zlib was built on Visual Studio. */
+#cmakedefine ZLIB_WINAPI 1
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_LIBC supported. */
+#cmakedefine ARCHIVE_CRYPTO_MD5_LIBC 1
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_LIBSYSTEM supported. */
+#cmakedefine ARCHIVE_CRYPTO_MD5_LIBSYSTEM 1
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_NETTLE supported. */
+#cmakedefine ARCHIVE_CRYPTO_MD5_NETTLE 1
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_OPENSSL supported. */
+#cmakedefine ARCHIVE_CRYPTO_MD5_OPENSSL 1
+
+/* MD5 via ARCHIVE_CRYPTO_MD5_WIN supported. */
+#cmakedefine ARCHIVE_CRYPTO_MD5_WIN 1
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_LIBC supported. */
+#cmakedefine ARCHIVE_CRYPTO_RMD160_LIBC 1
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_NETTLE supported. */
+#cmakedefine ARCHIVE_CRYPTO_RMD160_NETTLE 1
+
+/* RMD160 via ARCHIVE_CRYPTO_RMD160_OPENSSL supported. */
+#cmakedefine ARCHIVE_CRYPTO_RMD160_OPENSSL 1
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBC supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA1_LIBC 1
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBSYSTEM supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA1_LIBSYSTEM 1
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_NETTLE supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA1_NETTLE 1
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_OPENSSL supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA1_OPENSSL 1
+
+/* SHA1 via ARCHIVE_CRYPTO_SHA1_WIN supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA1_WIN 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_LIBC 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC2 supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_LIBC2 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC3 supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_LIBC3 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBSYSTEM supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_LIBSYSTEM 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_NETTLE supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_NETTLE 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_OPENSSL supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_OPENSSL 1
+
+/* SHA256 via ARCHIVE_CRYPTO_SHA256_WIN supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA256_WIN 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_LIBC 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC2 supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_LIBC2 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC3 supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_LIBC3 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBSYSTEM supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_LIBSYSTEM 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_NETTLE supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_NETTLE 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_OPENSSL supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_OPENSSL 1
+
+/* SHA384 via ARCHIVE_CRYPTO_SHA384_WIN supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA384_WIN 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_LIBC 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC2 supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_LIBC2 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC3 supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_LIBC3 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBSYSTEM supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_LIBSYSTEM 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_NETTLE supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_NETTLE 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_OPENSSL supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_OPENSSL 1
+
+/* SHA512 via ARCHIVE_CRYPTO_SHA512_WIN supported. */
+#cmakedefine ARCHIVE_CRYPTO_SHA512_WIN 1
+
 /* Version number of bsdcpio */
 #cmakedefine BSDCPIO_VERSION_STRING "${BSDCPIO_VERSION_STRING}"
 
@@ -48,6 +331,9 @@
 /* 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 <bsdxml.h> header file. */
+#cmakedefine HAVE_BSDXML_H 1
+
 /* Define to 1 if you have the <bzlib.h> header file. */
 #cmakedefine HAVE_BZLIB_H 1
 
@@ -60,15 +346,18 @@
 /* Define to 1 if you have the `chroot' function. */
 #cmakedefine HAVE_CHROOT 1
 
-/* Define to 1 if you have the `CreateHardLinkA' function. */
-#cmakedefine HAVE_CREATEHARDLINKA 1
+/* Define to 1 if you have the <copyfile.h> header file. */
+#cmakedefine HAVE_COPYFILE_H 1
 
-/* Define to 1 if you have the `CreateHardLinkW' function. */
-#cmakedefine HAVE_CREATEHARDLINKW 1
+/* Define to 1 if you have the `ctime_r' function. */
+#cmakedefine HAVE_CTIME_R 1
 
 /* Define to 1 if you have the <ctype.h> header file. */
 #cmakedefine HAVE_CTYPE_H 1
 
+/* 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 `INT64_MAX', and to 0 if you
    don't. */
 #cmakedefine HAVE_DECL_INT64_MAX 1
@@ -77,14 +366,6 @@
    don't. */
 #cmakedefine HAVE_DECL_INT64_MIN 1
 
-/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
-   */
-#cmakedefine HAVE_DECL_OPTARG 1
-
-/* Define to 1 if you have the declaration of `optind', and to 0 if you don't.
-   */
-#cmakedefine HAVE_DECL_OPTIND 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
@@ -130,6 +411,9 @@
 /* Define to 1 if you have the <errno.h> header file. */
 #cmakedefine HAVE_ERRNO_H 1
 
+/* Define to 1 if you have the <expat.h> header file. */
+#cmakedefine HAVE_EXPAT_H 1
+
 /* Define to 1 if you have the <ext2fs/ext2_fs.h> header file. */
 #cmakedefine HAVE_EXT2FS_EXT2_FS_H 1
 
@@ -145,6 +429,9 @@
 /* Define to 1 if you have the `extattr_set_file' function. */
 #cmakedefine HAVE_EXTATTR_SET_FILE 1
 
+/* Define to 1 if EXTATTR_NAMESPACE_USER is defined in sys/extattr.h. */
+#cmakedefine HAVE_DECL_EXTATTR_NAMESPACE_USER 1
+
 /* Define to 1 if you have the `fchdir' function. */
 #cmakedefine HAVE_FCHDIR 1
 
@@ -163,38 +450,95 @@
 /* Define to 1 if you have the <fcntl.h> header file. */
 #cmakedefine HAVE_FCNTL_H 1
 
+/* Define to 1 if you have the `fdopendir' function. */
+#cmakedefine HAVE_FDOPENDIR 1
+
+/* Define to 1 if you have the `fgetea' function. */
+#cmakedefine HAVE_FGETEA 1
+
+/* Define to 1 if you have the `fgetxattr' function. */
+#cmakedefine HAVE_FGETXATTR 1
+
+/* Define to 1 if you have the `flistea' function. */
+#cmakedefine HAVE_FLISTEA 1
+
+/* Define to 1 if you have the `flistxattr' function. */
+#cmakedefine HAVE_FLISTXATTR 1
+
 /* Define to 1 if you have the `fork' function. */
 #cmakedefine HAVE_FORK 1
 
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 #cmakedefine HAVE_FSEEKO 1
 
+/* Define to 1 if you have the `fsetea' function. */
+#cmakedefine HAVE_FSETEA 1
+
 /* Define to 1 if you have the `fsetxattr' function. */
 #cmakedefine HAVE_FSETXATTR 1
 
 /* Define to 1 if you have the `fstat' function. */
 #cmakedefine HAVE_FSTAT 1
 
+/* Define to 1 if you have the `fstatat' function. */
+#cmakedefine HAVE_FSTATAT 1
+
+/* Define to 1 if you have the `fstatfs' function. */
+#cmakedefine HAVE_FSTATFS 1
+
+/* Define to 1 if you have the `fstatvfs' function. */
+#cmakedefine HAVE_FSTATVFS 1
+
 /* Define to 1 if you have the `ftruncate' function. */
 #cmakedefine HAVE_FTRUNCATE 1
 
+/* Define to 1 if you have the `futimens' function. */
+#cmakedefine HAVE_FUTIMENS 1
+
 /* Define to 1 if you have the `futimes' function. */
 #cmakedefine HAVE_FUTIMES 1
 
+/* Define to 1 if you have the `futimesat' function. */
+#cmakedefine HAVE_FUTIMESAT 1
+
+/* Define to 1 if you have the `getea' function. */
+#cmakedefine HAVE_GETEA 1
+
 /* Define to 1 if you have the `geteuid' function. */
 #cmakedefine HAVE_GETEUID 1
 
+/* Define to 1 if you have the `getgrgid_r' function. */
+#cmakedefine HAVE_GETGRGID_R 1
+
+/* Define to 1 if you have the `getgrnam_r' function. */
+#cmakedefine HAVE_GETGRNAM_R 1
+
 /* Define to 1 if you have the `getpid' function. */
 #cmakedefine HAVE_GETPID 1
 
+/* Define to 1 if you have the `getpwnam_r' function. */
+#cmakedefine HAVE_GETPWNAM_R 1
+
+/* Define to 1 if you have the `getpwuid_r' function. */
+#cmakedefine HAVE_GETPWUID_R 1
+
+/* Define to 1 if you have the `getvfsbyname' function. */
+#cmakedefine HAVE_GETVFSBYNAME 1
+
 /* Define to 1 if you have the `getxattr' function. */
 #cmakedefine HAVE_GETXATTR 1
 
+/* Define to 1 if you have the `gmtime_r' function. */
+#cmakedefine HAVE_GMTIME_R 1
+
 /* Define to 1 if you have the <grp.h> header file. */
 #cmakedefine HAVE_GRP_H 1
 
-/* Define to 1 if the system has the type `intmax_t'. */
-#cmakedefine HAVE_INTMAX_T 1
+/* Define to 1 if you have the `iconv' function. */
+#cmakedefine HAVE_ICONV 1
+
+/* Define to 1 if you have the <iconv.h> header file. */
+#cmakedefine HAVE_ICONV_H 1
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #cmakedefine HAVE_INTTYPES_H 1
@@ -214,6 +558,9 @@
 /* Define to 1 if you have the `lchown' function. */
 #cmakedefine HAVE_LCHOWN 1
 
+/* Define to 1 if you have the `lgetea' function. */
+#cmakedefine HAVE_LGETEA 1
+
 /* Define to 1 if you have the `lgetxattr' function. */
 #cmakedefine HAVE_LGETXATTR 1
 
@@ -223,39 +570,81 @@
 /* Define to 1 if you have the `attr' library (-lattr). */
 #cmakedefine HAVE_LIBATTR 1
 
+/* Define to 1 if you have the `bsdxml' library (-lbsdxml). */
+#cmakedefine HAVE_LIBBSDXML 1
+
 /* Define to 1 if you have the `bz2' library (-lbz2). */
 #cmakedefine HAVE_LIBBZ2 1
 
+/* Define to 1 if you have the `expat' library (-lexpat). */
+#cmakedefine HAVE_LIBEXPAT 1
+
 /* Define to 1 if you have the `lzma' library (-llzma). */
 #cmakedefine HAVE_LIBLZMA 1
 
 /* Define to 1 if you have the `lzmadec' library (-llzmadec). */
 #cmakedefine HAVE_LIBLZMADEC 1
 
+/* Define to 1 if you have the `xml2' library (-lxml2). */
+#cmakedefine HAVE_LIBXML2 1
+
+/* Define to 1 if you have the <libxml/xmlreader.h> header file. */
+#cmakedefine HAVE_LIBXML_XMLREADER_H 1
+
+/* Define to 1 if you have the <libxml/xmlwriter.h> header file. */
+#cmakedefine HAVE_LIBXML_XMLWRITER_H 1
+
 /* Define to 1 if you have the `z' library (-lz). */
 #cmakedefine HAVE_LIBZ 1
 
 /* Define to 1 if you have the <limits.h> header file. */
 #cmakedefine HAVE_LIMITS_H 1
 
-/* Define to 1 if you have the link() function. */
+/* Define to 1 if you have the `link' function. */
 #cmakedefine HAVE_LINK 1
 
+/* Define to 1 if you have the <linux/types.h> header file. */
+#cmakedefine HAVE_LINUX_TYPES_H 1
+
+/* Define to 1 if you have the <linux/fiemap.h> header file. */
+#cmakedefine HAVE_LINUX_FIEMAP_H 1
+
 /* Define to 1 if you have the <linux/fs.h> header file. */
 #cmakedefine HAVE_LINUX_FS_H 1
 
+/* Define to 1 if you have the <linux/magic.h> header file. */
+#cmakedefine HAVE_LINUX_MAGIC_H 1
+
+/* Define to 1 if you have the `listea' function. */
+#cmakedefine HAVE_LISTEA 1
+
 /* Define to 1 if you have the `listxattr' function. */
 #cmakedefine HAVE_LISTXATTR 1
 
+/* Define to 1 if you have the `llistea' function. */
+#cmakedefine HAVE_LLISTEA 1
+
 /* Define to 1 if you have the `llistxattr' function. */
 #cmakedefine HAVE_LLISTXATTR 1
 
+/* Define to 1 if you have the <localcharset.h> header file. */
+#cmakedefine HAVE_LOCALCHARSET_H 1
+
+/* Define to 1 if you have the `locale_charset' function. */
+#cmakedefine HAVE_LOCALE_CHARSET 1
+
 /* Define to 1 if you have the <locale.h> header file. */
 #cmakedefine HAVE_LOCALE_H 1
 
+/* Define to 1 if you have the `localtime_r' function. */
+#cmakedefine HAVE_LOCALTIME_R 1
+
 /* Define to 1 if the system has the type `long long int'. */
 #cmakedefine HAVE_LONG_LONG_INT 1
 
+/* Define to 1 if you have the `lsetea' function. */
+#cmakedefine HAVE_LSETEA 1
+
 /* Define to 1 if you have the `lsetxattr' function. */
 #cmakedefine HAVE_LSETXATTR 1
 
@@ -275,11 +664,11 @@
 /* Define to 1 if you have the <lzma.h> header file. */
 #cmakedefine HAVE_LZMA_H 1
 
-/* Define to 1 if you have the `MD5' functions. */
-#cmakedefine HAVE_MD5 1
+/* Define to 1 if you have the `mbrtowc' function. */
+#cmakedefine HAVE_MBRTOWC 1
 
-/* Define to 1 if you have the <md5.h> header file. */
-#cmakedefine HAVE_MD5_H 1
+/* Define to 1 if you have the `mbsnrtowcs' function. */
+#cmakedefine HAVE_MBSNRTOWCS 1
 
 /* Define to 1 if you have the `memmove' function. */
 #cmakedefine HAVE_MEMMOVE 1
@@ -296,20 +685,17 @@
 /* Define to 1 if you have the `mknod' function. */
 #cmakedefine HAVE_MKNOD 1
 
+/* Define to 1 if you have the `mkstemp' function. */
+#cmakedefine HAVE_MKSTEMP 1
+
 /* 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 `nl_langinfo' function. */
 #cmakedefine HAVE_NL_LANGINFO 1
 
-/* Define to 1 if you have the <openssl/md5.h> header file. */
-#cmakedefine HAVE_OPENSSL_MD5_H 1
-
-/* Define to 1 if you have the <openssl/ripemd.h> header file. */
-#cmakedefine HAVE_OPENSSL_RIPEMD_H 1
-
-/* Define to 1 if you have the <openssl/sha.h> header file. */
-#cmakedefine HAVE_OPENSSL_SHA_H 1
+/* Define to 1 if you have the `openat' function. */
+#cmakedefine HAVE_OPENAT 1
 
 /* Define to 1 if you have the <paths.h> header file. */
 #cmakedefine HAVE_PATHS_H 1
@@ -329,21 +715,18 @@
 /* Define to 1 if you have the <pwd.h> header file. */
 #cmakedefine HAVE_PWD_H 1
 
+/* Define to 1 if you have the `readdir_r' function. */
+#cmakedefine HAVE_READDIR_R 1
+
 /* Define to 1 if you have the `readlink' function. */
 #cmakedefine HAVE_READLINK 1
 
+/* Define to 1 if you have the `readlinkat' function. */
+#cmakedefine HAVE_READLINKAT 1
+
 /* Define to 1 if you have the <regex.h> header file. */
 #cmakedefine HAVE_REGEX_H 1
 
-/* Define to 1 if you have the <ripemd.h> header file. */
-#cmakedefine HAVE_RIPEMD_H 1
-
-/* Define to 1 if you have the `RIPEMD160' functions. */
-#cmakedefine HAVE_RMD160 1
-
-/* Define to 1 if you have the <rmd160.h> header file. */
-#cmakedefine HAVE_RMD160_H 1
-
 /* Define to 1 if you have the `select' function. */
 #cmakedefine HAVE_SELECT 1
 
@@ -353,33 +736,18 @@
 /* Define to 1 if you have the `setlocale' function. */
 #cmakedefine HAVE_SETLOCALE 1
 
-/* Define to 1 if you have the `SHA1' functions. */
-#cmakedefine HAVE_SHA1 1
-
-/* Define to 1 if you have the <sha1.h> header file. */
-#cmakedefine HAVE_SHA1_H 1
-
-/* Define to 1 if you have the `SHA256' functions. */
-#cmakedefine HAVE_SHA256 1
-
-/* Define to 1 if you have the <sha256.h> header file. */
-#cmakedefine HAVE_SHA256_H 1
-
-/* Define to 1 if you have the <sha2.h> header file. */
-#cmakedefine HAVE_SHA2_H 1
-
-/* Define to 1 if you have the `SHA384' functions. */
-#cmakedefine HAVE_SHA384 1
-
-/* Define to 1 if you have the `SHA512' functions. */
-#cmakedefine HAVE_SHA512 1
-
-/* Define to 1 if you have the <sha.h> header file. */
-#cmakedefine HAVE_SHA_H 1
+/* Define to 1 if you have the `sigaction' function. */
+#cmakedefine HAVE_SIGACTION 1
 
 /* Define to 1 if you have the <signal.h> header file. */
 #cmakedefine HAVE_SIGNAL_H 1
 
+/* Define to 1 if you have the `statfs' function. */
+#cmakedefine HAVE_STATFS 1
+
+/* Define to 1 if you have the `statvfs' function. */
+#cmakedefine HAVE_STATVFS 1
+
 /* Define to 1 if `stat' has the bug that it succeeds when given the
    zero-length file name argument. */
 #cmakedefine HAVE_STAT_EMPTY_STRING_BUG 1
@@ -417,43 +785,61 @@
 /* Define to 1 if you have the `strrchr' function. */
 #cmakedefine HAVE_STRRCHR 1
 
-/* Define to 1 if `st_birthtime' is member of `struct stat'. */
+/* Define to 1 if `f_namemax' is a member of `struct statfs'. */
+#cmakedefine HAVE_STRUCT_STATFS_F_NAMEMAX 1
+
+/* Define to 1 if `f_iosize' is a member of `struct statvfs'. */
+#cmakedefine HAVE_STRUCT_STATVFS_F_IOSIZE 1
+
+/* Define to 1 if `st_birthtime' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_BIRTHTIME 1
 
-/* Define to 1 if `st_birthtimespec.tv_nsec' is member of `struct stat'. */
+/* Define to 1 if `st_birthtimespec.tv_nsec' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
 
-/* Define to 1 if `st_blksize' is member of `struct stat'. */
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_BLKSIZE 1
 
-/* Define to 1 if `st_flags' is member of `struct stat'. */
+/* Define to 1 if `st_flags' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_FLAGS 1
 
-/* Define to 1 if `st_mtimespec.tv_nsec' is member of `struct stat'. */
+/* Define to 1 if `st_mtimespec.tv_nsec' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
 
-/* Define to 1 if `st_mtime_n' is member of `struct stat'. */
+/* Define to 1 if `st_mtime_n' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_MTIME_N 1
 
-/* Define to 1 if `st_mtime_usec' is member of `struct stat'. */
+/* Define to 1 if `st_mtime_usec' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_MTIME_USEC 1
 
-/* Define to 1 if `st_mtim.tv_nsec' is member of `struct stat'. */
+/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
 
-/* Define to 1 if `st_umtime' is member of `struct stat'. */
+/* Define to 1 if `st_umtime' is a member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_UMTIME 1
 
-/* Define to 1 if you have the symlink() function. */
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+#cmakedefine HAVE_STRUCT_TM_TM_GMTOFF 1
+
+/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
+#cmakedefine HAVE_STRUCT_TM___TM_GMTOFF 1
+
+/* Define to 1 if you have the `symlink' function. */
 #cmakedefine HAVE_SYMLINK 1
 
 /* Define to 1 if you have the <sys/acl.h> header file. */
 #cmakedefine HAVE_SYS_ACL_H 1
 
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#cmakedefine HAVE_SYS_CDEFS_H 1
+
 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
    */
 #cmakedefine HAVE_SYS_DIR_H 1
 
+/* Define to 1 if you have the <sys/ea.h> header file. */
+#cmakedefine HAVE_SYS_EA_H 1
+
 /* Define to 1 if you have the <sys/extattr.h> header file. */
 #cmakedefine HAVE_SYS_EXTATTR_H 1
 
@@ -463,6 +849,9 @@
 /* Define to 1 if you have the <sys/mkdev.h> header file. */
 #cmakedefine HAVE_SYS_MKDEV_H 1
 
+/* Define to 1 if you have the <sys/mount.h> header file. */
+#cmakedefine HAVE_SYS_MOUNT_H 1
+
 /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
    */
 #cmakedefine HAVE_SYS_NDIR_H 1
@@ -476,6 +865,12 @@
 /* Define to 1 if you have the <sys/select.h> header file. */
 #cmakedefine HAVE_SYS_SELECT_H 1
 
+/* Define to 1 if you have the <sys/statfs.h> header file. */
+#cmakedefine HAVE_SYS_STATFS_H 1
+
+/* Define to 1 if you have the <sys/statvfs.h> header file. */
+#cmakedefine HAVE_SYS_STATVFS_H 1
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #cmakedefine HAVE_SYS_STAT_H 1
 
@@ -488,6 +883,12 @@
 /* Define to 1 if you have the <sys/utime.h> header file. */
 #cmakedefine HAVE_SYS_UTIME_H 1
 
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#cmakedefine HAVE_SYS_UTSNAME_H 1
+
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+#cmakedefine HAVE_SYS_VFS_H 1
+
 /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
 #cmakedefine HAVE_SYS_WAIT_H 1
 
@@ -503,9 +904,6 @@
 /* Define to 1 if you have the `tzset' function. */
 #cmakedefine HAVE_TZSET 1
 
-/* Define to 1 if the system has the type `uintmax_t'. */
-#cmakedefine HAVE_UINTMAX_T 1
-
 /* Define to 1 if you have the <unistd.h> header file. */
 #cmakedefine HAVE_UNISTD_H 1
 
@@ -521,6 +919,9 @@
 /* Define to 1 if you have the `utime' function. */
 #cmakedefine HAVE_UTIME 1
 
+/* Define to 1 if you have the `utimensat' function. */
+#cmakedefine HAVE_UTIMENSAT 1
+
 /* Define to 1 if you have the `utimes' function. */
 #cmakedefine HAVE_UTIMES 1
 
@@ -542,30 +943,66 @@
 /* Define to 1 if you have the `wcrtomb' function. */
 #cmakedefine HAVE_WCRTOMB 1
 
+/* Define to 1 if you have the `wcscmp' function. */
+#cmakedefine HAVE_WCSCMP 1
+
 /* Define to 1 if you have the `wcscpy' function. */
 #cmakedefine HAVE_WCSCPY 1
 
 /* Define to 1 if you have the `wcslen' function. */
 #cmakedefine HAVE_WCSLEN 1
 
+/* Define to 1 if you have the `wcsnrtombs' function. */
+#cmakedefine HAVE_WCSNRTOMBS 1
+
 /* Define to 1 if you have the `wctomb' function. */
 #cmakedefine HAVE_WCTOMB 1
 
 /* Define to 1 if you have the <wctype.h> header file. */
 #cmakedefine HAVE_WCTYPE_H 1
 
+/* Define to 1 if you have the <wincrypt.h> header file. */
+#cmakedefine HAVE_WINCRYPT_H 1
+
 /* Define to 1 if you have the <windows.h> header file. */
 #cmakedefine HAVE_WINDOWS_H 1
 
+/* Define to 1 if you have the <winioctl.h> header file. */
+#cmakedefine HAVE_WINIOCTL_H 1
+
+/* Define to 1 if you have _CrtSetReportMode in <crtdbg.h>  */
+#cmakedefine HAVE__CrtSetReportMode 1
+
 /* Define to 1 if you have the `wmemcmp' function. */
 #cmakedefine HAVE_WMEMCMP 1
 
 /* Define to 1 if you have the `wmemcpy' function. */
 #cmakedefine HAVE_WMEMCPY 1
 
+/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */
+#cmakedefine HAVE_WORKING_EXT2_IOC_GETFLAGS 1
+
 /* Define to 1 if you have the <zlib.h> header file. */
 #cmakedefine HAVE_ZLIB_H 1
 
+/* Define to 1 if you have the `_ctime64_s' function. */
+#cmakedefine HAVE__CTIME64_S 1
+
+/* Define to 1 if you have the `_fseeki64' function. */
+#cmakedefine HAVE__FSEEKI64 1
+
+/* Define to 1 if you have the `_get_timezone' function. */
+#cmakedefine HAVE__GET_TIMEZONE 1
+
+/* Define to 1 if you have the `_localtime64_s' function. */
+#cmakedefine HAVE__LOCALTIME64_S 1
+
+/* Define to 1 if you have the `_mkgmtime64' function. */
+#cmakedefine HAVE__MKGMTIME64 1
+
+/* Define as const if the declaration of iconv() needs const. */
+#define ICONV_CONST ${ICONV_CONST}
+
 /* Version number of libarchive as a single integer */
 #cmakedefine LIBARCHIVE_VERSION_NUMBER "${LIBARCHIVE_VERSION_NUMBER}"
 
@@ -584,36 +1021,9 @@
    <sysmacros.h>. */
 #cmakedefine MAJOR_IN_SYSMACROS 1
 
-/* Define to the generates final MD5 hash function. */
-#cmakedefine MD5_Final ${MD5_Final}
-
-/* Define to the initializes MD5 context function. */
-#cmakedefine MD5_Init ${MD5_Init}
-
-/* Define to the updates MD5 context function. */
-#cmakedefine MD5_Update ${MD5_Update}
-
 /* Define to 1 if your C compiler doesn't accept -c and -o together. */
 #cmakedefine NO_MINUS_C_MINUS_O 1
 
-/* Define to the generates final RIPEMD160 hash function. */
-#cmakedefine RIPEMD160_Final ${RIPEMD160_Final}
-
-/* Define to the initializes RIPEMD160 context function. */
-#cmakedefine RIPEMD160_Init ${RIPEMD160_Init}
-
-/* Define to the updates RIPEMD160 context function. */
-#cmakedefine RIPEMD160_Update ${RIPEMD160_Update}
-
-/* Define to the generates final SHA1 hash function. */
-#cmakedefine SHA1_Final ${SHA1_Final}
-
-/* Define to the initializes SHA1 context function. */
-#cmakedefine SHA1_Init ${SHA1_Init}
-
-/* Define to the updates SHA1 context function. */
-#cmakedefine SHA1_Update ${SHA1_Update}
-
 /* The size of `wchar_t', as computed by sizeof. */
 #cmakedefine SIZEOF_WCHAR_T ${SIZEOF_WCHAR_T}
 
@@ -623,6 +1033,33 @@
 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
 #cmakedefine TIME_WITH_SYS_TIME 1
 
+/*
+ * Some platform requires a macro to use extension functions.
+ */
+#cmakedefine SAFE_TO_DEFINE_EXTENSIONS 1
+#ifdef SAFE_TO_DEFINE_EXTENSIONS
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+#endif /* SAFE_TO_DEFINE_EXTENSIONS */
+
 /* Version number of package */
 #cmakedefine VERSION "${VERSION}"
 
@@ -635,10 +1072,9 @@
 /* Define for large files, on AIX-style hosts. */
 #cmakedefine _LARGE_FILES ${_LARGE_FILES}
 
-/* 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. */
-#cmakedefine _UINT64_T
+/* Define for Windows to use Windows 2000+ APIs. */
+#cmakedefine _WIN32_WINNT ${_WIN32_WINNT}
+#cmakedefine WINVER ${WINVER}
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #cmakedefine const ${const}
@@ -649,23 +1085,15 @@
 /* Define to `unsigned long' if <sys/types.h> does not define. */
 #cmakedefine id_t ${id_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. */
-#cmakedefine int64_t ${int64_t}
-
-/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
-   not define. */
-#cmakedefine intmax_t ${intmax_t}
-
 /* Define to `int' if <sys/types.h> does not define. */
 #cmakedefine mode_t ${mode_t}
 
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#cmakedefine dev_t ${dev_t}
-
 /* Define to `long long' if <sys/types.h> does not define. */
 #cmakedefine off_t ${off_t}
 
+/* Define to `int' if <sys/types.h> doesn't define. */
+#cmakedefine pid_t ${pid_t}
+
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #cmakedefine size_t ${size_t}
 
@@ -675,23 +1103,6 @@
 /* Define to `int' if <sys/types.h> doesn't define. */
 #cmakedefine uid_t ${uid_t}
 
-/* Define to `unsigned short' if <sys/types.h> doesn't define. */
-#cmakedefine uint16_t ${uint16_t}
-
-/* Define to `unsigned int' if <sys/types.h> doesn't define. */
-#cmakedefine uint32_t ${uint32_t}
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#cmakedefine int32_t ${int32_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. */
-#cmakedefine uint64_t ${uint64_t}
-
-/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
-   do not define. */
-#cmakedefine uintmax_t ${uintmax_t}
-
 /* Define to `int' if <sys/types.h> does not define. */
 #cmakedefine intptr_t ${intptr_t}
 

+ 11 - 0
Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in

@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libarchive
+Description: library that can create and read several streaming archive formats
+Version: @VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -larchive
+Libs.private: @LIBS@

+ 0 - 63
Utilities/cmlibarchive/build/release.sh

@@ -1,63 +0,0 @@
-#!/bin/sh +v
-
-PATH=/usr/local/gnu-autotools/bin/:$PATH
-export PATH
-
-# BSD make's "OBJDIR" support freaks out the automake-generated
-# Makefile.  Effectively disable it.
-export MAKEOBJDIRPREFIX=/junk
-
-# Start from the build directory, where the version file is located
-if [ -f build/version ]; then
-    cd build
-fi
-
-if [ \! -f version ]; then
-    echo "Can't find version file"
-    exit 1
-fi
-
-# Update the build number in the 'version' file.
-# Separate number from additional alpha/beta/etc marker
-MARKER=`cat version | sed 's/[0-9.]//g'`
-# Bump the number
-VN=`cat version | sed 's/[^0-9.]//g'`
-# Reassemble and write back out
-VN=$(($VN + 1))
-rm -f version.old
-mv version version.old
-chmod +w version.old
-echo $VN$MARKER > version
-# Build out the string.
-VS="$(($VN/1000000)).$(( ($VN/1000)%1000 )).$(( $VN%1000 ))$MARKER"
-
-cd ..
-
-# Substitute the integer version into Libarchive's archive.h
-perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive.h
-perl -p -i -e "s/^(#define\tARCHIVE_VERSION_STRING).*/\$1 \"libarchive $VS\"/" libarchive/archive.h
-# Substitute the string version into tar and cpio Makefiles
-perl -p -i -e "s/^(BSDTAR_VERSION_STRING)=.*/\$1=$VS/" tar/Makefile
-perl -p -i -e "s/^(BSDCPIO_VERSION_STRING)=.*/\$1=$VS/" cpio/Makefile
-# 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
-
-# Add a version notice to NEWS
-mv NEWS NEWS.bak
-chmod +w NEWS.bak
-echo > NEWS
-echo `date +"%b %d, %Y:"` libarchive $VS released >> NEWS
-cat NEWS.bak >> NEWS
-
-# Clean up first
-rm -rf /usr/obj`pwd`
-(cd examples/minitar && make cleandir && make clean)
-(cd libarchive && make cleandir && make clean)
-(cd libarchive/test && make cleandir && make clean && make list.h)
-(cd tar && make cleandir && make clean)
-
-# Build the libarchive distfile
-/bin/sh build/autogen.sh
-./configure
-make distcheck

+ 418 - 0
Utilities/cmlibarchive/build/utils/gen_archive_string_composition_h.sh

@@ -0,0 +1,418 @@
+#!/bin/sh
+#
+# This needs http://unicode.org/Public/UNIDATA/UnicodeData.txt
+#
+inputfile="$1"	# Expect UnicodeData.txt
+outfile=archive_string_composition.h
+pickout=/tmp/mk_unicode_composition_tbl$$.awk
+#################################################################################
+#
+# Append the file header of "archive_string_composition.h"
+#
+#################################################################################
+append_copyright()
+{
+cat > ${outfile} <<CR_END
+/*-
+ * Copyright (c) 2011 libarchive Project
+ * 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\$
+ *
+ */
+
+/*
+ * ATTENTION!
+ *  This file is generated by build/utils/gen_archive_string_composition_h.sh
+ *  from http://unicode.org/Public/UNIDATA/UnicodeData.txt
+ *
+ *  See also http://unicode.org/report/tr15/
+ */
+
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+#ifndef ARCHIVE_STRING_COMPOSITION_H_INCLUDED
+#define ARCHIVE_STRING_COMPOSITION_H_INCLUDED
+
+struct unicode_composition_table {
+	uint32_t cp1;
+	uint32_t cp2;
+	uint32_t nfc;
+};
+
+CR_END
+}
+#################################################################################
+#
+# awk script
+#
+#################################################################################
+cat > ${pickout} <<AWK_END
+#
+BEGIN {
+  FS = ";"
+  min = "";
+  max = "";
+  cmd="sort | awk -F ' ' '{printf \"\\\\t{ 0x%s , 0x%s , 0x%s },\\\\n\",\$1,\$2,\$3}'"
+  print "static const struct unicode_composition_table u_composition_table[] = {"
+}
+END {
+  close(cmd)
+  print "};"
+  print ""
+  #
+  # Output Canonical Combining Class tables used for translating NFD to NFC.
+  #
+  printf "#define CANONICAL_CLASS_MIN\\t0x%s\\n", min
+  printf "#define CANONICAL_CLASS_MAX\\t0x%s\\n", max
+  print ""
+  printf "#define IS_DECOMPOSABLE_BLOCK(uc)\\t\\\\\n"
+  printf "\\t(((uc)>>8) <= 0x%X && u_decomposable_blocks[(uc)>>8])\\n", highnum
+  printf "static const char u_decomposable_blocks[0x%X+1] = {\\n\\t", highnum
+  #
+  # Output blockmap
+  for (i = 0; i <= highnum; i++) {
+    if (i != 0 && i % 32 == 0)
+      printf "\\n\\t"
+    # Additionally Hangul[11XX(17), AC00(172) - D7FF(215)] is decomposable.
+    if (blockmap[i] || i == 17 || (i >= 172 && i <= 215))
+        printf "1,"
+    else
+        printf "0,"
+  }
+  printf "\\n};\\n\\n"
+  #
+  # Output a macro to get a canonical combining class.
+  #
+  print "/* Get Canonical Combining Class(CCC). */"
+  printf "#define CCC(uc)\\t\\\\\n"
+  printf "\\t(((uc) > 0x%s)?0:\\\\\\n", max
+  printf "\\tccc_val[ccc_val_index[ccc_index[(uc)>>8]][((uc)>>4)&0x0F]][(uc)&0x0F])\\n"
+  print ""
+  #
+  # Output a canonical combining class value table.
+  #
+  midcnt = 0
+  printf "/* The table of the value of Canonical Cimbining Class */\\n"
+  print "static const unsigned char ccc_val[][16] = {"
+  print " /* idx=0: XXXX0 - XXXXF */"
+  print " { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },"
+  for (h = 0; h <= highnum; h++) {
+    if (!blockmap[h])
+      continue;
+    for (m = 0; m < 16; m++) {
+      if (!xx_blockmap[h, m])
+        continue;
+      midcnt++
+      printf " /* idx=%d: %03X%1X0 - %03X%1XF */\\n {", midcnt, h, m, h, m
+      for (l = 0; l < 15; l++) {
+        printf "%d, ", xxx_blockmap[h, m, l]
+      }
+      printf "%d },\n", xxx_blockmap[h, m, 15]
+    }
+  }
+  printf "};\n"
+  #
+  # Output the index table of the canonical combining class value table.
+  #
+  cnt = 0
+  midcnt = 0
+  printf "\\n/* The index table to ccc_val[*][16] */\\n"
+  print "static const unsigned char ccc_val_index[][16] = {"
+  print " /* idx=0: XXX00 - XXXFF */"
+  print " { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },"
+  for (h = 0; h <= highnum; h++) {
+    if (!blockmap[h])
+      continue;
+    cnt++
+    printf " /* idx=%d: %03X00 - %03XFF */\\n {", cnt, h, h
+    for (m = 0; m < 16; m++) {
+      if (m != 0)
+          printf ","
+      if (xx_blockmap[h, m]) {
+          midcnt++
+          printf "%2d", midcnt
+      } else
+          printf " 0"
+    }
+    printf " },\\n"
+  }
+  printf "};\\n"
+  #
+  # Output the index table to the index table of the canonical combining
+  # class value table.
+  #
+  printf "\\n/* The index table to ccc_val_index[*][16] */\\n"
+  printf "static const unsigned char ccc_index[] = {\\n ", h
+  cnt = 0
+  for (h = 0; h <= highnum; h++) {
+    if (h != 0 && h % 24 == 0)
+      printf "\\n "
+    if (blockmap[h]) {
+      cnt++;
+      printf "%2d,", cnt
+    } else
+      printf " 0,"
+  }
+  print "};"
+  print ""
+  print "#endif /* ARCHIVE_STRING_COMPOSITION_H_INCLUDED */"
+}
+#
+#
+function hextoi(hex)
+{
+  dec = 0
+  for (i=0; i < length(hex); i++) {
+    x = substr(hex, i+1, 1)
+    if (x ~/[0-9]/)
+	dec = dec * 16 + x;
+    else if (x == "A")
+	dec = dec * 16 + 10;
+    else if (x == "B")
+	dec = dec * 16 + 11;
+    else if (x == "C")
+	dec = dec * 16 + 12;
+    else if (x == "D")
+	dec = dec * 16 + 13;
+    else if (x == "E")
+	dec = dec * 16 + 14;
+    else if (x == "F")
+	dec = dec * 16 + 15;
+  }
+  return dec
+}
+#
+# Collect Canonical Combining Class values.
+#
+\$4 ~/^[0-9A-F]+$/ {
+  if (\$4 !~/^0$/) {
+    if (min == "") {
+      min = \$1
+    }
+    max = \$1
+    high = substr(\$1, 1, length(\$1) -2)
+    highnum = hextoi(high)
+    mid = substr(\$1, length(\$1) -1, 1)
+    midnum = hextoi(mid)
+    low = substr(\$1, length(\$1), 1)
+    lownum = hextoi(low)
+    blockmap[highnum] = 1
+    xx_blockmap[highnum, midnum] = 1
+    xxx_blockmap[highnum, midnum, lownum] = \$4
+  }
+}
+#
+# Following code points are not decomposed in MAC OS.
+#   U+2000  - U+2FFF
+#   U+F900  - U+FAFF
+#   U+2F800 - U+2FAFF
+#
+#\$1 ~/^2[0-9A-F][0-9A-F][0-9A-F]\$/ {
+#        next
+#}
+#\$1 ~/^F[9A][0-9A-F][0-9A-F]\$/ {
+#        next
+#}
+#\$1 ~/^2F[89A][0-9A-F][0-9A-F]\$/ {
+#        next
+#}
+#
+# Exclusion code points specified by  
+# http://unicode.org/Public/UNIDATA/CompositionExclusions.txt
+##
+# 1. Script Specifices
+##
+\$1 ~/^095[89ABCDEF]\$/ {
+    next
+}
+\$1 ~/^09D[CDF]\$/ {
+    next
+}
+\$1 ~/^0A3[36]\$/ {
+    next
+}
+\$1 ~/^0A5[9ABE]\$/ {
+    next
+}
+\$1 ~/^0B5[CD]\$/ {
+    next
+}
+\$1 ~/^0F4[3D]\$/ {
+    next
+}
+\$1 ~/^0F5[27C]\$/ {
+    next
+}
+\$1 ~/^0F69\$/ {
+    next
+}
+\$1 ~/^0F7[68]\$/ {
+    next
+}
+\$1 ~/^0F9[3D]\$/ {
+    next
+}
+\$1 ~/^0FA[27C]\$/ {
+    next
+}
+\$1 ~/^0FB9\$/ {
+    next
+}
+\$1 ~/^FB1[DF]\$/ {
+    next
+}
+\$1 ~/^FB2[ABCDEF]\$/ {
+    next
+}
+\$1 ~/^FB3[012345689ABCE]\$/ {
+    next
+}
+\$1 ~/^FB4[01346789ABCDE]\$/ {
+    next
+}
+##
+# 2. Post Composition Version precomposed characters
+##
+\$1 ~/^2ADC\$/ {
+    next
+}
+\$1 ~/^1D15[EF]\$/ {
+    next
+}
+\$1 ~/^1D16[01234]\$/ {
+    next
+}
+\$1 ~/^1D1B[BCDEF]\$/ {
+    next
+}
+\$1 ~/^1D1C0\$/ {
+    next
+}
+##
+# 3. Singleton Decompositions
+##
+\$1 ~/^034[01]\$/ {
+    next
+}
+\$1 ~/^037[4E]\$/ {
+    next
+}
+\$1 ~/^0387\$/ {
+    next
+}
+\$1 ~/^1F7[13579BD]\$/ {
+    next
+}
+\$1 ~/^1FB[BE]\$/ {
+    next
+}
+\$1 ~/^1FC[9B]\$/ {
+    next
+}
+\$1 ~/^1FD[3B]\$/ {
+    next
+}
+\$1 ~/^1FE[3BEF]\$/ {
+    next
+}
+\$1 ~/^1FF[9BD]\$/ {
+    next
+}
+\$1 ~/^200[01]\$/ {
+    next
+}
+\$1 ~/^212[6AB]\$/ {
+    next
+}
+\$1 ~/^232[9A]\$/ {
+    next
+}
+\$1 ~/^F9[0-9A-F][0-9A-F]\$/ {
+    next
+}
+\$1 ~/^FA0[0-9A-D]\$/ {
+    next
+}
+\$1 ~/^FA1[025-9A-E]\$/ {
+    next
+}
+\$1 ~/^FA2[0256A-D]\$/ {
+    next
+}
+\$1 ~/^FA[3-5][0-9A-F]\$/ {
+    next
+}
+\$1 ~/^FA6[0-9A-D]\$/ {
+    next
+}
+\$1 ~/^FA[7-9A-C][0-9A-F]\$/ {
+    next
+}
+\$1 ~/^FAD[0-9]\$/ {
+    next
+}
+\$1 ~/^2F[89][0-9A-F][0-9A-F]\$/ {
+    next
+}
+\$1 ~/^2FA0[0-9A-F]\$/ {
+    next
+}
+\$1 ~/^2FA1[0-9A-D]\$/ {
+    next
+}
+##
+# 4. Non-Starter Decompositions
+##
+\$1 ~/^0344\$/ {
+    next
+}
+\$1 ~/^0F7[35]\$/ {
+    next
+}
+\$1 ~/^0F81\$/ {
+    next
+}
+#
+# Output combinations for NFD ==> NFC.
+#
+\$6 ~/^[0-9A-F]+ [0-9A-F]+\$/ {
+    split(\$6, cp, " ")
+    if (length(\$1) == 4)
+        print "0"cp[1], "0"cp[2], "0"\$1 | cmd
+    else
+        print cp[1], cp[2], \$1 | cmd
+}
+AWK_END
+#################################################################################
+#
+# Run awk a script.
+#
+#################################################################################
+append_copyright
+awk -f ${pickout} ${inputfile} >> ${outfile}
+#
+# Remove awk the script.
+rm ${pickout}

+ 1 - 1
Utilities/cmlibarchive/build/version

@@ -1 +1 @@
-2007900a
+3000002

+ 0 - 448
Utilities/cmlibarchive/configure.ac

@@ -1,448 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-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],[2.7.900a])
-m4_define([LIBARCHIVE_VERSION_N],[2007900])
-
-dnl bsdtar and bsdcpio versioning tracks libarchive
-m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
-m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())
-
-#
-# Now starts the "real" configure script.
-#
-
-AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[[email protected]])
-# Make sure the srcdir contains "libarchive" directory
-AC_CONFIG_SRCDIR([libarchive])
-# Use auxiliary subscripts from this subdirectory (cleans up root)
-AC_CONFIG_AUX_DIR([build/autoconf])
-# M4 scripts
-AC_CONFIG_MACRO_DIR([build/autoconf])
-# Must follow AC_CONFIG macros above...
-AM_INIT_AUTOMAKE()
-
-# Libtool versioning uses different conventions on different
-# platforms.  At least on FreeBSD, libtool uses an overly complex
-# convention that attempts to solve problems that most people just
-# don't have and which just causes confusion for most end users.
-ARCHIVE_MAJOR=$(( LIBARCHIVE_VERSION_N() / 1000000 ))
-ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
-ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
-ARCHIVE_LIBTOOL_MAJOR=`echo $((${ARCHIVE_MAJOR} + ${ARCHIVE_MINOR}))`
-ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_LIBTOOL_MAJOR:$ARCHIVE_REVISION:$ARCHIVE_MINOR
-
-# Stick the version numbers into config.h
-AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
-    [Version number of libarchive])
-AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
-    [Version number of libarchive as a single integer])
-AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
-    [Version number of bsdcpio])
-AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
-    [Version number of bsdtar])
-
-# 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()
-LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
-LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
-
-# Substitute the above version numbers into the various files below.
-# Yes, I believe this is the fourth time we define what are essentially
-# the same symbols.  Why? Ask autoconf.
-AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
-AC_SUBST(BSDCPIO_VERSION_STRING)
-AC_SUBST(BSDTAR_VERSION_STRING)
-AC_SUBST(LIBARCHIVE_VERSION_STRING)
-AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
-
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile])
-
-# Check for host type
-AC_CANONICAL_HOST
-
-dnl Compilation on mingw and Cygwin needs special Makefile rules
-inc_windows_files=no
-inc_cygwin_files=no
-case "$host_os" in
-  *mingw* ) inc_windows_files=yes ;;
-  *cygwin*) inc_cygwin_files=yes ;;
-esac
-AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
-AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
-
-dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
-PLATFORMCPPFLAGS=
-case "$host_os" in
-  *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
-esac
-AC_SUBST(PLATFORMCPPFLAGS)
-
-# Checks for programs.
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_LIBTOOL_WIN32_DLL
-AC_PROG_LIBTOOL
-AC_CHECK_TOOL([STRIP],[strip])
-
-#
-# Options for building bsdtar.
-#
-# Default is to build bsdtar, but allow people to override that.
-#
-AC_ARG_ENABLE([bsdtar],
-    [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
-    AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
-    AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
-AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
-    [], [enable_bsdtar=yes])
-
-case "$enable_bsdtar" in
-yes)
-    if test "$enable_static" = "no"; then
-        static_bsdtar=no
-    else
-        static_bsdtar=yes
-    fi
-    build_bsdtar=yes
-    ;;
-dynamic|shared)
-    if test "$enable_shared" = "no"; then
-        AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
-    fi
-    build_bsdtar=yes
-    static_bsdtar=no
-    ;;
-static)
-    build_bsdtar=yes
-    static_bsdtar=yes
-    ;;
-no)
-    build_bsdtar=no
-    static_bsdtar=no
-    ;;
-*)
-    AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
-    ;;
-esac
-
-AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
-AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
-
-#
-# Options for building bsdcpio.
-#
-# Default is not to build bsdcpio, but that can be overridden.
-#
-AC_ARG_ENABLE([bsdcpio],
-    [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
-    AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
-    AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
-AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
-    [], [enable_bsdcpio=yes])
-
-case "$enable_bsdcpio" in
-yes)
-    if test "$enable_static" = "no"; then
-       static_bsdcpio=no
-    else
-       static_bsdcpio=yes
-        fi
-    build_bsdcpio=yes
-    ;;
-dynamic|shared)
-    if test "$enabled_shared" = "no"; then
-       AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
-    fi
-    build_bsdcpio=yes
-    ;;
-static)
-    build_bsdcpio=yes
-    static_bsdcpio=yes
-    ;;
-no)
-    build_bsdcpio=no
-    static_bsdcpio=no
-    ;;
-*)
-    AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
-    ;;
-esac
-
-AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
-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.])
-  ;;
-esac
-
-# Checks for header files.
-AC_HEADER_STDC
-AC_HEADER_DIRENT
-AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h ctype.h errno.h])
-AC_CHECK_HEADERS([ext2fs/ext2_fs.h fcntl.h grp.h])
-AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h linux/fs.h])
-AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h signal.h stdarg.h])
-AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
-AC_CHECK_HEADERS([sys/acl.h sys/extattr.h sys/ioctl.h sys/mkdev.h])
-AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
-AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h windows.h])
-
-# Checks for libraries.
-AC_ARG_WITH([zlib],
-  AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
-
-if test "x$with_zlib" != "xno"; then
-  AC_CHECK_HEADERS([zlib.h])
-  AC_CHECK_LIB(z,inflate)
-fi
-
-AC_ARG_WITH([bz2lib],
-  AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
-
-if test "x$with_bz2lib" != "xno"; then
-  AC_CHECK_HEADERS([bzlib.h])
-  AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
-fi
-
-AC_ARG_WITH([lzmadec],
-  AS_HELP_STRING([--without-lzmadec], [Don't build support for lzma through lzmadec]))
-
-if test "x$with_lzmadec" != "xno"; then
-  AC_CHECK_HEADERS([lzmadec.h])
-  AC_CHECK_LIB(lzmadec,lzmadec_decode)
-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)
-fi
-
-AC_ARG_WITH([openssl],
-  AS_HELP_STRING([--without-openssl], [Don't build support for mtree hashes through openssl]))
-
-AC_CHECK_HEADERS([md5.h ripemd.h rmd160.h sha.h sha1.h sha2.h sha256.h])
-# Common names for libc implementation on NetBSD and OpenBSD
-AC_CHECK_FUNCS(MD5Init RMD160Init SHA1Init)
-# SHA2 on NetBSD and older OpenBSD
-AC_CHECK_FUNCS(SHA256_Init SHA384_Init SHA512_Init)
-# SHA2 on newer OpenBSD
-AC_CHECK_FUNCS(SHA256Init SHA384Init SHA512Init)
-
-if test "x$with_openssl" != "xno"; then
-  if test "$ac_cv_func_MD5Init" != "yes"; then
-    AC_CHECK_HEADERS([openssl/md5.h])
-    AC_SEARCH_LIBS([MD5_Init], [crypto])
-  fi
-  if test "$ac_cv_func_RMD160Init" != "yes"; then
-    AC_CHECK_HEADERS([openssl/ripemd.h])
-    AC_SEARCH_LIBS([RIMEMD160_Init], [crypto])
-  fi
-  if test "$ac_cv_func_SHA1Init" != "yes"; then
-    AC_CHECK_HEADERS([openssl/sha.h])
-    AC_SEARCH_LIBS([SHA1_Init], [crypto])
-  fi
-  if test "$ac_cv_func_SHA256Init" != "yes" ||
-     test "$ac_cv_func_SHA384Init" != "yes" ||
-     test "$ac_cv_func_SHA512Init" != "yes"; then
-    if test "$ac_cv_func_SHA256_Init" != "yes" ||
-       test "$ac_cv_func_SHA384_Init" != "yes" ||
-       test "$ac_cv_func_SHA512_Init" != "yes"; then
-      AC_CHECK_HEADERS([openssl/sha.h])
-      AC_SEARCH_LIBS([SHA256_Init SHA384_Init SHA512_Init], [crypto])
-    fi
-  fi
-fi
-
-# TODO: Give the user the option of using a pre-existing system
-# libarchive.  This will define HAVE_LIBARCHIVE which will cause
-# bsdtar_platform.h to use #include <...> for the libarchive headers.
-# Need to include Makefile.am magic to link against system
-# -larchive in that case.
-#AC_CHECK_LIB(archive,archive_version)
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-# AC_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
-# AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
-# most systems... default to "long long" instead.
-AC_CHECK_TYPE(off_t, [long long])
-AC_TYPE_SIZE_T
-AC_CHECK_TYPE(id_t, [unsigned long])
-AC_CHECK_TYPE(uintptr_t, [unsigned int])
-
-# Check for birthtime in struct stat
-AC_CHECK_MEMBERS([struct stat.st_birthtime])
-
-# Check for high-resolution timestamps in struct stat
-AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
-AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
-AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
-AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
-AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
-AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
-# Check for block size support in struct stat
-AC_CHECK_MEMBERS([struct stat.st_blksize])
-# Check for st_flags in struct stat (BSD fflags)
-AC_CHECK_MEMBERS([struct stat.st_flags])
-
-# If you have uintmax_t, we assume printf supports %ju
-# If you have unsigned long long, we assume printf supports %llu
-# TODO: Check for %ju and %llu support directly.
-AC_CHECK_TYPES([uintmax_t, unsigned long long])
-
-# We need int64_t, uint64_t, intmax_t, and uintmax_t
-AC_TYPE_INTMAX_T
-AC_TYPE_INT64_T
-AC_TYPE_UINTMAX_T
-AC_TYPE_UINT64_T
-
-# TODO: If any of these are missing, define them right here.
-AC_CHECK_DECLS([SIZE_MAX, SSIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
-
-AC_CHECK_DECL([EFTYPE],
-        [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
-        [],
-        [#include <errno.h>])
-AC_CHECK_DECL([EILSEQ],
-        [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
-        [],
-        [#include <errno.h>])
-AC_CHECK_TYPE([wchar_t],
-            [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
-        AC_CHECK_SIZEOF([wchar_t])],
-        [])
-
-AC_HEADER_TIME
-
-# Checks for library functions.
-AC_PROG_GCC_TRADITIONAL
-AC_HEADER_MAJOR
-AC_FUNC_FSEEKO
-AC_FUNC_MEMCMP
-AC_FUNC_LSTAT
-AC_FUNC_STAT
-AC_FUNC_STRERROR_R
-AC_FUNC_STRFTIME
-AC_FUNC_VPRINTF
-# check for:
-#   CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
-# 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])
-AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork])
-AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid])
-AC_CHECK_FUNCS([lchflags lchmod lchown link lstat])
-AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod])
-AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale])
-AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
-AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork])
-AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy])
-# detects cygwin-1.7, as opposed to older versions
-AC_CHECK_FUNCS([cygwin_conv_path])
-
-# FreeBSD's nl_langinfo supports an option to specify whether the
-# current locale uses month/day or day/month ordering.  It makes the
-# output a little prettier...
-AC_CHECK_DECL([D_MD_ORDER],
-[AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
-[],
-[#if HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-])
-
-# Check for dirent.d_namlen field explicitly
-# (This is a bit more straightforward than, if not quite as portable as,
-# the recipe given by the autoconf maintainers.)
-AC_CHECK_MEMBER(struct dirent.d_namlen,,,
-[#if HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-])
-
-# Check for Extended Attributes support
-AC_ARG_ENABLE([xattr],
-        AS_HELP_STRING([--disable-xattr],
-        [Enable Extended Attributes support (default: check)]))
-
-if test "x$enable_xattr" != "xno"; then
-    AC_CHECK_HEADERS([attr/xattr.h])
-    AC_CHECK_HEADERS([sys/xattr.h])
-    AC_CHECK_LIB(attr,setxattr)
-    AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
-    AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
-    AC_CHECK_FUNCS([fsetxattr getxattr])
-    AC_CHECK_FUNCS([lgetxattr listxattr llistxattr lsetxattr])
-fi
-
-# Check for ACL support
-#
-# The ACL support in libarchive is written against the POSIX1e draft,
-# which was never officially approved and varies quite a bit across
-# platforms.  Worse, some systems have completely non-POSIX acl functions,
-# which makes the following checks rather more complex than I would like.
-#
-AC_ARG_ENABLE([acl],
-        AS_HELP_STRING([--disable-acl],
-        [Enable ACL support (default: check)]))
-
-if test "x$enable_acl" != "xno"; then
-   AC_CHECK_HEADERS([sys/acl.h])
-   AC_CHECK_LIB([acl],[acl_get_file])
-   AC_CHECK_FUNCS([acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file])
-
-   AC_CHECK_TYPES(acl_permset_t,,,
-    [#if HAVE_SYS_TYPES_H
-    #include <sys/types.h>
-    #endif
-    #if HAVE_SYS_ACL_H
-    #include <sys/acl.h>
-    #endif
-    ])
-
-    # The "acl_get_perm()" function was omitted from the POSIX draft.
-    # (It's a pretty obvious oversight; otherwise, there's no way to
-    # test for specific permissions in a permset.)  Linux uses the obvious
-    # name, FreeBSD adds _np to mark it as "non-Posix extension."
-    # Test for both as a double-check that we really have POSIX-style ACL support.
-    AC_CHECK_FUNCS(acl_get_perm_np acl_get_perm acl_get_link acl_get_link_np,,,
-    [#if HAVE_SYS_TYPES_H
-    #include <sys/types.h>
-    #endif
-    #if HAVE_SYS_ACL_H
-    #include <sys/acl.h>
-    #endif
-    ])
-
-    # MacOS has an acl.h that isn't POSIX.  It can be detected by
-    # checking for ACL_USER
-    AC_CHECK_DECL([ACL_USER],
-        [AC_DEFINE(HAVE_ACL_USER, 1, [True for systems with POSIX ACL support])],
-        [],
-        [#include <sys/acl.h>])
-fi
-
-# Additional requirements
-AC_SYS_LARGEFILE
-
-AC_OUTPUT

+ 0 - 32
Utilities/cmlibarchive/contrib/README

@@ -1,32 +0,0 @@
-Many people have graciously sent me configuration
-files and other useful tidbits for use with libarchive.
-
-I do not support or use any of these; but if you can use them, enjoy!
-
-======================================================================
-
-From: Andre Stechert <[email protected]>
-
-libarchive_autodetect-st_lib_archive.m4
-
-M4 macros for use with autoconf to detect whether a suitable
-version of libarchive is installed on this system.
-
-
-======================================================================
-
-libarchive.spec
-
-An RPM ".spec" file for building libarchive on most systems.
-This apparently was originally developed by a group at pld-linux.org.
-Several people have sent me different versions of this file.
-
-======================================================================
-
-From: Robert Meier <[email protected]>
-
-libarchive.1aix53.spec
-
-As above, for use on AIX5.3.
-
-======================================================================

+ 0 - 160
Utilities/cmlibarchive/contrib/libarchive.1aix53.spec

@@ -1,160 +0,0 @@
-# $LastChangedRevision: 8 $, $LastChangedDate: 2008-04-30 18:11:33 -0400 (Wed, 30 Apr 2008) $
-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
-Release:        1aix53
-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/
-Requires:       glibc
-Requires:       zlib
-Requires:       bzip2
-BuildRequires:  gcc
-BuildRequires:  gcc-c++
-BuildRequires:  gawk
-BuildRequires:  zlib-devel
-BuildRequires:  bzip2
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-
-%description
-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.
-
-%prep
-%setup -q
-%patch0 -p1
-
-%build
-# Specify paths to avoid use of vacpp
-# -maix64 - required to use large files with aix-5.3
-# -static - required for interoperability without copying libraries
-# -D_BSD - required to include definition of makedev
-# -X64 - required to assemble 64-bit COFF files
-mkdir -p %{buildroot}
-PATH=/opt/freeware/libexec:/opt/freeware/bin:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:. \
-CPATH=/opt/freeware/include:/usr/local/include \
-LIBPATH=/opt/freeware/lib:/usr/local/lib:/usr/share/lib \
-LD_LIBRARY_PATH=/opt/freeware/lib:/usr/local/lib:/usr/share/lib \
-CFLAGS="$RPM_OPT_FLAGS -maix64 -static -D_BSD" \
-CXXFLAGS="$RPM_OPT_FLAGS -maix64 -static -D_BSD" \
-AR="ar -X64" \
-./configure \
---prefix=%{_prefix} \
---libexecdir=%{_libexecdir} \
---mandir=%{_mandir} \
---infodir=%{_infodir} \
---enable-shared=yes \
---enable-static=yes \
-| tee %{buildroot}/config.log
-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.a
-
-%files devel
-%defattr(644,root,root,755)
-%{_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"`)
-%changelog
-* %{date} PLD Team <[email protected]>
-All persons listed below can be reached at <cvs_login>@pld-linux.org
-
-$Log: libarchive.spec,v $
-Release 1aix53  2006/12/12 [email protected]
-- tweak for aix-5.3
-- 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 agains entering in 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

+ 0 - 147
Utilities/cmlibarchive/contrib/libarchive.spec

@@ -1,147 +0,0 @@
-# $LastChangedRevision: 8 $, $LastChangedDate: 2008-04-30 18:11:33 -0400 (Wed, 30 Apr 2008) $
-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
-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/
-Requires:       glibc
-Requires:       zlib
-Requires:       bzip2
-BuildRequires:  gcc
-BuildRequires:  gcc-c++
-BuildRequires:  gawk
-BuildRequires:  zlib-devel
-BuildRequires:  bzip2
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-
-%description
-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.
-
-%prep
-%setup -q
-%patch0 -p1
-
-%build
-mkdir -p %{buildroot}
-./configure \
---prefix=%{_prefix} \
---libexecdir=%{_libexecdir} \
---mandir=%{_mandir} \
---infodir=%{_infodir} \
---enable-shared=yes \
---enable-static=yes \
-| tee %{buildroot}/config.log
-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.a
-
-%files devel
-%defattr(644,root,root,755)
-%{_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"`)
-%changelog
-* %{date} PLD Team <[email protected]>
-All persons listed below can be reached at <cvs_login>@pld-linux.org
-
-$Log: libarchive.spec,v $
-Release 1  2006/12/12 [email protected]
-- 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 agains entering in 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

+ 0 - 154
Utilities/cmlibarchive/contrib/libarchive_autodetect-st_lib_archive.m4

@@ -1,154 +0,0 @@
-dnl
-dnl @synopsis ST_LIB_ARCHIVE([ENABLED-DEFAULT])
-dnl
-dnl This macro figures out what's necessary to link a program against an
-dnl instance of the BSD libarchive package by Tim Kientzle.
-dnl 
-dnl See http://people.freebsd.org/~kientzle/libarchive/ for more info.
-dnl
-dnl It exports and substitutes the variables LIBARCHIVE_LIBS, LIBARCHIVE_LDFLAGS,
-dnl and LIBARCHIVE_CPPFLAGS to appropriate values for the identified instance of
-dnl libarchive.  The values are AC_SUBST'd, so a user could, for example, simply
-dnl include @LIBARCHIVE_CPPFLAGS@ in the definition of AM_CPPFLAGS in a Makefile.am.
-dnl
-dnl ENABLED-DEFAULT is either "yes" or "no" and determines whether the default value
-dnl is --with-libarchive or --without-libarchive.  It is not possible to specify a
-dnl default directory.  More simply, any reasonable choice for a default should just
-dnl go into the auto-detect list.
-dnl
-dnl The macro defines the symbol HAVE_LIBARCHIVE if the library is found. You
-dnl should use autoheader to include a definition for this symbol in a config.h
-dnl file. Sample usage in a C/C++ source is as follows:
-dnl
-dnl   #ifdef HAVE_LIBARCHIVE
-dnl   #include <archive.h>
-dnl   #endif /* HAVE_LIBARCHIVE */
-dnl
-dnl @category InstalledPackages
-dnl @author Andre Stechert <[email protected]>
-dnl @version 2006-04-20
-dnl @license GPLWithACException
-
-AC_DEFUN([ST_LIB_ARCHIVE],
-[
-#
-# Handle input from the configurer and blend with the requirements from the maintainer.
-# We go through the trouble of creating a second set of variables other than the with_foo
-# variables in order to be sure that error/corner cases have been cleaned up.
-#
-# After this statement, three trusted variable are defined.
-#
-# st_lib_archive_ENABLED will be either "yes" or "no".  its value determines whether
-# or not we bother with the rest of the checks and whether or not we export a
-# bunch of variables.
-#
-# st_lib_archive_LOCATION will be either "auto" or "defined".  if it is "auto", then
-# we try a bunch of standard locations.  if it is "defined", then we just try the value
-# provided in st_lib_archive_DIR.
-#
-# st_lib_archive_DIR will contain the string provided by the user, provided that it's
-# actually a directory.
-#
-AC_MSG_CHECKING([if libarchive is wanted])
-AC_ARG_WITH([libarchive],
-    AS_HELP_STRING([--with-libarchive=DIR], [libarchive installation directory]),
-    [if test "x$with_libarchive" = "xno" ; then
-        st_lib_archive_ENABLED=no
-    elif test "x$with_libarchive" = "xyes" ; then
-        st_lib_archive_ENABLED=yes
-        st_lib_archive_LOCATION=auto
-    else
-        st_lib_archive_ENABLED=yes
-        st_lib_archive_LOCATION=defined
-        if test -d "$with_libarchive" ; then
-            st_lib_archive_DIR="$with_libarchive"
-        else
-            AC_MSG_ERROR([$with_libarchive is not a directory])
-        fi
-    fi],
-    [if test "x$1" = "xno" ; then
-        st_lib_archive_ENABLED=no
-    elif test "x$1" = "xyes" ; then
-        st_lib_archive_ENABLED=yes
-    else
-        st_lib_archive_ENABLED=yes
-    fi])
-
-if test "$st_lib_archive_ENABLED" = "yes" ; then
-    AC_MSG_RESULT([yes])
-#
-# After this statement, one trusted variable is defined.
-#
-# st_lib_archive_LIB will be either "lib" or "lib64", depending on whether the configurer
-# specified 32, 64.  The default is "lib".
-#
-    AC_MSG_CHECKING([whether to use lib or lib64])
-    AC_ARG_WITH([libarchive-bits],
-        AS_HELP_STRING([--with-libarchive-bits=32/64], [if 64, look in /lib64 on hybrid systems]),
-        [if test "x$with_libarchive_bits" = "x32" ; then
-            st_lib_archive_LIB=lib
-        elif test "x$with_libarchive_bits" = "x64" ; then
-            st_lib_archive_LIB=lib64
-        else
-            AC_MSG_ERROR([the argument must be either 32 or 64])
-        fi],
-        [st_lib_archive_LIB=lib])
-    AC_MSG_RESULT($st_lib_archive_LIB)
-#
-# Save the environment before verifying libarchive availability
-#
-    st_lib_archive_SAVECPPFLAGS="$CPPFLAGS"
-    st_lib_archive_SAVELDFLAGS="$LDFLAGS"
-    AC_LANG_SAVE
-    AC_LANG_C
-
-    if test "x$st_lib_archive_LOCATION" = "xdefined" ; then
-        CPPFLAGS="-I$st_lib_archive_DIR/include $st_lib_archive_SAVECPPFLAGS"
-        LDFLAGS="-L$st_lib_archive_DIR/$st_lib_archive_LIB $st_lib_archive_SAVELDFLAGS"
-        AC_CHECK_LIB(archive, archive_read_new, [st_lib_archive_found_lib=yes], [st_lib_archive_found_lib=no])
-        AC_CHECK_HEADER(archive.h, [st_lib_archive_found_hdr=yes], [st_lib_archive_found_hdr=no])
-        if test "x$st_lib_archive_found_lib" = "xyes" && test "x$st_lib_archive_found_hdr" = "xyes"; then
-            LIBARCHIVE_CPPFLAGS="-I$dir/include"
-            LIBARCHIVE_LDFLAGS="-L$dir/$st_lib_archive_LIB"
-        else
-            AC_MSG_ERROR([could not find libarchive in the requested location])
-        fi
-    else
-        #
-        # These are the common install directories for Linux, FreeBSD, Solaris, and Mac.
-        #
-        for dir in /usr /usr/local /usr/sfw /opt/csw /opt/local /sw
-        do
-            if test -d "$dir" ; then
-                CPPFLAGS="-I$dir/include $st_lib_archive_SAVECPPFLAGS"
-                LDFLAGS="-L$dir/$st_lib_archive_LIB $st_lib_archive_SAVELDFLAGS"
-                AC_CHECK_LIB(archive, archive_read_new, [st_lib_archive_found_lib=yes], [st_lib_archive_found_lib=no])
-                AC_CHECK_HEADER(archive.h, [st_lib_archive_found_hdr=yes], [st_lib_archive_found_hdr=no])
-                if test "x$st_lib_archive_found_lib" = "xyes" && test "x$st_lib_archive_found_hdr" = "xyes"; then
-                    LIBARCHIVE_CPPFLAGS="-I$dir/include"
-                    LIBARCHIVE_LDFLAGS="-L$dir/$st_lib_archive_LIB"
-                    break
-                fi
-            fi
-        done
-    fi
-
-    if test "x$st_lib_archive_found_hdr" = "xyes" && test "x$st_lib_archive_found_lib" = "xyes" ; then
-        LIBARCHIVE_LIBS="-larchive"
-        AC_DEFINE([HAVE_LIBARCHIVE], [1], [Defined to 1 if libarchive is available for use.])
-        AC_SUBST(LIBARCHIVE_LIBS)
-        AC_SUBST(LIBARCHIVE_CPPFLAGS)
-        AC_SUBST(LIBARCHIVE_LDFLAGS)
-    fi
-
-#
-# Restore the environment now that we're done.
-#
-    AC_LANG_RESTORE
-    CPPFLAGS="$st_lib_archive_SAVECPPFLAGS"
-    LDFLAGS="$st_lib_archive_SAVELDFLAGS"
-else
-    AC_MSG_RESULT([no])
-fi
-AM_CONDITIONAL(LIBARCHIVE, test "x$st_lib_archive_found_lib" = "xyes" && test "x$st_lib_archive_found_hdr" = "xyes")
-])

+ 0 - 122
Utilities/cmlibarchive/contrib/psota-benchmark/results.txt

@@ -1,122 +0,0 @@
-ODP: [Bug-tar] GNU tar, star and BSD tar speed comparision +new script
-
-Jan Psota
-Thu, 25 Oct 2007 06:51:13 -0700
-
-Latest TCP script at the bottom (3180 bytes).
-4 tests: 64bit dual core Athlon tmpfs / disk (reiserfs) - 60MB/s,
-        32bit Athlon tmpfs / disk (reiserfs) - 55MB/s
-Both machines were idle -- used for testing only.
-Tarball and extracted files were on different physical devices.
-Test data: linux 2.6.22/3 kernel sources for memory operations,
-for the other data average file size should bring enough info.
-
-2 x [...] processor means 1 processor with 2 cores (2 entries in cpuinfo).
-Archive format is set to pax (Joerg).
-Let's end with it. I only wanted to send You a new version of TCP script :-).
-
---
-Jan Psota
-
-TCP, version 2007-10-25
-Linux 2.6.22-suspend2-r2 / Gentoo Base System release 2.0.0_rc5
-2012MB of memory, 2 x AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ 2211.348 
-512 KB 4426.24 bmips
-gcc (GCC) 4.2.2 (Gentoo 4.2.2 p1.0)
-CFLAGS="-O2 -march=k8 -pipe"
-
-bsdtar: bsdtar 2.3.4 - libarchive 2.3.4
-gnutar: tar (GNU tar) 1.19
-star:   star: star 1.5a85 (x86_64-unknown-linux-gnu)
-
-best time of 5 repetitions,
-        src=linux-2.6.23, 291M in 23867 files, avg 13KB/file,
-        archive=/tmp/tcp.tar, extract to /tmp/tcptmp
-program operation       real    user    system  %CPU         speed
-bsdtar  create          0.764   0.232   0.532   99.96       370308 KB/s
-gnutar  create          0.743   0.200   0.512   95.87       380775 KB/s
-star    create          0.587   0.040   0.820   100.00      441247 KB/s
-
-bsdtar  list            0.164   0.096   0.068   99.84      1579341 KB/s
-gnutar  list            0.218   0.064   0.152   98.92      1188128 KB/s
-star    list            0.359   0.044   0.240   79.09       721481 KB/s
-
-bsdtar  extract         0.733   0.200   0.504   96.02       353358 KB/s
-gnutar  extract         0.625   0.092   0.508   96.02       414419 KB/s
-star    extract         0.875   0.096   0.980   100.00      296013 KB/s
-
-bsdtar  compare         0.001   0.000   0.000   0.00     259012000 KB/s
-gnutar  compare         0.719   0.288   0.400   95.66       360239 KB/s
-star    compare         0.695   0.224   0.636   100.00      372679 KB/s
-
-[...]
-best time of 3 repetitions,
-        src=/home, 3.2G in 7447 files, avg 554KB/file,
-        archive=/var/tcp.tar, extract to /mnt/a/tcptmp
-program operation       real    user    system  %CPU         speed
-bsdtar  create          184.680 0.552   13.365  7.53         17958 KB/s
-gnutar  create          159.240 0.256   12.417  7.95         20827 KB/s
-star    create          181.779 0.140   14.789  8.21         18203 KB/s
-
-bsdtar  list            0.053   0.032   0.016   91.41     62435471 KB/s
-gnutar  list            56.535  0.136   3.764   6.89         58531 KB/s
-star    list            56.652  0.080   5.236   9.38         58410 KB/s
-
-bsdtar  extract         78.914  0.820   15.149  20.23        41932 KB/s
-gnutar  extract         78.480  0.196   14.197  18.33        42164 KB/s
-star    extract         79.439  0.132   12.973  16.49        41655 KB/s
-
-bsdtar  compare         0.001   0.000   0.000   0.00    3309080000 KB/s
-gnutar  compare         61.771  3.464   8.905   20.02        53570 KB/s
-star    compare         57.561  1.728   9.897   20.19        57488 KB/s
-
-
-Linux 2.6.22-suspend2-smp / Gentoo Base System release 2.0.0_rc5
-504MB of memory, 1 x AMD Athlon(tm) Processor 1500.033 256 KB 3002.55 bmips
-gcc (GCC) 4.2.2 (Gentoo 4.2.2 p1.0)
-CFLAGS="-O2 -march=athlon-xp -mfpmath=sse -frename-registers -pipe"
-
-bsdtar: bsdtar 2.3.4 - libarchive 2.3.4
-gnutar: tar (GNU tar) 1.19
-star:   star: star 1.5a85 (i686-pc-linux-gnu)
-
-best time of 3 repetitions,
-        src=/usr/src/linux-2.6.22-suspend2/drivers, 119M in 5900 files,
-        avg 21KB/file, archive=/tmp/tcp.tar, extract to /tmp/tcptmp
-program operation       real    user    system  %CPU         speed
-bsdtar  create          1.329   0.192   1.132   99.63        89784 KB/s
-gnutar  create          1.223   0.124   1.092   99.46        97566 KB/s
-star    create          1.848   0.036   1.708   94.36        61372 KB/s
-
-bsdtar  list            0.167   0.060   0.108   100.00      679137 KB/s
-gnutar  list            0.161   0.040   0.124   100.00      704447 KB/s
-star    list            0.859   0.044   0.716   88.51       132032 KB/s
-
-bsdtar  extract         1.186   0.172   1.012   99.87        95629 KB/s
-gnutar  extract         1.064   0.056   1.004   99.63       106593 KB/s
-star    extract         1.920   0.088   1.724   94.40        59070 KB/s
-
-bsdtar  compare         0.002   0.000   0.000   0.00      56708000 KB/s
-gnutar  compare         0.925   0.232   0.692   99.90       122611 KB/s
-star    compare         1.569   0.376   1.096   93.79        72285 KB/s
-
-[...]
-best time of 3 repetitions,
-        src=/home/jasiu, 2.1G in 8416 files, avg 277KB/file,
-        archive=/home/j2/tcp.tar, extract to /mnt/a/tar/tcptmp
-program operation       real    user    system  %CPU         speed
-bsdtar  create          182.171 1.692   29.130  16.91        11584 KB/s
-gnutar  create          174.999 0.632   27.450  16.04        12059 KB/s
-star    create          180.004 0.360   41.795  23.41        11677 KB/s
-
-bsdtar  list            0.214   0.076   0.136   99.04      9822294 KB/s
-gnutar  list            0.210   0.076   0.136   100.00    10009385 KB/s
-star    list            43.462  0.148   18.109  42.00        48363 KB/s
-
-bsdtar  extract         94.912  4.476   31.574  37.98        22146 KB/s
-gnutar  extract         94.657  0.396   29.462  31.54        22206 KB/s
-star    extract         100.814 0.400   39.906  39.98        20849 KB/s
-
-bsdtar  compare         0.003   0.000   0.004   100.00   700657000 KB/s
-gnutar  compare         80.174  3.932   20.365  30.30        26217 KB/s
-star    compare         73.911  8.341   27.670  48.72        28439 KB/s

+ 0 - 104
Utilities/cmlibarchive/contrib/psota-benchmark/tcp.sh

@@ -1,104 +0,0 @@
-#!/bin/sh
-# tar comparision program
-# 2007-10-25 Jan Psota
-
-n=3                                     # number of repetitions
-TAR=(bsdtar gnutar star)                # TApeArchivers to compare
-OPT=("" "--seek" "-no-fsync")
-pax="--format=pax"                      # comment out for defaults
-OPN=(create list extract compare)       # operations
-version="2007-10-25"
-TIMEFORMAT=$'%R\t%U\t%S\t%P'
-LC_ALL=C
-
-test $# -ge 2 || {
-        echo -e "usage:\t$0 source_dir where_to_place_archive 
-[where_to_extract_it]
-
-TCP, version $version
-TCP stands for Tar Comparision Program here.
-It currently compares: BSD tar (bsdtar), GNU tar (gnutar) and star in archive
-creation, listing, extraction and archive-to-extracted comparision.
-Tcp prints out best time of n=$n repetitions.
-
-Tcp creates temporary archive named tcp.tar with $pax and some native
-(--seek/-no-fsync) options and extracts it to [\$3]/tcptmp/.
-If unset, third argument defaults to [\$2].
-After normal exit tcp removes tarball and extracted files.
-Tcp does not check filesystems destination directories are on for free space,
-so make sure there is enough space (a bit more than source_dir uses) for both:
-archive and extracted files.
-Do not use white space in arguments.
-        Jan Psota, $version"
-        exit 0
-}
-src=$1
-dst=$2/tcp.tar
-dst_path=${3:-$2}/tcptmp
-test -e $dst -o -e /tmp/tcp \
-        && { echo "$dst or /tmp/tcp exists, exiting"; exit 1; }
-mkdir $dst_path || exit 2
-
-use_times ()
-{
-        awk -F"\t" -vN=$n -vL="`du -k $dst`" -vOFS="\t" -vORS="" '
-                { if (NF==4) { printf "\t%s\t%10.1d KB/s\n", $0, ($1+0>0 ? 
-(L+0)/($1+0) : 0) } }' \
-                /tmp/tcp | sort | head -1
-        > /tmp/tcp
-}
-
-test -d $src || { echo "'$src' is not a directory"; exit 3; }
-
-# system information: type, release, memory, cpu(s), compiler and flags
-echo -e "TCP, version $version\n"`uname -sr`" / "`head -1 /etc/*-release`
-free -m | awk '/^Mem/ { printf "%dMB of memory, ", $2 }'
-test -e /proc/cpuinfo \
-        && awk -F: '/name|cache size|MHz|mips/ { if (!a) b=b $2 }
-        /^$/ { a++ } END { print a" x"b" bmips" }' /proc/cpuinfo
-test -e /etc/gentoo-release \
-        && gcc --version | head -1 && grep ^CFLAGS /etc/make.conf
-
-# tar versions
-echo
-for tar in [EMAIL PROTECTED]; do echo -ne "$tar:\t"; $tar --version | head -1; 
-done
-
-echo -e "\nbest time of $n repetitions,\n"\
-"       src=$src, "\
-`du -sh $src | awk '{print $1}'`" in "`find $src | wc -l`" files, "\
-"avg "$((`du -sk $src | awk '{print $1}'`/`find $src -type f | wc 
--l`))"KB/file,\n"\
-"       archive=$dst, extract to $dst_path"
-
-echo -e "program\toperation\treal\tuser\tsystem\t%CPU\t     speed"
-> /tmp/tcp
-let op_num=0
-for op in "cf $dst $pax -C $src ." "tf $dst" "xf $dst -C $dst_path" \
-        "f $dst -C $dst_path --diff"; do
-        let tar_num=0
-        for tar in [EMAIL PROTECTED]; do
-                echo -en "$tar\t${OPN[op_num]}\t"
-                for ((i=1; i<=$n; i++)); do
-                        echo $op | grep -q ^cf && rm -f $dst
-                        echo $op | grep -q ^xf &&
-                                { chmod -R u+w $dst_path
-                                rm -rf $dst_path; mkdir $dst_path; }
-                        sync
-                        if echo $op | grep -q ^f; then  # op == compare
-                                time $tar $op ${OPT[$tar_num]} > /dev/null
-                        else    # op in (create | list | extract)
-                                time $tar $op ${OPT[$tar_num]} > /dev/null \
-                                        || break 3
-                        fi 2>> /tmp/tcp
-                done
-                use_times
-                let tar_num++
-        done
-        let op_num++
-        echo
-done
-rm -rf $dst_path $dst
-echo
-cat /tmp/tcp
-rm -f /tmp/tcp

+ 0 - 128
Utilities/cmlibarchive/contrib/shar/shar.1

@@ -1,128 +0,0 @@
-.\" Copyright (c) 1990, 1993
-.\" The Regents of the University of California.  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.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     @(#)shar.1  8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
-.\"
-.Dd April 17, 2008
-.Dt SHAR 1
-.Os
-.Sh NAME
-.Nm shar
-.Nd create a shell archive of files
-.Sh SYNOPSIS
-.Nm
-.Op Fl br
-.Op Fl o Ar archive-file
-.Ar
-.Sh DESCRIPTION
-The
-.Nm
-command writes a
-.Xr sh 1
-shell script which will recreate the file hierarchy specified by the command
-line operands.
-.Pp
-The
-.Nm
-command is normally used for distributing files by
-.Xr ftp 1
-or
-.Xr mail 1 .
-.Pp
-The following options are available:
-.Bl -tag -width indent
-.It Fl b
-Use an alternative binary format.  Content of files will be uuencoded.
-This option should be used to archive binary files correctly.
-In this mode also file permissions will be stored to the archive.
-uudecode(1) is needed to extract archives created with this option.
-.It Fl o Ar archive-file
-Redirect output to
-.Ar archive-file .
-.It Fl r
-If
-.Ar file
-given on command line is a directory the entire subtree will be archived.
-Symbolic links given on command line are followed.  Other symbolic links will
-be archived as such.
-.El
-.Sh EXAMPLES
-To create a shell archive of the program
-.Xr ls 1
-and mail it to Rick:
-.Bd -literal -offset indent
-cd ls
-shar -r . \&| mail -s "ls source" rick
-.Ed
-.Pp
-To recreate the program directory:
-.Bd -literal -offset indent
-mkdir ls
-cd ls
-\&...
-<delete header lines and examine mailed archive>
-\&...
-sh archive
-.Ed
-.Sh SEE ALSO
-.Xr compress 1 ,
-.Xr mail 1 ,
-.Xr tar 1 ,
-.Xr uuencode 1 ,
-.Xr uuencode 5
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Bx 4.4 .
-This is a re-implementation based on the libarchive(3) library.
-.Sh BUGS
-The
-.Nm
-command makes no provisions for hard links.
-.Pp
-Files containing magic characters or files without a newline ('\\n') as the
-last character are not handled correctly with the default format.  Use the -b
-option for binary files.
-.Pp
-It is easy to insert trojan horses into
-.Nm
-files.
-It is strongly recommended that all shell archive files be examined
-before running them through
-.Xr sh 1 .
-Archives produced using this implementation of
-.Nm
-may be easily examined with the command:
-.Bd -literal -offset indent
-egrep -v '^[X#]' shar.file
-.Ed

+ 0 - 314
Utilities/cmlibarchive/contrib/shar/shar.c

@@ -1,314 +0,0 @@
-/*-
- * Copyright (c) 2008 Jaakko Heinonen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifdef __FBSDID
-__FBSDID("$FreeBSD$");
-#endif
-
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <archive.h>
-#include <archive_entry.h>
-#include <assert.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "tree.h"
-
-/* command line options */
-static int  b_opt;  /* use alternative shar binary format */
-static int  r_opt;  /* recurse into subdirectories */
-static char *o_arg; /* output file name */
-
-static void
-usage(void)
-{
-    fprintf(stderr, "Usage: shar [-br] [-o filename] file ...\n");
-    exit(EX_USAGE);
-}
-
-/*
- * Initialize archive structure and create a shar archive.
- */
-static struct archive *
-shar_create(void)
-{
-    struct archive *a;
-
-    if ((a = archive_write_new()) == NULL)
-        errx(EXIT_FAILURE, "%s", archive_error_string(a));
-
-    if (b_opt)
-        archive_write_set_format_shar_dump(a);
-    else
-        archive_write_set_format_shar(a);
-    archive_write_set_compression_none(a);
-
-    if (archive_write_open_filename(a, o_arg) != ARCHIVE_OK)
-        errx(EX_CANTCREAT, "%s", archive_error_string(a));
-
-    return (a);
-}
-
-/* buffer for file data */
-static char buffer[32768];
-
-/*
- * Write file data to an archive entry.
- */
-static int
-shar_write_entry_data(struct archive *a, const int fd)
-{
-    ssize_t bytes_read, bytes_written;
-
-    assert(a != NULL);
-    assert(fd >= 0);
-
-    bytes_read = read(fd, buffer, sizeof(buffer));
-    while (bytes_read != 0) {
-        if (bytes_read < 0) {
-            archive_set_error(a, errno, "Read failed");
-            return (ARCHIVE_WARN);
-        }
-        bytes_written = archive_write_data(a, buffer, bytes_read);
-        if (bytes_written < 0)
-            return (ARCHIVE_WARN);
-        bytes_read = read(fd, buffer, sizeof(buffer));
-    }
-
-    return (ARCHIVE_OK);
-}
-
-/*
- * Write a file to the archive. We have special handling for symbolic links.
- */
-static int
-shar_write_entry(struct archive *a, const char *pathname, const char *accpath,
-    const struct stat *st)
-{
-    struct archive_entry *entry;
-    int fd = -1;
-    int ret = ARCHIVE_OK;
-
-    assert(a != NULL);
-    assert(pathname != NULL);
-    assert(accpath != NULL);
-    assert(st != NULL);
-
-    entry = archive_entry_new();
-
-    if (S_ISREG(st->st_mode) && st->st_size > 0) {
-        /* regular file */
-        if ((fd = open(accpath, O_RDONLY)) == -1) {
-            warn("%s", accpath);
-            ret = ARCHIVE_WARN;
-            goto out;
-        }
-    } else if (S_ISLNK(st->st_mode)) {
-        /* symbolic link */
-        char lnkbuff[PATH_MAX + 1];
-        int lnklen;
-        if ((lnklen = readlink(accpath, lnkbuff, PATH_MAX)) == -1) {
-            warn("%s", accpath);
-            ret = ARCHIVE_WARN;
-            goto out;
-        }
-        lnkbuff[lnklen] = '\0';
-        archive_entry_set_symlink(entry, lnkbuff);
-    }
-    archive_entry_copy_stat(entry, st);
-    archive_entry_set_pathname(entry, pathname);
-    if (!S_ISREG(st->st_mode) || st->st_size == 0)
-        archive_entry_set_size(entry, 0);
-    if (archive_write_header(a, entry) != ARCHIVE_OK) {
-        warnx("%s: %s", pathname, archive_error_string(a));
-        ret = ARCHIVE_WARN;
-        goto out;
-    }
-    if (fd >= 0) {
-        if ((ret = shar_write_entry_data(a, fd)) != ARCHIVE_OK)
-            warnx("%s: %s", accpath, archive_error_string(a));
-    }
-out:
-    archive_entry_free(entry);
-    if (fd >= 0)
-        close(fd);
-
-    return (ret);
-}
-
-/*
- * Write singe path to the archive. The path can be a regular file, directory
- * or device. Symbolic links are followed.
- */
-static int
-shar_write_path(struct archive *a, const char *pathname)
-{
-    struct stat st;
-
-    assert(a != NULL);
-    assert(pathname != NULL);
-
-    if ((stat(pathname, &st)) == -1) {
-        warn("%s", pathname);
-        return (ARCHIVE_WARN);
-    }
-
-    return (shar_write_entry(a, pathname, pathname, &st));
-}
-
-/*
- * Write tree to the archive. If pathname is a symbolic link it will be
- * followed. Other symbolic links are stored as such to the archive.
- */
-static int
-shar_write_tree(struct archive *a, const char *pathname)
-{
-    struct tree *t;
-    const struct stat *lst, *st;
-    int error = 0;
-    int tree_ret;
-    int first;
-
-    assert(a != NULL);
-    assert(pathname != NULL);
-
-    t = tree_open(pathname);
-    for (first = 1; (tree_ret = tree_next(t)); first = 0) {
-        if (tree_ret == TREE_ERROR_DIR) {
-            warnx("%s: %s", tree_current_path(t),
-                strerror(tree_errno(t)));
-            error = 1;
-            continue;
-        } else if (tree_ret != TREE_REGULAR)
-            continue;
-        if ((lst = tree_current_lstat(t)) == NULL) {
-            warn("%s", tree_current_path(t));
-            error = 1;
-            continue;
-        }
-        /*
-         * If the symlink was given on command line then
-         * follow it rather than write it as symlink.
-         */
-        if (first && S_ISLNK(lst->st_mode)) {
-            if ((st = tree_current_stat(t)) == NULL) {
-                warn("%s", tree_current_path(t));
-                error = 1;
-                continue;
-            }
-        } else
-            st = lst;
-
-        if (shar_write_entry(a, tree_current_path(t),
-            tree_current_access_path(t), st) != ARCHIVE_OK)
-            error = 1;
-
-        tree_descend(t);
-    }
-
-    tree_close(t);
-
-    return ((error != 0) ? ARCHIVE_WARN : ARCHIVE_OK);
-}
-
-/*
- * Create a shar archive and write files/trees into it.
- */
-static int
-shar_write(char **fn, size_t nfn)
-{
-    struct archive *a;
-    size_t i;
-    int error = 0;
-
-    assert(fn != NULL);
-    assert(nfn > 0);
-
-    a = shar_create();
-
-    for (i = 0; i < nfn; i++) {
-        if (r_opt) {
-            if (shar_write_tree(a, fn[i]) !=  ARCHIVE_OK)
-                error = 1;
-        } else {
-            if (shar_write_path(a, fn[i]) != ARCHIVE_OK)
-                error = 1;
-        }
-    }
-
-    if (archive_write_finish(a) != ARCHIVE_OK)
-        errx(EXIT_FAILURE, "%s", archive_error_string(a));
-
-    if (error != 0)
-        warnx("Error exit delayed from previous errors.");
-
-    return (error);
-}
-
-int
-main(int argc, char **argv)
-{
-    int opt;
-
-    while ((opt = getopt(argc, argv, "bro:")) != -1) {
-        switch (opt) {
-        case 'b':
-            b_opt = 1;
-            break;
-        case 'o':
-            o_arg = optarg;
-            break;
-        case 'r':
-            r_opt = 1;
-            break;
-        default:
-            usage();
-            /* NOTREACHED */
-        }
-    }
-    argc -= optind;
-    argv += optind;
-
-    if(argc < 1)
-        usage();
-
-    if (shar_write(argv, argc) != 0)
-        exit(EXIT_FAILURE);
-    else
-        exit(EXIT_SUCCESS);
-    /* NOTREACHED */
-}
-

+ 0 - 542
Utilities/cmlibarchive/contrib/shar/tree.c

@@ -1,542 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*-
- * This is a new directory-walking system that addresses a number
- * of problems I've had with fts(3).  In particular, it has no
- * pathname-length limits (other than the size of 'int'), handles
- * deep logical traversals, uses considerably less memory, and has
- * an opaque interface (easier to modify in the future).
- *
- * Internally, it keeps a single list of "tree_entry" items that
- * represent filesystem objects that require further attention.
- * Non-directories are not kept in memory: they are pulled from
- * readdir(), returned to the client, then freed as soon as possible.
- * Any directory entry to be traversed gets pushed onto the stack.
- *
- * There is surprisingly little information that needs to be kept for
- * each item on the stack.  Just the name, depth (represented here as the
- * string length of the parent directory's pathname), and some markers
- * indicating how to get back to the parent (via chdir("..") for a
- * regular dir or via fchdir(2) for a symlink).
- */
-#include "tree_config.h"
-__FBSDID("$FreeBSD$");
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "tree.h"
-
-/*
- * TODO:
- *    1) Loop checking.
- *    3) Arbitrary logical traversals by closing/reopening intermediate fds.
- */
-
-struct tree_entry {
-    struct tree_entry *next;
-    struct tree_entry *parent;
-    char *name;
-    size_t dirname_length;
-    dev_t dev;
-    ino_t ino;
-    int fd;
-    int flags;
-};
-
-/* Definitions for tree_entry.flags bitmap. */
-#define isDir 1 /* This entry is a regular directory. */
-#define isDirLink 2 /* This entry is a symbolic link to a directory. */
-#define needsPreVisit 4 /* This entry needs to be previsited. */
-#define needsPostVisit 8 /* This entry needs to be postvisited. */
-
-/*
- * Local data for this package.
- */
-struct tree {
-    struct tree_entry   *stack;
-    struct tree_entry   *current;
-    DIR *d;
-    int  initialDirFd;
-    int  flags;
-    int  visit_type;
-    int  tree_errno; /* Error code from last failed operation. */
-
-    char    *buff;
-    const char  *basename;
-    size_t   buff_length;
-    size_t   path_length;
-    size_t   dirname_length;
-
-    int  depth;
-    int  openCount;
-    int  maxOpenCount;
-
-    struct stat lst;
-    struct stat st;
-};
-
-/* Definitions for tree.flags bitmap. */
-#define needsReturn 8  /* Marks first entry as not having been returned yet. */
-#define hasStat 16  /* The st entry is set. */
-#define hasLstat 32 /* The lst entry is set. */
-
-
-#ifdef HAVE_DIRENT_D_NAMLEN
-/* BSD extension; avoids need for a strlen() call. */
-#define D_NAMELEN(dp)   (dp)->d_namlen
-#else
-#define D_NAMELEN(dp)   (strlen((dp)->d_name))
-#endif
-
-#if 0
-#include <stdio.h>
-void
-tree_dump(struct tree *t, FILE *out)
-{
-    struct tree_entry *te;
-
-    fprintf(out, "\tdepth: %d\n", t->depth);
-    fprintf(out, "\tbuff: %s\n", t->buff);
-    fprintf(out, "\tpwd: "); fflush(stdout); system("pwd");
-    fprintf(out, "\taccess: %s\n", t->basename);
-    fprintf(out, "\tstack:\n");
-    for (te = t->stack; te != NULL; te = te->next) {
-        fprintf(out, "\t\tte->name: %s%s%s\n", te->name,
-            te->flags & needsPreVisit ? "" : " *",
-            t->current == te ? " (current)" : "");
-    }
-}
-#endif
-
-/*
- * Add a directory path to the current stack.
- */
-static void
-tree_push(struct tree *t, const char *path)
-{
-    struct tree_entry *te;
-
-    te = malloc(sizeof(*te));
-    memset(te, 0, sizeof(*te));
-    te->next = t->stack;
-    t->stack = te;
-    te->fd = -1;
-    te->name = strdup(path);
-    te->flags = needsPreVisit | needsPostVisit;
-    te->dirname_length = t->dirname_length;
-}
-
-/*
- * Append a name to the current path.
- */
-static void
-tree_append(struct tree *t, const char *name, size_t name_length)
-{
-    char *p;
-
-    if (t->buff != NULL)
-        t->buff[t->dirname_length] = '\0';
-    /* Strip trailing '/' from name, unless entire name is "/". */
-    while (name_length > 1 && name[name_length - 1] == '/')
-        name_length--;
-
-    /* Resize pathname buffer as needed. */
-    while (name_length + 1 + t->dirname_length >= t->buff_length) {
-        t->buff_length *= 2;
-        if (t->buff_length < 1024)
-            t->buff_length = 1024;
-        t->buff = realloc(t->buff, t->buff_length);
-    }
-    p = t->buff + t->dirname_length;
-    t->path_length = t->dirname_length + name_length;
-    /* Add a separating '/' if it's needed. */
-    if (t->dirname_length > 0 && p[-1] != '/') {
-        *p++ = '/';
-        t->path_length ++;
-    }
-    strncpy(p, name, name_length);
-    p[name_length] = '\0';
-    t->basename = p;
-}
-
-/*
- * Open a directory tree for traversal.
- */
-struct tree *
-tree_open(const char *path)
-{
-    struct tree *t;
-
-    t = malloc(sizeof(*t));
-    memset(t, 0, sizeof(*t));
-    tree_append(t, path, strlen(path));
-    t->initialDirFd = open(".", O_RDONLY);
-    /*
-     * During most of the traversal, items are set up and then
-     * returned immediately from tree_next().  That doesn't work
-     * for the very first entry, so we set a flag for this special
-     * case.
-     */
-    t->flags = needsReturn;
-    return (t);
-}
-
-/*
- * We've finished a directory; ascend back to the parent.
- */
-static void
-tree_ascend(struct tree *t)
-{
-    struct tree_entry *te;
-
-    te = t->stack;
-    t->depth--;
-    if (te->flags & isDirLink) {
-        fchdir(te->fd);
-        close(te->fd);
-        t->openCount--;
-    } else {
-        chdir("..");
-    }
-}
-
-/*
- * Pop the working stack.
- */
-static void
-tree_pop(struct tree *t)
-{
-    struct tree_entry *te;
-
-    t->buff[t->dirname_length] = '\0';
-    if (t->stack == t->current && t->current != NULL)
-        t->current = t->current->parent;
-    te = t->stack;
-    t->stack = te->next;
-    t->dirname_length = te->dirname_length;
-    t->basename = t->buff + t->dirname_length;
-    /* Special case: starting dir doesn't skip leading '/'. */
-    if (t->dirname_length > 0)
-        t->basename++;
-    free(te->name);
-    free(te);
-}
-
-/*
- * Get the next item in the tree traversal.
- */
-int
-tree_next(struct tree *t)
-{
-    struct dirent *de = NULL;
-
-    /* Handle the startup case by returning the initial entry. */
-    if (t->flags & needsReturn) {
-        t->flags &= ~needsReturn;
-        return (t->visit_type = TREE_REGULAR);
-    }
-
-    while (t->stack != NULL) {
-        /* If there's an open dir, get the next entry from there. */
-        while (t->d != NULL) {
-            de = readdir(t->d);
-            if (de == NULL) {
-                closedir(t->d);
-                t->d = NULL;
-            } else if (de->d_name[0] == '.'
-                && de->d_name[1] == '\0') {
-                /* Skip '.' */
-            } else if (de->d_name[0] == '.'
-                && de->d_name[1] == '.'
-                && de->d_name[2] == '\0') {
-                /* Skip '..' */
-            } else {
-                /*
-                 * Append the path to the current path
-                 * and return it.
-                 */
-                tree_append(t, de->d_name, D_NAMELEN(de));
-                t->flags &= ~hasLstat;
-                t->flags &= ~hasStat;
-                return (t->visit_type = TREE_REGULAR);
-            }
-        }
-
-        /* If the current dir needs to be visited, set it up. */
-        if (t->stack->flags & needsPreVisit) {
-            t->current = t->stack;
-            tree_append(t, t->stack->name, strlen(t->stack->name));
-            t->stack->flags &= ~needsPreVisit;
-            /* If it is a link, set up fd for the ascent. */
-            if (t->stack->flags & isDirLink) {
-                t->stack->fd = open(".", O_RDONLY);
-                t->openCount++;
-                if (t->openCount > t->maxOpenCount)
-                    t->maxOpenCount = t->openCount;
-            }
-            t->dirname_length = t->path_length;
-            if (chdir(t->stack->name) != 0) {
-                /* chdir() failed; return error */
-                tree_pop(t);
-                t->tree_errno = errno;
-                return (t->visit_type = TREE_ERROR_DIR);
-            }
-            t->depth++;
-            t->d = opendir(".");
-            if (t->d == NULL) {
-                tree_ascend(t); /* Undo "chdir" */
-                tree_pop(t);
-                t->tree_errno = errno;
-                return (t->visit_type = TREE_ERROR_DIR);
-            }
-            t->flags &= ~hasLstat;
-            t->flags &= ~hasStat;
-            t->basename = ".";
-            return (t->visit_type = TREE_POSTDESCENT);
-        }
-
-        /* We've done everything necessary for the top stack entry. */
-        if (t->stack->flags & needsPostVisit) {
-            tree_ascend(t);
-            tree_pop(t);
-            t->flags &= ~hasLstat;
-            t->flags &= ~hasStat;
-            return (t->visit_type = TREE_POSTASCENT);
-        }
-    }
-    return (t->visit_type = 0);
-}
-
-/*
- * Return error code.
- */
-int
-tree_errno(struct tree *t)
-{
-    return (t->tree_errno);
-}
-
-/*
- * Called by the client to mark the directory just returned from
- * tree_next() as needing to be visited.
- */
-void
-tree_descend(struct tree *t)
-{
-    if (t->visit_type != TREE_REGULAR)
-        return;
-
-    if (tree_current_is_physical_dir(t)) {
-        tree_push(t, t->basename);
-        t->stack->flags |= isDir;
-    } else if (tree_current_is_dir(t)) {
-        tree_push(t, t->basename);
-        t->stack->flags |= isDirLink;
-    }
-}
-
-/*
- * Get the stat() data for the entry just returned from tree_next().
- */
-const struct stat *
-tree_current_stat(struct tree *t)
-{
-    if (!(t->flags & hasStat)) {
-        if (stat(t->basename, &t->st) != 0)
-            return NULL;
-        t->flags |= hasStat;
-    }
-    return (&t->st);
-}
-
-/*
- * Get the lstat() data for the entry just returned from tree_next().
- */
-const struct stat *
-tree_current_lstat(struct tree *t)
-{
-    if (!(t->flags & hasLstat)) {
-        if (lstat(t->basename, &t->lst) != 0)
-            return NULL;
-        t->flags |= hasLstat;
-    }
-    return (&t->lst);
-}
-
-/*
- * Test whether current entry is a dir or link to a dir.
- */
-int
-tree_current_is_dir(struct tree *t)
-{
-    const struct stat *st;
-
-    /*
-     * If we already have lstat() info, then try some
-     * cheap tests to determine if this is a dir.
-     */
-    if (t->flags & hasLstat) {
-        /* If lstat() says it's a dir, it must be a dir. */
-        if (S_ISDIR(tree_current_lstat(t)->st_mode))
-            return 1;
-        /* Not a dir; might be a link to a dir. */
-        /* If it's not a link, then it's not a link to a dir. */
-        if (!S_ISLNK(tree_current_lstat(t)->st_mode))
-            return 0;
-        /*
-         * It's a link, but we don't know what it's a link to,
-         * so we'll have to use stat().
-         */
-    }
-
-    st = tree_current_stat(t);
-    /* If we can't stat it, it's not a dir. */
-    if (st == NULL)
-        return 0;
-    /* Use the definitive test.  Hopefully this is cached. */
-    return (S_ISDIR(st->st_mode));
-}
-
-/*
- * Test whether current entry is a physical directory.  Usually, we
- * already have at least one of stat() or lstat() in memory, so we
- * use tricks to try to avoid an extra trip to the disk.
- */
-int
-tree_current_is_physical_dir(struct tree *t)
-{
-    const struct stat *st;
-
-    /*
-     * If stat() says it isn't a dir, then it's not a dir.
-     * If stat() data is cached, this check is free, so do it first.
-     */
-    if ((t->flags & hasStat)
-        && (!S_ISDIR(tree_current_stat(t)->st_mode)))
-        return 0;
-
-    /*
-     * Either stat() said it was a dir (in which case, we have
-     * to determine whether it's really a link to a dir) or
-     * stat() info wasn't available.  So we use lstat(), which
-     * hopefully is already cached.
-     */
-
-    st = tree_current_lstat(t);
-    /* If we can't stat it, it's not a dir. */
-    if (st == NULL)
-        return 0;
-    /* Use the definitive test.  Hopefully this is cached. */
-    return (S_ISDIR(st->st_mode));
-}
-
-/*
- * Test whether current entry is a symbolic link.
- */
-int
-tree_current_is_physical_link(struct tree *t)
-{
-    const struct stat *st = tree_current_lstat(t);
-    if (st == NULL)
-        return 0;
-    return (S_ISLNK(st->st_mode));
-}
-
-/*
- * Return the access path for the entry just returned from tree_next().
- */
-const char *
-tree_current_access_path(struct tree *t)
-{
-    return (t->basename);
-}
-
-/*
- * Return the full path for the entry just returned from tree_next().
- */
-const char *
-tree_current_path(struct tree *t)
-{
-    return (t->buff);
-}
-
-/*
- * Return the length of the path for the entry just returned from tree_next().
- */
-size_t
-tree_current_pathlen(struct tree *t)
-{
-    return (t->path_length);
-}
-
-/*
- * Return the nesting depth of the entry just returned from tree_next().
- */
-int
-tree_current_depth(struct tree *t)
-{
-    return (t->depth);
-}
-
-/*
- * Terminate the traversal and release any resources.
- */
-void
-tree_close(struct tree *t)
-{
-    /* Release anything remaining in the stack. */
-    while (t->stack != NULL)
-        tree_pop(t);
-    if (t->buff)
-        free(t->buff);
-    /* chdir() back to where we started. */
-    if (t->initialDirFd >= 0) {
-        fchdir(t->initialDirFd);
-        close(t->initialDirFd);
-        t->initialDirFd = -1;
-    }
-    free(t);
-}

+ 0 - 115
Utilities/cmlibarchive/contrib/shar/tree.h

@@ -1,115 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*-
- * A set of routines for traversing directory trees.
- * Similar in concept to the fts library, but with a few
- * important differences:
- *    * Uses less memory.  In particular, fts stores an entire directory
- *      in memory at a time.  This package only keeps enough subdirectory
- *      information in memory to track the traversal.  Information
- *      about non-directories is discarded as soon as possible.
- *    * Supports very deep logical traversals.  The fts package
- *      uses "non-chdir" approach for logical traversals.  This
- *      package does use a chdir approach for logical traversals
- *      and can therefore handle pathnames much longer than
- *      PATH_MAX.
- *    * Supports deep physical traversals "out of the box."
- *      Due to the memory optimizations above, there's no need to
- *      limit dir names to 32k.
- */
-
-#include <sys/stat.h>
-#include <stdio.h>
-
-struct tree;
-
-/* Initiate/terminate a tree traversal. */
-struct tree *tree_open(const char * /* pathname */);
-void tree_close(struct tree *);
-
-/*
- * tree_next() returns Zero if there is no next entry, non-zero if there is.
- * Note that directories are potentially visited three times.  The first
- * time as "regular" file.  If tree_descend() is invoked at that time,
- * the directory is added to a work list and will be visited two more
- * times:  once just after descending into the directory and again
- * just after ascending back to the parent.
- *
- * TREE_ERROR is returned if the descent failed (because the
- * directory couldn't be opened, for instance).  This is returned
- * instead of TREE_PREVISIT/TREE_POSTVISIT.
- */
-#define TREE_REGULAR    1
-#define TREE_POSTDESCENT    2
-#define TREE_POSTASCENT 3
-#define TREE_ERROR_DIR  -1
-int tree_next(struct tree *);
-
-int tree_errno(struct tree *);
-
-/*
- * Request that current entry be visited.  If you invoke it on every
- * directory, you'll get a physical traversal.  This is ignored if the
- * current entry isn't a directory or a link to a directory.  So, if
- * you invoke this on every returned path, you'll get a full logical
- * traversal.
- */
-void tree_descend(struct tree *);
-
-/*
- * Return information about the current entry.
- */
-
-int tree_current_depth(struct tree *);
-/*
- * The current full pathname, length of the full pathname,
- * and a name that can be used to access the file.
- * Because tree does use chdir extensively, the access path is
- * almost never the same as the full current path.
- */
-const char *tree_current_path(struct tree *);
-size_t tree_current_pathlen(struct tree *);
-const char *tree_current_access_path(struct tree *);
-/*
- * Request the lstat() or stat() data for the current path.  Since the
- * tree package needs to do some of this anyway, and caches the
- * results, you should take advantage of it here if you need it rather
- * than make a redundant stat() or lstat() call of your own.
- */
-const struct stat *tree_current_stat(struct tree *);
-const struct stat *tree_current_lstat(struct tree *);
-/* The following tests may use mechanisms much faster than stat()/lstat(). */
-/* "is_physical_dir" is equivalent to S_ISDIR(tree_current_lstat()->st_mode) */
-int tree_current_is_physical_dir(struct tree *);
-/* "is_physical_link" is equivalent to S_ISLNK(tree_current_lstat()->st_mode) */
-int tree_current_is_physical_link(struct tree *);
-/* "is_dir" is equivalent to S_ISDIR(tree_current_stat()->st_mode) */
-int tree_current_is_dir(struct tree *);
-
-/* For testing/debugging: Dump the internal status to the given filehandle. */
-void tree_dump(struct tree *, FILE *);

+ 0 - 78
Utilities/cmlibarchive/contrib/shar/tree_config.h

@@ -1,78 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-#ifndef TREE_CONFIG_H_INCLUDED
-#define TREE_CONFIG_H_INCLUDED
-
-#if defined(PLATFORM_CONFIG_H)
-/*
- * Use hand-built config.h in environments that need it.
- */
-#include PLATFORM_CONFIG_H
-#elif defined(HAVE_CONFIG_H)
-/*
- * Most POSIX platforms use the 'configure' script to build config.h
- */
-#include "../config.h"
-#elif defined(__FreeBSD__)
-/*
- * Built-in definitions for FreeBSD.
- */
-#define HAVE_DIRENT_D_NAMLEN 1
-#define HAVE_DIRENT_H 1
-#define HAVE_ERRNO_H 1
-#define HAVE_FCNTL_H 1
-#define HAVE_LIBARCHIVE 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_UNISTD_H 1
-#else
-/*
- * Warn if there's no platform configuration.
- */
-#error Oops: No config.h and no built-in configuration in bsdtar_platform.h.
-#endif /* !HAVE_CONFIG_H */
-
-/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>  /* For __FBSDID */
-#else
-/* Just leaving this macro replacement empty leads to a dangling semicolon. */
-#define __FBSDID(a)     struct _undefined_hack
-#endif
-
-#ifdef HAVE_LIBARCHIVE
-/* If we're using the platform libarchive, include system headers. */
-#include <archive.h>
-#include <archive_entry.h>
-#else
-/* Otherwise, include user headers. */
-#include "archive.h"
-#include "archive_entry.h"
-#endif
-
-#endif /* !TREE_CONFIG_H_INCLUDED */

+ 0 - 225
Utilities/cmlibarchive/contrib/untar.c

@@ -1,225 +0,0 @@
-/*
- * "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.
- *  * Extremely portable standard C.  The only non-ANSI function
- *    used is mkdir().
- *  * Reads basic ustar tar archives.
- *  * Does not require libarchive or any other special library.
- *
- * To compile: cc -o untar untar.c
- *
- * Usage:  untar <archive>
- *
- * In particular, this program should be sufficient to extract the
- * distribution for libarchive, allowing people to bootstrap
- * libarchive on systems that do not already have a tar program.
- *
- * To unpack libarchive-x.y.z.tar.gz:
- *    * gunzip libarchive-x.y.z.tar.gz
- *    * untar libarchive-x.y.z.tar
- *
- * Written by Tim Kientzle, March 2009.
- *
- * Released into the public domain.
- */
-
-/* These are all highly standard and portable headers. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* This is for mkdir(); this may need to be changed for some platforms. */
-#include <sys/stat.h>  /* For mkdir() */
-
-/* Parse an octal number, ignoring leading and trailing nonsense. */
-static int
-parseoct(const char *p, size_t n)
-{
-    int i = 0;
-
-    while (*p < '0' || *p > '7') {
-        ++p;
-        --n;
-    }
-    while (*p >= '0' && *p <= '7' && n > 0) {
-        i *= 8;
-        i += *p - '0';
-        ++p;
-        --n;
-    }
-    return (i);
-}
-
-/* Returns true if this is 512 zero bytes. */
-static int
-is_end_of_archive(const char *p)
-{
-    int n;
-    for (n = 511; n >= 0; --n)
-        if (p[n] != '\0')
-            return (0);
-    return (1);
-}
-
-/* Create a directory, including parent directories as necessary. */
-static void
-create_dir(char *pathname, int mode)
-{
-    char *p;
-    int r;
-
-    /* Strip trailing '/' */
-    if (pathname[strlen(pathname) - 1] == '/')
-        pathname[strlen(pathname) - 1] = '\0';
-
-    /* Try creating the directory. */
-    r = mkdir(pathname, mode);
-
-    if (r != 0) {
-        /* On failure, try creating parent directory. */
-        p = strrchr(pathname, '/');
-        if (p != NULL) {
-            *p = '\0';
-            create_dir(pathname, 0755);
-            *p = '/';
-            r = mkdir(pathname, mode);
-        }
-    }
-    if (r != 0)
-        fprintf(stderr, "Could not create directory %s\n", pathname);
-}
-
-/* Create a file, including parent directory as necessary. */
-static FILE *
-create_file(char *pathname, int mode)
-{
-    FILE *f;
-    f = fopen(pathname, "w+");
-    if (f == NULL) {
-        /* Try creating parent dir and then creating file. */
-        char *p = strrchr(pathname, '/');
-        if (p != NULL) {
-            *p = '\0';
-            create_dir(pathname, 0755);
-            *p = '/';
-            f = fopen(pathname, "w+");
-        }
-    }
-    return (f);
-}
-
-/* Verify the tar checksum. */
-static int
-verify_checksum(const char *p)
-{
-    int n, u = 0;
-    for (n = 0; n < 512; ++n) {
-        if (n < 148 || n > 155)
-            /* Standard tar checksum adds unsigned bytes. */
-            u += ((unsigned char *)p)[n];
-        else
-            u += 0x20;
-
-    }
-    return (u == parseoct(p + 148, 8));
-}
-
-/* Extract a tar archive. */
-static void
-untar(FILE *a, const char *path)
-{
-    char buff[512];
-    FILE *f = NULL;
-    size_t bytes_read;
-    int filesize;
-
-    printf("Extracting from %s\n", path);
-    for (;;) {
-        bytes_read = fread(buff, 1, 512, a);
-        if (bytes_read < 512) {
-            fprintf(stderr,
-                "Short read on %s: expected 512, got %d\n",
-                path, bytes_read);
-            return;
-        }
-        if (is_end_of_archive(buff)) {
-            printf("End of %s\n", path);
-            return;
-        }
-        if (!verify_checksum(buff)) {
-            fprintf(stderr, "Checksum failure\n");
-            return;
-        }
-        filesize = parseoct(buff + 124, 12);
-        switch (buff[156]) {
-        case '1':
-            printf(" Ignoring hardlink %s\n", buff);
-            break;
-        case '2':
-            printf(" Ignoring symlink %s\n", buff);
-            break;
-        case '3':
-            printf(" Ignoring character device %s\n", buff);
-                break;
-        case '4':
-            printf(" Ignoring block device %s\n", buff);
-            break;
-        case '5':
-            printf(" Extracting dir %s\n", buff);
-            create_dir(buff, parseoct(buff + 100, 8));
-            filesize = 0;
-            break;
-        case '6':
-            printf(" Ignoring FIFO %s\n", buff);
-            break;
-        default:
-            printf(" Extracting file %s\n", buff);
-            f = create_file(buff, parseoct(buff + 100, 8));
-            break;
-        }
-        while (filesize > 0) {
-            bytes_read = fread(buff, 1, 512, a);
-            if (bytes_read < 512) {
-                fprintf(stderr,
-                    "Short read on %s: Expected 512, got %d\n",
-                    path, bytes_read);
-                return;
-            }
-            if (filesize < 512)
-                bytes_read = filesize;
-            if (f != NULL) {
-                if (fwrite(buff, 1, bytes_read, f)
-                    != bytes_read)
-                {
-                    fprintf(stderr, "Failed write\n");
-                    fclose(f);
-                    f = NULL;
-                }
-            }
-            filesize -= bytes_read;
-        }
-        if (f != NULL) {
-            fclose(f);
-            f = NULL;
-        }
-    }
-}
-
-int
-main(int argc, char **argv)
-{
-    FILE *a;
-
-    ++argv; /* Skip program name */
-    for ( ;*argv != NULL; ++argv) {
-        a = fopen(*argv, "r");
-        if (a == NULL)
-            fprintf(stderr, "Unable to open %s\n", *argv);
-        else {
-            untar(a, *argv);
-            fclose(a);
-        }
-    }
-    return (0);
-}

+ 0 - 54
Utilities/cmlibarchive/cpio/CMakeLists.txt

@@ -1,54 +0,0 @@
-############################################
-#
-# How to build bsdcpio
-#
-############################################
-IF(ENABLE_CPIO)
-
-  SET(bsdcpio_SOURCES
-    cmdline.c
-    cpio.c
-    cpio.h
-    cpio_platform.h
-    ../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/matching.c
-    ../libarchive_fe/matching.h
-    ../libarchive_fe/pathmatch.c
-    ../libarchive_fe/pathmatch.h
-  )
-  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
-  IF(WIN32 AND NOT CYGWIN)
-    LIST(APPEND bsdcpio_SOURCES cpio_windows.c)
-    LIST(APPEND bsdcpio_SOURCES cpio_windows.h)
-  ENDIF(WIN32 AND NOT CYGWIN)
-
-  # bsdcpio documentation
-  SET(bsdcpio_MANS bsdcpio.1)
-
-  # How to build bsdcpio
-  ADD_EXECUTABLE(bsdcpio ${bsdcpio_SOURCES})
-  IF(ENABLE_CPIO_SHARED)
-    TARGET_LINK_LIBRARIES(bsdcpio archive ${ADDITIONAL_LIBS})
-  ELSE(ENABLE_CPIO_SHARED)
-    TARGET_LINK_LIBRARIES(bsdcpio archive_static ${ADDITIONAL_LIBS})
-  ENDIF(ENABLE_CPIO_SHARED)
-  # On Windows, DLL must end up in same dir with EXEs
-  IF(WIN32 AND NOT CYGWIN)
-    SET_TARGET_PROPERTIES(bsdcpio PROPERTIES
-      RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-  ENDIF(WIN32 AND NOT CYGWIN)
-  # Full path to the compiled executable (used by test suite)
-  GET_TARGET_PROPERTY(BSDCPIO bsdcpio LOCATION)
-
-  # Installation rules
-  INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin)
-  INSTALL_MAN(${bsdcpio_MANS})
-
-ENDIF(ENABLE_CPIO)
-
-# Test suite
-add_subdirectory(test)

+ 0 - 405
Utilities/cmlibarchive/cpio/bsdcpio.1

@@ -1,405 +0,0 @@
-.\" Copyright (c) 2003-2007 Tim Kientzle
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd December 21, 2007
-.Dt BSDCPIO 1
-.Os
-.Sh NAME
-.Nm cpio
-.Nd copy files to and from archives
-.Sh SYNOPSIS
-.Nm
-.Brq Fl i
-.Op Ar options
-.Op Ar pattern ...
-.Op Ar < archive
-.Nm
-.Brq Fl o
-.Op Ar options
-.Ar < name-list
-.Op Ar > archive
-.Nm
-.Brq Fl p
-.Op Ar options
-.Ar dest-dir
-.Ar < name-list
-.Sh DESCRIPTION
-.Nm
-copies files between archives and directories.
-This implementation can extract from tar, pax, cpio, zip, jar, ar,
-and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
-and shar archives.
-.Pp
-The first option to
-.Nm
-is a mode indicator from the following list:
-.Bl -tag -compact -width indent
-.It Fl i
-Input.
-Read an archive from standard input (unless overriden) and extract the
-contents to disk or (if the
-.Fl t
-option is specified)
-list the contents to standard output.
-If one or more file patterns are specified, only files matching
-one of the patterns will be extracted.
-.It Fl o
-Output.
-Read a list of filenames from standard input and produce a new archive
-on standard output (unless overriden) containing the specified items.
-.It Fl p
-Pass-through.
-Read a list of filenames from standard input and copy the files to the
-specified directory.
-.El
-.Pp
-.Sh OPTIONS
-Unless specifically stated otherwise, options are applicable in
-all operating modes.
-.Bl -tag -width indent
-.It Fl 0
-Read filenames separated by NUL characters instead of newlines.
-This is necessary if any of the filenames being read might contain newlines.
-.It Fl A
-(o mode only)
-Append to the specified archive.
-(Not yet implemented.)
-.It Fl a
-(o and p modes)
-Reset access times on files after they are read.
-.It Fl B
-(o mode only)
-Block output to records of 5120 bytes.
-.It Fl C Ar size
-(o mode only)
-Block output to records of
-.Ar size
-bytes.
-.It Fl c
-(o mode only)
-Use the old POSIX portable character format.
-Equivalent to
-.Fl -format Ar odc .
-.It Fl d
-(i and p modes)
-Create directories as necessary.
-.It Fl E Ar file
-(i mode only)
-Read list of file name patterns from
-.Ar file
-to list and extract.
-.It Fl F Ar file
-Read archive from or write archive to
-.Ar file .
-.It Fl f Ar pattern
-(i mode only)
-Ignore files that match
-.Ar pattern .
-.It Fl -format Ar format
-(o mode only)
-Produce the output archive in the specified format.
-Supported formats include:
-.Pp
-.Bl -tag -width "iso9660" -compact
-.It Ar cpio
-Synonym for
-.Ar odc .
-.It Ar newc
-The SVR4 portable cpio format.
-.It Ar odc
-The old POSIX.1 portable octet-oriented cpio format.
-.It Ar pax
-The POSIX.1 pax format, an extension of the ustar format.
-.It Ar ustar
-The POSIX.1 tar format.
-.El
-.Pp
-The default format is
-.Ar odc .
-See
-.Xr libarchive_formats 5
-for more complete information about the
-formats currently supported by the underlying
-.Xr libarchive 3
-library.
-.It Fl H Ar format
-Synonym for
-.Fl -format .
-.It Fl h , Fl -help
-Print usage information.
-.It Fl I Ar file
-Read archive from
-.Ar file .
-.It Fl i
-Input mode.
-See above for description.
-.It Fl -insecure
-(i and p mode only)
-Disable security checks during extraction or copying.
-This allows extraction via symbolic links and path names containing
-.Sq ..
-in the name.
-.It Fl J
-(o mode only)
-Compress the file with xz-compatible compression before writing it.
-In input mode, this option is ignored; xz compression is recognized
-automatically on input.
-.It Fl j
-Synonym for
-.Fl y .
-.It Fl L
-(o and p modes)
-All symbolic links will be followed.
-Normally, symbolic links are archived and copied as symbolic links.
-With this option, the target of the link will be archived or copied instead.
-.It Fl l
-(p mode only)
-Create links from the target directory to the original files,
-instead of copying.
-.It Fl lzma
-(o mode only)
-Compress the file with lzma-compatible compression before writing it.
-In input mode, this option is ignored; lzma compression is recognized
-automatically on input.
-.It Fl m
-(i and p modes)
-Set file modification time on created files to match
-those in the source.
-.It Fl n
-(i mode, only with
-.Fl t )
-Display numeric uid and gid.
-By default,
-.Nm
-displays the user and group names when they are provided in the
-archive, or looks up the user and group names in the system
-password database.
-.It Fl no-preserve-owner
-(i mode only)
-Do not attempt to restore file ownership.
-This is the default when run by non-root users.
-.It Fl O Ar file
-Write archive to
-.Ar file .
-.It Fl o
-Output mode.
-See above for description.
-.It Fl p
-Pass-through mode.
-See above for description.
-.It Fl preserve-owner
-(i mode only)
-Restore file ownership.
-This is the default when run by the root user.
-.It Fl -quiet
-Suppress unnecessary messages.
-.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc
-Set the owner and/or group on files in the output.
-If group is specified with no user
-(for example,
-.Fl R Ar :wheel )
-then the group will be set but not the user.
-If the user is specified with a trailing colon and no group
-(for example,
-.Fl R Ar root: )
-then the group will be set to the user's default group.
-If the user is specified with no trailing colon, then
-the user will be set but not the group.
-In
-.Fl i
-and
-.Fl p
-modes, this option can only be used by the super-user.
-(For compatibility, a period can be used in place of the colon.)
-.It Fl r
-(All modes.)
-Rename files interactively.
-For each file, a prompt is written to
-.Pa /dev/tty
-containing the name of the file and a line is read from
-.Pa /dev/tty .
-If the line read is blank, the file is skipped.
-If the line contains a single period, the file is processed normally.
-Otherwise, the line is taken to be the new name of the file.
-.It Fl t
-(i mode only)
-List the contents of the archive to stdout;
-do not restore the contents to disk.
-.It Fl u
-(i and p modes)
-Unconditionally overwrite existing files.
-Ordinarily, an older file will not overwrite a newer file on disk.
-.It Fl v
-Print the name of each file to stderr as it is processed.
-With
-.Fl t ,
-provide a detailed listing of each file.
-.It Fl -version
-Print the program version information and exit.
-.It Fl y
-(o mode only)
-Compress the archive with bzip2-compatible compression before writing it.
-In input mode, this option is ignored;
-bzip2 compression is recognized automatically on input.
-.It Fl Z
-(o mode only)
-Compress the archive with compress-compatible compression before writing it.
-In input mode, this option is ignored;
-compression is recognized automatically on input.
-.It Fl z
-(o mode only)
-Compress the archive with gzip-compatible compression before writing it.
-In input mode, this option is ignored;
-gzip compression is recognized automatically on input.
-.El
-.Sh ENVIRONMENT
-The following environment variables affect the execution of
-.Nm :
-.Bl -tag -width ".Ev BLOCKSIZE"
-.It Ev LANG
-The locale to use.
-See
-.Xr environ 7
-for more information.
-.It Ev TZ
-The timezone to use when displaying dates.
-See
-.Xr environ 7
-for more information.
-.El
-.Sh EXIT STATUS
-.Ex -std
-.Sh EXAMPLES
-The
-.Nm
-command is traditionally used to copy file heirarchies in conjunction
-with the
-.Xr find 1
-command.
-The first example here simply copies all files from
-.Pa src
-to
-.Pa dest :
-.Dl Nm find Pa src | Nm Fl pmud Pa dest
-.Pp
-By carefully selecting options to the
-.Xr find 1
-command and combining it with other standard utilities,
-it is possible to exercise very fine control over which files are copied.
-This next example copies files from
-.Pa src
-to
-.Pa dest
-that are more than 2 days old and whose names match a particular pattern:
-.Dl Nm find Pa src Fl mtime Ar +2 | Nm grep foo[bar] | Nm Fl pdmu Pa dest
-.Pp
-This example copies files from
-.Pa src
-to
-.Pa dest
-that are more than 2 days old and which contain the word
-.Do foobar Dc :
-.Dl Nm find Pa src Fl mtime Ar +2 | Nm xargs Nm grep -l foobar | Nm Fl pdmu Pa dest
-.Sh COMPATIBILITY
-The mode options i, o, and p and the options
-a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
-.Pp
-The old POSIX.1 standard specified that only
-.Fl i ,
-.Fl o ,
-and
-.Fl p
-were interpreted as command-line options.
-Each took a single argument of a list of modifier
-characters.
-For example, the standard syntax allows
-.Fl imu
-but does not support
-.Fl miu
-or
-.Fl i Fl m Fl u ,
-since
-.Ar m
-and
-.Ar u
-are only modifiers to
-.Fl i ,
-they are not command-line options in their own right.
-The syntax supported by this implementation is backwards-compatible
-with the standard.
-For best compatibility, scripts should limit themselves to the
-standard syntax.
-.Sh SEE ALSO
-.Xr bzip2 1 ,
-.Xr tar 1 ,
-.Xr gzip 1 ,
-.Xr mt 1 ,
-.Xr pax 1 ,
-.Xr libarchive 3 ,
-.Xr cpio 5 ,
-.Xr libarchive-formats 5 ,
-.Xr tar 5
-.Sh STANDARDS
-There is no current POSIX standard for the cpio command; it appeared
-in
-.St -p1003.1-96
-but was dropped from
-.St -p1003.1-2001 .
-.Pp
-The cpio, ustar, and pax interchange file formats are defined by
-.St -p1003.1-2001
-for the pax command.
-.Sh HISTORY
-The original
-.Nm cpio
-and
-.Nm find
-utilities were written by Dick Haight
-while working in AT&T's Unix Support Group.
-They first appeared in 1977 in PWB/UNIX 1.0, the
-.Dq Programmer's Work Bench
-system developed for use within AT&T.
-They were first released outside of AT&T as part of System III Unix in 1981.
-As a result,
-.Nm cpio
-actually predates
-.Nm tar ,
-even though it was not well-known outside of AT&T until some time later.
-.Pp
-This is a complete re-implementation based on the
-.Xr libarchive 3
-library.
-.Sh BUGS
-The cpio archive format has several basic limitations:
-It does not store user and group names, only numbers.
-As a result, it cannot be reliably used to transfer
-files between systems with dissimilar user and group numbering.
-Older cpio formats limit the user and group numbers to
-16 or 18 bits, which is insufficient for modern systems.
-The cpio archive formats cannot support files over 4 gigabytes,
-except for the
-.Dq odc
-variant, which can support files up to 8 gigabytes.

+ 0 - 369
Utilities/cmlibarchive/cpio/cmdline.c

@@ -1,369 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "cpio_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.5 2008/12/06 07:30:40 kientzle Exp $");
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include "cpio.h"
-#include "err.h"
-
-/*
- * Short options for cpio.  Please keep this sorted.
- */
-static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuvW:yZz";
-
-/*
- * Long options for cpio.  Please keep this sorted.
- */
-static const struct option {
-    const char *name;
-    int required;   /* 1 if this option requires an argument */
-    int equivalent; /* Equivalent short option. */
-} cpio_longopts[] = {
-    { "create",         0, 'o' },
-    { "extract",            0, 'i' },
-    { "file",           1, 'F' },
-    { "format",                 1, 'H' },
-    { "help",           0, 'h' },
-    { "insecure",           0, OPTION_INSECURE },
-    { "link",           0, 'l' },
-    { "list",           0, 't' },
-    { "lzma",           0, OPTION_LZMA },
-    { "make-directories",       0, 'd' },
-    { "no-preserve-owner",      0, OPTION_NO_PRESERVE_OWNER },
-    { "null",           0, '0' },
-    { "numeric-uid-gid",        0, 'n' },
-    { "owner",          1, 'R' },
-    { "pass-through",       0, 'p' },
-    { "preserve-modification-time", 0, 'm' },
-    { "preserve-owner",     0, OPTION_PRESERVE_OWNER },
-    { "quiet",          0, OPTION_QUIET },
-    { "unconditional",      0, 'u' },
-    { "verbose",            0, 'v' },
-    { "version",            0, OPTION_VERSION },
-    { "xz",             0, 'J' },
-    { NULL, 0, 0 }
-};
-
-/*
- * I used to try to select platform-provided getopt() or
- * getopt_long(), but that caused a lot of headaches.  In particular,
- * I couldn't consistently use long options in the test harness
- * because not all platforms have getopt_long().  That in turn led to
- * overuse of the -W hack in the test harness, which made it rough to
- * run the test harness against GNU cpio.  (I periodically run the
- * test harness here against GNU cpio as a sanity-check.  Yes,
- * I've found a couple of bugs in GNU cpio that way.)
- */
-int
-cpio_getopt(struct cpio *cpio)
-{
-    enum { state_start = 0, state_next_word, state_short, state_long };
-    static int state = state_start;
-    static char *opt_word;
-
-    const struct option *popt, *match = NULL, *match2 = NULL;
-    const char *p, *long_prefix = "--";
-    size_t optlength;
-    int opt = '?';
-    int required = 0;
-
-    cpio->optarg = NULL;
-
-    /* First time through, initialize everything. */
-    if (state == state_start) {
-        /* Skip program name. */
-        ++cpio->argv;
-        --cpio->argc;
-        state = state_next_word;
-    }
-
-    /*
-     * We're ready to look at the next word in argv.
-     */
-    if (state == state_next_word) {
-        /* No more arguments, so no more options. */
-        if (cpio->argv[0] == NULL)
-            return (-1);
-        /* Doesn't start with '-', so no more options. */
-        if (cpio->argv[0][0] != '-')
-            return (-1);
-        /* "--" marks end of options; consume it and return. */
-        if (strcmp(cpio->argv[0], "--") == 0) {
-            ++cpio->argv;
-            --cpio->argc;
-            return (-1);
-        }
-        /* Get next word for parsing. */
-        opt_word = *cpio->argv++;
-        --cpio->argc;
-        if (opt_word[1] == '-') {
-            /* Set up long option parser. */
-            state = state_long;
-            opt_word += 2; /* Skip leading '--' */
-        } else {
-            /* Set up short option parser. */
-            state = state_short;
-            ++opt_word;  /* Skip leading '-' */
-        }
-    }
-
-    /*
-     * We're parsing a group of POSIX-style single-character options.
-     */
-    if (state == state_short) {
-        /* Peel next option off of a group of short options. */
-        opt = *opt_word++;
-        if (opt == '\0') {
-            /* End of this group; recurse to get next option. */
-            state = state_next_word;
-            return cpio_getopt(cpio);
-        }
-
-        /* Does this option take an argument? */
-        p = strchr(short_options, opt);
-        if (p == NULL)
-            return ('?');
-        if (p[1] == ':')
-            required = 1;
-
-        /* If it takes an argument, parse that. */
-        if (required) {
-            /* If arg is run-in, opt_word already points to it. */
-            if (opt_word[0] == '\0') {
-                /* Otherwise, pick up the next word. */
-                opt_word = *cpio->argv;
-                if (opt_word == NULL) {
-                    lafe_warnc(0,
-                        "Option -%c requires an argument",
-                        opt);
-                    return ('?');
-                }
-                ++cpio->argv;
-                --cpio->argc;
-            }
-            if (opt == 'W') {
-                state = state_long;
-                long_prefix = "-W "; /* For clearer errors. */
-            } else {
-                state = state_next_word;
-                cpio->optarg = opt_word;
-            }
-        }
-    }
-
-    /* We're reading a long option, including -W long=arg convention. */
-    if (state == state_long) {
-        /* After this long option, we'll be starting a new word. */
-        state = state_next_word;
-
-        /* Option name ends at '=' if there is one. */
-        p = strchr(opt_word, '=');
-        if (p != NULL) {
-            optlength = (size_t)(p - opt_word);
-            cpio->optarg = (char *)(uintptr_t)(p + 1);
-        } else {
-            optlength = strlen(opt_word);
-        }
-
-        /* Search the table for an unambiguous match. */
-        for (popt = cpio_longopts; popt->name != NULL; popt++) {
-            /* Short-circuit if first chars don't match. */
-            if (popt->name[0] != opt_word[0])
-                continue;
-            /* If option is a prefix of name in table, record it.*/
-            if (strncmp(opt_word, popt->name, optlength) == 0) {
-                match2 = match; /* Record up to two matches. */
-                match = popt;
-                /* If it's an exact match, we're done. */
-                if (strlen(popt->name) == optlength) {
-                    match2 = NULL; /* Forget the others. */
-                    break;
-                }
-            }
-        }
-
-        /* Fail if there wasn't a unique match. */
-        if (match == NULL) {
-            lafe_warnc(0,
-                "Option %s%s is not supported",
-                long_prefix, opt_word);
-            return ('?');
-        }
-        if (match2 != NULL) {
-            lafe_warnc(0,
-                "Ambiguous option %s%s (matches --%s and --%s)",
-                long_prefix, opt_word, match->name, match2->name);
-            return ('?');
-        }
-
-        /* We've found a unique match; does it need an argument? */
-        if (match->required) {
-            /* Argument required: get next word if necessary. */
-            if (cpio->optarg == NULL) {
-                cpio->optarg = *cpio->argv;
-                if (cpio->optarg == NULL) {
-                    lafe_warnc(0,
-                        "Option %s%s requires an argument",
-                        long_prefix, match->name);
-                    return ('?');
-                }
-                ++cpio->argv;
-                --cpio->argc;
-            }
-        } else {
-            /* Argument forbidden: fail if there is one. */
-            if (cpio->optarg != NULL) {
-                lafe_warnc(0,
-                    "Option %s%s does not allow an argument",
-                    long_prefix, match->name);
-                return ('?');
-            }
-        }
-        return (match->equivalent);
-    }
-
-    return (opt);
-}
-
-
-/*
- * Parse the argument to the -R or --owner flag.
- *
- * The format is one of the following:
- *   <username|uid>    - Override user but not group
- *   <username>:   - Override both, group is user's default group
- *   <uid>:    - Override user but not group
- *   <username|uid>:<groupname|gid> - Override both
- *   :<groupname|gid>  - Override group but not user
- *
- * Where uid/gid are decimal representations and groupname/username
- * are names to be looked up in system database.  Note that we try
- * to look up an argument as a name first, then try numeric parsing.
- *
- * A period can be used instead of the colon.
- *
- * Sets uid/gid return as appropriate, -1 indicates uid/gid not specified.
- *
- * Returns NULL if no error, otherwise returns error string for display.
- *
- */
-const char *
-owner_parse(const char *spec, int *uid, int *gid)
-{
-    static char errbuff[128];
-    const char *u, *ue, *g;
-
-    *uid = -1;
-    *gid = -1;
-
-    if (spec[0] == '\0')
-        return ("Invalid empty user/group spec");
-
-    /*
-     * Split spec into [user][:.][group]
-     *  u -> first char of username, NULL if no username
-     *  ue -> first char after username (colon, period, or \0)
-     *  g -> first char of group name
-     */
-    if (*spec == ':' || *spec == '.') {
-        /* If spec starts with ':' or '.', then just group. */
-        ue = u = NULL;
-        g = spec + 1;
-    } else {
-        /* Otherwise, [user] or [user][:] or [user][:][group] */
-        ue = u = spec;
-        while (*ue != ':' && *ue != '.' && *ue != '\0')
-            ++ue;
-        g = ue;
-        if (*g != '\0') /* Skip : or . to find first char of group. */
-            ++g;
-    }
-
-    if (u != NULL) {
-        /* Look up user: ue is first char after end of user. */
-        char *user;
-        struct passwd *pwent;
-
-        user = (char *)malloc(ue - u + 1);
-        if (user == NULL)
-            return ("Couldn't allocate memory");
-        memcpy(user, u, ue - u);
-        user[ue - u] = '\0';
-        if ((pwent = getpwnam(user)) != NULL) {
-            *uid = pwent->pw_uid;
-            if (*ue != '\0')
-                *gid = pwent->pw_gid;
-        } else {
-            char *end;
-            errno = 0;
-            *uid = strtoul(user, &end, 10);
-            if (errno || *end != '\0') {
-                snprintf(errbuff, sizeof(errbuff),
-                    "Couldn't lookup user ``%s''", user);
-                errbuff[sizeof(errbuff) - 1] = '\0';
-                return (errbuff);
-            }
-        }
-        free(user);
-    }
-
-    if (*g != '\0') {
-        struct group *grp;
-        if ((grp = getgrnam(g)) != NULL) {
-            *gid = grp->gr_gid;
-        } else {
-            char *end;
-            errno = 0;
-            *gid = strtoul(g, &end, 10);
-            if (errno || *end != '\0') {
-                snprintf(errbuff, sizeof(errbuff),
-                    "Couldn't lookup group ``%s''", g);
-                errbuff[sizeof(errbuff) - 1] = '\0';
-                return (errbuff);
-            }
-        }
-    }
-    return (NULL);
-}

+ 0 - 54
Utilities/cmlibarchive/cpio/config_freebsd.h

@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/usr.bin/cpio/config_freebsd.h,v 1.3 2008/12/06 07:30:40 kientzle Exp $
- */
-
-/* A hand-tooled configuration for FreeBSD. */
-
-#include <sys/param.h>  /* __FreeBSD_version */
-
-#define HAVE_DIRENT_H 1
-#define HAVE_ERRNO_H 1
-#define HAVE_FCNTL_H 1
-#define HAVE_FUTIMES 1
-#define HAVE_GRP_H 1
-#define HAVE_LIBARCHIVE 1
-#define HAVE_LINK 1
-#define HAVE_LSTAT 1
-#define HAVE_LUTIMES 1
-#define HAVE_PWD_H 1
-#define HAVE_READLINK 1
-#define HAVE_STDARG_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_SYMLINK 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_TIME_H 1
-#define HAVE_UINTMAX_T 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UNSIGNED_LONG_LONG 1
-#define HAVE_UTIMES 1
-

+ 0 - 1233
Utilities/cmlibarchive/cpio/cpio.c

@@ -1,1233 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "cpio_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle Exp $");
-
-#include <sys/types.h>
-#include <archive.h>
-#include <archive_entry.h>
-
-#ifdef HAVE_SYS_MKDEV_H
-#include <sys/mkdev.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-
-#include "cpio.h"
-#include "err.h"
-#include "line_reader.h"
-#include "matching.h"
-
-/* Fixed size of uname/gname caches. */
-#define name_cache_size 101
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-struct name_cache {
-    int probes;
-    int hits;
-    size_t  size;
-    struct {
-        id_t id;
-        char *name;
-    } cache[name_cache_size];
-};
-
-static int  copy_data(struct archive *, struct archive *);
-static const char *cpio_rename(const char *name);
-static int  entry_to_archive(struct cpio *, struct archive_entry *);
-static int  file_to_archive(struct cpio *, const char *);
-static void free_cache(struct name_cache *cache);
-static void list_item_verbose(struct cpio *, struct archive_entry *);
-static void long_help(void);
-static const char *lookup_gname(struct cpio *, gid_t gid);
-static int  lookup_gname_helper(struct cpio *,
-            const char **name, id_t gid);
-static const char *lookup_uname(struct cpio *, uid_t uid);
-static int  lookup_uname_helper(struct cpio *,
-            const char **name, id_t uid);
-static void mode_in(struct cpio *);
-static void mode_list(struct cpio *);
-static void mode_out(struct cpio *);
-static void mode_pass(struct cpio *, const char *);
-static int  restore_time(struct cpio *, struct archive_entry *,
-            const char *, int fd);
-static void usage(void);
-static void version(void);
-
-int
-main(int argc, char *argv[])
-{
-    static char buff[16384];
-    struct cpio _cpio; /* Allocated on stack. */
-    struct cpio *cpio;
-    const char *errmsg;
-    int uid, gid;
-    int opt;
-
-    cpio = &_cpio;
-    memset(cpio, 0, sizeof(*cpio));
-    cpio->buff = buff;
-    cpio->buff_size = sizeof(buff);
-
-    /* Need lafe_progname before calling lafe_warnc. */
-    if (*argv == NULL)
-        lafe_progname = "bsdcpio";
-    else {
-#if defined(_WIN32) && !defined(__CYGWIN__)
-        lafe_progname = strrchr(*argv, '\\');
-#else
-        lafe_progname = strrchr(*argv, '/');
-#endif
-        if (lafe_progname != NULL)
-            lafe_progname++;
-        else
-            lafe_progname = *argv;
-    }
-
-    cpio->uid_override = -1;
-    cpio->gid_override = -1;
-    cpio->argv = argv;
-    cpio->argc = argc;
-    cpio->mode = '\0';
-    cpio->verbose = 0;
-    cpio->compress = '\0';
-    cpio->extract_flags = ARCHIVE_EXTRACT_NO_AUTODIR;
-    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_PERM;
-    cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
-    cpio->extract_flags |= ARCHIVE_EXTRACT_ACL;
-#if !defined(_WIN32) && !defined(__CYGWIN__)
-    if (geteuid() == 0)
-        cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
-#endif
-    cpio->bytes_per_block = 512;
-    cpio->filename = NULL;
-
-    while ((opt = cpio_getopt(cpio)) != -1) {
-        switch (opt) {
-        case '0': /* GNU convention: --null, -0 */
-            cpio->option_null = 1;
-            break;
-        case 'A': /* NetBSD/OpenBSD */
-            cpio->option_append = 1;
-            break;
-        case 'a': /* POSIX 1997 */
-            cpio->option_atime_restore = 1;
-            break;
-        case 'B': /* POSIX 1997 */
-            cpio->bytes_per_block = 5120;
-            break;
-        case 'C': /* NetBSD/OpenBSD */
-            cpio->bytes_per_block = atoi(cpio->optarg);
-            if (cpio->bytes_per_block <= 0)
-                lafe_errc(1, 0, "Invalid blocksize %s", cpio->optarg);
-            break;
-        case 'c': /* POSIX 1997 */
-            cpio->format = "odc";
-            break;
-        case 'd': /* POSIX 1997 */
-            cpio->extract_flags &= ~ARCHIVE_EXTRACT_NO_AUTODIR;
-            break;
-        case 'E': /* NetBSD/OpenBSD */
-            lafe_include_from_file(&cpio->matching,
-                cpio->optarg, cpio->option_null);
-            break;
-        case 'F': /* NetBSD/OpenBSD/GNU cpio */
-            cpio->filename = cpio->optarg;
-            break;
-        case 'f': /* POSIX 1997 */
-            lafe_exclude(&cpio->matching, cpio->optarg);
-            break;
-        case 'H': /* GNU cpio (also --format) */
-            cpio->format = cpio->optarg;
-            break;
-        case 'h':
-            long_help();
-            break;
-        case 'I': /* NetBSD/OpenBSD */
-            cpio->filename = cpio->optarg;
-            break;
-        case 'i': /* POSIX 1997 */
-            if (cpio->mode != '\0')
-                lafe_errc(1, 0,
-                    "Cannot use both -i and -%c", cpio->mode);
-            cpio->mode = opt;
-            break;
-        case 'J': /* GNU tar, others */
-            cpio->compress = opt;
-            break;
-        case 'j': /* GNU tar, others */
-            cpio->compress = opt;
-            break;
-        case OPTION_INSECURE:
-            cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS;
-            cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
-            break;
-        case 'L': /* GNU cpio */
-            cpio->option_follow_links = 1;
-            break;
-        case 'l': /* POSIX 1997 */
-            cpio->option_link = 1;
-            break;
-        case OPTION_LZMA: /* GNU tar, others */
-            cpio->compress = opt;
-            break;
-        case 'm': /* POSIX 1997 */
-            cpio->extract_flags |= ARCHIVE_EXTRACT_TIME;
-            break;
-        case 'n': /* GNU cpio */
-            cpio->option_numeric_uid_gid = 1;
-            break;
-        case OPTION_NO_PRESERVE_OWNER: /* GNU cpio */
-            cpio->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
-            break;
-        case 'O': /* GNU cpio */
-            cpio->filename = cpio->optarg;
-            break;
-        case 'o': /* POSIX 1997 */
-            if (cpio->mode != '\0')
-                lafe_errc(1, 0,
-                    "Cannot use both -o and -%c", cpio->mode);
-            cpio->mode = opt;
-            break;
-        case 'p': /* POSIX 1997 */
-            if (cpio->mode != '\0')
-                lafe_errc(1, 0,
-                    "Cannot use both -p and -%c", cpio->mode);
-            cpio->mode = opt;
-            cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
-            break;
-        case OPTION_PRESERVE_OWNER:
-            cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
-            break;
-        case OPTION_QUIET: /* GNU cpio */
-            cpio->quiet = 1;
-            break;
-        case 'R': /* GNU cpio, also --owner */
-            errmsg = owner_parse(cpio->optarg, &uid, &gid);
-            if (errmsg) {
-                lafe_warnc(-1, "%s", errmsg);
-                usage();
-            }
-            if (uid != -1)
-                cpio->uid_override = uid;
-            if (gid != -1)
-                cpio->gid_override = gid;
-            break;
-        case 'r': /* POSIX 1997 */
-            cpio->option_rename = 1;
-            break;
-        case 't': /* POSIX 1997 */
-            cpio->option_list = 1;
-            break;
-        case 'u': /* POSIX 1997 */
-            cpio->extract_flags
-                &= ~ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
-            break;
-        case 'v': /* POSIX 1997 */
-            cpio->verbose++;
-            break;
-        case OPTION_VERSION: /* GNU convention */
-            version();
-            break;
-#if 0
-            /*
-         * cpio_getopt() handles -W specially, so it's not
-         * available here.
-         */
-        case 'W': /* Obscure, but useful GNU convention. */
-            break;
-#endif
-        case 'y': /* tar convention */
-            cpio->compress = opt;
-            break;
-        case 'Z': /* tar convention */
-            cpio->compress = opt;
-            break;
-        case 'z': /* tar convention */
-            cpio->compress = opt;
-            break;
-        default:
-            usage();
-        }
-    }
-
-    /*
-     * Sanity-check args, error out on nonsensical combinations.
-     */
-    /* -t implies -i if no mode was specified. */
-    if (cpio->option_list && cpio->mode == '\0')
-        cpio->mode = 'i';
-    /* -t requires -i */
-    if (cpio->option_list && cpio->mode != 'i')
-        lafe_errc(1, 0, "Option -t requires -i", cpio->mode);
-    /* -n requires -it */
-    if (cpio->option_numeric_uid_gid && !cpio->option_list)
-        lafe_errc(1, 0, "Option -n requires -it");
-    /* Can only specify format when writing */
-    if (cpio->format != NULL && cpio->mode != 'o')
-        lafe_errc(1, 0, "Option --format requires -o");
-    /* -l requires -p */
-    if (cpio->option_link && cpio->mode != 'p')
-        lafe_errc(1, 0, "Option -l requires -p");
-    /* TODO: Flag other nonsensical combinations. */
-
-    switch (cpio->mode) {
-    case 'o':
-        /* TODO: Implement old binary format in libarchive,
-           use that here. */
-        if (cpio->format == NULL)
-            cpio->format = "odc"; /* Default format */
-
-        mode_out(cpio);
-        break;
-    case 'i':
-        while (*cpio->argv != NULL) {
-            lafe_include(&cpio->matching, *cpio->argv);
-            --cpio->argc;
-            ++cpio->argv;
-        }
-        if (cpio->option_list)
-            mode_list(cpio);
-        else
-            mode_in(cpio);
-        break;
-    case 'p':
-        if (*cpio->argv == NULL || **cpio->argv == '\0')
-            lafe_errc(1, 0,
-                "-p mode requires a target directory");
-        mode_pass(cpio, *cpio->argv);
-        break;
-    default:
-        lafe_errc(1, 0,
-            "Must specify at least one of -i, -o, or -p");
-    }
-
-    free_cache(cpio->gname_cache);
-    free_cache(cpio->uname_cache);
-    return (0);
-}
-
-void
-usage(void)
-{
-    const char  *p;
-
-    p = lafe_progname;
-
-    fprintf(stderr, "Brief Usage:\n");
-    fprintf(stderr, "  List:    %s -it < archive\n", p);
-    fprintf(stderr, "  Extract: %s -i < archive\n", p);
-    fprintf(stderr, "  Create:  %s -o < filenames > archive\n", p);
-    fprintf(stderr, "  Help:    %s --help\n", p);
-    exit(1);
-}
-
-static const char *long_help_msg =
-    "First option must be a mode specifier:\n"
-    "  -i Input  -o Output  -p Pass\n"
-    "Common Options:\n"
-    "  -v    Verbose\n"
-    "Create: %p -o [options]  < [list of files] > [archive]\n"
-    "  -J,-y,-z,--lzma  Compress archive with xz/bzip2/gzip/lzma\n"
-    "  --format {odc|newc|ustar}  Select archive format\n"
-    "List: %p -it < [archive]\n"
-    "Extract: %p -i [options] < [archive]\n";
-
-
-/*
- * Note that the word 'bsdcpio' will always appear in the first line
- * of output.
- *
- * In particular, /bin/sh scripts that need to test for the presence
- * of bsdcpio can use the following template:
- *
- * if (cpio --help 2>&1 | grep bsdcpio >/dev/null 2>&1 ) then \
- *          echo bsdcpio; else echo not bsdcpio; fi
- */
-static void
-long_help(void)
-{
-    const char  *prog;
-    const char  *p;
-
-    prog = lafe_progname;
-
-    fflush(stderr);
-
-    p = (strcmp(prog,"bsdcpio") != 0) ? "(bsdcpio)" : "";
-    printf("%s%s: manipulate archive files\n", prog, p);
-
-    for (p = long_help_msg; *p != '\0'; p++) {
-        if (*p == '%') {
-            if (p[1] == 'p') {
-                fputs(prog, stdout);
-                p++;
-            } else
-                putchar('%');
-        } else
-            putchar(*p);
-    }
-    version();
-}
-
-static void
-version(void)
-{
-    fprintf(stdout,"bsdcpio %s -- %s\n",
-        BSDCPIO_VERSION_STRING,
-        archive_version());
-    exit(0);
-}
-
-static void
-mode_out(struct cpio *cpio)
-{
-    struct archive_entry *entry, *spare;
-    struct lafe_line_reader *lr;
-    const char *p;
-    int r;
-
-    if (cpio->option_append)
-        lafe_errc(1, 0, "Append mode not yet supported.");
-
-    cpio->archive_read_disk = archive_read_disk_new();
-    if (cpio->archive_read_disk == NULL)
-        lafe_errc(1, 0, "Failed to allocate archive object");
-    if (cpio->option_follow_links)
-        archive_read_disk_set_symlink_logical(cpio->archive_read_disk);
-    else
-        archive_read_disk_set_symlink_physical(cpio->archive_read_disk);
-    archive_read_disk_set_standard_lookup(cpio->archive_read_disk);
-
-    cpio->archive = archive_write_new();
-    if (cpio->archive == NULL)
-        lafe_errc(1, 0, "Failed to allocate archive object");
-    switch (cpio->compress) {
-    case 'J':
-        r = archive_write_set_compression_xz(cpio->archive);
-        break;
-    case OPTION_LZMA:
-        r = archive_write_set_compression_lzma(cpio->archive);
-        break;
-    case 'j': case 'y':
-        r = archive_write_set_compression_bzip2(cpio->archive);
-        break;
-    case 'z':
-        r = archive_write_set_compression_gzip(cpio->archive);
-        break;
-    case 'Z':
-        r = archive_write_set_compression_compress(cpio->archive);
-        break;
-    default:
-        r = archive_write_set_compression_none(cpio->archive);
-        break;
-    }
-    if (r < ARCHIVE_WARN)
-        lafe_errc(1, 0, "Requested compression not available");
-    r = archive_write_set_format_by_name(cpio->archive, cpio->format);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(cpio->archive));
-    archive_write_set_bytes_per_block(cpio->archive, cpio->bytes_per_block);
-    cpio->linkresolver = archive_entry_linkresolver_new();
-    archive_entry_linkresolver_set_strategy(cpio->linkresolver,
-        archive_format(cpio->archive));
-
-    /*
-     * The main loop:  Copy each file into the output archive.
-     */
-    r = archive_write_open_file(cpio->archive, cpio->filename);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(cpio->archive));
-    lr = lafe_line_reader("-", cpio->option_null);
-    while ((p = lafe_line_reader_next(lr)) != NULL)
-        file_to_archive(cpio, p);
-    lafe_line_reader_free(lr);
-
-    /*
-     * The hardlink detection may have queued up a couple of entries
-     * that can now be flushed.
-     */
-    entry = NULL;
-    archive_entry_linkify(cpio->linkresolver, &entry, &spare);
-    while (entry != NULL) {
-        entry_to_archive(cpio, entry);
-        archive_entry_free(entry);
-        entry = NULL;
-        archive_entry_linkify(cpio->linkresolver, &entry, &spare);
-    }
-
-    r = archive_write_close(cpio->archive);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(cpio->archive));
-
-    if (!cpio->quiet) {
-        int64_t blocks =
-            (archive_position_uncompressed(cpio->archive) + 511)
-            / 512;
-        fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
-            blocks == 1 ? "block" : "blocks");
-    }
-    archive_write_finish(cpio->archive);
-}
-
-/*
- * This is used by both out mode (to copy objects from disk into
- * an archive) and pass mode (to copy objects from disk to
- * an archive_write_disk "archive").
- */
-static int
-file_to_archive(struct cpio *cpio, const char *srcpath)
-{
-    const char *destpath;
-    struct archive_entry *entry, *spare;
-    size_t len;
-    const char *p;
-    int r;
-
-    /*
-     * Create an archive_entry describing the source file.
-     *
-     */
-    entry = archive_entry_new();
-    if (entry == NULL)
-        lafe_errc(1, 0, "Couldn't allocate entry");
-    archive_entry_copy_sourcepath(entry, srcpath);
-    r = archive_read_disk_entry_from_file(cpio->archive_read_disk,
-        entry, -1, NULL);
-    if (r < ARCHIVE_WARN)
-        lafe_errc(1, 0, archive_error_string(cpio->archive));
-    if (r < ARCHIVE_OK)
-        lafe_warnc(0, archive_error_string(cpio->archive));
-
-    if (cpio->uid_override >= 0)
-        archive_entry_set_uid(entry, cpio->uid_override);
-    if (cpio->gid_override >= 0)
-        archive_entry_set_gid(entry, cpio->gid_override);
-
-    /*
-     * Generate a destination path for this entry.
-     * "destination path" is the name to which it will be copied in
-     * pass mode or the name that will go into the archive in
-     * output mode.
-     */
-    destpath = srcpath;
-    if (cpio->destdir) {
-        len = strlen(cpio->destdir) + strlen(srcpath) + 8;
-        if (len >= cpio->pass_destpath_alloc) {
-            while (len >= cpio->pass_destpath_alloc) {
-                cpio->pass_destpath_alloc += 512;
-                cpio->pass_destpath_alloc *= 2;
-            }
-            free(cpio->pass_destpath);
-            cpio->pass_destpath = malloc(cpio->pass_destpath_alloc);
-            if (cpio->pass_destpath == NULL)
-                lafe_errc(1, ENOMEM,
-                    "Can't allocate path buffer");
-        }
-        strcpy(cpio->pass_destpath, cpio->destdir);
-        p = srcpath;
-        while (p[0] == '/')
-            ++p;
-        strcat(cpio->pass_destpath, p);
-        destpath = cpio->pass_destpath;
-    }
-    if (cpio->option_rename)
-        destpath = cpio_rename(destpath);
-    if (destpath == NULL)
-        return (0);
-    archive_entry_copy_pathname(entry, destpath);
-
-    /*
-     * If we're trying to preserve hardlinks, match them here.
-     */
-    spare = NULL;
-    if (cpio->linkresolver != NULL
-        && archive_entry_filetype(entry) != AE_IFDIR) {
-        archive_entry_linkify(cpio->linkresolver, &entry, &spare);
-    }
-
-    if (entry != NULL) {
-        r = entry_to_archive(cpio, entry);
-        archive_entry_free(entry);
-        if (spare != NULL) {
-            if (r == 0)
-                r = entry_to_archive(cpio, spare);
-            archive_entry_free(spare);
-        }
-    }
-    return (r);
-}
-
-static int
-entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
-{
-    const char *destpath = archive_entry_pathname(entry);
-    const char *srcpath = archive_entry_sourcepath(entry);
-    int fd = -1;
-    ssize_t bytes_read;
-    int r;
-
-    /* Print out the destination name to the user. */
-    if (cpio->verbose)
-        fprintf(stderr,"%s", destpath);
-
-    /*
-     * Option_link only makes sense in pass mode and for
-     * regular files.  Also note: if a link operation fails
-     * because of cross-device restrictions, we'll fall back
-     * to copy mode for that entry.
-     *
-     * TODO: Test other cpio implementations to see if they
-     * hard-link anything other than regular files here.
-     */
-    if (cpio->option_link
-        && archive_entry_filetype(entry) == AE_IFREG)
-    {
-        struct archive_entry *t;
-        /* Save the original entry in case we need it later. */
-        t = archive_entry_clone(entry);
-        if (t == NULL)
-            lafe_errc(1, ENOMEM, "Can't create link");
-        /* Note: link(2) doesn't create parent directories,
-         * so we use archive_write_header() instead as a
-         * convenience. */
-        archive_entry_set_hardlink(t, srcpath);
-        /* This is a straight link that carries no data. */
-        archive_entry_set_size(t, 0);
-        r = archive_write_header(cpio->archive, t);
-        archive_entry_free(t);
-        if (r != ARCHIVE_OK)
-            lafe_warnc(archive_errno(cpio->archive),
-                archive_error_string(cpio->archive));
-        if (r == ARCHIVE_FATAL)
-            exit(1);
-#ifdef EXDEV
-        if (r != ARCHIVE_OK && archive_errno(cpio->archive) == EXDEV) {
-            /* Cross-device link:  Just fall through and use
-             * the original entry to copy the file over. */
-            lafe_warnc(0, "Copying file instead");
-        } else
-#endif
-        return (0);
-    }
-
-    /*
-     * Make sure we can open the file (if necessary) before
-     * trying to write the header.
-     */
-    if (archive_entry_filetype(entry) == AE_IFREG) {
-        if (archive_entry_size(entry) > 0) {
-            fd = open(srcpath, O_RDONLY | O_BINARY);
-            if (fd < 0) {
-                lafe_warnc(errno,
-                    "%s: could not open file", srcpath);
-                goto cleanup;
-            }
-        }
-    } else {
-        archive_entry_set_size(entry, 0);
-    }
-
-    r = archive_write_header(cpio->archive, entry);
-
-    if (r != ARCHIVE_OK)
-        lafe_warnc(archive_errno(cpio->archive),
-            "%s: %s",
-            srcpath,
-            archive_error_string(cpio->archive));
-
-    if (r == ARCHIVE_FATAL)
-        exit(1);
-
-    if (r >= ARCHIVE_WARN && fd >= 0) {
-        bytes_read = read(fd, cpio->buff, cpio->buff_size);
-        while (bytes_read > 0) {
-            r = archive_write_data(cpio->archive,
-                cpio->buff, bytes_read);
-            if (r < 0)
-                lafe_errc(1, archive_errno(cpio->archive),
-                    archive_error_string(cpio->archive));
-            if (r < bytes_read) {
-                lafe_warnc(0,
-                    "Truncated write; file may have grown while being archived.");
-            }
-            bytes_read = read(fd, cpio->buff, cpio->buff_size);
-        }
-    }
-
-    fd = restore_time(cpio, entry, srcpath, fd);
-
-cleanup:
-    if (cpio->verbose)
-        fprintf(stderr,"\n");
-    if (fd >= 0)
-        close(fd);
-    return (0);
-}
-
-static int
-restore_time(struct cpio *cpio, struct archive_entry *entry,
-    const char *name, int fd)
-{
-#ifndef HAVE_UTIMES
-    static int warned = 0;
-
-    (void)cpio; /* UNUSED */
-    (void)entry; /* UNUSED */
-    (void)name; /* UNUSED */
-
-    if (!warned)
-        lafe_warnc(0, "Can't restore access times on this platform");
-    warned = 1;
-    return (fd);
-#else
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    struct __timeval times[2];
-#else
-    struct timeval times[2];
-#endif
-
-    if (!cpio->option_atime_restore)
-        return (fd);
-
-        times[1].tv_sec = archive_entry_mtime(entry);
-        times[1].tv_usec = archive_entry_mtime_nsec(entry) / 1000;
-
-        times[0].tv_sec = archive_entry_atime(entry);
-        times[0].tv_usec = archive_entry_atime_nsec(entry) / 1000;
-
-#ifdef HAVE_FUTIMES
-        if (fd >= 0 && futimes(fd, times) == 0)
-        return (fd);
-#endif
-    /*
-     * Some platform cannot restore access times if the file descriptor
-     * is still opened.
-     */
-    if (fd >= 0) {
-        close(fd);
-        fd = -1;
-    }
-
-#ifdef HAVE_LUTIMES
-        if (lutimes(name, times) != 0)
-#else
-        if ((AE_IFLNK != archive_entry_filetype(entry))
-            && utimes(name, times) != 0)
-#endif
-                lafe_warnc(errno, "Can't update time for %s", name);
-#endif
-    return (fd);
-}
-
-
-static void
-mode_in(struct cpio *cpio)
-{
-    struct archive *a;
-    struct archive_entry *entry;
-    struct archive *ext;
-    const char *destpath;
-    int r;
-
-    ext = archive_write_disk_new();
-    if (ext == NULL)
-        lafe_errc(1, 0, "Couldn't allocate restore object");
-    r = archive_write_disk_set_options(ext, cpio->extract_flags);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(ext));
-    a = archive_read_new();
-    if (a == NULL)
-        lafe_errc(1, 0, "Couldn't allocate archive object");
-    archive_read_support_compression_all(a);
-    archive_read_support_format_all(a);
-
-    if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
-        lafe_errc(1, archive_errno(a),
-            archive_error_string(a));
-    for (;;) {
-        r = archive_read_next_header(a, &entry);
-        if (r == ARCHIVE_EOF)
-            break;
-        if (r != ARCHIVE_OK) {
-            lafe_errc(1, archive_errno(a),
-                archive_error_string(a));
-        }
-        if (lafe_excluded(cpio->matching, archive_entry_pathname(entry)))
-            continue;
-        if (cpio->option_rename) {
-            destpath = cpio_rename(archive_entry_pathname(entry));
-            archive_entry_set_pathname(entry, destpath);
-        } else
-            destpath = archive_entry_pathname(entry);
-        if (destpath == NULL)
-            continue;
-        if (cpio->verbose)
-            fprintf(stdout, "%s\n", destpath);
-        if (cpio->uid_override >= 0)
-            archive_entry_set_uid(entry, cpio->uid_override);
-        if (cpio->gid_override >= 0)
-            archive_entry_set_gid(entry, cpio->gid_override);
-        r = archive_write_header(ext, entry);
-        if (r != ARCHIVE_OK) {
-            fprintf(stderr, "%s: %s\n",
-                archive_entry_pathname(entry),
-                archive_error_string(ext));
-        } else if (archive_entry_size(entry) > 0) {
-            r = copy_data(a, ext);
-        }
-    }
-    r = archive_read_close(a);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(a));
-    r = archive_write_close(ext);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(ext));
-    if (!cpio->quiet) {
-        int64_t blocks = (archive_position_uncompressed(a) + 511)
-                  / 512;
-        fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
-            blocks == 1 ? "block" : "blocks");
-    }
-    archive_read_finish(a);
-    archive_write_finish(ext);
-    exit(0);
-}
-
-static int
-copy_data(struct archive *ar, struct archive *aw)
-{
-    int r;
-    size_t size;
-    const void *block;
-    off_t offset;
-
-    for (;;) {
-        r = archive_read_data_block(ar, &block, &size, &offset);
-        if (r == ARCHIVE_EOF)
-            return (ARCHIVE_OK);
-        if (r != ARCHIVE_OK) {
-            lafe_warnc(archive_errno(ar),
-                "%s", archive_error_string(ar));
-            return (r);
-        }
-        r = archive_write_data_block(aw, block, size, offset);
-        if (r != ARCHIVE_OK) {
-            lafe_warnc(archive_errno(aw),
-                archive_error_string(aw));
-            return (r);
-        }
-    }
-}
-
-static void
-mode_list(struct cpio *cpio)
-{
-    struct archive *a;
-    struct archive_entry *entry;
-    int r;
-
-    a = archive_read_new();
-    if (a == NULL)
-        lafe_errc(1, 0, "Couldn't allocate archive object");
-    archive_read_support_compression_all(a);
-    archive_read_support_format_all(a);
-
-    if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
-        lafe_errc(1, archive_errno(a),
-            archive_error_string(a));
-    for (;;) {
-        r = archive_read_next_header(a, &entry);
-        if (r == ARCHIVE_EOF)
-            break;
-        if (r != ARCHIVE_OK) {
-            lafe_errc(1, archive_errno(a),
-                archive_error_string(a));
-        }
-        if (lafe_excluded(cpio->matching, archive_entry_pathname(entry)))
-            continue;
-        if (cpio->verbose)
-            list_item_verbose(cpio, entry);
-        else
-            fprintf(stdout, "%s\n", archive_entry_pathname(entry));
-    }
-    r = archive_read_close(a);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(a));
-    if (!cpio->quiet) {
-        int64_t blocks = (archive_position_uncompressed(a) + 511)
-                  / 512;
-        fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
-            blocks == 1 ? "block" : "blocks");
-    }
-    archive_read_finish(a);
-    exit(0);
-}
-
-/*
- * Display information about the current file.
- *
- * The format here roughly duplicates the output of 'ls -l'.
- * This is based on SUSv2, where 'tar tv' is documented as
- * listing additional information in an "unspecified format,"
- * and 'pax -l' is documented as using the same format as 'ls -l'.
- */
-static void
-list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
-{
-    char             size[32];
-    char             date[32];
-    char             uids[16], gids[16];
-    const char      *uname, *gname;
-    FILE            *out = stdout;
-    const struct stat   *st;
-    const char      *fmt;
-    time_t           tim;
-    static time_t        now;
-
-    st = archive_entry_stat(entry);
-
-    if (!now)
-        time(&now);
-
-    if (cpio->option_numeric_uid_gid) {
-        /* Format numeric uid/gid for display. */
-        snprintf(uids, sizeof(uids), CPIO_FILESIZE_PRINTF,
-            (CPIO_FILESIZE_TYPE)archive_entry_uid(entry));
-        uname = uids;
-        snprintf(gids, sizeof(gids), CPIO_FILESIZE_PRINTF,
-            (CPIO_FILESIZE_TYPE)archive_entry_gid(entry));
-        gname = gids;
-    } else {
-        /* Use uname if it's present, else lookup name from uid. */
-        uname = archive_entry_uname(entry);
-        if (uname == NULL)
-            uname = lookup_uname(cpio, archive_entry_uid(entry));
-        /* Use gname if it's present, else lookup name from gid. */
-        gname = archive_entry_gname(entry);
-        if (gname == NULL)
-            gname = lookup_gname(cpio, archive_entry_gid(entry));
-    }
-
-    /* Print device number or file size. */
-    if (archive_entry_filetype(entry) == AE_IFCHR
-        || archive_entry_filetype(entry) == AE_IFBLK) {
-        snprintf(size, sizeof(size), "%lu,%lu",
-            (unsigned long)archive_entry_rdevmajor(entry),
-            (unsigned long)archive_entry_rdevminor(entry));
-    } else {
-        snprintf(size, sizeof(size), CPIO_FILESIZE_PRINTF,
-            (CPIO_FILESIZE_TYPE)st->st_size);
-    }
-
-    /* Format the time using 'ls -l' conventions. */
-    tim = (time_t)st->st_mtime;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Windows' strftime function does not support %e format. */
-    if (tim - now > 365*86400/2
-        || tim - now < -365*86400/2)
-        fmt = cpio->day_first ? "%d %b  %Y" : "%b %d  %Y";
-    else
-        fmt = cpio->day_first ? "%d %b %H:%M" : "%b %d %H:%M";
-#else
-    if (abs(tim - now) > (365/2)*86400)
-        fmt = cpio->day_first ? "%e %b  %Y" : "%b %e  %Y";
-    else
-        fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
-#endif
-    strftime(date, sizeof(date), fmt, localtime(&tim));
-
-    fprintf(out, "%s%3d %-8s %-8s %8s %12s %s",
-        archive_entry_strmode(entry),
-        archive_entry_nlink(entry),
-        uname, gname, size, date,
-        archive_entry_pathname(entry));
-
-    /* Extra information for links. */
-    if (archive_entry_hardlink(entry)) /* Hard link */
-        fprintf(out, " link to %s", archive_entry_hardlink(entry));
-    else if (archive_entry_symlink(entry)) /* Symbolic link */
-        fprintf(out, " -> %s", archive_entry_symlink(entry));
-    fprintf(out, "\n");
-}
-
-static void
-mode_pass(struct cpio *cpio, const char *destdir)
-{
-    struct lafe_line_reader *lr;
-    const char *p;
-    int r;
-
-    /* Ensure target dir has a trailing '/' to simplify path surgery. */
-    cpio->destdir = malloc(strlen(destdir) + 8);
-    strcpy(cpio->destdir, destdir);
-    if (destdir[strlen(destdir) - 1] != '/')
-        strcat(cpio->destdir, "/");
-
-    cpio->archive = archive_write_disk_new();
-    if (cpio->archive == NULL)
-        lafe_errc(1, 0, "Failed to allocate archive object");
-    r = archive_write_disk_set_options(cpio->archive, cpio->extract_flags);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(cpio->archive));
-    cpio->linkresolver = archive_entry_linkresolver_new();
-    archive_write_disk_set_standard_lookup(cpio->archive);
-
-    cpio->archive_read_disk = archive_read_disk_new();
-    if (cpio->archive_read_disk == NULL)
-        lafe_errc(1, 0, "Failed to allocate archive object");
-    if (cpio->option_follow_links)
-        archive_read_disk_set_symlink_logical(cpio->archive_read_disk);
-    else
-        archive_read_disk_set_symlink_physical(cpio->archive_read_disk);
-    archive_read_disk_set_standard_lookup(cpio->archive_read_disk);
-
-    lr = lafe_line_reader("-", cpio->option_null);
-    while ((p = lafe_line_reader_next(lr)) != NULL)
-        file_to_archive(cpio, p);
-    lafe_line_reader_free(lr);
-
-    archive_entry_linkresolver_free(cpio->linkresolver);
-    r = archive_write_close(cpio->archive);
-    if (r != ARCHIVE_OK)
-        lafe_errc(1, 0, archive_error_string(cpio->archive));
-
-    if (!cpio->quiet) {
-        int64_t blocks =
-            (archive_position_uncompressed(cpio->archive) + 511)
-            / 512;
-        fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
-            blocks == 1 ? "block" : "blocks");
-    }
-
-    archive_write_finish(cpio->archive);
-}
-
-/*
- * Prompt for a new name for this entry.  Returns a pointer to the
- * new name or NULL if the entry should not be copied.  This
- * implements the semantics defined in POSIX.1-1996, which specifies
- * that an input of '.' means the name should be unchanged.  GNU cpio
- * treats '.' as a literal new name.
- */
-static const char *
-cpio_rename(const char *name)
-{
-    static char buff[1024];
-    FILE *t;
-    char *p, *ret;
-
-    t = fopen("/dev/tty", "r+");
-    if (t == NULL)
-        return (name);
-    fprintf(t, "%s (Enter/./(new name))? ", name);
-    fflush(t);
-
-    p = fgets(buff, sizeof(buff), t);
-    fclose(t);
-    if (p == NULL)
-        /* End-of-file is a blank line. */
-        return (NULL);
-
-    while (*p == ' ' || *p == '\t')
-        ++p;
-    if (*p == '\n' || *p == '\0')
-        /* Empty line. */
-        return (NULL);
-    if (*p == '.' && p[1] == '\n')
-        /* Single period preserves original name. */
-        return (name);
-    ret = p;
-    /* Trim the final newline. */
-    while (*p != '\0' && *p != '\n')
-        ++p;
-    /* Overwrite the final \n with a null character. */
-    *p = '\0';
-    return (ret);
-}
-
-static void
-free_cache(struct name_cache *cache)
-{
-    size_t i;
-
-    if (cache != NULL) {
-        for (i = 0; i < cache->size; i++)
-            free(cache->cache[i].name);
-        free(cache);
-    }
-}
-
-/*
- * Lookup uname/gname from uid/gid, return NULL if no match.
- */
-static const char *
-lookup_name(struct cpio *cpio, struct name_cache **name_cache_variable,
-    int (*lookup_fn)(struct cpio *, const char **, id_t), id_t id)
-{
-    char asnum[16];
-    struct name_cache   *cache;
-    const char *name;
-    int slot;
-
-
-    if (*name_cache_variable == NULL) {
-        *name_cache_variable = malloc(sizeof(struct name_cache));
-        if (*name_cache_variable == NULL)
-            lafe_errc(1, ENOMEM, "No more memory");
-        memset(*name_cache_variable, 0, sizeof(struct name_cache));
-        (*name_cache_variable)->size = name_cache_size;
-    }
-
-    cache = *name_cache_variable;
-    cache->probes++;
-
-    slot = id % cache->size;
-    if (cache->cache[slot].name != NULL) {
-        if (cache->cache[slot].id == id) {
-            cache->hits++;
-            return (cache->cache[slot].name);
-        }
-        free(cache->cache[slot].name);
-        cache->cache[slot].name = NULL;
-    }
-
-    if (lookup_fn(cpio, &name, id) == 0) {
-        if (name == NULL || name[0] == '\0') {
-            /* If lookup failed, format it as a number. */
-            snprintf(asnum, sizeof(asnum), "%u", (unsigned)id);
-            name = asnum;
-        }
-        cache->cache[slot].name = strdup(name);
-        if (cache->cache[slot].name != NULL) {
-            cache->cache[slot].id = id;
-            return (cache->cache[slot].name);
-        }
-        /*
-         * Conveniently, NULL marks an empty slot, so
-         * if the strdup() fails, we've just failed to
-         * cache it.  No recovery necessary.
-         */
-    }
-    return (NULL);
-}
-
-static const char *
-lookup_uname(struct cpio *cpio, uid_t uid)
-{
-    return (lookup_name(cpio, &cpio->uname_cache,
-            &lookup_uname_helper, (id_t)uid));
-}
-
-static int
-lookup_uname_helper(struct cpio *cpio, const char **name, id_t id)
-{
-    struct passwd   *pwent;
-
-    (void)cpio; /* UNUSED */
-
-    errno = 0;
-    pwent = getpwuid((uid_t)id);
-    if (pwent == NULL) {
-        *name = NULL;
-        if (errno != 0)
-            lafe_warnc(errno, "getpwuid(%d) failed", id);
-        return (errno);
-    }
-
-    *name = pwent->pw_name;
-    return (0);
-}
-
-static const char *
-lookup_gname(struct cpio *cpio, gid_t gid)
-{
-    return (lookup_name(cpio, &cpio->gname_cache,
-            &lookup_gname_helper, (id_t)gid));
-}
-
-static int
-lookup_gname_helper(struct cpio *cpio, const char **name, id_t id)
-{
-    struct group    *grent;
-
-    (void)cpio; /* UNUSED */
-
-    errno = 0;
-    grent = getgrgid((gid_t)id);
-    if (grent == NULL) {
-        *name = NULL;
-        if (errno != 0)
-            lafe_warnc(errno, "getgrgid(%d) failed", id);
-        return (errno);
-    }
-
-    *name = grent->gr_name;
-    return (0);
-}

+ 0 - 109
Utilities/cmlibarchive/cpio/cpio.h

@@ -1,109 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.7 2008/12/06 07:30:40 kientzle Exp $
- */
-
-#ifndef CPIO_H_INCLUDED
-#define CPIO_H_INCLUDED
-
-#include "cpio_platform.h"
-#include <stdio.h>
-
-#include "matching.h"
-
-/*
- * The internal state for the "cpio" program.
- *
- * Keeping all of the state in a structure like this simplifies memory
- * leak testing (at exit, anything left on the heap is suspect).  A
- * pointer to this structure is passed to most cpio internal
- * functions.
- */
-struct cpio {
-    /* Option parsing */
-    const char   *optarg;
-
-    /* Options */
-    const char   *filename;
-    char          mode; /* -i -o -p */
-    char          compress; /* -j, -y, or -z */
-    const char   *format; /* -H format */
-    int       bytes_per_block; /* -b block_size */
-    int       verbose;   /* -v */
-    int       quiet;   /* --quiet */
-    int       extract_flags; /* Flags for extract operation */
-    char          symlink_mode; /* H or L, per BSD conventions */
-    const char   *compress_program;
-    int       option_append; /* -A, only relevant for -o */
-    int       option_atime_restore; /* -a */
-    int       option_follow_links; /* -L */
-    int       option_link; /* -l */
-    int       option_list; /* -t */
-    char          option_null; /* --null */
-    int       option_numeric_uid_gid; /* -n */
-    int       option_rename; /* -r */
-    char         *destdir;
-    size_t        pass_destpath_alloc;
-    char         *pass_destpath;
-    int       uid_override;
-    int       gid_override;
-    int       day_first; /* true if locale prefers day/mon */
-
-    /* If >= 0, then close this when done. */
-    int       fd;
-
-    /* Miscellaneous state information */
-    struct archive   *archive;
-    struct archive   *archive_read_disk;
-    int       argc;
-    char        **argv;
-    int       return_value; /* Value returned by main() */
-    struct archive_entry_linkresolver *linkresolver;
-
-    struct name_cache *uname_cache;
-    struct name_cache *gname_cache;
-
-    /* Work data. */
-    struct lafe_matching  *matching;
-    char         *buff;
-    size_t        buff_size;
-};
-
-const char *owner_parse(const char *, int *, int *);
-
-
-/* Fake short equivalents for long options that otherwise lack them. */
-enum {
-    OPTION_INSECURE = 1,
-    OPTION_LZMA,
-    OPTION_NO_PRESERVE_OWNER,
-    OPTION_PRESERVE_OWNER,
-    OPTION_QUIET,
-    OPTION_VERSION
-};
-
-int cpio_getopt(struct cpio *cpio);
-
-#endif

+ 0 - 95
Utilities/cmlibarchive/cpio/cpio_platform.h

@@ -1,95 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/usr.bin/cpio/cpio_platform.h,v 1.2 2008/12/06 07:15:42 kientzle Exp $
- */
-
-/*
- * This header is the first thing included in any of the cpio
- * source files.  As far as possible, platform-specific issues should
- * be dealt with here and not within individual source files.
- */
-
-#ifndef CPIO_PLATFORM_H_INCLUDED
-#define CPIO_PLATFORM_H_INCLUDED
-
-#if defined(PLATFORM_CONFIG_H)
-/* Use hand-built config.h in environments that need it. */
-#include PLATFORM_CONFIG_H
-#else
-/* Read config.h or die trying. */
-#include "config.h"
-#endif
-
-/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>  /* For __FBSDID */
-#elif !defined(__FBSDID)
-/* Just leaving this macro replacement empty leads to a dangling semicolon. */
-#define __FBSDID(a)     struct _undefined_hack
-#endif
-
-#ifdef HAVE_LIBARCHIVE
-/* If we're using the platform libarchive, include system headers. */
-#include <archive.h>
-#include <archive_entry.h>
-#else
-/* Otherwise, include user headers. */
-#include "archive.h"
-#include "archive_entry.h"
-#endif
-
-/*
- * We need to be able to display a filesize using printf().  The type
- * and format string here must be compatible with one another and
- * large enough for any file.
- */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define CPIO_FILESIZE_TYPE  __int64
-#define CPIO_FILESIZE_PRINTF    "%I64u"
-#elif HAVE_UINTMAX_T
-#define CPIO_FILESIZE_TYPE  uintmax_t
-#define CPIO_FILESIZE_PRINTF    "%ju"
-#elif HAVE_UNSIGNED_LONG_LONG
-#define CPIO_FILESIZE_TYPE  unsigned long long
-#define CPIO_FILESIZE_PRINTF    "%llu"
-#else
-#define CPIO_FILESIZE_TYPE  unsigned long
-#define CPIO_FILESIZE_PRINTF    "%lu"
-#endif
-
-
-/* How to mark functions that don't return. */
-#if defined(__GNUC__) && (__GNUC__ > 2 || \
-                          (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define __LA_DEAD       __attribute__((__noreturn__))
-#else
-#define __LA_DEAD
-#endif
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include "cpio_windows.h"
-#endif
-
-#endif /* !CPIO_PLATFORM_H_INCLUDED */

+ 0 - 336
Utilities/cmlibarchive/cpio/cpio_windows.c

@@ -1,336 +0,0 @@
-/*-
- * Copyright (c) 2009 Michihiro NAKAJIMA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-
-#include "cpio_platform.h"
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <io.h>
-#include <stddef.h>
-#include <sys/utime.h>
-#include <sys/stat.h>
-#include <process.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <windows.h>
-#include <sddl.h>
-
-#include "cpio.h"
-#include "err.h"
-
-#define EPOC_TIME   (116444736000000000ULL)
-
-static void cpio_dosmaperr(unsigned long);
-
-/*
- * Prepend "\\?\" to the path name and convert it to unicode to permit
- * an extended-length path for a maximum total path length of 32767
- * characters.
- * see also http://msdn.microsoft.com/en-us/library/aa365247.aspx
- */
-static wchar_t *
-permissive_name(const char *name)
-{
-    wchar_t *wn, *wnp;
-    wchar_t *ws, *wsp;
-    size_t l, len, slen, alloclen;
-    int unc;
-
-    len = strlen(name);
-    wn = malloc((len + 1) * sizeof(wchar_t));
-    if (wn == NULL)
-        return (NULL);
-    l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len);
-    if (l == 0) {
-        free(wn);
-        return (NULL);
-    }
-    wn[l] = L'\0';
-
-    /* Get a full path names */
-    l = GetFullPathNameW(wn, 0, NULL, NULL);
-    if (l == 0) {
-        free(wn);
-        return (NULL);
-    }
-    wnp = malloc(l * sizeof(wchar_t));
-    if (wnp == NULL) {
-        free(wn);
-        return (NULL);
-    }
-    len = GetFullPathNameW(wn, l, wnp, NULL);
-    free(wn);
-    wn = wnp;
-
-    if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
-        wnp[2] == L'?' && wnp[3] == L'\\')
-        /* We have already permissive names. */
-        return (wn);
-
-    if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
-        wnp[2] == L'.' && wnp[3] == L'\\') {
-        /* Device names */
-        if (((wnp[4] >= L'a' && wnp[4] <= L'z') ||
-             (wnp[4] >= L'A' && wnp[4] <= L'Z')) &&
-            wnp[5] == L':' && wnp[6] == L'\\')
-            wnp[2] = L'?';/* Not device names. */
-        return (wn);
-    }
-
-    unc = 0;
-    if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') {
-        wchar_t *p = &wnp[2];
-
-        /* Skip server-name letters. */
-        while (*p != L'\\' && *p != L'\0')
-            ++p;
-        if (*p == L'\\') {
-            wchar_t *rp = ++p;
-            /* Skip share-name letters. */
-            while (*p != L'\\' && *p != L'\0')
-                ++p;
-            if (*p == L'\\' && p != rp) {
-                /* Now, match patterns such as
-                 * "\\server-name\share-name\" */
-                wnp += 2;
-                len -= 2;
-                unc = 1;
-            }
-        }
-    }
-
-    alloclen = slen = 4 + (unc * 4) + len + 1;
-    ws = wsp = malloc(slen * sizeof(wchar_t));
-    if (ws == NULL) {
-        free(wn);
-        return (NULL);
-    }
-    /* prepend "\\?\" */
-    wcsncpy(wsp, L"\\\\?\\", 4);
-    wsp += 4;
-    slen -= 4;
-    if (unc) {
-        /* append "UNC\" ---> "\\?\UNC\" */
-        wcsncpy(wsp, L"UNC\\", 4);
-        wsp += 4;
-        slen -= 4;
-    }
-    wcsncpy(wsp, wnp, slen);
-    free(wn);
-    ws[alloclen - 1] = L'\0';
-    return (ws);
-}
-
-static HANDLE
-cpio_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
-    LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
-    DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
-{
-    wchar_t *wpath;
-    HANDLE handle;
-
-    handle = CreateFileA(path, dwDesiredAccess, dwShareMode,
-        lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
-        hTemplateFile);
-    if (handle != INVALID_HANDLE_VALUE)
-        return (handle);
-    if (GetLastError() != ERROR_PATH_NOT_FOUND)
-        return (handle);
-    wpath = permissive_name(path);
-    if (wpath == NULL)
-        return (handle);
-    handle = CreateFileW(wpath, dwDesiredAccess, dwShareMode,
-        lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
-        hTemplateFile);
-    free(wpath);
-    return (handle);
-}
-
-#define WINTIME(sec, usec)  ((Int32x32To64(sec, 10000000) + EPOC_TIME) + (usec * 10))
-static int
-__hutimes(HANDLE handle, const struct __timeval *times)
-{
-    ULARGE_INTEGER wintm;
-    FILETIME fatime, fmtime;
-
-    wintm.QuadPart = WINTIME(times[0].tv_sec, times[0].tv_usec);
-    fatime.dwLowDateTime = wintm.LowPart;
-    fatime.dwHighDateTime = wintm.HighPart;
-    wintm.QuadPart = WINTIME(times[1].tv_sec, times[1].tv_usec);
-    fmtime.dwLowDateTime = wintm.LowPart;
-    fmtime.dwHighDateTime = wintm.HighPart;
-    if (SetFileTime(handle, NULL, &fatime, &fmtime) == 0) {
-        errno = EINVAL;
-        return (-1);
-    }
-    return (0);
-}
-
-int
-futimes(int fd, const struct __timeval *times)
-{
-
-    return (__hutimes((HANDLE)_get_osfhandle(fd), times));
-}
-
-int
-utimes(const char *name, const struct __timeval *times)
-{
-    int ret;
-    HANDLE handle;
-
-    handle = cpio_CreateFile(name, GENERIC_READ | GENERIC_WRITE,
-        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
-        FILE_FLAG_BACKUP_SEMANTICS, NULL);
-    if (handle == INVALID_HANDLE_VALUE) {
-        cpio_dosmaperr(GetLastError());
-        return (-1);
-    }
-    ret = __hutimes(handle, times);
-    CloseHandle(handle);
-    return (ret);
-}
-
-/*
- * The following function was modified from PostgreSQL sources and is
- * subject to the copyright below.
- */
-/*-------------------------------------------------------------------------
- *
- * win32error.c
- *    Map win32 error codes to errno values
- *
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
- *
- * IDENTIFICATION
- *    $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-/*
-PostgreSQL Database Management System
-(formerly known as Postgres, then as Postgres95)
-
-Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
-
-Portions Copyright (c) 1994, The Regents of the University of California
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose, without fee, and without a written agreement
-is hereby granted, provided that the above copyright notice and this
-paragraph and the following two paragraphs appear in all copies.
-
-IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
-DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
-LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
-DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
-ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
-PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-*/
-
-static const struct {
-    DWORD       winerr;
-    int     doserr;
-} doserrors[] =
-{
-    {   ERROR_INVALID_FUNCTION, EINVAL  },
-    {   ERROR_FILE_NOT_FOUND, ENOENT    },
-    {   ERROR_PATH_NOT_FOUND, ENOENT    },
-    {   ERROR_TOO_MANY_OPEN_FILES, EMFILE   },
-    {   ERROR_ACCESS_DENIED, EACCES },
-    {   ERROR_INVALID_HANDLE, EBADF },
-    {   ERROR_ARENA_TRASHED, ENOMEM },
-    {   ERROR_NOT_ENOUGH_MEMORY, ENOMEM },
-    {   ERROR_INVALID_BLOCK, ENOMEM },
-    {   ERROR_BAD_ENVIRONMENT, E2BIG    },
-    {   ERROR_BAD_FORMAT, ENOEXEC   },
-    {   ERROR_INVALID_ACCESS, EINVAL    },
-    {   ERROR_INVALID_DATA, EINVAL  },
-    {   ERROR_INVALID_DRIVE, ENOENT },
-    {   ERROR_CURRENT_DIRECTORY, EACCES },
-    {   ERROR_NOT_SAME_DEVICE, EXDEV    },
-    {   ERROR_NO_MORE_FILES, ENOENT },
-    {   ERROR_LOCK_VIOLATION, EACCES    },
-    {   ERROR_SHARING_VIOLATION, EACCES },
-    {   ERROR_BAD_NETPATH, ENOENT   },
-    {   ERROR_NETWORK_ACCESS_DENIED, EACCES },
-    {   ERROR_BAD_NET_NAME, ENOENT  },
-    {   ERROR_FILE_EXISTS, EEXIST   },
-    {   ERROR_CANNOT_MAKE, EACCES   },
-    {   ERROR_FAIL_I24, EACCES  },
-    {   ERROR_INVALID_PARAMETER, EINVAL },
-    {   ERROR_NO_PROC_SLOTS, EAGAIN },
-    {   ERROR_DRIVE_LOCKED, EACCES  },
-    {   ERROR_BROKEN_PIPE, EPIPE    },
-    {   ERROR_DISK_FULL, ENOSPC },
-    {   ERROR_INVALID_TARGET_HANDLE, EBADF  },
-    {   ERROR_INVALID_HANDLE, EINVAL    },
-    {   ERROR_WAIT_NO_CHILDREN, ECHILD  },
-    {   ERROR_CHILD_NOT_COMPLETE, ECHILD    },
-    {   ERROR_DIRECT_ACCESS_HANDLE, EBADF   },
-    {   ERROR_NEGATIVE_SEEK, EINVAL },
-    {   ERROR_SEEK_ON_DEVICE, EACCES    },
-    {   ERROR_DIR_NOT_EMPTY, ENOTEMPTY  },
-    {   ERROR_NOT_LOCKED, EACCES    },
-    {   ERROR_BAD_PATHNAME, ENOENT  },
-    {   ERROR_MAX_THRDS_REACHED, EAGAIN },
-    {   ERROR_LOCK_FAILED, EACCES   },
-    {   ERROR_ALREADY_EXISTS, EEXIST    },
-    {   ERROR_FILENAME_EXCED_RANGE, ENOENT  },
-    {   ERROR_NESTING_NOT_ALLOWED, EAGAIN   },
-    {   ERROR_NOT_ENOUGH_QUOTA, ENOMEM  }
-};
-
-static void
-cpio_dosmaperr(unsigned long e)
-{
-    int         i;
-
-    if (e == 0) {
-        errno = 0;
-        return;
-    }
-
-    for (i = 0; i < sizeof(doserrors); i++) {
-        if (doserrors[i].winerr == e) {
-            errno = doserrors[i].doserr;
-            return;
-        }
-    }
-
-    /* fprintf(stderr, "unrecognized win32 error code: %lu", e); */
-    errno = EINVAL;
-    return;
-}
-#endif

+ 0 - 72
Utilities/cmlibarchive/cpio/cpio_windows.h

@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 2009 Michihiro NAKAJIMA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-#ifndef CPIO_WINDOWS_H
-#define CPIO_WINDOWS_H 1
-
-#include <io.h>
-#include <string.h>
-
-#define getgrgid(id)    NULL
-#define getgrnam(name)  NULL
-#define getpwnam(name)  NULL
-#define getpwuid(id)    NULL
-
-#ifdef _MSC_VER
-#define snprintf    sprintf_s
-#define strdup      _strdup
-#define open    _open
-#define read    _read
-#define close   _close
-#endif
-
-struct passwd {
-    char    *pw_name;
-    uid_t    pw_uid;
-    gid_t    pw_gid;
-};
-
-struct group {
-    char    *gr_name;
-    gid_t    gr_gid;
-};
-
-struct _timeval64i32 {
-    time_t      tv_sec;
-    long        tv_usec;
-};
-#define __timeval _timeval64i32
-
-extern int futimes(int fd, const struct __timeval *times);
-#ifndef HAVE_FUTIMES
-#define HAVE_FUTIMES 1
-#endif
-extern int utimes(const char *name, const struct __timeval *times);
-#ifndef HAVE_UTIMES
-#define HAVE_UTIMES 1
-#endif
-
-#endif /* CPIO_WINDOWS_H */

+ 0 - 75
Utilities/cmlibarchive/cpio/test/CMakeLists.txt

@@ -1,75 +0,0 @@
-############################################
-#
-# How to build bsdcpio_test
-#
-############################################
-IF(ENABLE_CPIO AND ENABLE_TEST)
-  SET(bsdcpio_test_SOURCES
-    ../cmdline.c
-    ../../libarchive_fe/err.c
-    ../../libarchive_fe/pathmatch.c
-    main.c
-    test.h
-    test_0.c
-    test_basic.c
-    test_cmdline.c
-    test_format_newc.c
-    test_gcpio_compat.c
-    test_option_B_upper.c
-    test_option_C_upper.c
-    test_option_J_upper.c
-    test_option_L_upper.c
-    test_option_Z_upper.c
-    test_option_a.c
-    test_option_c.c
-    test_option_d.c
-    test_option_f.c
-    test_option_help.c
-    test_option_l.c
-    test_option_lzma.c
-    test_option_m.c
-    test_option_t.c
-    test_option_u.c
-    test_option_version.c
-    test_option_y.c
-    test_option_z.c
-    test_owner_parse.c
-    test_passthrough_dotdot.c
-    test_passthrough_reverse.c
-    test_pathmatch.c
-  )
-  IF(WIN32 AND NOT CYGWIN)
-    LIST(APPEND bsdcpio_test_SOURCES ../cpio_windows.h)
-  ENDIF(WIN32 AND NOT CYGWIN)
-
-  #
-  # Generate the list.h
-  #
-  GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
-    ${CMAKE_CURRENT_LIST_FILE} ${bsdcpio_test_SOURCES})
-  SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
-    ${CMAKE_CURRENT_BINARY_DIR})
-  #
-  # Register target
-  #
-  ADD_EXECUTABLE(bsdcpio_test ${bsdcpio_test_SOURCES})
-  SET_PROPERTY(TARGET bsdcpio_test PROPERTY COMPILE_DEFINITIONS LIST_H)
-
-  # ADD_TEST() for each separate test
-  SET(num 0)
-  FOREACH(test ${bsdcpio_test_SOURCES})
-    IF(test MATCHES "^test_[^/]+[.]c$")
-      STRING(REGEX REPLACE "^(test_[^/]+)[.]c$" "\\1" testname ${test})
-      ADD_TEST("bsdcpio_${testname}" bsdcpio_test
-        -v -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR} ${num})
-      MATH(EXPR num "${num} + 1")
-    ENDIF(test MATCHES "^test_[^/]+[.]c$")
-  ENDFOREACH(test)
-
-  # Experimental new test handling
-  ADD_CUSTOM_TARGET(run_bsdcpio_test
-    COMMAND bsdcpio_test -p ${BSDCPIO} -r ${CMAKE_CURRENT_SOURCE_DIR})
-  ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
-  ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
-ENDIF(ENABLE_CPIO AND ENABLE_TEST)
-

+ 0 - 2059
Utilities/cmlibarchive/cpio/test/main.c

@@ -1,2059 +0,0 @@
-/*
- * Copyright (c) 2003-2009 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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 <errno.h>
-#include <locale.h>
-#include <stdarg.h>
-#include <time.h>
-#include "test.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.
- */
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.3 2008/08/24 04:58:22 kientzle Exp $");
-#define KNOWNREF    "test_option_f.cpio.uu"
-#define ENVBASE "BSDCPIO" /* Prefix for environment variables. */
-#define PROGRAM "bsdcpio" /* Name of program being tested. */
-#undef LIBRARY        /* Not testing a library. */
-#undef  EXTRA_DUMP       /* How to dump extra data */
-/* 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__)
-#if !defined(__GNUC__)
-#include <crtdbg.h>
-#endif
-#include <io.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
-#define access _access
-#define chdir _chdir
-#ifndef fileno
-#define fileno _fileno
-#endif
-/*#define fstat _fstat64*/
-#define getcwd _getcwd
-#define lstat stat
-/*#define lstat _stat64*/
-/*#define stat _stat64*/
-#define rmdir _rmdir
-#define strdup _strdup
-#define umask _umask
-#define int64_t __int64
-#endif
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-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);
-}
-
-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_ATTRIBUTE_NORMAL, NULL);
-    if (h == INVALID_HANDLE_VALUE)
-        return (0);
-    r = GetFileInformationByHandle(h, bhfi);
-    CloseHandle(h);
-    return (r);
-}
-#endif
-
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
-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 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)
-{
-    if (log_console)
-        vfprintf(stdout, fmt, ap);
-    if (logfile != NULL)
-        vfprintf(logfile, fmt, ap);
-}
-
-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;
-    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 noticably.
- */
-static const char *test_filename;
-static int test_line;
-static void *test_extra;
-void assertion_setup(const char *filename, int line)
-{
-    test_filename = filename;
-    test_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];
-
-/* 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;
-    test_filename = filename;
-    failed_lines[line].count++;
-
-    /* Determine whether to log header to console. */
-    switch (verbosity) {
-    case VERBOSITY_FULL:
-        log_console = 1;
-        break;
-    case VERBOSITY_LIGHT_REPORT:
-        log_console = (failed_lines[line].count < 2);
-        break;
-    default:
-        log_console = 0;
-    }
-
-    /* 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("   detail: %s\n", EXTRA_DUMP(extra));
-#endif
-
-    if (dump_on_failure) {
-        fprintf(stderr,
-            " *** forcing core dump so failure can be debugged ***\n");
-        *(char *)(NULL) = 0;
-        exit(1);
-    }
-}
-
-/* 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);
-    /* failure_start() isn't quite right, but is awfully convenient. */
-    failure_start(test_filename, test_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[test_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);
-}
-
-static void strdump(const char *e, const char *p)
-{
-    logprintf("      %s = ", e);
-    if (p == NULL) {
-        logprintf("(null)");
-        return;
-    }
-    logprintf("\"");
-    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;
-        default:
-            if (c >= 32 && c < 127)
-                logprintf("%c", c);
-            else
-                logprintf("\\x%02X", c);
-        }
-    }
-    logprintf("\"");
-    logprintf(" (length %d)\n", p == NULL ? 0 : (int)strlen(p));
-}
-
-/* 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)
-{
-    assertion_count(file, line);
-    if (v1 == v2 || strcmp(v1, v2) == 0)
-        return (1);
-    failure_start(file, line, "%s != %s", e1, e2);
-    strdump(e1, v1);
-    strdump(e2, v2);
-    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");
-}
-
-/* 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 || 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;
-
-    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 || memcmp(v1, v2, l) == 0)
-        return (1);
-
-    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 < 64 ? l : 64, offset);
-    logprintf("      Dump of %s\n", e2);
-    hexdump(v2, v1, l < 64 ? l : 64, offset);
-    logprintf("\n");
-    failure_finish(extra);
-    return (0);
-}
-
-/* Verify that the named file exists and is empty. */
-int
-assertion_empty_file(const char *f1fmt, ...)
-{
-    char buff[1024];
-    char f1[1024];
-    struct stat st;
-    va_list ap;
-    ssize_t s;
-    FILE *f;
-
-    assertion_count(test_filename, test_line);
-    va_start(ap, f1fmt);
-    vsprintf(f1, f1fmt, ap);
-    va_end(ap);
-
-    if (stat(f1, &st) != 0) {
-        failure_start(test_filename, test_line, "Stat failed: %s", f1);
-        failure_finish(NULL);
-        return (0);
-    }
-    if (st.st_size == 0)
-        return (1);
-
-    failure_start(test_filename, test_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 *f1fmt, ...)
-{
-    char f1[1024];
-    struct stat st;
-    va_list ap;
-
-    assertion_count(test_filename, test_line);
-    va_start(ap, f1fmt);
-    vsprintf(f1, f1fmt, ap);
-    va_end(ap);
-
-    if (stat(f1, &st) != 0) {
-        failure_start(test_filename, test_line, "Stat failed: %s", f1);
-        failure_finish(NULL);
-        return (0);
-    }
-    if (st.st_size == 0) {
-        failure_start(test_filename, test_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 *fn1, const char *f2pattern, ...)
-{
-    char fn2[1024];
-    va_list ap;
-    char buff1[1024];
-    char buff2[1024];
-    FILE *f1, *f2;
-    int n1, n2;
-
-    assertion_count(test_filename, test_line);
-    va_start(ap, f2pattern);
-    vsprintf(fn2, f2pattern, ap);
-    va_end(ap);
-
-    f1 = fopen(fn1, "rb");
-    f2 = fopen(fn2, "rb");
-    for (;;) {
-        n1 = fread(buff1, 1, sizeof(buff1), f1);
-        n2 = 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(test_filename, test_line, "Files not identical");
-    logprintf("  file1=\"%s\"\n", fn1);
-    logprintf("  file2=\"%s\"\n", fn2);
-    failure_finish(test_extra);
-    return (0);
-}
-
-/* Verify that the named file does exist. */
-int
-assertion_file_exists(const char *fpattern, ...)
-{
-    char f[1024];
-    va_list ap;
-
-    assertion_count(test_filename, test_line);
-    va_start(ap, fpattern);
-    vsprintf(f, fpattern, ap);
-    va_end(ap);
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    if (!_access(f, 0))
-        return (1);
-#else
-    if (!access(f, F_OK))
-        return (1);
-#endif
-    failure_start(test_filename, test_line, "File should exist: %s", f);
-    failure_finish(test_extra);
-    return (0);
-}
-
-/* Verify that the named file doesn't exist. */
-int
-assertion_file_not_exists(const char *fpattern, ...)
-{
-    char f[1024];
-    va_list ap;
-
-    assertion_count(test_filename, test_line);
-    va_start(ap, fpattern);
-    vsprintf(f, fpattern, ap);
-    va_end(ap);
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    if (_access(f, 0))
-        return (1);
-#else
-    if (access(f, F_OK))
-        return (1);
-#endif
-    failure_start(test_filename, test_line, "File should not exist: %s", f);
-    failure_finish(test_extra);
-    return (0);
-}
-
-/* Compare the contents of a file to a block of memory. */
-int
-assertion_file_contents(const void *buff, int s, const char *fpattern, ...)
-{
-    char fn[1024];
-    va_list ap;
-    char *contents;
-    FILE *f;
-    int n;
-
-    assertion_count(test_filename, test_line);
-    va_start(ap, fpattern);
-    vsprintf(fn, fpattern, ap);
-    va_end(ap);
-
-    f = fopen(fn, "rb");
-    if (f == NULL) {
-        failure_start(test_filename, test_line,
-            "File should exist: %s", fn);
-        failure_finish(test_extra);
-        return (0);
-    }
-    contents = malloc(s * 2);
-    n = fread(contents, 1, s * 2, f);
-    fclose(f);
-    if (n == s && memcmp(buff, contents, s) == 0) {
-        free(contents);
-        return (1);
-    }
-    failure_start(test_filename, test_line, "File contents don't match");
-    logprintf("  file=\"%s\"\n", fn);
-    if (n > 0)
-        hexdump(contents, buff, n > 512 ? 512 : 0, 0);
-    else {
-        logprintf("  File empty, contents should be:\n");
-        hexdump(buff, NULL, s > 512 ? 512 : 0, 0);
-    }
-    failure_finish(test_extra);
-    free(contents);
-    return (0);
-}
-
-/* Check the contents of a text file, being tolerant of line endings. */
-int
-assertion_text_file_contents(const char *buff, const char *fn)
-{
-    char *contents;
-    const char *btxt, *ftxt;
-    FILE *f;
-    int n, s;
-
-    assertion_count(test_filename, test_line);
-    f = fopen(fn, "r");
-    s = strlen(buff);
-    contents = malloc(s * 2 + 128);
-    n = 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(test_filename, test_line, "Contents don't match");
-    logprintf("  file=\"%s\"\n", fn);
-    if (n > 0)
-        hexdump(contents, buff, n, 0);
-    else {
-        logprintf("  File empty, contents should be:\n");
-        hexdump(buff, NULL, s, 0);
-    }
-    failure_finish(test_extra);
-    free(contents);
-    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 ftime, fbirthtime, fatime, fmtime;
-    ULARGE_INTEGER wintm;
-    HANDLE h;
-    ftime.dwLowDateTime = 0;
-    ftime.dwHighDateTime = 0;
-
-    assertion_count(file, line);
-    h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL,
-        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 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': ftime = fatime; break;
-    case 'b': ftime = fbirthtime; break;
-    case 'm': ftime = fmtime; break;
-    }
-    CloseHandle(h);
-    if (r == 0) {
-        failure_start(file, line, "Can't GetFileTime %s\n", pathname);
-        failure_finish(NULL);
-        return (0);
-    }
-    wintm.LowPart = ftime.dwLowDateTime;
-    wintm.HighPart = ftime.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 */
-#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 %ld, %ld 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 %ld.%09ld, expected %ld.%09ld",
-            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 == 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 && 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;
-
-    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 != (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;
-
-    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 != (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__)
-    assertion_count(file, line);
-    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__)
-    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, const char *contents)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* TODO: Rework this to set file mode as well. */
-    FILE *f;
-    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) {
-        if (strlen(contents)
-            != fwrite(contents, 1, strlen(contents), 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) {
-        if ((ssize_t)strlen(contents)
-            != write(fd, contents, strlen(contents))) {
-            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);
-}
-
-/*
- *
- *  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.
- */
-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, "a");
-#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);
-}
-
-/*
- * Can this platform run the gzip program?
- */
-/* 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
-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 gunzip program?
- */
-int
-canGunzip(void)
-{
-    static int tested = 0, value = 0;
-    if (!tested) {
-        tested = 1;
-        if (systemf("gunzip -V %s", redirectArgs) == 0)
-            value = 1;
-    }
-    return (value);
-}
-
-/*
- * 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);
-}
-
-/* Read a uuencoded file from the reference directory, decode, and
- * write the result into the current directory. */
-#define UUDECODE(c) (((c) - 0x20) & 0x3f)
-void
-extract_reference_file(const char *name)
-{
-    char buff[1024];
-    FILE *in, *out;
-
-    sprintf(buff, "%s/%s.uu", refdir, name);
-    in = fopen(buff, "r");
-    failure("Couldn't open reference file %s", buff);
-    assert(in != NULL);
-    if (in == NULL)
-        return;
-    /* Read up to and including the 'begin' line. */
-    for (;;) {
-        if (fgets(buff, sizeof(buff), in) == NULL) {
-            /* TODO: This is a failure. */
-            return;
-        }
-        if (memcmp(buff, "begin ", 6) == 0)
-            break;
-    }
-    /* Now, decode the rest and write it. */
-    /* Not a lot of error checking here; the input better be right. */
-    out = fopen(name, "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) {
-                n = UUDECODE(*p++) << 18;
-                n |= UUDECODE(*p++) << 12;
-                fputc(n >> 16, out);
-                --bytes;
-            }
-            if (bytes > 0) {
-                n |= UUDECODE(*p++) << 6;
-                fputc((n >> 8) & 0xFF, out);
-                --bytes;
-            }
-            if (bytes > 0) {
-                n |= UUDECODE(*p++);
-                fputc(n & 0xFF, out);
-                --bytes;
-            }
-        }
-    }
-    fclose(out);
-    fclose(in);
-}
-
-/*
- *
- * 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 { void (*func)(void); const char *name; int failures; } tests[] = {
-    #include "list.h"
-};
-
-/*
- * Summarize repeated failures in the just-completed test.
- */
-static void
-test_summarize(const char *filename, int failed)
-{
-    unsigned int i;
-
-    switch (verbosity) {
-    case VERBOSITY_SUMMARY_ONLY:
-        printf(failed ? "E" : ".");
-        fflush(stdout);
-        break;
-    case VERBOSITY_PASSFAIL:
-        printf(failed ? "FAIL\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",
-                filename, i, failed_lines[i].count);
-    }
-    /* Clear the failure history for the next file. */
-    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 logfilename[64];
-    int failures_before = failures;
-    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);
-        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. */
-    if (!assertMakeDir(tests[i].name, 0755)
-        || !assertChdir(tests[i].name)) {
-        fprintf(stderr,
-            "ERROR: Can't chdir to work dir %s/%s\n",
-            tmpdir, tests[i].name);
-        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.
-     */
-    /* 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(test_filename, tests[i].failures);
-    /* 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__)
-            systemf("rmdir /S /Q %s", tests[i].name);
-            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("  -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. */
-    pwd = getcwd(NULL, 0);
-    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 (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);
-#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 i, tests_run = 0, tests_failed = 0, option;
-    time_t now;
-    char *refdir_alloc = NULL;
-    const char *progname;
-    const char *tmp, *option_arg, *p;
-    char tmpdir[256];
-    char tmpdir_timestamp[256];
-
-    (void)argc; /* UNUSED */
-
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
-    /* 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];
-    while (*p != '\0') {
-        /* Support \ or / dir separators for Windows compat. */
-        if (*p == '/' || *p == '\\')
-            progname = p + 1;
-        ++p;
-    }
-
-#ifdef PROGRAM
-    /* Get the target program from environment, if available. */
-    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;
-
-    /* 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
-                usage(progname);
-#endif
-                break;
-            case 'q':
-                verbosity--;
-                break;
-            case 'r':
-                refdir = option_arg;
-                break;
-            case 'v':
-                verbosity++;
-                break;
-            default:
-                usage(progname);
-            }
-        }
-    }
-
-    /*
-     * Sanity-check that our options make sense.
-     */
-#ifdef PROGRAM
-    if (testprogfile == NULL)
-        usage(progname);
-    {
-        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
-
-    /*
-     * 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.
-     */
-    if (*argv == NULL) {
-        /* Default: Run all tests. */
-        for (i = 0; i < limit; i++) {
-            if (test_run(i, tmpdir))
-                tests_failed++;
-            tests_run++;
-        }
-    } else {
-        while (*(argv) != NULL) {
-            if (**argv >= '0' && **argv <= '9') {
-                i = atoi(*argv);
-                if (i < 0 || i >= limit) {
-                    printf("*** INVALID Test %s\n", *argv);
-                    free(refdir_alloc);
-                    usage(progname);
-                    /* usage() never returns */
-                }
-            } else {
-                for (i = 0; i < limit; ++i) {
-                    if (strcmp(*argv, tests[i].name) == 0)
-                        break;
-                }
-                if (i >= limit) {
-                    printf("*** INVALID Test ``%s''\n",
-                           *argv);
-                    free(refdir_alloc);
-                    usage(progname);
-                    /* usage() never returns */
-                }
-            }
-            if (test_run(i, tmpdir))
-                tests_failed++;
-            tests_run++;
-            argv++;
-        }
-    }
-
-    /*
-     * 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);
-}

+ 0 - 277
Utilities/cmlibarchive/cpio/test/test.h

@@ -1,277 +0,0 @@
-/*
- * Copyright (c) 2003-2006 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/usr.bin/cpio/test/test.h,v 1.2 2008/06/21 02:17:18 kientzle Exp $
- */
-
-/* Every test program should #include "test.h" as the first thing. */
-
-/*
- * The goal of this file (and the matching test.c) is to
- * simplify the very repetitive test-*.c test programs.
- */
-#if defined(HAVE_CONFIG_H)
-/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "config.h"
-#elif defined(__FreeBSD__)
-/* Building as part of FreeBSD system requires a pre-built config.h. */
-#include "config_freebsd.h"
-#elif defined(_WIN32) && !defined(__CYGWIN__)
-/* Win32 can't run the 'configure' script. */
-#include "config_windows.h"
-#else
-/* Warn if the library hasn't been (automatically or manually) configured. */
-#error Oops: No config.h and no pre-built configuration in test.h.
-#endif
-
-#include <sys/types.h>  /* Windows requires this before sys/stat.h */
-#include <sys/stat.h>
-
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
-#endif
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#else
-#include <direct.h>
-#define dirent direct
-#endif
-#include <errno.h>
-#include <fcntl.h>
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <wchar.h>
-#ifdef HAVE_WINDOWS_H
-#include <windows.h>
-#endif
-
-/*
- * System-specific tweaks.  We really want to minimize these
- * as much as possible, since they make it harder to understand
- * the mainline code.
- */
-
-/* Windows (including Visual Studio and MinGW but not Cygwin) */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include "../cpio_windows.h"
-#define strdup _strdup
-#define LOCALE_DE   "deu"
-#else
-#define LOCALE_DE   "de_DE.UTF-8"
-#endif
-
-/* Visual Studio */
-#ifdef _MSC_VER
-#define snprintf    sprintf_s
-#endif
-
-/* Cygwin */
-#if defined(__CYGWIN__)
-/* Cygwin-1.7.x is lazy about populating nlinks, so don't
- * expect it to be accurate. */
-# define NLINKS_INACCURATE_FOR_DIRS
-#endif
-
-/* FreeBSD */
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>  /* For __FBSDID */
-#else
-/* Surprisingly, some non-FreeBSD platforms define __FBSDID. */
-#ifndef __FBSDID
-#define __FBSDID(a)     struct _undefined_hack
-#endif
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-/*
- * Redefine DEFINE_TEST for use in defining the test functions.
- */
-#undef DEFINE_TEST
-#define DEFINE_TEST(name) void name(void); void name(void)
-
-/* An implementation of the standard assert() macro */
-#define assert(e)   assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
-/* chdir() and error if it fails */
-#define assertChdir(path)  \
-  assertion_chdir(__FILE__, __LINE__, path)
-/* Assert two integers are the same.  Reports value of each one if not. */
-#define assertEqualInt(v1,v2) \
-  assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-/* Assert two strings are the same.  Reports value of each one if not. */
-#define assertEqualString(v1,v2)   \
-  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-/* As above, but v1 and v2 are wchar_t * */
-#define assertEqualWString(v1,v2)   \
-  assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-/* As above, but raw blocks of bytes. */
-#define assertEqualMem(v1, v2, l)   \
-  assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
-/* Assert two files are the same; allow printf-style expansion of second name.
- * See below for comments about variable arguments here...
- */
-#define assertEqualFile     \
-  assertion_setup(__FILE__, __LINE__);assertion_equal_file
-/* Assert that a file is empty; supports printf-style arguments. */
-#define assertEmptyFile     \
-  assertion_setup(__FILE__, __LINE__);assertion_empty_file
-/* Assert that a file is not empty; supports printf-style arguments. */
-#define assertNonEmptyFile      \
-  assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
-#define assertFileAtime(pathname, sec, nsec)    \
-  assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
-#define assertFileAtimeRecent(pathname) \
-  assertion_file_atime_recent(__FILE__, __LINE__, pathname)
-#define assertFileBirthtime(pathname, sec, nsec)    \
-  assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
-#define assertFileBirthtimeRecent(pathname) \
-  assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileExists        \
-  assertion_setup(__FILE__, __LINE__);assertion_file_exists
-/* Assert that a file exists; supports printf-style arguments. */
-#define assertFileNotExists     \
-  assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
-/* Assert that file contents match a string; supports printf-style arguments. */
-#define assertFileContents             \
-  assertion_setup(__FILE__, __LINE__);assertion_file_contents
-#define assertFileMtime(pathname, sec, nsec)    \
-  assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
-#define assertFileMtimeRecent(pathname) \
-  assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
-#define assertFileNLinks(pathname, nlinks)  \
-  assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
-#define assertFileSize(pathname, size)  \
-  assertion_file_size(__FILE__, __LINE__, pathname, size)
-#define assertTextFileContents         \
-  assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
-#define assertIsDir(pathname, mode)     \
-  assertion_is_dir(__FILE__, __LINE__, pathname, mode)
-#define assertIsHardlink(path1, path2)  \
-  assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
-#define assertIsNotHardlink(path1, path2)   \
-  assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
-#define assertIsReg(pathname, mode)     \
-  assertion_is_reg(__FILE__, __LINE__, pathname, mode)
-#define assertIsSymlink(pathname, contents) \
-  assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
-/* Create a directory, report error if it fails. */
-#define assertMakeDir(dirname, mode)    \
-  assertion_make_dir(__FILE__, __LINE__, dirname, mode)
-#define assertMakeFile(path, mode, contents) \
-  assertion_make_file(__FILE__, __LINE__, path, mode, contents)
-#define assertMakeHardlink(newfile, oldfile)    \
-  assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
-#define assertMakeSymlink(newfile, linkto)  \
-  assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
-#define assertUmask(mask)   \
-  assertion_umask(__FILE__, __LINE__, mask)
-
-/*
- * This would be simple with C99 variadic macros, but I don't want to
- * require that.  Instead, I insert a function call before each
- * skipping() call to pass the file and line information down.  Crude,
- * but effective.
- */
-#define skipping    \
-  assertion_setup(__FILE__, __LINE__);test_skipping
-
-/* Function declarations.  These are defined in test_utility.c. */
-void failure(const char *fmt, ...);
-int assertion_assert(const char *, int, int, const char *, void *);
-int assertion_chdir(const char *, int, const char *);
-int assertion_empty_file(const char *, ...);
-int assertion_equal_file(const char *, const char *, ...);
-int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
-int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
-int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
-int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
-int assertion_file_atime(const char *, int, const char *, long, long);
-int assertion_file_atime_recent(const char *, int, const char *);
-int assertion_file_birthtime(const char *, int, const char *, long, long);
-int assertion_file_birthtime_recent(const char *, int, const char *);
-int assertion_file_contents(const void *, int, const char *, ...);
-int assertion_file_exists(const char *, ...);
-int assertion_file_mtime(const char *, int, const char *, long, long);
-int assertion_file_mtime_recent(const char *, int, const char *);
-int assertion_file_nlinks(const char *, int, const char *, int);
-int assertion_file_not_exists(const char *, ...);
-int assertion_file_size(const char *, int, const char *, long);
-int assertion_is_dir(const char *, int, const char *, int);
-int assertion_is_hardlink(const char *, int, const char *, const char *);
-int assertion_is_not_hardlink(const char *, int, const char *, const char *);
-int assertion_is_reg(const char *, int, const char *, int);
-int assertion_is_symlink(const char *, int, const char *, const char *);
-int assertion_make_dir(const char *, int, const char *, int);
-int assertion_make_file(const char *, int, const char *, int, const char *);
-int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
-int assertion_make_symlink(const char *, int, const char *newpath, const char *);
-int assertion_non_empty_file(const char *, ...);
-int assertion_text_file_contents(const char *buff, const char *f);
-int assertion_umask(const char *, int, int);
-void assertion_setup(const char *, int);
-
-void test_skipping(const char *fmt, ...);
-
-/* Like sprintf, then system() */
-int systemf(const char * fmt, ...);
-
-/* Delay until time() returns a value after this. */
-void sleepUntilAfter(time_t);
-
-/* Return true if this platform can create symlinks. */
-int canSymlink(void);
-
-/* Return true if this platform can run the "gzip" program. */
-int canGzip(void);
-
-/* Return true if this platform can run the "gunzip" program. */
-int canGunzip(void);
-
-/* Suck file into string allocated via malloc(). Call free() when done. */
-/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
-char *slurpfile(size_t *, const char *fmt, ...);
-
-/* Extracts named reference file to the current directory. */
-void extract_reference_file(const char *);
-
-/*
- * Special interfaces for program test harness.
- */
-
-/* Pathname of exe to be tested. */
-const char *testprogfile;
-/* Name of exe to use in printf-formatted command strings. */
-/* On Windows, this includes leading/trailing quotes. */
-const char *testprog;

+ 0 - 67
Utilities/cmlibarchive/cpio/test/test_0.c

@@ -1,67 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-/*
- * 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?!", testprogfile);
-    if (!assertEqualInt(0, stat(testprogfile, &st)))
-        exit(1);
-
-    failure("%s is not executable?!", testprogfile);
-    if (!assert((st.st_mode & 0111) != 0))
-        exit(1);
-
-    /*
-     * Try to succesfully run the program; this requires that
-     * we know some option that will succeed.
-     */
-    if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
-        /* This worked. */
-    } else if (0 == systemf("%s -W version >" DEV_NULL, testprog)) {
-        /* This worked. */
-    } else {
-        failure("Unable to successfully run any of the following:\n"
-            "  * %s --version\n"
-            "  * %s -W version\n",
-            testprog, testprog);
-        assert(0);
-    }
-
-    /* TODO: Ensure that our reference files are available. */
-}

+ 0 - 173
Utilities/cmlibarchive/cpio/test/test_basic.c

@@ -1,173 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_basic.c,v 1.4 2008/08/25 06:39:29 kientzle Exp $");
-
-static void
-verify_files(const char *msg)
-{
-    /*
-     * Verify unpacked files.
-     */
-
-    /* Regular file with 2 links. */
-    assertIsReg("file", 0644);
-    failure(msg);
-    assertFileSize("file", 10);
-    assertFileNLinks("file", 2);
-
-    /* Another name for the same file. */
-    assertIsHardlink("linkfile", "file");
-
-    /* Symlink */
-    if (canSymlink())
-        assertIsSymlink("symlink", "file");
-
-    /* Another file with 1 link and different permissions. */
-    assertIsReg("file2", 0777);
-    assertFileSize("file2", 10);
-    assertFileNLinks("file2", 1);
-
-    /* dir */
-    assertIsDir("dir", 0775);
-}
-
-static void
-basic_cpio(const char *target,
-    const char *pack_options,
-    const char *unpack_options,
-    const char *se)
-{
-    int r;
-
-    if (!assertMakeDir(target, 0775))
-        return;
-
-    /* Use the cpio program to create an archive. */
-    r = systemf("%s -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);
-
-    assertChdir(target);
-
-    /* Verify stderr. */
-    failure("Expected: %s, options=%s", se, pack_options);
-    assertTextFileContents(se, "pack.err");
-
-    /*
-     * Use cpio to unpack the archive into another directory.
-     */
-    r = systemf("%s -i %s< archive >unpack.out 2>unpack.err",
-        testprog, unpack_options);
-    failure("Error invoking %s -i %s", testprog, unpack_options);
-    assertEqualInt(r, 0);
-
-    /* Verify stderr. */
-    failure("Error invoking %s -i %s in dir %s", testprog, unpack_options, target);
-    assertTextFileContents(se, "unpack.err");
-
-    verify_files(pack_options);
-
-    assertChdir("..");
-}
-
-static void
-passthrough(const char *target)
-{
-    int r;
-
-    if (!assertMakeDir(target, 0775))
-        return;
-
-    /*
-     * Use cpio passthrough mode to copy files to another directory.
-     */
-    r = systemf("%s -p %s <filelist >%s/stdout 2>%s/stderr",
-        testprog, target, target, target);
-    failure("Error invoking %s -p", testprog);
-    assertEqualInt(r, 0);
-
-    assertChdir(target);
-
-    /* Verify stderr. */
-    failure("Error invoking %s -p in dir %s",
-        testprog, target);
-    assertTextFileContents("1 block\n", "stderr");
-
-    verify_files("passthrough");
-    assertChdir("..");
-}
-
-DEFINE_TEST(test_basic)
-{
-    FILE *filelist;
-    const char *msg;
-
-    assertUmask(0);
-
-    /*
-     * Create an assortment of files on disk.
-     */
-    filelist = fopen("filelist", "w");
-
-    /* File with 10 bytes content. */
-    assertMakeFile("file", 0644, "1234567890");
-    fprintf(filelist, "file\n");
-
-    /* hardlink to above file. */
-    assertMakeHardlink("linkfile", "file");
-    fprintf(filelist, "linkfile\n");
-
-    /* Symlink to above file. */
-    if (canSymlink()) {
-        assertMakeSymlink("symlink", "file");
-        fprintf(filelist, "symlink\n");
-    }
-
-    /* Another file with different permissions. */
-    assertMakeFile("file2", 0777, "1234567890");
-    fprintf(filelist, "file2\n");
-
-    /* Directory. */
-    assertMakeDir("dir", 0775);
-    fprintf(filelist, "dir\n");
-    /* All done. */
-    fclose(filelist);
-
-    assertUmask(022);
-
-    /* Archive/dearchive with a variety of options. */
-    msg = canSymlink() ? "2 blocks\n" : "1 block\n";
-    basic_cpio("copy", "", "", msg);
-    basic_cpio("copy_odc", "--format=odc", "", msg);
-    basic_cpio("copy_newc", "-H newc", "", "2 blocks\n");
-    basic_cpio("copy_cpio", "-H odc", "", msg);
-    msg = canSymlink() ? "9 blocks\n" : "8 blocks\n";
-    basic_cpio("copy_ustar", "-H ustar", "", msg);
-
-    /* Copy in one step using -p */
-    passthrough("passthrough");
-}

+ 0 - 107
Utilities/cmlibarchive/cpio/test/test_cmdline.c

@@ -1,107 +0,0 @@
-/*-
- * Copyright (c) 2003-2009 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-/*
- * Test the command-line parsing.
- */
-
-DEFINE_TEST(test_cmdline)
-{
-    FILE *f;
-
-    /* Create an empty file. */
-    f = fopen("empty", "wb");
-    assert(f != NULL);
-    fclose(f);
-
-    failure("-Q is an invalid option on every cpio program I know of");
-    assert(0 != systemf("%s -i -Q <empty >1.out 2>1.err", testprog));
-    assertEmptyFile("1.out");
-
-    failure("-f requires an argument");
-    assert(0 != systemf("%s -if <empty >2.out 2>2.err", testprog));
-    assertEmptyFile("2.out");
-
-    failure("-f requires an argument");
-    assert(0 != systemf("%s -i -f <empty >3.out 2>3.err", testprog));
-    assertEmptyFile("3.out");
-
-    failure("--format requires an argument");
-    assert(0 != systemf("%s -i --format <empty >4.out 2>4.err", testprog));
-    assertEmptyFile("4.out");
-
-    failure("--badopt is an invalid option");
-    assert(0 != systemf("%s -i --badop <empty >5.out 2>5.err", testprog));
-    assertEmptyFile("5.out");
-
-    failure("--badopt is an invalid option");
-    assert(0 != systemf("%s -i --badopt <empty >6.out 2>6.err", testprog));
-    assertEmptyFile("6.out");
-
-    failure("--n is ambiguous");
-    assert(0 != systemf("%s -i --n <empty >7.out 2>7.err", testprog));
-    assertEmptyFile("7.out");
-
-    failure("--create forbids an argument");
-    assert(0 != systemf("%s --create=arg <empty >8.out 2>8.err", testprog));
-    assertEmptyFile("8.out");
-
-    failure("-i with empty input should succeed");
-    assert(0 == systemf("%s -i <empty >9.out 2>9.err", testprog));
-    assertEmptyFile("9.out");
-
-    failure("-o with empty input should succeed");
-    assert(0 == systemf("%s -o <empty >10.out 2>10.err", testprog));
-
-    failure("-i -p is nonsense");
-    assert(0 != systemf("%s -i -p <empty >11.out 2>11.err", testprog));
-    assertEmptyFile("11.out");
-
-    failure("-p -i is nonsense");
-    assert(0 != systemf("%s -p -i <empty >12.out 2>12.err", testprog));
-    assertEmptyFile("12.out");
-
-    failure("-i -o is nonsense");
-    assert(0 != systemf("%s -i -o <empty >13.out 2>13.err", testprog));
-    assertEmptyFile("13.out");
-
-    failure("-o -i is nonsense");
-    assert(0 != systemf("%s -o -i <empty >14.out 2>14.err", testprog));
-    assertEmptyFile("14.out");
-
-    failure("-o -p is nonsense");
-    assert(0 != systemf("%s -o -p <empty >15.out 2>15.err", testprog));
-    assertEmptyFile("15.out");
-
-    failure("-p -o is nonsense");
-    assert(0 != systemf("%s -p -o <empty >16.out 2>16.err", testprog));
-    assertEmptyFile("16.out");
-
-    failure("-p with empty input should fail");
-    assert(0 != systemf("%s -p <empty >17.out 2>17.err", testprog));
-    assertEmptyFile("17.out");
-}

+ 0 - 294
Utilities/cmlibarchive/cpio/test/test_format_newc.c

@@ -1,294 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_format_newc.c,v 1.2 2008/08/22 02:09:10 kientzle Exp $");
-
-/* Number of bytes needed to pad 'n' to multiple of 'block', assuming
- * that 'block' is a power of two. This trick can be more easily
- * remembered as -n & (block - 1), but many compilers quite reasonably
- * warn about "-n" when n is an unsigned value.  (~(n) + 1) is the
- * same thing, but written in a way that won't offend anyone. */
-#define PAD(n, block)  ((~(n) + 1) & ((block) - 1))
-
-static int
-is_hex(const char *p, size_t l)
-{
-    while (l > 0) {
-        if ((*p >= '0' && *p <= '9')
-            || (*p >= 'a' && *p <= 'f')
-            || (*p >= 'A' && *p <= 'F'))
-        {
-            --l;
-            ++p;
-        } else
-            return (0);
-
-    }
-    return (1);
-}
-
-static int
-from_hex(const char *p, size_t l)
-{
-    int r = 0;
-
-    while (l > 0) {
-        r *= 16;
-        if (*p >= 'a' && *p <= 'f')
-            r += *p + 10 - 'a';
-        else if (*p >= 'A' && *p <= 'F')
-            r += *p + 10 - 'A';
-        else
-            r += *p - '0';
-        --l;
-        ++p;
-    }
-    return (r);
-}
-
-DEFINE_TEST(test_format_newc)
-{
-    FILE *list;
-    int r;
-    int devmajor, devminor, ino, gid;
-    int uid = -1;
-    time_t t, t2, now;
-    char *p, *e;
-    size_t s, fs, ns;
-
-    assertUmask(0);
-
-#if !defined(_WIN32)
-    uid = getuid();
-#endif
-
-    /*
-     * Create an assortment of files.
-     * TODO: Extend this to cover more filetypes.
-     */
-    list = fopen("list", "w");
-
-    /* "file1" */
-    assertMakeFile("file1", 0644, "1234567890");
-    fprintf(list, "file1\n");
-
-    /* "hardlink" */
-    assertMakeHardlink("hardlink", "file1");
-    fprintf(list, "hardlink\n");
-
-    /* Another hardlink, but this one won't be archived. */
-    assertMakeHardlink("hardlink2", "file1");
-
-    /* "symlink" */
-    if (canSymlink()) {
-        assertMakeSymlink("symlink", "file1");
-        fprintf(list, "symlink\n");
-    }
-
-    /* "dir" */
-    assertMakeDir("dir", 0775);
-    fprintf(list, "dir\n");
-
-    /* Record some facts about what we just created: */
-    now = time(NULL); /* They were all created w/in last two seconds. */
-
-    /* Use the cpio program to create an archive. */
-    fclose(list);
-    r = systemf("%s -o --format=newc <list >newc.out 2>newc.err",
-        testprog);
-    if (!assertEqualInt(r, 0))
-        return;
-
-    /* Verify that nothing went to stderr. */
-    if (canSymlink()) {
-        assertTextFileContents("2 blocks\n", "newc.err");
-    } else {
-        assertTextFileContents("1 block\n", "newc.err");
-    }
-
-    /* Verify that stdout is a well-formed cpio file in "newc" format. */
-    p = slurpfile(&s, "newc.out");
-    assertEqualInt(s, canSymlink() ? 1024 : 512);
-    e = p;
-
-    /*
-     * Some of these assertions could be stronger, but it's
-     * a little tricky because they depend on the local environment.
-     */
-
-    /* First entry is "file1" */
-    assert(is_hex(e, 110)); /* Entire header is octal digits. */
-    assertEqualMem(e + 0, "070701", 6); /* Magic */
-    ino = from_hex(e + 6, 8); /* ino */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Group members bits and others bits do not work. */ 
-    assertEqualInt(0x8180, from_hex(e + 14, 8) & 0xffc0); /* Mode */
-#else
-    assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
-#endif  
-    if (uid < 0)
-        uid = from_hex(e + 22, 8);
-    assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
-    gid = from_hex(e + 30, 8); /* gid */
-    assertEqualMem(e + 38, "00000003", 8); /* nlink */
-    t = from_hex(e + 46, 8); /* mtime */
-    failure("t=0x%08x now=0x%08x=%d", t, now, now);
-    assert(t <= now); /* File wasn't created in future. */
-    failure("t=0x%08x now - 2=0x%08x = %d", t, now - 2, now - 2);
-    assert(t >= now - 2); /* File was created w/in last 2 secs. */
-    failure("newc format stores body only with last appearance of a link\n"
-        "       first appearance should be empty, so this file size\n"
-        "       field should be zero");
-    assertEqualInt(0, from_hex(e + 54, 8)); /* File size */
-    fs = from_hex(e + 54, 8);
-    fs += PAD(fs, 4);
-    devmajor = from_hex(e + 62, 8); /* devmajor */
-    devminor = from_hex(e + 70, 8); /* devminor */
-    assert(is_hex(e + 78, 8)); /* rdevmajor */
-    assert(is_hex(e + 86, 8)); /* rdevminor */
-    assertEqualMem(e + 94, "00000006", 8); /* Name size */
-    ns = from_hex(e + 94, 8);
-    ns += PAD(ns + 2, 4);
-    assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
-    assertEqualMem(e + 110, "file1\0", 6); /* Name contents */
-    /* Since there's another link, no file contents here. */
-    /* But add in file size so that an error here doesn't cascade. */
-    e += 110 + fs + ns;
-
-    if (canSymlink()) {
-        /* "symlink" pointing to "file1" */
-        assert(is_hex(e, 110));
-        assertEqualMem(e + 0, "070701", 6); /* Magic */
-        assert(is_hex(e + 6, 8)); /* ino */
-        assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */
-        assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
-        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
-        assertEqualMem(e + 38, "00000001", 8); /* nlink */
-        t2 = from_hex(e + 46, 8); /* mtime */
-        failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
-        assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
-        assertEqualMem(e + 54, "00000005", 8); /* File size */
-        fs = from_hex(e + 54, 8);
-        fs += PAD(fs, 4);
-        assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
-        assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
-        assert(is_hex(e + 78, 8)); /* rdevmajor */
-        assert(is_hex(e + 86, 8)); /* rdevminor */
-        assertEqualMem(e + 94, "00000008", 8); /* Name size */
-        ns = from_hex(e + 94, 8);
-        ns += PAD(ns + 2, 4);
-        assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
-        assertEqualMem(e + 110, "symlink\0\0\0", 10); /* Name contents */
-        assertEqualMem(e + 110 + ns, "file1\0\0\0", 8); /* symlink target */
-        e += 110 + fs + ns;
-    }
-
-    /* "dir" */
-    assert(is_hex(e, 110));
-    assertEqualMem(e + 0, "070701", 6); /* Magic */
-    assert(is_hex(e + 6, 8)); /* ino */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Group members bits and others bits do not work. */
-    assertEqualInt(0x41c0, from_hex(e + 14, 8) & 0xffc0); /* Mode */
-#else
-    /* Mode: sgid bit sometimes propagates from parent dirs, ignore it. */
-    assertEqualInt(040775, from_hex(e + 14, 8) & ~02000);
-#endif
-    assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
-    assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
-#ifndef NLINKS_INACCURATE_FOR_DIRS
-    assertEqualMem(e + 38, "00000002", 8); /* nlink */
-#endif
-    t2 = from_hex(e + 46, 8); /* mtime */
-    failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
-    assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
-    assertEqualMem(e + 54, "00000000", 8); /* File size */
-    fs = from_hex(e + 54, 8);
-    fs += PAD(fs, 4);
-    assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
-    assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
-    assert(is_hex(e + 78, 8)); /* rdevmajor */
-    assert(is_hex(e + 86, 8)); /* rdevminor */
-    assertEqualMem(e + 94, "00000004", 8); /* Name size */
-    ns = from_hex(e + 94, 8);
-    ns += PAD(ns + 2, 4);
-    assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
-    assertEqualMem(e + 110, "dir\0\0\0", 6); /* Name contents */
-    e += 110 + fs + ns;
-
-    /* Hardlink identical to "file1" */
-    /* Since we only wrote two of the three links to this
-     * file, this link should get deferred by the hardlink logic. */
-    assert(is_hex(e, 110));
-    assertEqualMem(e + 0, "070701", 6); /* Magic */
-    failure("If these aren't the same, then the hardlink detection failed to match them.");
-    assertEqualInt(ino, from_hex(e + 6, 8)); /* ino */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Group members bits and others bits do not work. */ 
-    assertEqualInt(0x8180, from_hex(e + 14, 8) & 0xffc0); /* Mode */
-#else
-    assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
-#endif
-    assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
-    assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
-    assertEqualMem(e + 38, "00000003", 8); /* nlink */
-    t2 = from_hex(e + 46, 8); /* mtime */
-    failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
-    assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
-    assertEqualInt(10, from_hex(e + 54, 8)); /* File size */
-    fs = from_hex(e + 54, 8);
-    fs += PAD(fs, 4);
-    assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
-    assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
-    assert(is_hex(e + 78, 8)); /* rdevmajor */
-    assert(is_hex(e + 86, 8)); /* rdevminor */
-    assertEqualMem(e + 94, "00000009", 8); /* Name size */
-    ns = from_hex(e + 94, 8);
-    ns += PAD(ns + 2, 4);
-    assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
-    assertEqualMem(e + 110, "hardlink\0\0", 10); /* Name contents */
-    assertEqualMem(e + 110 + ns, "1234567890\0\0", 12); /* File contents */
-    e += 110 + ns + fs;
-
-    /* Last entry is end-of-archive marker. */
-    assert(is_hex(e, 110));
-    assertEqualMem(e + 0, "070701", 6); /* Magic */
-    assertEqualMem(e + 8, "00000000", 8); /* ino */
-    assertEqualMem(e + 14, "00000000", 8); /* mode */
-    assertEqualMem(e + 22, "00000000", 8); /* uid */
-    assertEqualMem(e + 30, "00000000", 8); /* gid */
-    assertEqualMem(e + 38, "00000001", 8); /* nlink */
-    assertEqualMem(e + 46, "00000000", 8); /* mtime */
-    assertEqualMem(e + 54, "00000000", 8); /* size */
-    assertEqualMem(e + 62, "00000000", 8); /* devmajor */
-    assertEqualMem(e + 70, "00000000", 8); /* devminor */
-    assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */
-    assertEqualMem(e + 86, "00000000", 8); /* rdevminor */
-    assertEqualInt(11, from_hex(e + 94, 8)); /* name size */
-    assertEqualMem(e + 102, "00000000", 8); /* check field */
-    assertEqualMem(e + 110, "TRAILER!!!\0\0", 12); /* Name */
-
-    free(p);
-}

+ 0 - 108
Utilities/cmlibarchive/cpio/test/test_gcpio_compat.c

@@ -1,108 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_gcpio_compat.c,v 1.2 2008/08/22 02:27:06 kientzle Exp $");
-
-static void
-unpack_test(const char *from, const char *options, const char *se)
-{
-    int r;
-
-    /* Create a work dir named after the file we're unpacking. */
-    assertMakeDir(from, 0775);
-    assertChdir(from);
-
-    /*
-     * Use cpio to unpack the sample archive
-     */
-    extract_reference_file(from);
-    r = systemf("%s -i %s < %s >unpack.out 2>unpack.err",
-        testprog, options, from);
-    failure("Error invoking %s -i %s < %s",
-        testprog, options, from);
-    assertEqualInt(r, 0);
-
-    /* Verify that nothing went to stderr. */
-    if (canSymlink()) {
-        failure("Error invoking %s -i %s < %s",
-            testprog, options, from);
-        assertTextFileContents(se, "unpack.err");
-    }
-
-    /*
-     * Verify unpacked files.
-     */
-
-    /* Regular file with 2 links. */
-    assertIsReg("file", 0644);
-    failure("%s", from);
-    assertFileSize("file", 10);
-    assertFileSize("linkfile", 10);
-    failure("%s", from);
-    assertFileNLinks("file", 2);
-
-    /* Another name for the same file. */
-    failure("%s", from);
-    assertIsHardlink("linkfile", "file");
-    assertFileSize("file", 10);
-    assertFileSize("linkfile", 10);
-
-    /* Symlink */
-    if (canSymlink())
-        assertIsSymlink("symlink", "file");
-
-    /* dir */
-    assertIsDir("dir", 0775);
-
-    assertChdir("..");
-}
-
-DEFINE_TEST(test_gcpio_compat)
-{
-    assertUmask(0);
-
-    /* Dearchive sample files with a variety of options. */
-    if (canSymlink()) {
-        unpack_test("test_gcpio_compat_ref.bin",
-            "--no-preserve-owner", "1 block\n");
-        unpack_test("test_gcpio_compat_ref.crc",
-            "--no-preserve-owner", "2 blocks\n");
-        unpack_test("test_gcpio_compat_ref.newc",
-            "--no-preserve-owner", "2 blocks\n");
-        /* gcpio-2.9 only reads 6 blocks here */
-        unpack_test("test_gcpio_compat_ref.ustar",
-            "--no-preserve-owner", "7 blocks\n");
-    } else {
-        unpack_test("test_gcpio_compat_ref_nosym.bin",
-            "--no-preserve-owner", "1 block\n");
-        unpack_test("test_gcpio_compat_ref_nosym.crc",
-            "--no-preserve-owner", "2 blocks\n");
-        unpack_test("test_gcpio_compat_ref_nosym.newc",
-            "--no-preserve-owner", "2 blocks\n");
-        /* gcpio-2.9 only reads 6 blocks here */
-        unpack_test("test_gcpio_compat_ref_nosym.ustar",
-            "--no-preserve-owner", "7 blocks\n");
-    }
-}

+ 0 - 16
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.bin.uu

@@ -1,16 +0,0 @@
-$FreeBSD$
-begin 644 test_gcpio_compat_ref.bin
-MQW%9`*IWI('H`^@#`@````U'=YD%````"@!F:6QE```Q,C,T-38W.#D*QW%9
-M`*IWI('H`^@#`@````U'=YD)````"@!L:6YK9FEL90``,3(S-#4V-S@Y"L=Q
-M60"K=^VAZ`/H`P$````-1X29"`````0`<WEM;&EN:P!F:6QEQW%9`*YW_4'H
-M`^@#`@````U'A9D$``````!D:7(`QW$``````````````0`````````+````
-M``!44D%)3$52(2$A````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-1````````````````````````
-`
-end

+ 0 - 27
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.crc.uu

@@ -1,27 +0,0 @@
-$FreeBSD$
-begin 644 test_gcpio_compat_ref.crc
-M,#<P-S`R,#`S,S<W86$P,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P
-M,C0W,&0Y.3<W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y,#`P,#`P,#`P,#`P
-M,#`P,#`P,#`P,#`U,#`P,#`P,#!F:6QE```P-S`W,#(P,#,S-S=A83`P,#`X
-M,6$T,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`R-#<P9#DY-S<P,#`P,#`P83`P
-M,#`P,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#DP,#`P,#%E
-M-VQI;FMF:6QE```Q,C,T-38W.#D*```P-S`W,#(P,#,S-S=A8C`P,#!A,65D
-M,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`Q-#<P9#DY.#0P,#`P,#`P-#`P,#`P
-M,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#@P,#`P,#`P,'-Y
-M;6QI;FL```!F:6QE,#<P-S`R,#`S,S<W864P,#`P-#%F9#`P,#`P,V4X,#`P
-M,#`S93@P,#`P,#`P,C0W,&0Y.3@U,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#(P
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,&(P,#`P,#`P,%1204E,15(A(2$`````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-B````````````````````````````````````````````````
-`
-end

+ 0 - 27
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.newc.uu

@@ -1,27 +0,0 @@
-$FreeBSD$
-begin 644 test_gcpio_compat_ref.newc
-M,#<P-S`Q,#`S,S<W86$P,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P
-M,C0W,&0Y.3<W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y,#`P,#`P,#`P,#`P
-M,#`P,#`P,#`P,#`U,#`P,#`P,#!F:6QE```P-S`W,#$P,#,S-S=A83`P,#`X
-M,6$T,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`R-#<P9#DY-S<P,#`P,#`P83`P
-M,#`P,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#DP,#`P,#`P
-M,&QI;FMF:6QE```Q,C,T-38W.#D*```P-S`W,#$P,#,S-S=A8C`P,#!A,65D
-M,#`P,#`S93@P,#`P,#-E.#`P,#`P,#`Q-#<P9#DY.#0P,#`P,#`P-#`P,#`P
-M,#`P,#`P,#`P-3DP,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#@P,#`P,#`P,'-Y
-M;6QI;FL```!F:6QE,#<P-S`Q,#`S,S<W864P,#`P-#%F9#`P,#`P,V4X,#`P
-M,#`S93@P,#`P,#`P,C0W,&0Y.3@U,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4Y
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#$P
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,&(P,#`P,#`P,%1204E,15(A(2$`````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-B````````````````````````````````````````````````
-`
-end

+ 0 - 84
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref.ustar.uu

@@ -1,84 +0,0 @@
-$FreeBSD$
-begin 644 test_gcpio_compat_ref.ustar
-M9FEL90``````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#$R
-M`#$P-S`S,S$T-38W`#`P,3$S-C,`,```````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
-M````````````````````````````````````=&EM````````````````````
-M```````````````````P,#`P,#`P`#`P,#`P,#``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````Q,C,T-38W.#D*````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````&QI;FMF:6QE````
-M````````````````````````````````````````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,#`P,``Q,#<P,S,Q-#4V
-M-P`P,#$S,#<W`#%F:6QE````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````=7-T87(`,#!T:6T`````````````````
-M`````````````````````'1I;0``````````````````````````````````
-M````,#`P,#`P,``P,#`P,#`P````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````<WEM;&EN:P``````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#`W-34`,#`P,3<U,``P,#`Q-S4P`#`P,#`P
-M,#`P,#`P`#$P-S`S,S$T-C`T`#`P,3(W-C0`,F9I;&4`````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!U<W1A<@`P
-M,'1I;0``````````````````````````````````````=&EM````````````
-M```````````````````````````P,#`P,#`P`#`P,#`P,#``````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````!D:7(O````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````,#`P,#<W-0`P,#`Q
-M-S4P`#`P,#$W-3``,#`P,#`P,#`P,#``,3`W,#,S,30V,#4`,#`Q,3,P,0`U
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````'5S=&%R`#`P=&EM````````````````````````````````
-M``````!T:6T``````````````````````````````````````#`P,#`P,#``
-M,#`P,#`P,```````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-=````````````````````````````````````````
-`
-end

+ 0 - 15
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.bin.uu

@@ -1,15 +0,0 @@
-begin 644 test_gcpio_compat_ref_nosym.bin
-MQW%4`-[Z_4'H`^@#`@`VNZU*NQX$``````!D:7(`QW%4`-SZI('H`^@#`@`G
-MNZU*NQX%````"@!F:6QE```Q,C,T-38W.#D*QW%4`-SZI('H`^@#`@`GNZU*
-MNQX)````"@!L:6YK9FEL90``,3(S-#4V-S@Y"L=Q``````````````$`````
-M````"P``````5%)!24Q%4B$A(0``````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-1````````````````````````
-`
-end

+ 0 - 15
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.crc.uu

@@ -1,15 +0,0 @@
-begin 644 test_gcpio_compat_ref_nosym.crc
-M,#<P-S`R,#`U-D9!1$4P,#`P-#%&1#`P,#`P,T4X,#`P,#`S13@P,#`P,#`P
-M,C1!040Q14)",#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P0D(P,35"
-M,#`S-C`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#(P,#4V1D%$0S`P,#`X
-M,4$T,#`P,#`S13@P,#`P,#-%.#`P,#`P,#`R-$%!1#%%0D(P,#`P,#`P,#`P
-M,#`P,#`P,#`P,#`P-30P,#`P,#!"0C`Q-4(P,#(W,#`P,#`P,#4P,#`P,#`P
-M,&9I;&4``#`W,#<P,C`P-39&041#,#`P,#@Q030P,#`P,#-%.#`P,#`P,T4X
-M,#`P,#`P,#(T04%$,45"0C`P,#`P,#!!,#`P,#`P,#`P,#`P,#`U-#`P,#`P
-M,$)",#$U0C`P,C<P,#`P,#`P.3`P,#`P,44W;&EN:V9I;&4``#$R,S0U-C<X
-M.0H``#`W,#<P,C`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,#`P,#`P,#`P,#`P0C`P,#`P,#`P5%)!24Q%4B$A(0``````````````
-1````````````````````````
-`
-end

+ 0 - 15
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.newc.uu

@@ -1,15 +0,0 @@
-begin 644 test_gcpio_compat_ref_nosym.newc
-M,#<P-S`Q,#`U-D9!1$4P,#`P-#%&1#`P,#`P,T4X,#`P,#`S13@P,#`P,#`P
-M,C1!040Q14)",#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P0D(P,35"
-M,#`S-C`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#$P,#4V1D%$0S`P,#`X
-M,4$T,#`P,#`S13@P,#`P,#-%.#`P,#`P,#`R-$%!1#%%0D(P,#`P,#`P,#`P
-M,#`P,#`P,#`P,#`P-30P,#`P,#!"0C`Q-4(P,#(W,#`P,#`P,#4P,#`P,#`P
-M,&9I;&4``#`W,#<P,3`P-39&041#,#`P,#@Q030P,#`P,#-%.#`P,#`P,T4X
-M,#`P,#`P,#(T04%$,45"0C`P,#`P,#!!,#`P,#`P,#`P,#`P,#`U-#`P,#`P
-M,$)",#$U0C`P,C<P,#`P,#`P.3`P,#`P,#`P;&EN:V9I;&4``#$R,S0U-C<X
-M.0H``#`W,#<P,3`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,#`P,#`P,#`P,#`P0C`P,#`P,#`P5%)!24Q%4B$A(0``````````````
-1````````````````````````
-`
-end

+ 0 - 72
Utilities/cmlibarchive/cpio/test/test_gcpio_compat_ref_nosym.ustar.uu

@@ -1,72 +0,0 @@
-begin 644 test_gcpio_compat_ref_nosym.ustar
-M9&ER+P``````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#`W-S4`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#`P
-M`#$Q,C4S,C$W,C<S`#`P,3$S-3$`-0``````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
-M````````````````````````````````````=&EM````````````````````
-M```````````````````P,#`P,C<S`#8V,#`P-C8`````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````!F:6QE````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````,#`P,#8T-``P,#`Q-S4P`#`P
-M,#$W-3``,#`P,#`P,#`P,3(`,3$R-3,R,3<R-S,`,#`Q,30R,P`P````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````'5S=&%R`#`P=&EM``````````````````````````````````````!T
-M:6T``````````````````````````````````````#`P,#`R-S,`-C8P,#`T
-M-P``````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````````````````````````````#$R,S0U-C<X.0H`
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````;&EN:V9I;&4`````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P
-M,#`P,#`P`#$Q,C4S,C$W,C<S`#`P,3,Q,S<`,69I;&4`````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````````````!U<W1A<@`P
-M,'1I;0``````````````````````````````````````=&EM````````````
-M```````````````````````````P,#`P,C<S`#8V,#`P-#<`````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-,````````````````
-`
-end

+ 0 - 62
Utilities/cmlibarchive/cpio/test/test_option_C_upper.c

@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-
-DEFINE_TEST(test_option_C_upper)
-{
-    int r;
-
-    /*
-     * Create a file on disk.
-     */
-    assertMakeFile("file", 0644, NULL);
-
-    /* Create an archive without -C; this should be 512 bytes. */
-    r = systemf("echo file | %s -o > small.cpio 2>small.err", testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "small.err");
-    assertFileSize("small.cpio", 512);
-
-    /* Create an archive with -C 513; this should be 513 bytes. */
-    r = systemf("echo file | %s -o -C 513 > 513.cpio 2>513.err",
-            testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "513.err");
-    assertFileSize("513.cpio", 513);
-
-    /* Create an archive with -C 12345; this should be 12345 bytes. */
-    r = systemf("echo file | %s -o -C12345 > 12345.cpio 2>12345.err",
-            testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "12345.err");
-    assertFileSize("12345.cpio", 12345);
-
-    /* Create an archive with invalid -C request */
-    assert(0 != systemf("echo file | %s -o -C > bad.cpio 2>bad.err",
-                testprog));
-    assertEmptyFile("bad.cpio");
-}

+ 0 - 56
Utilities/cmlibarchive/cpio/test/test_option_J_upper.c

@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 2003-2009 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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_J_upper)
-{
-    char *p;
-    int r;
-    size_t s;
-
-    /* Create a file. */
-    assertMakeFile("f", 0644, "a");
-
-    /* Archive it with xz compression. */
-    r = systemf("echo f | %s -o -J >archive.out 2>archive.err",
-        testprog);
-    p = slurpfile(&s, "archive.err");
-    p[s] = '\0';
-    if (r != 0) {
-        if (strstr(p, "compression not available") != NULL) {
-            skipping("This version of bsdcpio was compiled "
-                "without xz support");
-            return;
-        }
-        failure("-J option is broken");
-        assertEqualInt(r, 0);
-        return;
-    }
-    /* Check that the archive file has an xz signature. */
-    p = slurpfile(&s, "archive.out");
-    assert(s > 2);
-    assertEqualMem(p, "\3757zXZ", 5);
-}

+ 0 - 96
Utilities/cmlibarchive/cpio/test/test_option_L_upper.c

@@ -1,96 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_L.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
-
-/* This is a little pointless, as Windows doesn't support symlinks
- * (except for the seriously crippled CreateSymbolicLink API) so these
- * tests won't run on Windows. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define CAT "type"
-#else
-#define CAT "cat"
-#endif
-
-DEFINE_TEST(test_option_L_upper)
-{
-    FILE *filelist;
-    int r;
-
-    if (!canSymlink()) {
-        skipping("Symlink tests");
-        return;
-    }
-
-    filelist = fopen("filelist", "w");
-
-    /* Create a file and a symlink to the file. */
-    assertMakeFile("file", 0644, "1234567890");
-    fprintf(filelist, "file\n");
-
-    /* Symlink to above file. */
-    assertMakeSymlink("symlink", "file");
-    fprintf(filelist, "symlink\n");
-
-    fclose(filelist);
-
-    r = systemf(CAT " filelist | %s -pd copy >copy.out 2>copy.err", testprog);
-    assertEqualInt(r, 0);
-
-    failure("Regular -p without -L should preserve symlinks.");
-    assertIsSymlink("copy/symlink", NULL);
-
-    r = systemf(CAT " filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
-    assertEqualInt(r, 0);
-    assertEmptyFile("copy-L.out");
-    assertTextFileContents("1 block\n", "copy-L.err");
-    failure("-pdL should dereference symlinks and turn them into files.");
-    assertIsReg("copy-L/symlink", -1);
-
-    r = systemf(CAT " filelist | %s -o >archive.out 2>archive.err", testprog);
-    failure("Error invoking %s -o ", testprog);
-    assertEqualInt(r, 0);
-
-    assertMakeDir("unpack", 0755);
-    assertChdir("unpack");
-    r = systemf(CAT " ../archive.out | %s -i >unpack.out 2>unpack.err", testprog);
-    assertChdir("..");
-    failure("Error invoking %s -i", testprog);
-    assertEqualInt(r, 0);
-
-    assertIsSymlink("unpack/symlink", NULL);
-
-    r = systemf(CAT " filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
-    failure("Error invoking %s -oL", testprog);
-    assertEqualInt(r, 0);
-
-    assertMakeDir("unpack-L", 0755);
-    assertChdir("unpack-L");
-    r = systemf(CAT " ../archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
-    assertChdir("..");
-    failure("Error invoking %s -i < archive-L.out", testprog);
-    assertEqualInt(r, 0);
-    assertIsReg("unpack-L/symlink", -1);
-}

+ 0 - 56
Utilities/cmlibarchive/cpio/test/test_option_Z_upper.c

@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 2003-2009 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 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_Z_upper)
-{
-    char *p;
-    int r;
-    size_t s;
-
-    /* Create a file. */
-    assertMakeFile("f", 0644, "a");
-
-    /* Archive it with compress compression. */
-    r = systemf("echo f | %s -oZ >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 compress support");
-            return;
-        }
-        failure("-Z option is broken");
-        assertEqualInt(r, 0);
-        return;
-    }
-    /* Check that the archive file has a compress signature. */
-    p = slurpfile(&s, "archive.out");
-    assert(s > 2);
-    assertEqualMem(p, "\x1f\x9d", 2);
-}

+ 0 - 154
Utilities/cmlibarchive/cpio/test/test_option_a.c

@@ -1,154 +0,0 @@
-/*-
- * Copyright (c) 2003-2008 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <sys/utime.h>
-#else
-#include <utime.h>
-#endif
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_a.c,v 1.3 2008/08/24 06:21:00 kientzle Exp $");
-
-static struct {
-    const char *name;
-    time_t atime_sec;
-} files[] = {
-    { "f0", 0 },
-    { "f1", 0 },
-    { "f2", 0 },
-    { "f3", 0 },
-    { "f4", 0 },
-    { "f5", 0 }
-};
-
-/*
- * Create a bunch of test files and record their atimes.
- * For the atime preserve/change tests, the files must have
- * atimes in the past.  We can accomplish this by explicitly invoking
- * utime() on platforms that support it or by simply sleeping
- * for a second after creating the files.  (Creating all of the files
- * at once means we only need to sleep once.)
- */
-static void
-test_create(void)
-{
-    struct stat st;
-    struct utimbuf times;
-    static const int numfiles = sizeof(files) / sizeof(files[0]);
-    int i;
-
-    for (i = 0; i < numfiles; ++i) {
-        /*
-         * Note: Have to write at least one byte to the file.
-         * cpio doesn't bother reading the file if it's zero length,
-         * so the atime never gets changed in that case, which
-         * makes the tests below rather pointless.
-         */
-        assertMakeFile(files[i].name, 0644, "a");
-
-        /* If utime() isn't supported on your platform, just
-         * #ifdef this section out.  Most of the test below is
-         * still valid. */
-        memset(&times, 0, sizeof(times));
-        times.actime = 1;
-        times.modtime = 3;
-        assertEqualInt(0, utime(files[i].name, &times));
-
-        /* Record whatever atime the file ended up with. */
-        /* If utime() is available, this should be 1, but there's
-         * no harm in being careful. */
-        assertEqualInt(0, stat(files[i].name, &st));
-        files[i].atime_sec = st.st_atime;
-    }
-
-    /* Wait until the atime on the last file is actually in the past. */
-    sleepUntilAfter(files[numfiles - 1].atime_sec);
-}
-
-DEFINE_TEST(test_option_a)
-{
-    struct stat st;
-    int r;
-    char *p;
-
-    /* Create all of the test files. */
-    test_create();
-
-    /* Sanity check; verify that atimes really do get modified. */
-    assert((p = slurpfile(NULL, "f0")) != NULL);
-    free(p);
-    assertEqualInt(0, stat("f0", &st));
-    if (st.st_atime == files[0].atime_sec) {
-        skipping("Cannot verify -a option\n"
-            "      Your system appears to not support atime.");
-    }
-    else
-    {
-        /*
-         * If this disk is mounted noatime, then we can't
-         * verify correct operation without -a.
-         */
-
-        /* Copy the file without -a; should change the atime. */
-        r = systemf("echo %s | %s -pd copy-no-a > copy-no-a.out 2>copy-no-a.err", files[1].name, testprog);
-        assertEqualInt(r, 0);
-        assertTextFileContents("1 block\n", "copy-no-a.err");
-        assertEmptyFile("copy-no-a.out");
-        assertEqualInt(0, stat(files[1].name, &st));
-        failure("Copying file without -a should have changed atime.");
-        assert(st.st_atime != files[1].atime_sec);
-
-        /* Archive the file without -a; should change the atime. */
-        r = systemf("echo %s | %s -o > archive-no-a.out 2>archive-no-a.err", files[2].name, testprog);
-        assertEqualInt(r, 0);
-        assertTextFileContents("1 block\n", "copy-no-a.err");
-        assertEqualInt(0, stat(files[2].name, &st));
-        failure("Archiving file without -a should have changed atime.");
-        assert(st.st_atime != files[2].atime_sec);
-    }
-
-    /*
-     * We can, of course, still verify that the atime is unchanged
-     * when using the -a option.
-     */
-
-    /* Copy the file with -a; should not change the atime. */
-    r = systemf("echo %s | %s -pad copy-a > copy-a.out 2>copy-a.err",
-        files[3].name, testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "copy-a.err");
-    assertEmptyFile("copy-a.out");
-    assertEqualInt(0, stat(files[3].name, &st));
-    failure("Copying file with -a should not have changed atime.");
-    assertEqualInt(st.st_atime, files[3].atime_sec);
-
-    /* Archive the file with -a; should not change the atime. */
-    r = systemf("echo %s | %s -oa > archive-a.out 2>archive-a.err",
-        files[4].name, testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "copy-a.err");
-    assertEqualInt(0, stat(files[4].name, &st));
-    failure("Archiving file with -a should not have changed atime.");
-    assertEqualInt(st.st_atime, files[4].atime_sec);
-}

+ 0 - 221
Utilities/cmlibarchive/cpio/test/test_option_c.c

@@ -1,221 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-static int
-is_octal(const char *p, size_t l)
-{
-    while (l > 0) {
-        if (*p < '0' || *p > '7')
-            return (0);
-        --l;
-        ++p;
-    }
-    return (1);
-}
-
-static int
-from_octal(const char *p, size_t l)
-{
-    int r = 0;
-
-    while (l > 0) {
-        r *= 8;
-        r += *p - '0';
-        --l;
-        ++p;
-    }
-    return (r);
-}
-
-DEFINE_TEST(test_option_c)
-{
-    FILE *filelist;
-    int r;
-    int uid = -1;
-    int dev, ino, gid;
-    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.
-     */
-    filelist = fopen("filelist", "w");
-
-    /* "file" */
-    assertMakeFile("file", 0644, "1234567890");
-    fprintf(filelist, "file\n");
-
-    /* "symlink" */
-    if (canSymlink()) {
-        assertMakeSymlink("symlink", "file");
-        fprintf(filelist, "symlink\n");
-    }
-
-    /* "dir" */
-    assertMakeDir("dir", 0775);
-    /* Record some facts about what we just created: */
-    now = time(NULL); /* They were all created w/in last two seconds. */
-    fprintf(filelist, "dir\n");
-
-    /* Use the cpio program to create an archive. */
-    fclose(filelist);
-    r = systemf("%s -oc <filelist >basic.out 2>basic.err", testprog);
-    /* Verify that nothing went to stderr. */
-    assertTextFileContents("1 block\n", "basic.err");
-
-    /* Assert that the program finished. */
-    failure("%s -oc crashed", testprog);
-    if (!assertEqualInt(r, 0))
-        return;
-
-    /* Verify that stdout is a well-formed cpio file in "odc" format. */
-    p = slurpfile(&s, "basic.out");
-    assertEqualInt(s, 512);
-    e = p;
-
-    /*
-     * Some of these assertions could be stronger, but it's
-     * a little tricky because they depend on the local environment.
-     */
-
-    /* First entry is "file" */
-    assert(is_octal(e, 76)); /* Entire header is octal digits. */
-    assertEqualMem(e + 0, "070707", 6); /* Magic */
-    assert(is_octal(e + 6, 6)); /* dev */
-    dev = from_octal(e + 6, 6);
-    assert(is_octal(e + 12, 6)); /* ino */
-    ino = from_octal(e + 12, 6);
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Group members bits and others bits do not work. */
-    assertEqualMem(e + 18, "100666", 6); /* Mode */
-#else
-    assertEqualMem(e + 18, "100644", 6); /* Mode */
-#endif
-    if (uid < 0)
-        uid = from_octal(e + 24, 6);
-    assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
-    assert(is_octal(e + 30, 6)); /* gid */
-    gid = from_octal(e + 30, 6);
-    assertEqualMem(e + 36, "000001", 6); /* nlink */
-    failure("file entries should not have rdev set (dev field was 0%o)",
-        dev);
-    assertEqualMem(e + 42, "000000", 6); /* rdev */
-    t = from_octal(e + 48, 11); /* mtime */
-    assert(t <= now); /* File wasn't created in future. */
-    assert(t >= now - 2); /* File was created w/in last 2 secs. */
-    assertEqualMem(e + 59, "000005", 6); /* Name size */
-    assertEqualMem(e + 65, "00000000012", 11); /* File size */
-    assertEqualMem(e + 76, "file\0", 5); /* Name contents */
-    assertEqualMem(e + 81, "1234567890", 10); /* File contents */
-    e += 91;
-
-    /* "symlink" pointing to "file" */
-    if (canSymlink()) {
-        assert(is_octal(e, 76)); /* Entire header is octal digits. */
-        assertEqualMem(e + 0, "070707", 6); /* Magic */
-        assertEqualInt(dev, from_octal(e + 6, 6)); /* dev */
-        assert(dev != from_octal(e + 12, 6)); /* ino */
-#if !defined(_WIN32) || defined(__CYGWIN__)
-        /* On Windows, symbolic link and group members bits and
-         * others bits do not work. */
-        assertEqualMem(e + 18, "120777", 6); /* Mode */
-#endif
-        assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
-        assertEqualInt(gid, from_octal(e + 30, 6)); /* gid */
-        assertEqualMem(e + 36, "000001", 6); /* nlink */
-        failure("file entries should have rdev == 0 (dev was 0%o)",
-            from_octal(e + 6, 6));
-        assertEqualMem(e + 42, "000000", 6); /* rdev */
-        t = from_octal(e + 48, 11); /* mtime */
-        assert(t <= now); /* File wasn't created in future. */
-        assert(t >= now - 2); /* File was created w/in last 2 secs. */
-        assertEqualMem(e + 59, "000010", 6); /* Name size */
-        assertEqualMem(e + 65, "00000000004", 11); /* File size */
-        assertEqualMem(e + 76, "symlink\0", 8); /* Name contents */
-        assertEqualMem(e + 84, "file", 4); /* Symlink target. */
-        e += 88;
-    }
-
-    /* "dir" */
-    assert(is_octal(e, 76));
-    assertEqualMem(e + 0, "070707", 6); /* Magic */
-    /* Dev should be same as first entry. */
-    assert(is_octal(e + 6, 6)); /* dev */
-    assertEqualInt(dev, from_octal(e + 6, 6));
-    /* Ino must be different from first entry. */
-    assert(is_octal(e + 12, 6)); /* ino */
-    assert(dev != from_octal(e + 12, 6));
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Group members bits and others bits do not work. */
-    assertEqualMem(e + 18, "040777", 6); /* Mode */
-#else
-    /* Accept 042775 to accomodate systems where sgid bit propagates. */
-    if (memcmp(e + 18, "042775", 6) != 0)
-        assertEqualMem(e + 18, "040775", 6); /* Mode */
-#endif
-    assertEqualInt(from_octal(e + 24, 6), uid); /* uid */
-    /* Gid should be same as first entry. */
-    assert(is_octal(e + 30, 6)); /* gid */
-    assertEqualInt(gid, from_octal(e + 30, 6));
-#ifndef NLINKS_INACCURATE_FOR_DIRS
-    assertEqualMem(e + 36, "000002", 6); /* Nlink */
-#endif
-    t = from_octal(e + 48, 11); /* mtime */
-    assert(t <= now); /* File wasn't created in future. */
-    assert(t >= now - 2); /* File was created w/in last 2 secs. */
-    assertEqualMem(e + 59, "000004", 6); /* Name size */
-    assertEqualMem(e + 65, "00000000000", 11); /* File size */
-    assertEqualMem(e + 76, "dir\0", 4); /* name */
-    e += 80;
-
-    /* TODO: Verify other types of entries. */
-
-    /* Last entry is end-of-archive marker. */
-    assert(is_octal(e, 76));
-    assertEqualMem(e + 0, "070707", 6); /* Magic */
-    assertEqualMem(e + 6, "000000", 6); /* dev */
-    assertEqualMem(e + 12, "000000", 6); /* ino */
-    assertEqualMem(e + 18, "000000", 6); /* Mode */
-    assertEqualMem(e + 24, "000000", 6); /* uid */
-    assertEqualMem(e + 30, "000000", 6); /* gid */
-    assertEqualMem(e + 36, "000001", 6); /* Nlink */
-    assertEqualMem(e + 42, "000000", 6); /* rdev */
-    assertEqualMem(e + 48, "00000000000", 11); /* mtime */
-    assertEqualMem(e + 59, "000013", 6); /* Name size */
-    assertEqualMem(e + 65, "00000000000", 11); /* File size */
-    assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */
-
-    free(p);
-}

+ 0 - 64
Utilities/cmlibarchive/cpio/test/test_option_d.c

@@ -1,64 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-
-DEFINE_TEST(test_option_d)
-{
-    int r;
-
-    /*
-     * Create a file in a directory.
-     */
-    assertMakeDir("dir", 0755);
-    assertMakeFile("dir/file", 0644, NULL);
-
-    /* Create an archive. */
-    r = systemf("echo dir/file | %s -o > archive.cpio 2>archive.err", testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "archive.err");
-    assertFileSize("archive.cpio", 512);
-
-    /* Dearchive without -d, this should fail. */
-    assertMakeDir("without-d", 0755);
-    assertChdir("without-d");
-    r = systemf("%s -i < ../archive.cpio >out 2>err", testprog);
-    assertEqualInt(r, 0);
-    assertEmptyFile("out");
-    /* And the file should not be restored. */
-    assertFileNotExists("dir/file");
-
-    /* Dearchive with -d, this should succeed. */
-    assertChdir("..");
-    assertMakeDir("with-d", 0755);
-    assertChdir("with-d");
-    r = systemf("%s -id < ../archive.cpio >out 2>err", testprog);
-    assertEqualInt(r, 0);
-    assertEmptyFile("out");
-    assertTextFileContents("1 block\n", "err");
-    /* And the file should be restored. */
-    assertFileExists("dir/file");
-}

+ 0 - 76
Utilities/cmlibarchive/cpio/test/test_option_f.c

@@ -1,76 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-/*
- * Unpack the archive in a new dir.
- */
-static void
-unpack(const char *dirname, const char *option)
-{
-    int r;
-
-    assertMakeDir(dirname, 0755);
-    assertChdir(dirname);
-    extract_reference_file("test_option_f.cpio");
-    r = systemf("%s -i %s < test_option_f.cpio > copy-no-a.out 2>copy-no-a.err", testprog, option);
-    assertEqualInt(0, r);
-    assertChdir("..");
-}
-
-DEFINE_TEST(test_option_f)
-{
-    /* Calibrate:  No -f option, so everything should be extracted. */
-    unpack("t0", "--no-preserve-owner");
-    assertFileExists("t0/a123");
-    assertFileExists("t0/a234");
-    assertFileExists("t0/b123");
-    assertFileExists("t0/b234");
-
-    /* Don't extract 'a*' files. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Single quotes isn't used by command.exe. */
-    unpack("t1", "--no-preserve-owner -f a*");
-#else
-    unpack("t1", "--no-preserve-owner -f 'a*'");
-#endif
-    assertFileNotExists("t1/a123");
-    assertFileNotExists("t1/a234");
-    assertFileExists("t1/b123");
-    assertFileExists("t1/b234");
-
-    /* Don't extract 'b*' files. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    /* Single quotes isn't used by command.exe. */
-    unpack("t2", "--no-preserve-owner -f b*");
-#else
-    unpack("t2", "--no-preserve-owner -f 'b*'");
-#endif
-    assertFileExists("t2/a123");
-    assertFileExists("t2/a234");
-    assertFileNotExists("t2/b123");
-    assertFileNotExists("t2/b234");
-}

+ 0 - 16
Utilities/cmlibarchive/cpio/test/test_option_f.cpio.uu

@@ -1,16 +0,0 @@
-$FreeBSD$
-begin 644 test_option_f.cpio
-M,#<P-S`W,#`P,3,Q-C(Q-38Q,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P
-M,#`P,3`W,S4Q,3(U,C8P,#`P,#4P,#`P,#`P,#`P,&$Q,C,`,#<P-S`W,#`P
-M,3,Q-C(Q-38S,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P,#`P,3`W,S4Q
-M,3(U-#`P,#`P,#4P,#`P,#`P,#`P,&$R,S0`,#<P-S`W,#`P,3,Q-C(Q-38R
-M,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P,#`P,3`W,S4Q,3(U,S0P,#`P
-M,#4P,#`P,#`P,#`P,&(Q,C,`,#<P-S`W,#`P,3,Q-C(Q-38T,3`P-C0T,#`Q
-M-S4P,#`Q-S4P,#`P,#`Q,#`P,#`P,3`W,S4Q,3(U-#,P,#`P,#4P,#`P,#`P
-M,#`P,&(R,S0`,#<P-S`W,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
-M,#`P,#`Q,#`P,#`P,#`P,#`P,#`P,#`P,#`P,3,P,#`P,#`P,#`P,%1204E,
-M15(A(2$`````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-1````````````````````````
-`
-end

+ 0 - 81
Utilities/cmlibarchive/cpio/test/test_option_help.c

@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-/*
- * 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_option_help)
-{
-    int r;
-    char *p;
-    size_t plen;
-
-    /* Exercise --help option. */
-    r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
-    failure("--help should generate nothing to stderr.");
-    assertEmptyFile("help.stderr");
-    /* Help message should start with name of program. */
-    p = slurpfile(&plen, "help.stdout");
-    failure("Help output should be long enough.");
-    assert(plen >= 7);
-    failure("First line of help output should contain string 'bsdcpio'");
-    assert(in_first_line(p, "bsdcpio"));
-    /*
-     * TODO: Extend this check to further verify that --help output
-     * looks approximately right.
-     */
-    free(p);
-
-    /* -h option should generate the same output. */
-    r = systemf("%s -h >h.stdout 2>h.stderr", testprog);
-    failure("-h should generate nothing to stderr.");
-    assertEmptyFile("h.stderr");
-    failure("stdout should be same for -h and --help");
-    assertEqualFile("h.stdout", "help.stdout");
-
-    /* -W help should be another synonym. */
-    r = systemf("%s -W help >Whelp.stdout 2>Whelp.stderr", testprog);
-    failure("-W help should generate nothing to stderr.");
-    assertEmptyFile("Whelp.stderr");
-    failure("stdout should be same for -W help and --help");
-    assertEqualFile("Whelp.stdout", "help.stdout");
-}

+ 0 - 56
Utilities/cmlibarchive/cpio/test/test_option_lzma.c

@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-DEFINE_TEST(test_option_lzma)
-{
-    char *p;
-    int r;
-    size_t s;
-
-    /* Create a file. */
-    assertMakeFile("f", 0644, "a");
-
-    /* Archive it with lzma compression. */
-    r = systemf("echo f | %s -o --lzma >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 lzma support");
-            return;
-        }
-        failure("--lzma option is broken");
-        assertEqualInt(r, 0);
-        return;
-    }
-    /* Check that the archive file has an lzma signature. */
-    p = slurpfile(&s, "archive.out");
-    assert(s > 2);
-    assertEqualMem(p, "\x5d\00\00", 3);
-}

+ 0 - 63
Utilities/cmlibarchive/cpio/test/test_option_m.c

@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-
-DEFINE_TEST(test_option_m)
-{
-    int r;
-
-    /*
-     * The reference archive has one file with an mtime in 1970, 1
-     * second after the start of the epoch.
-     */
-
-    /* Restored without -m, the result should have a current mtime. */
-    assertMakeDir("without-m", 0755);
-    assertChdir("without-m");
-    extract_reference_file("test_option_m.cpio");
-    r = systemf("%s --no-preserve-owner -i < test_option_m.cpio >out 2>err", testprog);
-    assertEqualInt(r, 0);
-    assertEmptyFile("out");
-    assertTextFileContents("1 block\n", "err");
-    /* Should have been created within the last few seconds. */
-    assertFileMtimeRecent("file");
-
-    /* With -m, it should have an mtime in 1970. */
-    assertChdir("..");
-    assertMakeDir("with-m", 0755);
-    assertChdir("with-m");
-    extract_reference_file("test_option_m.cpio");
-    r = systemf("%s --no-preserve-owner -im < test_option_m.cpio >out 2>err", testprog);
-    assertEqualInt(r, 0);
-    assertEmptyFile("out");
-    assertTextFileContents("1 block\n", "err");
-    /*
-     * mtime in reference archive is '1' == 1 second after
-     * midnight Jan 1, 1970 UTC.
-     */
-    assertFileMtime("file", 1, 0);
-}

+ 0 - 16
Utilities/cmlibarchive/cpio/test/test_option_m.cpio.uu

@@ -1,16 +0,0 @@
-$FreeBSD$
-begin 644 test_option_m.cpio
-M,#<P-S`W,#`P,3,Q-#4P,#8T,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P
-M,#`P,#`P,#`P,#`P,#$P,#`P,#4P,#`P,#`P,#`P,&9I;&4`,#<P-S`W,#`P
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P,#`P,#`P
-M,#`P,#`P,#`P,3,P,#`P,#`P,#`P,%1204E,15(A(2$`````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-1````````````````````````
-`
-end

+ 0 - 95
Utilities/cmlibarchive/cpio/test/test_option_t.c

@@ -1,95 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-
-DEFINE_TEST(test_option_t)
-{
-    char *p;
-    int r;
-
-    /* List reference archive, make sure the TOC is correct. */
-    extract_reference_file("test_option_t.cpio");
-    r = systemf("%s -it < test_option_t.cpio >it.out 2>it.err", testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "it.err");
-    extract_reference_file("test_option_t.stdout");
-    p = slurpfile(NULL, "test_option_t.stdout");
-    assertTextFileContents(p, "it.out");
-    free(p);
-
-    /* We accept plain "-t" as a synonym for "-it" */
-    r = systemf("%s -t < test_option_t.cpio >t.out 2>t.err", testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "t.err");
-    extract_reference_file("test_option_t.stdout");
-    p = slurpfile(NULL, "test_option_t.stdout");
-    assertTextFileContents(p, "t.out");
-    free(p);
-
-    /* But "-ot" is an error. */
-    assert(0 != systemf("%s -ot < test_option_t.cpio >ot.out 2>ot.err",
-                testprog));
-    assertEmptyFile("ot.out");
-
-    /* List reference archive verbosely, make sure the TOC is correct. */
-    r = systemf("%s -itv < test_option_t.cpio >tv.out 2>tv.err", testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "tv.err");
-    extract_reference_file("test_option_tv.stdout");
-
-    /* This doesn't work because the usernames on different systems
-     * are different and cpio now looks up numeric UIDs on
-     * the local system. */
-    /* assertEqualFile("tv.out", "test_option_tv.stdout"); */
-
-    /* List reference archive with numeric IDs, verify TOC is correct. */
-    r = systemf("%s -itnv < test_option_t.cpio >itnv.out 2>itnv.err",
-            testprog);
-    assertEqualInt(r, 0);
-    assertTextFileContents("1 block\n", "itnv.err");
-    p = slurpfile(NULL, "itnv.out");
-    /* Since -n uses numeric UID/GID, this part should be the
-     * same on every system. */
-    assertEqualMem(p, "-rw-r--r--   1 1000     1000            0 ",42);
-    /* Date varies depending on local timezone. */
-    if (memcmp(p + 42, "Dec 31  1969", 12) == 0) {
-        /* East of Greenwich we get Dec 31, 1969. */
-    } else {
-        /* West of Greenwich get Jan 1, 1970 */
-        assertEqualMem(p + 42, "Jan ", 4);
-        /* Some systems format "Jan 01", some "Jan  1" */
-        assert(p[46] == ' ' || p[46] == '0');
-        assertEqualMem(p + 47, "1  1970 ", 8);
-    }
-    assertEqualMem(p + 54, " file", 5);
-    free(p);
-
-    /* But "-n" without "-t" is an error. */
-    assert(0 != systemf("%s -in < test_option_t.cpio >in.out 2>in.err",
-                testprog));
-    assertEmptyFile("in.out");
-}

+ 0 - 16
Utilities/cmlibarchive/cpio/test/test_option_t.cpio.uu

@@ -1,16 +0,0 @@
-$FreeBSD$
-begin 644 test_option_t.cpio
-M,#<P-S`W,#`P,3,Q-#4P,#8T,3`P-C0T,#`Q-S4P,#`Q-S4P,#`P,#`Q,#`P
-M,#`P,#`P,#`P,#`P,#$P,#`P,#4P,#`P,#`P,#`P,&9I;&4`,#<P-S`W,#`P
-M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P,#`P,#`P
-M,#`P,#`P,#`P,3,P,#`P,#`P,#`P,%1204E,15(A(2$`````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-1````````````````````````
-`
-end

+ 0 - 5
Utilities/cmlibarchive/cpio/test/test_option_t.stdout.uu

@@ -1,5 +0,0 @@
-$FreeBSD$
-begin 644 test_option_t.stdout
-%9FEL90H`
-`
-end

+ 0 - 6
Utilities/cmlibarchive/cpio/test/test_option_tv.stdout.uu

@@ -1,6 +0,0 @@
-$FreeBSD: src/usr.bin/cpio/test/test_option_tv.stdout.uu,v 1.2 2008/11/29 20:22:02 kientzle Exp $
-begin 644 test_option_tv.stdout
-M+7)W+7(M+7(M+2`@(#$@=&EM("`@("`@=&EM("`@("`@("`@("`@(#`@1&5C
-/(#,Q("`Q.38Y(&9I;&4*
-`
-end

+ 0 - 81
Utilities/cmlibarchive/cpio/test/test_option_u.c

@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <sys/utime.h>
-#else
-#include <utime.h>
-#endif
-__FBSDID("$FreeBSD$");
-
-DEFINE_TEST(test_option_u)
-{
-    struct utimbuf times;
-    char *p;
-    size_t s;
-    int r;
-
-    /* Create a file. */
-    assertMakeFile("f", 0644, "a");
-
-    /* Copy the file to the "copy" dir. */
-    r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
-        testprog);
-    assertEqualInt(r, 0);
-
-    /* Check that the file contains only a single "a" */
-    p = slurpfile(&s, "copy/f");
-    assertEqualInt(s, 1);
-    assertEqualMem(p, "a", 1);
-
-    /* Recreate the file with a single "b" */
-    assertMakeFile("f", 0644, "b");
-
-    /* Set the mtime to the distant past. */
-    memset(&times, 0, sizeof(times));
-    times.actime = 1;
-    times.modtime = 3;
-    assertEqualInt(0, utime("f", &times));
-
-    /* Copy the file to the "copy" dir. */
-    r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
-        testprog);
-    assertEqualInt(r, 0);
-
-    /* Verify that the file hasn't changed (it wasn't overwritten) */
-    p = slurpfile(&s, "copy/f");
-    assertEqualInt(s, 1);
-    assertEqualMem(p, "a", 1);
-
-    /* Copy the file to the "copy" dir with -u (force) */
-    r = systemf("echo f | %s -pud copy >copy.out 2>copy.err",
-        testprog);
-    assertEqualInt(r, 0);
-
-    /* Verify that the file has changed (it was overwritten) */
-    p = slurpfile(&s, "copy/f");
-    assertEqualInt(s, 1);
-    assertEqualMem(p, "b", 1);
-}

+ 0 - 109
Utilities/cmlibarchive/cpio/test/test_option_version.c

@@ -1,109 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-/*
- * Test that --version option works and generates reasonable output.
- */
-
-static void
-verify(const char *p, size_t s)
-{
-    const char *q = p;
-
-    /* Version message should start with name of program, then space. */
-    failure("version message too short:", p);
-    if (!assert(s > 6))
-        return;
-    failure("Version message should begin with 'bsdcpio': %s", p);
-    if (!assertEqualMem(q, "bsdcpio ", 8))
-        /* If we're not testing bsdcpio, don't keep going. */
-        return;
-    q += 8; s -= 8;
-    /* Version number is a series of digits and periods. */
-    while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
-        ++q;
-        --s;
-    }
-    /* Version number terminated by space. */
-    failure("Version: %s", p);
-    assert(s > 1);
-    /* Skip a single trailing a,b,c, or d. */
-    if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
-        ++q;
-    failure("Version: %s", p);
-    assert(*q == ' ');
-    ++q; --s;
-    /* Separator. */
-    failure("Version: %s", p);
-    assertEqualMem(q, "-- ", 3);
-    q += 3; s -= 3;
-    /* libarchive name and version number */
-    assert(s > 11);
-    failure("Version: %s", p);
-    assertEqualMem(q, "libarchive ", 11);
-    q += 11; s -= 11;
-    /* Version number is a series of digits and periods. */
-    while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
-        ++q;
-        --s;
-    }
-    /* Skip a single trailing a,b,c, or d. */
-    if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
-        ++q;
-    /* All terminated by a newline. */
-    assert(s >= 1);
-    failure("Version: %s", p);
-#if defined(_WIN32) && !defined(__CYGWIN__)
-    assertEqualMem(q, "\r\n", 2);
-#else
-    assertEqualMem(q, "\n", 1);
-#endif
-}
-
-
-DEFINE_TEST(test_option_version)
-{
-    int r;
-    char *p;
-    size_t s;
-
-    r = systemf("%s --version >version.stdout 2>version.stderr", testprog);
-    if (r != 0)
-        r = systemf("%s -W version >version.stdout 2>version.stderr",
-            testprog);
-    failure("Unable to run either %s --version or %s -W version",
-        testprog, testprog);
-    if (!assert(r == 0))
-        return;
-
-    /* --version should generate nothing to stderr. */
-    assertEmptyFile("version.stderr");
-    /* Verify format of version message. */
-    p = slurpfile(&s, "version.stdout");
-    verify(p, s);
-    free(p);
-}

+ 0 - 57
Utilities/cmlibarchive/cpio/test/test_option_y.c

@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_y.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
-
-DEFINE_TEST(test_option_y)
-{
-    char *p;
-    int r;
-    size_t s;
-
-    /* Create a file. */
-    assertMakeFile("f", 0644, "a");
-
-    /* Archive it with bzip2 compression. */
-    r = systemf("echo f | %s -oy >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 bzip2 support");
-            return;
-        }
-        failure("-y option is broken");
-        assertEqualInt(r, 0);
-        return;
-    }
-    assertTextFileContents("1 block\n", "archive.err");
-    /* Check that the archive file has a bzip2 signature. */
-    p = slurpfile(&s, "archive.out");
-    assert(s > 2);
-    assertEqualMem(p, "BZh9", 4);
-}

+ 0 - 56
Utilities/cmlibarchive/cpio/test/test_option_z.c

@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-DEFINE_TEST(test_option_z)
-{
-    char *p;
-    int r;
-    size_t s;
-
-    /* Create a file. */
-    assertMakeFile("f", 0644, "a");
-
-    /* Archive it with gzip compression. */
-    r = systemf("echo f | %s -oz >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 gzip support");
-            return;
-        }
-        failure("-z option is broken");
-        assertEqualInt(r, 0);
-        return;
-    }
-    /* Check that the archive file has a gzip signature. */
-    p = slurpfile(&s, "archive.out");
-    assert(s > 4);
-    assertEqualMem(p, "\x1f\x8b\x08\x00", 4);
-}

+ 0 - 121
Utilities/cmlibarchive/cpio/test/test_owner_parse.c

@@ -1,121 +0,0 @@
-/*-
- * Copyright (c) 2003-2009 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-#include "../cpio.h"
-#include "err.h"
-
-#if !defined(_WIN32)
-#define ROOT "root"
-static int root_uids[] = { 0 };
-static int root_gids[] = { 0 };
-#elif defined(__CYGWIN__)
-/* On cygwin, the Administrator user most likely exists (unless
- * it has been renamed or is in a non-English localization), but
- * its primary group membership depends on how the user set up
- * their /etc/passwd. Likely values are 513 (None), 545 (Users),
- * or 544 (Administrators). Just check for one of those...
- * TODO: Handle non-English localizations...e.g. French 'Administrateur'
- *       Use CreateWellKnownSID() and LookupAccountName()?
- */
-#define ROOT "Administrator"
-static int root_uids[] = { 500 };
-static int root_gids[] = { 513, 545, 544 };
-#endif
-
-#if defined(ROOT)
-static int
-int_in_list(int i, int *l, size_t n)
-{
-    while (n-- > 0)
-        if (*l++ == i)
-            return (1);
-    failure("%d", i);
-    return (0);
-}
-#endif
-
-DEFINE_TEST(test_owner_parse)
-{
-#if !defined(ROOT)
-    skipping("No uid/gid configuration for this OS");
-#else
-    int uid, gid;
-
-    assert(NULL == owner_parse(ROOT, &uid, &gid));
-    assert(int_in_list(uid, root_uids,
-        sizeof(root_uids)/sizeof(root_uids[0])));
-    assertEqualInt(-1, gid);
-
-
-    assert(NULL == owner_parse(ROOT ":", &uid, &gid));
-    assert(int_in_list(uid, root_uids,
-        sizeof(root_uids)/sizeof(root_uids[0])));
-    assert(int_in_list(gid, root_gids,
-        sizeof(root_gids)/sizeof(root_gids[0])));
-
-    assert(NULL == owner_parse(ROOT ".", &uid, &gid));
-    assert(int_in_list(uid, root_uids,
-        sizeof(root_uids)/sizeof(root_uids[0])));
-    assert(int_in_list(gid, root_gids,
-        sizeof(root_gids)/sizeof(root_gids[0])));
-
-    assert(NULL == owner_parse("111", &uid, &gid));
-    assertEqualInt(111, uid);
-    assertEqualInt(-1, gid);
-
-    assert(NULL == owner_parse("112:", &uid, &gid));
-    assertEqualInt(112, uid);
-    /* Can't assert gid, since we don't know gid for user #112. */
-
-    assert(NULL == owner_parse("113.", &uid, &gid));
-    assertEqualInt(113, uid);
-    /* Can't assert gid, since we don't know gid for user #113. */
-
-    assert(NULL == owner_parse(":114", &uid, &gid));
-    assertEqualInt(-1, uid);
-    assertEqualInt(114, gid);
-
-    assert(NULL == owner_parse(".115", &uid, &gid));
-    assertEqualInt(-1, uid);
-    assertEqualInt(115, gid);
-
-    assert(NULL == owner_parse("116:117", &uid, &gid));
-    assertEqualInt(116, uid);
-    assertEqualInt(117, gid);
-
-    /*
-     * TODO: Lookup current user/group name, build strings and
-     * use those to verify username/groupname lookups for ordinary
-     * users.
-     */
-
-    assert(NULL != owner_parse(":nonexistentgroup", &uid, &gid));
-    assert(NULL != owner_parse(ROOT ":nonexistentgroup", &uid, &gid));
-    assert(NULL !=
-        owner_parse("nonexistentuser:nonexistentgroup", &uid, &gid));
-#endif
-}

+ 0 - 76
Utilities/cmlibarchive/cpio/test/test_passthrough_dotdot.c

@@ -1,76 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_dotdot.c,v 1.4 2008/08/24 06:21:00 kientzle Exp $");
-
-/*
- * Verify that "cpio -p .." works.
- */
-
-DEFINE_TEST(test_passthrough_dotdot)
-{
-    int r;
-    FILE *filelist;
-
-    assertUmask(0);
-
-    /*
-     * Create an assortment of files on disk.
-     */
-    filelist = fopen("filelist", "w");
-
-    /* Directory. */
-    assertMakeDir("dir", 0755);
-    assertChdir("dir");
-
-    fprintf(filelist, ".\n");
-
-    /* File with 10 bytes content. */
-    assertMakeFile("file", 0642, "1234567890");
-    fprintf(filelist, "file\n");
-
-    /* All done. */
-    fclose(filelist);
-
-
-    /*
-     * Use cpio passthrough mode to copy files to another directory.
-     */
-    r = systemf("%s -pdvm .. <../filelist >../stdout 2>../stderr",
-        testprog);
-    failure("Error invoking %s -pd ..", testprog);
-    assertEqualInt(r, 0);
-
-    assertChdir("..");
-
-    /* Verify stderr and stdout. */
-    assertTextFileContents("../.\n../file\n1 block\n", "stderr");
-    assertEmptyFile("stdout");
-
-    /* Regular file. */
-    assertIsReg("file", 0642);
-    assertFileSize("file", 10);
-    assertFileNLinks("file", 1);
-}

+ 0 - 85
Utilities/cmlibarchive/cpio/test/test_passthrough_reverse.c

@@ -1,85 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_reverse.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
-
-/*
- * As reported by Bernd Walter:  Some people are in the habit of
- * using "find -d" to generate a list for cpio -p because that
- * copies the top-level dir last, which preserves owner and mode
- * information.  That's not necessary for bsdcpio (libarchive defers
- * restoring directory information), but bsdcpio should still generate
- * the correct results with this usage.
- */
-
-DEFINE_TEST(test_passthrough_reverse)
-{
-    int r;
-    FILE *filelist;
-
-    assertUmask(0);
-
-    /*
-     * Create an assortment of files on disk.
-     */
-    filelist = fopen("filelist", "w");
-
-    /* Directory. */
-    assertMakeDir("dir", 0743);
-
-    /* File with 10 bytes content. */
-    assertMakeFile("dir/file", 0644, "1234567890");
-    fprintf(filelist, "dir/file\n");
-
-    /* Write dir last. */
-    fprintf(filelist, "dir\n");
-
-    /* All done. */
-    fclose(filelist);
-
-
-    /*
-     * Use cpio passthrough mode to copy files to another directory.
-     */
-    r = systemf("%s -pdvm out <filelist >stdout 2>stderr", testprog);
-    failure("Error invoking %s -pd out", testprog);
-    assertEqualInt(r, 0);
-
-    assertChdir("out");
-
-    /* Verify stderr and stdout. */
-    assertTextFileContents("out/dir/file\nout/dir\n1 block\n",
-        "../stderr");
-    assertEmptyFile("../stdout");
-
-    /* dir */
-    assertIsDir("dir", 0743);
-
-
-    /* Regular file. */
-    assertIsReg("dir/file", 0644);
-    assertFileSize("dir/file", 10);
-    assertFileNLinks("dir/file", 1);
-}

+ 0 - 243
Utilities/cmlibarchive/cpio/test/test_pathmatch.c

@@ -1,243 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-#include "pathmatch.h"
-
-/*
- * Verify that the pattern matcher implements the wildcard logic specified
- * in SUSv2 for the cpio command.  This is essentially the
- * shell glob syntax:
- *   * - matches any sequence of chars, including '/'
- *   ? - matches any single char, including '/'
- *   [...] - matches any of a set of chars, '-' specifies a range,
- *        initial '!' is undefined
- *
- * The specification in SUSv2 is a bit incomplete, I assume the following:
- *   Trailing '-' in [...] is not special.
- *
- * TODO: Figure out if there's a good way to extend this to handle
- * Windows paths that use '\' as a path separator.  <sigh>
- */
-
-DEFINE_TEST(test_pathmatch)
-{
-    assertEqualInt(1, lafe_pathmatch("a/b/c", "a/b/c", 0));
-    assertEqualInt(0, lafe_pathmatch("a/b/", "a/b/c", 0));
-    assertEqualInt(0, lafe_pathmatch("a/b", "a/b/c", 0));
-    assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b/", 0));
-    assertEqualInt(0, lafe_pathmatch("a/b/c", "a/b", 0));
-
-    /* Empty pattern only matches empty string. */
-    assertEqualInt(1, lafe_pathmatch("","", 0));
-    assertEqualInt(0, lafe_pathmatch("","a", 0));
-    assertEqualInt(1, lafe_pathmatch("*","", 0));
-    assertEqualInt(1, lafe_pathmatch("*","a", 0));
-    assertEqualInt(1, lafe_pathmatch("*","abcd", 0));
-    /* SUSv2: * matches / */
-    assertEqualInt(1, lafe_pathmatch("*","abcd/efgh/ijkl", 0));
-    assertEqualInt(1, lafe_pathmatch("abcd*efgh/ijkl","abcd/efgh/ijkl", 0));
-    assertEqualInt(1, lafe_pathmatch("abcd***efgh/ijkl","abcd/efgh/ijkl", 0));
-    assertEqualInt(1, lafe_pathmatch("abcd***/efgh/ijkl","abcd/efgh/ijkl", 0));
-    assertEqualInt(0, lafe_pathmatch("?", "", 0));
-    assertEqualInt(0, lafe_pathmatch("?", "\0", 0));
-    assertEqualInt(1, lafe_pathmatch("?", "a", 0));
-    assertEqualInt(0, lafe_pathmatch("?", "ab", 0));
-    assertEqualInt(1, lafe_pathmatch("?", ".", 0));
-    assertEqualInt(1, lafe_pathmatch("?", "?", 0));
-    assertEqualInt(1, lafe_pathmatch("a", "a", 0));
-    assertEqualInt(0, lafe_pathmatch("a", "ab", 0));
-    assertEqualInt(0, lafe_pathmatch("a", "ab", 0));
-    assertEqualInt(1, lafe_pathmatch("a?c", "abc", 0));
-    /* SUSv2: ? matches / */
-    assertEqualInt(1, lafe_pathmatch("a?c", "a/c", 0));
-    assertEqualInt(1, lafe_pathmatch("a?*c*", "a/c", 0));
-    assertEqualInt(1, lafe_pathmatch("*a*", "a/c", 0));
-    assertEqualInt(1, lafe_pathmatch("*a*", "/a/c", 0));
-    assertEqualInt(1, lafe_pathmatch("*a*", "defaaaaaaa", 0));
-    assertEqualInt(0, lafe_pathmatch("a*", "defghi", 0));
-    assertEqualInt(0, lafe_pathmatch("*a*", "defghi", 0));
-
-    /* Character classes */
-    assertEqualInt(1, lafe_pathmatch("abc[def", "abc[def", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[def]", "abc[def", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[def", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[def]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[def]", "abce", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[def]", "abcf", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[def]", "abcg", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d*f]", "abc*", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d*f]", "abcdefghi", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d*", "abcdefghi", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d*", "abc[defghi", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abce", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-f]", "abcf", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d-f]", "abcg", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abca", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abce", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcf", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcg", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abch", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abci", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abcj", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-k]", "abck", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abcl", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d-fh-k]", "abc-", 0));
-
-    /* [] matches nothing, [!] is the same as ? */
-    assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcdefg", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcqefg", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[]efg", "abcefg", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcdefg", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[!]efg", "abcqefg", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[!]efg", "abcefg", 0));
-
-    /* I assume: Trailing '-' is non-special. */
-    assertEqualInt(0, lafe_pathmatch("abc[d-fh-]", "abcl", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abch", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-fh-]", "abc-", 0));
-
-    /* ']' can be backslash-quoted within a character class. */
-    assertEqualInt(1, lafe_pathmatch("abc[\\]]", "abc]", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abc]", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[\\]d]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abc]", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d\\]]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d]e]", "abcde]", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d\\]e]", "abc]", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d\\]e]", "abcd]e", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[d]e]", "abc]", 0));
-
-    /* backslash-quoted chars can appear as either end of a range. */
-    assertEqualInt(1, lafe_pathmatch("abc[\\d-f]gh", "abcegh", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abcggh", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[\\d-f]gh", "abc\\gh", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d-\\f]gh", "abcegh", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[\\d-\\f]gh", "abcegh", 0));
-    /* backslash-quoted '-' isn't special. */
-    assertEqualInt(0, lafe_pathmatch("abc[d\\-f]gh", "abcegh", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[d\\-f]gh", "abc-gh", 0));
-
-    /* Leading '!' negates a character class. */
-    assertEqualInt(0, lafe_pathmatch("abc[!d]", "abcd", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[!d]", "abce", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[!d]", "abcc", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[!d-z]", "abcq", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[!d-gi-z]", "abch", 0));
-    assertEqualInt(1, lafe_pathmatch("abc[!fgijkl]", "abch", 0));
-    assertEqualInt(0, lafe_pathmatch("abc[!fghijkl]", "abch", 0));
-
-    /* Backslash quotes next character. */
-    assertEqualInt(0, lafe_pathmatch("abc\\[def]", "abc\\d", 0));
-    assertEqualInt(1, lafe_pathmatch("abc\\[def]", "abc[def]", 0));
-    assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc[def]", 0));
-    assertEqualInt(0, lafe_pathmatch("abc\\\\[def]", "abc\\[def]", 0));
-    assertEqualInt(1, lafe_pathmatch("abc\\\\[def]", "abc\\d", 0));
-    assertEqualInt(1, lafe_pathmatch("abcd\\", "abcd\\", 0));
-    assertEqualInt(0, lafe_pathmatch("abcd\\", "abcd\\[", 0));
-    assertEqualInt(0, lafe_pathmatch("abcd\\", "abcde", 0));
-    assertEqualInt(0, lafe_pathmatch("abcd\\[", "abcd\\", 0));
-
-    /*
-     * Because '.' and '/' have special meanings, we can
-     * identify many equivalent paths even if they're expressed
-     * differently.  (But quoting a character with '\\' suppresses
-     * special meanings!)
-     */
-    assertEqualInt(0, lafe_pathmatch("a/b/", "a/bc", 0));
-    assertEqualInt(1, lafe_pathmatch("a/./b", "a/b", 0));
-    assertEqualInt(0, lafe_pathmatch("a\\/./b", "a/b", 0));
-    assertEqualInt(0, lafe_pathmatch("a/\\./b", "a/b", 0));
-    assertEqualInt(0, lafe_pathmatch("a/.\\/b", "a/b", 0));
-    assertEqualInt(0, lafe_pathmatch("a\\/\\.\\/b", "a/b", 0));
-    assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def/", 0));
-    assertEqualInt(1, lafe_pathmatch("abc/def", "./././abc/./def", 0));
-    assertEqualInt(1, lafe_pathmatch("abc/def/././//", "./././abc/./def/", 0));
-    assertEqualInt(1, lafe_pathmatch(".////abc/.//def", "./././abc/./def", 0));
-    assertEqualInt(1, lafe_pathmatch("./abc?def/", "abc/def/", 0));
-    failure("\"?./\" is not the same as \"/./\"");
-    assertEqualInt(0, lafe_pathmatch("./abc?./def/", "abc/def/", 0));
-    failure("Trailing '/' should match no trailing '/'");
-    assertEqualInt(1, lafe_pathmatch("./abc/./def/", "abc/def", 0));
-    failure("Trailing '/./' is still the same directory.");
-    assertEqualInt(1, lafe_pathmatch("./abc/./def/./", "abc/def", 0));
-    failure("Trailing '/.' is still the same directory.");
-    assertEqualInt(1, lafe_pathmatch("./abc/./def/.", "abc/def", 0));
-    assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/", 0));
-    failure("Trailing '/./' is still the same directory.");
-    assertEqualInt(1, lafe_pathmatch("./abc/./def", "abc/def/./", 0));
-    failure("Trailing '/.' is still the same directory.");
-    assertEqualInt(1, lafe_pathmatch("./abc*/./def", "abc/def/.", 0));
-
-    /* Matches not anchored at beginning. */
-    assertEqualInt(0,
-        lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_START));
-    assertEqualInt(1,
-        lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_START));
-    assertEqualInt(0,
-        lafe_pathmatch("^bcd", "abcd", PATHMATCH_NO_ANCHOR_START));
-    assertEqualInt(1,
-        lafe_pathmatch("b/c/d", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
-    assertEqualInt(0,
-        lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
-    assertEqualInt(0,
-        lafe_pathmatch("^b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_START));
-
-    /* Matches not anchored at end. */
-    assertEqualInt(0,
-        lafe_pathmatch("bcd", "abcd", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("abcd", "abcd", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("abcd", "abcd/", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("abcd", "abcd/.", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(0,
-        lafe_pathmatch("abc", "abcd", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("a/b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(0,
-        lafe_pathmatch("a/b/c$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("a/b/c$", "a/b/c", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("a/b/c$", "a/b/c/", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("a/b/c/", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(0,
-        lafe_pathmatch("a/b/c/$", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("a/b/c/$", "a/b/c/", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(1,
-        lafe_pathmatch("a/b/c/$", "a/b/c", PATHMATCH_NO_ANCHOR_END));
-    assertEqualInt(0,
-        lafe_pathmatch("b/c", "a/b/c/d", PATHMATCH_NO_ANCHOR_END));
-}

+ 0 - 391
Utilities/cmlibarchive/doc/mdoc2man.awk

@@ -1,391 +0,0 @@
-#!/usr/bin/awk
-#
-# Copyright (c) 2003 Peter Stuge <[email protected]>
-#
-# Permission to use, copy, modify, and distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-# Dramatically overhauled by Tim Kientzle.  This version almost
-# handles library-style pages with Fn, Ft, etc commands.  Still
-# a lot of problems...
-
-BEGIN {
-  displaylines = 0
-  trailer = ""
-  out = ""
-  sep = ""
-  nextsep = " "
-}
-
-# Add a word with appropriate preceding whitespace
-# Maintain a short queue of the expected upcoming word separators.
-function add(str) {
-  out=out sep str
-  sep = nextsep
-  nextsep = " "
-}
-
-# Add a word with no following whitespace
-# Use for opening punctuation such as '('
-function addopen(str) {
-  add(str)
-  sep = ""
-}
-
-# Add a word with no preceding whitespace
-# Use for closing punctuation such as ')' or '.'
-function addclose(str) {
-  sep = ""
-  add(str)
-}
-
-# Add a word with no space before or after
-# Use for separating punctuation such as '='
-function addpunct(str) {
-  sep = ""
-  add(str)
-  sep = ""
-}
-
-# Emit the current line so far
-function endline() {
-  addclose(trailer)
-  trailer = ""
-  if(length(out) > 0) {
-    print out
-    out=""
-  }
-  if(displaylines > 0) {
-    displaylines = displaylines - 1
-    if (displaylines == 0)
-      dispend()
-  }
-  # First word on next line has no preceding whitespace
-  sep = ""
-}
-
-function linecmd(cmd) {
-  endline()
-  add(cmd)
-  endline()
-}
-
-function breakline() {
-  linecmd(".br")
-}
-
-# Start an indented display
-function dispstart() {
-  linecmd(".RS 4")
-}
-
-# End an indented display
-function dispend() {
-  linecmd(".RE")
-}
-
-# Collect rest of input line
-function wtail() {
-  retval=""
-  while(w<nwords) {
-    if(length(retval))
-      retval=retval " "
-    retval=retval words[++w]
-  }
-  return retval
-}
-
-function splitwords(l, dest, n, o, w) {
-  n = 1
-  delete dest
-  while (length(l) > 0) {
-    sub("^[ \t]*", "", l)
-    if (match(l, "^\"")) {
-      l = substr(l, 2)
-      o = index(l, "\"")
-      if (o > 0) {
-    w = substr(l, 1, o-1)
-    l = substr(l, o+1)
-    dest[n++] = w
-      } else {
-    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
-      } else {
-    dest[n++] = l
-    l = ""
-      }
-    }
-  }
-  return n-1
-}
-
-! /^\./ {
-  out = $0
-  endline()
-  next
-}
-
-/^\.\\"/ { next }
-
-{
-  sub("^\\.","")
-  nwords=splitwords($0, words)
-  # TODO: Instead of iterating 'w' over the array, have a separate
-  # function that returns 'next word' and use that.  This will allow
-  # proper handling of double-quoted arguments as well.
-  for(w=1;w<=nwords;w++) {
-    if(match(words[w],"^Li$")) { # Literal; rest of line is unformatted
-      dispstart()
-      displaylines = 1
-    } else if(match(words[w],"^Dl$")) { # Display literal
-      dispstart()
-      displaylines = 1
-    } else if(match(words[w],"^Bd$")) { # Begin display
-      if(match(words[w+1],"-literal")) {
-        dispstart()
-    linecmd(".nf")
-    displaylines=10000
-    w=nwords
-      }
-    } else if(match(words[w],"^Ed$")) { # End display
-      displaylines = 0
-      dispend()
-    } else if(match(words[w],"^Ns$")) { # Suppress space after next word
-      nextsep = ""
-    } else if(match(words[w],"^No$")) { # Normal text
-      add(words[++w])
-    } else if(match(words[w],"^Dq$")) { # Quote
-      addopen("``")
-      add(words[++w])
-      while(w<nwords&&!match(words[w+1],"^[\\.,]"))
-    add(words[++w])
-      addclose("''")
-    } else if(match(words[w],"^Do$")) {
-      addopen("``")
-    } else if(match(words[w],"^Dc$")) {
-      addclose("''")
-    } else if(match(words[w],"^Oo$")) {
-      addopen("[")
-    } else if(match(words[w],"^Oc$")) {
-      addclose("]")
-    } else if(match(words[w],"^Ao$")) {
-      addopen("<")
-    } else if(match(words[w],"^Ac$")) {
-      addclose(">")
-    } else if(match(words[w],"^Dd$")) {
-      date=wtail()
-      next
-    } else if(match(words[w],"^Dt$")) {
-      id=wtail()
-      next
-    } else if(match(words[w],"^Ox$")) {
-      add("OpenBSD")
-    } else if(match(words[w],"^Fx$")) {
-      add("FreeBSD")
-    } else if(match(words[w],"^Nx$")) {
-      add("NetBSD")
-    } else if(match(words[w],"^St$")) {
-      if (match(words[w+1], "^-p1003.1$")) {
-         w++
-         add("IEEE Std 1003.1 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-p1003.1-96$")) {
-         w++
-         add("ISO/IEC 9945-1:1996 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-p1003.1-88$")) {
-         w++
-         add("IEEE Std 1003.1-1988 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-p1003.1-2001$")) {
-         w++
-         add("IEEE Std 1003.1-2001 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-susv2$")) {
-         w++
-         add("Version 2 of the Single UNIX Specification (``SUSv2'')")
-      }
-    } else if(match(words[w],"^Ex$")) {
-      if (match(words[w+1], "^-std$")) {
-         w++
-         add("The \\fB" name "\\fP utility exits 0 on success, and >0 if an error occurs.")
-      }
-    } else if(match(words[w],"^Os$")) {
-      add(".TH " id " \"" date "\" \"" wtail() "\"")
-    } else if(match(words[w],"^Sh$")) {
-      section=wtail()
-      add(".SH " section)
-      linecmd(".ad l")
-    } else if(match(words[w],"^Xr$")) {
-      add("\\fB" words[++w] "\\fP(" words[++w] ")" words[++w])
-    } else if(match(words[w],"^Nm$")) {
-      if(match(section,"SYNOPSIS"))
-        breakline()
-      if(w >= nwords)
-    n=name
-      else if (match(words[w+1], "^[A-Z][a-z]$"))
-    n=name
-      else if (match(words[w+1], "^[.,;:]$"))
-    n=name
-      else {
-        n=words[++w]
-        if(!length(name))
-          name=n
-      }
-      if(!length(n))
-        n=name
-      add("\\fB\\%" n "\\fP")
-    } else if(match(words[w],"^Nd$")) {
-      add("\\- " wtail())
-    } else if(match(words[w],"^Fl$")) {
-      add("\\fB\\-" words[++w] "\\fP")
-    } else if(match(words[w],"^Ar$")) {
-      addopen("\\fI")
-      if(w==nwords)
-    add("file ...\\fP")
-      else
-    add(words[++w] "\\fP")
-    } else if(match(words[w],"^Cm$")) {
-      add("\\fB" words[++w] "\\fP")
-    } else if(match(words[w],"^Op$")) {
-      addopen("[")
-      option=1
-      trailer="]" trailer
-    } else if(match(words[w],"^Pp$")) {
-      linecmd(".PP")
-    } else if(match(words[w],"^An$")) {
-      endline()
-    } else if(match(words[w],"^Ss$")) {
-      add(".SS")
-    } else if(match(words[w],"^Ft$")) {
-      if (match(section, "SYNOPSIS")) {
-    breakline()
-      }
-      add("\\fI" wtail() "\\fP")
-      if (match(section, "SYNOPSIS")) {
-    breakline()
-      }
-    } else if(match(words[w],"^Fn$")) {
-      ++w
-      F = "\\fB\\%" words[w] "\\fP("
-      Fsep = ""
-      while(w<nwords) {
-    ++w
-    if (match(words[w], "^[.,:]$")) {
-      --w
-      break
-    }
-    gsub(" ", "\\ ", words[w])
-    F = F Fsep "\\fI\\%"  words[w] "\\fP"
-    Fsep = ", "
-      }
-      add(F ")")
-      if (match(section, "SYNOPSIS")) {
-    addclose(";")
-      }
-    } else if(match(words[w],"^Fo$")) {
-      w++
-      F = "\\fB\\%" words[w] "\\fP("
-      Fsep = ""
-    } else if(match(words[w],"^Fa$")) {
-      w++
-      gsub(" ", "\\ ", words[w])
-      F = F Fsep "\\fI\\%"  words[w] "\\fP"
-      Fsep = ", "
-    } else if(match(words[w],"^Fc$")) {
-      add(F ")")
-      if (match(section, "SYNOPSIS")) {
-    addclose(";")
-      }
-    } else if(match(words[w],"^Va$")) {
-      w++
-      add("\\fI" words[w] "\\fP")
-    } else if(match(words[w],"^In$")) {
-      w++
-      add("\\fB#include <" words[w] ">\\fP")
-    } else if(match(words[w],"^Pa$")) {
-      addopen("\\fI")
-      w++
-      if(match(words[w],"^\\."))
-    add("\\&")
-      add(words[w] "\\fP")
-    } else if(match(words[w],"^Dv$")) {
-      add(".BR")
-    } else if(match(words[w],"^Em|Ev$")) {
-      add(".IR")
-    } else if(match(words[w],"^Pq$")) {
-      addopen("(")
-      trailer=")" trailer
-    } else if(match(words[w],"^Aq$")) {
-      addopen("\\%<")
-      trailer=">" trailer
-    } else if(match(words[w],"^Brq$")) {
-      addopen("{")
-      trailer="}" trailer
-    } else if(match(words[w],"^S[xy]$")) {
-      add(".B " wtail())
-    } else if(match(words[w],"^Ic$")) {
-      add("\\fB")
-      trailer="\\fP" trailer
-    } else if(match(words[w],"^Bl$")) {
-      oldoptlist=optlist
-      linecmd(".RS 5")
-      if(match(words[w+1],"-bullet"))
-    optlist=1
-      else if(match(words[w+1],"-enum")) {
-    optlist=2
-    enum=0
-      } else if(match(words[w+1],"-tag"))
-    optlist=3
-      else if(match(words[w+1],"-item"))
-    optlist=4
-      else if(match(words[w+1],"-bullet"))
-    optlist=1
-      w=nwords
-    } else if(match(words[w],"^El$")) {
-      linecmd(".RE")
-      optlist=oldoptlist
-    } else if(match(words[w],"^It$")&&optlist) {
-      if(optlist==1)
-    add(".IP \\(bu")
-      else if(optlist==2)
-    add(".IP " ++enum ".")
-      else if(optlist==3) {
-    add(".TP")
-        endline()
-    if(match(words[w+1],"^Pa$|^Ev$")) {
-      add(".B")
-      w++
-    }
-      } else if(optlist==4)
-    add(".IP")
-    } else if(match(words[w],"^Xo$")) {
-      # TODO: Figure out how to handle this
-    } else if(match(words[w],"^Xc$")) {
-      # TODO: Figure out how to handle this
-    } else if(match(words[w],"^[=]$")) {
-      addpunct(words[w])
-    } else if(match(words[w],"^[\[{(]$")) {
-      addopen(words[w])
-    } else if(match(words[w],"^[\\\])}.,;:]$")) {
-      addclose(words[w])
-    } else {
-      add(words[w])
-    }
-  }
-  if(match(out,"^\\.[^a-zA-Z]"))
-    sub("^\\.","",out)
-  endline()
-}

+ 0 - 448
Utilities/cmlibarchive/doc/mdoc2wiki.awk

@@ -1,448 +0,0 @@
-#!/usr/bin/awk
-#
-# Copyright (c) 2003 Peter Stuge <[email protected]>
-#
-# Permission to use, copy, modify, and distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-# Dramatically overhauled by Tim Kientzle.  This version almost
-# handles library-style pages with Fn, Ft, etc commands.  Still
-# a lot of problems...
-
-BEGIN {
-  displaylines = 0
-  listdepth = 0
-  trailer = ""
-  out = ""
-  sep = ""
-  nextsep = " "
-  spaces = "                    "
-}
-
-# Add a word with appropriate preceding whitespace
-# Maintain a short queue of the expected upcoming word separators.
-function add(str) {
-  out=out sep str
-  sep = nextsep
-  nextsep = " "
-}
-
-# Add a word with no following whitespace
-# Use for opening punctuation such as '('
-function addopen(str) {
-  add(str)
-  sep = ""
-}
-
-# Add a word with no preceding whitespace
-# Use for closing punctuation such as ')' or '.'
-function addclose(str) {
-  sep = ""
-  add(str)
-}
-
-# Add a word with no space before or after
-# Use for separating punctuation such as '='
-function addpunct(str) {
-  sep = ""
-  add(str)
-  sep = ""
-}
-
-# Emit the current line so far
-function endline() {
-  addclose(trailer)
-  trailer = ""
-  if(length(out) > 0) {
-    print out
-    out=""
-  }
-  if(displaylines > 0) {
-    displaylines = displaylines - 1
-    if (displaylines == 0)
-      dispend()
-  }
-  # First word on next line has no preceding whitespace
-  sep = ""
-}
-
-function linecmd(cmd) {
-  endline()
-  add(cmd)
-  endline()
-}
-
-function breakline() {
-  linecmd("<br>")
-}
-
-# Start an indented display
-function dispstart() {
-  linecmd("{{{")
-}
-
-# End an indented display
-function dispend() {
-  linecmd("}}}")
-}
-
-# Collect rest of input line
-function wtail() {
-  retval=""
-  while(w<nwords) {
-    if(length(retval))
-      retval=retval " "
-    retval=retval words[++w]
-  }
-  return retval
-}
-
-function splitwords(l, dest, n, o, w) {
-  n = 1
-  delete dest
-  while (length(l) > 0) {
-    sub("^[ \t]*", "", l)
-    if (match(l, "^\"")) {
-      l = substr(l, 2)
-      o = index(l, "\"")
-      if (o > 0) {
-    w = substr(l, 1, o-1)
-    l = substr(l, o+1)
-    dest[n++] = w
-      } else {
-    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
-      } else {
-    dest[n++] = l
-    l = ""
-      }
-    }
-  }
-  return n-1
-}
-
-! /^\./ {
-  out = $0
-  endline()
-  next
-}
-
-/^\.\\"/ { next }
-
-{
-  sub("^\\.","")
-  nwords=splitwords($0, words)
-  # TODO: Instead of iterating 'w' over the array, have a separate
-  # function that returns 'next word' and use that.  This will allow
-  # proper handling of double-quoted arguments as well.
-  for(w=1;w<=nwords;w++) {
-    if(match(words[w],"^Li$")) { # Literal; rest of line is unformatted
-      dispstart()
-      displaylines = 1
-    } else if(match(words[w],"^Dl$")) { # Display literal
-      dispstart()
-      displaylines = 1
-    } else if(match(words[w],"^Bd$")) { # Begin display
-      if(match(words[w+1],"-literal")) {
-        dispstart()
-    displaylines=10000
-    w=nwords
-      }
-    } else if(match(words[w],"^Ed$")) { # End display
-      displaylines = 0
-      dispend()
-    } else if(match(words[w],"^Ns$")) { # Suppress space before next word
-      sep=""
-    } else if(match(words[w],"^No$")) { # Normal text
-      add(words[++w])
-    } else if(match(words[w],"^Dq$")) { # Quote
-      addopen("\"")
-      add(words[++w])
-      while(w<nwords&&!match(words[w+1],"^[\\.,]"))
-    add(words[++w])
-      addclose("\"")
-    } else if(match(words[w],"^Do$")) {
-      addopen("\"")
-    } else if(match(words[w],"^Dc$")) {
-      addclose("\"")
-    } else if(match(words[w],"^Oo$")) {
-      addopen("`[`")
-    } else if(match(words[w],"^Oc$")) {
-      addclose("`]`")
-    } else if(match(words[w],"^Ao$")) {
-      addopen("`<`")
-    } else if(match(words[w],"^Ac$")) {
-      addclose("`>`")
-    } else if(match(words[w],"^Dd$")) {
-      date=wtail()
-      next
-    } else if(match(words[w],"^Dt$")) {
-      id=wtail()
-      next
-    } else if(match(words[w],"^Ox$")) {
-      add("OpenBSD")
-    } else if(match(words[w],"^Fx$")) {
-      add("FreeBSD")
-    } else if(match(words[w],"^Bx$")) {
-      add("BSD")
-    } else if(match(words[w],"^Nx$")) {
-      add("NetBSD")
-    } else if(match(words[w],"^St$")) {
-      if (match(words[w+1], "^-p1003.1$")) {
-         w++
-         add("IEEE Std 1003.1 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-p1003.1-96$")) {
-         w++
-         add("ISO/IEC 9945-1:1996 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-p1003.1-88$")) {
-         w++
-         add("IEEE Std 1003.1-1988 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-p1003.1-2001$")) {
-         w++
-         add("IEEE Std 1003.1-2001 (``POSIX.1'')")
-      } else if(match(words[w+1], "^-susv2$")) {
-         w++
-         add("Version 2 of the Single UNIX Specification (``SUSv2'')")
-      }
-    } else if(match(words[w],"^Ex$")) {
-      if (match(words[w+1], "^-std$")) {
-         w++
-         add("The *" name "* utility exits 0 on success, and >0 if an error occurs.")
-      }
-    } else if(match(words[w],"^Os$")) {
-      add("#summary " id " manual page")
-    } else if(match(words[w],"^Sh$")) {
-      section=wtail()
-      linecmd("== " section " ==")
-    } else if(match(words[w],"^Xr$")) {
-      add("*" words[++w] "*(" words[++w] ")" words[++w])
-    } else if(match(words[w],"^Nm$")) {
-      if(match(section,"SYNOPSIS"))
-        breakline()
-      if(w >= nwords)
-    n=name
-      else if (match(words[w+1], "^[A-Z][a-z]$"))
-    n=name
-      else if (match(words[w+1], "^[.,;:]$"))
-    n=name
-      else {
-        n=words[++w]
-        if(!length(name))
-          name=n
-      }
-      if(!length(n))
-        n=name
-      if (displaylines == 0)
-    add("*" n "*")
-      else
-    add(n)
-    } else if(match(words[w],"^Nd$")) {
-      add("- " wtail())
-    } else if(match(words[w],"^Fl$")) {
-      if (displaylines == 0)
-    add("*-" words[++w] "*")
-      else
-    add("-" words[++w])
-    } else if(match(words[w],"^Ar$")) {
-      if(w==nwords)
-    add("_file ..._")
-      else {
-    ++w
-    gsub("<", "`<`", words[w])
-    add("_" words[w] "_")
-      }
-    } else if(match(words[w],"^Cm$")) {
-      ++w
-      if (displaylines == 0) {
-    gsub("^_", "`_`", words[w])
-    gsub("\\*$", "`*`", words[w])
-    add("*" words[w] "*")
-      } else
-    add(words[w])
-    } else if(match(words[w],"^Op$")) {
-      addopen("`[`")
-      option=1
-      trailer="`]`" trailer
-    } else if(match(words[w],"^Pp$")) {
-      ++w
-      endline()
-      print ""
-    } else if(match(words[w],"^An$")) {
-      if (match(words[w+1],"-nosplit"))
-    ++w
-      endline()
-    } else if(match(words[w],"^Ss$")) {
-      add("===")
-      trailer="==="
-    } else if(match(words[w],"^Ft$")) {
-      if (match(section, "SYNOPSIS")) {
-    breakline()
-      }
-      l = wtail()
-      gsub("\\*", "`*`", l)
-
-      add("*" l "*")
-      if (match(section, "SYNOPSIS")) {
-    breakline()
-      }
-    } else if(match(words[w],"^Fn$")) {
-      ++w
-      F = "*" words[w] "*("
-      Fsep = ""
-      while(w<nwords) {
-    ++w
-    if (match(words[w], "^[.,:]$")) {
-      --w
-      break
-    }
-    gsub("\\*", "`*`", words[w])
-    F = F Fsep "_"  words[w] "_"
-    Fsep = ", "
-      }
-      add(F ")")
-      if (match(section, "SYNOPSIS")) {
-    addclose(";")
-      }
-    } else if(match(words[w],"^Fo$")) {
-      w++
-      F = "*" words[w] "*("
-      Fsep = ""
-    } else if(match(words[w],"^Fa$")) {
-      w++
-      gsub("\\*", "`*`", words[w])
-      F = F Fsep "_"  words[w] "_"
-      Fsep = ", "
-    } else if(match(words[w],"^Fc$")) {
-      add(F ")")
-      if (match(section, "SYNOPSIS")) {
-    addclose(";")
-      }
-    } else if(match(words[w],"^Va$")) {
-      w++
-      add("_" words[w] "_")
-    } else if(match(words[w],"^In$")) {
-      w++
-      add("*#include <" words[w] ">*")
-    } else if(match(words[w],"^Pa$")) {
-      w++
-#      if(match(words[w],"^\\."))
-#   add("\\&")
-      if (displaylines == 0)
-    add("_" words[w] "_")
-      else
-    add(words[w])
-    } else if(match(words[w],"^Dv$")) {
-      linecmd()
-    } else if(match(words[w],"^Em|Ev$")) {
-      add(".IR")
-    } else if(match(words[w],"^Pq$")) {
-      addopen("(")
-      trailer=")" trailer
-    } else if(match(words[w],"^Aq$")) {
-      addopen(" <")
-      trailer=">" trailer
-    } else if(match(words[w],"^Brq$")) {
-      addopen("{")
-      trailer="}" trailer
-    } else if(match(words[w],"^S[xy]$")) {
-      add(".B " wtail())
-    } else if(match(words[w],"^Tn$")) {
-      n=wtail()
-      gsub("\\*$", "`*`", n)
-      add("*" n "*")
-    } else if(match(words[w],"^Ic$")) {
-      add("\\fB")
-      trailer="\\fP" trailer
-    } else if(match(words[w],"^Bl$")) {
-      ++listdepth
-      listnext[listdepth]=""
-      if(match(words[w+1],"-bullet")) {
-    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>"
-      } else if(match(words[w+1],"-tag")) {
-    optlist[listdepth]=3
-    addopen("<dl>")
-    listclose[listdepth]="</dl>"
-      } else if(match(words[w+1],"-item")) {
-    optlist[listdepth]=4
-    addopen("<ul>")
-    listclose[listdepth]="</ul>"
-      }
-      w=nwords
-    } else if(match(words[w],"^El$")) {
-      addclose(listnext[listdepth])
-      addclose(listclose[listdepth])
-      listclose[listdepth]=""
-      listdepth--
-    } else if(match(words[w],"^It$")) {
-      addclose(listnext[listdepth])
-      if(optlist[listdepth]==1) {
-    addpunct("<li>")
-    listnext[listdepth] = "</li>"
-      } else if(optlist[listdepth]==2) {
-    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>"
-    }
-      } else if(optlist[listdepth]==4) {
-    addpunct("<li>")
-    listnext[listdepth] = "</li>"
-      }
-    } else if(match(words[w],"^Xo$")) {
-      # TODO: Figure out how to handle this
-    } 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>"
-      }
-    } else if(match(words[w],"^[=]$")) {
-      addpunct(words[w])
-    } else if(match(words[w],"^[\[{(]$")) {
-      addopen(words[w])
-    } else if(match(words[w],"^[\\\])}.,;:]$")) {
-      addclose(words[w])
-    } else {
-      sub("\\\\&", "", words[w])
-      add(words[w])
-    }
-  }
-  if(match(out,"^\\.[^a-zA-Z]"))
-    sub("^\\.","",out)
-  endline()
-}

+ 0 - 112
Utilities/cmlibarchive/doc/update.sh

@@ -1,112 +0,0 @@
-#!/bin/sh
-
-#
-# Simple script to repopulate the 'doc' tree from
-# the mdoc man pages stored in each project.
-#
-
-# Build Makefile in 'man' directory
-cd man
-rm -f *.[135]
-echo > Makefile
-echo "default: all" >>Makefile
-echo >>Makefile
-all="all:"
-for d in libarchive tar cpio; do
-    for f in ../../$d/*.[135]; do
-    outname="`basename $f`"
-    echo >> Makefile
-    echo $outname: ../mdoc2man.awk $f >> Makefile
-    echo "  awk -f ../mdoc2man.awk < $f > $outname" >> Makefile
-        all="$all $outname"
-    done
-done
-echo $all >>Makefile
-cd ..
-
-# Rebuild Makefile in 'text' directory
-cd text
-rm -f *.txt
-echo > Makefile
-echo "default: all" >>Makefile
-echo >>Makefile
-all="all:"
-for d in libarchive tar cpio; do
-    for f in ../../$d/*.[135]; do
-    outname="`basename $f`.txt"
-    echo >> Makefile
-    echo $outname: $f >> Makefile
-    echo "  nroff -mdoc $f | col -b > $outname" >> Makefile
-        all="$all $outname"
-    done
-done
-echo $all >>Makefile
-cd ..
-
-# Rebuild Makefile in 'pdf' directory
-cd pdf
-rm -f *.pdf
-echo > Makefile
-echo "default: all" >>Makefile
-echo >>Makefile
-all="all:"
-for d in libarchive tar cpio; do
-    for f in ../../$d/*.[135]; do
-    outname="`basename $f`.pdf"
-    echo >> Makefile
-    echo $outname: $f >> Makefile
-    echo "  groff -mdoc -T ps $f | ps2pdf - - > $outname" >> Makefile
-        all="$all $outname"
-    done
-done
-echo $all >>Makefile
-cd ..
-
-# Build Makefile in 'html' directory
-cd html
-rm -f *.html
-echo > Makefile
-echo "default: all" >>Makefile
-echo >>Makefile
-all="all:"
-for d in libarchive tar cpio; do
-    for f in ../../$d/*.[135]; do
-    outname="`basename $f`.html"
-    echo >> Makefile
-    echo $outname: ../mdoc2man.awk $f >> Makefile
-    echo "  groff -mdoc -T html $f > $outname" >> Makefile
-        all="$all $outname"
-    done
-done
-echo $all >>Makefile
-cd ..
-
-# Build Makefile in 'wiki' directory
-cd wiki
-rm -f *.wiki
-echo > Makefile
-echo "default: all" >>Makefile
-echo >>Makefile
-all="all:"
-for d in libarchive tar cpio; do
-    for f in ../../$d/*.[135]; do
-    outname="`basename $f | awk '{ac=split($0,a,"[_.-]");o="ManPage";for(w=0;w<=ac;++w){o=o toupper(substr(a[w],1,1)) substr(a[w],2)};print o}'`.wiki"
-    echo >> Makefile
-    echo $outname: ../mdoc2wiki.awk $f >> Makefile
-    echo "  awk -f ../mdoc2wiki.awk < $f > $outname" >> Makefile
-        all="$all $outname"
-    done
-done
-echo $all >>Makefile
-cd ..
-
-# Convert all of the manpages to -man format
-(cd man && make)
-# Format all of the manpages to text
-(cd text && make)
-# Format all of the manpages to PDF
-(cd pdf && make)
-# Format all of the manpages to HTML
-(cd html && make)
-# Format all of the manpages to Google Wiki syntax
-(cd wiki && make)

+ 0 - 12
Utilities/cmlibarchive/examples/minitar/README

@@ -1,12 +0,0 @@
-"minitar" is a minimal example of a program that uses libarchive to
-read/write various archive formats.  It's a more ambitious version of
-'untar.c' that includes compile-time options to enable/disable various
-features, including non-tar formats, archive creation, and automatic
-decompression support.
-
-I use this as a test bed to check for "link pollution," ensuring that
-a program using libarchive does not pull in unnecessary code.
-
-The "minitar" program is also a good starting point for anyone who
-wants to use libarchive for their own purposes, as it demonstrates
-basic usage of the library.

+ 0 - 421
Utilities/cmlibarchive/examples/minitar/minitar.c

@@ -1,421 +0,0 @@
-/*-
- * This file is in the public domain.
- * Do with it as you will.
- */
-
-/*-
- * This is a compact "tar" program whose primary goal is small size.
- * Statically linked, it can be very small indeed.  This serves a number
- * of goals:
- *   o a testbed for libarchive (to check for link pollution),
- *   o a useful tool for space-constrained systems (boot floppies, etc),
- *   o a place to experiment with new implementation ideas for bsdtar,
- *   o a small program to demonstrate libarchive usage.
- *
- * Use the following macros to suppress features:
- *   NO_BZIP2 - Implies NO_BZIP2_CREATE and NO_BZIP2_EXTRACT
- *   NO_BZIP2_CREATE - Suppress bzip2 compression support.
- *   NO_BZIP2_EXTRACT - Suppress bzip2 auto-detection and decompression.
- *   NO_COMPRESS - Implies NO_COMPRESS_CREATE and NO_COMPRESS_EXTRACT
- *   NO_COMPRESS_CREATE - Suppress compress(1) compression support
- *   NO_COMPRESS_EXTRACT - Suppress compress(1) auto-detect and decompression.
- *   NO_CREATE - Suppress all archive creation support.
- *   NO_CPIO_EXTRACT - Suppress auto-detect and dearchiving of cpio archives.
- *   NO_GZIP - Implies NO_GZIP_CREATE and NO_GZIP_EXTRACT
- *   NO_GZIP_CREATE - Suppress gzip compression support.
- *   NO_GZIP_EXTRACT - Suppress gzip auto-detection and decompression.
- *   NO_LOOKUP - Try to avoid getpw/getgr routines, which can be very large
- *   NO_TAR_EXTRACT - Suppress tar extraction
- *
- * With all of the above macros defined (except NO_TAR_EXTRACT), you
- * get a very small program that can recognize and extract essentially
- * any uncompressed tar archive.  On FreeBSD 5.1, this minimal program
- * is under 64k, statically linked, which compares rather favorably to
- *         main(){printf("hello, world");}
- * which is over 60k statically linked on the same operating system.
- * Without any of the above macros, you get a static executable of
- * about 180k with a lot of very sophisticated modern features.
- * Obviously, it's trivial to add support for ISO, Zip, mtree,
- * lzma/xz, etc.  Just fill in the appropriate setup calls.
- */
-
-#include <sys/types.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/stat.h>
-
-#include <archive.h>
-#include <archive_entry.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifndef NO_CREATE
-#include "tree.h"
-#endif
-
-/*
- * NO_CREATE implies NO_BZIP2_CREATE and NO_GZIP_CREATE and NO_COMPRESS_CREATE.
- */
-#ifdef NO_CREATE
-#undef NO_BZIP2_CREATE
-#define NO_BZIP2_CREATE
-#undef NO_COMPRESS_CREATE
-#define NO_COMPRESS_CREATE
-#undef NO_GZIP_CREATE
-#define NO_GZIP_CREATE
-#endif
-
-/*
- * The combination of NO_BZIP2_CREATE and NO_BZIP2_EXTRACT is
- * equivalent to NO_BZIP2.
- */
-#ifdef NO_BZIP2_CREATE
-#ifdef NO_BZIP2_EXTRACT
-#undef NO_BZIP2
-#define NO_BZIP2
-#endif
-#endif
-
-#ifdef NO_BZIP2
-#undef NO_BZIP2_EXTRACT
-#define NO_BZIP2_EXTRACT
-#undef NO_BZIP2_CREATE
-#define NO_BZIP2_CREATE
-#endif
-
-/*
- * The combination of NO_COMPRESS_CREATE and NO_COMPRESS_EXTRACT is
- * equivalent to NO_COMPRESS.
- */
-#ifdef NO_COMPRESS_CREATE
-#ifdef NO_COMPRESS_EXTRACT
-#undef NO_COMPRESS
-#define NO_COMPRESS
-#endif
-#endif
-
-#ifdef NO_COMPRESS
-#undef NO_COMPRESS_EXTRACT
-#define NO_COMPRESS_EXTRACT
-#undef NO_COMPRESS_CREATE
-#define NO_COMPRESS_CREATE
-#endif
-
-/*
- * The combination of NO_GZIP_CREATE and NO_GZIP_EXTRACT is
- * equivalent to NO_GZIP.
- */
-#ifdef NO_GZIP_CREATE
-#ifdef NO_GZIP_EXTRACT
-#undef NO_GZIP
-#define NO_GZIP
-#endif
-#endif
-
-#ifdef NO_GZIP
-#undef NO_GZIP_EXTRACT
-#define NO_GZIP_EXTRACT
-#undef NO_GZIP_CREATE
-#define NO_GZIP_CREATE
-#endif
-
-#ifndef NO_CREATE
-static void create(const char *filename, int compress, const char **argv);
-#endif
-static void errmsg(const char *);
-static void extract(const char *filename, int do_extract, int flags);
-static int  copy_data(struct archive *, struct archive *);
-static void msg(const char *);
-static void usage(void);
-
-static int verbose = 0;
-
-int
-main(int argc, const char **argv)
-{
-    const char *filename = NULL;
-    int compress, flags, mode, opt;
-
-    (void)argc;
-    mode = 'x';
-    verbose = 0;
-    compress = '\0';
-    flags = ARCHIVE_EXTRACT_TIME;
-
-    /* Among other sins, getopt(3) pulls in printf(3). */
-    while (*++argv != NULL && **argv == '-') {
-        const char *p = *argv + 1;
-
-        while ((opt = *p++) != '\0') {
-            switch (opt) {
-#ifndef NO_CREATE
-            case 'c':
-                mode = opt;
-                break;
-#endif
-            case 'f':
-                if (*p != '\0')
-                    filename = p;
-                else
-                    filename = *++argv;
-                p += strlen(p);
-                break;
-#ifndef NO_BZIP2_CREATE
-            case 'j':
-                compress = opt;
-                break;
-#endif
-            case 'p':
-                flags |= ARCHIVE_EXTRACT_PERM;
-                flags |= ARCHIVE_EXTRACT_ACL;
-                flags |= ARCHIVE_EXTRACT_FFLAGS;
-                break;
-            case 't':
-                mode = opt;
-                break;
-            case 'v':
-                verbose++;
-                break;
-            case 'x':
-                mode = opt;
-                break;
-#ifndef NO_BZIP2_CREATE
-            case 'y':
-                compress = opt;
-                break;
-#endif
-#ifndef NO_COMPRESS_CREATE
-            case 'Z':
-                compress = opt;
-                break;
-#endif
-#ifndef NO_GZIP_CREATE
-            case 'z':
-                compress = opt;
-                break;
-#endif
-            default:
-                usage();
-            }
-        }
-    }
-
-    switch (mode) {
-#ifndef NO_CREATE
-    case 'c':
-        create(filename, compress, argv);
-        break;
-#endif
-    case 't':
-        extract(filename, 0, flags);
-        break;
-    case 'x':
-        extract(filename, 1, flags);
-        break;
-    }
-
-    return (0);
-}
-
-
-#ifndef NO_CREATE
-static char buff[16384];
-
-static void
-create(const char *filename, int compress, const char **argv)
-{
-    struct archive *a;
-    struct archive *disk;
-    struct archive_entry *entry;
-    ssize_t len;
-    int fd;
-
-    a = archive_write_new();
-    switch (compress) {
-#ifndef NO_BZIP2_CREATE
-    case 'j': case 'y':
-        archive_write_set_compression_bzip2(a);
-        break;
-#endif
-#ifndef NO_COMPRESS_CREATE
-    case 'Z':
-        archive_write_set_compression_compress(a);
-        break;
-#endif
-#ifndef NO_GZIP_CREATE
-    case 'z':
-        archive_write_set_compression_gzip(a);
-        break;
-#endif
-    default:
-        archive_write_set_compression_none(a);
-        break;
-    }
-    archive_write_set_format_ustar(a);
-    if (strcmp(filename, "-") == 0)
-        filename = NULL;
-    archive_write_open_file(a, filename);
-
-    disk = archive_read_disk_new();
-#ifndef NO_LOOKUP
-    archive_read_disk_set_standard_lookup(disk);
-#endif
-    while (*argv != NULL) {
-        struct tree *t = tree_open(*argv);
-        while (tree_next(t)) {
-            entry = archive_entry_new();
-            archive_entry_set_pathname(entry, tree_current_path(t));
-            archive_read_disk_entry_from_file(disk, entry, -1,
-                tree_current_stat(t));
-            if (verbose) {
-                msg("a ");
-                msg(tree_current_path(t));
-            }
-            archive_write_header(a, entry);
-            fd = open(tree_current_access_path(t), O_RDONLY);
-            len = read(fd, buff, sizeof(buff));
-            while (len > 0) {
-                archive_write_data(a, buff, len);
-                len = read(fd, buff, sizeof(buff));
-            }
-            close(fd);
-            archive_entry_free(entry);
-            if (verbose)
-                msg("\n");
-        }
-        argv++;
-    }
-    archive_write_close(a);
-    archive_write_finish(a);
-}
-#endif
-
-static void
-extract(const char *filename, int do_extract, int flags)
-{
-    struct archive *a;
-    struct archive *ext;
-    struct archive_entry *entry;
-    int r;
-
-    a = archive_read_new();
-    ext = archive_write_disk_new();
-    archive_write_disk_set_options(ext, flags);
-#ifndef NO_BZIP2_EXTRACT
-    archive_read_support_compression_bzip2(a);
-#endif
-#ifndef NO_GZIP_EXTRACT
-    archive_read_support_compression_gzip(a);
-#endif
-#ifndef NO_COMPRESS_EXTRACT
-    archive_read_support_compression_compress(a);
-#endif
-#ifndef NO_TAR_EXTRACT
-    archive_read_support_format_tar(a);
-#endif
-#ifndef NO_CPIO_EXTRACT
-    archive_read_support_format_cpio(a);
-#endif
-#ifndef NO_LOOKUP
-    archive_write_disk_set_standard_lookup(ext);
-#endif
-    if (filename != NULL && strcmp(filename, "-") == 0)
-        filename = NULL;
-    if ((r = archive_read_open_file(a, filename, 10240))) {
-        errmsg(archive_error_string(a));
-        errmsg("\n");
-        exit(r);
-    }
-    for (;;) {
-        r = archive_read_next_header(a, &entry);
-        if (r == ARCHIVE_EOF)
-            break;
-        if (r != ARCHIVE_OK) {
-            errmsg(archive_error_string(a));
-            errmsg("\n");
-            exit(1);
-        }
-        if (verbose && do_extract)
-            msg("x ");
-        if (verbose || !do_extract)
-            msg(archive_entry_pathname(entry));
-        if (do_extract) {
-            r = archive_write_header(ext, entry);
-            if (r != ARCHIVE_OK)
-                errmsg(archive_error_string(a));
-            else
-                copy_data(a, ext);
-        }
-        if (verbose || !do_extract)
-            msg("\n");
-    }
-    archive_read_close(a);
-    archive_read_finish(a);
-    exit(0);
-}
-
-static int
-copy_data(struct archive *ar, struct archive *aw)
-{
-    int r;
-    const void *buff;
-    size_t size;
-    off_t offset;
-
-    for (;;) {
-        r = archive_read_data_block(ar, &buff, &size, &offset);
-        if (r == ARCHIVE_EOF) {
-            errmsg(archive_error_string(ar));
-            return (ARCHIVE_OK);
-        }
-        if (r != ARCHIVE_OK)
-            return (r);
-        r = archive_write_data_block(aw, buff, size, offset);
-        if (r != ARCHIVE_OK) {
-            errmsg(archive_error_string(ar));
-            return (r);
-        }
-    }
-}
-
-static void
-msg(const char *m)
-{
-    write(1, m, strlen(m));
-}
-
-static void
-errmsg(const char *m)
-{
-    write(2, m, strlen(m));
-}
-
-static void
-usage(void)
-{
-/* Many program options depend on compile options. */
-    const char *m = "Usage: minitar [-"
-#ifndef NO_CREATE
-        "c"
-#endif
-#ifndef NO_BZIP2
-        "j"
-#endif
-        "tvx"
-#ifndef NO_BZIP2
-        "y"
-#endif
-#ifndef NO_COMPRESS
-        "Z"
-#endif
-#ifndef NO_GZIP
-        "z"
-#endif
-        "] [-f file] [file]\n";
-
-    errmsg(m);
-    exit(1);
-}

+ 0 - 50
Utilities/cmlibarchive/examples/minitar/notes

@@ -1,50 +0,0 @@
-create(const char* filename)
-{
-  struct archive *a;
-  a = archive_write_new();
-// pick a compression type
-  archive_write_set_compression_bzip2(a);
-  archive_write_set_compression_compress(a);
-  archive_write_set_compression_gzip(a);
-  archive_write_set_compression_none(a);
-  
-// what does this do???
-  archive_write_set_format_ustar(a); // is this what we want?
-// maybe this:
-  archive_write_set_format_pax(a);
-
-  archive_write_open_file(a, filename);
-
-  struct archive* disk = archive_read_disk_new();
-  archive_read_disk_set_standard_lookup(disk);
-  while (*argv != NULL)
-    {
-    struct tree *t = tree_open(*argv);
-    while (tree_next(t)) 
-      { 
-      entry = archive_entry_new();
-      archive_entry_set_pathname(entry, tree_current_path(t));
-      archive_read_disk_entry_from_file(disk, entry, -1,
-                                        tree_current_stat(t));
-      if (verbose)
-        {
-        msg("a ");
-        msg(tree_current_path(t));
-        }
-      archive_write_header(a, entry);
-      int fd = open(tree_current_access_path(t), O_RDONLY);
-      char buff[16384];
-      len = read(fd, buff, sizeof(buff));
-      while (len > 0)
-        {
-        archive_write_data(a, buff, len);
-        len = read(fd, buff, sizeof(buff));
-        }
-      close(fd);
-      archive_entry_free(entry);
-      if (verbose)
-        msg("\n");
-      }
-      }
-  
-}

+ 0 - 423
Utilities/cmlibarchive/examples/minitar/tree.c

@@ -1,423 +0,0 @@
-/*-
- * Copyright (c) 2003-2004 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*-
- * There is a single list of "tree_entry" items that represent
- * filesystem objects that require further attention.  Non-directories
- * are not kept in memory: they are pulled from readdir(), returned to
- * the client, then freed as soon as possible.  Any directory entry to
- * be traversed gets pushed onto the stack.
- *
- * There is surprisingly little information that needs to be kept for
- * each item on the stack.  Just the name, depth (represented here as the
- * string length of the parent directory's pathname), and some markers
- * indicating how to get back to the parent (via chdir("..") for a
- * regular dir or via fchdir(2) for a symlink).
- */
-
-#include <sys/stat.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "tree.h"
-
-/*
- * TODO:
- *    1) Loop checking.
- *    3) Arbitrary logical traversals by closing/reopening intermediate fds.
- */
-
-struct tree_entry {
-    struct tree_entry *next;
-    char *name;
-    size_t dirname_length;
-    int fd;
-    int flags;
-};
-
-/* Definitions for tree_entry.flags bitmap. */
-#define isDir 1 /* This entry is a regular directory. */
-#define isDirLink 2 /* This entry is a symbolic link to a directory. */
-#define needsTraversal 4 /* This entry hasn't yet been traversed. */
-
-/*
- * Local data for this package.
- */
-struct tree {
-    struct tree_entry   *stack;
-    DIR *d;
-    int  initialDirFd;
-    int  flags;
-
-    char    *buff;
-    char    *basename;
-    size_t   buff_length;
-    size_t   path_length;
-    size_t   dirname_length;
-
-    int  depth;
-    int  openCount;
-    int  maxOpenCount;
-
-    struct stat lst;
-    struct stat st;
-};
-
-/* Definitions for tree.flags bitmap. */
-#define needsReturn 8  /* Marks first entry as not having been returned yet. */
-#define hasStat 16  /* The st entry is set. */
-#define hasLstat 32 /* The lst entry is set. */
-
-
-#define HAVE_DIRENT_D_NAMLEN 1
-#ifdef HAVE_DIRENT_D_NAMLEN
-/* BSD extension; avoids need for a strlen() call. */
-#define D_NAMELEN(dp)   (dp)->d_namlen
-#else
-#define D_NAMELEN(dp)   (strlen((dp)->d_name))
-#endif
-
-#if 0
-static void
-dumpStack(struct tree *t)
-{
-    struct tree_entry *te;
-
-    printf("\tbuff: %s\n", t->buff);
-    printf("\tpwd: "); fflush(stdout); system("pwd");
-    printf("\tstack:\n");
-    for (te = t->stack; te != NULL; te = te->next) {
-        printf("\t\tte->name: %s %s\n", te->name, te->flags & needsTraversal ? "" : "*");
-    }
-}
-#endif
-
-/*
- * Add a directory path to the current stack.
- */
-static void
-tree_add(struct tree *t, const char *path)
-{
-    struct tree_entry *te;
-
-    te = malloc(sizeof(*te));
-    memset(te, 0, sizeof(*te));
-    te->next = t->stack;
-    t->stack = te;
-    te->fd = -1;
-    te->name = strdup(path);
-    te->flags = needsTraversal;
-    te->dirname_length = t->dirname_length;
-}
-
-/*
- * Append a name to the current path.
- */
-static void
-tree_append(struct tree *t, const char *name, size_t name_length)
-{
-    if (t->buff != NULL)
-        t->buff[t->dirname_length] = '\0';
-
-    /* Resize pathname buffer as needed. */
-    while (name_length + 1 + t->dirname_length >= t->buff_length) {
-        t->buff_length *= 2;
-        if (t->buff_length < 1024)
-            t->buff_length = 1024;
-        t->buff = realloc(t->buff, t->buff_length);
-    }
-    t->basename = t->buff + t->dirname_length;
-    t->path_length = t->dirname_length + name_length;
-    if (t->dirname_length > 0) {
-        *t->basename++ = '/';
-        t->path_length ++;
-    }
-    strcpy(t->basename, name);
-}
-
-/*
- * Open a directory tree for traversal.
- */
-struct tree *
-tree_open(const char *path)
-{
-    struct tree *t;
-
-    t = malloc(sizeof(*t));
-    memset(t, 0, sizeof(*t));
-    tree_append(t, path, strlen(path));
-    t->initialDirFd = open(".", O_RDONLY);
-    /*
-     * During most of the traversal, items are set up and then
-     * returned immediately from tree_next().  That doesn't work
-     * for the very first entry, so we set a flag for this special
-     * case.
-     */
-    t->flags = needsReturn;
-    return (t);
-}
-
-/*
- * We've finished a directory; ascend back to the parent.
- */
-static void
-tree_ascend(struct tree *t)
-{
-    struct tree_entry *te;
-
-    te = t->stack;
-    t->depth--;
-    if (te->flags & isDirLink) {
-        fchdir(te->fd);
-        close(te->fd);
-        t->openCount--;
-    } else {
-        chdir("..");
-    }
-}
-
-/*
- * Pop the working stack.
- */
-static void
-tree_pop(struct tree *t)
-{
-    struct tree_entry *te;
-
-    te = t->stack;
-    t->stack = te->next;
-    t->dirname_length = te->dirname_length;
-    free(te->name);
-    free(te);
-}
-
-/*
- * Get the next item in the tree traversal.
- */
-int
-tree_next(struct tree *t)
-{
-    struct dirent *de = NULL;
-
-    /* Handle the startup case by returning the initial entry. */
-    if (t->flags & needsReturn) {
-        t->flags &= ~needsReturn;
-        return (1);
-    }
-
-    while (t->stack != NULL) {
-        /* If there's an open dir, get the next entry from there. */
-        while (t->d != NULL) {
-            de = readdir(t->d);
-            if (de == NULL) {
-                closedir(t->d);
-                t->d = NULL;
-            } else if (de->d_name[0] == '.'
-                && de->d_name[1] == '\0') {
-                /* Skip '.' */
-            } else if (de->d_name[0] == '.'
-                && de->d_name[1] == '.'
-                && de->d_name[2] == '\0') {
-                /* Skip '..' */
-            } else {
-                /*
-                 * Append the path to the current path
-                 * and return it.
-                 */
-                tree_append(t, de->d_name, D_NAMELEN(de));
-                t->flags &= ~hasLstat;
-                t->flags &= ~hasStat;
-                return (1);
-            }
-        }
-
-        /* If the current dir needs to be traversed, set it up. */
-        if (t->stack->flags & needsTraversal) {
-            tree_append(t, t->stack->name, strlen(t->stack->name));
-            t->stack->flags &= ~needsTraversal;
-            /* If it is a link, set up fd for the ascent. */
-            if (t->stack->flags & isDirLink) {
-                t->stack->fd = open(".", O_RDONLY);
-                t->openCount++;
-                if (t->openCount > t->maxOpenCount)
-                    t->maxOpenCount = t->openCount;
-            }
-            if (chdir(t->stack->name) == 0) {
-                t->depth++;
-                t->dirname_length = t->path_length;
-                t->d = opendir(".");
-            } else
-                tree_pop(t);
-            continue;
-        }
-
-        /* We've done everything necessary for the top stack entry. */
-        tree_ascend(t);
-        tree_pop(t);
-    }
-    return (0);
-}
-
-/*
- * Called by the client to mark the directory just returned from
- * tree_next() as needing to be visited.
- */
-void
-tree_descend(struct tree *t)
-{
-    const struct stat *s = tree_current_lstat(t);
-
-    if (S_ISDIR(s->st_mode)) {
-        tree_add(t, t->basename);
-        t->stack->flags |= isDir;
-    }
-
-    if (S_ISLNK(s->st_mode) && S_ISDIR(tree_current_stat(t)->st_mode)) {
-        tree_add(t, t->basename);
-        t->stack->flags |= isDirLink;
-    }
-}
-
-/*
- * Get the stat() data for the entry just returned from tree_next().
- */
-const struct stat *
-tree_current_stat(struct tree *t)
-{
-    if (!(t->flags & hasStat)) {
-        stat(t->basename, &t->st);
-        t->flags |= hasStat;
-    }
-    return (&t->st);
-}
-
-/*
- * Get the lstat() data for the entry just returned from tree_next().
- */
-const struct stat *
-tree_current_lstat(struct tree *t)
-{
-    if (!(t->flags & hasLstat)) {
-        lstat(t->basename, &t->lst);
-        t->flags |= hasLstat;
-    }
-    return (&t->lst);
-}
-
-/*
- * Return the access path for the entry just returned from tree_next().
- */
-const char *
-tree_current_access_path(struct tree *t)
-{
-    return (t->basename);
-}
-
-/*
- * Return the full path for the entry just returned from tree_next().
- */
-const char *
-tree_current_path(struct tree *t)
-{
-    return (t->buff);
-}
-
-/*
- * Return the length of the path for the entry just returned from tree_next().
- */
-size_t
-tree_current_pathlen(struct tree *t)
-{
-    return (t->path_length);
-}
-
-/*
- * Return the nesting depth of the entry just returned from tree_next().
- */
-int
-tree_current_depth(struct tree *t)
-{
-    return (t->depth);
-}
-
-/*
- * Terminate the traversal and release any resources.
- */
-void
-tree_close(struct tree *t)
-{
-    /* Release anything remaining in the stack. */
-    while (t->stack != NULL)
-        tree_pop(t);
-    if (t->buff)
-        free(t->buff);
-    /* chdir() back to where we started. */
-    if (t->initialDirFd >= 0) {
-        fchdir(t->initialDirFd);
-        close(t->initialDirFd);
-        t->initialDirFd = -1;
-    }
-    free(t);
-}
-
-
-#if 0
-/* Main function for testing. */
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
-    size_t max_path_len = 0;
-    int max_depth = 0;
-
-    system("pwd");
-    while (*++argv) {
-        struct tree *t = tree_open(*argv);
-        while (tree_next(t)) {
-            size_t path_len = tree_current_pathlen(t);
-            int depth = tree_current_depth(t);
-            if (path_len > max_path_len)
-                max_path_len = path_len;
-            if (depth > max_depth)
-                max_depth = depth;
-            printf("%s\n", tree_current_path(t));
-            if (S_ISDIR(tree_current_lstat(t)->st_mode))
-                tree_descend(t); /* Descend into every dir. */
-        }
-        tree_close(t);
-        printf("Max path length: %d\n", max_path_len);
-        printf("Max depth: %d\n", max_depth);
-        printf("Final open count: %d\n", t->openCount);
-        printf("Max open count: %d\n", t->maxOpenCount);
-        fflush(stdout);
-        system("pwd");
-    }
-    return (0);
-}
-#endif

+ 0 - 78
Utilities/cmlibarchive/examples/minitar/tree.h

@@ -1,78 +0,0 @@
-/*-
- * Copyright (c) 2003-2004 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*-
- * A set of routines for traversing directory trees.
- * Similar in concept to the fts library, but with a few
- * important differences:
- *    * Uses less memory.  In particular, fts stores an entire directory
- *      in memory at a time.  This package only keeps enough subdirectory
- *      information in memory to track the traversal.  Information
- *      about non-directories is discarded as soon as possible.
- *    * Supports very deep logical traversals.  The fts package
- *      uses "non-chdir" approach for logical traversals.  This
- *      package does use a chdir approach for logical traversals
- *      and can therefore handle pathnames much longer than
- *      PATH_MAX.
- *    * Supports deep physical traversals "out of the box."
- *      Due to the memory optimizations above, there's no need to
- *      limit dir names to 32k.
- */
-
-#include <sys/stat.h>
-
-struct tree;
-
-struct tree *tree_open(const char *);
-/* Returns TRUE if there is a next entry.  Zero if there is no next entry. */
-int tree_next(struct tree *);
-/* Return information about the current entry. */
-int tree_current_depth(struct tree *);
-/*
- * The current full pathname, length of the full pathname,
- * and a name that can be used to access the file.
- * Because tree does use chdir extensively, the access path is
- * almost never the same as the full current path.
- */
-const char *tree_current_path(struct tree *);
-size_t tree_current_pathlen(struct tree *);
-const char *tree_current_access_path(struct tree *);
-/*
- * Request the lstat() or stat() data for the current path.
- * Since the tree package needs to do some of this anyway,
- * you should take advantage of it here if you need it.
- */
-const struct stat *tree_current_stat(struct tree *);
-const struct stat *tree_current_lstat(struct tree *);
-/*
- * Request that current entry be visited.  If you invoke it on every
- * directory, you'll get a physical traversal.  This is ignored if the
- * current entry isn't a directory or a link to a directory.  So, if
- * you invoke this on every returned path, you'll get a full logical
- * traversal.
- */
-void tree_descend(struct tree *);
-void tree_close(struct tree *);

+ 0 - 113
Utilities/cmlibarchive/examples/tarfilter.c

@@ -1,113 +0,0 @@
-/*
- * This file is in the public domain.
- *
- * Feel free to use it as you wish.
- */
-
-/*
- * This example program reads an archive from stdin (which can be in
- * any format recognized by libarchive) and writes certain entries to
- * an uncompressed ustar archive on stdout.  This is a template for
- * many kinds of archive manipulation: converting formats, resetting
- * ownership, inserting entries, removing entries, etc.
- *
- * To compile:
- * gcc -Wall -o tarfilter tarfilter.c -larchive -lz -lbz2
- */
-
-#include <sys/stat.h>
-#include <archive.h>
-#include <archive_entry.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void
-die(char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    vfprintf(stderr, fmt, ap);
-    va_end(ap);
-    fprintf(stderr, "\n");
-    exit(1);
-}
-
-int
-main(int argc, char **argv)
-{
-    char buff[8192];
-    ssize_t len;
-    int r;
-    mode_t m;
-    struct archive *ina;
-    struct archive *outa;
-    struct archive_entry *entry;
-
-    /* Read an archive from stdin, with automatic format detection. */
-    ina = archive_read_new();
-    if (ina == NULL)
-        die("Couldn't create archive reader.");
-    if (archive_read_support_compression_all(ina) != ARCHIVE_OK)
-        die("Couldn't enable decompression");
-    if (archive_read_support_format_all(ina) != ARCHIVE_OK)
-        die("Couldn't enable read formats");
-    if (archive_read_open_fd(ina, 0, 10240) != ARCHIVE_OK)
-        die("Couldn't open input archive");
-
-    /* Write an uncompressed ustar archive to stdout. */
-    outa = archive_write_new();
-    if (outa == NULL)
-        die("Couldn't create archive writer.");
-    if (archive_write_set_compression_none(outa) != ARCHIVE_OK)
-        die("Couldn't enable compression");
-    if (archive_write_set_format_ustar(outa) != ARCHIVE_OK)
-        die("Couldn't set output format");
-    if (archive_write_open_fd(outa, 1) != ARCHIVE_OK)
-        die("Couldn't open output archive");
-
-    /* Examine each entry in the input archive. */
-    while ((r = archive_read_next_header(ina, &entry)) == ARCHIVE_OK) {
-        fprintf(stderr, "%s: ", archive_entry_pathname(entry));
-
-        /* Skip anything that isn't a regular file. */
-        if (!S_ISREG(archive_entry_mode(entry))) {
-            fprintf(stderr, "skipped\n");
-            continue;
-        }
-
-        /* Make everything owned by root/wheel. */
-        archive_entry_set_uid(entry, 0);
-        archive_entry_set_uname(entry, "root");
-        archive_entry_set_gid(entry, 0);
-        archive_entry_set_gname(entry, "wheel");
-
-        /* Make everything permission 0744, strip SUID, etc. */
-        m = archive_entry_mode(entry);
-        archive_entry_set_mode(entry, (m & ~07777) | 0744);
-
-        /* Copy input entries to output archive. */
-        if (archive_write_header(outa, entry) != ARCHIVE_OK)
-            die("Error writing output archive");
-        if (archive_entry_size(entry) > 0) {
-            len = archive_read_data(ina, buff, sizeof(buff));
-            while (len > 0) {
-                if (archive_write_data(outa, buff, len) != len)
-                    die("Error writing output archive");
-                len = archive_read_data(ina, buff, sizeof(buff));
-            }
-            if (len < 0)
-                die("Error reading input archive");
-        }
-        fprintf(stderr, "copied\n");
-    }
-    if (r != ARCHIVE_EOF)
-        die("Error reading archive");
-    /* Close the archives.  */
-    if (archive_read_finish(ina) != ARCHIVE_OK)
-        die("Error closing input archive");
-    if (archive_write_finish(outa) != ARCHIVE_OK)
-        die("Error closing output archive");
-    return (0);
-}

+ 0 - 262
Utilities/cmlibarchive/examples/untar.c

@@ -1,262 +0,0 @@
-/*
- * This file is in the public domain.
- * Use it as you wish.
- */
-
-/*
- * This is a compact tar extraction program using libarchive whose
- * primary goal is small executable size.  Statically linked, it can
- * be very small, depending in large part on how cleanly factored your
- * system libraries are.  Note that this uses the standard libarchive,
- * without any special recompilation.  The only functional concession
- * is that this program uses the uid/gid from the archive instead of
- * doing uname/gname lookups.  (Add a call to
- * archive_write_disk_set_standard_lookup() to enable uname/gname
- * lookups, but be aware that this can add 500k or more to a static
- * executable, depending on the system libraries, since user/group
- * lookups frequently pull in password, YP/LDAP, networking, and DNS
- * resolver libraries.)
- *
- * To build:
- * $ gcc -static -Wall -o untar untar.c -larchive
- * $ strip untar
- *
- * NOTE: On some systems, you may need to add additional flags
- * to ensure that untar.c is compiled the same way as libarchive
- * was compiled.  In particular, Linux users will probably
- * have to add -D_FILE_OFFSET_BITS=64 to the command line above.
- *
- * For fun, statically compile the following simple hello.c program
- * using the same flags as for untar and compare the size:
- *
- * #include <stdio.h>
- * int main(int argc, char **argv) {
- *    printf("hello, world\n");
- *    return(0);
- * }
- *
- * You may be even more surprised by the compiled size of true.c listed here:
- *
- * int main(int argc, char **argv) {
- *    return (0);
- * }
- *
- * On a slightly customized FreeBSD 5 system that I used around
- * 2005, hello above compiled to 89k compared to untar of 69k.  So at
- * that time, libarchive's tar reader and extract-to-disk routines
- * compiled to less code than printf().
- *
- * On my FreeBSD development system today (August, 2009):
- *  hello: 195024 bytes
- *  true: 194912 bytes
- *  untar: 259924 bytes
- */
-
-#include <sys/types.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/stat.h>
-
-#include <archive.h>
-#include <archive_entry.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static void errmsg(const char *);
-static void extract(const char *filename, int do_extract, int flags);
-static void fail(const char *, const char *, int);
-static int  copy_data(struct archive *, struct archive *);
-static void msg(const char *);
-static void usage(void);
-static void warn(const char *, const char *);
-
-static int verbose = 0;
-
-int
-main(int argc, const char **argv)
-{
-    const char *filename = NULL;
-    int compress, flags, mode, opt;
-
-    (void)argc;
-    mode = 'x';
-    verbose = 0;
-    compress = '\0';
-    flags = ARCHIVE_EXTRACT_TIME;
-
-    /* Among other sins, getopt(3) pulls in printf(3). */
-    while (*++argv != NULL && **argv == '-') {
-        const char *p = *argv + 1;
-
-        while ((opt = *p++) != '\0') {
-            switch (opt) {
-            case 'f':
-                if (*p != '\0')
-                    filename = p;
-                else
-                    filename = *++argv;
-                p += strlen(p);
-                break;
-            case 'p':
-                flags |= ARCHIVE_EXTRACT_PERM;
-                flags |= ARCHIVE_EXTRACT_ACL;
-                flags |= ARCHIVE_EXTRACT_FFLAGS;
-                break;
-            case 't':
-                mode = opt;
-                break;
-            case 'v':
-                verbose++;
-                break;
-            case 'x':
-                mode = opt;
-                break;
-            default:
-                usage();
-            }
-        }
-    }
-
-    switch (mode) {
-    case 't':
-        extract(filename, 0, flags);
-        break;
-    case 'x':
-        extract(filename, 1, flags);
-        break;
-    }
-
-    return (0);
-}
-
-
-static void
-extract(const char *filename, int do_extract, int flags)
-{
-    struct archive *a;
-    struct archive *ext;
-    struct archive_entry *entry;
-    int r;
-
-    a = archive_read_new();
-    ext = archive_write_disk_new();
-    archive_write_disk_set_options(ext, flags);
-    /*
-     * Note: archive_write_disk_set_standard_lookup() is useful
-     * here, but it requires library routines that can add 500k or
-     * more to a static executable.
-     */
-    archive_read_support_format_tar(a);
-    /*
-     * On my system, enabling other archive formats adds 20k-30k
-     * each.  Enabling gzip decompression adds about 20k.
-     * Enabling bzip2 is more expensive because the libbz2 library
-     * isn't very well factored.
-     */
-    if (filename != NULL && strcmp(filename, "-") == 0)
-        filename = NULL;
-    if ((r = archive_read_open_file(a, filename, 10240)))
-        fail("archive_read_open_file()",
-            archive_error_string(a), r);
-    for (;;) {
-        r = archive_read_next_header(a, &entry);
-        if (r == ARCHIVE_EOF)
-            break;
-        if (r != ARCHIVE_OK)
-            fail("archive_read_next_header()",
-                archive_error_string(a), 1);
-        if (verbose && do_extract)
-            msg("x ");
-        if (verbose || !do_extract)
-            msg(archive_entry_pathname(entry));
-        if (do_extract) {
-            r = archive_write_header(ext, entry);
-            if (r != ARCHIVE_OK)
-                warn("archive_write_header()",
-                    archive_error_string(ext));
-            else {
-                copy_data(a, ext);
-                r = archive_write_finish_entry(ext);
-                if (r != ARCHIVE_OK)
-                    fail("archive_write_finish_entry()",
-                        archive_error_string(ext), 1);
-            }
-
-        }
-        if (verbose || !do_extract)
-            msg("\n");
-    }
-    archive_read_close(a);
-    archive_read_finish(a);
-    exit(0);
-}
-
-static int
-copy_data(struct archive *ar, struct archive *aw)
-{
-    int r;
-    const void *buff;
-    size_t size;
-    off_t offset;
-
-    for (;;) {
-        r = archive_read_data_block(ar, &buff, &size, &offset);
-        if (r == ARCHIVE_EOF)
-            return (ARCHIVE_OK);
-        if (r != ARCHIVE_OK)
-            return (r);
-        r = archive_write_data_block(aw, buff, size, offset);
-        if (r != ARCHIVE_OK) {
-            warn("archive_write_data_block()",
-                archive_error_string(aw));
-            return (r);
-        }
-    }
-}
-
-/*
- * These reporting functions use low-level I/O; on some systems, this
- * is a significant code reduction.  Of course, on many server and
- * desktop operating systems, malloc() and even crt rely on printf(),
- * which in turn pulls in most of the rest of stdio, so this is not an
- * optimization at all there.  (If you're going to pay 100k or more
- * for printf() anyway, you may as well use it!)
- */
-static void
-msg(const char *m)
-{
-    write(1, m, strlen(m));
-}
-
-static void
-errmsg(const char *m)
-{
-    write(2, m, strlen(m));
-}
-
-static void
-warn(const char *f, const char *m)
-{
-    errmsg(f);
-    errmsg(" failed: ");
-    errmsg(m);
-    errmsg("\n");
-}
-
-static void
-fail(const char *f, const char *m, int r)
-{
-    warn(f, m);
-    exit(r);
-}
-
-static void
-usage(void)
-{
-    const char *m = "Usage: untar [-tvx] [-f file] [file]\n";
-    errmsg(m);
-    exit(1);
-}

+ 55 - 49
Utilities/cmlibarchive/libarchive/CMakeLists.txt

@@ -13,23 +13,34 @@ SET(include_HEADERS
 
 # Sources and private headers
 SET(libarchive_SOURCES
+  archive_acl.c
   archive_check_magic.c
+  archive_crypto.c
+  archive_crypto_private.h
   archive_endian.h
   archive_entry.c
   archive_entry.h
   archive_entry_copy_stat.c
-#  archive_entry_copy_bhfi.c
   archive_entry_link_resolver.c
+  archive_entry_locale.h
   archive_entry_private.h
+  archive_entry_sparse.c
   archive_entry_stat.c
   archive_entry_strmode.c
   archive_entry_xattr.c
+  archive_options.c
+  archive_options_private.h
   archive_platform.h
+  archive_ppmd_private.h
+  archive_ppmd7.c
+  archive_ppmd7_private.h
   archive_private.h
+  archive_rb.c
+  archive_rb.h
   archive_read.c
   archive_read_data_into_fd.c
-  archive_read_disk.c
   archive_read_disk_entry_from_file.c
+  archive_read_disk_posix.c
   archive_read_disk_private.h
   archive_read_disk_set_standard_lookup.c
   archive_read_extract.c
@@ -38,29 +49,39 @@ SET(libarchive_SOURCES
   archive_read_open_filename.c
   archive_read_open_memory.c
   archive_read_private.h
-  archive_read_support_compression_all.c
-  archive_read_support_compression_bzip2.c
-  archive_read_support_compression_compress.c
-  archive_read_support_compression_gzip.c
-  archive_read_support_compression_none.c
-  archive_read_support_compression_program.c
-  archive_read_support_compression_xz.c
+  archive_read_set_options.c
+  archive_read_support_filter_all.c
+  archive_read_support_filter_bzip2.c
+  archive_read_support_filter_compress.c
+  archive_read_support_filter_gzip.c
+  archive_read_support_filter_none.c
+  archive_read_support_filter_program.c
+  archive_read_support_filter_rpm.c
+  archive_read_support_filter_uu.c
+  archive_read_support_filter_xz.c
+  archive_read_support_format_7zip.c
   archive_read_support_format_all.c
   archive_read_support_format_ar.c
+  archive_read_support_format_by_code.c
+  archive_read_support_format_cab.c
   archive_read_support_format_cpio.c
   archive_read_support_format_empty.c
   archive_read_support_format_iso9660.c
+  archive_read_support_format_lha.c
   archive_read_support_format_mtree.c
+  archive_read_support_format_rar.c
   archive_read_support_format_raw.c
   archive_read_support_format_tar.c
+  archive_read_support_format_xar.c
   archive_read_support_format_zip.c
   archive_string.c
   archive_string.h
+  archive_string_composition.h
   archive_string_sprintf.c
   archive_util.c
   archive_virtual.c
   archive_write.c
-  archive_write_disk.c
+  archive_write_disk_posix.c
   archive_write_disk_private.h
   archive_write_disk_set_standard_lookup.c
   archive_write_private.h
@@ -68,22 +89,27 @@ SET(libarchive_SOURCES
   archive_write_open_file.c
   archive_write_open_filename.c
   archive_write_open_memory.c
-  archive_write_set_compression_bzip2.c
-  archive_write_set_compression_compress.c
-  archive_write_set_compression_gzip.c
-  archive_write_set_compression_none.c
-  archive_write_set_compression_program.c
-  archive_write_set_compression_xz.c
+  archive_write_add_filter_bzip2.c
+  archive_write_add_filter_compress.c
+  archive_write_add_filter_gzip.c
+  archive_write_add_filter_none.c
+  archive_write_add_filter_program.c
+  archive_write_add_filter_xz.c
   archive_write_set_format.c
+  archive_write_set_format_7zip.c
   archive_write_set_format_ar.c
   archive_write_set_format_by_name.c
   archive_write_set_format_cpio.c
   archive_write_set_format_cpio_newc.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_shar.c
   archive_write_set_format_ustar.c
+  archive_write_set_format_xar.c
   archive_write_set_format_zip.c
+  archive_write_set_options.c
   filter_fork.c
   filter_fork.h
 )
@@ -91,11 +117,19 @@ SET(libarchive_SOURCES
 # Man pages
 SET(libarchive_MANS
   archive_entry.3
+  archive_entry_acl.3
+  archive_entry_linkify.3
+  archive_entry_paths.3
+  archive_entry_perms.3
+  archive_entry_stat.3
+  archive_entry_time.3
   archive_read.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
   cpio.5
   libarchive.3
   libarchive_internals.3
@@ -106,41 +140,13 @@ SET(libarchive_MANS
 
 IF(WIN32 AND NOT CYGWIN)
   LIST(APPEND libarchive_SOURCES archive_entry_copy_bhfi.c)
+  LIST(APPEND libarchive_SOURCES archive_read_disk_windows.c)
   LIST(APPEND libarchive_SOURCES archive_windows.c)
   LIST(APPEND libarchive_SOURCES archive_windows.h)
+  LIST(APPEND libarchive_SOURCES archive_write_disk_windows.c)
   LIST(APPEND libarchive_SOURCES filter_fork_windows.c)
 ENDIF(WIN32 AND NOT CYGWIN)
 
-IF(BUILD_ARCHIVE_WITHIN_CMAKE)
-  # when building inside the CMake tree only use static
-  # and call the library cmlibarchive
-  ADD_LIBRARY(cmlibarchive STATIC ${libarchive_SOURCES} ${include_HEADERS})
-  TARGET_LINK_LIBRARIES(cmlibarchive ${ADDITIONAL_LIBS})
-ELSE()
-  # Libarchive is a shared library
-  ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS})
-  TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS})
-  SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION})
-  SET_TARGET_PROPERTIES(archive PROPERTIES
-    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-  
-  # archive_static is a static library
-  ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS})
-  SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS
-    LIBARCHIVE_STATIC)
-  SET_TARGET_PROPERTIES(archive_static PROPERTIES
-    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-  #  On Posix systems, libarchive.so and libarchive.a can co-exist.
-  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)
-  ADD_SUBDIRECTORY(test)
-ENDIF()
+# CMake needs just one static "cmlibarchive" library.
+ADD_LIBRARY(cmlibarchive STATIC ${libarchive_SOURCES} ${include_HEADERS})
+TARGET_LINK_LIBRARIES(cmlibarchive ${ADDITIONAL_LIBS})

+ 450 - 363
Utilities/cmlibarchive/libarchive/archive.h

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,11 @@
  */
 
 #ifndef ARCHIVE_H_INCLUDED
-#define ARCHIVE_H_INCLUDED
+#define	ARCHIVE_H_INCLUDED
+
+#include <sys/stat.h>
+#include <stddef.h>  /* for wchar_t */
+#include <stdio.h> /* For FILE * */
 
 /*
  * Note: archive.h is for use outside of libarchive; the configuration
@@ -36,46 +40,46 @@
  * platform macros.
  */
 #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
-# define __LA_STDINT_H <stdint.h>
-#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(__osf__)
-# define __LA_STDINT_H <inttypes.h>
+# include <stdint.h>
+#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
+# include <inttypes.h>
 #endif
 
-#include <sys/stat.h>
-#include <sys/types.h>  /* Linux requires this for off_t */
-#ifdef __LA_STDINT_H
-# include __LA_STDINT_H /* int64_t, etc. */
+/* Borland symbols are case-insensitive.  This workaround only works
+   within CMake because we do not mix compilers.  */
+#if defined(__BORLANDC__)
+# define archive_read_open_FILE archive_read_open_FILE_
+# define archive_write_open_FILE archive_write_open_FILE_
 #endif
-#include <stdio.h> /* For FILE * */
 
 /* 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
+# define	__LA_INT64_T	__int64
 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
-#  define __LA_SSIZE_T ssize_t
+#  define	__LA_SSIZE_T	ssize_t
 # elif defined(_WIN64)
-#  define   __LA_SSIZE_T    __int64
+#  define	__LA_SSIZE_T	__int64
 # else
-#  define   __LA_SSIZE_T    long
+#  define	__LA_SSIZE_T	long
 # endif
 # if defined(__BORLANDC__)
-#  define __LA_UID_T uid_t
-#  define __LA_GID_T gid_t
+#  define	__LA_UID_T	uid_t
+#  define	__LA_GID_T	gid_t
 # else
-#  define __LA_UID_T short
-#  define __LA_GID_T short
+#  define	__LA_UID_T	short
+#  define	__LA_GID_T	short
 # endif
 #else
-#include <unistd.h>  /* ssize_t, uid_t, and gid_t */
-#if defined(__osf__)
-#  define __LA_INT64_T    long long
-#else
-#  define __LA_INT64_T    int64_t
-#endif
-#define __LA_SSIZE_T    ssize_t
-#define __LA_UID_T  uid_t
-#define __LA_GID_T  gid_t
+# include <unistd.h>  /* ssize_t, uid_t, and gid_t */
+# if defined(_SCO_DS) || defined(__osf__)
+#  define	__LA_INT64_T	long long
+# else
+#  define	__LA_INT64_T	int64_t
+# endif
+# define	__LA_SSIZE_T	ssize_t
+# define	__LA_UID_T	uid_t
+# define	__LA_GID_T	gid_t
 #endif
 
 /*
@@ -86,15 +90,15 @@
 #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
 # ifdef __LIBARCHIVE_BUILD
 #  ifdef __GNUC__
-#   define __LA_DECL    __attribute__((dllexport)) extern
+#   define __LA_DECL	__attribute__((dllexport)) extern
 #  else
-#   define __LA_DECL    __declspec(dllexport)
+#   define __LA_DECL	__declspec(dllexport)
 #  endif
 # else
 #  ifdef __GNUC__
-#   define __LA_DECL    __attribute__((dllimport)) extern
+#   define __LA_DECL
 #  else
-#   define __LA_DECL    __declspec(dllimport)
+#   define __LA_DECL	__declspec(dllimport)
 #  endif
 # endif
 #else
@@ -102,6 +106,13 @@
 # define __LA_DECL
 #endif
 
+#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
+#define	__LA_PRINTF(fmtarg, firstvararg) \
+	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+#else
+#define	__LA_PRINTF(fmtarg, firstvararg)	/* nothing */
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -120,49 +131,17 @@ extern "C" {
  * 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 >= 2012108.
- *
- * This single-number format was introduced with libarchive 1.9.0 in
- * the libarchive 1.x family and libarchive 2.2.4 in the libarchive
- * 2.x family.  The following may be useful if you really want to do
- * feature detection for earlier libarchive versions (which defined
- * ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead):
- *
- * #ifndef ARCHIVE_VERSION_NUMBER
- * #define ARCHIVE_VERSION_NUMBER   \
- *             (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
- * #endif
+ * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  */
-#define ARCHIVE_VERSION_NUMBER 2007900
-__LA_DECL int       archive_version_number(void);
+/* Note: Compiler will complain if this does not match archive_entry.h! */
+#define	ARCHIVE_VERSION_NUMBER 3000002
+__LA_DECL int		archive_version_number(void);
 
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define ARCHIVE_VERSION_STRING "libarchive 2.7.900a"
-__LA_DECL const char *  archive_version_string(void);
-
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/*
- * Deprecated; these are older names that will be removed in favor of
- * the simpler definitions above.
- */
-#define ARCHIVE_VERSION_STAMP   ARCHIVE_VERSION_NUMBER
-__LA_DECL int       archive_version_stamp(void);
-#define ARCHIVE_LIBRARY_VERSION ARCHIVE_VERSION_STRING
-__LA_DECL const char *  archive_version(void);
-#define ARCHIVE_API_VERSION (ARCHIVE_VERSION_NUMBER / 1000000)
-__LA_DECL int       archive_api_version(void);
-#define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_NUMBER / 1000) % 1000)
-__LA_DECL int       archive_api_feature(void);
-#endif
-
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* This should never have been here in the first place. */
-/* Legacy of old tar assumptions, will be removed in libarchive 3.0. */
-#define ARCHIVE_BYTES_PER_RECORD      512
-#define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240
-#endif
+#define	ARCHIVE_VERSION_STRING "libarchive 3.0.2"
+__LA_DECL const char *	archive_version_string(void);
 
 /* Declare our basic types. */
 struct archive;
@@ -173,14 +152,14 @@ struct archive_entry;
  * to retrieve details.  Unless specified otherwise, all functions
  * that return 'int' use these codes.
  */
-#define ARCHIVE_EOF   1 /* Found end of archive. */
-#define ARCHIVE_OK    0 /* Operation was successful. */
-#define ARCHIVE_RETRY   (-10)   /* Retry might succeed. */
-#define ARCHIVE_WARN    (-20)   /* Partial success. */
+#define	ARCHIVE_EOF	  1	/* Found end of archive. */
+#define	ARCHIVE_OK	  0	/* Operation was successful. */
+#define	ARCHIVE_RETRY	(-10)	/* Retry might succeed. */
+#define	ARCHIVE_WARN	(-20)	/* Partial success. */
 /* For example, if write_header "fails", then you can't push data. */
-#define ARCHIVE_FAILED  (-25)   /* Current operation cannot complete. */
+#define	ARCHIVE_FAILED	(-25)	/* Current operation cannot complete. */
 /* But if write_header is "fatal," then this archive is dead and useless. */
-#define ARCHIVE_FATAL   (-30)   /* No more operations are possible. */
+#define	ARCHIVE_FATAL	(-30)	/* No more operations are possible. */
 
 /*
  * As far as possible, archive_errno returns standard platform errno codes.
@@ -190,11 +169,11 @@ struct archive_entry;
  * platform-dependent error code.
  */
 /* Unrecognized or invalid file format. */
-/* #define  ARCHIVE_ERRNO_FILE_FORMAT */
+/* #define	ARCHIVE_ERRNO_FILE_FORMAT */
 /* Illegal usage of the library. */
-/* #define  ARCHIVE_ERRNO_PROGRAMMER_ERROR */
+/* #define	ARCHIVE_ERRNO_PROGRAMMER_ERROR */
 /* Unknown or unclassified error. */
-/* #define  ARCHIVE_ERRNO_MISC */
+/* #define	ARCHIVE_ERRNO_MISC */
 
 /*
  * Callbacks are invoked to automatically read/skip/write/open/close the
@@ -204,49 +183,59 @@ struct archive_entry;
  */
 
 /* Returns pointer and size of next block of data from 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 */
-#if ARCHIVE_VERSION_NUMBER < 2000000
-/* Libarchive 1.0 used ssize_t for the return, which is only 32 bits
- * on most 32-bit platforms; not large enough. */
-typedef __LA_SSIZE_T    archive_skip_callback(struct archive *,
-                void *_client_data, size_t request);
-#elif ARCHIVE_VERSION_NUMBER < 3000000
-/* Libarchive 2.0 used off_t here, but that is a bad idea on Linux and a
- * few other platforms where off_t varies with build settings. */
-typedef off_t       archive_skip_callback(struct archive *,
-                void *_client_data, off_t request);
-#else
-/* Libarchive 3.0 uses int64_t here, which is actually guaranteed to be
- * 64 bits on every platform. */
-typedef __LA_INT64_T    archive_skip_callback(struct archive *,
-                void *_client_data, __LA_INT64_T request);
-#endif
+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.
+ * This may skip fewer bytes than requested; it may even skip zero bytes.
+ * 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);
+
+/* 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);
 
 /* Returns size actually written, zero on EOF, -1 on error. */
-typedef __LA_SSIZE_T    archive_write_callback(struct archive *,
-                void *_client_data,
-                const void *_buffer, size_t _length);
+typedef __LA_SSIZE_T	archive_write_callback(struct archive *,
+			    void *_client_data,
+			    const void *_buffer, size_t _length);
 
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* Open callback is actually never needed; remove it in libarchive 3.0. */
-typedef int archive_open_callback(struct archive *, void *_client_data);
-#endif
+typedef int	archive_open_callback(struct archive *, void *_client_data);
 
-typedef int archive_close_callback(struct archive *, void *_client_data);
+typedef int	archive_close_callback(struct archive *, void *_client_data);
 
 /*
- * Codes for archive_compression.
+ * Codes to identify various stream filters.
  */
-#define ARCHIVE_COMPRESSION_NONE    0
-#define ARCHIVE_COMPRESSION_GZIP    1
-#define ARCHIVE_COMPRESSION_BZIP2   2
-#define ARCHIVE_COMPRESSION_COMPRESS    3
-#define ARCHIVE_COMPRESSION_PROGRAM 4
-#define ARCHIVE_COMPRESSION_LZMA    5
-#define ARCHIVE_COMPRESSION_XZ      6
+#define	ARCHIVE_FILTER_NONE	0
+#define	ARCHIVE_FILTER_GZIP	1
+#define	ARCHIVE_FILTER_BZIP2	2
+#define	ARCHIVE_FILTER_COMPRESS	3
+#define	ARCHIVE_FILTER_PROGRAM	4
+#define	ARCHIVE_FILTER_LZMA	5
+#define	ARCHIVE_FILTER_XZ	6
+#define	ARCHIVE_FILTER_UU	7
+#define	ARCHIVE_FILTER_RPM	8
+#define	ARCHIVE_FILTER_LZIP	9
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+#define	ARCHIVE_COMPRESSION_NONE	ARCHIVE_FILTER_NONE
+#define	ARCHIVE_COMPRESSION_GZIP	ARCHIVE_FILTER_GZIP
+#define	ARCHIVE_COMPRESSION_BZIP2	ARCHIVE_FILTER_BZIP2
+#define	ARCHIVE_COMPRESSION_COMPRESS	ARCHIVE_FILTER_COMPRESS
+#define	ARCHIVE_COMPRESSION_PROGRAM	ARCHIVE_FILTER_PROGRAM
+#define	ARCHIVE_COMPRESSION_LZMA	ARCHIVE_FILTER_LZMA
+#define	ARCHIVE_COMPRESSION_XZ		ARCHIVE_FILTER_XZ
+#define	ARCHIVE_COMPRESSION_UU		ARCHIVE_FILTER_UU
+#define	ARCHIVE_COMPRESSION_RPM		ARCHIVE_FILTER_RPM
+#define	ARCHIVE_COMPRESSION_LZIP	ARCHIVE_FILTER_LZIP
+#endif
 
 /*
  * Codes returned by archive_format.
@@ -260,34 +249,40 @@ typedef int archive_close_callback(struct archive *, void *_client_data);
  * will change the format code to indicate the extended format that
  * was used).  In other cases, it's because different tools have
  * modified the archive and so different parts of the archive
- * actually have slightly different formts.  (Both tar and cpio store
+ * actually have slightly different formats.  (Both tar and cpio store
  * format codes in each entry, so it is quite possible for each
  * entry to be in a different format.)
  */
-#define ARCHIVE_FORMAT_BASE_MASK        0xff0000
-#define ARCHIVE_FORMAT_CPIO         0x10000
-#define ARCHIVE_FORMAT_CPIO_POSIX       (ARCHIVE_FORMAT_CPIO | 1)
-#define ARCHIVE_FORMAT_CPIO_BIN_LE      (ARCHIVE_FORMAT_CPIO | 2)
-#define ARCHIVE_FORMAT_CPIO_BIN_BE      (ARCHIVE_FORMAT_CPIO | 3)
-#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC      (ARCHIVE_FORMAT_CPIO | 4)
-#define ARCHIVE_FORMAT_CPIO_SVR4_CRC        (ARCHIVE_FORMAT_CPIO | 5)
-#define ARCHIVE_FORMAT_SHAR         0x20000
-#define ARCHIVE_FORMAT_SHAR_BASE        (ARCHIVE_FORMAT_SHAR | 1)
-#define ARCHIVE_FORMAT_SHAR_DUMP        (ARCHIVE_FORMAT_SHAR | 2)
-#define ARCHIVE_FORMAT_TAR          0x30000
-#define ARCHIVE_FORMAT_TAR_USTAR        (ARCHIVE_FORMAT_TAR | 1)
-#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE  (ARCHIVE_FORMAT_TAR | 2)
-#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED   (ARCHIVE_FORMAT_TAR | 3)
-#define ARCHIVE_FORMAT_TAR_GNUTAR       (ARCHIVE_FORMAT_TAR | 4)
-#define ARCHIVE_FORMAT_ISO9660          0x40000
-#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE    (ARCHIVE_FORMAT_ISO9660 | 1)
-#define ARCHIVE_FORMAT_ZIP          0x50000
-#define ARCHIVE_FORMAT_EMPTY            0x60000
-#define ARCHIVE_FORMAT_AR           0x70000
-#define ARCHIVE_FORMAT_AR_GNU           (ARCHIVE_FORMAT_AR | 1)
-#define ARCHIVE_FORMAT_AR_BSD           (ARCHIVE_FORMAT_AR | 2)
-#define ARCHIVE_FORMAT_MTREE            0x80000
-#define ARCHIVE_FORMAT_RAW          0x90000
+#define	ARCHIVE_FORMAT_BASE_MASK		0xff0000
+#define	ARCHIVE_FORMAT_CPIO			0x10000
+#define	ARCHIVE_FORMAT_CPIO_POSIX		(ARCHIVE_FORMAT_CPIO | 1)
+#define	ARCHIVE_FORMAT_CPIO_BIN_LE		(ARCHIVE_FORMAT_CPIO | 2)
+#define	ARCHIVE_FORMAT_CPIO_BIN_BE		(ARCHIVE_FORMAT_CPIO | 3)
+#define	ARCHIVE_FORMAT_CPIO_SVR4_NOCRC		(ARCHIVE_FORMAT_CPIO | 4)
+#define	ARCHIVE_FORMAT_CPIO_SVR4_CRC		(ARCHIVE_FORMAT_CPIO | 5)
+#define	ARCHIVE_FORMAT_CPIO_AFIO_LARGE		(ARCHIVE_FORMAT_CPIO | 6)
+#define	ARCHIVE_FORMAT_SHAR			0x20000
+#define	ARCHIVE_FORMAT_SHAR_BASE		(ARCHIVE_FORMAT_SHAR | 1)
+#define	ARCHIVE_FORMAT_SHAR_DUMP		(ARCHIVE_FORMAT_SHAR | 2)
+#define	ARCHIVE_FORMAT_TAR			0x30000
+#define	ARCHIVE_FORMAT_TAR_USTAR		(ARCHIVE_FORMAT_TAR | 1)
+#define	ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE	(ARCHIVE_FORMAT_TAR | 2)
+#define	ARCHIVE_FORMAT_TAR_PAX_RESTRICTED	(ARCHIVE_FORMAT_TAR | 3)
+#define	ARCHIVE_FORMAT_TAR_GNUTAR		(ARCHIVE_FORMAT_TAR | 4)
+#define	ARCHIVE_FORMAT_ISO9660			0x40000
+#define	ARCHIVE_FORMAT_ISO9660_ROCKRIDGE	(ARCHIVE_FORMAT_ISO9660 | 1)
+#define	ARCHIVE_FORMAT_ZIP			0x50000
+#define	ARCHIVE_FORMAT_EMPTY			0x60000
+#define	ARCHIVE_FORMAT_AR			0x70000
+#define	ARCHIVE_FORMAT_AR_GNU			(ARCHIVE_FORMAT_AR | 1)
+#define	ARCHIVE_FORMAT_AR_BSD			(ARCHIVE_FORMAT_AR | 2)
+#define	ARCHIVE_FORMAT_MTREE			0x80000
+#define	ARCHIVE_FORMAT_RAW			0x90000
+#define	ARCHIVE_FORMAT_XAR			0xA0000
+#define	ARCHIVE_FORMAT_LHA			0xB0000
+#define	ARCHIVE_FORMAT_CAB			0xC0000
+#define	ARCHIVE_FORMAT_RAR			0xD0000
+#define	ARCHIVE_FORMAT_7ZIP			0xE0000
 
 /*-
  * Basic outline for reading an archive:
@@ -301,7 +296,7 @@ typedef int archive_close_callback(struct archive *, void *_client_data);
  *      data for entries of interest.
  *   5) Call archive_read_finish to end processing.
  */
-__LA_DECL struct archive    *archive_read_new(void);
+__LA_DECL struct archive	*archive_read_new(void);
 
 /*
  * The archive_read_support_XXX calls enable auto-detect for this
@@ -310,39 +305,83 @@ __LA_DECL struct archive    *archive_read_new(void);
  * support_compression_bzip2().  The "all" functions provide the
  * obvious shorthand.
  */
-__LA_DECL int        archive_read_support_compression_all(struct archive *);
-__LA_DECL int        archive_read_support_compression_bzip2(struct archive *);
-__LA_DECL int        archive_read_support_compression_compress(struct archive *);
-__LA_DECL int        archive_read_support_compression_gzip(struct archive *);
-__LA_DECL int        archive_read_support_compression_lzma(struct archive *);
-__LA_DECL int        archive_read_support_compression_none(struct archive *);
-__LA_DECL int        archive_read_support_compression_program(struct archive *,
-             const char *command);
-__LA_DECL int        archive_read_support_compression_program_signature
-                (struct archive *, const char *,
-                    const void * /* match */, size_t);
-
-__LA_DECL int        archive_read_support_compression_xz(struct archive *);
-
-__LA_DECL int        archive_read_support_format_all(struct archive *);
-__LA_DECL int        archive_read_support_format_ar(struct archive *);
-__LA_DECL int        archive_read_support_format_cpio(struct archive *);
-__LA_DECL int        archive_read_support_format_empty(struct archive *);
-__LA_DECL int        archive_read_support_format_gnutar(struct archive *);
-__LA_DECL int        archive_read_support_format_iso9660(struct archive *);
-__LA_DECL int        archive_read_support_format_mtree(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_zip(struct archive *);
-
-
-/* Open the archive using callbacks for archive I/O. */
-__LA_DECL int        archive_read_open(struct archive *, void *_client_data,
-             archive_open_callback *, archive_read_callback *,
-             archive_close_callback *);
-__LA_DECL int        archive_read_open2(struct archive *, void *_client_data,
-             archive_open_callback *, archive_read_callback *,
-             archive_skip_callback *, archive_close_callback *);
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+__LA_DECL int archive_read_support_compression_all(struct archive *);
+__LA_DECL int archive_read_support_compression_bzip2(struct archive *);
+__LA_DECL int archive_read_support_compression_compress(struct archive *);
+__LA_DECL int archive_read_support_compression_gzip(struct archive *);
+__LA_DECL int archive_read_support_compression_lzip(struct archive *);
+__LA_DECL int archive_read_support_compression_lzma(struct archive *);
+__LA_DECL int archive_read_support_compression_none(struct archive *);
+__LA_DECL int archive_read_support_compression_program(struct archive *,
+		     const char *command);
+__LA_DECL int archive_read_support_compression_program_signature
+		(struct archive *, const char *,
+				    const void * /* match */, size_t);
+
+__LA_DECL int archive_read_support_compression_rpm(struct archive *);
+__LA_DECL int archive_read_support_compression_uu(struct archive *);
+__LA_DECL int archive_read_support_compression_xz(struct archive *);
+#endif
+
+__LA_DECL int archive_read_support_filter_all(struct archive *);
+__LA_DECL int archive_read_support_filter_bzip2(struct archive *);
+__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_lzip(struct archive *);
+__LA_DECL int archive_read_support_filter_lzma(struct archive *);
+__LA_DECL int archive_read_support_filter_none(struct archive *);
+__LA_DECL int archive_read_support_filter_program(struct archive *,
+		     const char *command);
+__LA_DECL int archive_read_support_filter_program_signature
+		(struct archive *, const char *,
+				    const void * /* match */, size_t);
+
+__LA_DECL int archive_read_support_filter_rpm(struct archive *);
+__LA_DECL int archive_read_support_filter_uu(struct archive *);
+__LA_DECL int archive_read_support_filter_xz(struct archive *);
+
+__LA_DECL int archive_read_support_format_7zip(struct archive *);
+__LA_DECL int archive_read_support_format_all(struct archive *);
+__LA_DECL int archive_read_support_format_ar(struct archive *);
+__LA_DECL int archive_read_support_format_by_code(struct archive *, int);
+__LA_DECL int archive_read_support_format_cab(struct archive *);
+__LA_DECL int archive_read_support_format_cpio(struct archive *);
+__LA_DECL int archive_read_support_format_empty(struct archive *);
+__LA_DECL int archive_read_support_format_gnutar(struct archive *);
+__LA_DECL int archive_read_support_format_iso9660(struct archive *);
+__LA_DECL int archive_read_support_format_lha(struct archive *);
+__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_xar(struct archive *);
+__LA_DECL int archive_read_support_format_zip(struct archive *);
+
+/* Set various callbacks. */
+__LA_DECL int archive_read_set_open_callback(struct archive *,
+    archive_open_callback *);
+__LA_DECL int archive_read_set_read_callback(struct archive *,
+    archive_read_callback *);
+__LA_DECL int archive_read_set_seek_callback(struct archive *,
+    archive_seek_callback *);
+__LA_DECL int archive_read_set_skip_callback(struct archive *,
+    archive_skip_callback *);
+__LA_DECL int archive_read_set_close_callback(struct archive *,
+    archive_close_callback *);
+/* The callback data is provided to all of the callbacks above. */
+__LA_DECL int archive_read_set_callback_data(struct archive *, void *);
+/* Opening freezes the callbacks. */
+__LA_DECL int archive_read_open1(struct archive *);
+
+/* Convenience wrappers around the above. */
+__LA_DECL int archive_read_open(struct archive *, void *_client_data,
+		     archive_open_callback *, archive_read_callback *,
+		     archive_close_callback *);
+__LA_DECL int archive_read_open2(struct archive *, void *_client_data,
+		     archive_open_callback *, archive_read_callback *,
+		     archive_skip_callback *, archive_close_callback *);
 
 /*
  * A variety of shortcuts that invoke archive_read_open() with
@@ -350,41 +389,43 @@ __LA_DECL int        archive_read_open2(struct archive *, void *_client_data,
  * accept a block size handle tape blocking correctly.
  */
 /* Use this if you know the filename.  Note: NULL indicates stdin. */
-__LA_DECL int        archive_read_open_filename(struct archive *,
-             const char *_filename, size_t _block_size);
+__LA_DECL int archive_read_open_filename(struct archive *,
+		     const char *_filename, size_t _block_size);
+__LA_DECL int archive_read_open_filename_w(struct archive *,
+		     const wchar_t *_filename, size_t _block_size);
 /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
-__LA_DECL int        archive_read_open_file(struct archive *,
-             const char *_filename, size_t _block_size);
+__LA_DECL int archive_read_open_file(struct archive *,
+		     const char *_filename, size_t _block_size);
 /* Read an archive that's stored in memory. */
-__LA_DECL int        archive_read_open_memory(struct archive *,
-             void * buff, size_t size);
+__LA_DECL int archive_read_open_memory(struct archive *,
+		     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,
-             size_t size, size_t read_size);
+__LA_DECL int archive_read_open_memory2(struct archive *a, 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,
-             size_t _block_size);
+__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
+		     size_t _block_size);
 /* Read an archive that's already open, using a FILE *. */
 /* Note: DO NOT use this with tape drives. */
-__LA_DECL int        archive_read_open_FILE(struct archive *, FILE *_file);
+__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
 
 /* Parses and returns next entry header. */
-__LA_DECL int        archive_read_next_header(struct archive *,
-             struct archive_entry **);
+__LA_DECL int archive_read_next_header(struct archive *,
+		     struct archive_entry **);
 
 /* Parses and returns next entry header using the archive_entry passed in */
-__LA_DECL int        archive_read_next_header2(struct archive *,
-             struct archive_entry *);
+__LA_DECL int archive_read_next_header2(struct archive *,
+		     struct archive_entry *);
 
 /*
  * 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 *);
 
 /* Read data from the body of an entry.  Similar to read(2). */
-__LA_DECL __LA_SSIZE_T       archive_read_data(struct archive *,
-                    void *, size_t);
+__LA_DECL __LA_SSIZE_T		 archive_read_data(struct archive *,
+				    void *, size_t);
 
 /*
  * A zero-copy version of archive_read_data that also exposes the file offset
@@ -392,14 +433,8 @@ __LA_DECL __LA_SSIZE_T       archive_read_data(struct archive *,
  * the desired size of the block.  The API does guarantee that offsets will
  * be strictly increasing and that returned blocks will not overlap.
  */
-#if ARCHIVE_VERSION_NUMBER < 3000000
-__LA_DECL int        archive_read_data_block(struct archive *a,
-                const void **buff, size_t *size, off_t *offset);
-#else
-__LA_DECL int        archive_read_data_block(struct archive *a,
-                const void **buff, size_t *size,
-                __LA_INT64_T *offset);
-#endif
+__LA_DECL int archive_read_data_block(struct archive *a,
+		    const void **buff, size_t *size, __LA_INT64_T *offset);
 
 /*-
  * Some convenience functions that are built on archive_read_data:
@@ -407,23 +442,27 @@ __LA_DECL int        archive_read_data_block(struct archive *a,
  *  'into_buffer': writes data into memory buffer that you provide
  *  'into_fd': writes data to specified filedes
  */
-__LA_DECL int        archive_read_data_skip(struct archive *);
-__LA_DECL int        archive_read_data_into_buffer(struct archive *,
-                void *buffer, __LA_SSIZE_T len);
-__LA_DECL int        archive_read_data_into_fd(struct archive *, int fd);
+__LA_DECL int archive_read_data_skip(struct archive *);
+__LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
 
 /*
  * Set read options.
  */
-/* Apply option string to the format only. */
-__LA_DECL int       archive_read_set_format_options(struct archive *_a,
-                const char *s);
-/* Apply option string to the filter only. */
-__LA_DECL int       archive_read_set_filter_options(struct archive *_a,
-                const char *s);
+/* Apply option to the format only. */
+__LA_DECL int archive_read_set_format_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to the filter only. */
+__LA_DECL int archive_read_set_filter_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to both the format and the filter. */
+__LA_DECL int archive_read_set_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
 /* Apply option string to both the format and the filter. */
-__LA_DECL int       archive_read_set_options(struct archive *_a,
-                const char *s);
+__LA_DECL int archive_read_set_options(struct archive *_a,
+			    const char *opts);
 
 /*-
  * Convenience function to recreate the current entry (whose header
@@ -442,59 +481,61 @@ __LA_DECL int       archive_read_set_options(struct archive *_a,
 /* The "flags" argument selects optional behavior, 'OR' the flags you want. */
 
 /* Default: Do not try to set owner/group. */
-#define ARCHIVE_EXTRACT_OWNER           (0x0001)
+#define	ARCHIVE_EXTRACT_OWNER			(0x0001)
 /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
-#define ARCHIVE_EXTRACT_PERM            (0x0002)
+#define	ARCHIVE_EXTRACT_PERM			(0x0002)
 /* Default: Do not restore mtime/atime. */
-#define ARCHIVE_EXTRACT_TIME            (0x0004)
+#define	ARCHIVE_EXTRACT_TIME			(0x0004)
 /* Default: Replace existing files. */
-#define ARCHIVE_EXTRACT_NO_OVERWRITE        (0x0008)
+#define	ARCHIVE_EXTRACT_NO_OVERWRITE 		(0x0008)
 /* Default: Try create first, unlink only if create fails with EEXIST. */
-#define ARCHIVE_EXTRACT_UNLINK          (0x0010)
+#define	ARCHIVE_EXTRACT_UNLINK			(0x0010)
 /* Default: Do not restore ACLs. */
-#define ARCHIVE_EXTRACT_ACL         (0x0020)
+#define	ARCHIVE_EXTRACT_ACL			(0x0020)
 /* Default: Do not restore fflags. */
-#define ARCHIVE_EXTRACT_FFLAGS          (0x0040)
+#define	ARCHIVE_EXTRACT_FFLAGS			(0x0040)
 /* Default: Do not restore xattrs. */
-#define ARCHIVE_EXTRACT_XATTR           (0x0080)
+#define	ARCHIVE_EXTRACT_XATTR 			(0x0080)
 /* Default: Do not try to guard against extracts redirected by symlinks. */
 /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
-#define ARCHIVE_EXTRACT_SECURE_SYMLINKS     (0x0100)
+#define	ARCHIVE_EXTRACT_SECURE_SYMLINKS		(0x0100)
 /* Default: Do not reject entries with '..' as path elements. */
-#define ARCHIVE_EXTRACT_SECURE_NODOTDOT     (0x0200)
+#define	ARCHIVE_EXTRACT_SECURE_NODOTDOT		(0x0200)
 /* Default: Create parent directories as needed. */
-#define ARCHIVE_EXTRACT_NO_AUTODIR      (0x0400)
+#define	ARCHIVE_EXTRACT_NO_AUTODIR		(0x0400)
 /* Default: Overwrite files, even if one on disk is newer. */
-#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER  (0x0800)
+#define	ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER	(0x0800)
 /* Detect blocks of 0 and write holes instead. */
-#define ARCHIVE_EXTRACT_SPARSE          (0x1000)
-
-__LA_DECL int    archive_read_extract(struct archive *, struct archive_entry *,
-             int flags);
-__LA_DECL int    archive_read_extract2(struct archive *, struct archive_entry *,
-             struct archive * /* dest */);
-__LA_DECL void   archive_read_extract_set_progress_callback(struct archive *,
-             void (*_progress_func)(void *), void *_user_data);
+#define	ARCHIVE_EXTRACT_SPARSE			(0x1000)
+/* Default: Do not restore Mac extended metadata. */
+/* This has no effect except on Mac OS. */
+#define	ARCHIVE_EXTRACT_MAC_METADATA		(0x2000)
+
+__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
+		     int flags);
+__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
+		     struct archive * /* dest */);
+__LA_DECL void	 archive_read_extract_set_progress_callback(struct archive *,
+		     void (*_progress_func)(void *), void *_user_data);
 
 /* 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 *,
-             dev_t, ino_t);
+__LA_DECL void		archive_read_extract_set_skip_file(struct archive *,
+		     __LA_INT64_T, __LA_INT64_T);
 
 /* Close the file and release most resources. */
-__LA_DECL int        archive_read_close(struct archive *);
+__LA_DECL int		 archive_read_close(struct archive *);
 /* Release all resources and destroy the object. */
-/* Note that archive_read_finish will call archive_read_close for you. */
-#if ARCHIVE_VERSION_NUMBER < 2000000
-/* Erroneously declared to return void in libarchive 1.x */
-__LA_DECL void       archive_read_finish(struct archive *);
-#else
-__LA_DECL int        archive_read_finish(struct archive *);
+/* Note that archive_read_free will call archive_read_close for you. */
+__LA_DECL int		 archive_read_free(struct archive *);
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* Synonym for archive_read_free() for backwards compatibility. */
+__LA_DECL int		 archive_read_finish(struct archive *);
 #endif
 
 /*-
  * To create an archive:
- *   1) Ask archive_write_new for a archive writer object.
+ *   1) Ask archive_write_new for an archive writer object.
  *   2) Set any global properties.  In particular, you should set
  *      the compression and format to use.
  *   3) Call archive_write_open to open the file (most people
@@ -505,110 +546,122 @@ __LA_DECL int        archive_read_finish(struct archive *);
  *      - archive_write_header to write the header
  *      - archive_write_data to write the entry data
  *   5) archive_write_close to close the output
- *   6) archive_write_finish to cleanup the writer and release resources
+ *   6) archive_write_free to cleanup the writer and release resources
  */
-__LA_DECL struct archive    *archive_write_new(void);
-__LA_DECL int        archive_write_set_bytes_per_block(struct archive *,
-             int bytes_per_block);
-__LA_DECL int        archive_write_get_bytes_per_block(struct archive *);
+__LA_DECL struct archive	*archive_write_new(void);
+__LA_DECL int archive_write_set_bytes_per_block(struct archive *,
+		     int bytes_per_block);
+__LA_DECL int archive_write_get_bytes_per_block(struct archive *);
 /* XXX This is badly misnamed; suggestions appreciated. XXX */
-__LA_DECL int        archive_write_set_bytes_in_last_block(struct archive *,
-             int bytes_in_last_block);
-__LA_DECL int        archive_write_get_bytes_in_last_block(struct archive *);
+__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
+		     int bytes_in_last_block);
+__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 *, dev_t, ino_t);
-
-__LA_DECL int        archive_write_set_compression_bzip2(struct archive *);
-__LA_DECL int        archive_write_set_compression_compress(struct archive *);
-__LA_DECL int        archive_write_set_compression_gzip(struct archive *);
-__LA_DECL int        archive_write_set_compression_lzma(struct archive *);
-__LA_DECL int        archive_write_set_compression_none(struct archive *);
-__LA_DECL int        archive_write_set_compression_program(struct archive *,
-             const char *cmd);
-__LA_DECL int        archive_write_set_compression_xz(struct archive *);
+__LA_DECL int archive_write_set_skip_file(struct archive *,
+    __LA_INT64_T, __LA_INT64_T);
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+__LA_DECL int archive_write_set_compression_bzip2(struct archive *);
+__LA_DECL int archive_write_set_compression_compress(struct archive *);
+__LA_DECL int archive_write_set_compression_gzip(struct archive *);
+__LA_DECL int archive_write_set_compression_lzip(struct archive *);
+__LA_DECL int archive_write_set_compression_lzma(struct archive *);
+__LA_DECL int archive_write_set_compression_none(struct archive *);
+__LA_DECL int archive_write_set_compression_program(struct archive *,
+		     const char *cmd);
+__LA_DECL int archive_write_set_compression_xz(struct archive *);
+#endif
+
+__LA_DECL int archive_write_add_filter_bzip2(struct archive *);
+__LA_DECL int archive_write_add_filter_compress(struct archive *);
+__LA_DECL int archive_write_add_filter_gzip(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_none(struct archive *);
+__LA_DECL int archive_write_add_filter_program(struct archive *,
+		     const char *cmd);
+__LA_DECL int archive_write_add_filter_xz(struct archive *);
+
+
 /* A convenience function to set the format based on the code or name. */
-__LA_DECL int        archive_write_set_format(struct archive *, int format_code);
-__LA_DECL int        archive_write_set_format_by_name(struct archive *,
-             const char *name);
+__LA_DECL int archive_write_set_format(struct archive *, int format_code);
+__LA_DECL int archive_write_set_format_by_name(struct archive *,
+		     const char *name);
 /* To minimize link pollution, use one or more of the following. */
-__LA_DECL int        archive_write_set_format_ar_bsd(struct archive *);
-__LA_DECL int        archive_write_set_format_ar_svr4(struct archive *);
-__LA_DECL int        archive_write_set_format_cpio(struct archive *);
-__LA_DECL int        archive_write_set_format_cpio_newc(struct archive *);
-__LA_DECL int        archive_write_set_format_mtree(struct archive *);
+__LA_DECL int archive_write_set_format_7zip(struct archive *);
+__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
+__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
+__LA_DECL int archive_write_set_format_cpio(struct archive *);
+__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
+__LA_DECL int archive_write_set_format_gnutar(struct archive *);
+__LA_DECL int archive_write_set_format_iso9660(struct archive *);
+__LA_DECL int archive_write_set_format_mtree(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_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_zip(struct archive *);
-__LA_DECL int        archive_write_open(struct archive *, void *,
-             archive_open_callback *, archive_write_callback *,
-             archive_close_callback *);
-__LA_DECL int        archive_write_open_fd(struct archive *, int _fd);
-__LA_DECL int        archive_write_open_filename(struct archive *, const char *_file);
+__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_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_xar(struct archive *);
+__LA_DECL int archive_write_set_format_zip(struct archive *);
+__LA_DECL int archive_write_open(struct archive *, void *,
+		     archive_open_callback *, archive_write_callback *,
+		     archive_close_callback *);
+__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
+__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
+__LA_DECL int archive_write_open_filename_w(struct archive *,
+		     const wchar_t *_file);
 /* A deprecated synonym for archive_write_open_filename() */
-__LA_DECL int        archive_write_open_file(struct archive *, const char *_file);
-__LA_DECL int        archive_write_open_FILE(struct archive *, FILE *);
+__LA_DECL int archive_write_open_file(struct archive *, const char *_file);
+__LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
 /* _buffSize is the size of the buffer, _used refers to a variable that
  * will be updated after each write into the buffer. */
-__LA_DECL int        archive_write_open_memory(struct archive *,
-            void *_buffer, size_t _buffSize, size_t *_used);
+__LA_DECL int archive_write_open_memory(struct archive *,
+			void *_buffer, size_t _buffSize, size_t *_used);
 
 /*
  * Note that the library will truncate writes beyond the size provided
  * to archive_write_header or pad if the provided data is short.
  */
-__LA_DECL int        archive_write_header(struct archive *,
-             struct archive_entry *);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-/* This was erroneously declared to return "int" in libarchive 1.x. */
-__LA_DECL int        archive_write_data(struct archive *,
-                const void *, size_t);
-#else
-/* Libarchive 2.0 and later return ssize_t here. */
-__LA_DECL __LA_SSIZE_T   archive_write_data(struct archive *,
-                const void *, size_t);
-#endif
-
-#if ARCHIVE_VERSION_NUMBER < 3000000
-/* Libarchive 1.x and 2.x use off_t for the argument, but that's not
- * stable on Linux. */
-__LA_DECL __LA_SSIZE_T   archive_write_data_block(struct archive *,
-                    const void *, size_t, off_t);
-#else
-/* Libarchive 3.0 uses explicit int64_t to ensure consistent 64-bit support. */
-__LA_DECL __LA_SSIZE_T   archive_write_data_block(struct archive *,
-                    const void *, size_t, __LA_INT64_T);
-#endif
-__LA_DECL int        archive_write_finish_entry(struct archive *);
-__LA_DECL int        archive_write_close(struct archive *);
-#if ARCHIVE_VERSION_NUMBER < 2000000
-/* Return value was incorrect in libarchive 1.x. */
-__LA_DECL void       archive_write_finish(struct archive *);
-#else
-/* Libarchive 2.x and later returns an error if this fails. */
-/* It can fail if the archive wasn't already closed, in which case
- * archive_write_finish() will implicitly call archive_write_close(). */
-__LA_DECL int        archive_write_finish(struct archive *);
+__LA_DECL int archive_write_header(struct archive *,
+		     struct archive_entry *);
+__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 int		 archive_write_finish_entry(struct archive *);
+__LA_DECL int		 archive_write_close(struct archive *);
+/* This can fail if the archive wasn't already closed, in which case
+ * archive_write_free() will implicitly call archive_write_close(). */
+__LA_DECL int		 archive_write_free(struct archive *);
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* Synonym for archive_write_free() for backwards compatibility. */
+__LA_DECL int		 archive_write_finish(struct archive *);
 #endif
 
 /*
  * Set write options.
  */
-/* Apply option string to the format only. */
-__LA_DECL int       archive_write_set_format_options(struct archive *_a,
-                const char *s);
-/* Apply option string to the compressor only. */
-__LA_DECL int       archive_write_set_compressor_options(struct archive *_a,
-                const char *s);
-/* Apply option string to both the format and the compressor. */
-__LA_DECL int       archive_write_set_options(struct archive *_a,
-                const char *s);
-
+/* Apply option to the format only. */
+__LA_DECL int archive_write_set_format_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to the filter only. */
+__LA_DECL int archive_write_set_filter_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option to both the format and the filter. */
+__LA_DECL int archive_write_set_option(struct archive *_a,
+			    const char *m, const char *o,
+			    const char *v);
+/* Apply option string to both the format and the filter. */
+__LA_DECL int archive_write_set_options(struct archive *_a,
+			    const char *opts);
 
 /*-
  * ARCHIVE_WRITE_DISK API
@@ -621,19 +674,19 @@ __LA_DECL int       archive_write_set_options(struct archive *_a,
  *      - construct an appropriate struct archive_entry structure
  *      - archive_write_header to create the file/dir/etc on disk
  *      - archive_write_data to write the entry data
- *   4) archive_write_finish to cleanup the writer and release resources
+ *   4) archive_write_free to cleanup the writer and release resources
  *
  * In particular, you can use this in conjunction with archive_read()
  * to pull entries out of an archive and create them on disk.
  */
-__LA_DECL struct archive    *archive_write_disk_new(void);
+__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 *,
-             dev_t, ino_t);
+__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
+    __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 *,
-             int flags);
+__LA_DECL int		 archive_write_disk_set_options(struct archive *,
+		     int flags);
 /*
  * The lookup functions are given uname/uid (or gname/gid) pairs and
  * return a uid (gid) suitable for this system.  These are used for
@@ -651,20 +704,22 @@ __LA_DECL int        archive_write_disk_set_options(struct archive *,
  * particular, these match the specifications of POSIX "pax" and old
  * POSIX "tar".
  */
-__LA_DECL int    archive_write_disk_set_standard_lookup(struct archive *);
+__LA_DECL int	 archive_write_disk_set_standard_lookup(struct archive *);
 /*
  * If neither the default (naive) nor the standard (big) functions suit
  * your needs, you can write your own and register them.  Be sure to
  * include a cleanup function if you have allocated private data.
  */
-__LA_DECL int    archive_write_disk_set_group_lookup(struct archive *,
-                void * /* private_data */,
-                __LA_GID_T (*)(void *, const char *, __LA_GID_T),
-                void (* /* cleanup */)(void *));
-__LA_DECL int    archive_write_disk_set_user_lookup(struct archive *,
-                void * /* private_data */,
-                __LA_UID_T (*)(void *, const char *, __LA_UID_T),
-                void (* /* cleanup */)(void *));
+__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
+    void * /* private_data */,
+    __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),
+    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);
 
 /*
  * ARCHIVE_READ_DISK API
@@ -685,42 +740,74 @@ __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_GID_T);
-__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_UID_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 *);
+__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 *,
+__LA_DECL int	archive_read_disk_set_gname_lookup(struct archive *,
     void * /* private_data */,
-    const char *(* /* lookup_fn */)(void *, __LA_GID_T),
+    const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
     void (* /* cleanup_fn */)(void *));
-__LA_DECL int   archive_read_disk_set_uname_lookup(struct archive *,
+__LA_DECL int	archive_read_disk_set_uname_lookup(struct archive *,
     void * /* private_data */,
-    const char *(* /* lookup_fn */)(void *, __LA_UID_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 *);
+__LA_DECL int	archive_read_disk_open_w(struct archive *, const wchar_t *);
+/*
+ * Request that current entry be visited.  If you invoke it on every
+ * directory, you'll get a physical traversal.  This is ignored if the
+ * current entry isn't a directory or a link to a directory.  So, if
+ * you invoke this on every returned path, you'll get a full logical
+ * traversal.
+ */
+__LA_DECL int	archive_read_disk_descend(struct archive *);
+__LA_DECL int	archive_read_disk_current_filesystem(struct archive *);
+__LA_DECL int	archive_read_disk_current_filesystem_is_synthetic(struct archive *);
+__LA_DECL int	archive_read_disk_current_filesystem_is_remote(struct archive *);
+/* Request that the access time of the entry visited by travesal be restored. */
+__LA_DECL int  archive_read_disk_set_atime_restored(struct archive *);
 
 /*
  * Accessor functions to read/set various information in
  * the struct archive object:
  */
-/* Bytes written after compression or read before decompression. */
-__LA_DECL __LA_INT64_T   archive_position_compressed(struct archive *);
-/* Bytes written to compressor or read from decompressor. */
-__LA_DECL __LA_INT64_T   archive_position_uncompressed(struct archive *);
-
-__LA_DECL const char    *archive_compression_name(struct archive *);
-__LA_DECL int        archive_compression(struct archive *);
-__LA_DECL int        archive_errno(struct archive *);
-__LA_DECL const char    *archive_error_string(struct archive *);
-__LA_DECL const char    *archive_format_name(struct archive *);
-__LA_DECL int        archive_format(struct archive *);
-__LA_DECL void       archive_clear_error(struct archive *);
-__LA_DECL void       archive_set_error(struct archive *, int _err,
-                const char *fmt, ...);
-__LA_DECL void       archive_copy_error(struct archive *dest,
-                struct archive *src);
-__LA_DECL int        archive_file_count(struct archive *);
+
+/* Number of filters in the current filter pipeline. */
+/* Filter #0 is the one closest to the format, -1 is a synonym for the
+ * 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 int		 archive_filter_code(struct archive *, int);
+__LA_DECL const char *	 archive_filter_name(struct archive *, int);
+
+#if ARCHIVE_VERSION_NUMBER < 4000000
+/* 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 *);
+/* 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 *);
+/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
+__LA_DECL const char	*archive_compression_name(struct archive *);
+/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
+__LA_DECL int		 archive_compression(struct archive *);
+#endif
+
+__LA_DECL int		 archive_errno(struct archive *);
+__LA_DECL const char	*archive_error_string(struct archive *);
+__LA_DECL const char	*archive_format_name(struct archive *);
+__LA_DECL int		 archive_format(struct archive *);
+__LA_DECL void		 archive_clear_error(struct archive *);
+__LA_DECL void		 archive_set_error(struct archive *, int _err,
+			    const char *fmt, ...) __LA_PRINTF(3, 4);
+__LA_DECL void		 archive_copy_error(struct archive *dest,
+			    struct archive *src);
+__LA_DECL int		 archive_file_count(struct archive *);
 
 #ifdef __cplusplus
 }

+ 1264 - 0
Utilities/cmlibarchive/libarchive/archive_acl.c

@@ -0,0 +1,1264 @@
+/*-
+ * Copyright (c) 2003-2010 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+
+#include "archive_acl_private.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+
+#undef max
+#define	max(a, b)	((a)>(b)?(a):(b))
+
+#ifndef HAVE_WMEMCMP
+/* Good enough for simple equality testing, but not for sorting. */
+#define wmemcmp(a,b,i)  memcmp((a), (b), (i) * sizeof(wchar_t))
+#endif
+
+static int	acl_special(struct archive_acl *acl,
+		    int type, int permset, int tag);
+static struct archive_acl_entry *acl_new_entry(struct archive_acl *acl,
+		    int type, int permset, int tag, int id);
+static int	isint_w(const wchar_t *start, const wchar_t *end, int *result);
+static int	ismode_w(const wchar_t *start, const wchar_t *end, int *result);
+static void	next_field_w(const wchar_t **wp, const wchar_t **start,
+		    const wchar_t **end, wchar_t *sep);
+static int	prefix_w(const wchar_t *start, const wchar_t *end,
+		    const wchar_t *test);
+static void	append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
+		    const wchar_t *wname, int perm, int id);
+static void	append_id_w(wchar_t **wp, int id);
+static int	isint(const char *start, const char *end, int *result);
+static int	ismode(const char *start, const char *end, int *result);
+static void	next_field(const char **p, const char **start,
+		    const char **end, char *sep);
+static int	prefix(const char *start, const char *end,
+		    const char *test);
+static void	append_entry(char **p, const char *prefix, int tag,
+		    const char *name, int perm, int id);
+static void	append_id(char **p, int id);
+
+void
+archive_acl_clear(struct archive_acl *acl)
+{
+	struct archive_acl_entry *ap;
+
+	while (acl->acl_head != NULL) {
+		ap = acl->acl_head->next;
+		archive_mstring_clean(&acl->acl_head->name);
+		free(acl->acl_head);
+		acl->acl_head = ap;
+	}
+	if (acl->acl_text_w != NULL) {
+		free(acl->acl_text_w);
+		acl->acl_text_w = NULL;
+	}
+	if (acl->acl_text != NULL) {
+		free(acl->acl_text);
+		acl->acl_text = NULL;
+	}
+	acl->acl_p = NULL;
+	acl->acl_state = 0; /* Not counting. */
+}
+
+void
+archive_acl_copy(struct archive_acl *dest, struct archive_acl *src)
+{
+	struct archive_acl_entry *ap, *ap2;
+
+	archive_acl_clear(dest);
+
+	dest->mode = src->mode;
+	ap = src->acl_head;
+	while (ap != NULL) {
+		ap2 = acl_new_entry(dest,
+		    ap->type, ap->permset, ap->tag, ap->id);
+		if (ap2 != NULL)
+			archive_mstring_copy(&ap2->name, &ap->name);
+		ap = ap->next;
+	}
+}
+
+int
+archive_acl_add_entry(struct archive_acl *acl,
+    int type, int permset, int tag, int id, const char *name)
+{
+	struct archive_acl_entry *ap;
+
+	if (acl_special(acl, type, permset, tag) == 0)
+		return ARCHIVE_OK;
+	ap = acl_new_entry(acl, type, permset, tag, id);
+	if (ap == NULL) {
+		/* XXX Error XXX */
+		return ARCHIVE_FAILED;
+	}
+	if (name != NULL  &&  *name != '\0')
+		archive_mstring_copy_mbs(&ap->name, name);
+	else
+		archive_mstring_clean(&ap->name);
+	return ARCHIVE_OK;
+}
+
+int
+archive_acl_add_entry_w_len(struct archive_acl *acl,
+    int type, int permset, int tag, int id, const wchar_t *name, size_t len)
+{
+	struct archive_acl_entry *ap;
+
+	if (acl_special(acl, type, permset, tag) == 0)
+		return ARCHIVE_OK;
+	ap = acl_new_entry(acl, type, permset, tag, id);
+	if (ap == NULL) {
+		/* XXX Error XXX */
+		return ARCHIVE_FAILED;
+	}
+	if (name != NULL  &&  *name != L'\0' && len > 0)
+		archive_mstring_copy_wcs_len(&ap->name, name, len);
+	else
+		archive_mstring_clean(&ap->name);
+	return ARCHIVE_OK;
+}
+
+int
+archive_acl_add_entry_len_l(struct archive_acl *acl,
+    int type, int permset, int tag, int id, const char *name, size_t len,
+    struct archive_string_conv *sc)
+{
+	struct archive_acl_entry *ap;
+	int r;
+
+	if (acl_special(acl, type, permset, tag) == 0)
+		return ARCHIVE_OK;
+	ap = acl_new_entry(acl, type, permset, tag, id);
+	if (ap == NULL) {
+		/* XXX Error XXX */
+		return ARCHIVE_FAILED;
+	}
+	if (name != NULL  &&  *name != '\0' && len > 0) {
+		r = archive_mstring_copy_mbs_len_l(&ap->name, name, len, sc);
+	} else {
+		r = 0;
+		archive_mstring_clean(&ap->name);
+	}
+	if (r == 0)
+		return (ARCHIVE_OK);
+	else if (errno == ENOMEM)
+		return (ARCHIVE_FATAL);
+	else
+		return (ARCHIVE_WARN);
+}
+
+/*
+ * If this ACL entry is part of the standard POSIX permissions set,
+ * store the permissions in the stat structure and return zero.
+ */
+static int
+acl_special(struct archive_acl *acl, int type, int permset, int tag)
+{
+	if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+	    && ((permset & ~007) == 0)) {
+		switch (tag) {
+		case ARCHIVE_ENTRY_ACL_USER_OBJ:
+			acl->mode &= ~0700;
+			acl->mode |= (permset & 7) << 6;
+			return (0);
+		case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+			acl->mode &= ~0070;
+			acl->mode |= (permset & 7) << 3;
+			return (0);
+		case ARCHIVE_ENTRY_ACL_OTHER:
+			acl->mode &= ~0007;
+			acl->mode |= permset & 7;
+			return (0);
+		}
+	}
+	return (1);
+}
+
+/*
+ * Allocate and populate a new ACL entry with everything but the
+ * name.
+ */
+static struct archive_acl_entry *
+acl_new_entry(struct archive_acl *acl,
+    int type, int permset, int tag, int id)
+{
+	struct archive_acl_entry *ap, *aq;
+
+	/* Type argument must be a valid NFS4 or POSIX.1e type.
+	 * The type must agree with anything already set and
+	 * the permset must be compatible. */
+	if (type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+		if (acl->acl_types & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+			return (NULL);
+		}
+		if (permset &
+		    ~(ARCHIVE_ENTRY_ACL_PERMS_NFS4
+			| ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4)) {
+			return (NULL);
+		}
+	} else	if (type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) {
+		if (acl->acl_types & ~ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) {
+			return (NULL);
+		}
+		if (permset & ~ARCHIVE_ENTRY_ACL_PERMS_POSIX1E) {
+			return (NULL);
+		}
+	} else {
+		return (NULL);
+	}
+
+	/* Verify the tag is valid and compatible with NFS4 or POSIX.1e. */
+	switch (tag) {
+	case ARCHIVE_ENTRY_ACL_USER:
+	case ARCHIVE_ENTRY_ACL_USER_OBJ:
+	case ARCHIVE_ENTRY_ACL_GROUP:
+	case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+		/* Tags valid in both NFS4 and POSIX.1e */
+		break;
+	case ARCHIVE_ENTRY_ACL_MASK:
+	case ARCHIVE_ENTRY_ACL_OTHER:
+		/* Tags valid only in POSIX.1e. */
+		if (type & ~ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) {
+			return (NULL);
+		}
+		break;
+	case ARCHIVE_ENTRY_ACL_EVERYONE:
+		/* Tags valid only in NFS4. */
+		if (type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+			return (NULL);
+		}
+		break;
+	default:
+		/* No other values are valid. */
+		return (NULL);
+	}
+
+	if (acl->acl_text_w != NULL) {
+		free(acl->acl_text_w);
+		acl->acl_text_w = NULL;
+	}
+	if (acl->acl_text != NULL) {
+		free(acl->acl_text);
+		acl->acl_text = NULL;
+	}
+
+	/* If there's a matching entry already in the list, overwrite it. */
+	ap = acl->acl_head;
+	aq = NULL;
+	while (ap != NULL) {
+		if (ap->type == type && ap->tag == tag && ap->id == id) {
+			ap->permset = permset;
+			return (ap);
+		}
+		aq = ap;
+		ap = ap->next;
+	}
+
+	/* Add a new entry to the end of the list. */
+	ap = (struct archive_acl_entry *)malloc(sizeof(*ap));
+	if (ap == NULL)
+		return (NULL);
+	memset(ap, 0, sizeof(*ap));
+	if (aq == NULL)
+		acl->acl_head = ap;
+	else
+		aq->next = ap;
+	ap->type = type;
+	ap->tag = tag;
+	ap->id = id;
+	ap->permset = permset;
+	acl->acl_types |= type;
+	return (ap);
+}
+
+/*
+ * Return a count of entries matching "want_type".
+ */
+int
+archive_acl_count(struct archive_acl *acl, int want_type)
+{
+	int count;
+	struct archive_acl_entry *ap;
+
+	count = 0;
+	ap = acl->acl_head;
+	while (ap != NULL) {
+		if ((ap->type & want_type) != 0)
+			count++;
+		ap = ap->next;
+	}
+
+	if (count > 0 && ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0))
+		count += 3;
+	return (count);
+}
+
+/*
+ * Prepare for reading entries from the ACL data.  Returns a count
+ * of entries matching "want_type", or zero if there are no
+ * non-extended ACL entries of that type.
+ */
+int
+archive_acl_reset(struct archive_acl *acl, int want_type)
+{
+	int count, cutoff;
+
+	count = archive_acl_count(acl, want_type);
+
+	/*
+	 * If the only entries are the three standard ones,
+	 * then don't return any ACL data.  (In this case,
+	 * client can just use chmod(2) to set permissions.)
+	 */
+	if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)
+		cutoff = 3;
+	else
+		cutoff = 0;
+
+	if (count > cutoff)
+		acl->acl_state = ARCHIVE_ENTRY_ACL_USER_OBJ;
+	else
+		acl->acl_state = 0;
+	acl->acl_p = acl->acl_head;
+	return (count);
+}
+
+
+/*
+ * Return the next ACL entry in the list.  Fake entries for the
+ * standard permissions and include them in the returned list.
+ */
+int
+archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, int *type,
+    int *permset, int *tag, int *id, const char **name)
+{
+	*name = NULL;
+	*id = -1;
+
+	/*
+	 * The acl_state is either zero (no entries available), -1
+	 * (reading from list), or an entry type (retrieve that type
+	 * from ae_stat.aest_mode).
+	 */
+	if (acl->acl_state == 0)
+		return (ARCHIVE_WARN);
+
+	/* The first three access entries are special. */
+	if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+		switch (acl->acl_state) {
+		case ARCHIVE_ENTRY_ACL_USER_OBJ:
+			*permset = (acl->mode >> 6) & 7;
+			*type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+			*tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+			acl->acl_state = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+			return (ARCHIVE_OK);
+		case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+			*permset = (acl->mode >> 3) & 7;
+			*type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+			*tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+			acl->acl_state = ARCHIVE_ENTRY_ACL_OTHER;
+			return (ARCHIVE_OK);
+		case ARCHIVE_ENTRY_ACL_OTHER:
+			*permset = acl->mode & 7;
+			*type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+			*tag = ARCHIVE_ENTRY_ACL_OTHER;
+			acl->acl_state = -1;
+			acl->acl_p = acl->acl_head;
+			return (ARCHIVE_OK);
+		default:
+			break;
+		}
+	}
+
+	while (acl->acl_p != NULL && (acl->acl_p->type & want_type) == 0)
+		acl->acl_p = acl->acl_p->next;
+	if (acl->acl_p == NULL) {
+		acl->acl_state = 0;
+		*type = 0;
+		*permset = 0;
+		*tag = 0;
+		*id = -1;
+		*name = NULL;
+		return (ARCHIVE_EOF); /* End of ACL entries. */
+	}
+	*type = acl->acl_p->type;
+	*permset = acl->acl_p->permset;
+	*tag = acl->acl_p->tag;
+	*id = acl->acl_p->id;
+	if (archive_mstring_get_mbs(a, &acl->acl_p->name, name) != 0)
+		*name = NULL;
+	acl->acl_p = acl->acl_p->next;
+	return (ARCHIVE_OK);
+}
+
+/*
+ * Generate a text version of the ACL.  The flags parameter controls
+ * the style of the generated ACL.
+ */
+const wchar_t *
+archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags)
+{
+	int count;
+	size_t length;
+	const wchar_t *wname;
+	const wchar_t *prefix;
+	wchar_t separator;
+	struct archive_acl_entry *ap;
+	int id;
+	wchar_t *wp;
+
+	if (acl->acl_text_w != NULL) {
+		free (acl->acl_text_w);
+		acl->acl_text_w = NULL;
+	}
+
+	separator = L',';
+	count = 0;
+	length = 0;
+	ap = acl->acl_head;
+	while (ap != NULL) {
+		if ((ap->type & flags) != 0) {
+			count++;
+			if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) &&
+			    (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT))
+				length += 8; /* "default:" */
+			length += 5; /* tag name */
+			length += 1; /* colon */
+			if (archive_mstring_get_wcs(a, &ap->name, &wname) == 0 &&
+			    wname != NULL)
+				length += wcslen(wname);
+			else
+				length += sizeof(uid_t) * 3 + 1;
+			length ++; /* colon */
+			length += 3; /* rwx */
+			length += 1; /* colon */
+			length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1;
+			length ++; /* newline */
+		}
+		ap = ap->next;
+	}
+
+	if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) {
+		length += 10; /* "user::rwx\n" */
+		length += 11; /* "group::rwx\n" */
+		length += 11; /* "other::rwx\n" */
+	}
+
+	if (count == 0)
+		return (NULL);
+
+	/* Now, allocate the string and actually populate it. */
+	wp = acl->acl_text_w = (wchar_t *)malloc(length * sizeof(wchar_t));
+	if (wp == NULL)
+		__archive_errx(1, "No memory to generate the text version of the ACL");
+	count = 0;
+	if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+		append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
+		    acl->mode & 0700, -1);
+		*wp++ = ',';
+		append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL,
+		    acl->mode & 0070, -1);
+		*wp++ = ',';
+		append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL,
+		    acl->mode & 0007, -1);
+		count += 3;
+
+		ap = acl->acl_head;
+		while (ap != NULL) {
+			if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0 &&
+				archive_mstring_get_wcs(a, &ap->name, &wname) == 0) {
+				*wp++ = separator;
+				if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+					id = ap->id;
+				else
+					id = -1;
+				append_entry_w(&wp, NULL, ap->tag, wname,
+				    ap->permset, id);
+				count++;
+			}
+			ap = ap->next;
+		}
+	}
+
+
+	if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
+		if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT)
+			prefix = L"default:";
+		else
+			prefix = NULL;
+		ap = acl->acl_head;
+		count = 0;
+		while (ap != NULL) {
+			if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0 &&
+				archive_mstring_get_wcs(a, &ap->name, &wname) == 0) {
+				if (count > 0)
+					*wp++ = separator;
+				if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+					id = ap->id;
+				else
+					id = -1;
+				append_entry_w(&wp, prefix, ap->tag,
+				    wname, ap->permset, id);
+				count ++;
+			}
+			ap = ap->next;
+		}
+	}
+
+	return (acl->acl_text_w);
+}
+
+
+static void
+append_id_w(wchar_t **wp, int id)
+{
+	if (id < 0)
+		id = 0;
+	if (id > 9)
+		append_id_w(wp, id / 10);
+	*(*wp)++ = L"0123456789"[id % 10];
+}
+
+static void
+append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
+    const wchar_t *wname, int perm, int id)
+{
+	if (prefix != NULL) {
+		wcscpy(*wp, prefix);
+		*wp += wcslen(*wp);
+	}
+	switch (tag) {
+	case ARCHIVE_ENTRY_ACL_USER_OBJ:
+		wname = NULL;
+		id = -1;
+		/* FALLTHROUGH */
+	case ARCHIVE_ENTRY_ACL_USER:
+		wcscpy(*wp, L"user");
+		break;
+	case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+		wname = NULL;
+		id = -1;
+		/* FALLTHROUGH */
+	case ARCHIVE_ENTRY_ACL_GROUP:
+		wcscpy(*wp, L"group");
+		break;
+	case ARCHIVE_ENTRY_ACL_MASK:
+		wcscpy(*wp, L"mask");
+		wname = NULL;
+		id = -1;
+		break;
+	case ARCHIVE_ENTRY_ACL_OTHER:
+		wcscpy(*wp, L"other");
+		wname = NULL;
+		id = -1;
+		break;
+	}
+	*wp += wcslen(*wp);
+	*(*wp)++ = L':';
+	if (wname != NULL) {
+		wcscpy(*wp, wname);
+		*wp += wcslen(*wp);
+	} else if (tag == ARCHIVE_ENTRY_ACL_USER
+	    || tag == ARCHIVE_ENTRY_ACL_GROUP) {
+		append_id_w(wp, id);
+		id = -1;
+	}
+	*(*wp)++ = L':';
+	*(*wp)++ = (perm & 0444) ? L'r' : L'-';
+	*(*wp)++ = (perm & 0222) ? L'w' : L'-';
+	*(*wp)++ = (perm & 0111) ? L'x' : L'-';
+	if (id != -1) {
+		*(*wp)++ = L':';
+		append_id_w(wp, id);
+	}
+	**wp = L'\0';
+}
+
+int
+archive_acl_text_l(struct archive_acl *acl, int flags,
+    const char **acl_text, size_t *acl_text_len,
+    struct archive_string_conv *sc)
+{
+	int count;
+	size_t length;
+	const char *name;
+	const char *prefix;
+	char separator;
+	struct archive_acl_entry *ap;
+	size_t len;
+	int id, r;
+	char *p;
+
+	if (acl->acl_text != NULL) {
+		free (acl->acl_text);
+		acl->acl_text = NULL;
+	}
+
+	*acl_text = NULL;
+	if (acl_text_len != NULL)
+		*acl_text_len = 0;
+	separator = ',';
+	count = 0;
+	length = 0;
+	ap = acl->acl_head;
+	while (ap != NULL) {
+		if ((ap->type & flags) != 0) {
+			count++;
+			if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) &&
+			    (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT))
+				length += 8; /* "default:" */
+			length += 5; /* tag name */
+			length += 1; /* colon */
+			r = archive_mstring_get_mbs_l(
+			    &ap->name, &name, &len, sc);
+			if (r != 0)
+				return (-1);
+			if (len > 0 && name != NULL)
+				length += len;
+			else
+				length += sizeof(uid_t) * 3 + 1;
+			length ++; /* colon */
+			length += 3; /* rwx */
+			length += 1; /* colon */
+			length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1;
+			length ++; /* newline */
+		}
+		ap = ap->next;
+	}
+
+	if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) {
+		length += 10; /* "user::rwx\n" */
+		length += 11; /* "group::rwx\n" */
+		length += 11; /* "other::rwx\n" */
+	}
+
+	if (count == 0)
+		return (0);
+
+	/* Now, allocate the string and actually populate it. */
+	p = acl->acl_text = (char *)malloc(length);
+	if (p == NULL)
+		__archive_errx(1, "No memory to generate the text version of the ACL");
+	count = 0;
+	if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+		append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
+		    acl->mode & 0700, -1);
+		*p++ = ',';
+		append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL,
+		    acl->mode & 0070, -1);
+		*p++ = ',';
+		append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL,
+		    acl->mode & 0007, -1);
+		count += 3;
+
+		for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
+			if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) == 0)
+				continue;
+			r = archive_mstring_get_mbs_l(
+			    &ap->name, &name, &len, sc);
+			if (r != 0)
+				return (-1);
+			*p++ = separator;
+			if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+				id = ap->id;
+			else
+				id = -1;
+			append_entry(&p, NULL, ap->tag, name,
+			    ap->permset, id);
+			count++;
+		}
+	}
+
+
+	if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
+		if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT)
+			prefix = "default:";
+		else
+			prefix = NULL;
+		count = 0;
+		for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
+			if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) == 0)
+				continue;
+			r = archive_mstring_get_mbs_l(
+			    &ap->name, &name, &len, sc);
+			if (r != 0)
+				return (-1);
+			if (count > 0)
+				*p++ = separator;
+			if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+				id = ap->id;
+			else
+				id = -1;
+			append_entry(&p, prefix, ap->tag,
+			    name, ap->permset, id);
+			count ++;
+		}
+	}
+
+	*acl_text = acl->acl_text;
+	if (acl_text_len != NULL)
+		*acl_text_len = strlen(acl->acl_text);
+	return (0);
+}
+
+static void
+append_id(char **p, int id)
+{
+	if (id < 0)
+		id = 0;
+	if (id > 9)
+		append_id(p, id / 10);
+	*(*p)++ = "0123456789"[id % 10];
+}
+
+static void
+append_entry(char **p, const char *prefix, int tag,
+    const char *name, int perm, int id)
+{
+	if (prefix != NULL) {
+		strcpy(*p, prefix);
+		*p += strlen(*p);
+	}
+	switch (tag) {
+	case ARCHIVE_ENTRY_ACL_USER_OBJ:
+		name = NULL;
+		id = -1;
+		/* FALLTHROUGH */
+	case ARCHIVE_ENTRY_ACL_USER:
+		strcpy(*p, "user");
+		break;
+	case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+		name = NULL;
+		id = -1;
+		/* FALLTHROUGH */
+	case ARCHIVE_ENTRY_ACL_GROUP:
+		strcpy(*p, "group");
+		break;
+	case ARCHIVE_ENTRY_ACL_MASK:
+		strcpy(*p, "mask");
+		name = NULL;
+		id = -1;
+		break;
+	case ARCHIVE_ENTRY_ACL_OTHER:
+		strcpy(*p, "other");
+		name = NULL;
+		id = -1;
+		break;
+	}
+	*p += strlen(*p);
+	*(*p)++ = ':';
+	if (name != NULL) {
+		strcpy(*p, name);
+		*p += strlen(*p);
+	} else if (tag == ARCHIVE_ENTRY_ACL_USER
+	    || tag == ARCHIVE_ENTRY_ACL_GROUP) {
+		append_id(p, id);
+		id = -1;
+	}
+	*(*p)++ = ':';
+	*(*p)++ = (perm & 0444) ? 'r' : '-';
+	*(*p)++ = (perm & 0222) ? 'w' : '-';
+	*(*p)++ = (perm & 0111) ? 'x' : '-';
+	if (id != -1) {
+		*(*p)++ = ':';
+		append_id(p, id);
+	}
+	**p = '\0';
+}
+
+/*
+ * Parse a textual ACL.  This automatically recognizes and supports
+ * extensions described above.  The 'type' argument is used to
+ * indicate the type that should be used for any entries not
+ * explicitly marked as "default:".
+ */
+int
+archive_acl_parse_w(struct archive_acl *acl,
+    const wchar_t *text, int default_type)
+{
+	struct {
+		const wchar_t *start;
+		const wchar_t *end;
+	} field[4], name;
+
+	int fields, n;
+	int type, tag, permset, id;
+	wchar_t sep;
+
+	while (text != NULL  &&  *text != L'\0') {
+		/*
+		 * Parse the fields out of the next entry,
+		 * advance 'text' to start of next entry.
+		 */
+		fields = 0;
+		do {
+			const wchar_t *start, *end;
+			next_field_w(&text, &start, &end, &sep);
+			if (fields < 4) {
+				field[fields].start = start;
+				field[fields].end = end;
+			}
+			++fields;
+		} while (sep == L':');
+
+		/* Set remaining fields to blank. */
+		for (n = fields; n < 4; ++n)
+			field[n].start = field[n].end = NULL;
+
+		/* Check for a numeric ID in field 1 or 3. */
+		id = -1;
+		isint_w(field[1].start, field[1].end, &id);
+		/* Field 3 is optional. */
+		if (id == -1 && fields > 3)
+			isint_w(field[3].start, field[3].end, &id);
+
+		/*
+		 * Solaris extension:  "defaultuser::rwx" is the
+		 * default ACL corresponding to "user::rwx", etc.
+		 */
+		if (field[0].end - field[0].start > 7
+		    && wmemcmp(field[0].start, L"default", 7) == 0) {
+			type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+			field[0].start += 7;
+		} else
+			type = default_type;
+
+		name.start = name.end = NULL;
+		if (prefix_w(field[0].start, field[0].end, L"user")) {
+			if (!ismode_w(field[2].start, field[2].end, &permset))
+				return (ARCHIVE_WARN);
+			if (id != -1 || field[1].start < field[1].end) {
+				tag = ARCHIVE_ENTRY_ACL_USER;
+				name = field[1];
+			} else
+				tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+		} else if (prefix_w(field[0].start, field[0].end, L"group")) {
+			if (!ismode_w(field[2].start, field[2].end, &permset))
+				return (ARCHIVE_WARN);
+			if (id != -1 || field[1].start < field[1].end) {
+				tag = ARCHIVE_ENTRY_ACL_GROUP;
+				name = field[1];
+			} else
+				tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+		} else if (prefix_w(field[0].start, field[0].end, L"other")) {
+			if (fields == 2
+			    && field[1].start < field[1].end
+			    && ismode_w(field[1].start, field[1].end, &permset)) {
+				/* This is Solaris-style "other:rwx" */
+			} else if (fields == 3
+			    && field[1].start == field[1].end
+			    && field[2].start < field[2].end
+			    && ismode_w(field[2].start, field[2].end, &permset)) {
+				/* This is FreeBSD-style "other::rwx" */
+			} else
+				return (ARCHIVE_WARN);
+			tag = ARCHIVE_ENTRY_ACL_OTHER;
+		} else if (prefix_w(field[0].start, field[0].end, L"mask")) {
+			if (fields == 2
+			    && field[1].start < field[1].end
+			    && ismode_w(field[1].start, field[1].end, &permset)) {
+				/* This is Solaris-style "mask:rwx" */
+			} else if (fields == 3
+			    && field[1].start == field[1].end
+			    && field[2].start < field[2].end
+			    && ismode_w(field[2].start, field[2].end, &permset)) {
+				/* This is FreeBSD-style "mask::rwx" */
+			} else
+				return (ARCHIVE_WARN);
+			tag = ARCHIVE_ENTRY_ACL_MASK;
+		} else
+			return (ARCHIVE_WARN);
+
+		/* Add entry to the internal list. */
+		archive_acl_add_entry_w_len(acl, type, permset,
+		    tag, id, name.start, name.end - name.start);
+	}
+	return (ARCHIVE_OK);
+}
+
+/*
+ * Parse a string to a positive decimal integer.  Returns true if
+ * the string is non-empty and consists only of decimal digits,
+ * false otherwise.
+ */
+static int
+isint_w(const wchar_t *start, const wchar_t *end, int *result)
+{
+	int n = 0;
+	if (start >= end)
+		return (0);
+	while (start < end) {
+		if (*start < '0' || *start > '9')
+			return (0);
+		if (n > (INT_MAX / 10) ||
+		    (n == INT_MAX / 10 && (*start - '0') > INT_MAX % 10)) {
+			n = INT_MAX;
+		} else {
+			n *= 10;
+			n += *start - '0';
+		}
+		start++;
+	}
+	*result = n;
+	return (1);
+}
+
+/*
+ * Parse a string as a mode field.  Returns true if
+ * the string is non-empty and consists only of mode characters,
+ * false otherwise.
+ */
+static int
+ismode_w(const wchar_t *start, const wchar_t *end, int *permset)
+{
+	const wchar_t *p;
+
+	if (start >= end)
+		return (0);
+	p = start;
+	*permset = 0;
+	while (p < end) {
+		switch (*p++) {
+		case 'r': case 'R':
+			*permset |= ARCHIVE_ENTRY_ACL_READ;
+			break;
+		case 'w': case 'W':
+			*permset |= ARCHIVE_ENTRY_ACL_WRITE;
+			break;
+		case 'x': case 'X':
+			*permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+			break;
+		case '-':
+			break;
+		default:
+			return (0);
+		}
+	}
+	return (1);
+}
+
+/*
+ * Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]".  *wp is updated
+ * to point to just after the separator.  *start points to the first
+ * character of the matched text and *end just after the last
+ * character of the matched identifier.  In particular *end - *start
+ * is the length of the field body, not including leading or trailing
+ * whitespace.
+ */
+static void
+next_field_w(const wchar_t **wp, const wchar_t **start,
+    const wchar_t **end, wchar_t *sep)
+{
+	/* Skip leading whitespace to find start of field. */
+	while (**wp == L' ' || **wp == L'\t' || **wp == L'\n') {
+		(*wp)++;
+	}
+	*start = *wp;
+
+	/* Scan for the separator. */
+	while (**wp != L'\0' && **wp != L',' && **wp != L':' &&
+	    **wp != L'\n') {
+		(*wp)++;
+	}
+	*sep = **wp;
+
+	/* Trim trailing whitespace to locate end of field. */
+	*end = *wp - 1;
+	while (**end == L' ' || **end == L'\t' || **end == L'\n') {
+		(*end)--;
+	}
+	(*end)++;
+
+	/* Adjust scanner location. */
+	if (**wp != L'\0')
+		(*wp)++;
+}
+
+/*
+ * Return true if the characters [start...end) are a prefix of 'test'.
+ * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc.
+ */
+static int
+prefix_w(const wchar_t *start, const wchar_t *end, const wchar_t *test)
+{
+	if (start == end)
+		return (0);
+
+	if (*start++ != *test++)
+		return (0);
+
+	while (start < end  &&  *start++ == *test++)
+		;
+
+	if (start < end)
+		return (0);
+
+	return (1);
+}
+
+/*
+ * Parse a textual ACL.  This automatically recognizes and supports
+ * extensions described above.  The 'type' argument is used to
+ * indicate the type that should be used for any entries not
+ * explicitly marked as "default:".
+ */
+int
+archive_acl_parse_l(struct archive_acl *acl,
+    const char *text, int default_type, struct archive_string_conv *sc)
+{
+	struct {
+		const char *start;
+		const char *end;
+	} field[4], name;
+
+	int fields, n, r, ret = ARCHIVE_OK;
+	int type, tag, permset, id;
+	char sep;
+
+	while (text != NULL  &&  *text != '\0') {
+		/*
+		 * Parse the fields out of the next entry,
+		 * advance 'text' to start of next entry.
+		 */
+		fields = 0;
+		do {
+			const char *start, *end;
+			next_field(&text, &start, &end, &sep);
+			if (fields < 4) {
+				field[fields].start = start;
+				field[fields].end = end;
+			}
+			++fields;
+		} while (sep == ':');
+
+		/* Set remaining fields to blank. */
+		for (n = fields; n < 4; ++n)
+			field[n].start = field[n].end = NULL;
+
+		/* Check for a numeric ID in field 1 or 3. */
+		id = -1;
+		isint(field[1].start, field[1].end, &id);
+		/* Field 3 is optional. */
+		if (id == -1 && fields > 3)
+			isint(field[3].start, field[3].end, &id);
+
+		/*
+		 * Solaris extension:  "defaultuser::rwx" is the
+		 * default ACL corresponding to "user::rwx", etc.
+		 */
+		if (field[0].end - field[0].start > 7
+		    && memcmp(field[0].start, "default", 7) == 0) {
+			type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+			field[0].start += 7;
+		} else
+			type = default_type;
+
+		name.start = name.end = NULL;
+		if (prefix(field[0].start, field[0].end, "user")) {
+			if (!ismode(field[2].start, field[2].end, &permset))
+				return (ARCHIVE_WARN);
+			if (id != -1 || field[1].start < field[1].end) {
+				tag = ARCHIVE_ENTRY_ACL_USER;
+				name = field[1];
+			} else
+				tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+		} else if (prefix(field[0].start, field[0].end, "group")) {
+			if (!ismode(field[2].start, field[2].end, &permset))
+				return (ARCHIVE_WARN);
+			if (id != -1 || field[1].start < field[1].end) {
+				tag = ARCHIVE_ENTRY_ACL_GROUP;
+				name = field[1];
+			} else
+				tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+		} else if (prefix(field[0].start, field[0].end, "other")) {
+			if (fields == 2
+			    && field[1].start < field[1].end
+			    && ismode(field[1].start, field[1].end, &permset)) {
+				/* This is Solaris-style "other:rwx" */
+			} else if (fields == 3
+			    && field[1].start == field[1].end
+			    && field[2].start < field[2].end
+			    && ismode(field[2].start, field[2].end, &permset)) {
+				/* This is FreeBSD-style "other::rwx" */
+			} else
+				return (ARCHIVE_WARN);
+			tag = ARCHIVE_ENTRY_ACL_OTHER;
+		} else if (prefix(field[0].start, field[0].end, "mask")) {
+			if (fields == 2
+			    && field[1].start < field[1].end
+			    && ismode(field[1].start, field[1].end, &permset)) {
+				/* This is Solaris-style "mask:rwx" */
+			} else if (fields == 3
+			    && field[1].start == field[1].end
+			    && field[2].start < field[2].end
+			    && ismode(field[2].start, field[2].end, &permset)) {
+				/* This is FreeBSD-style "mask::rwx" */
+			} else
+				return (ARCHIVE_WARN);
+			tag = ARCHIVE_ENTRY_ACL_MASK;
+		} else
+			return (ARCHIVE_WARN);
+
+		/* Add entry to the internal list. */
+		r = archive_acl_add_entry_len_l(acl, type, permset,
+		    tag, id, name.start, name.end - name.start, sc);
+		if (r < ARCHIVE_WARN)
+			return (r);
+		if (r != ARCHIVE_OK)
+			ret = ARCHIVE_WARN;
+	}
+	return (ret);
+}
+
+/*
+ * Parse a string to a positive decimal integer.  Returns true if
+ * the string is non-empty and consists only of decimal digits,
+ * false otherwise.
+ */
+static int
+isint(const char *start, const char *end, int *result)
+{
+	int n = 0;
+	if (start >= end)
+		return (0);
+	while (start < end) {
+		if (*start < '0' || *start > '9')
+			return (0);
+		if (n > (INT_MAX / 10) ||
+		    (n == INT_MAX / 10 && (*start - '0') > INT_MAX % 10)) {
+			n = INT_MAX;
+		} else {
+			n *= 10;
+			n += *start - '0';
+		}
+		start++;
+	}
+	*result = n;
+	return (1);
+}
+
+/*
+ * Parse a string as a mode field.  Returns true if
+ * the string is non-empty and consists only of mode characters,
+ * false otherwise.
+ */
+static int
+ismode(const char *start, const char *end, int *permset)
+{
+	const char *p;
+
+	if (start >= end)
+		return (0);
+	p = start;
+	*permset = 0;
+	while (p < end) {
+		switch (*p++) {
+		case 'r': case 'R':
+			*permset |= ARCHIVE_ENTRY_ACL_READ;
+			break;
+		case 'w': case 'W':
+			*permset |= ARCHIVE_ENTRY_ACL_WRITE;
+			break;
+		case 'x': case 'X':
+			*permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+			break;
+		case '-':
+			break;
+		default:
+			return (0);
+		}
+	}
+	return (1);
+}
+
+/*
+ * Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]".  *wp is updated
+ * to point to just after the separator.  *start points to the first
+ * character of the matched text and *end just after the last
+ * character of the matched identifier.  In particular *end - *start
+ * is the length of the field body, not including leading or trailing
+ * whitespace.
+ */
+static void
+next_field(const char **p, const char **start,
+    const char **end, char *sep)
+{
+	/* Skip leading whitespace to find start of field. */
+	while (**p == ' ' || **p == '\t' || **p == '\n') {
+		(*p)++;
+	}
+	*start = *p;
+
+	/* Scan for the separator. */
+	while (**p != '\0' && **p != ',' && **p != ':' && **p != '\n') {
+		(*p)++;
+	}
+	*sep = **p;
+
+	/* Trim trailing whitespace to locate end of field. */
+	*end = *p - 1;
+	while (**end == ' ' || **end == '\t' || **end == '\n') {
+		(*end)--;
+	}
+	(*end)++;
+
+	/* Adjust scanner location. */
+	if (**p != '\0')
+		(*p)++;
+}
+
+/*
+ * Return true if the characters [start...end) are a prefix of 'test'.
+ * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc.
+ */
+static int
+prefix(const char *start, const char *end, const char *test)
+{
+	if (start == end)
+		return (0);
+
+	if (*start++ != *test++)
+		return (0);
+
+	while (start < end  &&  *start++ == *test++)
+		;
+
+	if (start < end)
+		return (0);
+
+	return (1);
+}

+ 87 - 0
Utilities/cmlibarchive/libarchive/archive_acl_private.h

@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2003-2010 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+#ifndef ARCHIVE_ACL_PRIVATE_H_INCLUDED
+#define	ARCHIVE_ACL_PRIVATE_H_INCLUDED
+
+#include "archive_string.h"
+
+struct archive_acl_entry {
+	struct archive_acl_entry *next;
+	int	type;			/* E.g., access or default */
+	int	tag;			/* E.g., user/group/other/mask */
+	int	permset;		/* r/w/x bits */
+	int	id;			/* uid/gid for user/group */
+	struct archive_mstring name;		/* uname/gname */
+};
+
+struct archive_acl {
+	mode_t		mode;
+	struct archive_acl_entry	*acl_head;
+	struct archive_acl_entry	*acl_p;
+	int		 acl_state;	/* See acl_next for details. */
+	wchar_t		*acl_text_w;
+	char		*acl_text;
+	int		 acl_types;
+};
+
+void archive_acl_clear(struct archive_acl *);
+void archive_acl_copy(struct archive_acl *, struct archive_acl *);
+int archive_acl_count(struct archive_acl *, int);
+int archive_acl_reset(struct archive_acl *, int);
+int archive_acl_next(struct archive *, struct archive_acl *, int,
+    int *, int *, int *, int *, const char **);
+
+int archive_acl_add_entry(struct archive_acl *, int, int, int, int, const char *);
+int archive_acl_add_entry_w_len(struct archive_acl *,
+    int, int, int, int, const wchar_t *, size_t);
+int archive_acl_add_entry_len(struct archive_acl *,
+    int, int, int, int, const char *, size_t);
+
+const wchar_t *archive_acl_text_w(struct archive *, struct archive_acl *, int);
+int archive_acl_text_l(struct archive_acl *, int, const char **, size_t *,
+    struct archive_string_conv *);
+
+/*
+ * Private ACL parser.  This is private because it handles some
+ * very weird formats that clients should not be messing with.
+ * Clients should only deal with their platform-native formats.
+ * Because of the need to support many formats cleanly, new arguments
+ * are likely to get added on a regular basis.  Clients who try to use
+ * this interface are likely to be surprised when it changes.
+ */
+int archive_acl_parse_w(struct archive_acl *,
+		    const wchar_t *, int /* type */);
+int archive_acl_parse_l(struct archive_acl *,
+		    const char *, int /* type */,
+		    struct archive_string_conv *);
+
+#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */

+ 97 - 58
Utilities/cmlibarchive/libarchive/archive_check_magic.c

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2010 Tim Kientzle
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_check_magic.c,v 1.9 2008/12/06 05:52:01 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_check_magic.c 201089 2009-12-28 02:20:23Z kientzle $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -50,86 +50,125 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_check_magic.c,v 1.9 2008/12/06 05
 static void
 errmsg(const char *m)
 {
-    size_t s = strlen(m);
-    ssize_t written;
-
-    while (s > 0) {
-        written = write(2, m, strlen(m));
-        if (written <= 0)
-            return;
-        m += written;
-        s -= written;
-    }
+	size_t s = strlen(m);
+	ssize_t written;
+
+	while (s > 0) {
+		written = write(2, m, strlen(m));
+		if (written <= 0)
+			return;
+		m += written;
+		s -= written;
+	}
 }
 
 static void
 diediedie(void)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
-    /* Cause a breakpoint exception  */
-    DebugBreak();
+	/* Cause a breakpoint exception  */
+	DebugBreak();
 #endif
-    *(char *)1 = 1; /* Deliberately segfault and force a coredump. */
-    _exit(1);   /* If that didn't work, just exit with an error. */
+	abort();        /* Terminate the program abnormally. */
 }
 
 static const char *
 state_name(unsigned s)
 {
-    switch (s) {
-    case ARCHIVE_STATE_NEW:     return ("new");
-    case ARCHIVE_STATE_HEADER:  return ("header");
-    case ARCHIVE_STATE_DATA:    return ("data");
-    case ARCHIVE_STATE_EOF:     return ("eof");
-    case ARCHIVE_STATE_CLOSED:  return ("closed");
-    case ARCHIVE_STATE_FATAL:   return ("fatal");
-    default:            return ("??");
-    }
+	switch (s) {
+	case ARCHIVE_STATE_NEW:		return ("new");
+	case ARCHIVE_STATE_HEADER:	return ("header");
+	case ARCHIVE_STATE_DATA:	return ("data");
+	case ARCHIVE_STATE_EOF:		return ("eof");
+	case ARCHIVE_STATE_CLOSED:	return ("closed");
+	case ARCHIVE_STATE_FATAL:	return ("fatal");
+	default:			return ("??");
+	}
+}
+
+static const char *
+archive_handle_type_name(unsigned m)
+{
+	switch (m) {
+	case ARCHIVE_WRITE_MAGIC:	return ("archive_write");
+	case ARCHIVE_READ_MAGIC:	return ("archive_read");
+	case ARCHIVE_WRITE_DISK_MAGIC:	return ("archive_write_disk");
+	case ARCHIVE_READ_DISK_MAGIC:	return ("archive_read_disk");
+	default:			return NULL;
+	}
 }
 
 
-static void
-write_all_states(unsigned int states)
+static char *
+write_all_states(char *buff, unsigned int states)
 {
-    unsigned int lowbit;
-
-    /* A trick for computing the lowest set bit. */
-    while ((lowbit = states & (1 + ~states)) != 0) {
-        states &= ~lowbit;      /* Clear the low bit. */
-        errmsg(state_name(lowbit));
-        if (states != 0)
-            errmsg("/");
-    }
+	unsigned int lowbit;
+
+	buff[0] = '\0';
+
+	/* A trick for computing the lowest set bit. */
+	while ((lowbit = states & (1 + ~states)) != 0) {
+		states &= ~lowbit;		/* Clear the low bit. */
+		strcat(buff, state_name(lowbit));
+		if (states != 0)
+			strcat(buff, "/");
+	}
+	return buff;
 }
 
 /*
- * Check magic value and current state; bail if it isn't valid.
+ * Check magic value and current state.
+ *   Magic value mismatches are fatal and result in calls to abort().
+ *   State mismatches return ARCHIVE_FATAL.
+ *   Otherwise, returns ARCHIVE_OK.
  *
  * This is designed to catch serious programming errors that violate
  * the libarchive API.
  */
-void
+int
 __archive_check_magic(struct archive *a, unsigned int magic,
     unsigned int state, const char *function)
 {
-    if (a->magic != magic) {
-        errmsg("INTERNAL ERROR: Function ");
-        errmsg(function);
-        errmsg(" invoked with invalid struct archive structure.\n");
-        diediedie();
-    }
-
-    if (state == ARCHIVE_STATE_ANY)
-        return;
-
-    if ((a->state & state) == 0) {
-        errmsg("INTERNAL ERROR: Function '");
-        errmsg(function);
-        errmsg("' invoked with archive structure in state '");
-        write_all_states(a->state);
-        errmsg("', should be in state '");
-        write_all_states(state);
-        errmsg("'\n");
-        diediedie();
-    }
+	char states1[64];
+	char states2[64];
+	const char *handle_type;
+
+	/*
+	 * If this isn't some form of archive handle,
+	 * then the library user has screwed up so bad that
+	 * we don't even have a reliable way to report an error.
+	 */
+	handle_type = archive_handle_type_name(a->magic);
+
+	if (!handle_type) {
+		errmsg("PROGRAMMER ERROR: Function ");
+		errmsg(function);
+		errmsg(" invoked with invalid archive handle.\n");
+		diediedie();
+	}
+
+	if (a->magic != magic) {
+		archive_set_error(a, -1,
+		    "PROGRAMMER ERROR: Function '%s' invoked"
+		    " on '%s' archive object, which is not supported.",
+		    function,
+		    handle_type);
+		a->state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
+
+	if ((a->state & state) == 0) {
+		/* If we're already FATAL, don't overwrite the error. */
+		if (a->state != ARCHIVE_STATE_FATAL)
+			archive_set_error(a, -1,
+			    "INTERNAL ERROR: Function '%s' invoked with"
+			    " archive structure in state '%s',"
+			    " should be in state '%s'",
+			    function,
+			    write_all_states(states1, a->state),
+			    write_all_states(states2, state));
+		a->state = ARCHIVE_STATE_FATAL;
+		return (ARCHIVE_FATAL);
+	}
+	return ARCHIVE_OK;
 }

Some files were not shown because too many files changed in this diff