Author: mm
Date: Sun Jul 17 21:27:38 2011
New Revision: 224152
URL: http://svn.freebsd.org/changeset/base/224152

Log:
  - Update libarchive to 2.8.4
  - Add support for extracting xar and rpm archives
  - Add libarchive_fe subdir (common code for tar and cpio)
  
  Approved by:  kientzle
  MFC after:    2 weeks

Added:
  head/lib/libarchive/archive_read_support_compression_rpm.c   (contents, props 
changed)
  head/lib/libarchive/archive_read_support_format_xar.c   (contents, props 
changed)
  head/lib/libarchive/libarchive_fe/
  head/lib/libarchive/libarchive_fe/err.c   (contents, props changed)
  head/lib/libarchive/libarchive_fe/err.h   (contents, props changed)
  head/lib/libarchive/libarchive_fe/lafe_platform.h   (contents, props changed)
  head/lib/libarchive/libarchive_fe/line_reader.c   (contents, props changed)
  head/lib/libarchive/libarchive_fe/line_reader.h   (contents, props changed)
  head/lib/libarchive/libarchive_fe/matching.c   (contents, props changed)
  head/lib/libarchive/libarchive_fe/matching.h   (contents, props changed)
  head/lib/libarchive/libarchive_fe/pathmatch.c   (contents, props changed)
  head/lib/libarchive/libarchive_fe/pathmatch.h   (contents, props changed)
  head/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c   (contents, 
props changed)
  head/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu   
(contents, props changed)
  head/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c   (contents, 
props changed)
  head/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu   
(contents, props changed)
  head/lib/libarchive/test/test_read_format_xar.c   (contents, props changed)
Modified:
  head/lib/libarchive/Makefile
  head/lib/libarchive/README
  head/lib/libarchive/archive.h
  head/lib/libarchive/archive_hash.h
  head/lib/libarchive/archive_read.3
  head/lib/libarchive/archive_read_disk_entry_from_file.c
  head/lib/libarchive/archive_read_disk_set_standard_lookup.c
  head/lib/libarchive/archive_read_support_compression_all.c
  head/lib/libarchive/archive_read_support_compression_bzip2.c
  head/lib/libarchive/archive_read_support_compression_uu.c
  head/lib/libarchive/archive_read_support_format_all.c
  head/lib/libarchive/archive_read_support_format_mtree.c
  head/lib/libarchive/archive_write_disk.c
  head/lib/libarchive/archive_write_disk_set_standard_lookup.c
  head/lib/libarchive/archive_write_set_compression_bzip2.c
  head/lib/libarchive/config_freebsd.h
  head/lib/libarchive/filter_fork.c
  head/lib/libarchive/test/Makefile
  head/lib/libarchive/test/main.c
  head/lib/libarchive/test/read_open_memory.c
  head/lib/libarchive/test/test.h
  head/lib/libarchive/test/test_entry.c
  head/lib/libarchive/test/test_fuzz.c
  head/lib/libarchive/test/test_pax_filename_encoding.c
  head/lib/libarchive/test/test_read_data_large.c
  head/lib/libarchive/test/test_read_large.c
  head/lib/libarchive/test/test_read_truncated.c
  head/lib/libarchive/test/test_ustar_filenames.c
  head/lib/libarchive/test/test_write_format_cpio.c

Modified: head/lib/libarchive/Makefile
==============================================================================
--- head/lib/libarchive/Makefile        Sun Jul 17 21:15:20 2011        
(r224151)
+++ head/lib/libarchive/Makefile        Sun Jul 17 21:27:38 2011        
(r224152)
@@ -13,6 +13,9 @@ DPADD+= ${LIBLZMA}
 LDADD+= -llzma
 CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
 
+DPADD+= ${LIBBSDXML}
+LDADD+= -lbsdxml
+
 # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system.
 # It has no real relation to the libarchive version number.
 SHLIB_MAJOR= 5
@@ -56,6 +59,7 @@ SRCS= archive_check_magic.c                           \
        archive_read_support_compression_gzip.c         \
        archive_read_support_compression_none.c         \
        archive_read_support_compression_program.c      \
+       archive_read_support_compression_rpm.c          \
        archive_read_support_compression_uu.c           \
        archive_read_support_compression_xz.c           \
        archive_read_support_format_all.c               \
@@ -66,6 +70,7 @@ SRCS= archive_check_magic.c                           \
        archive_read_support_format_mtree.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_sprintf.c                        \

Modified: head/lib/libarchive/README
==============================================================================
--- head/lib/libarchive/README  Sun Jul 17 21:15:20 2011        (r224151)
+++ head/lib/libarchive/README  Sun Jul 17 21:27:38 2011        (r224152)
@@ -21,6 +21,7 @@ Currently, the library automatically det
   * 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)
@@ -30,18 +31,26 @@ Currently, the library automatically det
   * POSIX octet-oriented cpio
   * SVR4 ASCII cpio
   * Binary cpio (big-endian or little-endian)
-  * ISO9660 CD-ROM images (with optional Rockridge extensions)
+  * 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:
  * This is a heavily stream-oriented system.  There is no direct

