|
|
|
@ -3,22 +3,44 @@
|
|
|
|
|
#include "bitmap.h" |
|
|
|
|
#include "sample.h" |
|
|
|
|
|
|
|
|
|
void usage() { |
|
|
|
|
puts("Usage: imdb-sample <db path> <id> <sample path>"); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
imdb_t db; |
|
|
|
|
imdb_rec_t rec; |
|
|
|
|
|
|
|
|
|
if (argc < 2) { |
|
|
|
|
puts("Usage: sampler-test <file>"); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
memset(&db, 0x0, sizeof(imdb_t)); |
|
|
|
|
memset(&rec, 0x0, sizeof(imdb_rec_t)); |
|
|
|
|
|
|
|
|
|
if (argc < 4) |
|
|
|
|
usage(); |
|
|
|
|
|
|
|
|
|
rec.num = strtoll(argv[2], NULL, 10); |
|
|
|
|
if (errno != 0) { |
|
|
|
|
puts("arg 1 not a number"); |
|
|
|
|
usage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memset(&rec, 0x0, sizeof(imdb_rec_t)); |
|
|
|
|
if (imdb_open(&db, argv[1]) != 0) { |
|
|
|
|
puts(db.errstr); |
|
|
|
|
usage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (imdb_sample(&rec, argv[1]) != 0) { |
|
|
|
|
if (imdb_sample(&rec, argv[3]) != 0) { |
|
|
|
|
puts("sampler failure"); |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
usage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(imdb_write_rec(&db, &rec) < 1) { |
|
|
|
|
puts(db.errstr); |
|
|
|
|
usage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
imdb_close(&db); |
|
|
|
|
bitmap_print(&rec.data[REC_OFF_BM]); |
|
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|