NeoMutt  2020-09-25
Teaching an old dog new tricks
DOXYGEN
lib.h
Go to the documentation of this file.
1 
52 #ifndef MUTT_STORE_LIB_H
53 #define MUTT_STORE_LIB_H
54 
55 #include <stdbool.h>
56 #include <stdlib.h>
57 
61 struct StoreOps
62 {
63  const char *name;
64 
75  void *(*open)(const char *path);
76 
86  void *(*fetch)(void *store, const char *key, size_t klen, size_t *vlen);
87 
93  void (*free)(void *store, void **ptr);
94 
105  int (*store)(void *store, const char *key, size_t klen, void *value, size_t vlen);
106 
115  int (*delete_record)(void *store, const char *key, size_t klen);
116 
121  void (*close)(void **ptr);
122 
127  const char *(*version)(void);
128 };
129 
130 const char * store_backend_list(void);
131 const struct StoreOps *store_get_backend_ops(const char *str);
132 bool store_is_valid_backend(const char *str);
133 
134 #define STORE_BACKEND_OPS(_name) \
135  const struct StoreOps store_##_name##_ops = { \
136  .name = #_name, \
137  .open = store_##_name##_open, \
138  .fetch = store_##_name##_fetch, \
139  .free = store_##_name##_free, \
140  .store = store_##_name##_store, \
141  .delete_record = store_##_name##_delete_record, \
142  .close = store_##_name##_close, \
143  .version = store_##_name##_version, \
144  };
145 
146 #endif /* MUTT_STORE_LIB_H */
const char * store_backend_list(void)
Get a list of backend names.
Definition: store.c:84
const struct StoreOps * store_get_backend_ops(const char *str)
Get the API functions for an store backend.
Definition: store.c:107
Key Value Store API.
Definition: lib.h:61
void(* close)(void **ptr)
Close a Store connection.
Definition: lib.h:121
int(* store)(void *store, const char *key, size_t klen, void *value, size_t vlen)
Write a Value to the Store.
Definition: lib.h:105
const char * name
Store name.
Definition: lib.h:63
int(* delete_record)(void *store, const char *key, size_t klen)
Delete a record from the Store.
Definition: lib.h:115
void(* free)(void *store, void **ptr)
Free a Value returned by fetch()
Definition: lib.h:93
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition: store.c:129