Modified: head/lib/libarchive/archive.h
==============================================================================
--- head/lib/libarchive/archive.h       Sun Jul 17 21:15:20 2011        
(r224151)
+++ head/lib/libarchive/archive.h       Sun Jul 17 21:27:38 2011        
(r224152)
@@ -52,7 +52,9 @@
 /* These should match the types used in 'struct stat' */
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define        __LA_INT64_T    __int64
-# if   defined(_WIN64)
+# if defined(_SSIZE_T_DEFINED)
+#  define      __LA_SSIZE_T    ssize_t
+# elif defined(_WIN64)
 #  define      __LA_SSIZE_T    __int64
 # else
 #  define      __LA_SSIZE_T    long
@@ -127,13 +129,13 @@ extern "C" {
  *             (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
  * #endif
  */
-#define        ARCHIVE_VERSION_NUMBER 2007901
+#define        ARCHIVE_VERSION_NUMBER 2008004
 __LA_DECL int          archive_version_number(void);
 
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define        ARCHIVE_VERSION_STRING "libarchive 2.7.901a"
+#define        ARCHIVE_VERSION_STRING "libarchive 2.8.4"
 __LA_DECL const char * archive_version_string(void);
 
 #if ARCHIVE_VERSION_NUMBER < 3000000
@@ -319,6 +321,7 @@ __LA_DECL int                archive_read_support_com
                                (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 *);
 
@@ -331,6 +334,7 @@ __LA_DECL int                archive_read_support_for
 __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_xar(struct archive *);
 __LA_DECL int           archive_read_support_format_zip(struct archive *);
 
 

Modified: head/lib/libarchive/archive_hash.h
==============================================================================
--- head/lib/libarchive/archive_hash.h  Sun Jul 17 21:15:20 2011        
(r224151)
+++ head/lib/libarchive/archive_hash.h  Sun Jul 17 21:27:38 2011        
(r224152)
@@ -29,6 +29,10 @@
 #error This header is only to be used internally to libarchive.
 #endif
 
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
 /*
  * Hash function support in various Operating Systems:
  *
@@ -41,43 +45,71 @@
  * - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name
  *
  * DragonFly and FreeBSD (XXX not used yet):
- * - MD5 in libmd: without _ after algorithm name
- * - SHA{1,256,512} in libmd: with _ after algorithm name (conflicts 
w/OpenSSL!)
+ * - MD5 and SHA1 in libmd: without _ after algorithm name
+ * - SHA256: with _ after algorithm name
+ *
+ * Mac OS X (10.4 and later):
+ * - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm 
name
  *
  * OpenSSL:
- * - MD5, SHA1, SHA2, SHA{256,384,512} in libcrypto: with _ after algorithm 
name
+ * - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name
+ *
+ * Windows:
+ * - MD5, SHA1 and SHA2 in archive_windows.c: without algorithm name
+ *   and with __la_ prefix.
  */
+#if defined(ARCHIVE_HASH_MD5_WIN)    ||\
+      defined(ARCHIVE_HASH_SHA1_WIN)   || defined(ARCHIVE_HASH_SHA256_WIN) ||\
+      defined(ARCHIVE_HASH_SHA384_WIN) || defined(ARCHIVE_HASH_SHA512_WIN)
+#include <wincrypt.h>
+typedef struct {
+       int             valid;
+       HCRYPTPROV      cryptProv;
+       HCRYPTHASH      hash;
+} Digest_CTX;
+extern void __la_hash_Init(Digest_CTX *, ALG_ID);
+extern void __la_hash_Final(unsigned char *, size_t, Digest_CTX *);
+extern void __la_hash_Update(Digest_CTX *, const unsigned char *, size_t);
+#endif
 
-#if defined(HAVE_MD5_H) && defined(HAVE_MD5INIT)
+#if defined(ARCHIVE_HASH_MD5_LIBC)
 #  include <md5.h>
 #  define ARCHIVE_HAS_MD5
 typedef MD5_CTX archive_md5_ctx;
 #  define archive_md5_init(ctx)                        MD5Init(ctx)
 #  define archive_md5_final(ctx, buf)          MD5Final(buf, ctx)
 #  define archive_md5_update(ctx, buf, n)      MD5Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_MD5_H)
+#elif defined(ARCHIVE_HASH_MD5_LIBSYSTEM)
+#  include <CommonCrypto/CommonDigest.h>
+#  define ARCHIVE_HAS_MD5
+typedef CC_MD5_CTX archive_md5_ctx;
+#  define archive_md5_init(ctx)                        CC_MD5_Init(ctx)
+#  define archive_md5_final(ctx, buf)          CC_MD5_Final(buf, ctx)
+#  define archive_md5_update(ctx, buf, n)      CC_MD5_Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_MD5_OPENSSL)
 #  include <openssl/md5.h>
 #  define ARCHIVE_HAS_MD5
 typedef MD5_CTX archive_md5_ctx;
 #  define archive_md5_init(ctx)                        MD5_Init(ctx)
 #  define archive_md5_final(ctx, buf)          MD5_Final(buf, ctx)
 #  define archive_md5_update(ctx, buf, n)      MD5_Update(ctx, buf, n)
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_MD5)
+#elif defined(ARCHIVE_HASH_MD5_WIN)
 #  define ARCHIVE_HAS_MD5
-typedef MD5_CTX archive_md5_ctx;
-#  define archive_md5_init(ctx)                        MD5_Init(ctx)
-#  define archive_md5_final(ctx, buf)          MD5_Final(buf, ctx)
-#  define archive_md5_update(ctx, buf, n)      MD5_Update(ctx, buf, n)
+#  define MD5_DIGEST_LENGTH    16
+typedef Digest_CTX archive_md5_ctx;
+#  define archive_md5_init(ctx)                        __la_hash_Init(ctx, 
CALG_MD5)
+#  define archive_md5_final(ctx, buf)          __la_hash_Final(buf, 
MD5_DIGEST_LENGTH, ctx)
+#  define archive_md5_update(ctx, buf, n)      __la_hash_Update(ctx, buf, n)
 #endif
 
