NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN

Write a Value to the Store. More...

+ Collaboration diagram for store():

Functions

static int store_bdb_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_gdbm_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_kyotocabinet_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_lmdb_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_qdbm_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_rocksdb_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_tokyocabinet_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 
static int store_tdb_store (void *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -. More...
 

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 ( void *  store,
const char *  key,
size_t  klen,
void *  value,
size_t  vlen 
)
static

Implements StoreOps::store() -.

Definition at line 189 of file bdb.c.

190 {
191  if (!store)
192  return -1;
193 
194  DBT dkey;
195  DBT databuf;
196 
197  struct StoreDbCtx *ctx = store;
198 
199  dbt_init(&dkey, (void *) key, klen);
200  dbt_empty_init(&databuf);
201  databuf.flags = DB_DBT_USERMEM;
202  databuf.data = value;
203  databuf.size = vlen;
204  databuf.ulen = vlen;
205 
206  return ctx->db->put(ctx->db, NULL, &dkey, &databuf, 0);
207 }
Berkeley DB context.
Definition: bdb.c:48
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB context.
Definition: bdb.c:62
DB * db
Definition: bdb.c:51
static void dbt_empty_init(DBT *dbt)
Initialise an empty BDB context.
Definition: bdb.c:76
+ Here is the call graph for this function:

◆ store_gdbm_store()

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

Implements StoreOps::store() -.

Definition at line 89 of file gdbm.c.

90 {
91  if (!store)
92  return -1;
93 
94  datum dkey;
95  datum databuf;
96 
97  GDBM_FILE db = store;
98 
99  dkey.dptr = (char *) key;
100  dkey.dsize = klen;
101 
102  databuf.dsize = vlen;
103  databuf.dptr = value;
104 
105  return gdbm_store(db, dkey, databuf, GDBM_REPLACE);
106 }
DB * db
Definition: bdb.c:51

◆ store_kyotocabinet_store()

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

Implements StoreOps::store() -.

Definition at line 95 of file kc.c.

97 {
98  if (!store)
99  return -1;
100 
101  KCDB *db = store;
102  if (!kcdbset(db, key, klen, value, vlen))
103  {
104  int ecode = kcdbecode(db);
105  return ecode ? ecode : -1;
106  }
107  return 0;
108 }
DB * db
Definition: bdb.c:51

◆ store_lmdb_store()

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

Implements StoreOps::store() -.

Definition at line 227 of file lmdb.c.

228 {
229  if (!store)
230  return -1;
231 
232  MDB_val dkey;
233  MDB_val databuf;
234 
235  struct StoreLmdbCtx *ctx = store;
236 
237  dkey.mv_data = (void *) key;
238  dkey.mv_size = klen;
239  databuf.mv_data = value;
240  databuf.mv_size = vlen;
241  int rc = mdb_get_w_txn(ctx);
242  if (rc != MDB_SUCCESS)
243  {
244  mutt_debug(LL_DEBUG2, "mdb_get_w_txn: %s\n", mdb_strerror(rc));
245  return rc;
246  }
247  rc = mdb_put(ctx->txn, ctx->db, &dkey, &databuf, 0);
248  if (rc != MDB_SUCCESS)
249  {
250  mutt_debug(LL_DEBUG2, "mdb_put: %s\n", mdb_strerror(rc));
251  mdb_txn_abort(ctx->txn);
253  ctx->txn = NULL;
254  }
255  return rc;
256 }
static int mdb_get_w_txn(struct StoreLmdbCtx *ctx)
Get an LMDB write transaction.
Definition: lmdb.c:97
enum MdbTxnMode txn_mode
Definition: lmdb.c:61
MDB_txn * txn
Definition: lmdb.c:59
LMDB context.
Definition: lmdb.c:56
Log at debug level 2.
Definition: logging.h:41
MDB_dbi db
Definition: lmdb.c:60
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Transaction is uninitialised.
Definition: lmdb.c:48
+ Here is the call graph for this function:

◆ store_qdbm_store()

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

Implements StoreOps::store() -.

Definition at line 78 of file qdbm.c.

79 {
80  if (!store)
81  return -1;
82 
83  VILLA *db = store;
84  /* Not sure if dbecode is reset on success, so better to explicitly return 0
85  * on success */
86  bool success = vlput(db, key, klen, value, vlen, VL_DOVER);
87  return success ? 0 : dpecode ? dpecode : -1;
88 }
MDB_dbi db
Definition: lmdb.c:60

◆ store_rocksdb_store()

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

Implements StoreOps::store() -.

Definition at line 121 of file rocksdb.c.

123 {
124  if (!store)
125  return -1;
126 
127  struct RocksDbCtx *ctx = store;
128 
129  rocksdb_put(ctx->db, ctx->write_options, key, klen, value, vlen, &ctx->err);
130  if (ctx->err)
131  {
132  rocksdb_free(ctx->err);
133  ctx->err = NULL;
134  return -1;
135  }
136 
137  return 0;
138 }
rocksdb_t * db
Definition: rocksdb.c:41
char * err
Definition: rocksdb.c:45
rocksdb_writeoptions_t * write_options
Definition: rocksdb.c:44
Berkeley DB context.
Definition: rocksdb.c:39

◆ store_tokyocabinet_store()

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

Implements StoreOps::store() -.

Definition at line 87 of file tc.c.

89 {
90  if (!store)
91  return -1;
92 
93  TCBDB *db = store;
94  if (!tcbdbput(db, key, klen, value, vlen))
95  {
96  int ecode = tcbdbecode(db);
97  return ecode ? ecode : -1;
98  }
99  return 0;
100 }
rocksdb_t * db
Definition: rocksdb.c:41

◆ store_tdb_store()

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

Implements StoreOps::store() -.

Definition at line 85 of file tdb.c.

86 {
87  if (!store)
88  return -1;
89 
90  TDB_CONTEXT *db = store;
91  TDB_DATA dkey;
92  TDB_DATA databuf;
93 
94  dkey.dptr = (unsigned char *) key;
95  dkey.dsize = klen;
96 
97  databuf.dsize = vlen;
98  databuf.dptr = value;
99 
100  return tdb_store(db, dkey, databuf, TDB_INSERT);
101 }
rocksdb_t * db
Definition: rocksdb.c:41