chiark / gitweb /
6857202f88cf4fb3a73ed8fd43ba47c8fecca738
[elogind.git] / src / basic / string-table.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3   This file is part of systemd.
4
5   Copyright 2010 Lennart Poettering
6 ***/
7
8 #include "string-table.h"
9 #include "string-util.h"
10
11 ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
12         size_t i;
13
14         if (!key)
15                 return -1;
16
17         for (i = 0; i < len; ++i)
18                 if (streq_ptr(table[i], key))
19                         return (ssize_t) i;
20
21         return -1;
22 }