NeoMutt  2024-04-16-36-g75b6fb
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_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 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_kyotocabinet_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_qdbm_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_tokyocabinet_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_bdb_store()

static int store_bdb_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 213 of file bdb.c.

215{
216 if (!store)
217 return -1;
218
219 // Decloak an opaque pointer
220 struct BdbStoreData *sdata = store;
221
222 DBT dkey = { 0 };
223 DBT databuf = { 0 };
224
225 dbt_init(&dkey, (void *) key, klen);
226 dbt_empty_init(&databuf);
227 databuf.flags = DB_DBT_USERMEM;
228 databuf.data = value;
229 databuf.size = vlen;
230 databuf.ulen = vlen;
231
232 return sdata->db->put(sdata->db, NULL, &dkey, &databuf, 0);
233}
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB thing.
Definition: bdb.c:101
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB thing.
Definition: bdb.c:87
Berkeley DB Store.
Definition: bdb.c:46
DB * db
Definition: bdb.c:48
+ Here is the call graph for this function:

◆ 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 92 of file gdbm.c.

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

◆ store_kyotocabinet_store()

static int store_kyotocabinet_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 96 of file kc.c.

98{
99 if (!store)
100 return -1;
101
102 // Decloak an opaque pointer
103 KCDB *db = store;
104 if (!kcdbset(db, key, klen, value, vlen))
105 {
106 int ecode = kcdbecode(db);
107 return ecode ? ecode : -1;
108 }
109 return 0;
110}

◆ 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 253 of file lmdb.c.

255{
256 if (!store)
257 return -1;
258
259 MDB_val dkey = { 0 };
260 MDB_val databuf = { 0 };
261
262 // Decloak an opaque pointer
263 struct LmdbStoreData *sdata = store;
264
265 dkey.mv_data = (void *) key;
266 dkey.mv_size = klen;
267 databuf.mv_data = value;
268 databuf.mv_size = vlen;
269 int rc = lmdb_get_write_txn(sdata);
270 if (rc != MDB_SUCCESS)
271 {
272 mutt_debug(LL_DEBUG2, "lmdb_get_write_txn: %s\n", mdb_strerror(rc));
273 return rc;
274 }
275 rc = mdb_put(sdata->txn, sdata->db, &dkey, &databuf, 0);
276 if (rc != MDB_SUCCESS)
277 {
278 mutt_debug(LL_DEBUG2, "mdb_put: %s\n", mdb_strerror(rc));
279 mdb_txn_abort(sdata->txn);
281 sdata->txn = NULL;
282 }
283 return rc;
284}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int lmdb_get_write_txn(struct LmdbStoreData *sdata)
Get an LMDB write transaction.
Definition: lmdb.c:125
@ TXN_UNINITIALIZED
Transaction is uninitialised.
Definition: lmdb.c:56
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
LMDB store.
Definition: lmdb.c:65
MDB_txn * txn
Definition: lmdb.c:67
MDB_dbi db
Definition: lmdb.c:68
enum LmdbTxnMode txn_mode
Definition: lmdb.c:69
+ Here is the call graph for this function:

◆ store_qdbm_store()

static int store_qdbm_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 80 of file qdbm.c.

82{
83 if (!store)
84 return -1;
85
86 // Decloak an opaque pointer
87 VILLA *db = store;
88 /* Not sure if dpecode is reset on success, so better to explicitly return 0
89 * on success */
90 bool success = vlput(db, key, klen, value, vlen, VL_DOVER);
91 return success ? 0 : dpecode ? dpecode : -1;
92}

◆ 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 150 of file rocksdb.c.

152{
153 if (!store)
154 return -1;
155
156 // Decloak an opaque pointer
157 struct RocksDbStoreData *sdata = store;
158
159 rocksdb_put(sdata->db, sdata->write_options, key, klen, value, vlen, &sdata->err);
160 if (sdata->err)
161 {
162 rocksdb_free(sdata->err);
163 sdata->err = NULL;
164 return -1;
165 }
166
167 return 0;
168}
RocksDB store.
Definition: rocksdb.c:41
rocksdb_t * db
Definition: rocksdb.c:42
rocksdb_writeoptions_t * write_options
Definition: rocksdb.c:45
char * err
Definition: rocksdb.c:46

◆ store_tokyocabinet_store()

static int store_tokyocabinet_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 90 of file tc.c.

92{
93 if (!store)
94 return -1;
95
96 // Decloak an opaque pointer
97 TCBDB *db = store;
98 if (!tcbdbput(db, key, klen, value, vlen))
99 {
100 int ecode = tcbdbecode(db);
101 return ecode ? ecode : -1;
102 }
103 return 0;
104}

◆ 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 91 of file tdb.c.

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