|
|
@ -179,13 +179,12 @@ int main(int argc, char **argv) |
|
|
|
const char *db_path = NULL; |
|
|
|
const char *db_path = NULL; |
|
|
|
float maxdiff = 0.10; |
|
|
|
float maxdiff = 0.10; |
|
|
|
unsigned short int cols = 64, map = 0, ret = 0; |
|
|
|
unsigned short int cols = 64, map = 0, ret = 0; |
|
|
|
imdb_db_t db; |
|
|
|
imdb_db_t *db = NULL; |
|
|
|
uint64_t a = 0, b = 0; |
|
|
|
uint64_t a = 0, b = 0; |
|
|
|
char *c = NULL; |
|
|
|
char *c = NULL; |
|
|
|
|
|
|
|
int err; |
|
|
|
char opt = '\0'; |
|
|
|
char opt = '\0'; |
|
|
|
|
|
|
|
|
|
|
|
memset(&db, 0x0, sizeof(imdb_db_t)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (argc < 3) |
|
|
|
if (argc < 3) |
|
|
|
usage(EXIT_FAILURE); |
|
|
|
usage(EXIT_FAILURE); |
|
|
|
|
|
|
|
|
|
|
@ -243,8 +242,8 @@ int main(int argc, char **argv) |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (imdb_open(&db, db_path, 0) == -1) { |
|
|
|
if ((db = imdb_open(db_path, 0, &err)) == NULL) { |
|
|
|
fprintf(stderr, "database open: %s\n", db.error); |
|
|
|
fprintf(stderr, "database open: %d\n", err); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -254,34 +253,34 @@ int main(int argc, char **argv) |
|
|
|
fprintf(stderr, "can't parse number\n"); |
|
|
|
fprintf(stderr, "can't parse number\n"); |
|
|
|
usage(EXIT_FAILURE); |
|
|
|
usage(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
ret = search_similar(&db, a, maxdiff); |
|
|
|
ret = search_similar(db, a, maxdiff); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case bitmap : |
|
|
|
case bitmap : |
|
|
|
if (a <= 0) { |
|
|
|
if (a <= 0) { |
|
|
|
fprintf(stderr, "can't parse number\n"); |
|
|
|
fprintf(stderr, "can't parse number\n"); |
|
|
|
usage(EXIT_FAILURE); |
|
|
|
usage(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
ret = rec_bitmap(&db, a); |
|
|
|
ret = rec_bitmap(db, a); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case usage_map : |
|
|
|
case usage_map : |
|
|
|
ret = db_usage_map(&db, cols); |
|
|
|
ret = db_usage_map(db, cols); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case usage_slice : |
|
|
|
case usage_slice : |
|
|
|
ret = db_usage_slice(&db, a, b); |
|
|
|
ret = db_usage_slice(db, a, b); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case diff : |
|
|
|
case diff : |
|
|
|
if (a <= 0 || b <= 0) { |
|
|
|
if (a <= 0 || b <= 0) { |
|
|
|
fprintf(stderr, "both numbers must be set\n"); |
|
|
|
fprintf(stderr, "both numbers must be set\n"); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
ret = rec_diff(&db, a, b, map); |
|
|
|
ret = rec_diff(db, a, b, map); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default : |
|
|
|
default : |
|
|
|
usage(EXIT_SUCCESS); |
|
|
|
usage(EXIT_SUCCESS); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
imdb_close(&db); |
|
|
|
imdb_close(db); |
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|