diff --git a/src/database.c b/src/database.c index 54d4431..30cee2c 100644 --- a/src/database.c +++ b/src/database.c @@ -44,7 +44,7 @@ const char *imdb_hdr_fmt = "IMDB v%02u, CAPS: %s;"; -int imdb_init(imdb_t *db, const char *path) +int imdb_init(imdb_db_t *db, const char *path) { ssize_t bytes = 0; unsigned char buf[IMDB_REC_LEN]; @@ -68,7 +68,7 @@ int imdb_init(imdb_t *db, const char *path) return 0; } -int imdb_open(imdb_t *db, const char *path) +int imdb_open(imdb_db_t *db, const char *path) { ssize_t bytes = 0; struct stat st; @@ -77,7 +77,7 @@ int imdb_open(imdb_t *db, const char *path) assert(db != NULL); assert(path != NULL); - memset(db, 0x0, sizeof(imdb_t)); + memset(db, 0x0, sizeof(imdb_db_t)); db->fd = -1; errno = 0; @@ -117,7 +117,7 @@ int imdb_open(imdb_t *db, const char *path) return 0; } -int imdb_close(imdb_t *db) +int imdb_close(imdb_db_t *db) { assert(db != NULL); @@ -131,7 +131,7 @@ int imdb_close(imdb_t *db) return 0; } -int imdb_read_rec(imdb_t *db, imdb_rec_t *rec) +int imdb_read_rec(imdb_db_t *db, imdb_rec_t *rec) { ssize_t bytes = 0; @@ -151,7 +151,7 @@ int imdb_read_rec(imdb_t *db, imdb_rec_t *rec) return 1; } -int imdb_write_rec(imdb_t *db, imdb_rec_t *rec) +int imdb_write_rec(imdb_db_t *db, imdb_rec_t *rec) { ssize_t bytes = 0; @@ -168,7 +168,7 @@ int imdb_write_rec(imdb_t *db, imdb_rec_t *rec) return 1; } -int imdb_read_blk(imdb_t *db, imdb_block_t *blk) +int imdb_read_blk(imdb_db_t *db, imdb_block_t *blk) { ssize_t bytes = 0; @@ -187,7 +187,7 @@ int imdb_read_blk(imdb_t *db, imdb_block_t *blk) } uint64_t -imdb_records_count(imdb_t * const db) { +imdb_records_count(imdb_db_t * const db) { struct stat st; off_t size = 0; @@ -210,7 +210,7 @@ ratio_from_rec_data(unsigned char * const data) { } int -imdb_search(imdb_t * const db, +imdb_search(imdb_db_t * const db, imdb_rec_t * const sample, imdb_search_t * const search, imdb_match_t **matches) @@ -291,8 +291,8 @@ imdb_search(imdb_t * const db, } uint64_t -imdb_usage_map(imdb_t * const db, - char ** const map) { +imdb_usage_map(imdb_db_t * const db, + char ** const map) { const int blk_size = 4096; imdb_block_t blk; uint64_t records; diff --git a/src/database.h b/src/database.h index 8a63530..7f021db 100644 --- a/src/database.h +++ b/src/database.h @@ -10,7 +10,7 @@ typedef struct { const char *path; const char *errstr; unsigned char caps[8]; -} imdb_t; +} imdb_db_t; /** Database header format - fixed length, 48 bytes @@ -92,15 +92,15 @@ typedef struct { * @return 1 on success, 0 if record not used * and -1 if record number not exists, */ -extern int imdb_read_rec (imdb_t *db, imdb_rec_t *rec); -extern int imdb_write_rec(imdb_t *db, imdb_rec_t *rec); +extern int imdb_read_rec (imdb_db_t *db, imdb_rec_t *rec); +extern int imdb_write_rec(imdb_db_t *db, imdb_rec_t *rec); -extern int imdb_read_blk (imdb_t *db, imdb_block_t *blk); -extern int imdb_write_blk(imdb_t *db, imdb_block_t *blk); +extern int imdb_read_blk (imdb_db_t *db, imdb_block_t *blk); +extern int imdb_write_blk(imdb_db_t *db, imdb_block_t *blk); -extern int imdb_init (imdb_t *db, const char *path); -extern int imdb_open (imdb_t *db, const char *path); -extern int imdb_close(imdb_t *db); +extern int imdb_init (imdb_db_t *db, const char *path); +extern int imdb_open (imdb_db_t *db, const char *path); +extern int imdb_close(imdb_db_t *db); float ratio_from_rec_data(unsigned char * const data); @@ -112,22 +112,22 @@ ratio_from_rec_data(unsigned char * const data); >0 if found some matches */ extern int -imdb_search(imdb_t * const db, +imdb_search(imdb_db_t * const db, imdb_rec_t * const sample, imdb_search_t * const search, - imdb_match_t **matches); + imdb_match_t ** matches); /** @returns: number of records in database */ uint64_t -imdb_records_count(imdb_t * const db); +imdb_records_count(imdb_db_t * const db); /** @brief fills buffer 'map' according to records existense in database @returns records processed (and also buffer size) */ uint64_t -imdb_usage_map(imdb_t * const db, - char ** const map); +imdb_usage_map(imdb_db_t * const db, + char ** const map); #endif diff --git a/src/query.c b/src/query.c index a63801e..b622eb0 100644 --- a/src/query.c +++ b/src/query.c @@ -38,7 +38,7 @@ void usage(int exitcode) { exit(exitcode); } -int search_similar(imdb_t *db, uint64_t number, float maxdiff) +int search_similar(imdb_db_t *db, uint64_t number, float maxdiff) { int ret = 0, i = 0; imdb_rec_t sample; @@ -68,7 +68,7 @@ int search_similar(imdb_t *db, uint64_t number, float maxdiff) return 0; } -int db_usage_map(imdb_t *db, unsigned short int cols) +int db_usage_map(imdb_db_t *db, unsigned short int cols) { char *map = NULL; char *m = NULL; @@ -97,7 +97,7 @@ int db_usage_map(imdb_t *db, unsigned short int cols) return 0; } -int rec_bitmap(imdb_t *db, uint64_t number) +int rec_bitmap(imdb_db_t *db, uint64_t number) { imdb_rec_t rec; @@ -115,7 +115,7 @@ int rec_bitmap(imdb_t *db, uint64_t number) return 0; } -int rec_diff(imdb_t *db, uint64_t a, uint64_t b, unsigned short int showmap) +int rec_diff(imdb_db_t *db, uint64_t a, uint64_t b, unsigned short int showmap) { imdb_rec_t rec; float diff = 0.0; @@ -158,12 +158,12 @@ int main(int argc, char **argv) const char *db_path = NULL; float maxdiff = 0.10; unsigned short int cols = 64, map = 0; - imdb_t db; + imdb_db_t db; uint64_t a = 0, b = 0; char *c = NULL; char opt = '\0'; - memset(&db, 0x0, sizeof(imdb_t)); + memset(&db, 0x0, sizeof(imdb_db_t)); if (argc < 3) usage(EXIT_FAILURE); diff --git a/src/sampler.c b/src/sampler.c index 328b836..9d18360 100644 --- a/src/sampler.c +++ b/src/sampler.c @@ -10,10 +10,10 @@ void usage() { int main(int argc, char **argv) { - imdb_t db; + imdb_db_t db; imdb_rec_t rec; - memset(&db, 0x0, sizeof(imdb_t)); + memset(&db, 0x0, sizeof(imdb_db_t)); memset(&rec, 0x0, sizeof(imdb_rec_t)); if (argc < 4)