gzip.c (99742a231f9bc662d03fb37ee620500cc1b4a8a7) | gzip.c (feeb03b2c8a08d6696f7f170e4d006e5d5cb9b8b) |
---|---|
1/* $NetBSD: gzip.c,v 1.94 2009/04/12 10:31:14 lukem Exp $ */ | 1/* $NetBSD: gzip.c,v 1.97 2009/10/11 09:17:21 mrg Exp $ */ |
2 3/*- 4 * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 134 unchanged lines hidden (view full) --- 144#ifndef NO_COMPRESS_SUPPORT 145 SUFFIX(Z_SUFFIX, ""), 146#endif 147 SUFFIX(GZ_SUFFIX, ""), /* Overwritten by -S "" */ 148#endif /* SMALL */ 149#undef SUFFIX 150}; 151#define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0]) | 2 3/*- 4 * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 134 unchanged lines hidden (view full) --- 144#ifndef NO_COMPRESS_SUPPORT 145 SUFFIX(Z_SUFFIX, ""), 146#endif 147 SUFFIX(GZ_SUFFIX, ""), /* Overwritten by -S "" */ 148#endif /* SMALL */ 149#undef SUFFIX 150}; 151#define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0]) |
152 | |
153#define SUFFIX_MAXLEN 30 154 | 152#define SUFFIX_MAXLEN 30 153 |
155static const char gzip_version[] = "FreeBSD gzip 20090621"; | 154static const char gzip_version[] = "FreeBSD gzip 20100407"; |
156 157#ifndef SMALL 158static const char gzip_copyright[] = \ 159" Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green\n" 160" All rights reserved.\n" 161"\n" 162" Redistribution and use in source and binary forms, with or without\n" 163" modification, are permitted provided that the following conditions\n" --- 37 unchanged lines hidden (view full) --- 201#endif 202 203static int exit_value = 0; /* exit value */ 204 205static char *infile; /* name of file coming in */ 206 207static void maybe_err(const char *fmt, ...) __dead2 208 __attribute__((__format__(__printf__, 1, 2))); | 155 156#ifndef SMALL 157static const char gzip_copyright[] = \ 158" Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green\n" 159" All rights reserved.\n" 160"\n" 161" Redistribution and use in source and binary forms, with or without\n" 162" modification, are permitted provided that the following conditions\n" --- 37 unchanged lines hidden (view full) --- 200#endif 201 202static int exit_value = 0; /* exit value */ 203 204static char *infile; /* name of file coming in */ 205 206static void maybe_err(const char *fmt, ...) __dead2 207 __attribute__((__format__(__printf__, 1, 2))); |
209#ifndef NO_BZIP2_SUPPORT | 208#if !defined(NO_BZIP2_SUPPORT) || !defined(NO_PACK_SUPPORT) |
210static void maybe_errx(const char *fmt, ...) __dead2 211 __attribute__((__format__(__printf__, 1, 2))); 212#endif 213static void maybe_warn(const char *fmt, ...) 214 __attribute__((__format__(__printf__, 1, 2))); 215static void maybe_warnx(const char *fmt, ...) 216 __attribute__((__format__(__printf__, 1, 2))); 217static enum filetype file_gettype(u_char *); --- 238 unchanged lines hidden (view full) --- 456 if (qflag == 0) { 457 va_start(ap, fmt); 458 vwarn(fmt, ap); 459 va_end(ap); 460 } 461 exit(2); 462} 463 | 209static void maybe_errx(const char *fmt, ...) __dead2 210 __attribute__((__format__(__printf__, 1, 2))); 211#endif 212static void maybe_warn(const char *fmt, ...) 213 __attribute__((__format__(__printf__, 1, 2))); 214static void maybe_warnx(const char *fmt, ...) 215 __attribute__((__format__(__printf__, 1, 2))); 216static enum filetype file_gettype(u_char *); --- 238 unchanged lines hidden (view full) --- 455 if (qflag == 0) { 456 va_start(ap, fmt); 457 vwarn(fmt, ap); 458 va_end(ap); 459 } 460 exit(2); 461} 462 |
464#ifndef NO_BZIP2_SUPPORT | 463#if !defined(NO_BZIP2_SUPPORT) || !defined(NO_PACK_SUPPORT) |
465/* ... without an errno. */ 466void 467maybe_errx(const char *fmt, ...) 468{ 469 va_list ap; 470 471 if (qflag == 0) { 472 va_start(ap, fmt); --- 841 unchanged lines hidden (view full) --- 1314{ 1315 struct stat isb, osb; 1316 off_t size; 1317 ssize_t rbytes; 1318 unsigned char header1[4]; 1319 enum filetype method; 1320 int fd, ofd, zfd = -1; 1321#ifndef SMALL | 464/* ... without an errno. */ 465void 466maybe_errx(const char *fmt, ...) 467{ 468 va_list ap; 469 470 if (qflag == 0) { 471 va_start(ap, fmt); --- 841 unchanged lines hidden (view full) --- 1313{ 1314 struct stat isb, osb; 1315 off_t size; 1316 ssize_t rbytes; 1317 unsigned char header1[4]; 1318 enum filetype method; 1319 int fd, ofd, zfd = -1; 1320#ifndef SMALL |
1321 ssize_t rv; |
|
1322 time_t timestamp = 0; 1323 unsigned char name[PATH_MAX + 1]; 1324#endif 1325 1326 /* gather the old name info */ 1327 1328 fd = open(file, O_RDONLY); 1329 if (fd < 0) { --- 29 unchanged lines hidden (view full) --- 1359 goto lose; 1360 } 1361 1362#endif 1363 1364#ifndef SMALL 1365 if (method == FT_GZIP && Nflag) { 1366 unsigned char ts[4]; /* timestamp */ | 1322 time_t timestamp = 0; 1323 unsigned char name[PATH_MAX + 1]; 1324#endif 1325 1326 /* gather the old name info */ 1327 1328 fd = open(file, O_RDONLY); 1329 if (fd < 0) { --- 29 unchanged lines hidden (view full) --- 1359 goto lose; 1360 } 1361 1362#endif 1363 1364#ifndef SMALL 1365 if (method == FT_GZIP && Nflag) { 1366 unsigned char ts[4]; /* timestamp */ |
1367 ssize_t rv; | |
1368 1369 rv = pread(fd, ts, sizeof ts, GZIP_TIMESTAMP); 1370 if (rv >= 0 && rv < (ssize_t)(sizeof ts)) 1371 goto unexpected_EOF; 1372 if (rv == -1) { 1373 if (!fflag) 1374 maybe_warn("can't read %s", file); 1375 goto lose; --- 673 unchanged lines hidden (view full) --- 2049} 2050 2051#ifndef SMALL 2052/* display the license information of FreeBSD gzip */ 2053static void 2054display_license(void) 2055{ 2056 | 1367 1368 rv = pread(fd, ts, sizeof ts, GZIP_TIMESTAMP); 1369 if (rv >= 0 && rv < (ssize_t)(sizeof ts)) 1370 goto unexpected_EOF; 1371 if (rv == -1) { 1372 if (!fflag) 1373 maybe_warn("can't read %s", file); 1374 goto lose; --- 673 unchanged lines hidden (view full) --- 2048} 2049 2050#ifndef SMALL 2051/* display the license information of FreeBSD gzip */ 2052static void 2053display_license(void) 2054{ 2055 |
2057 fprintf(stderr, "%s (based on NetBSD gzip 20060927)\n", gzip_version); | 2056 fprintf(stderr, "%s (based on NetBSD gzip 20091011)\n", gzip_version); |
2058 fprintf(stderr, "%s\n", gzip_copyright); 2059 exit(0); 2060} 2061#endif 2062 2063/* display the version of NetBSD gzip */ 2064static void 2065display_version(void) --- 29 unchanged lines hidden (view full) --- 2095 break; /* EOF */ 2096 } 2097 cp += ret; 2098 left -= ret; 2099 } 2100 2101 return sz - left; 2102} | 2057 fprintf(stderr, "%s\n", gzip_copyright); 2058 exit(0); 2059} 2060#endif 2061 2062/* display the version of NetBSD gzip */ 2063static void 2064display_version(void) --- 29 unchanged lines hidden (view full) --- 2094 break; /* EOF */ 2095 } 2096 cp += ret; 2097 left -= ret; 2098 } 2099 2100 return sz - left; 2101} |
2103 | |