Browse Source

* util.c : update

master
Alex 'AdUser' Z 10 years ago
parent
commit
f14fb207cc
  1. 18
      src/util.c

18
src/util.c

@ -22,12 +22,12 @@
#include <getopt.h> #include <getopt.h>
void usage(int exitcode) { void usage(int exitcode) {
printf( puts(
"Usage: imdb-util <opts>\n" "Usage: imdb-util <opts>\n"
" -b <path> Path to database\n" " -b <path> Path to database\n"
" -t <float> Maximum difference percent (0.0 - 1.0, default: 0.1)\n" " -t <int> Maximum difference pct (0 - 50, default: 10%)\n"
); );
printf("\n" puts(
" -I Create database (init)\n" " -I Create database (init)\n"
" -B <num> Show bitmap for this sample\n" " -B <num> Show bitmap for this sample\n"
" -C <a>,<b> Show difference percent for this samples\n" " -C <a>,<b> Show difference percent for this samples\n"
@ -161,7 +161,7 @@ int main(int argc, char **argv)
{ {
enum { undef, init, search, bitmap, usage_map, diff } mode = undef; enum { undef, init, search, bitmap, usage_map, diff } mode = undef;
const char *db_path = NULL; const char *db_path = NULL;
float tresh = 0.10; float maxdiff = 0.10;
unsigned short int cols = 64, map = 0; unsigned short int cols = 64, map = 0;
imdb_t db; imdb_t db;
uint64_t a = 0, b = 0; uint64_t a = 0, b = 0;
@ -179,8 +179,12 @@ int main(int argc, char **argv)
db_path = optarg; db_path = optarg;
break; break;
case 't' : case 't' :
tresh = atof(optarg); maxdiff = atoi(optarg);
tresh = (tresh > 0.0 && tresh < 1.0) ? tresh : 0.10; if (maxdiff > 50 || maxdiff < 0) {
puts("maxdiff out of bounds (0% - 50%), using default - 10%");
maxdiff = 10;
}
maxdiff /= 100;
break; break;
case 'I' : case 'I' :
mode = init; mode = init;
@ -234,7 +238,7 @@ int main(int argc, char **argv)
} }
if (mode == search) if (mode == search)
search_similar(&db, a, tresh); search_similar(&db, a, maxdiff);
if (mode == bitmap) if (mode == bitmap)
rec_bitmap(&db, a); rec_bitmap(&db, a);

Loading…
Cancel
Save