Browse Source

+ imdb_records_count()

master
Alex 'AdUser' Z 10 years ago
parent
commit
8329b4ed67
  1. 15
      src/database.c
  2. 8
      src/database.h

15
src/database.c

@ -192,7 +192,20 @@ int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
return processed;
}
inline float
uint64_t
imdb_records_count(imdb_t * const db) {
struct stat st;
off_t size = 0;
memset(&st, 0x0, sizeof(struct stat));
fstat(db->fd, &st);
size = st.st_size;
return size / IMDB_REC_LEN;
}
float
ratio_from_rec_data(unsigned char * const data) {
uint16_t iw, ih;

8
src/database.h

@ -86,6 +86,9 @@ extern int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len);
extern int imdb_open (imdb_t *db, const char *path);
extern int imdb_close(imdb_t *db);
float
ratio_from_rec_data(unsigned char * const data);
/**
@returns:
-1 on error
@ -98,4 +101,9 @@ imdb_search(imdb_t * const db,
imdb_search_t * const search,
imdb_match_t **matches);
/**
@returns: number of records in database
*/
uint64_t
imdb_records_count(imdb_t * const db);
#endif

Loading…
Cancel
Save