Browse Source

* rename functions

master
Alex 'AdUser' Z 10 years ago
parent
commit
7ba2885ff2
  1. 16
      src/database.c
  2. 14
      src/database.h
  3. 10
      src/util.c

16
src/database.c

@ -96,7 +96,7 @@ int imdb_close(imdb_t *db)
return 0; return 0;
} }
int db_rd_rec(imdb_t *db, imdb_rec_t *rec) int imdb_read_rec(imdb_t *db, imdb_rec_t *rec)
{ {
ssize_t bytes = 0; ssize_t bytes = 0;
@ -110,7 +110,7 @@ int db_rd_rec(imdb_t *db, imdb_rec_t *rec)
return bytes / IMDB_REC_LEN; return bytes / IMDB_REC_LEN;
} }
int db_wr_rec(imdb_t *db, imdb_rec_t *rec) int imdb_write_rec(imdb_t *db, imdb_rec_t *rec)
{ {
ssize_t bytes = 0; ssize_t bytes = 0;
@ -124,7 +124,7 @@ int db_wr_rec(imdb_t *db, imdb_rec_t *rec)
return bytes / IMDB_REC_LEN; return bytes / IMDB_REC_LEN;
} }
int db_rd_blk(imdb_t *db, block_t *blk) int imdb_read_blk(imdb_t *db, block_t *blk)
{ {
ssize_t bytes = 0; ssize_t bytes = 0;
@ -142,7 +142,7 @@ int db_rd_blk(imdb_t *db, block_t *blk)
return blk->records; return blk->records;
} }
int db_rd_list(imdb_t *db, imdb_rec_t *list, size_t list_len) int imdb_read_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
{ {
imdb_rec_t *r = NULL; imdb_rec_t *r = NULL;
ssize_t bytes; ssize_t bytes;
@ -163,7 +163,7 @@ int db_rd_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
return processed; return processed;
} }
int db_wr_list(imdb_t *db, imdb_rec_t *list, size_t list_len) int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
{ {
imdb_rec_t *r = NULL; imdb_rec_t *r = NULL;
ssize_t bytes; ssize_t bytes;
@ -184,7 +184,7 @@ int db_wr_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
return processed; return processed;
} }
int db_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches) int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches)
{ {
const int blk_size = 4096; const int blk_size = 4096;
uint64_t found = 0; uint64_t found = 0;
@ -201,7 +201,7 @@ int db_search(imdb_t *db, imdb_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 (imdb_read_rec(db, sample) < 1) {
db->errstr = "Can't read source sample"; db->errstr = "Can't read source sample";
return -1; return -1;
} }
@ -212,7 +212,7 @@ int db_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches)
} }
*matches = NULL; *matches = NULL;
while (db_rd_blk(db, &blk) > 0) { while (imdb_read_blk(db, &blk) > 0) {
p = blk.data; p = blk.data;
for (i = 0; i < blk.records; i++, p += IMDB_REC_LEN) { for (i = 0; i < blk.records; i++, p += IMDB_REC_LEN) {
t = p + REC_OFF_RU; t = p + REC_OFF_RU;

14
src/database.h

@ -70,14 +70,14 @@ typedef struct {
extern int imdb_open (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_close(imdb_t *db);
extern int db_rd_rec(imdb_t *db, imdb_rec_t *rec); extern int imdb_read_rec (imdb_t *db, imdb_rec_t *rec);
extern int db_wr_rec(imdb_t *db, imdb_rec_t *rec); extern int imdb_write_rec(imdb_t *db, imdb_rec_t *rec);
extern int db_rd_blk(imdb_t *db, block_t *blk); extern int imdb_read_blk (imdb_t *db, block_t *blk);
extern int db_wr_blk(imdb_t *db, block_t *blk); extern int imdb_write_blk(imdb_t *db, block_t *blk);
extern int db_rd_list(imdb_t *db, imdb_rec_t *list, size_t list_len); extern int imdb_read_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); extern int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len);
/** /**
@returns: @returns:
@ -85,6 +85,6 @@ extern int db_wr_list(imdb_t *db, imdb_rec_t *list, size_t list_len);
0 if nothing found 0 if nothing found
>0 if found some matches >0 if found some matches
*/ */
extern int db_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches); extern int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches);
#endif #endif

10
src/util.c

@ -42,7 +42,7 @@ int search_similar(imdb_t *db, imdb_rec_t *sample, float tresh)
int ret = 0, i = 0; int ret = 0, i = 0;
match_t *matches = NULL; match_t *matches = NULL;
ret = db_search(db, sample, tresh, &matches); ret = imdb_search(db, sample, tresh, &matches);
if (ret == -1) { if (ret == -1) {
printf("%s\n", db->errstr); printf("%s\n", db->errstr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -75,7 +75,7 @@ int db_usage_map(imdb_t *db, unsigned short int cols)
blk.start = 1; blk.start = 1;
blk.records = blk_size; blk.records = blk_size;
while (db_rd_blk(db, &blk) > 0) { while (imdb_read_blk(db, &blk) > 0) {
p = blk.data; p = blk.data;
for (i = 0; i < blk.records; i++, p += IMDB_REC_LEN) { for (i = 0; i < blk.records; i++, p += IMDB_REC_LEN) {
t = p + REC_OFF_RU; t = p + REC_OFF_RU;
@ -102,7 +102,7 @@ int rec_bitmap(imdb_t *db, imdb_rec_t *sample)
assert(db != NULL); assert(db != NULL);
assert(sample != NULL); assert(sample != NULL);
if (db_rd_rec(db, sample) < 1) if (imdb_read_rec(db, sample) < 1)
return -1; return -1;
if (!sample->data[0]) { if (!sample->data[0]) {
@ -139,7 +139,7 @@ int rec_diff(imdb_t *db, unsigned long a, unsigned long b, unsigned short int sh
src.num = a; src.num = a;
dst.num = b; dst.num = b;
if (db_rd_rec(db, &src) < 1) if (imdb_read_rec(db, &src) < 1)
return -1; return -1;
if (!src.data[0]) { if (!src.data[0]) {
@ -147,7 +147,7 @@ int rec_diff(imdb_t *db, unsigned long a, unsigned long b, unsigned short int sh
return 0; return 0;
} }
if (db_rd_rec(db, &dst) < 1) if (imdb_read_rec(db, &dst) < 1)
return -1; return -1;
if (!src.data[0]) { if (!src.data[0]) {

Loading…
Cancel
Save