88static void dbt_init(DBT *dbt,
void *data,
size_t len)
95 dbt->flags = DB_DBT_USERMEM;
122 const int pagesize = 512;
127 O_WRONLY | (create ? O_CREAT : 0), S_IRUSR | S_IWUSR);
137 int rc = db_env_create(&sdata->
env, 0);
141 rc = (*sdata->
env->open)(sdata->
env, NULL, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0600);
146 rc = db_create(&sdata->
db, sdata->
env, 0);
150 uint32_t createflags = DB_CREATE;
151 struct stat st = { 0 };
153 if ((stat(path, &st) != 0) && (errno == ENOENT))
155 createflags |= DB_EXCL;
156 sdata->
db->set_pagesize(sdata->
db, pagesize);
159 rc = (*sdata->
db->open)(sdata->
db, NULL, path, NULL, DB_BTREE, createflags, 0600);
167 sdata->
db->close(sdata->
db, 0);
169 sdata->
env->close(sdata->
env, 0);
194 dbt_init(&dkey, (
void *) key, klen);
196 data.flags = DB_DBT_MALLOC;
198 sdata->
db->get(sdata->
db, NULL, &dkey, &data, 0);
216 void *value,
size_t vlen)
227 dbt_init(&dkey, (
void *) key, klen);
229 databuf.flags = DB_DBT_USERMEM;
230 databuf.data = value;
234 return sdata->
db->put(sdata->
db, NULL, &dkey, &databuf, 0);
249 dbt_init(&dkey, (
void *) key, klen);
250 return sdata->
db->del(sdata->
db, NULL, &dkey, 0);
264 sdata->
db->close(sdata->
db, 0);
265 sdata->
env->close(sdata->
env, 0);
278 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, bool create)
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() -.
#define MUTT_MEM_CALLOC(n, type)
Convenience wrapper for the library headers.
void StoreHandle
Opaque type for store backend.
#define STORE_BACKEND_OPS(_name)
String manipulation buffer.