NeoMutt  2025-01-09-146-g8c4f7e
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:69
const char * name
Store name.
Definition: lib.h:70

Definition at line 163 of file lib.h.

Typedef Documentation

◆ StoreHandle

typedef void StoreHandle

Opaque type for store backend.

Definition at line 61 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 85 of file store.c.

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}
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
static const struct StoreOps * StoreOps[]
Backend implementations.
Definition: store.c:51
String list.
Definition: slist.h:37
#define D_SLIST_SEP_SPACE
Slist items are space-separated.
Definition: types.h:109
+ 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 104 of file store.c.

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}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:661
+ 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 126 of file store.c.

127{
128 return store_get_backend_ops(str);
129}
const struct StoreOps * store_get_backend_ops(const char *str)
Get the API functions for an store backend.
Definition: store.c:104
+ Here is the call graph for this function:
+ Here is the caller graph for this function: