NeoMutt  2024-11-14-138-ge5ca67
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 215 of file bdb.c.

217{
218 if (!store)
219 return -1;
220
221 // Decloak an opaque pointer
222 struct BdbStoreData *sdata = store;
223
224 DBT dkey = { 0 };
225 DBT databuf = { 0 };
226
227 dbt_init(&dkey, (void *) key, klen);
228 dbt_empty_init(&databuf);
229 databuf.flags = DB_DBT_USERMEM;
230 databuf.data = value;
231 databuf.size = vlen;
232 databuf.ulen = vlen;
233
234 return sdata->db->put(sdata->db, NULL, &dkey, &databuf, 0);
235}
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 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_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 97 of file kc.c.

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

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

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

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

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

◆ 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}