|
|
@ -35,8 +35,13 @@ int db_search(db_t *db, rec_t *sample, float tresh, match_t **matches) |
|
|
|
blk.start = 1; |
|
|
|
blk.start = 1; |
|
|
|
blk.records = blk_size; |
|
|
|
blk.records = blk_size; |
|
|
|
|
|
|
|
|
|
|
|
if (db_rd_rec(db, sample) != 1) |
|
|
|
if (db_rd_rec(db, sample) < 1) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sample->data[0]) { |
|
|
|
|
|
|
|
puts("Sample not exists"); |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
/* TODO: expand matches */ |
|
|
|
/* TODO: expand matches */ |
|
|
|
|
|
|
|
|
|
|
|
while (db_rd_blk(db, &blk) > 0) { |
|
|
|
while (db_rd_blk(db, &blk) > 0) { |
|
|
@ -65,9 +70,14 @@ int rec_bitmap(db_t *db, rec_t *sample) |
|
|
|
assert(db != NULL); |
|
|
|
assert(db != NULL); |
|
|
|
assert(sample != NULL); |
|
|
|
assert(sample != NULL); |
|
|
|
|
|
|
|
|
|
|
|
if (db_rd_rec(db, sample) != 1) |
|
|
|
if (db_rd_rec(db, sample) < 1) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sample->data[0]) { |
|
|
|
|
|
|
|
puts("Sample not exists"); |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) { |
|
|
|
for (i = 0; i < 16; i++) { |
|
|
|
row = *(((uint16_t *) sample->data) + i); |
|
|
|
row = *(((uint16_t *) sample->data) + i); |
|
|
|
for (j = 0; j < 16; j++) { |
|
|
|
for (j = 0; j < 16; j++) { |
|
|
@ -84,6 +94,7 @@ int main(int argc, char **argv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
db_t db; |
|
|
|
db_t db; |
|
|
|
rec_t sample; |
|
|
|
rec_t sample; |
|
|
|
|
|
|
|
float tresh; |
|
|
|
|
|
|
|
|
|
|
|
if (argc < 3) { |
|
|
|
if (argc < 3) { |
|
|
|
printf( |
|
|
|
printf( |
|
|
@ -96,8 +107,8 @@ int main(int argc, char **argv) |
|
|
|
|
|
|
|
|
|
|
|
memset(&db, 0x0, sizeof(db_t)); |
|
|
|
memset(&db, 0x0, sizeof(db_t)); |
|
|
|
memset(&sample, 0x0, sizeof(rec_t)); |
|
|
|
memset(&sample, 0x0, sizeof(rec_t)); |
|
|
|
sample.num = atoll(argv[2]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sample.num = atoll(argv[2]); |
|
|
|
assert(sample.num > 0); |
|
|
|
assert(sample.num > 0); |
|
|
|
|
|
|
|
|
|
|
|
if (db_open(&db, "test.db") == -1) { |
|
|
|
if (db_open(&db, "test.db") == -1) { |
|
|
@ -105,11 +116,14 @@ int main(int argc, char **argv) |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "search") == 0) |
|
|
|
if (strcmp(argv[1], "search") == 0) { |
|
|
|
db_search(&db, &sample, 0.15, NULL); |
|
|
|
tresh = (argc > 3) ? atof(argv[3]) : 0.15; |
|
|
|
|
|
|
|
db_search(&db, &sample, tresh, NULL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "bitmap") == 0) |
|
|
|
if (strcmp(argv[1], "bitmap") == 0) { |
|
|
|
rec_bitmap(&db, &sample); |
|
|
|
rec_bitmap(&db, &sample); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
db_close(&db); |
|
|
|
db_close(&db); |
|
|
|
|
|
|
|
|
|
|
|