From b374b7e3b110940faa9cd5aa305fea515fed3ed4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 5 Sep 2003 02:31:04 +0000 Subject: [PATCH] Added -o. --- main.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index e5e9898..c1d08d8 100644 --- a/main.c +++ b/main.c @@ -315,9 +315,10 @@ void report_time(char *legend, ...) static void usage(void) { - fprintf(stderr,"usage: shredtree [-c] [-d dir ] [-s shredsize] [-w] [-x] path...\n"); + fprintf(stderr,"usage: shredtree [-c] [-d dir ] [-o file] [-s shredsize] [-w] [-x] path...\n"); fprintf(stderr," -c = generate SCF files\n"); fprintf(stderr," -d dir = change directory before digesting.\n"); + fprintf(stderr," -o file = write to the specified file.\n"); fprintf(stderr," -s size = set shred size (default %d)\n", shredsize); fprintf(stderr," -w = remove whitespace.\n"); fprintf(stderr," -x = debug, display chunks in output.\n"); @@ -331,11 +332,11 @@ main(int argc, char *argv[]) int status, file_only, compile_only; struct scf_t *scf; - char *dir; + char *dir, *outfile; compile_only = file_only = 0; - dir = NULL; - while ((status = getopt(argc, argv, "cd:hs:wx")) != EOF) + dir = outfile = NULL; + while ((status = getopt(argc, argv, "cd:ho:s:wx")) != EOF) { switch (status) { @@ -347,6 +348,10 @@ main(int argc, char *argv[]) dir = optarg; break; + case 'o': + outfile = optarg; + break; + case 's': shredsize = atoi(optarg); break; @@ -375,6 +380,17 @@ main(int argc, char *argv[]) report_time(NULL); + if (outfile) + { + FILE *ofp; + + if (freopen(outfile, "w", stdout) == NULL) + { + perror("comparator"); + exit(1); + } + } + /* special case if user gave exactly one tree */ if (!compile_only && optind == argc - 1) { -- 2.43.0