From: Konrad Kleine Date: Thu, 12 Sep 2013 15:01:31 +0000 (+0200) Subject: Added all Zip compression names from 6.3.3 format X-Git-Tag: v3.1.900a~356^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa297a7a4642ebd0520ab26a92139d7c55efe468;p=thirdparty%2Flibarchive.git Added all Zip compression names from 6.3.3 format I've added all the compression names and IDs from the ".ZIP File Format Specification" version 6.3.3 that can be found in section "4.4.5 compression method" of this document: http://www.pkware.com/documents/casestudies/APPNOTE.TXT --- diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index c9fae7f24..00132dc94 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 2004 Tim Kientzle * Copyright (c) 2011-2012 Michihiro NAKAJIMA + * Copyright (c) 2013 Konrad Kleine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1128,26 +1129,49 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, return (ret); } +struct compression_method { + int id; + const char * name; + const char * description; +}; + +static const struct compression_method compression_methods[] = { +/* ID NAME DESCRIPTION */ + {0, "uncompressed", "The file is stored (no compression)"}, + {1, "shrinking", "The file is Shrunk"}, + {2, "reduced-1", "The file is Reduced with compression factor 1"}, + {3, "reduced-2", "The file is Reduced with compression factor 2"}, + {4, "reduced-3", "The file is Reduced with compression factor 3"}, + {5, "reduced-4", "The file is Reduced with compression factor 4"}, + {6, "imploded", "The file is Imploded"}, + {7, "reserved", "Reserved for Tokenizing compression algorithm"}, + {8, "deflation", "The file is Deflated"}, + {9, "deflation-64-bit", "Enhanced Deflating using Deflate64(tm)"}, + {10, "imb-terse", "PKWARE Data Compression Library Imploding (old IBM TERSE)"}, + {11, "reserved", "Reserved by PKWARE"}, + {12, "bzip", "File is compressed using BZIP2 algorithm"}, + {13, "reserved", "Reserved by PKWARE"}, + {14, "lzma", "LZMA (EFS)"}, + {15, "reserved", "Reserved by PKWARE"}, + {16, "reserved", "Reserved by PKWARE"}, + {17, "reserved", "Reserved by PKWARE"}, + {18, "imb-terse-new", "File is compressed using IBM TERSE (new)"}, + {19, "imb-lz777", "IBM LZ77 z Architecture (PFS)"}, + {97, "wav-pack", "WavPack compressed data"}, + {98, "ppmd-1", "PPMd version I, Rev 1"} +}; + static const char * -compression_name(int compression) +compression_name(const int compression) { - static const char *compression_names[] = { - "uncompressed", - "shrinking", - "reduced-1", - "reduced-2", - "reduced-3", - "reduced-4", - "imploded", - "reserved", - "deflation" - }; - - if (0 <= compression && compression < - (int)(sizeof(compression_names)/sizeof(compression_names[0]))) - return compression_names[compression]; - else - return "??"; + static const int num_compression_methods = sizeof(compression_methods)/sizeof(struct compression_method); + int i=0; + while(compression >= 0 && i++ < num_compression_methods) { + if (compression_methods[i].id == compression) { + return compression_methods[i].name; + } + } + return "??"; } /* Convert an MSDOS-style date/time into Unix-style time. */