summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c21
-rw-r--r--src/shared/util.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index fd837d96bd..e18645f8f1 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -148,6 +148,27 @@ char* endswith(const char *s, const char *postfix) {
return (char*) s + sl - pl;
}
+char* endswith_no_case(const char *s, const char *postfix) {
+ size_t sl, pl;
+
+ assert(s);
+ assert(postfix);
+
+ sl = strlen(s);
+ pl = strlen(postfix);
+
+ if (pl == 0)
+ return (char*) s + sl;
+
+ if (sl < pl)
+ return NULL;
+
+ if (strcasecmp(s + sl - pl, postfix) != 0)
+ return NULL;
+
+ return (char*) s + sl - pl;
+}
+
char* first_word(const char *s, const char *word) {
size_t sl, wl;
const char *p;
diff --git a/src/shared/util.h b/src/shared/util.h
index a2b1ec5030..0e806cf1a1 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -134,6 +134,7 @@ static inline char *startswith_no_case(const char *s, const char *prefix) {
}
char *endswith(const char *s, const char *postfix) _pure_;
+char *endswith_no_case(const char *s, const char *postfix) _pure_;
char *first_word(const char *s, const char *word) _pure_;