static const hcache_ops_t *
hcache_get_backend_ops(const char *backend)
{
- const char *b = NONULL(backend);
- if (!b || !*b)
- {
- return hcache_ops[0];
- }
+ const hcache_ops_t **ops = hcache_ops;
- for (size_t i = 0; i < sizeof(hcache_ops)/sizeof(*hcache_ops) - 1; ++i)
+ if (!backend || !*backend)
{
- if (!strcmp(b, hcache_ops[i]->name))
- {
- return hcache_ops[i];
- }
+ return *ops;
}
- return NULL;
+ for (; *ops; ++ops)
+ if (!strcmp(backend, (*ops)->name))
+ break;
+
+ return *ops;
}
#define hcache_get_ops() hcache_get_backend_ops(HeaderCacheBackend)
}
const char *
-mutt_hcache_backend()
+mutt_hcache_backend_list()
{
char tmp[STRING] = {0};
+ const hcache_ops_t **ops = hcache_ops;
size_t len = 0;
- for (size_t i = 0; i < sizeof(hcache_ops)/sizeof(*hcache_ops) - 1; ++i)
+ for (; *ops; ++ops)
{
if (len != 0)
{
len += snprintf(tmp+len, STRING-len, ", ");
}
- len += snprintf(tmp+len, STRING-len, "%s", hcache_ops[i]->name);
+ len += snprintf(tmp+len, STRING-len, "%s", (*ops)->name);
}
return strdup(tmp);
mutt_hcache_delete(header_cache_t *h, const char *key, size_t keylen);
/**
- * mutt_hcache_backend - get a backend-specific identification string.
+ * mutt_hcache_backend_list - get a list of backend identification strings.
*
- * @return String describing the currently used hcache backend.
+ * @return Comma separated string describing the compiled-in backends.
+ * @note The returned string must be free'd by the caller.
*/
const char *
-mutt_hcache_backend(void);
+mutt_hcache_backend_list(void);
/**
* mutt_hcache_is_valid_backend
void mutt_print_patchlist (void);
/* #include "hcache.h" */
-const char * mutt_hcache_backend (void);
+const char * mutt_hcache_backend_list (void);
const int SCREEN_WIDTH = 80;
#endif
#ifdef USE_HCACHE
- const char *backends = mutt_hcache_backend();
+ const char *backends = mutt_hcache_backend_list();
printf ("\nhcache backends: %s", backends);
FREE(&backends);
#endif