summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2008-01-03 17:54:26 +0000
committerdes <des@FreeBSD.org>2008-01-03 17:54:26 +0000
commitf836e69a7ed8e00a307d584a3919b53a6b67ce63 (patch)
treea8c2068a9a89a96837a2923ff4be4030426746af /lib/libarchive/archive_read.c
parent69daf9ac7f41d56f1d036122980df04659fa111f (diff)
downloadFreeBSD-src-f836e69a7ed8e00a307d584a3919b53a6b67ce63.zip
FreeBSD-src-f836e69a7ed8e00a307d584a3919b53a6b67ce63.tar.gz
Add an internal utility function to simplify the many, many places where
the number of bytes read is actually not important as long as we have at least what we ask for. Illustrate its benefits by using it throughout the ZIP support code, except for the few cases where it doesn't apply. Approved by: kientzle
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r--lib/libarchive/archive_read.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index 8ef839a..1028c5d 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -741,3 +741,14 @@ __archive_read_register_compression(struct archive_read *a,
__archive_errx(1, "Not enough slots for compression registration");
return (NULL); /* Never actually executed. */
}
+
+/* used internally to simplify read-ahead */
+const void *
+__archive_read_ahead(struct archive_read *a, size_t len)
+{
+ const void *h;
+
+ if ((a->decompressor->read_ahead)(a, &h, len) < (ssize_t)len)
+ return (NULL);
+ return (h);
+}
OpenPOWER on IntegriCloud