-#if defined(HAVE_RMD160_H) && defined(HAVE_RMD160INIT)
+#if defined(ARCHIVE_HASH_RMD160_LIBC)
 #  include <rmd160.h>
 #  define ARCHIVE_HAS_RMD160
 typedef RMD160_CTX archive_rmd160_ctx;
 #  define archive_rmd160_init(ctx)             RMD160Init(ctx)
 #  define archive_rmd160_final(ctx, buf)       RMD160Final(buf, ctx)
 #  define archive_rmd160_update(ctx, buf, n)   RMD160Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_RIPEMD_H)
+#elif defined(ARCHIVE_HASH_RMD160_OPENSSL)
 #  include <openssl/ripemd.h>
 #  define ARCHIVE_HAS_RMD160
 typedef RIPEMD160_CTX archive_rmd160_ctx;
@@ -86,111 +118,164 @@ typedef RIPEMD160_CTX archive_rmd160_ctx
 #  define archive_rmd160_update(ctx, buf, n)   RIPEMD160_Update(ctx, buf, n)
 #endif
 
-#if defined(HAVE_SHA1_H) && defined(HAVE_SHA1INIT)
+#if defined(ARCHIVE_HASH_SHA1_LIBC)
 #  include <sha1.h>
 #  define ARCHIVE_HAS_SHA1
 typedef SHA1_CTX archive_sha1_ctx;
 #  define archive_sha1_init(ctx)               SHA1Init(ctx)
 #  define archive_sha1_final(ctx, buf)         SHA1Final(buf, ctx)
 #  define archive_sha1_update(ctx, buf, n)     SHA1Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H)
+#elif defined(ARCHIVE_HASH_SHA1_LIBSYSTEM)
+#  include <CommonCrypto/CommonDigest.h>
+#  define ARCHIVE_HAS_SHA1
+typedef CC_SHA1_CTX archive_sha1_ctx;
+#  define archive_sha1_init(ctx)               CC_SHA1_Init(ctx)
+#  define archive_sha1_final(ctx, buf)         CC_SHA1_Final(buf, ctx)
+#  define archive_sha1_update(ctx, buf, n)     CC_SHA1_Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA1_OPENSSL)
 #  include <openssl/sha.h>
 #  define ARCHIVE_HAS_SHA1
 typedef SHA_CTX archive_sha1_ctx;
 #  define archive_sha1_init(ctx)               SHA1_Init(ctx)
 #  define archive_sha1_final(ctx, buf)         SHA1_Final(buf, ctx)
 #  define archive_sha1_update(ctx, buf, n)     SHA1_Update(ctx, buf, n)
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA1)
+#elif defined(ARCHIVE_HASH_SHA1_WIN)
 #  define ARCHIVE_HAS_SHA1
-typedef SHA1_CTX archive_sha1_ctx;
-#  define archive_sha1_init(ctx)               SHA1_Init(ctx)
-#  define archive_sha1_final(ctx, buf)         SHA1_Final(buf, ctx)
-#  define archive_sha1_update(ctx, buf, n)     SHA1_Update(ctx, buf, n)
+#  define SHA1_DIGEST_LENGTH   20
+typedef Digest_CTX archive_sha1_ctx;
+#  define archive_sha1_init(ctx)               __la_hash_Init(ctx, CALG_SHA1)
+#  define archive_sha1_final(ctx, buf)         __la_hash_Final(buf, 
SHA1_DIGEST_LENGTH, ctx)
+#  define archive_sha1_update(ctx, buf, n)     __la_hash_Update(ctx, buf, n)
 #endif
 
-#if defined(HAVE_SHA2_H) && defined(HAVE_SHA256_INIT)
+#if defined(ARCHIVE_HASH_SHA256_LIBC)
 #  include <sha2.h>
 #  define ARCHIVE_HAS_SHA256
 typedef SHA256_CTX archive_sha256_ctx;
 #  define archive_sha256_init(ctx)             SHA256_Init(ctx)
 #  define archive_sha256_final(ctx, buf)       SHA256_Final(buf, ctx)
 #  define archive_sha256_update(ctx, buf, n)   SHA256_Update(ctx, buf, n)
-#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA256INIT)
+#elif defined(ARCHIVE_HASH_SHA256_LIBC2)
 #  include <sha2.h>
 #  define ARCHIVE_HAS_SHA256
 typedef SHA256_CTX archive_sha256_ctx;
 #  define archive_sha256_init(ctx)             SHA256Init(ctx)
 #  define archive_sha256_final(ctx, buf)       SHA256Final(buf, ctx)
 #  define archive_sha256_update(ctx, buf, n)   SHA256Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA256_INIT)
