aboutsummaryrefslogtreecommitdiff
path: root/archival/gunzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/gunzip.c')
-rw-r--r--archival/gunzip.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c
index 8558573ba..194921682 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -76,40 +76,40 @@ static char *license_msg[] = {
76#define bb_need_name_too_long 76#define bb_need_name_too_long
77#include "messages.c" 77#include "messages.c"
78 78
79#define RECORD_IO 0 79static const int RECORD_IO = 0;
80 80
81/* Return codes from gzip */ 81/* Return codes from gzip */
82#define OK 0 82static const int OK = 0;
83#define ERROR 1 83static const int ERROR = 1;
84#define WARNING 2 84static const int WARNING = 2;
85 85
86#define DEFLATED 8 86static const int DEFLATED = 8;
87#define INBUFSIZ 0x2000 /* input buffer size */ 87static const int INBUFSIZ = 0x2000; /* input buffer size */
88#define INBUF_EXTRA 64 /* required by unlzw() */ 88static const int INBUF_EXTRA = 64; /* required by unlzw() */
89#define OUTBUFSIZ 8192 /* output buffer size */ 89static const int OUTBUFSIZ = 8192; /* output buffer size */
90#define OUTBUF_EXTRA 2048 /* required by unlzw() */ 90static const int OUTBUF_EXTRA = 2048; /* required by unlzw() */
91#define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */ 91static const int DIST_BUFSIZE = 0x2000; /* buffer for distances, see trees.c */
92 92
93#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */ 93#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */
94 94
95/* gzip flag byte */ 95/* gzip flag byte */
96#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ 96static const int EXTRA_FIELD = 0x04; /* bit 2 set: extra field present */
97#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ 97static const int ORIG_NAME = 0x08; /* bit 3 set: original file name present */
98#define COMMENT 0x10 /* bit 4 set: file comment present */ 98static const int COMMENT = 0x10; /* bit 4 set: file comment present */
99#define WSIZE 0x8000 /* window size--must be a power of two, and */ 99static const int WSIZE = 0x8000; /* window size--must be a power of two, and */
100 /* at least 32K for zip's deflate method */ 100 /* at least 32K for zip's deflate method */
101 101
102/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ 102/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
103#define BMAX 16 /* maximum bit length of any code (16 for explode) */ 103static const int BMAX = 16; /* maximum bit length of any code (16 for explode) */
104#define N_MAX 288 /* maximum number of codes in any set */ 104static const int N_MAX = 288; /* maximum number of codes in any set */
105 105
106/* PKZIP header definitions */ 106/* PKZIP header definitions */
107#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */ 107static const int LOCSIG = 0x04034b50L; /* four-byte lead-in (lsb first) */
108#define LOCCRC 14 /* offset of crc */ 108static const int LOCCRC = 14; /* offset of crc */
109#define LOCLEN 22 /* offset of uncompressed length */ 109static const int LOCLEN = 22; /* offset of uncompressed length */
110#define EXTHDR 16 /* size of extended local header, inc sig */ 110static const int EXTHDR = 16; /* size of extended local header, inc sig */
111 111
112#define BITS 16 112static const int BITS = 16;
113 113
114/* Diagnostic functions */ 114/* Diagnostic functions */
115#ifdef DEBUG 115#ifdef DEBUG
@@ -132,7 +132,7 @@ static char *license_msg[] = {
132# ifdef BUFSIZ 132# ifdef BUFSIZ
133# define MAX_PATH_LEN BUFSIZ 133# define MAX_PATH_LEN BUFSIZ
134# else 134# else
135# define MAX_PATH_LEN 1024 135static const int MAX_PATH_LEN = 1024;
136# endif 136# endif
137#endif 137#endif
138 138
@@ -165,8 +165,8 @@ static ush *tab_prefix1;
165/* local variables */ 165/* local variables */
166static int test_mode = 0; /* check file integrity option */ 166static int test_mode = 0; /* check file integrity option */
167static int foreground; /* set if program run in foreground */ 167static int foreground; /* set if program run in foreground */
168static int method = DEFLATED; /* compression method */ 168static int method; /* compression method */
169static int exit_code = OK; /* program exit code */ 169static int exit_code; /* program exit code */
170static int last_member; /* set for .zip and .Z files */ 170static int last_member; /* set for .zip and .Z files */
171static int part_nb; /* number of parts in .gz file */ 171static int part_nb; /* number of parts in .gz file */
172static long ifile_size; /* input file size, -1 for devices (debug only) */ 172static long ifile_size; /* input file size, -1 for devices (debug only) */
@@ -1225,6 +1225,9 @@ int gunzip_main(int argc, char **argv)
1225 char ifname[MAX_PATH_LEN + 1]; /* input file name */ 1225 char ifname[MAX_PATH_LEN + 1]; /* input file name */
1226 char ofname[MAX_PATH_LEN + 1]; /* output file name */ 1226 char ofname[MAX_PATH_LEN + 1]; /* output file name */
1227 1227
1228 method = DEFLATED; /* default compression method */
1229 exit_code = OK; /* let's go out on a limb and assume everything will run fine (wink wink) */
1230
1228 if (strcmp(applet_name, "zcat") == 0) { 1231 if (strcmp(applet_name, "zcat") == 0) {
1229 force = 1; 1232 force = 1;
1230 tostdout = 1; 1233 tostdout = 1;