NeoMutt
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)
 Implements StoreOps::open() -.
 
static void * store_bdb_fetch (StoreHandle *store, const char *key, size_t klen, size_t *vlen)
 Implements StoreOps::fetch() -.
 
static void store_bdb_free (StoreHandle *store, void **ptr)
 Implements StoreOps::free() -.
 
static int store_bdb_store (StoreHandle *store, const char *key, size_t klen, void *value, size_t vlen)
 Implements StoreOps::store() -.
 
static int store_bdb_delete_record (StoreHandle *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -.
 
static void store_bdb_close (StoreHandle **ptr)
 Implements StoreOps::close() -.
 
static const char * store_bdb_version (void)
 Implements StoreOps::version() -.
 

Detailed Description

Berkeley DB backend for the key/value Store.

Authors
  • Thomas Glanzmann
  • Tobias Werth
  • Brian Fundakowski Feldman
  • Pietro Cerutti

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 59 of file bdb.c.

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

75{
76 struct BdbStoreData *sdata = mutt_mem_calloc(1, sizeof(struct BdbStoreData));
77
78 sdata->lockfile = buf_make(128);
79
80 return sdata;
81}
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:70
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 89 of file bdb.c.

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

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