decoder_list: add _for_each() macros
This commit is contained in:
parent
9ebbdb9b0b
commit
d2d9b45a81
@ -58,8 +58,7 @@ cmdline_quark(void)
|
|||||||
static void
|
static void
|
||||||
print_all_decoders(FILE *fp)
|
print_all_decoders(FILE *fp)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
|
decoder_plugins_for_each(plugin) {
|
||||||
const struct decoder_plugin *plugin = decoder_plugins[i];
|
|
||||||
const char *const*suffixes;
|
const char *const*suffixes;
|
||||||
|
|
||||||
fprintf(fp, "[%s]", plugin->name);
|
fprintf(fp, "[%s]", plugin->name);
|
||||||
|
@ -174,12 +174,9 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
|
|||||||
const struct decoder_plugin *
|
const struct decoder_plugin *
|
||||||
decoder_plugin_from_name(const char *name)
|
decoder_plugin_from_name(const char *name)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
|
decoder_plugins_for_each_enabled(plugin)
|
||||||
const struct decoder_plugin *plugin = decoder_plugins[i];
|
if (strcmp(plugin->name, name) == 0)
|
||||||
if (decoder_plugins_enabled[i] &&
|
|
||||||
strcmp(plugin->name, name) == 0)
|
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -227,10 +224,6 @@ void decoder_plugin_init_all(void)
|
|||||||
|
|
||||||
void decoder_plugin_deinit_all(void)
|
void decoder_plugin_deinit_all(void)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; decoder_plugins[i] != NULL; ++i) {
|
decoder_plugins_for_each_enabled(plugin)
|
||||||
const struct decoder_plugin *plugin = decoder_plugins[i];
|
decoder_plugin_finish(plugin);
|
||||||
|
|
||||||
if (decoder_plugins_enabled[i])
|
|
||||||
decoder_plugin_finish(plugin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,16 @@ struct decoder_plugin;
|
|||||||
extern const struct decoder_plugin *const decoder_plugins[];
|
extern const struct decoder_plugin *const decoder_plugins[];
|
||||||
extern bool decoder_plugins_enabled[];
|
extern bool decoder_plugins_enabled[];
|
||||||
|
|
||||||
|
#define decoder_plugins_for_each(plugin) \
|
||||||
|
for (const struct decoder_plugin *plugin, \
|
||||||
|
*const*decoder_plugin_iterator = &decoder_plugins[0]; \
|
||||||
|
(plugin = *decoder_plugin_iterator) != NULL; \
|
||||||
|
++decoder_plugin_iterator)
|
||||||
|
|
||||||
|
#define decoder_plugins_for_each_enabled(plugin) \
|
||||||
|
decoder_plugins_for_each(plugin) \
|
||||||
|
if (decoder_plugins_enabled[decoder_plugin_iterator - decoder_plugins])
|
||||||
|
|
||||||
/* interface for using plugins */
|
/* interface for using plugins */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,6 @@ decoder_plugin_print(struct client *client,
|
|||||||
void
|
void
|
||||||
decoder_list_print(struct client *client)
|
decoder_list_print(struct client *client)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; decoder_plugins[i] != NULL; ++i)
|
decoder_plugins_for_each_enabled(plugin)
|
||||||
if (decoder_plugins_enabled[i])
|
decoder_plugin_print(client, plugin);
|
||||||
decoder_plugin_print(client, decoder_plugins[i]);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user