summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_private.h
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@gmail.com>2010-02-20 00:53:11 -0500
committerTim Kientzle <kientzle@gmail.com>2010-02-20 00:53:11 -0500
commit911dc2bff3dc37fa499c17379dcf35f352f88c0b (patch)
treebe38d9958879cea30c63edc440c6e31e826c6625 /libarchive/archive_write_private.h
parent8f43f6931172a59c0e25647b35503a99d6f26fde (diff)
downloadlibarchive-911dc2bff3dc37fa499c17379dcf35f352f88c0b.tar.gz
Stackable write filter support. This ended up touching an awful lot
of files. But, the old API is supported almost entirely unchanged, which I wasn't certain would be possible. Big changes: * You can add more than one write filter by using archive_write_add_filter_{bzip2,compress,gzip,lzma,xz}. This will be more interesting when we have uuencode, RPM, encryption. * The old archive_write_set_compression_XXXX are shorthands for "remove all the current filters and add this one." They're deprecated and scheduled to be removed in libarchive 4.0. * The internal API and life cycle for write filters has been rationalized: create, set options, open, write, close, free. * New utility functions provide information about each filter when there's more than one: code, name, and number of bytes processed * Old archive_bytes_compressed(), etc, are implemented in terms of the more generic new functions. * The read side was generalized to also support the new utility functions. In particular, the write filters are much simpler since each one doesn't have to deal with blocking. In this version, there's still a "write_add_filter_none" that handles blocking, but I think I'll soon fold that down into the client wrapper and add_filter_none will become a no-op. I think this also gets us a big step closer to multi-volume support on the write side. SVN-Revision: 1920
Diffstat (limited to 'libarchive/archive_write_private.h')
-rw-r--r--libarchive/archive_write_private.h45
1 files changed, 33 insertions, 12 deletions
diff --git a/libarchive/archive_write_private.h b/libarchive/archive_write_private.h
index f9b65655..ae5adfc0 100644
--- a/libarchive/archive_write_private.h
+++ b/libarchive/archive_write_private.h
@@ -36,6 +36,36 @@
#include "archive_string.h"
#include "archive_private.h"
+struct archive_write;
+
+struct archive_write_filter {
+ int64_t bytes_written;
+ struct archive *archive; /* Associated archive. */
+ struct archive_write_filter *next_filter; /* Who I write to. */
+ int (*options)(struct archive_write_filter *,
+ const char *key, const char *value);
+ int (*open)(struct archive_write_filter *);
+ int (*write)(struct archive_write_filter *, const void *, size_t);
+ int (*close)(struct archive_write_filter *);
+ int (*free)(struct archive_write_filter *);
+ void *data;
+ const char *name;
+ int code;
+ int bytes_per_block;
+ int bytes_in_last_block;
+};
+
+#if ARCHIVE_VERSION < 4000000
+void __archive_write_filters_free(struct archive *);
+#endif
+
+struct archive_write_filter *__archive_write_allocate_filter(struct archive *);
+
+int __archive_write_output(struct archive_write *, const void *, size_t);
+int __archive_write_filter(struct archive_write_filter *, const void *, size_t);
+int __archive_write_open_filter(struct archive_write_filter *);
+int __archive_write_close_filter(struct archive_write_filter *);
+
struct archive_write {
struct archive archive;
@@ -71,21 +101,12 @@ struct archive_write {
* effect on compression "none."
*/
int pad_uncompressed;
- int pad_uncompressed_byte; /* TODO: Support this. */
/*
- * On write, the client just invokes an archive_write_set function
- * which sets up the data here directly.
+ * First and last write filters in the pipeline.
*/
- struct {
- void *data;
- void *config;
- int (*init)(struct archive_write *);
- int (*options)(struct archive_write *,
- const char *key, const char *value);
- int (*finish)(struct archive_write *);
- int (*write)(struct archive_write *, const void *, size_t);
- } compressor;
+ struct archive_write_filter *filter_first;
+ struct archive_write_filter *filter_last;
/*
* Pointers to format-specific functions for writing. They're