summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-12-28 02:58:14 +0000
committerkientzle <kientzle@FreeBSD.org>2009-12-28 02:58:14 +0000
commitb1d1d36a226d1eb449da0728a90e9aaadcf5a109 (patch)
tree0b1a4cd0bb1f958cdbe07f9411a01f50bef72e1f /lib/libarchive
parentcd7df27c58c7c91d2f890a7ed45bb6f9db3ea5ca (diff)
downloadFreeBSD-src-b1d1d36a226d1eb449da0728a90e9aaadcf5a109.zip
FreeBSD-src-b1d1d36a226d1eb449da0728a90e9aaadcf5a109.tar.gz
New archive_file_count() utility.
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/Makefile1
-rw-r--r--lib/libarchive/archive.h1
-rw-r--r--lib/libarchive/archive_private.h18
-rw-r--r--lib/libarchive/archive_read.c1
-rw-r--r--lib/libarchive/archive_util.39
-rw-r--r--lib/libarchive/archive_util.c16
-rw-r--r--lib/libarchive/archive_virtual.c1
7 files changed, 42 insertions, 5 deletions
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index eb1c172..685b1f6 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -224,6 +224,7 @@ MLINKS+= archive_util.3 archive_compression.3
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
diff --git a/lib/libarchive/archive.h b/lib/libarchive/archive.h
index ee7e5ab..6665095 100644
--- a/lib/libarchive/archive.h
+++ b/lib/libarchive/archive.h
@@ -713,6 +713,7 @@ __LA_DECL void archive_set_error(struct archive *, int _err,
const char *fmt, ...);
__LA_DECL void archive_copy_error(struct archive *dest,
struct archive *src);
+__LA_DECL int archive_file_count(struct archive *);
#ifdef __cplusplus
}
diff --git a/lib/libarchive/archive_private.h b/lib/libarchive/archive_private.h
index 1b03133..e09ddce 100644
--- a/lib/libarchive/archive_private.h
+++ b/lib/libarchive/archive_private.h
@@ -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 *p, const char *fn,
#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
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index fd4f888..648b1f9 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -386,6 +386,7 @@ archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_read_next_header");
+ ++_a->file_count;
archive_entry_clear(entry);
archive_clear_error(&a->archive);
diff --git a/lib/libarchive/archive_util.3 b/lib/libarchive/archive_util.3
index 831355d..18234af 100644
--- a/lib/libarchive/archive_util.3
+++ b/lib/libarchive/archive_util.3
@@ -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.
diff --git a/lib/libarchive/archive_util.c b/lib/libarchive/archive_util.c
index 1c171b9..4c0de02 100644
--- a/lib/libarchive/archive_util.c
+++ b/lib/libarchive/archive_util.c
@@ -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);
}
diff --git a/lib/libarchive/archive_virtual.c b/lib/libarchive/archive_virtual.c
index 214e381..9ea24d0 100644
--- a/lib/libarchive/archive_virtual.c
+++ b/lib/libarchive/archive_virtual.c
@@ -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));
}
OpenPOWER on IntegriCloud