version 1.91, 2016/07/14 08:31:18 |
version 1.92, 2016/09/03 11:41:10 |
|
|
const char *comp_opts; |
const char *comp_opts; |
const char *decomp_opts; |
const char *decomp_opts; |
const char *cat_opts; |
const char *cat_opts; |
void *(*open)(int, const char *, char *, int, u_int32_t, int); |
void *(*ropen)(int, char *, int); |
|
void *(*wopen)(int, char *, int, u_int32_t); |
int (*read)(void *, char *, int); |
int (*read)(void *, char *, int); |
int (*write)(void *, const char *, int); |
int (*write)(void *, const char *, int); |
int (*close)(void *, struct z_info *, const char *, struct stat *); |
int (*close)(void *, struct z_info *, const char *, struct stat *); |
|
|
"123456789ab:cdfhLlNnOo:qrS:tVv", |
"123456789ab:cdfhLlNnOo:qrS:tVv", |
"cfhLlNno:qrtVv", |
"cfhLlNno:qrtVv", |
"fhqr", |
"fhqr", |
gz_open, |
gz_ropen, |
|
gz_wopen, |
gz_read, |
gz_read, |
gz_write, |
gz_write, |
gz_close |
gz_close |
|
|
"123456789ab:cdfghlNnOo:qrS:tv", |
"123456789ab:cdfghlNnOo:qrS:tv", |
"cfhlNno:qrtv", |
"cfhlNno:qrtv", |
"fghqr", |
"fghqr", |
z_open, |
z_ropen, |
|
z_wopen, |
zread, |
zread, |
zwrite, |
zwrite, |
z_close |
z_close |
}, |
}, |
#endif /* SMALL */ |
#endif /* SMALL */ |
#if 0 |
|
#define M_LZH (&c_table[2]) |
|
{ "lzh", ".lzh", "\037\240", lzh_open, lzh_read, lzh_write, lzh_close }, |
|
#define M_ZIP (&c_table[3]) |
|
{ "zip", ".zip", "PK", zip_open, zip_read, zip_write, zip_close }, |
|
#define M_PACK (&c_table[4]) |
|
{ "pack", ".pak", "\037\036", pak_open, pak_read, pak_write, pak_close }, |
|
#endif |
|
{ NULL } |
{ NULL } |
}; |
}; |
|
|
|
|
"123456789ab:cdfghlNnOo:qrS:tv", |
"123456789ab:cdfghlNnOo:qrS:tv", |
"cfhlNno:qrtv", |
"cfhlNno:qrtv", |
"fghqr", |
"fghqr", |
null_open, |
null_ropen, |
|
null_wopen, |
null_read, |
null_read, |
null_write, |
null_write, |
null_close |
null_close |
|
|
__dead void usage(int); |
__dead void usage(int); |
int docompress(const char *, char *, const struct compressor *, |
int docompress(const char *, char *, const struct compressor *, |
int, struct stat *); |
int, struct stat *); |
int dodecompress(const char *, char *, const struct compressor *, |
int dodecompress(const char *, char *, struct stat *); |
int, struct stat *); |
|
const struct compressor *check_method(int); |
const struct compressor *check_method(int); |
const char *check_suffix(const char *); |
const char *check_suffix(const char *); |
char *set_outfile(const char *, char *, size_t); |
char *set_outfile(const char *, char *, size_t); |
|
|
if (verbose > 0 && !pipin && !list) |
if (verbose > 0 && !pipin && !list) |
fprintf(stderr, "%s:\t", infile); |
fprintf(stderr, "%s:\t", infile); |
|
|
error = (decomp ? dodecompress : docompress) |
if (decomp) |
(infile, outfile, method, bits, entry->fts_statp); |
error = dodecompress(infile, outfile, entry->fts_statp); |
|
else |
|
error = docompress(infile, outfile, method, bits, entry->fts_statp); |
|
|
switch (error) { |
switch (error) { |
case SUCCESS: |
case SUCCESS: |
|
|
#ifndef SMALL |
#ifndef SMALL |
u_char buf[Z_BUFSIZE]; |
u_char buf[Z_BUFSIZE]; |
char *name; |
char *name; |
int error, ifd, ofd, flags, oreg; |
int error, ifd, ofd, oreg; |
void *cookie; |
void *cookie; |
ssize_t nr; |
ssize_t nr; |
u_int32_t mtime; |
u_int32_t mtime; |
|
|
struct stat osb; |
struct stat osb; |
|
|
mtime = 0; |
mtime = 0; |
flags = oreg = 0; |
oreg = 0; |
error = SUCCESS; |
error = SUCCESS; |
name = NULL; |
name = NULL; |
cookie = NULL; |
cookie = NULL; |
|
|
name = basename(in); |
name = basename(in); |
mtime = (u_int32_t)sb->st_mtime; |
mtime = (u_int32_t)sb->st_mtime; |
} |
} |
if ((cookie = (*method->open)(ofd, "w", name, bits, mtime, flags)) == NULL) { |
if ((cookie = method->wopen(ofd, name, bits, mtime)) == NULL) { |
if (verbose >= 0) |
if (verbose >= 0) |
warn("%s", out); |
warn("%s", out); |
if (oreg) |
if (oreg) |
|
|
} |
} |
|
|
int |
int |
dodecompress(const char *in, char *out, const struct compressor *method, |
dodecompress(const char *in, char *out, struct stat *sb) |
int bits, struct stat *sb) |
|
{ |
{ |
|
const struct compressor *method; |
u_char buf[Z_BUFSIZE]; |
u_char buf[Z_BUFSIZE]; |
char oldname[PATH_MAX]; |
char oldname[PATH_MAX]; |
int error, oreg, ifd, ofd; |
int error, oreg, ifd, ofd; |
|
|
|
|
/* XXX - open constrains outfile to MAXPATHLEN so this is safe */ |
/* XXX - open constrains outfile to MAXPATHLEN so this is safe */ |
oldname[0] = '\0'; |
oldname[0] = '\0'; |
if ((cookie = (*method->open)(ifd, "r", oldname, bits, 0, 1)) == NULL) { |
if ((cookie = method->ropen(ifd, oldname, 1)) == NULL) { |
if (verbose >= 0) |
if (verbose >= 0) |
warn("%s", in); |
warn("%s", in); |
close (ifd); |
close (ifd); |