From 2bf2f34b1211bfde95ef4ada77147a8b65830084 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 2 Mar 2014 00:17:32 +0100 Subject: InputPlugin: allow init() to soft-fail Add enum InputResult which is a tri-state. Input plugins may now fail and just become unavailable. --- src/input/InputPlugin.hxx | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/input/InputPlugin.hxx') diff --git a/src/input/InputPlugin.hxx b/src/input/InputPlugin.hxx index 83e0ab26e..090c73df8 100644 --- a/src/input/InputPlugin.hxx +++ b/src/input/InputPlugin.hxx @@ -26,12 +26,41 @@ #include #include +#ifdef WIN32 +#include +/* damn you, windows.h! */ +#ifdef ERROR +#undef ERROR +#endif +#endif + struct config_param; struct InputStream; class Error; struct Tag; struct InputPlugin { + enum class InitResult { + /** + * A fatal error has occurred (e.g. misconfiguration). + * The #Error has been set. + */ + ERROR, + + /** + * The plugin was initialized successfully and is + * ready to be used. + */ + SUCCESS, + + /** + * The plugin is not available and shall be disabled. + * The #Error may be set describing the situation (to + * be logged). + */ + UNAVAILABLE, + }; + typedef int64_t offset_type; const char *name; @@ -42,7 +71,7 @@ struct InputPlugin { * @return true on success, false if the plugin should be * disabled */ - bool (*init)(const config_param ¶m, Error &error); + InitResult (*init)(const config_param ¶m, Error &error); /** * Global deinitialization. Called once before MPD shuts -- cgit v1.2.3