]> thyrsus.com Git - comparator.git/commitdiff
More progress metering.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 3 Sep 2003 10:42:34 +0000 (10:42 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 3 Sep 2003 10:42:34 +0000 (10:42 +0000)
Makefile
main.c
report.c

index 58ed316a3197f5a88691ee93a5722df7d1867593..0dceeae15c87038035f157e047568d21e2506d57 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,8 @@ EXTRAS  = shredtree.py shredcompare.py
 TEST    = test1 test2 test3 test4
 ALL     = $(SOURCES) $(DOCS) $(EXTRAS) $(TEST)
 
+CFLAGS=-g
+
 all: comparator comparator.1
 
 main.o: main.c shred.h
diff --git a/main.c b/main.c
index 2f83611d2b49e906343cc2f29727287d1e3279d7..42757e68425ee096d4fb167f7d8e763f69c596f0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -191,6 +191,17 @@ void report_time(char *legend, ...)
     mark_time = endtime;
 }
 
+static void usage(void)
+{
+    fprintf(stderr,"usage: shredtree [-c] [-d dir ] [-s shredsize] [-w] [-x] path...\n");
+    fprintf(stderr,"  -c      = generate SCF files\n");
+    fprintf(stderr,"  -d dir  = change directory before digesting.\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");
+    exit(0);
+}
+
 main(int argc, char *argv[])
 {
     extern char        *optarg;        /* set by getopt */
@@ -226,17 +237,8 @@ main(int argc, char *argv[])
            debug = 1;
            break;
 
-       case 'h':
        default:
-           fprintf(stderr,"usage: shredtree [-c] [-d dir ] [-h] [-s shredsize] [-w] [-x] path\n");
-           fprintf(stderr,"  -c      = generate SCF files\n");
-           fprintf(stderr,"  -d dir  = change directory before digesting.\n");
-           fprintf(stderr,"  -h      = help (display this message).\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");
-           exit(0);
+           usage();
        }
     }
 
@@ -246,10 +248,13 @@ main(int argc, char *argv[])
        sort_count = 0;
     }
 
+    if ((argc - optind) == 0)
+       usage();
+
     report_time(NULL);
 
     /* special case if user gave exactly one tree */
-    if (optind == argc - 1)
+    if (!compile_only && optind == argc - 1)
     {
        generate_shredfile(argv[optind], stdout);
        exit(0);
index 53b0ed400ef8ced26986a7ddf6df863fe5c0bcbb..d86476cd90f25c304429e488f92d27acafaf5016 100644 (file)
--- a/report.c
+++ b/report.c
@@ -44,7 +44,9 @@ void merge_scf(const char *name, FILE *fp)
 {
     u_int32_t  sectcount;
     int hashcount = 0;
+    struct stat sb;
 
+    stat(name, &sb);
     fprintf(stderr, "%% Reading hash list %s...   ", name);
     fread(&sectcount, sizeof(u_int32_t), 1, fp);
     sectcount = ntohl(sectcount);
@@ -72,10 +74,8 @@ void merge_scf(const char *name, FILE *fp)
            this.end = FROMNET(this.end);
            corehook(this, head->file);
            hashcount++;
-#ifdef FIXME
            if (hashcount % 10000 == 0)
-               fprintf(stderr,"\b\b\b%02.0f%%",(ftell(fp) / (total * 0.01)));
-#endif
+               fprintf(stderr,"\b\b\b%02.0f%%",(ftell(fp) / (sb.st_size * 0.01)));
        }
     }
     fprintf(stderr, "\b\b\b100%%...done, %d entries\n", hashcount);