version 1.62, 2005/04/17 16:17:39 |
version 1.63, 2005/06/26 18:20:26 |
|
|
void *(*open)(int, const char *, char *, int, u_int32_t, int); |
void *(*open)(int, const char *, char *, int, u_int32_t, int); |
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 *); |
int (*close)(void *, struct z_info *, const char *, struct stat *); |
} c_table[] = { |
} c_table[] = { |
#define M_DEFLATE (&c_table[0]) |
#define M_DEFLATE (&c_table[0]) |
{ "deflate", ".gz", "\037\213", gz_open, gz_read, gz_write, gz_close }, |
{ "deflate", ".gz", "\037\213", gz_open, gz_read, gz_write, gz_close }, |
|
|
#endif /* SMALL */ |
#endif /* SMALL */ |
|
|
int permission(const char *); |
int permission(const char *); |
void setfile(const char *, int, struct stat *); |
|
__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 *); |
|
|
error = FAILURE; |
error = FAILURE; |
} |
} |
|
|
if (error == SUCCESS) |
if ((method->close)(cookie, &info, out, sb)) { |
setfile(out, ofd, sb); |
|
|
|
if ((method->close)(cookie, &info)) { |
|
if (!error && verbose >= 0) |
if (!error && verbose >= 0) |
warn("%s", out); |
warn("%s", out); |
error = FAILURE; |
error = FAILURE; |
|
|
else if ((ofd = open(out, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR)) < 0) { |
else if ((ofd = open(out, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR)) < 0) { |
if (verbose >= 0) |
if (verbose >= 0) |
warn("%s", in); |
warn("%s", in); |
(method->close)(cookie, NULL); |
(method->close)(cookie, NULL, NULL, NULL); |
return (FAILURE); |
return (FAILURE); |
} |
} |
|
|
|
|
error = errno == EINVAL ? WARNING : FAILURE; |
error = errno == EINVAL ? WARNING : FAILURE; |
} |
} |
|
|
if (error == SUCCESS) |
if ((method->close)(cookie, &info, NULL, NULL)) { |
setfile(out, ofd, sb); |
|
|
|
if ((method->close)(cookie, &info)) { |
|
if (!error && verbose >= 0) |
if (!error && verbose >= 0) |
warnx("%s", in); |
warnx("%s", in); |
error = FAILURE; |
error = FAILURE; |
} |
} |
|
|
if (!nosave) { |
if (!nosave) { |
if (info.mtime != 0) { |
if (info.mtime != 0) { |
sb->st_mtimespec.tv_sec = |
sb->st_mtimespec.tv_sec = |
|
|
if (cat && strcmp(out, "/dev/stdout") != 0) |
if (cat && strcmp(out, "/dev/stdout") != 0) |
cat = 0; /* have a real output name */ |
cat = 0; /* have a real output name */ |
} |
} |
|
if (error == SUCCESS) |
|
setfile(out, ofd, sb); |
|
|
if (ofd != -1 && close(ofd)) { |
if (ofd != -1 && close(ofd)) { |
if (!error && verbose >= 0) |
if (!error && verbose >= 0) |
|
|
{ |
{ |
struct timeval tv[2]; |
struct timeval tv[2]; |
|
|
if (cat || testmode) |
if (name == NULL || cat || testmode) |
return; |
return; |
|
|
if (!pipin || !nosave) { |
if (!pipin || !nosave) { |