Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-04 04:10:25 +0300
committerErik Andersen <andersen@codepoet.org>2000-01-04 04:10:25 +0300
commit7dc160721ee3ceb76240a43d1454b45aaa9dbee4 (patch)
tree7532471be456e2c9f11eab88cb34f1e38abd184f /gunzip.c
parent9c88cac5cbfb2ff70f800ee5bb3289e925aaa65f (diff)
Bunches of fixes. Typos, bugs, etc.
Added 'gunzip -t'. inittab support _almost_ works (but it isn't ready for prime time useage yet). -Erik
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[] =
"gunzip [OPTION]... FILE\n\n"
"Uncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
- "\t-c\tWrite output to standard output\n";
+ "\t-c\tWrite output to standard output\n"
+ "\t-t\tTest compressed file integrity\n";
/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
* Copyright (C) 1992-1993 Jean-loup Gailly
@@ -653,7 +654,7 @@ DECLARE(uch, window, 2L*WSIZE);
/* local variables */
-int force = 0; /* don't ask questions, compress links (-f) */
+int test_mode = 0; /* check file integrity option */
int foreground; /* set if program run in foreground */
int maxbits = BITS; /* max bits per code for LZW */
int method = DEFLATED;/* compression method */
@@ -714,6 +715,10 @@ int gunzip_main (int argc, char** argv)
case 'c':
to_stdout = 1;
break;
+ case 't':
+ test_mode = 1;
+ break;
+
default:
usage(gunzip_usage);
}
@@ -786,6 +791,9 @@ int gunzip_main (int argc, char** argv)
/* Actually do the compression/decompression. */
unzip(inFileNum, outFileNum);
+ } else if (test_mode) {
+ /* Actually do the compression/decompression. */
+ unzip(inFileNum, 2);
} else {
char* pos;
@@ -857,17 +865,8 @@ local int get_method(in)
uch flags; /* compression flags */
char magic[2]; /* magic header */
- /* If --force and --stdout, zcat == cat, so do not complain about
- * premature end of file: use try_byte instead of get_byte.
- */
- if (force) {
- magic[0] = (char)try_byte();
- magic[1] = (char)try_byte();
- /* If try_byte returned EOF, magic[1] == 0xff */
- } else {
- magic[0] = (char)get_byte();
- magic[1] = (char)get_byte();
- }
+ magic[0] = (char)get_byte();
+ magic[1] = (char)get_byte();
method = -1; /* unknown yet */
part_nb++; /* number of parts in gzip file */
header_bytes = 0;
@@ -1188,7 +1187,8 @@ void flush_outbuf()
{
if (outcnt == 0) return;
- write_buf(ofd, (char *)outbuf, outcnt);
+ if (!test_mode)
+ write_buf(ofd, (char *)outbuf, outcnt);
bytes_out += (ulg)outcnt;
outcnt = 0;
}
@@ -1202,8 +1202,8 @@ void flush_window()
if (outcnt == 0) return;
updcrc(window, outcnt);
- write_buf(ofd, (char *)window, outcnt);
-
+ if (!test_mode)
+ write_buf(ofd, (char *)window, outcnt);
bytes_out += (ulg)outcnt;
outcnt = 0;
}