NeoMutt  2024-04-25-85-g27bab4
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 214 of file bdb.c.

216{
217 if (!store)
218 return -1;
219
220 // Decloak an opaque pointer
221 struct BdbStoreData *sdata = store;
222
223 DBT dkey = { 0 };
224 DBT databuf = { 0 };
225
226 dbt_init(&dkey, (void *) key, klen);
227 dbt_empty_init(&databuf);
228 databuf.flags = DB_DBT_USERMEM;
229 databuf.data = value;
230 databuf.size = vlen;
231 databuf.ulen = vlen;
232
233 return sdata->db->put(sdata->db, NULL, &dkey, &databuf, 0);
234}
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB thing.
Definition: bdb.c:102
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB thing.
Definition: bdb.c:88
Berkeley DB Store.
Definition: bdb.c:47
DB * db
Definition: bdb.c:49
+ 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 259 of file lmdb.c.

261{
262 if (!store)
263 return -1;
264
265 MDB_val dkey = { 0 };
266 MDB_val databuf = { 0 };
267
268 // Decloak an opaque pointer
269 struct LmdbStoreData *sdata = store;
270
271 dkey.mv_data = (void *) key;
272 dkey.mv_size = klen;
273 databuf.mv_data = value;
274 databuf.mv_size = vlen;
275 int rc = lmdb_get_write_txn(sdata);
276 if (rc != MDB_SUCCESS)
277 {
278 mutt_debug(LL_DEBUG2, "lmdb_get_write_txn: %s\n", mdb_strerror(rc));
279 return rc;
280 }
281 rc = mdb_put(sdata->txn, sdata->db, &dkey, &databuf, 0);
282 if (rc != MDB_SUCCESS)
283 {
284 mutt_debug(LL_DEBUG2, "mdb_put: %s\n", mdb_strerror(rc));
285 mdb_txn_abort(sdata->txn);
287 sdata->txn = NULL;
288 }
289 return rc;
290}
#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:126
@ TXN_UNINITIALIZED
Transaction is uninitialised.
Definition: lmdb.c:57
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
LMDB store.
Definition: lmdb.c:66
MDB_txn * txn
Definition: lmdb.c:68
MDB_dbi db
Definition: lmdb.c:69
enum LmdbTxnMode txn_mode
Definition: lmdb.c:70
+ 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 153 of file rocksdb.c.

155{
156 if (!store)
157 return -1;
158
159 // Decloak an opaque pointer
160 struct RocksDbStoreData *sdata = store;
161
162 rocksdb_put(sdata->db, sdata->write_options, key, klen, value, vlen, &sdata->err);
163 if (sdata->err)
164 {
165 rocksdb_free(sdata->err);
166 sdata->err = NULL;
167 return -1;
168 }
169
170 return 0;
171}
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}