NeoMutt  2025-01-09-144-gb44c67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
store.c
Go to the documentation of this file.
1
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;
39STORE_BACKEND(gdbm)
40STORE_BACKEND(kyotocabinet)
41STORE_BACKEND(lmdb)
42STORE_BACKEND(qdbm)
43STORE_BACKEND(rocksdb)
45STORE_BACKEND(tokyocabinet)
46#undef STORE_BACKEND
47
51static const struct StoreOps *StoreOps[] = {
52#ifdef HAVE_TC
53 &store_tokyocabinet_ops,
54#endif
55#ifdef HAVE_KC
56 &store_kyotocabinet_ops,
57#endif
58#ifdef HAVE_QDBM
59 &store_qdbm_ops,
60#endif
61#ifdef HAVE_ROCKSDB
62 &store_rocksdb_ops,
63#endif
64#ifdef HAVE_GDBM
65 &store_gdbm_ops,
66#endif
67#ifdef HAVE_BDB
68 &store_bdb_ops,
69#endif
70#ifdef HAVE_TDB
71 &store_tdb_ops,
72#endif
73#ifdef HAVE_LMDB
74 &store_lmdb_ops,
75#endif
76 NULL,
77};
78
86{
87 struct Slist *sl = slist_new(D_SLIST_SEP_SPACE);
88
89 const struct StoreOps **store_ops = StoreOps;
90
91 for (; *store_ops; store_ops++)
92 {
93 slist_add_string(sl, (*store_ops)->name);
94 }
95
96 return sl;
97}
98
104const struct StoreOps *store_get_backend_ops(const char *str)
105{
106 const struct StoreOps **store_ops = StoreOps;
107
108 if (!str || (*str == '\0'))
109 {
110 return *store_ops;
111 }
112
113 for (; *store_ops; store_ops++)
114 if (mutt_str_equal(str, (*store_ops)->name))
115 break;
116
117 return *store_ops;
118}
119
126bool store_is_valid_backend(const char *str)
127{
128 return store_get_backend_ops(str);
129}
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:661
Key value store.
static const struct StoreOps * StoreOps[]
Backend implementations.
Definition: store.c:51
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition: store.c:126
#define STORE_BACKEND(name)
Definition: store.c:37
struct Slist * store_backend_list(void)
Get a list of backend names.
Definition: store.c:85
const struct StoreOps * store_get_backend_ops(const char *str)
Get the API functions for an store backend.
Definition: store.c:104
String list.
Definition: slist.h:37
Definition: lib.h:69
#define D_SLIST_SEP_SPACE
Slist items are space-separated.
Definition: types.h:109