87static void dbt_init(DBT *dbt,
void *data,
size_t len)
94 dbt->flags = DB_DBT_USERMEM;
121 const int pagesize = 512;
135 int rc = db_env_create(&sdata->
env, 0);
139 rc = (*sdata->
env->open)(sdata->
env, NULL, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0600);
144 rc = db_create(&sdata->
db, sdata->
env, 0);
148 uint32_t createflags = DB_CREATE;
149 struct stat st = { 0 };
151 if ((stat(path, &st) != 0) && (errno == ENOENT))
153 createflags |= DB_EXCL;
154 sdata->
db->set_pagesize(sdata->
db, pagesize);
157 rc = (*sdata->
db->open)(sdata->
db, NULL, path, NULL, DB_BTREE, createflags, 0600);
165 sdata->
db->close(sdata->
db, 0);
167 sdata->
env->close(sdata->
env, 0);
192 dbt_init(&dkey, (
void *) key, klen);
194 data.flags = DB_DBT_MALLOC;
196 sdata->
db->get(sdata->
db, NULL, &dkey, &data, 0);
214 void *value,
size_t vlen)
225 dbt_init(&dkey, (
void *) key, klen);
227 databuf.flags = DB_DBT_USERMEM;
228 databuf.data = value;
232 return sdata->
db->put(sdata->
db, NULL, &dkey, &databuf, 0);
247 dbt_init(&dkey, (
void *) key, klen);
248 return sdata->
db->del(sdata->
db, NULL, &dkey, 0);
262 sdata->
db->close(sdata->
db, 0);
263 sdata->
env->close(sdata->
env, 0);
276 return DB_VERSION_STRING;
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB thing.
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB thing.
static void bdb_sdata_free(struct BdbStoreData **ptr)
Free Bdb Store Data.
static struct BdbStoreData * bdb_sdata_new(void)
Create new Bdb Store Data.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
int mutt_file_lock(int fd, bool excl, bool timeout)
(Try to) Lock a file using fcntl()
int mutt_file_unlock(int fd)
Unlock a file previously locked by mutt_file_lock()
static void store_bdb_close(StoreHandle **ptr)
Close a Store connection - Implements StoreOps::close() -.
static int store_bdb_delete_record(StoreHandle *store, const char *key, size_t klen)
Delete a record from the Store - Implements StoreOps::delete_record() -.
static void * store_bdb_fetch(StoreHandle *store, const char *key, size_t klen, size_t *vlen)
Fetch a Value from the Store - Implements StoreOps::fetch() -.
static void store_bdb_free(StoreHandle *store, void **ptr)
Free a Value returned by fetch() - Implements StoreOps::free() -.
static StoreHandle * store_bdb_open(const char *path)
Open a connection to a Store - Implements StoreOps::open() -.
static int store_bdb_store(StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen)
Write a Value to the Store - Implements StoreOps::store() -.
static const char * store_bdb_version(void)
Get a Store version string - Implements StoreOps::version() -.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Convenience wrapper for the library headers.
void StoreHandle
Opaque type for store backend.
#define STORE_BACKEND_OPS(_name)
String manipulation buffer.