Browse Source

* rename type: db_t -> imdb_t

master
Alex 'AdUser' Z 10 years ago
parent
commit
cf9e738dac
  1. 18
      src/database.c
  2. 20
      src/database.h
  3. 12
      src/util.c
  4. 2
      tests/database.c

18
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;

20
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

12
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)

2
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";

Loading…
Cancel
Save