diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-11-06 08:54:28 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-11-06 08:54:28 +0100 |
commit | cbe17aebe6250e92cf44543d79d37e0a80ca34cb (patch) | |
tree | 1c5c91b8ad49061f1c00ae44fdfc9983cbf4fe75 | |
parent | 078bce41bcca438bb7513dceae3b77f43875ce1b (diff) |
owfd: wpa: add event-name getter
Add small helper to retrieve the event-name of a given type.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r-- | src/wpa.h | 1 | ||||
-rw-r--r-- | src/wpa_parser.c | 14 |
2 files changed, 15 insertions, 0 deletions
@@ -135,6 +135,7 @@ struct owfd_wpa_event { void owfd_wpa_event_init(struct owfd_wpa_event *ev); void owfd_wpa_event_reset(struct owfd_wpa_event *ev); int owfd_wpa_event_parse(struct owfd_wpa_event *ev, const char *event); +const char *owfd_wpa_event_name(unsigned int type); #ifdef __cplusplus } diff --git a/src/wpa_parser.c b/src/wpa_parser.c index 02f91e4..0ba935b 100644 --- a/src/wpa_parser.c +++ b/src/wpa_parser.c @@ -89,6 +89,20 @@ static const struct event_type { #undef EVENT }; +const char *owfd_wpa_event_name(unsigned int type) +{ + size_t i, max; + + max = sizeof(event_list) / sizeof(*event_list); + + for (i = 0; i < max; ++i) { + if (event_list[i].code == type) + return event_list[i].name; + } + + return "UNKNOWN"; +} + static int event_comp(const void *key, const void *type) { const struct event_type *t; |