NeoMutt  2024-11-14-138-ge5ca67
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

const char * store_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()

const char * store_backend_list ( void  )

Get a list of backend names.

Return values
ptrComma-space-separated list of names

The caller should free the string.

Definition at line 84 of file store.c.

85{
86 char tmp[256] = { 0 };
87 const struct StoreOps **store_ops = StoreOps;
88 size_t len = 0;
89
90 for (; *store_ops; store_ops++)
91 {
92 if (len != 0)
93 {
94 len += snprintf(tmp + len, sizeof(tmp) - len, ", ");
95 }
96 len += snprintf(tmp + len, sizeof(tmp) - len, "%s", (*store_ops)->name);
97 }
98
99 return mutt_str_dup(tmp);
100}
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
static const struct StoreOps * StoreOps[]
Backend implementations.
Definition: store.c:50
+ Here is the call 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 107 of file store.c.

108{
109 const struct StoreOps **store_ops = StoreOps;
110
111 if (!str || (*str == '\0'))
112 {
113 return *store_ops;
114 }
115
116 for (; *store_ops; store_ops++)
117 if (mutt_str_equal(str, (*store_ops)->name))
118 break;
119
120 return *store_ops;
121}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
+ 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 129 of file store.c.

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