NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
bdb.c File Reference

Berkeley DB backend for the key/value Store. More...

#include "config.h"
#include <db.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "lib.h"
+ Include dependency graph for bdb.c:

Go to the source code of this file.

Data Structures

struct  BdbStoreData
 Berkeley DB Store. More...
 

Functions

static void bdb_sdata_free (struct BdbStoreData **ptr)
 Free Bdb Store Data.
 
static struct BdbStoreDatabdb_sdata_new (void)
 Create new Bdb Store Data.
 
static void dbt_init (DBT *dbt, void *data, size_t len)
 Initialise a BDB thing.
 
static void dbt_empty_init (DBT *dbt)
 Initialise an empty BDB thing.
 
static StoreHandlestore_bdb_open (const char *path, bool create)
 Open a connection to a Store - Implements StoreOps::open() -.
 
static void * store_bdb_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Fetch a Value from the Store - Implements StoreOps::fetch() -.
 
static void store_bdb_free (StoreHandle *store, void **ptr)
 Free a Value returned by fetch() - Implements StoreOps::free() -.
 
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_bdb_delete_record (StoreHandle *store, const char *key, size_t klen)
 Delete a record from the Store - Implements StoreOps::delete_record() -.
 
static void store_bdb_close (StoreHandle **ptr)
 Close a Store connection - Implements StoreOps::close() -.
 
static const char * store_bdb_version (void)
 Get a Store version string - Implements StoreOps::version() -.
 

Detailed Description

Berkeley DB backend for the key/value Store.

Authors
  • Pietro Cerutti
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file bdb.c.

Function Documentation

◆ bdb_sdata_free()

static void bdb_sdata_free ( struct BdbStoreData **  ptr)
static

Free Bdb Store Data.

Parameters
ptrBdb Store Data to free

Definition at line 58 of file bdb.c.

59{
60 if (!ptr || !*ptr)
61 return;
62
63 struct BdbStoreData *sdata = *ptr;
64 buf_dealloc(&sdata->lockfile);
65
66 FREE(ptr);
67}
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:377
#define FREE(x)
Definition: memory.h:55
Berkeley DB Store.
Definition: bdb.c:47
struct Buffer lockfile
Definition: bdb.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bdb_sdata_new()

static struct BdbStoreData * bdb_sdata_new ( void  )
static

Create new Bdb Store Data.

Return values
ptrNew Bdb Store Data

Definition at line 73 of file bdb.c.

74{
75 struct BdbStoreData *sdata = MUTT_MEM_CALLOC(1, struct BdbStoreData);
76
77 buf_alloc(&sdata->lockfile, 128);
78
79 return sdata;
80}
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:337
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbt_init()

static void dbt_init ( DBT *  dbt,
void *  data,
size_t  len 
)
static

Initialise a BDB thing.

Parameters
dbtThing to initialise
dataID string to associate
lenLength of ID string

Definition at line 88 of file bdb.c.

89{
90 dbt->data = data;
91 dbt->size = len;
92 dbt->ulen = len;
93 dbt->dlen = 0;
94 dbt->doff = 0;
95 dbt->flags = DB_DBT_USERMEM;
96}
+ Here is the caller graph for this function:

◆ dbt_empty_init()

static void dbt_empty_init ( DBT *  dbt)
static

Initialise an empty BDB thing.

Parameters
dbtThing to initialise

Definition at line 102 of file bdb.c.

103{
104 dbt->data = NULL;
105 dbt->size = 0;
106 dbt->ulen = 0;
107 dbt->dlen = 0;
108 dbt->doff = 0;
109 dbt->flags = 0;
110}
+ Here is the caller graph for this function: