NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
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;
38STORE_BACKEND(gdbm)
39STORE_BACKEND(lmdb)
40STORE_BACKEND(rocksdb)
42#undef STORE_BACKEND
43
47static 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
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
88const 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
110bool store_is_valid_backend(const char *str)
111{
112 return store_get_backend_ops(str);
113}
Convenience wrapper for the config headers.
Convenience wrapper for the library headers.
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
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
Key value store.
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition store.c:110
#define STORE_BACKEND(name)
Definition store.c:37
struct Slist * store_backend_list(void)
Get a list of backend names.
Definition store.c:69
const struct StoreOps * store_get_backend_ops(const char *str)
Get the API functions for an store backend.
Definition store.c:88
String list.
Definition slist.h:37
Definition lib.h:66
#define D_SLIST_SEP_SPACE
Slist items are space-separated.
Definition types.h:110