NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches

Write a Value to the Store. More...

+ Collaboration diagram for store():

Functions

static int store_gdbm_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen)
 Write a Value to the Store - Implements StoreOps::store() -.
 
static int store_lmdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen)
 Write a Value to the Store - Implements StoreOps::store() -.
 
static int store_rocksdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen)
 Write a Value to the Store - Implements StoreOps::store() -.
 
static int store_tdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen)
 Write a Value to the Store - Implements StoreOps::store() -.
 

Detailed Description

Write a Value to the Store.

Parameters
[in]storeStore retrieved via open()
[in]keyKey identifying the record
[in]klenLength of the Key string
[in]valueValue to save
[in]vlenLength of the Value
Return values
0Success
numError, a backend-specific error code

Function Documentation

◆ store_gdbm_store()

static int store_gdbm_store ( StoreHandle * store,
const char * key,
size_t klen,
void * value,
size_t vlen )
static

Write a Value to the Store - Implements StoreOps::store() -.

Definition at line 94 of file gdbm.c.

96{
97 if (!store || (klen > INT_MAX) || (vlen > INT_MAX))
98 return -1;
99
100 datum dkey = { 0 };
101 datum databuf = { 0 };
102
103 // Decloak an opaque pointer
104 GDBM_FILE db = store;
105
106 dkey.dptr = (char *) key;
107 dkey.dsize = klen;
108
109 databuf.dsize = vlen;
110 databuf.dptr = value;
111
112 return gdbm_store(db, dkey, databuf, GDBM_REPLACE);
113}

◆ store_lmdb_store()

static int store_lmdb_store ( StoreHandle * store,
const char * key,
size_t klen,
void * value,
size_t vlen )
static

Write a Value to the Store - Implements StoreOps::store() -.

Definition at line 262 of file lmdb.c.

264{
265 if (!store)
266 return -1;
267
268 MDB_val dkey = { 0 };
269 MDB_val databuf = { 0 };
270
271 // Decloak an opaque pointer
272 struct LmdbStoreData *sdata = store;
273
274 dkey.mv_data = (void *) key;
275 dkey.mv_size = klen;
276 databuf.mv_data = value;
277 databuf.mv_size = vlen;
278 int rc = lmdb_get_write_txn(sdata);
279 if (rc != MDB_SUCCESS)
280 {
281 mutt_debug(LL_DEBUG2, "lmdb_get_write_txn: %s\n", mdb_strerror(rc));
282 return rc;
283 }
284 rc = mdb_put(sdata->txn, sdata->db, &dkey, &databuf, 0);
285 if (rc != MDB_SUCCESS)
286 {
287 mutt_debug(LL_DEBUG2, "mdb_put: %s\n", mdb_strerror(rc));
288 mdb_txn_abort(sdata->txn);
290 sdata->txn = NULL;
291 }
292 return rc;
293}
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
static int lmdb_get_write_txn(struct LmdbStoreData *sdata)
Get an LMDB write transaction.
Definition lmdb.c:127
@ TXN_UNINITIALIZED
Transaction is uninitialised.
Definition lmdb.c:58
@ LL_DEBUG2
Log at debug level 2.
Definition logging2.h:46
LMDB store.
Definition lmdb.c:67
MDB_txn * txn
LMDB transaction.
Definition lmdb.c:69
MDB_dbi db
LMDB database.
Definition lmdb.c:70
enum LmdbTxnMode txn_mode
Transaction mode.
Definition lmdb.c:71
+ Here is the call graph for this function:

◆ store_rocksdb_store()

static int store_rocksdb_store ( StoreHandle * store,
const char * key,
size_t klen,
void * value,
size_t vlen )
static

Write a Value to the Store - Implements StoreOps::store() -.

Definition at line 154 of file rocksdb.c.

156{
157 if (!store)
158 return -1;
159
160 // Decloak an opaque pointer
161 struct RocksDbStoreData *sdata = store;
162
163 rocksdb_put(sdata->db, sdata->write_options, key, klen, value, vlen, &sdata->err);
164 if (sdata->err)
165 {
166 rocksdb_free(sdata->err);
167 sdata->err = NULL;
168 return -1;
169 }
170
171 return 0;
172}
RocksDB store.
Definition rocksdb.c:42
rocksdb_t * db
RocksDB database.
Definition rocksdb.c:43
rocksdb_writeoptions_t * write_options
Write options.
Definition rocksdb.c:46
char * err
Error message.
Definition rocksdb.c:47

◆ store_tdb_store()

static int store_tdb_store ( StoreHandle * store,
const char * key,
size_t klen,
void * value,
size_t vlen )
static

Write a Value to the Store - Implements StoreOps::store() -.

Definition at line 93 of file tdb.c.

95{
96 if (!store)
97 return -1;
98
99 // Decloak an opaque pointer
100 TDB_CONTEXT *db = store;
101 TDB_DATA dkey;
102 TDB_DATA databuf;
103
104 dkey.dptr = (unsigned char *) key;
105 dkey.dsize = klen;
106
107 databuf.dsize = vlen;
108 databuf.dptr = value;
109
110 return tdb_store(db, dkey, databuf, TDB_INSERT);
111}