+#elif defined(ARCHIVE_HASH_SHA256_LIBC3)
+#  include <sha2.h>
+#  define ARCHIVE_HAS_SHA256
+typedef SHA2_CTX archive_sha256_ctx;
+#  define archive_sha256_init(ctx)             SHA256Init(ctx)
+#  define archive_sha256_final(ctx, buf)       SHA256Final(buf, ctx)
+#  define archive_sha256_update(ctx, buf, n)   SHA256Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA256_LIBSYSTEM)
+#  include <CommonCrypto/CommonDigest.h>
+#  define ARCHIVE_HAS_SHA256
+typedef CC_SHA256_CTX archive_shs256_ctx;
+#  define archive_shs256_init(ctx)             CC_SHA256_Init(ctx)
+#  define archive_shs256_final(ctx, buf)       CC_SHA256_Final(buf, ctx)
+#  define archive_shs256_update(ctx, buf, n)   CC_SHA256_Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA256_OPENSSL)
 #  include <openssl/sha.h>
 #  define ARCHIVE_HAS_SHA256
 typedef SHA256_CTX archive_sha256_ctx;
 #  define archive_sha256_init(ctx)             SHA256_Init(ctx)
 #  define archive_sha256_final(ctx, buf)       SHA256_Final(buf, ctx)
 #  define archive_sha256_update(ctx, buf, n)   SHA256_Update(ctx, buf, n)
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_256)
+#elif defined(ARCHIVE_HASH_SHA256_WIN)
 #  define ARCHIVE_HAS_SHA256
-typedef SHA256_CTX archive_sha256_ctx;
-#  define archive_sha256_init(ctx)             SHA256_Init(ctx)
-#  define archive_sha256_final(ctx, buf)       SHA256_Final(buf, ctx)
-#  define archive_sha256_update(ctx, buf, n)   SHA256_Update(ctx, buf, n)
+#  define SHA256_DIGEST_LENGTH 32
+typedef Digest_CTX archive_sha256_ctx;
+#  define archive_sha256_init(ctx)             __la_hash_Init(ctx, 
CALG_SHA_256)
+#  define archive_sha256_final(ctx, buf)       __la_hash_Final(buf, 
SHA256_DIGEST_LENGTH, ctx)
+#  define archive_sha256_update(ctx, buf, n)   __la_hash_Update(ctx, buf, n)
 #endif
 
-#if defined(HAVE_SHA2_H) && defined(HAVE_SHA384_INIT)
+#if defined(ARCHIVE_HASH_SHA384_LIBC)
 #  include <sha2.h>
 #  define ARCHIVE_HAS_SHA384
 typedef SHA384_CTX archive_sha384_ctx;
 #  define archive_sha384_init(ctx)             SHA384_Init(ctx)
 #  define archive_sha384_final(ctx, buf)       SHA384_Final(buf, ctx)
 #  define archive_sha384_update(ctx, buf, n)   SHA384_Update(ctx, buf, n)
-#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA384INIT)
+#elif defined(ARCHIVE_HASH_SHA384_LIBC2)
 #  include <sha2.h>
 #  define ARCHIVE_HAS_SHA384
 typedef SHA384_CTX archive_sha384_ctx;
 #  define archive_sha384_init(ctx)             SHA384Init(ctx)
 #  define archive_sha384_final(ctx, buf)       SHA384Final(buf, ctx)
 #  define archive_sha384_update(ctx, buf, n)   SHA384Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA384_INIT)
+#elif defined(ARCHIVE_HASH_SHA384_LIBC3)
+#  include <sha2.h>
+#  define ARCHIVE_HAS_SHA384
+typedef SHA2_CTX archive_sha384_ctx;
+#  define archive_sha384_init(ctx)             SHA384Init(ctx)
+#  define archive_sha384_final(ctx, buf)       SHA384Final(buf, ctx)
+#  define archive_sha384_update(ctx, buf, n)   SHA384Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA384_LIBSYSTEM)
+#  include <CommonCrypto/CommonDigest.h>
+#  define ARCHIVE_HAS_SHA384
+typedef CC_SHA512_CTX archive_shs384_ctx;
+#  define archive_shs384_init(ctx)             CC_SHA384_Init(ctx)
+#  define archive_shs384_final(ctx, buf)       CC_SHA384_Final(buf, ctx)
+#  define archive_shs384_update(ctx, buf, n)   CC_SHA384_Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA384_OPENSSL)
 #  include <openssl/sha.h>
 #  define ARCHIVE_HAS_SHA384
 typedef SHA512_CTX archive_sha384_ctx;
 #  define archive_sha384_init(ctx)             SHA384_Init(ctx)
 #  define archive_sha384_final(ctx, buf)       SHA384_Final(buf, ctx)
 #  define archive_sha384_update(ctx, buf, n)   SHA384_Update(ctx, buf, n)
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_384)
+#elif defined(ARCHIVE_HASH_SHA384_WIN)
 #  define ARCHIVE_HAS_SHA384
-typedef SHA512_CTX archive_sha384_ctx;
-#  define archive_sha384_init(ctx)             SHA384_Init(ctx)
-#  define archive_sha384_final(ctx, buf)       SHA384_Final(buf, ctx)
-#  define archive_sha384_update(ctx, buf, n)   SHA384_Update(ctx, buf, n)
+#  define SHA384_DIGEST_LENGTH 48
+typedef Digest_CTX archive_sha384_ctx;
+#  define archive_sha384_init(ctx)             __la_hash_Init(ctx, 
CALG_SHA_384)
+#  define archive_sha384_final(ctx, buf)       __la_hash_Final(buf, 
SHA384_DIGEST_LENGTH, ctx)
+#  define archive_sha384_update(ctx, buf, n)   __la_hash_Update(ctx, buf, n)
 #endif
 
