Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/newsyslog/newsyslog.c
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
#ifndef COMPRESS_SUFFIX_XZ | #ifndef COMPRESS_SUFFIX_XZ | ||||
#define COMPRESS_SUFFIX_XZ ".xz" | #define COMPRESS_SUFFIX_XZ ".xz" | ||||
#endif | #endif | ||||
#ifndef COMPRESS_SUFFIX_ZST | #ifndef COMPRESS_SUFFIX_ZST | ||||
#define COMPRESS_SUFFIX_ZST ".zst" | #define COMPRESS_SUFFIX_ZST ".zst" | ||||
#endif | #endif | ||||
#define COMPRESS_SUFFIX_MAXLEN MAX(MAX(sizeof(COMPRESS_SUFFIX_GZ),sizeof(COMPRESS_SUFFIX_BZ2)),sizeof(COMPRESS_SUFFIX_XZ)) | #define COMPRESS_SUFFIX_MAXLEN MAX(MAX(MAX(sizeof(COMPRESS_SUFFIX_GZ),sizeof(COMPRESS_SUFFIX_BZ2)),sizeof(COMPRESS_SUFFIX_XZ)),sizeof(COMPRESS_SUFFIX_ZST)) | ||||
/* | /* | ||||
* Compression types | * Compression types | ||||
*/ | */ | ||||
#define COMPRESS_TYPES 5 /* Number of supported compression types */ | #define COMPRESS_TYPES 5 /* Number of supported compression types */ | ||||
#define COMPRESS_NONE 0 | #define COMPRESS_NONE 0 | ||||
#define COMPRESS_GZIP 1 | #define COMPRESS_GZIP 1 | ||||
▲ Show 20 Lines • Show All 1,905 Lines • ▼ Show 20 Lines | |||||
do_zipwork(struct zipwork_entry *zwork) | do_zipwork(struct zipwork_entry *zwork) | ||||
{ | { | ||||
const char *pgm_name, *pgm_path; | const char *pgm_name, *pgm_path; | ||||
int errsav, fcount, zstatus; | int errsav, fcount, zstatus; | ||||
pid_t pidzip, wpid; | pid_t pidzip, wpid; | ||||
char zresult[MAXPATHLEN]; | char zresult[MAXPATHLEN]; | ||||
char command[BUFSIZ]; | char command[BUFSIZ]; | ||||
char **args; | char **args; | ||||
int c; | int c, i; | ||||
assert(zwork != NULL); | assert(zwork != NULL); | ||||
pgm_path = NULL; | pgm_path = NULL; | ||||
strlcpy(zresult, zwork->zw_fname, sizeof(zresult)); | strlcpy(zresult, zwork->zw_fname, sizeof(zresult)); | ||||
args = calloc(ARGS_NUM, sizeof(*args)); | args = calloc(ARGS_NUM, sizeof(*args)); | ||||
if (args == NULL) | if (args == NULL) | ||||
err(1, "calloc()"); | err(1, "calloc()"); | ||||
if (zwork->zw_conf != NULL && | if (zwork->zw_conf != NULL && | ||||
zwork->zw_conf->compress > COMPRESS_NONE) | zwork->zw_conf->compress > COMPRESS_NONE) | ||||
for (c = 1; c < COMPRESS_TYPES; c++) { | for (c = 1; c < COMPRESS_TYPES; c++) { | ||||
if (zwork->zw_conf->compress == c) { | if (zwork->zw_conf->compress == c) { | ||||
pgm_path = compress_type[c].path; | pgm_path = compress_type[c].path; | ||||
(void) strlcat(zresult, | (void) strlcat(zresult, | ||||
compress_type[c].suffix, sizeof(zresult)); | compress_type[c].suffix, sizeof(zresult)); | ||||
/* the first argument is always NULL, skip it */ | /* the first argument is always NULL, skip it */ | ||||
for (c = 1; c < ARGS_NUM; c++) { | for (i = 1; i < ARGS_NUM; i++) { | ||||
if (compress_type[c].args[c] == NULL) | if (compress_type[c].args[i] == NULL) | ||||
break; | break; | ||||
args[c] = compress_type[c].args[c]; | args[i] = compress_type[c].args[i]; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (pgm_path == NULL) { | if (pgm_path == NULL) { | ||||
warnx("invalid entry for %s in do_zipwork", zwork->zw_fname); | warnx("invalid entry for %s in do_zipwork", zwork->zw_fname); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 729 Lines • Show Last 20 Lines |