aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive_list.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-06-12 23:22:03 +0200
committerMax Kellermann <max@duempel.org>2012-06-12 23:22:03 +0200
commit4eb57e1e9a1718ce93eced6bd4fb06d8abb26477 (patch)
tree2355c6d77273cf614822f5a144005ab1d353863b /src/archive_list.c
parentd662c4c0cc089a6a493a7463e440f0f7e7959b48 (diff)
parent1d52e2cc7727d93e65d557c322b5dd7dc149651c (diff)
downloadmpd-4eb57e1e9a1718ce93eced6bd4fb06d8abb26477.tar.gz
mpd-4eb57e1e9a1718ce93eced6bd4fb06d8abb26477.tar.xz
mpd-4eb57e1e9a1718ce93eced6bd4fb06d8abb26477.zip
Merge branch 'v0.16.x'
Conflicts: src/cmdline.c src/decoder/wildmidi_decoder_plugin.c src/gcc.h src/glib_compat.h src/input_stream.c src/output_list.c src/output_thread.c valgrind.suppressions
Diffstat (limited to 'src/archive_list.c')
-rw-r--r--src/archive_list.c53
1 files changed, 15 insertions, 38 deletions
diff --git a/src/archive_list.c b/src/archive_list.c
index 24aa060c9..e23567bdb 100644
--- a/src/archive_list.c
+++ b/src/archive_list.c
@@ -28,7 +28,7 @@
#include <string.h>
#include <glib.h>
-static const struct archive_plugin *const archive_plugins[] = {
+const struct archive_plugin *const archive_plugins[] = {
#ifdef HAVE_BZ2
&bz2_archive_plugin,
#endif
@@ -44,53 +44,32 @@ static const struct archive_plugin *const archive_plugins[] = {
/** which plugins have been initialized successfully? */
static bool archive_plugins_enabled[G_N_ELEMENTS(archive_plugins) - 1];
+#define archive_plugins_for_each_enabled(plugin) \
+ archive_plugins_for_each(plugin) \
+ if (archive_plugins_enabled[archive_plugin_iterator - archive_plugins])
+
const struct archive_plugin *
archive_plugin_from_suffix(const char *suffix)
{
if (suffix == NULL)
return NULL;
- for (unsigned i = 0; archive_plugins[i] != NULL; ++i) {
- const struct archive_plugin *plugin = archive_plugins[i];
- if (archive_plugins_enabled[i] &&
- plugin->suffixes != NULL &&
- string_array_contains(plugin->suffixes, suffix)) {
- ++i;
+ archive_plugins_for_each_enabled(plugin)
+ if (plugin->suffixes != NULL &&
+ string_array_contains(plugin->suffixes, suffix))
return plugin;
- }
- }
+
return NULL;
}
const struct archive_plugin *
archive_plugin_from_name(const char *name)
{
- for (unsigned i = 0; archive_plugins[i] != NULL; ++i) {
- const struct archive_plugin *plugin = archive_plugins[i];
- if (archive_plugins_enabled[i] &&
- strcmp(plugin->name, name) == 0)
+ archive_plugins_for_each_enabled(plugin)
+ if (strcmp(plugin->name, name) == 0)
return plugin;
- }
- return NULL;
-}
-void archive_plugin_print_all_suffixes(FILE * fp)
-{
- const char *const*suffixes;
-
- for (unsigned i = 0; archive_plugins[i] != NULL; ++i) {
- const struct archive_plugin *plugin = archive_plugins[i];
- if (!archive_plugins_enabled[i])
- continue;
-
- suffixes = plugin->suffixes;
- while (suffixes && *suffixes) {
- fprintf(fp, "%s ", *suffixes);
- suffixes++;
- }
- }
- fprintf(fp, "\n");
- fflush(fp);
+ return NULL;
}
void archive_plugin_init_all(void)
@@ -104,10 +83,8 @@ void archive_plugin_init_all(void)
void archive_plugin_deinit_all(void)
{
- for (unsigned i = 0; archive_plugins[i] != NULL; ++i) {
- const struct archive_plugin *plugin = archive_plugins[i];
- if (archive_plugins_enabled[i] && plugin->finish != NULL)
- archive_plugins[i]->finish();
- }
+ archive_plugins_for_each_enabled(plugin)
+ if (plugin->finish != NULL)
+ plugin->finish();
}