From owner-p4-projects@FreeBSD.ORG Thu May 1 09:56:03 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8C40F1065677; Thu, 1 May 2008 09:56:03 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DEA01065673 for ; Thu, 1 May 2008 09:56:03 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 39ACE8FC1D for ; Thu, 1 May 2008 09:56:03 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m419u3ug092163 for ; Thu, 1 May 2008 09:56:03 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m419u3Dk092161 for perforce@freebsd.org; Thu, 1 May 2008 09:56:03 GMT (envelope-from strauss@FreeBSD.org) Date: Thu, 1 May 2008 09:56:03 GMT Message-Id: <200805010956.m419u3Dk092161@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to strauss@FreeBSD.org using -f From: Anselm Strauss To: Perforce Change Reviews Cc: Subject: PERFORCE change 140980 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 May 2008 09:56:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=140980 Change 140980 by strauss@strauss_marvelman on 2008/05/01 09:55:04 pull from parent Affected files ... .. //depot/projects/soc2008/strauss_libarchive/Makefile.am#2 integrate .. //depot/projects/soc2008/strauss_libarchive/contrib/README#1 branch .. //depot/projects/soc2008/strauss_libarchive/contrib/libarchive.1aix53.spec#1 branch .. //depot/projects/soc2008/strauss_libarchive/contrib/libarchive.spec#1 branch .. //depot/projects/soc2008/strauss_libarchive/contrib/libarchive_autodetect-st_lib_archive.m4#1 branch .. //depot/projects/soc2008/strauss_libarchive/contrib/psota-benchmark/results.txt#1 branch .. //depot/projects/soc2008/strauss_libarchive/contrib/psota-benchmark/tcp.sh#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/Makefile#2 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/bsdcpio.1#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_gcpio_compat_ref.bin.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_gcpio_compat_ref.crc.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_gcpio_compat_ref.newc.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_gcpio_compat_ref.ustar.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_f.cpio.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_m.cpio.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_t.cpio.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_t.stdout.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_tv.stdout.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/doc/mdoc2man.awk#1 branch .. //depot/projects/soc2008/strauss_libarchive/doc/update.sh#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/minitar/Makefile#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/minitar/README#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/minitar/minitar.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/minitar/tree.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/minitar/tree.h#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/tarfilter.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/examples/untar.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/libarchive/Makefile#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive.h.in#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.3#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.h#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_link_resolver.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_private.h#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_platform.h#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_iso9660.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_tar.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_zip.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.h#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_util.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_disk.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_pax.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_ustar.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/cpio.5#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/mtree.5#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/tar.5#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/Makefile#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/main.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_acl_pax.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_archive_api_feature.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_entry.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_pax_filename_encoding.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_tar_filenames.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_tar_large.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_ar.c#2 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/Makefile#2 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/bsdtar.c#2 integrate Differences ... ==== //depot/projects/soc2008/strauss_libarchive/Makefile.am#2 (text+ko) ==== @@ -317,9 +317,6 @@ tar/test/test_stdio.c \ tar/test/test_version.c -bsdtar_test_EXTRA_DIST= \ - tar/test/old - bsdtar_test_CPPFLAGS= -I$(top_builddir)/tar/test tar/test/list.h: Makefile ==== //depot/projects/soc2008/strauss_libarchive/cpio/Makefile#2 (text+ko) ==== @@ -11,7 +11,9 @@ SYMLINKS=bsdcpio ${BINDIR}/cpio MLINKS= bsdcpio.1 cpio.1 -check: $(PROG) +.PHONY: check test + +check test: $(PROG) bsdcpio.1.gz cd ${.CURDIR}/test && make clean test .include ==== //depot/projects/soc2008/strauss_libarchive/libarchive/Makefile#2 (text+ko) ==== @@ -8,12 +8,12 @@ # Version is three numbers: # Major: Bumped ONLY when API/ABI breakage happens (see SHLIB_MAJOR) # Minor: Bumped when significant new features are added -# Revision: Bumped on any notable change +# Revision: Bumped frequently. # The useful version number (one integer, easy to compare) -LIBARCHIVE_VERSION= 2004012 +LIBARCHIVE_VERSION_NUMBER=2005001 # The pretty version string -LIBARCHIVE_VERSION_STRING!= echo $$((${LIBARCHIVE_VERSION} / 1000000)).$$((${LIBARCHIVE_VERSION} / 1000 % 1000)).$$((${LIBARCHIVE_VERSION} % 1000)) +LIBARCHIVE_VERSION_STRING=2.5.1b # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system. # It has no real relation to the version number above. @@ -31,10 +31,8 @@ # Note: FreeBSD has inttypes.h, so enable that include in archive.h.in archive.h: archive.h.in Makefile cat ${.CURDIR}/archive.h.in | sed \ - -e 's/@LIBARCHIVE_VERSION@/${LIBARCHIVE_VERSION}/g' \ - -e 's/@LIBARCHIVE_VERSION_STRING@/${LIBARCHIVE_VERSION_STRING}/g' \ - -e 's/@SHLIB_MAJOR@/${SHLIB_MAJOR}/g' \ - -e 's|@ARCHIVE_H_INCLUDE_INTTYPES_H@|#include /* For int64_t */|g' \ + -e 's/@LIBARCHIVE_VERSION_NUMBER@/${LIBARCHIVE_VERSION_NUMBER}/g' \ + -e 's/@LIBARCHIVE_VERSION_STRING@/${LIBARCHIVE_VERSION_STRING}/g' \ > archive.h # archive.h needs to be cleaned @@ -246,7 +244,8 @@ MLINKS+= archive_write_disk.3 archive_write_disk_set_user_lookup.3 MLINKS+= libarchive.3 archive.3 -check: +.PHONY: check test +check test: cd ${.CURDIR}/test && make test .include ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive.h.in#2 (text+ko) ==== @@ -29,17 +29,48 @@ #define ARCHIVE_H_INCLUDED #include /* Linux requires this for off_t */ -@ARCHIVE_H_INCLUDE_INTTYPES_H@ +/* TODO: Conditionalize this include on platforms that don't support it. */ +#include /* int64_t, etc. */ #include /* For FILE * */ -#ifndef _WIN32 -#include /* For ssize_t and size_t */ + +/* Get appropriate definitions of standard POSIX-style types. */ +/* These should match the types used in 'struct stat' */ +#ifdef _WIN32 +#define __LA_SSIZE_T long +#define __LA_UID_T unsigned int +#define __LA_GID_T unsigned int +#else +#include /* ssize_t, uid_t, and gid_t */ +#define __LA_SSIZE_T ssize_t +#define __LA_UID_T uid_t +#define __LA_GID_T gid_t +#endif + +/* + * On Windows, define LIBARCHIVE_STATIC if you're building or using a + * .lib. The default here assumes you're building a DLL. Only + * libarchive source should ever define __LIBARCHIVE_BUILD. + */ +#if ((defined __WIN32__) || (defined _WIN32)) && (!defined LIBARCHIVE_STATIC) +# ifdef __LIBARCHIVE_BUILD +# ifdef __GNUC__ +# define __LA_DECL __attribute__((dllexport)) extern +# else +# define __LA_DECL __declspec(dllexport) +# endif +# else +# ifdef __GNUC__ +# define __LA_DECL __attribute__((dllimport)) extern +# else +# define __LA_DECL __declspec(dllimport) +# endif +# endif #else -typedef long ssize_t; -typedef unsigned int uid_t; -typedef unsigned int gid_t; -typedef unsigned short mode_t; +/* Static libraries or non-Windows needs no special declaration. */ +# define __LA_DECL #endif + #ifdef __cplusplus extern "C" { #endif @@ -48,7 +79,9 @@ * The version number is provided as both a macro and a function. * The macro identifies the installed header; the function identifies * the library version (which may not be the same if you're using a - * dynamically-linked version of the library). + * dynamically-linked version of the library). Of course, if the + * header and library are very different, you should expect some + * strangeness. Don't do that. */ /* @@ -69,13 +102,14 @@ * (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000) * #endif */ -#define ARCHIVE_VERSION_NUMBER @LIBARCHIVE_VERSION@ -int archive_version_number(void); +#define ARCHIVE_VERSION_NUMBER @LIBARCHIVE_VERSION_NUMBER@ +__LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -const char * archive_version_string(void); +#define ARCHIVE_VERSION_STRING "libarchive @LIBARCHIVE_VERSION_STRING@" +__LA_DECL const char * archive_version_string(void); #if ARCHIVE_VERSION_NUMBER < 3000000 /* @@ -83,13 +117,13 @@ * the simpler definitions above. */ #define ARCHIVE_VERSION_STAMP ARCHIVE_VERSION_NUMBER -int archive_version_stamp(void); -#define ARCHIVE_LIBRARY_VERSION "libarchive @LIBARCHIVE_VERSION_STRING@" -const char * archive_version(void); +__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) -int archive_api_version(void); +__LA_DECL int archive_api_version(void); #define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_NUMBER / 1000) % 1000) -int archive_api_feature(void); +__LA_DECL int archive_api_feature(void); #endif #if ARCHIVE_VERSION_NUMBER < 3000000 @@ -139,18 +173,18 @@ */ /* Returns pointer and size of next block of data from archive. */ -typedef ssize_t archive_read_callback(struct archive *, void *_client_data, +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 -typedef ssize_t archive_skip_callback(struct archive *, void *_client_data, +typedef __LA_SSIZE_T archive_skip_callback(struct archive *, void *_client_data, size_t request); #else typedef off_t archive_skip_callback(struct archive *, void *_client_data, off_t request); #endif /* Returns size actually written, zero on EOF, -1 on error. */ -typedef ssize_t archive_write_callback(struct archive *, void *_client_data, +typedef __LA_SSIZE_T archive_write_callback(struct archive *, void *_client_data, const void *_buffer, size_t _length); typedef int archive_open_callback(struct archive *, void *_client_data); typedef int archive_close_callback(struct archive *, void *_client_data); @@ -218,7 +252,7 @@ * data for entries of interest. * 5) Call archive_read_finish to end processing. */ -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 @@ -227,30 +261,30 @@ * support_compression_bzip2(). The "all" functions provide the * obvious shorthand. */ -int archive_read_support_compression_all(struct archive *); -int archive_read_support_compression_bzip2(struct archive *); -int archive_read_support_compression_compress(struct archive *); -int archive_read_support_compression_gzip(struct archive *); -int archive_read_support_compression_none(struct archive *); -int archive_read_support_compression_program(struct archive *, +__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_none(struct archive *); +__LA_DECL int archive_read_support_compression_program(struct archive *, const char *command); -int archive_read_support_format_all(struct archive *); -int archive_read_support_format_ar(struct archive *); -int archive_read_support_format_cpio(struct archive *); -int archive_read_support_format_empty(struct archive *); -int archive_read_support_format_gnutar(struct archive *); -int archive_read_support_format_iso9660(struct archive *); -int archive_read_support_format_mtree(struct archive *); -int archive_read_support_format_tar(struct archive *); -int archive_read_support_format_zip(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_tar(struct archive *); +__LA_DECL int archive_read_support_format_zip(struct archive *); /* Open the archive using callbacks for archive I/O. */ -int archive_read_open(struct archive *, void *_client_data, +__LA_DECL int archive_read_open(struct archive *, void *_client_data, archive_open_callback *, archive_read_callback *, archive_close_callback *); -int archive_read_open2(struct archive *, void *_client_data, +__LA_DECL int archive_read_open2(struct archive *, void *_client_data, archive_open_callback *, archive_read_callback *, archive_skip_callback *, archive_close_callback *); @@ -260,43 +294,43 @@ * accept a block size handle tape blocking correctly. */ /* Use this if you know the filename. Note: NULL indicates stdin. */ -int archive_read_open_filename(struct archive *, +__LA_DECL int archive_read_open_filename(struct archive *, const char *_filename, size_t _block_size); /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ -int archive_read_open_file(struct archive *, +__LA_DECL int archive_read_open_file(struct archive *, const char *_filename, size_t _block_size); /* Read an archive that's stored in memory. */ -int archive_read_open_memory(struct archive *, +__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. */ -int archive_read_open_memory2(struct archive *a, void *buff, +__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. */ -int archive_read_open_fd(struct archive *, int _fd, +__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. */ -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. */ -int archive_read_next_header(struct archive *, +__LA_DECL int archive_read_next_header(struct archive *, struct archive_entry **); /* * Retrieve the byte offset in UNCOMPRESSED data where last-read * header started. */ -int64_t archive_read_header_position(struct archive *); +__LA_DECL int64_t archive_read_header_position(struct archive *); /* Read data from the body of an entry. Similar to read(2). */ -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 * of each returned block. Note that the client has no way to specify * the desired size of the block. The API does guarantee that offsets will * be strictly increasing and that returned blocks will not overlap. */ -int archive_read_data_block(struct archive *a, +__LA_DECL int archive_read_data_block(struct archive *a, const void **buff, size_t *size, off_t *offset); /*- @@ -305,10 +339,10 @@ * 'into_buffer': writes data into memory buffer that you provide * 'into_fd': writes data to specified filedes */ -int archive_read_data_skip(struct archive *); -int archive_read_data_into_buffer(struct archive *, void *buffer, - ssize_t len); -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_buffer(struct archive *, void *buffer, + __LA_SSIZE_T len); +__LA_DECL int archive_read_data_into_fd(struct archive *, int fd); /*- * Convenience function to recreate the current entry (whose header @@ -352,26 +386,26 @@ /* Default: Overwrite files, even if one on disk is newer. */ #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (2048) -int archive_read_extract(struct archive *, struct archive_entry *, +__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *, int flags); -void archive_read_extract_set_progress_callback(struct archive *, +__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. */ -void archive_read_extract_set_skip_file(struct archive *, +__LA_DECL void archive_read_extract_set_skip_file(struct archive *, dev_t, ino_t); /* Close the file and release most resources. */ -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 -int archive_read_finish(struct archive *); +__LA_DECL int archive_read_finish(struct archive *); #else /* Temporarily allow library to compile with either 1.x or 2.0 API. */ /* Erroneously declared to return void in libarchive 1.x */ -void archive_read_finish(struct archive *); +__LA_DECL void archive_read_finish(struct archive *); #endif /*- @@ -389,75 +423,75 @@ * 5) archive_write_close to close the output * 6) archive_write_finish to cleanup the writer and release resources */ -struct archive *archive_write_new(void); -int archive_write_set_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); -int archive_write_get_bytes_per_block(struct archive *); +__LA_DECL int archive_write_get_bytes_per_block(struct archive *); /* XXX This is badly misnamed; suggestions appreciated. XXX */ -int archive_write_set_bytes_in_last_block(struct archive *, +__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *, int bytes_in_last_block); -int archive_write_get_bytes_in_last_block(struct archive *); +__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. */ -int archive_write_set_skip_file(struct archive *, dev_t, ino_t); +__LA_DECL int archive_write_set_skip_file(struct archive *, dev_t, ino_t); -int archive_write_set_compression_bzip2(struct archive *); -int archive_write_set_compression_compress(struct archive *); -int archive_write_set_compression_gzip(struct archive *); -int archive_write_set_compression_none(struct archive *); -int archive_write_set_compression_program(struct archive *, +__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_none(struct archive *); +__LA_DECL int archive_write_set_compression_program(struct archive *, const char *cmd); /* A convenience function to set the format based on the code or name. */ -int archive_write_set_format(struct archive *, int format_code); -int archive_write_set_format_by_name(struct archive *, +__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. */ -int archive_write_set_format_ar_bsd(struct archive *); -int archive_write_set_format_ar_svr4(struct archive *); -int archive_write_set_format_cpio(struct archive *); -int archive_write_set_format_cpio_newc(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 *); /* TODO: int archive_write_set_format_old_tar(struct archive *); */ -int archive_write_set_format_pax(struct archive *); -int archive_write_set_format_pax_restricted(struct archive *); -int archive_write_set_format_shar(struct archive *); -int archive_write_set_format_shar_dump(struct archive *); -int archive_write_set_format_ustar(struct archive *); -int archive_write_open(struct archive *, void *, +__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_open(struct archive *, void *, archive_open_callback *, archive_write_callback *, archive_close_callback *); -int archive_write_open_fd(struct archive *, int _fd); -int archive_write_open_filename(struct archive *, const char *_file); +__LA_DECL int archive_write_open_fd(struct archive *, int _fd); +__LA_DECL int archive_write_open_filename(struct archive *, const char *_file); /* A deprecated synonym for archive_write_open_filename() */ -int archive_write_open_file(struct archive *, const char *_file); -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. */ -int archive_write_open_memory(struct archive *, +__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. */ -int archive_write_header(struct archive *, +__LA_DECL int archive_write_header(struct archive *, struct archive_entry *); #if ARCHIVE_VERSION_NUMBER >= 2000000 -ssize_t archive_write_data(struct archive *, const void *, size_t); +__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *, const void *, size_t); #else /* Temporarily allow library to compile with either 1.x or 2.0 API. */ /* This was erroneously declared to return "int" in libarchive 1.x. */ -int archive_write_data(struct archive *, const void *, size_t); +__LA_DECL int archive_write_data(struct archive *, const void *, size_t); #endif -ssize_t archive_write_data_block(struct archive *, const void *, size_t, off_t); -int archive_write_finish_entry(struct archive *); -int archive_write_close(struct archive *); +__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *, const void *, size_t, off_t); +__LA_DECL int archive_write_finish_entry(struct archive *); +__LA_DECL int archive_write_close(struct archive *); #if ARCHIVE_VERSION_NUMBER >= 2000000 -int archive_write_finish(struct archive *); +__LA_DECL int archive_write_finish(struct archive *); #else /* Temporarily allow library to compile with either 1.x or 2.0 API. */ /* Return value was incorrect in libarchive 1.x. */ -void archive_write_finish(struct archive *); +__LA_DECL void archive_write_finish(struct archive *); #endif /*- @@ -474,12 +508,12 @@ * In particular, you can use this in conjunction with archive_read() * to pull entries out of an archive and create them on disk. */ -struct archive *archive_write_disk_new(void); +__LA_DECL struct archive *archive_write_disk_new(void); /* This file will not be overwritten. */ -int archive_write_disk_set_skip_file(struct archive *, +__LA_DECL int archive_write_disk_set_skip_file(struct archive *, dev_t, ino_t); /* Set flags to control how the next item gets created. */ -int archive_write_disk_set_options(struct archive *, +__LA_DECL int archive_write_disk_set_options(struct archive *, int flags); /* * The lookup functions are given uname/uid (or gname/gid) pairs and @@ -498,42 +532,47 @@ * particular, these match the specifications of POSIX "pax" and old * POSIX "tar". */ -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. */ -int archive_write_disk_set_group_lookup(struct archive *, - void *private_data, - gid_t (*loookup)(void *, const char *gname, gid_t gid), - void (*cleanup)(void *)); -int archive_write_disk_set_user_lookup(struct archive *, - void *private_data, - uid_t (*)(void *, const char *uname, uid_t uid), - void (*cleanup)(void *)); +__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 *)); /* * Accessor functions to read/set various information in * the struct archive object: */ /* Bytes written after compression or read before decompression. */ -int64_t archive_position_compressed(struct archive *); +__LA_DECL int64_t archive_position_compressed(struct archive *); /* Bytes written to compressor or read from decompressor. */ -int64_t archive_position_uncompressed(struct archive *); +__LA_DECL int64_t archive_position_uncompressed(struct archive *); -const char *archive_compression_name(struct archive *); -int archive_compression(struct archive *); -int archive_errno(struct archive *); -const char *archive_error_string(struct archive *); -const char *archive_format_name(struct archive *); -int archive_format(struct archive *); -void archive_clear_error(struct archive *); -void archive_set_error(struct archive *, int _err, const char *fmt, ...); -void archive_copy_error(struct archive *dest, struct archive *src); +__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); #ifdef __cplusplus } #endif +/* This is meaningless outside of this header. */ +#undef __LA_DECL + #endif /* !ARCHIVE_H_INCLUDED */ ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.3#2 (text+ko) ==== @@ -48,6 +48,7 @@ .Nm archive_entry_copy_link , .Nm archive_entry_copy_link_w , .Nm archive_entry_copy_pathname_w , +.Nm archive_entry_copy_sourcepath , .Nm archive_entry_copy_stat , .Nm archive_entry_copy_symlink , .Nm archive_entry_copy_symlink_w , @@ -95,6 +96,7 @@ .Nm archive_entry_set_uid , .Nm archive_entry_set_uname , .Nm archive_entry_size , +.Nm archive_entry_sourcepath , .Nm archive_entry_stat , .Nm archive_entry_symlink , .Nm archive_entry_uid , @@ -167,6 +169,8 @@ .Ft void .Fn archive_entry_copy_hardlink_w "struct archive_entry *" "const wchar_t *" .Ft void +.Fn archive_entry_copy_sourcepath "struct archive_entry *" "const char *" +.Ft void .Fn archive_entry_copy_pathname_w "struct archive_entry *" "const wchar_t *" .Ft void .Fn archive_entry_copy_stat "struct archive_entry *" "const struct stat *" @@ -270,6 +274,8 @@ .Fn archive_entry_set_uname "struct archive_entry *" "const char *" .Ft int64_t .Fn archive_entry_size "struct archive_entry *" +.Ft const char * +.Fn archive_entry_sourcepath "struct archive_entry *" .Ft const struct stat * .Fn archive_entry_stat "struct archive_entry *" .Ft const char * ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.c#2 (text+ko) ==== @@ -91,15 +91,17 @@ static void aes_copy(struct aes *dest, struct aes *src); static const char * aes_get_mbs(struct aes *); static const wchar_t * aes_get_wcs(struct aes *); -static void aes_set_mbs(struct aes *, const char *mbs); -static void aes_copy_mbs(struct aes *, const char *mbs); +static int aes_set_mbs(struct aes *, const char *mbs); +static int aes_copy_mbs(struct aes *, const char *mbs); /* static void aes_set_wcs(struct aes *, const wchar_t *wcs); */ -static void aes_copy_wcs(struct aes *, const wchar_t *wcs); -static void aes_copy_wcs_len(struct aes *, const wchar_t *wcs, size_t); +static int aes_copy_wcs(struct aes *, const wchar_t *wcs); +static int aes_copy_wcs_len(struct aes *, const wchar_t *wcs, size_t); static char * ae_fflagstostr(unsigned long bitset, unsigned long bitclear); static const wchar_t *ae_wcstofflags(const wchar_t *stringp, unsigned long *setp, unsigned long *clrp); +static const char *ae_strtofflags(const char *stringp, + unsigned long *setp, unsigned long *clrp); 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); @@ -144,173 +146,216 @@ #define wmemcpy(a,b,i) (wchar_t *)memcpy((a), (b), (i) * sizeof(wchar_t)) #endif - static void aes_clean(struct aes *aes) { - if (aes->aes_mbs_alloc) { - free(aes->aes_mbs_alloc); - aes->aes_mbs_alloc = NULL; + if (aes->aes_wcs) { + free((wchar_t *)(uintptr_t)aes->aes_wcs); + aes->aes_wcs = NULL; } - if (aes->aes_wcs_alloc) { - free(aes->aes_wcs_alloc); - aes->aes_wcs_alloc = NULL; - } - memset(aes, 0, sizeof(*aes)); + archive_string_free(&(aes->aes_mbs)); + archive_string_free(&(aes->aes_utf8)); + aes->aes_set = 0; } static void aes_copy(struct aes *dest, struct aes *src) { - *dest = *src; - if (src->aes_mbs != NULL) { - dest->aes_mbs_alloc = strdup(src->aes_mbs); - dest->aes_mbs = dest->aes_mbs_alloc; - if (dest->aes_mbs == NULL) - __archive_errx(1, "No memory for aes_copy()"); - } + wchar_t *wp; + + dest->aes_set = src->aes_set; + archive_string_copy(&(dest->aes_mbs), &(src->aes_mbs)); + archive_string_copy(&(dest->aes_utf8), &(src->aes_utf8)); if (src->aes_wcs != NULL) { - dest->aes_wcs_alloc = (wchar_t *)malloc((wcslen(src->aes_wcs) + 1) + wp = (wchar_t *)malloc((wcslen(src->aes_wcs) + 1) * sizeof(wchar_t)); - dest->aes_wcs = dest->aes_wcs_alloc; - if (dest->aes_wcs == NULL) + if (wp == NULL) __archive_errx(1, "No memory for aes_copy()"); - wcscpy(dest->aes_wcs_alloc, src->aes_wcs); + wcscpy(wp, src->aes_wcs); + dest->aes_wcs = wp; + } +} + +static const char * +aes_get_utf8(struct aes *aes) +{ + if (aes->aes_set & AES_SET_UTF8) + return (aes->aes_utf8.s); + if ((aes->aes_set & AES_SET_WCS) + && archive_strappend_w_utf8(&(aes->aes_utf8), aes->aes_wcs) != NULL) { + aes->aes_set |= AES_SET_UTF8; + return (aes->aes_utf8.s); } + return (NULL); } static const char * aes_get_mbs(struct aes *aes) { - if (aes->aes_mbs == NULL && aes->aes_wcs == NULL) - return NULL; - if (aes->aes_mbs == NULL && aes->aes_wcs != NULL) { - /* - * XXX Need to estimate the number of byte in the - * multi-byte form. Assume that, on average, wcs - * chars encode to no more than 3 bytes. There must - * be a better way... XXX - */ - size_t mbs_length = wcslen(aes->aes_wcs) * 3 + 64; - - aes->aes_mbs_alloc = (char *)malloc(mbs_length); - aes->aes_mbs = aes->aes_mbs_alloc; - if (aes->aes_mbs == NULL) - __archive_errx(1, "No memory for aes_get_mbs()"); - wcstombs(aes->aes_mbs_alloc, aes->aes_wcs, mbs_length - 1); - aes->aes_mbs_alloc[mbs_length - 1] = 0; + /* If we already have an MBS form, return that immediately. */ + if (aes->aes_set & AES_SET_MBS) + return (aes->aes_mbs.s); + /* If there's a WCS form, try converting with the native locale. */ + if ((aes->aes_set & AES_SET_WCS) + && archive_strappend_w_mbs(&(aes->aes_mbs), aes->aes_wcs) != NULL) { + aes->aes_set |= AES_SET_MBS; + return (aes->aes_mbs.s); } - return (aes->aes_mbs); + /* We'll use UTF-8 for MBS if all else fails. */ + return (aes_get_utf8(aes)); } static const wchar_t * aes_get_wcs(struct aes *aes) { + wchar_t *w; int r; - if (aes->aes_wcs == NULL && aes->aes_mbs == NULL) - return NULL; - if (aes->aes_wcs == NULL && aes->aes_mbs != NULL) { + /* Return WCS form if we already have it. */ + if (aes->aes_set & AES_SET_WCS) + return (aes->aes_wcs); + + if (aes->aes_set & AES_SET_MBS) { + /* Try converting MBS to WCS using native locale. */ /* * No single byte will be more than one wide character, * so this length estimate will always be big enough. */ - size_t wcs_length = strlen(aes->aes_mbs); + size_t wcs_length = aes->aes_mbs.length; - aes->aes_wcs_alloc - = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t)); - aes->aes_wcs = aes->aes_wcs_alloc; - if (aes->aes_wcs == NULL) + w = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t)); + if (w == NULL) __archive_errx(1, "No memory for aes_get_wcs()"); - r = mbstowcs(aes->aes_wcs_alloc, aes->aes_mbs, wcs_length); - aes->aes_wcs_alloc[wcs_length] = 0; - if (r == -1) { - /* Conversion failed, don't lie to our clients. */ - free(aes->aes_wcs_alloc); - aes->aes_wcs = aes->aes_wcs_alloc = NULL; + r = mbstowcs(w, aes->aes_mbs.s, wcs_length); + w[wcs_length] = 0; + if (r > 0) { + aes->aes_set |= AES_SET_WCS; + return (aes->aes_wcs = w); } + free(w); } - return (aes->aes_wcs); + + if (aes->aes_set & AES_SET_UTF8) { + /* Try converting UTF8 to WCS. */ + aes->aes_wcs = __archive_string_utf8_w(&(aes->aes_utf8)); + aes->aes_set |= AES_SET_WCS; + return (aes->aes_wcs); + } + return (NULL); } -static void +static int aes_set_mbs(struct aes *aes, const char *mbs) { - if (aes->aes_mbs_alloc) { - free(aes->aes_mbs_alloc); - aes->aes_mbs_alloc = NULL; - } - if (aes->aes_wcs_alloc) { - free(aes->aes_wcs_alloc); - aes->aes_wcs_alloc = NULL; - } - aes->aes_mbs = mbs; - aes->aes_wcs = NULL; + return (aes_copy_mbs(aes, mbs)); } -static void +static int aes_copy_mbs(struct aes *aes, const char *mbs) { - if (aes->aes_mbs_alloc) { - free(aes->aes_mbs_alloc); - aes->aes_mbs_alloc = NULL; + if (mbs == NULL) { + aes->aes_set = 0; + return (0); } - if (aes->aes_wcs_alloc) { - free(aes->aes_wcs_alloc); - aes->aes_wcs_alloc = NULL; + aes->aes_set = AES_SET_MBS; /* Only MBS form is set now. */ + archive_strcpy(&(aes->aes_mbs), mbs); + archive_string_empty(&(aes->aes_utf8)); + if (aes->aes_wcs) { + free((wchar_t *)(uintptr_t)aes->aes_wcs); + aes->aes_wcs = NULL; } - aes->aes_mbs_alloc = (char *)malloc((strlen(mbs) + 1) * sizeof(char)); - if (aes->aes_mbs_alloc == NULL) - __archive_errx(1, "No memory for aes_copy_mbs()"); - strcpy(aes->aes_mbs_alloc, mbs); - aes->aes_mbs = aes->aes_mbs_alloc; - aes->aes_wcs = NULL; + return (0); } -#if 0 -static void -aes_set_wcs(struct aes *aes, const wchar_t *wcs) +/* + * The 'update' form tries to proactively update all forms of + * this string (WCS and MBS) and returns an error if any of + * them fail. This is used by the 'pax' handler, for instance, + * to detect and report character-conversion failures early while + * still allowing clients to get potentially useful values from + * the more tolerant lazy conversions. (get_mbs and get_wcs will + * strive to give the user something useful, so you can get hopefully + * usable values even if some of the character conversions are failing.) + */ +static int +aes_update_utf8(struct aes *aes, const char *utf8) { - if (aes->aes_mbs_alloc) { - free(aes->aes_mbs_alloc); - aes->aes_mbs_alloc = NULL; + if (utf8 == NULL) { + aes->aes_set = 0; + return (1); /* Succeeded in clearing everything. */ } - if (aes->aes_wcs_alloc) { - free(aes->aes_wcs_alloc); - aes->aes_wcs_alloc = NULL; + + /* Save the UTF8 string. */ + archive_strcpy(&(aes->aes_utf8), utf8); + + /* Empty the mbs and wcs strings. */ + archive_string_empty(&(aes->aes_mbs)); + if (aes->aes_wcs) { + free((wchar_t *)(uintptr_t)aes->aes_wcs); + aes->aes_wcs = NULL; } - aes->aes_mbs = NULL; - aes->aes_wcs = wcs; + + aes->aes_set = AES_SET_UTF8; /* Only UTF8 is set now. */ + + /* TODO: We should just do a direct UTF-8 to MBS conversion + * here. That would be faster, use less space, and give the + * same information. (If a UTF-8 to MBS conversion succeeds, + * then UTF-8->WCS and Unicode->MBS conversions will both + * succeed.) */ + + /* Try converting UTF8 to WCS, return false on failure. */ + aes->aes_wcs = __archive_string_utf8_w(&(aes->aes_utf8)); + if (aes->aes_wcs == NULL) + return (0); + aes->aes_set = AES_SET_UTF8 | AES_SET_WCS; /* Both UTF8 and WCS set. */ + + /* Try converting WCS to MBS, return false on failure. */ + if (archive_strappend_w_mbs(&(aes->aes_mbs), aes->aes_wcs) == NULL) + return (0); + aes->aes_set = AES_SET_UTF8 | AES_SET_WCS | AES_SET_MBS; + + /* All conversions succeeded. */ + return (1); } -#endif -static void +static int aes_copy_wcs(struct aes *aes, const wchar_t *wcs) { - aes_copy_wcs_len(aes, wcs, wcslen(wcs)); + return aes_copy_wcs_len(aes, wcs, wcs == NULL ? 0 : wcslen(wcs)); } -static void +static int aes_copy_wcs_len(struct aes *aes, const wchar_t *wcs, size_t len) { - if (aes->aes_mbs_alloc) { - free(aes->aes_mbs_alloc); - aes->aes_mbs_alloc = NULL; + wchar_t *w; + + if (wcs == NULL) { + aes->aes_set = 0; + return (0); } - if (aes->aes_wcs_alloc) { - free(aes->aes_wcs_alloc); - aes->aes_wcs_alloc = NULL; + aes->aes_set = AES_SET_WCS; /* Only WCS form set. */ + archive_string_empty(&(aes->aes_mbs)); + archive_string_empty(&(aes->aes_utf8)); + if (aes->aes_wcs) { + free((wchar_t *)(uintptr_t)aes->aes_wcs); + aes->aes_wcs = NULL; } - aes->aes_mbs = NULL; - aes->aes_wcs_alloc = (wchar_t *)malloc((len + 1) * sizeof(wchar_t)); - if (aes->aes_wcs_alloc == NULL) + w = (wchar_t *)malloc((len + 1) * sizeof(wchar_t)); + if (w == NULL) __archive_errx(1, "No memory for aes_copy_wcs()"); - wmemcpy(aes->aes_wcs_alloc, wcs, len); - aes->aes_wcs_alloc[len] = L'\0'; - aes->aes_wcs = aes->aes_wcs_alloc; + wmemcpy(w, wcs, len); + w[len] = L'\0'; + aes->aes_wcs = w; + return (0); } +/**************************************************************************** + * + * Public Interface + * + ****************************************************************************/ + struct archive_entry * >>> TRUNCATED FOR MAIL (1000 lines) <<<