From 7690b3e24f17d0976af33d4c80fdb8b32d5888b4 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 2 Dec 2009 23:48:06 +0000 Subject: add dieflag and variable threshold --- weasel.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/weasel.c b/weasel.c index a28b0e8..f85abf9 100644 --- a/weasel.c +++ b/weasel.c @@ -268,11 +268,13 @@ main(int argc, char **argv) int display = 1; int dontstop = 0; int uflag = 1; + float threshold = 0.90; + int dieflag = 0; alphabet = defalpha; nthreads = ncpu(); - while ((c = getopt(argc, argv, "a:m:np:st:")) != -1) + while ((c = getopt(argc, argv, "a:m:np:sS:t:")) != -1) switch (c) { case 'a': alphabet = strdup(optarg); @@ -295,6 +297,10 @@ main(int argc, char **argv) case 's': dontstop = 1; break; + case 'S': + dontstop = 1; + threshold = atof(optarg); + break; case 't': i = atoi(optarg); if (i <= 0) @@ -322,8 +328,9 @@ main(int argc, char **argv) pthread_attr_init(&attr); // pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - for (i = 0; !success(&best) || dontstop; i++) { - if (dontstop && average > 0.99) + for (i = 0; !dieflag || dontstop; i++) { + dieflag = success(&best); + if (dontstop && average > threshold) switchcase(aim, &uflag); for (n = 0; n < nthreads; n++) pthread_create(&threads[n], &attr, intercourse, NULL); -- cgit v1.2.3