]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Move archive_compressor_gzip_free and archive_compressor_gzip_options
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 11 Oct 2012 20:15:29 +0000 (05:15 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 11 Oct 2012 20:15:29 +0000 (05:15 +0900)
after archive_write_add_filter_gzip. This is preparation to use an
external program gzip if zlib is not available.

libarchive/archive_write_add_filter_gzip.c

index 398751f3a8b7e492d69b4598acb2ed736807f5cb..3d3f1f47504315ce48e1caf65d3b442ebd970afa 100644 (file)
@@ -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.