NeoMutt  2022-04-29-145-g9b6a0e
Teaching an old dog new tricks
DOXYGEN
lib.h
Go to the documentation of this file.
1 
54 #ifndef MUTT_STORE_LIB_H
55 #define MUTT_STORE_LIB_H
56 
57 #include <stdbool.h>
58 #include <stdlib.h>
59 
65 struct StoreOps
66 {
67  const char *name;
68 
82  void *(*open)(const char *path);
83 
96  void *(*fetch)(void *store, const char *key, size_t klen, size_t *vlen);
97 
106  void (*free)(void *store, void **ptr);
107 
121  int (*store)(void *store, const char *key, size_t klen, void *value, size_t vlen);
122 
134  int (*delete_record)(void *store, const char *key, size_t klen);
135 
143  void (*close)(void **ptr);
144 
152  const char *(*version)(void);
153 };
154 
155 const char * store_backend_list(void);
156 const struct StoreOps *store_get_backend_ops(const char *str);
157 bool store_is_valid_backend(const char *str);
158 
159 #define STORE_BACKEND_OPS(_name) \
160  const struct StoreOps store_##_name##_ops = { \
161  .name = #_name, \
162  .open = store_##_name##_open, \
163  .fetch = store_##_name##_fetch, \
164  .free = store_##_name##_free, \
165  .store = store_##_name##_store, \
166  .delete_record = store_##_name##_delete_record, \
167  .close = store_##_name##_close, \
168  .version = store_##_name##_version, \
169  };
170 
171 #endif /* MUTT_STORE_LIB_H */
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition: store.c:129
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
Definition: lib.h:66
void(* free)(void *store, void **ptr)
Definition: lib.h:106
int(* delete_record)(void *store, const char *key, size_t klen)
Definition: lib.h:134
const char * name
Store name.
Definition: lib.h:67
int(* store)(void *store, const char *key, size_t klen, void *value, size_t vlen)
Definition: lib.h:121
void(* close)(void **ptr)
Definition: lib.h:143