diff options
author | Tom Gundersen <teg@jklm.no> | 2016-01-14 17:02:57 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2016-01-14 17:02:57 +0100 |
commit | becc96b7264a7f56dc2024bb3000cd179526c43e (patch) | |
tree | 7ceafc37af826fb969b0f706778978446a60c0a1 /src/basic/string-util.c | |
parent | deebd4d26f42e837ed57f6e9ccbe99dfe0e7f6d6 (diff) | |
parent | 81ec9e0887ef12bebd36d48f10372cf003df5d38 (diff) |
Merge pull request #2316 from poettering/dnssec14
Fourteenth DNSSEC PR
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r-- | src/basic/string-util.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 849e457439..1f95a9abba 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -348,6 +348,36 @@ char *ascii_strlower_n(char *t, size_t n) { return t; } +int ascii_strcasecmp_n(const char *a, const char *b, size_t n) { + + for (; n > 0; a++, b++, n--) { + int x, y; + + x = (int) (uint8_t) ascii_tolower(*a); + y = (int) (uint8_t) ascii_tolower(*b); + + if (x != y) + return x - y; + } + + return 0; +} + +int ascii_strcasecmp_nn(const char *a, size_t n, const char *b, size_t m) { + int r; + + r = ascii_strcasecmp_n(a, b, MIN(n, m)); + if (r != 0) + return r; + + if (n < m) + return -1; + else if (n > m) + return 1; + else + return 0; +} + bool chars_intersect(const char *a, const char *b) { const char *p; |