#error you need zcat to have gzip support!
#endif
-static const char gzip_usage[] = "gzip\nignores all command line arguments\ncompress stdin to stdout with -9 compression\n";
+static const char gzip_usage[] =
+ "gzip [OPTION]... [FILE]...\n\n"
+ "Compress FILEs with maximum compression.\n\n"
+ "Options:\n"
+ "\t-c\tWrite output on standard output\n";
+
/* gzip.h -- common declarations for all gzip modules
* Copyright (C) 1992-1993 Jean-loup Gailly.
extern int verbose; /* be verbose (-v) */
extern int quiet; /* be quiet (-q) */
extern int test; /* check .z file integrity */
-extern int to_stdout; /* output to stdout (-c) */
extern int save_orig_name; /* set if original name must be saved */
#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(0))
/* local variables */
int ascii = 0; /* convert end-of-lines to local OS conventions */
-int to_stdout = 0; /* output to stdout (-c) */
int decompress = 0; /* decompress (-d) */
+int tostdout = 0; /* uncompress to stdout (-c) */
int no_name = -1; /* don't save or restore the original file name */
int no_time = -1; /* don't save or restore the original file time */
int foreground; /* set if program run in foreground */
// int main (argc, argv)
// int argc;
// char **argv;
-int gzip_main(int argc, char * * argv)
+int gzip_main(int argc, char ** argv)
{
+
+ /* Parse any options */
+ while (--argc > 0 && **(++argv) == '-') {
+ while (*(++(*argv))) {
+ switch (**argv) {
+ case 'c':
+ tostdout = 1;
+ break;
+ default:
+ usage(gzip_usage);
+ }
+ }
+ }
+
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
(void) signal (SIGINT, (sig_type)abort_gzip);
strncpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)-1);
z_len = strlen(z_suffix);
- to_stdout = 1;
-
/* Allocate all global buffers (for DYN_ALLOC option) */
ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
#endif
/* And get to work */
- treat_stdin();
+ treat_stdin();
do_exit(exit_code);
return exit_code; /* just to avoid lint warning */
}
*/
local void treat_stdin()
{
- SET_BINARY_MODE(fileno(stdout));
+ SET_BINARY_MODE(fileno(stdout));
strcpy(ifname, "stdin");
strcpy(ofname, "stdout");
ifile_size = -1L; /* convention for unknown size */
clear_bufs(); /* clear input and output buffers */
- to_stdout = 1;
part_nb = 0;
/* Actually do the compression/decompression. Loop over zipped members.
*/
- if ((*work)(fileno(stdin), fileno(stdout)) != OK) return;
+ if ((*work)(fileno(stdin), fileno(stdout)) != OK) return;
}
/* ========================================================================
extern int errno;
#endif
-extern ulg crc_32_tab[]; /* crc table, defined below */
-
/* ===========================================================================
* Copy input to output unchanged: zcat == cat with --force.
* IN assertion: insize bytes have already been read in inbuf.
#error you need zcat to have gzip support!
#endif
-static const char gzip_usage[] = "gzip\nignores all command line arguments\ncompress stdin to stdout with -9 compression\n";
+static const char gzip_usage[] =
+ "gzip [OPTION]... [FILE]...\n\n"
+ "Compress FILEs with maximum compression.\n\n"
+ "Options:\n"
+ "\t-c\tWrite output on standard output\n";
+
/* gzip.h -- common declarations for all gzip modules
* Copyright (C) 1992-1993 Jean-loup Gailly.
extern int verbose; /* be verbose (-v) */
extern int quiet; /* be quiet (-q) */
extern int test; /* check .z file integrity */
-extern int to_stdout; /* output to stdout (-c) */
extern int save_orig_name; /* set if original name must be saved */
#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(0))
/* local variables */
int ascii = 0; /* convert end-of-lines to local OS conventions */
-int to_stdout = 0; /* output to stdout (-c) */
int decompress = 0; /* decompress (-d) */
+int tostdout = 0; /* uncompress to stdout (-c) */
int no_name = -1; /* don't save or restore the original file name */
int no_time = -1; /* don't save or restore the original file time */
int foreground; /* set if program run in foreground */
// int main (argc, argv)
// int argc;
// char **argv;
-int gzip_main(int argc, char * * argv)
+int gzip_main(int argc, char ** argv)
{
+
+ /* Parse any options */
+ while (--argc > 0 && **(++argv) == '-') {
+ while (*(++(*argv))) {
+ switch (**argv) {
+ case 'c':
+ tostdout = 1;
+ break;
+ default:
+ usage(gzip_usage);
+ }
+ }
+ }
+
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
(void) signal (SIGINT, (sig_type)abort_gzip);
strncpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)-1);
z_len = strlen(z_suffix);
- to_stdout = 1;
-
/* Allocate all global buffers (for DYN_ALLOC option) */
ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
#endif
/* And get to work */
- treat_stdin();
+ treat_stdin();
do_exit(exit_code);
return exit_code; /* just to avoid lint warning */
}
*/
local void treat_stdin()
{
- SET_BINARY_MODE(fileno(stdout));
+ SET_BINARY_MODE(fileno(stdout));
strcpy(ifname, "stdin");
strcpy(ofname, "stdout");
ifile_size = -1L; /* convention for unknown size */
clear_bufs(); /* clear input and output buffers */
- to_stdout = 1;
part_nb = 0;
/* Actually do the compression/decompression. Loop over zipped members.
*/
- if ((*work)(fileno(stdin), fileno(stdout)) != OK) return;
+ if ((*work)(fileno(stdin), fileno(stdout)) != OK) return;
}
/* ========================================================================
extern int errno;
#endif
-extern ulg crc_32_tab[]; /* crc table, defined below */
-
/* ===========================================================================
* Copy input to output unchanged: zcat == cat with --force.
* IN assertion: insize bytes have already been read in inbuf.
extern int errno;
#endif
-const ulg crc_32_tab[]; /* crc table, defined below */
+static const ulg crc_32_tab[]; /* crc table, defined below */
/* ===========================================================================
* Run a set of bytes through the crc shift register. If s is a NULL
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by makecrc.c)
*/
-const ulg crc_32_tab[] = {
+static const ulg crc_32_tab[] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,