version 1.102, 2022/10/22 14:41:27 |
version 1.103, 2022/10/23 19:06:35 |
|
|
const char *name; |
const char *name; |
const char *suffix; |
const char *suffix; |
const u_char *magic; |
const u_char *magic; |
const char *comp_opts; |
const char *opts; |
const char *decomp_opts; |
|
const char *cat_opts; |
|
void *(*ropen)(int, char *, int); |
void *(*ropen)(int, char *, int); |
int (*read)(void *, char *, int); |
int (*read)(void *, char *, int); |
#ifndef SMALL |
#ifndef SMALL |
|
|
".gz", |
".gz", |
"\037\213", |
"\037\213", |
"123456789ab:cdfhkLlNnOo:qrS:tVv", |
"123456789ab:cdfhkLlNnOo:qrS:tVv", |
"cfhkLlNno:qrtVv", |
|
"fhqr", |
|
gz_ropen, |
gz_ropen, |
gz_read, |
gz_read, |
#ifndef SMALL |
#ifndef SMALL |
|
|
".Z", |
".Z", |
"\037\235", |
"\037\235", |
"123456789ab:cdfghlNnOo:qrS:tv", |
"123456789ab:cdfghlNnOo:qrS:tv", |
"cfhlNno:qrtv", |
|
"fghqr", |
|
z_ropen, |
z_ropen, |
zread, |
zread, |
z_wopen, |
z_wopen, |
|
|
".zip", |
".zip", |
"PK", |
"PK", |
NULL, |
NULL, |
"cfhkLlNno:qrtVv", |
|
"fhqr", |
|
zip_ropen, |
zip_ropen, |
zip_read, |
zip_read, |
NULL, |
NULL, |
|
|
".nul", |
".nul", |
"XX", |
"XX", |
"123456789ab:cdfghlNnOo:qrS:tv", |
"123456789ab:cdfghlNnOo:qrS:tv", |
"cfhlNno:qrtv", |
|
"fghqr", |
|
null_ropen, |
null_ropen, |
null_read, |
null_read, |
null_wopen, |
null_wopen, |
|
|
}; |
}; |
#endif /* SMALL */ |
#endif /* SMALL */ |
|
|
int permission(const char *); |
static int permission(const char *); |
__dead void usage(int); |
static __dead void usage(int); |
int docompress(const char *, char *, const struct compressor *, |
static int docompress(const char *, char *, const struct compressor *, |
int, struct stat *); |
int, struct stat *); |
int dodecompress(const char *, char *, struct stat *); |
static int dodecompress(const char *, char *, struct stat *); |
const struct compressor *check_method(int); |
static const char *check_suffix(const char *); |
const char *check_suffix(const char *); |
static char *set_outfile(const char *, char *, size_t); |
char *set_outfile(const char *, char *, size_t); |
static void list_stats(const char *, const struct compressor *, |
void list_stats(const char *, const struct compressor *, struct z_info *); |
struct z_info *); |
void verbose_info(const char *, off_t, off_t, u_int32_t); |
static void verbose_info(const char *, off_t, off_t, u_int32_t); |
|
|
const struct option longopts[] = { |
|
#ifndef SMALL |
#ifndef SMALL |
|
const struct option longopts[] = { |
{ "ascii", no_argument, 0, 'a' }, |
{ "ascii", no_argument, 0, 'a' }, |
{ "stdout", no_argument, 0, 'c' }, |
{ "stdout", no_argument, 0, 'c' }, |
{ "to-stdout", no_argument, 0, 'c' }, |
{ "to-stdout", no_argument, 0, 'c' }, |
|
|
{ "version", no_argument, 0, 'V' }, |
{ "version", no_argument, 0, 'V' }, |
{ "fast", no_argument, 0, '1' }, |
{ "fast", no_argument, 0, '1' }, |
{ "best", no_argument, 0, '9' }, |
{ "best", no_argument, 0, '9' }, |
#endif /* SMALL */ |
|
{ NULL } |
{ NULL } |
}; |
}; |
|
#else /* SMALL */ |
|
const struct option *longopts = NULL; |
|
#endif /* SMALL */ |
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
|
|
method = M_COMPRESS; |
method = M_COMPRESS; |
#endif /* SMALL */ |
#endif /* SMALL */ |
} |
} |
optstr = method->comp_opts; |
optstr = method->opts; |
|
|
decomp = 0; |
decomp = 0; |
pmode = MODE_COMP; |
pmode = MODE_COMP; |
|
|
#endif |
#endif |
} |
} |
|
|
const struct compressor * |
static const struct compressor * |
check_method(int fd) |
check_method(int fd) |
{ |
{ |
const struct compressor *method; |
const struct compressor *method; |
|
|
return (NULL); |
return (NULL); |
} |
} |
|
|
int |
static int |
dodecompress(const char *in, char *out, struct stat *sb) |
dodecompress(const char *in, char *out, struct stat *sb) |
{ |
{ |
const struct compressor *method; |
const struct compressor *method; |
|
|
return (FAILURE); |
return (FAILURE); |
} |
} |
if (storename && oldname[0] != '\0') { |
if (storename && oldname[0] != '\0') { |
char *oldbase = basename(oldname); |
const char *oldbase = basename(oldname); |
char *cp = strrchr(out, '/'); |
char *cp = strrchr(out, '/'); |
if (cp != NULL) { |
if (cp != NULL) { |
*(cp + 1) = '\0'; |
*(cp + 1) = '\0'; |
|
|
warn("futimens: %s", name); |
warn("futimens: %s", name); |
} |
} |
|
|
int |
static int |
permission(const char *fname) |
permission(const char *fname) |
{ |
{ |
int ch, first; |
int ch, first; |
|
|
/* |
/* |
* Check infile for a known suffix and return the suffix portion or NULL. |
* Check infile for a known suffix and return the suffix portion or NULL. |
*/ |
*/ |
const char * |
static const char * |
check_suffix(const char *infile) |
check_suffix(const char *infile) |
{ |
{ |
int i; |
int i; |
|
|
* Set outfile based on the suffix. In most cases we just strip |
* Set outfile based on the suffix. In most cases we just strip |
* off the suffix but things like .tgz and .taz are special. |
* off the suffix but things like .tgz and .taz are special. |
*/ |
*/ |
char * |
static char * |
set_outfile(const char *infile, char *outfile, size_t osize) |
set_outfile(const char *infile, char *outfile, size_t osize) |
{ |
{ |
const char *s; |
const char *s; |
|
|
/* |
/* |
* Print output for the -l option. |
* Print output for the -l option. |
*/ |
*/ |
void |
static void |
list_stats(const char *name, const struct compressor *method, |
list_stats(const char *name, const struct compressor *method, |
struct z_info *info) |
struct z_info *info) |
{ |
{ |
|
|
} |
} |
} |
} |
|
|
void |
static void |
verbose_info(const char *file, off_t compressed, off_t uncompressed, |
verbose_info(const char *file, off_t compressed, off_t uncompressed, |
u_int32_t hlen) |
u_int32_t hlen) |
{ |
{ |
|
|
(long long)(decomp ? uncompressed : compressed)); |
(long long)(decomp ? uncompressed : compressed)); |
} |
} |
|
|
__dead void |
static __dead void |
usage(int status) |
usage(int status) |
{ |
{ |
const bool gzip = (__progname[0] == 'g'); |
const bool gzip = (__progname[0] == 'g'); |