aboutsummaryrefslogtreecommitdiffstats
path: root/src/Idle.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-09 08:05:02 +0100
committerMax Kellermann <max@duempel.org>2014-02-09 08:07:48 +0100
commit570b12ec1392dc6561b21c7bb8b653eb7a922a01 (patch)
tree670fa261da1ee278273b095d29feb36688ada785 /src/Idle.cxx
parentac286ef734cb3d8cc59acb71096da29c6d83d690 (diff)
downloadmpd-570b12ec1392dc6561b21c7bb8b653eb7a922a01.tar.gz
mpd-570b12ec1392dc6561b21c7bb8b653eb7a922a01.tar.xz
mpd-570b12ec1392dc6561b21c7bb8b653eb7a922a01.zip
Idle: error out when unrecognized idle event was specified
Implements the error checks missing in commit 0bad8406
Diffstat (limited to '')
-rw-r--r--src/Idle.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Idle.cxx b/src/Idle.cxx
index ed16bbecb..713454da5 100644
--- a/src/Idle.cxx
+++ b/src/Idle.cxx
@@ -25,6 +25,7 @@
#include "config.h"
#include "Idle.hxx"
#include "GlobalEvents.hxx"
+#include "util/ASCII.hxx"
#include <atomic>
@@ -70,3 +71,15 @@ idle_get_names(void)
{
return idle_names;
}
+
+unsigned
+idle_parse_name(const char *name)
+{
+ assert(name != nullptr);
+
+ for (unsigned i = 0; idle_names[i] != nullptr; ++i)
+ if (StringEqualsCaseASCII(name, idle_names[i]))
+ return 1 << i;
+
+ return 0;
+}