summaryrefslogtreecommitdiff
path: root/lib/util/enum_by_name.c
blob: fa0131bc687852e68e3305427baada6f059fb5e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* SPDX-License-Identifier: ISC */
#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;
}