From owner-svn-src-all@FreeBSD.ORG Mon Dec 28 02:58:14 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C47181065679; Mon, 28 Dec 2009 02:58:14 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B36B48FC16; Mon, 28 Dec 2009 02:58:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBS2wEVm076750; Mon, 28 Dec 2009 02:58:14 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBS2wEDw076742; Mon, 28 Dec 2009 02:58:14 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200912280258.nBS2wEDw076742@svn.freebsd.org> From: Tim Kientzle Date: Mon, 28 Dec 2009 02:58:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201098 - head/lib/libarchive X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2009 02:58:14 -0000 Author: kientzle Date: Mon Dec 28 02:58:14 2009 New Revision: 201098 URL: http://svn.freebsd.org/changeset/base/201098 Log: New archive_file_count() utility. Modified: head/lib/libarchive/Makefile head/lib/libarchive/archive.h head/lib/libarchive/archive_private.h head/lib/libarchive/archive_read.c head/lib/libarchive/archive_util.3 head/lib/libarchive/archive_util.c head/lib/libarchive/archive_virtual.c Modified: head/lib/libarchive/Makefile ============================================================================== --- head/lib/libarchive/Makefile Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/Makefile Mon Dec 28 02:58:14 2009 (r201098) @@ -224,6 +224,7 @@ MLINKS+= archive_util.3 archive_compress MLINKS+= archive_util.3 archive_compression_name.3 MLINKS+= archive_util.3 archive_errno.3 MLINKS+= archive_util.3 archive_error_string.3 +MLINKS+= archive_util.3 archive_file_count.3 MLINKS+= archive_util.3 archive_format.3 MLINKS+= archive_util.3 archive_format_name.3 MLINKS+= archive_util.3 archive_set_error.3 Modified: head/lib/libarchive/archive.h ============================================================================== --- head/lib/libarchive/archive.h Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/archive.h Mon Dec 28 02:58:14 2009 (r201098) @@ -713,6 +713,7 @@ __LA_DECL void archive_set_error(struc const char *fmt, ...); __LA_DECL void archive_copy_error(struct archive *dest, struct archive *src); +__LA_DECL int archive_file_count(struct archive *); #ifdef __cplusplus } Modified: head/lib/libarchive/archive_private.h ============================================================================== --- head/lib/libarchive/archive_private.h Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/archive_private.h Mon Dec 28 02:58:14 2009 (r201098) @@ -25,6 +25,10 @@ * $FreeBSD$ */ +#ifndef __LIBARCHIVE_BUILD +#error This header is only to be used internally to libarchive. +#endif + #ifndef ARCHIVE_PRIVATE_H_INCLUDED #define ARCHIVE_PRIVATE_H_INCLUDED @@ -87,9 +91,11 @@ struct archive { const char *compression_name; /* Position in UNCOMPRESSED data stream. */ - off_t file_position; + int64_t file_position; /* Position in COMPRESSED data stream. */ - off_t raw_position; + int64_t raw_position; + /* Number of file entries processed. */ + int file_count; int archive_error_number; const char *error; @@ -107,4 +113,12 @@ int __archive_parse_options(const char * #define err_combine(a,b) ((a) < (b) ? (a) : (b)) +#if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER <= 1300) +# define ARCHIVE_LITERAL_LL(x) x##i64 +# define ARCHIVE_LITERAL_ULL(x) x##ui64 +#else +# define ARCHIVE_LITERAL_LL(x) x##ll +# define ARCHIVE_LITERAL_ULL(x) x##ull +#endif + #endif Modified: head/lib/libarchive/archive_read.c ============================================================================== --- head/lib/libarchive/archive_read.c Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/archive_read.c Mon Dec 28 02:58:14 2009 (r201098) @@ -386,6 +386,7 @@ archive_read_next_header2(struct archive ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, "archive_read_next_header"); + ++_a->file_count; archive_entry_clear(entry); archive_clear_error(&a->archive); Modified: head/lib/libarchive/archive_util.3 ============================================================================== --- head/lib/libarchive/archive_util.3 Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/archive_util.3 Mon Dec 28 02:58:14 2009 (r201098) @@ -34,6 +34,7 @@ .Nm archive_copy_error , .Nm archive_errno , .Nm archive_error_string , +.Nm archive_file_count , .Nm archive_format , .Nm archive_format_name , .Nm archive_set_error @@ -53,6 +54,8 @@ .Ft const char * .Fn archive_error_string "struct archive *" .Ft int +.Fn archive_file_count "struct archive *" +.Ft int .Fn archive_format "struct archive *" .Ft const char * .Fn archive_format_name "struct archive *" @@ -92,6 +95,12 @@ obtained from passing the result of .Fn archive_errno to .Xr strerror 3 . +.It Fn archive_file_count +Returns a count of the number of files processed by this archive object. +The count is incremented by calls to +.Xr archive_write_header +or +.Xr archive_read_next_header . .It Fn archive_format Returns a numeric code indicating the format of the current archive entry. Modified: head/lib/libarchive/archive_util.c ============================================================================== --- head/lib/libarchive/archive_util.c Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/archive_util.c Mon Dec 28 02:58:14 2009 (r201098) @@ -100,6 +100,11 @@ archive_error_string(struct archive *a) return ("(Empty error message)"); } +int +archive_file_count(struct archive *a) +{ + return (a->file_count); +} int archive_format(struct archive *a) @@ -182,9 +187,14 @@ void __archive_errx(int retvalue, const char *msg) { static const char *msg1 = "Fatal Internal Error in libarchive: "; - write(2, msg1, strlen(msg1)); - write(2, msg, strlen(msg)); - write(2, "\n", 1); + size_t s; + + s = write(2, msg1, strlen(msg1)); + (void)s; /* UNUSED */ + s = write(2, msg, strlen(msg)); + (void)s; /* UNUSED */ + s = write(2, "\n", 1); + (void)s; /* UNUSED */ exit(retvalue); } Modified: head/lib/libarchive/archive_virtual.c ============================================================================== --- head/lib/libarchive/archive_virtual.c Mon Dec 28 02:45:56 2009 (r201097) +++ head/lib/libarchive/archive_virtual.c Mon Dec 28 02:58:14 2009 (r201098) @@ -66,6 +66,7 @@ archive_read_finish(struct archive *a) int archive_write_header(struct archive *a, struct archive_entry *entry) { + ++a->file_count; return ((a->vtable->archive_write_header)(a, entry)); }