From b203005b52d093a688a0961dbd706c3405557b4b Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 19 Mar 2015 15:55:51 +1000 Subject: [PATCH] * rename type: rec__t -> imdb_rec_t --- src/common.h | 2 +- src/database.c | 14 +++++++------- src/database.h | 10 +++++----- src/imdb_1to2.c | 10 +++++----- src/util.c | 16 ++++++++-------- tests/database.c | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/common.h b/src/common.h index 5f17e33..5c84253 100644 --- a/src/common.h +++ b/src/common.h @@ -27,5 +27,5 @@ extern int image_add(uint64_t, char *path); extern int image_del(uint64_t); extern int image_exists(uint64_t); -extern int image_search(uint64_t, rec_t **data, size_t limit); +extern int image_search(uint64_t, imdb_rec_t **data, size_t limit); */ diff --git a/src/database.c b/src/database.c index f817866..7c8322a 100644 --- a/src/database.c +++ b/src/database.c @@ -96,7 +96,7 @@ int db_close(imdb_t *db) return 0; } -int db_rd_rec(imdb_t *db, rec_t *rec) +int db_rd_rec(imdb_t *db, imdb_rec_t *rec) { ssize_t bytes = 0; @@ -110,7 +110,7 @@ int db_rd_rec(imdb_t *db, rec_t *rec) return bytes / IMDB_REC_LEN; } -int db_wr_rec(imdb_t *db, rec_t *rec) +int db_wr_rec(imdb_t *db, imdb_rec_t *rec) { ssize_t bytes = 0; @@ -142,9 +142,9 @@ int db_rd_blk(imdb_t *db, block_t *blk) return blk->records; } -int db_rd_list(imdb_t *db, rec_t *list, size_t list_len) +int db_rd_list(imdb_t *db, imdb_rec_t *list, size_t list_len) { - rec_t *r = NULL; + imdb_rec_t *r = NULL; ssize_t bytes; unsigned int i = 0; unsigned int processed = 0; @@ -163,9 +163,9 @@ int db_rd_list(imdb_t *db, rec_t *list, size_t list_len) return processed; } -int db_wr_list(imdb_t *db, rec_t *list, size_t list_len) +int db_wr_list(imdb_t *db, imdb_rec_t *list, size_t list_len) { - rec_t *r = NULL; + imdb_rec_t *r = NULL; ssize_t bytes; unsigned int i = 0; unsigned int processed = 0; @@ -184,7 +184,7 @@ int db_wr_list(imdb_t *db, rec_t *list, size_t list_len) return processed; } -int db_search(imdb_t *db, rec_t *sample, float tresh, match_t **matches) +int db_search(imdb_t *db, imdb_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 cbaf4f7..2c5da95 100644 --- a/src/database.h +++ b/src/database.h @@ -60,7 +60,7 @@ sect | [ 0-15 ][ 16-31 ][ 32-48 ] typedef struct { uint64_t num; unsigned char data[IMDB_REC_LEN]; -} rec_t; +} imdb_rec_t; typedef struct { uint64_t num; @@ -70,14 +70,14 @@ typedef struct { extern int db_open(imdb_t *db, const char *path); extern int db_close(imdb_t *db); -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_rec(imdb_t *db, imdb_rec_t *rec); +extern int db_wr_rec(imdb_t *db, imdb_rec_t *rec); 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(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); +extern int db_rd_list(imdb_t *db, imdb_rec_t *list, size_t list_len); +extern int db_wr_list(imdb_t *db, imdb_rec_t *list, size_t list_len); /** @returns: diff --git a/src/imdb_1to2.c b/src/imdb_1to2.c index 1d59b03..1fc6b6e 100644 --- a/src/imdb_1to2.c +++ b/src/imdb_1to2.c @@ -19,7 +19,7 @@ void usage(const char *message) { int main(int argc, char **argv) { int in, out; - long unsigned int rec_total, rec_first, rec_last, records; + long unsigned int imdb_rec_total, rec_first, rec_last, records; unsigned char in_buf[IMDB_REC_LEN * BLK_SIZE]; unsigned char out_buf[IMDB_REC_LEN * BLK_SIZE]; unsigned char header[IMDB_REC_LEN]; @@ -46,8 +46,8 @@ int main(int argc, char **argv) { if ((st.st_size % IMDB_REC_LEN) != 0) usage("database size expected to be multiples to 48"); - rec_total = (st.st_size / IMDB_REC_LEN); - printf("Processing %lu records\n", rec_total - 1); + imdb_rec_total = (st.st_size / IMDB_REC_LEN); + printf("Processing %lu records\n", imdb_rec_total - 1); if (lseek(in, IMDB_REC_LEN, SEEK_SET) < 0) usage(strerror(errno)); @@ -57,9 +57,9 @@ int main(int argc, char **argv) { if (write(out, header, IMDB_REC_LEN) != IMDB_REC_LEN) usage(strerror(errno)); - for (unsigned int block = 0; block <= (rec_total / BLK_SIZE); block++) { + for (unsigned int block = 0; block <= (imdb_rec_total / BLK_SIZE); block++) { rec_first = rec_last = (block * BLK_SIZE) + 1; - records = ((rec_first + BLK_SIZE) > rec_total) ? rec_total - rec_first : BLK_SIZE; + records = ((rec_first + BLK_SIZE) > imdb_rec_total) ? imdb_rec_total - rec_first : BLK_SIZE; rec_last = rec_first + records; printf("* block %u, %4lu records [%lu, %lu]\n", block + 1, records, rec_first, rec_last - 1); diff --git a/src/util.c b/src/util.c index 2c7d643..2cfb56a 100644 --- a/src/util.c +++ b/src/util.c @@ -37,7 +37,7 @@ void usage(int exitcode) { exit(exitcode); } -int search_similar(imdb_t *db, rec_t *sample, float tresh) +int search_similar(imdb_t *db, imdb_rec_t *sample, float tresh) { int ret = 0, i = 0; match_t *matches = NULL; @@ -95,7 +95,7 @@ int db_usage_map(imdb_t *db, unsigned short int cols) return 0; } -int rec_bitmap(imdb_t *db, rec_t *sample) +int rec_bitmap(imdb_t *db, imdb_rec_t *sample) { uint16_t row; uint8_t i, j; @@ -124,8 +124,8 @@ int rec_bitmap(imdb_t *db, rec_t *sample) int rec_diff(imdb_t *db, unsigned long a, unsigned long b, unsigned short int showmap) { - rec_t src; - rec_t dst; + imdb_rec_t src; + imdb_rec_t dst; float diff = 0.0; unsigned char map[BITMAP_SIZE]; uint16_t row; @@ -133,8 +133,8 @@ int rec_diff(imdb_t *db, unsigned long a, unsigned long b, unsigned short int sh assert(db != NULL); - memset(&src, 1, sizeof(rec_t)); - memset(&dst, 2, sizeof(rec_t)); + memset(&src, 1, sizeof(imdb_rec_t)); + memset(&dst, 2, sizeof(imdb_rec_t)); src.num = a; dst.num = b; @@ -183,13 +183,13 @@ int main(int argc, char **argv) float tresh = 0.10; unsigned short int cols = 64, map = 0; imdb_t db; - rec_t sample; + imdb_rec_t sample; unsigned long a = 0, b = 0; char *c = NULL; char opt = '\0'; memset(&db, 0x0, sizeof(imdb_t)); - memset(&sample, 0x0, sizeof(rec_t)); + memset(&sample, 0x0, sizeof(imdb_rec_t)); if (argc < 3) usage(EXIT_FAILURE); diff --git a/tests/database.c b/tests/database.c index cdb0072..02c2561 100644 --- a/tests/database.c +++ b/tests/database.c @@ -4,7 +4,7 @@ int main(int argc, char **argv) { imdb_t db; - rec_t rec[2]; + imdb_rec_t rec[2]; block_t blk; char *path = "test.db";