*/
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#define memzero(s, n) memset ((void *)(s), 0, (n))
#ifndef RETSIGTYPE
(char *) window + start, length) != EQUAL) {
fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length);
- error_msg("invalid match\n");
+ error_msg("invalid match");
}
if (verbose > 1) {
fprintf(stderr, "\\[%d,%d]", start - match, length);
case 'd':
exit(gunzip_main(argc, argv));
default:
- usage(gzip_usage);
+ show_usage();
}
}
}
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
- error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not read from terminal. Use -f to force it.");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
- error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not written to terminal. Use -f to force it.");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
} else {
/* Open up the input file */
if (argc <= 0)
- usage(gzip_usage);
+ show_usage();
strncpy(ifname, *argv, MAX_PATH_LEN);
- /* Open input fille */
+ /* Open input file */
inFileNum = open(ifname, O_RDONLY);
- if (inFileNum < 0) {
- perror(ifname);
- exit(WARNING);
- }
+ if (inFileNum < 0)
+ perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
- result = stat(ifname, &statBuf);
- if (result < 0) {
- perror(ifname);
- exit(WARNING);
- }
+ if (stat(ifname, &statBuf) < 0)
+ perror_msg_and_die("%s", ifname);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
#else
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
#endif
- if (outFileNum < 0) {
- perror(ofname);
- exit(WARNING);
- }
+ if (outFileNum < 0)
+ perror_msg_and_die("%s", ofname);
SET_BINARY_MODE(outFileNum);
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
else
delFileName = ofname;
- if (unlink(delFileName) < 0) {
- perror(delFileName);
- exit(EXIT_FAILURE);
- }
+ if (unlink(delFileName) < 0)
+ perror_msg_and_die("%s", delFileName);
}
return(exit_code);
#endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
- error_msg("block vanished\n");
+ error_msg("block vanished");
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) {
- error_msg("-l used on binary file\n");
+ error_msg("-l used on binary file");
}
}
/* Copy the program name first */
if (oargc-- < 0)
- error_msg("argc<=0\n");
+ error_msg("argc<=0");
*(nargv++) = *(oargv++);
/* Then copy the environment args */