From 570b12ec1392dc6561b21c7bb8b653eb7a922a01 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 9 Feb 2014 08:05:02 +0100 Subject: Idle: error out when unrecognized idle event was specified Implements the error checks missing in commit 0bad8406 --- src/Idle.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Idle.cxx') 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 @@ -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; +} -- cgit v1.2.3