From fadb954e898a96c316cbe12036400db7baede9e8 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Mon, 9 Jan 2017 18:02:33 +1000 Subject: [PATCH] * drop simdb_record_write(), simdb_rec_t, simdb_block_t, DB_{READ,WRITE} macro --- src/database.c | 31 ------------------------------- src/simdb.h | 27 --------------------------- 2 files changed, 58 deletions(-) diff --git a/src/database.c b/src/database.c index 1db26f2..6d325bf 100644 --- a/src/database.c +++ b/src/database.c @@ -31,19 +31,6 @@ struct _simdb_t { char path[PATH_MAX]; /**< path to database file */ }; -/** read some records from database file and checks for errors */ -#define DB_READ(db, buf, len, off) \ - errno = 0; \ - memset((buf), 0x0, (len)); \ - bytes = pread((db)->fd, (buf), (len), (off)); \ - if (errno) { return SIMDB_ERR_SYSTEM; } - -/** write some records from database file and checks for errors */ -#define DB_WRITE(db, buf, len, off) \ - errno = 0; \ - bytes = pwrite((db)->fd, (buf), (len), (off)); \ - if (errno) { return SIMDB_ERR_SYSTEM; } - /** database header format line */ const char *simdb_hdr_fmt = "IMDB v%02u, CAPS: %s;"; @@ -237,24 +224,6 @@ simdb_write(simdb_t *db, int start, int records, simdb_urec_t *data) { return records; } -int simdb_record_write(simdb_t *db, simdb_rec_t *rec) { - ssize_t bytes = 0; - - assert(db != NULL); - assert(rec != NULL); - assert(rec->num > 0); - - if (!(db->flags & SIMDB_FLAG_WRITE)) - return SIMDB_ERR_READONLY; - - DB_WRITE(db, rec->data, SIMDB_REC_LEN, rec->num * SIMDB_REC_LEN); - - if (bytes != SIMDB_REC_LEN) - return SIMDB_ERR_SYSTEM; - - return 1; -} - int simdb_records_count(simdb_t * const db) { struct stat st; diff --git a/src/simdb.h b/src/simdb.h index 214a09f..313f0f3 100644 --- a/src/simdb.h +++ b/src/simdb.h @@ -40,23 +40,6 @@ /** opaque database handler */ typedef struct _simdb_t simdb_t; -/** - * database record - */ -typedef struct { - uint64_t num; /**< record number in database */ - unsigned char data[SIMDB_REC_LEN]; /**< record raw data */ -} simdb_rec_t; - -/** - * block of sequental records of database - */ -typedef struct { - uint64_t start; /**< first record number of block */ - size_t records; /**< records count */ - unsigned char *data; /**< raw records data */ -} simdb_block_t; - /** * search parameters * maxdiff_* fields should have value from 0.0 to 1.0 (0% - 100%) @@ -121,16 +104,6 @@ int simdb_search(simdb_t * const db, int num, simdb_search_t * const search, simdb_match_t ** matches); -/** - * @brief Write single record to database - * @param db Database handle - * @param rec Record struct to write - * @note @a num member of @a rec struct should be set - * @retval 1 on success - * @retval <0 on error (system error or record missing) - */ -int simdb_record_write(simdb_t *db, simdb_rec_t *rec); - /** * @brief Create record from image file * @param path Path to source image