diff options
author | kientzle <kientzle@FreeBSD.org> | 2007-05-29 01:00:21 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2007-05-29 01:00:21 +0000 |
commit | 013be331bc10706807599a452a143f4744398e9f (patch) | |
tree | 793787ab8615d768ba51341dfd934a5fb3039728 /lib/libarchive/archive_read_private.h | |
parent | c611006e893ac2bf962cabe02743954e3b3c3314 (diff) | |
download | FreeBSD-src-013be331bc10706807599a452a143f4744398e9f.zip FreeBSD-src-013be331bc10706807599a452a143f4744398e9f.tar.gz |
libarchive 2.2.3
* "compression_program" support uses an external program
* Portability: no longer uses "struct stat" as a primary
data interchange structure internally
* Part of the above: refactor archive_entry to separate
out copy_stat() and stat() functions
* More complete tests for archive_entry
* Finish archive_entry_clone()
* Isolate major()/minor()/makedev() in archive_entry; remove
these from everywhere else.
* Bug fix: properly handle decompression look-ahead at end-of-data
* Bug fixes to 'ar' support
* Fix memory leak in ZIP reader
* Portability: better timegm() emulation in iso9660 reader
* New write_disk flags to suppress auto dir creation and not
overwrite newer files (for future cpio front-end)
* Simplify trailing-'/' fixup when writing tar and pax
* Test enhancements: fix various compiler warnings, improve
portability, add lots of new tests.
* Documentation: document new functions, first draft of
libarchive_internals.3
MFC after: 14 days
Thanks to: Joerg Sonnenberger (compression_program)
Thanks to: Kai Wang (ar)
Thanks to: Colin Percival (many small fixes)
Thanks to: Many others who sent me various patches and problem reports.
Diffstat (limited to 'lib/libarchive/archive_read_private.h')
-rw-r--r-- | lib/libarchive/archive_read_private.h | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/lib/libarchive/archive_read_private.h b/lib/libarchive/archive_read_private.h index 64844d7..f9b1749 100644 --- a/lib/libarchive/archive_read_private.h +++ b/lib/libarchive/archive_read_private.h @@ -86,33 +86,35 @@ struct archive_read { off_t header_position; /* - * Detection functions for decompression: bid functions are - * given a block of data from the beginning of the stream and - * can bid on whether or not they support the data stream. - * General guideline: bid the number of bits that you actually - * test, e.g., 16 if you test a 2-byte magic value. The - * highest bidder will have their init function invoked, which - * can set up pointers to specific handlers. + * Decompressors have a very specific lifecycle: + * public setup function initializes a slot in this table + * 'config' holds minimal configuration data + * bid() examines a block of data and returns a bid [1] + * init() is called for successful bidder + * 'data' is initialized by init() + * read() returns a pointer to the next block of data + * consume() indicates how much data is used + * skip() ignores bytes of data + * finish() cleans up and frees 'data' and 'config' + * + * [1] General guideline: bid the number of bits that you actually + * test, e.g., 16 if you test a 2-byte magic value. */ - struct { + struct decompressor_t { + void *config; + void *data; int (*bid)(const void *buff, size_t); - int (*init)(struct archive_read *, const void *buff, size_t); + int (*init)(struct archive_read *, + const void *buff, size_t); + int (*finish)(struct archive_read *); + ssize_t (*read_ahead)(struct archive_read *, + const void **, size_t); + ssize_t (*consume)(struct archive_read *, size_t); + off_t (*skip)(struct archive_read *, off_t); } decompressors[4]; - /* Read/write data stream (with compression). */ - void *compression_data; /* Data for (de)compressor. */ - int (*compression_finish)(struct archive_read *); - /* - * Read uses a peek/consume I/O model: the decompression code - * returns a pointer to the requested block and advances the - * file position only when requested by a consume call. This - * reduces copying and also simplifies look-ahead for format - * detection. - */ - ssize_t (*compression_read_ahead)(struct archive_read *, - const void **, size_t request); - ssize_t (*compression_read_consume)(struct archive_read *, size_t); - off_t (*compression_skip)(struct archive_read *, off_t); + /* Pointer to current decompressor. */ + struct decompressor_t *decompressor; /* * Format detection is mostly the same as compression @@ -130,27 +132,16 @@ struct archive_read { */ struct archive_format_descriptor { + void *data; int (*bid)(struct archive_read *); int (*read_header)(struct archive_read *, struct archive_entry *); int (*read_data)(struct archive_read *, const void **, size_t *, off_t *); int (*read_data_skip)(struct archive_read *); int (*cleanup)(struct archive_read *); - void *format_data; /* Format-specific data for readers. */ } formats[8]; struct archive_format_descriptor *format; /* Active format. */ /* - * Storage for format-specific data. Note that there can be - * multiple format readers active at one time, so we need to - * allow for multiple format readers to have their data - * available. The pformat_data slot here is the solution: on - * read, it is guaranteed to always point to a void* variable - * that the format can use. - */ - void **pformat_data; /* Pointer to current format_data. */ - void *format_data; /* Used by writers. */ - - /* * Pointers to format-specific functions for writing. They're * initialized by archive_write_set_format_XXX() calls. */ @@ -177,7 +168,8 @@ int __archive_read_register_format(struct archive_read *a, int (*read_data_skip)(struct archive_read *), int (*cleanup)(struct archive_read *)); -int __archive_read_register_compression(struct archive_read *a, +struct decompressor_t + *__archive_read_register_compression(struct archive_read *a, int (*bid)(const void *, size_t), int (*init)(struct archive_read *, const void *, size_t)); |