From: Michihiro NAKAJIMA Date: Thu, 11 Oct 2012 20:15:29 +0000 (+0900) Subject: Move archive_compressor_gzip_free and archive_compressor_gzip_options X-Git-Tag: v3.1.0~40^2~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee9bf37b9215d46783afec37c0b8abb807868c93;p=thirdparty%2Flibarchive.git Move archive_compressor_gzip_free and archive_compressor_gzip_options after archive_write_add_filter_gzip. This is preparation to use an external program gzip if zlib is not available. --- diff --git a/libarchive/archive_write_add_filter_gzip.c b/libarchive/archive_write_add_filter_gzip.c index 398751f3a..3d3f1f475 100644 --- a/libarchive/archive_write_add_filter_gzip.c +++ b/libarchive/archive_write_add_filter_gzip.c @@ -120,6 +120,39 @@ archive_write_add_filter_gzip(struct archive *_a) return (ARCHIVE_OK); } +static int +archive_compressor_gzip_free(struct archive_write_filter *f) +{ + struct private_data *data = (struct private_data *)f->data; + free(data->compressed); + free(data); + f->data = NULL; + return (ARCHIVE_OK); +} + +/* + * Set write options. + */ +static int +archive_compressor_gzip_options(struct archive_write_filter *f, const char *key, + const char *value) +{ + struct private_data *data = (struct private_data *)f->data; + + if (strcmp(key, "compression-level") == 0) { + if (value == NULL || !(value[0] >= '0' && value[0] <= '9') || + value[1] != '\0') + return (ARCHIVE_WARN); + data->compression_level = value[0] - '0'; + return (ARCHIVE_OK); + } + + /* Note: The "warn" return is just to inform the options + * supervisor that we didn't handle it. It will generate + * a suitable error if no one used this option. */ + return (ARCHIVE_WARN); +} + /* * Setup callback. */ @@ -214,29 +247,6 @@ archive_compressor_gzip_open(struct archive_write_filter *f) return (ARCHIVE_FATAL); } -/* - * Set write options. - */ -static int -archive_compressor_gzip_options(struct archive_write_filter *f, const char *key, - const char *value) -{ - struct private_data *data = (struct private_data *)f->data; - - if (strcmp(key, "compression-level") == 0) { - if (value == NULL || !(value[0] >= '0' && value[0] <= '9') || - value[1] != '\0') - return (ARCHIVE_WARN); - data->compression_level = value[0] - '0'; - return (ARCHIVE_OK); - } - - /* Note: The "warn" return is just to inform the options - * supervisor that we didn't handle it. It will generate - * a suitable error if no one used this option. */ - return (ARCHIVE_WARN); -} - /* * Write data to the compressed stream. */ @@ -303,16 +313,6 @@ archive_compressor_gzip_close(struct archive_write_filter *f) return (r1 < ret ? r1 : ret); } -static int -archive_compressor_gzip_free(struct archive_write_filter *f) -{ - struct private_data *data = (struct private_data *)f->data; - free(data->compressed); - free(data); - f->data = NULL; - return (ARCHIVE_OK); -} - /* * Utility function to push input data through compressor, * writing full output blocks as necessary.