NeoMutt  2021-02-05-666-ge300cd
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 
63 struct StoreOps
64 {
65  const char *name;
66 
80  void *(*open)(const char *path);
81 
94  void *(*fetch)(void *store, const char *key, size_t klen, size_t *vlen);
95 
104  void (*free)(void *store, void **ptr);
105 
119  int (*store)(void *store, const char *key, size_t klen, void *value, size_t vlen);
120 
132  int (*delete_record)(void *store, const char *key, size_t klen);
133 
141  void (*close)(void **ptr);
142 
150  const char *(*version)(void);
151 };
152 
153 const char * store_backend_list(void);
154 const struct StoreOps *store_get_backend_ops(const char *str);
155 bool store_is_valid_backend(const char *str);
156 
157 #define STORE_BACKEND_OPS(_name) \
158  const struct StoreOps store_##_name##_ops = { \
159  .name = #_name, \
160  .open = store_##_name##_open, \
161  .fetch = store_##_name##_fetch, \
162  .free = store_##_name##_free, \
163  .store = store_##_name##_store, \
164  .delete_record = store_##_name##_delete_record, \
165  .close = store_##_name##_close, \
166  .version = store_##_name##_version, \
167  };
168 
169 #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
Definition: lib.h:63
void(* close)(void **ptr)
Definition: lib.h:141
int(* store)(void *store, const char *key, size_t klen, void *value, size_t vlen)
Definition: lib.h:119
const char * name
Store name.
Definition: lib.h:65
int(* delete_record)(void *store, const char *key, size_t klen)
Definition: lib.h:132
void(* free)(void *store, void **ptr)
Definition: lib.h:104
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition: store.c:129