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

Key value store. More...

#include <stdbool.h>
#include <stdlib.h>
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  StoreOps
 

Macros

#define STORE_BACKEND_OPS(_name)
 

Typedefs

typedef void StoreHandle
 Opaque type for store backend.
 

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.
 

Detailed Description

Key value store.

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 lib.h.

Macro Definition Documentation

◆ STORE_BACKEND_OPS

#define STORE_BACKEND_OPS ( _name)
Value:
const struct StoreOps store_##_name##_ops = { \
.name = #_name, \
.open = store_##_name##_open, \
.fetch = store_##_name##_fetch, \
.free = store_##_name##_free, \
.store = store_##_name##_store, \
.delete_record = store_##_name##_delete_record, \
.close = store_##_name##_close, \
.version = store_##_name##_version, \
};
Definition lib.h:66

Definition at line 160 of file lib.h.

160#define STORE_BACKEND_OPS(_name) \
161 const struct StoreOps store_##_name##_ops = { \
162 .name = #_name, \
163 .open = store_##_name##_open, \
164 .fetch = store_##_name##_fetch, \
165 .free = store_##_name##_free, \
166 .store = store_##_name##_store, \
167 .delete_record = store_##_name##_delete_record, \
168 .close = store_##_name##_close, \
169 .version = store_##_name##_version, \
170 };

Typedef Documentation

◆ StoreHandle

typedef void StoreHandle

Opaque type for store backend.

Definition at line 58 of file lib.h.

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: