From cf9e738dacce419f7b0d6112e00493d7865529b7 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 19 Mar 2015 15:53:21 +1000 Subject: [PATCH] * rename type: db_t -> imdb_t --- src/database.c | 18 +++++++++--------- src/database.h | 20 ++++++++++---------- src/util.c | 12 ++++++------ tests/database.c | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/database.c b/src/database.c index c8720f9..f817866 100644 --- a/src/database.c +++ b/src/database.c @@ -44,7 +44,7 @@ const char *imdb_hdr_fmt = "IMDB v%02u, CAPS: %s;"; -int db_open(db_t *db, const char *path) +int db_open(imdb_t *db, const char *path) { int init = 0; ssize_t bytes = 0; @@ -54,7 +54,7 @@ int db_open(db_t *db, const char *path) assert(db != NULL); assert(path != NULL); - memset(db, 0x0, sizeof(db_t)); + memset(db, 0x0, sizeof(imdb_t)); db->fd = -1; errno = 0; @@ -82,7 +82,7 @@ int db_open(db_t *db, const char *path) return 0; } -int db_close(db_t *db) +int db_close(imdb_t *db) { assert(db != NULL); @@ -96,7 +96,7 @@ int db_close(db_t *db) return 0; } -int db_rd_rec(db_t *db, rec_t *rec) +int db_rd_rec(imdb_t *db, rec_t *rec) { ssize_t bytes = 0; @@ -110,7 +110,7 @@ int db_rd_rec(db_t *db, rec_t *rec) return bytes / IMDB_REC_LEN; } -int db_wr_rec(db_t *db, rec_t *rec) +int db_wr_rec(imdb_t *db, rec_t *rec) { ssize_t bytes = 0; @@ -124,7 +124,7 @@ int db_wr_rec(db_t *db, rec_t *rec) return bytes / IMDB_REC_LEN; } -int db_rd_blk(db_t *db, block_t *blk) +int db_rd_blk(imdb_t *db, block_t *blk) { ssize_t bytes = 0; @@ -142,7 +142,7 @@ int db_rd_blk(db_t *db, block_t *blk) return blk->records; } -int db_rd_list(db_t *db, rec_t *list, size_t list_len) +int db_rd_list(imdb_t *db, rec_t *list, size_t list_len) { rec_t *r = NULL; ssize_t bytes; @@ -163,7 +163,7 @@ int db_rd_list(db_t *db, rec_t *list, size_t list_len) return processed; } -int db_wr_list(db_t *db, rec_t *list, size_t list_len) +int db_wr_list(imdb_t *db, rec_t *list, size_t list_len) { rec_t *r = NULL; ssize_t bytes; @@ -184,7 +184,7 @@ int db_wr_list(db_t *db, rec_t *list, size_t list_len) return processed; } -int db_search(db_t *db, rec_t *sample, float tresh, match_t **matches) +int db_search(imdb_t *db, rec_t *sample, float tresh, match_t **matches) { const int blk_size = 4096; uint64_t found = 0; diff --git a/src/database.h b/src/database.h index 4bc2f91..cbaf4f7 100644 --- a/src/database.h +++ b/src/database.h @@ -9,7 +9,7 @@ typedef struct { int fd; const char *path; const char *errstr; -} db_t; +} imdb_t; typedef struct { uint64_t start; @@ -67,17 +67,17 @@ typedef struct { float diff; } match_t; -extern int db_open(db_t *db, const char *path); -extern int db_close(db_t *db); +extern int db_open(imdb_t *db, const char *path); +extern int db_close(imdb_t *db); -extern int db_rd_rec(db_t *db, rec_t *rec); -extern int db_wr_rec(db_t *db, rec_t *rec); +extern int db_rd_rec(imdb_t *db, rec_t *rec); +extern int db_wr_rec(imdb_t *db, rec_t *rec); -extern int db_rd_blk(db_t *db, block_t *blk); -extern int db_wr_blk(db_t *db, block_t *blk); +extern int db_rd_blk(imdb_t *db, block_t *blk); +extern int db_wr_blk(imdb_t *db, block_t *blk); -extern int db_rd_list(db_t *db, rec_t *list, size_t list_len); -extern int db_wr_list(db_t *db, rec_t *list, size_t list_len); +extern int db_rd_list(imdb_t *db, rec_t *list, size_t list_len); +extern int db_wr_list(imdb_t *db, rec_t *list, size_t list_len); /** @returns: @@ -85,6 +85,6 @@ extern int db_wr_list(db_t *db, rec_t *list, size_t list_len); 0 if nothing found >0 if found some matches */ -extern int db_search(db_t *db, rec_t *sample, float tresh, match_t **matches); +extern int db_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches); #endif diff --git a/src/util.c b/src/util.c index 2924e4c..2c7d643 100644 --- a/src/util.c +++ b/src/util.c @@ -37,7 +37,7 @@ void usage(int exitcode) { exit(exitcode); } -int search_similar(db_t *db, rec_t *sample, float tresh) +int search_similar(imdb_t *db, rec_t *sample, float tresh) { int ret = 0, i = 0; match_t *matches = NULL; @@ -58,7 +58,7 @@ int search_similar(db_t *db, rec_t *sample, float tresh) return 0; } -int db_usage_map(db_t *db, unsigned short int cols) +int db_usage_map(imdb_t *db, unsigned short int cols) { const int blk_size = 4096; unsigned int i, j = 0; @@ -95,7 +95,7 @@ int db_usage_map(db_t *db, unsigned short int cols) return 0; } -int rec_bitmap(db_t *db, rec_t *sample) +int rec_bitmap(imdb_t *db, rec_t *sample) { uint16_t row; uint8_t i, j; @@ -122,7 +122,7 @@ int rec_bitmap(db_t *db, rec_t *sample) return 0; } -int rec_diff(db_t *db, unsigned long a, unsigned long b, unsigned short int showmap) +int rec_diff(imdb_t *db, unsigned long a, unsigned long b, unsigned short int showmap) { rec_t src; rec_t dst; @@ -182,13 +182,13 @@ int main(int argc, char **argv) const char *db_path = NULL; float tresh = 0.10; unsigned short int cols = 64, map = 0; - db_t db; + imdb_t db; rec_t sample; unsigned long a = 0, b = 0; char *c = NULL; char opt = '\0'; - memset(&db, 0x0, sizeof(db_t)); + memset(&db, 0x0, sizeof(imdb_t)); memset(&sample, 0x0, sizeof(rec_t)); if (argc < 3) diff --git a/tests/database.c b/tests/database.c index 3f926d0..cdb0072 100644 --- a/tests/database.c +++ b/tests/database.c @@ -3,7 +3,7 @@ int main(int argc, char **argv) { - db_t db; + imdb_t db; rec_t rec[2]; block_t blk; char *path = "test.db";