X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.c;h=ba035caed064315363af1f2358fb6a5b16f246ad;hb=2404701e679904979751816930101511d8ec5d49;hp=f5fcebebe7a1c26028593ebd93446e5eefb2d4ad;hpb=eef46c372f64f40dd75415b2c504c73138719c8d;p=elogind.git diff --git a/src/shared/util.c b/src/shared/util.c index f5fcebebe..ba035caed 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -8089,3 +8089,16 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility) { *p += k; return 1; } + +ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) { + size_t i; + + if (!key) + return -1; + + for (i = 0; i < len; ++i) + if (streq_ptr(table[i], key)) + return (ssize_t)i; + + return -1; +}