diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-02-25 14:33:19 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-24 17:04:20 +0100 |
commit | 9a88f7da453eadc72d8f333700dbd80777feecd1 (patch) | |
tree | 8a096e37123ece1d20bcb4d0ae8e064bdd39747a /lib/src/enum_by_name.c |
Initial commit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/src/enum_by_name.c')
-rw-r--r-- | lib/src/enum_by_name.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/src/enum_by_name.c b/lib/src/enum_by_name.c new file mode 100644 index 0000000..1948eb9 --- /dev/null +++ b/lib/src/enum_by_name.c @@ -0,0 +1,15 @@ +#include <string.h> + +#include "util.h" + +const enum_map_t *enum_by_name(const enum_map_t *map, const char *name) +{ + size_t i; + + for (i = 0; map[i].name != NULL; ++i) { + if (!strcmp(map[i].name, name)) + return map + i; + } + + return NULL; +} |