diff options
author | Marc-Antoine Perennou <Marc-Antoine@Perennou.com> | 2010-05-09 18:13:02 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-05-09 19:12:28 +0200 |
commit | 3177a7fa12247d30b854fcb7697cd578b9086bf5 (patch) | |
tree | ceb596a9217ea720c7c6f49d5933fc97cd3715b4 /util.c | |
parent | 07b0b134d3076fe223d6e15959b6081a74b56792 (diff) |
hostname: read hostname for Gentoo
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -42,6 +42,7 @@ #include <sys/inotify.h> #include <sys/poll.h> #include <libgen.h> +#include <ctype.h> #include "macro.h" #include "util.h" @@ -141,6 +142,30 @@ bool startswith(const char *s, const char *prefix) { return memcmp(s, prefix, pl) == 0; } +bool startswith_no_case(const char *s, const char *prefix) { + size_t sl, pl; + unsigned i; + + assert(s); + assert(prefix); + + sl = strlen(s); + pl = strlen(prefix); + + if (pl == 0) + return true; + + if (sl < pl) + return false; + + for(i = 0; i < pl; ++i) { + if (tolower(s[i]) != tolower(prefix[i])) + return false; + } + + return true; +} + bool first_word(const char *s, const char *word) { size_t sl, wl; |