-#if defined(HAVE_SHA2_H) && defined(HAVE_SHA512_INIT)
+#if defined(ARCHIVE_HASH_SHA512_LIBC)
 #  include <sha2.h>
 #  define ARCHIVE_HAS_SHA512
 typedef SHA512_CTX archive_sha512_ctx;
 #  define archive_sha512_init(ctx)             SHA512_Init(ctx)
 #  define archive_sha512_final(ctx, buf)       SHA512_Final(buf, ctx)
 #  define archive_sha512_update(ctx, buf, n)   SHA512_Update(ctx, buf, n)
-#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA512INIT)
+#elif defined(ARCHIVE_HASH_SHA512_LIBC2)
 #  include <sha2.h>
 #  define ARCHIVE_HAS_SHA512
 typedef SHA512_CTX archive_sha512_ctx;
 #  define archive_sha512_init(ctx)             SHA512Init(ctx)
 #  define archive_sha512_final(ctx, buf)       SHA512Final(buf, ctx)
 #  define archive_sha512_update(ctx, buf, n)   SHA512Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA512_INIT)
+#elif defined(ARCHIVE_HASH_SHA512_LIBC3)
+#  include <sha2.h>
+#  define ARCHIVE_HAS_SHA512
+typedef SHA2_CTX archive_sha512_ctx;
+#  define archive_sha512_init(ctx)             SHA512Init(ctx)
+#  define archive_sha512_final(ctx, buf)       SHA512Final(buf, ctx)
+#  define archive_sha512_update(ctx, buf, n)   SHA512Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA512_LIBSYSTEM)
+#  include <CommonCrypto/CommonDigest.h>
+#  define ARCHIVE_HAS_SHA512
+typedef CC_SHA512_CTX archive_shs512_ctx;
+#  define archive_shs512_init(ctx)             CC_SHA512_Init(ctx)
+#  define archive_shs512_final(ctx, buf)       CC_SHA512_Final(buf, ctx)
+#  define archive_shs512_update(ctx, buf, n)   CC_SHA512_Update(ctx, buf, n)
+#elif defined(ARCHIVE_HASH_SHA512_OPENSSL)
 #  include <openssl/sha.h>
 #  define ARCHIVE_HAS_SHA512
 typedef SHA512_CTX archive_sha512_ctx;
 #  define archive_sha512_init(ctx)             SHA512_Init(ctx)
 #  define archive_sha512_final(ctx, buf)       SHA512_Final(buf, ctx)
 #  define archive_sha512_update(ctx, buf, n)   SHA512_Update(ctx, buf, n)
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_512)
+#elif defined(ARCHIVE_HASH_SHA512_WIN)
 #  define ARCHIVE_HAS_SHA512
-typedef SHA512_CTX archive_sha512_ctx;
-#  define archive_sha512_init(ctx)             SHA512_Init(ctx)
-#  define archive_sha512_final(ctx, buf)       SHA512_Final(buf, ctx)
-#  define archive_sha512_update(ctx, buf, n)   SHA512_Update(ctx, buf, n)
+#  define SHA512_DIGEST_LENGTH 64
+typedef Digest_CTX archive_sha512_ctx;
+#  define archive_sha512_init(ctx)             __la_hash_Init(ctx, 
CALG_SHA_512)
+#  define archive_sha512_final(ctx, buf)       __la_hash_Final(buf, 
SHA512_DIGEST_LENGTH, ctx)
+#  define archive_sha512_update(ctx, buf, n)   __la_hash_Update(ctx, buf, n)
 #endif

Modified: head/lib/libarchive/archive_read.3
==============================================================================
--- head/lib/libarchive/archive_read.3  Sun Jul 17 21:15:20 2011        
(r224151)
+++ head/lib/libarchive/archive_read.3  Sun Jul 17 21:27:38 2011        
(r224152)
@@ -597,7 +597,7 @@ list_archive(const char *name)
   archive_read_support_format_all(a);
   archive_read_open(a, mydata, myopen, myread, myclose);
   while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
-    printf("%s\\n",archive_entry_pathname(entry));
+    printf("%s\en",archive_entry_pathname(entry));
     archive_read_data_skip(a);
   }
   archive_read_free(a);

Modified: head/lib/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- head/lib/libarchive/archive_read_disk_entry_from_file.c     Sun Jul 17 
21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_disk_entry_from_file.c     Sun Jul 17 
21:27:38 2011        (r224152)
@@ -208,6 +208,12 @@ setup_acls_posix1e(struct archive_read_d
 #if HAVE_ACL_GET_LINK_NP
        else if (!a->follow_symlinks)
                acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
+#else
+       else if ((!a->follow_symlinks)
+           && (archive_entry_filetype(entry) == AE_IFLNK))
+               /* We can't get the ACL of a symlink, so we assume it can't
+                  have one. */
+               acl = NULL;
 #endif
        else
                acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
@@ -419,7 +425,8 @@ setup_xattrs(struct archive_read_disk *a
        return (ARCHIVE_OK);
 }
 
-#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE
+#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE && \
+    HAVE_DECL_EXTATTR_NAMESPACE_USER
 
 /*
  * FreeBSD extattr interface.
@@ -430,11 +437,11 @@ setup_xattrs(struct archive_read_disk *a
  * to not include the system extattrs that hold ACLs; we handle
  * those separately.
  */
-int
+static int
 setup_xattr(struct archive_read_disk *a, struct archive_entry *entry,
     int namespace, const char *name, const char *fullname, int fd);
 
-int
+static int
 setup_xattr(struct archive_read_disk *a, struct archive_entry *entry,
     int namespace, const char *name, const char *fullname, int fd)
 {

Modified: head/lib/libarchive/archive_read_disk_set_standard_lookup.c
==============================================================================
--- head/lib/libarchive/archive_read_disk_set_standard_lookup.c Sun Jul 17 
21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_disk_set_standard_lookup.c Sun Jul 17 
21:27:38 2011        (r224152)
@@ -182,6 +182,7 @@ lookup_uname(void *data, uid_t uid)
                    &lookup_uname_helper, (id_t)uid));
 }
 
