NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
store.c File Reference

Shared store code. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "lib.h"
+ Include dependency graph for store.c:

Go to the source code of this file.

Macros

#define STORE_BACKEND(name)   extern const struct StoreOps store_##name##_ops;
 

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.
 

Variables

static const struct StoreOpsStoreOps []
 Backend implementations.
 

Detailed Description

Shared store code.

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 store.c.

Macro Definition Documentation

◆ STORE_BACKEND

#define STORE_BACKEND (   name)    extern const struct StoreOps store_##name##_ops;

Definition at line 36 of file store.c.

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
Definition: lib.h:69
+ 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 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:654
+ 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:

Variable Documentation

◆ StoreOps

const struct StoreOps* StoreOps[]
static
Initial value:
= {
&store_tokyocabinet_ops,
&store_kyotocabinet_ops,
&store_qdbm_ops,
&store_gdbm_ops,
&store_bdb_ops,
&store_tdb_ops,
&store_lmdb_ops,
NULL,
}

Backend implementations.

Definition at line 50 of file store.c.