Idle: error out when unrecognized idle event was specified

Implements the error checks missing in commit 0bad8406
This commit is contained in:
Max Kellermann
2014-02-09 08:05:02 +01:00
parent ac286ef734
commit 570b12ec13
4 changed files with 33 additions and 8 deletions

View File

@@ -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;
}