From: Jo-Philipp Wich Date: Mon, 27 Oct 2014 15:57:19 +0000 (+0100) Subject: lib: add iwinfo_backend_by_name() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7901e7c69fc793aa590529afad433ec856baca72;p=oweals%2Fiwinfo.git lib: add iwinfo_backend_by_name() Signed-off-by: Jo-Philipp Wich --- diff --git a/include/iwinfo.h b/include/iwinfo.h index 68d459b..38120e6 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -182,6 +182,7 @@ struct iwinfo_ops { const char * iwinfo_type(const char *ifname); const struct iwinfo_ops * iwinfo_backend(const char *ifname); +const struct iwinfo_ops * iwinfo_backend_by_name(const char *name); void iwinfo_finish(void); extern const struct iwinfo_ops wext_ops; diff --git a/iwinfo_lib.c b/iwinfo_lib.c index 4ae8f59..c30d834 100644 --- a/iwinfo_lib.c +++ b/iwinfo_lib.c @@ -350,6 +350,17 @@ const struct iwinfo_ops * iwinfo_backend(const char *ifname) return NULL; } +const struct iwinfo_ops * iwinfo_backend_by_name(const char *name) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(backends); i++) + if (!strcmp(backends[i]->name, name)) + return backends[i]; + + return NULL; +} + void iwinfo_finish(void) { int i;