diff options
author | kientzle <kientzle@FreeBSD.org> | 2007-03-03 07:37:37 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2007-03-03 07:37:37 +0000 |
commit | 1a60578adb6be1f7da9ed95f38cf52c20be13591 (patch) | |
tree | 1b026213a337089af577dee3ed6d194ee1b87d88 /lib/libarchive/archive_read_support_compression_none.c | |
parent | 56746aa8e0ffff51b371e72446368d6dbbe6b4ba (diff) | |
download | FreeBSD-src-1a60578adb6be1f7da9ed95f38cf52c20be13591.zip FreeBSD-src-1a60578adb6be1f7da9ed95f38cf52c20be13591.tar.gz |
libarchive 2.0
* libarchive_test program exercises many of the core features
* Refactored old "read_extract" into new "archive_write_disk", which
uses archive_write methods to put entries onto disk. In particular,
you can now use archive_write_disk to create objects on disk
without having an archive available.
* Pushed some security checks from bsdtar down into libarchive, where
they can be better optimized.
* Rearchitected the logic for creating objects on disk to reduce
the number of system calls. Several common cases now use a
minimum number of system calls.
* Virtualized some internal interfaces to provide a clearer separation
of read and write handling and make it simpler to override key
methods.
* New "empty" format reader.
* Corrected return types (this ABI breakage required the "2.0" version bump)
* Many bug fixes.
Diffstat (limited to 'lib/libarchive/archive_read_support_compression_none.c')
-rw-r--r-- | lib/libarchive/archive_read_support_compression_none.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/libarchive/archive_read_support_compression_none.c b/lib/libarchive/archive_read_support_compression_none.c index 1109488..72328a3 100644 --- a/lib/libarchive/archive_read_support_compression_none.c +++ b/lib/libarchive/archive_read_support_compression_none.c @@ -26,7 +26,6 @@ #include "archive_platform.h" __FBSDID("$FreeBSD$"); -#include <assert.h> #ifdef HAVE_ERRNO_H #include <errno.h> #endif @@ -45,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "archive.h" #include "archive_private.h" +#include "archive_read_private.h" struct archive_decompress_none { char *buffer; @@ -75,18 +75,19 @@ struct archive_decompress_none { #define minimum(a, b) (a < b ? a : b) static int archive_decompressor_none_bid(const void *, size_t); -static int archive_decompressor_none_finish(struct archive *); -static int archive_decompressor_none_init(struct archive *, +static int archive_decompressor_none_finish(struct archive_read *); +static int archive_decompressor_none_init(struct archive_read *, const void *, size_t); -static ssize_t archive_decompressor_none_read_ahead(struct archive *, +static ssize_t archive_decompressor_none_read_ahead(struct archive_read *, const void **, size_t); -static ssize_t archive_decompressor_none_read_consume(struct archive *, +static ssize_t archive_decompressor_none_read_consume(struct archive_read *, size_t); -static off_t archive_decompressor_none_skip(struct archive *, off_t); +static off_t archive_decompressor_none_skip(struct archive_read *, off_t); int -archive_read_support_compression_none(struct archive *a) +archive_read_support_compression_none(struct archive *_a) { + struct archive_read *a = (struct archive_read *)_a; return (__archive_read_register_compression(a, archive_decompressor_none_bid, archive_decompressor_none_init)); @@ -105,16 +106,16 @@ archive_decompressor_none_bid(const void *buff, size_t len) } static int -archive_decompressor_none_init(struct archive *a, const void *buff, size_t n) +archive_decompressor_none_init(struct archive_read *a, const void *buff, size_t n) { struct archive_decompress_none *state; - a->compression_code = ARCHIVE_COMPRESSION_NONE; - a->compression_name = "none"; + a->archive.compression_code = ARCHIVE_COMPRESSION_NONE; + a->archive.compression_name = "none"; state = (struct archive_decompress_none *)malloc(sizeof(*state)); if (!state) { - archive_set_error(a, ENOMEM, "Can't allocate input data"); + archive_set_error(&a->archive, ENOMEM, "Can't allocate input data"); return (ARCHIVE_FATAL); } memset(state, 0, sizeof(*state)); @@ -124,7 +125,7 @@ archive_decompressor_none_init(struct archive *a, const void *buff, size_t n) state->next = state->buffer; if (state->buffer == NULL) { free(state); - archive_set_error(a, ENOMEM, "Can't allocate input buffer"); + archive_set_error(&a->archive, ENOMEM, "Can't allocate input buffer"); return (ARCHIVE_FATAL); } @@ -149,7 +150,7 @@ archive_decompressor_none_init(struct archive *a, const void *buff, size_t n) * buffer to combine reads. */ static ssize_t -archive_decompressor_none_read_ahead(struct archive *a, const void **buff, +archive_decompressor_none_read_ahead(struct archive_read *a, const void **buff, size_t min) { struct archive_decompress_none *state; @@ -217,7 +218,8 @@ archive_decompressor_none_read_ahead(struct archive *a, const void **buff, * char ** should be compatible, but they * aren't, hence the cast. */ - bytes_read = (a->client_reader)(a, a->client_data, + bytes_read = (a->client_reader)(&a->archive, + a->client_data, (const void **)&state->client_buff); if (bytes_read < 0) { /* Read error. */ state->client_total = state->client_avail = 0; @@ -231,7 +233,7 @@ archive_decompressor_none_read_ahead(struct archive *a, const void **buff, state->end_of_file = 1; break; } - a->raw_position += bytes_read; + a->archive.raw_position += bytes_read; state->client_total = bytes_read; state->client_avail = state->client_total; state->client_next = state->client_buff; @@ -248,7 +250,7 @@ archive_decompressor_none_read_ahead(struct archive *a, const void **buff, * request. */ static ssize_t -archive_decompressor_none_read_consume(struct archive *a, size_t request) +archive_decompressor_none_read_consume(struct archive_read *a, size_t request) { struct archive_decompress_none *state; @@ -262,7 +264,7 @@ archive_decompressor_none_read_consume(struct archive *a, size_t request) state->client_next += request; state->client_avail -= request; } - a->file_position += request; + a->archive.file_position += request; return (request); } @@ -272,7 +274,7 @@ archive_decompressor_none_read_consume(struct archive *a, size_t request) * read_ahead, which does not guarantee a minimum count. */ static off_t -archive_decompressor_none_skip(struct archive *a, off_t request) +archive_decompressor_none_skip(struct archive_read *a, off_t request) { struct archive_decompress_none *state; off_t bytes_skipped, total_bytes_skipped = 0; @@ -306,8 +308,8 @@ archive_decompressor_none_skip(struct archive *a, off_t request) #else if (a->client_skipper != NULL) { #endif - bytes_skipped = (a->client_skipper)(a, a->client_data, - request); + bytes_skipped = (a->client_skipper)(&a->archive, + a->client_data, request); if (bytes_skipped < 0) { /* error */ state->client_total = state->client_avail = 0; state->client_next = state->client_buff = NULL; @@ -315,10 +317,10 @@ archive_decompressor_none_skip(struct archive *a, off_t request) return (bytes_skipped); } total_bytes_skipped += bytes_skipped; - a->file_position += bytes_skipped; + a->archive.file_position += bytes_skipped; request -= bytes_skipped; state->client_next = state->client_buff; - a->raw_position += bytes_skipped; + a->archive.raw_position += bytes_skipped; state->client_avail = state->client_total = 0; } /* @@ -336,23 +338,21 @@ archive_decompressor_none_skip(struct archive *a, off_t request) return (bytes_read); if (bytes_read == 0) { /* We hit EOF before we satisfied the skip request. */ - archive_set_error(a, ARCHIVE_ERRNO_MISC, + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Truncated input file (need to skip %jd bytes)", (intmax_t)request); return (ARCHIVE_FATAL); } - assert(bytes_read >= 0); /* precondition for cast below */ min = (size_t)(minimum(bytes_read, request)); bytes_read = archive_decompressor_none_read_consume(a, min); total_bytes_skipped += bytes_read; request -= bytes_read; } - assert(request == 0); return (total_bytes_skipped); } static int -archive_decompressor_none_finish(struct archive *a) +archive_decompressor_none_finish(struct archive_read *a) { struct archive_decompress_none *state; @@ -361,6 +361,6 @@ archive_decompressor_none_finish(struct archive *a) free(state); a->compression_data = NULL; if (a->client_closer != NULL) - return ((a->client_closer)(a, a->client_data)); + return ((a->client_closer)(&a->archive, a->client_data)); return (ARCHIVE_OK); } |