aboutsummaryrefslogtreecommitdiff
path: root/lib/src/enum_by_name.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/enum_by_name.c')
-rw-r--r--lib/src/enum_by_name.c15
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;
+}