NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
store.c File Reference

Shared store code. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "lib.h"
+ Include dependency graph for store.c:

Go to the source code of this file.

Macros

#define STORE_BACKEND(name)
 

Functions

struct Sliststore_backend_list (void)
 Get a list of backend names.
 
const struct StoreOpsstore_get_backend_ops (const char *str)
 Get the API functions for an store backend.
 
bool store_is_valid_backend (const char *str)
 Is the string a valid Store backend.
 

Variables

static const struct StoreOps * StoreOps []
 Backend implementations.
 

Detailed Description

Shared store code.

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 store.c.

Macro Definition Documentation

◆ STORE_BACKEND

#define STORE_BACKEND ( name)
Value:
extern const struct StoreOps store_##name##_ops;
Definition lib.h:66

Definition at line 37 of file store.c.

Function Documentation

◆ store_backend_list()

struct Slist * store_backend_list ( void )

Get a list of backend names.

Return values
ptrList of names
Note
Caller should free the Slist

Definition at line 69 of file store.c.

70{
71 struct Slist *sl = slist_new(D_SLIST_SEP_SPACE);
72
73 const struct StoreOps **store_ops = StoreOps;
74
75 for (; *store_ops; store_ops++)
76 {
77 slist_add_string(sl, (*store_ops)->name);
78 }
79
80 return sl;
81}
struct Slist * slist_add_string(struct Slist *list, const char *str)
Add a string to a list.
Definition slist.c:68
struct Slist * slist_new(uint32_t flags)
Create a new string list.
Definition slist.c:51
String list.
Definition slist.h:37
#define D_SLIST_SEP_SPACE
Slist items are space-separated.
Definition types.h:110
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store_get_backend_ops()

const struct StoreOps * store_get_backend_ops ( const char * str)

Get the API functions for an store backend.

Parameters
strName of the Store
Return values
ptrSet of function pointers

Definition at line 88 of file store.c.

89{
90 const struct StoreOps **store_ops = StoreOps;
91
92 if (!str || (*str == '\0'))
93 {
94 return *store_ops;
95 }
96
97 for (; *store_ops; store_ops++)
98 if (mutt_str_equal(str, (*store_ops)->name))
99 return *store_ops;
100
101 return NULL;
102}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store_is_valid_backend()

bool store_is_valid_backend ( const char * str)

Is the string a valid Store backend.

Parameters
strStore name
Return values
trues is recognized as a valid backend
falseotherwise

Definition at line 110 of file store.c.

111{
112 return store_get_backend_ops(str);
113}
const struct StoreOps * store_get_backend_ops(const char *str)
Get the API functions for an store backend.
Definition store.c:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ StoreOps

const struct StoreOps* StoreOps[]
static
Initial value:
= {
&store_lmdb_ops,
&store_gdbm_ops,
&store_tdb_ops,
NULL,
}

Backend implementations.

Definition at line 47 of file store.c.

47 {
48#ifdef HAVE_LMDB
49 &store_lmdb_ops, // Strongly recommended
50#endif
51#ifdef HAVE_GDBM
52 &store_gdbm_ops, // Good fallback
53#endif
54#ifdef HAVE_ROCKSDB
55 &store_rocksdb_ops,
56#endif
57#ifdef HAVE_TDB
58 &store_tdb_ops,
59#endif
60 NULL,
61};