Calling lrzip via lrzcat would fail as the proper parameters weren't being passed to the control structure. Fix.

This commit is contained in:
Con Kolivas 2012-03-10 20:47:57 +11:00
parent c286cccfa6
commit 14c3ce2ab4

19
main.c
View file

@ -189,6 +189,7 @@ int main(int argc, char *argv[])
struct timeval start_time, end_time; struct timeval start_time, end_time;
struct sigaction handler; struct sigaction handler;
double seconds,total_time; // for timers double seconds,total_time; // for timers
bool lrzcat = false;
int c, i; int c, i;
int hours,minutes; int hours,minutes;
extern int optind; extern int optind;
@ -200,8 +201,10 @@ int main(int argc, char *argv[])
if (strstr(argv[0], "lrunzip")) if (strstr(argv[0], "lrunzip"))
control->flags |= FLAG_DECOMPRESS; control->flags |= FLAG_DECOMPRESS;
else if (strstr(argv[0], "lrzcat")) else if (strstr(argv[0], "lrzcat")) {
control->flags |= FLAG_DECOMPRESS | FLAG_STDOUT; control->flags |= FLAG_DECOMPRESS | FLAG_STDOUT;
lrzcat = true;
}
/* generate crc table */ /* generate crc table */
CrcGenerateTable(); CrcGenerateTable();
@ -409,17 +412,17 @@ int main(int argc, char *argv[])
if (INFO && STDIN) if (INFO && STDIN)
failure("Will not get file info from STDIN\n"); failure("Will not get file info from STDIN\n");
if (control->outname && (strcmp(control->outname, "-") == 0)) { if ((control->outname && (strcmp(control->outname, "-") == 0)) ||
/* If no output filename is specified, and we're using
* stdin, use stdout */
(!control->outname && STDIN) || lrzcat ) {
control->flags |= FLAG_STDOUT; control->flags |= FLAG_STDOUT;
control->outFILE = stdout; control->outFILE = stdout;
control->msgout = stderr; control->msgout = stderr;
register_outputfile(control, control->msgout); register_outputfile(control, control->msgout);
} }
/* If no output filename is specified, and we're using stdin, if (lrzcat) {
* use stdout */
if (!control->outname && STDIN) {
control->flags |= FLAG_STDOUT;
control->msgout = stderr; control->msgout = stderr;
control->outFILE = stdout; control->outFILE = stdout;
register_outputfile(control, control->msgout); register_outputfile(control, control->msgout);
@ -429,7 +432,9 @@ int main(int argc, char *argv[])
control->msgout = stdout; control->msgout = stdout;
register_outputfile(control, control->msgout); register_outputfile(control, control->msgout);
} }
if (STDIN) control->inFILE = stdin;
if (STDIN)
control->inFILE = stdin;
/* Implement signal handler only once flags are set */ /* Implement signal handler only once flags are set */
handler.sa_handler = &sighandler; handler.sa_handler = &sighandler;
sigaction(SIGTERM, &handler, 0); sigaction(SIGTERM, &handler, 0);