+#if HAVE_GETPWUID_R
 static const char *
 lookup_uname_helper(struct name_cache *cache, id_t id)
 {
@@ -222,6 +223,20 @@ lookup_uname_helper(struct name_cache *c
 
        return strdup(result->pw_name);
 }
+#else
+static const char *
+lookup_uname_helper(struct name_cache *cache, id_t id)
+{
+       struct passwd   *result;
+
+       result = getpwuid((uid_t)id);
+
+       if (result == NULL)
+               return (NULL);
+
+       return strdup(result->pw_name);
+}
+#endif
 
 static const char *
 lookup_gname(void *data, gid_t gid)
@@ -231,6 +246,7 @@ lookup_gname(void *data, gid_t gid)
                    &lookup_gname_helper, (id_t)gid));
 }
 
+#if HAVE_GETGRGID_R
 static const char *
 lookup_gname_helper(struct name_cache *cache, id_t id)
 {
@@ -269,4 +285,19 @@ lookup_gname_helper(struct name_cache *c
 
        return strdup(result->gr_name);
 }
+#else
+static const char *
+lookup_gname_helper(struct name_cache *cache, id_t id)
+{
+       struct group    *result;
+
+       result = getgrgid((gid_t)id);
+
+       if (result == NULL)
+               return (NULL);
+
+       return strdup(result->gr_name);
+}
+#endif
+
 #endif /* ! (_WIN32 && !__CYGWIN__) */

Modified: head/lib/libarchive/archive_read_support_compression_all.c
==============================================================================
--- head/lib/libarchive/archive_read_support_compression_all.c  Sun Jul 17 
21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_support_compression_all.c  Sun Jul 17 
21:27:38 2011        (r224152)
@@ -46,6 +46,8 @@ archive_read_support_compression_all(str
        archive_read_support_compression_xz(a);
        /* The decode code doesn't use an outside library. */
        archive_read_support_compression_uu(a);
+       /* The decode code doesn't use an outside library. */
+       archive_read_support_compression_rpm(a);
 
        /* Note: We always return ARCHIVE_OK here, even if some of the
         * above return ARCHIVE_WARN.  The intent here is to enable

Modified: head/lib/libarchive/archive_read_support_compression_bzip2.c
==============================================================================
--- head/lib/libarchive/archive_read_support_compression_bzip2.c        Sun Jul 
17 21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_support_compression_bzip2.c        Sun Jul 
17 21:27:38 2011        (r224152)
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
 #include "archive_private.h"
 #include "archive_read_private.h"
 
-#if HAVE_BZLIB_H
+#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
 struct private_data {
        bz_stream        stream;
        char            *out_block;
@@ -86,7 +86,7 @@ archive_read_support_compression_bzip2(s
        reader->init = bzip2_reader_init;
        reader->options = NULL;
        reader->free = bzip2_reader_free;
-#if HAVE_BZLIB_H
+#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
        return (ARCHIVE_OK);
 #else
        archive_set_error(_a, ARCHIVE_ERRNO_MISC,
@@ -146,7 +146,7 @@ bzip2_reader_bid(struct archive_read_fil
        return (bits_checked);
 }
 
-#ifndef HAVE_BZLIB_H
+#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR)
 
 /*
  * If we don't have the library on this system, we can't actually do the

Added: head/lib/libarchive/archive_read_support_compression_rpm.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/archive_read_support_compression_rpm.c  Sun Jul 17 
21:27:38 2011        (r224152)
@@ -0,0 +1,288 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+struct rpm {
+       int64_t          total_in;
+       size_t           hpos;
+       size_t           hlen;
+       unsigned char    header[16];
+       enum {
+               ST_LEAD,        /* Skipping 'Lead' section. */
+               ST_HEADER,      /* Reading 'Header' section;
+                                * first 16 bytes. */
+               ST_HEADER_DATA, /* Skipping 'Header' section. */
+               ST_PADDING,     /* Skipping padding data after the
+                                * 'Header' section. */
+               ST_ARCHIVE      /* Reading 'Archive' section. */
+       }                state;
+       int              first_header;
+};
+#define RPM_LEAD_SIZE  96      /* Size of 'Lead' section. */
+
+static int     rpm_bidder_bid(struct archive_read_filter_bidder *,
+                   struct archive_read_filter *);
+static int     rpm_bidder_init(struct archive_read_filter *);
+
+static ssize_t rpm_filter_read(struct archive_read_filter *,
+                   const void **);
+static int     rpm_filter_close(struct archive_read_filter *);
+
+int
+archive_read_support_compression_rpm(struct archive *_a)
+{
+       struct archive_read *a = (struct archive_read *)_a;
+       struct archive_read_filter_bidder *bidder;
+
+       bidder = __archive_read_get_bidder(a);
+       archive_clear_error(_a);
+       if (bidder == NULL)
+               return (ARCHIVE_FATAL);
+
+       bidder->data = NULL;
+       bidder->bid = rpm_bidder_bid;
+       bidder->init = rpm_bidder_init;
+       bidder->options = NULL;
+       bidder->free = NULL;
+       return (ARCHIVE_OK);
+}
+
+static int
+rpm_bidder_bid(struct archive_read_filter_bidder *self,
+    struct archive_read_filter *filter)
+{
+       const unsigned char *b;
+       ssize_t avail;
+       int bits_checked;
+
+       (void)self; /* UNUSED */
+
+       b = __archive_read_filter_ahead(filter, 8, &avail);
+       if (b == NULL)
+               return (0);
+
+       bits_checked = 0;
+       /*
+        * Verify Header Magic Bytes : 0xed 0xab 0xee 0xdb
+        */
+       if (b[0] != 0xed)
+               return (0);
+       bits_checked += 8;
+       if (b[1] != 0xab)
+               return (0);
+       bits_checked += 8;
+       if (b[2] != 0xee)
+               return (0);
+       bits_checked += 8;
+       if (b[3] != 0xdb)
+               return (0);
+       bits_checked += 8;
+       /*
+        * Check major version.
+        */
+       if (b[4] != 3 && b[4] != 4)
+               return (0);
+       bits_checked += 8;
+       /*
+        * Check package type; binary or source.
+        */
+       if (b[6] != 0)
+               return (0);
+       bits_checked += 8;
+       if (b[7] != 0 && b[7] != 1)
+               return (0);
+       bits_checked += 8;
+
+       return (bits_checked);
+}
+
+static int
+rpm_bidder_init(struct archive_read_filter *self)
+{
+       struct rpm   *rpm;
+
+       self->code = ARCHIVE_COMPRESSION_RPM;
+       self->name = "rpm";
+       self->read = rpm_filter_read;
+       self->skip = NULL; /* not supported */
+       self->close = rpm_filter_close;
+
+       rpm = (struct rpm *)calloc(sizeof(*rpm), 1);
+       if (rpm == NULL) {
+               archive_set_error(&self->archive->archive, ENOMEM,
+                   "Can't allocate data for rpm");
+               return (ARCHIVE_FATAL);
+       }
+
+       self->data = rpm;
+       rpm->state = ST_LEAD;
+
+       return (ARCHIVE_OK);
+}
+
+static ssize_t
+rpm_filter_read(struct archive_read_filter *self, const void **buff)
+{
+       struct rpm *rpm;
+       const unsigned char *b;
+       ssize_t avail_in, total;
+       size_t used, n;
+       uint32_t section;
+       uint32_t bytes;
+
+       rpm = (struct rpm *)self->data;
+       *buff = NULL;
+       total = avail_in = 0;
+       b = NULL;
+       used = 0;
+       do {
+               if (b == NULL) {
+                       b = __archive_read_filter_ahead(self->upstream, 1,
+                           &avail_in);
+                       if (b == NULL) {
+                               if (avail_in < 0)
+                                       return (ARCHIVE_FATAL);
+                               else
+                                       break;
+                       }
+               }
+
+               switch (rpm->state) {
+               case ST_LEAD:
+                       if (rpm->total_in + avail_in < RPM_LEAD_SIZE)
+                               used += avail_in;
+                       else {
+                               n = RPM_LEAD_SIZE - rpm->total_in;
+                               used += n;
+                               b += n;
+                               rpm->state = ST_HEADER;
+                               rpm->hpos = 0;
+                               rpm->hlen = 0;
+                               rpm->first_header = 1;
+                       }
+                       break;
+               case ST_HEADER:
+                       n = 16 - rpm->hpos;
+                       if (n > avail_in - used)
+                               n = avail_in - used;
+                       memcpy(rpm->header+rpm->hpos, b, n);
+                       b += n;
+                       used += n;
+                       rpm->hpos += n;
+
+                       if (rpm->hpos == 16) {
+                               if (rpm->header[0] != 0x8e ||
+                                   rpm->header[1] != 0xad ||
+                                   rpm->header[2] != 0xe8 ||
+                                   rpm->header[3] != 0x01) {
+                                       if (rpm->first_header) {
+                                               archive_set_error(
+                                                   &self->archive->archive,
+                                                   ARCHIVE_ERRNO_FILE_FORMAT,
+                                                   "Unrecoginized rpm header");
+                                               return (ARCHIVE_FATAL);
+                                       }
+                                       rpm->state = ST_ARCHIVE;
+                                       *buff = rpm->header;
+                                       total = rpm->hpos;
+                                       break;
+                               }
+                               /* Calculate 'Header' length. */
+                               section = archive_be32dec(rpm->header+8);
+                               bytes = archive_be32dec(rpm->header+12);
+                               rpm->hlen = 16 + section * 16 + bytes;
+                               rpm->state = ST_HEADER_DATA;
+                               rpm->first_header = 0;
+                       }
+                       break;
+               case ST_HEADER_DATA:
+                       n = rpm->hlen - rpm->hpos;
+                       if (n > avail_in - used)
+                               n = avail_in - used;
+                       b += n;
+                       used += n;
+                       rpm->hpos += n;
+                       if (rpm->hpos == rpm->hlen)
+                               rpm->state = ST_PADDING;
+                       break;
+               case ST_PADDING:
+                       while (used < (size_t)avail_in) {
+                               if (*b != 0) {
+                                       /* Read next header. */
+                                       rpm->state = ST_HEADER;
+                                       rpm->hpos = 0;
+                                       rpm->hlen = 0;
+                                       break;
+                               }
+                               b++;
+                               used++;
+                       }
+                       break;
+               case ST_ARCHIVE:
+                       *buff = b;
+                       total = avail_in;
+                       used = avail_in;
+                       break;
+               }
+               if (used == (size_t)avail_in) {
+                       rpm->total_in += used;
+                       __archive_read_filter_consume(self->upstream, used);
+                       b = NULL;
+                       used = 0;
+               }
+       } while (total == 0 && avail_in > 0);
+
+       if (used > 0 && b != NULL) {
+               rpm->total_in += used;
+               __archive_read_filter_consume(self->upstream, used);
+       }
+       return (total);
+}
+
+static int
+rpm_filter_close(struct archive_read_filter *self)
+{
+       struct rpm *rpm;
+
+       rpm = (struct rpm *)self->data;
+       free(rpm);
+
+       return (ARCHIVE_OK);
+}
+

