aboutsummaryrefslogtreecommitdiff
path: root/gunzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'gunzip.c')
-rw-r--r--gunzip.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/gunzip.c b/gunzip.c
index 61391a33f..84f5d02b7 100644
--- a/gunzip.c
+++ b/gunzip.c
@@ -8,7 +8,8 @@ static const char gunzip_usage[] =
8 "gunzip [OPTION]... FILE\n\n" 8 "gunzip [OPTION]... FILE\n\n"
9 "Uncompress FILE (or standard input if FILE is '-').\n\n" 9 "Uncompress FILE (or standard input if FILE is '-').\n\n"
10 "Options:\n" 10 "Options:\n"
11 "\t-c\tWrite output to standard output\n"; 11 "\t-c\tWrite output to standard output\n"
12 "\t-t\tTest compressed file integrity\n";
12 13
13/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface 14/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
14 * Copyright (C) 1992-1993 Jean-loup Gailly 15 * Copyright (C) 1992-1993 Jean-loup Gailly
@@ -653,7 +654,7 @@ DECLARE(uch, window, 2L*WSIZE);
653 654
654 /* local variables */ 655 /* local variables */
655 656
656int force = 0; /* don't ask questions, compress links (-f) */ 657int test_mode = 0; /* check file integrity option */
657int foreground; /* set if program run in foreground */ 658int foreground; /* set if program run in foreground */
658int maxbits = BITS; /* max bits per code for LZW */ 659int maxbits = BITS; /* max bits per code for LZW */
659int method = DEFLATED;/* compression method */ 660int method = DEFLATED;/* compression method */
@@ -714,6 +715,10 @@ int gunzip_main (int argc, char** argv)
714 case 'c': 715 case 'c':
715 to_stdout = 1; 716 to_stdout = 1;
716 break; 717 break;
718 case 't':
719 test_mode = 1;
720 break;
721
717 default: 722 default:
718 usage(gunzip_usage); 723 usage(gunzip_usage);
719 } 724 }
@@ -786,6 +791,9 @@ int gunzip_main (int argc, char** argv)
786 /* Actually do the compression/decompression. */ 791 /* Actually do the compression/decompression. */
787 unzip(inFileNum, outFileNum); 792 unzip(inFileNum, outFileNum);
788 793
794 } else if (test_mode) {
795 /* Actually do the compression/decompression. */
796 unzip(inFileNum, 2);
789 } else { 797 } else {
790 char* pos; 798 char* pos;
791 799
@@ -857,17 +865,8 @@ local int get_method(in)
857 uch flags; /* compression flags */ 865 uch flags; /* compression flags */
858 char magic[2]; /* magic header */ 866 char magic[2]; /* magic header */
859 867
860 /* If --force and --stdout, zcat == cat, so do not complain about 868 magic[0] = (char)get_byte();
861 * premature end of file: use try_byte instead of get_byte. 869 magic[1] = (char)get_byte();
862 */
863 if (force) {
864 magic[0] = (char)try_byte();
865 magic[1] = (char)try_byte();
866 /* If try_byte returned EOF, magic[1] == 0xff */
867 } else {
868 magic[0] = (char)get_byte();
869 magic[1] = (char)get_byte();
870 }
871 method = -1; /* unknown yet */ 870 method = -1; /* unknown yet */
872 part_nb++; /* number of parts in gzip file */ 871 part_nb++; /* number of parts in gzip file */
873 header_bytes = 0; 872 header_bytes = 0;
@@ -1188,7 +1187,8 @@ void flush_outbuf()
1188{ 1187{
1189 if (outcnt == 0) return; 1188 if (outcnt == 0) return;
1190 1189
1191 write_buf(ofd, (char *)outbuf, outcnt); 1190 if (!test_mode)
1191 write_buf(ofd, (char *)outbuf, outcnt);
1192 bytes_out += (ulg)outcnt; 1192 bytes_out += (ulg)outcnt;
1193 outcnt = 0; 1193 outcnt = 0;
1194} 1194}
@@ -1202,8 +1202,8 @@ void flush_window()
1202 if (outcnt == 0) return; 1202 if (outcnt == 0) return;
1203 updcrc(window, outcnt); 1203 updcrc(window, outcnt);
1204 1204
1205 write_buf(ofd, (char *)window, outcnt); 1205 if (!test_mode)
1206 1206 write_buf(ofd, (char *)window, outcnt);
1207 bytes_out += (ulg)outcnt; 1207 bytes_out += (ulg)outcnt;
1208 outcnt = 0; 1208 outcnt = 0;
1209} 1209}