NeoMutt  2024-03-23-147-g885fbc
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 <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)
 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 57 of file bdb.c.

58{
59 if (!ptr || !*ptr)
60 return;
61
62 struct BdbStoreData *sdata = *ptr;
63 buf_dealloc(&sdata->lockfile);
64
65 FREE(ptr);
66}
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:376
#define FREE(x)
Definition: memory.h:45
Berkeley DB Store.
Definition: bdb.c:46
struct Buffer lockfile
Definition: bdb.c:50
+ 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 72 of file bdb.c.

73{
74 struct BdbStoreData *sdata = mutt_mem_calloc(1, sizeof(struct BdbStoreData));
75
76 buf_alloc(&sdata->lockfile, 128);
77
78 return sdata;
79}
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:336
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
+ 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 87 of file bdb.c.

88{
89 dbt->data = data;
90 dbt->size = len;
91 dbt->ulen = len;
92 dbt->dlen = 0;
93 dbt->doff = 0;
94 dbt->flags = DB_DBT_USERMEM;
95}
+ 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 101 of file bdb.c.

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