Modified: head/lib/libarchive/archive_read_support_compression_uu.c
==============================================================================
--- head/lib/libarchive/archive_read_support_compression_uu.c   Sun Jul 17 
21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_support_compression_uu.c   Sun Jul 17 
21:27:38 2011        (r224152)
@@ -325,7 +325,7 @@ uudecode_bidder_bid(struct archive_read_
                        --len;
                }
                b += nl;
-               
+
                if (avail >= 5 && memcmp(b, "====\n", 5) == 0)
                        return (firstline+40);
                if (avail >= 6 && memcmp(b, "====\r\n", 6) == 0)

Modified: head/lib/libarchive/archive_read_support_format_all.c
==============================================================================
--- head/lib/libarchive/archive_read_support_format_all.c       Sun Jul 17 
21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_support_format_all.c       Sun Jul 17 
21:27:38 2011        (r224152)
@@ -37,6 +37,7 @@ archive_read_support_format_all(struct a
        archive_read_support_format_iso9660(a);
        archive_read_support_format_mtree(a);
        archive_read_support_format_tar(a);
+       archive_read_support_format_xar(a);
        archive_read_support_format_zip(a);
        return (ARCHIVE_OK);
 }

Modified: head/lib/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- head/lib/libarchive/archive_read_support_format_mtree.c     Sun Jul 17 
21:15:20 2011        (r224151)
+++ head/lib/libarchive/archive_read_support_format_mtree.c     Sun Jul 17 
21:27:38 2011        (r224152)
@@ -370,7 +370,7 @@ process_add_entry(struct archive_read *a
                line = next;
                next = line + strcspn(line, " \t\r\n");
                eq = strchr(line, '=');
-               if (eq > next)
+               if (eq == NULL || eq > next)
                        len = next - line;
                else
                        len = eq - line;

Added: head/lib/libarchive/archive_read_support_format_xar.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libarchive/archive_read_support_format_xar.c       Sun Jul 17 
21:27:38 2011        (r224152)
@@ -0,0 +1,3151 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_LIBXML_XMLREADER_H
+#include <libxml/xmlreader.h>
+#elif HAVE_BSDXML_H
+#include <bsdxml.h>
+#elif HAVE_EXPAT_H
+#include <expat.h>
+#endif
+#ifdef HAVE_BZLIB_H
+#include <bzlib.h>
+#endif
+#if HAVE_LZMA_H
+#include <lzma.h>
+#elif HAVE_LZMADEC_H
+#include <lzmadec.h>
+#endif
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_entry.h"
+#include "archive_hash.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+#if (!defined(HAVE_LIBXML_XMLREADER_H) && \
+     !defined(HAVE_BSDXML_H) && !defined(HAVE_EXPAT_H)) ||\
+       !defined(HAVE_ZLIB_H) || \
+       !defined(ARCHIVE_HAS_MD5) || !defined(ARCHIVE_HAS_SHA1)
+/*
+ * xar needs several external libraries.
+ *   o libxml2 or expat --- XML parser
+ *   o openssl or MD5/SHA1 hash function
+ *   o zlib
+ *   o bzlib2 (option)
+ *   o liblzma (option)
+ */
+int
+archive_read_support_format_xar(struct archive *_a)
+{
+       struct archive_read *a = (struct archive_read *)_a;
+
+       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+           "Xar not supported on this platform");
+       return (ARCHIVE_WARN);
+}
+
+#else  /* Support xar format */
+
+//#define DEBUG 1
+//#define DEBUG_PRINT_TOC 1
+#if DEBUG_PRINT_TOC
+#define PRINT_TOC(d, outbytes) do {                            \
+       unsigned char *x = (unsigned char *)(uintptr_t)d;       \
+       unsigned char c = x[outbytes-1];                        \
+       x[outbytes - 1] = 0;                                    \
+       fprintf(stderr, "%s", x);                               \
+       fprintf(stderr, "%c", c);                               \
+       x[outbytes - 1] = c;                                    \
+} while (0)
+#else
+#define PRINT_TOC(d, outbytes)
+#endif
+
+#define HEADER_MAGIC   0x78617221
+#define HEADER_SIZE    28
+#define HEADER_VERSION 1
+#define CKSUM_NONE     0
+#define CKSUM_SHA1     1
+#define CKSUM_MD5      2
+
+#define MD5_SIZE       16
+#define SHA1_SIZE      20
+#define MAX_SUM_SIZE   20
+
+enum enctype {
+       NONE,
+       GZIP,
+       BZIP2,
+       LZMA,
+       XZ,
+};
+
+struct chksumval {
+       int                      alg;
+       size_t                   len;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to