diff options
author | Brad King <brad.king@kitware.com> | 2014-04-15 20:34:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-04-15 20:34:50 (GMT) |
commit | 4533560c23adf29a03d57b5c5678048795ed6134 (patch) | |
tree | ae53680c085c37e68c2fc101306acdd40fecb780 /Utilities/cmlibarchive | |
parent | 44d6b82f4351dc3941fd9794ad8f3909148c0314 (diff) | |
parent | 37f225b72c8e4c440025a98f68eda9914f7ba5f7 (diff) | |
download | CMake-4533560c23adf29a03d57b5c5678048795ed6134.zip CMake-4533560c23adf29a03d57b5c5678048795ed6134.tar.gz CMake-4533560c23adf29a03d57b5c5678048795ed6134.tar.bz2 |
Merge branch 'libarchive-upstream' into update-libarchive
Resolve conflicts in Utilities/cmlibarchive/CMakeLists.txt as
appropriate.
Diffstat (limited to 'Utilities/cmlibarchive')
9 files changed, 192 insertions, 139 deletions
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index e493966..77010c5 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -28,6 +28,7 @@ STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision}) SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}") SET(BSDCPIO_VERSION_STRING "${VERSION}") SET(BSDTAR_VERSION_STRING "${VERSION}") +SET(BSDCAT_VERSION_STRING "${VERSION}") SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}") SET(LIBARCHIVE_VERSION_STRING "${VERSION}") @@ -1291,6 +1292,12 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) ADD_DEFINITIONS(-DHAVE_CONFIG_H) # +# Expose ADDITIONAL_LIBS for projects using libarchive as a subdirectory +# and linking against archive_static. +# +set(LIBARCHIVE_ADDITIONAL_LIBS ${ADDITIONAL_LIBS} CACHE INTERNAL "libarchive dependencies") + +# # Register installation of PDF documents. # IF(WIN32 AND NOT CYGWIN) diff --git a/Utilities/cmlibarchive/build/cmake/config.h.in b/Utilities/cmlibarchive/build/cmake/config.h.in index f2d2068..32a29d0 100644 --- a/Utilities/cmlibarchive/build/cmake/config.h.in +++ b/Utilities/cmlibarchive/build/cmake/config.h.in @@ -292,6 +292,9 @@ typedef uint64_t uintmax_t; /* Version number of bsdtar */ #cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}" +/* Version number of bsdcat */ +#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}" + /* Define to 1 if you have the `acl_create_entry' function. */ #cmakedefine HAVE_ACL_CREATE_ENTRY 1 diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt index 8a68424..8908a62 100644 --- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt @@ -54,6 +54,7 @@ SET(libarchive_SOURCES archive_read_disk_private.h archive_read_disk_set_standard_lookup.c archive_read_extract.c + archive_read_extract2.c archive_read_open_fd.c archive_read_open_file.c archive_read_open_filename.c diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract.c b/Utilities/cmlibarchive/libarchive/archive_read_extract.c index 795f2ab..ce76a6c 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_extract.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_extract.c @@ -26,146 +26,40 @@ #include "archive_platform.h" __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $"); -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif #ifdef HAVE_ERRNO_H #include <errno.h> #endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif #include "archive.h" #include "archive_entry.h" #include "archive_private.h" #include "archive_read_private.h" -#include "archive_write_disk_private.h" - -struct extract { - struct archive *ad; /* archive_write_disk object */ - - /* Progress function invoked during extract. */ - void (*extract_progress)(void *); - void *extract_progress_user_data; -}; static int archive_read_extract_cleanup(struct archive_read *); -static int copy_data(struct archive *ar, struct archive *aw); -static struct extract *get_extract(struct archive_read *); - -static struct extract * -get_extract(struct archive_read *a) -{ - /* If we haven't initialized, do it now. */ - /* This also sets up a lot of global state. */ - if (a->extract == NULL) { - a->extract = (struct extract *)malloc(sizeof(*a->extract)); - if (a->extract == NULL) { - archive_set_error(&a->archive, ENOMEM, "Can't extract"); - return (NULL); - } - memset(a->extract, 0, sizeof(*a->extract)); - a->extract->ad = archive_write_disk_new(); - if (a->extract->ad == NULL) { - archive_set_error(&a->archive, ENOMEM, "Can't extract"); - return (NULL); - } - archive_write_disk_set_standard_lookup(a->extract->ad); - a->cleanup_archive_extract = archive_read_extract_cleanup; - } - return (a->extract); -} int archive_read_extract(struct archive *_a, struct archive_entry *entry, int flags) { - struct extract *extract; + struct archive_read_extract *extract; + struct archive_read * a = (struct archive_read *)_a; - extract = get_extract((struct archive_read *)_a); + extract = __archive_read_get_extract(a); if (extract == NULL) return (ARCHIVE_FATAL); - archive_write_disk_set_options(extract->ad, flags); - return (archive_read_extract2(_a, entry, extract->ad)); -} - -int -archive_read_extract2(struct archive *_a, struct archive_entry *entry, - struct archive *ad) -{ - struct archive_read *a = (struct archive_read *)_a; - int r, r2; - /* Set up for this particular entry. */ - if (a->skip_file_set) - archive_write_disk_set_skip_file(ad, - a->skip_file_dev, a->skip_file_ino); - r = archive_write_header(ad, entry); - if (r < ARCHIVE_WARN) - r = ARCHIVE_WARN; - if (r != ARCHIVE_OK) - /* If _write_header failed, copy the error. */ - archive_copy_error(&a->archive, ad); - else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0) - /* Otherwise, pour data into the entry. */ - r = copy_data(_a, ad); - r2 = archive_write_finish_entry(ad); - if (r2 < ARCHIVE_WARN) - r2 = ARCHIVE_WARN; - /* Use the first message. */ - if (r2 != ARCHIVE_OK && r == ARCHIVE_OK) - archive_copy_error(&a->archive, ad); - /* Use the worst error return. */ - if (r2 < r) - r = r2; - return (r); -} - -void -archive_read_extract_set_progress_callback(struct archive *_a, - void (*progress_func)(void *), void *user_data) -{ - struct archive_read *a = (struct archive_read *)_a; - struct extract *extract = get_extract(a); - if (extract != NULL) { - extract->extract_progress = progress_func; - extract->extract_progress_user_data = user_data; - } -} - -static int -copy_data(struct archive *ar, struct archive *aw) -{ - int64_t offset; - const void *buff; - struct extract *extract; - size_t size; - int r; - - extract = get_extract((struct archive_read *)ar); - if (extract == NULL) - return (ARCHIVE_FATAL); - for (;;) { - r = archive_read_data_block(ar, &buff, &size, &offset); - if (r == ARCHIVE_EOF) - return (ARCHIVE_OK); - if (r != ARCHIVE_OK) - return (r); - r = (int)archive_write_data_block(aw, buff, size, offset); - if (r < ARCHIVE_WARN) - r = ARCHIVE_WARN; - if (r != ARCHIVE_OK) { - archive_set_error(ar, archive_errno(aw), - "%s", archive_error_string(aw)); - return (r); + /* If we haven't initialized the archive_write_disk object, do it now. */ + if (extract->ad == NULL) { + extract->ad = archive_write_disk_new(); + if (extract->ad == NULL) { + archive_set_error(&a->archive, ENOMEM, "Can't extract"); + return (ARCHIVE_FATAL); } - if (extract->extract_progress) - (extract->extract_progress) - (extract->extract_progress_user_data); + archive_write_disk_set_standard_lookup(extract->ad); + a->cleanup_archive_extract = archive_read_extract_cleanup; } + + archive_write_disk_set_options(extract->ad, flags); + return (archive_read_extract2(&a->archive, entry, extract->ad)); } /* diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract2.c b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c new file mode 100644 index 0000000..3c65e80 --- /dev/null +++ b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c @@ -0,0 +1,137 @@ +/*- + * 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 "archive_platform.h" +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $"); + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include "archive.h" +#include "archive_entry.h" +#include "archive_private.h" +#include "archive_read_private.h" + +static int copy_data(struct archive *ar, struct archive *aw); + +/* Retrieve an extract object without initialising the associated + * archive_write_disk object. + */ +struct archive_read_extract * +__archive_read_get_extract(struct archive_read *a) +{ + if (a->extract == NULL) { + a->extract = (struct archive_read_extract *)malloc(sizeof(*a->extract)); + if (a->extract == NULL) { + archive_set_error(&a->archive, ENOMEM, "Can't extract"); + return (NULL); + } + memset(a->extract, 0, sizeof(*a->extract)); + } + return (a->extract); +} + +int +archive_read_extract2(struct archive *_a, struct archive_entry *entry, + struct archive *ad) +{ + struct archive_read *a = (struct archive_read *)_a; + int r, r2; + + /* Set up for this particular entry. */ + if (a->skip_file_set) + archive_write_disk_set_skip_file(ad, + a->skip_file_dev, a->skip_file_ino); + r = archive_write_header(ad, entry); + if (r < ARCHIVE_WARN) + r = ARCHIVE_WARN; + if (r != ARCHIVE_OK) + /* If _write_header failed, copy the error. */ + archive_copy_error(&a->archive, ad); + else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0) + /* Otherwise, pour data into the entry. */ + r = copy_data(_a, ad); + r2 = archive_write_finish_entry(ad); + if (r2 < ARCHIVE_WARN) + r2 = ARCHIVE_WARN; + /* Use the first message. */ + if (r2 != ARCHIVE_OK && r == ARCHIVE_OK) + archive_copy_error(&a->archive, ad); + /* Use the worst error return. */ + if (r2 < r) + r = r2; + return (r); +} + +void +archive_read_extract_set_progress_callback(struct archive *_a, + void (*progress_func)(void *), void *user_data) +{ + struct archive_read *a = (struct archive_read *)_a; + struct archive_read_extract *extract = __archive_read_get_extract(a); + if (extract != NULL) { + extract->extract_progress = progress_func; + extract->extract_progress_user_data = user_data; + } +} + +static int +copy_data(struct archive *ar, struct archive *aw) +{ + int64_t offset; + const void *buff; + struct archive_read_extract *extract; + size_t size; + int r; + + extract = __archive_read_get_extract((struct archive_read *)ar); + if (extract == NULL) + return (ARCHIVE_FATAL); + for (;;) { + r = archive_read_data_block(ar, &buff, &size, &offset); + if (r == ARCHIVE_EOF) + return (ARCHIVE_OK); + if (r != ARCHIVE_OK) + return (r); + r = (int)archive_write_data_block(aw, buff, size, offset); + if (r < ARCHIVE_WARN) + r = ARCHIVE_WARN; + if (r != ARCHIVE_OK) { + archive_set_error(ar, archive_errno(aw), + "%s", archive_error_string(aw)); + return (r); + } + if (extract->extract_progress) + (extract->extract_progress) + (extract->extract_progress_user_data); + } +} diff --git a/Utilities/cmlibarchive/libarchive/archive_read_private.h b/Utilities/cmlibarchive/libarchive/archive_read_private.h index 6636a59..27e203b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_read_private.h @@ -142,6 +142,14 @@ struct archive_read_client { struct archive_read_data_node *dataset; }; +struct archive_read_extract { + struct archive *ad; /* archive_write_disk object */ + + /* Progress function invoked during extract. */ + void (*extract_progress)(void *); + void *extract_progress_user_data; +}; + struct archive_read { struct archive archive; @@ -215,7 +223,7 @@ struct archive_read { /* * Various information needed by archive_extract. */ - struct extract *extract; + struct archive_read_extract *extract; int (*cleanup_archive_extract)(struct archive_read *); }; @@ -245,4 +253,5 @@ int64_t __archive_read_filter_consume(struct archive_read_filter *, int64_t); int __archive_read_program(struct archive_read_filter *, const char *); void __archive_read_free_filters(struct archive_read *); int __archive_read_close_filters(struct archive_read *); +struct archive_read_extract *__archive_read_get_extract(struct archive_read *); #endif diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c index 3f4014b..b2614a0 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c @@ -204,10 +204,11 @@ compression_name(const int compression) { static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]); int i=0; - while(compression >= 0 && i++ < num_compression_methods) { + while(compression >= 0 && i < num_compression_methods) { if (compression_methods[i].id == compression) { return compression_methods[i].name; } + i++; } return "??"; } @@ -743,7 +744,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, zip->end_of_entry = 1; /* Set up a more descriptive format name. */ - sprintf(zip->format_name, "ZIP %d.%d (%s)", + snprintf(zip->format_name, sizeof(zip->format_name), "ZIP %d.%d (%s)", version / 10, version % 10, compression_name(zip->entry->compression)); a->archive.archive_format_name = zip->format_name; diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c index b69c873..80389ee 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c @@ -2215,7 +2215,8 @@ _archive_write_disk_free(struct archive *_a) free(a->resource_fork); free(a->compressed_buffer); free(a->uncompressed_buffer); -#ifdef HAVE_ZLIB_H +#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\ + && defined(HAVE_ZLIB_H) if (a->stream_valid) { switch (deflateEnd(&a->stream)) { case Z_OK: diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c index 157f100..3b07e35 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c @@ -405,8 +405,8 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) unsigned char *e; unsigned char *cd_extra; size_t filename_length; - const char *symlink = NULL; - size_t symlink_size = 0; + const char *slink = NULL; + size_t slink_size = 0; struct archive_string_conv *sconv = get_sconv(a, zip); int ret, ret2 = ARCHIVE_OK; int64_t size; @@ -528,16 +528,16 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) /* Determine appropriate compression and size for this entry. */ if (type == AE_IFLNK) { - symlink = archive_entry_symlink(zip->entry); - if (symlink != NULL) - symlink_size = strlen(symlink); + slink = archive_entry_symlink(zip->entry); + if (slink != NULL) + slink_size = strlen(slink); else - symlink_size = 0; - zip->entry_uncompressed_limit = symlink_size; - zip->entry_compressed_size = symlink_size; - zip->entry_uncompressed_size = symlink_size; + slink_size = 0; + zip->entry_uncompressed_limit = slink_size; + zip->entry_compressed_size = slink_size; + zip->entry_uncompressed_size = slink_size; zip->entry_crc32 = zip->crc32func(zip->entry_crc32, - (const unsigned char *)symlink, symlink_size); + (const unsigned char *)slink, slink_size); zip->entry_compression = COMPRESSION_STORE; version_needed = 20; } else if (type != AE_IFREG) { @@ -742,13 +742,13 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) zip->written_bytes += e - local_extra; /* For symlinks, write the body now. */ - if (symlink != NULL) { - ret = __archive_write_output(a, symlink, (size_t)symlink_size); + if (slink != NULL) { + ret = __archive_write_output(a, slink, slink_size); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->entry_compressed_written += symlink_size; - zip->entry_uncompressed_written += symlink_size; - zip->written_bytes += symlink_size; + zip->entry_compressed_written += slink_size; + zip->entry_uncompressed_written += slink_size; + zip->written_bytes += slink_size; } #ifdef HAVE_ZLIB_H |