summaryrefslogtreecommitdiff
path: root/src/basic/string-util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/string-util.h')
-rw-r--r--src/basic/string-util.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index d3a01a65e..3cada129e 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -234,3 +234,25 @@ static inline void *memory_startswith(const void *p, size_t sz, const char *toke
return (uint8_t*) p + n;
}
+
+/* Like startswith_no_case(), but operates on arbitrary memory blocks.
+ * It works only for ASCII strings.
+ */
+static inline void *memory_startswith_no_case(const void *p, size_t sz, const char *token) {
+ size_t n, i;
+
+ assert(token);
+
+ n = strlen(token);
+ if (sz < n)
+ return NULL;
+
+ assert(p);
+
+ for (i = 0; i < n; i++) {
+ if (ascii_tolower(((char *)p)[i]) != ascii_tolower(token[i]))
+ return NULL;
+ }
+
+ return (uint8_t*) p + n;
+}