NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
store.c
Go to the documentation of this file.
1
23
29
30
#include "config.h"
31
#include <stdbool.h>
32
#include <stdio.h>
33
#include "
mutt/lib.h
"
34
#include "
config/lib.h
"
35
#include "
lib.h
"
36
37
#define STORE_BACKEND(name) extern const struct StoreOps store_##name##_ops;
38
STORE_BACKEND
(gdbm)
39
STORE_BACKEND
(lmdb)
40
STORE_BACKEND
(rocksdb)
41
STORE_BACKEND
(tdb)
42
#undef STORE_BACKEND
43
47
static
const
struct
StoreOps
*
StoreOps
[] = {
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
};
62
69
struct
Slist
*
store_backend_list
(
void
)
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
}
82
88
const
struct
StoreOps
*
store_get_backend_ops
(
const
char
*str)
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
}
103
110
bool
store_is_valid_backend
(
const
char
*str)
111
{
112
return
store_get_backend_ops
(str);
113
}
lib.h
Convenience wrapper for the config headers.
lib.h
Convenience wrapper for the library headers.
slist_add_string
struct Slist * slist_add_string(struct Slist *list, const char *str)
Add a string to a list.
Definition
slist.c:68
slist_new
struct Slist * slist_new(uint32_t flags)
Create a new string list.
Definition
slist.c:51
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition
string.c:666
lib.h
Key value store.
store_is_valid_backend
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition
store.c:110
STORE_BACKEND
#define STORE_BACKEND(name)
Definition
store.c:37
store_backend_list
struct Slist * store_backend_list(void)
Get a list of backend names.
Definition
store.c:69
store_get_backend_ops
const struct StoreOps * store_get_backend_ops(const char *str)
Get the API functions for an store backend.
Definition
store.c:88
Slist
String list.
Definition
slist.h:37
StoreOps
Definition
lib.h:66
D_SLIST_SEP_SPACE
#define D_SLIST_SEP_SPACE
Slist items are space-separated.
Definition
types.h:110